Snap for 8730993 from 7ba00e6ef23ef83a56c7ac822ced1115608a3ce2 to mainline-tzdata3-release
Change-Id: I16accacfac3aa62959083d4ca8f0aa11b0deb1ed
diff --git a/.github/dependabot.yml b/.github/dependabot.yml
deleted file mode 100644
index 1e956d2..0000000
--- a/.github/dependabot.yml
+++ /dev/null
@@ -1,16 +0,0 @@
-version: 2
-updates:
-# TODO(b/170636568): Enable Maven updates? Perhaps wait until we can more
-# easily import the generated PRs into our internal repo.
-# - package-ecosystem: "maven"
-# directory: "/"
-# schedule:
-# interval: "daily"
-# - package-ecosystem: "maven"
-# directory: "/android"
-# schedule:
-# interval: "daily"
- - package-ecosystem: "github-actions"
- directory: "/"
- schedule:
- interval: "daily"
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
deleted file mode 100644
index df20b1a..0000000
--- a/.github/workflows/ci.yml
+++ /dev/null
@@ -1,105 +0,0 @@
-name: CI
-
-on:
- push:
- branches:
- - master
- pull_request:
- branches:
- - master
-
-jobs:
- test:
- name: "${{ matrix.root-pom }} on JDK ${{ matrix.java }}"
- strategy:
- matrix:
- java: [ 8, 11 ]
- root-pom: [ 'pom.xml', 'android/pom.xml' ]
- runs-on: ubuntu-latest
- env:
- ROOT_POM: ${{ matrix.root-pom }}
- steps:
- # Cancel any previous runs for the same branch that are still running.
- - name: 'Cancel previous runs'
- uses: styfle/cancel-workflow-action@0.9.1
- with:
- access_token: ${{ github.token }}
- - name: 'Check out repository'
- uses: actions/checkout@v2.3.4
- - name: 'Cache local Maven repository'
- uses: actions/cache@v2.1.6
- with:
- path: ~/.m2/repository
- key: maven-${{ hashFiles('**/pom.xml') }}
- restore-keys: |
- maven-
- - name: 'Set up JDK ${{ matrix.java }}'
- uses: actions/setup-java@v2
- with:
- java-version: ${{ matrix.java }}
- distribution: 'zulu'
- - name: 'Install'
- shell: bash
- run: mvn -B -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn install -U -DskipTests=true -f $ROOT_POM
- - name: 'Test'
- shell: bash
- run: mvn -B -P!standard-with-extra-repos verify -U -Dmaven.javadoc.skip=true -f $ROOT_POM
- - name: 'Print Surefire reports'
- # Note: Normally a step won't run if the job has failed, but this causes it to
- if: ${{ failure() }}
- shell: bash
- run: ./util/print_surefire_reports.sh
-
- publish_snapshot:
- name: 'Publish snapshot'
- needs: test
- if: github.event_name == 'push' && github.repository == 'google/guava'
- runs-on: ubuntu-latest
- steps:
- - name: 'Check out repository'
- uses: actions/checkout@v2.3.4
- - name: 'Cache local Maven repository'
- uses: actions/cache@v2.1.6
- with:
- path: ~/.m2/repository
- key: maven-${{ hashFiles('**/pom.xml') }}
- restore-keys: |
- maven-
- - name: 'Set up JDK 11'
- uses: actions/setup-java@v2
- with:
- java-version: 11
- distribution: 'zulu'
- server-id: sonatype-nexus-snapshots
- server-username: CI_DEPLOY_USERNAME
- server-password: CI_DEPLOY_PASSWORD
- - name: 'Publish'
- env:
- CI_DEPLOY_USERNAME: ${{ secrets.CI_DEPLOY_USERNAME }}
- CI_DEPLOY_PASSWORD: ${{ secrets.CI_DEPLOY_PASSWORD }}
- run: ./util/deploy_snapshot.sh
-
- generate_docs:
- name: 'Generate latest docs'
- needs: test
- if: github.event_name == 'push' && github.repository == 'google/guava'
- runs-on: ubuntu-latest
- steps:
- - name: 'Check out repository'
- uses: actions/checkout@v2.3.4
- - name: 'Cache local Maven repository'
- uses: actions/cache@v2.1.6
- with:
- path: ~/.m2/repository
- key: maven-${{ hashFiles('**/pom.xml') }}
- restore-keys: |
- maven-
- - name: 'Set up JDK 11'
- uses: actions/setup-java@v2
- with:
- java-version: 11
- distribution: 'zulu'
- - name: 'Generate latest docs'
- env:
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- run: ./util/update_snapshot_docs.sh
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..fac7af9
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,42 @@
+sudo: false
+
+language: java
+
+jdk:
+ - openjdk8
+ - openjdk11
+
+addons:
+ apt:
+ packages:
+ - openjdk-8-source
+
+install: mvn -B -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn install -U -DskipTests=true -f $ROOT_POM
+
+# https://docs.travis-ci.com/user/common-build-problems/#build-times-out-because-no-output-was-received
+script: travis_wait 60 mvn -B -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn verify -U -Dmaven.javadoc.skip=true -f $ROOT_POM
+
+after_success:
+ - util/deploy_snapshot.sh
+ - util/update_snapshot_docs.sh
+
+after_failure:
+ - util/print_surefire_reports.sh
+
+cache:
+ directories:
+ - $HOME/.m2
+
+env:
+ global:
+ - secure: "IPvqFwnLx/GXyImJuwM2MIvzDlBLqEXaQXFGJgAP1nbuenaLAloOOlqQ+iy2FDLBD/j+zjSbR3WWF9DIT4YxAS03Z6iMwxh7GCfk+tyhVtLQnwt7w1rquyhbrrGFsY5U0hr5q80Ww6J+zfp2yZ8aP9FHSy5ahNjqys4FtubOWLk="
+ - secure: "G77Wt2h2fceQ867i1uwOjUygrNeBpLRS8sxgfUZsO66dvlrx1wYFpZLLRIiPcy01peUTE2SvXIXLHKe9v3AlMonPibsQtvvfQSVfx+jgKwLZx9cuf/M5VQlD3etRUh4K/rBezlxWRroeeKcM2DQqiEVLsTDSyNZV9kVAjwfLTvM="
+ - secure: "wieIClPLTXS3QjDzqyp0TqIrVP/Q6iWNPOtcUQYfdDZJGwufE61laTFtzVKXZRb7uJ4GXDObcVU3AcpAwkTX/5sEksBxgv3TZ5Qi0mVx2GRmbE06ULLxi7sPnTCZ/VFtselDWcWArWGAcdCjW9gcCrgj5K/+sYpVKz9a8V+SDM4="
+ matrix:
+ - ROOT_POM="pom.xml"
+ - ROOT_POM="android/pom.xml"
+
+branches:
+ only:
+ - master
+ - /^release.*$/
diff --git a/Android.bp b/Android.bp
index 376abe9..2fdd93c 100644
--- a/Android.bp
+++ b/Android.bp
@@ -49,24 +49,6 @@
],
}
-// Instructions for updating the guava version
-//
-// Guava updates must be merged to AOSP first. Make sure you are not using a
-// shallow copy of the Android tree to run the following instructions:
-//
-// 1. File a bug to generate a branch with the version you want to update to.
-// You can use b/209469232 as starting point. This step will generate an
-// upstream branch.
-// 2. Create your work branch using `repo start <your_branch_name>`.
-// 3. Fetch the upstream branch using `git fetch aosp <upstream_branch_name>`.
-// 4. Run the merge using `git merge FETCH_HEAD`.
-// 5. Update the METADATA file in this directory to reflect your changes.
-//
-// Note: When running `repo upload` to generate the CL, repo will produce a
-// warning about the number of commits you are trying to upload. This is
-// expected, and you can accept safely (a single gerrit "merge commit" change
-// will be created).
-
java_library {
name: "guava",
host_supported: true,
diff --git a/BUILD b/BUILD
deleted file mode 100644
index 22c9e62..0000000
--- a/BUILD
+++ /dev/null
@@ -1,58 +0,0 @@
-# TODO(b/198224074): auto-generate this file using bp2build.
-#
-
-alias(
- name = "guava",
- actual = select({
- "//build/bazel/platforms/os:android": ":guava-android-host",
- "//conditions:default": ":guava-jre",
- }),
- visibility = ["//visibility:public"],
-)
-
-java_library(
- name = "guava-android-host",
- srcs = glob(["android/guava/src/**/*.java"]),
- visibility = ["//visibility:public"],
- deps = [
- ":guava-android-annotation-stubs",
- ":guava-both",
- "//external/error_prone:error_prone_annotations",
- ],
- exports = [
- ":guava-both",
- ],
- target_compatible_with = ["//build/bazel/platforms/os:android"],
-)
-
-java_library(
- name = "guava-android-annotation-stubs",
- srcs = glob(["android-annotation-stubs/src/**/*.java"]),
-)
-
-java_library(
- name = "guava-both",
- srcs = glob(["futures/failureaccess/**/*.java"]),
- deps = [
- ":guava-android-annotation-stubs",
- "//external/error_prone:error_prone_annotations",
- "//external/jsr305",
- ],
- exports = [
- "//external/jsr305",
- ],
-)
-
-java_library(
- name = "guava-jre",
- srcs = glob(["guava/src/**/*.java"]),
- visibility = ["//visibility:public"],
- deps = [
- ":guava-android-annotation-stubs",
- ":guava-both",
- "//external/error_prone:error_prone_annotations",
- ],
- exports = [
- ":guava-both",
- ],
-)
diff --git a/METADATA b/METADATA
index 9bf3de1..27cdada 100644
--- a/METADATA
+++ b/METADATA
@@ -9,11 +9,11 @@
type: GIT
value: "https://github.com/google/guava.git"
}
- version: "31.0.1"
+ version: "27.1"
license_type: NOTICE
last_upgrade_date {
- year: 2021
- month: 12
- day: 7
+ year: 2019
+ month: 4
+ day: 10
}
}
diff --git a/README.md b/README.md
index d5bcf55..f95062c 100644
--- a/README.md
+++ b/README.md
@@ -1,7 +1,7 @@
# Guava: Google Core Libraries for Java
[![Latest release](https://img.shields.io/github/release/google/guava.svg)](https://github.com/google/guava/releases/latest)
-[![Build Status](https://github.com/google/guava/workflows/CI/badge.svg?branch=master)](https://github.com/google/guava/actions)
+[![Build Status](https://travis-ci.org/google/guava.svg?branch=master)](https://travis-ci.org/google/guava)
Guava is a set of core Java libraries from Google that includes new collection types
(such as multimap and multiset), immutable collections, a graph library, and
@@ -23,7 +23,7 @@
Guava provides two different "flavors": one for use on a (Java 8+) JRE and one
for use on Android or Java 7 or by any library that wants to be compatible with
either of those. These flavors are specified in the Maven version field as
-either `31.0.1-jre` or `31.0.1-android`. For more about depending on Guava, see
+either `30.0-jre` or `30.0-android`. For more about depending on Guava, see
[using Guava in your build].
To add a dependency on Guava using Maven, use the following:
@@ -32,9 +32,9 @@
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
- <version>31.0.1-jre</version>
+ <version>30.0-jre</version>
<!-- or, for Android: -->
- <version>31.0.1-android</version>
+ <version>30.0-android</version>
</dependency>
```
@@ -45,16 +45,16 @@
// Pick one:
// 1. Use Guava in your implementation only:
- implementation("com.google.guava:guava:31.0.1-jre")
+ implementation("com.google.guava:guava:30.0-jre")
// 2. Use Guava types in your public API:
- api("com.google.guava:guava:31.0.1-jre")
+ api("com.google.guava:guava:30.0-jre")
// 3. Android - Use Guava in your implementation only:
- implementation("com.google.guava:guava:31.0.1-android")
+ implementation("com.google.guava:guava:30.0-android")
// 4. Android - Use Guava types in your public API:
- api("com.google.guava:guava:31.0.1-android")
+ api("com.google.guava:guava:30.0-android")
}
```
@@ -101,10 +101,8 @@
plans to start removing things again, but officially, we're leaving our
options open in case of surprises (like, say, a serious security problem).
-3. Guava has one dependency that is needed for linkage at runtime:
- `com.google.guava:failureaccess:1.0.1`. It also has
- [some annotation-only dependencies][guava-deps], which we discuss in more
- detail at that link.
+3. Guava has one dependency that is needed at runtime:
+ `com.google.guava:failureaccess:1.0.1`
4. Serialized forms of ALL objects are subject to change unless noted
otherwise. Do not persist these and assume they can be read by a future
@@ -113,10 +111,10 @@
5. Our classes are not designed to protect against a malicious caller. You
should not use them for communication between trusted and untrusted code.
-6. For the mainline flavor, we test the libraries using only OpenJDK 8 and
- OpenJDK 11 on Linux. Some features, especially in `com.google.common.io`,
- may not work correctly in other environments. For the Android flavor, our
- unit tests also run on API level 15 (Ice Cream Sandwich).
+6. For the mainline flavor, we unit-test the libraries using only OpenJDK 1.8
+ on Linux. Some features, especially in `com.google.common.io`, may not work
+ correctly in other environments. For the Android flavor, our unit tests run
+ on API level 15 (Ice Cream Sandwich).
[guava-snapshot-api-docs]: https://guava.dev/releases/snapshot-jre/api/docs/
[guava-snapshot-api-diffs]: https://guava.dev/releases/snapshot-jre/api/diffs/
@@ -127,4 +125,4 @@
[using Guava in your build]: https://github.com/google/guava/wiki/UseGuavaInYourBuild
[repackage]: https://github.com/google/guava/wiki/UseGuavaInYourBuild#what-if-i-want-to-use-beta-apis-from-a-library-that-people-use-as-a-dependency
-[guava-deps]: https://github.com/google/guava/wiki/UseGuavaInYourBuild#what-about-guavas-own-dependencies
+
diff --git a/android/guava-bom/pom.xml b/android/guava-bom/pom.xml
index b0afa45..cbb2fda 100644
--- a/android/guava-bom/pom.xml
+++ b/android/guava-bom/pom.xml
@@ -8,14 +8,13 @@
<groupId>com.google.guava</groupId>
<artifactId>guava-bom</artifactId>
- <version>31.0.1-android</version>
+ <version>30.0-android</version>
<packaging>pom</packaging>
<parent>
<groupId>org.sonatype.oss</groupId>
<artifactId>oss-parent</artifactId>
<version>9</version>
- <relativePath></relativePath>
</parent>
<name>Guava BOM</name>
diff --git a/android/guava-testlib/pom.xml b/android/guava-testlib/pom.xml
index 8e67de7..ed18b46 100644
--- a/android/guava-testlib/pom.xml
+++ b/android/guava-testlib/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>com.google.guava</groupId>
<artifactId>guava-parent</artifactId>
- <version>31.0.1-android</version>
+ <version>30.0-android</version>
</parent>
<artifactId>guava-testlib</artifactId>
<name>Guava Testing Library</name>
diff --git a/android/guava-testlib/src/com/google/common/collect/testing/CollectionTestSuiteBuilder.java b/android/guava-testlib/src/com/google/common/collect/testing/CollectionTestSuiteBuilder.java
index 5f9aff4..cf1ed23 100644
--- a/android/guava-testlib/src/com/google/common/collect/testing/CollectionTestSuiteBuilder.java
+++ b/android/guava-testlib/src/com/google/common/collect/testing/CollectionTestSuiteBuilder.java
@@ -57,8 +57,6 @@
.named(getName() + " reserialized")
.withFeatures(computeReserializedCollectionFeatures(parentBuilder.getFeatures()))
.suppressing(parentBuilder.getSuppressedTests())
- .withSetUp(parentBuilder.getSetUp())
- .withTearDown(parentBuilder.getTearDown())
.createTestSuite());
}
return derivedSuites;
diff --git a/android/guava-testlib/src/com/google/common/collect/testing/FeatureSpecificTestSuiteBuilder.java b/android/guava-testlib/src/com/google/common/collect/testing/FeatureSpecificTestSuiteBuilder.java
index b629fa9..0d921a5 100644
--- a/android/guava-testlib/src/com/google/common/collect/testing/FeatureSpecificTestSuiteBuilder.java
+++ b/android/guava-testlib/src/com/google/common/collect/testing/FeatureSpecificTestSuiteBuilder.java
@@ -81,7 +81,7 @@
return self();
}
- public Runnable getSetUp() {
+ protected Runnable getSetUp() {
return setUp;
}
@@ -90,13 +90,13 @@
return self();
}
- public Runnable getTearDown() {
+ protected Runnable getTearDown() {
return tearDown;
}
// Features
- private final Set<Feature<?>> features = new LinkedHashSet<>();
+ private Set<Feature<?>> features = new LinkedHashSet<>();
/**
* Configures this builder to produce tests appropriate for the given features. This method may be
@@ -138,7 +138,7 @@
// Test suppression
- private final Set<Method> suppressedTests = new HashSet<>();
+ private Set<Method> suppressedTests = new HashSet<>();
/**
* Prevents the given methods from being run as part of the test suite.
diff --git a/android/guava-testlib/src/com/google/common/collect/testing/ListTestSuiteBuilder.java b/android/guava-testlib/src/com/google/common/collect/testing/ListTestSuiteBuilder.java
index 061e310..e010564 100644
--- a/android/guava-testlib/src/com/google/common/collect/testing/ListTestSuiteBuilder.java
+++ b/android/guava-testlib/src/com/google/common/collect/testing/ListTestSuiteBuilder.java
@@ -112,8 +112,6 @@
.named(getName() + " reserialized")
.withFeatures(computeReserializedCollectionFeatures(parentBuilder.getFeatures()))
.suppressing(parentBuilder.getSuppressedTests())
- .withSetUp(parentBuilder.getSetUp())
- .withTearDown(parentBuilder.getTearDown())
.createTestSuite());
}
return derivedSuites;
diff --git a/android/guava-testlib/src/com/google/common/collect/testing/MapTestSuiteBuilder.java b/android/guava-testlib/src/com/google/common/collect/testing/MapTestSuiteBuilder.java
index 7b8e40a..7bb418f 100644
--- a/android/guava-testlib/src/com/google/common/collect/testing/MapTestSuiteBuilder.java
+++ b/android/guava-testlib/src/com/google/common/collect/testing/MapTestSuiteBuilder.java
@@ -101,8 +101,6 @@
.withFeatures(computeReserializedMapFeatures(parentBuilder.getFeatures()))
.named(parentBuilder.getName() + " reserialized")
.suppressing(parentBuilder.getSuppressedTests())
- .withSetUp(parentBuilder.getSetUp())
- .withTearDown(parentBuilder.getTearDown())
.createTestSuite());
}
@@ -112,8 +110,6 @@
.withFeatures(computeEntrySetFeatures(parentBuilder.getFeatures()))
.named(parentBuilder.getName() + " entrySet")
.suppressing(parentBuilder.getSuppressedTests())
- .withSetUp(parentBuilder.getSetUp())
- .withTearDown(parentBuilder.getTearDown())
.createTestSuite());
derivedSuites.add(
@@ -121,8 +117,6 @@
.withFeatures(computeKeySetFeatures(parentBuilder.getFeatures()))
.named(parentBuilder.getName() + " keys")
.suppressing(parentBuilder.getSuppressedTests())
- .withSetUp(parentBuilder.getSetUp())
- .withTearDown(parentBuilder.getTearDown())
.createTestSuite());
derivedSuites.add(
@@ -131,8 +125,6 @@
.named(parentBuilder.getName() + " values")
.withFeatures(computeValuesCollectionFeatures(parentBuilder.getFeatures()))
.suppressing(parentBuilder.getSuppressedTests())
- .withSetUp(parentBuilder.getSetUp())
- .withTearDown(parentBuilder.getTearDown())
.createTestSuite());
return derivedSuites;
diff --git a/android/guava-testlib/src/com/google/common/collect/testing/SetTestSuiteBuilder.java b/android/guava-testlib/src/com/google/common/collect/testing/SetTestSuiteBuilder.java
index 4ac51a4..26a2870 100644
--- a/android/guava-testlib/src/com/google/common/collect/testing/SetTestSuiteBuilder.java
+++ b/android/guava-testlib/src/com/google/common/collect/testing/SetTestSuiteBuilder.java
@@ -78,8 +78,6 @@
.named(getName() + " reserialized")
.withFeatures(computeReserializedCollectionFeatures(parentBuilder.getFeatures()))
.suppressing(parentBuilder.getSuppressedTests())
- .withSetUp(parentBuilder.getSetUp())
- .withTearDown(parentBuilder.getTearDown())
.createTestSuite());
}
return derivedSuites;
diff --git a/android/guava-testlib/src/com/google/common/collect/testing/SortedMapTestSuiteBuilder.java b/android/guava-testlib/src/com/google/common/collect/testing/SortedMapTestSuiteBuilder.java
index aa1d6d5..e95383a 100644
--- a/android/guava-testlib/src/com/google/common/collect/testing/SortedMapTestSuiteBuilder.java
+++ b/android/guava-testlib/src/com/google/common/collect/testing/SortedMapTestSuiteBuilder.java
@@ -121,8 +121,6 @@
.named(parentBuilder.getName() + " subMap " + from + "-" + to)
.withFeatures(features)
.suppressing(parentBuilder.getSuppressedTests())
- .withSetUp(parentBuilder.getSetUp())
- .withTearDown(parentBuilder.getTearDown())
.createTestSuite();
}
diff --git a/android/guava-testlib/src/com/google/common/collect/testing/SortedSetTestSuiteBuilder.java b/android/guava-testlib/src/com/google/common/collect/testing/SortedSetTestSuiteBuilder.java
index 5092661..e97b08f 100644
--- a/android/guava-testlib/src/com/google/common/collect/testing/SortedSetTestSuiteBuilder.java
+++ b/android/guava-testlib/src/com/google/common/collect/testing/SortedSetTestSuiteBuilder.java
@@ -94,8 +94,6 @@
.named(parentBuilder.getName() + " subSet " + from + "-" + to)
.withFeatures(features)
.suppressing(parentBuilder.getSuppressedTests())
- .withSetUp(parentBuilder.getSetUp())
- .withTearDown(parentBuilder.getTearDown())
.createTestSuite();
}
diff --git a/android/guava-testlib/src/com/google/common/collect/testing/google/BiMapTestSuiteBuilder.java b/android/guava-testlib/src/com/google/common/collect/testing/google/BiMapTestSuiteBuilder.java
index 0821fb0..fa21a71 100644
--- a/android/guava-testlib/src/com/google/common/collect/testing/google/BiMapTestSuiteBuilder.java
+++ b/android/guava-testlib/src/com/google/common/collect/testing/google/BiMapTestSuiteBuilder.java
@@ -88,8 +88,6 @@
.suppressing(parentBuilder.getSuppressedTests())
.suppressing(SetCreationTester.class.getMethods())
// BiMap.entrySet() duplicate-handling behavior is too confusing for SetCreationTester
- .withSetUp(parentBuilder.getSetUp())
- .withTearDown(parentBuilder.getTearDown())
.createTestSuite());
/*
* TODO(cpovirk): the Map tests duplicate most of this effort by using a
@@ -103,8 +101,6 @@
.suppressing(parentBuilder.getSuppressedTests())
.suppressing(SetCreationTester.class.getMethods())
// BiMap.values() duplicate-handling behavior is too confusing for SetCreationTester
- .withSetUp(parentBuilder.getSetUp())
- .withTearDown(parentBuilder.getTearDown())
.createTestSuite());
if (!parentBuilder.getFeatures().contains(NoRecurse.INVERSE)) {
derived.add(
@@ -113,8 +109,6 @@
.withFeatures(computeInverseFeatures(parentBuilder.getFeatures()))
.named(parentBuilder.getName() + " inverse")
.suppressing(parentBuilder.getSuppressedTests())
- .withSetUp(parentBuilder.getSetUp())
- .withTearDown(parentBuilder.getTearDown())
.createTestSuite());
}
diff --git a/android/guava-testlib/src/com/google/common/collect/testing/google/MultimapTestSuiteBuilder.java b/android/guava-testlib/src/com/google/common/collect/testing/google/MultimapTestSuiteBuilder.java
index 97c24c9..8504940 100644
--- a/android/guava-testlib/src/com/google/common/collect/testing/google/MultimapTestSuiteBuilder.java
+++ b/android/guava-testlib/src/com/google/common/collect/testing/google/MultimapTestSuiteBuilder.java
@@ -115,8 +115,6 @@
.withFeatures(computeReserializedMultimapFeatures(parentBuilder.getFeatures()))
.named(parentBuilder.getName() + " reserialized")
.suppressing(parentBuilder.getSuppressedTests())
- .withSetUp(parentBuilder.getSetUp())
- .withTearDown(parentBuilder.getTearDown())
.createTestSuite());
}
@@ -125,8 +123,6 @@
.withFeatures(computeAsMapFeatures(parentBuilder.getFeatures()))
.named(parentBuilder.getName() + ".asMap")
.suppressing(parentBuilder.getSuppressedTests())
- .withSetUp(parentBuilder.getSetUp())
- .withTearDown(parentBuilder.getTearDown())
.createTestSuite());
derivedSuites.add(computeEntriesTestSuite(parentBuilder));
@@ -157,8 +153,6 @@
.withFeatures(computeEntriesFeatures(parentBuilder.getFeatures()))
.named(parentBuilder.getName() + ".entries")
.suppressing(parentBuilder.getSuppressedTests())
- .withSetUp(parentBuilder.getSetUp())
- .withTearDown(parentBuilder.getTearDown())
.createTestSuite();
}
@@ -170,8 +164,6 @@
.withFeatures(computeMultimapGetFeatures(parentBuilder.getFeatures()))
.named(parentBuilder.getName() + ".get[key]")
.suppressing(parentBuilder.getSuppressedTests())
- .withSetUp(parentBuilder.getSetUp())
- .withTearDown(parentBuilder.getTearDown())
.createTestSuite();
}
@@ -187,8 +179,6 @@
.withFeatures(features)
.named(parentBuilder.getName() + ".asMap[].get[key]")
.suppressing(parentBuilder.getSuppressedTests())
- .withSetUp(parentBuilder.getSetUp())
- .withTearDown(parentBuilder.getTearDown())
.createTestSuite();
}
}
@@ -201,8 +191,6 @@
.withFeatures(computeKeysFeatures(parentBuilder.getFeatures()))
.named(parentBuilder.getName() + ".keys")
.suppressing(parentBuilder.getSuppressedTests())
- .withSetUp(parentBuilder.getSetUp())
- .withTearDown(parentBuilder.getTearDown())
.createTestSuite();
}
diff --git a/android/guava-testlib/src/com/google/common/collect/testing/google/MultisetTestSuiteBuilder.java b/android/guava-testlib/src/com/google/common/collect/testing/google/MultisetTestSuiteBuilder.java
index d6a665c..266daa4 100644
--- a/android/guava-testlib/src/com/google/common/collect/testing/google/MultisetTestSuiteBuilder.java
+++ b/android/guava-testlib/src/com/google/common/collect/testing/google/MultisetTestSuiteBuilder.java
@@ -130,8 +130,6 @@
.named(getName() + ".entrySet")
.withFeatures(computeEntrySetFeatures(parentBuilder.getFeatures()))
.suppressing(parentBuilder.getSuppressedTests())
- .withSetUp(parentBuilder.getSetUp())
- .withTearDown(parentBuilder.getTearDown())
.createTestSuite());
}
@@ -142,8 +140,6 @@
.named(getName() + " reserialized")
.withFeatures(computeReserializedMultisetFeatures(parentBuilder.getFeatures()))
.suppressing(parentBuilder.getSuppressedTests())
- .withSetUp(parentBuilder.getSetUp())
- .withTearDown(parentBuilder.getTearDown())
.createTestSuite());
}
return derivedSuites;
@@ -157,8 +153,6 @@
.named(getName() + ".elementSet")
.withFeatures(computeElementSetFeatures(parentBuilder.getFeatures()))
.suppressing(parentBuilder.getSuppressedTests())
- .withSetUp(parentBuilder.getSetUp())
- .withTearDown(parentBuilder.getTearDown())
.createTestSuite();
}
diff --git a/android/guava-testlib/src/com/google/common/collect/testing/testers/CollectionToArrayTester.java b/android/guava-testlib/src/com/google/common/collect/testing/testers/CollectionToArrayTester.java
index b40fc36..83a4cea 100644
--- a/android/guava-testlib/src/com/google/common/collect/testing/testers/CollectionToArrayTester.java
+++ b/android/guava-testlib/src/com/google/common/collect/testing/testers/CollectionToArrayTester.java
@@ -48,8 +48,8 @@
}
/**
- * {@link Collection#toArray(Object[])} says: "Note that {@code toArray(new Object[0])} is
- * identical in function to {@code toArray()}."
+ * {@link Collection#toArray(Object[])} says: "Note that <tt>toArray(new Object[0])</tt> is
+ * identical in function to <tt>toArray()</tt>."
*
* <p>For maximum effect, the collection under test should be created from an element array of a
* type other than {@code Object[]}.
diff --git a/android/guava-testlib/src/com/google/common/testing/FreshValueGenerator.java b/android/guava-testlib/src/com/google/common/testing/FreshValueGenerator.java
index 9110490..21e25cb 100644
--- a/android/guava-testlib/src/com/google/common/testing/FreshValueGenerator.java
+++ b/android/guava-testlib/src/com/google/common/testing/FreshValueGenerator.java
@@ -354,7 +354,7 @@
private @interface Empty {}
@Generates
- Class<?> generateClass() {
+ private Class<?> generateClass() {
return pickInstance(
ImmutableList.of(
int.class, long.class, void.class, Object.class, Object[].class, Iterable.class),
@@ -362,147 +362,147 @@
}
@Generates
- Object generateObject() {
+ private Object generateObject() {
return generateString();
}
@Generates
- Number generateNumber() {
+ private Number generateNumber() {
return generateInt();
}
@Generates
- int generateInt() {
+ private int generateInt() {
return freshness.get();
}
@Generates
- Integer generateInteger() {
+ private Integer generateInteger() {
return new Integer(generateInt());
}
@Generates
- long generateLong() {
+ private long generateLong() {
return generateInt();
}
@Generates
- Long generateLongObject() {
+ private Long generateLongObject() {
return new Long(generateLong());
}
@Generates
- float generateFloat() {
+ private float generateFloat() {
return generateInt();
}
@Generates
- Float generateFloatObject() {
+ private Float generateFloatObject() {
return new Float(generateFloat());
}
@Generates
- double generateDouble() {
+ private double generateDouble() {
return generateInt();
}
@Generates
- Double generateDoubleObject() {
+ private Double generateDoubleObject() {
return new Double(generateDouble());
}
@Generates
- short generateShort() {
+ private short generateShort() {
return (short) generateInt();
}
@Generates
- Short generateShortObject() {
+ private Short generateShortObject() {
return new Short(generateShort());
}
@Generates
- byte generateByte() {
+ private byte generateByte() {
return (byte) generateInt();
}
@Generates
- Byte generateByteObject() {
+ private Byte generateByteObject() {
return new Byte(generateByte());
}
@Generates
- char generateChar() {
+ private char generateChar() {
return generateString().charAt(0);
}
@Generates
- Character generateCharacter() {
+ private Character generateCharacter() {
return new Character(generateChar());
}
@Generates
- boolean generateBoolean() {
+ private boolean generateBoolean() {
return generateInt() % 2 == 0;
}
@Generates
- Boolean generateBooleanObject() {
+ private Boolean generateBooleanObject() {
return new Boolean(generateBoolean());
}
@Generates
- UnsignedInteger generateUnsignedInteger() {
+ private UnsignedInteger generateUnsignedInteger() {
return UnsignedInteger.fromIntBits(generateInt());
}
@Generates
- UnsignedLong generateUnsignedLong() {
+ private UnsignedLong generateUnsignedLong() {
return UnsignedLong.fromLongBits(generateLong());
}
@Generates
- BigInteger generateBigInteger() {
+ private BigInteger generateBigInteger() {
return BigInteger.valueOf(generateInt());
}
@Generates
- BigDecimal generateBigDecimal() {
+ private BigDecimal generateBigDecimal() {
return BigDecimal.valueOf(generateInt());
}
@Generates
- CharSequence generateCharSequence() {
+ private CharSequence generateCharSequence() {
return generateString();
}
@Generates
- String generateString() {
+ private String generateString() {
return Integer.toString(generateInt());
}
@Generates
- Comparable<?> generateComparable() {
+ private Comparable<?> generateComparable() {
return generateString();
}
@Generates
- Pattern generatePattern() {
+ private Pattern generatePattern() {
return Pattern.compile(generateString());
}
@Generates
- Charset generateCharset() {
+ private Charset generateCharset() {
return pickInstance(Charset.availableCharsets().values(), Charsets.UTF_8);
}
@Generates
- Locale generateLocale() {
+ private Locale generateLocale() {
return pickInstance(Locale.getAvailableLocales(), Locale.US);
}
@Generates
- Currency generateCurrency() {
+ private Currency generateCurrency() {
try {
Method method = Currency.class.getMethod("getAvailableCurrencies");
@SuppressWarnings("unchecked") // getAvailableCurrencies() returns Set<Currency>.
@@ -538,27 +538,27 @@
// common.base
@Empty
- <T> com.google.common.base.Optional<T> generateGoogleOptional() {
+ private <T> com.google.common.base.Optional<T> generateGoogleOptional() {
return com.google.common.base.Optional.absent();
}
@Generates
- <T> com.google.common.base.Optional<T> generateGoogleOptional(T value) {
+ private <T> com.google.common.base.Optional<T> generateGoogleOptional(T value) {
return com.google.common.base.Optional.of(value);
}
@Generates
- Joiner generateJoiner() {
+ private Joiner generateJoiner() {
return Joiner.on(generateString());
}
@Generates
- Splitter generateSplitter() {
+ private Splitter generateSplitter() {
return Splitter.on(generateString());
}
@Generates
- <T> Equivalence<T> generateEquivalence() {
+ private <T> Equivalence<T> generateEquivalence() {
return new Equivalence<T>() {
@Override
protected boolean doEquivalent(T a, T b) {
@@ -580,7 +580,7 @@
}
@Generates
- CharMatcher generateCharMatcher() {
+ private CharMatcher generateCharMatcher() {
return new CharMatcher() {
@Override
public boolean matches(char c) {
@@ -597,7 +597,7 @@
}
@Generates
- Ticker generateTicker() {
+ private Ticker generateTicker() {
return new Ticker() {
@Override
public long read() {
@@ -615,12 +615,12 @@
// collect
@Generates
- <T> Comparator<T> generateComparator() {
+ private <T> Comparator<T> generateComparator() {
return generateOrdering();
}
@Generates
- <T> Ordering<T> generateOrdering() {
+ private <T> Ordering<T> generateOrdering() {
return new Ordering<T>() {
@Override
public int compare(T left, T right) {
@@ -637,283 +637,279 @@
}
@Empty
- static <C extends Comparable<?>> Range<C> generateRange() {
+ private static <C extends Comparable<?>> Range<C> generateRange() {
return Range.all();
}
@Generates
- static <C extends Comparable<?>> Range<C> generateRange(C freshElement) {
+ private static <C extends Comparable<?>> Range<C> generateRange(C freshElement) {
return Range.singleton(freshElement);
}
@Generates
- static <E> Iterable<E> generateIterable(@NullableDecl E freshElement) {
+ private static <E> Iterable<E> generateIterable(E freshElement) {
return generateList(freshElement);
}
@Generates
- static <E> Collection<E> generateCollection(@NullableDecl E freshElement) {
+ private static <E> Collection<E> generateCollection(E freshElement) {
return generateList(freshElement);
}
@Generates
- static <E> List<E> generateList(@NullableDecl E freshElement) {
+ private static <E> List<E> generateList(E freshElement) {
return generateArrayList(freshElement);
}
@Generates
- static <E> ArrayList<E> generateArrayList(@NullableDecl E freshElement) {
+ private static <E> ArrayList<E> generateArrayList(E freshElement) {
ArrayList<E> list = Lists.newArrayList();
list.add(freshElement);
return list;
}
@Generates
- static <E> LinkedList<E> generateLinkedList(@NullableDecl E freshElement) {
+ private static <E> LinkedList<E> generateLinkedList(E freshElement) {
LinkedList<E> list = Lists.newLinkedList();
list.add(freshElement);
return list;
}
@Generates
- static <E> ImmutableList<E> generateImmutableList(E freshElement) {
+ private static <E> ImmutableList<E> generateImmutableList(E freshElement) {
return ImmutableList.of(freshElement);
}
@Generates
- static <E> ImmutableCollection<E> generateImmutableCollection(E freshElement) {
+ private static <E> ImmutableCollection<E> generateImmutableCollection(E freshElement) {
return generateImmutableList(freshElement);
}
@Generates
- static <E> Set<E> generateSet(@NullableDecl E freshElement) {
+ private static <E> Set<E> generateSet(E freshElement) {
return generateHashSet(freshElement);
}
@Generates
- static <E> HashSet<E> generateHashSet(@NullableDecl E freshElement) {
+ private static <E> HashSet<E> generateHashSet(E freshElement) {
return generateLinkedHashSet(freshElement);
}
@Generates
- static <E> LinkedHashSet<E> generateLinkedHashSet(@NullableDecl E freshElement) {
+ private static <E> LinkedHashSet<E> generateLinkedHashSet(E freshElement) {
LinkedHashSet<E> set = Sets.newLinkedHashSet();
set.add(freshElement);
return set;
}
@Generates
- static <E> ImmutableSet<E> generateImmutableSet(E freshElement) {
+ private static <E> ImmutableSet<E> generateImmutableSet(E freshElement) {
return ImmutableSet.of(freshElement);
}
@Generates
- static <E extends Comparable<? super E>> SortedSet<E> generateSortedSet(E freshElement) {
+ private static <E extends Comparable<? super E>> SortedSet<E> generateSortedSet(E freshElement) {
return generateNavigableSet(freshElement);
}
@Generates
- static <E extends Comparable<? super E>> NavigableSet<E> generateNavigableSet(E freshElement) {
+ private static <E extends Comparable<? super E>> NavigableSet<E> generateNavigableSet(
+ E freshElement) {
return generateTreeSet(freshElement);
}
@Generates
- static <E extends Comparable<? super E>> TreeSet<E> generateTreeSet(E freshElement) {
+ private static <E extends Comparable<? super E>> TreeSet<E> generateTreeSet(E freshElement) {
TreeSet<E> set = Sets.newTreeSet();
set.add(freshElement);
return set;
}
@Generates
- static <E extends Comparable<? super E>> ImmutableSortedSet<E> generateImmutableSortedSet(
+ private static <E extends Comparable<? super E>> ImmutableSortedSet<E> generateImmutableSortedSet(
E freshElement) {
return ImmutableSortedSet.of(freshElement);
}
@Generates
- static <E> Multiset<E> generateMultiset(@NullableDecl E freshElement) {
+ private static <E> Multiset<E> generateMultiset(E freshElement) {
return generateHashMultiset(freshElement);
}
@Generates
- static <E> HashMultiset<E> generateHashMultiset(@NullableDecl E freshElement) {
+ private static <E> HashMultiset<E> generateHashMultiset(E freshElement) {
HashMultiset<E> multiset = HashMultiset.create();
multiset.add(freshElement);
return multiset;
}
@Generates
- static <E> LinkedHashMultiset<E> generateLinkedHashMultiset(@NullableDecl E freshElement) {
+ private static <E> LinkedHashMultiset<E> generateLinkedHashMultiset(E freshElement) {
LinkedHashMultiset<E> multiset = LinkedHashMultiset.create();
multiset.add(freshElement);
return multiset;
}
@Generates
- static <E> ImmutableMultiset<E> generateImmutableMultiset(E freshElement) {
+ private static <E> ImmutableMultiset<E> generateImmutableMultiset(E freshElement) {
return ImmutableMultiset.of(freshElement);
}
@Generates
- static <E extends Comparable<E>> SortedMultiset<E> generateSortedMultiset(E freshElement) {
+ private static <E extends Comparable<E>> SortedMultiset<E> generateSortedMultiset(
+ E freshElement) {
return generateTreeMultiset(freshElement);
}
@Generates
- static <E extends Comparable<E>> TreeMultiset<E> generateTreeMultiset(E freshElement) {
+ private static <E extends Comparable<E>> TreeMultiset<E> generateTreeMultiset(E freshElement) {
TreeMultiset<E> multiset = TreeMultiset.create();
multiset.add(freshElement);
return multiset;
}
@Generates
- static <E extends Comparable<E>> ImmutableSortedMultiset<E> generateImmutableSortedMultiset(
- E freshElement) {
+ private static <E extends Comparable<E>>
+ ImmutableSortedMultiset<E> generateImmutableSortedMultiset(E freshElement) {
return ImmutableSortedMultiset.of(freshElement);
}
@Generates
- static <K, V> Map<K, V> generateMap(@NullableDecl K key, @NullableDecl V value) {
+ private static <K, V> Map<K, V> generateMap(K key, V value) {
return generateHashdMap(key, value);
}
@Generates
- static <K, V> HashMap<K, V> generateHashdMap(@NullableDecl K key, @NullableDecl V value) {
+ private static <K, V> HashMap<K, V> generateHashdMap(K key, V value) {
return generateLinkedHashMap(key, value);
}
@Generates
- static <K, V> LinkedHashMap<K, V> generateLinkedHashMap(
- @NullableDecl K key, @NullableDecl V value) {
+ private static <K, V> LinkedHashMap<K, V> generateLinkedHashMap(K key, V value) {
LinkedHashMap<K, V> map = Maps.newLinkedHashMap();
map.put(key, value);
return map;
}
@Generates
- static <K, V> ImmutableMap<K, V> generateImmutableMap(K key, V value) {
+ private static <K, V> ImmutableMap<K, V> generateImmutableMap(K key, V value) {
return ImmutableMap.of(key, value);
}
@Empty
- static <K, V> ConcurrentMap<K, V> generateConcurrentMap() {
+ private static <K, V> ConcurrentMap<K, V> generateConcurrentMap() {
return Maps.newConcurrentMap();
}
@Generates
- static <K, V> ConcurrentMap<K, V> generateConcurrentMap(K key, V value) {
+ private static <K, V> ConcurrentMap<K, V> generateConcurrentMap(K key, V value) {
ConcurrentMap<K, V> map = Maps.newConcurrentMap();
map.put(key, value);
return map;
}
@Generates
- static <K extends Comparable<? super K>, V> SortedMap<K, V> generateSortedMap(
- K key, @NullableDecl V value) {
+ private static <K extends Comparable<? super K>, V> SortedMap<K, V> generateSortedMap(
+ K key, V value) {
return generateNavigableMap(key, value);
}
@Generates
- static <K extends Comparable<? super K>, V> NavigableMap<K, V> generateNavigableMap(
- K key, @NullableDecl V value) {
+ private static <K extends Comparable<? super K>, V> NavigableMap<K, V> generateNavigableMap(
+ K key, V value) {
return generateTreeMap(key, value);
}
@Generates
- static <K extends Comparable<? super K>, V> TreeMap<K, V> generateTreeMap(
- K key, @NullableDecl V value) {
+ private static <K extends Comparable<? super K>, V> TreeMap<K, V> generateTreeMap(
+ K key, V value) {
TreeMap<K, V> map = Maps.newTreeMap();
map.put(key, value);
return map;
}
@Generates
- static <K extends Comparable<? super K>, V> ImmutableSortedMap<K, V> generateImmutableSortedMap(
- K key, V value) {
+ private static <K extends Comparable<? super K>, V>
+ ImmutableSortedMap<K, V> generateImmutableSortedMap(K key, V value) {
return ImmutableSortedMap.of(key, value);
}
@Generates
- static <K, V> Multimap<K, V> generateMultimap(@NullableDecl K key, @NullableDecl V value) {
+ private static <K, V> Multimap<K, V> generateMultimap(K key, V value) {
return generateListMultimap(key, value);
}
@Generates
- static <K, V> ImmutableMultimap<K, V> generateImmutableMultimap(K key, V value) {
+ private static <K, V> ImmutableMultimap<K, V> generateImmutableMultimap(K key, V value) {
return ImmutableMultimap.of(key, value);
}
@Generates
- static <K, V> ListMultimap<K, V> generateListMultimap(
- @NullableDecl K key, @NullableDecl V value) {
+ private static <K, V> ListMultimap<K, V> generateListMultimap(K key, V value) {
return generateArrayListMultimap(key, value);
}
@Generates
- static <K, V> ArrayListMultimap<K, V> generateArrayListMultimap(
- @NullableDecl K key, @NullableDecl V value) {
+ private static <K, V> ArrayListMultimap<K, V> generateArrayListMultimap(K key, V value) {
ArrayListMultimap<K, V> multimap = ArrayListMultimap.create();
multimap.put(key, value);
return multimap;
}
@Generates
- static <K, V> ImmutableListMultimap<K, V> generateImmutableListMultimap(K key, V value) {
+ private static <K, V> ImmutableListMultimap<K, V> generateImmutableListMultimap(K key, V value) {
return ImmutableListMultimap.of(key, value);
}
@Generates
- static <K, V> SetMultimap<K, V> generateSetMultimap(@NullableDecl K key, @NullableDecl V value) {
+ private static <K, V> SetMultimap<K, V> generateSetMultimap(K key, V value) {
return generateLinkedHashMultimap(key, value);
}
@Generates
- static <K, V> HashMultimap<K, V> generateHashMultimap(
- @NullableDecl K key, @NullableDecl V value) {
+ private static <K, V> HashMultimap<K, V> generateHashMultimap(K key, V value) {
HashMultimap<K, V> multimap = HashMultimap.create();
multimap.put(key, value);
return multimap;
}
@Generates
- static <K, V> LinkedHashMultimap<K, V> generateLinkedHashMultimap(
- @NullableDecl K key, @NullableDecl V value) {
+ private static <K, V> LinkedHashMultimap<K, V> generateLinkedHashMultimap(K key, V value) {
LinkedHashMultimap<K, V> multimap = LinkedHashMultimap.create();
multimap.put(key, value);
return multimap;
}
@Generates
- static <K, V> ImmutableSetMultimap<K, V> generateImmutableSetMultimap(K key, V value) {
+ private static <K, V> ImmutableSetMultimap<K, V> generateImmutableSetMultimap(K key, V value) {
return ImmutableSetMultimap.of(key, value);
}
@Generates
- static <K, V> BiMap<K, V> generateBimap(@NullableDecl K key, @NullableDecl V value) {
+ private static <K, V> BiMap<K, V> generateBimap(K key, V value) {
return generateHashBiMap(key, value);
}
@Generates
- static <K, V> HashBiMap<K, V> generateHashBiMap(@NullableDecl K key, @NullableDecl V value) {
+ private static <K, V> HashBiMap<K, V> generateHashBiMap(K key, V value) {
HashBiMap<K, V> bimap = HashBiMap.create();
bimap.put(key, value);
return bimap;
}
@Generates
- static <K, V> ImmutableBiMap<K, V> generateImmutableBimap(K key, V value) {
+ private static <K, V> ImmutableBiMap<K, V> generateImmutableBimap(K key, V value) {
return ImmutableBiMap.of(key, value);
}
@Generates
- static <R, C, V> Table<R, C, V> generateTable(
- @NullableDecl R row, @NullableDecl C column, @NullableDecl V value) {
+ private static <R, C, V> Table<R, C, V> generateTable(R row, C column, V value) {
return generateHashBasedTable(row, column, value);
}
@Generates
- static <R, C, V> HashBasedTable<R, C, V> generateHashBasedTable(
- @NullableDecl R row, @NullableDecl C column, @NullableDecl V value) {
+ private static <R, C, V> HashBasedTable<R, C, V> generateHashBasedTable(
+ R row, C column, V value) {
HashBasedTable<R, C, V> table = HashBasedTable.create();
table.put(row, column, value);
return table;
@@ -921,14 +917,14 @@
@SuppressWarnings("rawtypes") // TreeBasedTable.create() is defined as such
@Generates
- static <R extends Comparable, C extends Comparable, V>
+ private static <R extends Comparable, C extends Comparable, V>
RowSortedTable<R, C, V> generateRowSortedTable(R row, C column, V value) {
return generateTreeBasedTable(row, column, value);
}
@SuppressWarnings("rawtypes") // TreeBasedTable.create() is defined as such
@Generates
- static <R extends Comparable, C extends Comparable, V>
+ private static <R extends Comparable, C extends Comparable, V>
TreeBasedTable<R, C, V> generateTreeBasedTable(R row, C column, V value) {
TreeBasedTable<R, C, V> table = TreeBasedTable.create();
table.put(row, column, value);
@@ -936,84 +932,85 @@
}
@Generates
- static <R, C, V> ImmutableTable<R, C, V> generateImmutableTable(R row, C column, V value) {
+ private static <R, C, V> ImmutableTable<R, C, V> generateImmutableTable(
+ R row, C column, V value) {
return ImmutableTable.of(row, column, value);
}
// common.reflect
@Generates
- TypeToken<?> generateTypeToken() {
+ private TypeToken<?> generateTypeToken() {
return TypeToken.of(generateClass());
}
// io types
@Generates
- File generateFile() {
+ private File generateFile() {
return new File(generateString());
}
@Generates
- static ByteArrayInputStream generateByteArrayInputStream() {
+ private static ByteArrayInputStream generateByteArrayInputStream() {
return new ByteArrayInputStream(new byte[0]);
}
@Generates
- static InputStream generateInputStream() {
+ private static InputStream generateInputStream() {
return generateByteArrayInputStream();
}
@Generates
- StringReader generateStringReader() {
+ private StringReader generateStringReader() {
return new StringReader(generateString());
}
@Generates
- Reader generateReader() {
+ private Reader generateReader() {
return generateStringReader();
}
@Generates
- Readable generateReadable() {
+ private Readable generateReadable() {
return generateReader();
}
@Generates
- Buffer generateBuffer() {
+ private Buffer generateBuffer() {
return generateCharBuffer();
}
@Generates
- CharBuffer generateCharBuffer() {
+ private CharBuffer generateCharBuffer() {
return CharBuffer.allocate(generateInt());
}
@Generates
- ByteBuffer generateByteBuffer() {
+ private ByteBuffer generateByteBuffer() {
return ByteBuffer.allocate(generateInt());
}
@Generates
- ShortBuffer generateShortBuffer() {
+ private ShortBuffer generateShortBuffer() {
return ShortBuffer.allocate(generateInt());
}
@Generates
- IntBuffer generateIntBuffer() {
+ private IntBuffer generateIntBuffer() {
return IntBuffer.allocate(generateInt());
}
@Generates
- LongBuffer generateLongBuffer() {
+ private LongBuffer generateLongBuffer() {
return LongBuffer.allocate(generateInt());
}
@Generates
- FloatBuffer generateFloatBuffer() {
+ private FloatBuffer generateFloatBuffer() {
return FloatBuffer.allocate(generateInt());
}
@Generates
- DoubleBuffer generateDoubleBuffer() {
+ private DoubleBuffer generateDoubleBuffer() {
return DoubleBuffer.allocate(generateInt());
}
}
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 e32a950..a32a53b 100644
--- a/android/guava-testlib/src/com/google/common/testing/NullPointerTester.java
+++ b/android/guava-testlib/src/com/google/common/testing/NullPointerTester.java
@@ -52,7 +52,7 @@
/**
* 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 an annotation with the simple name {@code Nullable}, {@code
+ * parameter that isn't annotated with an annotation with the simple name {@code Nullable}, {@lcode
* CheckForNull}, {@link NullableType}, or {@link NullableDecl}.
*
* <p>The tested methods and constructors are invoked -- each time with one parameter being null and
@@ -474,8 +474,7 @@
}
private static final ImmutableSet<String> NULLABLE_ANNOTATION_SIMPLE_NAMES =
- ImmutableSet.of(
- "CheckForNull", "Nullable", "NullableDecl", "NullableType", "ParametricNullness");
+ ImmutableSet.of("CheckForNull", "Nullable", "NullableDecl", "NullableType");
static boolean isNullable(AnnotatedElement e) {
for (Annotation annotation : e.getAnnotations()) {
@@ -491,7 +490,7 @@
}
/**
- * Returns true if the given member is a method that overrides {@link Object#equals(Object)}.
+ * Returns true if the the given member is a method that overrides {@link Object#equals(Object)}.
*
* <p>The documentation for {@link Object#equals} says it should accept null, so don't require an
* explicit {@code @NullableDecl} annotation (see <a
diff --git a/android/guava-testlib/src/com/google/common/testing/SerializableTester.java b/android/guava-testlib/src/com/google/common/testing/SerializableTester.java
index 6298076..65445e5 100644
--- a/android/guava-testlib/src/com/google/common/testing/SerializableTester.java
+++ b/android/guava-testlib/src/com/google/common/testing/SerializableTester.java
@@ -29,6 +29,7 @@
* serialization tests require more setup. This no-op behavior allows test authors to intersperse
* {@code SerializableTester} calls with other, GWT-compatible tests.
*
+ *
* @author Mike Bostock
* @since 10.0
*/
diff --git a/android/guava-testlib/src/com/google/common/util/concurrent/testing/AbstractListenableFutureTest.java b/android/guava-testlib/src/com/google/common/util/concurrent/testing/AbstractListenableFutureTest.java
old mode 100644
new mode 100755
diff --git a/android/guava-testlib/src/com/google/common/util/concurrent/testing/MockFutureListener.java b/android/guava-testlib/src/com/google/common/util/concurrent/testing/MockFutureListener.java
old mode 100644
new mode 100755
diff --git a/android/guava-testlib/src/com/google/common/util/concurrent/testing/SameThreadScheduledExecutorService.java b/android/guava-testlib/src/com/google/common/util/concurrent/testing/SameThreadScheduledExecutorService.java
old mode 100644
new mode 100755
diff --git a/android/guava-testlib/src/com/google/common/util/concurrent/testing/TestingExecutors.java b/android/guava-testlib/src/com/google/common/util/concurrent/testing/TestingExecutors.java
old mode 100644
new mode 100755
diff --git a/android/guava-testlib/test/com/google/common/collect/testing/MapTestSuiteBuilderTests.java b/android/guava-testlib/test/com/google/common/collect/testing/MapTestSuiteBuilderTests.java
index a4d216d..1a54f68 100644
--- a/android/guava-testlib/test/com/google/common/collect/testing/MapTestSuiteBuilderTests.java
+++ b/android/guava-testlib/test/com/google/common/collect/testing/MapTestSuiteBuilderTests.java
@@ -26,11 +26,6 @@
import com.google.common.collect.testing.features.CollectionSize;
import com.google.common.collect.testing.features.Feature;
import com.google.common.collect.testing.features.MapFeature;
-import com.google.common.reflect.Reflection;
-import java.io.Serializable;
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
import java.util.AbstractMap;
import java.util.AbstractSet;
import java.util.Collection;
@@ -41,7 +36,6 @@
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
-import java.util.concurrent.atomic.AtomicBoolean;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
@@ -58,7 +52,6 @@
TestSuite suite = new TestSuite(MapTestSuiteBuilderTests.class.getSimpleName());
suite.addTest(testsForHashMapNullKeysForbidden());
suite.addTest(testsForHashMapNullValuesForbidden());
- suite.addTest(testsForSetUpTearDown());
return suite;
}
@@ -259,89 +252,4 @@
"HashMap w/out null values",
ALLOWS_NULL_KEYS);
}
-
- /**
- * Map generator that verifies that {@code setUp()} methods are called in all the test cases. The
- * {@code setUpRan} parameter is set true by the {@code setUp} that every test case is supposed to
- * have registered, and set false by the {@code tearDown}. We use a dynamic proxy to intercept all
- * of the {@code Map} method calls and check that {@code setUpRan} is true.
- */
- private static class CheckSetUpHashMapGenerator extends WrappedHashMapGenerator {
- private final AtomicBoolean setUpRan;
-
- CheckSetUpHashMapGenerator(AtomicBoolean setUpRan) {
- this.setUpRan = setUpRan;
- }
-
- @Override
- Map<String, String> wrap(HashMap<String, String> map) {
- @SuppressWarnings("unchecked")
- Map<String, String> proxy =
- Reflection.newProxy(Map.class, new CheckSetUpInvocationHandler(map, setUpRan));
- return proxy;
- }
- }
-
- /**
- * Intercepts calls to a {@code Map} to check that {@code setUpRan} is true when they happen. Then
- * forwards the calls to the underlying {@code Map}.
- */
- private static class CheckSetUpInvocationHandler implements InvocationHandler, Serializable {
- private final Map<String, String> map;
- private final AtomicBoolean setUpRan;
-
- CheckSetUpInvocationHandler(Map<String, String> map, AtomicBoolean setUpRan) {
- this.map = map;
- this.setUpRan = setUpRan;
- }
-
- @Override
- public Object invoke(Object target, Method method, Object[] args) throws Throwable {
- assertTrue("setUp should have run", setUpRan.get());
- try {
- return method.invoke(map, args);
- } catch (InvocationTargetException e) {
- throw e.getCause();
- } catch (IllegalAccessException e) {
- throw newLinkageError(e);
- }
- }
- }
-
- /** Verifies that {@code setUp} and {@code tearDown} are called in all map test cases. */
- private static Test testsForSetUpTearDown() {
- final AtomicBoolean setUpRan = new AtomicBoolean();
- Runnable setUp =
- new Runnable() {
- @Override
- public void run() {
- assertFalse("previous tearDown should have run before setUp", setUpRan.getAndSet(true));
- }
- };
- Runnable tearDown =
- new Runnable() {
- @Override
- public void run() {
- assertTrue("setUp should have run", setUpRan.getAndSet(false));
- }
- };
- return MapTestSuiteBuilder.using(new CheckSetUpHashMapGenerator(setUpRan))
- .named("setUpTearDown")
- .withFeatures(
- MapFeature.GENERAL_PURPOSE,
- MapFeature.ALLOWS_NULL_KEYS,
- MapFeature.ALLOWS_NULL_VALUES,
- CollectionFeature.SERIALIZABLE,
- CollectionFeature.SUPPORTS_ITERATOR_REMOVE,
- CollectionSize.ANY)
- .withSetUp(setUp)
- .withTearDown(tearDown)
- .createTestSuite();
- }
-
- private static LinkageError newLinkageError(Throwable cause) {
- LinkageError error = new LinkageError(cause.toString());
- error.initCause(cause);
- return error;
- }
}
diff --git a/android/guava-testlib/test/com/google/common/testing/FakeTickerTest.java b/android/guava-testlib/test/com/google/common/testing/FakeTickerTest.java
index 654304b..5c00832 100644
--- a/android/guava-testlib/test/com/google/common/testing/FakeTickerTest.java
+++ b/android/guava-testlib/test/com/google/common/testing/FakeTickerTest.java
@@ -151,7 +151,7 @@
final CountDownLatch startLatch = new CountDownLatch(numberOfThreads);
final CountDownLatch doneLatch = new CountDownLatch(numberOfThreads);
for (int i = numberOfThreads; i > 0; i--) {
- @SuppressWarnings("unused") // https://errorprone.info/bugpattern/FutureReturnValueIgnored
+ @SuppressWarnings("unused") // go/futurereturn-lsc
Future<?> possiblyIgnoredError =
executorService.submit(
new Callable<Void>() {
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 d1dc49b..99f01d6 100644
--- a/android/guava-testlib/test/com/google/common/testing/NullPointerTesterTest.java
+++ b/android/guava-testlib/test/com/google/common/testing/NullPointerTesterTest.java
@@ -54,7 +54,6 @@
* @author Kevin Bourrillion
* @author Mick Killianey
*/
-@SuppressWarnings("CheckReturnValue")
public class NullPointerTesterTest extends TestCase {
/** Non-NPE RuntimeException. */
diff --git a/android/guava-testlib/test/com/google/common/testing/PackageSanityTests.java b/android/guava-testlib/test/com/google/common/testing/PackageSanityTests.java
index d5483d3..cf446d2 100644
--- a/android/guava-testlib/test/com/google/common/testing/PackageSanityTests.java
+++ b/android/guava-testlib/test/com/google/common/testing/PackageSanityTests.java
@@ -16,7 +16,6 @@
package com.google.common.testing;
-
/** Test nulls for the entire package. */
public class PackageSanityTests extends AbstractPackageSanityTests {}
diff --git a/android/guava-testlib/test/com/google/common/util/concurrent/testing/TestingExecutorsTest.java b/android/guava-testlib/test/com/google/common/util/concurrent/testing/TestingExecutorsTest.java
old mode 100644
new mode 100755
diff --git a/android/guava-tests/benchmark/com/google/common/base/CharMatcherBenchmark.java b/android/guava-tests/benchmark/com/google/common/base/CharMatcherBenchmark.java
index 9dee99b..e2ba458 100644
--- a/android/guava-tests/benchmark/com/google/common/base/CharMatcherBenchmark.java
+++ b/android/guava-tests/benchmark/com/google/common/base/CharMatcherBenchmark.java
@@ -29,6 +29,7 @@
/**
* Benchmark for the {@link CharMatcher} class.
*
+ *
* @author David Beaumont
* @author Kevin Bourrillion
* @author David Richter
diff --git a/android/guava-tests/benchmark/com/google/common/base/StringsRepeatBenchmark.java b/android/guava-tests/benchmark/com/google/common/base/StringsRepeatBenchmark.java
index 16e00ef..30261da 100644
--- a/android/guava-tests/benchmark/com/google/common/base/StringsRepeatBenchmark.java
+++ b/android/guava-tests/benchmark/com/google/common/base/StringsRepeatBenchmark.java
@@ -40,7 +40,7 @@
}
@Benchmark
- void oldRepeat(long reps) {
+ void oldRepeat(int reps) {
for (int i = 0; i < reps; i++) {
String x = oldRepeat(originalString, count);
if (x.length() != (originalString.length() * count)) {
@@ -62,7 +62,7 @@
}
@Benchmark
- void mikeRepeat(long reps) {
+ void mikeRepeat(int reps) {
for (int i = 0; i < reps; i++) {
String x = mikeRepeat(originalString, count);
if (x.length() != (originalString.length() * count)) {
@@ -95,7 +95,7 @@
}
@Benchmark
- void martinRepeat(long reps) {
+ void martinRepeat(int reps) {
for (int i = 0; i < reps; i++) {
String x = martinRepeat(originalString, count);
if (x.length() != (originalString.length() * count)) {
diff --git a/android/guava-tests/benchmark/com/google/common/base/ToStringHelperBenchmark.java b/android/guava-tests/benchmark/com/google/common/base/ToStringHelperBenchmark.java
index 47dd8f4..6b33599 100644
--- a/android/guava-tests/benchmark/com/google/common/base/ToStringHelperBenchmark.java
+++ b/android/guava-tests/benchmark/com/google/common/base/ToStringHelperBenchmark.java
@@ -18,8 +18,6 @@
import com.google.caliper.Benchmark;
import com.google.caliper.Param;
-import java.util.Arrays;
-import java.util.Collections;
/**
* Some microbenchmarks for the {@link MoreObjects.ToStringHelper} class.
@@ -28,114 +26,33 @@
*/
public class ToStringHelperBenchmark {
- @Param({"0", "1", "5"})
+ @Param({"0", "2", "5", "10"})
int dataSize;
- @Param({"false", "true"})
- boolean omitNulls;
+ private static final String NAME = "abcdefgh";
+ private static final String NAME3 = Strings.repeat(NAME, 3);
- enum Dataset {
- SMALL {
- void addEntries(MoreObjects.ToStringHelper helper) {
- helper
- .add(SHORT_NAME, 10)
- .addValue(10L)
- .add(SHORT_NAME, 3.14f)
- .addValue(3.14d)
- .add(LONG_NAME, false)
- .add(LONG_NAME, LONG_NAME);
- }
- },
- CONDITIONAL {
- void addEntries(MoreObjects.ToStringHelper helper) {
- helper
- .add(SHORT_NAME, "x")
- .add(LONG_NAME, "y")
- .add(SHORT_NAME, null)
- .add(LONG_NAME, null)
- .addValue("z")
- .addValue("")
- .addValue(null)
- .add(SHORT_NAME, Arrays.asList("A"))
- .add(LONG_NAME, Arrays.asList("B"))
- .add(SHORT_NAME, Arrays.asList())
- .add(LONG_NAME, Arrays.asList())
- .addValue(Arrays.asList("C"))
- .addValue(Arrays.asList())
- .add(SHORT_NAME, Collections.singletonMap("k1", "v1"))
- .add(LONG_NAME, Collections.singletonMap("k2", "v2"))
- .addValue(Collections.singletonMap("k3", "v3"))
- .addValue(Collections.emptyMap())
- .addValue(null)
- .add(SHORT_NAME, Optional.of("1"))
- .add(LONG_NAME, Optional.of("1"))
- .add(SHORT_NAME, Optional.absent())
- .add(LONG_NAME, Optional.absent())
- .add(SHORT_NAME, Optional.of("2"))
- .add(SHORT_NAME, Optional.absent())
- .addValue(null)
- .add(SHORT_NAME, new int[] {1})
- .add(LONG_NAME, new int[] {2})
- .addValue(new int[] {3})
- .addValue(new int[] {})
- .addValue(null);
- }
- },
- UNCONDITIONAL {
- void addEntries(MoreObjects.ToStringHelper helper) {
- helper
- .add(SHORT_NAME, false)
- .add(LONG_NAME, false)
- .addValue(true)
- .add(SHORT_NAME, (byte) 1)
- .add(LONG_NAME, (byte) 2)
- .addValue((byte) 3)
- .add(SHORT_NAME, 'A')
- .add(LONG_NAME, 'B')
- .addValue('C')
- .add(SHORT_NAME, (short) 4)
- .add(LONG_NAME, (short) 5)
- .addValue((short) 6)
- .add(SHORT_NAME, 7)
- .add(LONG_NAME, 8)
- .addValue(9)
- .add(SHORT_NAME, 10L)
- .add(LONG_NAME, 11L)
- .addValue(12L)
- .add(SHORT_NAME, 13.0f)
- .add(LONG_NAME, 14.0f)
- .addValue(15.0f);
- }
- };
-
- void addEntries(MoreObjects.ToStringHelper helper) {}
- }
-
- @Param Dataset dataset;
-
- private static final String SHORT_NAME = "userId";
- private static final String LONG_NAME = "fluxCapacitorFailureRate95Percentile";
-
- private MoreObjects.ToStringHelper newHelper() {
- MoreObjects.ToStringHelper helper = MoreObjects.toStringHelper("klass");
- if (omitNulls) {
- helper = helper.omitNullValues();
- }
- return helper;
+ private static void addEntries(MoreObjects.ToStringHelper helper) {
+ helper
+ .add(NAME, 10)
+ .addValue(10L)
+ .add(NAME, 3.14f)
+ .addValue(3.14d)
+ .add(NAME3, false)
+ .add(NAME3, NAME3)
+ .add(NAME3, 'x');
}
@Benchmark
int toString(int reps) {
int dummy = 0;
for (int i = 0; i < reps; i++) {
- MoreObjects.ToStringHelper helper = newHelper();
+ MoreObjects.ToStringHelper helper = MoreObjects.toStringHelper("klass").omitNullValues();
for (int j = 0; j < dataSize; ++j) {
- dataset.addEntries(helper);
+ addEntries(helper);
}
dummy ^= helper.toString().hashCode();
}
return dummy;
}
-
- // When omitEmptyValues() is released, remove this method and add a new @Param "omitEmptyValues".
}
diff --git a/android/guava-tests/benchmark/com/google/common/util/concurrent/ExecutionListBenchmark.java b/android/guava-tests/benchmark/com/google/common/util/concurrent/ExecutionListBenchmark.java
index c9df774..e1b94a3 100644
--- a/android/guava-tests/benchmark/com/google/common/util/concurrent/ExecutionListBenchmark.java
+++ b/android/guava-tests/benchmark/com/google/common/util/concurrent/ExecutionListBenchmark.java
@@ -252,7 +252,7 @@
final AtomicInteger integer = new AtomicInteger();
// Execute a bunch of tasks to ensure that our threads are allocated and hot
for (int i = 0; i < NUM_THREADS * 10; i++) {
- @SuppressWarnings("unused") // https://errorprone.info/bugpattern/FutureReturnValueIgnored
+ @SuppressWarnings("unused") // go/futurereturn-lsc
Future<?> possiblyIgnoredError =
executorService.submit(
new Runnable() {
@@ -334,10 +334,10 @@
list = impl.newExecutionList();
listenerLatch = new CountDownLatch(numListeners * NUM_THREADS);
for (int j = 0; j < NUM_THREADS; j++) {
- @SuppressWarnings("unused") // https://errorprone.info/bugpattern/FutureReturnValueIgnored
+ @SuppressWarnings("unused") // go/futurereturn-lsc
Future<?> possiblyIgnoredError = executorService.submit(addTask);
}
- @SuppressWarnings("unused") // https://errorprone.info/bugpattern/FutureReturnValueIgnored
+ @SuppressWarnings("unused") // go/futurereturn-lsc
Future<?> possiblyIgnoredError = executorService.submit(executeTask);
returnValue += (int) listenerLatch.getCount();
listenerLatch.await();
@@ -360,10 +360,10 @@
for (int i = 0; i < reps; i++) {
list = impl.newExecutionList();
listenerLatch = new CountDownLatch(numListeners * NUM_THREADS);
- @SuppressWarnings("unused") // https://errorprone.info/bugpattern/FutureReturnValueIgnored
+ @SuppressWarnings("unused") // go/futurereturn-lsc
Future<?> possiblyIgnoredError = executorService.submit(executeTask);
for (int j = 0; j < NUM_THREADS; j++) {
- @SuppressWarnings("unused") // https://errorprone.info/bugpattern/FutureReturnValueIgnored
+ @SuppressWarnings("unused") // go/futurereturn-lsc
Future<?> possiblyIgnoredError1 = executorService.submit(addTask);
}
returnValue += (int) listenerLatch.getCount();
diff --git a/android/guava-tests/benchmark/com/google/common/util/concurrent/FuturesGetCheckedBenchmark.java b/android/guava-tests/benchmark/com/google/common/util/concurrent/FuturesGetCheckedBenchmark.java
index bb76420..dd1883b 100644
--- a/android/guava-tests/benchmark/com/google/common/util/concurrent/FuturesGetCheckedBenchmark.java
+++ b/android/guava-tests/benchmark/com/google/common/util/concurrent/FuturesGetCheckedBenchmark.java
@@ -21,6 +21,7 @@
import static com.google.common.util.concurrent.Futures.immediateFailedFuture;
import static com.google.common.util.concurrent.Futures.immediateFuture;
import static com.google.common.util.concurrent.FuturesGetChecked.checkExceptionClassValidity;
+import static com.google.common.util.concurrent.FuturesGetChecked.classValueValidator;
import static com.google.common.util.concurrent.FuturesGetChecked.getChecked;
import static com.google.common.util.concurrent.FuturesGetChecked.isCheckedException;
import static com.google.common.util.concurrent.FuturesGetChecked.weakSetValidator;
@@ -51,7 +52,7 @@
NON_CACHING_WITH_CONSTRUCTOR_CHECK(nonCachingWithConstructorCheckValidator()),
NON_CACHING_WITHOUT_CONSTRUCTOR_CHECK(nonCachingWithoutConstructorCheckValidator()),
WEAK_SET(weakSetValidator()),
- ;
+ CLASS_VALUE(classValueValidator());
final GetCheckedTypeValidator validator;
diff --git a/android/guava-tests/benchmark/com/google/common/util/concurrent/MonitorBasedArrayBlockingQueue.java b/android/guava-tests/benchmark/com/google/common/util/concurrent/MonitorBasedArrayBlockingQueue.java
index 61f735d..7998a72 100644
--- a/android/guava-tests/benchmark/com/google/common/util/concurrent/MonitorBasedArrayBlockingQueue.java
+++ b/android/guava-tests/benchmark/com/google/common/util/concurrent/MonitorBasedArrayBlockingQueue.java
@@ -36,12 +36,12 @@
*
* <p>This is a classic "bounded buffer", in which a fixed-sized array holds elements
* inserted by producers and extracted by consumers. Once created, the capacity cannot be increased.
- * Attempts to {@code put} an element into a full queue will result in the operation blocking;
- * attempts to {@code take} an element from an empty queue will similarly block.
+ * Attempts to <tt>put</tt> an element into a full queue will result in the operation blocking;
+ * attempts to <tt>take</tt> an element from an empty queue will similarly block.
*
* <p>This class supports an optional fairness policy for ordering waiting producer and consumer
* threads. By default, this ordering is not guaranteed. However, a queue constructed with fairness
- * set to {@code true} grants threads access in FIFO order. Fairness generally decreases throughput
+ * set to <tt>true</tt> grants threads access in FIFO order. Fairness generally decreases throughput
* but reduces variability and avoids starvation.
*
* <p>This class and its iterator implement all of the <em>optional</em> methods of the {@link
@@ -139,24 +139,24 @@
}
/**
- * Creates an {@code MonitorBasedArrayBlockingQueue} with the given (fixed) capacity and default
+ * Creates an <tt>MonitorBasedArrayBlockingQueue</tt> with the given (fixed) capacity and default
* access policy.
*
* @param capacity the capacity of this queue
- * @throws IllegalArgumentException if {@code capacity} is less than 1
+ * @throws IllegalArgumentException if <tt>capacity</tt> is less than 1
*/
public MonitorBasedArrayBlockingQueue(int capacity) {
this(capacity, false);
}
/**
- * Creates an {@code MonitorBasedArrayBlockingQueue} with the given (fixed) capacity and the
+ * Creates an <tt>MonitorBasedArrayBlockingQueue</tt> with the given (fixed) capacity and the
* specified access policy.
*
* @param capacity the capacity of this queue
- * @param fair if {@code true} then queue accesses for threads blocked on insertion or removal,
- * are processed in FIFO order; if {@code false} the access order is unspecified.
- * @throws IllegalArgumentException if {@code capacity} is less than 1
+ * @param fair if <tt>true</tt> then queue accesses for threads blocked on insertion or removal,
+ * are processed in FIFO order; if <tt>false</tt> the access order is unspecified.
+ * @throws IllegalArgumentException if <tt>capacity</tt> is less than 1
*/
public MonitorBasedArrayBlockingQueue(int capacity, boolean fair) {
if (capacity <= 0) throw new IllegalArgumentException();
@@ -179,15 +179,15 @@
}
/**
- * Creates an {@code MonitorBasedArrayBlockingQueue} with the given (fixed) capacity, the
+ * Creates an <tt>MonitorBasedArrayBlockingQueue</tt> with the given (fixed) capacity, the
* specified access policy and initially containing the elements of the given collection, added in
* traversal order of the collection's iterator.
*
* @param capacity the capacity of this queue
- * @param fair if {@code true} then queue accesses for threads blocked on insertion or removal,
- * are processed in FIFO order; if {@code false} the access order is unspecified.
+ * @param fair if <tt>true</tt> then queue accesses for threads blocked on insertion or removal,
+ * are processed in FIFO order; if <tt>false</tt> the access order is unspecified.
* @param c the collection of elements to initially contain
- * @throws IllegalArgumentException if {@code capacity} is less than {@code c.size()}, or less
+ * @throws IllegalArgumentException if <tt>capacity</tt> is less than <tt>c.size()</tt>, or less
* than 1.
* @throws NullPointerException if the specified collection or any of its elements are null
*/
@@ -205,11 +205,11 @@
/**
* Inserts the specified element at the tail of this queue if it is possible to do so immediately
- * without exceeding the queue's capacity, returning {@code true} upon success and throwing an
- * {@code IllegalStateException} if this queue is full.
+ * without exceeding the queue's capacity, returning <tt>true</tt> upon success and throwing an
+ * <tt>IllegalStateException</tt> if this queue is full.
*
* @param e the element to add
- * @return {@code true} (as specified by {@link Collection#add})
+ * @return <tt>true</tt> (as specified by {@link Collection#add})
* @throws IllegalStateException if this queue is full
* @throws NullPointerException if the specified element is null
*/
@@ -220,7 +220,7 @@
/**
* Inserts the specified element at the tail of this queue if it is possible to do so immediately
- * without exceeding the queue's capacity, returning {@code true} upon success and {@code false}
+ * without exceeding the queue's capacity, returning <tt>true</tt> upon success and <tt>false</tt>
* if this queue is full. This method is generally preferable to method {@link #add}, which can
* fail to insert an element only by throwing an exception.
*
@@ -361,11 +361,11 @@
/**
* Returns the number of additional elements that this queue can ideally (in the absence of memory
* or resource constraints) accept without blocking. This is always equal to the initial capacity
- * of this queue less the current {@code size} of this queue.
+ * of this queue less the current <tt>size</tt> of this queue.
*
* <p>Note that you <em>cannot</em> always tell if an attempt to insert an element will succeed by
- * inspecting {@code remainingCapacity} because it may be the case that another thread is about to
- * insert or remove an element.
+ * inspecting <tt>remainingCapacity</tt> because it may be the case that another thread is about
+ * to insert or remove an element.
*/
@Override
public int remainingCapacity() {
@@ -380,12 +380,12 @@
/**
* Removes a single instance of the specified element from this queue, if it is present. More
- * formally, removes an element {@code e} such that {@code o.equals(e)}, if this queue contains
- * one or more such elements. Returns {@code true} if this queue contained the specified element
+ * formally, removes an element <tt>e</tt> such that <tt>o.equals(e)</tt>, if this queue contains
+ * one or more such elements. Returns <tt>true</tt> if this queue contained the specified element
* (or equivalently, if this queue changed as a result of the call).
*
* @param o element to be removed from this queue, if present
- * @return {@code true} if this queue changed as a result of the call
+ * @return <tt>true</tt> if this queue changed as a result of the call
*/
@Override
public boolean remove(@NullableDecl Object o) {
@@ -410,12 +410,12 @@
}
/**
- * Returns {@code true} if this queue contains the specified element. More formally, returns
- * {@code true} if and only if this queue contains at least one element {@code e} such that {@code
- * o.equals(e)}.
+ * Returns <tt>true</tt> if this queue contains the specified element. More formally, returns
+ * <tt>true</tt> if and only if this queue contains at least one element <tt>e</tt> such that
+ * <tt>o.equals(e)</tt>.
*
* @param o object to be checked for containment in this queue
- * @return {@code true} if this queue contains the specified element
+ * @return <tt>true</tt> if this queue contains the specified element
*/
@Override
public boolean contains(@NullableDecl Object o) {
@@ -474,19 +474,19 @@
*
* <p>If this queue fits in the specified array with room to spare (i.e., the array has more
* elements than this queue), the element in the array immediately following the end of the queue
- * is set to {@code null}.
+ * is set to <tt>null</tt>.
*
* <p>Like the {@link #toArray()} method, this method acts as bridge between array-based and
* collection-based APIs. Further, this method allows precise control over the runtime type of the
* output array, and may, under certain circumstances, be used to save allocation costs.
*
- * <p>Suppose {@code x} is a queue known to contain only strings. The following code can be used
- * to dump the queue into a newly allocated array of {@code String}:
+ * <p>Suppose <tt>x</tt> is a queue known to contain only strings. The following code can be used
+ * to dump the queue into a newly allocated array of <tt>String</tt>:
*
* <pre>
* String[] y = x.toArray(new String[0]);</pre>
*
- * <p>Note that {@code toArray(new Object[0])} is identical in function to {@code toArray()}.
+ * <p>Note that <tt>toArray(new Object[0])</tt> is identical in function to <tt>toArray()</tt>.
*
* @param a the array into which the elements of the queue are to be stored, if it is big enough;
* otherwise, a new array of the same runtime type is allocated for this purpose
@@ -626,8 +626,8 @@
}
/**
- * Returns an iterator over the elements in this queue in proper sequence. The returned {@code
- * Iterator} is a "weakly consistent" iterator that will never throw {@link
+ * Returns an iterator over the elements in this queue in proper sequence. The returned
+ * <tt>Iterator</tt> is a "weakly consistent" iterator that will never throw {@link
* ConcurrentModificationException}, and guarantees to traverse elements as they existed upon
* construction of the iterator, and may (but is not guaranteed to) reflect any modifications
* subsequent to construction.
diff --git a/android/guava-tests/benchmark/com/google/common/util/concurrent/MonitorBasedPriorityBlockingQueue.java b/android/guava-tests/benchmark/com/google/common/util/concurrent/MonitorBasedPriorityBlockingQueue.java
index 086253d..715a9c8 100644
--- a/android/guava-tests/benchmark/com/google/common/util/concurrent/MonitorBasedPriorityBlockingQueue.java
+++ b/android/guava-tests/benchmark/com/google/common/util/concurrent/MonitorBasedPriorityBlockingQueue.java
@@ -35,23 +35,23 @@
/**
* An unbounded {@linkplain BlockingQueue blocking queue} that uses the same ordering rules as class
* {@link PriorityQueue} and supplies blocking retrieval operations. While this queue is logically
- * unbounded, attempted additions may fail due to resource exhaustion (causing {@code
- * OutOfMemoryError}). This class does not permit {@code null} elements. A priority queue relying on
- * {@linkplain Comparable natural ordering} also does not permit insertion of non-comparable objects
- * (doing so results in {@code ClassCastException}).
+ * unbounded, attempted additions may fail due to resource exhaustion (causing
+ * <tt>OutOfMemoryError</tt>). This class does not permit <tt>null</tt> elements. A priority queue
+ * relying on {@linkplain Comparable natural ordering} also does not permit insertion of
+ * non-comparable objects (doing so results in <tt>ClassCastException</tt>).
*
* <p>This class and its iterator implement all of the <em>optional</em> methods of the {@link
* Collection} and {@link Iterator} interfaces. The Iterator provided in method {@link #iterator()}
* is <em>not</em> guaranteed to traverse the elements of the MonitorBasedPriorityBlockingQueue in
- * any particular order. If you need ordered traversal, consider using {@code
- * Arrays.sort(pq.toArray())}. Also, method {@code drainTo} can be used to <em>remove</em> some or
- * all elements in priority order and place them in another collection.
+ * any particular order. If you need ordered traversal, consider using
+ * <tt>Arrays.sort(pq.toArray())</tt>. Also, method <tt>drainTo</tt> can be used to <em>remove</em>
+ * some or all elements in priority order and place them in another collection.
*
* <p>Operations on this class make no guarantees about the ordering of elements with equal
* priority. If you need to enforce an ordering, you can define custom classes or comparators that
* use a secondary key to break ties in primary priority values. For example, here is a class that
* applies first-in-first-out tie-breaking to comparable elements. To use it, you would insert a
- * {@code new FIFOEntry(anEntry)} instead of a plain entry object.
+ * <tt>new FIFOEntry(anEntry)</tt> instead of a plain entry object.
*
* <pre>
* class FIFOEntry<E extends Comparable<? super E>>
@@ -96,32 +96,32 @@
};
/**
- * Creates a {@code MonitorBasedPriorityBlockingQueue} with the default initial capacity (11) that
- * orders its elements according to their {@linkplain Comparable natural ordering}.
+ * Creates a <tt>MonitorBasedPriorityBlockingQueue</tt> with the default initial capacity (11)
+ * that orders its elements according to their {@linkplain Comparable natural ordering}.
*/
public MonitorBasedPriorityBlockingQueue() {
q = new PriorityQueue<E>();
}
/**
- * Creates a {@code MonitorBasedPriorityBlockingQueue} with the specified initial capacity that
+ * Creates a <tt>MonitorBasedPriorityBlockingQueue</tt> with the specified initial capacity that
* orders its elements according to their {@linkplain Comparable natural ordering}.
*
* @param initialCapacity the initial capacity for this priority queue
- * @throws IllegalArgumentException if {@code initialCapacity} is less than 1
+ * @throws IllegalArgumentException if <tt>initialCapacity</tt> is less than 1
*/
public MonitorBasedPriorityBlockingQueue(int initialCapacity) {
q = new PriorityQueue<E>(initialCapacity, null);
}
/**
- * Creates a {@code MonitorBasedPriorityBlockingQueue} with the specified initial capacity that
+ * Creates a <tt>MonitorBasedPriorityBlockingQueue</tt> with the specified initial capacity that
* orders its elements according to the specified comparator.
*
* @param initialCapacity the initial capacity for this priority queue
* @param comparator the comparator that will be used to order this priority queue. If {@code
* null}, the {@linkplain Comparable natural ordering} of the elements will be used.
- * @throws IllegalArgumentException if {@code initialCapacity} is less than 1
+ * @throws IllegalArgumentException if <tt>initialCapacity</tt> is less than 1
*/
public MonitorBasedPriorityBlockingQueue(
int initialCapacity, @NullableDecl Comparator<? super E> comparator) {
@@ -129,7 +129,7 @@
}
/**
- * Creates a {@code MonitorBasedPriorityBlockingQueue} containing the elements in the specified
+ * Creates a <tt>MonitorBasedPriorityBlockingQueue</tt> containing the elements in the specified
* collection. If the specified collection is a {@link SortedSet} or a {@link PriorityQueue}, this
* priority queue will be ordered according to the same ordering. Otherwise, this priority queue
* will be ordered according to the {@linkplain Comparable natural ordering} of its elements.
@@ -147,7 +147,7 @@
* Inserts the specified element into this priority queue.
*
* @param e the element to add
- * @return {@code true} (as specified by {@link Collection#add})
+ * @return <tt>true</tt> (as specified by {@link Collection#add})
* @throws ClassCastException if the specified element cannot be compared with elements currently
* in the priority queue according to the priority queue's ordering
* @throws NullPointerException if the specified element is null
@@ -161,7 +161,7 @@
* Inserts the specified element into this priority queue.
*
* @param e the element to add
- * @return {@code true} (as specified by {@link Queue#offer})
+ * @return <tt>true</tt> (as specified by {@link Queue#offer})
* @throws ClassCastException if the specified element cannot be compared with elements currently
* in the priority queue according to the priority queue's ordering
* @throws NullPointerException if the specified element is null
@@ -188,7 +188,7 @@
* @param e the element to add
* @param timeout This parameter is ignored as the method never blocks
* @param unit This parameter is ignored as the method never blocks
- * @return {@code true}
+ * @return <tt>true</tt>
* @throws ClassCastException if the specified element cannot be compared with elements currently
* in the priority queue according to the priority queue's ordering
* @throws NullPointerException if the specified element is null
@@ -261,10 +261,10 @@
}
/**
- * Returns the comparator used to order the elements in this queue, or {@code null} if this queue
+ * Returns the comparator used to order the elements in this queue, or <tt>null</tt> if this queue
* uses the {@linkplain Comparable natural ordering} of its elements.
*
- * @return the comparator used to order the elements in this queue, or {@code null} if this queue
+ * @return the comparator used to order the elements in this queue, or <tt>null</tt> if this queue
* uses the natural ordering of its elements
*/
public Comparator<? super E> comparator() {
@@ -283,10 +283,10 @@
}
/**
- * Always returns {@code Integer.MAX_VALUE} because a {@code MonitorBasedPriorityBlockingQueue} is
- * not capacity constrained.
+ * Always returns <tt>Integer.MAX_VALUE</tt> because a <tt>MonitorBasedPriorityBlockingQueue</tt>
+ * is not capacity constrained.
*
- * @return {@code Integer.MAX_VALUE}
+ * @return <tt>Integer.MAX_VALUE</tt>
*/
@Override
public int remainingCapacity() {
@@ -300,7 +300,7 @@
* specified element (or equivalently, if this queue changed as a result of the call).
*
* @param o element to be removed from this queue, if present
- * @return {@code true} if this queue changed as a result of the call
+ * @return <tt>true</tt> if this queue changed as a result of the call
*/
@Override
public boolean remove(@NullableDecl Object o) {
@@ -319,7 +319,7 @@
* o.equals(e)}.
*
* @param o object to be checked for containment in this queue
- * @return {@code true} if this queue contains the specified element
+ * @return <tt>true</tt> if this queue contains the specified element
*/
@Override
public boolean contains(@NullableDecl Object o) {
@@ -363,19 +363,19 @@
*
* <p>If this queue fits in the specified array with room to spare (i.e., the array has more
* elements than this queue), the element in the array immediately following the end of the queue
- * is set to {@code null}.
+ * is set to <tt>null</tt>.
*
* <p>Like the {@link #toArray()} method, this method acts as bridge between array-based and
* collection-based APIs. Further, this method allows precise control over the runtime type of the
* output array, and may, under certain circumstances, be used to save allocation costs.
*
- * <p>Suppose {@code x} is a queue known to contain only strings. The following code can be used
- * to dump the queue into a newly allocated array of {@code String}:
+ * <p>Suppose <tt>x</tt> is a queue known to contain only strings. The following code can be used
+ * to dump the queue into a newly allocated array of <tt>String</tt>:
*
* <pre>
* String[] y = x.toArray(new String[0]);</pre>
*
- * <p>Note that {@code toArray(new Object[0])} is identical in function to {@code toArray()}.
+ * <p>Note that <tt>toArray(new Object[0])</tt> is identical in function to <tt>toArray()</tt>.
*
* @param a the array into which the elements of the queue are to be stored, if it is big enough;
* otherwise, a new array of the same runtime type is allocated for this purpose
@@ -474,7 +474,7 @@
/**
* Returns an iterator over the elements in this queue. The iterator does not return the elements
- * in any particular order. The returned {@code Iterator} is a "weakly consistent" iterator that
+ * in any particular order. The returned <tt>Iterator</tt> is a "weakly consistent" iterator that
* will never throw {@link ConcurrentModificationException}, and guarantees to traverse elements
* as they existed upon construction of the iterator, and may (but is not guaranteed to) reflect
* any modifications subsequent to construction.
diff --git a/android/guava-tests/pom.xml b/android/guava-tests/pom.xml
index 7f57d87..5191c8e 100644
--- a/android/guava-tests/pom.xml
+++ b/android/guava-tests/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>com.google.guava</groupId>
<artifactId>guava-parent</artifactId>
- <version>31.0.1-android</version>
+ <version>30.0-android</version>
</parent>
<artifactId>guava-tests</artifactId>
<name>Guava Unit Tests</name>
@@ -102,9 +102,6 @@
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>animal-sniffer-maven-plugin</artifactId>
- <configuration>
- <checkTestClasses>false</checkTestClasses> <!-- TODO(cpovirk): Consider checking them. -->
- </configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
diff --git a/android/guava-tests/test/com/google/common/base/AbstractIteratorTest.java b/android/guava-tests/test/com/google/common/base/AbstractIteratorTest.java
index da732bf..e8f8b93 100644
--- a/android/guava-tests/test/com/google/common/base/AbstractIteratorTest.java
+++ b/android/guava-tests/test/com/google/common/base/AbstractIteratorTest.java
@@ -171,7 +171,6 @@
}
}
-
@GwtIncompatible // weak references
public void testFreesNextReference() {
Iterator<Object> itr =
diff --git a/android/guava-tests/test/com/google/common/base/AndroidIncompatible.java b/android/guava-tests/test/com/google/common/base/AndroidIncompatible.java
index 5e190a3..e3a250d 100644
--- a/android/guava-tests/test/com/google/common/base/AndroidIncompatible.java
+++ b/android/guava-tests/test/com/google/common/base/AndroidIncompatible.java
@@ -32,6 +32,7 @@
* Google-internal Android suite generators. Note that those generators also suppress any test
* annotated with MediumTest or LargeTest.
*
+ *
* <p>Why use a custom annotation instead of {@code android.test.suitebuilder.annotation.Suppress}?
* I'm not completely sure that this is the right choice, but it has various advantages:
*
diff --git a/android/guava-tests/test/com/google/common/base/EnumsTest.java b/android/guava-tests/test/com/google/common/base/EnumsTest.java
index d8b13af..413f308 100644
--- a/android/guava-tests/test/com/google/common/base/EnumsTest.java
+++ b/android/guava-tests/test/com/google/common/base/EnumsTest.java
@@ -79,7 +79,6 @@
assertThat(Enums.getIfPresent(TestEnum.class, "WOMBAT")).isAbsent();
}
-
@GwtIncompatible // weak references
public void testGetIfPresent_doesNotPreventClassUnloading() throws Exception {
WeakReference<?> shadowLoaderReference = doTestClassUnloading();
diff --git a/android/guava-tests/test/com/google/common/base/FinalizableReferenceQueueClassLoaderUnloadingTest.java b/android/guava-tests/test/com/google/common/base/FinalizableReferenceQueueClassLoaderUnloadingTest.java
index ae35c16..453b23c 100644
--- a/android/guava-tests/test/com/google/common/base/FinalizableReferenceQueueClassLoaderUnloadingTest.java
+++ b/android/guava-tests/test/com/google/common/base/FinalizableReferenceQueueClassLoaderUnloadingTest.java
@@ -47,7 +47,6 @@
* @author Eamonn McManus
*/
-
public class FinalizableReferenceQueueClassLoaderUnloadingTest extends TestCase {
/*
@@ -111,8 +110,7 @@
// Now make a parallel FRQ and an associated FinalizableWeakReference to an object, in order to
// exercise some classes from the parallel ClassLoader.
- AtomicReference<Object> sepFrqA =
- new AtomicReference<Object>(sepFrqC.getDeclaredConstructor().newInstance());
+ AtomicReference<Object> sepFrqA = new AtomicReference<Object>(sepFrqC.newInstance());
Class<?> sepFwrC = sepLoader.loadClass(MyFinalizableWeakReference.class.getName());
Constructor<?> sepFwrCons = sepFwrC.getConstructor(Object.class, sepFrqC);
// The object that we will wrap in FinalizableWeakReference is a Stopwatch.
@@ -242,7 +240,7 @@
assertNotSame(frqUserC, sepFrqUserC);
assertSame(sepLoader, sepFrqUserC.getClassLoader());
- Callable<?> sepFrqUser = (Callable<?>) sepFrqUserC.getDeclaredConstructor().newInstance();
+ Callable<?> sepFrqUser = (Callable<?>) sepFrqUserC.newInstance();
WeakReference<?> finalizableWeakReference = (WeakReference<?>) sepFrqUser.call();
GcFinalization.awaitClear(finalizableWeakReference);
diff --git a/android/guava-tests/test/com/google/common/base/FinalizableReferenceQueueTest.java b/android/guava-tests/test/com/google/common/base/FinalizableReferenceQueueTest.java
index 3e99122..9678701 100644
--- a/android/guava-tests/test/com/google/common/base/FinalizableReferenceQueueTest.java
+++ b/android/guava-tests/test/com/google/common/base/FinalizableReferenceQueueTest.java
@@ -40,7 +40,6 @@
frq = null;
}
-
public void testFinalizeReferentCalled() {
final MockReference reference = new MockReference(frq = new FinalizableReferenceQueue());
@@ -72,7 +71,6 @@
*/
private WeakReference<ReferenceQueue<Object>> queueReference;
-
public void testThatFinalizerStops() {
weaklyReferenceQueue();
GcFinalization.awaitClear(queueReference);
diff --git a/android/guava-tests/test/com/google/common/base/OptionalTest.java b/android/guava-tests/test/com/google/common/base/OptionalTest.java
index ba6ace7..35de2d4 100644
--- a/android/guava-tests/test/com/google/common/base/OptionalTest.java
+++ b/android/guava-tests/test/com/google/common/base/OptionalTest.java
@@ -68,7 +68,6 @@
assertFalse(Optional.absent().isPresent());
}
- @SuppressWarnings("OptionalOfRedundantMethod") // Unit tests for Optional
public void testIsPresent_yes() {
assertTrue(Optional.of("training").isPresent());
}
@@ -86,7 +85,6 @@
assertEquals("training", Optional.of("training").get());
}
- @SuppressWarnings("OptionalOfRedundantMethod") // Unit tests for Optional
public void testOr_T_present() {
assertEquals("a", Optional.of("a").or("default"));
}
@@ -95,7 +93,6 @@
assertEquals("default", Optional.absent().or("default"));
}
- @SuppressWarnings("OptionalOfRedundantMethod") // Unit tests for Optional
public void testOr_supplier_present() {
assertEquals("a", Optional.of("a").or(Suppliers.ofInstance("fallback")));
}
@@ -114,13 +111,11 @@
}
}
- @SuppressWarnings("OptionalOfRedundantMethod") // Unit tests for Optional
public void testOr_nullSupplier_present() {
Supplier<String> nullSupplier = Suppliers.ofInstance(null);
assertEquals("a", Optional.of("a").or(nullSupplier));
}
- @SuppressWarnings("OptionalOfRedundantMethod") // Unit tests for Optional
public void testOr_Optional_present() {
assertEquals(Optional.of("a"), Optional.of("a").or(Optional.of("fallback")));
}
@@ -129,7 +124,6 @@
assertEquals(Optional.of("fallback"), Optional.absent().or(Optional.of("fallback")));
}
- @SuppressWarnings("OptionalOfRedundantMethod") // Unit tests for Optional
public void testOrNull_present() {
assertEquals("a", Optional.of("a").orNull());
}
diff --git a/android/guava-tests/test/com/google/common/base/PreconditionsTest.java b/android/guava-tests/test/com/google/common/base/PreconditionsTest.java
index 1add44d..072649f 100644
--- a/android/guava-tests/test/com/google/common/base/PreconditionsTest.java
+++ b/android/guava-tests/test/com/google/common/base/PreconditionsTest.java
@@ -24,6 +24,7 @@
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Lists;
import com.google.common.testing.ArbitraryInstances;
+import com.google.common.testing.NullPointerTester;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
@@ -538,22 +539,8 @@
@GwtIncompatible // NullPointerTester
public void testNullPointers() {
- /*
- * Don't bother testing: Preconditions defines a bunch of methods that accept a template (or
- * even entire message) that simultaneously:
- *
- * - _shouldn't_ be null, so we don't annotate it with @Nullable
- *
- * - _can_ be null without causing a runtime failure (because we don't want the interesting
- * details of precondition failure to be hidden by an exception we throw about an unexpectedly
- * null _failure message_)
- *
- * That combination upsets NullPointerTester, which wants any call that passes null for a
- * non-@Nullable parameter to trigger a NullPointerException.
- *
- * (We still define this empty method to keep PackageSanityTests from generating its own
- * automated nullness tests, which would fail.)
- */
+ NullPointerTester tester = new NullPointerTester();
+ tester.testAllPublicStaticMethods(Preconditions.class);
}
private static final Object IGNORE_ME =
diff --git a/android/guava-tests/test/com/google/common/base/ToStringHelperTest.java b/android/guava-tests/test/com/google/common/base/ToStringHelperTest.java
index db15f2e..3f1ef0f 100644
--- a/android/guava-tests/test/com/google/common/base/ToStringHelperTest.java
+++ b/android/guava-tests/test/com/google/common/base/ToStringHelperTest.java
@@ -116,15 +116,15 @@
@GwtIncompatible // Class names are obfuscated in GWT
public void testToStringHelper_moreThanNineAnonymousClasses() {
// The nth anonymous class has a name ending like "Outer.$n"
- Object unused1 = new Object() {};
- Object unused2 = new Object() {};
- Object unused3 = new Object() {};
- Object unused4 = new Object() {};
- Object unused5 = new Object() {};
- Object unused6 = new Object() {};
- Object unused7 = new Object() {};
- Object unused8 = new Object() {};
- Object unused9 = new Object() {};
+ Object o1 = new Object() {};
+ Object o2 = new Object() {};
+ Object o3 = new Object() {};
+ Object o4 = new Object() {};
+ Object o5 = new Object() {};
+ Object o6 = new Object() {};
+ Object o7 = new Object() {};
+ Object o8 = new Object() {};
+ Object o9 = new Object() {};
Object o10 = new Object() {};
String toTest = MoreObjects.toStringHelper(o10).toString();
assertEquals("{}", toTest);
@@ -132,15 +132,15 @@
public void testToStringHelperLenient_moreThanNineAnonymousClasses() {
// The nth anonymous class has a name ending like "Outer.$n"
- Object unused1 = new Object() {};
- Object unused2 = new Object() {};
- Object unused3 = new Object() {};
- Object unused4 = new Object() {};
- Object unused5 = new Object() {};
- Object unused6 = new Object() {};
- Object unused7 = new Object() {};
- Object unused8 = new Object() {};
- Object unused9 = new Object() {};
+ Object o1 = new Object() {};
+ Object o2 = new Object() {};
+ Object o3 = new Object() {};
+ Object o4 = new Object() {};
+ Object o5 = new Object() {};
+ Object o6 = new Object() {};
+ Object o7 = new Object() {};
+ Object o8 = new Object() {};
+ Object o9 = new Object() {};
Object o10 = new Object() {};
String toTest = MoreObjects.toStringHelper(o10).toString();
assertTrue(toTest, toTest.matches(".*\\{\\}"));
@@ -357,7 +357,7 @@
}
@GwtIncompatible // Class names are obfuscated in GWT
- public void testToStringOmitEmptyValues_oneValue() {
+ public void testToStringOmitNullValues_oneValue() {
String toTest =
MoreObjects.toStringHelper(new TestClass()).omitNullValues().addValue(null).toString();
assertEquals("TestClass{}", toTest);
diff --git a/android/guava-tests/test/com/google/common/base/VerifyTest.java b/android/guava-tests/test/com/google/common/base/VerifyTest.java
index 37c6efc..03d2c2f 100644
--- a/android/guava-tests/test/com/google/common/base/VerifyTest.java
+++ b/android/guava-tests/test/com/google/common/base/VerifyTest.java
@@ -19,12 +19,11 @@
import static com.google.common.truth.Truth.assertThat;
import com.google.common.annotations.GwtCompatible;
-import com.google.common.annotations.GwtIncompatible;
import junit.framework.AssertionFailedError;
import junit.framework.TestCase;
/** Unit test for {@link com.google.common.base.Verify}. */
-@GwtCompatible(emulated = true)
+@GwtCompatible
public class VerifyTest extends TestCase {
public void testVerify_simple_success() {
verify(true);
@@ -93,11 +92,6 @@
}
}
- @GwtIncompatible // NullPointerTester
- public void testNullPointers() {
- // Don't bother testing: Verify is like Preconditions. See the discussion on that class.
- }
-
private static final Object IGNORE_ME =
new Object() {
@Override
diff --git a/android/guava-tests/test/com/google/common/cache/CacheBuilderSpecTest.java b/android/guava-tests/test/com/google/common/cache/CacheBuilderSpecTest.java
index 09f2eb6..ba2e08e 100644
--- a/android/guava-tests/test/com/google/common/cache/CacheBuilderSpecTest.java
+++ b/android/guava-tests/test/com/google/common/cache/CacheBuilderSpecTest.java
@@ -468,13 +468,11 @@
.testEquals();
}
- @SuppressWarnings("ReturnValueIgnored")
public void testMaximumWeight_withWeigher() {
CacheBuilder<Object, Object> builder = CacheBuilder.from(parse("maximumWeight=9000"));
builder.weigher(constantWeigher(42)).build(CacheLoader.from(Suppliers.ofInstance(null)));
}
- @SuppressWarnings("ReturnValueIgnored")
public void testMaximumWeight_withoutWeigher() {
CacheBuilder<Object, Object> builder = CacheBuilder.from(parse("maximumWeight=9000"));
try {
@@ -484,13 +482,11 @@
}
}
- @SuppressWarnings("ReturnValueIgnored")
public void testMaximumSize_withWeigher() {
CacheBuilder<Object, Object> builder = CacheBuilder.from(parse("maximumSize=9000"));
builder.weigher(constantWeigher(42)).build(CacheLoader.from(Suppliers.ofInstance(null)));
}
- @SuppressWarnings("ReturnValueIgnored")
public void testMaximumSize_withoutWeigher() {
CacheBuilder<Object, Object> builder = CacheBuilder.from(parse("maximumSize=9000"));
builder.build(CacheLoader.from(Suppliers.ofInstance(null)));
diff --git a/android/guava-tests/test/com/google/common/cache/CacheBuilderTest.java b/android/guava-tests/test/com/google/common/cache/CacheBuilderTest.java
index 1a9faee..f97f0be 100644
--- a/android/guava-tests/test/com/google/common/cache/CacheBuilderTest.java
+++ b/android/guava-tests/test/com/google/common/cache/CacheBuilderTest.java
@@ -285,7 +285,6 @@
}
}
- @SuppressWarnings("ReturnValueIgnored")
public void testTimeToLive_small() {
CacheBuilder.newBuilder().expireAfterWrite(1, NANOSECONDS).build(identityLoader());
// well, it didn't blow up.
@@ -311,7 +310,6 @@
}
}
- @SuppressWarnings("ReturnValueIgnored")
public void testTimeToIdle_small() {
CacheBuilder.newBuilder().expireAfterAccess(1, NANOSECONDS).build(identityLoader());
// well, it didn't blow up.
@@ -328,7 +326,6 @@
}
}
- @SuppressWarnings("ReturnValueIgnored")
public void testTimeToIdleAndToLive() {
CacheBuilder.newBuilder()
.expireAfterWrite(1, NANOSECONDS)
@@ -503,7 +500,7 @@
final CountDownLatch tasksFinished = new CountDownLatch(nTasks);
for (int i = 0; i < nTasks; i++) {
final String s = "a" + i;
- @SuppressWarnings("unused") // https://errorprone.info/bugpattern/FutureReturnValueIgnored
+ @SuppressWarnings("unused") // go/futurereturn-lsc
Future<?> possiblyIgnoredError =
threadPool.submit(
new Runnable() {
@@ -598,7 +595,7 @@
ExecutorService threadPool = Executors.newFixedThreadPool(nThreads);
for (int i = 0; i < nTasks; i++) {
- @SuppressWarnings("unused") // https://errorprone.info/bugpattern/FutureReturnValueIgnored
+ @SuppressWarnings("unused") // go/futurereturn-lsc
Future<?> possiblyIgnoredError =
threadPool.submit(
new Runnable() {
diff --git a/android/guava-tests/test/com/google/common/cache/CacheLoaderTest.java b/android/guava-tests/test/com/google/common/cache/CacheLoaderTest.java
index e078ddd..6147ff2 100644
--- a/android/guava-tests/test/com/google/common/cache/CacheLoaderTest.java
+++ b/android/guava-tests/test/com/google/common/cache/CacheLoaderTest.java
@@ -18,10 +18,10 @@
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.Queues;
+import com.google.common.collect.Lists;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
-import java.util.Deque;
+import java.util.LinkedList;
import java.util.Map;
import java.util.concurrent.Executor;
import java.util.concurrent.Future;
@@ -36,7 +36,7 @@
public class CacheLoaderTest extends TestCase {
private static class QueuingExecutor implements Executor {
- private final Deque<Runnable> tasks = Queues.newArrayDeque();
+ private LinkedList<Runnable> tasks = Lists.newLinkedList();
@Override
public void execute(Runnable task) {
@@ -79,7 +79,7 @@
assertEquals(0, loadAllCount.get());
baseLoader.load(new Object());
- @SuppressWarnings("unused") // https://errorprone.info/bugpattern/FutureReturnValueIgnored
+ @SuppressWarnings("unused") // go/futurereturn-lsc
Future<?> possiblyIgnoredError = baseLoader.reload(new Object(), new Object());
baseLoader.loadAll(ImmutableList.of(new Object()));
assertEquals(1, loadCount.get());
@@ -90,7 +90,7 @@
CacheLoader<Object, Object> asyncReloader = CacheLoader.asyncReloading(baseLoader, executor);
asyncReloader.load(new Object());
- @SuppressWarnings("unused") // https://errorprone.info/bugpattern/FutureReturnValueIgnored
+ @SuppressWarnings("unused") // go/futurereturn-lsc
Future<?> possiblyIgnoredError1 = asyncReloader.reload(new Object(), new Object());
asyncReloader.loadAll(ImmutableList.of(new Object()));
assertEquals(2, loadCount.get());
diff --git a/android/guava-tests/test/com/google/common/cache/CacheLoadingTest.java b/android/guava-tests/test/com/google/common/cache/CacheLoadingTest.java
index f5ea546..ba3e7e9 100644
--- a/android/guava-tests/test/com/google/common/cache/CacheLoadingTest.java
+++ b/android/guava-tests/test/com/google/common/cache/CacheLoadingTest.java
@@ -1766,7 +1766,6 @@
assertEquals(0, removalListener.getCount());
}
-
public void testReloadAfterValueReclamation() throws InterruptedException, ExecutionException {
CountingLoader countingLoader = new CountingLoader();
LoadingCache<Object, Object> cache =
@@ -1941,7 +1940,6 @@
}
}
-
public void testConcurrentLoading() throws InterruptedException {
testConcurrentLoading(CacheBuilder.newBuilder());
}
@@ -1954,7 +1952,6 @@
testConcurrentLoadingCheckedException(builder);
}
-
public void testConcurrentExpirationLoading() throws InterruptedException {
testConcurrentLoading(CacheBuilder.newBuilder().expireAfterWrite(10, TimeUnit.SECONDS));
}
@@ -2184,7 +2181,6 @@
return resultList;
}
-
public void testAsMapDuringLoading() throws InterruptedException, ExecutionException {
final CountDownLatch getStartedSignal = new CountDownLatch(2);
final CountDownLatch letGetFinishSignal = new CountDownLatch(1);
@@ -2243,7 +2239,6 @@
assertEquals(refreshKey + suffix, map.get(refreshKey));
}
-
public void testInvalidateDuringLoading() throws InterruptedException, ExecutionException {
// computation starts; invalidate() is called on the key being computed, computation finishes
final CountDownLatch computationStarted = new CountDownLatch(2);
@@ -2300,7 +2295,6 @@
assertEquals(2, cache.size());
}
-
public void testInvalidateAndReloadDuringLoading()
throws InterruptedException, ExecutionException {
// computation starts; clear() is called, computation finishes
@@ -2373,7 +2367,6 @@
assertEquals(refreshKey + suffix, map.get(refreshKey));
}
-
public void testExpandDuringLoading() throws InterruptedException {
final int count = 3;
final AtomicInteger callCount = new AtomicInteger();
diff --git a/android/guava-tests/test/com/google/common/cache/EmptyCachesTest.java b/android/guava-tests/test/com/google/common/cache/EmptyCachesTest.java
index a5e3a59..a56c280 100644
--- a/android/guava-tests/test/com/google/common/cache/EmptyCachesTest.java
+++ b/android/guava-tests/test/com/google/common/cache/EmptyCachesTest.java
@@ -47,7 +47,6 @@
}
}
-
public void testInvalidate_empty() {
for (LoadingCache<Object, Object> cache : caches()) {
cache.getUnchecked("a");
@@ -69,7 +68,6 @@
}
}
-
public void testEquals_null() {
for (LoadingCache<Object, Object> cache : caches()) {
assertFalse(cache.equals(null));
@@ -139,7 +137,6 @@
}
}
-
public void testKeySet_clear() {
for (LoadingCache<Object, Object> cache : caches()) {
warmUp(cache, 0, 100);
@@ -214,7 +211,6 @@
}
}
-
public void testValues_clear() {
for (LoadingCache<Object, Object> cache : caches()) {
warmUp(cache, 0, 100);
@@ -289,7 +285,6 @@
}
}
-
public void testEntrySet_clear() {
for (LoadingCache<Object, Object> cache : caches()) {
warmUp(cache, 0, 100);
diff --git a/android/guava-tests/test/com/google/common/cache/ForwardingLoadingCacheTest.java b/android/guava-tests/test/com/google/common/cache/ForwardingLoadingCacheTest.java
index d78db2d..c5681d2 100644
--- a/android/guava-tests/test/com/google/common/cache/ForwardingLoadingCacheTest.java
+++ b/android/guava-tests/test/com/google/common/cache/ForwardingLoadingCacheTest.java
@@ -90,7 +90,7 @@
public void testSize() {
when(mock.size()).thenReturn(0L);
- long unused = forward.size();
+ forward.size();
}
public void testStats() {
diff --git a/android/guava-tests/test/com/google/common/cache/LocalCacheTest.java b/android/guava-tests/test/com/google/common/cache/LocalCacheTest.java
index 3c4529c..667ea93 100644
--- a/android/guava-tests/test/com/google/common/cache/LocalCacheTest.java
+++ b/android/guava-tests/test/com/google/common/cache/LocalCacheTest.java
@@ -97,7 +97,6 @@
}
}
-
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTestSuite(LocalCacheTest.class);
@@ -701,7 +700,6 @@
assertEquals(1, map.size());
}
-
public void testCopyEntry_computing() {
final CountDownLatch startSignal = new CountDownLatch(1);
final CountDownLatch computingSignal = new CountDownLatch(1);
@@ -803,7 +801,6 @@
checkLogged(e);
}
-
public void testRemovalListener_replaced_computing() {
final CountDownLatch startSignal = new CountDownLatch(1);
final CountDownLatch computingSignal = new CountDownLatch(1);
diff --git a/android/guava-tests/test/com/google/common/cache/LocalLoadingCacheTest.java b/android/guava-tests/test/com/google/common/cache/LocalLoadingCacheTest.java
index 8ba9dbc..6b73bdc 100644
--- a/android/guava-tests/test/com/google/common/cache/LocalLoadingCacheTest.java
+++ b/android/guava-tests/test/com/google/common/cache/LocalLoadingCacheTest.java
@@ -157,7 +157,7 @@
assertThat(map).containsEntry(three, one);
assertThat(map).containsEntry(one, two);
- // TODO(user): Confirm with fry@ that this is a reasonable substitute.
+ // TODO(cgruber): Confirm with fry@ that this is a reasonable substitute.
// Set<Entry<Object, Object>> entries = map.entrySet();
// assertThat(entries).containsExactly(
// Maps.immutableEntry(three, one), Maps.immutableEntry(one, two));
@@ -293,7 +293,6 @@
assertFalse(segment.recencyQueue.isEmpty());
}
-
public void testRecursiveComputation() throws InterruptedException {
final AtomicReference<LoadingCache<Integer, String>> cacheRef = new AtomicReference<>();
CacheLoader<Integer, String> recursiveLoader =
diff --git a/android/guava-tests/test/com/google/common/cache/PopulatedCachesTest.java b/android/guava-tests/test/com/google/common/cache/PopulatedCachesTest.java
index b02b8ac..1e71b63 100644
--- a/android/guava-tests/test/com/google/common/cache/PopulatedCachesTest.java
+++ b/android/guava-tests/test/com/google/common/cache/PopulatedCachesTest.java
@@ -187,7 +187,6 @@
}
}
-
public void testKeySet_populated() {
for (LoadingCache<Object, Object> cache : caches()) {
Set<Object> keys = cache.asMap().keySet();
@@ -238,7 +237,6 @@
}
}
-
public void testEntrySet_populated() {
for (LoadingCache<Object, Object> cache : caches()) {
Set<Entry<Object, Object>> entries = cache.asMap().entrySet();
diff --git a/android/guava-tests/test/com/google/common/collect/AbstractIteratorTest.java b/android/guava-tests/test/com/google/common/collect/AbstractIteratorTest.java
index 3592210..4cb9d1b 100644
--- a/android/guava-tests/test/com/google/common/collect/AbstractIteratorTest.java
+++ b/android/guava-tests/test/com/google/common/collect/AbstractIteratorTest.java
@@ -137,7 +137,6 @@
}
}
-
@GwtIncompatible // weak references
public void testFreesNextReference() {
Iterator<Object> itr =
diff --git a/android/guava-tests/test/com/google/common/collect/DiscreteDomainTest.java b/android/guava-tests/test/com/google/common/collect/DiscreteDomainTest.java
index b9e15fd..5de3f8d 100644
--- a/android/guava-tests/test/com/google/common/collect/DiscreteDomainTest.java
+++ b/android/guava-tests/test/com/google/common/collect/DiscreteDomainTest.java
@@ -87,48 +87,4 @@
} catch (IllegalArgumentException expected) {
}
}
-
- public void testCustomOffsetExceptions() {
- try {
- new MyIntegerDomain().offset(0, -1);
- fail();
- } catch (IllegalArgumentException expected) {
- }
- try {
- new MyIntegerDomain().offset(Integer.MAX_VALUE, 1);
- fail();
- } catch (IllegalArgumentException expected) {
- }
- }
-
- private static final class MyIntegerDomain extends DiscreteDomain<Integer> {
- static final DiscreteDomain<Integer> DELEGATE = DiscreteDomain.integers();
-
- @Override
- public Integer next(Integer value) {
- return DELEGATE.next(value);
- }
-
- @Override
- public Integer previous(Integer value) {
- return DELEGATE.previous(value);
- }
-
- // Do *not* override offset() to delegate: We want to test the default implementation.
-
- @Override
- public long distance(Integer start, Integer end) {
- return DELEGATE.distance(start, end);
- }
-
- @Override
- public Integer minValue() {
- return DELEGATE.minValue();
- }
-
- @Override
- public Integer maxValue() {
- return DELEGATE.maxValue();
- }
- }
}
diff --git a/android/guava-tests/test/com/google/common/collect/ImmutableBiMapTest.java b/android/guava-tests/test/com/google/common/collect/ImmutableBiMapTest.java
index e0dd1ef..cb23f3e 100644
--- a/android/guava-tests/test/com/google/common/collect/ImmutableBiMapTest.java
+++ b/android/guava-tests/test/com/google/common/collect/ImmutableBiMapTest.java
@@ -32,7 +32,6 @@
import com.google.common.collect.testing.google.BiMapInverseTester;
import com.google.common.collect.testing.google.BiMapTestSuiteBuilder;
import com.google.common.testing.SerializableTester;
-import java.util.AbstractMap;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.Map;
@@ -396,136 +395,6 @@
"four",
5,
"five");
- assertMapEquals(
- ImmutableBiMap.of(
- "one", 1,
- "two", 2,
- "three", 3,
- "four", 4,
- "five", 5,
- "six", 6),
- "one",
- 1,
- "two",
- 2,
- "three",
- 3,
- "four",
- 4,
- "five",
- 5,
- "six",
- 6);
- assertMapEquals(
- ImmutableBiMap.of(
- "one", 1,
- "two", 2,
- "three", 3,
- "four", 4,
- "five", 5,
- "six", 6,
- "seven", 7),
- "one",
- 1,
- "two",
- 2,
- "three",
- 3,
- "four",
- 4,
- "five",
- 5,
- "six",
- 6,
- "seven",
- 7);
- assertMapEquals(
- ImmutableBiMap.of(
- "one", 1,
- "two", 2,
- "three", 3,
- "four", 4,
- "five", 5,
- "six", 6,
- "seven", 7,
- "eight", 8),
- "one",
- 1,
- "two",
- 2,
- "three",
- 3,
- "four",
- 4,
- "five",
- 5,
- "six",
- 6,
- "seven",
- 7,
- "eight",
- 8);
- assertMapEquals(
- ImmutableBiMap.of(
- "one", 1,
- "two", 2,
- "three", 3,
- "four", 4,
- "five", 5,
- "six", 6,
- "seven", 7,
- "eight", 8,
- "nine", 9),
- "one",
- 1,
- "two",
- 2,
- "three",
- 3,
- "four",
- 4,
- "five",
- 5,
- "six",
- 6,
- "seven",
- 7,
- "eight",
- 8,
- "nine",
- 9);
- assertMapEquals(
- ImmutableBiMap.of(
- "one", 1,
- "two", 2,
- "three", 3,
- "four", 4,
- "five", 5,
- "six", 6,
- "seven", 7,
- "eight", 8,
- "nine", 9,
- "ten", 10),
- "one",
- 1,
- "two",
- 2,
- "three",
- 3,
- "four",
- 4,
- "five",
- 5,
- "six",
- 6,
- "seven",
- 7,
- "eight",
- 8,
- "nine",
- 9,
- "ten",
- 10);
}
public void testOfNullKey() {
@@ -565,30 +434,6 @@
}
}
- public void testOfEntries() {
- assertMapEquals(
- ImmutableBiMap.ofEntries(entry("one", 1), entry("two", 2)), "one", 1, "two", 2);
- }
-
- public void testOfEntriesNull() {
- Entry<Integer, Integer> nullKey = entry(null, 23);
- try {
- ImmutableBiMap.ofEntries(nullKey);
- fail();
- } catch (NullPointerException expected) {
- }
- Entry<Integer, Integer> nullValue = entry(23, null);
- try {
- ImmutableBiMap.ofEntries(nullValue);
- fail();
- } catch (NullPointerException expected) {
- }
- }
-
- private static <T> Entry<T, T> entry(T key, T value) {
- return new AbstractMap.SimpleImmutableEntry<>(key, value);
- }
-
public void testCopyOfEmptyMap() {
ImmutableBiMap<String, Integer> copy =
ImmutableBiMap.copyOf(Collections.<String, Integer>emptyMap());
@@ -661,30 +506,6 @@
assertThat(expected.getMessage()).contains("1");
}
}
-
- // TODO(b/172823566): Use mainline testToImmutableBiMap once CollectorTester is usable to java7.
- public void testToImmutableBiMap_java7_combine() {
- ImmutableBiMap.Builder<String, Integer> zis =
- ImmutableBiMap.<String, Integer>builder().put("one", 1);
- ImmutableBiMap.Builder<String, Integer> zat =
- ImmutableBiMap.<String, Integer>builder().put("two", 2).put("three", 3);
- ImmutableBiMap<String, Integer> biMap = zis.combine(zat).build();
- assertMapEquals(biMap, "one", 1, "two", 2, "three", 3);
- }
-
- // TODO(b/172823566): Use mainline testToImmutableBiMap once CollectorTester is usable to java7.
- public void testToImmutableBiMap_exceptionOnDuplicateKey_java7_combine() {
- ImmutableBiMap.Builder<String, Integer> zis =
- ImmutableBiMap.<String, Integer>builder().put("one", 1).put("two", 2);
- ImmutableBiMap.Builder<String, Integer> zat =
- ImmutableBiMap.<String, Integer>builder().put("two", 22).put("three", 3);
- try {
- zis.combine(zat).build();
- fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
- // expected
- }
- }
}
public static class BiMapSpecificTests extends TestCase {
diff --git a/android/guava-tests/test/com/google/common/collect/ImmutableListMultimapTest.java b/android/guava-tests/test/com/google/common/collect/ImmutableListMultimapTest.java
index 1260740..f073163 100644
--- a/android/guava-tests/test/com/google/common/collect/ImmutableListMultimapTest.java
+++ b/android/guava-tests/test/com/google/common/collect/ImmutableListMultimapTest.java
@@ -29,7 +29,6 @@
import com.google.common.collect.testing.google.TestStringListMultimapGenerator;
import com.google.common.collect.testing.google.UnmodifiableCollectionTests;
import com.google.common.testing.EqualsTester;
-import com.google.common.testing.NullPointerTester;
import com.google.common.testing.SerializableTester;
import java.util.Arrays;
import java.util.Collection;
@@ -388,20 +387,6 @@
}
}
- // TODO(b/172823566): Use mainline testToImmutableListMultimap once CollectorTester is usable.
- public void testToImmutableListMultimap_java7_combine() {
- ImmutableListMultimap.Builder<String, Integer> zis =
- ImmutableListMultimap.<String, Integer>builder().put("a", 1).put("b", 2);
- ImmutableListMultimap.Builder<String, Integer> zat =
- ImmutableListMultimap.<String, Integer>builder().put("a", 3).put("c", 4);
- ImmutableListMultimap<String, Integer> multimap = zis.combine(zat).build();
- assertThat(multimap.keySet()).containsExactly("a", "b", "c").inOrder();
- assertThat(multimap.values()).containsExactly(1, 3, 2, 4).inOrder();
- assertThat(multimap.get("a")).containsExactly(1, 3).inOrder();
- assertThat(multimap.get("b")).containsExactly(2);
- assertThat(multimap.get("c")).containsExactly(4);
- }
-
public void testEmptyMultimapReads() {
Multimap<String, Integer> multimap = ImmutableListMultimap.of();
assertFalse(multimap.containsKey("foo"));
@@ -572,13 +557,4 @@
Multimap<String, Integer> multimap = ImmutableListMultimap.of();
assertSame(multimap, SerializableTester.reserialize(multimap));
}
-
- @GwtIncompatible // reflection
- public void testNulls() throws Exception {
- NullPointerTester tester = new NullPointerTester();
- tester.testAllPublicStaticMethods(ImmutableListMultimap.class);
- tester.ignore(ImmutableListMultimap.class.getMethod("get", Object.class));
- tester.testAllPublicInstanceMethods(ImmutableListMultimap.of());
- tester.testAllPublicInstanceMethods(ImmutableListMultimap.of("a", 1));
- }
}
diff --git a/android/guava-tests/test/com/google/common/collect/ImmutableListTest.java b/android/guava-tests/test/com/google/common/collect/ImmutableListTest.java
index 52ed7fa..1688bad 100644
--- a/android/guava-tests/test/com/google/common/collect/ImmutableListTest.java
+++ b/android/guava-tests/test/com/google/common/collect/ImmutableListTest.java
@@ -459,14 +459,6 @@
} catch (NullPointerException expected) {
}
}
-
- // TODO(b/172823566): Use mainline testToImmutableList once CollectorTester is usable to java7.
- public void testToImmutableList_java7_combine() {
- ImmutableList.Builder<String> zis = ImmutableList.<String>builder().add("a", "b");
- ImmutableList.Builder<String> zat = ImmutableList.<String>builder().add("c", "d");
- ImmutableList<String> list = zis.combine(zat).build();
- assertEquals(asList("a", "b", "c", "d"), list);
- }
}
@GwtIncompatible // reflection
diff --git a/android/guava-tests/test/com/google/common/collect/ImmutableMapTest.java b/android/guava-tests/test/com/google/common/collect/ImmutableMapTest.java
index f4da971..2cf43ef 100644
--- a/android/guava-tests/test/com/google/common/collect/ImmutableMapTest.java
+++ b/android/guava-tests/test/com/google/common/collect/ImmutableMapTest.java
@@ -18,7 +18,6 @@
import static com.google.common.testing.SerializableTester.reserialize;
import static com.google.common.truth.Truth.assertThat;
-import static com.google.common.truth.Truth.assertWithMessage;
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.GwtIncompatible;
@@ -50,7 +49,6 @@
import java.io.ByteArrayOutputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
-import java.util.AbstractMap;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedHashMap;
@@ -592,136 +590,6 @@
4,
"five",
5);
- assertMapEquals(
- ImmutableMap.of(
- "one", 1,
- "two", 2,
- "three", 3,
- "four", 4,
- "five", 5,
- "six", 6),
- "one",
- 1,
- "two",
- 2,
- "three",
- 3,
- "four",
- 4,
- "five",
- 5,
- "six",
- 6);
- assertMapEquals(
- ImmutableMap.of(
- "one", 1,
- "two", 2,
- "three", 3,
- "four", 4,
- "five", 5,
- "six", 6,
- "seven", 7),
- "one",
- 1,
- "two",
- 2,
- "three",
- 3,
- "four",
- 4,
- "five",
- 5,
- "six",
- 6,
- "seven",
- 7);
- assertMapEquals(
- ImmutableMap.of(
- "one", 1,
- "two", 2,
- "three", 3,
- "four", 4,
- "five", 5,
- "six", 6,
- "seven", 7,
- "eight", 8),
- "one",
- 1,
- "two",
- 2,
- "three",
- 3,
- "four",
- 4,
- "five",
- 5,
- "six",
- 6,
- "seven",
- 7,
- "eight",
- 8);
- assertMapEquals(
- ImmutableMap.of(
- "one", 1,
- "two", 2,
- "three", 3,
- "four", 4,
- "five", 5,
- "six", 6,
- "seven", 7,
- "eight", 8,
- "nine", 9),
- "one",
- 1,
- "two",
- 2,
- "three",
- 3,
- "four",
- 4,
- "five",
- 5,
- "six",
- 6,
- "seven",
- 7,
- "eight",
- 8,
- "nine",
- 9);
- assertMapEquals(
- ImmutableMap.of(
- "one", 1,
- "two", 2,
- "three", 3,
- "four", 4,
- "five", 5,
- "six", 6,
- "seven", 7,
- "eight", 8,
- "nine", 9,
- "ten", 10),
- "one",
- 1,
- "two",
- 2,
- "three",
- 3,
- "four",
- 4,
- "five",
- 5,
- "six",
- 6,
- "seven",
- 7,
- "eight",
- 8,
- "nine",
- 9,
- "ten",
- 10);
}
public void testOfNullKey() {
@@ -784,29 +652,6 @@
assertSame(copy, ImmutableMap.copyOf(copy));
}
- // TODO(b/172823566): Use mainline testToImmutableMap once CollectorTester is usable to java7.
- public void testToImmutableMap_java7_combine() {
- ImmutableMap.Builder<String, Integer> zis =
- ImmutableMap.<String, Integer>builder().put("one", 1);
- ImmutableMap.Builder<String, Integer> zat =
- ImmutableMap.<String, Integer>builder().put("two", 2).put("three", 3);
- assertMapEquals(zis.combine(zat).build(), "one", 1, "two", 2, "three", 3);
- }
-
- // TODO(b/172823566): Use mainline testToImmutableMap once CollectorTester is usable to java7.
- public void testToImmutableMap_exceptionOnDuplicateKey_java7_combine() {
- ImmutableMap.Builder<String, Integer> zis =
- ImmutableMap.<String, Integer>builder().put("one", 1).put("two", 2);
- ImmutableMap.Builder<String, Integer> zat =
- ImmutableMap.<String, Integer>builder().put("two", 22).put("three", 3);
- try {
- zis.combine(zat).build();
- fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
- // expected
- }
- }
-
public static void hashtableTestHelper(ImmutableList<Integer> sizes) {
for (int size : sizes) {
Builder<Integer, Integer> builder = ImmutableMap.builderWithExpectedSize(size);
@@ -981,84 +826,15 @@
public void testEquals() {
new EqualsTester()
- .addEqualityGroup(
- ImmutableMap.of(), ImmutableMap.builder().build(), ImmutableMap.ofEntries(), map())
- .addEqualityGroup(
- ImmutableMap.of(1, 1),
- ImmutableMap.builder().put(1, 1).build(),
- ImmutableMap.ofEntries(entry(1, 1)),
- map(1, 1))
- .addEqualityGroup(
- ImmutableMap.of(1, 1, 2, 2),
- ImmutableMap.builder().put(1, 1).put(2, 2).build(),
- ImmutableMap.ofEntries(entry(1, 1), entry(2, 2)),
- map(1, 1, 2, 2))
- .addEqualityGroup(
- ImmutableMap.of(1, 1, 2, 2, 3, 3),
- ImmutableMap.builder().put(1, 1).put(2, 2).put(3, 3).build(),
- ImmutableMap.ofEntries(entry(1, 1), entry(2, 2), entry(3, 3)),
- map(1, 1, 2, 2, 3, 3))
- .addEqualityGroup(
- ImmutableMap.of(1, 4, 2, 2, 3, 3),
- ImmutableMap.builder().put(1, 4).put(2, 2).put(3, 3).build(),
- ImmutableMap.ofEntries(entry(1, 4), entry(2, 2), entry(3, 3)),
- map(1, 4, 2, 2, 3, 3))
- .addEqualityGroup(
- ImmutableMap.of(1, 1, 2, 4, 3, 3),
- ImmutableMap.builder().put(1, 1).put(2, 4).put(3, 3).build(),
- ImmutableMap.ofEntries(entry(1, 1), entry(2, 4), entry(3, 3)),
- map(1, 1, 2, 4, 3, 3))
- .addEqualityGroup(
- ImmutableMap.of(1, 1, 2, 2, 3, 4),
- ImmutableMap.builder().put(1, 1).put(2, 2).put(3, 4).build(),
- ImmutableMap.ofEntries(entry(1, 1), entry(2, 2), entry(3, 4)),
- map(1, 1, 2, 2, 3, 4))
- .addEqualityGroup(
- ImmutableMap.of(1, 2, 2, 3, 3, 1),
- ImmutableMap.builder().put(1, 2).put(2, 3).put(3, 1).build(),
- ImmutableMap.ofEntries(entry(1, 2), entry(2, 3), entry(3, 1)),
- map(1, 2, 2, 3, 3, 1))
- .addEqualityGroup(
- ImmutableMap.of(1, 1, 2, 2, 3, 3, 4, 4),
- ImmutableMap.builder().put(1, 1).put(2, 2).put(3, 3).put(4, 4).build(),
- ImmutableMap.ofEntries(entry(1, 1), entry(2, 2), entry(3, 3), entry(4, 4)),
- map(1, 1, 2, 2, 3, 3, 4, 4))
- .addEqualityGroup(
- ImmutableMap.of(1, 1, 2, 2, 3, 3, 4, 4, 5, 5),
- ImmutableMap.builder().put(1, 1).put(2, 2).put(3, 3).put(4, 4).put(5, 5).build(),
- ImmutableMap.ofEntries(entry(1, 1), entry(2, 2), entry(3, 3), entry(4, 4), entry(5, 5)),
- map(1, 1, 2, 2, 3, 3, 4, 4, 5, 5))
+ .addEqualityGroup(ImmutableMap.of(), ImmutableMap.builder().build())
+ .addEqualityGroup(ImmutableMap.of(1, 1), ImmutableMap.builder().put(1, 1).build())
+ .addEqualityGroup(ImmutableMap.of(1, 1, 2, 2))
+ .addEqualityGroup(ImmutableMap.of(1, 1, 2, 2, 3, 3))
+ .addEqualityGroup(ImmutableMap.of(1, 4, 2, 2, 3, 3))
+ .addEqualityGroup(ImmutableMap.of(1, 1, 2, 4, 3, 3))
+ .addEqualityGroup(ImmutableMap.of(1, 1, 2, 2, 3, 4))
+ .addEqualityGroup(ImmutableMap.of(1, 2, 2, 3, 3, 1))
+ .addEqualityGroup(ImmutableMap.of(1, 1, 2, 2, 3, 3, 4, 4))
.testEquals();
}
-
- public void testOfEntriesNull() {
- Entry<Integer, Integer> nullKey = entry(null, 23);
- try {
- ImmutableMap.ofEntries(nullKey);
- fail();
- } catch (NullPointerException expected) {
- }
- Entry<Integer, Integer> nullValue = entry(23, null);
- try {
- ImmutableMap.ofEntries(nullValue);
- fail();
- } catch (NullPointerException expected) {
- }
- }
-
- private static <T> Map<T, T> map(T... keysAndValues) {
- assertThat(keysAndValues.length % 2).isEqualTo(0);
- LinkedHashMap<T, T> map = new LinkedHashMap<>();
- for (int i = 0; i < keysAndValues.length; i += 2) {
- T key = keysAndValues[i];
- T value = keysAndValues[i + 1];
- T old = map.put(key, value);
- assertWithMessage("Key %s set to %s and %s", key, value, old).that(old).isNull();
- }
- return map;
- }
-
- private static <T> Entry<T, T> entry(T key, T value) {
- return new AbstractMap.SimpleImmutableEntry<>(key, value);
- }
}
diff --git a/android/guava-tests/test/com/google/common/collect/ImmutableMultimapTest.java b/android/guava-tests/test/com/google/common/collect/ImmutableMultimapTest.java
index ac09593..5263258 100644
--- a/android/guava-tests/test/com/google/common/collect/ImmutableMultimapTest.java
+++ b/android/guava-tests/test/com/google/common/collect/ImmutableMultimapTest.java
@@ -17,13 +17,11 @@
package com.google.common.collect;
import com.google.common.annotations.GwtCompatible;
-import com.google.common.annotations.GwtIncompatible;
import com.google.common.collect.ImmutableMultimap.Builder;
import com.google.common.collect.testing.SampleElements;
import com.google.common.collect.testing.SampleElements.Unhashables;
import com.google.common.collect.testing.UnhashableObject;
import com.google.common.testing.EqualsTester;
-import com.google.common.testing.NullPointerTester;
import java.util.Arrays;
import java.util.Map.Entry;
import junit.framework.TestCase;
@@ -126,13 +124,4 @@
ImmutableMultimap.of(1, "a", 2, "b"), ImmutableMultimap.of(2, "b", 1, "a"))
.testEquals();
}
-
- @GwtIncompatible // reflection
- public void testNulls() throws Exception {
- NullPointerTester tester = new NullPointerTester();
- tester.testAllPublicStaticMethods(ImmutableMultimap.class);
- tester.ignore(ImmutableListMultimap.class.getMethod("get", Object.class));
- tester.testAllPublicInstanceMethods(ImmutableMultimap.of());
- tester.testAllPublicInstanceMethods(ImmutableMultimap.of("a", 1));
- }
}
diff --git a/android/guava-tests/test/com/google/common/collect/ImmutableRangeMapTest.java b/android/guava-tests/test/com/google/common/collect/ImmutableRangeMapTest.java
index 59f3a1b..9de4309 100644
--- a/android/guava-tests/test/com/google/common/collect/ImmutableRangeMapTest.java
+++ b/android/guava-tests/test/com/google/common/collect/ImmutableRangeMapTest.java
@@ -15,7 +15,6 @@
package com.google.common.collect;
import static com.google.common.collect.BoundType.OPEN;
-import static com.google.common.truth.Truth.assertThat;
import com.google.common.annotations.GwtIncompatible;
import com.google.common.testing.SerializableTester;
@@ -208,7 +207,6 @@
}
}
-
public void testSubRangeMap() {
for (Range<Integer> range1 : RANGES) {
for (Range<Integer> range2 : RANGES) {
@@ -256,21 +254,4 @@
SerializableTester.reserializeAndAssert(nonEmptyRangeMap);
}
-
- // TODO(b/172823566): Use mainline testToImmutableRangeMap once CollectorTester is usable to java7
- public void testToImmutableRangeMap() {
- Range<Integer> rangeOne = Range.closedOpen(1, 5);
- Range<Integer> rangeTwo = Range.openClosed(6, 7);
-
- ImmutableRangeMap.Builder<Integer, Integer> zis =
- ImmutableRangeMap.<Integer, Integer>builder().put(rangeOne, 1);
- ImmutableRangeMap.Builder<Integer, Integer> zat =
- ImmutableRangeMap.<Integer, Integer>builder().put(rangeTwo, 6);
-
- ImmutableRangeMap<Integer, Integer> rangeMap = zis.combine(zat).build();
-
- assertThat(rangeMap.asMapOfRanges().entrySet())
- .containsExactly(Maps.immutableEntry(rangeOne, 1), Maps.immutableEntry(rangeTwo, 6))
- .inOrder();
- }
}
diff --git a/android/guava-tests/test/com/google/common/collect/ImmutableRangeSetTest.java b/android/guava-tests/test/com/google/common/collect/ImmutableRangeSetTest.java
index 5ca1f58..fcb315c 100644
--- a/android/guava-tests/test/com/google/common/collect/ImmutableRangeSetTest.java
+++ b/android/guava-tests/test/com/google/common/collect/ImmutableRangeSetTest.java
@@ -590,23 +590,4 @@
}
}
}
-
- // TODO(b/172823566): Use mainline testToImmutableRangeSet once CollectorTester is usable to java7
- public void testToImmutableRangeSet_java7_combine() {
- Range<Integer> rangeOne = Range.closedOpen(1, 3);
- Range<Integer> rangeTwo = Range.closedOpen(7, 9);
- Range<Integer> rangeThree = Range.closedOpen(4, 5);
- Range<Integer> rangeFour = Range.closedOpen(6, 7);
-
- ImmutableRangeSet.Builder<Integer> zis =
- ImmutableRangeSet.<Integer>builder().add(rangeOne).add(rangeTwo);
- ImmutableRangeSet.Builder<Integer> zat =
- ImmutableRangeSet.<Integer>builder().add(rangeThree).add(rangeFour);
-
- ImmutableRangeSet<Integer> rangeSet = zis.combine(zat).build();
-
- assertThat(rangeSet.asRanges())
- .containsExactly(Range.closedOpen(1, 3), Range.closedOpen(4, 5), Range.closedOpen(6, 9))
- .inOrder();
- }
}
diff --git a/android/guava-tests/test/com/google/common/collect/ImmutableSetMultimapTest.java b/android/guava-tests/test/com/google/common/collect/ImmutableSetMultimapTest.java
index 33d4ec1..a8f626b 100644
--- a/android/guava-tests/test/com/google/common/collect/ImmutableSetMultimapTest.java
+++ b/android/guava-tests/test/com/google/common/collect/ImmutableSetMultimapTest.java
@@ -29,7 +29,6 @@
import com.google.common.collect.testing.google.TestStringSetMultimapGenerator;
import com.google.common.collect.testing.google.UnmodifiableCollectionTests;
import com.google.common.testing.EqualsTester;
-import com.google.common.testing.NullPointerTester;
import com.google.common.testing.SerializableTester;
import java.util.Arrays;
import java.util.Collection;
@@ -401,20 +400,6 @@
}
}
- // TODO(b/172823566): Use mainline testToImmutableSetMultimap once CollectorTester is usable.
- public void testToImmutableSetMultimap_java7_combine() {
- ImmutableSetMultimap.Builder<String, Integer> zis =
- ImmutableSetMultimap.<String, Integer>builder().put("a", 1).put("b", 2);
- ImmutableSetMultimap.Builder<String, Integer> zat =
- ImmutableSetMultimap.<String, Integer>builder().put("a", 3).put("c", 4);
- ImmutableSetMultimap<String, Integer> multimap = zis.combine(zat).build();
- assertThat(multimap.keySet()).containsExactly("a", "b", "c").inOrder();
- assertThat(multimap.values()).containsExactly(1, 3, 2, 4).inOrder();
- assertThat(multimap.get("a")).containsExactly(1, 3).inOrder();
- assertThat(multimap.get("b")).containsExactly(2);
- assertThat(multimap.get("c")).containsExactly(4);
- }
-
public void testEmptyMultimapReads() {
Multimap<String, Integer> multimap = ImmutableSetMultimap.of();
assertFalse(multimap.containsKey("foo"));
@@ -593,13 +578,4 @@
.put("foo", 3)
.build();
}
-
- @GwtIncompatible // reflection
- public void testNulls() throws Exception {
- NullPointerTester tester = new NullPointerTester();
- tester.testAllPublicStaticMethods(ImmutableSetMultimap.class);
- tester.ignore(ImmutableSetMultimap.class.getMethod("get", Object.class));
- tester.testAllPublicInstanceMethods(ImmutableSetMultimap.of());
- tester.testAllPublicInstanceMethods(ImmutableSetMultimap.of("a", 1));
- }
}
diff --git a/android/guava-tests/test/com/google/common/collect/ImmutableSetTest.java b/android/guava-tests/test/com/google/common/collect/ImmutableSetTest.java
index 2ddd1ee..6dc6f22 100644
--- a/android/guava-tests/test/com/google/common/collect/ImmutableSetTest.java
+++ b/android/guava-tests/test/com/google/common/collect/ImmutableSetTest.java
@@ -321,14 +321,6 @@
assertNotSame(sortedSet, copy);
}
- // TODO(b/172823566): Use mainline testToImmutableSet once CollectorTester is usable to java7.
- public void testToImmutableSet_java7() {
- ImmutableSet.Builder<String> zis = ImmutableSet.<String>builder().add("a", "b", "a");
- ImmutableSet.Builder<String> zat = ImmutableSet.<String>builder().add("c", "b", "d", "c");
- ImmutableSet<String> set = zis.combine(zat).build();
- assertThat(set).containsExactly("a", "b", "c", "d").inOrder();
- }
-
@GwtIncompatible // GWT is single threaded
public void testCopyOf_threadSafe() {
verifyThreadSafe();
diff --git a/android/guava-tests/test/com/google/common/collect/ImmutableSortedMapTest.java b/android/guava-tests/test/com/google/common/collect/ImmutableSortedMapTest.java
index 850a8e7..4e3e1de 100644
--- a/android/guava-tests/test/com/google/common/collect/ImmutableSortedMapTest.java
+++ b/android/guava-tests/test/com/google/common/collect/ImmutableSortedMapTest.java
@@ -314,7 +314,6 @@
assertMapEquals(map, "five", 5, "four", 4, "one", 1, "three", 3, "two", 2);
}
- @SuppressWarnings("DoNotCall")
public void testBuilder_orderEntriesByValueFails() {
ImmutableSortedMap.Builder<String, Integer> builder = ImmutableSortedMap.naturalOrder();
try {
@@ -482,136 +481,6 @@
3,
"two",
2);
- assertMapEquals(
- ImmutableSortedMap.of(
- "one", 1,
- "two", 2,
- "three", 3,
- "four", 4,
- "five", 5,
- "six", 6),
- "five",
- 5,
- "four",
- 4,
- "one",
- 1,
- "six",
- 6,
- "three",
- 3,
- "two",
- 2);
- assertMapEquals(
- ImmutableSortedMap.of(
- "one", 1,
- "two", 2,
- "three", 3,
- "four", 4,
- "five", 5,
- "six", 6,
- "seven", 7),
- "five",
- 5,
- "four",
- 4,
- "one",
- 1,
- "seven",
- 7,
- "six",
- 6,
- "three",
- 3,
- "two",
- 2);
- assertMapEquals(
- ImmutableSortedMap.of(
- "one", 1,
- "two", 2,
- "three", 3,
- "four", 4,
- "five", 5,
- "six", 6,
- "seven", 7,
- "eight", 8),
- "eight",
- 8,
- "five",
- 5,
- "four",
- 4,
- "one",
- 1,
- "seven",
- 7,
- "six",
- 6,
- "three",
- 3,
- "two",
- 2);
- assertMapEquals(
- ImmutableSortedMap.of(
- "one", 1,
- "two", 2,
- "three", 3,
- "four", 4,
- "five", 5,
- "six", 6,
- "seven", 7,
- "eight", 8,
- "nine", 9),
- "eight",
- 8,
- "five",
- 5,
- "four",
- 4,
- "nine",
- 9,
- "one",
- 1,
- "seven",
- 7,
- "six",
- 6,
- "three",
- 3,
- "two",
- 2);
- assertMapEquals(
- ImmutableSortedMap.of(
- "one", 1,
- "two", 2,
- "three", 3,
- "four", 4,
- "five", 5,
- "six", 6,
- "seven", 7,
- "eight", 8,
- "nine", 9,
- "ten", 10),
- "eight",
- 8,
- "five",
- 5,
- "four",
- 4,
- "nine",
- 9,
- "one",
- 1,
- "seven",
- 7,
- "six",
- 6,
- "ten",
- 10,
- "three",
- 3,
- "two",
- 2);
}
public void testOfNullKey() {
@@ -798,31 +667,6 @@
assertMapEquals(map, "two", 2, "three", 3, "one", 1, "four", 4, "five", 5);
assertSame(comparator, map.comparator());
}
-
- // TODO(b/172823566): Use mainline testToImmutableSortedMap once CollectorTester is usable.
- public void testToImmutableSortedMap_java7_combine() {
- ImmutableSortedMap.Builder<String, Integer> zis =
- ImmutableSortedMap.<String, Integer>naturalOrder().put("one", 1).put("four", 4);
- ImmutableSortedMap.Builder<String, Integer> zat =
- ImmutableSortedMap.<String, Integer>naturalOrder().put("two", 2).put("three", 3);
- ImmutableSortedMap<String, Integer> sortedMap = zis.combine(zat).build();
- assertMapEquals(sortedMap, "four", 4, "one", 1, "three", 3, "two", 2);
- }
-
- // TODO(b/172823566): Use mainline testToImmutableSortedMap once CollectorTester is usable.
- public void testToImmutableSortedMap_exceptionOnDuplicateKey_java7_combine() {
- ImmutableSortedMap.Builder<String, Integer> zis =
- ImmutableSortedMap.<String, Integer>naturalOrder().put("one", 1).put("two", 2);
- ImmutableSortedMap.Builder<String, Integer> zat =
- ImmutableSortedMap.<String, Integer>naturalOrder().put("two", 22).put("three", 3);
- try {
- ImmutableSortedMap.Builder<String, Integer> combined = zis.combine(zat);
- combined.build();
- fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
- // expected
- }
- }
}
public void testNullGet() {
diff --git a/android/guava-tests/test/com/google/common/collect/ImmutableSortedSetTest.java b/android/guava-tests/test/com/google/common/collect/ImmutableSortedSetTest.java
index ea0e3a8..cf2f5aa 100644
--- a/android/guava-tests/test/com/google/common/collect/ImmutableSortedSetTest.java
+++ b/android/guava-tests/test/com/google/common/collect/ImmutableSortedSetTest.java
@@ -708,30 +708,6 @@
assertSame(STRING_LENGTH, set.comparator());
}
- // TODO(b/172823566): Use mainline testToImmutableSortedSet once CollectorTester is usable.
- public void testToImmutableSortedSet_java7() {
- // Note that a Collector should generally enforce consistent comparator between builders
- ImmutableSortedSet.Builder<String> zis =
- ImmutableSortedSet.<String>naturalOrder().add("c", "b", "c");
- ImmutableSortedSet.Builder<String> zat =
- ImmutableSortedSet.<String>naturalOrder().add("a", "b", "d", "c");
- ImmutableSortedSet<String> sortedSet = zis.combine(zat).build();
- assertThat(sortedSet).containsExactly("a", "b", "c", "d").inOrder();
- }
-
- // TODO(b/172823566): Use mainline testToImmutableSortedSet_customComparator once CollectorTester
- // is usable to java7.
- public void testToImmutableSortedSet_customComparator_java7() {
- // Note that a Collector should generally enforce consistent comparator between builders.
- // So no tests for non-matching comparator shenanigans.
- ImmutableSortedSet.Builder<String> zis =
- ImmutableSortedSet.<String>orderedBy(STRING_LENGTH).add("ccc", "bb", "ccc");
- ImmutableSortedSet.Builder<String> zat =
- ImmutableSortedSet.<String>orderedBy(STRING_LENGTH).add("a", "bb", "dddd", "ccc");
- ImmutableSortedSet<String> sortedSet = zis.combine(zat).build();
- assertThat(sortedSet).containsExactly("a", "bb", "ccc", "dddd").inOrder();
- }
-
public void testEquals_bothDefaultOrdering() {
SortedSet<String> set = of("a", "b", "c");
assertEquals(set, Sets.newTreeSet(asList("a", "b", "c")));
@@ -915,7 +891,7 @@
assertTrue(Iterables.elementsEqual(LegacyComparable.VALUES_BACKWARD, set));
}
- @SuppressWarnings({"deprecation", "static-access", "DoNotCall"})
+ @SuppressWarnings({"deprecation", "static-access"})
public void testBuilderMethod() {
try {
ImmutableSortedSet.builder();
diff --git a/android/guava-tests/test/com/google/common/collect/ImmutableTableTest.java b/android/guava-tests/test/com/google/common/collect/ImmutableTableTest.java
index 9bdc99c..9789f72 100644
--- a/android/guava-tests/test/com/google/common/collect/ImmutableTableTest.java
+++ b/android/guava-tests/test/com/google/common/collect/ImmutableTableTest.java
@@ -38,25 +38,6 @@
return builder.build();
}
- // TODO(b/172823566): Use mainline testToImmutableMap once CollectorTester is usable to java7.
- public void testToImmutableTable_java7_combine() {
- ImmutableTable.Builder<String, String, Integer> zis =
- ImmutableTable.<String, String, Integer>builder().put("one", "uno", 1).put("two", "dos", 2);
- ImmutableTable.Builder<String, String, Integer> zat =
- ImmutableTable.<String, String, Integer>builder()
- .put("one", "eins", 1)
- .put("two", "twei", 2);
- ImmutableTable<String, String, Integer> table = zis.combine(zat).build();
- ImmutableTable<String, String, Integer> expected =
- ImmutableTable.<String, String, Integer>builder()
- .put("one", "uno", 1)
- .put("two", "dos", 2)
- .put("one", "eins", 1)
- .put("two", "twei", 2)
- .build();
- assertThat(table).isEqualTo(expected);
- }
-
public void testBuilder() {
ImmutableTable.Builder<Character, Integer, String> builder = new ImmutableTable.Builder<>();
assertEquals(ImmutableTable.of(), builder.build());
diff --git a/android/guava-tests/test/com/google/common/collect/InternersTest.java b/android/guava-tests/test/com/google/common/collect/InternersTest.java
index cfa14b8..08bdc53 100644
--- a/android/guava-tests/test/com/google/common/collect/InternersTest.java
+++ b/android/guava-tests/test/com/google/common/collect/InternersTest.java
@@ -84,7 +84,6 @@
assertEquals(concurrencyLevel, internerImpl.map.concurrencyLevel);
}
-
public void testWeak_afterGC() throws InterruptedException {
Integer canonical = new Integer(5);
Integer not = new Integer(5);
diff --git a/android/guava-tests/test/com/google/common/collect/LinkedListMultimapTest.java b/android/guava-tests/test/com/google/common/collect/LinkedListMultimapTest.java
index b0d48f0..d57d5c0 100644
--- a/android/guava-tests/test/com/google/common/collect/LinkedListMultimapTest.java
+++ b/android/guava-tests/test/com/google/common/collect/LinkedListMultimapTest.java
@@ -35,7 +35,6 @@
import com.google.common.collect.testing.google.ListMultimapTestSuiteBuilder;
import com.google.common.collect.testing.google.TestStringListMultimapGenerator;
import com.google.common.testing.EqualsTester;
-import com.google.common.testing.NullPointerTester;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
@@ -497,13 +496,4 @@
LinkedListMultimap.create(), LinkedListMultimap.create(), LinkedListMultimap.create(1))
.testEquals();
}
-
- @GwtIncompatible // reflection
- public void testNulls() throws Exception {
- NullPointerTester tester = new NullPointerTester();
- tester.testAllPublicStaticMethods(LinkedListMultimap.class);
- tester.ignore(LinkedListMultimap.class.getMethod("get", Object.class));
- tester.ignore(LinkedListMultimap.class.getMethod("removeAll", Object.class));
- tester.testAllPublicInstanceMethods(LinkedListMultimap.create());
- }
}
diff --git a/android/guava-tests/test/com/google/common/collect/QueuesTest.java b/android/guava-tests/test/com/google/common/collect/QueuesTest.java
index 819700e..66d99fe 100644
--- a/android/guava-tests/test/com/google/common/collect/QueuesTest.java
+++ b/android/guava-tests/test/com/google/common/collect/QueuesTest.java
@@ -101,15 +101,15 @@
private void testMultipleProducers(BlockingQueue<Object> q) throws InterruptedException {
for (boolean interruptibly : new boolean[] {true, false}) {
- @SuppressWarnings("unused") // https://errorprone.info/bugpattern/FutureReturnValueIgnored
+ @SuppressWarnings("unused") // go/futurereturn-lsc
Future<?> possiblyIgnoredError = threadPool.submit(new Producer(q, 20));
- @SuppressWarnings("unused") // https://errorprone.info/bugpattern/FutureReturnValueIgnored
+ @SuppressWarnings("unused") // go/futurereturn-lsc
Future<?> possiblyIgnoredError1 = threadPool.submit(new Producer(q, 20));
- @SuppressWarnings("unused") // https://errorprone.info/bugpattern/FutureReturnValueIgnored
+ @SuppressWarnings("unused") // go/futurereturn-lsc
Future<?> possiblyIgnoredError2 = threadPool.submit(new Producer(q, 20));
- @SuppressWarnings("unused") // https://errorprone.info/bugpattern/FutureReturnValueIgnored
+ @SuppressWarnings("unused") // go/futurereturn-lsc
Future<?> possiblyIgnoredError3 = threadPool.submit(new Producer(q, 20));
- @SuppressWarnings("unused") // https://errorprone.info/bugpattern/FutureReturnValueIgnored
+ @SuppressWarnings("unused") // go/futurereturn-lsc
Future<?> possiblyIgnoredError4 = threadPool.submit(new Producer(q, 20));
List<Object> buf = newArrayList();
@@ -182,7 +182,7 @@
}
private void testNegativeMaxElements(BlockingQueue<Object> q) throws InterruptedException {
- @SuppressWarnings("unused") // https://errorprone.info/bugpattern/FutureReturnValueIgnored
+ @SuppressWarnings("unused") // go/futurereturn-lsc
Future<?> possiblyIgnoredError = threadPool.submit(new Producer(q, 1));
List<Object> buf = newArrayList();
@@ -201,7 +201,7 @@
}
private void testDrain_throws(BlockingQueue<Object> q) {
- @SuppressWarnings("unused") // https://errorprone.info/bugpattern/FutureReturnValueIgnored
+ @SuppressWarnings("unused") // go/futurereturn-lsc
Future<?> possiblyIgnoredError = threadPool.submit(new Interrupter(currentThread()));
try {
Queues.drain(q, ImmutableList.of(), 100, MAX_VALUE, NANOSECONDS);
@@ -218,7 +218,7 @@
private void testDrainUninterruptibly_doesNotThrow(final BlockingQueue<Object> q) {
final Thread mainThread = currentThread();
- @SuppressWarnings("unused") // https://errorprone.info/bugpattern/FutureReturnValueIgnored
+ @SuppressWarnings("unused") // go/futurereturn-lsc
Future<?> possiblyIgnoredError =
threadPool.submit(
new Callable<Void>() {
@@ -275,7 +275,7 @@
}
// but does the wait actually occurs?
- @SuppressWarnings("unused") // https://errorprone.info/bugpattern/FutureReturnValueIgnored
+ @SuppressWarnings("unused") // go/futurereturn-lsc
Future<?> possiblyIgnoredError = threadPool.submit(new Interrupter(currentThread()));
try {
// if waiting works, this should get stuck
@@ -291,7 +291,7 @@
assertEquals(0, Queues.drainUninterruptibly(q, ImmutableList.of(), 0, 10, MILLISECONDS));
// but does the wait actually occurs?
- @SuppressWarnings("unused") // https://errorprone.info/bugpattern/FutureReturnValueIgnored
+ @SuppressWarnings("unused") // go/futurereturn-lsc
Future<?> possiblyIgnoredError = threadPool.submit(new Interrupter(currentThread()));
Stopwatch timer = Stopwatch.createStarted();
diff --git a/android/guava-tests/test/com/google/common/collect/SynchronizedDequeTest.java b/android/guava-tests/test/com/google/common/collect/SynchronizedDequeTest.java
index 1df6aa1..0a11b27 100644
--- a/android/guava-tests/test/com/google/common/collect/SynchronizedDequeTest.java
+++ b/android/guava-tests/test/com/google/common/collect/SynchronizedDequeTest.java
@@ -254,7 +254,6 @@
private static final long serialVersionUID = 0;
}
- @SuppressWarnings("CheckReturnValue")
public void testHoldsLockOnAllOperations() {
create().element();
create().offer("foo");
@@ -264,8 +263,8 @@
create().add("foo");
create().addAll(ImmutableList.of("foo"));
create().clear();
- create().contains("foo");
- create().containsAll(ImmutableList.of("foo"));
+ boolean unused = create().contains("foo");
+ boolean unused2 = create().containsAll(ImmutableList.of("foo"));
create().equals(new ArrayDeque<>(ImmutableList.of("foo")));
create().hashCode();
create().isEmpty();
diff --git a/android/guava-tests/test/com/google/common/collect/SynchronizedMapTest.java b/android/guava-tests/test/com/google/common/collect/SynchronizedMapTest.java
index b07802a..34d1c6f 100644
--- a/android/guava-tests/test/com/google/common/collect/SynchronizedMapTest.java
+++ b/android/guava-tests/test/com/google/common/collect/SynchronizedMapTest.java
@@ -159,11 +159,11 @@
*/
public void testSize() {
- int unused = create().size();
+ create().size();
}
public void testIsEmpty() {
- boolean unused = create().isEmpty();
+ create().isEmpty();
}
public void testRemove() {
diff --git a/android/guava-tests/test/com/google/common/collect/SynchronizedQueueTest.java b/android/guava-tests/test/com/google/common/collect/SynchronizedQueueTest.java
index f7b04fe..70ff774 100644
--- a/android/guava-tests/test/com/google/common/collect/SynchronizedQueueTest.java
+++ b/android/guava-tests/test/com/google/common/collect/SynchronizedQueueTest.java
@@ -152,7 +152,6 @@
private static final long serialVersionUID = 0;
}
- @SuppressWarnings("CheckReturnValue")
public void testHoldsLockOnAllOperations() {
create().element();
create().offer("foo");
@@ -162,8 +161,8 @@
create().add("foo");
create().addAll(ImmutableList.of("foo"));
create().clear();
- create().contains("foo");
- create().containsAll(ImmutableList.of("foo"));
+ boolean unused = create().contains("foo");
+ boolean unused2 = create().containsAll(ImmutableList.of("foo"));
create().equals(new ArrayDeque<>(ImmutableList.of("foo")));
create().hashCode();
create().isEmpty();
diff --git a/android/guava-tests/test/com/google/common/collect/TopKSelectorTest.java b/android/guava-tests/test/com/google/common/collect/TopKSelectorTest.java
index 2cebdc3..e21f817 100644
--- a/android/guava-tests/test/com/google/common/collect/TopKSelectorTest.java
+++ b/android/guava-tests/test/com/google/common/collect/TopKSelectorTest.java
@@ -18,7 +18,6 @@
import static com.google.common.truth.Truth.assertThat;
-import com.google.common.annotations.GwtCompatible;
import com.google.common.math.IntMath;
import com.google.common.primitives.Ints;
import java.math.RoundingMode;
@@ -32,7 +31,6 @@
*
* @author Louis Wasserman
*/
-@GwtCompatible
public class TopKSelectorTest extends TestCase {
public void testNegativeK() {
@@ -121,13 +119,4 @@
assertThat(top.topK()).containsExactlyElementsIn(Collections.nCopies(k, 0));
assertThat(compareCalls[0]).isAtMost(10L * n * IntMath.log2(k, RoundingMode.CEILING));
}
-
- public void testExceedMaxIteration() {
- /*
- * Bug #5692 occurred when TopKSelector called Arrays.sort incorrectly.
- */
- TopKSelector<Integer> top = TopKSelector.least(7);
- top.offerAll(Ints.asList(5, 7, 6, 2, 4, 3, 1, 0, 0, 0, 0, 0, 0, 0));
- assertThat(top.topK()).isEqualTo(Ints.asList(0, 0, 0, 0, 0, 0, 0));
- }
}
diff --git a/android/guava-tests/test/com/google/common/collect/TreeRangeMapTest.java b/android/guava-tests/test/com/google/common/collect/TreeRangeMapTest.java
index db68b89..d82633a 100644
--- a/android/guava-tests/test/com/google/common/collect/TreeRangeMapTest.java
+++ b/android/guava-tests/test/com/google/common/collect/TreeRangeMapTest.java
@@ -539,7 +539,6 @@
rangeMap.asMapOfRanges());
}
-
public void testSubRangeMapExhaustive() {
for (Range<Integer> range1 : RANGES) {
for (Range<Integer> range2 : RANGES) {
diff --git a/android/guava-tests/test/com/google/common/collect/TreeRangeSetTest.java b/android/guava-tests/test/com/google/common/collect/TreeRangeSetTest.java
index b33ab2d..498a1a1 100644
--- a/android/guava-tests/test/com/google/common/collect/TreeRangeSetTest.java
+++ b/android/guava-tests/test/com/google/common/collect/TreeRangeSetTest.java
@@ -271,7 +271,6 @@
return expected;
}
-
public void testSubRangeSet() {
for (Range<Integer> range1 : QUERY_RANGES) {
for (Range<Integer> range2 : QUERY_RANGES) {
@@ -310,7 +309,6 @@
}
}
-
public void testSubRangeSetOfComplement() {
for (Range<Integer> range1 : QUERY_RANGES) {
for (Range<Integer> range2 : QUERY_RANGES) {
@@ -326,7 +324,6 @@
}
}
-
public void testComplementOfSubRangeSet() {
for (Range<Integer> range1 : QUERY_RANGES) {
for (Range<Integer> range2 : QUERY_RANGES) {
diff --git a/android/guava-tests/test/com/google/common/graph/AbstractNetworkTest.java b/android/guava-tests/test/com/google/common/graph/AbstractNetworkTest.java
index 776e4bf..e386252 100644
--- a/android/guava-tests/test/com/google/common/graph/AbstractNetworkTest.java
+++ b/android/guava-tests/test/com/google/common/graph/AbstractNetworkTest.java
@@ -785,7 +785,6 @@
assertThat(network.edgesConnecting(N1, N2)).containsExactly(E12);
}
-
@Test
public void concurrentIteration() throws Exception {
addEdge(1, 2, "foo");
diff --git a/android/guava-tests/test/com/google/common/graph/MapCacheTest.java b/android/guava-tests/test/com/google/common/graph/MapCacheTest.java
index f04f010..f66b19b 100644
--- a/android/guava-tests/test/com/google/common/graph/MapCacheTest.java
+++ b/android/guava-tests/test/com/google/common/graph/MapCacheTest.java
@@ -90,4 +90,25 @@
assertThat(mapCache.remove(fooReference2)).isEqualTo("bar");
assertThat(mapCache.get(fooReference1)).isNull();
}
+
+ @Test
+ public void testHandleNulls() {
+ mapCache.put("foo", "bar");
+ mapCache.put("non-null key", null);
+ mapCache.put(null, "non-null value");
+
+ assertThat(mapCache.get("foo")).isEqualTo("bar");
+ assertThat(mapCache.get("non-null key")).isNull();
+ assertThat(mapCache.get(null)).isEqualTo("non-null value");
+
+ assertThat(mapCache.containsKey("foo")).isTrue();
+ assertThat(mapCache.containsKey("bar")).isFalse();
+ assertThat(mapCache.containsKey("non-null key")).isTrue();
+ assertThat(mapCache.containsKey(null)).isTrue();
+
+ // Test again - in reverse order.
+ assertThat(mapCache.get(null)).isEqualTo("non-null value");
+ assertThat(mapCache.get("non-null key")).isNull();
+ assertThat(mapCache.get("foo")).isEqualTo("bar");
+ }
}
diff --git a/android/guava-tests/test/com/google/common/graph/ValueGraphTest.java b/android/guava-tests/test/com/google/common/graph/ValueGraphTest.java
index b17c91d..a3f4814 100644
--- a/android/guava-tests/test/com/google/common/graph/ValueGraphTest.java
+++ b/android/guava-tests/test/com/google/common/graph/ValueGraphTest.java
@@ -380,7 +380,6 @@
.inOrder();
}
-
@Test
public void concurrentIteration() throws Exception {
graph = ValueGraphBuilder.directed().build();
diff --git a/android/guava-tests/test/com/google/common/hash/BloomFilterTest.java b/android/guava-tests/test/com/google/common/hash/BloomFilterTest.java
index f69b578..4d64f98 100644
--- a/android/guava-tests/test/com/google/common/hash/BloomFilterTest.java
+++ b/android/guava-tests/test/com/google/common/hash/BloomFilterTest.java
@@ -519,7 +519,6 @@
assertEquals(BloomFilterStrategies.MURMUR128_MITZ_64, BloomFilterStrategies.values()[1]);
}
-
public void testNoRaceConditions() throws Exception {
final BloomFilter<Integer> bloomFilter =
BloomFilter.create(Funnels.integerFunnel(), 15_000_000, 0.01);
diff --git a/android/guava-tests/test/com/google/common/hash/Crc32cHashFunctionTest.java b/android/guava-tests/test/com/google/common/hash/Crc32cHashFunctionTest.java
index 3bea975..4619cec 100644
--- a/android/guava-tests/test/com/google/common/hash/Crc32cHashFunctionTest.java
+++ b/android/guava-tests/test/com/google/common/hash/Crc32cHashFunctionTest.java
@@ -17,7 +17,6 @@
import static com.google.common.base.Charsets.UTF_8;
import java.util.Arrays;
-import java.util.Random;
import junit.framework.TestCase;
/**
@@ -27,22 +26,14 @@
* @author Kurt Alfred Kluever
*/
public class Crc32cHashFunctionTest extends TestCase {
- public void testEmpty() {
- assertCrc(0, new byte[0]);
- }
public void testZeros() {
// Test 32 byte array of 0x00.
byte[] zeros = new byte[32];
+ Arrays.fill(zeros, (byte) 0x00);
assertCrc(0x8a9136aa, zeros);
}
- public void testZeros100() {
- // Test 100 byte array of 0x00.
- byte[] zeros = new byte[100];
- assertCrc(0x07cb9ff6, zeros);
- }
-
public void testFull() {
// Test 32 byte array of 0xFF.
byte[] fulls = new byte[32];
@@ -50,13 +41,6 @@
assertCrc(0x62a8ab43, fulls);
}
- public void testFull100() {
- // Test 100 byte array of 0xFF.
- byte[] fulls = new byte[100];
- Arrays.fill(fulls, (byte) 0xFF);
- assertCrc(0xbc753add, fulls);
- }
-
public void testAscending() {
// Test 32 byte arrays of ascending.
byte[] ascending = new byte[32];
@@ -75,15 +59,6 @@
assertCrc(0x113fdb5c, descending);
}
- public void testDescending100() {
- // Test 100 byte arrays of descending.
- byte[] descending = new byte[100];
- for (int i = 0; i < 100; i++) {
- descending[i] = (byte) (99 - i);
- }
- assertCrc(0xd022db97, descending);
- }
-
public void testScsiReadCommand() {
// Test SCSI read command.
byte[] scsiReadCommand =
@@ -112,23 +87,6 @@
assertCrc(0xBFE92A83, "23456789".getBytes(UTF_8));
}
- public void testAgainstSimplerImplementation() {
- Random r = new Random(1234567);
- for (int length = 0; length < 1000; length++) {
- byte[] bytes = new byte[length];
- r.nextBytes(bytes);
- assertCrc(referenceCrc(bytes), bytes);
- }
- }
-
- private static int referenceCrc(byte[] bytes) {
- int crc = ~0;
- for (byte b : bytes) {
- crc = (crc >>> 8) ^ Crc32cHashFunction.Crc32cHasher.BYTE_TABLE[(crc ^ b) & 0xFF];
- }
- return ~crc;
- }
-
/**
* Verifies that the crc of an array of byte data matches the expected value.
*
@@ -137,15 +95,7 @@
*/
private static void assertCrc(int expectedCrc, byte[] data) {
int actualCrc = Hashing.crc32c().hashBytes(data).asInt();
- assertEquals(
- String.format("expected: %08x, actual: %08x", expectedCrc, actualCrc),
- expectedCrc,
- actualCrc);
- int actualCrcHasher = Hashing.crc32c().newHasher().putBytes(data).hash().asInt();
- assertEquals(
- String.format("expected: %08x, actual: %08x", expectedCrc, actualCrc),
- expectedCrc,
- actualCrcHasher);
+ assertEquals(expectedCrc, actualCrc);
}
// From RFC 3720, Section 12.1, the polynomial generator is 0x11EDC6F41.
@@ -155,7 +105,7 @@
private static final int CRC32C_GENERATOR = 0x1EDC6F41; // 0x11EDC6F41
private static final int CRC32C_GENERATOR_FLIPPED = Integer.reverse(CRC32C_GENERATOR);
- public void testCrc32cByteTable() {
+ public void testCrc32cLookupTable() {
// See Hacker's Delight 2nd Edition, Figure 14-7.
int[] expected = new int[256];
for (int i = 0; i < expected.length; i++) {
@@ -167,47 +117,9 @@
expected[i] = crc;
}
- int[] actual = Crc32cHashFunction.Crc32cHasher.BYTE_TABLE;
+ int[] actual = Crc32cHashFunction.Crc32cHasher.CRC_TABLE;
assertTrue(
"Expected: \n" + Arrays.toString(expected) + "\nActual:\n" + Arrays.toString(actual),
Arrays.equals(expected, actual));
}
-
- static int advanceOneBit(int next) {
- if ((next & 1) != 0) {
- return (next >>> 1) ^ CRC32C_GENERATOR_FLIPPED;
- } else {
- return next >>> 1;
- }
- }
-
- public void testCrc32cStrideTable() {
- int next = CRC32C_GENERATOR_FLIPPED;
- for (int i = 0; i < 12; i++) { // for 3 ints = 12 bytes in between each stride window
- next = (next >>> 8) ^ Crc32cHashFunction.Crc32cHasher.BYTE_TABLE[next & 0xFF];
- }
- int[][] expected = new int[4][256];
- for (int b = 0; b < 4; ++b) {
- for (int bit = 128; bit != 0; bit >>= 1) {
- expected[b][bit] = next;
- next = advanceOneBit(next);
- }
- }
- for (int b = 0; b < 4; ++b) {
- expected[b][0] = 0;
- for (int bit = 2; bit < 256; bit <<= 1) {
- for (int i = bit + 1; i < (bit << 1); i++) {
- expected[b][i] = expected[b][bit] ^ expected[b][i ^ bit];
- }
- }
- }
-
- int[][] actual = Crc32cHashFunction.Crc32cHasher.STRIDE_TABLE;
- assertTrue(
- "Expected: \n"
- + Arrays.deepToString(expected)
- + "\nActual:\n"
- + Arrays.deepToString(actual),
- Arrays.deepEquals(expected, actual));
- }
}
diff --git a/android/guava-tests/test/com/google/common/hash/HashFunctionEnum.java b/android/guava-tests/test/com/google/common/hash/HashFunctionEnum.java
index 3471747..c055063 100644
--- a/android/guava-tests/test/com/google/common/hash/HashFunctionEnum.java
+++ b/android/guava-tests/test/com/google/common/hash/HashFunctionEnum.java
@@ -16,7 +16,6 @@
package com.google.common.hash;
-
/**
* An enum that contains all of the known hash functions.
*
@@ -32,7 +31,6 @@
MD5(Hashing.md5()),
MURMUR3_128(Hashing.murmur3_128()),
MURMUR3_32(Hashing.murmur3_32()),
- MURMUR3_32_FIXED(Hashing.murmur3_32_fixed()),
SHA1(Hashing.sha1()),
SHA256(Hashing.sha256()),
SHA384(Hashing.sha384()),
diff --git a/android/guava-tests/test/com/google/common/hash/HashTestUtils.java b/android/guava-tests/test/com/google/common/hash/HashTestUtils.java
index 9e9944b..8dfbdb0 100644
--- a/android/guava-tests/test/com/google/common/hash/HashTestUtils.java
+++ b/android/guava-tests/test/com/google/common/hash/HashTestUtils.java
@@ -195,8 +195,8 @@
int limit = pos + random.nextInt(value.length - pos + 1);
for (PrimitiveSink sink : sinks) {
ByteBuffer buffer = ByteBuffer.wrap(value);
- Java8Compatibility.position(buffer, pos);
- Java8Compatibility.limit(buffer, limit);
+ buffer.position(pos);
+ buffer.limit(limit);
sink.putBytes(buffer);
assertEquals(limit, buffer.limit());
assertEquals(limit, buffer.position());
diff --git a/android/guava-tests/test/com/google/common/hash/HashingTest.java b/android/guava-tests/test/com/google/common/hash/HashingTest.java
index bc3db34..dc50299 100644
--- a/android/guava-tests/test/com/google/common/hash/HashingTest.java
+++ b/android/guava-tests/test/com/google/common/hash/HashingTest.java
@@ -146,7 +146,7 @@
// goodFastHash(128) uses Murmur3_128. Use the same epsilon bounds.
public void testGoodFastHash128() {
HashTestUtils.check2BitAvalanche(Hashing.goodFastHash(128), 250, 0.20);
- HashTestUtils.checkAvalanche(Hashing.goodFastHash(128), 500, 0.17);
+ HashTestUtils.checkAvalanche(Hashing.goodFastHash(128), 250, 0.17);
HashTestUtils.checkNo2BitCharacteristics(Hashing.goodFastHash(128));
HashTestUtils.checkNoFunnels(Hashing.goodFastHash(128));
HashTestUtils.assertInvariants(Hashing.goodFastHash(128));
@@ -155,7 +155,7 @@
// goodFastHash(256) uses Murmur3_128. Use the same epsilon bounds.
public void testGoodFastHash256() {
HashTestUtils.check2BitAvalanche(Hashing.goodFastHash(256), 250, 0.20);
- HashTestUtils.checkAvalanche(Hashing.goodFastHash(256), 500, 0.17);
+ HashTestUtils.checkAvalanche(Hashing.goodFastHash(256), 250, 0.17);
HashTestUtils.checkNo2BitCharacteristics(Hashing.goodFastHash(256));
HashTestUtils.checkNoFunnels(Hashing.goodFastHash(256));
HashTestUtils.assertInvariants(Hashing.goodFastHash(256));
@@ -432,9 +432,6 @@
.put(Hashing.murmur3_32(), EMPTY_STRING, "00000000")
.put(Hashing.murmur3_32(), TQBFJOTLD, "23f74f2e")
.put(Hashing.murmur3_32(), TQBFJOTLDP, "fc8bc4d5")
- .put(Hashing.murmur3_32_fixed(), EMPTY_STRING, "00000000")
- .put(Hashing.murmur3_32_fixed(), TQBFJOTLD, "23f74f2e")
- .put(Hashing.murmur3_32_fixed(), TQBFJOTLDP, "fc8bc4d5")
.put(Hashing.sha1(), EMPTY_STRING, "da39a3ee5e6b4b0d3255bfef95601890afd80709")
.put(Hashing.sha1(), TQBFJOTLD, "2fd4e1c67a2d28fced849ee1bb76e7391b93eb12")
.put(Hashing.sha1(), TQBFJOTLDP, "408d94384216f890ff7a0c3528e8bed1e0b01621")
diff --git a/android/guava-tests/test/com/google/common/hash/Murmur3Hash32Test.java b/android/guava-tests/test/com/google/common/hash/Murmur3Hash32Test.java
index 181b2a7..de86e4b 100644
--- a/android/guava-tests/test/com/google/common/hash/Murmur3Hash32Test.java
+++ b/android/guava-tests/test/com/google/common/hash/Murmur3Hash32Test.java
@@ -17,11 +17,9 @@
package com.google.common.hash;
import static com.google.common.hash.Hashing.murmur3_32;
-import static com.google.common.hash.Hashing.murmur3_32_fixed;
import com.google.common.base.Charsets;
import com.google.common.hash.HashTestUtils.HashFn;
-import java.nio.charset.Charset;
import java.util.Random;
import junit.framework.TestCase;
@@ -53,53 +51,16 @@
-528633700, murmur3_32().hashUnencodedChars("The quick brown fox jumps over the lazy dog"));
}
- @SuppressWarnings("deprecation")
- public void testKnownEncodedStringInputs() {
- assertStringHash(0, "", Charsets.UTF_8);
- assertStringHash(0xcfbda5d1, "k", Charsets.UTF_8);
- assertStringHash(0xa167dbf3, "hell", Charsets.UTF_8);
- assertStringHash(0x248bfa47, "hello", Charsets.UTF_8);
- assertStringHash(0x3d41b97c, "http://www.google.com/", Charsets.UTF_8);
- assertStringHash(0x2e4ff723, "The quick brown fox jumps over the lazy dog", Charsets.UTF_8);
- assertStringHash(0xb5a4be05, "ABCDefGHI\u0799", Charsets.UTF_8);
- assertStringHash(0xfc5ba834, "毎月1日,毎週月曜日", Charsets.UTF_8);
- assertStringHash(0x8a5c3699, "surrogate pair: \uD83D\uDCB0", Charsets.UTF_8);
-
- assertStringHash(0, "", Charsets.UTF_16LE);
- assertStringHash(0x288418e4, "k", Charsets.UTF_16LE);
- assertStringHash(0x5a0cb7c3, "hell", Charsets.UTF_16LE);
- assertStringHash(0xd7c31989, "hello", Charsets.UTF_16LE);
- assertStringHash(0x73564d8c, "http://www.google.com/", Charsets.UTF_16LE);
- assertStringHash(0xe07db09c, "The quick brown fox jumps over the lazy dog", Charsets.UTF_16LE);
- assertStringHash(0xfefa3e76, "ABCDefGHI\u0799", Charsets.UTF_16LE);
- assertStringHash(0x6a7be132, "毎月1日,毎週月曜日", Charsets.UTF_16LE);
- assertStringHash(0x5a2d41c7, "surrogate pair: \uD83D\uDCB0", Charsets.UTF_16LE);
- }
-
- @SuppressWarnings("deprecation")
- private void assertStringHash(int expected, String string, Charset charset) {
- if (allBmp(string)) {
- assertHash(expected, murmur3_32().hashString(string, charset));
- }
- assertHash(expected, murmur3_32_fixed().hashString(string, charset));
- assertHash(expected, murmur3_32().newHasher().putString(string, charset).hash());
- assertHash(expected, murmur3_32_fixed().newHasher().putString(string, charset).hash());
- assertHash(expected, murmur3_32().hashBytes(string.getBytes(charset)));
- assertHash(expected, murmur3_32_fixed().hashBytes(string.getBytes(charset)));
- assertHash(expected, murmur3_32().newHasher().putBytes(string.getBytes(charset)).hash());
- assertHash(expected, murmur3_32_fixed().newHasher().putBytes(string.getBytes(charset)).hash());
- }
-
- private boolean allBmp(String string) {
- // Ordinarily we'd use something like i += Character.charCount(string.codePointAt(i)) here. But
- // we can get away with i++ because the whole point of this method is to return false if we find
- // a code point that doesn't fit in a char.
- for (int i = 0; i < string.length(); i++) {
- if (string.codePointAt(i) > 0xffff) {
- return false;
- }
- }
- return true;
+ public void testKnownUtf8StringInputs() {
+ assertHash(0, murmur3_32().hashString("", Charsets.UTF_8));
+ assertHash(0xcfbda5d1, murmur3_32().hashString("k", Charsets.UTF_8));
+ assertHash(0xa167dbf3, murmur3_32().hashString("hell", Charsets.UTF_8));
+ assertHash(0x248bfa47, murmur3_32().hashString("hello", Charsets.UTF_8));
+ assertHash(0x3d41b97c, murmur3_32().hashString("http://www.google.com/", Charsets.UTF_8));
+ assertHash(
+ 0x2e4ff723,
+ murmur3_32().hashString("The quick brown fox jumps over the lazy dog", Charsets.UTF_8));
+ assertHash(0xfc5ba834, murmur3_32().hashString("毎月1日,毎週月曜日", Charsets.UTF_8));
}
@SuppressWarnings("deprecation")
@@ -110,7 +71,7 @@
}
@SuppressWarnings("deprecation")
- public void testEncodedStringInputs() {
+ public void testStringInputsUtf8() {
Random rng = new Random(0);
for (int z = 0; z < 100; z++) {
String str;
@@ -127,16 +88,9 @@
builder.appendCodePoint(codePoints[i]);
}
str = builder.toString();
- HashCode hashUtf8 = murmur3_32().hashBytes(str.getBytes(Charsets.UTF_8));
assertEquals(
- hashUtf8, murmur3_32().newHasher().putBytes(str.getBytes(Charsets.UTF_8)).hash());
- assertEquals(hashUtf8, murmur3_32().hashString(str, Charsets.UTF_8));
- assertEquals(hashUtf8, murmur3_32().newHasher().putString(str, Charsets.UTF_8).hash());
- HashCode hashUtf16 = murmur3_32().hashBytes(str.getBytes(Charsets.UTF_16));
- assertEquals(
- hashUtf16, murmur3_32().newHasher().putBytes(str.getBytes(Charsets.UTF_16)).hash());
- assertEquals(hashUtf16, murmur3_32().hashString(str, Charsets.UTF_16));
- assertEquals(hashUtf16, murmur3_32().newHasher().putString(str, Charsets.UTF_16).hash());
+ murmur3_32().hashBytes(str.getBytes(Charsets.UTF_8)),
+ murmur3_32().hashString(str, Charsets.UTF_8));
}
}
@@ -184,12 +138,8 @@
assertEquals(
murmur3_32().hashBytes(str.getBytes(Charsets.UTF_8)),
murmur3_32().hashString(str, Charsets.UTF_8));
- assertEquals(
- murmur3_32_fixed().hashBytes(str.getBytes(Charsets.UTF_8)),
- murmur3_32().hashString(str, Charsets.UTF_8));
}
- @SuppressWarnings("deprecation")
public void testInvalidUnicodeHasherPutString() {
String str =
new String(
@@ -197,8 +147,5 @@
assertEquals(
murmur3_32().hashBytes(str.getBytes(Charsets.UTF_8)),
murmur3_32().newHasher().putString(str, Charsets.UTF_8).hash());
- assertEquals(
- murmur3_32_fixed().hashBytes(str.getBytes(Charsets.UTF_8)),
- murmur3_32_fixed().newHasher().putString(str, Charsets.UTF_8).hash());
}
}
diff --git a/android/guava-tests/test/com/google/common/html/HtmlEscapersTest.java b/android/guava-tests/test/com/google/common/html/HtmlEscapersTest.java
old mode 100644
new mode 100755
diff --git a/android/guava-tests/test/com/google/common/io/ByteSourceTest.java b/android/guava-tests/test/com/google/common/io/ByteSourceTest.java
index 3cf6cca..f0ba829 100644
--- a/android/guava-tests/test/com/google/common/io/ByteSourceTest.java
+++ b/android/guava-tests/test/com/google/common/io/ByteSourceTest.java
@@ -30,7 +30,6 @@
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
import com.google.common.hash.Hashing;
-import com.google.common.io.Closer.LoggingSuppressor;
import com.google.common.primitives.UnsignedBytes;
import com.google.common.testing.TestLogHandler;
import java.io.ByteArrayOutputStream;
@@ -396,7 +395,7 @@
ImmutableSet.of(BROKEN_CLOSE_SINK, BROKEN_OPEN_SINK, BROKEN_WRITE_SINK);
public void testCopyExceptions() {
- if (Closer.create().suppressor instanceof LoggingSuppressor) {
+ if (!Closer.SuppressingSuppressor.isAvailable()) {
// test that exceptions are logged
TestLogHandler logHandler = new TestLogHandler();
diff --git a/android/guava-tests/test/com/google/common/io/ByteSourceTester.java b/android/guava-tests/test/com/google/common/io/ByteSourceTester.java
index 7585412..490f1e6 100644
--- a/android/guava-tests/test/com/google/common/io/ByteSourceTester.java
+++ b/android/guava-tests/test/com/google/common/io/ByteSourceTester.java
@@ -38,7 +38,7 @@
/**
* A generator of {@code TestSuite} instances for testing {@code ByteSource} implementations.
* Generates tests of a all methods on a {@code ByteSource} given various inputs the source is
- * expected to contain as well as sub-suites for testing the {@code CharSource} view and {@code
+ * expected to contain as well as as sub-suites for testing the {@code CharSource} view and {@code
* slice()} views in the same way.
*
* @author Colin Decker
diff --git a/android/guava-tests/test/com/google/common/io/ByteStreamsTest.java b/android/guava-tests/test/com/google/common/io/ByteStreamsTest.java
index 3ae2c25..f715303 100644
--- a/android/guava-tests/test/com/google/common/io/ByteStreamsTest.java
+++ b/android/guava-tests/test/com/google/common/io/ByteStreamsTest.java
@@ -51,7 +51,6 @@
assertThat(out.toByteArray()).isEqualTo(expected);
}
-
public void testCopyFileChannel() throws IOException {
final int chunkSize = 14407; // Random prime, unlikely to match any internal chunk size
ByteArrayOutputStream out = new ByteArrayOutputStream();
diff --git a/android/guava-tests/test/com/google/common/io/CharSequenceReaderTest.java b/android/guava-tests/test/com/google/common/io/CharSequenceReaderTest.java
index dbe94fc..12bc17e 100644
--- a/android/guava-tests/test/com/google/common/io/CharSequenceReaderTest.java
+++ b/android/guava-tests/test/com/google/common/io/CharSequenceReaderTest.java
@@ -211,7 +211,7 @@
reader = new CharSequenceReader(charSequence);
CharBuffer buf2 = CharBuffer.allocate(expected.length());
assertEquals(expected.length() == 0 ? -1 : expected.length(), reader.read(buf2));
- Java8Compatibility.flip(buf2);
+ buf2.flip();
assertEquals(expected, buf2.toString());
assertFullyRead(reader);
@@ -220,9 +220,9 @@
buf2 = CharBuffer.allocate(5);
builder = new StringBuilder();
while (reader.read(buf2) != -1) {
- Java8Compatibility.flip(buf2);
+ buf2.flip();
builder.append(buf2);
- Java8Compatibility.clear(buf2);
+ buf2.clear();
}
assertEquals(expected, builder.toString());
assertFullyRead(reader);
diff --git a/android/guava-tests/test/com/google/common/io/CharSourceTest.java b/android/guava-tests/test/com/google/common/io/CharSourceTest.java
index 6cc210b..a103490 100644
--- a/android/guava-tests/test/com/google/common/io/CharSourceTest.java
+++ b/android/guava-tests/test/com/google/common/io/CharSourceTest.java
@@ -25,7 +25,6 @@
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
-import com.google.common.io.Closer.LoggingSuppressor;
import com.google.common.testing.TestLogHandler;
import java.io.BufferedReader;
import java.io.IOException;
@@ -259,7 +258,7 @@
ImmutableSet.of(BROKEN_CLOSE_SINK, BROKEN_OPEN_SINK, BROKEN_WRITE_SINK);
public void testCopyExceptions() {
- if (Closer.create().suppressor instanceof LoggingSuppressor) {
+ if (!Closer.SuppressingSuppressor.isAvailable()) {
// test that exceptions are logged
TestLogHandler logHandler = new TestLogHandler();
diff --git a/android/guava-tests/test/com/google/common/io/CloserTest.java b/android/guava-tests/test/com/google/common/io/CloserTest.java
index 23037f2..b97a305 100644
--- a/android/guava-tests/test/com/google/common/io/CloserTest.java
+++ b/android/guava-tests/test/com/google/common/io/CloserTest.java
@@ -24,7 +24,6 @@
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Lists;
-import com.google.common.io.Closer.LoggingSuppressor;
import com.google.common.testing.TestLogHandler;
import java.io.Closeable;
import java.io.IOException;
@@ -312,12 +311,13 @@
}
public static void testSuppressingSuppressorIfPossible() throws IOException {
- Closer closer = Closer.create();
// can't test the JDK7 suppressor when not running on JDK7
- if (closer.suppressor instanceof LoggingSuppressor) {
+ if (!Closer.SuppressingSuppressor.isAvailable()) {
return;
}
+ Closer closer = new Closer(new Closer.SuppressingSuppressor());
+
IOException thrownException = new IOException();
IOException c1Exception = new IOException();
RuntimeException c2Exception = new RuntimeException();
diff --git a/android/guava-tests/test/com/google/common/io/FileBackedOutputStreamTest.java b/android/guava-tests/test/com/google/common/io/FileBackedOutputStreamTest.java
index 6841a41..66558e9 100644
--- a/android/guava-tests/test/com/google/common/io/FileBackedOutputStreamTest.java
+++ b/android/guava-tests/test/com/google/common/io/FileBackedOutputStreamTest.java
@@ -16,7 +16,6 @@
package com.google.common.io;
-
import com.google.common.testing.GcFinalization;
import java.io.File;
import java.io.IOException;
@@ -30,7 +29,6 @@
*/
public class FileBackedOutputStreamTest extends IoTestCase {
-
public void testThreshold() throws Exception {
testThreshold(0, 100, true, false);
testThreshold(10, 100, true, false);
@@ -78,7 +76,6 @@
}
}
-
public void testFinalizeDeletesFile() throws Exception {
byte[] data = newPreFilledByteArray(100);
FileBackedOutputStream out = new FileBackedOutputStream(0, true);
@@ -102,7 +99,6 @@
});
}
-
public void testThreshold_resetOnFinalize() throws Exception {
testThreshold(0, 100, true, true);
testThreshold(10, 100, true, true);
diff --git a/android/guava-tests/test/com/google/common/io/FilesTest.java b/android/guava-tests/test/com/google/common/io/FilesTest.java
index 8446da1..e987f60 100644
--- a/android/guava-tests/test/com/google/common/io/FilesTest.java
+++ b/android/guava-tests/test/com/google/common/io/FilesTest.java
@@ -16,6 +16,7 @@
package com.google.common.io;
+import static com.google.common.io.Files.touch;
import static com.google.common.truth.Truth.assertThat;
import com.google.common.base.Charsets;
@@ -195,7 +196,7 @@
File temp2 = createTempFile();
Files.write(ASCII, temp2, Charsets.UTF_8);
Files.copy(temp1, temp2);
- assertEquals(ASCII, Files.toString(temp2, Charsets.UTF_8));
+ assertEquals(ASCII, Files.toString(temp1, Charsets.UTF_8));
}
public void testEqual() throws IOException {
diff --git a/android/guava-tests/test/com/google/common/io/PatternFilenameFilterTest.java b/android/guava-tests/test/com/google/common/io/PatternFilenameFilterTest.java
index 94ab1f0..77ace52 100644
--- a/android/guava-tests/test/com/google/common/io/PatternFilenameFilterTest.java
+++ b/android/guava-tests/test/com/google/common/io/PatternFilenameFilterTest.java
@@ -16,8 +16,6 @@
package com.google.common.io;
-import com.google.common.testing.NullPointerTester;
-import com.google.common.testing.NullPointerTester.Visibility;
import java.io.File;
import java.io.FilenameFilter;
import java.util.regex.PatternSyntaxException;
@@ -48,15 +46,4 @@
// Show that dir is ignored
assertTrue(filter.accept(null, "a"));
}
-
- public void testNulls() throws Exception {
- NullPointerTester tester = new NullPointerTester();
-
- tester.testConstructors(PatternFilenameFilter.class, Visibility.PACKAGE);
- tester.testStaticMethods(PatternFilenameFilter.class, Visibility.PACKAGE); // currently none
-
- // The reason that we skip this method is discussed in a comment on the method.
- tester.ignore(PatternFilenameFilter.class.getMethod("accept", File.class, String.class));
- tester.testInstanceMethods(new PatternFilenameFilter(".*"), Visibility.PACKAGE);
- }
}
diff --git a/android/guava-tests/test/com/google/common/io/SourceSinkFactories.java b/android/guava-tests/test/com/google/common/io/SourceSinkFactories.java
index cf3fad4..8bfa6e1 100644
--- a/android/guava-tests/test/com/google/common/io/SourceSinkFactories.java
+++ b/android/guava-tests/test/com/google/common/io/SourceSinkFactories.java
@@ -407,9 +407,9 @@
StringBuilder builder = new StringBuilder();
CharBuffer buffer = CharBuffer.allocate(100);
while (reader.read(buffer) != -1) {
- Java8Compatibility.flip(buffer);
+ buffer.flip();
builder.append(buffer);
- Java8Compatibility.clear(buffer);
+ buffer.clear();
}
return builder.toString();
}
diff --git a/android/guava-tests/test/com/google/common/math/BigIntegerMathTest.java b/android/guava-tests/test/com/google/common/math/BigIntegerMathTest.java
index 170261b..8a9b4fc 100644
--- a/android/guava-tests/test/com/google/common/math/BigIntegerMathTest.java
+++ b/android/guava-tests/test/com/google/common/math/BigIntegerMathTest.java
@@ -441,7 +441,7 @@
@GwtIncompatible // TODO
@AndroidIncompatible // slow
public void testDivNonZeroExact() {
- boolean isAndroid = System.getProperty("java.runtime.name").contains("Android");
+ boolean isAndroid = System.getProperties().getProperty("java.runtime.name").contains("Android");
for (BigInteger p : NONZERO_BIGINTEGER_CANDIDATES) {
for (BigInteger q : NONZERO_BIGINTEGER_CANDIDATES) {
if (isAndroid && p.equals(BAD_FOR_ANDROID_P) && q.equals(BAD_FOR_ANDROID_Q)) {
diff --git a/android/guava-tests/test/com/google/common/math/LongMathTest.java b/android/guava-tests/test/com/google/common/math/LongMathTest.java
index 40c2ac9..2284668 100644
--- a/android/guava-tests/test/com/google/common/math/LongMathTest.java
+++ b/android/guava-tests/test/com/google/common/math/LongMathTest.java
@@ -747,7 +747,6 @@
}
}
-
@GwtIncompatible // Slow
public void testBinomial_exhaustiveNotOverflowing() {
// Tests all of the inputs to LongMath.binomial that won't cause it to overflow, that weren't
@@ -784,7 +783,6 @@
}
}
-
@GwtIncompatible // far too slow
public void testSqrtOfPerfectSquareAsDoubleIsPerfect() {
// This takes just over a minute on my machine.
diff --git a/android/guava-tests/test/com/google/common/math/MathPreconditionsTest.java b/android/guava-tests/test/com/google/common/math/MathPreconditionsTest.java
index 5dbe017..69719e0 100644
--- a/android/guava-tests/test/com/google/common/math/MathPreconditionsTest.java
+++ b/android/guava-tests/test/com/google/common/math/MathPreconditionsTest.java
@@ -289,15 +289,4 @@
assertThat(expected).hasMessageThat().contains("testCheckNoOverflow_failure(0, 0)");
}
}
-
- public void testNulls() {
- /*
- * Don't bother testing. All non-primitive parameters are used only to construct error messages.
- * We never want to pass null for them, so we haven't annotated them to say that null is
- * allowed. But at the same time, it seems wasteful to bother inserting the checkNotNull calls
- * that NullPointerTester wants.
- *
- * (This empty method disables the automatic null testing provided by PackageSanityTests.)
- */
- }
}
diff --git a/android/guava-tests/test/com/google/common/math/TestPlatform.java b/android/guava-tests/test/com/google/common/math/TestPlatform.java
index 03eb2ec..95df331 100644
--- a/android/guava-tests/test/com/google/common/math/TestPlatform.java
+++ b/android/guava-tests/test/com/google/common/math/TestPlatform.java
@@ -26,6 +26,6 @@
}
static boolean isAndroid() {
- return System.getProperty("java.runtime.name").contains("Android");
+ return System.getProperties().getProperty("java.runtime.name").contains("Android");
}
}
diff --git a/android/guava-tests/test/com/google/common/net/HostAndPortTest.java b/android/guava-tests/test/com/google/common/net/HostAndPortTest.java
index 65e8096..5e7eb2f 100644
--- a/android/guava-tests/test/com/google/common/net/HostAndPortTest.java
+++ b/android/guava-tests/test/com/google/common/net/HostAndPortTest.java
@@ -59,13 +59,6 @@
checkFromStringCase("[2001::2]:85", 77, "2001::2", 85, true);
}
- public void testFromStringNonAsciiDigits() {
- // Same as testFromStringUnusedDefaultPort but with Gujarati digits for port numbers.
- checkFromStringCase("gmail.com:૮1", 77, null, -1, false);
- checkFromStringCase("192.0.2.2:૮૩", 77, null, -1, false);
- checkFromStringCase("[2001::2]:૮૫", 77, null, -1, false);
- }
-
public void testFromStringBadPort() {
// Out-of-range ports.
checkFromStringCase("google.com:65536", 1, null, 99, false);
diff --git a/android/guava-tests/test/com/google/common/net/HttpHeadersTest.java b/android/guava-tests/test/com/google/common/net/HttpHeadersTest.java
index 5361b3f..9927e6b 100644
--- a/android/guava-tests/test/com/google/common/net/HttpHeadersTest.java
+++ b/android/guava-tests/test/com/google/common/net/HttpHeadersTest.java
@@ -50,8 +50,8 @@
.build();
ImmutableSet<String> uppercaseAcronyms =
ImmutableSet.of(
- "CH", "ID", "DNT", "DNS", "ECT", "HTTP2", "IP", "MD5", "P3P", "RTT", "TE", "UA", "UID",
- "URL", "WWW", "XSS");
+ "CH", "ID", "DNT", "DNS", "HTTP2", "IP", "MD5", "P3P", "TE", "UA", "UID", "URL", "WWW",
+ "XSS");
assertConstantNameMatchesString(HttpHeaders.class, specialCases, uppercaseAcronyms);
}
diff --git a/android/guava-tests/test/com/google/common/net/InetAddressesTest.java b/android/guava-tests/test/com/google/common/net/InetAddressesTest.java
index be77e7b..ed3aa27 100644
--- a/android/guava-tests/test/com/google/common/net/InetAddressesTest.java
+++ b/android/guava-tests/test/com/google/common/net/InetAddressesTest.java
@@ -135,20 +135,6 @@
assertTrue(InetAddresses.isInetAddress(ipStr));
}
- public void testForStringIPv4NonAsciiInput() throws UnknownHostException {
- String ipStr = "૧૯૨.૧૬૮.૦.૧"; // 192.168.0.1 in Gujarati digits
- // Shouldn't hit DNS, because it's an IP string literal.
- InetAddress ipv4Addr;
- try {
- ipv4Addr = InetAddress.getByName(ipStr);
- } catch (UnknownHostException e) {
- // OK: this is probably Android, which is stricter.
- return;
- }
- assertEquals(ipv4Addr, InetAddresses.forString(ipStr));
- assertTrue(InetAddresses.isInetAddress(ipStr));
- }
-
public void testForStringIPv6Input() throws UnknownHostException {
String ipStr = "3ffe::1";
// Shouldn't hit DNS, because it's an IP string literal.
@@ -157,20 +143,6 @@
assertTrue(InetAddresses.isInetAddress(ipStr));
}
- public void testForStringIPv6NonAsciiInput() throws UnknownHostException {
- String ipStr = "૩ffe::૧"; // 3ffe::1 with Gujarati digits for 3 and 1
- // Shouldn't hit DNS, because it's an IP string literal.
- InetAddress ipv6Addr;
- try {
- ipv6Addr = InetAddress.getByName(ipStr);
- } catch (UnknownHostException e) {
- // OK: this is probably Android, which is stricter.
- return;
- }
- assertEquals(ipv6Addr, InetAddresses.forString(ipStr));
- assertTrue(InetAddresses.isInetAddress(ipStr));
- }
-
public void testForStringIPv6EightColons() throws UnknownHostException {
ImmutableSet<String> eightColons =
ImmutableSet.of("::7:6:5:4:3:2:1", "::7:6:5:4:3:2:0", "7:6:5:4:3:2:1::", "0:6:5:4:3:2:1::");
diff --git a/android/guava-tests/test/com/google/common/net/InternetDomainNameTest.java b/android/guava-tests/test/com/google/common/net/InternetDomainNameTest.java
index 7113fb4..09602b7 100644
--- a/android/guava-tests/test/com/google/common/net/InternetDomainNameTest.java
+++ b/android/guava-tests/test/com/google/common/net/InternetDomainNameTest.java
@@ -16,7 +16,6 @@
package com.google.common.net;
-
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.GwtIncompatible;
import com.google.common.base.Ascii;
diff --git a/android/guava-tests/test/com/google/common/net/MediaTypeTest.java b/android/guava-tests/test/com/google/common/net/MediaTypeTest.java
index 574db68..cec3cdd 100644
--- a/android/guava-tests/test/com/google/common/net/MediaTypeTest.java
+++ b/android/guava-tests/test/com/google/common/net/MediaTypeTest.java
@@ -46,6 +46,7 @@
import com.google.common.testing.NullPointerTester;
import java.lang.reflect.Field;
import java.nio.charset.Charset;
+import java.nio.charset.IllegalCharsetNameException;
import java.nio.charset.UnsupportedCharsetException;
import java.util.Arrays;
import junit.framework.TestCase;
@@ -536,7 +537,7 @@
try {
mediaType.charset();
fail();
- } catch (IllegalArgumentException expected) {
+ } catch (IllegalCharsetNameException expected) {
}
}
diff --git a/android/guava-tests/test/com/google/common/primitives/UnsignedLongTest.java b/android/guava-tests/test/com/google/common/primitives/UnsignedLongTest.java
index cfa2862..dd2a8ab 100644
--- a/android/guava-tests/test/com/google/common/primitives/UnsignedLongTest.java
+++ b/android/guava-tests/test/com/google/common/primitives/UnsignedLongTest.java
@@ -36,23 +36,13 @@
static {
ImmutableSet.Builder<Long> testLongsBuilder = ImmutableSet.builder();
ImmutableSet.Builder<BigInteger> testBigIntegersBuilder = ImmutableSet.builder();
-
- // The values here look like 111...11101...010 in binary, where the initial 111...1110 takes
- // up exactly as many bits as can be represented in the significand (24 for float, 53 for
- // double). That final 0 should be rounded up to 1 because the remaining bits make that number
- // slightly nearer.
- long floatConversionTest = 0xfffffe8000000002L;
- long doubleConversionTest = 0xfffffffffffff402L;
-
for (long i = -3; i <= 3; i++) {
testLongsBuilder
.add(i)
.add(Long.MAX_VALUE + i)
.add(Long.MIN_VALUE + i)
.add(Integer.MIN_VALUE + i)
- .add(Integer.MAX_VALUE + i)
- .add(floatConversionTest + i)
- .add(doubleConversionTest + i);
+ .add(Integer.MAX_VALUE + i);
BigInteger bigI = BigInteger.valueOf(i);
testBigIntegersBuilder
.add(bigI)
@@ -140,26 +130,17 @@
}
}
- @AndroidIncompatible // b/28251030, re-enable when the fix is everywhere we run this test
public void testFloatValue() {
for (long value : TEST_LONGS) {
UnsignedLong unsignedValue = UnsignedLong.fromLongBits(value);
- assertEquals(
- "Float value of " + unsignedValue,
- unsignedValue.bigIntegerValue().floatValue(),
- unsignedValue.floatValue(),
- 0.0f);
+ assertEquals(unsignedValue.bigIntegerValue().floatValue(), unsignedValue.floatValue());
}
}
public void testDoubleValue() {
for (long value : TEST_LONGS) {
UnsignedLong unsignedValue = UnsignedLong.fromLongBits(value);
- assertEquals(
- "Double value of " + unsignedValue,
- unsignedValue.bigIntegerValue().doubleValue(),
- unsignedValue.doubleValue(),
- 0.0);
+ assertEquals(unsignedValue.bigIntegerValue().doubleValue(), unsignedValue.doubleValue());
}
}
diff --git a/android/guava-tests/test/com/google/common/reflect/ClassPathTest.java b/android/guava-tests/test/com/google/common/reflect/ClassPathTest.java
index d199d1f..8bccae7 100644
--- a/android/guava-tests/test/com/google/common/reflect/ClassPathTest.java
+++ b/android/guava-tests/test/com/google/common/reflect/ClassPathTest.java
@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
package com.google.common.reflect;
import static com.google.common.base.Charsets.US_ASCII;
@@ -22,7 +23,6 @@
import com.google.common.base.Joiner;
import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableSet;
import com.google.common.io.Closer;
import com.google.common.io.Files;
import com.google.common.io.Resources;
@@ -42,7 +42,10 @@
import java.net.URLClassLoader;
import java.security.Permission;
import java.security.PermissionCollection;
+import java.util.HashSet;
+import java.util.Set;
import java.util.jar.Attributes;
+import java.util.jar.JarFile;
import java.util.jar.JarOutputStream;
import java.util.jar.Manifest;
import java.util.logging.Logger;
@@ -68,7 +71,7 @@
@AndroidIncompatible // Android forbids null parent ClassLoader
public void testClassPathEntries_emptyURLClassLoader_noParent() {
- assertThat(ClassPath.getClassPathEntries(new URLClassLoader(new URL[0], null)).keySet())
+ assertThat(ClassPath.Scanner.getClassPathEntries(new URLClassLoader(new URL[0], null)).keySet())
.isEmpty();
}
@@ -77,7 +80,7 @@
URL url1 = new URL("file:/a");
URL url2 = new URL("file:/b");
URLClassLoader classloader = new URLClassLoader(new URL[] {url1, url2}, null);
- assertThat(ClassPath.getClassPathEntries(classloader))
+ assertThat(ClassPath.Scanner.getClassPathEntries(classloader))
.containsExactly(new File("/a"), classloader, new File("/b"), classloader);
}
@@ -87,7 +90,7 @@
URL url2 = new URL("file:/b");
URLClassLoader parent = new URLClassLoader(new URL[] {url1}, null);
URLClassLoader child = new URLClassLoader(new URL[] {url2}, parent) {};
- assertThat(ClassPath.getClassPathEntries(child))
+ assertThat(ClassPath.Scanner.getClassPathEntries(child))
.containsExactly(new File("/a"), parent, new File("/b"), child)
.inOrder();
}
@@ -97,19 +100,20 @@
URL url = new URL("file:/a");
URLClassLoader parent = new URLClassLoader(new URL[] {url}, null);
URLClassLoader child = new URLClassLoader(new URL[] {url}, parent) {};
- assertThat(ClassPath.getClassPathEntries(child)).containsExactly(new File("/a"), parent);
+ assertThat(ClassPath.Scanner.getClassPathEntries(child))
+ .containsExactly(new File("/a"), parent);
}
@AndroidIncompatible // Android forbids null parent ClassLoader
public void testClassPathEntries_notURLClassLoader_noParent() {
- assertThat(ClassPath.getClassPathEntries(new ClassLoader(null) {})).isEmpty();
+ assertThat(ClassPath.Scanner.getClassPathEntries(new ClassLoader(null) {})).isEmpty();
}
@AndroidIncompatible // Android forbids null parent ClassLoader
public void testClassPathEntries_notURLClassLoader_withParent() throws Exception {
URL url = new URL("file:/a");
URLClassLoader parent = new URLClassLoader(new URL[] {url}, null);
- assertThat(ClassPath.getClassPathEntries(new ClassLoader(parent) {}))
+ assertThat(ClassPath.Scanner.getClassPathEntries(new ClassLoader(parent) {}))
.containsExactly(new File("/a"), parent);
}
@@ -119,7 +123,7 @@
URL url2 = new URL("file:/b");
URLClassLoader grandParent = new URLClassLoader(new URL[] {url1}, null);
URLClassLoader parent = new URLClassLoader(new URL[] {url2}, grandParent);
- assertThat(ClassPath.getClassPathEntries(new ClassLoader(parent) {}))
+ assertThat(ClassPath.Scanner.getClassPathEntries(new ClassLoader(parent) {}))
.containsExactly(new File("/a"), grandParent, new File("/b"), parent);
}
@@ -128,7 +132,7 @@
URL url = new URL("file:/a");
URLClassLoader grandParent = new URLClassLoader(new URL[] {url}, null);
ClassLoader parent = new ClassLoader(grandParent) {};
- assertThat(ClassPath.getClassPathEntries(new ClassLoader(parent) {}))
+ assertThat(ClassPath.Scanner.getClassPathEntries(new ClassLoader(parent) {}))
.containsExactly(new File("/a"), grandParent);
}
@@ -137,7 +141,7 @@
public void testClassPathEntries_URLClassLoader_pathWithSpace() throws Exception {
URL url = new URL("file:///c:/Documents and Settings/");
URLClassLoader classloader = new URLClassLoader(new URL[] {url}, null);
- assertThat(ClassPath.getClassPathEntries(classloader))
+ assertThat(ClassPath.Scanner.getClassPathEntries(classloader))
.containsExactly(new File("/c:/Documents and Settings/"), classloader);
}
@@ -146,7 +150,7 @@
public void testClassPathEntries_URLClassLoader_pathWithEscapedSpace() throws Exception {
URL url = new URL("file:///c:/Documents%20and%20Settings/");
URLClassLoader classloader = new URLClassLoader(new URL[] {url}, null);
- assertThat(ClassPath.getClassPathEntries(classloader))
+ assertThat(ClassPath.Scanner.getClassPathEntries(classloader))
.containsExactly(new File("/c:/Documents and Settings/"), classloader);
}
@@ -169,7 +173,6 @@
.isEqualTo(new File("/C:\\\u20320 \u22909"));
}
-
@AndroidIncompatible // Android forbids null parent ClassLoader
// https://github.com/google/guava/issues/2152
public void testJarFileWithSpaces() throws Exception {
@@ -178,83 +181,84 @@
assertThat(ClassPath.from(classloader).getTopLevelClasses()).isNotEmpty();
}
-
public void testScan_classPathCycle() throws IOException {
File jarFile = File.createTempFile("with_circular_class_path", ".jar");
try {
writeSelfReferencingJarFile(jarFile, "test.txt");
- assertThat(
- new ClassPath.LocationInfo(jarFile, ClassPathTest.class.getClassLoader())
- .scanResources())
- .hasSize(1);
+ ClassPath.DefaultScanner scanner = new ClassPath.DefaultScanner();
+ scanner.scan(jarFile, ClassPathTest.class.getClassLoader());
+ assertThat(scanner.getResources()).hasSize(1);
} finally {
jarFile.delete();
}
}
-
public void testScanFromFile_fileNotExists() throws IOException {
ClassLoader classLoader = ClassPathTest.class.getClassLoader();
- assertThat(
- new ClassPath.LocationInfo(new File("no/such/file/anywhere"), classLoader)
- .scanResources())
- .isEmpty();
+ ClassPath.DefaultScanner scanner = new ClassPath.DefaultScanner();
+ scanner.scan(new File("no/such/file/anywhere"), classLoader);
+ assertThat(scanner.getResources()).isEmpty();
}
-
public void testScanFromFile_notJarFile() throws IOException {
ClassLoader classLoader = ClassPathTest.class.getClassLoader();
File notJar = File.createTempFile("not_a_jar", "txt");
+ ClassPath.DefaultScanner scanner = new ClassPath.DefaultScanner();
try {
- assertThat(new ClassPath.LocationInfo(notJar, classLoader).scanResources()).isEmpty();
+ scanner.scan(notJar, classLoader);
} finally {
notJar.delete();
}
+ assertThat(scanner.getResources()).isEmpty();
}
public void testGetClassPathEntry() throws MalformedURLException, URISyntaxException {
assertEquals(
new File("/usr/test/dep.jar").toURI(),
- ClassPath.getClassPathEntry(new File("/home/build/outer.jar"), "file:/usr/test/dep.jar")
+ ClassPath.Scanner.getClassPathEntry(
+ new File("/home/build/outer.jar"), "file:/usr/test/dep.jar")
.toURI());
assertEquals(
new File("/home/build/a.jar").toURI(),
- ClassPath.getClassPathEntry(new File("/home/build/outer.jar"), "a.jar").toURI());
+ ClassPath.Scanner.getClassPathEntry(new File("/home/build/outer.jar"), "a.jar").toURI());
assertEquals(
new File("/home/build/x/y/z").toURI(),
- ClassPath.getClassPathEntry(new File("/home/build/outer.jar"), "x/y/z").toURI());
+ ClassPath.Scanner.getClassPathEntry(new File("/home/build/outer.jar"), "x/y/z").toURI());
assertEquals(
new File("/home/build/x/y/z.jar").toURI(),
- ClassPath.getClassPathEntry(new File("/home/build/outer.jar"), "x/y/z.jar").toURI());
+ ClassPath.Scanner.getClassPathEntry(new File("/home/build/outer.jar"), "x/y/z.jar")
+ .toURI());
assertEquals(
"/home/build/x y.jar",
- ClassPath.getClassPathEntry(new File("/home/build/outer.jar"), "x y.jar").getFile());
+ ClassPath.Scanner.getClassPathEntry(new File("/home/build/outer.jar"), "x y.jar")
+ .getFile());
}
public void testGetClassPathFromManifest_nullManifest() {
- assertThat(ClassPath.getClassPathFromManifest(new File("some.jar"), null)).isEmpty();
+ assertThat(ClassPath.Scanner.getClassPathFromManifest(new File("some.jar"), null)).isEmpty();
}
public void testGetClassPathFromManifest_noClassPath() throws IOException {
File jarFile = new File("base.jar");
- assertThat(ClassPath.getClassPathFromManifest(jarFile, manifest(""))).isEmpty();
+ assertThat(ClassPath.Scanner.getClassPathFromManifest(jarFile, manifest(""))).isEmpty();
}
public void testGetClassPathFromManifest_emptyClassPath() throws IOException {
File jarFile = new File("base.jar");
- assertThat(ClassPath.getClassPathFromManifest(jarFile, manifestClasspath(""))).isEmpty();
+ assertThat(ClassPath.Scanner.getClassPathFromManifest(jarFile, manifestClasspath("")))
+ .isEmpty();
}
public void testGetClassPathFromManifest_badClassPath() throws IOException {
File jarFile = new File("base.jar");
Manifest manifest = manifestClasspath("nosuchscheme:an_invalid^path");
- assertThat(ClassPath.getClassPathFromManifest(jarFile, manifest)).isEmpty();
+ assertThat(ClassPath.Scanner.getClassPathFromManifest(jarFile, manifest)).isEmpty();
}
public void testGetClassPathFromManifest_pathWithStrangeCharacter() throws IOException {
File jarFile = new File("base/some.jar");
Manifest manifest = manifestClasspath("file:the^file.jar");
- assertThat(ClassPath.getClassPathFromManifest(jarFile, manifest))
+ assertThat(ClassPath.Scanner.getClassPathFromManifest(jarFile, manifest))
.containsExactly(fullpath("base/the^file.jar"));
}
@@ -262,7 +266,7 @@
File jarFile = new File("base/some.jar");
// with/relative/directory is the Class-Path value in the mf file.
Manifest manifest = manifestClasspath("with/relative/dir");
- assertThat(ClassPath.getClassPathFromManifest(jarFile, manifest))
+ assertThat(ClassPath.Scanner.getClassPathFromManifest(jarFile, manifest))
.containsExactly(fullpath("base/with/relative/dir"));
}
@@ -270,7 +274,7 @@
File jarFile = new File("base/some.jar");
// with/relative/directory is the Class-Path value in the mf file.
Manifest manifest = manifestClasspath("with/relative.jar");
- assertThat(ClassPath.getClassPathFromManifest(jarFile, manifest))
+ assertThat(ClassPath.Scanner.getClassPathFromManifest(jarFile, manifest))
.containsExactly(fullpath("base/with/relative.jar"));
}
@@ -278,28 +282,28 @@
File jarFile = new File("base/some.jar");
// with/relative/directory is the Class-Path value in the mf file.
Manifest manifest = manifestClasspath("current.jar");
- assertThat(ClassPath.getClassPathFromManifest(jarFile, manifest))
+ assertThat(ClassPath.Scanner.getClassPathFromManifest(jarFile, manifest))
.containsExactly(fullpath("base/current.jar"));
}
public void testGetClassPathFromManifest_absoluteDirectory() throws IOException {
File jarFile = new File("base/some.jar");
Manifest manifest = manifestClasspath("file:/with/absolute/dir");
- assertThat(ClassPath.getClassPathFromManifest(jarFile, manifest))
+ assertThat(ClassPath.Scanner.getClassPathFromManifest(jarFile, manifest))
.containsExactly(fullpath("/with/absolute/dir"));
}
public void testGetClassPathFromManifest_absoluteJar() throws IOException {
File jarFile = new File("base/some.jar");
Manifest manifest = manifestClasspath("file:/with/absolute.jar");
- assertThat(ClassPath.getClassPathFromManifest(jarFile, manifest))
+ assertThat(ClassPath.Scanner.getClassPathFromManifest(jarFile, manifest))
.containsExactly(fullpath("/with/absolute.jar"));
}
public void testGetClassPathFromManifest_multiplePaths() throws IOException {
File jarFile = new File("base/some.jar");
Manifest manifest = manifestClasspath("file:/with/absolute.jar relative.jar relative/dir");
- assertThat(ClassPath.getClassPathFromManifest(jarFile, manifest))
+ assertThat(ClassPath.Scanner.getClassPathFromManifest(jarFile, manifest))
.containsExactly(
fullpath("/with/absolute.jar"),
fullpath("base/relative.jar"),
@@ -310,14 +314,14 @@
public void testGetClassPathFromManifest_leadingBlanks() throws IOException {
File jarFile = new File("base/some.jar");
Manifest manifest = manifestClasspath(" relative.jar");
- assertThat(ClassPath.getClassPathFromManifest(jarFile, manifest))
+ assertThat(ClassPath.Scanner.getClassPathFromManifest(jarFile, manifest))
.containsExactly(fullpath("base/relative.jar"));
}
public void testGetClassPathFromManifest_trailingBlanks() throws IOException {
File jarFile = new File("base/some.jar");
Manifest manifest = manifestClasspath("relative.jar ");
- assertThat(ClassPath.getClassPathFromManifest(jarFile, manifest))
+ assertThat(ClassPath.Scanner.getClassPathFromManifest(jarFile, manifest))
.containsExactly(fullpath("base/relative.jar"));
}
@@ -351,7 +355,6 @@
// Test that ResourceInfo.urls() returns identical content to ClassLoader.getResources()
-
public void testGetClassPathUrls() throws Exception {
String oldPathSeparator = PATH_SEPARATOR.value();
String oldClassPath = JAVA_CLASS_PATH.value();
@@ -365,7 +368,7 @@
"relative/path/to/class/root",
"/absolute/path/to/class/root"));
try {
- ImmutableList<URL> urls = ClassPath.parseJavaClassPath();
+ ImmutableList<URL> urls = ClassPath.Scanner.parseJavaClassPath();
assertThat(urls.get(0).getProtocol()).isEqualTo("file");
assertThat(urls.get(0).getAuthority()).isNull();
@@ -392,50 +395,18 @@
private static class Nested {}
-
public void testNulls() throws IOException {
new NullPointerTester().testAllPublicStaticMethods(ClassPath.class);
new NullPointerTester()
.testAllPublicInstanceMethods(ClassPath.from(getClass().getClassLoader()));
}
-
- public void testLocationsFrom_idempotentScan() throws IOException {
- ImmutableSet<ClassPath.LocationInfo> locations =
- ClassPath.locationsFrom(getClass().getClassLoader());
- assertThat(locations).isNotEmpty();
- for (ClassPath.LocationInfo location : locations) {
- ImmutableSet<ResourceInfo> resources = location.scanResources();
- assertThat(location.scanResources()).containsExactlyElementsIn(resources);
- }
+ public void testResourceScanner() throws IOException {
+ ResourceScanner scanner = new ResourceScanner();
+ scanner.scan(ClassLoader.getSystemClassLoader());
+ assertThat(scanner.resources).contains("com/google/common/reflect/ClassPathTest.class");
}
- public void testLocationsFrom_idempotentLocations() {
- ImmutableSet<ClassPath.LocationInfo> locations =
- ClassPath.locationsFrom(getClass().getClassLoader());
- assertThat(ClassPath.locationsFrom(getClass().getClassLoader()))
- .containsExactlyElementsIn(locations);
- }
-
- public void testLocationEquals() {
- ClassLoader child = getClass().getClassLoader();
- ClassLoader parent = child.getParent();
- new EqualsTester()
- .addEqualityGroup(
- new ClassPath.LocationInfo(new File("foo.jar"), child),
- new ClassPath.LocationInfo(new File("foo.jar"), child))
- .addEqualityGroup(new ClassPath.LocationInfo(new File("foo.jar"), parent))
- .addEqualityGroup(new ClassPath.LocationInfo(new File("foo"), child))
- .testEquals();
- }
-
-
- public void testScanAllResources() throws IOException {
- assertThat(scanResourceNames(ClassLoader.getSystemClassLoader()))
- .contains("com/google/common/reflect/ClassPathTest.class");
- }
-
-
public void testExistsThrowsSecurityException() throws IOException, URISyntaxException {
SecurityManager oldSecurityManager = System.getSecurityManager();
try {
@@ -450,7 +421,7 @@
// In Java 9, Logger may read the TZ database. Only disallow reading the class path URLs.
final PermissionCollection readClassPathFiles =
new FilePermission("", "read").newPermissionCollection();
- for (URL url : ClassPath.parseJavaClassPath()) {
+ for (URL url : ClassPath.Scanner.parseJavaClassPath()) {
if (url.getProtocol().equalsIgnoreCase("file")) {
file = new File(url.toURI());
readClassPathFiles.add(new FilePermission(file.getAbsolutePath(), "read"));
@@ -542,30 +513,46 @@
return new File(new File(path).toURI());
}
+ private static class ResourceScanner extends ClassPath.Scanner {
+ final Set<String> resources = new HashSet<>();
+
+ @Override
+ protected void scanResource(ResourceInfo resource) throws IOException {
+ resources.add(resource.getResourceName());
+ }
+ }
+
private static URL makeJarUrlWithName(String name) throws IOException {
File fullPath = new File(Files.createTempDir(), name);
- File jarFile = pickAnyJarFile();
+ File jarFile = JarFileFinder.pickAnyJarFile();
Files.copy(jarFile, fullPath);
return fullPath.toURI().toURL();
}
- private static File pickAnyJarFile() throws IOException {
- for (ClassPath.LocationInfo location :
- ClassPath.locationsFrom(ClassPathTest.class.getClassLoader())) {
- if (!location.file().isDirectory() && location.file().exists()) {
- return location.file();
- }
- }
- throw new AssertionError("Failed to find a jar file");
- }
+ private static final class JarFileFinder extends ClassPath.Scanner {
- private static ImmutableSet<String> scanResourceNames(ClassLoader loader) throws IOException {
- ImmutableSet.Builder<String> builder = ImmutableSet.builder();
- for (ClassPath.LocationInfo location : ClassPath.locationsFrom(loader)) {
- for (ResourceInfo resource : location.scanResources()) {
- builder.add(resource.getResourceName());
+ private File found;
+
+ static File pickAnyJarFile() throws IOException {
+ JarFileFinder finder = new JarFileFinder();
+ try {
+ finder.scan(JarFileFinder.class.getClassLoader());
+ throw new IllegalStateException("No jar file found!");
+ } catch (StopScanningException expected) {
+ return finder.found;
}
}
- return builder.build();
+
+ @Override
+ void scanJarFile(ClassLoader classloader, JarFile file) throws IOException {
+ this.found = new File(file.getName());
+ throw new StopScanningException();
+ }
+
+ @Override
+ protected void scanResource(ResourceInfo resource) {}
+
+ // Special exception just to terminate the scanning when we get any jar file to use.
+ private static final class StopScanningException extends RuntimeException {}
}
}
diff --git a/android/guava-tests/test/com/google/common/reflect/ElementTest.java b/android/guava-tests/test/com/google/common/reflect/ElementTest.java
new file mode 100644
index 0000000..abe63ba
--- /dev/null
+++ b/android/guava-tests/test/com/google/common/reflect/ElementTest.java
@@ -0,0 +1,247 @@
+/*
+ * Copyright (C) 2012 The Guava Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.google.common.reflect;
+
+import com.google.common.testing.EqualsTester;
+import com.google.common.testing.NullPointerTester;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.reflect.Constructor;
+import junit.framework.TestCase;
+
+/**
+ * Unit tests of {@link Element}.
+ *
+ * @author Ben Yu
+ */
+public class ElementTest extends TestCase {
+
+ public void testPrivateField() throws Exception {
+ Element element = A.field("privateField");
+ assertTrue(element.isPrivate());
+ assertFalse(element.isAbstract());
+ assertFalse(element.isPackagePrivate());
+ assertFalse(element.isProtected());
+ assertFalse(element.isPublic());
+ assertFalse(element.isFinal());
+ assertFalse(element.isStatic());
+ assertTrue(element.isAnnotationPresent(Tested.class));
+ }
+
+ public void testPackagePrivateField() throws Exception {
+ Element element = A.field("packagePrivateField");
+ assertFalse(element.isPrivate());
+ assertTrue(element.isPackagePrivate());
+ assertFalse(element.isProtected());
+ assertFalse(element.isPublic());
+ assertFalse(element.isFinal());
+ assertFalse(element.isStatic());
+ assertTrue(element.isAnnotationPresent(Tested.class));
+ }
+
+ public void testProtectedField() throws Exception {
+ Element element = A.field("protectedField");
+ assertFalse(element.isPrivate());
+ assertFalse(element.isPackagePrivate());
+ assertTrue(element.isProtected());
+ assertFalse(element.isPublic());
+ assertFalse(element.isFinal());
+ assertFalse(element.isStatic());
+ assertTrue(element.isAnnotationPresent(Tested.class));
+ }
+
+ public void testPublicField() throws Exception {
+ Element element = A.field("publicField");
+ assertFalse(element.isPrivate());
+ assertFalse(element.isPackagePrivate());
+ assertFalse(element.isProtected());
+ assertTrue(element.isPublic());
+ assertFalse(element.isFinal());
+ assertFalse(element.isStatic());
+ assertTrue(element.isAnnotationPresent(Tested.class));
+ }
+
+ public void testFinalField() throws Exception {
+ Element element = A.field("finalField");
+ assertTrue(element.isFinal());
+ assertFalse(element.isStatic());
+ assertTrue(element.isAnnotationPresent(Tested.class));
+ }
+
+ public void testStaticField() throws Exception {
+ Element element = A.field("staticField");
+ assertTrue(element.isStatic());
+ assertTrue(element.isAnnotationPresent(Tested.class));
+ }
+
+ public void testVolatileField() throws Exception {
+ Element element = A.field("volatileField");
+ assertTrue(element.isVolatile());
+ }
+
+ public void testTransientField() throws Exception {
+ Element element = A.field("transientField");
+ assertTrue(element.isTransient());
+ }
+
+ public void testConstructor() throws Exception {
+ Element element = A.constructor();
+ assertTrue(element.isPublic());
+ assertFalse(element.isPackagePrivate());
+ assertFalse(element.isAbstract());
+ assertFalse(element.isStatic());
+ assertTrue(element.isAnnotationPresent(Tested.class));
+ }
+
+ public void testAbstractMethod() throws Exception {
+ Element element = A.method("abstractMethod");
+ assertTrue(element.isPackagePrivate());
+ assertTrue(element.isAbstract());
+ assertFalse(element.isFinal());
+ assertTrue(element.isAnnotationPresent(Tested.class));
+ }
+
+ public void testOverridableMethod() throws Exception {
+ Element element = A.method("overridableMethod");
+ assertTrue(element.isPackagePrivate());
+ assertFalse(element.isAbstract());
+ assertFalse(element.isFinal());
+ assertTrue(element.isAnnotationPresent(Tested.class));
+ }
+
+ public void testPrivateMethod() throws Exception {
+ Element element = A.method("privateMethod");
+ assertFalse(element.isAbstract());
+ assertTrue(element.isPrivate());
+ assertFalse(element.isPackagePrivate());
+ assertFalse(element.isPublic());
+ assertFalse(element.isProtected());
+ assertTrue(element.isAnnotationPresent(Tested.class));
+ }
+
+ public void testProtectedMethod() throws Exception {
+ Element element = A.method("protectedMethod");
+ assertFalse(element.isAbstract());
+ assertFalse(element.isPrivate());
+ assertFalse(element.isPackagePrivate());
+ assertFalse(element.isFinal());
+ assertFalse(element.isPublic());
+ assertTrue(element.isProtected());
+ assertTrue(element.isAnnotationPresent(Tested.class));
+ }
+
+ public void testFinalMethod() throws Exception {
+ Element element = A.method("publicFinalMethod");
+ assertFalse(element.isAbstract());
+ assertFalse(element.isPrivate());
+ assertTrue(element.isFinal());
+ assertTrue(element.isPublic());
+ assertTrue(element.isAnnotationPresent(Tested.class));
+ }
+
+ public void testNativeMethod() throws Exception {
+ Element element = A.method("nativeMethod");
+ assertTrue(element.isNative());
+ assertTrue(element.isPackagePrivate());
+ }
+
+ public void testSynchronizedMethod() throws Exception {
+ Element element = A.method("synchronizedMethod");
+ assertTrue(element.isSynchronized());
+ }
+
+ public void testUnannotatedMethod() throws Exception {
+ Element element = A.method("notAnnotatedMethod");
+ assertFalse(element.isAnnotationPresent(Tested.class));
+ }
+
+ public void testEquals() throws Exception {
+ new EqualsTester()
+ .addEqualityGroup(A.field("privateField"), A.field("privateField"))
+ .addEqualityGroup(A.field("publicField"))
+ .addEqualityGroup(A.constructor(), A.constructor())
+ .addEqualityGroup(A.method("privateMethod"), A.method("privateMethod"))
+ .addEqualityGroup(A.method("publicFinalMethod"))
+ .testEquals();
+ }
+
+ public void testNulls() {
+ new NullPointerTester().testAllPublicStaticMethods(Element.class);
+ }
+
+ @Retention(RetentionPolicy.RUNTIME)
+ private @interface Tested {}
+
+ private abstract static class A {
+ @Tested private boolean privateField;
+ @Tested int packagePrivateField;
+ @Tested protected int protectedField;
+ @Tested public String publicField;
+ @Tested private static Iterable<String> staticField;
+ @Tested private final Object finalField;
+ private volatile char volatileField;
+ private transient long transientField;
+
+ @Tested
+ public A(Object finalField) {
+ this.finalField = finalField;
+ }
+
+ @Tested
+ abstract void abstractMethod();
+
+ @Tested
+ void overridableMethod() {}
+
+ @Tested
+ protected void protectedMethod() {}
+
+ @Tested
+ private void privateMethod() {}
+
+ @Tested
+ public final void publicFinalMethod() {}
+
+ void notAnnotatedMethod() {}
+
+ static Element field(String name) throws Exception {
+ Element element = new Element(A.class.getDeclaredField(name));
+ assertEquals(name, element.getName());
+ assertEquals(A.class, element.getDeclaringClass());
+ return element;
+ }
+
+ static Element constructor() throws Exception {
+ Constructor<?> constructor = A.class.getDeclaredConstructor(Object.class);
+ Element element = new Element(constructor);
+ assertEquals(constructor.getName(), element.getName());
+ assertEquals(A.class, element.getDeclaringClass());
+ return element;
+ }
+
+ static Element method(String name, Class<?>... parameterTypes) throws Exception {
+ Element element = new Element(A.class.getDeclaredMethod(name, parameterTypes));
+ assertEquals(name, element.getName());
+ assertEquals(A.class, element.getDeclaringClass());
+ return element;
+ }
+
+ native void nativeMethod();
+
+ synchronized void synchronizedMethod() {}
+ }
+}
diff --git a/android/guava-tests/test/com/google/common/reflect/InvokableTest.java b/android/guava-tests/test/com/google/common/reflect/InvokableTest.java
index f116ee2..816aed3 100644
--- a/android/guava-tests/test/com/google/common/reflect/InvokableTest.java
+++ b/android/guava-tests/test/com/google/common/reflect/InvokableTest.java
@@ -19,16 +19,13 @@
import static com.google.common.truth.Truth.assertThat;
import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
import com.google.common.testing.EqualsTester;
import com.google.common.testing.NullPointerTester;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
-import java.lang.reflect.AccessibleObject;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.TypeVariable;
import java.util.Collections;
@@ -42,180 +39,6 @@
*/
@AndroidIncompatible // lots of failures, possibly some related to bad equals() implementations?
public class InvokableTest extends TestCase {
- // Historically Invokable inherited from java.lang.reflect.AccessibleObject. That's no longer the
- // case, but we do check that its API still has the same public methods. We exclude some methods
- // that were added in Java 9 and that people probably weren't calling via Invokable, namely
- // `boolean canAccess(Object)`.
- public void testApiCompatibleWithAccessibleObject() {
- ImmutableSet<String> invokableMethods =
- publicMethodSignatures(Invokable.class, ImmutableSet.<String>of());
- ImmutableSet<String> accesibleObjectMethods =
- publicMethodSignatures(AccessibleObject.class, ImmutableSet.of("canAccess"));
- assertThat(invokableMethods).containsAtLeastElementsIn(accesibleObjectMethods);
- Class<?> genericDeclaration;
- try {
- genericDeclaration = Class.forName("java.lang.reflect.GenericDeclaration");
- ImmutableSet<String> genericDeclarationMethods =
- publicMethodSignatures(genericDeclaration, ImmutableSet.<String>of());
- assertThat(invokableMethods).containsAtLeastElementsIn(genericDeclarationMethods);
- } catch (ClassNotFoundException e) {
- // OK: we're on Java 7, which doesn't have this class
- }
- }
-
- private static ImmutableSet<String> publicMethodSignatures(
- Class<?> c, ImmutableSet<String> ignore) {
- ImmutableSet.Builder<String> methods = ImmutableSet.builder();
- for (Method method : c.getMethods()) {
- if (Modifier.isStatic(method.getModifiers()) || ignore.contains(method.getName())) {
- continue;
- }
- StringBuilder signature =
- new StringBuilder()
- .append(typeName(method.getReturnType()))
- .append(" ")
- .append(method.getName())
- .append("(");
- String sep = "";
- for (Class<?> param : method.getParameterTypes()) {
- signature.append(sep).append(typeName(param));
- sep = ", ";
- }
- methods.add(signature.append(")").toString());
- }
- return methods.build();
- }
-
- private static String typeName(Class<?> type) {
- return type.isArray() ? typeName(type.getComponentType()) + "[]" : type.getName();
- }
-
- public void testConstructor() throws Exception {
- Invokable<A, A> invokable = A.constructor();
- assertTrue(invokable.isPublic());
- assertFalse(invokable.isPackagePrivate());
- assertFalse(invokable.isAbstract());
- assertFalse(invokable.isStatic());
- assertTrue(invokable.isAnnotationPresent(Tested.class));
- }
-
- public void testAbstractMethod() throws Exception {
- Invokable<?, Object> invokable = A.method("abstractMethod");
- assertTrue(invokable.isPackagePrivate());
- assertTrue(invokable.isAbstract());
- assertFalse(invokable.isFinal());
- assertTrue(invokable.isAnnotationPresent(Tested.class));
- }
-
- public void testOverridableMethod() throws Exception {
- Invokable<?, Object> invokable = A.method("overridableMethod");
- assertTrue(invokable.isPackagePrivate());
- assertFalse(invokable.isAbstract());
- assertFalse(invokable.isFinal());
- assertTrue(invokable.isAnnotationPresent(Tested.class));
- }
-
- public void testPrivateMethod() throws Exception {
- Invokable<?, Object> invokable = A.method("privateMethod");
- assertFalse(invokable.isAbstract());
- assertTrue(invokable.isPrivate());
- assertFalse(invokable.isPackagePrivate());
- assertFalse(invokable.isPublic());
- assertFalse(invokable.isProtected());
- assertTrue(invokable.isAnnotationPresent(Tested.class));
- }
-
- public void testProtectedMethod() throws Exception {
- Invokable<?, Object> invokable = A.method("protectedMethod");
- assertFalse(invokable.isAbstract());
- assertFalse(invokable.isPrivate());
- assertFalse(invokable.isPackagePrivate());
- assertFalse(invokable.isFinal());
- assertFalse(invokable.isPublic());
- assertTrue(invokable.isProtected());
- assertTrue(invokable.isAnnotationPresent(Tested.class));
- }
-
- public void testFinalMethod() throws Exception {
- Invokable<?, Object> invokable = A.method("publicFinalMethod");
- assertFalse(invokable.isAbstract());
- assertFalse(invokable.isPrivate());
- assertTrue(invokable.isFinal());
- assertTrue(invokable.isPublic());
- assertTrue(invokable.isAnnotationPresent(Tested.class));
- }
-
- public void testNativeMethod() throws Exception {
- Invokable<?, Object> invokable = A.method("nativeMethod");
- assertTrue(invokable.isNative());
- assertTrue(invokable.isPackagePrivate());
- }
-
- public void testSynchronizedMethod() throws Exception {
- Invokable<?, Object> invokable = A.method("synchronizedMethod");
- assertTrue(invokable.isSynchronized());
- }
-
- public void testUnannotatedMethod() throws Exception {
- Invokable<?, Object> invokable = A.method("notAnnotatedMethod");
- assertFalse(invokable.isAnnotationPresent(Tested.class));
- }
-
- @Retention(RetentionPolicy.RUNTIME)
- private @interface Tested {}
-
- private abstract static class A {
- @Tested private boolean privateField;
- @Tested int packagePrivateField;
- @Tested protected int protectedField;
- @Tested public String publicField;
- @Tested private static Iterable<String> staticField;
- @Tested private final Object finalField;
- private volatile char volatileField;
- private transient long transientField;
-
- @Tested
- public A(Object finalField) {
- this.finalField = finalField;
- }
-
- @Tested
- abstract void abstractMethod();
-
- @Tested
- void overridableMethod() {}
-
- @Tested
- protected void protectedMethod() {}
-
- @Tested
- private void privateMethod() {}
-
- @Tested
- public final void publicFinalMethod() {}
-
- void notAnnotatedMethod() {}
-
- static Invokable<A, A> constructor() throws Exception {
- Constructor<A> constructor = A.class.getDeclaredConstructor(Object.class);
- Invokable<A, A> invokable = Invokable.from(constructor);
- assertEquals(constructor.getName(), invokable.getName());
- assertEquals(A.class, invokable.getDeclaringClass());
- return invokable;
- }
-
- static Invokable<?, Object> method(String name, Class<?>... parameterTypes) throws Exception {
- Invokable<?, Object> invokable =
- Invokable.from(A.class.getDeclaredMethod(name, parameterTypes));
- assertEquals(name, invokable.getName());
- assertEquals(A.class, invokable.getDeclaringClass());
- return invokable;
- }
-
- native void nativeMethod();
-
- synchronized void synchronizedMethod() {}
- }
public void testConstructor_returnType() throws Exception {
assertEquals(Prepender.class, Prepender.constructor().getReturnType().getType());
@@ -251,7 +74,7 @@
public void testConstructor_typeParameters() throws Exception {
TypeVariable<?>[] variables = Prepender.constructor().getTypeParameters();
assertThat(variables).hasLength(1);
- assertEquals("T", variables[0].getName());
+ assertEquals("A", variables[0].getName());
}
public void testConstructor_parameters() throws Exception {
@@ -707,9 +530,6 @@
public void testEquals() throws Exception {
new EqualsTester()
- .addEqualityGroup(A.constructor(), A.constructor())
- .addEqualityGroup(A.method("privateMethod"), A.method("privateMethod"))
- .addEqualityGroup(A.method("publicFinalMethod"))
.addEqualityGroup(Prepender.constructor(), Prepender.constructor())
.addEqualityGroup(Prepender.constructor(String.class, int.class))
.addEqualityGroup(Prepender.method("privateMethod"), Prepender.method("privateMethod"))
@@ -742,7 +562,7 @@
}
// just for testing
- private <T> Prepender() {
+ private <A> Prepender() {
this(null, 0);
}
diff --git a/android/guava-tests/test/com/google/common/util/concurrent/AbstractExecutionThreadServiceTest.java b/android/guava-tests/test/com/google/common/util/concurrent/AbstractExecutionThreadServiceTest.java
index 557fc0b..9b3f0f8 100644
--- a/android/guava-tests/test/com/google/common/util/concurrent/AbstractExecutionThreadServiceTest.java
+++ b/android/guava-tests/test/com/google/common/util/concurrent/AbstractExecutionThreadServiceTest.java
@@ -68,7 +68,6 @@
thrownByExecutionThread);
}
-
public void testServiceStartStop() throws Exception {
WaitOnRunService service = new WaitOnRunService();
assertFalse(service.startUpCalled);
@@ -85,7 +84,6 @@
executionThread.join();
}
-
public void testServiceStopIdempotence() throws Exception {
WaitOnRunService service = new WaitOnRunService();
@@ -102,7 +100,6 @@
executionThread.join();
}
-
public void testServiceExitingOnItsOwn() throws Exception {
WaitOnRunService service = new WaitOnRunService();
service.expectedShutdownState = Service.State.RUNNING;
@@ -173,7 +170,6 @@
}
}
-
public void testServiceThrowOnStartUp() throws Exception {
ThrowOnStartUpService service = new ThrowOnStartUpService();
assertFalse(service.startUpCalled);
@@ -212,7 +208,6 @@
}
}
-
public void testServiceThrowOnRun() throws Exception {
ThrowOnRunService service = new ThrowOnRunService();
@@ -229,7 +224,6 @@
assertEquals(Service.State.FAILED, service.state());
}
-
public void testServiceThrowOnRunAndThenAgainOnShutDown() throws Exception {
ThrowOnRunService service = new ThrowOnRunService();
service.throwOnShutDown = true;
@@ -271,7 +265,6 @@
}
}
-
public void testServiceThrowOnShutDown() throws Exception {
ThrowOnShutDown service = new ThrowOnShutDown();
@@ -331,7 +324,6 @@
protected void run() throws Exception {}
}
-
public void testStopWhileStarting_runNotCalled() throws Exception {
final CountDownLatch started = new CountDownLatch(1);
FakeService service =
@@ -361,7 +353,6 @@
assertEquals(0, service.shutdownCalled);
}
-
public void testDefaultService() throws InterruptedException {
WaitOnRunService service = new WaitOnRunService();
service.startAsync().awaitRunning();
diff --git a/android/guava-tests/test/com/google/common/util/concurrent/AbstractFutureFallbackAtomicHelperTest.java b/android/guava-tests/test/com/google/common/util/concurrent/AbstractFutureFallbackAtomicHelperTest.java
index 208cf24..77d04ff 100644
--- a/android/guava-tests/test/com/google/common/util/concurrent/AbstractFutureFallbackAtomicHelperTest.java
+++ b/android/guava-tests/test/com/google/common/util/concurrent/AbstractFutureFallbackAtomicHelperTest.java
@@ -107,7 +107,7 @@
private void runTestMethod(ClassLoader classLoader) throws Exception {
Class<?> test = classLoader.loadClass(AbstractFutureTest.class.getName());
- test.getMethod(getName()).invoke(test.getDeclaredConstructor().newInstance());
+ test.getMethod(getName()).invoke(test.newInstance());
}
private void checkHelperVersion(ClassLoader classLoader, String expectedHelperClassName)
diff --git a/android/guava-tests/test/com/google/common/util/concurrent/AbstractFutureTest.java b/android/guava-tests/test/com/google/common/util/concurrent/AbstractFutureTest.java
index e55a31e..3c210ce 100644
--- a/android/guava-tests/test/com/google/common/util/concurrent/AbstractFutureTest.java
+++ b/android/guava-tests/test/com/google/common/util/concurrent/AbstractFutureTest.java
@@ -579,7 +579,7 @@
final AbstractFuture<String> future = new AbstractFuture<String>() {};
currentFuture.set(future);
for (Callable<?> task : allTasks) {
- @SuppressWarnings("unused") // https://errorprone.info/bugpattern/FutureReturnValueIgnored
+ @SuppressWarnings("unused") // go/futurereturn-lsc
Future<?> possiblyIgnoredError = executor.submit(task);
}
awaitUnchecked(barrier);
@@ -798,7 +798,7 @@
final AbstractFuture<String> future = new AbstractFuture<String>() {};
currentFuture.set(future);
for (Callable<?> task : allTasks) {
- @SuppressWarnings("unused") // https://errorprone.info/bugpattern/FutureReturnValueIgnored
+ @SuppressWarnings("unused") // go/futurereturn-lsc
Future<?> possiblyIgnoredError = executor.submit(task);
}
awaitUnchecked(barrier);
diff --git a/android/guava-tests/test/com/google/common/util/concurrent/AbstractScheduledServiceTest.java b/android/guava-tests/test/com/google/common/util/concurrent/AbstractScheduledServiceTest.java
index a2411ad..16a4cd0 100644
--- a/android/guava-tests/test/com/google/common/util/concurrent/AbstractScheduledServiceTest.java
+++ b/android/guava-tests/test/com/google/common/util/concurrent/AbstractScheduledServiceTest.java
@@ -21,7 +21,6 @@
import static com.google.common.util.concurrent.MoreExecutors.directExecutor;
import static java.util.concurrent.TimeUnit.SECONDS;
-import com.google.common.util.concurrent.AbstractScheduledService.Cancellable;
import com.google.common.util.concurrent.AbstractScheduledService.Scheduler;
import com.google.common.util.concurrent.Service.State;
import com.google.common.util.concurrent.testing.TestingExecutors;
@@ -29,7 +28,6 @@
import java.util.concurrent.CancellationException;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.CyclicBarrier;
-import java.util.concurrent.Delayed;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.ScheduledExecutorService;
@@ -390,7 +388,7 @@
public void testFixedRateSchedule() {
Scheduler schedule = Scheduler.newFixedRateSchedule(initialDelay, delay, unit);
- Cancellable unused =
+ Future<?> unused =
schedule.schedule(
null,
new ScheduledThreadPoolExecutor(1) {
@@ -398,7 +396,7 @@
public ScheduledFuture<?> scheduleAtFixedRate(
Runnable command, long initialDelay, long period, TimeUnit unit) {
assertSingleCallWithCorrectParameters(command, initialDelay, delay, unit);
- return new ThrowingScheduledFuture<>();
+ return null;
}
},
testRunnable);
@@ -407,7 +405,7 @@
public void testFixedDelaySchedule() {
Scheduler schedule = newFixedDelaySchedule(initialDelay, delay, unit);
- Cancellable unused =
+ Future<?> unused =
schedule.schedule(
null,
new ScheduledThreadPoolExecutor(10) {
@@ -415,32 +413,13 @@
public ScheduledFuture<?> scheduleWithFixedDelay(
Runnable command, long initialDelay, long delay, TimeUnit unit) {
assertSingleCallWithCorrectParameters(command, initialDelay, delay, unit);
- return new ThrowingScheduledFuture<>();
+ return null;
}
},
testRunnable);
assertTrue(called);
}
- private static final class ThrowingScheduledFuture<V> extends ForwardingFuture<V>
- implements ScheduledFuture<V> {
- @Override
- protected Future<V> delegate() {
- throw new UnsupportedOperationException("test should not care about this");
- }
-
- @Override
- public long getDelay(TimeUnit unit) {
- throw new UnsupportedOperationException("test should not care about this");
- }
-
- @Override
- public int compareTo(Delayed other) {
- throw new UnsupportedOperationException("test should not care about this");
- }
- }
-
-
public void testFixedDelayScheduleFarFuturePotentiallyOverflowingScheduleIsNeverReached()
throws Exception {
TestAbstractScheduledCustomService service =
@@ -461,7 +440,6 @@
service.awaitTerminated();
}
-
public void testCustomSchedulerFarFuturePotentiallyOverflowingScheduleIsNeverReached()
throws Exception {
TestAbstractScheduledCustomService service =
@@ -497,7 +475,6 @@
}
}
-
public void testCustomSchedule_startStop() throws Exception {
final CyclicBarrier firstBarrier = new CyclicBarrier(2);
final CyclicBarrier secondBarrier = new CyclicBarrier(2);
@@ -517,7 +494,7 @@
}
};
TestCustomScheduler scheduler = new TestCustomScheduler();
- Cancellable future = scheduler.schedule(null, Executors.newScheduledThreadPool(10), task);
+ Future<?> future = scheduler.schedule(null, Executors.newScheduledThreadPool(10), task);
firstBarrier.await();
assertEquals(1, scheduler.scheduleCounter.get());
secondBarrier.await();
@@ -528,7 +505,6 @@
future.cancel(false);
}
-
public void testCustomSchedulerServiceStop() throws Exception {
TestAbstractScheduledCustomService service = new TestAbstractScheduledCustomService();
service.startAsync().awaitRunning();
@@ -542,7 +518,6 @@
assertEquals(1, service.numIterations.get());
}
-
public void testCustomScheduler_deadlock() throws InterruptedException, BrokenBarrierException {
final CyclicBarrier inGetNextSchedule = new CyclicBarrier(2);
// This will flakily deadlock, so run it multiple times to increase the flake likelihood
@@ -573,7 +548,6 @@
}
}
-
public void testBig() throws Exception {
TestAbstractScheduledCustomService service =
new TestAbstractScheduledCustomService() {
@@ -633,7 +607,6 @@
}
}
-
public void testCustomSchedulerFailure() throws Exception {
TestFailingCustomScheduledService service = new TestFailingCustomScheduledService();
service.startAsync().awaitRunning();
diff --git a/android/guava-tests/test/com/google/common/util/concurrent/AbstractServiceTest.java b/android/guava-tests/test/com/google/common/util/concurrent/AbstractServiceTest.java
index e3c22a8..5f42106 100644
--- a/android/guava-tests/test/com/google/common/util/concurrent/AbstractServiceTest.java
+++ b/android/guava-tests/test/com/google/common/util/concurrent/AbstractServiceTest.java
@@ -330,7 +330,6 @@
}
}
-
public void testAwaitTerminated() throws Exception {
final NoOpService service = new NoOpService();
Thread waiter =
@@ -348,7 +347,6 @@
assertFalse(waiter.isAlive());
}
-
public void testAwaitTerminated_FailedService() throws Exception {
final ManualSwitchedService service = new ManualSwitchedService();
final AtomicReference<Throwable> exception = Atomics.newReference();
@@ -376,7 +374,6 @@
assertThat(exception.get()).hasCauseThat().isEqualTo(EXCEPTION);
}
-
public void testThreadedServiceStartAndWaitStopAndWait() throws Throwable {
ThreadedService service = new ThreadedService();
RecordingListener listener = RecordingListener.record(service);
@@ -394,7 +391,6 @@
listener.getStateHistory());
}
-
public void testThreadedServiceStopIdempotence() throws Throwable {
ThreadedService service = new ThreadedService();
@@ -410,7 +406,6 @@
throwIfSet(thrownByExecutionThread);
}
-
public void testThreadedServiceStopIdempotenceAfterWait() throws Throwable {
ThreadedService service = new ThreadedService();
@@ -428,7 +423,6 @@
throwIfSet(thrownByExecutionThread);
}
-
public void testThreadedServiceStopIdempotenceDoubleWait() throws Throwable {
ThreadedService service = new ThreadedService();
@@ -661,7 +655,6 @@
}
}
-
public void testAddListenerAfterFailureDoesntCauseDeadlock() throws InterruptedException {
final StartFailingService service = new StartFailingService();
service.startAsync();
@@ -681,7 +674,6 @@
assertFalse(thread + " is deadlocked", thread.isAlive());
}
-
public void testListenerDoesntDeadlockOnStartAndWaitFromRunning() throws Exception {
final NoOpThreadedService service = new NoOpThreadedService();
service.addListener(
@@ -696,7 +688,6 @@
service.stopAsync();
}
-
public void testListenerDoesntDeadlockOnStopAndWaitFromTerminated() throws Exception {
final NoOpThreadedService service = new NoOpThreadedService();
service.addListener(
diff --git a/android/guava-tests/test/com/google/common/util/concurrent/AggregateFutureStateFallbackAtomicHelperTest.java b/android/guava-tests/test/com/google/common/util/concurrent/AggregateFutureStateFallbackAtomicHelperTest.java
index fec9394..761f7d7 100644
--- a/android/guava-tests/test/com/google/common/util/concurrent/AggregateFutureStateFallbackAtomicHelperTest.java
+++ b/android/guava-tests/test/com/google/common/util/concurrent/AggregateFutureStateFallbackAtomicHelperTest.java
@@ -95,7 +95,7 @@
private void runTestMethod(ClassLoader classLoader) throws Exception {
Class<?> test = classLoader.loadClass(FuturesTest.class.getName());
- Object testInstance = test.getDeclaredConstructor().newInstance();
+ Object testInstance = test.newInstance();
test.getMethod("setUp").invoke(testInstance);
test.getMethod(getName()).invoke(testInstance);
test.getMethod("tearDown").invoke(testInstance);
diff --git a/android/guava-tests/test/com/google/common/util/concurrent/AtomicDoubleTest.java b/android/guava-tests/test/com/google/common/util/concurrent/AtomicDoubleTest.java
index fe68e00..468ee38 100644
--- a/android/guava-tests/test/com/google/common/util/concurrent/AtomicDoubleTest.java
+++ b/android/guava-tests/test/com/google/common/util/concurrent/AtomicDoubleTest.java
@@ -13,7 +13,6 @@
package com.google.common.util.concurrent;
-
/** Unit test for {@link AtomicDouble}. */
public class AtomicDoubleTest extends JSR166TestCase {
diff --git a/android/guava-tests/test/com/google/common/util/concurrent/AtomicLongMapBasherTest.java b/android/guava-tests/test/com/google/common/util/concurrent/AtomicLongMapBasherTest.java
index 4765825..d905dcd 100644
--- a/android/guava-tests/test/com/google/common/util/concurrent/AtomicLongMapBasherTest.java
+++ b/android/guava-tests/test/com/google/common/util/concurrent/AtomicLongMapBasherTest.java
@@ -47,7 +47,7 @@
ExecutorService threadPool = Executors.newFixedThreadPool(nThreads);
for (int i = 0; i < nTasks; i++) {
- @SuppressWarnings("unused") // https://errorprone.info/bugpattern/FutureReturnValueIgnored
+ @SuppressWarnings("unused") // go/futurereturn-lsc
Future<?> possiblyIgnoredError =
threadPool.submit(
new Runnable() {
diff --git a/android/guava-tests/test/com/google/common/util/concurrent/ClosingFutureTest.java b/android/guava-tests/test/com/google/common/util/concurrent/ClosingFutureTest.java
index f5f12db..66c8d6d 100644
--- a/android/guava-tests/test/com/google/common/util/concurrent/ClosingFutureTest.java
+++ b/android/guava-tests/test/com/google/common/util/concurrent/ClosingFutureTest.java
@@ -38,7 +38,6 @@
import com.google.common.reflect.Reflection;
import com.google.common.truth.FailureStrategy;
import com.google.common.truth.StandardSubjectBuilder;
-import com.google.common.util.concurrent.ClosingFuture.AsyncClosingCallable;
import com.google.common.util.concurrent.ClosingFuture.AsyncClosingFunction;
import com.google.common.util.concurrent.ClosingFuture.ClosingCallable;
import com.google.common.util.concurrent.ClosingFuture.ClosingFunction;
@@ -268,76 +267,6 @@
assertClosed(closeable1, closeable2);
}
- public void testSubmitAsync() throws Exception {
- ClosingFuture<TestCloseable> closingFuture =
- ClosingFuture.submitAsync(
- new AsyncClosingCallable<TestCloseable>() {
- @Override
- public ClosingFuture<TestCloseable> call(DeferredCloser closer) {
- closer.eventuallyClose(closeable1, closingExecutor);
- return ClosingFuture.submit(
- new ClosingCallable<TestCloseable>() {
- @Override
- public TestCloseable call(DeferredCloser deferredCloser) throws Exception {
- return closeable2;
- }
- },
- directExecutor());
- }
- },
- executor);
- assertThat(getFinalValue(closingFuture)).isSameInstanceAs(closeable2);
- waitUntilClosed(closingFuture);
- assertClosed(closeable1);
- assertStillOpen(closeable2);
- }
-
- public void testSubmitAsync_cancelledPipeline() throws Exception {
- ClosingFuture<TestCloseable> closingFuture =
- ClosingFuture.submitAsync(
- waiter.waitFor(
- new AsyncClosingCallable<TestCloseable>() {
- @Override
- public ClosingFuture<TestCloseable> call(DeferredCloser closer) throws Exception {
- awaitUninterruptibly(futureCancelled);
- closer.eventuallyClose(closeable1, closingExecutor);
- closer.eventuallyClose(closeable2, closingExecutor);
- return ClosingFuture.submit(
- new ClosingCallable<TestCloseable>() {
- @Override
- public TestCloseable call(DeferredCloser deferredCloser)
- throws Exception {
- deferredCloser.eventuallyClose(closeable3, closingExecutor);
- return closeable3;
- }
- },
- directExecutor());
- }
- }),
- executor);
- waiter.awaitStarted();
- cancelFinalStepAndWait(closingFuture);
- waiter.awaitReturned();
- assertClosed(closeable1, closeable2, closeable3);
- }
-
- public void testSubmitAsync_throws() throws Exception {
- ClosingFuture<Object> closingFuture =
- ClosingFuture.submitAsync(
- new AsyncClosingCallable<Object>() {
- @Override
- public ClosingFuture<Object> call(DeferredCloser closer) throws Exception {
- closer.eventuallyClose(closeable1, closingExecutor);
- closer.eventuallyClose(closeable2, closingExecutor);
- throw exception;
- }
- },
- executor);
- assertFinallyFailsWithException(closingFuture);
- waitUntilClosed(closingFuture);
- assertClosed(closeable1, closeable2);
- }
-
public void testStatusFuture() throws Exception {
ClosingFuture<String> closingFuture =
ClosingFuture.submit(
@@ -1908,10 +1837,6 @@
return waitFor(closingCallable, ClosingCallable.class);
}
- <V> AsyncClosingCallable<V> waitFor(AsyncClosingCallable<V> asyncClosingCallable) {
- return waitFor(asyncClosingCallable, AsyncClosingCallable.class);
- }
-
<T, U> ClosingFunction<T, U> waitFor(ClosingFunction<T, U> closingFunction) {
return waitFor(closingFunction, ClosingFunction.class);
}
diff --git a/android/guava-tests/test/com/google/common/util/concurrent/CycleDetectingLockFactoryTest.java b/android/guava-tests/test/com/google/common/util/concurrent/CycleDetectingLockFactoryTest.java
index 18e69b1..5abe6ce 100644
--- a/android/guava-tests/test/com/google/common/util/concurrent/CycleDetectingLockFactoryTest.java
+++ b/android/guava-tests/test/com/google/common/util/concurrent/CycleDetectingLockFactoryTest.java
@@ -16,7 +16,6 @@
package com.google.common.util.concurrent;
-
import com.google.common.base.Joiner;
import com.google.common.util.concurrent.CycleDetectingLockFactory.Policies;
import com.google.common.util.concurrent.CycleDetectingLockFactory.Policy;
@@ -442,7 +441,6 @@
lockD.lock();
}
-
public void testReentrantLock_tryLock() throws Exception {
LockingThread thread = new LockingThread(lockA);
thread.start();
@@ -454,7 +452,6 @@
assertTrue(lockA.tryLock());
}
-
public void testReentrantWriteLock_tryLock() throws Exception {
LockingThread thread = new LockingThread(writeLockA);
thread.start();
@@ -468,7 +465,6 @@
assertTrue(readLockA.tryLock());
}
-
public void testReentrantReadLock_tryLock() throws Exception {
LockingThread thread = new LockingThread(readLockA);
thread.start();
diff --git a/android/guava-tests/test/com/google/common/util/concurrent/ExecutionListTest.java b/android/guava-tests/test/com/google/common/util/concurrent/ExecutionListTest.java
index 5bd3cf7..34678ed 100644
--- a/android/guava-tests/test/com/google/common/util/concurrent/ExecutionListTest.java
+++ b/android/guava-tests/test/com/google/common/util/concurrent/ExecutionListTest.java
@@ -36,7 +36,6 @@
private final ExecutionList list = new ExecutionList();
-
public void testRunOnPopulatedList() throws Exception {
Executor exec = Executors.newCachedThreadPool();
CountDownLatch countDownLatch = new CountDownLatch(3);
@@ -67,7 +66,6 @@
assertEquals(1, runCalled.get());
}
-
public void testExecute_idempotentConcurrently() throws InterruptedException {
final CountDownLatch okayToRun = new CountDownLatch(1);
final AtomicInteger runCalled = new AtomicInteger();
@@ -103,7 +101,6 @@
assertEquals(1, runCalled.get());
}
-
public void testAddAfterRun() throws Exception {
// Run the previous test
testRunOnPopulatedList();
diff --git a/android/guava-tests/test/com/google/common/util/concurrent/ExecutionSequencerTest.java b/android/guava-tests/test/com/google/common/util/concurrent/ExecutionSequencerTest.java
index 1c03f5a..687f226 100644
--- a/android/guava-tests/test/com/google/common/util/concurrent/ExecutionSequencerTest.java
+++ b/android/guava-tests/test/com/google/common/util/concurrent/ExecutionSequencerTest.java
@@ -88,7 +88,6 @@
assertThat(thirdCallable.called).isTrue();
}
-
public void testCancellationMultipleThreads() throws Exception {
final BlockingCallable blockingCallable = new BlockingCallable();
ListenableFuture<Void> unused = serializer.submit(blockingCallable, executor);
@@ -116,7 +115,6 @@
assertThat(getDone(future2)).isFalse();
}
-
public void testSecondTaskWaitsForFirstEvenIfCancelled() throws Exception {
final BlockingCallable blockingCallable = new BlockingCallable();
ListenableFuture<Void> future1 = serializer.submit(blockingCallable, executor);
diff --git a/android/guava-tests/test/com/google/common/util/concurrent/FluentFutureTest.java b/android/guava-tests/test/com/google/common/util/concurrent/FluentFutureTest.java
index cc4751d..ab53f53 100644
--- a/android/guava-tests/test/com/google/common/util/concurrent/FluentFutureTest.java
+++ b/android/guava-tests/test/com/google/common/util/concurrent/FluentFutureTest.java
@@ -132,7 +132,6 @@
assertThat(f.get()).isEqualTo(2);
}
-
@GwtIncompatible // withTimeout
public void testWithTimeout() throws Exception {
ScheduledExecutorService executor = newScheduledThreadPool(1);
diff --git a/android/guava-tests/test/com/google/common/util/concurrent/ForwardingObjectTester.java b/android/guava-tests/test/com/google/common/util/concurrent/ForwardingObjectTester.java
index 84b0426..021d96d 100644
--- a/android/guava-tests/test/com/google/common/util/concurrent/ForwardingObjectTester.java
+++ b/android/guava-tests/test/com/google/common/util/concurrent/ForwardingObjectTester.java
@@ -61,7 +61,7 @@
new Function<Object, T>() {
@Override
public T apply(Object delegate) {
- T mock = mock(forwarderClass, CALLS_REAL_METHODS);
+ T mock = mock(forwarderClass, CALLS_REAL_METHODS.get());
try {
T stubber = doReturn(delegate).when(mock);
DELEGATE_METHOD.invoke(stubber);
diff --git a/android/guava-tests/test/com/google/common/util/concurrent/FuturesGetCheckedTest.java b/android/guava-tests/test/com/google/common/util/concurrent/FuturesGetCheckedTest.java
index 3bc69bd..2ec1736 100644
--- a/android/guava-tests/test/com/google/common/util/concurrent/FuturesGetCheckedTest.java
+++ b/android/guava-tests/test/com/google/common/util/concurrent/FuturesGetCheckedTest.java
@@ -353,7 +353,6 @@
public static final class WillBeUnloadedException extends Exception {}
-
public void testGetChecked_classUnloading() throws Exception {
WeakReference<?> classUsedByGetChecked = doTestClassUnloading();
GcFinalization.awaitClear(classUsedByGetChecked);
@@ -381,8 +380,5 @@
* environment that forces Futures.getChecked to its fallback WeakSetValidator. One awful way of
* doing so would be to derive a separate test library by using remove_from_jar to strip out
* ClassValueValidator.
- *
- * Fortunately, we get pretty good coverage "by accident": We run all these tests against the
- * *backport*, where ClassValueValidator is not present.
*/
}
diff --git a/android/guava-tests/test/com/google/common/util/concurrent/FuturesTest.java b/android/guava-tests/test/com/google/common/util/concurrent/FuturesTest.java
index fa3b14a..797ee48 100644
--- a/android/guava-tests/test/com/google/common/util/concurrent/FuturesTest.java
+++ b/android/guava-tests/test/com/google/common/util/concurrent/FuturesTest.java
@@ -3375,13 +3375,11 @@
: pseudoTimedGetUninterruptibly(future, 2500, MILLISECONDS);
}
-
@GwtIncompatible // threads
public void testAllAsList_extensive() throws InterruptedException {
runExtensiveMergerTest(Merger.allMerger);
}
-
@GwtIncompatible // threads
public void testSuccessfulAsList_extensive() throws InterruptedException {
runExtensiveMergerTest(Merger.successMerger);
diff --git a/android/guava-tests/test/com/google/common/util/concurrent/FuturesTransformAsyncTest.java b/android/guava-tests/test/com/google/common/util/concurrent/FuturesTransformAsyncTest.java
index d0fcee2..2499020 100644
--- a/android/guava-tests/test/com/google/common/util/concurrent/FuturesTransformAsyncTest.java
+++ b/android/guava-tests/test/com/google/common/util/concurrent/FuturesTransformAsyncTest.java
@@ -131,7 +131,6 @@
}
}
-
public void testFutureCancellableBeforeFunctionCompletion() throws Exception {
// Set the result in a separate thread since this test runs the function
// (which will block) in the same thread.
diff --git a/android/guava-tests/test/com/google/common/util/concurrent/InterruptibleMonitorTest.java b/android/guava-tests/test/com/google/common/util/concurrent/InterruptibleMonitorTest.java
index 4d7a45f..f0727da 100644
--- a/android/guava-tests/test/com/google/common/util/concurrent/InterruptibleMonitorTest.java
+++ b/android/guava-tests/test/com/google/common/util/concurrent/InterruptibleMonitorTest.java
@@ -16,7 +16,6 @@
package com.google.common.util.concurrent;
-
/**
* Tests for {@link Monitor}'s interruptible methods.
*
diff --git a/android/guava-tests/test/com/google/common/util/concurrent/InterruptibleTaskTest.java b/android/guava-tests/test/com/google/common/util/concurrent/InterruptibleTaskTest.java
index afa7eae..8f91bcc 100644
--- a/android/guava-tests/test/com/google/common/util/concurrent/InterruptibleTaskTest.java
+++ b/android/guava-tests/test/com/google/common/util/concurrent/InterruptibleTaskTest.java
@@ -17,15 +17,12 @@
import static com.google.common.truth.Truth.assertThat;
-import java.lang.reflect.Method;
import java.nio.channels.spi.AbstractInterruptibleChannel;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
-import java.util.concurrent.locks.AbstractOwnableSynchronizer;
import java.util.concurrent.locks.LockSupport;
import junit.framework.TestCase;
-
public final class InterruptibleTaskTest extends TestCase {
// Regression test for a deadlock where a task could be stuck busy waiting for the task to
@@ -54,10 +51,7 @@
}
@Override
- void afterRanInterruptiblySuccess(Void result) {}
-
- @Override
- void afterRanInterruptiblyFailure(Throwable error) {}
+ void afterRanInterruptibly(Void result, Throwable error) {}
};
Thread runner = new Thread(task);
runner.start();
@@ -120,38 +114,25 @@
}
@Override
- void afterRanInterruptiblySuccess(Void result) {}
-
- @Override
- void afterRanInterruptiblyFailure(Throwable error) {}
+ void afterRanInterruptibly(Void result, Throwable error) {}
};
Thread runner = new Thread(task, "runner");
runner.start();
isInterruptibleRegistered.await();
// trigger the interrupt on another thread since it will block
- Thread interrupter =
- new Thread("Interrupter") {
- @Override
- public void run() {
- task.interruptTask();
- }
- };
- interrupter.start();
+ new Thread("Interrupter") {
+ @Override
+ public void run() {
+ task.interruptTask();
+ }
+ }.start();
// this will happen once the interrupt has been set which means that
// 1. the runner has been woken up
// 2. the interrupter is stuck in the call the Thread.interrupt()
// after some period of time the runner thread should become blocked on the task because it is
// waiting for the slow interrupting thread to complete Thread.interrupt
- awaitBlockedOnInstanceOf(runner, InterruptibleTask.Blocker.class);
-
- Object blocker = LockSupport.getBlocker(runner);
- assertThat(blocker).isInstanceOf(AbstractOwnableSynchronizer.class);
- Method getExclusiveOwnerThread =
- AbstractOwnableSynchronizer.class.getDeclaredMethod("getExclusiveOwnerThread");
- getExclusiveOwnerThread.setAccessible(true);
- Thread owner = (Thread) getExclusiveOwnerThread.invoke(blocker);
- assertThat(owner).isSameInstanceAs(interrupter);
+ awaitBlockedOn(runner, task);
slowChannel.exitClose.countDown(); // release the interrupter
@@ -161,9 +142,8 @@
}
// waits for the given thread to be blocked on the given object
- private static void awaitBlockedOnInstanceOf(Thread t, Class<?> blocker)
- throws InterruptedException {
- while (!isThreadBlockedOnInstanceOf(t, blocker)) {
+ private static void awaitBlockedOn(Thread t, Object blocker) throws InterruptedException {
+ while (!isThreadBlockedOn(t, blocker)) {
if (t.getState() == Thread.State.TERMINATED) {
throw new RuntimeException("Thread " + t + " exited unexpectedly");
}
@@ -171,8 +151,8 @@
}
}
- private static boolean isThreadBlockedOnInstanceOf(Thread t, Class<?> blocker) {
- return t.getState() == Thread.State.WAITING && blocker.isInstance(LockSupport.getBlocker(t));
+ private static boolean isThreadBlockedOn(Thread t, Object blocker) {
+ return t.getState() == Thread.State.WAITING && LockSupport.getBlocker(t) == blocker;
}
static final class SlowChannel extends AbstractInterruptibleChannel {
diff --git a/android/guava-tests/test/com/google/common/util/concurrent/JSR166TestCase.java b/android/guava-tests/test/com/google/common/util/concurrent/JSR166TestCase.java
index 2f8e1b7..0822ae1 100644
--- a/android/guava-tests/test/com/google/common/util/concurrent/JSR166TestCase.java
+++ b/android/guava-tests/test/com/google/common/util/concurrent/JSR166TestCase.java
@@ -675,7 +675,7 @@
/**
* Returns the number of milliseconds since time given by startNanoTime, which must have been
- * previously returned from a call to {@link System#nanoTime()}.
+ * previously returned from a call to {@link System.nanoTime()}.
*/
long millisElapsedSince(long startNanoTime) {
return NANOSECONDS.toMillis(System.nanoTime() - startNanoTime);
diff --git a/android/guava-tests/test/com/google/common/util/concurrent/JdkFutureAdaptersTest.java b/android/guava-tests/test/com/google/common/util/concurrent/JdkFutureAdaptersTest.java
index 3bb819a..741ff45 100644
--- a/android/guava-tests/test/com/google/common/util/concurrent/JdkFutureAdaptersTest.java
+++ b/android/guava-tests/test/com/google/common/util/concurrent/JdkFutureAdaptersTest.java
@@ -100,7 +100,6 @@
assertTrue(listenableFuture.isDone());
}
-
public void testListenInPoolThreadUsesGivenExecutor() throws Exception {
ExecutorService executorService =
newCachedThreadPool(new ThreadFactoryBuilder().setDaemon(true).build());
@@ -125,7 +124,6 @@
assertTrue(listenableFuture.isDone());
}
-
public void testListenInPoolThreadCustomExecutorInterrupted() throws Exception {
final CountDownLatch submitSuccessful = new CountDownLatch(1);
ExecutorService executorService =
@@ -235,7 +233,6 @@
}
}
-
@SuppressWarnings("IsInstanceIncompatibleType") // intentional.
public void testListenInPoolThreadRunsListenerAfterRuntimeException() throws Exception {
RuntimeExceptionThrowingFuture<String> input = new RuntimeExceptionThrowingFuture<>();
diff --git a/android/guava-tests/test/com/google/common/util/concurrent/ListenableFutureTaskTest.java b/android/guava-tests/test/com/google/common/util/concurrent/ListenableFutureTaskTest.java
index 8969a75..fd51a73 100644
--- a/android/guava-tests/test/com/google/common/util/concurrent/ListenableFutureTaskTest.java
+++ b/android/guava-tests/test/com/google/common/util/concurrent/ListenableFutureTaskTest.java
@@ -80,7 +80,6 @@
super.tearDown();
}
-
public void testListenerDoesNotRunUntilTaskCompletes() throws Exception {
// Test default state of not started.
@@ -106,7 +105,6 @@
assertFalse(task.isCancelled());
}
-
public void testListenerCalledOnException() throws Exception {
throwException = true;
@@ -142,7 +140,6 @@
assertEquals(1, runLatch.getCount());
}
-
public void testListenerCalledOnCancelFromRunning() throws Exception {
exec.execute(task);
runLatch.await();
diff --git a/android/guava-tests/test/com/google/common/util/concurrent/ListenerCallQueueTest.java b/android/guava-tests/test/com/google/common/util/concurrent/ListenerCallQueueTest.java
index 5fd9b95..e0eb32e 100644
--- a/android/guava-tests/test/com/google/common/util/concurrent/ListenerCallQueueTest.java
+++ b/android/guava-tests/test/com/google/common/util/concurrent/ListenerCallQueueTest.java
@@ -129,7 +129,6 @@
logHandler.getStoredLogRecords().get(0).getMessage());
}
-
public void testEnqueueAndDispatch_multithreaded() throws InterruptedException {
Object listener = new Object();
ExecutorService service = Executors.newFixedThreadPool(4);
@@ -153,7 +152,6 @@
}
}
-
public void testEnqueueAndDispatch_multithreaded_withThrowingRunnable()
throws InterruptedException {
Object listener = new Object();
diff --git a/android/guava-tests/test/com/google/common/util/concurrent/MoreExecutorsTest.java b/android/guava-tests/test/com/google/common/util/concurrent/MoreExecutorsTest.java
index fe4e7f5..08c8f19 100644
--- a/android/guava-tests/test/com/google/common/util/concurrent/MoreExecutorsTest.java
+++ b/android/guava-tests/test/com/google/common/util/concurrent/MoreExecutorsTest.java
@@ -88,7 +88,6 @@
public void run() {}
};
-
public void testDirectExecutorServiceServiceInThreadExecution() throws Exception {
final ListeningExecutorService executor = newDirectExecutorService();
final ThreadLocal<Integer> threadLocalCount =
@@ -168,7 +167,6 @@
assertEquals(10, threadLocalCount.get().intValue());
}
-
public void testDirectExecutorServiceServiceTermination() throws Exception {
final ExecutorService executor = newDirectExecutorService();
final CyclicBarrier barrier = new CyclicBarrier(2);
@@ -354,7 +352,6 @@
verify(delegate).execute(task);
}
-
public void testListeningDecorator_scheduleSuccess() throws Exception {
final CountDownLatch completed = new CountDownLatch(1);
ScheduledThreadPoolExecutor delegate =
@@ -380,7 +377,6 @@
assertEquals(0, delegate.getQueue().size());
}
-
public void testListeningDecorator_scheduleFailure() throws Exception {
ScheduledThreadPoolExecutor delegate = new ScheduledThreadPoolExecutor(1);
ListeningScheduledExecutorService service = listeningDecorator(delegate);
@@ -391,7 +387,6 @@
assertEquals(0, delegate.getQueue().size());
}
-
public void testListeningDecorator_schedulePeriodic() throws Exception {
ScheduledThreadPoolExecutor delegate = new ScheduledThreadPoolExecutor(1);
ListeningScheduledExecutorService service = listeningDecorator(delegate);
@@ -412,7 +407,6 @@
assertEquals(0, delegate.getQueue().size());
}
-
public void testListeningDecorator_cancelled() throws Exception {
ScheduledThreadPoolExecutor delegate = new ScheduledThreadPoolExecutor(1);
BlockingQueue<?> delegateQueue = delegate.getQueue();
@@ -566,7 +560,6 @@
}
}
-
public void testAddDelayedShutdownHook_success() throws InterruptedException {
TestApplication application = new TestApplication();
ExecutorService service = mock(ExecutorService.class);
@@ -578,7 +571,6 @@
shutdownFirst.verify(service).awaitTermination(2, TimeUnit.SECONDS);
}
-
public void testAddDelayedShutdownHook_interrupted() throws InterruptedException {
TestApplication application = new TestApplication();
ExecutorService service = mock(ExecutorService.class);
@@ -588,7 +580,6 @@
verify(service).shutdown();
}
-
public void testGetExitingExecutorService_executorSetToUseDaemonThreads() {
TestApplication application = new TestApplication();
ThreadPoolExecutor executor =
@@ -597,7 +588,6 @@
assertTrue(executor.getThreadFactory().newThread(EMPTY_RUNNABLE).isDaemon());
}
-
public void testGetExitingExecutorService_executorDelegatesToOriginal() {
TestApplication application = new TestApplication();
ThreadPoolExecutor executor = mock(ThreadPoolExecutor.class);
@@ -607,7 +597,6 @@
verify(executor).execute(EMPTY_RUNNABLE);
}
-
public void testGetExitingExecutorService_shutdownHookRegistered() throws InterruptedException {
TestApplication application = new TestApplication();
ThreadPoolExecutor executor = mock(ThreadPoolExecutor.class);
@@ -618,7 +607,6 @@
verify(executor).shutdown();
}
-
public void testGetExitingScheduledExecutorService_executorSetToUseDaemonThreads() {
TestApplication application = new TestApplication();
ScheduledThreadPoolExecutor executor = new ScheduledThreadPoolExecutor(1);
@@ -626,7 +614,6 @@
assertTrue(executor.getThreadFactory().newThread(EMPTY_RUNNABLE).isDaemon());
}
-
public void testGetExitingScheduledExecutorService_executorDelegatesToOriginal() {
TestApplication application = new TestApplication();
ScheduledThreadPoolExecutor executor = mock(ScheduledThreadPoolExecutor.class);
@@ -636,7 +623,6 @@
verify(executor).execute(EMPTY_RUNNABLE);
}
-
public void testGetScheduledExitingExecutorService_shutdownHookRegistered()
throws InterruptedException {
TestApplication application = new TestApplication();
@@ -669,7 +655,6 @@
assertEquals(oldName, Thread.currentThread().getName());
}
-
public void testExecutors_nullCheck() throws Exception {
new ClassSanityTester()
.setDefault(RateLimiter.class, RateLimiter.create(1.0))
@@ -699,14 +684,12 @@
/* Half of a 1-second timeout in nanoseconds */
private static final long HALF_SECOND_NANOS = NANOSECONDS.convert(1L, SECONDS) / 2;
-
public void testShutdownAndAwaitTermination_immediateShutdown() throws Exception {
ExecutorService service = Executors.newSingleThreadExecutor();
assertTrue(shutdownAndAwaitTermination(service, 1L, SECONDS));
assertTrue(service.isTerminated());
}
-
public void testShutdownAndAwaitTermination_immediateShutdownInternal() throws Exception {
ExecutorService service = mock(ExecutorService.class);
when(service.awaitTermination(HALF_SECOND_NANOS, NANOSECONDS)).thenReturn(true);
@@ -716,7 +699,6 @@
verify(service).awaitTermination(HALF_SECOND_NANOS, NANOSECONDS);
}
-
public void testShutdownAndAwaitTermination_forcedShutDownInternal() throws Exception {
ExecutorService service = mock(ExecutorService.class);
when(service.awaitTermination(HALF_SECOND_NANOS, NANOSECONDS))
@@ -729,7 +711,6 @@
verify(service).shutdownNow();
}
-
public void testShutdownAndAwaitTermination_nonTerminationInternal() throws Exception {
ExecutorService service = mock(ExecutorService.class);
when(service.awaitTermination(HALF_SECOND_NANOS, NANOSECONDS))
@@ -741,7 +722,6 @@
verify(service).shutdownNow();
}
-
public void testShutdownAndAwaitTermination_interruptedInternal() throws Exception {
final ExecutorService service = mock(ExecutorService.class);
when(service.awaitTermination(HALF_SECOND_NANOS, NANOSECONDS))
diff --git a/android/guava-tests/test/com/google/common/util/concurrent/SequentialExecutorTest.java b/android/guava-tests/test/com/google/common/util/concurrent/SequentialExecutorTest.java
index 20209e8..ff9e311 100644
--- a/android/guava-tests/test/com/google/common/util/concurrent/SequentialExecutorTest.java
+++ b/android/guava-tests/test/com/google/common/util/concurrent/SequentialExecutorTest.java
@@ -274,7 +274,6 @@
assertEquals(1, numCalls.get());
}
-
public void testTaskThrowsError() throws Exception {
class MyError extends Error {}
final CyclicBarrier barrier = new CyclicBarrier(2);
@@ -313,7 +312,6 @@
}
}
-
public void testRejectedExecutionThrownWithMultipleCalls() throws Exception {
final CountDownLatch latch = new CountDownLatch(1);
final SettableFuture<?> future = SettableFuture.create();
diff --git a/android/guava-tests/test/com/google/common/util/concurrent/ServiceManagerTest.java b/android/guava-tests/test/com/google/common/util/concurrent/ServiceManagerTest.java
index 20ed3de..fbc238e 100644
--- a/android/guava-tests/test/com/google/common/util/concurrent/ServiceManagerTest.java
+++ b/android/guava-tests/test/com/google/common/util/concurrent/ServiceManagerTest.java
@@ -119,19 +119,19 @@
}
}
-
public void testServiceStartupTimes() {
Service a = new NoOpDelayedService(150);
Service b = new NoOpDelayedService(353);
ServiceManager serviceManager = new ServiceManager(asList(a, b));
serviceManager.startAsync().awaitHealthy();
ImmutableMap<Service, Long> startupTimes = serviceManager.startupTimes();
- assertThat(startupTimes).hasSize(2);
- assertThat(startupTimes.get(a)).isAtLeast(150);
- assertThat(startupTimes.get(b)).isAtLeast(353);
+ assertEquals(2, startupTimes.size());
+ // TODO(kak): Use assertThat(startupTimes.get(a)).isAtLeast(150);
+ assertTrue(startupTimes.get(a) >= 150);
+ // TODO(kak): Use assertThat(startupTimes.get(b)).isAtLeast(353);
+ assertTrue(startupTimes.get(b) >= 353);
}
-
public void testServiceStartupTimes_selfStartingServices() {
// This tests to ensure that:
// 1. service times are accurate when the service is started by the manager
@@ -157,8 +157,9 @@
ServiceManager serviceManager = new ServiceManager(asList(a, b));
serviceManager.startAsync().awaitHealthy();
ImmutableMap<Service, Long> startupTimes = serviceManager.startupTimes();
- assertThat(startupTimes).hasSize(2);
- assertThat(startupTimes.get(a)).isAtLeast(150);
+ assertEquals(2, startupTimes.size());
+ // TODO(kak): Use assertThat(startupTimes.get(a)).isAtLeast(150);
+ assertTrue(startupTimes.get(a) >= 150);
// Service b startup takes at least 353 millis, but starting the timer is delayed by at least
// 150 milliseconds. so in a perfect world the timing would be 353-150=203ms, but since either
// of our sleep calls can be arbitrarily delayed we should just assert that there is a time
@@ -166,7 +167,6 @@
assertThat(startupTimes.get(b)).isNotNull();
}
-
public void testServiceStartStop() {
Service a = new NoOpService();
Service b = new NoOpService();
@@ -188,7 +188,6 @@
assertTrue(listener.failedServices.isEmpty());
}
-
public void testFailStart() throws Exception {
Service a = new NoOpService();
Service b = new FailStartService();
@@ -216,7 +215,6 @@
assertTrue(listener.stoppedCalled);
}
-
public void testFailRun() throws Exception {
Service a = new NoOpService();
Service b = new FailRunService();
@@ -239,7 +237,6 @@
assertTrue(listener.stoppedCalled);
}
-
public void testFailStop() throws Exception {
Service a = new NoOpService();
Service b = new FailStopService();
@@ -268,7 +265,6 @@
assertThat(toString).contains("FailStartService");
}
-
public void testTimeouts() throws Exception {
Service a = new NoOpDelayedService(50);
ServiceManager manager = new ServiceManager(asList(a));
diff --git a/android/guava-tests/test/com/google/common/util/concurrent/SettableFutureTest.java b/android/guava-tests/test/com/google/common/util/concurrent/SettableFutureTest.java
index 9b8b88f..105e8de 100644
--- a/android/guava-tests/test/com/google/common/util/concurrent/SettableFutureTest.java
+++ b/android/guava-tests/test/com/google/common/util/concurrent/SettableFutureTest.java
@@ -51,19 +51,16 @@
}
}
-
public void testSetValue() throws Exception {
assertTrue(future.set("value"));
tester.testCompletedFuture("value");
}
-
public void testSetFailure() throws Exception {
assertTrue(future.setException(new Exception("failure")));
tester.testFailedFuture("failure");
}
-
public void testSetFailureNull() throws Exception {
try {
future.setException(null);
@@ -75,7 +72,6 @@
tester.testFailedFuture("failure");
}
-
public void testCancel() throws Exception {
assertTrue(future.cancel(true));
tester.testCancelledFuture();
diff --git a/android/guava-tests/test/com/google/common/util/concurrent/StripedTest.java b/android/guava-tests/test/com/google/common/util/concurrent/StripedTest.java
index fa9d87f..9832c30 100644
--- a/android/guava-tests/test/com/google/common/util/concurrent/StripedTest.java
+++ b/android/guava-tests/test/com/google/common/util/concurrent/StripedTest.java
@@ -129,7 +129,6 @@
assertTrue(Striped.lazyWeakLock(256).size() == 256);
}
-
public void testWeakImplementations() {
for (Striped<?> striped : weakImplementations()) {
WeakReference<Object> weakRef = new WeakReference<>(striped.get(new Object()));
@@ -137,7 +136,6 @@
}
}
-
public void testWeakReadWrite() {
Striped<ReadWriteLock> striped = Striped.lazyWeakReadWriteLock(1000);
Object key = new Object();
@@ -150,7 +148,6 @@
readLock.unlock();
}
-
public void testStrongImplementations() {
for (Striped<?> striped : strongImplementations()) {
WeakReference<Object> weakRef = new WeakReference<>(striped.get(new Object()));
diff --git a/android/guava-tests/test/com/google/common/util/concurrent/ThreadFactoryBuilderTest.java b/android/guava-tests/test/com/google/common/util/concurrent/ThreadFactoryBuilderTest.java
index 7684b96..a3a7b8e 100644
--- a/android/guava-tests/test/com/google/common/util/concurrent/ThreadFactoryBuilderTest.java
+++ b/android/guava-tests/test/com/google/common/util/concurrent/ThreadFactoryBuilderTest.java
@@ -56,7 +56,6 @@
builder = new ThreadFactoryBuilder();
}
-
public void testThreadFactoryBuilder_defaults() throws InterruptedException {
ThreadFactory threadFactory = builder.build();
Thread thread = threadFactory.newThread(monitoredRunnable);
@@ -93,7 +92,6 @@
assertThat(thread.getName()).matches("^pool-\\d+-thread-" + threadId + "$");
}
-
public void testNameFormatWithPercentS_custom() {
String format = "super-duper-thread-%s";
ThreadFactory factory = builder.setNameFormat(format).build();
@@ -102,7 +100,6 @@
}
}
-
public void testNameFormatWithPercentD_custom() {
String format = "super-duper-thread-%d";
ThreadFactory factory = builder.setNameFormat(format).build();
@@ -111,21 +108,18 @@
}
}
-
public void testDaemon_false() {
ThreadFactory factory = builder.setDaemon(false).build();
Thread thread = factory.newThread(monitoredRunnable);
assertFalse(thread.isDaemon());
}
-
public void testDaemon_true() {
ThreadFactory factory = builder.setDaemon(true).build();
Thread thread = factory.newThread(monitoredRunnable);
assertTrue(thread.isDaemon());
}
-
public void testPriority_custom() {
for (int i = Thread.MIN_PRIORITY; i <= Thread.MAX_PRIORITY; i++) {
ThreadFactory factory = builder.setPriority(i).build();
@@ -150,7 +144,6 @@
}
}
-
public void testUncaughtExceptionHandler_custom() {
assertEquals(
UNCAUGHT_EXCEPTION_HANDLER,
@@ -161,7 +154,6 @@
.getUncaughtExceptionHandler());
}
-
public void testBuildMutateBuild() {
ThreadFactory factory1 = builder.setPriority(1).build();
assertEquals(1, factory1.newThread(monitoredRunnable).getPriority());
@@ -177,7 +169,6 @@
unused = builder.build(); // this is *also* allowed
}
-
public void testBuildMutate() {
ThreadFactory factory1 = builder.setPriority(1).build();
assertEquals(1, factory1.newThread(monitoredRunnable).getPriority());
@@ -186,7 +177,6 @@
assertEquals(1, factory1.newThread(monitoredRunnable).getPriority());
}
-
public void testThreadFactory() throws InterruptedException {
final String THREAD_NAME = "ludicrous speed";
final int THREAD_PRIORITY = 1;
diff --git a/android/guava-tests/test/com/google/common/util/concurrent/TrustedInputFutureTest.java b/android/guava-tests/test/com/google/common/util/concurrent/TrustedInputFutureTest.java
index 1f2ecca..d452f96 100644
--- a/android/guava-tests/test/com/google/common/util/concurrent/TrustedInputFutureTest.java
+++ b/android/guava-tests/test/com/google/common/util/concurrent/TrustedInputFutureTest.java
@@ -16,7 +16,6 @@
package com.google.common.util.concurrent;
-
import com.google.common.annotations.GwtCompatible;
import com.google.common.util.concurrent.AbstractFuture.TrustedFuture;
diff --git a/android/guava-tests/test/com/google/common/util/concurrent/UninterruptibleFutureTest.java b/android/guava-tests/test/com/google/common/util/concurrent/UninterruptibleFutureTest.java
index 0d24266..47507cd 100644
--- a/android/guava-tests/test/com/google/common/util/concurrent/UninterruptibleFutureTest.java
+++ b/android/guava-tests/test/com/google/common/util/concurrent/UninterruptibleFutureTest.java
@@ -116,7 +116,6 @@
assertTrue(sleeper.completed);
}
-
public void testMakeUninterruptible_timeoutPreservedThroughInterruption()
throws ExecutionException {
@@ -155,32 +154,26 @@
}
}
-
public void testMakeUninterruptible_untimed_uninterrupted() throws Exception {
runUntimedInterruptsTest(0);
}
-
public void testMakeUninterruptible_untimed_interrupted() throws Exception {
runUntimedInterruptsTest(1);
}
-
public void testMakeUninterruptible_untimed_multiplyInterrupted() throws Exception {
runUntimedInterruptsTest(38);
}
-
public void testMakeUninterruptible_timed_uninterrupted() throws Exception {
runTimedInterruptsTest(0);
}
-
public void testMakeUninterruptible_timed_interrupted() throws Exception {
runTimedInterruptsTest(1);
}
-
public void testMakeUninterruptible_timed_multiplyInterrupted() throws Exception {
runTimedInterruptsTest(38);
}
@@ -235,7 +228,6 @@
}
}
-
public void testMakeUninterruptible_timedGetZeroTimeoutAttempted()
throws TimeoutException, ExecutionException {
SettableFuture<String> future = SettableFuture.create();
@@ -248,7 +240,6 @@
assertEquals(RESULT, getUninterruptibly(future, 0, SECONDS));
}
-
public void testMakeUninterruptible_timedGetNegativeTimeoutAttempted()
throws TimeoutException, ExecutionException {
SettableFuture<String> future = SettableFuture.create();
diff --git a/android/guava-tests/test/com/google/common/util/concurrent/UninterruptibleMonitorTest.java b/android/guava-tests/test/com/google/common/util/concurrent/UninterruptibleMonitorTest.java
index 59bf808..30ce22d 100644
--- a/android/guava-tests/test/com/google/common/util/concurrent/UninterruptibleMonitorTest.java
+++ b/android/guava-tests/test/com/google/common/util/concurrent/UninterruptibleMonitorTest.java
@@ -16,7 +16,6 @@
package com.google.common.util.concurrent;
-
/**
* Tests for {@link Monitor}'s uninterruptible methods.
*
diff --git a/android/guava-tests/test/com/google/common/util/concurrent/UntrustedInputFutureTest.java b/android/guava-tests/test/com/google/common/util/concurrent/UntrustedInputFutureTest.java
index a6241d2..2d071b5 100644
--- a/android/guava-tests/test/com/google/common/util/concurrent/UntrustedInputFutureTest.java
+++ b/android/guava-tests/test/com/google/common/util/concurrent/UntrustedInputFutureTest.java
@@ -16,7 +16,6 @@
package com.google.common.util.concurrent;
-
import com.google.common.annotations.GwtCompatible;
import com.google.common.util.concurrent.AbstractFuture.TrustedFuture;
diff --git a/android/guava-tests/test/com/google/common/util/concurrent/WrappingScheduledExecutorServiceTest.java b/android/guava-tests/test/com/google/common/util/concurrent/WrappingScheduledExecutorServiceTest.java
index 8d0183e..6a8adfe 100644
--- a/android/guava-tests/test/com/google/common/util/concurrent/WrappingScheduledExecutorServiceTest.java
+++ b/android/guava-tests/test/com/google/common/util/concurrent/WrappingScheduledExecutorServiceTest.java
@@ -46,11 +46,11 @@
MockExecutor mock = new MockExecutor();
TestExecutor testExecutor = new TestExecutor(mock);
- @SuppressWarnings("unused") // https://errorprone.info/bugpattern/FutureReturnValueIgnored
+ @SuppressWarnings("unused") // go/futurereturn-lsc
Future<?> possiblyIgnoredError = testExecutor.schedule(DO_NOTHING, 10, TimeUnit.MINUTES);
mock.assertLastMethodCalled("scheduleRunnable", 10, TimeUnit.MINUTES);
- @SuppressWarnings("unused") // https://errorprone.info/bugpattern/FutureReturnValueIgnored
+ @SuppressWarnings("unused") // go/futurereturn-lsc
Future<?> possiblyIgnoredError1 =
testExecutor.schedule(Executors.callable(DO_NOTHING), 5, TimeUnit.SECONDS);
mock.assertLastMethodCalled("scheduleCallable", 5, TimeUnit.SECONDS);
@@ -59,12 +59,12 @@
public void testSchedule_repeating() {
MockExecutor mock = new MockExecutor();
TestExecutor testExecutor = new TestExecutor(mock);
- @SuppressWarnings("unused") // https://errorprone.info/bugpattern/FutureReturnValueIgnored
+ @SuppressWarnings("unused") // go/futurereturn-lsc
Future<?> possiblyIgnoredError =
testExecutor.scheduleWithFixedDelay(DO_NOTHING, 100, 10, TimeUnit.MINUTES);
mock.assertLastMethodCalled("scheduleWithFixedDelay", 100, 10, TimeUnit.MINUTES);
- @SuppressWarnings("unused") // https://errorprone.info/bugpattern/FutureReturnValueIgnored
+ @SuppressWarnings("unused") // go/futurereturn-lsc
Future<?> possiblyIgnoredError1 =
testExecutor.scheduleAtFixedRate(DO_NOTHING, 3, 7, TimeUnit.SECONDS);
mock.assertLastMethodCalled("scheduleAtFixedRate", 3, 7, TimeUnit.SECONDS);
diff --git a/android/guava-tests/test/com/google/common/xml/XmlEscapersTest.java b/android/guava-tests/test/com/google/common/xml/XmlEscapersTest.java
old mode 100644
new mode 100755
diff --git a/android/guava/pom.xml b/android/guava/pom.xml
index e9154c7..92db217 100644
--- a/android/guava/pom.xml
+++ b/android/guava/pom.xml
@@ -5,15 +5,14 @@
<parent>
<groupId>com.google.guava</groupId>
<artifactId>guava-parent</artifactId>
- <version>31.0.1-android</version>
+ <version>30.0-android</version>
</parent>
<artifactId>guava</artifactId>
<packaging>bundle</packaging>
<name>Guava: Google Core Libraries for Java</name>
- <url>https://github.com/google/guava</url>
<description>
Guava is a suite of core and expanded libraries that include
- utility classes, Google's collections, I/O classes, and
+ utility classes, google's collections, io classes, and much
much more.
</description>
<dependencies>
@@ -33,10 +32,6 @@
</dependency>
<dependency>
<groupId>org.checkerframework</groupId>
- <artifactId>checker-qual</artifactId>
- </dependency>
- <dependency>
- <groupId>org.checkerframework</groupId>
<artifactId>checker-compat-qual</artifactId>
</dependency>
<dependency>
@@ -120,12 +115,6 @@
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>animal-sniffer-maven-plugin</artifactId>
- <configuration>
- <ignores>
- <!-- Allow requireNonNull: Android desugaring rewrites it (so it's safe for us to use), and it's useful for null checks. Note that this line allows *all* methods from java.util.Objects. That's the best that we can do with the configuration options that Animal Sniffer offers. -->
- <ignore>java.util.Objects</ignore>
- </ignores>
- </configuration>
</plugin>
<plugin>
<artifactId>maven-javadoc-plugin</artifactId>
diff --git a/android/guava/src/com/google/common/annotations/Beta.java b/android/guava/src/com/google/common/annotations/Beta.java
old mode 100644
new mode 100755
index f71dc94..47dafe8
--- a/android/guava/src/com/google/common/annotations/Beta.java
+++ b/android/guava/src/com/google/common/annotations/Beta.java
@@ -31,6 +31,7 @@
* work during upgrades. However it is generally inadvisable for <i>libraries</i> (which get
* included on users' CLASSPATHs, outside the library developers' control) to do so.
*
+ *
* @author Kevin Bourrillion
*/
@Retention(RetentionPolicy.CLASS)
diff --git a/android/guava/src/com/google/common/annotations/GwtCompatible.java b/android/guava/src/com/google/common/annotations/GwtCompatible.java
old mode 100644
new mode 100755
index 4bf6efb..1391728
--- a/android/guava/src/com/google/common/annotations/GwtCompatible.java
+++ b/android/guava/src/com/google/common/annotations/GwtCompatible.java
@@ -54,6 +54,7 @@
*
* <p>Note that a {@code GwtCompatible} type may have some {@link GwtIncompatible} methods.
*
+ *
* @author Charles Fry
* @author Hayward Chan
*/
diff --git a/android/guava/src/com/google/common/annotations/GwtIncompatible.java b/android/guava/src/com/google/common/annotations/GwtIncompatible.java
old mode 100644
new mode 100755
diff --git a/android/guava/src/com/google/common/annotations/VisibleForTesting.java b/android/guava/src/com/google/common/annotations/VisibleForTesting.java
old mode 100644
new mode 100755
diff --git a/android/guava/src/com/google/common/annotations/package-info.java b/android/guava/src/com/google/common/annotations/package-info.java
old mode 100644
new mode 100755
diff --git a/android/guava/src/com/google/common/base/Absent.java b/android/guava/src/com/google/common/base/Absent.java
index f96136b..86aec05 100644
--- a/android/guava/src/com/google/common/base/Absent.java
+++ b/android/guava/src/com/google/common/base/Absent.java
@@ -19,11 +19,10 @@
import com.google.common.annotations.GwtCompatible;
import java.util.Collections;
import java.util.Set;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/** Implementation of an {@link Optional} not containing a reference. */
@GwtCompatible
-@ElementTypesAreNonnullByDefault
final class Absent<T> extends Optional<T> {
static final Absent<Object> INSTANCE = new Absent<>();
@@ -62,7 +61,7 @@
}
@Override
- @CheckForNull
+ @NullableDecl
public T orNull() {
return null;
}
@@ -79,7 +78,7 @@
}
@Override
- public boolean equals(@CheckForNull Object object) {
+ public boolean equals(@NullableDecl Object object) {
return object == this;
}
diff --git a/android/guava/src/com/google/common/base/AbstractIterator.java b/android/guava/src/com/google/common/base/AbstractIterator.java
index bb0a1d3..f6f521e 100644
--- a/android/guava/src/com/google/common/base/AbstractIterator.java
+++ b/android/guava/src/com/google/common/base/AbstractIterator.java
@@ -14,23 +14,20 @@
package com.google.common.base;
-import static com.google.common.base.NullnessCasts.uncheckedCastNullableTToT;
import static com.google.common.base.Preconditions.checkState;
import com.google.common.annotations.GwtCompatible;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import java.util.Iterator;
import java.util.NoSuchElementException;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* Note this class is a copy of {@link com.google.common.collect.AbstractIterator} (for dependency
* reasons).
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-abstract class AbstractIterator<T extends @Nullable Object> implements Iterator<T> {
+abstract class AbstractIterator<T> implements Iterator<T> {
private State state = State.NOT_READY;
protected AbstractIterator() {}
@@ -42,13 +39,12 @@
FAILED,
}
- @CheckForNull private T next;
+ @NullableDecl private T next;
- @CheckForNull
protected abstract T computeNext();
@CanIgnoreReturnValue
- @CheckForNull
+ @NullableDecl
protected final T endOfData() {
state = State.DONE;
return null;
@@ -78,14 +74,12 @@
}
@Override
- @ParametricNullness
public final T next() {
if (!hasNext()) {
throw new NoSuchElementException();
}
state = State.NOT_READY;
- // Safe because hasNext() ensures that tryToComputeNext() has put a T into `next`.
- T result = uncheckedCastNullableTToT(next);
+ T result = next;
next = null;
return result;
}
diff --git a/android/guava/src/com/google/common/base/Ascii.java b/android/guava/src/com/google/common/base/Ascii.java
index 0c651bb..0a8ec50 100644
--- a/android/guava/src/com/google/common/base/Ascii.java
+++ b/android/guava/src/com/google/common/base/Ascii.java
@@ -37,7 +37,6 @@
* @since 7.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
public final class Ascii {
private Ascii() {}
@@ -440,7 +439,7 @@
}
/**
- * If the argument is an {@linkplain #isUpperCase(char) uppercase ASCII character}, returns the
+ * If the argument is an {@linkplain #isUpperCase(char) uppercase ASCII character} returns the
* lowercase equivalent. Otherwise returns the argument.
*/
public static char toLowerCase(char c) {
@@ -488,7 +487,7 @@
}
/**
- * If the argument is a {@linkplain #isLowerCase(char) lowercase ASCII character}, returns the
+ * If the argument is a {@linkplain #isLowerCase(char) lowercase ASCII character} returns the
* uppercase equivalent. Otherwise returns the argument.
*/
public static char toUpperCase(char c) {
@@ -543,6 +542,7 @@
* <li>it is safe to use non-ASCII characters in the truncation indicator
* </ul>
*
+ *
* @throws IllegalArgumentException if {@code maxLength} is less than the length of {@code
* truncationIndicator}
* @since 16.0
diff --git a/android/guava/src/com/google/common/base/CaseFormat.java b/android/guava/src/com/google/common/base/CaseFormat.java
index 7b393eb..5e24bc9 100644
--- a/android/guava/src/com/google/common/base/CaseFormat.java
+++ b/android/guava/src/com/google/common/base/CaseFormat.java
@@ -15,11 +15,10 @@
package com.google.common.base;
import static com.google.common.base.Preconditions.checkNotNull;
-import static java.util.Objects.requireNonNull;
import com.google.common.annotations.GwtCompatible;
import java.io.Serializable;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* Utility class for converting between various ASCII case formats. Behavior is undefined for
@@ -29,7 +28,6 @@
* @since 1.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
public enum CaseFormat {
/** Hyphenated variable naming convention, e.g., "lower-hyphen". */
LOWER_HYPHEN(CharMatcher.is('-'), "-") {
@@ -140,14 +138,14 @@
out = new StringBuilder(s.length() + 4 * format.wordSeparator.length());
out.append(format.normalizeFirstWord(s.substring(i, j)));
} else {
- requireNonNull(out).append(format.normalizeWord(s.substring(i, j)));
+ out.append(format.normalizeWord(s.substring(i, j)));
}
out.append(format.wordSeparator);
i = j + wordSeparator.length();
}
return (i == 0)
? format.normalizeFirstWord(s)
- : requireNonNull(out).append(format.normalizeWord(s.substring(i))).toString();
+ : out.append(format.normalizeWord(s.substring(i))).toString();
}
/**
@@ -181,7 +179,7 @@
}
@Override
- public boolean equals(@CheckForNull Object object) {
+ public boolean equals(@NullableDecl Object object) {
if (object instanceof StringConverter) {
StringConverter that = (StringConverter) object;
return sourceFormat.equals(that.sourceFormat) && targetFormat.equals(that.targetFormat);
diff --git a/android/guava/src/com/google/common/base/CharMatcher.java b/android/guava/src/com/google/common/base/CharMatcher.java
index 7941883..e17db17 100644
--- a/android/guava/src/com/google/common/base/CharMatcher.java
+++ b/android/guava/src/com/google/common/base/CharMatcher.java
@@ -61,7 +61,6 @@
* @since 1.0
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
public abstract class CharMatcher implements Predicate<Character> {
/*
* N777777777NO
diff --git a/android/guava/src/com/google/common/base/Charsets.java b/android/guava/src/com/google/common/base/Charsets.java
index 7aebea8..2c9563d 100644
--- a/android/guava/src/com/google/common/base/Charsets.java
+++ b/android/guava/src/com/google/common/base/Charsets.java
@@ -31,7 +31,6 @@
* @since 1.0
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
public final class Charsets {
private Charsets() {}
diff --git a/android/guava/src/com/google/common/base/CommonMatcher.java b/android/guava/src/com/google/common/base/CommonMatcher.java
index d63b46b..6d14c6b 100644
--- a/android/guava/src/com/google/common/base/CommonMatcher.java
+++ b/android/guava/src/com/google/common/base/CommonMatcher.java
@@ -22,7 +22,6 @@
* javadoc for details.
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
abstract class CommonMatcher {
public abstract boolean matches();
diff --git a/android/guava/src/com/google/common/base/CommonPattern.java b/android/guava/src/com/google/common/base/CommonPattern.java
index c425d52..6be5b01 100644
--- a/android/guava/src/com/google/common/base/CommonPattern.java
+++ b/android/guava/src/com/google/common/base/CommonPattern.java
@@ -22,7 +22,6 @@
* javadoc for details.
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
abstract class CommonPattern {
public abstract CommonMatcher matcher(CharSequence t);
diff --git a/android/guava/src/com/google/common/base/Converter.java b/android/guava/src/com/google/common/base/Converter.java
index 208a032..82c0057 100644
--- a/android/guava/src/com/google/common/base/Converter.java
+++ b/android/guava/src/com/google/common/base/Converter.java
@@ -14,7 +14,6 @@
package com.google.common.base;
-import static com.google.common.base.NullnessCasts.uncheckedCastNullableTToT;
import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.annotations.GwtCompatible;
@@ -24,7 +23,7 @@
import com.google.j2objc.annotations.RetainedWith;
import java.io.Serializable;
import java.util.Iterator;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* A function from {@code A} to {@code B} with an associated <i>reverse</i> function from {@code B}
@@ -56,6 +55,7 @@
* behavior for all converters; implementations of {@link #doForward} and {@link #doBackward} are
* guaranteed to never be passed {@code null}, and must never return {@code null}.
*
+ *
* <h3>Common ways to use</h3>
*
* <p>Getting a converter:
@@ -114,36 +114,11 @@
* @since 16.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-/*
- * 1. The type parameter is <T> rather than <T extends @Nullable> so that we can use T in the
- * doForward and doBackward methods to indicate that the parameter cannot be null. (We also take
- * advantage of that for convertAll, as discussed on that method.)
- *
- * 2. The supertype of this class could be `Function<@Nullable A, @Nullable B>`, since
- * Converter.apply (like Converter.convert) is capable of accepting null inputs. However, a
- * supertype of `Function<A, B>` turns out to be massively more useful to callers in practice: They
- * want their output to be non-null in operations like `stream.map(myConverter)`, and we can
- * guarantee that as long as we also require the input type to be non-null[*] (which is a
- * requirement that existing callers already fulfill).
- *
- * Disclaimer: Part of the reason that callers are so well adapted to `Function<A, B>` may be that
- * that is how the signature looked even prior to this comment! So naturally any change can break
- * existing users, but it can't *fix* existing users because any users who needed
- * `Function<@Nullable A, @Nullable B>` already had to find a workaround. Still, there is a *ton* of
- * fallout from trying to switch. I would be shocked if the switch would offer benefits to anywhere
- * near enough users to justify the costs.
- *
- * Fortunately, if anyone does want to use a Converter as a `Function<@Nullable A, @Nullable B>`,
- * it's easy to get one: `converter::convert`.
- *
- * [*] In annotating this class, we're ignoring LegacyConverter.
- */
public abstract class Converter<A, B> implements Function<A, B> {
private final boolean handleNullAutomatically;
// We lazily cache the reverse view to avoid allocating on every call to reverse().
- @LazyInit @RetainedWith @CheckForNull private transient Converter<B, A> reverse;
+ @LazyInit @RetainedWith @NullableDecl private transient Converter<B, A> reverse;
/** Constructor for use by subclasses. */
protected Converter() {
@@ -190,67 +165,31 @@
* @return the converted value; is null <i>if and only if</i> {@code a} is null
*/
@CanIgnoreReturnValue
- @CheckForNull
- public final B convert(@CheckForNull A a) {
+ @NullableDecl
+ public final B convert(@NullableDecl A a) {
return correctedDoForward(a);
}
- @CheckForNull
- B correctedDoForward(@CheckForNull A a) {
+ @NullableDecl
+ B correctedDoForward(@NullableDecl 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));
} else {
- return unsafeDoForward(a);
+ return doForward(a);
}
}
- @CheckForNull
- A correctedDoBackward(@CheckForNull B b) {
+ @NullableDecl
+ A correctedDoBackward(@NullableDecl 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));
} else {
- return unsafeDoBackward(b);
+ return doBackward(b);
}
}
- /*
- * LegacyConverter violates the contract of Converter by allowing its doForward and doBackward
- * methods to accept null. We could avoid having unchecked casts in Converter.java itself if we
- * could perform a cast to LegacyConverter, but we can't because it's an internal-only class.
- *
- * TODO(cpovirk): So make it part of the open-source build, albeit package-private there?
- *
- * So we use uncheckedCastNullableTToT here. This is a weird usage of that method: The method is
- * documented as being for use with type parameters that have parametric nullness. But Converter's
- * type parameters do not. Still, we use it here so that we can suppress a warning at a smaller
- * level than the whole method but without performing a runtime null check. That way, we can still
- * pass null inputs to LegacyConverter, and it can violate the contract of Converter.
- *
- * TODO(cpovirk): Could this be simplified if we modified implementations of LegacyConverter to
- * override methods (probably called "unsafeDoForward" and "unsafeDoBackward") with the same
- * signatures as the methods below, rather than overriding the same doForward and doBackward
- * methods as implementations of normal converters do?
- *
- * But no matter what we do, it's worth remembering that the resulting code is going to be unsound
- * in the presence of LegacyConverter, at least in the case of users who view the converter as a
- * Function<A, B> or who call convertAll (and for any checkers that apply @PolyNull-like semantics
- * to Converter.convert). So maybe we don't want to think too hard about how to prevent our
- * checkers from issuing errors related to LegacyConverter, since it turns out that
- * LegacyConverter does violate the assumptions we make elsewhere.
- */
-
- @CheckForNull
- private B unsafeDoForward(@CheckForNull A a) {
- return doForward(uncheckedCastNullableTToT(a));
- }
-
- @CheckForNull
- private A unsafeDoBackward(@CheckForNull B b) {
- return doBackward(uncheckedCastNullableTToT(b));
- }
-
/**
* Returns an iterable that applies {@code convert} to each element of {@code fromIterable}. The
* conversion is done lazily.
@@ -260,16 +199,6 @@
* element.
*/
@CanIgnoreReturnValue
- /*
- * Just as Converter could implement `Function<@Nullable A, @Nullable B>` instead of `Function<A,
- * B>`, convertAll could accept and return iterables with nullable element types. In both cases,
- * we've chosen to instead use a signature that benefits existing users -- and is still safe.
- *
- * For convertAll, I haven't looked as closely at *how* much existing users benefit, so we should
- * keep an eye out for problems that new users encounter. Note also that convertAll could support
- * both use cases by using @PolyNull. (By contrast, we can't use @PolyNull for our superinterface
- * (`implements Function<@PolyNull A, @PolyNull B>`), at least as far as I know.)
- */
public Iterable<B> convertAll(final Iterable<? extends A> fromIterable) {
checkNotNull(fromIterable, "fromIterable");
return new Iterable<B>() {
@@ -284,8 +213,6 @@
}
@Override
- @SuppressWarnings("nullness") // See code comments on convertAll and Converter.apply.
- @CheckForNull
public B next() {
return convert(fromIterator.next());
}
@@ -339,14 +266,14 @@
}
@Override
- @CheckForNull
- A correctedDoForward(@CheckForNull B b) {
+ @NullableDecl
+ A correctedDoForward(@NullableDecl B b) {
return original.correctedDoBackward(b);
}
@Override
- @CheckForNull
- B correctedDoBackward(@CheckForNull A a) {
+ @NullableDecl
+ B correctedDoBackward(@NullableDecl A a) {
return original.correctedDoForward(a);
}
@@ -356,7 +283,7 @@
}
@Override
- public boolean equals(@CheckForNull Object object) {
+ public boolean equals(@NullableDecl Object object) {
if (object instanceof ReverseConverter) {
ReverseConverter<?, ?> that = (ReverseConverter<?, ?>) object;
return this.original.equals(that.original);
@@ -421,19 +348,19 @@
}
@Override
- @CheckForNull
- C correctedDoForward(@CheckForNull A a) {
+ @NullableDecl
+ C correctedDoForward(@NullableDecl A a) {
return second.correctedDoForward(first.correctedDoForward(a));
}
@Override
- @CheckForNull
- A correctedDoBackward(@CheckForNull C c) {
+ @NullableDecl
+ A correctedDoBackward(@NullableDecl C c) {
return first.correctedDoBackward(second.correctedDoBackward(c));
}
@Override
- public boolean equals(@CheckForNull Object object) {
+ public boolean equals(@NullableDecl Object object) {
if (object instanceof ConverterComposition) {
ConverterComposition<?, ?, ?> that = (ConverterComposition<?, ?, ?>) object;
return this.first.equals(that.first) && this.second.equals(that.second);
@@ -460,39 +387,8 @@
@Deprecated
@Override
@CanIgnoreReturnValue
- /*
- * Even though we implement `Function<A, B>` instead of `Function<@Nullable A, @Nullable B>` (as
- * discussed in a code comment at the top of the class), we declare our override of Function.apply
- * to accept and return null. This requires a suppression, but it's safe:
- *
- * - Callers who use Converter as a Function<A, B> will neither pass null nor have it returned to
- * them. (Or, if they're not using nullness checking, they might be able to pass null and thus
- * have null returned to them. But our signature isn't making their existing nullness type error
- * any worse.)
- * - In the relatively unlikely event that anyone calls Converter.apply directly, that caller is
- * allowed to pass null but is also forced to deal with a potentially null return.
- * - Perhaps more important than actual *callers* of this method are various tools that look at
- * bytecode. Notably, NullPointerTester expects a method to throw NPE when passed null unless it
- * is annotated in a way that identifies its parameter type as potentially including null. (And
- * this method does not throw NPE -- nor do we want to enact a dangerous change to make it begin
- * doing so.) We can even imagine tools that rewrite bytecode to insert null checks before and
- * after calling methods with allegedly non-nullable parameters[*]. If we didn't annotate the
- * parameter and return type here, then anyone who used such a tool (and managed to pass null to
- * this method, presumably because that user doesn't run a normal nullness checker) could see
- * NullPointerException.
- *
- * [*] Granted, such tools could conceivably be smart enough to recognize that the apply() method
- * on a a Function<Foo, Bar> should never allow null inputs and never produce null outputs even if
- * this specific subclass claims otherwise. Such tools might still produce NPE for calls to this
- * method. And that is one reason that we should be nervous about "lying" by extending Function<A,
- * B> in the first place. But for now, we're giving it a try, since extending Function<@Nullable
- * A, @Nullable B> will cause issues *today*, whereas extending Function<A, B> causes problems in
- * various hypothetical futures. (Plus, a tool that were that smart would likely already introduce
- * problems with LegacyConverter.)
- */
- @SuppressWarnings("nullness")
- @CheckForNull
- public final B apply(@CheckForNull A a) {
+ @NullableDecl
+ public final B apply(@NullableDecl A a) {
return convert(a);
}
@@ -508,7 +404,7 @@
* interchangeable.
*/
@Override
- public boolean equals(@CheckForNull Object object) {
+ public boolean equals(@NullableDecl Object object) {
return super.equals(object);
}
@@ -557,7 +453,7 @@
}
@Override
- public boolean equals(@CheckForNull Object object) {
+ public boolean equals(@NullableDecl Object object) {
if (object instanceof FunctionBasedConverter) {
FunctionBasedConverter<?, ?> that = (FunctionBasedConverter<?, ?>) object;
return this.forwardFunction.equals(that.forwardFunction)
diff --git a/android/guava/src/com/google/common/base/Defaults.java b/android/guava/src/com/google/common/base/Defaults.java
index 5d12343..00adbde 100644
--- a/android/guava/src/com/google/common/base/Defaults.java
+++ b/android/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 javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* This class provides default values for all Java types, as defined by the JLS.
@@ -26,12 +26,11 @@
* @since 1.0
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public final class Defaults {
private Defaults() {}
- private static final Double DOUBLE_DEFAULT = 0d;
- private static final Float FLOAT_DEFAULT = 0f;
+ private static final Double DOUBLE_DEFAULT = Double.valueOf(0d);
+ private static final Float FLOAT_DEFAULT = Float.valueOf(0f);
/**
* Returns the default value of {@code type} as defined by JLS --- {@code 0} for numbers, {@code
@@ -39,28 +38,27 @@
* {@code void}, {@code null} is returned.
*/
@SuppressWarnings("unchecked")
- @CheckForNull
+ @NullableDecl
public static <T> T defaultValue(Class<T> type) {
checkNotNull(type);
- if (type.isPrimitive()) {
- if (type == boolean.class) {
- return (T) Boolean.FALSE;
- } else if (type == char.class) {
- return (T) Character.valueOf('\0');
- } else if (type == byte.class) {
- return (T) Byte.valueOf((byte) 0);
- } else if (type == short.class) {
- return (T) Short.valueOf((short) 0);
- } else if (type == int.class) {
- return (T) Integer.valueOf(0);
- } else if (type == long.class) {
- return (T) Long.valueOf(0L);
- } else if (type == float.class) {
- return (T) FLOAT_DEFAULT;
- } else if (type == double.class) {
- return (T) DOUBLE_DEFAULT;
- }
+ if (type == boolean.class) {
+ return (T) Boolean.FALSE;
+ } else if (type == char.class) {
+ return (T) Character.valueOf('\0');
+ } else if (type == byte.class) {
+ return (T) Byte.valueOf((byte) 0);
+ } else if (type == short.class) {
+ return (T) Short.valueOf((short) 0);
+ } else if (type == int.class) {
+ return (T) Integer.valueOf(0);
+ } else if (type == long.class) {
+ return (T) Long.valueOf(0L);
+ } else if (type == float.class) {
+ return (T) FLOAT_DEFAULT;
+ } else if (type == double.class) {
+ return (T) DOUBLE_DEFAULT;
+ } else {
+ return null;
}
- return null;
}
}
diff --git a/android/guava/src/com/google/common/base/ElementTypesAreNonnullByDefault.java b/android/guava/src/com/google/common/base/ElementTypesAreNonnullByDefault.java
deleted file mode 100644
index 890e3a3..0000000
--- a/android/guava/src/com/google/common/base/ElementTypesAreNonnullByDefault.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) 2021 The Guava Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.common.base;
-
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.PARAMETER;
-import static java.lang.annotation.ElementType.TYPE;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-import com.google.common.annotations.GwtCompatible;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-import javax.annotation.Nonnull;
-import javax.annotation.meta.TypeQualifierDefault;
-
-/**
- * Marks all "top-level" types as non-null in a way that is recognized by Kotlin. Note that this
- * unfortunately includes type-variable usages, so we also provide {@link ParametricNullness} to
- * "undo" it as best we can.
- */
-@GwtCompatible
-@Retention(RUNTIME)
-@Target(TYPE)
-@TypeQualifierDefault({FIELD, METHOD, PARAMETER})
-@Nonnull
-@interface ElementTypesAreNonnullByDefault {}
diff --git a/android/guava/src/com/google/common/base/Enums.java b/android/guava/src/com/google/common/base/Enums.java
index 449b7e3..247fa6e 100644
--- a/android/guava/src/com/google/common/base/Enums.java
+++ b/android/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 javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* Utility methods for working with {@link Enum} instances.
@@ -34,7 +34,6 @@
* @since 9.0
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
public final class Enums {
private Enums() {}
@@ -129,7 +128,7 @@
}
@Override
- public boolean equals(@CheckForNull Object object) {
+ public boolean equals(@NullableDecl Object object) {
if (object instanceof StringConverter) {
StringConverter<?> that = (StringConverter<?>) object;
return this.enumClass.equals(that.enumClass);
diff --git a/android/guava/src/com/google/common/base/Equivalence.java b/android/guava/src/com/google/common/base/Equivalence.java
index 0ce901f..4364448 100644
--- a/android/guava/src/com/google/common/base/Equivalence.java
+++ b/android/guava/src/com/google/common/base/Equivalence.java
@@ -19,8 +19,7 @@
import com.google.common.annotations.GwtCompatible;
import com.google.errorprone.annotations.ForOverride;
import java.io.Serializable;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* A strategy for determining whether two instances are considered equivalent, and for computing
@@ -39,11 +38,6 @@
* source-compatible</a> since 4.0)
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-/*
- * The type parameter is <T> rather than <T extends @Nullable> so that we can use T in the
- * doEquivalent and doHash methods to indicate that the parameter cannot be null.
- */
public abstract class Equivalence<T> {
/** Constructor for use by subclasses. */
protected Equivalence() {}
@@ -65,7 +59,7 @@
* <p>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(@CheckForNull T a, @CheckForNull T b) {
+ public final boolean equivalent(@NullableDecl T a, @NullableDecl T b) {
if (a == b) {
return true;
}
@@ -76,6 +70,8 @@
}
/**
+ * This method should not be called except by {@link #equivalent}. When {@link #equivalent} calls
+ * this method, {@code a} and {@code b} are guaranteed to be distinct, non-null instances.
*
* @since 10.0 (previously, subclasses would override equivalent())
*/
@@ -99,7 +95,7 @@
* <li>{@code hash(null)} is {@code 0}.
* </ul>
*/
- public final int hash(@CheckForNull T t) {
+ public final int hash(@NullableDecl T t) {
if (t == null) {
return 0;
}
@@ -141,7 +137,7 @@
*
* @since 10.0
*/
- public final <F> Equivalence<F> onResultOf(Function<? super F, ? extends @Nullable T> function) {
+ public final <F> Equivalence<F> onResultOf(Function<F, ? extends T> function) {
return new FunctionalEquivalence<>(function, this);
}
@@ -152,7 +148,7 @@
*
* @since 10.0
*/
- public final <S extends @Nullable T> Wrapper<S> wrap(@ParametricNullness S reference) {
+ public final <S extends T> Wrapper<S> wrap(@NullableDecl S reference) {
return new Wrapper<S>(this, reference);
}
@@ -176,17 +172,17 @@
*
* @since 10.0
*/
- public static final class Wrapper<T extends @Nullable Object> implements Serializable {
+ public static final class Wrapper<T> implements Serializable {
private final Equivalence<? super T> equivalence;
- @ParametricNullness private final T reference;
+ @NullableDecl private final T reference;
- private Wrapper(Equivalence<? super T> equivalence, @ParametricNullness T reference) {
+ private Wrapper(Equivalence<? super T> equivalence, @NullableDecl T reference) {
this.equivalence = checkNotNull(equivalence);
this.reference = reference;
}
/** Returns the (possibly null) reference wrapped by this instance. */
- @ParametricNullness
+ @NullableDecl
public T get() {
return reference;
}
@@ -197,7 +193,7 @@
* equivalence.
*/
@Override
- public boolean equals(@CheckForNull Object obj) {
+ public boolean equals(@NullableDecl Object obj) {
if (obj == this) {
return true;
}
@@ -247,10 +243,10 @@
* @since 10.0
*/
@GwtCompatible(serializable = true)
- public final <S extends @Nullable T> Equivalence<Iterable<S>> pairwise() {
+ public final <S extends T> Equivalence<Iterable<S>> pairwise() {
// Ideally, the returned equivalence would support Iterable<? extends T>. However,
// the need for this is so rare that it's not worth making callers deal with the ugly wildcard.
- return new PairwiseEquivalence<>(this);
+ return new PairwiseEquivalence<S>(this);
}
/**
@@ -259,28 +255,27 @@
*
* @since 10.0
*/
- public final Predicate<@Nullable T> equivalentTo(@CheckForNull T target) {
+ public final Predicate<T> equivalentTo(@NullableDecl T target) {
return new EquivalentToPredicate<T>(this, target);
}
- private static final class EquivalentToPredicate<T>
- implements Predicate<@Nullable T>, Serializable {
+ private static final class EquivalentToPredicate<T> implements Predicate<T>, Serializable {
private final Equivalence<T> equivalence;
- @CheckForNull private final T target;
+ @NullableDecl private final T target;
- EquivalentToPredicate(Equivalence<T> equivalence, @CheckForNull T target) {
+ EquivalentToPredicate(Equivalence<T> equivalence, @NullableDecl T target) {
this.equivalence = checkNotNull(equivalence);
this.target = target;
}
@Override
- public boolean apply(@CheckForNull T input) {
+ public boolean apply(@NullableDecl T input) {
return equivalence.equivalent(input, target);
}
@Override
- public boolean equals(@CheckForNull Object obj) {
+ public boolean equals(@NullableDecl Object obj) {
if (this == obj) {
return true;
}
diff --git a/android/guava/src/com/google/common/base/ExtraObjectsMethodsForWeb.java b/android/guava/src/com/google/common/base/ExtraObjectsMethodsForWeb.java
index 6770755..21cca2c 100644
--- a/android/guava/src/com/google/common/base/ExtraObjectsMethodsForWeb.java
+++ b/android/guava/src/com/google/common/base/ExtraObjectsMethodsForWeb.java
@@ -21,5 +21,4 @@
* version.
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
abstract class ExtraObjectsMethodsForWeb {}
diff --git a/android/guava/src/com/google/common/base/FinalizablePhantomReference.java b/android/guava/src/com/google/common/base/FinalizablePhantomReference.java
index 4f93996..f920575 100644
--- a/android/guava/src/com/google/common/base/FinalizablePhantomReference.java
+++ b/android/guava/src/com/google/common/base/FinalizablePhantomReference.java
@@ -17,7 +17,6 @@
import com.google.common.annotations.GwtIncompatible;
import java.lang.ref.PhantomReference;
import java.lang.ref.ReferenceQueue;
-import javax.annotation.CheckForNull;
/**
* Phantom reference with a {@code finalizeReferent()} method which a background thread invokes
@@ -30,7 +29,6 @@
* @since 2.0
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public abstract class FinalizablePhantomReference<T> extends PhantomReference<T>
implements FinalizableReference {
/**
@@ -39,7 +37,7 @@
* @param referent to phantom reference
* @param queue that should finalize the referent
*/
- protected FinalizablePhantomReference(@CheckForNull T referent, FinalizableReferenceQueue queue) {
+ protected FinalizablePhantomReference(T referent, FinalizableReferenceQueue queue) {
super(referent, queue.queue);
queue.cleanUp();
}
diff --git a/android/guava/src/com/google/common/base/FinalizableReference.java b/android/guava/src/com/google/common/base/FinalizableReference.java
index 73753c9..848e7ee 100644
--- a/android/guava/src/com/google/common/base/FinalizableReference.java
+++ b/android/guava/src/com/google/common/base/FinalizableReference.java
@@ -26,7 +26,6 @@
*/
@DoNotMock("Use an instance of one of the Finalizable*Reference classes")
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public interface FinalizableReference {
/**
* Invoked on a background thread after the referent has been garbage collected unless security
diff --git a/android/guava/src/com/google/common/base/FinalizableReferenceQueue.java b/android/guava/src/com/google/common/base/FinalizableReferenceQueue.java
index 5ce1d31..40dfd46 100644
--- a/android/guava/src/com/google/common/base/FinalizableReferenceQueue.java
+++ b/android/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 javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* A reference queue with an associated background thread that dequeues references and invokes
@@ -37,7 +37,7 @@
* finalized. If this object is garbage collected earlier, the backing thread will not invoke {@code
* finalizeReferent()} on the remaining references.
*
- * <p>As an example of how this is used, imagine you have a class {@code MyServer} that creates a
+ * <p>As an example of how this is used, imagine you have a class {@code MyServer} that creates a a
* {@link java.net.ServerSocket ServerSocket}, and you would like to ensure that the {@code
* ServerSocket} is closed even if the {@code MyServer} object is garbage-collected without calling
* its {@code close} method. You <em>could</em> use a finalizer to accomplish this, but that has a
@@ -89,7 +89,6 @@
* @since 2.0
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public class FinalizableReferenceQueue implements Closeable {
/*
* The Finalizer thread keeps a phantom reference to this object. When the client (for example, a
@@ -229,7 +228,7 @@
*
* @throws SecurityException if we don't have the appropriate privileges
*/
- @CheckForNull
+ @NullableDecl
Class<?> loadFinalizer();
}
@@ -243,7 +242,7 @@
@VisibleForTesting static boolean disabled;
@Override
- @CheckForNull
+ @NullableDecl
public Class<?> loadFinalizer() {
if (disabled) {
return null;
@@ -281,7 +280,7 @@
+ "issue, or move Guava to your system class path.";
@Override
- @CheckForNull
+ @NullableDecl
public Class<?> loadFinalizer() {
try {
/*
diff --git a/android/guava/src/com/google/common/base/FinalizableSoftReference.java b/android/guava/src/com/google/common/base/FinalizableSoftReference.java
index c0e9b6b..45ecc65 100644
--- a/android/guava/src/com/google/common/base/FinalizableSoftReference.java
+++ b/android/guava/src/com/google/common/base/FinalizableSoftReference.java
@@ -17,7 +17,6 @@
import com.google.common.annotations.GwtIncompatible;
import java.lang.ref.ReferenceQueue;
import java.lang.ref.SoftReference;
-import javax.annotation.CheckForNull;
/**
* Soft reference with a {@code finalizeReferent()} method which a background thread invokes after
@@ -28,7 +27,6 @@
* @since 2.0
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public abstract class FinalizableSoftReference<T> extends SoftReference<T>
implements FinalizableReference {
/**
@@ -37,7 +35,7 @@
* @param referent to softly reference
* @param queue that should finalize the referent
*/
- protected FinalizableSoftReference(@CheckForNull T referent, FinalizableReferenceQueue queue) {
+ protected FinalizableSoftReference(T referent, FinalizableReferenceQueue queue) {
super(referent, queue.queue);
queue.cleanUp();
}
diff --git a/android/guava/src/com/google/common/base/FinalizableWeakReference.java b/android/guava/src/com/google/common/base/FinalizableWeakReference.java
index 9cca92e..fb3b09b 100644
--- a/android/guava/src/com/google/common/base/FinalizableWeakReference.java
+++ b/android/guava/src/com/google/common/base/FinalizableWeakReference.java
@@ -17,7 +17,6 @@
import com.google.common.annotations.GwtIncompatible;
import java.lang.ref.ReferenceQueue;
import java.lang.ref.WeakReference;
-import javax.annotation.CheckForNull;
/**
* Weak reference with a {@code finalizeReferent()} method which a background thread invokes after
@@ -28,7 +27,6 @@
* @since 2.0
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public abstract class FinalizableWeakReference<T> extends WeakReference<T>
implements FinalizableReference {
/**
@@ -37,7 +35,7 @@
* @param referent to weakly reference
* @param queue that should finalize the referent
*/
- protected FinalizableWeakReference(@CheckForNull T referent, FinalizableReferenceQueue queue) {
+ protected FinalizableWeakReference(T referent, FinalizableReferenceQueue queue) {
super(referent, queue.queue);
queue.cleanUp();
}
diff --git a/android/guava/src/com/google/common/base/Function.java b/android/guava/src/com/google/common/base/Function.java
index 7d633af..0583186 100644
--- a/android/guava/src/com/google/common/base/Function.java
+++ b/android/guava/src/com/google/common/base/Function.java
@@ -16,8 +16,7 @@
import com.google.common.annotations.GwtCompatible;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* Determines an output value based on an input value; a pre-Java-8 version of {@link
@@ -45,8 +44,7 @@
* @since 2.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-public interface Function<F extends @Nullable Object, T extends @Nullable Object> {
+public interface Function<F, T> {
/**
* Returns the result of applying this function to {@code input}. This method is <i>generally
* expected</i>, but not absolutely required, to have the following properties:
@@ -62,8 +60,8 @@
* arguments
*/
@CanIgnoreReturnValue // TODO(kevinb): remove this
- @ParametricNullness
- T apply(@ParametricNullness F input);
+ @NullableDecl
+ T apply(@NullableDecl F input);
/**
* <i>May</i> return {@code true} if {@code object} is a {@code Function} that behaves identically
@@ -77,5 +75,5 @@
* disappear. It is best not to depend on it.
*/
@Override
- boolean equals(@CheckForNull Object object);
+ boolean equals(@NullableDecl Object object);
}
diff --git a/android/guava/src/com/google/common/base/FunctionalEquivalence.java b/android/guava/src/com/google/common/base/FunctionalEquivalence.java
index 8bb67be..17dd400 100644
--- a/android/guava/src/com/google/common/base/FunctionalEquivalence.java
+++ b/android/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 javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* Equivalence applied on functional result.
@@ -29,16 +29,14 @@
*/
@Beta
@GwtCompatible
-@ElementTypesAreNonnullByDefault
final class FunctionalEquivalence<F, T> extends Equivalence<F> implements Serializable {
private static final long serialVersionUID = 0;
- private final Function<? super F, ? extends T> function;
+ private final Function<F, ? extends T> function;
private final Equivalence<T> resultEquivalence;
- FunctionalEquivalence(
- Function<? super F, ? extends T> function, Equivalence<T> resultEquivalence) {
+ FunctionalEquivalence(Function<F, ? extends T> function, Equivalence<T> resultEquivalence) {
this.function = checkNotNull(function);
this.resultEquivalence = checkNotNull(resultEquivalence);
}
@@ -54,7 +52,7 @@
}
@Override
- public boolean equals(@CheckForNull Object obj) {
+ public boolean equals(@NullableDecl Object obj) {
if (obj == this) {
return true;
}
diff --git a/android/guava/src/com/google/common/base/Functions.java b/android/guava/src/com/google/common/base/Functions.java
index 5337d0e..805f15c 100644
--- a/android/guava/src/com/google/common/base/Functions.java
+++ b/android/guava/src/com/google/common/base/Functions.java
@@ -14,15 +14,13 @@
package com.google.common.base;
-import static com.google.common.base.NullnessCasts.uncheckedCastNullableTToT;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.annotations.GwtCompatible;
import java.io.Serializable;
import java.util.Map;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* Static utility methods pertaining to {@code com.google.common.base.Function} instances; see that
@@ -38,7 +36,6 @@
* @since 2.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
public final class Functions {
private Functions() {}
@@ -82,17 +79,17 @@
/** Returns the identity function. */
// implementation is "fully variant"; E has become a "pass-through" type
@SuppressWarnings("unchecked")
- public static <E extends @Nullable Object> Function<E, E> identity() {
+ public static <E> Function<E, E> identity() {
return (Function<E, E>) IdentityFunction.INSTANCE;
}
// enum singleton pattern
- private enum IdentityFunction implements Function<@Nullable Object, @Nullable Object> {
+ private enum IdentityFunction implements Function<Object, Object> {
INSTANCE;
@Override
- @CheckForNull
- public Object apply(@CheckForNull Object o) {
+ @NullableDecl
+ public Object apply(@NullableDecl Object o) {
return o;
}
@@ -115,8 +112,7 @@
* key (instead of an exception being thrown), you can use the method reference {@code map::get}
* instead.
*/
- public static <K extends @Nullable Object, V extends @Nullable Object> Function<K, V> forMap(
- Map<K, V> map) {
+ public static <K, V> Function<K, V> forMap(Map<K, V> map) {
return new FunctionForMapNoDefault<>(map);
}
@@ -133,14 +129,12 @@
* @return function that returns {@code map.get(a)} when {@code a} is a key, or {@code
* defaultValue} otherwise
*/
- public static <K extends @Nullable Object, V extends @Nullable Object> Function<K, V> forMap(
- Map<K, ? extends V> map, @ParametricNullness V defaultValue) {
+ public static <K, V> Function<K, V> forMap(
+ Map<K, ? extends V> map, @NullableDecl V defaultValue) {
return new ForMapWithDefault<>(map, defaultValue);
}
- private static class FunctionForMapNoDefault<
- K extends @Nullable Object, V extends @Nullable Object>
- implements Function<K, V>, Serializable {
+ private static class FunctionForMapNoDefault<K, V> implements Function<K, V>, Serializable {
final Map<K, V> map;
FunctionForMapNoDefault(Map<K, V> map) {
@@ -148,16 +142,14 @@
}
@Override
- @ParametricNullness
- public V apply(@ParametricNullness K key) {
+ public V apply(@NullableDecl K key) {
V result = map.get(key);
checkArgument(result != null || map.containsKey(key), "Key '%s' not present in map", key);
- // The unchecked cast is safe because of the containsKey check.
- return uncheckedCastNullableTToT(result);
+ return result;
}
@Override
- public boolean equals(@CheckForNull Object o) {
+ public boolean equals(@NullableDecl Object o) {
if (o instanceof FunctionForMapNoDefault) {
FunctionForMapNoDefault<?, ?> that = (FunctionForMapNoDefault<?, ?>) o;
return map.equals(that.map);
@@ -178,28 +170,23 @@
private static final long serialVersionUID = 0;
}
- private static class ForMapWithDefault<K extends @Nullable Object, V extends @Nullable Object>
- implements Function<K, V>, Serializable {
+ private static class ForMapWithDefault<K, V> implements Function<K, V>, Serializable {
final Map<K, ? extends V> map;
- @ParametricNullness final V defaultValue;
+ @NullableDecl final V defaultValue;
- ForMapWithDefault(Map<K, ? extends V> map, @ParametricNullness V defaultValue) {
+ ForMapWithDefault(Map<K, ? extends V> map, @NullableDecl V defaultValue) {
this.map = checkNotNull(map);
this.defaultValue = defaultValue;
}
@Override
- @ParametricNullness
- public V apply(@ParametricNullness K key) {
+ public V apply(@NullableDecl K key) {
V result = map.get(key);
- // The unchecked cast is safe because of the containsKey check.
- return (result != null || map.containsKey(key))
- ? uncheckedCastNullableTToT(result)
- : defaultValue;
+ return (result != null || map.containsKey(key)) ? result : defaultValue;
}
@Override
- public boolean equals(@CheckForNull Object o) {
+ public boolean equals(@NullableDecl Object o) {
if (o instanceof ForMapWithDefault) {
ForMapWithDefault<?, ?> that = (ForMapWithDefault<?, ?>) o;
return map.equals(that.map) && Objects.equal(defaultValue, that.defaultValue);
@@ -233,14 +220,11 @@
* @return the composition of {@code f} and {@code g}
* @see <a href="//en.wikipedia.org/wiki/Function_composition">function composition</a>
*/
- public static <A extends @Nullable Object, B extends @Nullable Object, C extends @Nullable Object>
- Function<A, C> compose(Function<B, C> g, Function<A, ? extends B> f) {
+ public static <A, B, C> Function<A, C> compose(Function<B, C> g, Function<A, ? extends B> f) {
return new FunctionComposition<>(g, f);
}
- private static class FunctionComposition<
- A extends @Nullable Object, B extends @Nullable Object, C extends @Nullable Object>
- implements Function<A, C>, Serializable {
+ private static class FunctionComposition<A, B, C> implements Function<A, C>, Serializable {
private final Function<B, C> g;
private final Function<A, ? extends B> f;
@@ -250,13 +234,12 @@
}
@Override
- @ParametricNullness
- public C apply(@ParametricNullness A a) {
+ public C apply(@NullableDecl A a) {
return g.apply(f.apply(a));
}
@Override
- public boolean equals(@CheckForNull Object obj) {
+ public boolean equals(@NullableDecl Object obj) {
if (obj instanceof FunctionComposition) {
FunctionComposition<?, ?, ?> that = (FunctionComposition<?, ?, ?>) obj;
return f.equals(that.f) && g.equals(that.g);
@@ -286,14 +269,12 @@
*
* <p><b>Java 8 users:</b> use the method reference {@code predicate::test} instead.
*/
- public static <T extends @Nullable Object> Function<T, Boolean> forPredicate(
- Predicate<T> predicate) {
+ public static <T> Function<T, Boolean> forPredicate(Predicate<T> predicate) {
return new PredicateFunction<T>(predicate);
}
/** @see Functions#forPredicate */
- private static class PredicateFunction<T extends @Nullable Object>
- implements Function<T, Boolean>, Serializable {
+ private static class PredicateFunction<T> implements Function<T, Boolean>, Serializable {
private final Predicate<T> predicate;
private PredicateFunction(Predicate<T> predicate) {
@@ -301,12 +282,12 @@
}
@Override
- public Boolean apply(@ParametricNullness T t) {
+ public Boolean apply(@NullableDecl T t) {
return predicate.apply(t);
}
@Override
- public boolean equals(@CheckForNull Object obj) {
+ public boolean equals(@NullableDecl Object obj) {
if (obj instanceof PredicateFunction) {
PredicateFunction<?> that = (PredicateFunction<?>) obj;
return predicate.equals(that.predicate);
@@ -335,27 +316,24 @@
* @param value the constant value for the function to return
* @return a function that always returns {@code value}
*/
- public static <E extends @Nullable Object> Function<@Nullable Object, E> constant(
- @ParametricNullness E value) {
- return new ConstantFunction<>(value);
+ public static <E> Function<Object, E> constant(@NullableDecl E value) {
+ return new ConstantFunction<E>(value);
}
- private static class ConstantFunction<E extends @Nullable Object>
- implements Function<@Nullable Object, E>, Serializable {
- @ParametricNullness private final E value;
+ private static class ConstantFunction<E> implements Function<Object, E>, Serializable {
+ @NullableDecl private final E value;
- public ConstantFunction(@ParametricNullness E value) {
+ public ConstantFunction(@NullableDecl E value) {
this.value = value;
}
@Override
- @ParametricNullness
- public E apply(@CheckForNull Object from) {
+ public E apply(@NullableDecl Object from) {
return value;
}
@Override
- public boolean equals(@CheckForNull Object obj) {
+ public boolean equals(@NullableDecl Object obj) {
if (obj instanceof ConstantFunction) {
ConstantFunction<?> that = (ConstantFunction<?>) obj;
return Objects.equal(value, that.value);
@@ -383,14 +361,12 @@
*
* @since 10.0
*/
- public static <F extends @Nullable Object, T extends @Nullable Object> Function<F, T> forSupplier(
- Supplier<T> supplier) {
- return new SupplierFunction<>(supplier);
+ public static <T> Function<Object, T> forSupplier(Supplier<T> supplier) {
+ return new SupplierFunction<T>(supplier);
}
/** @see Functions#forSupplier */
- private static class SupplierFunction<F extends @Nullable Object, T extends @Nullable Object>
- implements Function<F, T>, Serializable {
+ private static class SupplierFunction<T> implements Function<Object, T>, Serializable {
private final Supplier<T> supplier;
@@ -399,15 +375,14 @@
}
@Override
- @ParametricNullness
- public T apply(@ParametricNullness F input) {
+ public T apply(@NullableDecl Object input) {
return supplier.get();
}
@Override
- public boolean equals(@CheckForNull Object obj) {
+ public boolean equals(@NullableDecl Object obj) {
if (obj instanceof SupplierFunction) {
- SupplierFunction<?, ?> that = (SupplierFunction<?, ?>) obj;
+ SupplierFunction<?> that = (SupplierFunction<?>) obj;
return this.supplier.equals(that.supplier);
}
return false;
diff --git a/android/guava/src/com/google/common/base/Java8Compatibility.java b/android/guava/src/com/google/common/base/Java8Compatibility.java
deleted file mode 100644
index edc8b73..0000000
--- a/android/guava/src/com/google/common/base/Java8Compatibility.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (C) 2020 The Guava Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
- * or implied. See the License for the specific language governing permissions and limitations under
- * the License.
- */
-
-package com.google.common.base;
-
-import com.google.common.annotations.GwtIncompatible;
-import java.nio.Buffer;
-
-/**
- * Wrappers around {@link Buffer} methods that are covariantly overridden in Java 9+. See
- * https://github.com/google/guava/issues/3990
- */
-@GwtIncompatible
-@ElementTypesAreNonnullByDefault
-final class Java8Compatibility {
- static void clear(Buffer b) {
- b.clear();
- }
-
- static void flip(Buffer b) {
- b.flip();
- }
-
- static void limit(Buffer b, int limit) {
- b.limit(limit);
- }
-
- static void position(Buffer b, int position) {
- b.position(position);
- }
-
- private Java8Compatibility() {}
-}
diff --git a/android/guava/src/com/google/common/base/JdkPattern.java b/android/guava/src/com/google/common/base/JdkPattern.java
index 4788398..f7791db 100644
--- a/android/guava/src/com/google/common/base/JdkPattern.java
+++ b/android/guava/src/com/google/common/base/JdkPattern.java
@@ -20,7 +20,6 @@
import java.util.regex.Pattern;
/** A regex pattern implementation which is backed by the {@link Pattern}. */
-@ElementTypesAreNonnullByDefault
@GwtIncompatible
final class JdkPattern extends CommonPattern implements Serializable {
private final Pattern pattern;
diff --git a/android/guava/src/com/google/common/base/Joiner.java b/android/guava/src/com/google/common/base/Joiner.java
index 0f3d6e4..f74f02f 100644
--- a/android/guava/src/com/google/common/base/Joiner.java
+++ b/android/guava/src/com/google/common/base/Joiner.java
@@ -15,7 +15,6 @@
package com.google.common.base;
import static com.google.common.base.Preconditions.checkNotNull;
-import static java.util.Objects.requireNonNull;
import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtCompatible;
@@ -26,8 +25,7 @@
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* An object which joins pieces of text (specified as an array, {@link Iterable}, varargs or even a
@@ -65,7 +63,6 @@
* @since 2.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
public class Joiner {
/** Returns a joiner which automatically places {@code separator} between consecutive elements. */
public static Joiner on(String separator) {
@@ -87,19 +84,12 @@
this.separator = prototype.separator;
}
- /*
- * In this file, we use <? extends @Nullable Object> instead of <?> to work around a Kotlin bug
- * (see b/189937072 until we file a bug against Kotlin itself). (The two should be equivalent, so
- * we normally prefer the shorter one.)
- */
-
/**
* Appends the string representation of each of {@code parts}, using the previously configured
* separator between each, to {@code appendable}.
*/
@CanIgnoreReturnValue
- public <A extends Appendable> A appendTo(A appendable, Iterable<? extends @Nullable Object> parts)
- throws IOException {
+ public <A extends Appendable> A appendTo(A appendable, Iterable<?> parts) throws IOException {
return appendTo(appendable, parts.iterator());
}
@@ -110,8 +100,7 @@
* @since 11.0
*/
@CanIgnoreReturnValue
- public <A extends Appendable> A appendTo(A appendable, Iterator<? extends @Nullable Object> parts)
- throws IOException {
+ public <A extends Appendable> A appendTo(A appendable, Iterator<?> parts) throws IOException {
checkNotNull(appendable);
if (parts.hasNext()) {
appendable.append(toString(parts.next()));
@@ -128,18 +117,14 @@
* separator between each, to {@code appendable}.
*/
@CanIgnoreReturnValue
- public final <A extends Appendable> A appendTo(A appendable, @Nullable Object[] parts)
- throws IOException {
+ public final <A extends Appendable> A appendTo(A appendable, Object[] parts) throws IOException {
return appendTo(appendable, Arrays.asList(parts));
}
/** Appends to {@code appendable} the string representation of each of the remaining arguments. */
@CanIgnoreReturnValue
public final <A extends Appendable> A appendTo(
- A appendable,
- @CheckForNull Object first,
- @CheckForNull Object second,
- @Nullable Object... rest)
+ A appendable, @NullableDecl Object first, @NullableDecl Object second, Object... rest)
throws IOException {
return appendTo(appendable, iterable(first, second, rest));
}
@@ -150,8 +135,7 @@
* Iterable)}, except that it does not throw {@link IOException}.
*/
@CanIgnoreReturnValue
- public final StringBuilder appendTo(
- StringBuilder builder, Iterable<? extends @Nullable Object> parts) {
+ public final StringBuilder appendTo(StringBuilder builder, Iterable<?> parts) {
return appendTo(builder, parts.iterator());
}
@@ -163,8 +147,7 @@
* @since 11.0
*/
@CanIgnoreReturnValue
- public final StringBuilder appendTo(
- StringBuilder builder, Iterator<? extends @Nullable Object> parts) {
+ public final StringBuilder appendTo(StringBuilder builder, Iterator<?> parts) {
try {
appendTo((Appendable) builder, parts);
} catch (IOException impossible) {
@@ -179,7 +162,7 @@
* Iterable)}, except that it does not throw {@link IOException}.
*/
@CanIgnoreReturnValue
- public final StringBuilder appendTo(StringBuilder builder, @Nullable Object[] parts) {
+ public final StringBuilder appendTo(StringBuilder builder, Object[] parts) {
return appendTo(builder, Arrays.asList(parts));
}
@@ -191,9 +174,9 @@
@CanIgnoreReturnValue
public final StringBuilder appendTo(
StringBuilder builder,
- @CheckForNull Object first,
- @CheckForNull Object second,
- @Nullable Object... rest) {
+ @NullableDecl Object first,
+ @NullableDecl Object second,
+ Object... rest) {
return appendTo(builder, iterable(first, second, rest));
}
@@ -201,7 +184,7 @@
* Returns a string containing the string representation of each of {@code parts}, using the
* previously configured separator between each.
*/
- public final String join(Iterable<? extends @Nullable Object> parts) {
+ public final String join(Iterable<?> parts) {
return join(parts.iterator());
}
@@ -211,7 +194,7 @@
*
* @since 11.0
*/
- public final String join(Iterator<? extends @Nullable Object> parts) {
+ public final String join(Iterator<?> parts) {
return appendTo(new StringBuilder(), parts).toString();
}
@@ -219,7 +202,7 @@
* Returns a string containing the string representation of each of {@code parts}, using the
* previously configured separator between each.
*/
- public final String join(@Nullable Object[] parts) {
+ public final String join(Object[] parts) {
return join(Arrays.asList(parts));
}
@@ -228,7 +211,7 @@
* configured separator between each.
*/
public final String join(
- @CheckForNull Object first, @CheckForNull Object second, @Nullable Object... rest) {
+ @NullableDecl Object first, @NullableDecl Object second, Object... rest) {
return join(iterable(first, second, rest));
}
@@ -240,7 +223,7 @@
checkNotNull(nullText);
return new Joiner(this) {
@Override
- CharSequence toString(@CheckForNull Object part) {
+ CharSequence toString(@NullableDecl Object part) {
return (part == null) ? nullText : Joiner.this.toString(part);
}
@@ -263,8 +246,7 @@
public Joiner skipNulls() {
return new Joiner(this) {
@Override
- public <A extends Appendable> A appendTo(
- A appendable, Iterator<? extends @Nullable Object> parts) throws IOException {
+ public <A extends Appendable> A appendTo(A appendable, Iterator<?> parts) throws IOException {
checkNotNull(appendable, "appendable");
checkNotNull(parts, "parts");
while (parts.hasNext()) {
@@ -470,41 +452,21 @@
}
}
- CharSequence toString(@CheckForNull Object part) {
- /*
- * requireNonNull is not safe: Joiner.on(...).join(somethingThatContainsNull) will indeed throw.
- * However, Joiner.on(...).useForNull(...).join(somethingThatContainsNull) *is* safe -- because
- * it returns a subclass of Joiner that overrides this method to tolerate null inputs.
- *
- * Unfortunately, we don't distinguish between these two cases in our public API: Joiner.on(...)
- * and Joiner.on(...).useForNull(...) both declare the same return type: plain Joiner. To ensure
- * that users *can* pass null arguments to Joiner, we annotate it as if it always tolerates null
- * inputs, rather than as if it never tolerates them.
- *
- * We rely on checkers to implement special cases to catch dangerous calls to join(), etc. based
- * on what they know about the particular Joiner instances the calls are performed on.
- *
- * (In addition to useForNull, we also offer skipNulls. It, too, tolerates null inputs, but its
- * tolerance is implemented differently: Its implementation avoids calling this toString(Object)
- * method in the first place.)
- */
- requireNonNull(part);
+ CharSequence toString(Object part) {
+ checkNotNull(part); // checkNotNull for GWT (do not optimize).
return (part instanceof CharSequence) ? (CharSequence) part : part.toString();
}
- private static Iterable<@Nullable Object> iterable(
- @CheckForNull final Object first,
- @CheckForNull final Object second,
- final @Nullable Object[] rest) {
+ private static Iterable<Object> iterable(
+ final Object first, final Object second, final Object[] rest) {
checkNotNull(rest);
- return new AbstractList<@Nullable Object>() {
+ return new AbstractList<Object>() {
@Override
public int size() {
return rest.length + 2;
}
@Override
- @CheckForNull
public Object get(int index) {
switch (index) {
case 0:
diff --git a/android/guava/src/com/google/common/base/MoreObjects.java b/android/guava/src/com/google/common/base/MoreObjects.java
index da97624..a56b2a6 100644
--- a/android/guava/src/com/google/common/base/MoreObjects.java
+++ b/android/guava/src/com/google/common/base/MoreObjects.java
@@ -18,11 +18,8 @@
import com.google.common.annotations.GwtCompatible;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
-import java.lang.reflect.Array;
import java.util.Arrays;
-import java.util.Collection;
-import java.util.Map;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* Helper functions that operate on any {@code Object}, and are not already provided in {@link
@@ -36,7 +33,6 @@
* @since 18.0 (since 2.0 as {@code Objects})
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
public final class MoreObjects {
/**
* Returns the first of two given parameters that is not {@code null}, if either is, or otherwise
@@ -58,24 +54,7 @@
* @throws NullPointerException if both {@code first} and {@code second} are null
* @since 18.0 (since 3.0 as {@code Objects.firstNonNull()}).
*/
- /*
- * We annotate firstNonNull in a way that protects against NullPointerException at the cost of
- * forbidding some reasonable calls.
- *
- * The more permissive signature would be to accept (@CheckForNull T first, @CheckForNull T
- * second), since it's OK for `second` to be null as long as `first` is not also null. But we
- * expect for that flexibility to be useful relatively rarely: The more common use case is to
- * supply a clearly non-null default, like `firstNonNull(someString, "")`. And users who really
- * know that `first` is guaranteed non-null when `second` is null can write the logic out
- * longhand, including a requireNonNull call, which calls attention to the fact that the static
- * analyzer can't prove that the operation is safe.
- *
- * This matches the signature we currently have for requireNonNullElse in our own checker. (And
- * that in turn matches that method's signature under the Checker Framework.) As always, we could
- * consider the more flexible signature if we judge it worth the risks. If we do, we would likely
- * update both methods so that they continue to match.
- */
- public static <T> T firstNonNull(@CheckForNull T first, T second) {
+ public static <T> T firstNonNull(@NullableDecl T first, @NullableDecl T second) {
if (first != null) {
return first;
}
@@ -166,7 +145,6 @@
private final ValueHolder holderHead = new ValueHolder();
private ValueHolder holderTail = holderHead;
private boolean omitNullValues = false;
- private boolean omitEmptyValues = false;
/** Use {@link MoreObjects#toStringHelper(Object)} to create an instance. */
private ToStringHelper(String className) {
@@ -192,7 +170,7 @@
* called, in which case this name/value pair will not be added.
*/
@CanIgnoreReturnValue
- public ToStringHelper add(String name, @CheckForNull Object value) {
+ public ToStringHelper add(String name, @NullableDecl Object value) {
return addHolder(name, value);
}
@@ -203,7 +181,7 @@
*/
@CanIgnoreReturnValue
public ToStringHelper add(String name, boolean value) {
- return addUnconditionalHolder(name, String.valueOf(value));
+ return addHolder(name, String.valueOf(value));
}
/**
@@ -213,7 +191,7 @@
*/
@CanIgnoreReturnValue
public ToStringHelper add(String name, char value) {
- return addUnconditionalHolder(name, String.valueOf(value));
+ return addHolder(name, String.valueOf(value));
}
/**
@@ -223,7 +201,7 @@
*/
@CanIgnoreReturnValue
public ToStringHelper add(String name, double value) {
- return addUnconditionalHolder(name, String.valueOf(value));
+ return addHolder(name, String.valueOf(value));
}
/**
@@ -233,7 +211,7 @@
*/
@CanIgnoreReturnValue
public ToStringHelper add(String name, float value) {
- return addUnconditionalHolder(name, String.valueOf(value));
+ return addHolder(name, String.valueOf(value));
}
/**
@@ -243,7 +221,7 @@
*/
@CanIgnoreReturnValue
public ToStringHelper add(String name, int value) {
- return addUnconditionalHolder(name, String.valueOf(value));
+ return addHolder(name, String.valueOf(value));
}
/**
@@ -253,7 +231,7 @@
*/
@CanIgnoreReturnValue
public ToStringHelper add(String name, long value) {
- return addUnconditionalHolder(name, String.valueOf(value));
+ return addHolder(name, String.valueOf(value));
}
/**
@@ -263,7 +241,7 @@
* readable name.
*/
@CanIgnoreReturnValue
- public ToStringHelper addValue(@CheckForNull Object value) {
+ public ToStringHelper addValue(@NullableDecl Object value) {
return addHolder(value);
}
@@ -277,7 +255,7 @@
*/
@CanIgnoreReturnValue
public ToStringHelper addValue(boolean value) {
- return addUnconditionalHolder(String.valueOf(value));
+ return addHolder(String.valueOf(value));
}
/**
@@ -290,7 +268,7 @@
*/
@CanIgnoreReturnValue
public ToStringHelper addValue(char value) {
- return addUnconditionalHolder(String.valueOf(value));
+ return addHolder(String.valueOf(value));
}
/**
@@ -303,7 +281,7 @@
*/
@CanIgnoreReturnValue
public ToStringHelper addValue(double value) {
- return addUnconditionalHolder(String.valueOf(value));
+ return addHolder(String.valueOf(value));
}
/**
@@ -316,7 +294,7 @@
*/
@CanIgnoreReturnValue
public ToStringHelper addValue(float value) {
- return addUnconditionalHolder(String.valueOf(value));
+ return addHolder(String.valueOf(value));
}
/**
@@ -329,7 +307,7 @@
*/
@CanIgnoreReturnValue
public ToStringHelper addValue(int value) {
- return addUnconditionalHolder(String.valueOf(value));
+ return addHolder(String.valueOf(value));
}
/**
@@ -342,23 +320,7 @@
*/
@CanIgnoreReturnValue
public ToStringHelper addValue(long value) {
- return addUnconditionalHolder(String.valueOf(value));
- }
-
- private static boolean isEmpty(Object value) {
- // Put types estimated to be most frequent first.
- if (value instanceof CharSequence) {
- return ((CharSequence) value).length() == 0;
- } else if (value instanceof Collection) {
- return ((Collection<?>) value).isEmpty();
- } else if (value instanceof Map) {
- return ((Map<?, ?>) value).isEmpty();
- } else if (value instanceof Optional) {
- return !((Optional) value).isPresent();
- } else if (value.getClass().isArray()) {
- return Array.getLength(value) == 0;
- }
- return false;
+ return addHolder(String.valueOf(value));
}
/**
@@ -373,17 +335,13 @@
public String toString() {
// create a copy to keep it consistent in case value changes
boolean omitNullValuesSnapshot = omitNullValues;
- boolean omitEmptyValuesSnapshot = omitEmptyValues;
String nextSeparator = "";
StringBuilder builder = new StringBuilder(32).append(className).append('{');
for (ValueHolder valueHolder = holderHead.next;
valueHolder != null;
valueHolder = valueHolder.next) {
Object value = valueHolder.value;
- if (valueHolder instanceof UnconditionalValueHolder
- || (value == null
- ? !omitNullValuesSnapshot
- : (!omitEmptyValuesSnapshot || !isEmpty(value)))) {
+ if (!omitNullValuesSnapshot || value != null) {
builder.append(nextSeparator);
nextSeparator = ", ";
@@ -408,51 +366,24 @@
return valueHolder;
}
- private ToStringHelper addHolder(@CheckForNull Object value) {
+ private ToStringHelper addHolder(@NullableDecl Object value) {
ValueHolder valueHolder = addHolder();
valueHolder.value = value;
return this;
}
- private ToStringHelper addHolder(String name, @CheckForNull Object value) {
+ private ToStringHelper addHolder(String name, @NullableDecl Object value) {
ValueHolder valueHolder = addHolder();
valueHolder.value = value;
valueHolder.name = checkNotNull(name);
return this;
}
- private UnconditionalValueHolder addUnconditionalHolder() {
- UnconditionalValueHolder valueHolder = new UnconditionalValueHolder();
- holderTail = holderTail.next = valueHolder;
- return valueHolder;
+ private static final class ValueHolder {
+ @NullableDecl String name;
+ @NullableDecl Object value;
+ @NullableDecl ValueHolder next;
}
-
- private ToStringHelper addUnconditionalHolder(Object value) {
- UnconditionalValueHolder valueHolder = addUnconditionalHolder();
- valueHolder.value = value;
- return this;
- }
-
- private ToStringHelper addUnconditionalHolder(String name, Object value) {
- UnconditionalValueHolder valueHolder = addUnconditionalHolder();
- valueHolder.value = value;
- valueHolder.name = checkNotNull(name);
- return this;
- }
-
- // Holder object for values that might be null and/or empty.
- private static class ValueHolder {
- @CheckForNull String name;
- @CheckForNull Object value;
- @CheckForNull ValueHolder next;
- }
-
- /**
- * Holder object for values that cannot be null or empty (will be printed unconditionally). This
- * helps to shortcut most calls to isEmpty(), which is important because the check for emptiness
- * is relatively expensive. Use a subtype so this also doesn't need any extra storage.
- */
- private static final class UnconditionalValueHolder extends ValueHolder {}
}
private MoreObjects() {}
diff --git a/android/guava/src/com/google/common/base/NullnessCasts.java b/android/guava/src/com/google/common/base/NullnessCasts.java
deleted file mode 100644
index 1ada6bf..0000000
--- a/android/guava/src/com/google/common/base/NullnessCasts.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright (C) 2021 The Guava Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
- * or implied. See the License for the specific language governing permissions and limitations under
- * the License.
- */
-
-package com.google.common.base;
-
-import com.google.common.annotations.GwtCompatible;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
-
-/** A utility method to perform unchecked casts to suppress errors produced by nullness analyses. */
-@GwtCompatible
-@ElementTypesAreNonnullByDefault
-final class NullnessCasts {
- /**
- * Accepts a {@code @Nullable T} and returns a plain {@code T}, without performing any check that
- * that conversion is safe.
- *
- * <p>This method is intended to help with usages of type parameters that have {@linkplain
- * ParametricNullness parametric nullness}. If a type parameter instead ranges over only non-null
- * types (or if the type is a non-variable type, like {@code String}), then code should almost
- * never use this method, preferring instead to call {@code requireNonNull} so as to benefit from
- * its runtime check.
- *
- * <p>An example use case for this method is in implementing an {@code Iterator<T>} whose {@code
- * next} field is lazily initialized. The type of that field would be {@code @Nullable T}, and the
- * code would be responsible for populating a "real" {@code T} (which might still be the value
- * {@code null}!) before returning it to callers. Depending on how the code is structured, a
- * nullness analysis might not understand that the field has been populated. To avoid that problem
- * without having to add {@code @SuppressWarnings}, the code can call this method.
- *
- * <p>Why <i>not</i> just add {@code SuppressWarnings}? The problem is that this method is
- * typically useful for {@code return} statements. That leaves the code with two options: Either
- * add the suppression to the whole method (which turns off checking for a large section of code),
- * or extract a variable, and put the suppression on that. However, a local variable typically
- * doesn't work: Because nullness analyses typically infer the nullness of local variables,
- * there's no way to assign a {@code @Nullable T} to a field {@code T foo;} and instruct the
- * analysis that that means "plain {@code T}" rather than the inferred type {@code @Nullable T}.
- * (Even if supported added {@code @NonNull}, that would not help, since the problem case
- * addressed by this method is the case in which {@code T} has parametric nullness -- and thus its
- * value may be legitimately {@code null}.)
- */
- @ParametricNullness
- @SuppressWarnings("nullness")
- static <T extends @Nullable Object> T uncheckedCastNullableTToT(@CheckForNull T t) {
- return t;
- }
-
- private NullnessCasts() {}
-}
diff --git a/android/guava/src/com/google/common/base/Objects.java b/android/guava/src/com/google/common/base/Objects.java
index bd6b0d9..1a409a6 100644
--- a/android/guava/src/com/google/common/base/Objects.java
+++ b/android/guava/src/com/google/common/base/Objects.java
@@ -16,8 +16,7 @@
import com.google.common.annotations.GwtCompatible;
import java.util.Arrays;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* Helper functions that can operate on any {@code Object}.
@@ -30,7 +29,6 @@
* @since 2.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
public final class Objects extends ExtraObjectsMethodsForWeb {
private Objects() {}
@@ -50,7 +48,7 @@
* <p><b>Note for Java 7 and later:</b> This method should be treated as deprecated; use {@link
* java.util.Objects#equals} instead.
*/
- public static boolean equal(@CheckForNull Object a, @CheckForNull Object b) {
+ public static boolean equal(@NullableDecl Object a, @NullableDecl Object b) {
return a == b || (a != null && a.equals(b));
}
@@ -75,7 +73,7 @@
* <p><b>Note for Java 7 and later:</b> This method should be treated as deprecated; use {@link
* java.util.Objects#hash} instead.
*/
- public static int hashCode(@CheckForNull @Nullable Object... objects) {
+ public static int hashCode(@NullableDecl Object... objects) {
return Arrays.hashCode(objects);
}
}
diff --git a/android/guava/src/com/google/common/base/Optional.java b/android/guava/src/com/google/common/base/Optional.java
index a7a0b3d..611ba54 100644
--- a/android/guava/src/com/google/common/base/Optional.java
+++ b/android/guava/src/com/google/common/base/Optional.java
@@ -22,7 +22,7 @@
import java.io.Serializable;
import java.util.Iterator;
import java.util.Set;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* An immutable object that may contain a non-null reference to another object. Each instance of
@@ -82,7 +82,6 @@
*/
@DoNotMock("Use Optional.of(value) or Optional.absent()")
@GwtCompatible(serializable = true)
-@ElementTypesAreNonnullByDefault
public abstract class Optional<T> implements Serializable {
/**
* Returns an {@code Optional} instance with no contained reference.
@@ -113,7 +112,7 @@
* <p><b>Comparison to {@code java.util.Optional}:</b> this method is equivalent to Java 8's
* {@code Optional.ofNullable}.
*/
- public static <T> Optional<T> fromNullable(@CheckForNull T nullableReference) {
+ public static <T> Optional<T> fromNullable(@NullableDecl T nullableReference) {
return (nullableReference == null) ? Optional.<T>absent() : new Present<T>(nullableReference);
}
@@ -207,7 +206,7 @@
* <p><b>Comparison to {@code java.util.Optional}:</b> this method is equivalent to Java 8's
* {@code Optional.orElse(null)}.
*/
- @CheckForNull
+ @NullableDecl
public abstract T orNull();
/**
@@ -256,7 +255,7 @@
* <p><b>Comparison to {@code java.util.Optional}:</b> no differences.
*/
@Override
- public abstract boolean equals(@CheckForNull Object object);
+ public abstract boolean equals(@NullableDecl Object object);
/**
* Returns a hash code for this instance.
@@ -301,7 +300,6 @@
checkNotNull(optionals.iterator());
@Override
- @CheckForNull
protected T computeNext() {
while (iterator.hasNext()) {
Optional<? extends T> optional = iterator.next();
diff --git a/android/guava/src/com/google/common/base/PairwiseEquivalence.java b/android/guava/src/com/google/common/base/PairwiseEquivalence.java
index 74be27f..cb7d784 100644
--- a/android/guava/src/com/google/common/base/PairwiseEquivalence.java
+++ b/android/guava/src/com/google/common/base/PairwiseEquivalence.java
@@ -17,16 +17,14 @@
import com.google.common.annotations.GwtCompatible;
import java.io.Serializable;
import java.util.Iterator;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
@GwtCompatible(serializable = true)
-@ElementTypesAreNonnullByDefault
-final class PairwiseEquivalence<E, T extends @Nullable E> extends Equivalence<Iterable<T>>
- implements Serializable {
- final Equivalence<E> elementEquivalence;
+final class PairwiseEquivalence<T> extends Equivalence<Iterable<T>> implements Serializable {
- PairwiseEquivalence(Equivalence<E> elementEquivalence) {
+ final Equivalence<? super T> elementEquivalence;
+
+ PairwiseEquivalence(Equivalence<? super T> elementEquivalence) {
this.elementEquivalence = Preconditions.checkNotNull(elementEquivalence);
}
@@ -54,9 +52,9 @@
}
@Override
- public boolean equals(@CheckForNull Object object) {
+ public boolean equals(@NullableDecl Object object) {
if (object instanceof PairwiseEquivalence) {
- PairwiseEquivalence<?, ?> that = (PairwiseEquivalence<?, ?>) object;
+ PairwiseEquivalence<?> that = (PairwiseEquivalence<?>) object;
return this.elementEquivalence.equals(that.elementEquivalence);
}
diff --git a/android/guava/src/com/google/common/base/ParametricNullness.java b/android/guava/src/com/google/common/base/ParametricNullness.java
deleted file mode 100644
index c736055..0000000
--- a/android/guava/src/com/google/common/base/ParametricNullness.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2021 The Guava Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.common.base;
-
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.PARAMETER;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-import static javax.annotation.meta.When.UNKNOWN;
-
-import com.google.common.annotations.GwtCompatible;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-import javax.annotation.Nonnull;
-import javax.annotation.meta.TypeQualifierNickname;
-
-/**
- * Marks a "top-level" type-variable usage as (a) a Kotlin platform type when the type argument is
- * non-nullable and (b) nullable when the type argument is nullable. This is the closest we can get
- * to "non-nullable when non-nullable; nullable when nullable" (like the Android <a
- * href="https://android.googlesource.com/platform/libcore/+/master/luni/src/main/java/libcore/util/NullFromTypeParam.java">{@code
- * NullFromTypeParam}</a>). We use this to "undo" {@link ElementTypesAreNonnullByDefault}.
- */
-@GwtCompatible
-@Retention(RUNTIME)
-@Target({FIELD, METHOD, PARAMETER})
-@TypeQualifierNickname
-@Nonnull(when = UNKNOWN)
-@interface ParametricNullness {}
diff --git a/android/guava/src/com/google/common/base/PatternCompiler.java b/android/guava/src/com/google/common/base/PatternCompiler.java
index 72a45fa..813a25f 100644
--- a/android/guava/src/com/google/common/base/PatternCompiler.java
+++ b/android/guava/src/com/google/common/base/PatternCompiler.java
@@ -22,7 +22,6 @@
* java.util.ServiceLoader} mechanism.
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
interface PatternCompiler {
/**
* Compiles the given pattern.
diff --git a/android/guava/src/com/google/common/base/Platform.java b/android/guava/src/com/google/common/base/Platform.java
index 703b860..26c5c29 100644
--- a/android/guava/src/com/google/common/base/Platform.java
+++ b/android/guava/src/com/google/common/base/Platform.java
@@ -21,7 +21,7 @@
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.regex.Pattern;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* Methods factored out so that they can be emulated differently in GWT.
@@ -29,7 +29,6 @@
* @author Jesse Wilson
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
final class Platform {
private static final Logger logger = Logger.getLogger(Platform.class.getName());
private static final PatternCompiler patternCompiler = loadPatternCompiler();
@@ -55,28 +54,15 @@
return String.format(Locale.ROOT, "%.4g", value);
}
- static boolean stringIsNullOrEmpty(@CheckForNull String string) {
+ static boolean stringIsNullOrEmpty(@NullableDecl String string) {
return string == null || string.isEmpty();
}
- /**
- * Returns the string if it is not null, or an empty string otherwise.
- *
- * @param string the string to test and possibly return
- * @return {@code string} if it is not null; {@code ""} otherwise
- */
- static String nullToEmpty(@CheckForNull String string) {
+ static String nullToEmpty(@NullableDecl String string) {
return (string == null) ? "" : string;
}
- /**
- * Returns the string if it is not empty, or a null string otherwise.
- *
- * @param string the string to test and possibly return
- * @return {@code string} if it is not empty; {@code null} otherwise
- */
- @CheckForNull
- static String emptyToNull(@CheckForNull String string) {
+ static String emptyToNull(@NullableDecl String string) {
return stringIsNullOrEmpty(string) ? null : string;
}
diff --git a/android/guava/src/com/google/common/base/Preconditions.java b/android/guava/src/com/google/common/base/Preconditions.java
index 13ff77b..995d394 100644
--- a/android/guava/src/com/google/common/base/Preconditions.java
+++ b/android/guava/src/com/google/common/base/Preconditions.java
@@ -18,8 +18,8 @@
import com.google.common.annotations.GwtCompatible;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NonNullDecl;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* Static convenience methods that help a method or constructor check whether it was invoked
@@ -114,12 +114,9 @@
* @since 2.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
public final class Preconditions {
private Preconditions() {}
- // TODO(cpovirk): Standardize parameter names (expression vs. b, reference vs. obj).
-
/**
* Ensures the truth of an expression involving one or more parameters to the calling method.
*
@@ -140,7 +137,7 @@
* string using {@link String#valueOf(Object)}
* @throws IllegalArgumentException if {@code expression} is false
*/
- public static void checkArgument(boolean expression, @CheckForNull Object errorMessage) {
+ public static void checkArgument(boolean expression, @NullableDecl Object errorMessage) {
if (!expression) {
throw new IllegalArgumentException(String.valueOf(errorMessage));
}
@@ -161,8 +158,8 @@
*/
public static void checkArgument(
boolean expression,
- String errorMessageTemplate,
- @CheckForNull @Nullable Object... errorMessageArgs) {
+ @NullableDecl String errorMessageTemplate,
+ @NullableDecl Object... errorMessageArgs) {
if (!expression) {
throw new IllegalArgumentException(lenientFormat(errorMessageTemplate, errorMessageArgs));
}
@@ -175,7 +172,7 @@
*
* @since 20.0 (varargs overload since 2.0)
*/
- public static void checkArgument(boolean b, String errorMessageTemplate, char p1) {
+ public static void checkArgument(boolean b, @NullableDecl String errorMessageTemplate, char p1) {
if (!b) {
throw new IllegalArgumentException(lenientFormat(errorMessageTemplate, p1));
}
@@ -188,7 +185,7 @@
*
* @since 20.0 (varargs overload since 2.0)
*/
- public static void checkArgument(boolean b, String errorMessageTemplate, int p1) {
+ public static void checkArgument(boolean b, @NullableDecl String errorMessageTemplate, int p1) {
if (!b) {
throw new IllegalArgumentException(lenientFormat(errorMessageTemplate, p1));
}
@@ -201,7 +198,7 @@
*
* @since 20.0 (varargs overload since 2.0)
*/
- public static void checkArgument(boolean b, String errorMessageTemplate, long p1) {
+ public static void checkArgument(boolean b, @NullableDecl String errorMessageTemplate, long p1) {
if (!b) {
throw new IllegalArgumentException(lenientFormat(errorMessageTemplate, p1));
}
@@ -215,7 +212,7 @@
* @since 20.0 (varargs overload since 2.0)
*/
public static void checkArgument(
- boolean b, String errorMessageTemplate, @CheckForNull Object p1) {
+ boolean b, @NullableDecl String errorMessageTemplate, @NullableDecl Object p1) {
if (!b) {
throw new IllegalArgumentException(lenientFormat(errorMessageTemplate, p1));
}
@@ -228,33 +225,8 @@
*
* @since 20.0 (varargs overload since 2.0)
*/
- public static void checkArgument(boolean b, String errorMessageTemplate, char p1, char p2) {
- if (!b) {
- throw new IllegalArgumentException(lenientFormat(errorMessageTemplate, p1, p2));
- }
- }
-
- /**
- * Ensures the truth of an expression involving one or more parameters to the calling method.
- *
- * <p>See {@link #checkArgument(boolean, String, Object...)} for details.
- *
- * @since 20.0 (varargs overload since 2.0)
- */
- public static void checkArgument(boolean b, String errorMessageTemplate, char p1, int p2) {
- if (!b) {
- throw new IllegalArgumentException(lenientFormat(errorMessageTemplate, p1, p2));
- }
- }
-
- /**
- * Ensures the truth of an expression involving one or more parameters to the calling method.
- *
- * <p>See {@link #checkArgument(boolean, String, Object...)} for details.
- *
- * @since 20.0 (varargs overload since 2.0)
- */
- public static void checkArgument(boolean b, String errorMessageTemplate, char p1, long p2) {
+ public static void checkArgument(
+ boolean b, @NullableDecl String errorMessageTemplate, char p1, char p2) {
if (!b) {
throw new IllegalArgumentException(lenientFormat(errorMessageTemplate, p1, p2));
}
@@ -268,46 +240,7 @@
* @since 20.0 (varargs overload since 2.0)
*/
public static void checkArgument(
- boolean b, String errorMessageTemplate, char p1, @CheckForNull Object p2) {
- if (!b) {
- throw new IllegalArgumentException(lenientFormat(errorMessageTemplate, p1, p2));
- }
- }
-
- /**
- * Ensures the truth of an expression involving one or more parameters to the calling method.
- *
- * <p>See {@link #checkArgument(boolean, String, Object...)} for details.
- *
- * @since 20.0 (varargs overload since 2.0)
- */
- public static void checkArgument(boolean b, String errorMessageTemplate, int p1, char p2) {
- if (!b) {
- throw new IllegalArgumentException(lenientFormat(errorMessageTemplate, p1, p2));
- }
- }
-
- /**
- * Ensures the truth of an expression involving one or more parameters to the calling method.
- *
- * <p>See {@link #checkArgument(boolean, String, Object...)} for details.
- *
- * @since 20.0 (varargs overload since 2.0)
- */
- public static void checkArgument(boolean b, String errorMessageTemplate, int p1, int p2) {
- if (!b) {
- throw new IllegalArgumentException(lenientFormat(errorMessageTemplate, p1, p2));
- }
- }
-
- /**
- * Ensures the truth of an expression involving one or more parameters to the calling method.
- *
- * <p>See {@link #checkArgument(boolean, String, Object...)} for details.
- *
- * @since 20.0 (varargs overload since 2.0)
- */
- public static void checkArgument(boolean b, String errorMessageTemplate, int p1, long p2) {
+ boolean b, @NullableDecl String errorMessageTemplate, char p1, int p2) {
if (!b) {
throw new IllegalArgumentException(lenientFormat(errorMessageTemplate, p1, p2));
}
@@ -321,46 +254,7 @@
* @since 20.0 (varargs overload since 2.0)
*/
public static void checkArgument(
- boolean b, String errorMessageTemplate, int p1, @CheckForNull Object p2) {
- if (!b) {
- throw new IllegalArgumentException(lenientFormat(errorMessageTemplate, p1, p2));
- }
- }
-
- /**
- * Ensures the truth of an expression involving one or more parameters to the calling method.
- *
- * <p>See {@link #checkArgument(boolean, String, Object...)} for details.
- *
- * @since 20.0 (varargs overload since 2.0)
- */
- public static void checkArgument(boolean b, String errorMessageTemplate, long p1, char p2) {
- if (!b) {
- throw new IllegalArgumentException(lenientFormat(errorMessageTemplate, p1, p2));
- }
- }
-
- /**
- * Ensures the truth of an expression involving one or more parameters to the calling method.
- *
- * <p>See {@link #checkArgument(boolean, String, Object...)} for details.
- *
- * @since 20.0 (varargs overload since 2.0)
- */
- public static void checkArgument(boolean b, String errorMessageTemplate, long p1, int p2) {
- if (!b) {
- throw new IllegalArgumentException(lenientFormat(errorMessageTemplate, p1, p2));
- }
- }
-
- /**
- * Ensures the truth of an expression involving one or more parameters to the calling method.
- *
- * <p>See {@link #checkArgument(boolean, String, Object...)} for details.
- *
- * @since 20.0 (varargs overload since 2.0)
- */
- public static void checkArgument(boolean b, String errorMessageTemplate, long p1, long p2) {
+ boolean b, @NullableDecl String errorMessageTemplate, char p1, long p2) {
if (!b) {
throw new IllegalArgumentException(lenientFormat(errorMessageTemplate, p1, p2));
}
@@ -374,7 +268,7 @@
* @since 20.0 (varargs overload since 2.0)
*/
public static void checkArgument(
- boolean b, String errorMessageTemplate, long p1, @CheckForNull Object p2) {
+ boolean b, @NullableDecl String errorMessageTemplate, char p1, @NullableDecl Object p2) {
if (!b) {
throw new IllegalArgumentException(lenientFormat(errorMessageTemplate, p1, p2));
}
@@ -388,7 +282,7 @@
* @since 20.0 (varargs overload since 2.0)
*/
public static void checkArgument(
- boolean b, String errorMessageTemplate, @CheckForNull Object p1, char p2) {
+ boolean b, @NullableDecl String errorMessageTemplate, int p1, char p2) {
if (!b) {
throw new IllegalArgumentException(lenientFormat(errorMessageTemplate, p1, p2));
}
@@ -402,7 +296,7 @@
* @since 20.0 (varargs overload since 2.0)
*/
public static void checkArgument(
- boolean b, String errorMessageTemplate, @CheckForNull Object p1, int p2) {
+ boolean b, @NullableDecl String errorMessageTemplate, int p1, int p2) {
if (!b) {
throw new IllegalArgumentException(lenientFormat(errorMessageTemplate, p1, p2));
}
@@ -416,7 +310,7 @@
* @since 20.0 (varargs overload since 2.0)
*/
public static void checkArgument(
- boolean b, String errorMessageTemplate, @CheckForNull Object p1, long p2) {
+ boolean b, @NullableDecl String errorMessageTemplate, int p1, long p2) {
if (!b) {
throw new IllegalArgumentException(lenientFormat(errorMessageTemplate, p1, p2));
}
@@ -430,7 +324,105 @@
* @since 20.0 (varargs overload since 2.0)
*/
public static void checkArgument(
- boolean b, String errorMessageTemplate, @CheckForNull Object p1, @CheckForNull Object p2) {
+ boolean b, @NullableDecl String errorMessageTemplate, int p1, @NullableDecl Object p2) {
+ if (!b) {
+ throw new IllegalArgumentException(lenientFormat(errorMessageTemplate, p1, p2));
+ }
+ }
+
+ /**
+ * Ensures the truth of an expression involving one or more parameters to the calling method.
+ *
+ * <p>See {@link #checkArgument(boolean, String, Object...)} for details.
+ *
+ * @since 20.0 (varargs overload since 2.0)
+ */
+ public static void checkArgument(
+ boolean b, @NullableDecl String errorMessageTemplate, long p1, char p2) {
+ if (!b) {
+ throw new IllegalArgumentException(lenientFormat(errorMessageTemplate, p1, p2));
+ }
+ }
+
+ /**
+ * Ensures the truth of an expression involving one or more parameters to the calling method.
+ *
+ * <p>See {@link #checkArgument(boolean, String, Object...)} for details.
+ *
+ * @since 20.0 (varargs overload since 2.0)
+ */
+ public static void checkArgument(
+ boolean b, @NullableDecl String errorMessageTemplate, long p1, int p2) {
+ if (!b) {
+ throw new IllegalArgumentException(lenientFormat(errorMessageTemplate, p1, p2));
+ }
+ }
+
+ /**
+ * Ensures the truth of an expression involving one or more parameters to the calling method.
+ *
+ * <p>See {@link #checkArgument(boolean, String, Object...)} for details.
+ *
+ * @since 20.0 (varargs overload since 2.0)
+ */
+ public static void checkArgument(
+ boolean b, @NullableDecl String errorMessageTemplate, long p1, long p2) {
+ if (!b) {
+ throw new IllegalArgumentException(lenientFormat(errorMessageTemplate, p1, p2));
+ }
+ }
+
+ /**
+ * Ensures the truth of an expression involving one or more parameters to the calling method.
+ *
+ * <p>See {@link #checkArgument(boolean, String, Object...)} for details.
+ *
+ * @since 20.0 (varargs overload since 2.0)
+ */
+ public static void checkArgument(
+ boolean b, @NullableDecl String errorMessageTemplate, long p1, @NullableDecl Object p2) {
+ if (!b) {
+ throw new IllegalArgumentException(lenientFormat(errorMessageTemplate, p1, p2));
+ }
+ }
+
+ /**
+ * Ensures the truth of an expression involving one or more parameters to the calling method.
+ *
+ * <p>See {@link #checkArgument(boolean, String, Object...)} for details.
+ *
+ * @since 20.0 (varargs overload since 2.0)
+ */
+ public static void checkArgument(
+ boolean b, @NullableDecl String errorMessageTemplate, @NullableDecl Object p1, char p2) {
+ if (!b) {
+ throw new IllegalArgumentException(lenientFormat(errorMessageTemplate, p1, p2));
+ }
+ }
+
+ /**
+ * Ensures the truth of an expression involving one or more parameters to the calling method.
+ *
+ * <p>See {@link #checkArgument(boolean, String, Object...)} for details.
+ *
+ * @since 20.0 (varargs overload since 2.0)
+ */
+ public static void checkArgument(
+ boolean b, @NullableDecl String errorMessageTemplate, @NullableDecl Object p1, int p2) {
+ if (!b) {
+ throw new IllegalArgumentException(lenientFormat(errorMessageTemplate, p1, p2));
+ }
+ }
+
+ /**
+ * Ensures the truth of an expression involving one or more parameters to the calling method.
+ *
+ * <p>See {@link #checkArgument(boolean, String, Object...)} for details.
+ *
+ * @since 20.0 (varargs overload since 2.0)
+ */
+ public static void checkArgument(
+ boolean b, @NullableDecl String errorMessageTemplate, @NullableDecl Object p1, long p2) {
if (!b) {
throw new IllegalArgumentException(lenientFormat(errorMessageTemplate, p1, p2));
}
@@ -445,10 +437,27 @@
*/
public static void checkArgument(
boolean b,
- String errorMessageTemplate,
- @CheckForNull Object p1,
- @CheckForNull Object p2,
- @CheckForNull Object p3) {
+ @NullableDecl String errorMessageTemplate,
+ @NullableDecl Object p1,
+ @NullableDecl Object p2) {
+ if (!b) {
+ throw new IllegalArgumentException(lenientFormat(errorMessageTemplate, p1, p2));
+ }
+ }
+
+ /**
+ * Ensures the truth of an expression involving one or more parameters to the calling method.
+ *
+ * <p>See {@link #checkArgument(boolean, String, Object...)} for details.
+ *
+ * @since 20.0 (varargs overload since 2.0)
+ */
+ public static void checkArgument(
+ boolean b,
+ @NullableDecl String errorMessageTemplate,
+ @NullableDecl Object p1,
+ @NullableDecl Object p2,
+ @NullableDecl Object p3) {
if (!b) {
throw new IllegalArgumentException(lenientFormat(errorMessageTemplate, p1, p2, p3));
}
@@ -463,11 +472,11 @@
*/
public static void checkArgument(
boolean b,
- String errorMessageTemplate,
- @CheckForNull Object p1,
- @CheckForNull Object p2,
- @CheckForNull Object p3,
- @CheckForNull Object p4) {
+ @NullableDecl String errorMessageTemplate,
+ @NullableDecl Object p1,
+ @NullableDecl Object p2,
+ @NullableDecl Object p3,
+ @NullableDecl Object p4) {
if (!b) {
throw new IllegalArgumentException(lenientFormat(errorMessageTemplate, p1, p2, p3, p4));
}
@@ -497,7 +506,7 @@
* @throws IllegalStateException if {@code expression} is false
* @see Verify#verify Verify.verify()
*/
- public static void checkState(boolean expression, @CheckForNull Object errorMessage) {
+ public static void checkState(boolean expression, @NullableDecl Object errorMessage) {
if (!expression) {
throw new IllegalStateException(String.valueOf(errorMessage));
}
@@ -520,16 +529,8 @@
*/
public static void checkState(
boolean expression,
- /*
- * TODO(cpovirk): Consider removing @CheckForNull here, as we've done with the other methods'
- * errorMessageTemplate parameters: It it unlikely that callers intend for their string
- * template to be null (though we do handle that case gracefully at runtime). I've left this
- * one as it is because one of our users has defined a wrapper API around Preconditions,
- * declaring a checkState method that accepts a possibly null template. So we'd need to update
- * that user first.
- */
- @CheckForNull String errorMessageTemplate,
- @CheckForNull @Nullable Object... errorMessageArgs) {
+ @NullableDecl String errorMessageTemplate,
+ @NullableDecl Object... errorMessageArgs) {
if (!expression) {
throw new IllegalStateException(lenientFormat(errorMessageTemplate, errorMessageArgs));
}
@@ -543,7 +544,7 @@
*
* @since 20.0 (varargs overload since 2.0)
*/
- public static void checkState(boolean b, String errorMessageTemplate, char p1) {
+ public static void checkState(boolean b, @NullableDecl String errorMessageTemplate, char p1) {
if (!b) {
throw new IllegalStateException(lenientFormat(errorMessageTemplate, p1));
}
@@ -557,7 +558,7 @@
*
* @since 20.0 (varargs overload since 2.0)
*/
- public static void checkState(boolean b, String errorMessageTemplate, int p1) {
+ public static void checkState(boolean b, @NullableDecl String errorMessageTemplate, int p1) {
if (!b) {
throw new IllegalStateException(lenientFormat(errorMessageTemplate, p1));
}
@@ -571,7 +572,7 @@
*
* @since 20.0 (varargs overload since 2.0)
*/
- public static void checkState(boolean b, String errorMessageTemplate, long p1) {
+ public static void checkState(boolean b, @NullableDecl String errorMessageTemplate, long p1) {
if (!b) {
throw new IllegalStateException(lenientFormat(errorMessageTemplate, p1));
}
@@ -585,7 +586,8 @@
*
* @since 20.0 (varargs overload since 2.0)
*/
- public static void checkState(boolean b, String errorMessageTemplate, @CheckForNull Object p1) {
+ public static void checkState(
+ boolean b, @NullableDecl String errorMessageTemplate, @NullableDecl Object p1) {
if (!b) {
throw new IllegalStateException(lenientFormat(errorMessageTemplate, p1));
}
@@ -599,35 +601,8 @@
*
* @since 20.0 (varargs overload since 2.0)
*/
- public static void checkState(boolean b, String errorMessageTemplate, char p1, char p2) {
- if (!b) {
- throw new IllegalStateException(lenientFormat(errorMessageTemplate, p1, p2));
- }
- }
-
- /**
- * Ensures the truth of an expression involving the state of the calling instance, but not
- * involving any parameters to the calling method.
- *
- * <p>See {@link #checkState(boolean, String, Object...)} for details.
- *
- * @since 20.0 (varargs overload since 2.0)
- */
- public static void checkState(boolean b, String errorMessageTemplate, char p1, int p2) {
- if (!b) {
- throw new IllegalStateException(lenientFormat(errorMessageTemplate, p1, p2));
- }
- }
-
- /**
- * Ensures the truth of an expression involving the state of the calling instance, but not
- * involving any parameters to the calling method.
- *
- * <p>See {@link #checkState(boolean, String, Object...)} for details.
- *
- * @since 20.0 (varargs overload since 2.0)
- */
- public static void checkState(boolean b, String errorMessageTemplate, char p1, long p2) {
+ public static void checkState(
+ boolean b, @NullableDecl String errorMessageTemplate, char p1, char p2) {
if (!b) {
throw new IllegalStateException(lenientFormat(errorMessageTemplate, p1, p2));
}
@@ -642,49 +617,7 @@
* @since 20.0 (varargs overload since 2.0)
*/
public static void checkState(
- boolean b, String errorMessageTemplate, char p1, @CheckForNull Object p2) {
- if (!b) {
- throw new IllegalStateException(lenientFormat(errorMessageTemplate, p1, p2));
- }
- }
-
- /**
- * Ensures the truth of an expression involving the state of the calling instance, but not
- * involving any parameters to the calling method.
- *
- * <p>See {@link #checkState(boolean, String, Object...)} for details.
- *
- * @since 20.0 (varargs overload since 2.0)
- */
- public static void checkState(boolean b, String errorMessageTemplate, int p1, char p2) {
- if (!b) {
- throw new IllegalStateException(lenientFormat(errorMessageTemplate, p1, p2));
- }
- }
-
- /**
- * Ensures the truth of an expression involving the state of the calling instance, but not
- * involving any parameters to the calling method.
- *
- * <p>See {@link #checkState(boolean, String, Object...)} for details.
- *
- * @since 20.0 (varargs overload since 2.0)
- */
- public static void checkState(boolean b, String errorMessageTemplate, int p1, int p2) {
- if (!b) {
- throw new IllegalStateException(lenientFormat(errorMessageTemplate, p1, p2));
- }
- }
-
- /**
- * Ensures the truth of an expression involving the state of the calling instance, but not
- * involving any parameters to the calling method.
- *
- * <p>See {@link #checkState(boolean, String, Object...)} for details.
- *
- * @since 20.0 (varargs overload since 2.0)
- */
- public static void checkState(boolean b, String errorMessageTemplate, int p1, long p2) {
+ boolean b, @NullableDecl String errorMessageTemplate, char p1, int p2) {
if (!b) {
throw new IllegalStateException(lenientFormat(errorMessageTemplate, p1, p2));
}
@@ -699,49 +632,7 @@
* @since 20.0 (varargs overload since 2.0)
*/
public static void checkState(
- boolean b, String errorMessageTemplate, int p1, @CheckForNull Object p2) {
- if (!b) {
- throw new IllegalStateException(lenientFormat(errorMessageTemplate, p1, p2));
- }
- }
-
- /**
- * Ensures the truth of an expression involving the state of the calling instance, but not
- * involving any parameters to the calling method.
- *
- * <p>See {@link #checkState(boolean, String, Object...)} for details.
- *
- * @since 20.0 (varargs overload since 2.0)
- */
- public static void checkState(boolean b, String errorMessageTemplate, long p1, char p2) {
- if (!b) {
- throw new IllegalStateException(lenientFormat(errorMessageTemplate, p1, p2));
- }
- }
-
- /**
- * Ensures the truth of an expression involving the state of the calling instance, but not
- * involving any parameters to the calling method.
- *
- * <p>See {@link #checkState(boolean, String, Object...)} for details.
- *
- * @since 20.0 (varargs overload since 2.0)
- */
- public static void checkState(boolean b, String errorMessageTemplate, long p1, int p2) {
- if (!b) {
- throw new IllegalStateException(lenientFormat(errorMessageTemplate, p1, p2));
- }
- }
-
- /**
- * Ensures the truth of an expression involving the state of the calling instance, but not
- * involving any parameters to the calling method.
- *
- * <p>See {@link #checkState(boolean, String, Object...)} for details.
- *
- * @since 20.0 (varargs overload since 2.0)
- */
- public static void checkState(boolean b, String errorMessageTemplate, long p1, long p2) {
+ boolean b, @NullableDecl String errorMessageTemplate, char p1, long p2) {
if (!b) {
throw new IllegalStateException(lenientFormat(errorMessageTemplate, p1, p2));
}
@@ -756,7 +647,7 @@
* @since 20.0 (varargs overload since 2.0)
*/
public static void checkState(
- boolean b, String errorMessageTemplate, long p1, @CheckForNull Object p2) {
+ boolean b, @NullableDecl String errorMessageTemplate, char p1, @NullableDecl Object p2) {
if (!b) {
throw new IllegalStateException(lenientFormat(errorMessageTemplate, p1, p2));
}
@@ -771,7 +662,7 @@
* @since 20.0 (varargs overload since 2.0)
*/
public static void checkState(
- boolean b, String errorMessageTemplate, @CheckForNull Object p1, char p2) {
+ boolean b, @NullableDecl String errorMessageTemplate, int p1, char p2) {
if (!b) {
throw new IllegalStateException(lenientFormat(errorMessageTemplate, p1, p2));
}
@@ -786,7 +677,7 @@
* @since 20.0 (varargs overload since 2.0)
*/
public static void checkState(
- boolean b, String errorMessageTemplate, @CheckForNull Object p1, int p2) {
+ boolean b, @NullableDecl String errorMessageTemplate, int p1, int p2) {
if (!b) {
throw new IllegalStateException(lenientFormat(errorMessageTemplate, p1, p2));
}
@@ -801,7 +692,7 @@
* @since 20.0 (varargs overload since 2.0)
*/
public static void checkState(
- boolean b, String errorMessageTemplate, @CheckForNull Object p1, long p2) {
+ boolean b, @NullableDecl String errorMessageTemplate, int p1, long p2) {
if (!b) {
throw new IllegalStateException(lenientFormat(errorMessageTemplate, p1, p2));
}
@@ -816,7 +707,112 @@
* @since 20.0 (varargs overload since 2.0)
*/
public static void checkState(
- boolean b, String errorMessageTemplate, @CheckForNull Object p1, @CheckForNull Object p2) {
+ boolean b, @NullableDecl String errorMessageTemplate, int p1, @NullableDecl Object p2) {
+ if (!b) {
+ throw new IllegalStateException(lenientFormat(errorMessageTemplate, p1, p2));
+ }
+ }
+
+ /**
+ * Ensures the truth of an expression involving the state of the calling instance, but not
+ * involving any parameters to the calling method.
+ *
+ * <p>See {@link #checkState(boolean, String, Object...)} for details.
+ *
+ * @since 20.0 (varargs overload since 2.0)
+ */
+ public static void checkState(
+ boolean b, @NullableDecl String errorMessageTemplate, long p1, char p2) {
+ if (!b) {
+ throw new IllegalStateException(lenientFormat(errorMessageTemplate, p1, p2));
+ }
+ }
+
+ /**
+ * Ensures the truth of an expression involving the state of the calling instance, but not
+ * involving any parameters to the calling method.
+ *
+ * <p>See {@link #checkState(boolean, String, Object...)} for details.
+ *
+ * @since 20.0 (varargs overload since 2.0)
+ */
+ public static void checkState(
+ boolean b, @NullableDecl String errorMessageTemplate, long p1, int p2) {
+ if (!b) {
+ throw new IllegalStateException(lenientFormat(errorMessageTemplate, p1, p2));
+ }
+ }
+
+ /**
+ * Ensures the truth of an expression involving the state of the calling instance, but not
+ * involving any parameters to the calling method.
+ *
+ * <p>See {@link #checkState(boolean, String, Object...)} for details.
+ *
+ * @since 20.0 (varargs overload since 2.0)
+ */
+ public static void checkState(
+ boolean b, @NullableDecl String errorMessageTemplate, long p1, long p2) {
+ if (!b) {
+ throw new IllegalStateException(lenientFormat(errorMessageTemplate, p1, p2));
+ }
+ }
+
+ /**
+ * Ensures the truth of an expression involving the state of the calling instance, but not
+ * involving any parameters to the calling method.
+ *
+ * <p>See {@link #checkState(boolean, String, Object...)} for details.
+ *
+ * @since 20.0 (varargs overload since 2.0)
+ */
+ public static void checkState(
+ boolean b, @NullableDecl String errorMessageTemplate, long p1, @NullableDecl Object p2) {
+ if (!b) {
+ throw new IllegalStateException(lenientFormat(errorMessageTemplate, p1, p2));
+ }
+ }
+
+ /**
+ * Ensures the truth of an expression involving the state of the calling instance, but not
+ * involving any parameters to the calling method.
+ *
+ * <p>See {@link #checkState(boolean, String, Object...)} for details.
+ *
+ * @since 20.0 (varargs overload since 2.0)
+ */
+ public static void checkState(
+ boolean b, @NullableDecl String errorMessageTemplate, @NullableDecl Object p1, char p2) {
+ if (!b) {
+ throw new IllegalStateException(lenientFormat(errorMessageTemplate, p1, p2));
+ }
+ }
+
+ /**
+ * Ensures the truth of an expression involving the state of the calling instance, but not
+ * involving any parameters to the calling method.
+ *
+ * <p>See {@link #checkState(boolean, String, Object...)} for details.
+ *
+ * @since 20.0 (varargs overload since 2.0)
+ */
+ public static void checkState(
+ boolean b, @NullableDecl String errorMessageTemplate, @NullableDecl Object p1, int p2) {
+ if (!b) {
+ throw new IllegalStateException(lenientFormat(errorMessageTemplate, p1, p2));
+ }
+ }
+
+ /**
+ * Ensures the truth of an expression involving the state of the calling instance, but not
+ * involving any parameters to the calling method.
+ *
+ * <p>See {@link #checkState(boolean, String, Object...)} for details.
+ *
+ * @since 20.0 (varargs overload since 2.0)
+ */
+ public static void checkState(
+ boolean b, @NullableDecl String errorMessageTemplate, @NullableDecl Object p1, long p2) {
if (!b) {
throw new IllegalStateException(lenientFormat(errorMessageTemplate, p1, p2));
}
@@ -832,10 +828,28 @@
*/
public static void checkState(
boolean b,
- String errorMessageTemplate,
- @CheckForNull Object p1,
- @CheckForNull Object p2,
- @CheckForNull Object p3) {
+ @NullableDecl String errorMessageTemplate,
+ @NullableDecl Object p1,
+ @NullableDecl Object p2) {
+ if (!b) {
+ throw new IllegalStateException(lenientFormat(errorMessageTemplate, p1, p2));
+ }
+ }
+
+ /**
+ * Ensures the truth of an expression involving the state of the calling instance, but not
+ * involving any parameters to the calling method.
+ *
+ * <p>See {@link #checkState(boolean, String, Object...)} for details.
+ *
+ * @since 20.0 (varargs overload since 2.0)
+ */
+ public static void checkState(
+ boolean b,
+ @NullableDecl String errorMessageTemplate,
+ @NullableDecl Object p1,
+ @NullableDecl Object p2,
+ @NullableDecl Object p3) {
if (!b) {
throw new IllegalStateException(lenientFormat(errorMessageTemplate, p1, p2, p3));
}
@@ -851,30 +865,16 @@
*/
public static void checkState(
boolean b,
- String errorMessageTemplate,
- @CheckForNull Object p1,
- @CheckForNull Object p2,
- @CheckForNull Object p3,
- @CheckForNull Object p4) {
+ @NullableDecl String errorMessageTemplate,
+ @NullableDecl Object p1,
+ @NullableDecl Object p2,
+ @NullableDecl Object p3,
+ @NullableDecl Object p4) {
if (!b) {
throw new IllegalStateException(lenientFormat(errorMessageTemplate, p1, p2, p3, p4));
}
}
- /*
- * Preconditions.checkNotNull is *intended* for performing eager null checks on parameters that a
- * nullness checker can already "prove" are non-null. That means that the first parameter to
- * checkNotNull *should* be annotated to require it to be non-null.
- *
- * However, for a variety of reasons, Google developers have written a ton of code over the past
- * decade that assumes that they can use checkNotNull for non-precondition checks. I had hoped to
- * take a principled stand on this, but the amount of such code is simply overwhelming. To avoid
- * creating a lot of compile errors that users would not find to be informative, we're giving in
- * and allowing callers to pass arguments that a nullness checker believes could be null.
- *
- * We still encourage people to use requireNonNull over checkNotNull for non-precondition checks.
- */
-
/**
* Ensures that an object reference passed as a parameter to the calling method is not null.
*
@@ -884,7 +884,8 @@
* @see Verify#verifyNotNull Verify.verifyNotNull()
*/
@CanIgnoreReturnValue
- public static <T> T checkNotNull(@CheckForNull T reference) {
+ @NonNullDecl
+ public static <T extends Object> T checkNotNull(@NonNullDecl T reference) {
if (reference == null) {
throw new NullPointerException();
}
@@ -902,7 +903,9 @@
* @see Verify#verifyNotNull Verify.verifyNotNull()
*/
@CanIgnoreReturnValue
- public static <T> T checkNotNull(@CheckForNull T reference, @CheckForNull Object errorMessage) {
+ @NonNullDecl
+ public static <T extends Object> T checkNotNull(
+ @NonNullDecl T reference, @NullableDecl Object errorMessage) {
if (reference == null) {
throw new NullPointerException(String.valueOf(errorMessage));
}
@@ -925,10 +928,11 @@
* @see Verify#verifyNotNull Verify.verifyNotNull()
*/
@CanIgnoreReturnValue
- public static <T> T checkNotNull(
- @CheckForNull T reference,
- String errorMessageTemplate,
- @CheckForNull @Nullable Object... errorMessageArgs) {
+ @NonNullDecl
+ public static <T extends Object> T checkNotNull(
+ @NonNullDecl T reference,
+ @NullableDecl String errorMessageTemplate,
+ @NullableDecl Object... errorMessageArgs) {
if (reference == null) {
throw new NullPointerException(lenientFormat(errorMessageTemplate, errorMessageArgs));
}
@@ -943,7 +947,9 @@
* @since 20.0 (varargs overload since 2.0)
*/
@CanIgnoreReturnValue
- public static <T> T checkNotNull(@CheckForNull T obj, String errorMessageTemplate, char p1) {
+ @NonNullDecl
+ public static <T extends Object> T checkNotNull(
+ @NonNullDecl T obj, @NullableDecl String errorMessageTemplate, char p1) {
if (obj == null) {
throw new NullPointerException(lenientFormat(errorMessageTemplate, p1));
}
@@ -958,7 +964,9 @@
* @since 20.0 (varargs overload since 2.0)
*/
@CanIgnoreReturnValue
- public static <T> T checkNotNull(@CheckForNull T obj, String errorMessageTemplate, int p1) {
+ @NonNullDecl
+ public static <T extends Object> T checkNotNull(
+ @NonNullDecl T obj, @NullableDecl String errorMessageTemplate, int p1) {
if (obj == null) {
throw new NullPointerException(lenientFormat(errorMessageTemplate, p1));
}
@@ -973,7 +981,9 @@
* @since 20.0 (varargs overload since 2.0)
*/
@CanIgnoreReturnValue
- public static <T> T checkNotNull(@CheckForNull T obj, String errorMessageTemplate, long p1) {
+ @NonNullDecl
+ public static <T extends Object> T checkNotNull(
+ @NonNullDecl T obj, @NullableDecl String errorMessageTemplate, long p1) {
if (obj == null) {
throw new NullPointerException(lenientFormat(errorMessageTemplate, p1));
}
@@ -988,8 +998,9 @@
* @since 20.0 (varargs overload since 2.0)
*/
@CanIgnoreReturnValue
- public static <T> T checkNotNull(
- @CheckForNull T obj, String errorMessageTemplate, @CheckForNull Object p1) {
+ @NonNullDecl
+ public static <T extends Object> T checkNotNull(
+ @NonNullDecl T obj, @NullableDecl String errorMessageTemplate, @NullableDecl Object p1) {
if (obj == null) {
throw new NullPointerException(lenientFormat(errorMessageTemplate, p1));
}
@@ -1004,8 +1015,9 @@
* @since 20.0 (varargs overload since 2.0)
*/
@CanIgnoreReturnValue
- public static <T> T checkNotNull(
- @CheckForNull T obj, String errorMessageTemplate, char p1, char p2) {
+ @NonNullDecl
+ public static <T extends Object> T checkNotNull(
+ @NonNullDecl T obj, @NullableDecl String errorMessageTemplate, char p1, char p2) {
if (obj == null) {
throw new NullPointerException(lenientFormat(errorMessageTemplate, p1, p2));
}
@@ -1020,8 +1032,9 @@
* @since 20.0 (varargs overload since 2.0)
*/
@CanIgnoreReturnValue
- public static <T> T checkNotNull(
- @CheckForNull T obj, String errorMessageTemplate, char p1, int p2) {
+ @NonNullDecl
+ public static <T extends Object> T checkNotNull(
+ @NonNullDecl T obj, @NullableDecl String errorMessageTemplate, char p1, int p2) {
if (obj == null) {
throw new NullPointerException(lenientFormat(errorMessageTemplate, p1, p2));
}
@@ -1036,8 +1049,9 @@
* @since 20.0 (varargs overload since 2.0)
*/
@CanIgnoreReturnValue
- public static <T> T checkNotNull(
- @CheckForNull T obj, String errorMessageTemplate, char p1, long p2) {
+ @NonNullDecl
+ public static <T extends Object> T checkNotNull(
+ @NonNullDecl T obj, @NullableDecl String errorMessageTemplate, char p1, long p2) {
if (obj == null) {
throw new NullPointerException(lenientFormat(errorMessageTemplate, p1, p2));
}
@@ -1052,8 +1066,12 @@
* @since 20.0 (varargs overload since 2.0)
*/
@CanIgnoreReturnValue
- public static <T> T checkNotNull(
- @CheckForNull T obj, String errorMessageTemplate, char p1, @CheckForNull Object p2) {
+ @NonNullDecl
+ public static <T extends Object> T checkNotNull(
+ @NonNullDecl T obj,
+ @NullableDecl String errorMessageTemplate,
+ char p1,
+ @NullableDecl Object p2) {
if (obj == null) {
throw new NullPointerException(lenientFormat(errorMessageTemplate, p1, p2));
}
@@ -1068,8 +1086,9 @@
* @since 20.0 (varargs overload since 2.0)
*/
@CanIgnoreReturnValue
- public static <T> T checkNotNull(
- @CheckForNull T obj, String errorMessageTemplate, int p1, char p2) {
+ @NonNullDecl
+ public static <T extends Object> T checkNotNull(
+ @NonNullDecl T obj, @NullableDecl String errorMessageTemplate, int p1, char p2) {
if (obj == null) {
throw new NullPointerException(lenientFormat(errorMessageTemplate, p1, p2));
}
@@ -1084,8 +1103,9 @@
* @since 20.0 (varargs overload since 2.0)
*/
@CanIgnoreReturnValue
- public static <T> T checkNotNull(
- @CheckForNull T obj, String errorMessageTemplate, int p1, int p2) {
+ @NonNullDecl
+ public static <T extends Object> T checkNotNull(
+ @NonNullDecl T obj, @NullableDecl String errorMessageTemplate, int p1, int p2) {
if (obj == null) {
throw new NullPointerException(lenientFormat(errorMessageTemplate, p1, p2));
}
@@ -1100,8 +1120,9 @@
* @since 20.0 (varargs overload since 2.0)
*/
@CanIgnoreReturnValue
- public static <T> T checkNotNull(
- @CheckForNull T obj, String errorMessageTemplate, int p1, long p2) {
+ @NonNullDecl
+ public static <T extends Object> T checkNotNull(
+ @NonNullDecl T obj, @NullableDecl String errorMessageTemplate, int p1, long p2) {
if (obj == null) {
throw new NullPointerException(lenientFormat(errorMessageTemplate, p1, p2));
}
@@ -1116,8 +1137,12 @@
* @since 20.0 (varargs overload since 2.0)
*/
@CanIgnoreReturnValue
- public static <T> T checkNotNull(
- @CheckForNull T obj, String errorMessageTemplate, int p1, @CheckForNull Object p2) {
+ @NonNullDecl
+ public static <T extends Object> T checkNotNull(
+ @NonNullDecl T obj,
+ @NullableDecl String errorMessageTemplate,
+ int p1,
+ @NullableDecl Object p2) {
if (obj == null) {
throw new NullPointerException(lenientFormat(errorMessageTemplate, p1, p2));
}
@@ -1132,8 +1157,9 @@
* @since 20.0 (varargs overload since 2.0)
*/
@CanIgnoreReturnValue
- public static <T> T checkNotNull(
- @CheckForNull T obj, String errorMessageTemplate, long p1, char p2) {
+ @NonNullDecl
+ public static <T extends Object> T checkNotNull(
+ @NonNullDecl T obj, @NullableDecl String errorMessageTemplate, long p1, char p2) {
if (obj == null) {
throw new NullPointerException(lenientFormat(errorMessageTemplate, p1, p2));
}
@@ -1148,8 +1174,9 @@
* @since 20.0 (varargs overload since 2.0)
*/
@CanIgnoreReturnValue
- public static <T> T checkNotNull(
- @CheckForNull T obj, String errorMessageTemplate, long p1, int p2) {
+ @NonNullDecl
+ public static <T extends Object> T checkNotNull(
+ @NonNullDecl T obj, @NullableDecl String errorMessageTemplate, long p1, int p2) {
if (obj == null) {
throw new NullPointerException(lenientFormat(errorMessageTemplate, p1, p2));
}
@@ -1164,8 +1191,9 @@
* @since 20.0 (varargs overload since 2.0)
*/
@CanIgnoreReturnValue
- public static <T> T checkNotNull(
- @CheckForNull T obj, String errorMessageTemplate, long p1, long p2) {
+ @NonNullDecl
+ public static <T extends Object> T checkNotNull(
+ @NonNullDecl T obj, @NullableDecl String errorMessageTemplate, long p1, long p2) {
if (obj == null) {
throw new NullPointerException(lenientFormat(errorMessageTemplate, p1, p2));
}
@@ -1180,8 +1208,12 @@
* @since 20.0 (varargs overload since 2.0)
*/
@CanIgnoreReturnValue
- public static <T> T checkNotNull(
- @CheckForNull T obj, String errorMessageTemplate, long p1, @CheckForNull Object p2) {
+ @NonNullDecl
+ public static <T extends Object> T checkNotNull(
+ @NonNullDecl T obj,
+ @NullableDecl String errorMessageTemplate,
+ long p1,
+ @NullableDecl Object p2) {
if (obj == null) {
throw new NullPointerException(lenientFormat(errorMessageTemplate, p1, p2));
}
@@ -1196,8 +1228,12 @@
* @since 20.0 (varargs overload since 2.0)
*/
@CanIgnoreReturnValue
- public static <T> T checkNotNull(
- @CheckForNull T obj, String errorMessageTemplate, @CheckForNull Object p1, char p2) {
+ @NonNullDecl
+ public static <T extends Object> T checkNotNull(
+ @NonNullDecl T obj,
+ @NullableDecl String errorMessageTemplate,
+ @NullableDecl Object p1,
+ char p2) {
if (obj == null) {
throw new NullPointerException(lenientFormat(errorMessageTemplate, p1, p2));
}
@@ -1212,8 +1248,12 @@
* @since 20.0 (varargs overload since 2.0)
*/
@CanIgnoreReturnValue
- public static <T> T checkNotNull(
- @CheckForNull T obj, String errorMessageTemplate, @CheckForNull Object p1, int p2) {
+ @NonNullDecl
+ public static <T extends Object> T checkNotNull(
+ @NonNullDecl T obj,
+ @NullableDecl String errorMessageTemplate,
+ @NullableDecl Object p1,
+ int p2) {
if (obj == null) {
throw new NullPointerException(lenientFormat(errorMessageTemplate, p1, p2));
}
@@ -1228,8 +1268,12 @@
* @since 20.0 (varargs overload since 2.0)
*/
@CanIgnoreReturnValue
- public static <T> T checkNotNull(
- @CheckForNull T obj, String errorMessageTemplate, @CheckForNull Object p1, long p2) {
+ @NonNullDecl
+ public static <T extends Object> T checkNotNull(
+ @NonNullDecl T obj,
+ @NullableDecl String errorMessageTemplate,
+ @NullableDecl Object p1,
+ long p2) {
if (obj == null) {
throw new NullPointerException(lenientFormat(errorMessageTemplate, p1, p2));
}
@@ -1244,11 +1288,12 @@
* @since 20.0 (varargs overload since 2.0)
*/
@CanIgnoreReturnValue
- public static <T> T checkNotNull(
- @CheckForNull T obj,
- String errorMessageTemplate,
- @CheckForNull Object p1,
- @CheckForNull Object p2) {
+ @NonNullDecl
+ public static <T extends Object> T checkNotNull(
+ @NonNullDecl T obj,
+ @NullableDecl String errorMessageTemplate,
+ @NullableDecl Object p1,
+ @NullableDecl Object p2) {
if (obj == null) {
throw new NullPointerException(lenientFormat(errorMessageTemplate, p1, p2));
}
@@ -1263,12 +1308,13 @@
* @since 20.0 (varargs overload since 2.0)
*/
@CanIgnoreReturnValue
- public static <T> T checkNotNull(
- @CheckForNull T obj,
- String errorMessageTemplate,
- @CheckForNull Object p1,
- @CheckForNull Object p2,
- @CheckForNull Object p3) {
+ @NonNullDecl
+ public static <T extends Object> T checkNotNull(
+ @NonNullDecl T obj,
+ @NullableDecl String errorMessageTemplate,
+ @NullableDecl Object p1,
+ @NullableDecl Object p2,
+ @NullableDecl Object p3) {
if (obj == null) {
throw new NullPointerException(lenientFormat(errorMessageTemplate, p1, p2, p3));
}
@@ -1283,13 +1329,14 @@
* @since 20.0 (varargs overload since 2.0)
*/
@CanIgnoreReturnValue
- public static <T> T checkNotNull(
- @CheckForNull T obj,
- String errorMessageTemplate,
- @CheckForNull Object p1,
- @CheckForNull Object p2,
- @CheckForNull Object p3,
- @CheckForNull Object p4) {
+ @NonNullDecl
+ public static <T extends Object> T checkNotNull(
+ @NonNullDecl T obj,
+ @NullableDecl String errorMessageTemplate,
+ @NullableDecl Object p1,
+ @NullableDecl Object p2,
+ @NullableDecl Object p3,
+ @NullableDecl Object p4) {
if (obj == null) {
throw new NullPointerException(lenientFormat(errorMessageTemplate, p1, p2, p3, p4));
}
@@ -1349,7 +1396,7 @@
* @throws IllegalArgumentException if {@code size} is negative
*/
@CanIgnoreReturnValue
- public static int checkElementIndex(int index, int size, String desc) {
+ public static int checkElementIndex(int index, int size, @NullableDecl String desc) {
// Carefully optimized for execution by hotspot (explanatory comment above)
if (index < 0 || index >= size) {
throw new IndexOutOfBoundsException(badElementIndex(index, size, desc));
@@ -1357,7 +1404,7 @@
return index;
}
- private static String badElementIndex(int index, int size, String desc) {
+ private static String badElementIndex(int index, int size, @NullableDecl String desc) {
if (index < 0) {
return lenientFormat("%s (%s) must not be negative", desc, index);
} else if (size < 0) {
@@ -1394,7 +1441,7 @@
* @throws IllegalArgumentException if {@code size} is negative
*/
@CanIgnoreReturnValue
- public static int checkPositionIndex(int index, int size, String desc) {
+ public static int checkPositionIndex(int index, int size, @NullableDecl String desc) {
// Carefully optimized for execution by hotspot (explanatory comment above)
if (index < 0 || index > size) {
throw new IndexOutOfBoundsException(badPositionIndex(index, size, desc));
@@ -1402,7 +1449,7 @@
return index;
}
- private static String badPositionIndex(int index, int size, String desc) {
+ private static String badPositionIndex(int index, int size, @NullableDecl String desc) {
if (index < 0) {
return lenientFormat("%s (%s) must not be negative", desc, index);
} else if (size < 0) {
diff --git a/android/guava/src/com/google/common/base/Predicate.java b/android/guava/src/com/google/common/base/Predicate.java
index 35d57a6..e062725 100644
--- a/android/guava/src/com/google/common/base/Predicate.java
+++ b/android/guava/src/com/google/common/base/Predicate.java
@@ -16,8 +16,7 @@
import com.google.common.annotations.GwtCompatible;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* Determines a true or false value for a given input; a pre-Java-8 version of {@link
@@ -46,8 +45,7 @@
* @since 2.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-public interface Predicate<T extends @Nullable Object> {
+public interface Predicate<T> {
/**
* Returns the result of applying this predicate to {@code input} (Java 8 users, see notes in the
* class documentation above). This method is <i>generally expected</i>, but not absolutely
@@ -64,7 +62,7 @@
* arguments
*/
@CanIgnoreReturnValue
- boolean apply(@ParametricNullness T input);
+ boolean apply(@NullableDecl T input);
/**
* Indicates whether another object is equal to this predicate.
@@ -77,5 +75,5 @@
* predicates are known <i>not</i> to be interchangeable.
*/
@Override
- boolean equals(@CheckForNull Object object);
+ boolean equals(@NullableDecl Object object);
}
diff --git a/android/guava/src/com/google/common/base/Predicates.java b/android/guava/src/com/google/common/base/Predicates.java
index c3b5562..9c8f1e5 100644
--- a/android/guava/src/com/google/common/base/Predicates.java
+++ b/android/guava/src/com/google/common/base/Predicates.java
@@ -25,8 +25,7 @@
import java.util.Collection;
import java.util.List;
import java.util.regex.Pattern;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* Static utility methods pertaining to {@code Predicate} instances.
@@ -40,7 +39,6 @@
* @since 2.0
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
public final class Predicates {
private Predicates() {}
@@ -49,13 +47,13 @@
/** Returns a predicate that always evaluates to {@code true}. */
@GwtCompatible(serializable = true)
- public static <T extends @Nullable Object> Predicate<T> alwaysTrue() {
+ public static <T> Predicate<T> alwaysTrue() {
return ObjectPredicate.ALWAYS_TRUE.withNarrowedType();
}
/** Returns a predicate that always evaluates to {@code false}. */
@GwtCompatible(serializable = true)
- public static <T extends @Nullable Object> Predicate<T> alwaysFalse() {
+ public static <T> Predicate<T> alwaysFalse() {
return ObjectPredicate.ALWAYS_FALSE.withNarrowedType();
}
@@ -64,7 +62,7 @@
* null.
*/
@GwtCompatible(serializable = true)
- public static <T extends @Nullable Object> Predicate<T> isNull() {
+ public static <T> Predicate<T> isNull() {
return ObjectPredicate.IS_NULL.withNarrowedType();
}
@@ -73,7 +71,7 @@
* null.
*/
@GwtCompatible(serializable = true)
- public static <T extends @Nullable Object> Predicate<T> notNull() {
+ public static <T> Predicate<T> notNull() {
return ObjectPredicate.NOT_NULL.withNarrowedType();
}
@@ -81,7 +79,7 @@
* Returns a predicate that evaluates to {@code true} if the given predicate evaluates to {@code
* false}.
*/
- public static <T extends @Nullable Object> Predicate<T> not(Predicate<T> predicate) {
+ public static <T> Predicate<T> not(Predicate<T> predicate) {
return new NotPredicate<T>(predicate);
}
@@ -92,8 +90,7 @@
* changes to it won't alter the behavior of this predicate. If {@code components} is empty, the
* returned predicate will always evaluate to {@code true}.
*/
- public static <T extends @Nullable Object> Predicate<T> and(
- Iterable<? extends Predicate<? super T>> components) {
+ public static <T> Predicate<T> and(Iterable<? extends Predicate<? super T>> components) {
return new AndPredicate<T>(defensiveCopy(components));
}
@@ -105,7 +102,7 @@
* returned predicate will always evaluate to {@code true}.
*/
@SafeVarargs
- public static <T extends @Nullable Object> Predicate<T> and(Predicate<? super T>... components) {
+ public static <T> Predicate<T> and(Predicate<? super T>... components) {
return new AndPredicate<T>(defensiveCopy(components));
}
@@ -114,8 +111,7 @@
* true}. The components are evaluated in order, and evaluation will be "short-circuited" as soon
* as a false predicate is found.
*/
- public static <T extends @Nullable Object> Predicate<T> and(
- Predicate<? super T> first, Predicate<? super T> second) {
+ public static <T> Predicate<T> and(Predicate<? super T> first, Predicate<? super T> second) {
return new AndPredicate<T>(Predicates.<T>asList(checkNotNull(first), checkNotNull(second)));
}
@@ -126,8 +122,7 @@
* changes to it won't alter the behavior of this predicate. If {@code components} is empty, the
* returned predicate will always evaluate to {@code false}.
*/
- public static <T extends @Nullable Object> Predicate<T> or(
- Iterable<? extends Predicate<? super T>> components) {
+ public static <T> Predicate<T> or(Iterable<? extends Predicate<? super T>> components) {
return new OrPredicate<T>(defensiveCopy(components));
}
@@ -139,7 +134,7 @@
* returned predicate will always evaluate to {@code false}.
*/
@SafeVarargs
- public static <T extends @Nullable Object> Predicate<T> or(Predicate<? super T>... components) {
+ public static <T> Predicate<T> or(Predicate<? super T>... components) {
return new OrPredicate<T>(defensiveCopy(components));
}
@@ -148,8 +143,7 @@
* {@code true}. The components are evaluated in order, and evaluation will be "short-circuited"
* as soon as a true predicate is found.
*/
- public static <T extends @Nullable Object> Predicate<T> or(
- Predicate<? super T> first, Predicate<? super T> second) {
+ public static <T> Predicate<T> or(Predicate<? super T> first, Predicate<? super T> second) {
return new OrPredicate<T>(Predicates.<T>asList(checkNotNull(first), checkNotNull(second)));
}
@@ -157,10 +151,8 @@
* Returns a predicate that evaluates to {@code true} if the object being tested {@code equals()}
* the given target or both are null.
*/
- public static <T extends @Nullable Object> Predicate<T> equalTo(@ParametricNullness T target) {
- return (target == null)
- ? Predicates.<T>isNull()
- : new IsEqualToPredicate(target).withNarrowedType();
+ public static <T> Predicate<T> equalTo(@NullableDecl T target) {
+ return (target == null) ? Predicates.<T>isNull() : new IsEqualToPredicate<T>(target);
}
/**
@@ -177,8 +169,8 @@
* instances {@code Lists.newArrayList(1)} and {@code Arrays.asList(1)}.
*/
@GwtIncompatible // Class.isInstance
- public static <T extends @Nullable Object> Predicate<T> instanceOf(Class<?> clazz) {
- return new InstanceOfPredicate<>(clazz);
+ public static Predicate<Object> instanceOf(Class<?> clazz) {
+ return new InstanceOfPredicate(clazz);
}
/**
@@ -212,7 +204,7 @@
*
* @param target the collection that may contain the function input
*/
- public static <T extends @Nullable Object> Predicate<T> in(Collection<? extends T> target) {
+ public static <T> Predicate<T> in(Collection<? extends T> target) {
return new InPredicate<T>(target);
}
@@ -222,7 +214,7 @@
*
* @return the composition of the provided function and predicate
*/
- public static <A extends @Nullable Object, B extends @Nullable Object> Predicate<A> compose(
+ public static <A, B> Predicate<A> compose(
Predicate<B> predicate, Function<A, ? extends B> function) {
return new CompositionPredicate<>(predicate, function);
}
@@ -255,11 +247,11 @@
// End public API, begin private implementation classes.
// Package private for GWT serialization.
- enum ObjectPredicate implements Predicate<@Nullable Object> {
+ enum ObjectPredicate implements Predicate<Object> {
/** @see Predicates#alwaysTrue() */
ALWAYS_TRUE {
@Override
- public boolean apply(@CheckForNull Object o) {
+ public boolean apply(@NullableDecl Object o) {
return true;
}
@@ -271,7 +263,7 @@
/** @see Predicates#alwaysFalse() */
ALWAYS_FALSE {
@Override
- public boolean apply(@CheckForNull Object o) {
+ public boolean apply(@NullableDecl Object o) {
return false;
}
@@ -283,7 +275,7 @@
/** @see Predicates#isNull() */
IS_NULL {
@Override
- public boolean apply(@CheckForNull Object o) {
+ public boolean apply(@NullableDecl Object o) {
return o == null;
}
@@ -295,7 +287,7 @@
/** @see Predicates#notNull() */
NOT_NULL {
@Override
- public boolean apply(@CheckForNull Object o) {
+ public boolean apply(@NullableDecl Object o) {
return o != null;
}
@@ -306,14 +298,13 @@
};
@SuppressWarnings("unchecked") // safe contravariant cast
- <T extends @Nullable Object> Predicate<T> withNarrowedType() {
+ <T> Predicate<T> withNarrowedType() {
return (Predicate<T>) this;
}
}
/** @see Predicates#not(Predicate) */
- private static class NotPredicate<T extends @Nullable Object>
- implements Predicate<T>, Serializable {
+ private static class NotPredicate<T> implements Predicate<T>, Serializable {
final Predicate<T> predicate;
NotPredicate(Predicate<T> predicate) {
@@ -321,7 +312,7 @@
}
@Override
- public boolean apply(@ParametricNullness T t) {
+ public boolean apply(@NullableDecl T t) {
return !predicate.apply(t);
}
@@ -331,7 +322,7 @@
}
@Override
- public boolean equals(@CheckForNull Object obj) {
+ public boolean equals(@NullableDecl Object obj) {
if (obj instanceof NotPredicate) {
NotPredicate<?> that = (NotPredicate<?>) obj;
return predicate.equals(that.predicate);
@@ -348,8 +339,7 @@
}
/** @see Predicates#and(Iterable) */
- private static class AndPredicate<T extends @Nullable Object>
- implements Predicate<T>, Serializable {
+ private static class AndPredicate<T> implements Predicate<T>, Serializable {
private final List<? extends Predicate<? super T>> components;
private AndPredicate(List<? extends Predicate<? super T>> components) {
@@ -357,7 +347,7 @@
}
@Override
- public boolean apply(@ParametricNullness T t) {
+ public boolean apply(@NullableDecl 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)) {
@@ -374,7 +364,7 @@
}
@Override
- public boolean equals(@CheckForNull Object obj) {
+ public boolean equals(@NullableDecl Object obj) {
if (obj instanceof AndPredicate) {
AndPredicate<?> that = (AndPredicate<?>) obj;
return components.equals(that.components);
@@ -391,8 +381,7 @@
}
/** @see Predicates#or(Iterable) */
- private static class OrPredicate<T extends @Nullable Object>
- implements Predicate<T>, Serializable {
+ private static class OrPredicate<T> implements Predicate<T>, Serializable {
private final List<? extends Predicate<? super T>> components;
private OrPredicate(List<? extends Predicate<? super T>> components) {
@@ -400,7 +389,7 @@
}
@Override
- public boolean apply(@ParametricNullness T t) {
+ public boolean apply(@NullableDecl 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)) {
@@ -417,7 +406,7 @@
}
@Override
- public boolean equals(@CheckForNull Object obj) {
+ public boolean equals(@NullableDecl Object obj) {
if (obj instanceof OrPredicate) {
OrPredicate<?> that = (OrPredicate<?>) obj;
return components.equals(that.components);
@@ -447,16 +436,16 @@
}
/** @see Predicates#equalTo(Object) */
- private static class IsEqualToPredicate implements Predicate<@Nullable Object>, Serializable {
- private final Object target;
+ private static class IsEqualToPredicate<T> implements Predicate<T>, Serializable {
+ private final T target;
- private IsEqualToPredicate(Object target) {
+ private IsEqualToPredicate(T target) {
this.target = target;
}
@Override
- public boolean apply(@CheckForNull Object o) {
- return target.equals(o);
+ public boolean apply(T t) {
+ return target.equals(t);
}
@Override
@@ -465,9 +454,9 @@
}
@Override
- public boolean equals(@CheckForNull Object obj) {
+ public boolean equals(@NullableDecl Object obj) {
if (obj instanceof IsEqualToPredicate) {
- IsEqualToPredicate that = (IsEqualToPredicate) obj;
+ IsEqualToPredicate<?> that = (IsEqualToPredicate<?>) obj;
return target.equals(that.target);
}
return false;
@@ -479,17 +468,11 @@
}
private static final long serialVersionUID = 0;
-
- @SuppressWarnings("unchecked") // safe contravariant cast
- <T extends @Nullable Object> Predicate<T> withNarrowedType() {
- return (Predicate<T>) this;
- }
}
/** @see Predicates#instanceOf(Class) */
@GwtIncompatible // Class.isInstance
- private static class InstanceOfPredicate<T extends @Nullable Object>
- implements Predicate<T>, Serializable {
+ private static class InstanceOfPredicate implements Predicate<Object>, Serializable {
private final Class<?> clazz;
private InstanceOfPredicate(Class<?> clazz) {
@@ -497,7 +480,7 @@
}
@Override
- public boolean apply(@ParametricNullness T o) {
+ public boolean apply(@NullableDecl Object o) {
return clazz.isInstance(o);
}
@@ -507,9 +490,9 @@
}
@Override
- public boolean equals(@CheckForNull Object obj) {
+ public boolean equals(@NullableDecl Object obj) {
if (obj instanceof InstanceOfPredicate) {
- InstanceOfPredicate<?> that = (InstanceOfPredicate<?>) obj;
+ InstanceOfPredicate that = (InstanceOfPredicate) obj;
return clazz == that.clazz;
}
return false;
@@ -543,7 +526,7 @@
}
@Override
- public boolean equals(@CheckForNull Object obj) {
+ public boolean equals(@NullableDecl Object obj) {
if (obj instanceof SubtypeOfPredicate) {
SubtypeOfPredicate that = (SubtypeOfPredicate) obj;
return clazz == that.clazz;
@@ -560,8 +543,7 @@
}
/** @see Predicates#in(Collection) */
- private static class InPredicate<T extends @Nullable Object>
- implements Predicate<T>, Serializable {
+ private static class InPredicate<T> implements Predicate<T>, Serializable {
private final Collection<?> target;
private InPredicate(Collection<?> target) {
@@ -569,7 +551,7 @@
}
@Override
- public boolean apply(@ParametricNullness T t) {
+ public boolean apply(@NullableDecl T t) {
try {
return target.contains(t);
} catch (NullPointerException | ClassCastException e) {
@@ -578,7 +560,7 @@
}
@Override
- public boolean equals(@CheckForNull Object obj) {
+ public boolean equals(@NullableDecl Object obj) {
if (obj instanceof InPredicate) {
InPredicate<?> that = (InPredicate<?>) obj;
return target.equals(that.target);
@@ -600,8 +582,7 @@
}
/** @see Predicates#compose(Predicate, Function) */
- private static class CompositionPredicate<A extends @Nullable Object, B extends @Nullable Object>
- implements Predicate<A>, Serializable {
+ private static class CompositionPredicate<A, B> implements Predicate<A>, Serializable {
final Predicate<B> p;
final Function<A, ? extends B> f;
@@ -611,12 +592,12 @@
}
@Override
- public boolean apply(@ParametricNullness A a) {
+ public boolean apply(@NullableDecl A a) {
return p.apply(f.apply(a));
}
@Override
- public boolean equals(@CheckForNull Object obj) {
+ public boolean equals(@NullableDecl Object obj) {
if (obj instanceof CompositionPredicate) {
CompositionPredicate<?, ?> that = (CompositionPredicate<?, ?>) obj;
return f.equals(that.f) && p.equals(that.p);
@@ -661,7 +642,7 @@
}
@Override
- public boolean equals(@CheckForNull Object obj) {
+ public boolean equals(@NullableDecl Object obj) {
if (obj instanceof ContainsPatternPredicate) {
ContainsPatternPredicate that = (ContainsPatternPredicate) obj;
@@ -702,7 +683,7 @@
private static final long serialVersionUID = 0;
}
- private static <T extends @Nullable Object> List<Predicate<? super T>> asList(
+ private static <T> List<Predicate<? super T>> asList(
Predicate<? super T> first, Predicate<? super T> second) {
// TODO(kevinb): understand why we still get a warning despite @SafeVarargs!
return Arrays.<Predicate<? super T>>asList(first, second);
diff --git a/android/guava/src/com/google/common/base/Present.java b/android/guava/src/com/google/common/base/Present.java
index 59efebc..d33eb8e 100644
--- a/android/guava/src/com/google/common/base/Present.java
+++ b/android/guava/src/com/google/common/base/Present.java
@@ -19,11 +19,10 @@
import com.google.common.annotations.GwtCompatible;
import java.util.Collections;
import java.util.Set;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/** Implementation of an {@link Optional} containing a reference. */
@GwtCompatible
-@ElementTypesAreNonnullByDefault
final class Present<T> extends Optional<T> {
private final T reference;
@@ -78,7 +77,7 @@
}
@Override
- public boolean equals(@CheckForNull Object object) {
+ public boolean equals(@NullableDecl Object object) {
if (object instanceof Present) {
Present<?> other = (Present<?>) object;
return reference.equals(other.reference);
diff --git a/android/guava/src/com/google/common/base/SmallCharMatcher.java b/android/guava/src/com/google/common/base/SmallCharMatcher.java
index f0e801b..1e565c8 100644
--- a/android/guava/src/com/google/common/base/SmallCharMatcher.java
+++ b/android/guava/src/com/google/common/base/SmallCharMatcher.java
@@ -26,7 +26,6 @@
* @author Christopher Swenson
*/
@GwtIncompatible // no precomputation is done in GWT
-@ElementTypesAreNonnullByDefault
final class SmallCharMatcher extends NamedFastMatcher {
static final int MAX_SIZE = 1023;
private final char[] table;
diff --git a/android/guava/src/com/google/common/base/Splitter.java b/android/guava/src/com/google/common/base/Splitter.java
index bde2e0e..150c2fe 100644
--- a/android/guava/src/com/google/common/base/Splitter.java
+++ b/android/guava/src/com/google/common/base/Splitter.java
@@ -27,7 +27,6 @@
import java.util.List;
import java.util.Map;
import java.util.regex.Pattern;
-import javax.annotation.CheckForNull;
/**
* Extracts non-overlapping substrings from an input string, typically by recognizing appearances of
@@ -98,7 +97,6 @@
* @since 1.0
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
public final class Splitter {
private final CharMatcher trimmer;
private final boolean omitEmptyStrings;
@@ -549,7 +547,6 @@
this.toSplit = toSplit;
}
- @CheckForNull
@Override
protected String computeNext() {
/*
diff --git a/android/guava/src/com/google/common/base/StandardSystemProperty.java b/android/guava/src/com/google/common/base/StandardSystemProperty.java
index dc29792..2feb073 100644
--- a/android/guava/src/com/google/common/base/StandardSystemProperty.java
+++ b/android/guava/src/com/google/common/base/StandardSystemProperty.java
@@ -15,7 +15,7 @@
package com.google.common.base;
import com.google.common.annotations.GwtIncompatible;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* Represents a {@linkplain System#getProperties() standard system property}.
@@ -24,7 +24,6 @@
* @since 15.0
*/
@GwtIncompatible // java.lang.System#getProperty
-@ElementTypesAreNonnullByDefault
public enum StandardSystemProperty {
/** Java Runtime Environment version. */
@@ -81,15 +80,7 @@
/** Name of JIT compiler to use. */
JAVA_COMPILER("java.compiler"),
- /**
- * Path of extension directory or directories.
- *
- * @deprecated This property was <a
- * href="https://openjdk.java.net/jeps/220#Removed:-The-extension-mechanism">deprecated</a> in
- * Java 8 and removed in Java 9. We do not plan to remove this API from Guava, but if you are
- * using it, it is probably not doing what you want.
- */
- @Deprecated
+ /** Path of extension directory or directories. */
JAVA_EXT_DIRS("java.ext.dirs"),
/** Operating system name. */
@@ -133,27 +124,8 @@
/**
* Returns the current value for this system property by delegating to {@link
* System#getProperty(String)}.
- *
- * <p>The value returned by this method is non-null except in rare circumstances:
- *
- * <ul>
- * <li>{@link #JAVA_EXT_DIRS} was deprecated in Java 8 and removed in Java 9. We have not
- * confirmed whether it is available under older versions.
- * <li>{@link #JAVA_COMPILER}, while still listed as required as of Java 15, is typically not
- * available even under older version.
- * <li>Any property may be cleared through APIs like {@link System#clearProperty}.
- * <li>Unusual environments like GWT may have their own special handling of system properties.
- * </ul>
- *
- * <p>Note that {@code StandardSystemProperty} does not provide constants for more recently added
- * properties, including:
- *
- * <ul>
- * <li>{@code java.vendor.version} (added in Java 11, listed as optional as of Java 13)
- * <li>{@code jdk.module.*} (added in Java 9, optional)
- * </ul>
*/
- @CheckForNull
+ @NullableDecl
public String value() {
return System.getProperty(key);
}
diff --git a/android/guava/src/com/google/common/base/Stopwatch.java b/android/guava/src/com/google/common/base/Stopwatch.java
index f76c098..4a6767d 100644
--- a/android/guava/src/com/google/common/base/Stopwatch.java
+++ b/android/guava/src/com/google/common/base/Stopwatch.java
@@ -77,7 +77,7 @@
* Stopwatch.createStarted(
* new Ticker() {
* public long read() {
- * return android.os.SystemClock.elapsedRealtimeNanos(); // requires API Level 17
+ * return android.os.SystemClock.elapsedRealtimeNanos();
* }
* });
* }</pre>
@@ -85,9 +85,8 @@
* @author Kevin Bourrillion
* @since 10.0
*/
-@GwtCompatible(emulated = true)
+@GwtCompatible
@SuppressWarnings("GoodTime") // lots of violations
-@ElementTypesAreNonnullByDefault
public final class Stopwatch {
private final Ticker ticker;
private boolean isRunning;
diff --git a/android/guava/src/com/google/common/base/Strings.java b/android/guava/src/com/google/common/base/Strings.java
index fa36266..4758517 100644
--- a/android/guava/src/com/google/common/base/Strings.java
+++ b/android/guava/src/com/google/common/base/Strings.java
@@ -21,8 +21,7 @@
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.VisibleForTesting;
import java.util.logging.Logger;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* Static utility methods pertaining to {@code String} or {@code CharSequence} instances.
@@ -31,7 +30,6 @@
* @since 3.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
public final class Strings {
private Strings() {}
@@ -41,7 +39,7 @@
* @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(@CheckForNull String string) {
+ public static String nullToEmpty(@NullableDecl String string) {
return Platform.nullToEmpty(string);
}
@@ -51,8 +49,8 @@
* @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
*/
- @CheckForNull
- public static String emptyToNull(@CheckForNull String string) {
+ @NullableDecl
+ public static String emptyToNull(@NullableDecl String string) {
return Platform.emptyToNull(string);
}
@@ -67,7 +65,7 @@
* @param string a string reference to check
* @return {@code true} if the string is null or is the empty string
*/
- public static boolean isNullOrEmpty(@CheckForNull String string) {
+ public static boolean isNullOrEmpty(@NullableDecl String string) {
return Platform.stringIsNullOrEmpty(string);
}
@@ -259,8 +257,7 @@
* @since 25.1
*/
// TODO(diamondm) consider using Arrays.toString() for array parameters
- public static String lenientFormat(
- @CheckForNull String template, @CheckForNull @Nullable Object... args) {
+ public static String lenientFormat(@NullableDecl String template, @NullableDecl Object... args) {
template = String.valueOf(template); // null -> "null"
if (args == null) {
@@ -300,7 +297,7 @@
return builder.toString();
}
- private static String lenientToString(@CheckForNull Object o) {
+ private static String lenientToString(@NullableDecl Object o) {
if (o == null) {
return "null";
}
diff --git a/android/guava/src/com/google/common/base/Supplier.java b/android/guava/src/com/google/common/base/Supplier.java
index f9e1e34..662bf1f 100644
--- a/android/guava/src/com/google/common/base/Supplier.java
+++ b/android/guava/src/com/google/common/base/Supplier.java
@@ -16,7 +16,6 @@
import com.google.common.annotations.GwtCompatible;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* A class that can supply objects of a single type; a pre-Java-8 version of {@link
@@ -46,8 +45,7 @@
* @since 2.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-public interface Supplier<T extends @Nullable Object> {
+public interface Supplier<T> {
/**
* Retrieves an instance of the appropriate type. The returned object may or may not be a new
* instance, depending on the implementation.
@@ -55,6 +53,5 @@
* @return an instance of the appropriate type
*/
@CanIgnoreReturnValue
- @ParametricNullness
T get();
}
diff --git a/android/guava/src/com/google/common/base/Suppliers.java b/android/guava/src/com/google/common/base/Suppliers.java
index 57d3486..da1490d 100644
--- a/android/guava/src/com/google/common/base/Suppliers.java
+++ b/android/guava/src/com/google/common/base/Suppliers.java
@@ -14,17 +14,14 @@
package com.google.common.base;
-import static com.google.common.base.NullnessCasts.uncheckedCastNullableTToT;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
-import static java.util.Objects.requireNonNull;
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.VisibleForTesting;
import java.io.Serializable;
import java.util.concurrent.TimeUnit;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* Useful suppliers.
@@ -36,7 +33,6 @@
* @since 2.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
public final class Suppliers {
private Suppliers() {}
@@ -46,13 +42,11 @@
* and then applying {@code function} to that value. Note that the resulting supplier will not
* call {@code supplier} or invoke {@code function} until it is called.
*/
- public static <F extends @Nullable Object, T extends @Nullable Object> Supplier<T> compose(
- Function<? super F, T> function, Supplier<F> supplier) {
+ public static <F, T> Supplier<T> compose(Function<? super F, T> function, Supplier<F> supplier) {
return new SupplierComposition<>(function, supplier);
}
- private static class SupplierComposition<F extends @Nullable Object, T extends @Nullable Object>
- implements Supplier<T>, Serializable {
+ private static class SupplierComposition<F, T> implements Supplier<T>, Serializable {
final Function<? super F, T> function;
final Supplier<F> supplier;
@@ -62,13 +56,12 @@
}
@Override
- @ParametricNullness
public T get() {
return function.apply(supplier.get());
}
@Override
- public boolean equals(@CheckForNull Object obj) {
+ public boolean equals(@NullableDecl Object obj) {
if (obj instanceof SupplierComposition) {
SupplierComposition<?, ?> that = (SupplierComposition<?, ?>) obj;
return function.equals(that.function) && supplier.equals(that.supplier);
@@ -105,7 +98,7 @@
* <p>If {@code delegate} is an instance created by an earlier call to {@code memoize}, it is
* returned directly.
*/
- public static <T extends @Nullable Object> Supplier<T> memoize(Supplier<T> delegate) {
+ public static <T> Supplier<T> memoize(Supplier<T> delegate) {
if (delegate instanceof NonSerializableMemoizingSupplier
|| delegate instanceof MemoizingSupplier) {
return delegate;
@@ -116,19 +109,18 @@
}
@VisibleForTesting
- static class MemoizingSupplier<T extends @Nullable Object> implements Supplier<T>, Serializable {
+ static class MemoizingSupplier<T> implements Supplier<T>, Serializable {
final Supplier<T> delegate;
transient volatile boolean initialized;
// "value" does not need to be volatile; visibility piggy-backs
// on volatile read of "initialized".
- @CheckForNull transient T value;
+ @NullableDecl transient T value;
MemoizingSupplier(Supplier<T> delegate) {
this.delegate = checkNotNull(delegate);
}
@Override
- @ParametricNullness
public T get() {
// A 2-field variant of Double Checked Locking.
if (!initialized) {
@@ -141,8 +133,7 @@
}
}
}
- // This is safe because we checked `initialized.`
- return uncheckedCastNullableTToT(value);
+ return value;
}
@Override
@@ -156,31 +147,24 @@
}
@VisibleForTesting
- static class NonSerializableMemoizingSupplier<T extends @Nullable Object> implements Supplier<T> {
- @CheckForNull volatile Supplier<T> delegate;
+ static class NonSerializableMemoizingSupplier<T> implements Supplier<T> {
+ volatile Supplier<T> delegate;
volatile boolean initialized;
// "value" does not need to be volatile; visibility piggy-backs
// on volatile read of "initialized".
- @CheckForNull T value;
+ @NullableDecl T value;
NonSerializableMemoizingSupplier(Supplier<T> delegate) {
this.delegate = checkNotNull(delegate);
}
@Override
- @ParametricNullness
public T get() {
// A 2-field variant of Double Checked Locking.
if (!initialized) {
synchronized (this) {
if (!initialized) {
- /*
- * requireNonNull is safe because we read and write `delegate` under synchronization.
- *
- * TODO(cpovirk): To avoid having to check for null, replace `delegate` with a singleton
- * `Supplier` that always throws an exception.
- */
- T t = requireNonNull(delegate).get();
+ T t = delegate.get();
value = t;
initialized = true;
// Release the delegate to GC.
@@ -189,8 +173,7 @@
}
}
}
- // This is safe because we checked `initialized.`
- return uncheckedCastNullableTToT(value);
+ return value;
}
@Override
@@ -224,18 +207,17 @@
* @since 2.0
*/
@SuppressWarnings("GoodTime") // should accept a java.time.Duration
- public static <T extends @Nullable Object> Supplier<T> memoizeWithExpiration(
+ public static <T> Supplier<T> memoizeWithExpiration(
Supplier<T> delegate, long duration, TimeUnit unit) {
return new ExpiringMemoizingSupplier<T>(delegate, duration, unit);
}
@VisibleForTesting
@SuppressWarnings("GoodTime") // lots of violations
- static class ExpiringMemoizingSupplier<T extends @Nullable Object>
- implements Supplier<T>, Serializable {
+ static class ExpiringMemoizingSupplier<T> implements Supplier<T>, Serializable {
final Supplier<T> delegate;
final long durationNanos;
- @CheckForNull transient volatile T value;
+ @NullableDecl transient volatile T value;
// The special value 0 means "not yet initialized".
transient volatile long expirationNanos;
@@ -246,7 +228,6 @@
}
@Override
- @ParametricNullness
public T get() {
// Another variant of Double Checked Locking.
//
@@ -269,8 +250,7 @@
}
}
}
- // This is safe because we checked `expirationNanos.`
- return uncheckedCastNullableTToT(value);
+ return value;
}
@Override
@@ -284,27 +264,24 @@
}
/** Returns a supplier that always supplies {@code instance}. */
- public static <T extends @Nullable Object> Supplier<T> ofInstance(
- @ParametricNullness T instance) {
+ public static <T> Supplier<T> ofInstance(@NullableDecl T instance) {
return new SupplierOfInstance<T>(instance);
}
- private static class SupplierOfInstance<T extends @Nullable Object>
- implements Supplier<T>, Serializable {
- @ParametricNullness final T instance;
+ private static class SupplierOfInstance<T> implements Supplier<T>, Serializable {
+ @NullableDecl final T instance;
- SupplierOfInstance(@ParametricNullness T instance) {
+ SupplierOfInstance(@NullableDecl T instance) {
this.instance = instance;
}
@Override
- @ParametricNullness
public T get() {
return instance;
}
@Override
- public boolean equals(@CheckForNull Object obj) {
+ public boolean equals(@NullableDecl Object obj) {
if (obj instanceof SupplierOfInstance) {
SupplierOfInstance<?> that = (SupplierOfInstance<?>) obj;
return Objects.equal(instance, that.instance);
@@ -329,13 +306,11 @@
* Returns a supplier whose {@code get()} method synchronizes on {@code delegate} before calling
* it, making it thread-safe.
*/
- public static <T extends @Nullable Object> Supplier<T> synchronizedSupplier(
- Supplier<T> delegate) {
+ public static <T> Supplier<T> synchronizedSupplier(Supplier<T> delegate) {
return new ThreadSafeSupplier<T>(delegate);
}
- private static class ThreadSafeSupplier<T extends @Nullable Object>
- implements Supplier<T>, Serializable {
+ private static class ThreadSafeSupplier<T> implements Supplier<T>, Serializable {
final Supplier<T> delegate;
ThreadSafeSupplier(Supplier<T> delegate) {
@@ -343,7 +318,6 @@
}
@Override
- @ParametricNullness
public T get() {
synchronized (delegate) {
return delegate.get();
@@ -366,21 +340,20 @@
*
* @since 8.0
*/
- public static <T extends @Nullable Object> Function<Supplier<T>, T> supplierFunction() {
+ public static <T> Function<Supplier<T>, T> supplierFunction() {
@SuppressWarnings("unchecked") // implementation is "fully variant"
SupplierFunction<T> sf = (SupplierFunction<T>) SupplierFunctionImpl.INSTANCE;
return sf;
}
- private interface SupplierFunction<T extends @Nullable Object> extends Function<Supplier<T>, T> {}
+ private interface SupplierFunction<T> extends Function<Supplier<T>, T> {}
- private enum SupplierFunctionImpl implements SupplierFunction<@Nullable Object> {
+ private enum SupplierFunctionImpl implements SupplierFunction<Object> {
INSTANCE;
// Note: This makes T a "pass-through type"
@Override
- @CheckForNull
- public Object apply(Supplier<@Nullable Object> input) {
+ public Object apply(Supplier<Object> input) {
return input.get();
}
diff --git a/android/guava/src/com/google/common/base/Throwables.java b/android/guava/src/com/google/common/base/Throwables.java
index 7832d18..b2abb50 100644
--- a/android/guava/src/com/google/common/base/Throwables.java
+++ b/android/guava/src/com/google/common/base/Throwables.java
@@ -17,7 +17,6 @@
import static com.google.common.base.Preconditions.checkNotNull;
import static java.util.Arrays.asList;
import static java.util.Collections.unmodifiableList;
-import static java.util.Objects.requireNonNull;
import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtCompatible;
@@ -33,7 +32,7 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* Static utility methods pertaining to instances of {@link Throwable}.
@@ -46,7 +45,6 @@
* @since 1.0
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
public final class Throwables {
private Throwables() {}
@@ -101,7 +99,7 @@
@Deprecated
@GwtIncompatible // throwIfInstanceOf
public static <X extends Throwable> void propagateIfInstanceOf(
- @CheckForNull Throwable throwable, Class<X> declaredType) throws X {
+ @NullableDecl Throwable throwable, Class<X> declaredType) throws X {
if (throwable != null) {
throwIfInstanceOf(throwable, declaredType);
}
@@ -156,7 +154,7 @@
*/
@Deprecated
@GwtIncompatible
- public static void propagateIfPossible(@CheckForNull Throwable throwable) {
+ public static void propagateIfPossible(@NullableDecl Throwable throwable) {
if (throwable != null) {
throwIfUnchecked(throwable);
}
@@ -182,7 +180,7 @@
*/
@GwtIncompatible // propagateIfInstanceOf
public static <X extends Throwable> void propagateIfPossible(
- @CheckForNull Throwable throwable, Class<X> declaredType) throws X {
+ @NullableDecl Throwable throwable, Class<X> declaredType) throws X {
propagateIfInstanceOf(throwable, declaredType);
propagateIfPossible(throwable);
}
@@ -200,7 +198,7 @@
*/
@GwtIncompatible // propagateIfInstanceOf
public static <X1 extends Throwable, X2 extends Throwable> void propagateIfPossible(
- @CheckForNull Throwable throwable, Class<X1> declaredType1, Class<X2> declaredType2)
+ @NullableDecl Throwable throwable, Class<X1> declaredType1, Class<X2> declaredType2)
throws X1, X2 {
checkNotNull(declaredType2);
propagateIfInstanceOf(throwable, declaredType1);
@@ -332,7 +330,6 @@
*/
@Beta
@GwtIncompatible // Class.cast(Object)
- @CheckForNull
public static <X extends Throwable> X getCauseAs(
Throwable throwable, Class<X> expectedCauseType) {
try {
@@ -415,22 +412,15 @@
* AOSP grief.
*/
return new AbstractList<StackTraceElement>() {
- /*
- * The following requireNonNull calls are safe because we use jlaStackTrace() only if
- * lazyStackTraceIsLazy() returns true.
- */
@Override
public StackTraceElement get(int n) {
return (StackTraceElement)
- invokeAccessibleNonThrowingMethod(
- requireNonNull(getStackTraceElementMethod), requireNonNull(jla), t, n);
+ invokeAccessibleNonThrowingMethod(getStackTraceElementMethod, jla, t, n);
}
@Override
public int size() {
- return (Integer)
- invokeAccessibleNonThrowingMethod(
- requireNonNull(getStackTraceDepthMethod), requireNonNull(jla), t);
+ return (Integer) invokeAccessibleNonThrowingMethod(getStackTraceDepthMethod, jla, t);
}
};
}
@@ -458,7 +448,7 @@
/** Access to some fancy internal JVM internals. */
@GwtIncompatible // java.lang.reflect
- @CheckForNull
+ @NullableDecl
private static final Object jla = getJLA();
/**
@@ -466,7 +456,7 @@
* find it when available. When this is null, use the slow way.
*/
@GwtIncompatible // java.lang.reflect
- @CheckForNull
+ @NullableDecl
private static final Method getStackTraceElementMethod = (jla == null) ? null : getGetMethod();
/**
@@ -474,15 +464,15 @@
* when available. When this is null, use the slow way.
*/
@GwtIncompatible // java.lang.reflect
- @CheckForNull
- private static final Method getStackTraceDepthMethod = (jla == null) ? null : getSizeMethod(jla);
+ @NullableDecl
+ private static final Method getStackTraceDepthMethod = (jla == null) ? null : getSizeMethod();
/**
* Returns the JavaLangAccess class that is present in all Sun JDKs. It is not allowed in
* AppEngine, and not present in non-Sun JDKs.
*/
@GwtIncompatible // java.lang.reflect
- @CheckForNull
+ @NullableDecl
private static Object getJLA() {
try {
/*
@@ -508,7 +498,7 @@
* method cannot be found (it is only to be found in fairly recent JDKs).
*/
@GwtIncompatible // java.lang.reflect
- @CheckForNull
+ @NullableDecl
private static Method getGetMethod() {
return getJlaMethod("getStackTraceElement", Throwable.class, int.class);
}
@@ -523,14 +513,14 @@
* UnsupportedOperationException</a>.
*/
@GwtIncompatible // java.lang.reflect
- @CheckForNull
- private static Method getSizeMethod(Object jla) {
+ @NullableDecl
+ private static Method getSizeMethod() {
try {
Method getStackTraceDepth = getJlaMethod("getStackTraceDepth", Throwable.class);
if (getStackTraceDepth == null) {
return null;
}
- getStackTraceDepth.invoke(jla, new Throwable());
+ getStackTraceDepth.invoke(getJLA(), new Throwable());
return getStackTraceDepth;
} catch (UnsupportedOperationException | IllegalAccessException | InvocationTargetException e) {
return null;
@@ -538,7 +528,7 @@
}
@GwtIncompatible // java.lang.reflect
- @CheckForNull
+ @NullableDecl
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/android/guava/src/com/google/common/base/Ticker.java b/android/guava/src/com/google/common/base/Ticker.java
index d898735..a53883b 100644
--- a/android/guava/src/com/google/common/base/Ticker.java
+++ b/android/guava/src/com/google/common/base/Ticker.java
@@ -28,7 +28,6 @@
* source-compatible</a> since 9.0)
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
public abstract class Ticker {
/** Constructor for use by subclasses. */
protected Ticker() {}
diff --git a/android/guava/src/com/google/common/base/Utf8.java b/android/guava/src/com/google/common/base/Utf8.java
index bb945a3..8a2fbb7 100644
--- a/android/guava/src/com/google/common/base/Utf8.java
+++ b/android/guava/src/com/google/common/base/Utf8.java
@@ -38,7 +38,6 @@
*/
@Beta
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
public final class Utf8 {
/**
* Returns the number of bytes in the UTF-8-encoded form of {@code sequence}. For a string, this
diff --git a/android/guava/src/com/google/common/base/Verify.java b/android/guava/src/com/google/common/base/Verify.java
index b2e9f5f..843a77f 100644
--- a/android/guava/src/com/google/common/base/Verify.java
+++ b/android/guava/src/com/google/common/base/Verify.java
@@ -18,8 +18,7 @@
import com.google.common.annotations.GwtCompatible;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* Static convenience methods that serve the same purpose as Java language <a
@@ -88,7 +87,6 @@
* @since 17.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
public final class Verify {
/**
* Ensures that {@code expression} is {@code true}, throwing a {@code VerifyException} with no
@@ -120,8 +118,8 @@
*/
public static void verify(
boolean expression,
- String errorMessageTemplate,
- @CheckForNull @Nullable Object... errorMessageArgs) {
+ @NullableDecl String errorMessageTemplate,
+ @NullableDecl Object... errorMessageArgs) {
if (!expression) {
throw new VerifyException(lenientFormat(errorMessageTemplate, errorMessageArgs));
}
@@ -135,7 +133,8 @@
*
* @since 23.1 (varargs overload since 17.0)
*/
- public static void verify(boolean expression, String errorMessageTemplate, char p1) {
+ public static void verify(
+ boolean expression, @NullableDecl String errorMessageTemplate, char p1) {
if (!expression) {
throw new VerifyException(lenientFormat(errorMessageTemplate, p1));
}
@@ -149,21 +148,7 @@
*
* @since 23.1 (varargs overload since 17.0)
*/
- public static void verify(boolean expression, String errorMessageTemplate, int p1) {
- if (!expression) {
- throw new VerifyException(lenientFormat(errorMessageTemplate, p1));
- }
- }
-
- /**
- * Ensures that {@code expression} is {@code true}, throwing a {@code VerifyException} with a
- * custom message otherwise.
- *
- * <p>See {@link #verify(boolean, String, Object...)} for details.
- *
- * @since 23.1 (varargs overload since 17.0)
- */
- public static void verify(boolean expression, String errorMessageTemplate, long p1) {
+ public static void verify(boolean expression, @NullableDecl String errorMessageTemplate, int p1) {
if (!expression) {
throw new VerifyException(lenientFormat(errorMessageTemplate, p1));
}
@@ -178,7 +163,7 @@
* @since 23.1 (varargs overload since 17.0)
*/
public static void verify(
- boolean expression, String errorMessageTemplate, @CheckForNull Object p1) {
+ boolean expression, @NullableDecl String errorMessageTemplate, long p1) {
if (!expression) {
throw new VerifyException(lenientFormat(errorMessageTemplate, p1));
}
@@ -192,9 +177,10 @@
*
* @since 23.1 (varargs overload since 17.0)
*/
- public static void verify(boolean expression, String errorMessageTemplate, char p1, char p2) {
+ public static void verify(
+ boolean expression, @NullableDecl String errorMessageTemplate, @NullableDecl Object p1) {
if (!expression) {
- throw new VerifyException(lenientFormat(errorMessageTemplate, p1, p2));
+ throw new VerifyException(lenientFormat(errorMessageTemplate, p1));
}
}
@@ -206,21 +192,8 @@
*
* @since 23.1 (varargs overload since 17.0)
*/
- public static void verify(boolean expression, String errorMessageTemplate, int p1, char p2) {
- if (!expression) {
- throw new VerifyException(lenientFormat(errorMessageTemplate, p1, p2));
- }
- }
-
- /**
- * Ensures that {@code expression} is {@code true}, throwing a {@code VerifyException} with a
- * custom message otherwise.
- *
- * <p>See {@link #verify(boolean, String, Object...)} for details.
- *
- * @since 23.1 (varargs overload since 17.0)
- */
- public static void verify(boolean expression, String errorMessageTemplate, long p1, char p2) {
+ public static void verify(
+ boolean expression, @NullableDecl String errorMessageTemplate, char p1, char p2) {
if (!expression) {
throw new VerifyException(lenientFormat(errorMessageTemplate, p1, p2));
}
@@ -235,49 +208,7 @@
* @since 23.1 (varargs overload since 17.0)
*/
public static void verify(
- boolean expression, String errorMessageTemplate, @CheckForNull Object p1, char p2) {
- if (!expression) {
- throw new VerifyException(lenientFormat(errorMessageTemplate, p1, p2));
- }
- }
-
- /**
- * Ensures that {@code expression} is {@code true}, throwing a {@code VerifyException} with a
- * custom message otherwise.
- *
- * <p>See {@link #verify(boolean, String, Object...)} for details.
- *
- * @since 23.1 (varargs overload since 17.0)
- */
- public static void verify(boolean expression, String errorMessageTemplate, char p1, int p2) {
- if (!expression) {
- throw new VerifyException(lenientFormat(errorMessageTemplate, p1, p2));
- }
- }
-
- /**
- * Ensures that {@code expression} is {@code true}, throwing a {@code VerifyException} with a
- * custom message otherwise.
- *
- * <p>See {@link #verify(boolean, String, Object...)} for details.
- *
- * @since 23.1 (varargs overload since 17.0)
- */
- public static void verify(boolean expression, String errorMessageTemplate, int p1, int p2) {
- if (!expression) {
- throw new VerifyException(lenientFormat(errorMessageTemplate, p1, p2));
- }
- }
-
- /**
- * Ensures that {@code expression} is {@code true}, throwing a {@code VerifyException} with a
- * custom message otherwise.
- *
- * <p>See {@link #verify(boolean, String, Object...)} for details.
- *
- * @since 23.1 (varargs overload since 17.0)
- */
- public static void verify(boolean expression, String errorMessageTemplate, long p1, int p2) {
+ boolean expression, @NullableDecl String errorMessageTemplate, int p1, char p2) {
if (!expression) {
throw new VerifyException(lenientFormat(errorMessageTemplate, p1, p2));
}
@@ -292,109 +223,7 @@
* @since 23.1 (varargs overload since 17.0)
*/
public static void verify(
- boolean expression, String errorMessageTemplate, @CheckForNull Object p1, int p2) {
- if (!expression) {
- throw new VerifyException(lenientFormat(errorMessageTemplate, p1, p2));
- }
- }
-
- /**
- * Ensures that {@code expression} is {@code true}, throwing a {@code VerifyException} with a
- * custom message otherwise.
- *
- * <p>See {@link #verify(boolean, String, Object...)} for details.
- *
- * @since 23.1 (varargs overload since 17.0)
- */
- public static void verify(boolean expression, String errorMessageTemplate, char p1, long p2) {
- if (!expression) {
- throw new VerifyException(lenientFormat(errorMessageTemplate, p1, p2));
- }
- }
-
- /**
- * Ensures that {@code expression} is {@code true}, throwing a {@code VerifyException} with a
- * custom message otherwise.
- *
- * <p>See {@link #verify(boolean, String, Object...)} for details.
- *
- * @since 23.1 (varargs overload since 17.0)
- */
- public static void verify(boolean expression, String errorMessageTemplate, int p1, long p2) {
- if (!expression) {
- throw new VerifyException(lenientFormat(errorMessageTemplate, p1, p2));
- }
- }
-
- /**
- * Ensures that {@code expression} is {@code true}, throwing a {@code VerifyException} with a
- * custom message otherwise.
- *
- * <p>See {@link #verify(boolean, String, Object...)} for details.
- *
- * @since 23.1 (varargs overload since 17.0)
- */
- public static void verify(boolean expression, String errorMessageTemplate, long p1, long p2) {
- if (!expression) {
- throw new VerifyException(lenientFormat(errorMessageTemplate, p1, p2));
- }
- }
-
- /**
- * Ensures that {@code expression} is {@code true}, throwing a {@code VerifyException} with a
- * custom message otherwise.
- *
- * <p>See {@link #verify(boolean, String, Object...)} for details.
- *
- * @since 23.1 (varargs overload since 17.0)
- */
- public static void verify(
- boolean expression, String errorMessageTemplate, @CheckForNull Object p1, long p2) {
- if (!expression) {
- throw new VerifyException(lenientFormat(errorMessageTemplate, p1, p2));
- }
- }
-
- /**
- * Ensures that {@code expression} is {@code true}, throwing a {@code VerifyException} with a
- * custom message otherwise.
- *
- * <p>See {@link #verify(boolean, String, Object...)} for details.
- *
- * @since 23.1 (varargs overload since 17.0)
- */
- public static void verify(
- boolean expression, String errorMessageTemplate, char p1, @CheckForNull Object p2) {
- if (!expression) {
- throw new VerifyException(lenientFormat(errorMessageTemplate, p1, p2));
- }
- }
-
- /**
- * Ensures that {@code expression} is {@code true}, throwing a {@code VerifyException} with a
- * custom message otherwise.
- *
- * <p>See {@link #verify(boolean, String, Object...)} for details.
- *
- * @since 23.1 (varargs overload since 17.0)
- */
- public static void verify(
- boolean expression, String errorMessageTemplate, int p1, @CheckForNull Object p2) {
- if (!expression) {
- throw new VerifyException(lenientFormat(errorMessageTemplate, p1, p2));
- }
- }
-
- /**
- * Ensures that {@code expression} is {@code true}, throwing a {@code VerifyException} with a
- * custom message otherwise.
- *
- * <p>See {@link #verify(boolean, String, Object...)} for details.
- *
- * @since 23.1 (varargs overload since 17.0)
- */
- public static void verify(
- boolean expression, String errorMessageTemplate, long p1, @CheckForNull Object p2) {
+ boolean expression, @NullableDecl String errorMessageTemplate, long p1, char p2) {
if (!expression) {
throw new VerifyException(lenientFormat(errorMessageTemplate, p1, p2));
}
@@ -410,9 +239,54 @@
*/
public static void verify(
boolean expression,
- String errorMessageTemplate,
- @CheckForNull Object p1,
- @CheckForNull Object p2) {
+ @NullableDecl String errorMessageTemplate,
+ @NullableDecl Object p1,
+ char p2) {
+ if (!expression) {
+ throw new VerifyException(lenientFormat(errorMessageTemplate, p1, p2));
+ }
+ }
+
+ /**
+ * Ensures that {@code expression} is {@code true}, throwing a {@code VerifyException} with a
+ * custom message otherwise.
+ *
+ * <p>See {@link #verify(boolean, String, Object...)} for details.
+ *
+ * @since 23.1 (varargs overload since 17.0)
+ */
+ public static void verify(
+ boolean expression, @NullableDecl String errorMessageTemplate, char p1, int p2) {
+ if (!expression) {
+ throw new VerifyException(lenientFormat(errorMessageTemplate, p1, p2));
+ }
+ }
+
+ /**
+ * Ensures that {@code expression} is {@code true}, throwing a {@code VerifyException} with a
+ * custom message otherwise.
+ *
+ * <p>See {@link #verify(boolean, String, Object...)} for details.
+ *
+ * @since 23.1 (varargs overload since 17.0)
+ */
+ public static void verify(
+ boolean expression, @NullableDecl String errorMessageTemplate, int p1, int p2) {
+ if (!expression) {
+ throw new VerifyException(lenientFormat(errorMessageTemplate, p1, p2));
+ }
+ }
+
+ /**
+ * Ensures that {@code expression} is {@code true}, throwing a {@code VerifyException} with a
+ * custom message otherwise.
+ *
+ * <p>See {@link #verify(boolean, String, Object...)} for details.
+ *
+ * @since 23.1 (varargs overload since 17.0)
+ */
+ public static void verify(
+ boolean expression, @NullableDecl String errorMessageTemplate, long p1, int p2) {
if (!expression) {
throw new VerifyException(lenientFormat(errorMessageTemplate, p1, p2));
}
@@ -428,10 +302,163 @@
*/
public static void verify(
boolean expression,
- String errorMessageTemplate,
- @CheckForNull Object p1,
- @CheckForNull Object p2,
- @CheckForNull Object p3) {
+ @NullableDecl String errorMessageTemplate,
+ @NullableDecl Object p1,
+ int p2) {
+ if (!expression) {
+ throw new VerifyException(lenientFormat(errorMessageTemplate, p1, p2));
+ }
+ }
+
+ /**
+ * Ensures that {@code expression} is {@code true}, throwing a {@code VerifyException} with a
+ * custom message otherwise.
+ *
+ * <p>See {@link #verify(boolean, String, Object...)} for details.
+ *
+ * @since 23.1 (varargs overload since 17.0)
+ */
+ public static void verify(
+ boolean expression, @NullableDecl String errorMessageTemplate, char p1, long p2) {
+ if (!expression) {
+ throw new VerifyException(lenientFormat(errorMessageTemplate, p1, p2));
+ }
+ }
+
+ /**
+ * Ensures that {@code expression} is {@code true}, throwing a {@code VerifyException} with a
+ * custom message otherwise.
+ *
+ * <p>See {@link #verify(boolean, String, Object...)} for details.
+ *
+ * @since 23.1 (varargs overload since 17.0)
+ */
+ public static void verify(
+ boolean expression, @NullableDecl String errorMessageTemplate, int p1, long p2) {
+ if (!expression) {
+ throw new VerifyException(lenientFormat(errorMessageTemplate, p1, p2));
+ }
+ }
+
+ /**
+ * Ensures that {@code expression} is {@code true}, throwing a {@code VerifyException} with a
+ * custom message otherwise.
+ *
+ * <p>See {@link #verify(boolean, String, Object...)} for details.
+ *
+ * @since 23.1 (varargs overload since 17.0)
+ */
+ public static void verify(
+ boolean expression, @NullableDecl String errorMessageTemplate, long p1, long p2) {
+ if (!expression) {
+ throw new VerifyException(lenientFormat(errorMessageTemplate, p1, p2));
+ }
+ }
+
+ /**
+ * Ensures that {@code expression} is {@code true}, throwing a {@code VerifyException} with a
+ * custom message otherwise.
+ *
+ * <p>See {@link #verify(boolean, String, Object...)} for details.
+ *
+ * @since 23.1 (varargs overload since 17.0)
+ */
+ public static void verify(
+ boolean expression,
+ @NullableDecl String errorMessageTemplate,
+ @NullableDecl Object p1,
+ long p2) {
+ if (!expression) {
+ throw new VerifyException(lenientFormat(errorMessageTemplate, p1, p2));
+ }
+ }
+
+ /**
+ * Ensures that {@code expression} is {@code true}, throwing a {@code VerifyException} with a
+ * custom message otherwise.
+ *
+ * <p>See {@link #verify(boolean, String, Object...)} for details.
+ *
+ * @since 23.1 (varargs overload since 17.0)
+ */
+ public static void verify(
+ boolean expression,
+ @NullableDecl String errorMessageTemplate,
+ char p1,
+ @NullableDecl Object p2) {
+ if (!expression) {
+ throw new VerifyException(lenientFormat(errorMessageTemplate, p1, p2));
+ }
+ }
+
+ /**
+ * Ensures that {@code expression} is {@code true}, throwing a {@code VerifyException} with a
+ * custom message otherwise.
+ *
+ * <p>See {@link #verify(boolean, String, Object...)} for details.
+ *
+ * @since 23.1 (varargs overload since 17.0)
+ */
+ public static void verify(
+ boolean expression,
+ @NullableDecl String errorMessageTemplate,
+ int p1,
+ @NullableDecl Object p2) {
+ if (!expression) {
+ throw new VerifyException(lenientFormat(errorMessageTemplate, p1, p2));
+ }
+ }
+
+ /**
+ * Ensures that {@code expression} is {@code true}, throwing a {@code VerifyException} with a
+ * custom message otherwise.
+ *
+ * <p>See {@link #verify(boolean, String, Object...)} for details.
+ *
+ * @since 23.1 (varargs overload since 17.0)
+ */
+ public static void verify(
+ boolean expression,
+ @NullableDecl String errorMessageTemplate,
+ long p1,
+ @NullableDecl Object p2) {
+ if (!expression) {
+ throw new VerifyException(lenientFormat(errorMessageTemplate, p1, p2));
+ }
+ }
+
+ /**
+ * Ensures that {@code expression} is {@code true}, throwing a {@code VerifyException} with a
+ * custom message otherwise.
+ *
+ * <p>See {@link #verify(boolean, String, Object...)} for details.
+ *
+ * @since 23.1 (varargs overload since 17.0)
+ */
+ public static void verify(
+ boolean expression,
+ @NullableDecl String errorMessageTemplate,
+ @NullableDecl Object p1,
+ @NullableDecl Object p2) {
+ if (!expression) {
+ throw new VerifyException(lenientFormat(errorMessageTemplate, p1, p2));
+ }
+ }
+
+ /**
+ * Ensures that {@code expression} is {@code true}, throwing a {@code VerifyException} with a
+ * custom message otherwise.
+ *
+ * <p>See {@link #verify(boolean, String, Object...)} for details.
+ *
+ * @since 23.1 (varargs overload since 17.0)
+ */
+ public static void verify(
+ boolean expression,
+ @NullableDecl String errorMessageTemplate,
+ @NullableDecl Object p1,
+ @NullableDecl Object p2,
+ @NullableDecl Object p3) {
if (!expression) {
throw new VerifyException(lenientFormat(errorMessageTemplate, p1, p2, p3));
}
@@ -447,25 +474,16 @@
*/
public static void verify(
boolean expression,
- String errorMessageTemplate,
- @CheckForNull Object p1,
- @CheckForNull Object p2,
- @CheckForNull Object p3,
- @CheckForNull Object p4) {
+ @NullableDecl String errorMessageTemplate,
+ @NullableDecl Object p1,
+ @NullableDecl Object p2,
+ @NullableDecl Object p3,
+ @NullableDecl Object p4) {
if (!expression) {
throw new VerifyException(lenientFormat(errorMessageTemplate, p1, p2, p3, p4));
}
}
- /*
- * For a discussion of the signature of verifyNotNull, see the discussion above
- * Preconditions.checkNotNull.
- *
- * (verifyNotNull has many fewer "problem" callers, so we could try to be stricter. On the other
- * hand, verifyNotNull arguably has more reason to accept nullable arguments in the first
- * place....)
- */
-
/**
* Ensures that {@code reference} is non-null, throwing a {@code VerifyException} with a default
* message otherwise.
@@ -475,7 +493,7 @@
* @see Preconditions#checkNotNull Preconditions.checkNotNull()
*/
@CanIgnoreReturnValue
- public static <T> T verifyNotNull(@CheckForNull T reference) {
+ public static <T> T verifyNotNull(@NullableDecl T reference) {
return verifyNotNull(reference, "expected a non-null reference");
}
@@ -496,12 +514,10 @@
*/
@CanIgnoreReturnValue
public static <T> T verifyNotNull(
- @CheckForNull T reference,
- String errorMessageTemplate,
- @CheckForNull @Nullable Object... errorMessageArgs) {
- if (reference == null) {
- throw new VerifyException(lenientFormat(errorMessageTemplate, errorMessageArgs));
- }
+ @NullableDecl T reference,
+ @NullableDecl String errorMessageTemplate,
+ @NullableDecl Object... errorMessageArgs) {
+ verify(reference != null, errorMessageTemplate, errorMessageArgs);
return reference;
}
diff --git a/android/guava/src/com/google/common/base/VerifyException.java b/android/guava/src/com/google/common/base/VerifyException.java
index 10b99de..eed5c6d 100644
--- a/android/guava/src/com/google/common/base/VerifyException.java
+++ b/android/guava/src/com/google/common/base/VerifyException.java
@@ -15,7 +15,7 @@
package com.google.common.base;
import com.google.common.annotations.GwtCompatible;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* Exception thrown upon the failure of a <a
@@ -25,13 +25,12 @@
* @since 17.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
public class VerifyException extends RuntimeException {
/** Constructs a {@code VerifyException} with no message. */
public VerifyException() {}
/** Constructs a {@code VerifyException} with the message {@code message}. */
- public VerifyException(@CheckForNull String message) {
+ public VerifyException(@NullableDecl String message) {
super(message);
}
@@ -41,7 +40,7 @@
*
* @since 19.0
*/
- public VerifyException(@CheckForNull Throwable cause) {
+ public VerifyException(@NullableDecl Throwable cause) {
super(cause);
}
@@ -51,7 +50,7 @@
*
* @since 19.0
*/
- public VerifyException(@CheckForNull String message, @CheckForNull Throwable cause) {
+ public VerifyException(@NullableDecl String message, @NullableDecl Throwable cause) {
super(message, cause);
}
}
diff --git a/android/guava/src/com/google/common/cache/AbstractCache.java b/android/guava/src/com/google/common/cache/AbstractCache.java
index eec5fdc..d8ef032 100644
--- a/android/guava/src/com/google/common/cache/AbstractCache.java
+++ b/android/guava/src/com/google/common/cache/AbstractCache.java
@@ -38,7 +38,6 @@
* @since 10.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
public abstract class AbstractCache<K, V> implements Cache<K, V> {
/** Constructor for use by subclasses. */
@@ -59,12 +58,8 @@
*
* @since 11.0
*/
- /*
- * <? extends Object> is mostly the same as <?> to plain Java. But to nullness checkers, they
- * differ: <? extends Object> means "non-null types," while <?> means "all types."
- */
@Override
- public ImmutableMap<K, V> getAllPresent(Iterable<? extends Object> keys) {
+ public ImmutableMap<K, V> getAllPresent(Iterable<?> keys) {
Map<K, V> result = Maps.newLinkedHashMap();
for (Object key : keys) {
if (!result.containsKey(key)) {
@@ -108,8 +103,7 @@
/** @since 11.0 */
@Override
- // For discussion of <? extends Object>, see getAllPresent.
- public void invalidateAll(Iterable<? extends Object> keys) {
+ public void invalidateAll(Iterable<?> keys) {
for (Object key : keys) {
invalidate(key);
}
diff --git a/android/guava/src/com/google/common/cache/AbstractLoadingCache.java b/android/guava/src/com/google/common/cache/AbstractLoadingCache.java
index 489597c..38b9774 100644
--- a/android/guava/src/com/google/common/cache/AbstractLoadingCache.java
+++ b/android/guava/src/com/google/common/cache/AbstractLoadingCache.java
@@ -38,7 +38,6 @@
* @since 11.0
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public abstract class AbstractLoadingCache<K, V> extends AbstractCache<K, V>
implements LoadingCache<K, V> {
diff --git a/android/guava/src/com/google/common/cache/Cache.java b/android/guava/src/com/google/common/cache/Cache.java
index 1234bb6..69bd752 100644
--- a/android/guava/src/com/google/common/cache/Cache.java
+++ b/android/guava/src/com/google/common/cache/Cache.java
@@ -18,14 +18,13 @@
import com.google.common.collect.ImmutableMap;
import com.google.common.util.concurrent.ExecutionError;
import com.google.common.util.concurrent.UncheckedExecutionException;
-import com.google.errorprone.annotations.CheckReturnValue;
import com.google.errorprone.annotations.CompatibleWith;
import com.google.errorprone.annotations.DoNotMock;
import java.util.Map;
import java.util.concurrent.Callable;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.ExecutionException;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* A semi-persistent mapping from keys to values. Cache entries are manually added using {@link
@@ -35,14 +34,11 @@
* <p>Implementations of this interface are expected to be thread-safe, and can be safely accessed
* by multiple concurrent threads.
*
- * @param <K> the type of the cache's keys, which are not permitted to be null
- * @param <V> the type of the cache's values, which are not permitted to be null
* @author Charles Fry
* @since 10.0
*/
@DoNotMock("Use CacheBuilder.newBuilder().build()")
@GwtCompatible
-@ElementTypesAreNonnullByDefault
public interface Cache<K, V> {
/**
@@ -51,7 +47,7 @@
*
* @since 11.0
*/
- @CheckForNull
+ @NullableDecl
V getIfPresent(@CompatibleWith("K") Object key);
/**
@@ -108,11 +104,7 @@
*
* @since 11.0
*/
- /*
- * <? extends Object> is mostly the same as <?> to plain Java. But to nullness checkers, they
- * differ: <? extends Object> means "non-null types," while <?> means "all types."
- */
- ImmutableMap<K, V> getAllPresent(Iterable<? extends Object> keys);
+ ImmutableMap<K, V> getAllPresent(Iterable<?> keys);
/**
* Associates {@code value} with {@code key} in this cache. If the cache previously contained a
@@ -143,14 +135,12 @@
*
* @since 11.0
*/
- // For discussion of <? extends Object>, see getAllPresent.
- void invalidateAll(Iterable<? extends Object> keys);
+ void invalidateAll(Iterable<?> keys);
/** Discards all entries in the cache. */
void invalidateAll();
/** Returns the approximate number of entries in this cache. */
- @CheckReturnValue
long size();
/**
@@ -164,7 +154,6 @@
* all values is returned.
*
*/
- @CheckReturnValue
CacheStats stats();
/**
@@ -180,7 +169,6 @@
* {@code ConcurrentMap} documentation. They will not function correctly and it is impossible for
* Guava to fix them until Guava is ready to <i>require</i> Java 8 for all users.
*/
- @CheckReturnValue
ConcurrentMap<K, V> asMap();
/**
diff --git a/android/guava/src/com/google/common/cache/CacheBuilder.java b/android/guava/src/com/google/common/cache/CacheBuilder.java
index 227b2c2..cd98515 100644
--- a/android/guava/src/com/google/common/cache/CacheBuilder.java
+++ b/android/guava/src/com/google/common/cache/CacheBuilder.java
@@ -39,55 +39,15 @@
import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
import java.util.logging.Logger;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
- * A builder of {@link LoadingCache} and {@link Cache} instances.
- *
- * <h2>Prefer <a href="https://github.com/ben-manes/caffeine/wiki">Caffeine</a> over Guava's caching
- * API</h2>
- *
- * <p>The successor to Guava's caching API is <a
- * href="https://github.com/ben-manes/caffeine/wiki">Caffeine</a>. Its API is designed to make it a
- * nearly drop-in replacement -- though it requires Java 8 APIs and is not available for Android or
- * GWT/j2cl. Its equivalent to {@code CacheBuilder} is its <a
- * href="https://www.javadoc.io/doc/com.github.ben-manes.caffeine/caffeine/latest/com.github.benmanes.caffeine/com/github/benmanes/caffeine/cache/Caffeine.html">{@code
- * Caffeine}</a> class. Caffeine offers better performance, more features (including asynchronous
- * loading), and fewer <a
- * href="https://github.com/google/guava/issues?q=is%3Aopen+is%3Aissue+label%3Apackage%3Dcache+label%3Atype%3Ddefect">bugs</a>.
- *
- * <p>Caffeine defines its own interfaces (<a
- * href="https://www.javadoc.io/doc/com.github.ben-manes.caffeine/caffeine/latest/com.github.benmanes.caffeine/com/github/benmanes/caffeine/cache/Cache.html">{@code
- * Cache}</a>, <a
- * href="https://www.javadoc.io/doc/com.github.ben-manes.caffeine/caffeine/latest/com.github.benmanes.caffeine/com/github/benmanes/caffeine/cache/LoadingCache.html">{@code
- * LoadingCache}</a>, <a
- * href="https://www.javadoc.io/doc/com.github.ben-manes.caffeine/caffeine/latest/com.github.benmanes.caffeine/com/github/benmanes/caffeine/cache/CacheLoader.html">{@code
- * CacheLoader}</a>, etc.), so you can use Caffeine without needing to use any Guava types.
- * Caffeine's types are better than Guava's, especially for <a
- * href="https://www.javadoc.io/doc/com.github.ben-manes.caffeine/caffeine/latest/com.github.benmanes.caffeine/com/github/benmanes/caffeine/cache/AsyncLoadingCache.html">their
- * deep support for asynchronous operations</a>. But if you want to migrate to Caffeine with minimal
- * code changes, you can use <a
- * href="https://www.javadoc.io/doc/com.github.ben-manes.caffeine/guava/latest/com.github.benmanes.caffeine.guava/com/github/benmanes/caffeine/guava/CaffeinatedGuava.html">its
- * {@code CaffeinatedGuava} adapter class</a>, which lets you build a Guava {@code Cache} or a Guava
- * {@code LoadingCache} backed by a Guava {@code CacheLoader}.
- *
- * <p>Caffeine's API for asynchronous operations uses {@code CompletableFuture}: <a
- * href="https://www.javadoc.io/doc/com.github.ben-manes.caffeine/caffeine/latest/com.github.benmanes.caffeine/com/github/benmanes/caffeine/cache/AsyncLoadingCache.html#get(K)">{@code
- * AsyncLoadingCache.get}</a> returns a {@code CompletableFuture}, and implementations of <a
- * href="https://www.javadoc.io/doc/com.github.ben-manes.caffeine/caffeine/latest/com.github.benmanes.caffeine/com/github/benmanes/caffeine/cache/AsyncCacheLoader.html#asyncLoad(K,java.util.concurrent.Executor)">{@code
- * AsyncCacheLoader.asyncLoad}</a> must return a {@code CompletableFuture}. Users of Guava's {@link
- * com.google.common.util.concurrent.ListenableFuture} can adapt between the two {@code Future}
- * types by using <a href="https://github.com/lukas-krecan/future-converter#java8-guava">{@code
- * net.javacrumbs.futureconverter.java8guava.FutureConverter}</a>.
- *
- * <h2>More on {@code CacheBuilder}</h2>
- *
- * {@code CacheBuilder} builds caches with any combination of the following features:
+ * A builder of {@link LoadingCache} and {@link Cache} instances having any combination of the
+ * following features:
*
* <ul>
* <li>automatic loading of entries into the cache
- * <li>least-recently-used eviction when a maximum size is exceeded (note that the cache is
- * divided into segments, each of which does LRU internally)
+ * <li>least-recently-used eviction when a maximum size is exceeded
* <li>time-based expiration of entries, measured since last access or last write
* <li>keys automatically wrapped in {@code WeakReference}
* <li>values automatically wrapped in {@code WeakReference} or {@code SoftReference}
@@ -95,6 +55,7 @@
* <li>accumulation of cache access statistics
* </ul>
*
+ *
* <p>These features are all optional; caches can be created using all or none of them. By default
* cache instances created by {@code CacheBuilder} will not perform any type of eviction.
*
@@ -182,16 +143,15 @@
*
* @param <K> the most general key type this builder will be able to create caches for. This is
* normally {@code Object} unless it is constrained by using a method like {@code
- * #removalListener}. Cache keys may not be null.
+ * #removalListener}
* @param <V> the most general value type this builder will be able to create caches for. This is
* normally {@code Object} unless it is constrained by using a method like {@code
- * #removalListener}. Cache values may not be null.
+ * #removalListener}
* @author Charles Fry
* @author Kevin Bourrillion
* @since 10.0
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
public final class CacheBuilder<K, V> {
private static final int DEFAULT_INITIAL_CAPACITY = 16;
private static final int DEFAULT_CONCURRENCY_LEVEL = 4;
@@ -271,10 +231,10 @@
int concurrencyLevel = UNSET_INT;
long maximumSize = UNSET_INT;
long maximumWeight = UNSET_INT;
- @Nullable Weigher<? super K, ? super V> weigher;
+ @NullableDecl Weigher<? super K, ? super V> weigher;
- @Nullable Strength keyStrength;
- @Nullable Strength valueStrength;
+ @NullableDecl Strength keyStrength;
+ @NullableDecl Strength valueStrength;
@SuppressWarnings("GoodTime") // should be a java.time.Duration
long expireAfterWriteNanos = UNSET_INT;
@@ -285,11 +245,11 @@
@SuppressWarnings("GoodTime") // should be a java.time.Duration
long refreshNanos = UNSET_INT;
- @Nullable Equivalence<Object> keyEquivalence;
- @Nullable Equivalence<Object> valueEquivalence;
+ @NullableDecl Equivalence<Object> keyEquivalence;
+ @NullableDecl Equivalence<Object> valueEquivalence;
- @Nullable RemovalListener<? super K, ? super V> removalListener;
- @Nullable Ticker ticker;
+ @NullableDecl RemovalListener<? super K, ? super V> removalListener;
+ @NullableDecl Ticker ticker;
Supplier<? extends StatsCounter> statsCounterSupplier = NULL_STATS_COUNTER;
@@ -302,7 +262,6 @@
* <p>Note that while this return type is {@code CacheBuilder<Object, Object>}, type parameters on
* the {@link #build} methods allow you to create a cache of any key and value type desired.
*/
- @CheckReturnValue
public static CacheBuilder<Object, Object> newBuilder() {
return new CacheBuilder<>();
}
@@ -313,7 +272,6 @@
* @since 12.0
*/
@GwtIncompatible // To be supported
- @CheckReturnValue
public static CacheBuilder<Object, Object> from(CacheBuilderSpec spec) {
return spec.toCacheBuilder().lenientParsing();
}
@@ -326,7 +284,6 @@
* @since 12.0
*/
@GwtIncompatible // To be supported
- @CheckReturnValue
public static CacheBuilder<Object, Object> from(String spec) {
return from(CacheBuilderSpec.parse(spec));
}
@@ -521,8 +478,8 @@
this.maximumWeight);
checkState(
this.maximumSize == UNSET_INT, "maximum size was already set to %s", this.maximumSize);
- checkArgument(maximumWeight >= 0, "maximum weight must not be negative");
this.maximumWeight = maximumWeight;
+ checkArgument(maximumWeight >= 0, "maximum weight must not be negative");
return this;
}
@@ -691,7 +648,7 @@
* @param unit the unit that {@code duration} is expressed in
* @return this {@code CacheBuilder} instance (for chaining)
* @throws IllegalArgumentException if {@code duration} is negative
- * @throws IllegalStateException if {@link #expireAfterWrite} was already set
+ * @throws IllegalStateException if the time to live or time to idle was already set
*/
@SuppressWarnings("GoodTime") // should accept a java.time.Duration
public CacheBuilder<K, V> expireAfterWrite(long duration, TimeUnit unit) {
@@ -731,7 +688,7 @@
* @param unit the unit that {@code duration} is expressed in
* @return this {@code CacheBuilder} instance (for chaining)
* @throws IllegalArgumentException if {@code duration} is negative
- * @throws IllegalStateException if {@link #expireAfterAccess} was already set
+ * @throws IllegalStateException if the time to idle or time to live was already set
*/
@SuppressWarnings("GoodTime") // should accept a java.time.Duration
public CacheBuilder<K, V> expireAfterAccess(long duration, TimeUnit unit) {
@@ -763,8 +720,7 @@
* operations.
*
* <p>Currently automatic refreshes are performed when the first stale request for an entry
- * occurs. The request triggering refresh will make a synchronous call to {@link
- * CacheLoader#reload}
+ * occurs. The request triggering refresh will make a blocking call to {@link CacheLoader#reload}
* and immediately return the new value if the returned future is complete, and the old value
* otherwise.
*
@@ -775,7 +731,7 @@
* @param unit the unit that {@code duration} is expressed in
* @return this {@code CacheBuilder} instance (for chaining)
* @throws IllegalArgumentException if {@code duration} is negative
- * @throws IllegalStateException if {@link #refreshAfterWrite} was already set
+ * @throws IllegalStateException if the refresh interval was already set
* @since 11.0
*/
@GwtIncompatible // To be supported (synchronously).
@@ -890,7 +846,6 @@
* @param loader the cache loader used to obtain new values
* @return a cache having the requested features
*/
- @CheckReturnValue
public <K1 extends K, V1 extends V> LoadingCache<K1, V1> build(
CacheLoader<? super K1, V1> loader) {
checkWeightWithWeigher();
@@ -909,7 +864,6 @@
* @return a cache having the requested features
* @since 11.0
*/
- @CheckReturnValue
public <K1 extends K, V1 extends V> Cache<K1, V1> build() {
checkWeightWithWeigher();
checkNonLoadingCache();
diff --git a/android/guava/src/com/google/common/cache/CacheBuilderSpec.java b/android/guava/src/com/google/common/cache/CacheBuilderSpec.java
index 64b5ad2..e804866 100644
--- a/android/guava/src/com/google/common/cache/CacheBuilderSpec.java
+++ b/android/guava/src/com/google/common/cache/CacheBuilderSpec.java
@@ -15,7 +15,6 @@
package com.google.common.cache;
import static com.google.common.base.Preconditions.checkArgument;
-import static com.google.common.base.Strings.isNullOrEmpty;
import com.google.common.annotations.GwtIncompatible;
import com.google.common.annotations.VisibleForTesting;
@@ -28,8 +27,7 @@
import java.util.List;
import java.util.Locale;
import java.util.concurrent.TimeUnit;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* A specification of a {@link CacheBuilder} configuration.
@@ -80,11 +78,10 @@
*/
@SuppressWarnings("GoodTime") // lots of violations (nanosecond math)
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public final class CacheBuilderSpec {
/** Parses a single value. */
private interface ValueParser {
- void parse(CacheBuilderSpec spec, String key, @CheckForNull String value);
+ void parse(CacheBuilderSpec spec, String key, @NullableDecl String value);
}
/** Splits each key-value pair. */
@@ -110,19 +107,19 @@
.put("refreshInterval", new RefreshDurationParser())
.build();
- @VisibleForTesting @CheckForNull Integer initialCapacity;
- @VisibleForTesting @CheckForNull Long maximumSize;
- @VisibleForTesting @CheckForNull Long maximumWeight;
- @VisibleForTesting @CheckForNull Integer concurrencyLevel;
- @VisibleForTesting @CheckForNull Strength keyStrength;
- @VisibleForTesting @CheckForNull Strength valueStrength;
- @VisibleForTesting @CheckForNull Boolean recordStats;
+ @VisibleForTesting @NullableDecl Integer initialCapacity;
+ @VisibleForTesting @NullableDecl Long maximumSize;
+ @VisibleForTesting @NullableDecl Long maximumWeight;
+ @VisibleForTesting @NullableDecl Integer concurrencyLevel;
+ @VisibleForTesting @NullableDecl Strength keyStrength;
+ @VisibleForTesting @NullableDecl Strength valueStrength;
+ @VisibleForTesting @NullableDecl Boolean recordStats;
@VisibleForTesting long writeExpirationDuration;
- @VisibleForTesting @CheckForNull TimeUnit writeExpirationTimeUnit;
+ @VisibleForTesting @NullableDecl TimeUnit writeExpirationTimeUnit;
@VisibleForTesting long accessExpirationDuration;
- @VisibleForTesting @CheckForNull TimeUnit accessExpirationTimeUnit;
+ @VisibleForTesting @NullableDecl TimeUnit accessExpirationTimeUnit;
@VisibleForTesting long refreshDuration;
- @VisibleForTesting @CheckForNull TimeUnit refreshTimeUnit;
+ @VisibleForTesting @NullableDecl TimeUnit refreshTimeUnit;
/** Specification; used for toParseableString(). */
private final String specification;
@@ -251,7 +248,7 @@
}
@Override
- public boolean equals(@CheckForNull Object obj) {
+ public boolean equals(@NullableDecl Object obj) {
if (this == obj) {
return true;
}
@@ -281,8 +278,8 @@
* Converts an expiration duration/unit pair into a single Long for hashing and equality. Uses
* nanos to match CacheBuilder implementation.
*/
- @CheckForNull
- private static Long durationInNanos(long duration, @CheckForNull TimeUnit unit) {
+ @NullableDecl
+ private static Long durationInNanos(long duration, @NullableDecl TimeUnit unit) {
return (unit == null) ? null : unit.toNanos(duration);
}
@@ -291,10 +288,8 @@
protected abstract void parseInteger(CacheBuilderSpec spec, int value);
@Override
- public void parse(CacheBuilderSpec spec, String key, @Nullable String value) {
- if (isNullOrEmpty(value)) {
- throw new IllegalArgumentException("value of key " + key + " omitted");
- }
+ public void parse(CacheBuilderSpec spec, String key, String value) {
+ checkArgument(value != null && !value.isEmpty(), "value of key %s omitted", key);
try {
parseInteger(spec, Integer.parseInt(value));
} catch (NumberFormatException e) {
@@ -309,10 +304,8 @@
protected abstract void parseLong(CacheBuilderSpec spec, long value);
@Override
- public void parse(CacheBuilderSpec spec, String key, @Nullable String value) {
- if (isNullOrEmpty(value)) {
- throw new IllegalArgumentException("value of key " + key + " omitted");
- }
+ public void parse(CacheBuilderSpec spec, String key, String value) {
+ checkArgument(value != null && !value.isEmpty(), "value of key %s omitted", key);
try {
parseLong(spec, Long.parseLong(value));
} catch (NumberFormatException e) {
@@ -377,7 +370,7 @@
}
@Override
- public void parse(CacheBuilderSpec spec, String key, @CheckForNull String value) {
+ public void parse(CacheBuilderSpec spec, String key, @NullableDecl 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;
@@ -393,7 +386,7 @@
}
@Override
- public void parse(CacheBuilderSpec spec, String key, @CheckForNull String value) {
+ public void parse(CacheBuilderSpec spec, String key, @NullableDecl 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);
@@ -406,7 +399,7 @@
static class RecordStatsParser implements ValueParser {
@Override
- public void parse(CacheBuilderSpec spec, String key, @CheckForNull String value) {
+ public void parse(CacheBuilderSpec spec, String key, @NullableDecl String value) {
checkArgument(value == null, "recordStats does not take values");
checkArgument(spec.recordStats == null, "recordStats already set");
spec.recordStats = true;
@@ -418,10 +411,8 @@
protected abstract void parseDuration(CacheBuilderSpec spec, long duration, TimeUnit unit);
@Override
- public void parse(CacheBuilderSpec spec, String key, @CheckForNull String value) {
- if (isNullOrEmpty(value)) {
- throw new IllegalArgumentException("value of key " + key + " omitted");
- }
+ public void parse(CacheBuilderSpec spec, String key, String value) {
+ checkArgument(value != null && !value.isEmpty(), "value of key %s omitted", key);
try {
char lastChar = value.charAt(value.length() - 1);
TimeUnit timeUnit;
@@ -440,7 +431,8 @@
break;
default:
throw new IllegalArgumentException(
- format("key %s invalid unit: was %s, must end with one of [dhms]", key, value));
+ format(
+ "key %s invalid format. was %s, must end with one of [dDhHmMsS]", key, value));
}
long duration = Long.parseLong(value.substring(0, value.length() - 1));
diff --git a/android/guava/src/com/google/common/cache/CacheLoader.java b/android/guava/src/com/google/common/cache/CacheLoader.java
index bb544cd..b490d48 100644
--- a/android/guava/src/com/google/common/cache/CacheLoader.java
+++ b/android/guava/src/com/google/common/cache/CacheLoader.java
@@ -23,7 +23,6 @@
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.ListenableFutureTask;
-import com.google.errorprone.annotations.CheckReturnValue;
import java.io.Serializable;
import java.util.Map;
import java.util.concurrent.Callable;
@@ -57,7 +56,6 @@
* @since 10.0
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
public abstract class CacheLoader<K, V> {
/** Constructor for use by subclasses. */
protected CacheLoader() {}
@@ -138,7 +136,6 @@
* @param function the function to be used for loading values; must never return {@code null}
* @return a cache loader that loads values by passing each key to {@code function}
*/
- @CheckReturnValue
public static <K, V> CacheLoader<K, V> from(Function<K, V> function) {
return new FunctionToCacheLoader<>(function);
}
@@ -152,7 +149,6 @@
* @return a cache loader that loads values by calling {@link Supplier#get}, irrespective of the
* key
*/
- @CheckReturnValue
public static <V> CacheLoader<Object, V> from(Supplier<V> supplier) {
return new SupplierToCacheLoader<V>(supplier);
}
@@ -182,7 +178,6 @@
*
* @since 17.0
*/
- @CheckReturnValue
@GwtIncompatible // Executor + Futures
public static <K, V> CacheLoader<K, V> asyncReloading(
final CacheLoader<K, V> loader, final Executor executor) {
diff --git a/android/guava/src/com/google/common/cache/CacheStats.java b/android/guava/src/com/google/common/cache/CacheStats.java
index 8307e94..e0c39c3 100644
--- a/android/guava/src/com/google/common/cache/CacheStats.java
+++ b/android/guava/src/com/google/common/cache/CacheStats.java
@@ -22,7 +22,7 @@
import com.google.common.base.MoreObjects;
import com.google.common.base.Objects;
import java.util.concurrent.Callable;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* Statistics about the performance of a {@link Cache}. Instances of this class are immutable.
@@ -57,7 +57,6 @@
* @since 10.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
public final class CacheStats {
private final long hitCount;
private final long missCount;
@@ -277,7 +276,7 @@
}
@Override
- public boolean equals(@CheckForNull Object object) {
+ public boolean equals(@NullableDecl Object object) {
if (object instanceof CacheStats) {
CacheStats other = (CacheStats) object;
return hitCount == other.hitCount
diff --git a/android/guava/src/com/google/common/cache/ElementTypesAreNonnullByDefault.java b/android/guava/src/com/google/common/cache/ElementTypesAreNonnullByDefault.java
deleted file mode 100644
index bcf0fce..0000000
--- a/android/guava/src/com/google/common/cache/ElementTypesAreNonnullByDefault.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) 2021 The Guava Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.common.cache;
-
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.PARAMETER;
-import static java.lang.annotation.ElementType.TYPE;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-import com.google.common.annotations.GwtCompatible;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-import javax.annotation.Nonnull;
-import javax.annotation.meta.TypeQualifierDefault;
-
-/**
- * Marks all "top-level" types as non-null in a way that is recognized by Kotlin. Note that this
- * unfortunately includes type-variable usages, so we also provide {@link ParametricNullness} to
- * "undo" it as best we can.
- */
-@GwtCompatible
-@Retention(RUNTIME)
-@Target(TYPE)
-@TypeQualifierDefault({FIELD, METHOD, PARAMETER})
-@Nonnull
-@interface ElementTypesAreNonnullByDefault {}
diff --git a/android/guava/src/com/google/common/cache/ForwardingCache.java b/android/guava/src/com/google/common/cache/ForwardingCache.java
index f118977..217042b 100644
--- a/android/guava/src/com/google/common/cache/ForwardingCache.java
+++ b/android/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 javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* A cache which forwards all its method calls to another cache. Subclasses should override one or
@@ -33,7 +33,6 @@
* @since 10.0
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public abstract class ForwardingCache<K, V> extends ForwardingObject implements Cache<K, V> {
/** Constructor for use by subclasses. */
@@ -44,7 +43,7 @@
/** @since 11.0 */
@Override
- @CheckForNull
+ @NullableDecl
public V getIfPresent(Object key) {
return delegate().getIfPresent(key);
}
@@ -57,11 +56,7 @@
/** @since 11.0 */
@Override
- /*
- * <? extends Object> is mostly the same as <?> to plain Java. But to nullness checkers, they
- * differ: <? extends Object> means "non-null types," while <?> means "all types."
- */
- public ImmutableMap<K, V> getAllPresent(Iterable<? extends Object> keys) {
+ public ImmutableMap<K, V> getAllPresent(Iterable<?> keys) {
return delegate().getAllPresent(keys);
}
@@ -84,8 +79,7 @@
/** @since 11.0 */
@Override
- // For discussion of <? extends Object>, see getAllPresent.
- public void invalidateAll(Iterable<? extends Object> keys) {
+ public void invalidateAll(Iterable<?> keys) {
delegate().invalidateAll(keys);
}
diff --git a/android/guava/src/com/google/common/cache/ForwardingLoadingCache.java b/android/guava/src/com/google/common/cache/ForwardingLoadingCache.java
index ecd44ca..ba88ded 100644
--- a/android/guava/src/com/google/common/cache/ForwardingLoadingCache.java
+++ b/android/guava/src/com/google/common/cache/ForwardingLoadingCache.java
@@ -31,7 +31,6 @@
* @since 11.0
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public abstract class ForwardingLoadingCache<K, V> extends ForwardingCache<K, V>
implements LoadingCache<K, V> {
diff --git a/android/guava/src/com/google/common/cache/LoadingCache.java b/android/guava/src/com/google/common/cache/LoadingCache.java
index e338ac4..6af1d3a 100644
--- a/android/guava/src/com/google/common/cache/LoadingCache.java
+++ b/android/guava/src/com/google/common/cache/LoadingCache.java
@@ -33,13 +33,10 @@
* <p>When evaluated as a {@link Function}, a cache yields the same result as invoking {@link
* #getUnchecked}.
*
- * @param <K> the type of the cache's keys, which are not permitted to be null
- * @param <V> the type of the cache's values, which are not permitted to be null
* @author Charles Fry
* @since 11.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
public interface LoadingCache<K, V> extends Cache<K, V>, Function<K, V> {
/**
@@ -133,11 +130,11 @@
V apply(K key);
/**
- * Loads a new value for {@code key}, possibly asynchronously. While the new value is loading the
- * previous value (if any) will continue to be returned by {@code get(key)} unless it is evicted.
- * If the new value is loaded successfully it will replace the previous value in the cache; if an
- * exception is thrown while refreshing the previous value will remain, <i>and the exception will
- * be logged (using {@link java.util.logging.Logger}) and swallowed</i>.
+ * Loads a new value for key {@code key}, possibly asynchronously. While the new value is loading
+ * the previous value (if any) will continue to be returned by {@code get(key)} unless it is
+ * evicted. If the new value is loaded successfully it will replace the previous value in the
+ * cache; if an exception is thrown while refreshing the previous value will remain, <i>and the
+ * exception will be logged (using {@link java.util.logging.Logger}) and swallowed</i>.
*
* <p>Caches loaded by a {@link CacheLoader} will call {@link CacheLoader#reload} if the cache
* currently contains a value for {@code key}, and {@link CacheLoader#load} otherwise. Loading is
diff --git a/android/guava/src/com/google/common/cache/LocalCache.java b/android/guava/src/com/google/common/cache/LocalCache.java
index f61f68e..86f9dbe 100644
--- a/android/guava/src/com/google/common/cache/LocalCache.java
+++ b/android/guava/src/com/google/common/cache/LocalCache.java
@@ -93,12 +93,8 @@
* @author Bob Lee ({@code com.google.common.collect.MapMaker})
* @author Doug Lea ({@code ConcurrentHashMap})
*/
-@SuppressWarnings({
- "GoodTime", // lots of violations (nanosecond math)
- "nullness", // too much trouble for the payoff
-})
+@SuppressWarnings("GoodTime") // lots of violations (nanosecond math)
@GwtCompatible(emulated = true)
-// TODO(cpovirk): Annotate for nullness.
class LocalCache<K, V> extends AbstractMap<K, V> implements ConcurrentMap<K, V> {
/*
@@ -3865,7 +3861,8 @@
return value;
}
- @SuppressWarnings("MissingOverride") // Supermethod will not exist if we build with --release 7.
+ // Only becomes available in Java 8 when it's on the interface.
+ // @Override
@NullableDecl
public V getOrDefault(@NullableDecl Object key, @NullableDecl V defaultValue) {
V result = get(key);
diff --git a/android/guava/src/com/google/common/cache/LongAddable.java b/android/guava/src/com/google/common/cache/LongAddable.java
index 9851052..eaa6414 100644
--- a/android/guava/src/com/google/common/cache/LongAddable.java
+++ b/android/guava/src/com/google/common/cache/LongAddable.java
@@ -22,7 +22,6 @@
* @author Louis Wasserman
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
interface LongAddable {
void increment();
diff --git a/android/guava/src/com/google/common/cache/LongAddables.java b/android/guava/src/com/google/common/cache/LongAddables.java
index b0f9e2b..203d2ef 100644
--- a/android/guava/src/com/google/common/cache/LongAddables.java
+++ b/android/guava/src/com/google/common/cache/LongAddables.java
@@ -24,7 +24,6 @@
* @author Louis Wasserman
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
final class LongAddables {
private static final Supplier<LongAddable> SUPPLIER;
diff --git a/android/guava/src/com/google/common/cache/LongAdder.java b/android/guava/src/com/google/common/cache/LongAdder.java
index 7ead7e8..f0c44ff 100644
--- a/android/guava/src/com/google/common/cache/LongAdder.java
+++ b/android/guava/src/com/google/common/cache/LongAdder.java
@@ -40,7 +40,6 @@
* @author Doug Lea
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
final class LongAdder extends Striped64 implements Serializable, LongAddable {
private static final long serialVersionUID = 7249069246863182397L;
diff --git a/android/guava/src/com/google/common/cache/ParametricNullness.java b/android/guava/src/com/google/common/cache/ParametricNullness.java
deleted file mode 100644
index 19305a6..0000000
--- a/android/guava/src/com/google/common/cache/ParametricNullness.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2021 The Guava Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.common.cache;
-
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.PARAMETER;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-import static javax.annotation.meta.When.UNKNOWN;
-
-import com.google.common.annotations.GwtCompatible;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-import javax.annotation.Nonnull;
-import javax.annotation.meta.TypeQualifierNickname;
-
-/**
- * Marks a "top-level" type-variable usage as (a) a Kotlin platform type when the type argument is
- * non-nullable and (b) nullable when the type argument is nullable. This is the closest we can get
- * to "non-nullable when non-nullable; nullable when nullable" (like the Android <a
- * href="https://android.googlesource.com/platform/libcore/+/master/luni/src/main/java/libcore/util/NullFromTypeParam.java">{@code
- * NullFromTypeParam}</a>). We use this to "undo" {@link ElementTypesAreNonnullByDefault}.
- */
-@GwtCompatible
-@Retention(RUNTIME)
-@Target({FIELD, METHOD, PARAMETER})
-@TypeQualifierNickname
-@Nonnull(when = UNKNOWN)
-@interface ParametricNullness {}
diff --git a/android/guava/src/com/google/common/cache/ReferenceEntry.java b/android/guava/src/com/google/common/cache/ReferenceEntry.java
index 8ff2e6c..f9027ab 100644
--- a/android/guava/src/com/google/common/cache/ReferenceEntry.java
+++ b/android/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 javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* An entry in a reference map.
@@ -39,24 +39,22 @@
* </ul>
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
interface ReferenceEntry<K, V> {
/** Returns the value reference from this entry. */
- @CheckForNull
ValueReference<K, V> getValueReference();
/** Sets the value reference for this entry. */
void setValueReference(ValueReference<K, V> valueReference);
/** Returns the next entry in the chain. */
- @CheckForNull
+ @NullableDecl
ReferenceEntry<K, V> getNext();
/** Returns the entry's hash. */
int getHash();
/** Returns the key for this entry. */
- @CheckForNull
+ @NullableDecl
K getKey();
/*
diff --git a/android/guava/src/com/google/common/cache/RemovalCause.java b/android/guava/src/com/google/common/cache/RemovalCause.java
index 2e68e68..8ecc1d6 100644
--- a/android/guava/src/com/google/common/cache/RemovalCause.java
+++ b/android/guava/src/com/google/common/cache/RemovalCause.java
@@ -26,7 +26,6 @@
* @since 10.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
public enum RemovalCause {
/**
* The entry was manually removed by the user. This can result from the user invoking {@link
diff --git a/android/guava/src/com/google/common/cache/RemovalListener.java b/android/guava/src/com/google/common/cache/RemovalListener.java
index a7472d7..5e738bf 100644
--- a/android/guava/src/com/google/common/cache/RemovalListener.java
+++ b/android/guava/src/com/google/common/cache/RemovalListener.java
@@ -33,7 +33,6 @@
* @since 10.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
public interface RemovalListener<K, V> {
/**
* Notifies the listener that a removal occurred at some point in the past.
diff --git a/android/guava/src/com/google/common/cache/RemovalListeners.java b/android/guava/src/com/google/common/cache/RemovalListeners.java
index d0623e7..c82b094 100644
--- a/android/guava/src/com/google/common/cache/RemovalListeners.java
+++ b/android/guava/src/com/google/common/cache/RemovalListeners.java
@@ -26,7 +26,6 @@
* @since 10.0
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public final class RemovalListeners {
private RemovalListeners() {}
diff --git a/android/guava/src/com/google/common/cache/RemovalNotification.java b/android/guava/src/com/google/common/cache/RemovalNotification.java
index dab7fe5..e30ec0c 100644
--- a/android/guava/src/com/google/common/cache/RemovalNotification.java
+++ b/android/guava/src/com/google/common/cache/RemovalNotification.java
@@ -18,8 +18,7 @@
import com.google.common.annotations.GwtCompatible;
import java.util.AbstractMap.SimpleImmutableEntry;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* A notification of the removal of a single entry. The key and/or value may be null if they were
@@ -33,9 +32,7 @@
* @since 10.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-public final class RemovalNotification<K, V>
- extends SimpleImmutableEntry<@Nullable K, @Nullable V> {
+public final class RemovalNotification<K, V> extends SimpleImmutableEntry<K, V> {
private final RemovalCause cause;
/**
@@ -46,11 +43,11 @@
* @since 19.0
*/
public static <K, V> RemovalNotification<K, V> create(
- @CheckForNull K key, @CheckForNull V value, RemovalCause cause) {
+ @NullableDecl K key, @NullableDecl V value, RemovalCause cause) {
return new RemovalNotification(key, value, cause);
}
- private RemovalNotification(@CheckForNull K key, @CheckForNull V value, RemovalCause cause) {
+ private RemovalNotification(@NullableDecl K key, @NullableDecl V value, RemovalCause cause) {
super(key, value);
this.cause = checkNotNull(cause);
}
diff --git a/android/guava/src/com/google/common/cache/Striped64.java b/android/guava/src/com/google/common/cache/Striped64.java
index 0d2d75b..676e09a 100644
--- a/android/guava/src/com/google/common/cache/Striped64.java
+++ b/android/guava/src/com/google/common/cache/Striped64.java
@@ -13,8 +13,7 @@
import com.google.common.annotations.GwtIncompatible;
import java.util.Random;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* A package-local class holding common representation and mechanics for classes supporting dynamic
@@ -22,7 +21,6 @@
* so.
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
abstract class Striped64 extends Number {
/*
* This class maintains a lazily-initialized table of atomically
@@ -127,7 +125,7 @@
* class, we use a suboptimal int[] representation to avoid introducing a new type that can impede
* class-unloading when ThreadLocals are not removed.
*/
- static final ThreadLocal<int @Nullable []> threadHashCode = new ThreadLocal<>();
+ static final ThreadLocal<int[]> threadHashCode = new ThreadLocal<>();
/** Generator of new random hash codes */
static final Random rng = new Random();
@@ -136,7 +134,7 @@
static final int NCPU = Runtime.getRuntime().availableProcessors();
/** Table of cells. When non-null, size is a power of 2. */
- @CheckForNull transient volatile Cell[] cells;
+ @NullableDecl transient volatile Cell[] cells;
/**
* Base value, used mainly when there is no contention, but also as a fallback during table
@@ -179,7 +177,7 @@
* @param hc the hash code holder
* @param wasUncontended false if CAS failed before call
*/
- final void retryUpdate(long x, @CheckForNull int[] hc, boolean wasUncontended) {
+ final void retryUpdate(long x, int[] hc, boolean wasUncontended) {
int h;
if (hc == null) {
threadHashCode.set(hc = new int[1]); // Initialize randomly
diff --git a/android/guava/src/com/google/common/cache/Weigher.java b/android/guava/src/com/google/common/cache/Weigher.java
index d5bcd5b..cf552d4 100644
--- a/android/guava/src/com/google/common/cache/Weigher.java
+++ b/android/guava/src/com/google/common/cache/Weigher.java
@@ -23,7 +23,6 @@
* @since 11.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
public interface Weigher<K, V> {
/**
diff --git a/android/guava/src/com/google/common/collect/AbstractBiMap.java b/android/guava/src/com/google/common/collect/AbstractBiMap.java
index 151764b..0b314ae 100644
--- a/android/guava/src/com/google/common/collect/AbstractBiMap.java
+++ b/android/guava/src/com/google/common/collect/AbstractBiMap.java
@@ -18,7 +18,7 @@
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkState;
-import static com.google.common.collect.NullnessCasts.uncheckedCastNullableTToT;
+import static com.google.common.collect.CollectPreconditions.checkRemove;
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.GwtIncompatible;
@@ -34,8 +34,7 @@
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* A general-purpose bimap implementation using any two backing {@code Map} instances.
@@ -47,12 +46,11 @@
* @author Mike Bostock
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
-abstract class AbstractBiMap<K extends @Nullable Object, V extends @Nullable Object>
- extends ForwardingMap<K, V> implements BiMap<K, V>, Serializable {
+abstract class AbstractBiMap<K, V> extends ForwardingMap<K, V>
+ implements BiMap<K, V>, Serializable {
- private transient Map<K, V> delegate;
- @RetainedWith transient AbstractBiMap<V, K> inverse;
+ @NullableDecl private transient Map<K, V> delegate;
+ @RetainedWith @NullableDecl transient AbstractBiMap<V, K> inverse;
/** Package-private constructor for creating a map-backed bimap. */
AbstractBiMap(Map<K, V> forward, Map<V, K> backward) {
@@ -72,15 +70,13 @@
/** Returns its input, or throws an exception if this is not a valid key. */
@CanIgnoreReturnValue
- @ParametricNullness
- K checkKey(@ParametricNullness K key) {
+ K checkKey(@NullableDecl K key) {
return key;
}
/** Returns its input, or throws an exception if this is not a valid value. */
@CanIgnoreReturnValue
- @ParametricNullness
- V checkValue(@ParametricNullness V value) {
+ V checkValue(@NullableDecl V value) {
return value;
}
@@ -109,7 +105,7 @@
// Query Operations (optimizations)
@Override
- public boolean containsValue(@CheckForNull Object value) {
+ public boolean containsValue(@NullableDecl Object value) {
return inverse.containsKey(value);
}
@@ -117,20 +113,17 @@
@CanIgnoreReturnValue
@Override
- @CheckForNull
- public V put(@ParametricNullness K key, @ParametricNullness V value) {
+ public V put(@NullableDecl K key, @NullableDecl V value) {
return putInBothMaps(key, value, false);
}
@CanIgnoreReturnValue
@Override
- @CheckForNull
- public V forcePut(@ParametricNullness K key, @ParametricNullness V value) {
+ public V forcePut(@NullableDecl K key, @NullableDecl V value) {
return putInBothMaps(key, value, true);
}
- @CheckForNull
- private V putInBothMaps(@ParametricNullness K key, @ParametricNullness V value, boolean force) {
+ private V putInBothMaps(@NullableDecl K key, @NullableDecl V value, boolean force) {
checkKey(key);
checkValue(value);
boolean containedKey = containsKey(key);
@@ -147,35 +140,27 @@
return oldValue;
}
- private void updateInverseMap(
- @ParametricNullness K key,
- boolean containedKey,
- @CheckForNull V oldValue,
- @ParametricNullness V newValue) {
+ private void updateInverseMap(K key, boolean containedKey, V oldValue, V newValue) {
if (containedKey) {
- // The cast is safe because of the containedKey check.
- removeFromInverseMap(uncheckedCastNullableTToT(oldValue));
+ removeFromInverseMap(oldValue);
}
inverse.delegate.put(newValue, key);
}
@CanIgnoreReturnValue
@Override
- @CheckForNull
- public V remove(@CheckForNull Object key) {
+ public V remove(@NullableDecl Object key) {
return containsKey(key) ? removeFromBothMaps(key) : null;
}
@CanIgnoreReturnValue
- @ParametricNullness
- private V removeFromBothMaps(@CheckForNull Object key) {
- // The cast is safe because the callers of this method first check that the key is present.
- V oldValue = uncheckedCastNullableTToT(delegate.remove(key));
+ private V removeFromBothMaps(Object key) {
+ V oldValue = delegate.remove(key);
removeFromInverseMap(oldValue);
return oldValue;
}
- private void removeFromInverseMap(@ParametricNullness V oldValue) {
+ private void removeFromInverseMap(V oldValue) {
inverse.delegate.remove(oldValue);
}
@@ -201,7 +186,7 @@
return inverse;
}
- @CheckForNull private transient Set<K> keySet;
+ @NullableDecl private transient Set<K> keySet;
@Override
public Set<K> keySet() {
@@ -222,7 +207,7 @@
}
@Override
- public boolean remove(@CheckForNull Object key) {
+ public boolean remove(Object key) {
if (!contains(key)) {
return false;
}
@@ -246,7 +231,7 @@
}
}
- @CheckForNull private transient Set<V> valueSet;
+ @NullableDecl private transient Set<V> valueSet;
@Override
public Set<V> values() {
@@ -273,13 +258,12 @@
}
@Override
- public @Nullable Object[] toArray() {
+ public Object[] toArray() {
return standardToArray();
}
@Override
- @SuppressWarnings("nullness") // bug in our checker's handling of toArray signatures
- public <T extends @Nullable Object> T[] toArray(T[] array) {
+ public <T> T[] toArray(T[] array) {
return standardToArray(array);
}
@@ -289,7 +273,7 @@
}
}
- @CheckForNull private transient Set<Entry<K, V>> entrySet;
+ @NullableDecl private transient Set<Entry<K, V>> entrySet;
@Override
public Set<Entry<K, V>> entrySet() {
@@ -329,7 +313,7 @@
Iterator<Entry<K, V>> entrySetIterator() {
final Iterator<Entry<K, V>> iterator = delegate.entrySet().iterator();
return new Iterator<Entry<K, V>>() {
- @CheckForNull Entry<K, V> entry;
+ @NullableDecl Entry<K, V> entry;
@Override
public boolean hasNext() {
@@ -344,9 +328,7 @@
@Override
public void remove() {
- if (entry == null) {
- throw new IllegalStateException("no calls to next() since the last call to remove()");
- }
+ checkRemove(entry != null);
V value = entry.getValue();
iterator.remove();
removeFromInverseMap(value);
@@ -370,15 +352,12 @@
}
@Override
- public boolean remove(@CheckForNull Object object) {
- /*
- * `o instanceof Entry` is guaranteed by `contains`, but we check it here to satisfy our
- * nullness checker.
- */
- if (!esDelegate.contains(object) || !(object instanceof Entry)) {
+ public boolean remove(Object object) {
+ if (!esDelegate.contains(object)) {
return false;
}
+ // safe because esDelegate.contains(object).
Entry<?, ?> entry = (Entry<?, ?>) object;
inverse.delegate.remove(entry.getValue());
/*
@@ -399,24 +378,16 @@
@Override
public Object[] toArray() {
- /*
- * standardToArray returns `@Nullable Object[]` rather than `Object[]` but only because it can
- * be used with collections that may contain null. This collection never contains nulls, so we
- * can treat it as a plain `Object[]`.
- */
- @SuppressWarnings("nullness")
- Object[] result = standardToArray();
- return result;
+ return standardToArray();
}
@Override
- @SuppressWarnings("nullness") // bug in our checker's handling of toArray signatures
- public <T extends @Nullable Object> T[] toArray(T[] array) {
+ public <T> T[] toArray(T[] array) {
return standardToArray(array);
}
@Override
- public boolean contains(@CheckForNull Object o) {
+ public boolean contains(Object o) {
return Maps.containsEntryImpl(delegate(), o);
}
@@ -437,8 +408,7 @@
}
/** The inverse of any other {@code AbstractBiMap} subclass. */
- static class Inverse<K extends @Nullable Object, V extends @Nullable Object>
- extends AbstractBiMap<K, V> {
+ static class Inverse<K, V> extends AbstractBiMap<K, V> {
Inverse(Map<K, V> backward, AbstractBiMap<V, K> forward) {
super(backward, forward);
}
@@ -453,14 +423,12 @@
*/
@Override
- @ParametricNullness
- K checkKey(@ParametricNullness K key) {
+ K checkKey(K key) {
return inverse.checkValue(key);
}
@Override
- @ParametricNullness
- V checkValue(@ParametricNullness V value) {
+ V checkValue(V value) {
return inverse.checkKey(value);
}
diff --git a/android/guava/src/com/google/common/collect/AbstractIndexedListIterator.java b/android/guava/src/com/google/common/collect/AbstractIndexedListIterator.java
index abb3960..855fb1c 100644
--- a/android/guava/src/com/google/common/collect/AbstractIndexedListIterator.java
+++ b/android/guava/src/com/google/common/collect/AbstractIndexedListIterator.java
@@ -21,7 +21,6 @@
import com.google.common.annotations.GwtCompatible;
import java.util.ListIterator;
import java.util.NoSuchElementException;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* This class provides a skeletal implementation of the {@link ListIterator} interface across a
@@ -31,14 +30,11 @@
* @author Jared Levy
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-abstract class AbstractIndexedListIterator<E extends @Nullable Object>
- extends UnmodifiableListIterator<E> {
+abstract class AbstractIndexedListIterator<E> extends UnmodifiableListIterator<E> {
private final int size;
private int position;
/** Returns the element with the specified index. This method is called by {@link #next()}. */
- @ParametricNullness
protected abstract E get(int index);
/**
@@ -74,7 +70,6 @@
}
@Override
- @ParametricNullness
public final E next() {
if (!hasNext()) {
throw new NoSuchElementException();
@@ -93,7 +88,6 @@
}
@Override
- @ParametricNullness
public final E previous() {
if (!hasPrevious()) {
throw new NoSuchElementException();
diff --git a/android/guava/src/com/google/common/collect/AbstractIterator.java b/android/guava/src/com/google/common/collect/AbstractIterator.java
index 66273f4..ea5ea7a 100644
--- a/android/guava/src/com/google/common/collect/AbstractIterator.java
+++ b/android/guava/src/com/google/common/collect/AbstractIterator.java
@@ -17,13 +17,11 @@
package com.google.common.collect;
import static com.google.common.base.Preconditions.checkState;
-import static com.google.common.collect.NullnessCasts.uncheckedCastNullableTToT;
import com.google.common.annotations.GwtCompatible;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import java.util.NoSuchElementException;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* This class provides a skeletal implementation of the {@code Iterator} interface, to make this
@@ -63,8 +61,7 @@
// When making changes to this class, please also update the copy at
// com.google.common.base.AbstractIterator
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-public abstract class AbstractIterator<T extends @Nullable Object> extends UnmodifiableIterator<T> {
+public abstract class AbstractIterator<T> extends UnmodifiableIterator<T> {
private State state = State.NOT_READY;
/** Constructor for use by subclasses. */
@@ -84,7 +81,7 @@
FAILED,
}
- @CheckForNull private T next;
+ @NullableDecl private T next;
/**
* Returns the next element. <b>Note:</b> the implementation must call {@link #endOfData()} when
@@ -110,7 +107,6 @@
* this method. Any further attempts to use the iterator will result in an {@link
* IllegalStateException}.
*/
- @CheckForNull
protected abstract T computeNext();
/**
@@ -121,7 +117,6 @@
* simple statement {@code return endOfData();}
*/
@CanIgnoreReturnValue
- @CheckForNull
protected final T endOfData() {
state = State.DONE;
return null;
@@ -153,14 +148,12 @@
@CanIgnoreReturnValue // TODO(kak): Should we remove this?
@Override
- @ParametricNullness
public final T next() {
if (!hasNext()) {
throw new NoSuchElementException();
}
state = State.NOT_READY;
- // Safe because hasNext() ensures that tryToComputeNext() has put a T into `next`.
- T result = uncheckedCastNullableTToT(next);
+ T result = next;
next = null;
return result;
}
@@ -172,12 +165,10 @@
* <p>Implementations of {@code AbstractIterator} that wish to expose this functionality should
* implement {@code PeekingIterator}.
*/
- @ParametricNullness
public final T peek() {
if (!hasNext()) {
throw new NoSuchElementException();
}
- // Safe because hasNext() ensures that tryToComputeNext() has put a T into `next`.
- return uncheckedCastNullableTToT(next);
+ return next;
}
}
diff --git a/android/guava/src/com/google/common/collect/AbstractListMultimap.java b/android/guava/src/com/google/common/collect/AbstractListMultimap.java
index 46c4ee2..4f075d1 100644
--- a/android/guava/src/com/google/common/collect/AbstractListMultimap.java
+++ b/android/guava/src/com/google/common/collect/AbstractListMultimap.java
@@ -22,8 +22,7 @@
import java.util.Collections;
import java.util.List;
import java.util.Map;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* Basic implementation of the {@link ListMultimap} interface. It's a wrapper around {@link
@@ -34,9 +33,8 @@
* @since 2.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-abstract class AbstractListMultimap<K extends @Nullable Object, V extends @Nullable Object>
- extends AbstractMapBasedMultimap<K, V> implements ListMultimap<K, V> {
+abstract class AbstractListMultimap<K, V> extends AbstractMapBasedMultimap<K, V>
+ implements ListMultimap<K, V> {
/**
* Creates a new multimap that uses the provided map.
*
@@ -55,13 +53,12 @@
}
@Override
- <E extends @Nullable Object> Collection<E> unmodifiableCollectionSubclass(
- Collection<E> collection) {
+ <E> Collection<E> unmodifiableCollectionSubclass(Collection<E> collection) {
return Collections.unmodifiableList((List<E>) collection);
}
@Override
- Collection<V> wrapCollection(@ParametricNullness K key, Collection<V> collection) {
+ Collection<V> wrapCollection(K key, Collection<V> collection) {
return wrapList(key, (List<V>) collection, null);
}
@@ -75,7 +72,7 @@
* Multimap} interface.
*/
@Override
- public List<V> get(@ParametricNullness K key) {
+ public List<V> get(@NullableDecl K key) {
return (List<V>) super.get(key);
}
@@ -88,7 +85,7 @@
*/
@CanIgnoreReturnValue
@Override
- public List<V> removeAll(@CheckForNull Object key) {
+ public List<V> removeAll(@NullableDecl Object key) {
return (List<V>) super.removeAll(key);
}
@@ -101,7 +98,7 @@
*/
@CanIgnoreReturnValue
@Override
- public List<V> replaceValues(@ParametricNullness K key, Iterable<? extends V> values) {
+ public List<V> replaceValues(@NullableDecl K key, Iterable<? extends V> values) {
return (List<V>) super.replaceValues(key, values);
}
@@ -114,7 +111,7 @@
*/
@CanIgnoreReturnValue
@Override
- public boolean put(@ParametricNullness K key, @ParametricNullness V value) {
+ public boolean put(@NullableDecl K key, @NullableDecl V value) {
return super.put(key, value);
}
@@ -136,7 +133,7 @@
* in the same order. If the value orderings disagree, the multimaps will not be considered equal.
*/
@Override
- public boolean equals(@CheckForNull Object object) {
+ public boolean equals(@NullableDecl Object object) {
return super.equals(object);
}
diff --git a/android/guava/src/com/google/common/collect/AbstractMapBasedMultimap.java b/android/guava/src/com/google/common/collect/AbstractMapBasedMultimap.java
index 72cf8f1..b72f135 100644
--- a/android/guava/src/com/google/common/collect/AbstractMapBasedMultimap.java
+++ b/android/guava/src/com/google/common/collect/AbstractMapBasedMultimap.java
@@ -18,9 +18,7 @@
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.base.Preconditions.checkState;
-import static com.google.common.collect.NullnessCasts.uncheckedCastNullableTToT;
-import static java.util.Objects.requireNonNull;
+import static com.google.common.collect.CollectPreconditions.checkRemove;
import com.google.common.annotations.GwtCompatible;
import com.google.common.collect.Maps.ViewCachingAbstractMap;
@@ -42,8 +40,7 @@
import java.util.Set;
import java.util.SortedMap;
import java.util.SortedSet;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* Basic implementation of the {@link Multimap} interface. This class represents a multimap as a map
@@ -84,9 +81,8 @@
* @author Louis Wasserman
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-abstract class AbstractMapBasedMultimap<K extends @Nullable Object, V extends @Nullable Object>
- extends AbstractMultimap<K, V> implements Serializable {
+abstract class AbstractMapBasedMultimap<K, V> extends AbstractMultimap<K, V>
+ implements Serializable {
/*
* Here's an outline of the overall design.
*
@@ -159,7 +155,7 @@
* @param key key to associate with values in the collection
* @return an empty collection of values
*/
- Collection<V> createCollection(@ParametricNullness K key) {
+ Collection<V> createCollection(@NullableDecl K key) {
return createCollection();
}
@@ -175,14 +171,14 @@
}
@Override
- public boolean containsKey(@CheckForNull Object key) {
+ public boolean containsKey(@NullableDecl Object key) {
return map.containsKey(key);
}
// Modification Operations
@Override
- public boolean put(@ParametricNullness K key, @ParametricNullness V value) {
+ public boolean put(@NullableDecl K key, @NullableDecl V value) {
Collection<V> collection = map.get(key);
if (collection == null) {
collection = createCollection(key);
@@ -201,7 +197,7 @@
}
}
- private Collection<V> getOrCreateCollection(@ParametricNullness K key) {
+ private Collection<V> getOrCreateCollection(@NullableDecl K key) {
Collection<V> collection = map.get(key);
if (collection == null) {
collection = createCollection(key);
@@ -218,7 +214,7 @@
* <p>The returned collection is immutable.
*/
@Override
- public Collection<V> replaceValues(@ParametricNullness K key, Iterable<? extends V> values) {
+ public Collection<V> replaceValues(@NullableDecl K key, Iterable<? extends V> values) {
Iterator<? extends V> iterator = values.iterator();
if (!iterator.hasNext()) {
return removeAll(key);
@@ -247,7 +243,7 @@
* <p>The returned collection is immutable.
*/
@Override
- public Collection<V> removeAll(@CheckForNull Object key) {
+ public Collection<V> removeAll(@NullableDecl Object key) {
Collection<V> collection = map.remove(key);
if (collection == null) {
@@ -262,8 +258,7 @@
return unmodifiableCollectionSubclass(output);
}
- <E extends @Nullable Object> Collection<E> unmodifiableCollectionSubclass(
- Collection<E> collection) {
+ <E> Collection<E> unmodifiableCollectionSubclass(Collection<E> collection) {
return Collections.unmodifiableCollection(collection);
}
@@ -285,7 +280,7 @@
* <p>The returned collection is not serializable.
*/
@Override
- public Collection<V> get(@ParametricNullness K key) {
+ public Collection<V> get(@NullableDecl K key) {
Collection<V> collection = map.get(key);
if (collection == null) {
collection = createCollection(key);
@@ -297,12 +292,12 @@
* 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<V> wrapCollection(@ParametricNullness K key, Collection<V> collection) {
+ Collection<V> wrapCollection(@NullableDecl K key, Collection<V> collection) {
return new WrappedCollection(key, collection, null);
}
final List<V> wrapList(
- @ParametricNullness K key, List<V> list, @CheckForNull WrappedCollection ancestor) {
+ @NullableDecl K key, List<V> list, @NullableDecl WrappedCollection ancestor) {
return (list instanceof RandomAccess)
? new RandomAccessWrappedList(key, list, ancestor)
: new WrappedList(key, list, ancestor);
@@ -325,15 +320,13 @@
*/
@WeakOuter
class WrappedCollection extends AbstractCollection<V> {
- @ParametricNullness final K key;
+ @NullableDecl final K key;
Collection<V> delegate;
- @CheckForNull final WrappedCollection ancestor;
- @CheckForNull final Collection<V> ancestorDelegate;
+ @NullableDecl final WrappedCollection ancestor;
+ @NullableDecl final Collection<V> ancestorDelegate;
WrappedCollection(
- @ParametricNullness K key,
- Collection<V> delegate,
- @CheckForNull WrappedCollection ancestor) {
+ @NullableDecl K key, Collection<V> delegate, @NullableDecl WrappedCollection ancestor) {
this.key = key;
this.delegate = delegate;
this.ancestor = ancestor;
@@ -373,7 +366,6 @@
}
}
- @ParametricNullness
K getKey() {
return key;
}
@@ -399,7 +391,7 @@
}
@Override
- public boolean equals(@CheckForNull Object object) {
+ public boolean equals(@NullableDecl Object object) {
if (object == this) {
return true;
}
@@ -459,7 +451,6 @@
}
@Override
- @ParametricNullness
public V next() {
validateIterator();
return delegateIterator.next();
@@ -479,7 +470,7 @@
}
@Override
- public boolean add(@ParametricNullness V value) {
+ public boolean add(V value) {
refreshIfEmpty();
boolean wasEmpty = delegate.isEmpty();
boolean changed = delegate.add(value);
@@ -492,7 +483,6 @@
return changed;
}
- @CheckForNull
WrappedCollection getAncestor() {
return ancestor;
}
@@ -517,7 +507,7 @@
}
@Override
- public boolean contains(@CheckForNull Object o) {
+ public boolean contains(Object o) {
refreshIfEmpty();
return delegate.contains(o);
}
@@ -540,7 +530,7 @@
}
@Override
- public boolean remove(@CheckForNull Object o) {
+ public boolean remove(Object o) {
refreshIfEmpty();
boolean changed = delegate.remove(o);
if (changed) {
@@ -579,8 +569,7 @@
}
}
- private static <E extends @Nullable Object> Iterator<E> iteratorOrListIterator(
- Collection<E> collection) {
+ private static <E> Iterator<E> iteratorOrListIterator(Collection<E> collection) {
return (collection instanceof List)
? ((List<E>) collection).listIterator()
: collection.iterator();
@@ -589,7 +578,7 @@
/** Set decorator that stays in sync with the multimap values for a key. */
@WeakOuter
class WrappedSet extends WrappedCollection implements Set<V> {
- WrappedSet(@ParametricNullness K key, Set<V> delegate) {
+ WrappedSet(@NullableDecl K key, Set<V> delegate) {
super(key, delegate, null);
}
@@ -617,9 +606,7 @@
@WeakOuter
class WrappedSortedSet extends WrappedCollection implements SortedSet<V> {
WrappedSortedSet(
- @ParametricNullness K key,
- SortedSet<V> delegate,
- @CheckForNull WrappedCollection ancestor) {
+ @NullableDecl K key, SortedSet<V> delegate, @NullableDecl WrappedCollection ancestor) {
super(key, delegate, ancestor);
}
@@ -628,27 +615,24 @@
}
@Override
- @CheckForNull
public Comparator<? super V> comparator() {
return getSortedSetDelegate().comparator();
}
@Override
- @ParametricNullness
public V first() {
refreshIfEmpty();
return getSortedSetDelegate().first();
}
@Override
- @ParametricNullness
public V last() {
refreshIfEmpty();
return getSortedSetDelegate().last();
}
@Override
- public SortedSet<V> headSet(@ParametricNullness V toElement) {
+ public SortedSet<V> headSet(V toElement) {
refreshIfEmpty();
return new WrappedSortedSet(
getKey(),
@@ -657,7 +641,7 @@
}
@Override
- public SortedSet<V> subSet(@ParametricNullness V fromElement, @ParametricNullness V toElement) {
+ public SortedSet<V> subSet(V fromElement, V toElement) {
refreshIfEmpty();
return new WrappedSortedSet(
getKey(),
@@ -666,7 +650,7 @@
}
@Override
- public SortedSet<V> tailSet(@ParametricNullness V fromElement) {
+ public SortedSet<V> tailSet(V fromElement) {
refreshIfEmpty();
return new WrappedSortedSet(
getKey(),
@@ -678,9 +662,7 @@
@WeakOuter
class WrappedNavigableSet extends WrappedSortedSet implements NavigableSet<V> {
WrappedNavigableSet(
- @ParametricNullness K key,
- NavigableSet<V> delegate,
- @CheckForNull WrappedCollection ancestor) {
+ @NullableDecl K key, NavigableSet<V> delegate, @NullableDecl WrappedCollection ancestor) {
super(key, delegate, ancestor);
}
@@ -690,37 +672,31 @@
}
@Override
- @CheckForNull
- public V lower(@ParametricNullness V v) {
+ public V lower(V v) {
return getSortedSetDelegate().lower(v);
}
@Override
- @CheckForNull
- public V floor(@ParametricNullness V v) {
+ public V floor(V v) {
return getSortedSetDelegate().floor(v);
}
@Override
- @CheckForNull
- public V ceiling(@ParametricNullness V v) {
+ public V ceiling(V v) {
return getSortedSetDelegate().ceiling(v);
}
@Override
- @CheckForNull
- public V higher(@ParametricNullness V v) {
+ public V higher(V v) {
return getSortedSetDelegate().higher(v);
}
@Override
- @CheckForNull
public V pollFirst() {
return Iterators.pollNext(iterator());
}
@Override
- @CheckForNull
public V pollLast() {
return Iterators.pollNext(descendingIterator());
}
@@ -741,21 +717,18 @@
@Override
public NavigableSet<V> subSet(
- @ParametricNullness V fromElement,
- boolean fromInclusive,
- @ParametricNullness V toElement,
- boolean toInclusive) {
+ V fromElement, boolean fromInclusive, V toElement, boolean toInclusive) {
return wrap(
getSortedSetDelegate().subSet(fromElement, fromInclusive, toElement, toInclusive));
}
@Override
- public NavigableSet<V> headSet(@ParametricNullness V toElement, boolean inclusive) {
+ public NavigableSet<V> headSet(V toElement, boolean inclusive) {
return wrap(getSortedSetDelegate().headSet(toElement, inclusive));
}
@Override
- public NavigableSet<V> tailSet(@ParametricNullness V fromElement, boolean inclusive) {
+ public NavigableSet<V> tailSet(V fromElement, boolean inclusive) {
return wrap(getSortedSetDelegate().tailSet(fromElement, inclusive));
}
}
@@ -763,8 +736,7 @@
/** List decorator that stays in sync with the multimap values for a key. */
@WeakOuter
class WrappedList extends WrappedCollection implements List<V> {
- WrappedList(
- @ParametricNullness K key, List<V> delegate, @CheckForNull WrappedCollection ancestor) {
+ WrappedList(@NullableDecl K key, List<V> delegate, @NullableDecl WrappedCollection ancestor) {
super(key, delegate, ancestor);
}
@@ -790,21 +762,19 @@
}
@Override
- @ParametricNullness
public V get(int index) {
refreshIfEmpty();
return getListDelegate().get(index);
}
@Override
- @ParametricNullness
- public V set(int index, @ParametricNullness V element) {
+ public V set(int index, V element) {
refreshIfEmpty();
return getListDelegate().set(index, element);
}
@Override
- public void add(int index, @ParametricNullness V element) {
+ public void add(int index, V element) {
refreshIfEmpty();
boolean wasEmpty = getDelegate().isEmpty();
getListDelegate().add(index, element);
@@ -815,7 +785,6 @@
}
@Override
- @ParametricNullness
public V remove(int index) {
refreshIfEmpty();
V value = getListDelegate().remove(index);
@@ -825,13 +794,13 @@
}
@Override
- public int indexOf(@CheckForNull Object o) {
+ public int indexOf(Object o) {
refreshIfEmpty();
return getListDelegate().indexOf(o);
}
@Override
- public int lastIndexOf(@CheckForNull Object o) {
+ public int lastIndexOf(Object o) {
refreshIfEmpty();
return getListDelegate().lastIndexOf(o);
}
@@ -875,7 +844,6 @@
}
@Override
- @ParametricNullness
public V previous() {
return getDelegateListIterator().previous();
}
@@ -891,12 +859,12 @@
}
@Override
- public void set(@ParametricNullness V value) {
+ public void set(V value) {
getDelegateListIterator().set(value);
}
@Override
- public void add(@ParametricNullness V value) {
+ public void add(V value) {
boolean wasEmpty = isEmpty();
getDelegateListIterator().add(value);
totalSize++;
@@ -913,7 +881,7 @@
*/
private class RandomAccessWrappedList extends WrappedList implements RandomAccess {
RandomAccessWrappedList(
- @ParametricNullness K key, List<V> delegate, @CheckForNull WrappedCollection ancestor) {
+ @NullableDecl K key, List<V> delegate, @NullableDecl WrappedCollection ancestor) {
super(key, delegate, ancestor);
}
}
@@ -943,7 +911,7 @@
public Iterator<K> iterator() {
final Iterator<Entry<K, Collection<V>>> entryIterator = map().entrySet().iterator();
return new Iterator<K>() {
- @CheckForNull Entry<K, Collection<V>> entry;
+ @NullableDecl Entry<K, Collection<V>> entry;
@Override
public boolean hasNext() {
@@ -951,7 +919,6 @@
}
@Override
- @ParametricNullness
public K next() {
entry = entryIterator.next();
return entry.getKey();
@@ -959,7 +926,7 @@
@Override
public void remove() {
- checkState(entry != null, "no calls to next() since the last call to remove()");
+ checkRemove(entry != null);
Collection<V> collection = entry.getValue();
entryIterator.remove();
totalSize -= collection.size();
@@ -972,7 +939,7 @@
// The following methods are included for better performance.
@Override
- public boolean remove(@CheckForNull Object key) {
+ public boolean remove(Object key) {
int count = 0;
Collection<V> collection = map().remove(key);
if (collection != null) {
@@ -994,7 +961,7 @@
}
@Override
- public boolean equals(@CheckForNull Object object) {
+ public boolean equals(@NullableDecl Object object) {
return this == object || this.map().keySet().equals(object);
}
@@ -1016,35 +983,32 @@
}
@Override
- @CheckForNull
public Comparator<? super K> comparator() {
return sortedMap().comparator();
}
@Override
- @ParametricNullness
public K first() {
return sortedMap().firstKey();
}
@Override
- public SortedSet<K> headSet(@ParametricNullness K toElement) {
+ public SortedSet<K> headSet(K toElement) {
return new SortedKeySet(sortedMap().headMap(toElement));
}
@Override
- @ParametricNullness
public K last() {
return sortedMap().lastKey();
}
@Override
- public SortedSet<K> subSet(@ParametricNullness K fromElement, @ParametricNullness K toElement) {
+ public SortedSet<K> subSet(K fromElement, K toElement) {
return new SortedKeySet(sortedMap().subMap(fromElement, toElement));
}
@Override
- public SortedSet<K> tailSet(@ParametricNullness K fromElement) {
+ public SortedSet<K> tailSet(K fromElement) {
return new SortedKeySet(sortedMap().tailMap(fromElement));
}
}
@@ -1061,37 +1025,31 @@
}
@Override
- @CheckForNull
- public K lower(@ParametricNullness K k) {
+ public K lower(K k) {
return sortedMap().lowerKey(k);
}
@Override
- @CheckForNull
- public K floor(@ParametricNullness K k) {
+ public K floor(K k) {
return sortedMap().floorKey(k);
}
@Override
- @CheckForNull
- public K ceiling(@ParametricNullness K k) {
+ public K ceiling(K k) {
return sortedMap().ceilingKey(k);
}
@Override
- @CheckForNull
- public K higher(@ParametricNullness K k) {
+ public K higher(K k) {
return sortedMap().higherKey(k);
}
@Override
- @CheckForNull
public K pollFirst() {
return Iterators.pollNext(iterator());
}
@Override
- @CheckForNull
public K pollLast() {
return Iterators.pollNext(descendingIterator());
}
@@ -1107,44 +1065,40 @@
}
@Override
- public NavigableSet<K> headSet(@ParametricNullness K toElement) {
+ public NavigableSet<K> headSet(K toElement) {
return headSet(toElement, false);
}
@Override
- public NavigableSet<K> headSet(@ParametricNullness K toElement, boolean inclusive) {
+ public NavigableSet<K> headSet(K toElement, boolean inclusive) {
return new NavigableKeySet(sortedMap().headMap(toElement, inclusive));
}
@Override
- public NavigableSet<K> subSet(
- @ParametricNullness K fromElement, @ParametricNullness K toElement) {
+ public NavigableSet<K> subSet(K fromElement, K toElement) {
return subSet(fromElement, true, toElement, false);
}
@Override
public NavigableSet<K> subSet(
- @ParametricNullness K fromElement,
- boolean fromInclusive,
- @ParametricNullness K toElement,
- boolean toInclusive) {
+ K fromElement, boolean fromInclusive, K toElement, boolean toInclusive) {
return new NavigableKeySet(
sortedMap().subMap(fromElement, fromInclusive, toElement, toInclusive));
}
@Override
- public NavigableSet<K> tailSet(@ParametricNullness K fromElement) {
+ public NavigableSet<K> tailSet(K fromElement) {
return tailSet(fromElement, true);
}
@Override
- public NavigableSet<K> tailSet(@ParametricNullness K fromElement, boolean inclusive) {
+ public NavigableSet<K> tailSet(K fromElement, boolean inclusive) {
return new NavigableKeySet(sortedMap().tailMap(fromElement, inclusive));
}
}
/** Removes all values for the provided key. */
- private void removeValuesForKey(@CheckForNull Object key) {
+ private void removeValuesForKey(Object key) {
Collection<V> collection = Maps.safeRemove(map, key);
if (collection != null) {
@@ -1154,10 +1108,10 @@
}
}
- private abstract class Itr<T extends @Nullable Object> implements Iterator<T> {
+ private abstract class Itr<T> implements Iterator<T> {
final Iterator<Entry<K, Collection<V>>> keyIterator;
- @CheckForNull K key;
- @CheckForNull Collection<V> collection;
+ @NullableDecl K key;
+ @NullableDecl Collection<V> collection;
Iterator<V> valueIterator;
Itr() {
@@ -1167,7 +1121,7 @@
valueIterator = Iterators.emptyModifiableIterator();
}
- abstract T output(@ParametricNullness K key, @ParametricNullness V value);
+ abstract T output(K key, V value);
@Override
public boolean hasNext() {
@@ -1182,21 +1136,13 @@
collection = mapEntry.getValue();
valueIterator = collection.iterator();
}
- /*
- * uncheckedCastNullableTToT is safe: The first call to this method always enters the !hasNext() case and
- * populates key, after which it's never cleared.
- */
- return output(uncheckedCastNullableTToT(key), valueIterator.next());
+ return output(key, valueIterator.next());
}
@Override
public void remove() {
valueIterator.remove();
- /*
- * requireNonNull is safe because we've already initialized `collection`. If we hadn't, then
- * valueIterator.remove() would have failed.
- */
- if (requireNonNull(collection).isEmpty()) {
+ if (collection.isEmpty()) {
keyIterator.remove();
}
totalSize--;
@@ -1223,8 +1169,7 @@
Iterator<V> valueIterator() {
return new Itr<V>() {
@Override
- @ParametricNullness
- V output(@ParametricNullness K key, @ParametricNullness V value) {
+ V output(K key, V value) {
return value;
}
};
@@ -1276,7 +1221,7 @@
Iterator<Entry<K, V>> entryIterator() {
return new Itr<Entry<K, V>>() {
@Override
- Entry<K, V> output(@ParametricNullness K key, @ParametricNullness V value) {
+ Entry<K, V> output(K key, V value) {
return Maps.immutableEntry(key, value);
}
};
@@ -1317,13 +1262,12 @@
// The following methods are included for performance.
@Override
- public boolean containsKey(@CheckForNull Object key) {
+ public boolean containsKey(Object key) {
return Maps.safeContainsKey(submap, key);
}
@Override
- @CheckForNull
- public Collection<V> get(@CheckForNull Object key) {
+ public Collection<V> get(Object key) {
Collection<V> collection = Maps.safeGet(submap, key);
if (collection == null) {
return null;
@@ -1344,8 +1288,7 @@
}
@Override
- @CheckForNull
- public Collection<V> remove(@CheckForNull Object key) {
+ public Collection<V> remove(Object key) {
Collection<V> collection = submap.remove(key);
if (collection == null) {
return null;
@@ -1359,7 +1302,7 @@
}
@Override
- public boolean equals(@CheckForNull Object object) {
+ public boolean equals(@NullableDecl Object object) {
return this == object || submap.equals(object);
}
@@ -1402,17 +1345,16 @@
// The following methods are included for performance.
@Override
- public boolean contains(@CheckForNull Object o) {
+ public boolean contains(Object o) {
return Collections2.safeContains(submap.entrySet(), o);
}
@Override
- public boolean remove(@CheckForNull Object o) {
+ public boolean remove(Object o) {
if (!contains(o)) {
return false;
}
- // requireNonNull is safe because of the contains check.
- Entry<?, ?> entry = requireNonNull((Entry<?, ?>) o);
+ Entry<?, ?> entry = (Entry<?, ?>) o;
removeValuesForKey(entry.getKey());
return true;
}
@@ -1421,7 +1363,7 @@
/** Iterator across all keys and value collections. */
class AsMapIterator implements Iterator<Entry<K, Collection<V>>> {
final Iterator<Entry<K, Collection<V>>> delegateIterator = submap.entrySet().iterator();
- @CheckForNull Collection<V> collection;
+ @NullableDecl Collection<V> collection;
@Override
public boolean hasNext() {
@@ -1437,7 +1379,7 @@
@Override
public void remove() {
- checkState(collection != null, "no calls to next() since the last call to remove()");
+ checkRemove(collection != null);
delegateIterator.remove();
totalSize -= collection.size();
collection.clear();
@@ -1457,40 +1399,36 @@
}
@Override
- @CheckForNull
public Comparator<? super K> comparator() {
return sortedMap().comparator();
}
@Override
- @ParametricNullness
public K firstKey() {
return sortedMap().firstKey();
}
@Override
- @ParametricNullness
public K lastKey() {
return sortedMap().lastKey();
}
@Override
- public SortedMap<K, Collection<V>> headMap(@ParametricNullness K toKey) {
+ public SortedMap<K, Collection<V>> headMap(K toKey) {
return new SortedAsMap(sortedMap().headMap(toKey));
}
@Override
- public SortedMap<K, Collection<V>> subMap(
- @ParametricNullness K fromKey, @ParametricNullness K toKey) {
+ public SortedMap<K, Collection<V>> subMap(K fromKey, K toKey) {
return new SortedAsMap(sortedMap().subMap(fromKey, toKey));
}
@Override
- public SortedMap<K, Collection<V>> tailMap(@ParametricNullness K fromKey) {
+ public SortedMap<K, Collection<V>> tailMap(K fromKey) {
return new SortedAsMap(sortedMap().tailMap(fromKey));
}
- @CheckForNull SortedSet<K> sortedKeySet;
+ @NullableDecl SortedSet<K> sortedKeySet;
// returns a SortedSet, even though returning a Set would be sufficient to
// satisfy the SortedMap.keySet() interface
@@ -1518,84 +1456,71 @@
}
@Override
- @CheckForNull
- public Entry<K, Collection<V>> lowerEntry(@ParametricNullness K key) {
+ public Entry<K, Collection<V>> lowerEntry(K key) {
Entry<K, Collection<V>> entry = sortedMap().lowerEntry(key);
return (entry == null) ? null : wrapEntry(entry);
}
@Override
- @CheckForNull
- public K lowerKey(@ParametricNullness K key) {
+ public K lowerKey(K key) {
return sortedMap().lowerKey(key);
}
@Override
- @CheckForNull
- public Entry<K, Collection<V>> floorEntry(@ParametricNullness K key) {
+ public Entry<K, Collection<V>> floorEntry(K key) {
Entry<K, Collection<V>> entry = sortedMap().floorEntry(key);
return (entry == null) ? null : wrapEntry(entry);
}
@Override
- @CheckForNull
- public K floorKey(@ParametricNullness K key) {
+ public K floorKey(K key) {
return sortedMap().floorKey(key);
}
@Override
- @CheckForNull
- public Entry<K, Collection<V>> ceilingEntry(@ParametricNullness K key) {
+ public Entry<K, Collection<V>> ceilingEntry(K key) {
Entry<K, Collection<V>> entry = sortedMap().ceilingEntry(key);
return (entry == null) ? null : wrapEntry(entry);
}
@Override
- @CheckForNull
- public K ceilingKey(@ParametricNullness K key) {
+ public K ceilingKey(K key) {
return sortedMap().ceilingKey(key);
}
@Override
- @CheckForNull
- public Entry<K, Collection<V>> higherEntry(@ParametricNullness K key) {
+ public Entry<K, Collection<V>> higherEntry(K key) {
Entry<K, Collection<V>> entry = sortedMap().higherEntry(key);
return (entry == null) ? null : wrapEntry(entry);
}
@Override
- @CheckForNull
- public K higherKey(@ParametricNullness K key) {
+ public K higherKey(K key) {
return sortedMap().higherKey(key);
}
@Override
- @CheckForNull
public Entry<K, Collection<V>> firstEntry() {
Entry<K, Collection<V>> entry = sortedMap().firstEntry();
return (entry == null) ? null : wrapEntry(entry);
}
@Override
- @CheckForNull
public Entry<K, Collection<V>> lastEntry() {
Entry<K, Collection<V>> entry = sortedMap().lastEntry();
return (entry == null) ? null : wrapEntry(entry);
}
@Override
- @CheckForNull
public Entry<K, Collection<V>> pollFirstEntry() {
return pollAsMapEntry(entrySet().iterator());
}
@Override
- @CheckForNull
public Entry<K, Collection<V>> pollLastEntry() {
return pollAsMapEntry(descendingMap().entrySet().iterator());
}
- @CheckForNull
Entry<K, Collection<V>> pollAsMapEntry(Iterator<Entry<K, Collection<V>>> entryIterator) {
if (!entryIterator.hasNext()) {
return null;
@@ -1633,38 +1558,33 @@
}
@Override
- public NavigableMap<K, Collection<V>> subMap(
- @ParametricNullness K fromKey, @ParametricNullness K toKey) {
+ public NavigableMap<K, Collection<V>> subMap(K fromKey, K toKey) {
return subMap(fromKey, true, toKey, false);
}
@Override
public NavigableMap<K, Collection<V>> subMap(
- @ParametricNullness K fromKey,
- boolean fromInclusive,
- @ParametricNullness K toKey,
- boolean toInclusive) {
+ K fromKey, boolean fromInclusive, K toKey, boolean toInclusive) {
return new NavigableAsMap(sortedMap().subMap(fromKey, fromInclusive, toKey, toInclusive));
}
@Override
- public NavigableMap<K, Collection<V>> headMap(@ParametricNullness K toKey) {
+ public NavigableMap<K, Collection<V>> headMap(K toKey) {
return headMap(toKey, false);
}
@Override
- public NavigableMap<K, Collection<V>> headMap(@ParametricNullness K toKey, boolean inclusive) {
+ public NavigableMap<K, Collection<V>> headMap(K toKey, boolean inclusive) {
return new NavigableAsMap(sortedMap().headMap(toKey, inclusive));
}
@Override
- public NavigableMap<K, Collection<V>> tailMap(@ParametricNullness K fromKey) {
+ public NavigableMap<K, Collection<V>> tailMap(K fromKey) {
return tailMap(fromKey, true);
}
@Override
- public NavigableMap<K, Collection<V>> tailMap(
- @ParametricNullness K fromKey, boolean inclusive) {
+ public NavigableMap<K, Collection<V>> tailMap(K fromKey, boolean inclusive) {
return new NavigableAsMap(sortedMap().tailMap(fromKey, inclusive));
}
}
diff --git a/android/guava/src/com/google/common/collect/AbstractMapBasedMultiset.java b/android/guava/src/com/google/common/collect/AbstractMapBasedMultiset.java
index 8c71e68..3ff472a 100644
--- a/android/guava/src/com/google/common/collect/AbstractMapBasedMultiset.java
+++ b/android/guava/src/com/google/common/collect/AbstractMapBasedMultiset.java
@@ -31,12 +31,11 @@
import java.util.ConcurrentModificationException;
import java.util.Iterator;
import java.util.NoSuchElementException;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* Basic implementation of {@code Multiset<E>} backed by an instance of {@code
- * ObjectCountHashMap<E>}.
+ * AbstractObjectCountMap<E>}.
*
* <p>For serialization to work, the subclass must specify explicit {@code readObject} and {@code
* writeObject} methods.
@@ -44,21 +43,19 @@
* @author Kevin Bourrillion
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
-abstract class AbstractMapBasedMultiset<E extends @Nullable Object> extends AbstractMultiset<E>
- implements Serializable {
+abstract class AbstractMapBasedMultiset<E> extends AbstractMultiset<E> implements Serializable {
transient ObjectCountHashMap<E> backingMap;
transient long size;
AbstractMapBasedMultiset(int distinctElements) {
- backingMap = newBackingMap(distinctElements);
+ init(distinctElements);
}
- abstract ObjectCountHashMap<E> newBackingMap(int distinctElements);
+ abstract void init(int distinctElements);
@Override
- public final int count(@CheckForNull Object element) {
+ public final int count(@NullableDecl Object element) {
return backingMap.get(element);
}
@@ -72,7 +69,7 @@
*/
@CanIgnoreReturnValue
@Override
- public final int add(@ParametricNullness E element, int occurrences) {
+ public final int add(@NullableDecl E element, int occurrences) {
if (occurrences == 0) {
return count(element);
}
@@ -93,7 +90,7 @@
@CanIgnoreReturnValue
@Override
- public final int remove(@CheckForNull Object element, int occurrences) {
+ public final int remove(@NullableDecl Object element, int occurrences) {
if (occurrences == 0) {
return count(element);
}
@@ -117,7 +114,7 @@
@CanIgnoreReturnValue
@Override
- public final int setCount(@ParametricNullness E element, int count) {
+ public final int setCount(@NullableDecl E element, int count) {
checkNonnegative(count, "count");
int oldCount = (count == 0) ? backingMap.remove(element) : backingMap.put(element, count);
size += (count - oldCount);
@@ -125,7 +122,7 @@
}
@Override
- public final boolean setCount(@ParametricNullness E element, int oldCount, int newCount) {
+ public final boolean setCount(@NullableDecl E element, int oldCount, int newCount) {
checkNonnegative(oldCount, "oldCount");
checkNonnegative(newCount, "newCount");
int entryIndex = backingMap.indexOf(element);
@@ -163,12 +160,11 @@
* Skeleton of per-entry iterators. We could push this down and win a few bytes, but it's complex
* enough it's not especially worth it.
*/
- abstract class Itr<T extends @Nullable Object> implements Iterator<T> {
+ abstract class Itr<T> implements Iterator<T> {
int entryIndex = backingMap.firstIndex();
int toRemove = -1;
int expectedModCount = backingMap.modCount;
- @ParametricNullness
abstract T result(int entryIndex);
private void checkForConcurrentModification() {
@@ -184,7 +180,6 @@
}
@Override
- @ParametricNullness
public T next() {
if (!hasNext()) {
throw new NoSuchElementException();
@@ -210,7 +205,6 @@
final Iterator<E> elementIterator() {
return new Itr<E>() {
@Override
- @ParametricNullness
E result(int entryIndex) {
return backingMap.getKey(entryIndex);
}
@@ -264,7 +258,7 @@
private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {
stream.defaultReadObject();
int distinctElements = Serialization.readCount(stream);
- backingMap = newBackingMap(ObjectCountHashMap.DEFAULT_SIZE);
+ init(ObjectCountHashMap.DEFAULT_SIZE);
Serialization.populateMultiset(this, stream, distinctElements);
}
diff --git a/android/guava/src/com/google/common/collect/AbstractMapEntry.java b/android/guava/src/com/google/common/collect/AbstractMapEntry.java
index e9accf0..27ea432 100644
--- a/android/guava/src/com/google/common/collect/AbstractMapEntry.java
+++ b/android/guava/src/com/google/common/collect/AbstractMapEntry.java
@@ -19,8 +19,7 @@
import com.google.common.annotations.GwtCompatible;
import com.google.common.base.Objects;
import java.util.Map.Entry;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* Implementation of the {@code equals}, {@code hashCode}, and {@code toString} methods of {@code
@@ -29,26 +28,21 @@
* @author Jared Levy
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-abstract class AbstractMapEntry<K extends @Nullable Object, V extends @Nullable Object>
- implements Entry<K, V> {
+abstract class AbstractMapEntry<K, V> implements Entry<K, V> {
@Override
- @ParametricNullness
public abstract K getKey();
@Override
- @ParametricNullness
public abstract V getValue();
@Override
- @ParametricNullness
- public V setValue(@ParametricNullness V value) {
+ public V setValue(V value) {
throw new UnsupportedOperationException();
}
@Override
- public boolean equals(@CheckForNull Object object) {
+ public boolean equals(@NullableDecl Object object) {
if (object instanceof Entry) {
Entry<?, ?> that = (Entry<?, ?>) object;
return Objects.equal(this.getKey(), that.getKey())
diff --git a/android/guava/src/com/google/common/collect/AbstractMultimap.java b/android/guava/src/com/google/common/collect/AbstractMultimap.java
index 17e84a6..5d03ec9 100644
--- a/android/guava/src/com/google/common/collect/AbstractMultimap.java
+++ b/android/guava/src/com/google/common/collect/AbstractMultimap.java
@@ -20,7 +20,6 @@
import com.google.common.annotations.GwtCompatible;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
-import com.google.errorprone.annotations.concurrent.LazyInit;
import com.google.j2objc.annotations.WeakOuter;
import java.util.AbstractCollection;
import java.util.Collection;
@@ -28,8 +27,7 @@
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* A skeleton {@code Multimap} implementation, not necessarily in terms of a {@code Map}.
@@ -37,16 +35,14 @@
* @author Louis Wasserman
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-abstract class AbstractMultimap<K extends @Nullable Object, V extends @Nullable Object>
- implements Multimap<K, V> {
+abstract class AbstractMultimap<K, V> implements Multimap<K, V> {
@Override
public boolean isEmpty() {
return size() == 0;
}
@Override
- public boolean containsValue(@CheckForNull Object value) {
+ public boolean containsValue(@NullableDecl Object value) {
for (Collection<V> collection : asMap().values()) {
if (collection.contains(value)) {
return true;
@@ -57,27 +53,27 @@
}
@Override
- public boolean containsEntry(@CheckForNull Object key, @CheckForNull Object value) {
+ public boolean containsEntry(@NullableDecl Object key, @NullableDecl Object value) {
Collection<V> collection = asMap().get(key);
return collection != null && collection.contains(value);
}
@CanIgnoreReturnValue
@Override
- public boolean remove(@CheckForNull Object key, @CheckForNull Object value) {
+ public boolean remove(@NullableDecl Object key, @NullableDecl Object value) {
Collection<V> collection = asMap().get(key);
return collection != null && collection.remove(value);
}
@CanIgnoreReturnValue
@Override
- public boolean put(@ParametricNullness K key, @ParametricNullness V value) {
+ public boolean put(@NullableDecl K key, @NullableDecl V value) {
return get(key).add(value);
}
@CanIgnoreReturnValue
@Override
- public boolean putAll(@ParametricNullness K key, Iterable<? extends V> values) {
+ public boolean putAll(@NullableDecl K key, Iterable<? extends V> values) {
checkNotNull(values);
// make sure we only call values.iterator() once
// and we only call get(key) if values is nonempty
@@ -102,14 +98,14 @@
@CanIgnoreReturnValue
@Override
- public Collection<V> replaceValues(@ParametricNullness K key, Iterable<? extends V> values) {
+ public Collection<V> replaceValues(@NullableDecl K key, Iterable<? extends V> values) {
checkNotNull(values);
Collection<V> result = removeAll(key);
putAll(key, values);
return result;
}
- @LazyInit @CheckForNull private transient Collection<Entry<K, V>> entries;
+ @NullableDecl private transient Collection<Entry<K, V>> entries;
@Override
public Collection<Entry<K, V>> entries() {
@@ -140,14 +136,14 @@
}
@Override
- public boolean equals(@CheckForNull Object obj) {
+ public boolean equals(@NullableDecl Object obj) {
return Sets.equalsImpl(this, obj);
}
}
abstract Iterator<Entry<K, V>> entryIterator();
- @LazyInit @CheckForNull private transient Set<K> keySet;
+ @NullableDecl private transient Set<K> keySet;
@Override
public Set<K> keySet() {
@@ -157,7 +153,7 @@
abstract Set<K> createKeySet();
- @LazyInit @CheckForNull private transient Multiset<K> keys;
+ @NullableDecl private transient Multiset<K> keys;
@Override
public Multiset<K> keys() {
@@ -167,7 +163,7 @@
abstract Multiset<K> createKeys();
- @LazyInit @CheckForNull private transient Collection<V> values;
+ @NullableDecl private transient Collection<V> values;
@Override
public Collection<V> values() {
@@ -190,7 +186,7 @@
}
@Override
- public boolean contains(@CheckForNull Object o) {
+ public boolean contains(@NullableDecl Object o) {
return AbstractMultimap.this.containsValue(o);
}
@@ -204,7 +200,7 @@
return Maps.valueIterator(entries().iterator());
}
- @LazyInit @CheckForNull private transient Map<K, Collection<V>> asMap;
+ @NullableDecl private transient Map<K, Collection<V>> asMap;
@Override
public Map<K, Collection<V>> asMap() {
@@ -217,7 +213,7 @@
// Comparison and hashing
@Override
- public boolean equals(@CheckForNull Object object) {
+ public boolean equals(@NullableDecl Object object) {
return Multimaps.equalsImpl(this, object);
}
diff --git a/android/guava/src/com/google/common/collect/AbstractMultiset.java b/android/guava/src/com/google/common/collect/AbstractMultiset.java
index 8203e44..c0a7f5e 100644
--- a/android/guava/src/com/google/common/collect/AbstractMultiset.java
+++ b/android/guava/src/com/google/common/collect/AbstractMultiset.java
@@ -26,8 +26,7 @@
import java.util.Collection;
import java.util.Iterator;
import java.util.Set;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* This class provides a skeletal implementation of the {@link Multiset} interface. A new multiset
@@ -43,9 +42,7 @@
* @author Louis Wasserman
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-abstract class AbstractMultiset<E extends @Nullable Object> extends AbstractCollection<E>
- implements Multiset<E> {
+abstract class AbstractMultiset<E> extends AbstractCollection<E> implements Multiset<E> {
// Query Operations
@Override
@@ -54,45 +51,45 @@
}
@Override
- public boolean contains(@CheckForNull Object element) {
+ public boolean contains(@NullableDecl Object element) {
return count(element) > 0;
}
// Modification Operations
@CanIgnoreReturnValue
@Override
- public final boolean add(@ParametricNullness E element) {
+ public final boolean add(@NullableDecl E element) {
add(element, 1);
return true;
}
@CanIgnoreReturnValue
@Override
- public int add(@ParametricNullness E element, int occurrences) {
+ public int add(@NullableDecl E element, int occurrences) {
throw new UnsupportedOperationException();
}
@CanIgnoreReturnValue
@Override
- public final boolean remove(@CheckForNull Object element) {
+ public final boolean remove(@NullableDecl Object element) {
return remove(element, 1) > 0;
}
@CanIgnoreReturnValue
@Override
- public int remove(@CheckForNull Object element, int occurrences) {
+ public int remove(@NullableDecl Object element, int occurrences) {
throw new UnsupportedOperationException();
}
@CanIgnoreReturnValue
@Override
- public int setCount(@ParametricNullness E element, int count) {
+ public int setCount(@NullableDecl E element, int count) {
return setCountImpl(this, element, count);
}
@CanIgnoreReturnValue
@Override
- public boolean setCount(@ParametricNullness E element, int oldCount, int newCount) {
+ public boolean setCount(@NullableDecl E element, int oldCount, int newCount) {
return setCountImpl(this, element, oldCount, newCount);
}
@@ -127,7 +124,7 @@
// Views
- @LazyInit @CheckForNull private transient Set<E> elementSet;
+ @LazyInit @NullableDecl private transient Set<E> elementSet;
@Override
public Set<E> elementSet() {
@@ -161,7 +158,7 @@
abstract Iterator<E> elementIterator();
- @LazyInit @CheckForNull private transient Set<Entry<E>> entrySet;
+ @LazyInit @NullableDecl private transient Set<Entry<E>> entrySet;
@Override
public Set<Entry<E>> entrySet() {
@@ -207,7 +204,7 @@
* and if, for each element, the two multisets have the same count.
*/
@Override
- public final boolean equals(@CheckForNull Object object) {
+ public final boolean equals(@NullableDecl Object object) {
return Multisets.equalsImpl(this, object);
}
diff --git a/android/guava/src/com/google/common/collect/AbstractNavigableMap.java b/android/guava/src/com/google/common/collect/AbstractNavigableMap.java
index 47048d0..e5259e8 100644
--- a/android/guava/src/com/google/common/collect/AbstractNavigableMap.java
+++ b/android/guava/src/com/google/common/collect/AbstractNavigableMap.java
@@ -24,8 +24,7 @@
import java.util.NoSuchElementException;
import java.util.Set;
import java.util.SortedMap;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* Skeletal implementation of {@link NavigableMap}.
@@ -33,40 +32,38 @@
* @author Louis Wasserman
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
-abstract class AbstractNavigableMap<K extends @Nullable Object, V extends @Nullable Object>
- extends IteratorBasedAbstractMap<K, V> implements NavigableMap<K, V> {
+abstract class AbstractNavigableMap<K, V> extends IteratorBasedAbstractMap<K, V>
+ implements NavigableMap<K, V> {
@Override
- @CheckForNull
- public abstract V get(@CheckForNull Object key);
+ @NullableDecl
+ public abstract V get(@NullableDecl Object key);
@Override
- @CheckForNull
+ @NullableDecl
public Entry<K, V> firstEntry() {
return Iterators.getNext(entryIterator(), null);
}
@Override
- @CheckForNull
+ @NullableDecl
public Entry<K, V> lastEntry() {
return Iterators.getNext(descendingEntryIterator(), null);
}
@Override
- @CheckForNull
+ @NullableDecl
public Entry<K, V> pollFirstEntry() {
return Iterators.pollNext(entryIterator());
}
@Override
- @CheckForNull
+ @NullableDecl
public Entry<K, V> pollLastEntry() {
return Iterators.pollNext(descendingEntryIterator());
}
@Override
- @ParametricNullness
public K firstKey() {
Entry<K, V> entry = firstEntry();
if (entry == null) {
@@ -77,7 +74,6 @@
}
@Override
- @ParametricNullness
public K lastKey() {
Entry<K, V> entry = lastEntry();
if (entry == null) {
@@ -88,67 +84,63 @@
}
@Override
- @CheckForNull
- public Entry<K, V> lowerEntry(@ParametricNullness K key) {
+ @NullableDecl
+ public Entry<K, V> lowerEntry(K key) {
return headMap(key, false).lastEntry();
}
@Override
- @CheckForNull
- public Entry<K, V> floorEntry(@ParametricNullness K key) {
+ @NullableDecl
+ public Entry<K, V> floorEntry(K key) {
return headMap(key, true).lastEntry();
}
@Override
- @CheckForNull
- public Entry<K, V> ceilingEntry(@ParametricNullness K key) {
+ @NullableDecl
+ public Entry<K, V> ceilingEntry(K key) {
return tailMap(key, true).firstEntry();
}
@Override
- @CheckForNull
- public Entry<K, V> higherEntry(@ParametricNullness K key) {
+ @NullableDecl
+ public Entry<K, V> higherEntry(K key) {
return tailMap(key, false).firstEntry();
}
@Override
- @CheckForNull
- public K lowerKey(@ParametricNullness K key) {
+ public K lowerKey(K key) {
return Maps.keyOrNull(lowerEntry(key));
}
@Override
- @CheckForNull
- public K floorKey(@ParametricNullness K key) {
+ public K floorKey(K key) {
return Maps.keyOrNull(floorEntry(key));
}
@Override
- @CheckForNull
- public K ceilingKey(@ParametricNullness K key) {
+ public K ceilingKey(K key) {
return Maps.keyOrNull(ceilingEntry(key));
}
@Override
- @CheckForNull
- public K higherKey(@ParametricNullness K key) {
+ public K higherKey(K key) {
return Maps.keyOrNull(higherEntry(key));
}
abstract Iterator<Entry<K, V>> descendingEntryIterator();
@Override
- public SortedMap<K, V> subMap(@ParametricNullness K fromKey, @ParametricNullness K toKey) {
+ public SortedMap<K, V> subMap(K fromKey, K toKey) {
return subMap(fromKey, true, toKey, false);
}
@Override
- public SortedMap<K, V> headMap(@ParametricNullness K toKey) {
+ public SortedMap<K, V> headMap(K toKey) {
return headMap(toKey, false);
}
@Override
- public SortedMap<K, V> tailMap(@ParametricNullness K fromKey) {
+ public SortedMap<K, V> tailMap(K fromKey) {
return tailMap(fromKey, true);
}
diff --git a/android/guava/src/com/google/common/collect/AbstractRangeSet.java b/android/guava/src/com/google/common/collect/AbstractRangeSet.java
index 032be3d..42ae893 100644
--- a/android/guava/src/com/google/common/collect/AbstractRangeSet.java
+++ b/android/guava/src/com/google/common/collect/AbstractRangeSet.java
@@ -15,7 +15,7 @@
package com.google.common.collect;
import com.google.common.annotations.GwtIncompatible;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* A skeletal implementation of {@code RangeSet}.
@@ -23,7 +23,6 @@
* @author Louis Wasserman
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
abstract class AbstractRangeSet<C extends Comparable> implements RangeSet<C> {
AbstractRangeSet() {}
@@ -33,7 +32,6 @@
}
@Override
- @CheckForNull
public abstract Range<C> rangeContaining(C value);
@Override
@@ -104,7 +102,7 @@
public abstract boolean encloses(Range<C> otherRange);
@Override
- public boolean equals(@CheckForNull Object obj) {
+ public boolean equals(@NullableDecl Object obj) {
if (obj == this) {
return true;
} else if (obj instanceof RangeSet) {
diff --git a/android/guava/src/com/google/common/collect/AbstractSequentialIterator.java b/android/guava/src/com/google/common/collect/AbstractSequentialIterator.java
index 172fe35..bda0692 100644
--- a/android/guava/src/com/google/common/collect/AbstractSequentialIterator.java
+++ b/android/guava/src/com/google/common/collect/AbstractSequentialIterator.java
@@ -18,7 +18,7 @@
import com.google.common.annotations.GwtCompatible;
import java.util.NoSuchElementException;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* This class provides a skeletal implementation of the {@code Iterator} interface for sequences
@@ -40,15 +40,14 @@
* @since 12.0 (in Guava as {@code AbstractLinkedIterator} since 8.0)
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
public abstract class AbstractSequentialIterator<T> extends UnmodifiableIterator<T> {
- @CheckForNull private T nextOrNull;
+ @NullableDecl 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(@CheckForNull T firstOrNull) {
+ protected AbstractSequentialIterator(@NullableDecl T firstOrNull) {
this.nextOrNull = firstOrNull;
}
@@ -57,7 +56,7 @@
* remain. This method is invoked during each call to {@link #next()} in order to compute the
* result of a <i>future</i> call to {@code next()}.
*/
- @CheckForNull
+ @NullableDecl
protected abstract T computeNext(T previous);
@Override
@@ -67,11 +66,13 @@
@Override
public final T next() {
- if (nextOrNull == null) {
+ if (!hasNext()) {
throw new NoSuchElementException();
}
- T oldNext = nextOrNull;
- nextOrNull = computeNext(oldNext);
- return oldNext;
+ try {
+ return nextOrNull;
+ } finally {
+ nextOrNull = computeNext(nextOrNull);
+ }
}
}
diff --git a/android/guava/src/com/google/common/collect/AbstractSetMultimap.java b/android/guava/src/com/google/common/collect/AbstractSetMultimap.java
index 90aa9dc..2779d1c 100644
--- a/android/guava/src/com/google/common/collect/AbstractSetMultimap.java
+++ b/android/guava/src/com/google/common/collect/AbstractSetMultimap.java
@@ -23,8 +23,7 @@
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* Basic implementation of the {@link SetMultimap} interface. It's a wrapper around {@link
@@ -34,9 +33,8 @@
* @author Jared Levy
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-abstract class AbstractSetMultimap<K extends @Nullable Object, V extends @Nullable Object>
- extends AbstractMapBasedMultimap<K, V> implements SetMultimap<K, V> {
+abstract class AbstractSetMultimap<K, V> extends AbstractMapBasedMultimap<K, V>
+ implements SetMultimap<K, V> {
/**
* Creates a new multimap that uses the provided map.
*
@@ -55,13 +53,12 @@
}
@Override
- <E extends @Nullable Object> Collection<E> unmodifiableCollectionSubclass(
- Collection<E> collection) {
+ <E> Collection<E> unmodifiableCollectionSubclass(Collection<E> collection) {
return Collections.unmodifiableSet((Set<E>) collection);
}
@Override
- Collection<V> wrapCollection(@ParametricNullness K key, Collection<V> collection) {
+ Collection<V> wrapCollection(K key, Collection<V> collection) {
return new WrappedSet(key, (Set<V>) collection);
}
@@ -74,7 +71,7 @@
* {@link Set}, instead of the {@link Collection} specified in the {@link Multimap} interface.
*/
@Override
- public Set<V> get(@ParametricNullness K key) {
+ public Set<V> get(@NullableDecl K key) {
return (Set<V>) super.get(key);
}
@@ -97,7 +94,7 @@
*/
@CanIgnoreReturnValue
@Override
- public Set<V> removeAll(@CheckForNull Object key) {
+ public Set<V> removeAll(@NullableDecl Object key) {
return (Set<V>) super.removeAll(key);
}
@@ -111,7 +108,7 @@
*/
@CanIgnoreReturnValue
@Override
- public Set<V> replaceValues(@ParametricNullness K key, Iterable<? extends V> values) {
+ public Set<V> replaceValues(@NullableDecl K key, Iterable<? extends V> values) {
return (Set<V>) super.replaceValues(key, values);
}
@@ -136,7 +133,7 @@
*/
@CanIgnoreReturnValue
@Override
- public boolean put(@ParametricNullness K key, @ParametricNullness V value) {
+ public boolean put(@NullableDecl K key, @NullableDecl V value) {
return super.put(key, value);
}
@@ -147,7 +144,7 @@
* Equality does not depend on the ordering of keys or values.
*/
@Override
- public boolean equals(@CheckForNull Object object) {
+ public boolean equals(@NullableDecl Object object) {
return super.equals(object);
}
diff --git a/android/guava/src/com/google/common/collect/AbstractSortedKeySortedSetMultimap.java b/android/guava/src/com/google/common/collect/AbstractSortedKeySortedSetMultimap.java
index 676936f..0ee6edb 100644
--- a/android/guava/src/com/google/common/collect/AbstractSortedKeySortedSetMultimap.java
+++ b/android/guava/src/com/google/common/collect/AbstractSortedKeySortedSetMultimap.java
@@ -21,7 +21,6 @@
import java.util.Set;
import java.util.SortedMap;
import java.util.SortedSet;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Basic implementation of a {@link SortedSetMultimap} with a sorted key set.
@@ -32,10 +31,7 @@
* @author Louis Wasserman
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-abstract class AbstractSortedKeySortedSetMultimap<
- K extends @Nullable Object, V extends @Nullable Object>
- extends AbstractSortedSetMultimap<K, V> {
+abstract class AbstractSortedKeySortedSetMultimap<K, V> extends AbstractSortedSetMultimap<K, V> {
AbstractSortedKeySortedSetMultimap(SortedMap<K, Collection<V>> map) {
super(map);
diff --git a/android/guava/src/com/google/common/collect/AbstractSortedMultiset.java b/android/guava/src/com/google/common/collect/AbstractSortedMultiset.java
index fd4fce2..091bb8c 100644
--- a/android/guava/src/com/google/common/collect/AbstractSortedMultiset.java
+++ b/android/guava/src/com/google/common/collect/AbstractSortedMultiset.java
@@ -21,8 +21,7 @@
import java.util.Comparator;
import java.util.Iterator;
import java.util.NavigableSet;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* This class provides a skeletal implementation of the {@link SortedMultiset} interface.
@@ -34,9 +33,7 @@
* @author Louis Wasserman
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
-abstract class AbstractSortedMultiset<E extends @Nullable Object> extends AbstractMultiset<E>
- implements SortedMultiset<E> {
+abstract class AbstractSortedMultiset<E> extends AbstractMultiset<E> implements SortedMultiset<E> {
@GwtTransient final Comparator<? super E> comparator;
// needed for serialization
@@ -65,21 +62,18 @@
}
@Override
- @CheckForNull
public Entry<E> firstEntry() {
Iterator<Entry<E>> entryIterator = entryIterator();
return entryIterator.hasNext() ? entryIterator.next() : null;
}
@Override
- @CheckForNull
public Entry<E> lastEntry() {
Iterator<Entry<E>> entryIterator = descendingEntryIterator();
return entryIterator.hasNext() ? entryIterator.next() : null;
}
@Override
- @CheckForNull
public Entry<E> pollFirstEntry() {
Iterator<Entry<E>> entryIterator = entryIterator();
if (entryIterator.hasNext()) {
@@ -92,7 +86,6 @@
}
@Override
- @CheckForNull
public Entry<E> pollLastEntry() {
Iterator<Entry<E>> entryIterator = descendingEntryIterator();
if (entryIterator.hasNext()) {
@@ -106,9 +99,9 @@
@Override
public SortedMultiset<E> subMultiset(
- @ParametricNullness E fromElement,
+ @NullableDecl E fromElement,
BoundType fromBoundType,
- @ParametricNullness E toElement,
+ @NullableDecl E toElement,
BoundType toBoundType) {
// These are checked elsewhere, but NullPointerTester wants them checked eagerly.
checkNotNull(fromBoundType);
@@ -122,7 +115,7 @@
return Multisets.iteratorImpl(descendingMultiset());
}
- @CheckForNull private transient SortedMultiset<E> descendingMultiset;
+ @NullableDecl private transient SortedMultiset<E> descendingMultiset;
@Override
public SortedMultiset<E> descendingMultiset() {
diff --git a/android/guava/src/com/google/common/collect/AbstractSortedSetMultimap.java b/android/guava/src/com/google/common/collect/AbstractSortedSetMultimap.java
index 3231613..6254a6e 100644
--- a/android/guava/src/com/google/common/collect/AbstractSortedSetMultimap.java
+++ b/android/guava/src/com/google/common/collect/AbstractSortedSetMultimap.java
@@ -23,8 +23,7 @@
import java.util.Map;
import java.util.NavigableSet;
import java.util.SortedSet;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* Basic implementation of the {@link SortedSetMultimap} interface. It's a wrapper around {@link
@@ -34,9 +33,8 @@
* @author Jared Levy
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-abstract class AbstractSortedSetMultimap<K extends @Nullable Object, V extends @Nullable Object>
- extends AbstractSetMultimap<K, V> implements SortedSetMultimap<K, V> {
+abstract class AbstractSortedSetMultimap<K, V> extends AbstractSetMultimap<K, V>
+ implements SortedSetMultimap<K, V> {
/**
* Creates a new multimap that uses the provided map.
*
@@ -55,8 +53,7 @@
}
@Override
- <E extends @Nullable Object> SortedSet<E> unmodifiableCollectionSubclass(
- Collection<E> collection) {
+ <E> SortedSet<E> unmodifiableCollectionSubclass(Collection<E> collection) {
if (collection instanceof NavigableSet) {
return Sets.unmodifiableNavigableSet((NavigableSet<E>) collection);
} else {
@@ -65,7 +62,7 @@
}
@Override
- Collection<V> wrapCollection(@ParametricNullness K key, Collection<V> collection) {
+ Collection<V> wrapCollection(K key, Collection<V> collection) {
if (collection instanceof NavigableSet) {
return new WrappedNavigableSet(key, (NavigableSet<V>) collection, null);
} else {
@@ -86,7 +83,7 @@
* Multimap} interface.
*/
@Override
- public SortedSet<V> get(@ParametricNullness K key) {
+ public SortedSet<V> get(@NullableDecl K key) {
return (SortedSet<V>) super.get(key);
}
@@ -99,7 +96,7 @@
*/
@CanIgnoreReturnValue
@Override
- public SortedSet<V> removeAll(@CheckForNull Object key) {
+ public SortedSet<V> removeAll(@NullableDecl Object key) {
return (SortedSet<V>) super.removeAll(key);
}
@@ -115,7 +112,7 @@
*/
@CanIgnoreReturnValue
@Override
- public SortedSet<V> replaceValues(@ParametricNullness K key, Iterable<? extends V> values) {
+ public SortedSet<V> replaceValues(@NullableDecl K key, Iterable<? extends V> values) {
return (SortedSet<V>) super.replaceValues(key, values);
}
diff --git a/android/guava/src/com/google/common/collect/AbstractTable.java b/android/guava/src/com/google/common/collect/AbstractTable.java
index fe1d4e7..7cb34a6 100644
--- a/android/guava/src/com/google/common/collect/AbstractTable.java
+++ b/android/guava/src/com/google/common/collect/AbstractTable.java
@@ -24,8 +24,7 @@
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* Skeletal, implementation-agnostic implementation of the {@link Table} interface.
@@ -33,18 +32,15 @@
* @author Louis Wasserman
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-abstract class AbstractTable<
- R extends @Nullable Object, C extends @Nullable Object, V extends @Nullable Object>
- implements Table<R, C, V> {
+abstract class AbstractTable<R, C, V> implements Table<R, C, V> {
@Override
- public boolean containsRow(@CheckForNull Object rowKey) {
+ public boolean containsRow(@NullableDecl Object rowKey) {
return Maps.safeContainsKey(rowMap(), rowKey);
}
@Override
- public boolean containsColumn(@CheckForNull Object columnKey) {
+ public boolean containsColumn(@NullableDecl Object columnKey) {
return Maps.safeContainsKey(columnMap(), columnKey);
}
@@ -59,7 +55,7 @@
}
@Override
- public boolean containsValue(@CheckForNull Object value) {
+ public boolean containsValue(@NullableDecl Object value) {
for (Map<C, V> row : rowMap().values()) {
if (row.containsValue(value)) {
return true;
@@ -69,14 +65,13 @@
}
@Override
- public boolean contains(@CheckForNull Object rowKey, @CheckForNull Object columnKey) {
+ public boolean contains(@NullableDecl Object rowKey, @NullableDecl Object columnKey) {
Map<C, V> row = Maps.safeGet(rowMap(), rowKey);
return row != null && Maps.safeContainsKey(row, columnKey);
}
@Override
- @CheckForNull
- public V get(@CheckForNull Object rowKey, @CheckForNull Object columnKey) {
+ public V get(@NullableDecl Object rowKey, @NullableDecl Object columnKey) {
Map<C, V> row = Maps.safeGet(rowMap(), rowKey);
return (row == null) ? null : Maps.safeGet(row, columnKey);
}
@@ -93,17 +88,14 @@
@CanIgnoreReturnValue
@Override
- @CheckForNull
- public V remove(@CheckForNull Object rowKey, @CheckForNull Object columnKey) {
+ public V remove(@NullableDecl Object rowKey, @NullableDecl Object columnKey) {
Map<C, V> row = Maps.safeGet(rowMap(), rowKey);
return (row == null) ? null : Maps.safeRemove(row, columnKey);
}
@CanIgnoreReturnValue
@Override
- @CheckForNull
- public V put(
- @ParametricNullness R rowKey, @ParametricNullness C columnKey, @ParametricNullness V value) {
+ public V put(R rowKey, C columnKey, V value) {
return row(rowKey).put(columnKey, value);
}
@@ -114,7 +106,7 @@
}
}
- @LazyInit @CheckForNull private transient Set<Cell<R, C, V>> cellSet;
+ @LazyInit @NullableDecl private transient Set<Cell<R, C, V>> cellSet;
@Override
public Set<Cell<R, C, V>> cellSet() {
@@ -131,7 +123,7 @@
@WeakOuter
class CellSet extends AbstractSet<Cell<R, C, V>> {
@Override
- public boolean contains(@CheckForNull Object o) {
+ public boolean contains(Object o) {
if (o instanceof Cell) {
Cell<?, ?, ?> cell = (Cell<?, ?, ?>) o;
Map<C, V> row = Maps.safeGet(rowMap(), cell.getRowKey());
@@ -143,7 +135,7 @@
}
@Override
- public boolean remove(@CheckForNull Object o) {
+ public boolean remove(@NullableDecl Object o) {
if (o instanceof Cell) {
Cell<?, ?, ?> cell = (Cell<?, ?, ?>) o;
Map<C, V> row = Maps.safeGet(rowMap(), cell.getRowKey());
@@ -170,7 +162,7 @@
}
}
- @LazyInit @CheckForNull private transient Collection<V> values;
+ @LazyInit @NullableDecl private transient Collection<V> values;
@Override
public Collection<V> values() {
@@ -185,7 +177,6 @@
Iterator<V> valuesIterator() {
return new TransformedIterator<Cell<R, C, V>, V>(cellSet().iterator()) {
@Override
- @ParametricNullness
V transform(Cell<R, C, V> cell) {
return cell.getValue();
}
@@ -200,7 +191,7 @@
}
@Override
- public boolean contains(@CheckForNull Object o) {
+ public boolean contains(Object o) {
return containsValue(o);
}
@@ -216,7 +207,7 @@
}
@Override
- public boolean equals(@CheckForNull Object obj) {
+ public boolean equals(@NullableDecl Object obj) {
return Tables.equalsImpl(this, obj);
}
diff --git a/android/guava/src/com/google/common/collect/AllEqualOrdering.java b/android/guava/src/com/google/common/collect/AllEqualOrdering.java
index f6ca6fa..bbcd19e 100644
--- a/android/guava/src/com/google/common/collect/AllEqualOrdering.java
+++ b/android/guava/src/com/google/common/collect/AllEqualOrdering.java
@@ -19,8 +19,7 @@
import com.google.common.annotations.GwtCompatible;
import java.io.Serializable;
import java.util.List;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* An ordering that treats all references as equals, even nulls.
@@ -28,29 +27,27 @@
* @author Emily Soldal
*/
@GwtCompatible(serializable = true)
-@ElementTypesAreNonnullByDefault
-final class AllEqualOrdering extends Ordering<@Nullable Object> implements Serializable {
+final class AllEqualOrdering extends Ordering<Object> implements Serializable {
static final AllEqualOrdering INSTANCE = new AllEqualOrdering();
@Override
- public int compare(@CheckForNull Object left, @CheckForNull Object right) {
+ public int compare(@NullableDecl Object left, @NullableDecl Object right) {
return 0;
}
@Override
- public <E extends @Nullable Object> List<E> sortedCopy(Iterable<E> iterable) {
+ public <E> List<E> sortedCopy(Iterable<E> iterable) {
return Lists.newArrayList(iterable);
}
@Override
- @SuppressWarnings("nullness") // unsafe: see supertype
- public <E extends @Nullable Object> ImmutableList<E> immutableSortedCopy(Iterable<E> iterable) {
+ public <E> ImmutableList<E> immutableSortedCopy(Iterable<E> iterable) {
return ImmutableList.copyOf(iterable);
}
@SuppressWarnings("unchecked")
@Override
- public <S extends @Nullable Object> Ordering<S> reverse() {
+ public <S> Ordering<S> reverse() {
return (Ordering<S>) this;
}
diff --git a/android/guava/src/com/google/common/collect/ArrayListMultimap.java b/android/guava/src/com/google/common/collect/ArrayListMultimap.java
index 33f4c75..1faf476 100644
--- a/android/guava/src/com/google/common/collect/ArrayListMultimap.java
+++ b/android/guava/src/com/google/common/collect/ArrayListMultimap.java
@@ -29,7 +29,6 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Implementation of {@code Multimap} that uses an {@code ArrayList} to store the values for a given
@@ -60,8 +59,7 @@
* @since 2.0
*/
@GwtCompatible(serializable = true, emulated = true)
-@ElementTypesAreNonnullByDefault
-public final class ArrayListMultimap<K extends @Nullable Object, V extends @Nullable Object>
+public final class ArrayListMultimap<K, V>
extends ArrayListMultimapGwtSerializationDependencies<K, V> {
// Default from ArrayList
private static final int DEFAULT_VALUES_PER_KEY = 3;
@@ -74,8 +72,7 @@
* <p>This method will soon be deprecated in favor of {@code
* MultimapBuilder.hashKeys().arrayListValues().build()}.
*/
- public static <K extends @Nullable Object, V extends @Nullable Object>
- ArrayListMultimap<K, V> create() {
+ public static <K, V> ArrayListMultimap<K, V> create() {
return new ArrayListMultimap<>();
}
@@ -91,8 +88,7 @@
* @throws IllegalArgumentException if {@code expectedKeys} or {@code expectedValuesPerKey} is
* negative
*/
- public static <K extends @Nullable Object, V extends @Nullable Object>
- ArrayListMultimap<K, V> create(int expectedKeys, int expectedValuesPerKey) {
+ public static <K, V> ArrayListMultimap<K, V> create(int expectedKeys, int expectedValuesPerKey) {
return new ArrayListMultimap<>(expectedKeys, expectedValuesPerKey);
}
@@ -104,8 +100,7 @@
*
* @param multimap the multimap whose contents are copied to this multimap
*/
- public static <K extends @Nullable Object, V extends @Nullable Object>
- ArrayListMultimap<K, V> create(Multimap<? extends K, ? extends V> multimap) {
+ public static <K, V> ArrayListMultimap<K, V> create(Multimap<? extends K, ? extends V> multimap) {
return new ArrayListMultimap<>(multimap);
}
diff --git a/android/guava/src/com/google/common/collect/ArrayTable.java b/android/guava/src/com/google/common/collect/ArrayTable.java
index ebc9fa0..c9af17f 100644
--- a/android/guava/src/com/google/common/collect/ArrayTable.java
+++ b/android/guava/src/com/google/common/collect/ArrayTable.java
@@ -19,7 +19,6 @@
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkElementIndex;
import static com.google.common.base.Preconditions.checkNotNull;
-import static java.util.Collections.emptyMap;
import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtCompatible;
@@ -27,7 +26,6 @@
import com.google.common.base.Objects;
import com.google.common.collect.Maps.IteratorBasedAbstractMap;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
-import com.google.errorprone.annotations.DoNotCall;
import com.google.j2objc.annotations.WeakOuter;
import java.io.Serializable;
import java.lang.reflect.Array;
@@ -36,22 +34,11 @@
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* Fixed-size {@link Table} implementation backed by a two-dimensional array.
*
- * <p><b>Warning:</b> {@code ArrayTable} is rarely the {@link Table} implementation you want. First,
- * it requires that the complete universe of rows and columns be specified at construction time.
- * Second, it is always backed by an array large enough to hold a value for every possible
- * combination of row and column keys. (This is rarely optimal unless the table is extremely dense.)
- * Finally, every possible combination of row and column keys is always considered to have a value
- * associated with it: It is not possible to "remove" a value, only to replace it with {@code null},
- * which will still appear when iterating over the table's contents in a foreach loop or a call to a
- * null-hostile method like {@link ImmutableTable#copyOf}. For alternatives, please see <a
- * href="https://github.com/google/guava/wiki/NewCollectionTypesExplained#table">the wiki</a>.
- *
* <p>The allowed row and column keys must be supplied when the table is created. The table always
* contains a mapping for every row key / column pair. The value corresponding to a given row and
* column is null unless another value is provided.
@@ -90,9 +77,7 @@
*/
@Beta
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
-public final class ArrayTable<R, C, V> extends AbstractTable<R, C, @Nullable V>
- implements Serializable {
+public final class ArrayTable<R, C, V> extends AbstractTable<R, C, V> implements Serializable {
/**
* Creates an {@code ArrayTable} filled with {@code null}.
@@ -132,8 +117,8 @@
*
* @throws NullPointerException if {@code table} has a null key
*/
- public static <R, C, V> ArrayTable<R, C, V> create(Table<R, C, ? extends @Nullable V> table) {
- return (table instanceof ArrayTable)
+ public static <R, C, V> ArrayTable<R, C, V> create(Table<R, C, V> table) {
+ return (table instanceof ArrayTable<?, ?, ?>)
? new ArrayTable<R, C, V>((ArrayTable<R, C, V>) table)
: new ArrayTable<R, C, V>(table);
}
@@ -144,7 +129,7 @@
// TODO(jlevy): Add getters returning rowKeyToIndex and columnKeyToIndex?
private final ImmutableMap<R, Integer> rowKeyToIndex;
private final ImmutableMap<C, Integer> columnKeyToIndex;
- private final @Nullable V[][] array;
+ private final V[][] array;
private ArrayTable(Iterable<? extends R> rowKeys, Iterable<? extends C> columnKeys) {
this.rowList = ImmutableList.copyOf(rowKeys);
@@ -161,14 +146,13 @@
columnKeyToIndex = Maps.indexMap(columnList);
@SuppressWarnings("unchecked")
- @Nullable
- V[][] tmpArray = (@Nullable V[][]) new Object[rowList.size()][columnList.size()];
+ V[][] tmpArray = (V[][]) new Object[rowList.size()][columnList.size()];
array = tmpArray;
// Necessary because in GWT the arrays are initialized with "undefined" instead of null.
eraseAll();
}
- private ArrayTable(Table<R, C, ? extends @Nullable V> table) {
+ private ArrayTable(Table<R, C, V> table) {
this(table.rowKeySet(), table.columnKeySet());
putAll(table);
}
@@ -179,16 +163,14 @@
rowKeyToIndex = table.rowKeyToIndex;
columnKeyToIndex = table.columnKeyToIndex;
@SuppressWarnings("unchecked")
- @Nullable
- V[][] copy = (@Nullable V[][]) new Object[rowList.size()][columnList.size()];
+ V[][] copy = (V[][]) new Object[rowList.size()][columnList.size()];
array = copy;
for (int i = 0; i < rowList.size(); i++) {
System.arraycopy(table.array[i], 0, copy[i], 0, table.array[i].length);
}
}
- private abstract static class ArrayMap<K, V extends @Nullable Object>
- extends IteratorBasedAbstractMap<K, V> {
+ private abstract static class ArrayMap<K, V> extends IteratorBasedAbstractMap<K, V> {
private final ImmutableMap<K, Integer> keyIndex;
private ArrayMap(ImmutableMap<K, Integer> keyIndex) {
@@ -206,11 +188,11 @@
abstract String getKeyRole();
- @ParametricNullness
+ @NullableDecl
abstract V getValue(int index);
- @ParametricNullness
- abstract V setValue(int index, @ParametricNullness V newValue);
+ @NullableDecl
+ abstract V setValue(int index, V newValue);
@Override
public int size() {
@@ -231,14 +213,12 @@
}
@Override
- @ParametricNullness
public V getValue() {
return ArrayMap.this.getValue(index);
}
@Override
- @ParametricNullness
- public V setValue(@ParametricNullness V value) {
+ public V setValue(V value) {
return ArrayMap.this.setValue(index, value);
}
};
@@ -257,13 +237,12 @@
// TODO(lowasser): consider an optimized values() implementation
@Override
- public boolean containsKey(@CheckForNull Object key) {
+ public boolean containsKey(@NullableDecl Object key) {
return keyIndex.containsKey(key);
}
- @CheckForNull
@Override
- public V get(@CheckForNull Object key) {
+ public V get(@NullableDecl Object key) {
Integer index = keyIndex.get(key);
if (index == null) {
return null;
@@ -273,8 +252,7 @@
}
@Override
- @CheckForNull
- public V put(K key, @ParametricNullness V value) {
+ public V put(K key, V value) {
Integer index = keyIndex.get(key);
if (index == null) {
throw new IllegalArgumentException(
@@ -284,8 +262,7 @@
}
@Override
- @CheckForNull
- public V remove(@CheckForNull Object key) {
+ public V remove(Object key) {
throw new UnsupportedOperationException();
}
@@ -323,7 +300,6 @@
* or equal to the number of allowed row keys, or {@code columnIndex} is greater than or equal
* to the number of allowed column keys
*/
- @CheckForNull
public V at(int rowIndex, int columnIndex) {
// In GWT array access never throws IndexOutOfBoundsException.
checkElementIndex(rowIndex, rowList.size());
@@ -345,8 +321,7 @@
* to the number of allowed column keys
*/
@CanIgnoreReturnValue
- @CheckForNull
- public V set(int rowIndex, int columnIndex, @CheckForNull V value) {
+ public V set(int rowIndex, int columnIndex, @NullableDecl V value) {
// In GWT array access never throws IndexOutOfBoundsException.
checkElementIndex(rowIndex, rowList.size());
checkElementIndex(columnIndex, columnList.size());
@@ -365,10 +340,9 @@
* @param valueClass class of values stored in the returned array
*/
@GwtIncompatible // reflection
- public @Nullable V[][] toArray(Class<V> valueClass) {
+ public V[][] toArray(Class<V> valueClass) {
@SuppressWarnings("unchecked") // TODO: safe?
- @Nullable
- V[][] copy = (@Nullable V[][]) Array.newInstance(valueClass, rowList.size(), columnList.size());
+ V[][] copy = (V[][]) Array.newInstance(valueClass, rowList.size(), columnList.size());
for (int i = 0; i < rowList.size(); i++) {
System.arraycopy(array[i], 0, copy[i], 0, array[i].length);
}
@@ -381,7 +355,6 @@
* @throws UnsupportedOperationException always
* @deprecated Use {@link #eraseAll}
*/
- @DoNotCall("Always throws UnsupportedOperationException")
@Override
@Deprecated
public void clear() {
@@ -390,7 +363,7 @@
/** Associates the value {@code null} with every pair of allowed row and column keys. */
public void eraseAll() {
- for (@Nullable V[] row : array) {
+ for (V[] row : array) {
Arrays.fill(row, null);
}
}
@@ -400,7 +373,7 @@
* constructed.
*/
@Override
- public boolean contains(@CheckForNull Object rowKey, @CheckForNull Object columnKey) {
+ public boolean contains(@NullableDecl Object rowKey, @NullableDecl Object columnKey) {
return containsRow(rowKey) && containsColumn(columnKey);
}
@@ -409,7 +382,7 @@
* table was constructed.
*/
@Override
- public boolean containsColumn(@CheckForNull Object columnKey) {
+ public boolean containsColumn(@NullableDecl Object columnKey) {
return columnKeyToIndex.containsKey(columnKey);
}
@@ -418,13 +391,13 @@
* constructed.
*/
@Override
- public boolean containsRow(@CheckForNull Object rowKey) {
+ public boolean containsRow(@NullableDecl Object rowKey) {
return rowKeyToIndex.containsKey(rowKey);
}
@Override
- public boolean containsValue(@CheckForNull Object value) {
- for (@Nullable V[] row : array) {
+ public boolean containsValue(@NullableDecl Object value) {
+ for (V[] row : array) {
for (V element : row) {
if (Objects.equal(value, element)) {
return true;
@@ -435,8 +408,7 @@
}
@Override
- @CheckForNull
- public V get(@CheckForNull Object rowKey, @CheckForNull Object columnKey) {
+ public V get(@NullableDecl Object rowKey, @NullableDecl Object columnKey) {
Integer rowIndex = rowKeyToIndex.get(rowKey);
Integer columnIndex = columnKeyToIndex.get(columnKey);
return (rowIndex == null || columnIndex == null) ? null : at(rowIndex, columnIndex);
@@ -458,8 +430,7 @@
*/
@CanIgnoreReturnValue
@Override
- @CheckForNull
- public V put(R rowKey, C columnKey, @CheckForNull V value) {
+ public V put(R rowKey, C columnKey, @NullableDecl V value) {
checkNotNull(rowKey);
checkNotNull(columnKey);
Integer rowIndex = rowKeyToIndex.get(rowKey);
@@ -485,7 +456,7 @@
* in {@link #rowKeySet()} or {@link #columnKeySet()}
*/
@Override
- public void putAll(Table<? extends R, ? extends C, ? extends @Nullable V> table) {
+ public void putAll(Table<? extends R, ? extends C, ? extends V> table) {
super.putAll(table);
}
@@ -495,12 +466,10 @@
* @throws UnsupportedOperationException always
* @deprecated Use {@link #erase}
*/
- @DoNotCall("Always throws UnsupportedOperationException")
@CanIgnoreReturnValue
@Override
@Deprecated
- @CheckForNull
- public V remove(@CheckForNull Object rowKey, @CheckForNull Object columnKey) {
+ public V remove(Object rowKey, Object columnKey) {
throw new UnsupportedOperationException();
}
@@ -518,8 +487,7 @@
* for the keys
*/
@CanIgnoreReturnValue
- @CheckForNull
- public V erase(@CheckForNull Object rowKey, @CheckForNull Object columnKey) {
+ public V erase(@NullableDecl Object rowKey, @NullableDecl Object columnKey) {
Integer rowIndex = rowKeyToIndex.get(rowKey);
Integer columnIndex = columnKeyToIndex.get(columnKey);
if (rowIndex == null || columnIndex == null) {
@@ -547,22 +515,22 @@
* @return set of table cells consisting of row key / column key / value triplets
*/
@Override
- public Set<Cell<R, C, @Nullable V>> cellSet() {
+ public Set<Cell<R, C, V>> cellSet() {
return super.cellSet();
}
@Override
- Iterator<Cell<R, C, @Nullable V>> cellIterator() {
- return new AbstractIndexedListIterator<Cell<R, C, @Nullable V>>(size()) {
+ Iterator<Cell<R, C, V>> cellIterator() {
+ return new AbstractIndexedListIterator<Cell<R, C, V>>(size()) {
@Override
- protected Cell<R, C, @Nullable V> get(final int index) {
+ protected Cell<R, C, V> get(final int index) {
return getCell(index);
}
};
}
- private Cell<R, C, @Nullable V> getCell(final int index) {
- return new Tables.AbstractCell<R, C, @Nullable V>() {
+ private Cell<R, C, V> getCell(final int index) {
+ return new Tables.AbstractCell<R, C, V>() {
final int rowIndex = index / columnList.size();
final int columnIndex = index % columnList.size();
@@ -577,14 +545,12 @@
}
@Override
- @CheckForNull
public V getValue() {
return at(rowIndex, columnIndex);
}
};
}
- @CheckForNull
private V getValue(int index) {
int rowIndex = index / columnList.size();
int columnIndex = index % columnList.size();
@@ -603,17 +569,13 @@
* @return the corresponding map from row keys to values
*/
@Override
- public Map<R, @Nullable V> column(C columnKey) {
+ public Map<R, V> column(C columnKey) {
checkNotNull(columnKey);
Integer columnIndex = columnKeyToIndex.get(columnKey);
- if (columnIndex == null) {
- return emptyMap();
- } else {
- return new Column(columnIndex);
- }
+ return (columnIndex == null) ? ImmutableMap.<R, V>of() : new Column(columnIndex);
}
- private class Column extends ArrayMap<R, @Nullable V> {
+ private class Column extends ArrayMap<R, V> {
final int columnIndex;
Column(int columnIndex) {
@@ -627,14 +589,12 @@
}
@Override
- @CheckForNull
V getValue(int index) {
return at(index, columnIndex);
}
@Override
- @CheckForNull
- V setValue(int index, @CheckForNull V newValue) {
+ V setValue(int index, V newValue) {
return set(index, columnIndex, newValue);
}
}
@@ -650,16 +610,16 @@
return columnKeyToIndex.keySet();
}
- @CheckForNull private transient ColumnMap columnMap;
+ @NullableDecl private transient ColumnMap columnMap;
@Override
- public Map<C, Map<R, @Nullable V>> columnMap() {
+ public Map<C, Map<R, V>> columnMap() {
ColumnMap map = columnMap;
return (map == null) ? columnMap = new ColumnMap() : map;
}
@WeakOuter
- private class ColumnMap extends ArrayMap<C, Map<R, @Nullable V>> {
+ private class ColumnMap extends ArrayMap<C, Map<R, V>> {
private ColumnMap() {
super(columnKeyToIndex);
}
@@ -670,18 +630,17 @@
}
@Override
- Map<R, @Nullable V> getValue(int index) {
+ Map<R, V> getValue(int index) {
return new Column(index);
}
@Override
- Map<R, @Nullable V> setValue(int index, Map<R, @Nullable V> newValue) {
+ Map<R, V> setValue(int index, Map<R, V> newValue) {
throw new UnsupportedOperationException();
}
@Override
- @CheckForNull
- public Map<R, @Nullable V> put(C key, Map<R, @Nullable V> value) {
+ public Map<R, V> put(C key, Map<R, V> value) {
throw new UnsupportedOperationException();
}
}
@@ -698,17 +657,13 @@
* @return the corresponding map from column keys to values
*/
@Override
- public Map<C, @Nullable V> row(R rowKey) {
+ public Map<C, V> row(R rowKey) {
checkNotNull(rowKey);
Integer rowIndex = rowKeyToIndex.get(rowKey);
- if (rowIndex == null) {
- return emptyMap();
- } else {
- return new Row(rowIndex);
- }
+ return (rowIndex == null) ? ImmutableMap.<C, V>of() : new Row(rowIndex);
}
- private class Row extends ArrayMap<C, @Nullable V> {
+ private class Row extends ArrayMap<C, V> {
final int rowIndex;
Row(int rowIndex) {
@@ -722,14 +677,12 @@
}
@Override
- @CheckForNull
V getValue(int index) {
return at(rowIndex, index);
}
@Override
- @CheckForNull
- V setValue(int index, @CheckForNull V newValue) {
+ V setValue(int index, V newValue) {
return set(rowIndex, index, newValue);
}
}
@@ -745,16 +698,16 @@
return rowKeyToIndex.keySet();
}
- @CheckForNull private transient RowMap rowMap;
+ @NullableDecl private transient RowMap rowMap;
@Override
- public Map<R, Map<C, @Nullable V>> rowMap() {
+ public Map<R, Map<C, V>> rowMap() {
RowMap map = rowMap;
return (map == null) ? rowMap = new RowMap() : map;
}
@WeakOuter
- private class RowMap extends ArrayMap<R, Map<C, @Nullable V>> {
+ private class RowMap extends ArrayMap<R, Map<C, V>> {
private RowMap() {
super(rowKeyToIndex);
}
@@ -765,18 +718,17 @@
}
@Override
- Map<C, @Nullable V> getValue(int index) {
+ Map<C, V> getValue(int index) {
return new Row(index);
}
@Override
- Map<C, @Nullable V> setValue(int index, Map<C, @Nullable V> newValue) {
+ Map<C, V> setValue(int index, Map<C, V> newValue) {
throw new UnsupportedOperationException();
}
@Override
- @CheckForNull
- public Map<C, @Nullable V> put(R key, Map<C, @Nullable V> value) {
+ public Map<C, V> put(R key, Map<C, V> value) {
throw new UnsupportedOperationException();
}
}
@@ -791,15 +743,14 @@
* @return collection of values
*/
@Override
- public Collection<@Nullable V> values() {
+ public Collection<V> values() {
return super.values();
}
@Override
- Iterator<@Nullable V> valuesIterator() {
- return new AbstractIndexedListIterator<@Nullable V>(size()) {
+ Iterator<V> valuesIterator() {
+ return new AbstractIndexedListIterator<V>(size()) {
@Override
- @CheckForNull
protected V get(int index) {
return getValue(index);
}
diff --git a/android/guava/src/com/google/common/collect/BaseImmutableMultimap.java b/android/guava/src/com/google/common/collect/BaseImmutableMultimap.java
index 2e69c2a..6ebdf14 100644
--- a/android/guava/src/com/google/common/collect/BaseImmutableMultimap.java
+++ b/android/guava/src/com/google/common/collect/BaseImmutableMultimap.java
@@ -22,5 +22,4 @@
* retaining additional implementation details of {@link ImmutableMultimap}.
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
abstract class BaseImmutableMultimap<K, V> extends AbstractMultimap<K, V> {}
diff --git a/android/guava/src/com/google/common/collect/BiMap.java b/android/guava/src/com/google/common/collect/BiMap.java
index 12eb4e3..0fd75c0 100644
--- a/android/guava/src/com/google/common/collect/BiMap.java
+++ b/android/guava/src/com/google/common/collect/BiMap.java
@@ -20,8 +20,7 @@
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import java.util.Map;
import java.util.Set;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* A bimap (or "bidirectional map") is a map that preserves the uniqueness of its values as well as
@@ -29,14 +28,13 @@
* bimap containing the same entries as this bimap but with reversed keys and values.
*
* <p>See the Guava User Guide article on <a href=
- * "https://github.com/google/guava/wiki/NewCollectionTypesExplained#bimap">{@code BiMap}</a>.
+ * "https://github.com/google/guava/wiki/NewCollectionTypesExplained#bimap"> {@code BiMap}</a>.
*
* @author Kevin Bourrillion
* @since 2.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-public interface BiMap<K extends @Nullable Object, V extends @Nullable Object> extends Map<K, V> {
+public interface BiMap<K, V> extends Map<K, V> {
// Modification Operations
/**
@@ -48,8 +46,8 @@
*/
@CanIgnoreReturnValue
@Override
- @CheckForNull
- V put(@ParametricNullness K key, @ParametricNullness V value);
+ @NullableDecl
+ V put(@NullableDecl K key, @NullableDecl V value);
/**
* An alternate form of {@code put} that silently removes any existing entry with the value {@code
@@ -64,14 +62,12 @@
*
* @param key the key with which the specified value is to be associated
* @param value the value to be associated with the specified key
- * @return the value that was previously associated with the key, or {@code null} if there was no
- * previous entry. (If the bimap contains null values, then {@code forcePut}, like {@code
- * put}, returns {@code null} both if the key is absent and if it is present with a null
- * value.)
+ * @return the value which was previously associated with the key, which may be {@code null}, or
+ * {@code null} if there was no previous entry
*/
@CanIgnoreReturnValue
- @CheckForNull
- V forcePut(@ParametricNullness K key, @ParametricNullness V value);
+ @NullableDecl
+ V forcePut(@NullableDecl K key, @NullableDecl V value);
// Bulk Operations
diff --git a/android/guava/src/com/google/common/collect/BoundType.java b/android/guava/src/com/google/common/collect/BoundType.java
index 00ac08c..ce03802 100644
--- a/android/guava/src/com/google/common/collect/BoundType.java
+++ b/android/guava/src/com/google/common/collect/BoundType.java
@@ -24,7 +24,6 @@
* @since 10.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
public enum BoundType {
/** The endpoint value <i>is not</i> considered part of the set ("exclusive"). */
OPEN(false),
@@ -40,4 +39,8 @@
static BoundType forBoolean(boolean inclusive) {
return inclusive ? CLOSED : OPEN;
}
+
+ BoundType flip() {
+ return forBoolean(!inclusive);
+ }
}
diff --git a/android/guava/src/com/google/common/collect/ByFunctionOrdering.java b/android/guava/src/com/google/common/collect/ByFunctionOrdering.java
index 43ebddd..9e8671b 100644
--- a/android/guava/src/com/google/common/collect/ByFunctionOrdering.java
+++ b/android/guava/src/com/google/common/collect/ByFunctionOrdering.java
@@ -22,17 +22,14 @@
import com.google.common.base.Function;
import com.google.common.base.Objects;
import java.io.Serializable;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* An ordering that orders elements by applying an order to the result of a function on those
* elements.
*/
@GwtCompatible(serializable = true)
-@ElementTypesAreNonnullByDefault
-final class ByFunctionOrdering<F extends @Nullable Object, T extends @Nullable Object>
- extends Ordering<F> implements Serializable {
+final class ByFunctionOrdering<F, T> extends Ordering<F> implements Serializable {
final Function<F, ? extends T> function;
final Ordering<T> ordering;
@@ -42,12 +39,12 @@
}
@Override
- public int compare(@ParametricNullness F left, @ParametricNullness F right) {
+ public int compare(F left, F right) {
return ordering.compare(function.apply(left), function.apply(right));
}
@Override
- public boolean equals(@CheckForNull Object object) {
+ public boolean equals(@NullableDecl Object object) {
if (object == this) {
return true;
}
diff --git a/android/guava/src/com/google/common/collect/CartesianList.java b/android/guava/src/com/google/common/collect/CartesianList.java
index 475b3f2..63c7f1a 100644
--- a/android/guava/src/com/google/common/collect/CartesianList.java
+++ b/android/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 javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* Implementation of {@link Lists#cartesianProduct(List)}.
@@ -30,7 +30,6 @@
* @author Louis Wasserman
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
final class CartesianList<E> extends AbstractList<List<E>> implements RandomAccess {
private final transient ImmutableList<List<E>> axes;
@@ -68,7 +67,7 @@
}
@Override
- public int indexOf(@CheckForNull Object o) {
+ public int indexOf(Object o) {
if (!(o instanceof List)) {
return -1;
}
@@ -90,7 +89,7 @@
}
@Override
- public int lastIndexOf(@CheckForNull Object o) {
+ public int lastIndexOf(Object o) {
if (!(o instanceof List)) {
return -1;
}
@@ -141,7 +140,7 @@
}
@Override
- public boolean contains(@CheckForNull Object object) {
+ public boolean contains(@NullableDecl Object object) {
if (!(object instanceof List)) {
return false;
}
diff --git a/android/guava/src/com/google/common/collect/ClassToInstanceMap.java b/android/guava/src/com/google/common/collect/ClassToInstanceMap.java
index 9bd826f..8d454c0 100644
--- a/android/guava/src/com/google/common/collect/ClassToInstanceMap.java
+++ b/android/guava/src/com/google/common/collect/ClassToInstanceMap.java
@@ -20,7 +20,7 @@
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import com.google.errorprone.annotations.DoNotMock;
import java.util.Map;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* A map, each entry of which maps a Java <a href="http://tinyurl.com/2cmwkz">raw type</a> to an
@@ -30,19 +30,8 @@
* <p>Like any other {@code Map<Class, Object>}, this map may contain entries for primitive types,
* and a primitive type and its corresponding wrapper type may map to different values.
*
- * <p>This class's support for {@code null} requires some explanation: From release 31.0 onward,
- * Guava specifies the nullness of its types through annotations. In the case of {@code
- * ClassToInstanceMap}, it specifies that both the key and value types are restricted to
- * non-nullable types. This specification is reasonable for <i>keys</i>, which must be non-null
- * classes. This is in contrast to the specification for <i>values</i>: Null values <i>are</i>
- * supported by the implementation {@link MutableClassToInstanceMap}, even though that
- * implementation and this interface specify otherwise. Thus, if you use a nullness checker, you can
- * safely suppress any warnings it produces when you write null values into a {@code
- * MutableClassToInstanceMap}. Just be sure to be prepared for null values when reading from it,
- * since nullness checkers will assume that vaules are non-null then, too.
- *
* <p>See the Guava User Guide article on <a href=
- * "https://github.com/google/guava/wiki/NewCollectionTypesExplained#classtoinstancemap">{@code
+ * "https://github.com/google/guava/wiki/NewCollectionTypesExplained#classtoinstancemap"> {@code
* ClassToInstanceMap}</a>.
*
* <p>To map a generic type to an instance of that type, use {@link
@@ -54,18 +43,12 @@
*/
@DoNotMock("Use ImmutableClassToInstanceMap or MutableClassToInstanceMap")
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-// If we ever support non-null projections (https://github.com/jspecify/jspecify/issues/86), we
-// we might annotate this as...
-// ClassToInstanceMap<B extends @Nullable Object> extends Map<Class<? extends @Nonnull B>, B>
-// ...and change its methods similarly (<T extends @Nonnull B> or Class<@Nonnull T>).
public interface ClassToInstanceMap<B> extends Map<Class<? extends B>, B> {
/**
* Returns the value the specified class is mapped to, or {@code null} if no entry for this class
* is present. This will only return a value that was bound to this specific class, not a value
* that may have been bound to a subtype.
*/
- @CheckForNull
<T extends B> T getInstance(Class<T> type);
/**
@@ -76,6 +59,5 @@
* null} if there was no previous entry.
*/
@CanIgnoreReturnValue
- @CheckForNull
- <T extends B> T putInstance(Class<T> type, T value);
+ <T extends B> T putInstance(Class<T> type, @NullableDecl T value);
}
diff --git a/android/guava/src/com/google/common/collect/CollectPreconditions.java b/android/guava/src/com/google/common/collect/CollectPreconditions.java
index c649b03..98b30c6 100644
--- a/android/guava/src/com/google/common/collect/CollectPreconditions.java
+++ b/android/guava/src/com/google/common/collect/CollectPreconditions.java
@@ -23,7 +23,6 @@
/** Precondition checks useful in collection implementations. */
@GwtCompatible
-@ElementTypesAreNonnullByDefault
final class CollectPreconditions {
static void checkEntryNotNull(Object key, Object value) {
diff --git a/android/guava/src/com/google/common/collect/Collections2.java b/android/guava/src/com/google/common/collect/Collections2.java
index 1e651b5..56b7a5b 100644
--- a/android/guava/src/com/google/common/collect/Collections2.java
+++ b/android/guava/src/com/google/common/collect/Collections2.java
@@ -19,7 +19,6 @@
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.collect.CollectPreconditions.checkNonnegative;
-import static java.util.Objects.requireNonNull;
import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtCompatible;
@@ -36,8 +35,7 @@
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* Provides static methods for working with {@code Collection} instances.
@@ -53,7 +51,6 @@
* @since 2.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
public final class Collections2 {
private Collections2() {}
@@ -84,8 +81,7 @@
*/
// TODO(kevinb): how can we omit that Iterables link when building gwt
// javadoc?
- public static <E extends @Nullable Object> Collection<E> filter(
- Collection<E> unfiltered, Predicate<? super E> predicate) {
+ public static <E> Collection<E> filter(Collection<E> unfiltered, Predicate<? super E> predicate) {
if (unfiltered instanceof FilteredCollection) {
// Support clear(), removeAll(), and retainAll() when filtering a filtered
// collection.
@@ -99,7 +95,7 @@
* Delegates to {@link Collection#contains}. Returns {@code false} if the {@code contains} method
* throws a {@code ClassCastException} or {@code NullPointerException}.
*/
- static boolean safeContains(Collection<?> collection, @CheckForNull Object object) {
+ static boolean safeContains(Collection<?> collection, @NullableDecl Object object) {
checkNotNull(collection);
try {
return collection.contains(object);
@@ -112,7 +108,7 @@
* 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, @CheckForNull Object object) {
+ static boolean safeRemove(Collection<?> collection, @NullableDecl Object object) {
checkNotNull(collection);
try {
return collection.remove(object);
@@ -121,7 +117,7 @@
}
}
- static class FilteredCollection<E extends @Nullable Object> extends AbstractCollection<E> {
+ static class FilteredCollection<E> extends AbstractCollection<E> {
final Collection<E> unfiltered;
final Predicate<? super E> predicate;
@@ -136,7 +132,7 @@
}
@Override
- public boolean add(@ParametricNullness E element) {
+ public boolean add(E element) {
checkArgument(predicate.apply(element));
return unfiltered.add(element);
}
@@ -155,7 +151,7 @@
}
@Override
- public boolean contains(@CheckForNull Object element) {
+ public boolean contains(@NullableDecl Object element) {
if (safeContains(unfiltered, element)) {
@SuppressWarnings("unchecked") // element is in unfiltered, so it must be an E
E e = (E) element;
@@ -180,7 +176,7 @@
}
@Override
- public boolean remove(@CheckForNull Object element) {
+ public boolean remove(Object element) {
return contains(element) && unfiltered.remove(element);
}
@@ -224,14 +220,13 @@
}
@Override
- public @Nullable Object[] toArray() {
+ public Object[] toArray() {
// creating an ArrayList so filtering happens once
return Lists.newArrayList(iterator()).toArray();
}
@Override
- @SuppressWarnings("nullness") // b/192354773 in our checker affects toArray declarations
- public <T extends @Nullable Object> T[] toArray(T[] array) {
+ public <T> T[] toArray(T[] array) {
return Lists.newArrayList(iterator()).toArray(array);
}
}
@@ -255,13 +250,12 @@
*
* <p><b>{@code Stream} equivalent:</b> {@link java.util.stream.Stream#map Stream.map}.
*/
- public static <F extends @Nullable Object, T extends @Nullable Object> Collection<T> transform(
+ public static <F, T> Collection<T> transform(
Collection<F> fromCollection, Function<? super F, T> function) {
return new TransformedCollection<>(fromCollection, function);
}
- static class TransformedCollection<F extends @Nullable Object, T extends @Nullable Object>
- extends AbstractCollection<T> {
+ static class TransformedCollection<F, T> extends AbstractCollection<T> {
final Collection<F> fromCollection;
final Function<? super F, ? extends T> function;
@@ -472,7 +466,7 @@
}
@Override
- public boolean contains(@CheckForNull Object obj) {
+ public boolean contains(@NullableDecl Object obj) {
if (obj instanceof List) {
List<?> list = (List<?>) obj;
return isPermutation(inputList, list);
@@ -487,7 +481,7 @@
}
private static final class OrderedPermutationIterator<E> extends AbstractIterator<List<E>> {
- @CheckForNull List<E> nextPermutation;
+ @NullableDecl List<E> nextPermutation;
final Comparator<? super E> comparator;
OrderedPermutationIterator(List<E> list, Comparator<? super E> comparator) {
@@ -496,7 +490,6 @@
}
@Override
- @CheckForNull
protected List<E> computeNext() {
if (nextPermutation == null) {
return endOfData();
@@ -512,11 +505,6 @@
nextPermutation = null;
return;
}
- /*
- * requireNonNull is safe because we don't clear nextPermutation until we're done calling this
- * method.
- */
- requireNonNull(nextPermutation);
int l = findNextL(j);
Collections.swap(nextPermutation, j, l);
@@ -525,11 +513,6 @@
}
int findNextJ() {
- /*
- * requireNonNull is safe because we don't clear nextPermutation until we're done calling this
- * method.
- */
- requireNonNull(nextPermutation);
for (int k = nextPermutation.size() - 2; k >= 0; k--) {
if (comparator.compare(nextPermutation.get(k), nextPermutation.get(k + 1)) < 0) {
return k;
@@ -539,11 +522,6 @@
}
int findNextL(int j) {
- /*
- * requireNonNull is safe because we don't clear nextPermutation until we're done calling this
- * method.
- */
- requireNonNull(nextPermutation);
E ak = nextPermutation.get(j);
for (int l = nextPermutation.size() - 1; l > j; l--) {
if (comparator.compare(ak, nextPermutation.get(l)) < 0) {
@@ -599,7 +577,7 @@
}
@Override
- public boolean contains(@CheckForNull Object obj) {
+ public boolean contains(@NullableDecl Object obj) {
if (obj instanceof List) {
List<?> list = (List<?>) obj;
return isPermutation(inputList, list);
@@ -630,7 +608,6 @@
}
@Override
- @CheckForNull
protected List<E> computeNext() {
if (j <= 0) {
return endOfData();
diff --git a/android/guava/src/com/google/common/collect/CompactHashMap.java b/android/guava/src/com/google/common/collect/CompactHashMap.java
index e70596d..1fa4f96 100644
--- a/android/guava/src/com/google/common/collect/CompactHashMap.java
+++ b/android/guava/src/com/google/common/collect/CompactHashMap.java
@@ -19,9 +19,6 @@
import static com.google.common.collect.CollectPreconditions.checkRemove;
import static com.google.common.collect.CompactHashing.UNSET;
import static com.google.common.collect.Hashing.smearedHash;
-import static com.google.common.collect.NullnessCasts.uncheckedCastNullableTToT;
-import static com.google.common.collect.NullnessCasts.unsafeNull;
-import static java.util.Objects.requireNonNull;
import com.google.common.annotations.GwtIncompatible;
import com.google.common.annotations.VisibleForTesting;
@@ -46,8 +43,7 @@
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Set;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* CompactHashMap is an implementation of a Map. All optional operations (put and remove) are
@@ -76,9 +72,7 @@
* @author Jon Noack
*/
@GwtIncompatible // not worth using in GWT for now
-@ElementTypesAreNonnullByDefault
-class CompactHashMap<K extends @Nullable Object, V extends @Nullable Object>
- extends AbstractMap<K, V> implements Serializable {
+class CompactHashMap<K, V> extends AbstractMap<K, V> implements Serializable {
/*
* TODO: Make this a drop-in replacement for j.u. versions, actually drop them in, and test the
* world. Figure out what sort of space-time tradeoff we're actually going to get here with the
@@ -88,8 +82,7 @@
*/
/** Creates an empty {@code CompactHashMap} instance. */
- public static <K extends @Nullable Object, V extends @Nullable Object>
- CompactHashMap<K, V> create() {
+ public static <K, V> CompactHashMap<K, V> create() {
return new CompactHashMap<>();
}
@@ -102,8 +95,7 @@
* elements without resizing
* @throws IllegalArgumentException if {@code expectedSize} is negative
*/
- public static <K extends @Nullable Object, V extends @Nullable Object>
- CompactHashMap<K, V> createWithExpectedSize(int expectedSize) {
+ public static <K, V> CompactHashMap<K, V> createWithExpectedSize(int expectedSize) {
return new CompactHashMap<>(expectedSize);
}
@@ -123,46 +115,6 @@
*/
private static final int MAX_HASH_BUCKET_LENGTH = 9;
- // The way the `table`, `entries`, `keys`, and `values` arrays work together is as follows.
- //
- // The `table` array always has a size that is a power of 2. The hashcode of a key in the map
- // is masked in order to correspond to the current table size. For example, if the table size
- // is 128 then the mask is 127 == 0x7f, keeping the bottom 7 bits of the hash value.
- // If a key hashes to 0x89abcdef the mask reduces it to 0x89abcdef & 0x7f == 0x6f. We'll call this
- // the "short hash".
- //
- // The `keys`, `values`, and `entries` arrays always have the same size as each other. They can be
- // seen as fields of an imaginary `Entry` object like this:
- //
- // class Entry {
- // int hash;
- // Entry next;
- // K key;
- // V value;
- // }
- //
- // The imaginary `hash` and `next` values are combined into a single `int` value in the `entries`
- // array. The top bits of this value are the remaining bits of the hash value that were not used
- // in the short hash. We saw that a mask of 0x7f would keep the 7-bit value 0x6f from a full
- // hashcode of 0x89abcdef. The imaginary `hash` value would then be the remaining top 25 bits,
- // 0x89abcd80. To this is added (or'd) the `next` value, which is an index within `entries`
- // (and therefore within `keys` and `values`) of another entry that has the same short hash
- // value. In our example, it would be another entry for a key whose short hash is also 0x6f.
- //
- // Essentially, then, `table[h]` gives us the start of a linked list in `entries`, where every
- // element of the list has the short hash value h.
- //
- // A wrinkle here is that the value 0 (called UNSET in the code) is used as the equivalent of a
- // null pointer. If `table[h] == 0` that means there are no keys in the map whose short hash is h.
- // If the `next` bits in `entries[i]` are 0 that means there are no further entries for the given
- // short hash. But 0 is also a valid index in `entries`, so we add 1 to these indices before
- // putting them in `table` or in `next` bits, and subtract 1 again when we need an index value.
- //
- // The elements of `keys`, `values`, and `entries` are added sequentially, so that elements 0 to
- // `size() - 1` are used and remaining elements are not. This makes iteration straightforward.
- // Removing an entry generally involves moving the last element of each array to where the removed
- // entry was, and adjusting index links accordingly.
-
/**
* The hashtable object. This can be either:
*
@@ -182,7 +134,7 @@
* <li>null, if no entries have yet been added to the map
* </ul>
*/
- @CheckForNull private transient Object table;
+ @NullableDecl private transient Object table;
/**
* Contains the logical entries, in the range of [0, size()). The high bits of each int are the
@@ -192,38 +144,32 @@
*
* <pre>
* hash = aaaaaaaa
- * mask = 00000fff
- * next = 00000bbb
- * entry = aaaaabbb
+ * mask = 0000ffff
+ * next = 0000bbbb
+ * entry = aaaabbbb
* </pre>
*
* <p>The pointers in [size(), entries.length) are all "null" (UNSET).
*/
- @VisibleForTesting @CheckForNull transient int[] entries;
+ @VisibleForTesting @NullableDecl transient int[] entries;
/**
* The keys of the entries in the map, in the range of [0, size()). The keys in [size(),
* keys.length) are all {@code null}.
*/
- @VisibleForTesting @CheckForNull transient @Nullable Object[] keys;
+ @VisibleForTesting @NullableDecl transient Object[] keys;
/**
* The values of the entries in the map, in the range of [0, size()). The values in [size(),
* values.length) are all {@code null}.
*/
- @VisibleForTesting @CheckForNull transient @Nullable Object[] values;
+ @VisibleForTesting @NullableDecl transient Object[] values;
/**
* Keeps track of metadata like the number of hash table bits and modifications of this data
* structure (to make it possible to throw ConcurrentModificationException in the iterator). Note
* that we choose not to make this volatile, so we do less of a "best effort" to track such
* errors, for better performance.
- *
- * <p>For a new instance, where the arrays above have not yet been allocated, the value of {@code
- * metadata} is the size that the arrays should be allocated with. Once the arrays have been
- * allocated, the value of {@code metadata} combines the number of bits in the "short hash", in
- * its bottom {@value CompactHashing#HASH_TABLE_BITS_MAX_BITS} bits, with a modification count in
- * the remaining bits that is used to detect concurrent modification during iteration.
*/
private transient int metadata;
@@ -277,7 +223,7 @@
@SuppressWarnings("unchecked")
@VisibleForTesting
- @CheckForNull
+ @NullableDecl
Map<K, V> delegateOrNull() {
if (table instanceof Map) {
return (Map<K, V>) table;
@@ -289,12 +235,13 @@
return new LinkedHashMap<>(tableSize, 1.0f);
}
+ @SuppressWarnings("unchecked")
@VisibleForTesting
@CanIgnoreReturnValue
Map<K, V> convertToHashFloodingResistantImplementation() {
Map<K, V> newDelegate = createHashFloodingResistantDelegate(hashTableMask() + 1);
for (int i = firstEntryIndex(); i >= 0; i = getSuccessor(i)) {
- newDelegate.put(key(i), value(i));
+ newDelegate.put((K) keys[i], (V) values[i]);
}
this.table = newDelegate;
this.entries = null;
@@ -330,31 +277,31 @@
@CanIgnoreReturnValue
@Override
- @CheckForNull
- public V put(@ParametricNullness K key, @ParametricNullness V value) {
+ @NullableDecl
+ public V put(@NullableDecl K key, @NullableDecl V value) {
if (needsAllocArrays()) {
allocArrays();
}
- Map<K, V> delegate = delegateOrNull();
+ @NullableDecl Map<K, V> delegate = delegateOrNull();
if (delegate != null) {
return delegate.put(key, value);
}
- int[] entries = requireEntries();
- @Nullable Object[] keys = requireKeys();
- @Nullable Object[] values = requireValues();
+ int[] entries = this.entries;
+ Object[] keys = this.keys;
+ Object[] values = this.values;
int newEntryIndex = this.size; // current size, and pointer to the entry to be appended
int newSize = newEntryIndex + 1;
int hash = smearedHash(key);
int mask = hashTableMask();
int tableIndex = hash & mask;
- int next = CompactHashing.tableGet(requireTable(), tableIndex);
+ int next = CompactHashing.tableGet(table, tableIndex);
if (next == UNSET) { // uninitialized bucket
if (newSize > mask) {
// Resize and add new entry
mask = resizeTable(mask, CompactHashing.newCapacity(mask), hash, newEntryIndex);
} else {
- CompactHashing.tableSet(requireTable(), tableIndex, newEntryIndex + 1);
+ CompactHashing.tableSet(table, tableIndex, newEntryIndex + 1);
}
} else {
int entryIndex;
@@ -367,6 +314,7 @@
if (CompactHashing.getHashPrefix(entry, mask) == hashPrefix
&& Objects.equal(key, keys[entryIndex])) {
@SuppressWarnings("unchecked") // known to be a V
+ @NullableDecl
V oldValue = (V) values[entryIndex];
values[entryIndex] = value;
@@ -398,16 +346,15 @@
/**
* Creates a fresh entry with the specified object at the specified position in the entry arrays.
*/
- void insertEntry(
- int entryIndex, @ParametricNullness K key, @ParametricNullness V value, int hash, int mask) {
- this.setEntry(entryIndex, CompactHashing.maskCombine(hash, UNSET, mask));
- this.setKey(entryIndex, key);
- this.setValue(entryIndex, value);
+ void insertEntry(int entryIndex, @NullableDecl K key, @NullableDecl V value, int hash, int mask) {
+ this.entries[entryIndex] = CompactHashing.maskCombine(hash, UNSET, mask);
+ this.keys[entryIndex] = key;
+ this.values[entryIndex] = value;
}
/** Resizes the entries storage if necessary. */
private void resizeMeMaybe(int newSize) {
- int entriesSize = requireEntries().length;
+ int entriesSize = entries.length;
if (newSize > entriesSize) {
// 1.5x but round up to nearest odd (this is optimal for memory consumption on Android)
int newCapacity =
@@ -423,13 +370,13 @@
* the current capacity.
*/
void resizeEntries(int newCapacity) {
- this.entries = Arrays.copyOf(requireEntries(), newCapacity);
- this.keys = Arrays.copyOf(requireKeys(), newCapacity);
- this.values = Arrays.copyOf(requireValues(), newCapacity);
+ this.entries = Arrays.copyOf(entries, newCapacity);
+ this.keys = Arrays.copyOf(keys, newCapacity);
+ this.values = Arrays.copyOf(values, newCapacity);
}
@CanIgnoreReturnValue
- private int resizeTable(int oldMask, int newCapacity, int targetHash, int targetEntryIndex) {
+ private int resizeTable(int mask, int newCapacity, int targetHash, int targetEntryIndex) {
Object newTable = CompactHashing.createTable(newCapacity);
int newMask = newCapacity - 1;
@@ -438,35 +385,25 @@
CompactHashing.tableSet(newTable, targetHash & newMask, targetEntryIndex + 1);
}
- Object oldTable = requireTable();
- int[] entries = requireEntries();
+ Object table = this.table;
+ int[] entries = this.entries;
- // Loop over `oldTable` to construct its replacement, ``newTable`. The entries do not move, so
- // the `keys` and `values` arrays do not need to change. But because the "short hash" now has a
- // different number of bits, we must rewrite each element of `entries` so that its contribution
- // to the full hashcode reflects the change, and so that its `next` link corresponds to the new
- // linked list of entries with the new short hash.
- for (int oldTableIndex = 0; oldTableIndex <= oldMask; oldTableIndex++) {
- int oldNext = CompactHashing.tableGet(oldTable, oldTableIndex);
- // Each element of `oldTable` is the head of a (possibly empty) linked list of elements in
- // `entries`. The `oldNext` loop is going to traverse that linked list.
- // We need to rewrite the `next` link of each of the elements so that it is in the appropriate
- // linked list starting from `newTable`. In general, each element from the old linked list
- // belongs to a different linked list from `newTable`. We insert each element in turn at the
- // head of its appropriate `newTable` linked list.
- while (oldNext != UNSET) {
- int entryIndex = oldNext - 1;
- int oldEntry = entries[entryIndex];
+ // Loop over current hashtable
+ for (int tableIndex = 0; tableIndex <= mask; tableIndex++) {
+ int next = CompactHashing.tableGet(table, tableIndex);
+ while (next != UNSET) {
+ int entryIndex = next - 1;
+ int entry = entries[entryIndex];
- // Rebuild the full 32-bit hash using entry hashPrefix and oldTableIndex ("hashSuffix").
- int hash = CompactHashing.getHashPrefix(oldEntry, oldMask) | oldTableIndex;
+ // Rebuild hash using entry hashPrefix and tableIndex ("hashSuffix")
+ int hash = CompactHashing.getHashPrefix(entry, mask) | tableIndex;
int newTableIndex = hash & newMask;
int newNext = CompactHashing.tableGet(newTable, newTableIndex);
- CompactHashing.tableSet(newTable, newTableIndex, oldNext);
+ CompactHashing.tableSet(newTable, newTableIndex, next);
entries[entryIndex] = CompactHashing.maskCombine(hash, newNext, newMask);
- oldNext = CompactHashing.getNext(oldEntry, oldMask);
+ next = CompactHashing.getNext(entry, mask);
}
}
@@ -475,22 +412,22 @@
return newMask;
}
- private int indexOf(@CheckForNull Object key) {
+ private int indexOf(@NullableDecl Object key) {
if (needsAllocArrays()) {
return -1;
}
int hash = smearedHash(key);
int mask = hashTableMask();
- int next = CompactHashing.tableGet(requireTable(), hash & mask);
+ int next = CompactHashing.tableGet(table, hash & mask);
if (next == UNSET) {
return -1;
}
int hashPrefix = CompactHashing.getHashPrefix(hash, mask);
do {
int entryIndex = next - 1;
- int entry = entry(entryIndex);
+ int entry = entries[entryIndex];
if (CompactHashing.getHashPrefix(entry, mask) == hashPrefix
- && Objects.equal(key, key(entryIndex))) {
+ && Objects.equal(key, keys[entryIndex])) {
return entryIndex;
}
next = CompactHashing.getNext(entry, mask);
@@ -499,15 +436,15 @@
}
@Override
- public boolean containsKey(@CheckForNull Object key) {
- Map<K, V> delegate = delegateOrNull();
+ public boolean containsKey(@NullableDecl Object key) {
+ @NullableDecl Map<K, V> delegate = delegateOrNull();
return (delegate != null) ? delegate.containsKey(key) : indexOf(key) != -1;
}
+ @SuppressWarnings("unchecked") // known to be a V
@Override
- @CheckForNull
- public V get(@CheckForNull Object key) {
- Map<K, V> delegate = delegateOrNull();
+ public V get(@NullableDecl Object key) {
+ @NullableDecl Map<K, V> delegate = delegateOrNull();
if (delegate != null) {
return delegate.get(key);
}
@@ -516,15 +453,15 @@
return null;
}
accessEntry(index);
- return value(index);
+ return (V) values[index];
}
@CanIgnoreReturnValue
@SuppressWarnings("unchecked") // known to be a V
@Override
- @CheckForNull
- public V remove(@CheckForNull Object key) {
- Map<K, V> delegate = delegateOrNull();
+ @NullableDecl
+ public V remove(@NullableDecl Object key) {
+ @NullableDecl Map<K, V> delegate = delegateOrNull();
if (delegate != null) {
return delegate.remove(key);
}
@@ -532,25 +469,20 @@
return (oldValue == NOT_FOUND) ? null : (V) oldValue;
}
- private @Nullable Object removeHelper(@CheckForNull Object key) {
+ @NullableDecl
+ private Object removeHelper(@NullableDecl Object key) {
if (needsAllocArrays()) {
return NOT_FOUND;
}
int mask = hashTableMask();
int index =
CompactHashing.remove(
- key,
- /* value= */ null,
- mask,
- requireTable(),
- requireEntries(),
- requireKeys(),
- /* values= */ null);
+ key, /* value= */ null, mask, table, entries, keys, /* values= */ null);
if (index == -1) {
return NOT_FOUND;
}
- Object oldValue = value(index);
+ @NullableDecl Object oldValue = values[index];
moveLastEntry(index, mask);
size--;
@@ -563,14 +495,10 @@
* Moves the last entry in the entry array into {@code dstIndex}, and nulls out its old position.
*/
void moveLastEntry(int dstIndex, int mask) {
- Object table = requireTable();
- int[] entries = requireEntries();
- @Nullable Object[] keys = requireKeys();
- @Nullable Object[] values = requireValues();
int srcIndex = size() - 1;
if (dstIndex < srcIndex) {
// move last entry to deleted spot
- Object key = keys[srcIndex];
+ @NullableDecl Object key = keys[srcIndex];
keys[dstIndex] = key;
values[dstIndex] = values[srcIndex];
keys[srcIndex] = null;
@@ -623,7 +551,7 @@
return indexBeforeRemove - 1;
}
- private abstract class Itr<T extends @Nullable Object> implements Iterator<T> {
+ private abstract class Itr<T> implements Iterator<T> {
int expectedMetadata = metadata;
int currentIndex = firstEntryIndex();
int indexToRemove = -1;
@@ -633,11 +561,9 @@
return currentIndex >= 0;
}
- @ParametricNullness
abstract T getOutput(int entry);
@Override
- @ParametricNullness
public T next() {
checkForConcurrentModification();
if (!hasNext()) {
@@ -654,7 +580,7 @@
checkForConcurrentModification();
checkRemove(indexToRemove >= 0);
incrementExpectedModCount();
- CompactHashMap.this.remove(key(indexToRemove));
+ CompactHashMap.this.remove(keys[indexToRemove]);
currentIndex = adjustAfterRemove(currentIndex, indexToRemove);
indexToRemove = -1;
}
@@ -670,7 +596,7 @@
}
}
- @CheckForNull private transient Set<K> keySetView;
+ @NullableDecl private transient Set<K> keySetView;
@Override
public Set<K> keySet() {
@@ -689,13 +615,13 @@
}
@Override
- public boolean contains(@CheckForNull Object o) {
+ public boolean contains(Object o) {
return CompactHashMap.this.containsKey(o);
}
@Override
- public boolean remove(@CheckForNull Object o) {
- Map<K, V> delegate = delegateOrNull();
+ public boolean remove(@NullableDecl Object o) {
+ @NullableDecl Map<K, V> delegate = delegateOrNull();
return (delegate != null)
? delegate.keySet().remove(o)
: CompactHashMap.this.removeHelper(o) != NOT_FOUND;
@@ -713,20 +639,20 @@
}
Iterator<K> keySetIterator() {
- Map<K, V> delegate = delegateOrNull();
+ @NullableDecl Map<K, V> delegate = delegateOrNull();
if (delegate != null) {
return delegate.keySet().iterator();
}
return new Itr<K>() {
+ @SuppressWarnings("unchecked") // known to be a K
@Override
- @ParametricNullness
K getOutput(int entry) {
- return key(entry);
+ return (K) keys[entry];
}
};
}
- @CheckForNull private transient Set<Entry<K, V>> entrySetView;
+ @NullableDecl private transient Set<Entry<K, V>> entrySetView;
@Override
public Set<Entry<K, V>> entrySet() {
@@ -756,21 +682,21 @@
}
@Override
- public boolean contains(@CheckForNull Object o) {
- Map<K, V> delegate = delegateOrNull();
+ public boolean contains(@NullableDecl Object o) {
+ @NullableDecl Map<K, V> delegate = delegateOrNull();
if (delegate != null) {
return delegate.entrySet().contains(o);
} else if (o instanceof Entry) {
Entry<?, ?> entry = (Entry<?, ?>) o;
int index = indexOf(entry.getKey());
- return index != -1 && Objects.equal(value(index), entry.getValue());
+ return index != -1 && Objects.equal(values[index], entry.getValue());
}
return false;
}
@Override
- public boolean remove(@CheckForNull Object o) {
- Map<K, V> delegate = delegateOrNull();
+ public boolean remove(@NullableDecl Object o) {
+ @NullableDecl Map<K, V> delegate = delegateOrNull();
if (delegate != null) {
return delegate.entrySet().remove(o);
} else if (o instanceof Entry) {
@@ -781,13 +707,7 @@
int mask = hashTableMask();
int index =
CompactHashing.remove(
- entry.getKey(),
- entry.getValue(),
- mask,
- requireTable(),
- requireEntries(),
- requireKeys(),
- requireValues());
+ entry.getKey(), entry.getValue(), mask, table, entries, keys, values);
if (index == -1) {
return false;
}
@@ -803,7 +723,7 @@
}
Iterator<Entry<K, V>> entrySetIterator() {
- Map<K, V> delegate = delegateOrNull();
+ @NullableDecl Map<K, V> delegate = delegateOrNull();
if (delegate != null) {
return delegate.entrySet().iterator();
}
@@ -816,17 +736,18 @@
}
final class MapEntry extends AbstractMapEntry<K, V> {
- @ParametricNullness private final K key;
+ @NullableDecl private final K key;
private int lastKnownIndex;
+ @SuppressWarnings("unchecked") // known to be a K
MapEntry(int index) {
- this.key = key(index);
+ this.key = (K) keys[index];
this.lastKnownIndex = index;
}
+ @NullableDecl
@Override
- @ParametricNullness
public K getKey() {
return key;
}
@@ -834,48 +755,37 @@
private void updateLastKnownIndex() {
if (lastKnownIndex == -1
|| lastKnownIndex >= size()
- || !Objects.equal(key, key(lastKnownIndex))) {
+ || !Objects.equal(key, keys[lastKnownIndex])) {
lastKnownIndex = indexOf(key);
}
}
+ @SuppressWarnings("unchecked") // known to be a V
@Override
- @ParametricNullness
+ @NullableDecl
public V getValue() {
- Map<K, V> delegate = delegateOrNull();
+ @NullableDecl Map<K, V> delegate = delegateOrNull();
if (delegate != null) {
- /*
- * The cast is safe because the entry is present in the map. Or, if it has been removed by a
- * concurrent modification, behavior is undefined.
- */
- return uncheckedCastNullableTToT(delegate.get(key));
+ return delegate.get(key);
}
updateLastKnownIndex();
- /*
- * If the entry has been removed from the map, we return null, even though that might not be a
- * valid value. That's the best we can do, short of holding a reference to the most recently
- * seen value. And while we *could* do that, we aren't required to: Map.Entry explicitly says
- * that behavior is undefined when the backing map is modified through another API. (It even
- * permits us to throw IllegalStateException. Maybe we should have done that, but we probably
- * shouldn't change now for fear of breaking people.)
- */
- return (lastKnownIndex == -1) ? unsafeNull() : value(lastKnownIndex);
+ return (lastKnownIndex == -1) ? null : (V) values[lastKnownIndex];
}
+ @SuppressWarnings("unchecked") // known to be a V
@Override
- @ParametricNullness
- public V setValue(@ParametricNullness V value) {
- Map<K, V> delegate = delegateOrNull();
+ public V setValue(V value) {
+ @NullableDecl Map<K, V> delegate = delegateOrNull();
if (delegate != null) {
- return uncheckedCastNullableTToT(delegate.put(key, value)); // See discussion in getValue().
+ return delegate.put(key, value);
}
updateLastKnownIndex();
if (lastKnownIndex == -1) {
put(key, value);
- return unsafeNull(); // See discussion in getValue().
+ return null;
} else {
- V old = value(lastKnownIndex);
- CompactHashMap.this.setValue(lastKnownIndex, value);
+ V old = (V) values[lastKnownIndex];
+ values[lastKnownIndex] = value;
return old;
}
}
@@ -883,7 +793,7 @@
@Override
public int size() {
- Map<K, V> delegate = delegateOrNull();
+ @NullableDecl Map<K, V> delegate = delegateOrNull();
return (delegate != null) ? delegate.size() : size;
}
@@ -893,20 +803,20 @@
}
@Override
- public boolean containsValue(@CheckForNull Object value) {
- Map<K, V> delegate = delegateOrNull();
+ public boolean containsValue(@NullableDecl Object value) {
+ @NullableDecl Map<K, V> delegate = delegateOrNull();
if (delegate != null) {
return delegate.containsValue(value);
}
for (int i = 0; i < size; i++) {
- if (Objects.equal(value, value(i))) {
+ if (Objects.equal(value, values[i])) {
return true;
}
}
return false;
}
- @CheckForNull private transient Collection<V> valuesView;
+ @NullableDecl private transient Collection<V> valuesView;
@Override
public Collection<V> values() {
@@ -936,15 +846,15 @@
}
Iterator<V> valuesIterator() {
- Map<K, V> delegate = delegateOrNull();
+ @NullableDecl Map<K, V> delegate = delegateOrNull();
if (delegate != null) {
return delegate.values().iterator();
}
return new Itr<V>() {
+ @SuppressWarnings("unchecked") // known to be a V
@Override
- @ParametricNullness
V getOutput(int entry) {
- return value(entry);
+ return (V) values[entry];
}
};
}
@@ -957,7 +867,7 @@
if (needsAllocArrays()) {
return;
}
- Map<K, V> delegate = delegateOrNull();
+ @NullableDecl Map<K, V> delegate = delegateOrNull();
if (delegate != null) {
Map<K, V> newDelegate = createHashFloodingResistantDelegate(size());
newDelegate.putAll(delegate);
@@ -965,7 +875,7 @@
return;
}
int size = this.size;
- if (size < requireEntries().length) {
+ if (size < entries.length) {
resizeEntries(size);
}
int minimumTableSize = CompactHashing.tableSize(size);
@@ -981,7 +891,7 @@
return;
}
incrementModCount();
- Map<K, V> delegate = delegateOrNull();
+ @NullableDecl Map<K, V> delegate = delegateOrNull();
if (delegate != null) {
metadata =
Ints.constrainToRange(size(), CompactHashing.DEFAULT_SIZE, CompactHashing.MAX_SIZE);
@@ -989,10 +899,10 @@
table = null;
size = 0;
} else {
- Arrays.fill(requireKeys(), 0, size, null);
- Arrays.fill(requireValues(), 0, size, null);
- CompactHashing.tableClear(requireTable());
- Arrays.fill(requireEntries(), 0, size, 0);
+ Arrays.fill(keys, 0, size, null);
+ Arrays.fill(values, 0, size, null);
+ CompactHashing.tableClear(table);
+ Arrays.fill(entries, 0, size, 0);
this.size = 0;
}
}
@@ -1022,66 +932,4 @@
put(key, value);
}
}
-
- /*
- * The following methods are safe to call as long as both of the following hold:
- *
- * - allocArrays() has been called. Callers can confirm this by checking needsAllocArrays().
- *
- * - The map has not switched to delegating to a java.util implementation to mitigate hash
- * flooding. Callers can confirm this by null-checking delegateOrNull().
- *
- * In an ideal world, we would document why we know those things are true every time we call these
- * methods. But that is a bit too painful....
- */
-
- private Object requireTable() {
- return requireNonNull(table);
- }
-
- private int[] requireEntries() {
- return requireNonNull(entries);
- }
-
- private @Nullable Object[] requireKeys() {
- return requireNonNull(keys);
- }
-
- private @Nullable Object[] requireValues() {
- return requireNonNull(values);
- }
-
- /*
- * The following methods are safe to call as long as the conditions in the *previous* comment are
- * met *and* the index is less than size().
- *
- * (The above explains when these methods are safe from a `nullness` perspective. From an
- * `unchecked` perspective, they're safe because we put only K/V elements into each array.)
- */
-
- @SuppressWarnings("unchecked")
- private K key(int i) {
- return (K) requireKeys()[i];
- }
-
- @SuppressWarnings("unchecked")
- private V value(int i) {
- return (V) requireValues()[i];
- }
-
- private int entry(int i) {
- return requireEntries()[i];
- }
-
- private void setKey(int i, K key) {
- requireKeys()[i] = key;
- }
-
- private void setValue(int i, V value) {
- requireValues()[i] = value;
- }
-
- private void setEntry(int i, int value) {
- requireEntries()[i] = value;
- }
}
diff --git a/android/guava/src/com/google/common/collect/CompactHashSet.java b/android/guava/src/com/google/common/collect/CompactHashSet.java
index 08c7294..d4c585c 100644
--- a/android/guava/src/com/google/common/collect/CompactHashSet.java
+++ b/android/guava/src/com/google/common/collect/CompactHashSet.java
@@ -19,7 +19,6 @@
import static com.google.common.collect.CollectPreconditions.checkRemove;
import static com.google.common.collect.CompactHashing.UNSET;
import static com.google.common.collect.Hashing.smearedHash;
-import static java.util.Objects.requireNonNull;
import com.google.common.annotations.GwtIncompatible;
import com.google.common.annotations.VisibleForTesting;
@@ -41,8 +40,7 @@
import java.util.LinkedHashSet;
import java.util.NoSuchElementException;
import java.util.Set;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* CompactHashSet is an implementation of a Set. All optional operations (adding and removing) are
@@ -72,12 +70,11 @@
* @author Jon Noack
*/
@GwtIncompatible // not worth using in GWT for now
-@ElementTypesAreNonnullByDefault
-class CompactHashSet<E extends @Nullable Object> extends AbstractSet<E> implements Serializable {
+class CompactHashSet<E> extends AbstractSet<E> implements Serializable {
// TODO(user): cache all field accesses in local vars
/** Creates an empty {@code CompactHashSet} instance. */
- public static <E extends @Nullable Object> CompactHashSet<E> create() {
+ public static <E> CompactHashSet<E> create() {
return new CompactHashSet<>();
}
@@ -88,8 +85,7 @@
* @param collection the elements that the set should contain
* @return a new {@code CompactHashSet} containing those elements (minus duplicates)
*/
- public static <E extends @Nullable Object> CompactHashSet<E> create(
- Collection<? extends E> collection) {
+ public static <E> CompactHashSet<E> create(Collection<? extends E> collection) {
CompactHashSet<E> set = createWithExpectedSize(collection.size());
set.addAll(collection);
return set;
@@ -103,7 +99,7 @@
* @return a new {@code CompactHashSet} containing those elements (minus duplicates)
*/
@SafeVarargs
- public static <E extends @Nullable Object> CompactHashSet<E> create(E... elements) {
+ public static <E> CompactHashSet<E> create(E... elements) {
CompactHashSet<E> set = createWithExpectedSize(elements.length);
Collections.addAll(set, elements);
return set;
@@ -118,8 +114,7 @@
* elements without resizing
* @throws IllegalArgumentException if {@code expectedSize} is negative
*/
- public static <E extends @Nullable Object> CompactHashSet<E> createWithExpectedSize(
- int expectedSize) {
+ public static <E> CompactHashSet<E> createWithExpectedSize(int expectedSize) {
return new CompactHashSet<>(expectedSize);
}
@@ -137,10 +132,6 @@
*/
private static final int MAX_HASH_BUCKET_LENGTH = 9;
- // See CompactHashMap for a detailed description of how the following fields work. That
- // description talks about `keys`, `values`, and `entries`; here the `keys` and `values` arrays
- // are replaced by a single `elements` array but everything else works similarly.
-
/**
* The hashtable object. This can be either:
*
@@ -160,7 +151,7 @@
* <li>null, if no entries have yet been added to the map
* </ul>
*/
- @CheckForNull private transient Object table;
+ @NullableDecl private transient Object table;
/**
* Contains the logical entries, in the range of [0, size()). The high bits of each int are the
@@ -170,20 +161,20 @@
*
* <pre>
* hash = aaaaaaaa
- * mask = 00000fff
- * next = 00000bbb
- * entry = aaaaabbb
+ * mask = 0000ffff
+ * next = 0000bbbb
+ * entry = aaaabbbb
* </pre>
*
* <p>The pointers in [size(), entries.length) are all "null" (UNSET).
*/
- @CheckForNull private transient int[] entries;
+ @NullableDecl private transient int[] entries;
/**
* The elements contained in the set, in the range of [0, size()). The elements in [size(),
* elements.length) are all {@code null}.
*/
- @VisibleForTesting @CheckForNull transient @Nullable Object[] elements;
+ @VisibleForTesting @NullableDecl transient Object[] elements;
/**
* Keeps track of metadata like the number of hash table bits and modifications of this data
@@ -242,7 +233,7 @@
@SuppressWarnings("unchecked")
@VisibleForTesting
- @CheckForNull
+ @NullableDecl
Set<E> delegateOrNull() {
if (table instanceof Set) {
return (Set<E>) table;
@@ -254,12 +245,13 @@
return new LinkedHashSet<>(tableSize, 1.0f);
}
+ @SuppressWarnings("unchecked")
@VisibleForTesting
@CanIgnoreReturnValue
Set<E> convertToHashFloodingResistantImplementation() {
Set<E> newDelegate = createHashFloodingResistantDelegate(hashTableMask() + 1);
for (int i = firstEntryIndex(); i >= 0; i = getSuccessor(i)) {
- newDelegate.add(element(i));
+ newDelegate.add((E) elements[i]);
}
this.table = newDelegate;
this.entries = null;
@@ -291,29 +283,29 @@
@CanIgnoreReturnValue
@Override
- public boolean add(@ParametricNullness E object) {
+ public boolean add(@NullableDecl E object) {
if (needsAllocArrays()) {
allocArrays();
}
- Set<E> delegate = delegateOrNull();
+ @NullableDecl Set<E> delegate = delegateOrNull();
if (delegate != null) {
return delegate.add(object);
}
- int[] entries = requireEntries();
- @Nullable Object[] elements = requireElements();
+ int[] entries = this.entries;
+ Object[] elements = this.elements;
int newEntryIndex = this.size; // current size, and pointer to the entry to be appended
int newSize = newEntryIndex + 1;
int hash = smearedHash(object);
int mask = hashTableMask();
int tableIndex = hash & mask;
- int next = CompactHashing.tableGet(requireTable(), tableIndex);
+ int next = CompactHashing.tableGet(table, tableIndex);
if (next == UNSET) { // uninitialized bucket
if (newSize > mask) {
// Resize and add new entry
mask = resizeTable(mask, CompactHashing.newCapacity(mask), hash, newEntryIndex);
} else {
- CompactHashing.tableSet(requireTable(), tableIndex, newEntryIndex + 1);
+ CompactHashing.tableSet(table, tableIndex, newEntryIndex + 1);
}
} else {
int entryIndex;
@@ -352,14 +344,14 @@
/**
* Creates a fresh entry with the specified object at the specified position in the entry arrays.
*/
- void insertEntry(int entryIndex, @ParametricNullness E object, int hash, int mask) {
- setEntry(entryIndex, CompactHashing.maskCombine(hash, UNSET, mask));
- setElement(entryIndex, object);
+ void insertEntry(int entryIndex, @NullableDecl E object, int hash, int mask) {
+ this.entries[entryIndex] = CompactHashing.maskCombine(hash, UNSET, mask);
+ this.elements[entryIndex] = object;
}
/** Resizes the entries storage if necessary. */
private void resizeMeMaybe(int newSize) {
- int entriesSize = requireEntries().length;
+ int entriesSize = entries.length;
if (newSize > entriesSize) {
// 1.5x but round up to nearest odd (this is optimal for memory consumption on Android)
int newCapacity =
@@ -375,12 +367,12 @@
* the current capacity.
*/
void resizeEntries(int newCapacity) {
- this.entries = Arrays.copyOf(requireEntries(), newCapacity);
- this.elements = Arrays.copyOf(requireElements(), newCapacity);
+ this.entries = Arrays.copyOf(entries, newCapacity);
+ this.elements = Arrays.copyOf(elements, newCapacity);
}
@CanIgnoreReturnValue
- private int resizeTable(int oldMask, int newCapacity, int targetHash, int targetEntryIndex) {
+ private int resizeTable(int mask, int newCapacity, int targetHash, int targetEntryIndex) {
Object newTable = CompactHashing.createTable(newCapacity);
int newMask = newCapacity - 1;
@@ -389,25 +381,25 @@
CompactHashing.tableSet(newTable, targetHash & newMask, targetEntryIndex + 1);
}
- Object oldTable = requireTable();
- int[] entries = requireEntries();
+ Object table = this.table;
+ int[] entries = this.entries;
// Loop over current hashtable
- for (int oldTableIndex = 0; oldTableIndex <= oldMask; oldTableIndex++) {
- int oldNext = CompactHashing.tableGet(oldTable, oldTableIndex);
- while (oldNext != UNSET) {
- int entryIndex = oldNext - 1;
- int oldEntry = entries[entryIndex];
+ for (int tableIndex = 0; tableIndex <= mask; tableIndex++) {
+ int next = CompactHashing.tableGet(table, tableIndex);
+ while (next != UNSET) {
+ int entryIndex = next - 1;
+ int entry = entries[entryIndex];
// Rebuild hash using entry hashPrefix and tableIndex ("hashSuffix")
- int hash = CompactHashing.getHashPrefix(oldEntry, oldMask) | oldTableIndex;
+ int hash = CompactHashing.getHashPrefix(entry, mask) | tableIndex;
int newTableIndex = hash & newMask;
int newNext = CompactHashing.tableGet(newTable, newTableIndex);
- CompactHashing.tableSet(newTable, newTableIndex, oldNext);
+ CompactHashing.tableSet(newTable, newTableIndex, next);
entries[entryIndex] = CompactHashing.maskCombine(hash, newNext, newMask);
- oldNext = CompactHashing.getNext(oldEntry, oldMask);
+ next = CompactHashing.getNext(entry, mask);
}
}
@@ -417,26 +409,26 @@
}
@Override
- public boolean contains(@CheckForNull Object object) {
+ public boolean contains(@NullableDecl Object object) {
if (needsAllocArrays()) {
return false;
}
- Set<E> delegate = delegateOrNull();
+ @NullableDecl Set<E> delegate = delegateOrNull();
if (delegate != null) {
return delegate.contains(object);
}
int hash = smearedHash(object);
int mask = hashTableMask();
- int next = CompactHashing.tableGet(requireTable(), hash & mask);
+ int next = CompactHashing.tableGet(table, hash & mask);
if (next == UNSET) {
return false;
}
int hashPrefix = CompactHashing.getHashPrefix(hash, mask);
do {
int entryIndex = next - 1;
- int entry = entry(entryIndex);
+ int entry = entries[entryIndex];
if (CompactHashing.getHashPrefix(entry, mask) == hashPrefix
- && Objects.equal(object, element(entryIndex))) {
+ && Objects.equal(object, elements[entryIndex])) {
return true;
}
next = CompactHashing.getNext(entry, mask);
@@ -446,24 +438,18 @@
@CanIgnoreReturnValue
@Override
- public boolean remove(@CheckForNull Object object) {
+ public boolean remove(@NullableDecl Object object) {
if (needsAllocArrays()) {
return false;
}
- Set<E> delegate = delegateOrNull();
+ @NullableDecl Set<E> delegate = delegateOrNull();
if (delegate != null) {
return delegate.remove(object);
}
int mask = hashTableMask();
int index =
CompactHashing.remove(
- object,
- /* value= */ null,
- mask,
- requireTable(),
- requireEntries(),
- requireElements(),
- /* values= */ null);
+ object, /* value= */ null, mask, table, entries, elements, /* values= */ null);
if (index == -1) {
return false;
}
@@ -479,13 +465,10 @@
* Moves the last entry in the entry array into {@code dstIndex}, and nulls out its old position.
*/
void moveLastEntry(int dstIndex, int mask) {
- Object table = requireTable();
- int[] entries = requireEntries();
- @Nullable Object[] elements = requireElements();
int srcIndex = size() - 1;
if (dstIndex < srcIndex) {
// move last entry to deleted spot
- Object object = elements[srcIndex];
+ @NullableDecl Object object = elements[srcIndex];
elements[dstIndex] = object;
elements[srcIndex] = null;
@@ -537,7 +520,7 @@
@Override
public Iterator<E> iterator() {
- Set<E> delegate = delegateOrNull();
+ @NullableDecl Set<E> delegate = delegateOrNull();
if (delegate != null) {
return delegate.iterator();
}
@@ -551,15 +534,15 @@
return currentIndex >= 0;
}
+ @SuppressWarnings("unchecked") // known to be Es
@Override
- @ParametricNullness
public E next() {
checkForConcurrentModification();
if (!hasNext()) {
throw new NoSuchElementException();
}
indexToRemove = currentIndex;
- E result = element(currentIndex);
+ E result = (E) elements[currentIndex];
currentIndex = getSuccessor(currentIndex);
return result;
}
@@ -569,7 +552,7 @@
checkForConcurrentModification();
checkRemove(indexToRemove >= 0);
incrementExpectedModCount();
- CompactHashSet.this.remove(element(indexToRemove));
+ CompactHashSet.this.remove(elements[indexToRemove]);
currentIndex = adjustAfterRemove(currentIndex, indexToRemove);
indexToRemove = -1;
}
@@ -588,7 +571,7 @@
@Override
public int size() {
- Set<E> delegate = delegateOrNull();
+ @NullableDecl Set<E> delegate = delegateOrNull();
return (delegate != null) ? delegate.size() : size;
}
@@ -598,28 +581,27 @@
}
@Override
- public @Nullable Object[] toArray() {
+ public Object[] toArray() {
if (needsAllocArrays()) {
return new Object[0];
}
- Set<E> delegate = delegateOrNull();
- return (delegate != null) ? delegate.toArray() : Arrays.copyOf(requireElements(), size);
+ @NullableDecl Set<E> delegate = delegateOrNull();
+ return (delegate != null) ? delegate.toArray() : Arrays.copyOf(elements, size);
}
@CanIgnoreReturnValue
@Override
- @SuppressWarnings("nullness") // b/192354773 in our checker affects toArray declarations
- public <T extends @Nullable Object> T[] toArray(T[] a) {
+ public <T> T[] toArray(T[] a) {
if (needsAllocArrays()) {
if (a.length > 0) {
a[0] = null;
}
return a;
}
- Set<E> delegate = delegateOrNull();
+ @NullableDecl Set<E> delegate = delegateOrNull();
return (delegate != null)
? delegate.toArray(a)
- : ObjectArrays.toArrayImpl(requireElements(), 0, size, a);
+ : ObjectArrays.toArrayImpl(elements, 0, size, a);
}
/**
@@ -630,7 +612,7 @@
if (needsAllocArrays()) {
return;
}
- Set<E> delegate = delegateOrNull();
+ @NullableDecl Set<E> delegate = delegateOrNull();
if (delegate != null) {
Set<E> newDelegate = createHashFloodingResistantDelegate(size());
newDelegate.addAll(delegate);
@@ -638,7 +620,7 @@
return;
}
int size = this.size;
- if (size < requireEntries().length) {
+ if (size < entries.length) {
resizeEntries(size);
}
int minimumTableSize = CompactHashing.tableSize(size);
@@ -654,7 +636,7 @@
return;
}
incrementModCount();
- Set<E> delegate = delegateOrNull();
+ @NullableDecl Set<E> delegate = delegateOrNull();
if (delegate != null) {
metadata =
Ints.constrainToRange(size(), CompactHashing.DEFAULT_SIZE, CompactHashing.MAX_SIZE);
@@ -662,9 +644,9 @@
table = null;
size = 0;
} else {
- Arrays.fill(requireElements(), 0, size, null);
- CompactHashing.tableClear(requireTable());
- Arrays.fill(requireEntries(), 0, size, 0);
+ Arrays.fill(elements, 0, size, null);
+ CompactHashing.tableClear(table);
+ Arrays.fill(entries, 0, size, 0);
this.size = 0;
}
}
@@ -690,38 +672,4 @@
add(element);
}
}
-
- /*
- * For discussion of the safety of the following methods, see the comments near the end of
- * CompactHashMap.
- */
-
- private Object requireTable() {
- return requireNonNull(table);
- }
-
- private int[] requireEntries() {
- return requireNonNull(entries);
- }
-
- private @Nullable Object[] requireElements() {
- return requireNonNull(elements);
- }
-
- @SuppressWarnings("unchecked")
- private E element(int i) {
- return (E) requireElements()[i];
- }
-
- private int entry(int i) {
- return requireEntries()[i];
- }
-
- private void setElement(int i, E value) {
- requireElements()[i] = value;
- }
-
- private void setEntry(int i, int value) {
- requireEntries()[i] = value;
- }
}
diff --git a/android/guava/src/com/google/common/collect/CompactHashing.java b/android/guava/src/com/google/common/collect/CompactHashing.java
index a8fe902..7e83a05 100644
--- a/android/guava/src/com/google/common/collect/CompactHashing.java
+++ b/android/guava/src/com/google/common/collect/CompactHashing.java
@@ -20,8 +20,7 @@
import com.google.common.base.Objects;
import com.google.common.primitives.Ints;
import java.util.Arrays;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* Helper classes and static methods for implementing compact hash-based collections.
@@ -29,7 +28,6 @@
* @author Jon Noack
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
final class CompactHashing {
private CompactHashing() {}
@@ -98,11 +96,6 @@
}
}
- /**
- * Returns {@code table[index]}, where {@code table} is actually a {@code byte[]}, {@code
- * short[]}, or {@code int[]}. When it is a {@code byte[]} or {@code short[]}, the returned value
- * is unsigned, so the range of possible returned values is 0–255 or 0–65535, respectively.
- */
static int tableGet(Object table, int index) {
if (table instanceof byte[]) {
return ((byte[]) table)[index] & BYTE_MASK; // unsigned read
@@ -113,13 +106,6 @@
}
}
- /**
- * Sets {@code table[index]} to {@code entry}, where {@code table} is actually a {@code byte[]},
- * {@code short[]}, or {@code int[]}. The value of {@code entry} should fit in the size of the
- * assigned array element, when seen as an unsigned value. So if {@code table} is a {@code byte[]}
- * then we should have {@code 0 ≤ entry ≤ 255}, and if {@code table} is a {@code short[]} then we
- * should have {@code 0 ≤ entry ≤ 65535}. It is the caller's responsibility to ensure this.
- */
static void tableSet(Object table, int index, int entry) {
if (table instanceof byte[]) {
((byte[]) table)[index] = (byte) entry; // unsigned write
@@ -157,13 +143,13 @@
}
static int remove(
- @CheckForNull Object key,
- @CheckForNull Object value,
+ @NullableDecl Object key,
+ @NullableDecl Object value,
int mask,
Object table,
int[] entries,
- @Nullable Object[] keys,
- @CheckForNull @Nullable Object[] values) {
+ Object[] keys,
+ @NullableDecl Object[] values) {
int hash = Hashing.smearedHash(key);
int tableIndex = hash & mask;
int next = tableGet(table, tableIndex);
diff --git a/android/guava/src/com/google/common/collect/CompactLinkedHashMap.java b/android/guava/src/com/google/common/collect/CompactLinkedHashMap.java
index fb648a7..9135524 100644
--- a/android/guava/src/com/google/common/collect/CompactLinkedHashMap.java
+++ b/android/guava/src/com/google/common/collect/CompactLinkedHashMap.java
@@ -16,16 +16,13 @@
package com.google.common.collect;
-import static java.util.Objects.requireNonNull;
-
import com.google.common.annotations.GwtIncompatible;
import com.google.common.annotations.VisibleForTesting;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.Map;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* CompactLinkedHashMap is an implementation of a Map with insertion or LRU iteration order,
@@ -48,14 +45,11 @@
* @author Louis Wasserman
*/
@GwtIncompatible // not worth using in GWT for now
-@ElementTypesAreNonnullByDefault
-class CompactLinkedHashMap<K extends @Nullable Object, V extends @Nullable Object>
- extends CompactHashMap<K, V> {
+class CompactLinkedHashMap<K, V> extends CompactHashMap<K, V> {
// TODO(lowasser): implement removeEldestEntry so this can be used as a drop-in replacement
/** Creates an empty {@code CompactLinkedHashMap} instance. */
- public static <K extends @Nullable Object, V extends @Nullable Object>
- CompactLinkedHashMap<K, V> create() {
+ public static <K, V> CompactLinkedHashMap<K, V> create() {
return new CompactLinkedHashMap<>();
}
@@ -68,8 +62,7 @@
* expectedSize} elements without resizing
* @throws IllegalArgumentException if {@code expectedSize} is negative
*/
- public static <K extends @Nullable Object, V extends @Nullable Object>
- CompactLinkedHashMap<K, V> createWithExpectedSize(int expectedSize) {
+ public static <K, V> CompactLinkedHashMap<K, V> createWithExpectedSize(int expectedSize) {
return new CompactLinkedHashMap<>(expectedSize);
}
@@ -84,7 +77,7 @@
* <p>A node with "prev" pointer equal to {@code ENDPOINT} is the first node in the linked list,
* and a node with "next" pointer equal to {@code ENDPOINT} is the last node.
*/
- @CheckForNull @VisibleForTesting transient long[] links;
+ @VisibleForTesting @NullableDecl transient long[] links;
/** Pointer to the first node in the linked list, or {@code ENDPOINT} if there are no entries. */
private transient int firstEntry;
@@ -134,29 +127,23 @@
return result;
}
- /*
- * For discussion of the safety of the following methods for operating on predecessors and
- * successors, see the comments near the end of CompactHashMap, noting that the methods here call
- * link(), which is defined at the end of this file.
- */
-
private int getPredecessor(int entry) {
- return ((int) (link(entry) >>> 32)) - 1;
+ return ((int) (links[entry] >>> 32)) - 1;
}
@Override
int getSuccessor(int entry) {
- return ((int) link(entry)) - 1;
+ return ((int) links[entry]) - 1;
}
private void setSuccessor(int entry, int succ) {
long succMask = (~0L) >>> 32;
- setLink(entry, (link(entry) & ~succMask) | ((succ + 1) & succMask));
+ links[entry] = (links[entry] & ~succMask) | ((succ + 1) & succMask);
}
private void setPredecessor(int entry, int pred) {
long predMask = ~0L << 32;
- setLink(entry, (link(entry) & ~predMask) | ((long) (pred + 1) << 32));
+ links[entry] = (links[entry] & ~predMask) | ((long) (pred + 1) << 32);
}
private void setSucceeds(int pred, int succ) {
@@ -174,8 +161,7 @@
}
@Override
- void insertEntry(
- int entryIndex, @ParametricNullness K key, @ParametricNullness V value, int hash, int mask) {
+ void insertEntry(int entryIndex, @NullableDecl K key, @NullableDecl V value, int hash, int mask) {
super.insertEntry(entryIndex, key, value, hash, mask);
setSucceeds(lastEntry, entryIndex);
setSucceeds(entryIndex, ENDPOINT);
@@ -203,13 +189,13 @@
setSucceeds(getPredecessor(srcIndex), dstIndex);
setSucceeds(dstIndex, getSuccessor(srcIndex));
}
- setLink(srcIndex, 0);
+ links[srcIndex] = 0;
}
@Override
void resizeEntries(int newCapacity) {
super.resizeEntries(newCapacity);
- links = Arrays.copyOf(requireLinks(), newCapacity);
+ links = Arrays.copyOf(links, newCapacity);
}
@Override
@@ -234,27 +220,4 @@
}
super.clear();
}
-
- /*
- * For discussion of the safety of the following methods, see the comments near the end of
- * CompactHashMap.
- */
-
- private long[] requireLinks() {
- return requireNonNull(links);
- }
-
- private long link(int i) {
- return requireLinks()[i];
- }
-
- private void setLink(int i, long value) {
- requireLinks()[i] = value;
- }
-
- /*
- * We don't define getPredecessor+getSuccessor and setPredecessor+setSuccessor here because
- * they're defined above -- including logic to add and subtract 1 to map between the values stored
- * in the predecessor/successor arrays and the indexes in the elements array that they identify.
- */
}
diff --git a/android/guava/src/com/google/common/collect/CompactLinkedHashSet.java b/android/guava/src/com/google/common/collect/CompactLinkedHashSet.java
index 21d4805..4f9aa4a 100644
--- a/android/guava/src/com/google/common/collect/CompactLinkedHashSet.java
+++ b/android/guava/src/com/google/common/collect/CompactLinkedHashSet.java
@@ -16,16 +16,13 @@
package com.google.common.collect;
-import static java.util.Objects.requireNonNull;
-
import com.google.common.annotations.GwtIncompatible;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Set;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* CompactLinkedHashSet is an implementation of a Set, which a predictable iteration order that
@@ -49,11 +46,10 @@
* @author Louis Wasserman
*/
@GwtIncompatible // not worth using in GWT for now
-@ElementTypesAreNonnullByDefault
-class CompactLinkedHashSet<E extends @Nullable Object> extends CompactHashSet<E> {
+class CompactLinkedHashSet<E> extends CompactHashSet<E> {
/** Creates an empty {@code CompactLinkedHashSet} instance. */
- public static <E extends @Nullable Object> CompactLinkedHashSet<E> create() {
+ public static <E> CompactLinkedHashSet<E> create() {
return new CompactLinkedHashSet<>();
}
@@ -64,8 +60,7 @@
* @param collection the elements that the set should contain
* @return a new {@code CompactLinkedHashSet} containing those elements (minus duplicates)
*/
- public static <E extends @Nullable Object> CompactLinkedHashSet<E> create(
- Collection<? extends E> collection) {
+ public static <E> CompactLinkedHashSet<E> create(Collection<? extends E> collection) {
CompactLinkedHashSet<E> set = createWithExpectedSize(collection.size());
set.addAll(collection);
return set;
@@ -79,7 +74,7 @@
* @return a new {@code CompactLinkedHashSet} containing those elements (minus duplicates)
*/
@SafeVarargs
- public static <E extends @Nullable Object> CompactLinkedHashSet<E> create(E... elements) {
+ public static <E> CompactLinkedHashSet<E> create(E... elements) {
CompactLinkedHashSet<E> set = createWithExpectedSize(elements.length);
Collections.addAll(set, elements);
return set;
@@ -94,8 +89,7 @@
* expectedSize} elements without resizing
* @throws IllegalArgumentException if {@code expectedSize} is negative
*/
- public static <E extends @Nullable Object> CompactLinkedHashSet<E> createWithExpectedSize(
- int expectedSize) {
+ public static <E> CompactLinkedHashSet<E> createWithExpectedSize(int expectedSize) {
return new CompactLinkedHashSet<>(expectedSize);
}
@@ -109,13 +103,13 @@
* Pointer to the predecessor of an entry in insertion order. ENDPOINT indicates a node is the
* first node in insertion order; all values at indices ≥ {@link #size()} are UNSET.
*/
- @CheckForNull private transient int[] predecessor;
+ @NullableDecl private transient int[] predecessor;
/**
* Pointer to the successor of an entry in insertion order. ENDPOINT indicates a node is the last
* node in insertion order; all values at indices ≥ {@link #size()} are UNSET.
*/
- @CheckForNull private transient int[] successor;
+ @NullableDecl private transient int[] successor;
/** Pointer to the first node in the linked list, or {@code ENDPOINT} if there are no entries. */
private transient int firstEntry;
@@ -155,27 +149,21 @@
return result;
}
- /*
- * For discussion of the safety of the following methods for operating on predecessors and
- * successors, see the comments near the end of CompactHashMap, noting that the methods here call
- * requirePredecessors() and requireSuccessors(), which are defined at the end of this file.
- */
-
private int getPredecessor(int entry) {
- return requirePredecessors()[entry] - 1;
+ return predecessor[entry] - 1;
}
@Override
int getSuccessor(int entry) {
- return requireSuccessors()[entry] - 1;
+ return successor[entry] - 1;
}
private void setSuccessor(int entry, int succ) {
- requireSuccessors()[entry] = succ + 1;
+ successor[entry] = succ + 1;
}
private void setPredecessor(int entry, int pred) {
- requirePredecessors()[entry] = pred + 1;
+ predecessor[entry] = pred + 1;
}
private void setSucceeds(int pred, int succ) {
@@ -193,7 +181,7 @@
}
@Override
- void insertEntry(int entryIndex, @ParametricNullness E object, int hash, int mask) {
+ void insertEntry(int entryIndex, @NullableDecl E object, int hash, int mask) {
super.insertEntry(entryIndex, object, hash, mask);
setSucceeds(lastEntry, entryIndex);
setSucceeds(entryIndex, ENDPOINT);
@@ -209,15 +197,15 @@
setSucceeds(getPredecessor(srcIndex), dstIndex);
setSucceeds(dstIndex, getSuccessor(srcIndex));
}
- requirePredecessors()[srcIndex] = 0;
- requireSuccessors()[srcIndex] = 0;
+ predecessor[srcIndex] = 0;
+ successor[srcIndex] = 0;
}
@Override
void resizeEntries(int newCapacity) {
super.resizeEntries(newCapacity);
- predecessor = Arrays.copyOf(requirePredecessors(), newCapacity);
- successor = Arrays.copyOf(requireSuccessors(), newCapacity);
+ predecessor = Arrays.copyOf(predecessor, newCapacity);
+ successor = Arrays.copyOf(successor, newCapacity);
}
@Override
@@ -231,13 +219,12 @@
}
@Override
- public @Nullable Object[] toArray() {
+ public Object[] toArray() {
return ObjectArrays.toArrayImpl(this);
}
@Override
- @SuppressWarnings("nullness") // b/192354773 in our checker affects toArray declarations
- public <T extends @Nullable Object> T[] toArray(T[] a) {
+ public <T> T[] toArray(T[] a) {
return ObjectArrays.toArrayImpl(this, a);
}
@@ -248,30 +235,10 @@
}
this.firstEntry = ENDPOINT;
this.lastEntry = ENDPOINT;
- // Either both arrays are null or neither is, but we check both to satisfy the nullness checker.
- if (predecessor != null && successor != null) {
+ if (predecessor != null) {
Arrays.fill(predecessor, 0, size(), 0);
Arrays.fill(successor, 0, size(), 0);
}
super.clear();
}
-
- /*
- * For discussion of the safety of the following methods, see the comments near the end of
- * CompactHashMap.
- */
-
- private int[] requirePredecessors() {
- return requireNonNull(predecessor);
- }
-
- private int[] requireSuccessors() {
- return requireNonNull(successor);
- }
-
- /*
- * We don't define getPredecessor+getSuccessor and setPredecessor+setSuccessor here because
- * they're defined above -- including logic to add and subtract 1 to map between the values stored
- * in the predecessor/successor arrays and the indexes in the elements array that they identify.
- */
}
diff --git a/android/guava/src/com/google/common/collect/ComparatorOrdering.java b/android/guava/src/com/google/common/collect/ComparatorOrdering.java
index 8b34070..a408920 100644
--- a/android/guava/src/com/google/common/collect/ComparatorOrdering.java
+++ b/android/guava/src/com/google/common/collect/ComparatorOrdering.java
@@ -21,14 +21,11 @@
import com.google.common.annotations.GwtCompatible;
import java.io.Serializable;
import java.util.Comparator;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/** An ordering for a pre-existing comparator. */
@GwtCompatible(serializable = true)
-@ElementTypesAreNonnullByDefault
-final class ComparatorOrdering<T extends @Nullable Object> extends Ordering<T>
- implements Serializable {
+final class ComparatorOrdering<T> extends Ordering<T> implements Serializable {
final Comparator<T> comparator;
ComparatorOrdering(Comparator<T> comparator) {
@@ -36,12 +33,12 @@
}
@Override
- public int compare(@ParametricNullness T a, @ParametricNullness T b) {
+ public int compare(T a, T b) {
return comparator.compare(a, b);
}
@Override
- public boolean equals(@CheckForNull Object object) {
+ public boolean equals(@NullableDecl Object object) {
if (object == this) {
return true;
}
diff --git a/android/guava/src/com/google/common/collect/Comparators.java b/android/guava/src/com/google/common/collect/Comparators.java
index 6a5670c..555e5b8 100644
--- a/android/guava/src/com/google/common/collect/Comparators.java
+++ b/android/guava/src/com/google/common/collect/Comparators.java
@@ -22,7 +22,7 @@
import com.google.common.annotations.GwtCompatible;
import java.util.Comparator;
import java.util.Iterator;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* Provides static methods for working with {@link Comparator} instances. For many other helpful
@@ -41,7 +41,6 @@
*/
@Beta
@GwtCompatible
-@ElementTypesAreNonnullByDefault
public final class Comparators {
private Comparators() {}
@@ -59,8 +58,7 @@
// Note: 90% of the time we don't add type parameters or wildcards that serve only to "tweak" the
// desired return type. However, *nested* generics introduce a special class of problems that we
// think tip it over into being worthwhile.
- public static <T extends @Nullable Object, S extends T> Comparator<Iterable<S>> lexicographical(
- Comparator<T> comparator) {
+ public static <T, S extends T> Comparator<Iterable<S>> lexicographical(Comparator<T> comparator) {
return new LexicographicalOrdering<S>(checkNotNull(comparator));
}
@@ -69,8 +67,7 @@
* equal to the element that preceded it, according to the specified comparator. Note that this is
* always true when the iterable has fewer than two elements.
*/
- public static <T extends @Nullable Object> boolean isInOrder(
- Iterable<? extends T> iterable, Comparator<T> comparator) {
+ public static <T> boolean isInOrder(Iterable<? extends T> iterable, Comparator<T> comparator) {
checkNotNull(comparator);
Iterator<? extends T> it = iterable.iterator();
if (it.hasNext()) {
@@ -91,7 +88,7 @@
* greater than the element that preceded it, according to the specified comparator. Note that
* this is always true when the iterable has fewer than two elements.
*/
- public static <T extends @Nullable Object> boolean isInStrictOrder(
+ public static <T> boolean isInStrictOrder(
Iterable<? extends T> iterable, Comparator<T> comparator) {
checkNotNull(comparator);
Iterator<? extends T> it = iterable.iterator();
@@ -142,9 +139,7 @@
* @since 30.0
*/
@Beta
- @ParametricNullness
- public static <T extends @Nullable Object> T min(
- @ParametricNullness T a, @ParametricNullness T b, Comparator<T> comparator) {
+ public static <T> T min(@NullableDecl T a, @NullableDecl T b, Comparator<T> comparator) {
return (comparator.compare(a, b) <= 0) ? a : b;
}
@@ -182,9 +177,7 @@
* @since 30.0
*/
@Beta
- @ParametricNullness
- public static <T extends @Nullable Object> T max(
- @ParametricNullness T a, @ParametricNullness T b, Comparator<T> comparator) {
+ public static <T> T max(@NullableDecl T a, @NullableDecl T b, Comparator<T> comparator) {
return (comparator.compare(a, b) >= 0) ? a : b;
}
}
diff --git a/android/guava/src/com/google/common/collect/ComparisonChain.java b/android/guava/src/com/google/common/collect/ComparisonChain.java
index 32aeb4d..2f74896 100644
--- a/android/guava/src/com/google/common/collect/ComparisonChain.java
+++ b/android/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.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* A utility for performing a chained comparison statement. For example:
@@ -57,7 +57,6 @@
* @since 2.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
public abstract class ComparisonChain {
private ComparisonChain() {}
@@ -68,15 +67,15 @@
private static final ComparisonChain ACTIVE =
new ComparisonChain() {
- @SuppressWarnings("unchecked") // unsafe; see discussion on supertype
+ @SuppressWarnings("unchecked")
@Override
- public ComparisonChain compare(Comparable<?> left, Comparable<?> right) {
- return classify(((Comparable<Object>) left).compareTo(right));
+ public ComparisonChain compare(Comparable left, Comparable right) {
+ return classify(left.compareTo(right));
}
@Override
- public <T extends @Nullable Object> ComparisonChain compare(
- @ParametricNullness T left, @ParametricNullness T right, Comparator<T> comparator) {
+ public <T> ComparisonChain compare(
+ @NullableDecl T left, @NullableDecl T right, Comparator<T> comparator) {
return classify(comparator.compare(left, right));
}
@@ -132,13 +131,13 @@
}
@Override
- public ComparisonChain compare(Comparable<?> left, Comparable<?> right) {
+ public ComparisonChain compare(@NullableDecl Comparable left, @NullableDecl Comparable right) {
return this;
}
@Override
- public <T extends @Nullable Object> ComparisonChain compare(
- @ParametricNullness T left, @ParametricNullness T right, Comparator<T> comparator) {
+ public <T> ComparisonChain compare(
+ @NullableDecl T left, @NullableDecl T right, @NullableDecl Comparator<T> comparator) {
return this;
}
@@ -181,18 +180,6 @@
/**
* Compares two comparable objects as specified by {@link Comparable#compareTo}, <i>if</i> the
* result of this comparison chain has not already been determined.
- *
- * <p>This method is declared to accept any 2 {@code Comparable} objects, even if they are not <a
- * href="https://docs.oracle.com/javase/tutorial/collections/interfaces/order.html">mutually
- * comparable</a>. If you pass objects that are not mutually comparable, this method may throw an
- * exception. (The reason for this decision is lost to time, but the reason <i>might</i> be that
- * we wanted to support legacy classes that implement the raw type {@code Comparable} (instead of
- * implementing {@code Comparable<Foo>}) without producing warnings. If so, we would prefer today
- * to produce warnings in that case, and we may change this method to do so in the future. Support
- * for raw {@code Comparable} types in Guava in general is tracked as <a
- * href="https://github.com/google/guava/issues/989">#989</a>.)
- *
- * @throws ClassCastException if the parameters are not mutually comparable
*/
public abstract ComparisonChain compare(Comparable<?> left, Comparable<?> right);
@@ -200,8 +187,8 @@
* Compares two objects using a comparator, <i>if</i> the result of this comparison chain has not
* already been determined.
*/
- public abstract <T extends @Nullable Object> ComparisonChain compare(
- @ParametricNullness T left, @ParametricNullness T right, Comparator<T> comparator);
+ public abstract <T> ComparisonChain compare(
+ @NullableDecl T left, @NullableDecl T right, Comparator<T> comparator);
/**
* Compares two {@code int} values as specified by {@link Ints#compare}, <i>if</i> the result of
diff --git a/android/guava/src/com/google/common/collect/CompoundOrdering.java b/android/guava/src/com/google/common/collect/CompoundOrdering.java
index 42feed3..e803acb 100644
--- a/android/guava/src/com/google/common/collect/CompoundOrdering.java
+++ b/android/guava/src/com/google/common/collect/CompoundOrdering.java
@@ -20,14 +20,10 @@
import java.io.Serializable;
import java.util.Arrays;
import java.util.Comparator;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
/** An ordering that tries several comparators in order. */
@GwtCompatible(serializable = true)
-@ElementTypesAreNonnullByDefault
-final class CompoundOrdering<T extends @Nullable Object> extends Ordering<T>
- implements Serializable {
+final class CompoundOrdering<T> extends Ordering<T> implements Serializable {
final Comparator<? super T>[] comparators;
CompoundOrdering(Comparator<? super T> primary, Comparator<? super T> secondary) {
@@ -39,7 +35,7 @@
}
@Override
- public int compare(@ParametricNullness T left, @ParametricNullness T right) {
+ public int compare(T left, T right) {
for (int i = 0; i < comparators.length; i++) {
int result = comparators[i].compare(left, right);
if (result != 0) {
@@ -50,7 +46,7 @@
}
@Override
- public boolean equals(@CheckForNull Object object) {
+ public boolean equals(Object object) {
if (object == this) {
return true;
}
diff --git a/android/guava/src/com/google/common/collect/ComputationException.java b/android/guava/src/com/google/common/collect/ComputationException.java
index b05577c..dc569da 100644
--- a/android/guava/src/com/google/common/collect/ComputationException.java
+++ b/android/guava/src/com/google/common/collect/ComputationException.java
@@ -17,7 +17,7 @@
package com.google.common.collect;
import com.google.common.annotations.GwtCompatible;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* Wraps an exception that occurred during a computation.
@@ -34,10 +34,9 @@
*/
@Deprecated
@GwtCompatible
-@ElementTypesAreNonnullByDefault
public class ComputationException extends RuntimeException {
/** Creates a new instance with the given cause. */
- public ComputationException(@CheckForNull Throwable cause) {
+ public ComputationException(@NullableDecl Throwable cause) {
super(cause);
}
diff --git a/android/guava/src/com/google/common/collect/ConcurrentHashMultiset.java b/android/guava/src/com/google/common/collect/ConcurrentHashMultiset.java
index ab03ead..8bdfca3 100644
--- a/android/guava/src/com/google/common/collect/ConcurrentHashMultiset.java
+++ b/android/guava/src/com/google/common/collect/ConcurrentHashMultiset.java
@@ -18,8 +18,8 @@
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.base.Preconditions.checkState;
import static com.google.common.collect.CollectPreconditions.checkNonnegative;
+import static com.google.common.collect.CollectPreconditions.checkRemove;
import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtIncompatible;
@@ -41,8 +41,7 @@
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.atomic.AtomicInteger;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* A multiset that supports concurrent modifications and that provides atomic versions of most
@@ -57,7 +56,6 @@
* @since 2.0
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public final class ConcurrentHashMultiset<E> extends AbstractMultiset<E> implements Serializable {
/*
@@ -139,7 +137,7 @@
* @return the nonnegative number of occurrences of the element
*/
@Override
- public int count(@CheckForNull Object element) {
+ public int count(@NullableDecl Object element) {
AtomicInteger existingCounter = Maps.safeGet(countMap, element);
return (existingCounter == null) ? 0 : existingCounter.get();
}
@@ -170,8 +168,7 @@
}
@Override
- @SuppressWarnings("nullness") // b/192354773 in our checker affects toArray declarations
- public <T extends @Nullable Object> T[] toArray(T[] array) {
+ public <T> T[] toArray(T[] array) {
return snapshot().toArray(array);
}
@@ -208,7 +205,7 @@
if (occurrences == 0) {
return count(element);
}
- CollectPreconditions.checkPositive(occurrences, "occurrences");
+ CollectPreconditions.checkPositive(occurrences, "occurences");
while (true) {
AtomicInteger existingCounter = Maps.safeGet(countMap, element);
@@ -264,17 +261,17 @@
* if occurrences == 0. This satisfies both NullPointerTester and
* CollectionRemoveTester.testRemove_nullAllowed, but it's not clear that it's
* a good policy, especially because, in order for the test to pass, the
- * parameter must be misleadingly annotated as @Nullable. I suspect that
- * we'll want to remove @Nullable, add an eager checkNotNull, and loosen up
+ * parameter must be misleadingly annotated as @NullableDecl. I suspect that
+ * we'll want to remove @NullableDecl, add an eager checkNotNull, and loosen up
* testRemove_nullAllowed.
*/
@CanIgnoreReturnValue
@Override
- public int remove(@CheckForNull Object element, int occurrences) {
+ public int remove(@NullableDecl Object element, int occurrences) {
if (occurrences == 0) {
return count(element);
}
- CollectPreconditions.checkPositive(occurrences, "occurrences");
+ CollectPreconditions.checkPositive(occurrences, "occurences");
AtomicInteger existingCounter = Maps.safeGet(countMap, element);
if (existingCounter == null) {
@@ -311,11 +308,11 @@
* @throws IllegalArgumentException if {@code occurrences} is negative
*/
@CanIgnoreReturnValue
- public boolean removeExactly(@CheckForNull Object element, int occurrences) {
+ public boolean removeExactly(@NullableDecl Object element, int occurrences) {
if (occurrences == 0) {
return true;
}
- CollectPreconditions.checkPositive(occurrences, "occurrences");
+ CollectPreconditions.checkPositive(occurrences, "occurences");
AtomicInteger existingCounter = Maps.safeGet(countMap, element);
if (existingCounter == null) {
@@ -457,7 +454,7 @@
}
@Override
- public boolean contains(@CheckForNull Object object) {
+ public boolean contains(@NullableDecl Object object) {
return object != null && Collections2.safeContains(delegate, object);
}
@@ -467,7 +464,7 @@
}
@Override
- public boolean remove(@CheckForNull Object object) {
+ public boolean remove(Object object) {
return object != null && Collections2.safeRemove(delegate, object);
}
@@ -510,7 +507,6 @@
countMap.entrySet().iterator();
@Override
- @CheckForNull
protected Entry<E> computeNext() {
while (true) {
if (!mapEntries.hasNext()) {
@@ -526,7 +522,7 @@
};
return new ForwardingIterator<Entry<E>>() {
- @CheckForNull private Entry<E> last;
+ @NullableDecl private Entry<E> last;
@Override
protected Iterator<Entry<E>> delegate() {
@@ -541,7 +537,7 @@
@Override
public void remove() {
- checkState(last != null, "no calls to next() since the last call to remove()");
+ checkRemove(last != null);
ConcurrentHashMultiset.this.setCount(last.getElement(), 0);
last = null;
}
@@ -576,8 +572,7 @@
}
@Override
- @SuppressWarnings("nullness") // b/192354773 in our checker affects toArray declarations
- public <T extends @Nullable Object> T[] toArray(T[] array) {
+ public <T> T[] toArray(T[] array) {
return snapshot().toArray(array);
}
diff --git a/android/guava/src/com/google/common/collect/ConsumingQueueIterator.java b/android/guava/src/com/google/common/collect/ConsumingQueueIterator.java
index 7721e12..2f288f0 100644
--- a/android/guava/src/com/google/common/collect/ConsumingQueueIterator.java
+++ b/android/guava/src/com/google/common/collect/ConsumingQueueIterator.java
@@ -17,30 +17,29 @@
import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.annotations.GwtCompatible;
+import java.util.ArrayDeque;
+import java.util.Collections;
import java.util.Queue;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* An Iterator implementation which draws elements from a queue, removing them from the queue as it
* iterates.
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-final class ConsumingQueueIterator<T extends @Nullable Object> extends AbstractIterator<T> {
+class ConsumingQueueIterator<T> extends AbstractIterator<T> {
private final Queue<T> queue;
+ ConsumingQueueIterator(T... elements) {
+ this.queue = new ArrayDeque<T>(elements.length);
+ Collections.addAll(queue, elements);
+ }
+
ConsumingQueueIterator(Queue<T> queue) {
this.queue = checkNotNull(queue);
}
@Override
- @CheckForNull
public T computeNext() {
- // TODO(b/192579700): Use a ternary once it no longer confuses our nullness checker.
- if (queue.isEmpty()) {
- return endOfData();
- }
- return queue.remove();
+ return queue.isEmpty() ? endOfData() : queue.remove();
}
}
diff --git a/android/guava/src/com/google/common/collect/ContiguousSet.java b/android/guava/src/com/google/common/collect/ContiguousSet.java
index cd77042..6755be6 100644
--- a/android/guava/src/com/google/common/collect/ContiguousSet.java
+++ b/android/guava/src/com/google/common/collect/ContiguousSet.java
@@ -16,12 +16,10 @@
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
-import static java.util.Objects.requireNonNull;
import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.GwtIncompatible;
-import com.google.errorprone.annotations.DoNotCall;
import java.util.Collections;
import java.util.NoSuchElementException;
import java.util.Set;
@@ -50,7 +48,6 @@
*/
@GwtCompatible(emulated = true)
@SuppressWarnings("rawtypes") // allow ungenerified Comparable types
-@ElementTypesAreNonnullByDefault
public abstract class ContiguousSet<C extends Comparable> extends ImmutableSortedSet<C> {
/**
* Returns a {@code ContiguousSet} containing the same values in the given domain {@linkplain
@@ -76,19 +73,13 @@
throw new IllegalArgumentException(e);
}
- boolean empty;
- if (effectiveRange.isEmpty()) {
- empty = true;
- } else {
- /*
- * requireNonNull is safe because the effectiveRange operations above would have thrown or
- * effectiveRange.isEmpty() would have returned true.
- */
- C afterLower = requireNonNull(range.lowerBound.leastValueAbove(domain));
- C beforeUpper = requireNonNull(range.upperBound.greatestValueBelow(domain));
- // Per class spec, we are allowed to throw CCE if necessary
- empty = Range.compareOrThrow(afterLower, beforeUpper) > 0;
- }
+ // Per class spec, we are allowed to throw CCE if necessary
+ boolean empty =
+ effectiveRange.isEmpty()
+ || Range.compareOrThrow(
+ range.lowerBound.leastValueAbove(domain),
+ range.upperBound.greatestValueBelow(domain))
+ > 0;
return empty
? new EmptyContiguousSet<C>(domain)
@@ -200,14 +191,15 @@
/*
* These methods perform most headSet, subSet, and tailSet logic, besides parameter validation.
*/
- @SuppressWarnings("MissingOverride") // Supermethod does not exist under GWT.
+ // TODO(kevinb): we can probably make these real @Overrides now
+ /* @Override */
abstract ContiguousSet<C> headSetImpl(C toElement, boolean inclusive);
- @SuppressWarnings("MissingOverride") // Supermethod does not exist under GWT.
+ /* @Override */
abstract ContiguousSet<C> subSetImpl(
C fromElement, boolean fromInclusive, C toElement, boolean toInclusive);
- @SuppressWarnings("MissingOverride") // Supermethod does not exist under GWT.
+ /* @Override */
abstract ContiguousSet<C> tailSetImpl(C fromElement, boolean inclusive);
/**
@@ -260,7 +252,6 @@
* @deprecated Use {@link #create}.
*/
@Deprecated
- @DoNotCall("Always throws UnsupportedOperationException")
public static <E> ImmutableSortedSet.Builder<E> builder() {
throw new UnsupportedOperationException();
}
diff --git a/android/guava/src/com/google/common/collect/Count.java b/android/guava/src/com/google/common/collect/Count.java
index 7aa5550..9a0ea41 100644
--- a/android/guava/src/com/google/common/collect/Count.java
+++ b/android/guava/src/com/google/common/collect/Count.java
@@ -16,7 +16,7 @@
import com.google.common.annotations.GwtCompatible;
import java.io.Serializable;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* A mutable value of type {@code int}, for multisets to use in tracking counts of values.
@@ -24,7 +24,6 @@
* @author Louis Wasserman
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
final class Count implements Serializable {
private int value;
@@ -60,7 +59,7 @@
}
@Override
- public boolean equals(@CheckForNull Object obj) {
+ public boolean equals(@NullableDecl Object obj) {
return obj instanceof Count && ((Count) obj).value == value;
}
diff --git a/android/guava/src/com/google/common/collect/Cut.java b/android/guava/src/com/google/common/collect/Cut.java
index 4a8d4c7..b792d84 100644
--- a/android/guava/src/com/google/common/collect/Cut.java
+++ b/android/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 javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* Implementation detail for the internal structure of {@link Range} instances. Represents a unique
@@ -32,11 +32,10 @@
* @author Kevin Bourrillion
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
abstract class Cut<C extends Comparable> implements Comparable<Cut<C>>, Serializable {
- final C endpoint;
+ @NullableDecl final C endpoint;
- Cut(C endpoint) {
+ Cut(@NullableDecl C endpoint) {
this.endpoint = endpoint;
}
@@ -54,10 +53,8 @@
abstract void describeAsUpperBound(StringBuilder sb);
- @CheckForNull
abstract C leastValueAbove(DiscreteDomain<C> domain);
- @CheckForNull
abstract C greatestValueBelow(DiscreteDomain<C> domain);
/*
@@ -91,15 +88,14 @@
@SuppressWarnings("unchecked") // catching CCE
@Override
- public boolean equals(@CheckForNull Object obj) {
+ public boolean equals(Object obj) {
if (obj instanceof Cut) {
// It might not really be a Cut<C>, but we'll catch a CCE if it's not
Cut<C> that = (Cut<C>) obj;
try {
int compareResult = compareTo(that);
return compareResult == 0;
- } catch (ClassCastException wastNotComparableToOurType) {
- return false;
+ } catch (ClassCastException ignored) {
}
}
return false;
@@ -124,13 +120,7 @@
private static final BelowAll INSTANCE = new BelowAll();
private BelowAll() {
- /*
- * No code ever sees this bogus value for `endpoint`: This class overrides both methods that
- * use the `endpoint` field, compareTo() and endpoint(). Additionally, the main implementation
- * of Cut.compareTo checks for belowAll before reading accessing `endpoint` on another Cut
- * instance.
- */
- super("");
+ super(null);
}
@Override
@@ -229,8 +219,7 @@
private static final AboveAll INSTANCE = new AboveAll();
private AboveAll() {
- // For discussion of "", see BelowAll.
- super("");
+ super(null);
}
@Override
@@ -337,7 +326,7 @@
case CLOSED:
return this;
case OPEN:
- C previous = domain.previous(endpoint);
+ @NullableDecl C previous = domain.previous(endpoint);
return (previous == null) ? Cut.<C>belowAll() : new AboveValue<C>(previous);
default:
throw new AssertionError();
@@ -348,7 +337,7 @@
Cut<C> withUpperBoundType(BoundType boundType, DiscreteDomain<C> domain) {
switch (boundType) {
case CLOSED:
- C previous = domain.previous(endpoint);
+ @NullableDecl C previous = domain.previous(endpoint);
return (previous == null) ? Cut.<C>aboveAll() : new AboveValue<C>(previous);
case OPEN:
return this;
@@ -373,7 +362,6 @@
}
@Override
- @CheckForNull
C greatestValueBelow(DiscreteDomain<C> domain) {
return domain.previous(endpoint);
}
@@ -421,7 +409,7 @@
case OPEN:
return this;
case CLOSED:
- C next = domain.next(endpoint);
+ @NullableDecl C next = domain.next(endpoint);
return (next == null) ? Cut.<C>belowAll() : belowValue(next);
default:
throw new AssertionError();
@@ -432,7 +420,7 @@
Cut<C> withUpperBoundType(BoundType boundType, DiscreteDomain<C> domain) {
switch (boundType) {
case OPEN:
- C next = domain.next(endpoint);
+ @NullableDecl C next = domain.next(endpoint);
return (next == null) ? Cut.<C>aboveAll() : belowValue(next);
case CLOSED:
return this;
@@ -452,7 +440,6 @@
}
@Override
- @CheckForNull
C leastValueAbove(DiscreteDomain<C> domain) {
return domain.next(endpoint);
}
diff --git a/android/guava/src/com/google/common/collect/DenseImmutableTable.java b/android/guava/src/com/google/common/collect/DenseImmutableTable.java
index 9de77c5..4e28c89 100644
--- a/android/guava/src/com/google/common/collect/DenseImmutableTable.java
+++ b/android/guava/src/com/google/common/collect/DenseImmutableTable.java
@@ -14,20 +14,16 @@
package com.google.common.collect;
-import static java.util.Objects.requireNonNull;
-
import com.google.common.annotations.GwtCompatible;
import com.google.common.collect.ImmutableMap.IteratorBasedImmutableMap;
import com.google.errorprone.annotations.Immutable;
import com.google.j2objc.annotations.WeakOuter;
import java.util.Map;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/** A {@code RegularImmutableTable} optimized for dense data. */
@GwtCompatible
@Immutable(containerOf = {"R", "C", "V"})
-@ElementTypesAreNonnullByDefault
final class DenseImmutableTable<R, C, V> extends RegularImmutableTable<R, C, V> {
private final ImmutableMap<R, Integer> rowKeyToIndex;
private final ImmutableMap<C, Integer> columnKeyToIndex;
@@ -41,7 +37,7 @@
private final int[] columnCounts;
@SuppressWarnings("Immutable") // We don't modify this after construction.
- private final @Nullable V[][] values;
+ private final V[][] values;
// For each cell in iteration order, the index of that cell's row key in the row key list.
@SuppressWarnings("Immutable") // We don't modify this after construction.
@@ -56,8 +52,7 @@
ImmutableSet<R> rowSpace,
ImmutableSet<C> columnSpace) {
@SuppressWarnings("unchecked")
- @Nullable
- V[][] array = (@Nullable V[][]) new Object[rowSpace.size()][columnSpace.size()];
+ V[][] array = (V[][]) new Object[rowSpace.size()][columnSpace.size()];
this.values = array;
this.rowKeyToIndex = Maps.indexMap(rowSpace);
this.columnKeyToIndex = Maps.indexMap(columnSpace);
@@ -69,9 +64,8 @@
Cell<R, C, V> cell = cellList.get(i);
R rowKey = cell.getRowKey();
C columnKey = cell.getColumnKey();
- // The requireNonNull calls are safe because we construct the indexes with indexMap.
- int rowIndex = requireNonNull(rowKeyToIndex.get(rowKey));
- int columnIndex = requireNonNull(columnKeyToIndex.get(columnKey));
+ int rowIndex = rowKeyToIndex.get(rowKey);
+ int columnIndex = columnKeyToIndex.get(columnKey);
V existingValue = values[rowIndex][columnIndex];
checkNoDuplicate(rowKey, columnKey, existingValue, cell.getValue());
values[rowIndex][columnIndex] = cell.getValue();
@@ -105,7 +99,7 @@
return keyToIndex().keySet().asList().get(index);
}
- @CheckForNull
+ @NullableDecl
abstract V getValue(int keyIndex);
@Override
@@ -119,8 +113,7 @@
}
@Override
- @CheckForNull
- public V get(@CheckForNull Object key) {
+ public V get(@NullableDecl Object key) {
Integer keyIndex = keyToIndex().get(key);
return (keyIndex == null) ? null : getValue(keyIndex);
}
@@ -132,7 +125,6 @@
private final int maxIndex = keyToIndex().size();
@Override
- @CheckForNull
protected Entry<K, V> computeNext() {
for (index++; index < maxIndex; index++) {
V value = getValue(index);
@@ -160,7 +152,6 @@
}
@Override
- @CheckForNull
V getValue(int keyIndex) {
return values[rowIndex][keyIndex];
}
@@ -185,7 +176,6 @@
}
@Override
- @CheckForNull
V getValue(int keyIndex) {
return values[keyIndex][columnIndex];
}
@@ -255,8 +245,7 @@
}
@Override
- @CheckForNull
- public V get(@CheckForNull Object rowKey, @CheckForNull Object columnKey) {
+ public V get(@NullableDecl Object rowKey, @NullableDecl Object columnKey) {
Integer rowIndex = rowKeyToIndex.get(rowKey);
Integer columnIndex = columnKeyToIndex.get(columnKey);
return ((rowIndex == null) || (columnIndex == null)) ? null : values[rowIndex][columnIndex];
@@ -273,15 +262,13 @@
int columnIndex = cellColumnIndices[index];
R rowKey = rowKeySet().asList().get(rowIndex);
C columnKey = columnKeySet().asList().get(columnIndex);
- // requireNonNull is safe because we use indexes that were populated by the constructor.
- V value = requireNonNull(values[rowIndex][columnIndex]);
+ V value = values[rowIndex][columnIndex];
return cellOf(rowKey, columnKey, value);
}
@Override
V getValue(int index) {
- // requireNonNull is safe because we use indexes that were populated by the constructor.
- return requireNonNull(values[cellRowIndices[index]][cellColumnIndices[index]]);
+ return values[cellRowIndices[index]][cellColumnIndices[index]];
}
@Override
diff --git a/android/guava/src/com/google/common/collect/DescendingImmutableSortedMultiset.java b/android/guava/src/com/google/common/collect/DescendingImmutableSortedMultiset.java
index 181731c..189acdb 100644
--- a/android/guava/src/com/google/common/collect/DescendingImmutableSortedMultiset.java
+++ b/android/guava/src/com/google/common/collect/DescendingImmutableSortedMultiset.java
@@ -15,7 +15,7 @@
package com.google.common.collect;
import com.google.common.annotations.GwtIncompatible;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* A descending wrapper around an {@code ImmutableSortedMultiset}
@@ -24,7 +24,6 @@
*/
@SuppressWarnings("serial") // uses writeReplace, not default serialization
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
final class DescendingImmutableSortedMultiset<E> extends ImmutableSortedMultiset<E> {
private final transient ImmutableSortedMultiset<E> forward;
@@ -33,18 +32,16 @@
}
@Override
- public int count(@CheckForNull Object element) {
+ public int count(@NullableDecl Object element) {
return forward.count(element);
}
@Override
- @CheckForNull
public Entry<E> firstEntry() {
return forward.lastEntry();
}
@Override
- @CheckForNull
public Entry<E> lastEntry() {
return forward.firstEntry();
}
diff --git a/android/guava/src/com/google/common/collect/DescendingImmutableSortedSet.java b/android/guava/src/com/google/common/collect/DescendingImmutableSortedSet.java
index 88c7d6b..64e3e89 100644
--- a/android/guava/src/com/google/common/collect/DescendingImmutableSortedSet.java
+++ b/android/guava/src/com/google/common/collect/DescendingImmutableSortedSet.java
@@ -17,7 +17,7 @@
package com.google.common.collect;
import com.google.common.annotations.GwtIncompatible;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* Skeletal implementation of {@link ImmutableSortedSet#descendingSet()}.
@@ -25,7 +25,6 @@
* @author Louis Wasserman
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
final class DescendingImmutableSortedSet<E> extends ImmutableSortedSet<E> {
private final ImmutableSortedSet<E> forward;
@@ -35,7 +34,7 @@
}
@Override
- public boolean contains(@CheckForNull Object object) {
+ public boolean contains(@NullableDecl Object object) {
return forward.contains(object);
}
@@ -84,31 +83,27 @@
}
@Override
- @CheckForNull
public E lower(E element) {
return forward.higher(element);
}
@Override
- @CheckForNull
public E floor(E element) {
return forward.ceiling(element);
}
@Override
- @CheckForNull
public E ceiling(E element) {
return forward.floor(element);
}
@Override
- @CheckForNull
public E higher(E element) {
return forward.lower(element);
}
@Override
- int indexOf(@CheckForNull Object target) {
+ int indexOf(@NullableDecl Object target) {
int index = forward.indexOf(target);
if (index == -1) {
return index;
diff --git a/android/guava/src/com/google/common/collect/DescendingMultiset.java b/android/guava/src/com/google/common/collect/DescendingMultiset.java
index ec5a1d0..72a88af 100644
--- a/android/guava/src/com/google/common/collect/DescendingMultiset.java
+++ b/android/guava/src/com/google/common/collect/DescendingMultiset.java
@@ -22,8 +22,7 @@
import java.util.Iterator;
import java.util.NavigableSet;
import java.util.Set;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* A skeleton implementation of a descending multiset. Only needs {@code forwardMultiset()} and
@@ -32,12 +31,10 @@
* @author Louis Wasserman
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
-abstract class DescendingMultiset<E extends @Nullable Object> extends ForwardingMultiset<E>
- implements SortedMultiset<E> {
+abstract class DescendingMultiset<E> extends ForwardingMultiset<E> implements SortedMultiset<E> {
abstract SortedMultiset<E> forwardMultiset();
- @CheckForNull private transient Comparator<? super E> comparator;
+ @NullableDecl private transient Comparator<? super E> comparator;
@Override
public Comparator<? super E> comparator() {
@@ -48,7 +45,7 @@
return result;
}
- @CheckForNull private transient NavigableSet<E> elementSet;
+ @NullableDecl private transient NavigableSet<E> elementSet;
@Override
public NavigableSet<E> elementSet() {
@@ -60,35 +57,30 @@
}
@Override
- @CheckForNull
public Entry<E> pollFirstEntry() {
return forwardMultiset().pollLastEntry();
}
@Override
- @CheckForNull
public Entry<E> pollLastEntry() {
return forwardMultiset().pollFirstEntry();
}
@Override
- public SortedMultiset<E> headMultiset(@ParametricNullness E toElement, BoundType boundType) {
+ public SortedMultiset<E> headMultiset(E toElement, BoundType boundType) {
return forwardMultiset().tailMultiset(toElement, boundType).descendingMultiset();
}
@Override
public SortedMultiset<E> subMultiset(
- @ParametricNullness E fromElement,
- BoundType fromBoundType,
- @ParametricNullness E toElement,
- BoundType toBoundType) {
+ E fromElement, BoundType fromBoundType, E toElement, BoundType toBoundType) {
return forwardMultiset()
.subMultiset(toElement, toBoundType, fromElement, fromBoundType)
.descendingMultiset();
}
@Override
- public SortedMultiset<E> tailMultiset(@ParametricNullness E fromElement, BoundType boundType) {
+ public SortedMultiset<E> tailMultiset(E fromElement, BoundType boundType) {
return forwardMultiset().headMultiset(fromElement, boundType).descendingMultiset();
}
@@ -103,20 +95,18 @@
}
@Override
- @CheckForNull
public Entry<E> firstEntry() {
return forwardMultiset().lastEntry();
}
@Override
- @CheckForNull
public Entry<E> lastEntry() {
return forwardMultiset().firstEntry();
}
abstract Iterator<Entry<E>> entryIterator();
- @CheckForNull private transient Set<Entry<E>> entrySet;
+ @NullableDecl private transient Set<Entry<E>> entrySet;
@Override
public Set<Entry<E>> entrySet() {
@@ -151,13 +141,12 @@
}
@Override
- public @Nullable Object[] toArray() {
+ public Object[] toArray() {
return standardToArray();
}
@Override
- @SuppressWarnings("nullness") // b/192354773 in our checker affects toArray declarations
- public <T extends @Nullable Object> T[] toArray(T[] array) {
+ public <T> T[] toArray(T[] array) {
return standardToArray(array);
}
diff --git a/android/guava/src/com/google/common/collect/DiscreteDomain.java b/android/guava/src/com/google/common/collect/DiscreteDomain.java
index bce7062..3777a6d 100644
--- a/android/guava/src/com/google/common/collect/DiscreteDomain.java
+++ b/android/guava/src/com/google/common/collect/DiscreteDomain.java
@@ -25,7 +25,6 @@
import java.io.Serializable;
import java.math.BigInteger;
import java.util.NoSuchElementException;
-import javax.annotation.CheckForNull;
/**
* A descriptor for a <i>discrete</i> {@code Comparable} domain such as all {@link Integer}
@@ -44,7 +43,6 @@
* @since 10.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
public abstract class DiscreteDomain<C extends Comparable> {
/**
@@ -64,14 +62,12 @@
}
@Override
- @CheckForNull
public Integer next(Integer value) {
int i = value;
return (i == Integer.MAX_VALUE) ? null : i + 1;
}
@Override
- @CheckForNull
public Integer previous(Integer value) {
int i = value;
return (i == Integer.MIN_VALUE) ? null : i - 1;
@@ -127,14 +123,12 @@
}
@Override
- @CheckForNull
public Long next(Long value) {
long l = value;
return (l == Long.MAX_VALUE) ? null : l + 1;
}
@Override
- @CheckForNull
public Long previous(Long value) {
long l = value;
return (l == Long.MIN_VALUE) ? null : l - 1;
@@ -254,16 +248,11 @@
* #next} on {@code origin} {@code distance} times.
*/
C offset(C origin, long distance) {
- C current = origin;
checkNonnegative(distance, "distance");
for (long i = 0; i < distance; i++) {
- current = next(current);
- if (current == null) {
- throw new IllegalArgumentException(
- "overflowed computing offset(" + origin + ", " + distance + ")");
- }
+ origin = next(origin);
}
- return current;
+ return origin;
}
/**
@@ -274,7 +263,6 @@
* @return the least value greater than {@code value}, or {@code null} if {@code value} is {@code
* maxValue()}
*/
- @CheckForNull
public abstract C next(C value);
/**
@@ -285,7 +273,6 @@
* @return the greatest value less than {@code value}, or {@code null} if {@code value} is {@code
* minValue()}
*/
- @CheckForNull
public abstract C previous(C value);
/**
diff --git a/android/guava/src/com/google/common/collect/ElementTypesAreNonnullByDefault.java b/android/guava/src/com/google/common/collect/ElementTypesAreNonnullByDefault.java
deleted file mode 100644
index e1c640f..0000000
--- a/android/guava/src/com/google/common/collect/ElementTypesAreNonnullByDefault.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) 2021 The Guava Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.common.collect;
-
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.PARAMETER;
-import static java.lang.annotation.ElementType.TYPE;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-import com.google.common.annotations.GwtCompatible;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-import javax.annotation.Nonnull;
-import javax.annotation.meta.TypeQualifierDefault;
-
-/**
- * Marks all "top-level" types as non-null in a way that is recognized by Kotlin. Note that this
- * unfortunately includes type-variable usages, so we also provide {@link ParametricNullness} to
- * "undo" it as best we can.
- */
-@GwtCompatible
-@Retention(RUNTIME)
-@Target(TYPE)
-@TypeQualifierDefault({FIELD, METHOD, PARAMETER})
-@Nonnull
-@interface ElementTypesAreNonnullByDefault {}
diff --git a/android/guava/src/com/google/common/collect/EmptyContiguousSet.java b/android/guava/src/com/google/common/collect/EmptyContiguousSet.java
index f4fe33c..8043ef7 100644
--- a/android/guava/src/com/google/common/collect/EmptyContiguousSet.java
+++ b/android/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 javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* An empty contiguous set.
@@ -27,7 +27,6 @@
*/
@GwtCompatible(emulated = true)
@SuppressWarnings("rawtypes") // allow ungenerified Comparable types
-@ElementTypesAreNonnullByDefault
final class EmptyContiguousSet<C extends Comparable> extends ContiguousSet<C> {
EmptyContiguousSet(DiscreteDomain<C> domain) {
super(domain);
@@ -80,13 +79,13 @@
}
@Override
- public boolean contains(@CheckForNull Object object) {
+ public boolean contains(Object object) {
return false;
}
@GwtIncompatible // not used by GWT emulation
@Override
- int indexOf(@CheckForNull Object target) {
+ int indexOf(Object target) {
return -1;
}
@@ -122,7 +121,7 @@
}
@Override
- public boolean equals(@CheckForNull Object object) {
+ public boolean equals(@NullableDecl Object object) {
if (object instanceof Set) {
Set<?> that = (Set<?>) object;
return that.isEmpty();
diff --git a/android/guava/src/com/google/common/collect/EmptyImmutableListMultimap.java b/android/guava/src/com/google/common/collect/EmptyImmutableListMultimap.java
index 10d030f..9b167fb 100644
--- a/android/guava/src/com/google/common/collect/EmptyImmutableListMultimap.java
+++ b/android/guava/src/com/google/common/collect/EmptyImmutableListMultimap.java
@@ -24,7 +24,6 @@
* @author Jared Levy
*/
@GwtCompatible(serializable = true)
-@ElementTypesAreNonnullByDefault
class EmptyImmutableListMultimap extends ImmutableListMultimap<Object, Object> {
static final EmptyImmutableListMultimap INSTANCE = new EmptyImmutableListMultimap();
diff --git a/android/guava/src/com/google/common/collect/EmptyImmutableSetMultimap.java b/android/guava/src/com/google/common/collect/EmptyImmutableSetMultimap.java
index bd0a67a..ec2ce2e 100644
--- a/android/guava/src/com/google/common/collect/EmptyImmutableSetMultimap.java
+++ b/android/guava/src/com/google/common/collect/EmptyImmutableSetMultimap.java
@@ -24,7 +24,6 @@
* @author Mike Ward
*/
@GwtCompatible(serializable = true)
-@ElementTypesAreNonnullByDefault
class EmptyImmutableSetMultimap extends ImmutableSetMultimap<Object, Object> {
static final EmptyImmutableSetMultimap INSTANCE = new EmptyImmutableSetMultimap();
diff --git a/android/guava/src/com/google/common/collect/EnumBiMap.java b/android/guava/src/com/google/common/collect/EnumBiMap.java
index 82aa052..f72b8b9 100644
--- a/android/guava/src/com/google/common/collect/EnumBiMap.java
+++ b/android/guava/src/com/google/common/collect/EnumBiMap.java
@@ -38,7 +38,6 @@
* @since 2.0
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
public final class EnumBiMap<K extends Enum<K>, V extends Enum<V>> extends AbstractBiMap<K, V> {
private transient Class<K> keyType;
private transient Class<V> valueType;
diff --git a/android/guava/src/com/google/common/collect/EnumHashBiMap.java b/android/guava/src/com/google/common/collect/EnumHashBiMap.java
index f68bc4c..0a7e52e 100644
--- a/android/guava/src/com/google/common/collect/EnumHashBiMap.java
+++ b/android/guava/src/com/google/common/collect/EnumHashBiMap.java
@@ -27,8 +27,7 @@
import java.util.EnumMap;
import java.util.HashMap;
import java.util.Map;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* A {@code BiMap} backed by an {@code EnumMap} instance for keys-to-values, and a {@code HashMap}
@@ -42,9 +41,7 @@
* @since 2.0
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
-public final class EnumHashBiMap<K extends Enum<K>, V extends @Nullable Object>
- extends AbstractBiMap<K, V> {
+public final class EnumHashBiMap<K extends Enum<K>, V> extends AbstractBiMap<K, V> {
private transient Class<K> keyType;
/**
@@ -52,8 +49,7 @@
*
* @param keyType the key type
*/
- public static <K extends Enum<K>, V extends @Nullable Object> EnumHashBiMap<K, V> create(
- Class<K> keyType) {
+ public static <K extends Enum<K>, V> EnumHashBiMap<K, V> create(Class<K> keyType) {
return new EnumHashBiMap<>(keyType);
}
@@ -67,8 +63,7 @@
* @throws IllegalArgumentException if map is not an {@code EnumBiMap} or an {@code EnumHashBiMap}
* instance and contains no mappings
*/
- public static <K extends Enum<K>, V extends @Nullable Object> EnumHashBiMap<K, V> create(
- Map<K, ? extends V> map) {
+ public static <K extends Enum<K>, V> EnumHashBiMap<K, V> create(Map<K, ? extends V> map) {
EnumHashBiMap<K, V> bimap = create(EnumBiMap.inferKeyType(map));
bimap.putAll(map);
return bimap;
@@ -90,19 +85,13 @@
@CanIgnoreReturnValue
@Override
- @SuppressWarnings("RedundantOverride") // b/192446478: RedundantOverride ignores some annotations.
- // TODO(b/192446998): Remove this override after tools understand nullness better.
- @CheckForNull
- public V put(K key, @ParametricNullness V value) {
+ public V put(K key, @NullableDecl V value) {
return super.put(key, value);
}
@CanIgnoreReturnValue
@Override
- @SuppressWarnings("RedundantOverride") // b/192446478: RedundantOverride ignores some annotations.
- // TODO(b/192446998): Remove this override after tools understand nullness better.
- @CheckForNull
- public V forcePut(K key, @ParametricNullness V value) {
+ public V forcePut(K key, @NullableDecl V value) {
return super.forcePut(key, value);
}
diff --git a/android/guava/src/com/google/common/collect/EnumMultiset.java b/android/guava/src/com/google/common/collect/EnumMultiset.java
index 0fed4ad..af0deef 100644
--- a/android/guava/src/com/google/common/collect/EnumMultiset.java
+++ b/android/guava/src/com/google/common/collect/EnumMultiset.java
@@ -30,7 +30,7 @@
import java.util.Arrays;
import java.util.Iterator;
import java.util.NoSuchElementException;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* Multiset implementation specialized for enum elements, supporting all single-element operations
@@ -44,7 +44,6 @@
* @since 2.0
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
public final class EnumMultiset<E extends Enum<E>> extends AbstractMultiset<E>
implements Serializable {
/** Creates an empty {@code EnumMultiset}. */
@@ -94,7 +93,7 @@
this.counts = new int[enumConstants.length];
}
- private boolean isActuallyE(@CheckForNull Object o) {
+ private boolean isActuallyE(@NullableDecl Object o) {
if (o instanceof Enum) {
Enum<?> e = (Enum<?>) o;
int index = e.ordinal();
@@ -107,7 +106,7 @@
* Returns {@code element} cast to {@code E}, if it actually is a nonnull E. Otherwise, throws
* either a NullPointerException or a ClassCastException as appropriate.
*/
- private void checkIsE(Object element) {
+ void checkIsE(@NullableDecl Object element) {
checkNotNull(element);
if (!isActuallyE(element)) {
throw new ClassCastException("Expected an " + type + " but got " + element);
@@ -125,9 +124,8 @@
}
@Override
- public int count(@CheckForNull Object element) {
- // isActuallyE checks for null, but we check explicitly to help nullness checkers.
- if (element == null || !isActuallyE(element)) {
+ public int count(@NullableDecl Object element) {
+ if (!isActuallyE(element)) {
return 0;
}
Enum<?> e = (Enum<?>) element;
@@ -158,9 +156,8 @@
// Modification Operations
@CanIgnoreReturnValue
@Override
- public int remove(@CheckForNull Object element, int occurrences) {
- // isActuallyE checks for null, but we check explicitly to help nullness checkers.
- if (element == null || !isActuallyE(element)) {
+ public int remove(@NullableDecl Object element, int occurrences) {
+ if (!isActuallyE(element)) {
return 0;
}
Enum<?> e = (Enum<?>) element;
diff --git a/android/guava/src/com/google/common/collect/EvictingQueue.java b/android/guava/src/com/google/common/collect/EvictingQueue.java
index 45f59f3..37a65f3 100644
--- a/android/guava/src/com/google/common/collect/EvictingQueue.java
+++ b/android/guava/src/com/google/common/collect/EvictingQueue.java
@@ -45,7 +45,6 @@
*/
@Beta
@GwtCompatible
-@ElementTypesAreNonnullByDefault
public final class EvictingQueue<E> extends ForwardingQueue<E> implements Serializable {
private final Queue<E> delegate;
@@ -127,19 +126,17 @@
}
@Override
- public Object[] toArray() {
- /*
- * If we could, we'd declare the no-arg `Collection.toArray()` to return "Object[] but elements
- * have the same nullness as E." Since we can't, we declare it to return nullable elements, and
- * we can override it in our non-null-guaranteeing subtypes to present a better signature to
- * their users.
- *
- * However, the checker *we* use has this special knowledge about `Collection.toArray()` anyway,
- * so in our implementation code, we can rely on that. That's why the expression below
- * type-checks.
- */
- return super.toArray();
+ public boolean contains(Object object) {
+ return delegate().contains(checkNotNull(object));
}
+ @Override
+ @CanIgnoreReturnValue
+ public boolean remove(Object object) {
+ return delegate().remove(checkNotNull(object));
+ }
+
+ // TODO(kak): Do we want to checkNotNull each element in containsAll, removeAll, and retainAll?
+
private static final long serialVersionUID = 0L;
}
diff --git a/android/guava/src/com/google/common/collect/ExplicitOrdering.java b/android/guava/src/com/google/common/collect/ExplicitOrdering.java
index 383318a..710c1ae 100644
--- a/android/guava/src/com/google/common/collect/ExplicitOrdering.java
+++ b/android/guava/src/com/google/common/collect/ExplicitOrdering.java
@@ -19,11 +19,10 @@
import com.google.common.annotations.GwtCompatible;
import java.io.Serializable;
import java.util.List;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/** An ordering that compares objects according to a given order. */
@GwtCompatible(serializable = true)
-@ElementTypesAreNonnullByDefault
final class ExplicitOrdering<T> extends Ordering<T> implements Serializable {
final ImmutableMap<T, Integer> rankMap;
@@ -49,7 +48,7 @@
}
@Override
- public boolean equals(@CheckForNull Object object) {
+ public boolean equals(@NullableDecl Object object) {
if (object instanceof ExplicitOrdering) {
ExplicitOrdering<?> that = (ExplicitOrdering<?>) object;
return this.rankMap.equals(that.rankMap);
diff --git a/android/guava/src/com/google/common/collect/FilteredEntryMultimap.java b/android/guava/src/com/google/common/collect/FilteredEntryMultimap.java
index 3ff00b7..5860d88 100644
--- a/android/guava/src/com/google/common/collect/FilteredEntryMultimap.java
+++ b/android/guava/src/com/google/common/collect/FilteredEntryMultimap.java
@@ -33,8 +33,7 @@
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* Implementation of {@link Multimaps#filterEntries(Multimap, Predicate)}.
@@ -43,9 +42,7 @@
* @author Louis Wasserman
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-class FilteredEntryMultimap<K extends @Nullable Object, V extends @Nullable Object>
- extends AbstractMultimap<K, V> implements FilteredMultimap<K, V> {
+class FilteredEntryMultimap<K, V> extends AbstractMultimap<K, V> implements FilteredMultimap<K, V> {
final Multimap<K, V> unfiltered;
final Predicate<? super Entry<K, V>> predicate;
@@ -69,24 +66,24 @@
return entries().size();
}
- private boolean satisfies(@ParametricNullness K key, @ParametricNullness V value) {
+ private boolean satisfies(K key, V value) {
return predicate.apply(Maps.immutableEntry(key, value));
}
final class ValuePredicate implements Predicate<V> {
- @ParametricNullness private final K key;
+ private final K key;
- ValuePredicate(@ParametricNullness K key) {
+ ValuePredicate(K key) {
this.key = key;
}
@Override
- public boolean apply(@ParametricNullness V value) {
+ public boolean apply(@NullableDecl V value) {
return satisfies(key, value);
}
}
- static <E extends @Nullable Object> Collection<E> filterCollection(
+ static <E> Collection<E> filterCollection(
Collection<E> collection, Predicate<? super E> predicate) {
if (collection instanceof Set) {
return Sets.filter((Set<E>) collection, predicate);
@@ -96,12 +93,12 @@
}
@Override
- public boolean containsKey(@CheckForNull Object key) {
+ public boolean containsKey(@NullableDecl Object key) {
return asMap().get(key) != null;
}
@Override
- public Collection<V> removeAll(@CheckForNull Object key) {
+ public Collection<V> removeAll(@NullableDecl Object key) {
return MoreObjects.firstNonNull(asMap().remove(key), unmodifiableEmptyCollection());
}
@@ -118,7 +115,7 @@
}
@Override
- public Collection<V> get(@ParametricNullness final K key) {
+ public Collection<V> get(final K key) {
return filterCollection(unfiltered.get(key), new ValuePredicate(key));
}
@@ -169,7 +166,7 @@
@WeakOuter
class AsMap extends ViewCachingAbstractMap<K, Collection<V>> {
@Override
- public boolean containsKey(@CheckForNull Object key) {
+ public boolean containsKey(@NullableDecl Object key) {
return get(key) != null;
}
@@ -179,8 +176,7 @@
}
@Override
- @CheckForNull
- public Collection<V> get(@CheckForNull Object key) {
+ public Collection<V> get(@NullableDecl Object key) {
Collection<V> result = unfiltered.asMap().get(key);
if (result == null) {
return null;
@@ -192,8 +188,7 @@
}
@Override
- @CheckForNull
- public Collection<V> remove(@CheckForNull Object key) {
+ public Collection<V> remove(@NullableDecl Object key) {
Collection<V> collection = unfiltered.asMap().get(key);
if (collection == null) {
return null;
@@ -237,7 +232,7 @@
}
@Override
- public boolean remove(@CheckForNull Object o) {
+ public boolean remove(@NullableDecl Object o) {
return AsMap.this.remove(o) != null;
}
}
@@ -260,7 +255,6 @@
unfiltered.asMap().entrySet().iterator();
@Override
- @CheckForNull
protected Entry<K, Collection<V>> computeNext() {
while (backingIterator.hasNext()) {
Entry<K, Collection<V>> entry = backingIterator.next();
@@ -303,7 +297,7 @@
}
@Override
- public boolean remove(@CheckForNull Object o) {
+ public boolean remove(@NullableDecl Object o) {
if (o instanceof Collection) {
Collection<?> c = (Collection<?>) o;
Iterator<Entry<K, Collection<V>>> entryIterator =
@@ -352,7 +346,7 @@
}
@Override
- public int remove(@CheckForNull Object key, int occurrences) {
+ public int remove(@NullableDecl Object key, int occurrences) {
checkNonnegative(occurrences, "occurrences");
if (occurrences == 0) {
return count(key);
diff --git a/android/guava/src/com/google/common/collect/FilteredEntrySetMultimap.java b/android/guava/src/com/google/common/collect/FilteredEntrySetMultimap.java
index 20413f8..94740a4 100644
--- a/android/guava/src/com/google/common/collect/FilteredEntrySetMultimap.java
+++ b/android/guava/src/com/google/common/collect/FilteredEntrySetMultimap.java
@@ -20,8 +20,6 @@
import com.google.common.base.Predicate;
import java.util.Map.Entry;
import java.util.Set;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Implementation of {@link Multimaps#filterEntries(SetMultimap, Predicate)}.
@@ -29,9 +27,8 @@
* @author Louis Wasserman
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-final class FilteredEntrySetMultimap<K extends @Nullable Object, V extends @Nullable Object>
- extends FilteredEntryMultimap<K, V> implements FilteredSetMultimap<K, V> {
+final class FilteredEntrySetMultimap<K, V> extends FilteredEntryMultimap<K, V>
+ implements FilteredSetMultimap<K, V> {
FilteredEntrySetMultimap(SetMultimap<K, V> unfiltered, Predicate<? super Entry<K, V>> predicate) {
super(unfiltered, predicate);
@@ -43,17 +40,17 @@
}
@Override
- public Set<V> get(@ParametricNullness K key) {
+ public Set<V> get(K key) {
return (Set<V>) super.get(key);
}
@Override
- public Set<V> removeAll(@CheckForNull Object key) {
+ public Set<V> removeAll(Object key) {
return (Set<V>) super.removeAll(key);
}
@Override
- public Set<V> replaceValues(@ParametricNullness K key, Iterable<? extends V> values) {
+ public Set<V> replaceValues(K key, Iterable<? extends V> values) {
return (Set<V>) super.replaceValues(key, values);
}
diff --git a/android/guava/src/com/google/common/collect/FilteredKeyListMultimap.java b/android/guava/src/com/google/common/collect/FilteredKeyListMultimap.java
index c82c8da..2a55225 100644
--- a/android/guava/src/com/google/common/collect/FilteredKeyListMultimap.java
+++ b/android/guava/src/com/google/common/collect/FilteredKeyListMultimap.java
@@ -19,8 +19,7 @@
import com.google.common.annotations.GwtCompatible;
import com.google.common.base.Predicate;
import java.util.List;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* Implementation of {@link Multimaps#filterKeys(ListMultimap, Predicate)}.
@@ -28,9 +27,8 @@
* @author Louis Wasserman
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-final class FilteredKeyListMultimap<K extends @Nullable Object, V extends @Nullable Object>
- extends FilteredKeyMultimap<K, V> implements ListMultimap<K, V> {
+final class FilteredKeyListMultimap<K, V> extends FilteredKeyMultimap<K, V>
+ implements ListMultimap<K, V> {
FilteredKeyListMultimap(ListMultimap<K, V> unfiltered, Predicate<? super K> keyPredicate) {
super(unfiltered, keyPredicate);
}
@@ -41,17 +39,17 @@
}
@Override
- public List<V> get(@ParametricNullness K key) {
+ public List<V> get(K key) {
return (List<V>) super.get(key);
}
@Override
- public List<V> removeAll(@CheckForNull Object key) {
+ public List<V> removeAll(@NullableDecl Object key) {
return (List<V>) super.removeAll(key);
}
@Override
- public List<V> replaceValues(@ParametricNullness K key, Iterable<? extends V> values) {
+ public List<V> replaceValues(K key, Iterable<? extends V> values) {
return (List<V>) super.replaceValues(key, values);
}
}
diff --git a/android/guava/src/com/google/common/collect/FilteredKeyMultimap.java b/android/guava/src/com/google/common/collect/FilteredKeyMultimap.java
index 68fad75..2a3003d 100644
--- a/android/guava/src/com/google/common/collect/FilteredKeyMultimap.java
+++ b/android/guava/src/com/google/common/collect/FilteredKeyMultimap.java
@@ -16,8 +16,6 @@
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkPositionIndex;
-import static java.util.Collections.emptyList;
-import static java.util.Collections.emptySet;
import com.google.common.annotations.GwtCompatible;
import com.google.common.base.Predicate;
@@ -30,8 +28,7 @@
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* Implementation of {@link Multimaps#filterKeys(Multimap, Predicate)}.
@@ -39,9 +36,7 @@
* @author Louis Wasserman
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-class FilteredKeyMultimap<K extends @Nullable Object, V extends @Nullable Object>
- extends AbstractMultimap<K, V> implements FilteredMultimap<K, V> {
+class FilteredKeyMultimap<K, V> extends AbstractMultimap<K, V> implements FilteredMultimap<K, V> {
final Multimap<K, V> unfiltered;
final Predicate<? super K> keyPredicate;
@@ -70,7 +65,7 @@
}
@Override
- public boolean containsKey(@CheckForNull Object key) {
+ public boolean containsKey(@NullableDecl Object key) {
if (unfiltered.containsKey(key)) {
@SuppressWarnings("unchecked") // k is equal to a K, if not one itself
K k = (K) key;
@@ -80,15 +75,15 @@
}
@Override
- public Collection<V> removeAll(@CheckForNull Object key) {
+ public Collection<V> removeAll(Object key) {
return containsKey(key) ? unfiltered.removeAll(key) : unmodifiableEmptyCollection();
}
Collection<V> unmodifiableEmptyCollection() {
if (unfiltered instanceof SetMultimap) {
- return emptySet();
+ return ImmutableSet.of();
} else {
- return emptyList();
+ return ImmutableList.of();
}
}
@@ -103,7 +98,7 @@
}
@Override
- public Collection<V> get(@ParametricNullness K key) {
+ public Collection<V> get(K key) {
if (keyPredicate.apply(key)) {
return unfiltered.get(key);
} else if (unfiltered instanceof SetMultimap) {
@@ -113,16 +108,15 @@
}
}
- static class AddRejectingSet<K extends @Nullable Object, V extends @Nullable Object>
- extends ForwardingSet<V> {
- @ParametricNullness final K key;
+ static class AddRejectingSet<K, V> extends ForwardingSet<V> {
+ final K key;
- AddRejectingSet(@ParametricNullness K key) {
+ AddRejectingSet(K key) {
this.key = key;
}
@Override
- public boolean add(@ParametricNullness V element) {
+ public boolean add(V element) {
throw new IllegalArgumentException("Key does not satisfy predicate: " + key);
}
@@ -138,22 +132,21 @@
}
}
- static class AddRejectingList<K extends @Nullable Object, V extends @Nullable Object>
- extends ForwardingList<V> {
- @ParametricNullness final K key;
+ static class AddRejectingList<K, V> extends ForwardingList<V> {
+ final K key;
- AddRejectingList(@ParametricNullness K key) {
+ AddRejectingList(K key) {
this.key = key;
}
@Override
- public boolean add(@ParametricNullness V v) {
+ public boolean add(V v) {
add(0, v);
return true;
}
@Override
- public void add(int index, @ParametricNullness V element) {
+ public void add(int index, V element) {
checkPositionIndex(index, 0);
throw new IllegalArgumentException("Key does not satisfy predicate: " + key);
}
@@ -197,7 +190,7 @@
@Override
@SuppressWarnings("unchecked")
- public boolean remove(@CheckForNull Object o) {
+ public boolean remove(@NullableDecl Object o) {
if (o instanceof Entry) {
Entry<?, ?> entry = (Entry<?, ?>) o;
if (unfiltered.containsKey(entry.getKey())
diff --git a/android/guava/src/com/google/common/collect/FilteredKeySetMultimap.java b/android/guava/src/com/google/common/collect/FilteredKeySetMultimap.java
index e492a5c..1ec8e65 100644
--- a/android/guava/src/com/google/common/collect/FilteredKeySetMultimap.java
+++ b/android/guava/src/com/google/common/collect/FilteredKeySetMultimap.java
@@ -20,8 +20,7 @@
import com.google.common.base.Predicate;
import java.util.Map.Entry;
import java.util.Set;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* Implementation of {@link Multimaps#filterKeys(SetMultimap, Predicate)}.
@@ -29,9 +28,8 @@
* @author Louis Wasserman
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-final class FilteredKeySetMultimap<K extends @Nullable Object, V extends @Nullable Object>
- extends FilteredKeyMultimap<K, V> implements FilteredSetMultimap<K, V> {
+final class FilteredKeySetMultimap<K, V> extends FilteredKeyMultimap<K, V>
+ implements FilteredSetMultimap<K, V> {
FilteredKeySetMultimap(SetMultimap<K, V> unfiltered, Predicate<? super K> keyPredicate) {
super(unfiltered, keyPredicate);
@@ -43,17 +41,17 @@
}
@Override
- public Set<V> get(@ParametricNullness K key) {
+ public Set<V> get(K key) {
return (Set<V>) super.get(key);
}
@Override
- public Set<V> removeAll(@CheckForNull Object key) {
+ public Set<V> removeAll(Object key) {
return (Set<V>) super.removeAll(key);
}
@Override
- public Set<V> replaceValues(@ParametricNullness K key, Iterable<? extends V> values) {
+ public Set<V> replaceValues(K key, Iterable<? extends V> values) {
return (Set<V>) super.replaceValues(key, values);
}
@@ -74,7 +72,7 @@
}
@Override
- public boolean equals(@CheckForNull Object o) {
+ public boolean equals(@NullableDecl Object o) {
return Sets.equalsImpl(this, o);
}
}
diff --git a/android/guava/src/com/google/common/collect/FilteredMultimap.java b/android/guava/src/com/google/common/collect/FilteredMultimap.java
index 4e1fa06..ef5ed4a 100644
--- a/android/guava/src/com/google/common/collect/FilteredMultimap.java
+++ b/android/guava/src/com/google/common/collect/FilteredMultimap.java
@@ -19,7 +19,6 @@
import com.google.common.annotations.GwtCompatible;
import com.google.common.base.Predicate;
import java.util.Map.Entry;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* An interface for all filtered multimap types.
@@ -27,9 +26,7 @@
* @author Louis Wasserman
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-interface FilteredMultimap<K extends @Nullable Object, V extends @Nullable Object>
- extends Multimap<K, V> {
+interface FilteredMultimap<K, V> extends Multimap<K, V> {
Multimap<K, V> unfiltered();
Predicate<? super Entry<K, V>> entryPredicate();
diff --git a/android/guava/src/com/google/common/collect/FilteredMultimapValues.java b/android/guava/src/com/google/common/collect/FilteredMultimapValues.java
index ecbfab2..b92707a 100644
--- a/android/guava/src/com/google/common/collect/FilteredMultimapValues.java
+++ b/android/guava/src/com/google/common/collect/FilteredMultimapValues.java
@@ -25,8 +25,7 @@
import java.util.Collection;
import java.util.Iterator;
import java.util.Map.Entry;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* Implementation for {@link FilteredMultimap#values()}.
@@ -34,9 +33,7 @@
* @author Louis Wasserman
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-final class FilteredMultimapValues<K extends @Nullable Object, V extends @Nullable Object>
- extends AbstractCollection<V> {
+final class FilteredMultimapValues<K, V> extends AbstractCollection<V> {
@Weak private final FilteredMultimap<K, V> multimap;
FilteredMultimapValues(FilteredMultimap<K, V> multimap) {
@@ -49,7 +46,7 @@
}
@Override
- public boolean contains(@CheckForNull Object o) {
+ public boolean contains(@NullableDecl Object o) {
return multimap.containsValue(o);
}
@@ -59,7 +56,7 @@
}
@Override
- public boolean remove(@CheckForNull Object o) {
+ public boolean remove(@NullableDecl Object o) {
Predicate<? super Entry<K, V>> entryPredicate = multimap.entryPredicate();
for (Iterator<Entry<K, V>> unfilteredItr = multimap.unfiltered().entries().iterator();
unfilteredItr.hasNext(); ) {
diff --git a/android/guava/src/com/google/common/collect/FilteredSetMultimap.java b/android/guava/src/com/google/common/collect/FilteredSetMultimap.java
index 8e2ff7c..a0a149f 100644
--- a/android/guava/src/com/google/common/collect/FilteredSetMultimap.java
+++ b/android/guava/src/com/google/common/collect/FilteredSetMultimap.java
@@ -17,7 +17,6 @@
package com.google.common.collect;
import com.google.common.annotations.GwtCompatible;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* A supertype for filtered {@link SetMultimap} implementations.
@@ -25,9 +24,7 @@
* @author Louis Wasserman
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-interface FilteredSetMultimap<K extends @Nullable Object, V extends @Nullable Object>
- extends FilteredMultimap<K, V>, SetMultimap<K, V> {
+interface FilteredSetMultimap<K, V> extends FilteredMultimap<K, V>, SetMultimap<K, V> {
@Override
SetMultimap<K, V> unfiltered();
}
diff --git a/android/guava/src/com/google/common/collect/FluentIterable.java b/android/guava/src/com/google/common/collect/FluentIterable.java
index 72401d7..66ae098 100644
--- a/android/guava/src/com/google/common/collect/FluentIterable.java
+++ b/android/guava/src/com/google/common/collect/FluentIterable.java
@@ -24,16 +24,13 @@
import com.google.common.base.Optional;
import com.google.common.base.Predicate;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
-import com.google.errorprone.annotations.InlineMe;
import java.util.Arrays;
import java.util.Collection;
-import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
import java.util.SortedSet;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* An expanded {@code Iterable} API, providing functionality similar to Java 8's powerful <a href=
@@ -112,12 +109,11 @@
* @since 12.0
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
-public abstract class FluentIterable<E extends @Nullable Object> implements Iterable<E> {
+public abstract class FluentIterable<E> implements Iterable<E> {
// We store 'iterable' and use it instead of 'this' to allow Iterables to perform instanceof
// checks on the _original_ iterable when FluentIterable.from is used.
// To avoid a self retain cycle under j2objc, we store Optional.absent() instead of
- // Optional.of(this). To access the delegate iterable, call #getDelegate(), which converts to
+ // Optional.of(this). To access the iterator delegate, call #getDelegate(), which converts to
// absent() back to 'this'.
private final Optional<Iterable<E>> iterableDelegate;
@@ -127,7 +123,8 @@
}
FluentIterable(Iterable<E> iterable) {
- this.iterableDelegate = Optional.of(iterable);
+ checkNotNull(iterable);
+ this.iterableDelegate = Optional.fromNullable(this != iterable ? iterable : null);
}
private Iterable<E> getDelegate() {
@@ -141,7 +138,7 @@
* <p><b>{@code Stream} equivalent:</b> {@code iterable.stream()} if {@code iterable} is a {@link
* Collection}; {@code StreamSupport.stream(iterable.spliterator(), false)} otherwise.
*/
- public static <E extends @Nullable Object> FluentIterable<E> from(final Iterable<E> iterable) {
+ public static <E> FluentIterable<E> from(final Iterable<E> iterable) {
return (iterable instanceof FluentIterable)
? (FluentIterable<E>) iterable
: new FluentIterable<E>(iterable) {
@@ -163,7 +160,7 @@
* @since 20.0 (since 18.0 as an overload of {@code of})
*/
@Beta
- public static <E extends @Nullable Object> FluentIterable<E> from(E[] elements) {
+ public static <E> FluentIterable<E> from(E[] elements) {
return from(Arrays.asList(elements));
}
@@ -176,10 +173,7 @@
* FluentIterable}
*/
@Deprecated
- @InlineMe(
- replacement = "checkNotNull(iterable)",
- staticImports = {"com.google.common.base.Preconditions.checkNotNull"})
- public static <E extends @Nullable Object> FluentIterable<E> from(FluentIterable<E> iterable) {
+ public static <E> FluentIterable<E> from(FluentIterable<E> iterable) {
return checkNotNull(iterable);
}
@@ -196,8 +190,7 @@
* @since 20.0
*/
@Beta
- public static <T extends @Nullable Object> FluentIterable<T> concat(
- Iterable<? extends T> a, Iterable<? extends T> b) {
+ public static <T> FluentIterable<T> concat(Iterable<? extends T> a, Iterable<? extends T> b) {
return concatNoDefensiveCopy(a, b);
}
@@ -215,7 +208,7 @@
* @since 20.0
*/
@Beta
- public static <T extends @Nullable Object> FluentIterable<T> concat(
+ public static <T> FluentIterable<T> concat(
Iterable<? extends T> a, Iterable<? extends T> b, Iterable<? extends T> c) {
return concatNoDefensiveCopy(a, b, c);
}
@@ -235,7 +228,7 @@
* @since 20.0
*/
@Beta
- public static <T extends @Nullable Object> FluentIterable<T> concat(
+ public static <T> FluentIterable<T> concat(
Iterable<? extends T> a,
Iterable<? extends T> b,
Iterable<? extends T> c,
@@ -259,8 +252,7 @@
* @since 20.0
*/
@Beta
- public static <T extends @Nullable Object> FluentIterable<T> concat(
- Iterable<? extends T>... inputs) {
+ public static <T> FluentIterable<T> concat(Iterable<? extends T>... inputs) {
return concatNoDefensiveCopy(Arrays.copyOf(inputs, inputs.length));
}
@@ -279,7 +271,7 @@
* @since 20.0
*/
@Beta
- public static <T extends @Nullable Object> FluentIterable<T> concat(
+ public static <T> FluentIterable<T> concat(
final Iterable<? extends Iterable<? extends T>> inputs) {
checkNotNull(inputs);
return new FluentIterable<T>() {
@@ -291,7 +283,7 @@
}
/** Concatenates a varargs array of iterables without making a defensive copy of the array. */
- private static <T extends @Nullable Object> FluentIterable<T> concatNoDefensiveCopy(
+ private static <T> FluentIterable<T> concatNoDefensiveCopy(
final Iterable<? extends T>... inputs) {
for (Iterable<? extends T> input : inputs) {
checkNotNull(input);
@@ -319,8 +311,8 @@
* @since 20.0
*/
@Beta
- public static <E extends @Nullable Object> FluentIterable<E> of() {
- return FluentIterable.from(Collections.<E>emptyList());
+ public static <E> FluentIterable<E> of() {
+ return FluentIterable.from(ImmutableList.<E>of());
}
/**
@@ -332,8 +324,7 @@
* @since 20.0
*/
@Beta
- public static <E extends @Nullable Object> FluentIterable<E> of(
- @ParametricNullness E element, E... elements) {
+ public static <E> FluentIterable<E> of(@NullableDecl E element, E... elements) {
return from(Lists.asList(element, elements));
}
@@ -364,7 +355,7 @@
*
* <p><b>{@code Stream} equivalent:</b> {@code stream.anyMatch(Predicate.isEqual(target))}.
*/
- public final boolean contains(@CheckForNull Object target) {
+ public final boolean contains(@NullableDecl Object target) {
return Iterables.contains(getDelegate(), target);
}
@@ -474,7 +465,6 @@
*
* <p><b>{@code Stream} equivalent:</b> {@code stream.filter(predicate).findFirst()}.
*/
- @SuppressWarnings("nullness") // Unsafe, but we can't do much about it now.
public final Optional<E> firstMatch(Predicate<? super E> predicate) {
return Iterables.tryFind(getDelegate(), predicate);
}
@@ -489,8 +479,7 @@
*
* <p><b>{@code Stream} equivalent:</b> {@link Stream#map}.
*/
- public final <T extends @Nullable Object> FluentIterable<T> transform(
- Function<? super E, T> function) {
+ public final <T> FluentIterable<T> transform(Function<? super E, T> function) {
return from(Iterables.transform(getDelegate(), function));
}
@@ -507,7 +496,7 @@
*
* @since 13.0 (required {@code Function<E, Iterable<T>>} until 14.0)
*/
- public <T extends @Nullable Object> FluentIterable<T> transformAndConcat(
+ public <T> FluentIterable<T> transformAndConcat(
Function<? super E, ? extends Iterable<? extends T>> function) {
return FluentIterable.concat(transform(function));
}
@@ -522,7 +511,6 @@
* @throws NullPointerException if the first element is null; if this is a possibility, use {@code
* iterator().next()} or {@link Iterables#getFirst} instead.
*/
- @SuppressWarnings("nullness") // Unsafe, but we can't do much about it now.
public final Optional<E> first() {
Iterator<E> iterator = getDelegate().iterator();
return iterator.hasNext() ? Optional.of(iterator.next()) : Optional.<E>absent();
@@ -539,7 +527,6 @@
* @throws NullPointerException if the last element is null; if this is a possibility, use {@link
* Iterables#getLast} instead.
*/
- @SuppressWarnings("nullness") // Unsafe, but we can't do much about it now.
public final Optional<E> last() {
// Iterables#getLast was inlined here so we don't have to throw/catch a NSEE
@@ -629,7 +616,6 @@
* @throws NullPointerException if any element is {@code null}
* @since 14.0 (since 12.0 as {@code toImmutableList()}).
*/
- @SuppressWarnings("nullness") // Unsafe, but we can't do much about it now.
public final ImmutableList<E> toList() {
return ImmutableList.copyOf(getDelegate());
}
@@ -647,7 +633,6 @@
* @throws NullPointerException if any element of this iterable is {@code null}
* @since 14.0 (since 13.0 as {@code toSortedImmutableList()}).
*/
- @SuppressWarnings("nullness") // Unsafe, but we can't do much about it now.
public final ImmutableList<E> toSortedList(Comparator<? super E> comparator) {
return Ordering.from(comparator).immutableSortedCopy(getDelegate());
}
@@ -662,7 +647,6 @@
* @throws NullPointerException if any element is {@code null}
* @since 14.0 (since 12.0 as {@code toImmutableSet()}).
*/
- @SuppressWarnings("nullness") // Unsafe, but we can't do much about it now.
public final ImmutableSet<E> toSet() {
return ImmutableSet.copyOf(getDelegate());
}
@@ -681,7 +665,6 @@
* @throws NullPointerException if any element of this iterable is {@code null}
* @since 14.0 (since 12.0 as {@code toImmutableSortedSet()}).
*/
- @SuppressWarnings("nullness") // Unsafe, but we can't do much about it now.
public final ImmutableSortedSet<E> toSortedSet(Comparator<? super E> comparator) {
return ImmutableSortedSet.copyOf(comparator, getDelegate());
}
@@ -695,7 +678,6 @@
* @throws NullPointerException if any element is null
* @since 19.0
*/
- @SuppressWarnings("nullness") // Unsafe, but we can't do much about it now.
public final ImmutableMultiset<E> toMultiset() {
return ImmutableMultiset.copyOf(getDelegate());
}
@@ -717,7 +699,6 @@
* valueFunction} produces {@code null} for any key
* @since 14.0
*/
- @SuppressWarnings("nullness") // Unsafe, but we can't do much about it now.
public final <V> ImmutableMap<E, V> toMap(Function<? super E, V> valueFunction) {
return Maps.toMap(getDelegate(), valueFunction);
}
@@ -740,7 +721,6 @@
* keyFunction} produces {@code null} for any key
* @since 14.0
*/
- @SuppressWarnings("nullness") // Unsafe, but we can't do much about it now.
public final <K> ImmutableListMultimap<K, E> index(Function<? super E, K> keyFunction) {
return Multimaps.index(getDelegate(), keyFunction);
}
@@ -777,7 +757,6 @@
* keyFunction} produces {@code null} for any key
* @since 14.0
*/
- @SuppressWarnings("nullness") // Unsafe, but we can't do much about it now.
public final <K> ImmutableMap<K, E> uniqueIndex(Function<? super E, K> keyFunction) {
return Maps.uniqueIndex(getDelegate(), keyFunction);
}
@@ -795,15 +774,7 @@
* copied
*/
@GwtIncompatible // Array.newArray(Class, int)
- /*
- * Both the declaration of our Class<E> parameter and its usage in a call to Iterables.toArray
- * produce a nullness error: E may be a nullable type, and our nullness checker has Class's type
- * parameter bounded to non-null types. To avoid that, we'd use Class<@Nonnull E> if we could.
- * (Granted, this is only one of many nullness-checking problems that arise from letting
- * FluentIterable support null elements, and most of the other produce outright unsoundness.)
- */
- @SuppressWarnings("nullness")
- public final @Nullable E[] toArray(Class<E> type) {
+ public final E[] toArray(Class<E> type) {
return Iterables.toArray(getDelegate(), type);
}
@@ -859,14 +830,13 @@
* @throws IndexOutOfBoundsException if {@code position} is negative or greater than or equal to
* the size of this fluent iterable
*/
- @ParametricNullness
+ // TODO(kevinb): add @NullableDecl?
public final E get(int position) {
return Iterables.get(getDelegate(), position);
}
/** Function that transforms {@code Iterable<E>} into a fluent iterable. */
- private static class FromIterableFunction<E extends @Nullable Object>
- implements Function<Iterable<E>, FluentIterable<E>> {
+ private static class FromIterableFunction<E> implements Function<Iterable<E>, FluentIterable<E>> {
@Override
public FluentIterable<E> apply(Iterable<E> fromObject) {
return FluentIterable.from(fromObject);
diff --git a/android/guava/src/com/google/common/collect/ForwardingBlockingDeque.java b/android/guava/src/com/google/common/collect/ForwardingBlockingDeque.java
index 49d4bcf..7d3895d 100644
--- a/android/guava/src/com/google/common/collect/ForwardingBlockingDeque.java
+++ b/android/guava/src/com/google/common/collect/ForwardingBlockingDeque.java
@@ -20,7 +20,6 @@
import java.util.Collection;
import java.util.concurrent.BlockingDeque;
import java.util.concurrent.TimeUnit;
-import javax.annotation.CheckForNull;
/**
* A {@link BlockingDeque} which forwards all its method calls to another {@code BlockingDeque}.
@@ -47,7 +46,6 @@
*/
@Deprecated
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public abstract class ForwardingBlockingDeque<E> extends ForwardingDeque<E>
implements BlockingDeque<E> {
@@ -93,13 +91,11 @@
}
@Override
- @CheckForNull
public E pollFirst(long timeout, TimeUnit unit) throws InterruptedException {
return delegate().pollFirst(timeout, unit);
}
@Override
- @CheckForNull
public E pollLast(long timeout, TimeUnit unit) throws InterruptedException {
return delegate().pollLast(timeout, unit);
}
@@ -120,7 +116,6 @@
}
@Override
- @CheckForNull
public E poll(long timeout, TimeUnit unit) throws InterruptedException {
return delegate().poll(timeout, unit);
}
diff --git a/android/guava/src/com/google/common/collect/ForwardingCollection.java b/android/guava/src/com/google/common/collect/ForwardingCollection.java
index ca1edc1..416ff96 100644
--- a/android/guava/src/com/google/common/collect/ForwardingCollection.java
+++ b/android/guava/src/com/google/common/collect/ForwardingCollection.java
@@ -21,8 +21,7 @@
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import java.util.Collection;
import java.util.Iterator;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* A collection which forwards all its method calls to another collection. Subclasses should
@@ -47,9 +46,7 @@
* @since 2.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-public abstract class ForwardingCollection<E extends @Nullable Object> extends ForwardingObject
- implements Collection<E> {
+public abstract class ForwardingCollection<E> extends ForwardingObject implements Collection<E> {
// TODO(lowasser): identify places where thread safety is actually lost
/** Constructor for use by subclasses. */
@@ -80,19 +77,19 @@
}
@Override
- public boolean contains(@CheckForNull Object object) {
+ public boolean contains(Object object) {
return delegate().contains(object);
}
@CanIgnoreReturnValue
@Override
- public boolean add(@ParametricNullness E element) {
+ public boolean add(E element) {
return delegate().add(element);
}
@CanIgnoreReturnValue
@Override
- public boolean remove(@CheckForNull Object object) {
+ public boolean remove(Object object) {
return delegate().remove(object);
}
@@ -119,14 +116,13 @@
}
@Override
- public @Nullable Object[] toArray() {
+ public Object[] toArray() {
return delegate().toArray();
}
@CanIgnoreReturnValue
@Override
- @SuppressWarnings("nullness") // b/192354773 in our checker affects toArray declarations
- public <T extends @Nullable Object> T[] toArray(T[] array) {
+ public <T> T[] toArray(T[] array) {
return delegate().toArray(array);
}
@@ -137,7 +133,7 @@
*
* @since 7.0
*/
- protected boolean standardContains(@CheckForNull Object object) {
+ protected boolean standardContains(@NullableDecl Object object) {
return Iterators.contains(iterator(), object);
}
@@ -169,7 +165,7 @@
*
* @since 7.0
*/
- protected boolean standardRemove(@CheckForNull Object object) {
+ protected boolean standardRemove(@NullableDecl Object object) {
Iterator<E> iterator = iterator();
while (iterator.hasNext()) {
if (Objects.equal(iterator.next(), object)) {
@@ -242,8 +238,8 @@
*
* @since 7.0
*/
- protected @Nullable Object[] standardToArray() {
- @Nullable Object[] newArray = new @Nullable Object[size()];
+ protected Object[] standardToArray() {
+ Object[] newArray = new Object[size()];
return toArray(newArray);
}
@@ -254,7 +250,7 @@
*
* @since 7.0
*/
- protected <T extends @Nullable Object> T[] standardToArray(T[] array) {
+ protected <T> T[] standardToArray(T[] array) {
return ObjectArrays.toArrayImpl(this, array);
}
}
diff --git a/android/guava/src/com/google/common/collect/ForwardingConcurrentMap.java b/android/guava/src/com/google/common/collect/ForwardingConcurrentMap.java
index b662b07..0910424 100644
--- a/android/guava/src/com/google/common/collect/ForwardingConcurrentMap.java
+++ b/android/guava/src/com/google/common/collect/ForwardingConcurrentMap.java
@@ -19,7 +19,6 @@
import com.google.common.annotations.GwtCompatible;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import java.util.concurrent.ConcurrentMap;
-import javax.annotation.CheckForNull;
/**
* A concurrent map which forwards all its method calls to another concurrent map. Subclasses should
@@ -37,7 +36,6 @@
* @since 2.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
public abstract class ForwardingConcurrentMap<K, V> extends ForwardingMap<K, V>
implements ConcurrentMap<K, V> {
@@ -49,20 +47,18 @@
@CanIgnoreReturnValue
@Override
- @CheckForNull
public V putIfAbsent(K key, V value) {
return delegate().putIfAbsent(key, value);
}
@CanIgnoreReturnValue
@Override
- public boolean remove(@CheckForNull Object key, @CheckForNull Object value) {
+ public boolean remove(Object key, Object value) {
return delegate().remove(key, value);
}
@CanIgnoreReturnValue
@Override
- @CheckForNull
public V replace(K key, V value) {
return delegate().replace(key, value);
}
diff --git a/android/guava/src/com/google/common/collect/ForwardingDeque.java b/android/guava/src/com/google/common/collect/ForwardingDeque.java
index 571535c..87ac71b 100644
--- a/android/guava/src/com/google/common/collect/ForwardingDeque.java
+++ b/android/guava/src/com/google/common/collect/ForwardingDeque.java
@@ -20,8 +20,6 @@
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import java.util.Deque;
import java.util.Iterator;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* A deque which forwards all its method calls to another deque. Subclasses should override one or
@@ -41,9 +39,7 @@
* @since 12.0
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
-public abstract class ForwardingDeque<E extends @Nullable Object> extends ForwardingQueue<E>
- implements Deque<E> {
+public abstract class ForwardingDeque<E> extends ForwardingQueue<E> implements Deque<E> {
/** Constructor for use by subclasses. */
protected ForwardingDeque() {}
@@ -52,12 +48,12 @@
protected abstract Deque<E> delegate();
@Override
- public void addFirst(@ParametricNullness E e) {
+ public void addFirst(E e) {
delegate().addFirst(e);
}
@Override
- public void addLast(@ParametricNullness E e) {
+ public void addLast(E e) {
delegate().addLast(e);
}
@@ -67,90 +63,81 @@
}
@Override
- @ParametricNullness
public E getFirst() {
return delegate().getFirst();
}
@Override
- @ParametricNullness
public E getLast() {
return delegate().getLast();
}
@CanIgnoreReturnValue // TODO(cpovirk): Consider removing this?
@Override
- public boolean offerFirst(@ParametricNullness E e) {
+ public boolean offerFirst(E e) {
return delegate().offerFirst(e);
}
@CanIgnoreReturnValue // TODO(cpovirk): Consider removing this?
@Override
- public boolean offerLast(@ParametricNullness E e) {
+ public boolean offerLast(E e) {
return delegate().offerLast(e);
}
@Override
- @CheckForNull
public E peekFirst() {
return delegate().peekFirst();
}
@Override
- @CheckForNull
public E peekLast() {
return delegate().peekLast();
}
@CanIgnoreReturnValue // TODO(cpovirk): Consider removing this?
@Override
- @CheckForNull
public E pollFirst() {
return delegate().pollFirst();
}
@CanIgnoreReturnValue // TODO(cpovirk): Consider removing this?
@Override
- @CheckForNull
public E pollLast() {
return delegate().pollLast();
}
@CanIgnoreReturnValue
@Override
- @ParametricNullness
public E pop() {
return delegate().pop();
}
@Override
- public void push(@ParametricNullness E e) {
+ public void push(E e) {
delegate().push(e);
}
@CanIgnoreReturnValue
@Override
- @ParametricNullness
public E removeFirst() {
return delegate().removeFirst();
}
@CanIgnoreReturnValue
@Override
- @ParametricNullness
public E removeLast() {
return delegate().removeLast();
}
@CanIgnoreReturnValue
@Override
- public boolean removeFirstOccurrence(@CheckForNull Object o) {
+ public boolean removeFirstOccurrence(Object o) {
return delegate().removeFirstOccurrence(o);
}
@CanIgnoreReturnValue
@Override
- public boolean removeLastOccurrence(@CheckForNull Object o) {
+ public boolean removeLastOccurrence(Object o) {
return delegate().removeLastOccurrence(o);
}
}
diff --git a/android/guava/src/com/google/common/collect/ForwardingImmutableCollection.java b/android/guava/src/com/google/common/collect/ForwardingImmutableCollection.java
index 043fe58..c0b9c5e 100644
--- a/android/guava/src/com/google/common/collect/ForwardingImmutableCollection.java
+++ b/android/guava/src/com/google/common/collect/ForwardingImmutableCollection.java
@@ -24,7 +24,6 @@
* @author Hayward Chan
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
class ForwardingImmutableCollection {
private ForwardingImmutableCollection() {}
}
diff --git a/android/guava/src/com/google/common/collect/ForwardingImmutableList.java b/android/guava/src/com/google/common/collect/ForwardingImmutableList.java
index bd5480d..2b9092e 100644
--- a/android/guava/src/com/google/common/collect/ForwardingImmutableList.java
+++ b/android/guava/src/com/google/common/collect/ForwardingImmutableList.java
@@ -24,7 +24,6 @@
* @author Chris Povirk
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
abstract class ForwardingImmutableList<E> {
private ForwardingImmutableList() {}
}
diff --git a/android/guava/src/com/google/common/collect/ForwardingImmutableMap.java b/android/guava/src/com/google/common/collect/ForwardingImmutableMap.java
index 22cc9ff..a367157 100644
--- a/android/guava/src/com/google/common/collect/ForwardingImmutableMap.java
+++ b/android/guava/src/com/google/common/collect/ForwardingImmutableMap.java
@@ -24,7 +24,6 @@
* @author Chris Povirk
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
abstract class ForwardingImmutableMap<K, V> {
private ForwardingImmutableMap() {}
}
diff --git a/android/guava/src/com/google/common/collect/ForwardingImmutableSet.java b/android/guava/src/com/google/common/collect/ForwardingImmutableSet.java
index 047d5fd..c7d7bf6 100644
--- a/android/guava/src/com/google/common/collect/ForwardingImmutableSet.java
+++ b/android/guava/src/com/google/common/collect/ForwardingImmutableSet.java
@@ -24,7 +24,6 @@
* @author Chris Povirk
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
abstract class ForwardingImmutableSet<E> {
private ForwardingImmutableSet() {}
}
diff --git a/android/guava/src/com/google/common/collect/ForwardingIterator.java b/android/guava/src/com/google/common/collect/ForwardingIterator.java
index 1f5a8f1..5ecd3d2 100644
--- a/android/guava/src/com/google/common/collect/ForwardingIterator.java
+++ b/android/guava/src/com/google/common/collect/ForwardingIterator.java
@@ -19,7 +19,6 @@
import com.google.common.annotations.GwtCompatible;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import java.util.Iterator;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* An iterator which forwards all its method calls to another iterator. Subclasses should override
@@ -37,9 +36,7 @@
* @since 2.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-public abstract class ForwardingIterator<T extends @Nullable Object> extends ForwardingObject
- implements Iterator<T> {
+public abstract class ForwardingIterator<T> extends ForwardingObject implements Iterator<T> {
/** Constructor for use by subclasses. */
protected ForwardingIterator() {}
@@ -54,7 +51,6 @@
@CanIgnoreReturnValue
@Override
- @ParametricNullness
public T next() {
return delegate().next();
}
diff --git a/android/guava/src/com/google/common/collect/ForwardingList.java b/android/guava/src/com/google/common/collect/ForwardingList.java
index 4b4551e..bfd2083 100644
--- a/android/guava/src/com/google/common/collect/ForwardingList.java
+++ b/android/guava/src/com/google/common/collect/ForwardingList.java
@@ -23,8 +23,7 @@
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* A list which forwards all its method calls to another list. Subclasses should override one or
@@ -52,9 +51,7 @@
* @since 2.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-public abstract class ForwardingList<E extends @Nullable Object> extends ForwardingCollection<E>
- implements List<E> {
+public abstract class ForwardingList<E> extends ForwardingCollection<E> implements List<E> {
// TODO(lowasser): identify places where thread safety is actually lost
/** Constructor for use by subclasses. */
@@ -64,7 +61,7 @@
protected abstract List<E> delegate();
@Override
- public void add(int index, @ParametricNullness E element) {
+ public void add(int index, E element) {
delegate().add(index, element);
}
@@ -75,18 +72,17 @@
}
@Override
- @ParametricNullness
public E get(int index) {
return delegate().get(index);
}
@Override
- public int indexOf(@CheckForNull Object element) {
+ public int indexOf(Object element) {
return delegate().indexOf(element);
}
@Override
- public int lastIndexOf(@CheckForNull Object element) {
+ public int lastIndexOf(Object element) {
return delegate().lastIndexOf(element);
}
@@ -102,15 +98,13 @@
@CanIgnoreReturnValue
@Override
- @ParametricNullness
public E remove(int index) {
return delegate().remove(index);
}
@CanIgnoreReturnValue
@Override
- @ParametricNullness
- public E set(int index, @ParametricNullness E element) {
+ public E set(int index, E element) {
return delegate().set(index, element);
}
@@ -120,7 +114,7 @@
}
@Override
- public boolean equals(@CheckForNull Object object) {
+ public boolean equals(@NullableDecl Object object) {
return object == this || delegate().equals(object);
}
@@ -136,7 +130,7 @@
*
* @since 7.0
*/
- protected boolean standardAdd(@ParametricNullness E element) {
+ protected boolean standardAdd(E element) {
add(size(), element);
return true;
}
@@ -159,7 +153,7 @@
*
* @since 7.0
*/
- protected int standardIndexOf(@CheckForNull Object element) {
+ protected int standardIndexOf(@NullableDecl Object element) {
return Lists.indexOfImpl(this, element);
}
@@ -170,7 +164,7 @@
*
* @since 7.0
*/
- protected int standardLastIndexOf(@CheckForNull Object element) {
+ protected int standardLastIndexOf(@NullableDecl Object element) {
return Lists.lastIndexOfImpl(this, element);
}
@@ -228,7 +222,7 @@
* @since 7.0
*/
@Beta
- protected boolean standardEquals(@CheckForNull Object object) {
+ protected boolean standardEquals(@NullableDecl Object object) {
return Lists.equalsImpl(this, object);
}
diff --git a/android/guava/src/com/google/common/collect/ForwardingListIterator.java b/android/guava/src/com/google/common/collect/ForwardingListIterator.java
index a2ac32b..bc2a5ad 100644
--- a/android/guava/src/com/google/common/collect/ForwardingListIterator.java
+++ b/android/guava/src/com/google/common/collect/ForwardingListIterator.java
@@ -19,7 +19,6 @@
import com.google.common.annotations.GwtCompatible;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import java.util.ListIterator;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* A list iterator which forwards all its method calls to another list iterator. Subclasses should
@@ -37,9 +36,8 @@
* @since 2.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-public abstract class ForwardingListIterator<E extends @Nullable Object>
- extends ForwardingIterator<E> implements ListIterator<E> {
+public abstract class ForwardingListIterator<E> extends ForwardingIterator<E>
+ implements ListIterator<E> {
/** Constructor for use by subclasses. */
protected ForwardingListIterator() {}
@@ -48,7 +46,7 @@
protected abstract ListIterator<E> delegate();
@Override
- public void add(@ParametricNullness E element) {
+ public void add(E element) {
delegate().add(element);
}
@@ -64,7 +62,6 @@
@CanIgnoreReturnValue
@Override
- @ParametricNullness
public E previous() {
return delegate().previous();
}
@@ -75,7 +72,7 @@
}
@Override
- public void set(@ParametricNullness E element) {
+ public void set(E element) {
delegate().set(element);
}
}
diff --git a/android/guava/src/com/google/common/collect/ForwardingListMultimap.java b/android/guava/src/com/google/common/collect/ForwardingListMultimap.java
index 11779c0..8cf3d70 100644
--- a/android/guava/src/com/google/common/collect/ForwardingListMultimap.java
+++ b/android/guava/src/com/google/common/collect/ForwardingListMultimap.java
@@ -19,8 +19,7 @@
import com.google.common.annotations.GwtCompatible;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import java.util.List;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* A list multimap which forwards all its method calls to another list multimap. Subclasses should
@@ -35,9 +34,8 @@
* @since 3.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-public abstract class ForwardingListMultimap<K extends @Nullable Object, V extends @Nullable Object>
- extends ForwardingMultimap<K, V> implements ListMultimap<K, V> {
+public abstract class ForwardingListMultimap<K, V> extends ForwardingMultimap<K, V>
+ implements ListMultimap<K, V> {
/** Constructor for use by subclasses. */
protected ForwardingListMultimap() {}
@@ -46,19 +44,19 @@
protected abstract ListMultimap<K, V> delegate();
@Override
- public List<V> get(@ParametricNullness K key) {
+ public List<V> get(@NullableDecl K key) {
return delegate().get(key);
}
@CanIgnoreReturnValue
@Override
- public List<V> removeAll(@CheckForNull Object key) {
+ public List<V> removeAll(@NullableDecl Object key) {
return delegate().removeAll(key);
}
@CanIgnoreReturnValue
@Override
- public List<V> replaceValues(@ParametricNullness K key, Iterable<? extends V> values) {
+ public List<V> replaceValues(K key, Iterable<? extends V> values) {
return delegate().replaceValues(key, values);
}
}
diff --git a/android/guava/src/com/google/common/collect/ForwardingMap.java b/android/guava/src/com/google/common/collect/ForwardingMap.java
index 315a4fa..4032bf9 100644
--- a/android/guava/src/com/google/common/collect/ForwardingMap.java
+++ b/android/guava/src/com/google/common/collect/ForwardingMap.java
@@ -24,8 +24,7 @@
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* A map which forwards all its method calls to another map. Subclasses should override one or more
@@ -56,9 +55,7 @@
* @since 2.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-public abstract class ForwardingMap<K extends @Nullable Object, V extends @Nullable Object>
- extends ForwardingObject implements Map<K, V> {
+public abstract class ForwardingMap<K, V> extends ForwardingObject implements Map<K, V> {
// TODO(lowasser): identify places where thread safety is actually lost
/** Constructor for use by subclasses. */
@@ -79,8 +76,7 @@
@CanIgnoreReturnValue
@Override
- @CheckForNull
- public V remove(@CheckForNull Object key) {
+ public V remove(Object key) {
return delegate().remove(key);
}
@@ -90,25 +86,23 @@
}
@Override
- public boolean containsKey(@CheckForNull Object key) {
+ public boolean containsKey(@NullableDecl Object key) {
return delegate().containsKey(key);
}
@Override
- public boolean containsValue(@CheckForNull Object value) {
+ public boolean containsValue(@NullableDecl Object value) {
return delegate().containsValue(value);
}
@Override
- @CheckForNull
- public V get(@CheckForNull Object key) {
+ public V get(@NullableDecl Object key) {
return delegate().get(key);
}
@CanIgnoreReturnValue
@Override
- @CheckForNull
- public V put(@ParametricNullness K key, @ParametricNullness V value) {
+ public V put(K key, V value) {
return delegate().put(key, value);
}
@@ -133,7 +127,7 @@
}
@Override
- public boolean equals(@CheckForNull Object object) {
+ public boolean equals(@NullableDecl Object object) {
return object == this || delegate().equals(object);
}
@@ -164,8 +158,7 @@
* @since 7.0
*/
@Beta
- @CheckForNull
- protected V standardRemove(@CheckForNull Object key) {
+ protected V standardRemove(@NullableDecl Object key) {
Iterator<Entry<K, V>> entryIterator = entrySet().iterator();
while (entryIterator.hasNext()) {
Entry<K, V> entry = entryIterator.next();
@@ -214,7 +207,7 @@
* @since 7.0
*/
@Beta
- protected boolean standardContainsKey(@CheckForNull Object key) {
+ protected boolean standardContainsKey(@NullableDecl Object key) {
return Maps.containsKeyImpl(this, key);
}
@@ -242,7 +235,7 @@
*
* @since 7.0
*/
- protected boolean standardContainsValue(@CheckForNull Object value) {
+ protected boolean standardContainsValue(@NullableDecl Object value) {
return Maps.containsValueImpl(this, value);
}
@@ -284,7 +277,7 @@
*
* @since 7.0
*/
- protected boolean standardEquals(@CheckForNull Object object) {
+ protected boolean standardEquals(@NullableDecl Object object) {
return Maps.equalsImpl(this, object);
}
diff --git a/android/guava/src/com/google/common/collect/ForwardingMapEntry.java b/android/guava/src/com/google/common/collect/ForwardingMapEntry.java
index 6816ccb..198b94b 100644
--- a/android/guava/src/com/google/common/collect/ForwardingMapEntry.java
+++ b/android/guava/src/com/google/common/collect/ForwardingMapEntry.java
@@ -21,8 +21,7 @@
import com.google.common.base.Objects;
import java.util.Map;
import java.util.Map.Entry;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* A map entry which forwards all its method calls to another map entry. Subclasses should override
@@ -48,9 +47,7 @@
* @since 2.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-public abstract class ForwardingMapEntry<K extends @Nullable Object, V extends @Nullable Object>
- extends ForwardingObject implements Map.Entry<K, V> {
+public abstract class ForwardingMapEntry<K, V> extends ForwardingObject implements Map.Entry<K, V> {
// TODO(lowasser): identify places where thread safety is actually lost
/** Constructor for use by subclasses. */
@@ -60,25 +57,22 @@
protected abstract Entry<K, V> delegate();
@Override
- @ParametricNullness
public K getKey() {
return delegate().getKey();
}
@Override
- @ParametricNullness
public V getValue() {
return delegate().getValue();
}
@Override
- @ParametricNullness
- public V setValue(@ParametricNullness V value) {
+ public V setValue(V value) {
return delegate().setValue(value);
}
@Override
- public boolean equals(@CheckForNull Object object) {
+ public boolean equals(@NullableDecl Object object) {
return delegate().equals(object);
}
@@ -94,7 +88,7 @@
*
* @since 7.0
*/
- protected boolean standardEquals(@CheckForNull Object object) {
+ protected boolean standardEquals(@NullableDecl Object object) {
if (object instanceof Entry) {
Entry<?, ?> that = (Entry<?, ?>) object;
return Objects.equal(this.getKey(), that.getKey())
diff --git a/android/guava/src/com/google/common/collect/ForwardingMultimap.java b/android/guava/src/com/google/common/collect/ForwardingMultimap.java
index a3db061..991d0cf 100644
--- a/android/guava/src/com/google/common/collect/ForwardingMultimap.java
+++ b/android/guava/src/com/google/common/collect/ForwardingMultimap.java
@@ -22,8 +22,7 @@
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* A multimap which forwards all its method calls to another multimap. Subclasses should override
@@ -38,9 +37,7 @@
* @since 2.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-public abstract class ForwardingMultimap<K extends @Nullable Object, V extends @Nullable Object>
- extends ForwardingObject implements Multimap<K, V> {
+public abstract class ForwardingMultimap<K, V> extends ForwardingObject implements Multimap<K, V> {
/** Constructor for use by subclasses. */
protected ForwardingMultimap() {}
@@ -59,17 +56,17 @@
}
@Override
- public boolean containsEntry(@CheckForNull Object key, @CheckForNull Object value) {
+ public boolean containsEntry(@NullableDecl Object key, @NullableDecl Object value) {
return delegate().containsEntry(key, value);
}
@Override
- public boolean containsKey(@CheckForNull Object key) {
+ public boolean containsKey(@NullableDecl Object key) {
return delegate().containsKey(key);
}
@Override
- public boolean containsValue(@CheckForNull Object value) {
+ public boolean containsValue(@NullableDecl Object value) {
return delegate().containsValue(value);
}
@@ -79,7 +76,7 @@
}
@Override
- public Collection<V> get(@ParametricNullness K key) {
+ public Collection<V> get(@NullableDecl K key) {
return delegate().get(key);
}
@@ -100,13 +97,13 @@
@CanIgnoreReturnValue
@Override
- public boolean put(@ParametricNullness K key, @ParametricNullness V value) {
+ public boolean put(K key, V value) {
return delegate().put(key, value);
}
@CanIgnoreReturnValue
@Override
- public boolean putAll(@ParametricNullness K key, Iterable<? extends V> values) {
+ public boolean putAll(K key, Iterable<? extends V> values) {
return delegate().putAll(key, values);
}
@@ -118,19 +115,19 @@
@CanIgnoreReturnValue
@Override
- public boolean remove(@CheckForNull Object key, @CheckForNull Object value) {
+ public boolean remove(@NullableDecl Object key, @NullableDecl Object value) {
return delegate().remove(key, value);
}
@CanIgnoreReturnValue
@Override
- public Collection<V> removeAll(@CheckForNull Object key) {
+ public Collection<V> removeAll(@NullableDecl Object key) {
return delegate().removeAll(key);
}
@CanIgnoreReturnValue
@Override
- public Collection<V> replaceValues(@ParametricNullness K key, Iterable<? extends V> values) {
+ public Collection<V> replaceValues(K key, Iterable<? extends V> values) {
return delegate().replaceValues(key, values);
}
@@ -145,7 +142,7 @@
}
@Override
- public boolean equals(@CheckForNull Object object) {
+ public boolean equals(@NullableDecl Object object) {
return object == this || delegate().equals(object);
}
diff --git a/android/guava/src/com/google/common/collect/ForwardingMultiset.java b/android/guava/src/com/google/common/collect/ForwardingMultiset.java
index 857b9ae..9a7084f 100644
--- a/android/guava/src/com/google/common/collect/ForwardingMultiset.java
+++ b/android/guava/src/com/google/common/collect/ForwardingMultiset.java
@@ -23,8 +23,7 @@
import java.util.Collection;
import java.util.Iterator;
import java.util.Set;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* A multiset which forwards all its method calls to another multiset. Subclasses should override
@@ -49,9 +48,7 @@
* @since 2.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-public abstract class ForwardingMultiset<E extends @Nullable Object> extends ForwardingCollection<E>
- implements Multiset<E> {
+public abstract class ForwardingMultiset<E> extends ForwardingCollection<E> implements Multiset<E> {
/** Constructor for use by subclasses. */
protected ForwardingMultiset() {}
@@ -60,19 +57,19 @@
protected abstract Multiset<E> delegate();
@Override
- public int count(@CheckForNull Object element) {
+ public int count(Object element) {
return delegate().count(element);
}
@CanIgnoreReturnValue
@Override
- public int add(@ParametricNullness E element, int occurrences) {
+ public int add(E element, int occurrences) {
return delegate().add(element, occurrences);
}
@CanIgnoreReturnValue
@Override
- public int remove(@CheckForNull Object element, int occurrences) {
+ public int remove(Object element, int occurrences) {
return delegate().remove(element, occurrences);
}
@@ -87,7 +84,7 @@
}
@Override
- public boolean equals(@CheckForNull Object object) {
+ public boolean equals(@NullableDecl Object object) {
return object == this || delegate().equals(object);
}
@@ -98,13 +95,13 @@
@CanIgnoreReturnValue
@Override
- public int setCount(@ParametricNullness E element, int count) {
+ public int setCount(E element, int count) {
return delegate().setCount(element, count);
}
@CanIgnoreReturnValue
@Override
- public boolean setCount(@ParametricNullness E element, int oldCount, int newCount) {
+ public boolean setCount(E element, int oldCount, int newCount) {
return delegate().setCount(element, oldCount, newCount);
}
@@ -115,7 +112,7 @@
* @since 7.0
*/
@Override
- protected boolean standardContains(@CheckForNull Object object) {
+ protected boolean standardContains(@NullableDecl Object object) {
return count(object) > 0;
}
@@ -139,7 +136,7 @@
* @since 7.0
*/
@Beta
- protected int standardCount(@CheckForNull Object object) {
+ protected int standardCount(@NullableDecl Object object) {
for (Entry<?> entry : this.entrySet()) {
if (Objects.equal(entry.getElement(), object)) {
return entry.getCount();
@@ -155,7 +152,7 @@
*
* @since 7.0
*/
- protected boolean standardAdd(@ParametricNullness E element) {
+ protected boolean standardAdd(E element) {
add(element, 1);
return true;
}
@@ -181,7 +178,7 @@
* @since 7.0
*/
@Override
- protected boolean standardRemove(@CheckForNull Object element) {
+ protected boolean standardRemove(Object element) {
return remove(element, 1) > 0;
}
@@ -217,7 +214,7 @@
*
* @since 7.0
*/
- protected int standardSetCount(@ParametricNullness E element, int count) {
+ protected int standardSetCount(E element, int count) {
return Multisets.setCountImpl(this, element, count);
}
@@ -228,7 +225,7 @@
*
* @since 7.0
*/
- protected boolean standardSetCount(@ParametricNullness E element, int oldCount, int newCount) {
+ protected boolean standardSetCount(E element, int oldCount, int newCount) {
return Multisets.setCountImpl(this, element, oldCount, newCount);
}
@@ -288,7 +285,7 @@
*
* @since 7.0
*/
- protected boolean standardEquals(@CheckForNull Object object) {
+ protected boolean standardEquals(@NullableDecl Object object) {
return Multisets.equalsImpl(this, object);
}
diff --git a/android/guava/src/com/google/common/collect/ForwardingNavigableMap.java b/android/guava/src/com/google/common/collect/ForwardingNavigableMap.java
index e0e1c39..c8d0fd5 100644
--- a/android/guava/src/com/google/common/collect/ForwardingNavigableMap.java
+++ b/android/guava/src/com/google/common/collect/ForwardingNavigableMap.java
@@ -16,6 +16,7 @@
package com.google.common.collect;
+import static com.google.common.collect.CollectPreconditions.checkRemove;
import static com.google.common.collect.Maps.keyOrNull;
import com.google.common.annotations.Beta;
@@ -25,8 +26,6 @@
import java.util.NavigableSet;
import java.util.NoSuchElementException;
import java.util.SortedMap;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* A navigable map which forwards all its method calls to another navigable map. Subclasses should
@@ -55,9 +54,8 @@
* @since 12.0
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
-public abstract class ForwardingNavigableMap<K extends @Nullable Object, V extends @Nullable Object>
- extends ForwardingSortedMap<K, V> implements NavigableMap<K, V> {
+public abstract class ForwardingNavigableMap<K, V> extends ForwardingSortedMap<K, V>
+ implements NavigableMap<K, V> {
/** Constructor for use by subclasses. */
protected ForwardingNavigableMap() {}
@@ -66,8 +64,7 @@
protected abstract NavigableMap<K, V> delegate();
@Override
- @CheckForNull
- public Entry<K, V> lowerEntry(@ParametricNullness K key) {
+ public Entry<K, V> lowerEntry(K key) {
return delegate().lowerEntry(key);
}
@@ -76,14 +73,12 @@
* #headMap(Object, boolean)}. If you override {@code headMap}, you may wish to override {@code
* lowerEntry} to forward to this implementation.
*/
- @CheckForNull
- protected Entry<K, V> standardLowerEntry(@ParametricNullness K key) {
+ protected Entry<K, V> standardLowerEntry(K key) {
return headMap(key, false).lastEntry();
}
@Override
- @CheckForNull
- public K lowerKey(@ParametricNullness K key) {
+ public K lowerKey(K key) {
return delegate().lowerKey(key);
}
@@ -92,14 +87,12 @@
* {@link #lowerEntry}, you may wish to override {@code lowerKey} to forward to this
* implementation.
*/
- @CheckForNull
- protected K standardLowerKey(@ParametricNullness K key) {
+ protected K standardLowerKey(K key) {
return keyOrNull(lowerEntry(key));
}
@Override
- @CheckForNull
- public Entry<K, V> floorEntry(@ParametricNullness K key) {
+ public Entry<K, V> floorEntry(K key) {
return delegate().floorEntry(key);
}
@@ -108,14 +101,12 @@
* #headMap(Object, boolean)}. If you override {@code headMap}, you may wish to override {@code
* floorEntry} to forward to this implementation.
*/
- @CheckForNull
- protected Entry<K, V> standardFloorEntry(@ParametricNullness K key) {
+ protected Entry<K, V> standardFloorEntry(K key) {
return headMap(key, true).lastEntry();
}
@Override
- @CheckForNull
- public K floorKey(@ParametricNullness K key) {
+ public K floorKey(K key) {
return delegate().floorKey(key);
}
@@ -124,14 +115,12 @@
* {@code floorEntry}, you may wish to override {@code floorKey} to forward to this
* implementation.
*/
- @CheckForNull
- protected K standardFloorKey(@ParametricNullness K key) {
+ protected K standardFloorKey(K key) {
return keyOrNull(floorEntry(key));
}
@Override
- @CheckForNull
- public Entry<K, V> ceilingEntry(@ParametricNullness K key) {
+ public Entry<K, V> ceilingEntry(K key) {
return delegate().ceilingEntry(key);
}
@@ -140,14 +129,12 @@
* #tailMap(Object, boolean)}. If you override {@code tailMap}, you may wish to override {@code
* ceilingEntry} to forward to this implementation.
*/
- @CheckForNull
- protected Entry<K, V> standardCeilingEntry(@ParametricNullness K key) {
+ protected Entry<K, V> standardCeilingEntry(K key) {
return tailMap(key, true).firstEntry();
}
@Override
- @CheckForNull
- public K ceilingKey(@ParametricNullness K key) {
+ public K ceilingKey(K key) {
return delegate().ceilingKey(key);
}
@@ -156,14 +143,12 @@
* {@code ceilingEntry}, you may wish to override {@code ceilingKey} to forward to this
* implementation.
*/
- @CheckForNull
- protected K standardCeilingKey(@ParametricNullness K key) {
+ protected K standardCeilingKey(K key) {
return keyOrNull(ceilingEntry(key));
}
@Override
- @CheckForNull
- public Entry<K, V> higherEntry(@ParametricNullness K key) {
+ public Entry<K, V> higherEntry(K key) {
return delegate().higherEntry(key);
}
@@ -172,14 +157,12 @@
* #tailMap(Object, boolean)}. If you override {@code tailMap}, you may wish to override {@code
* higherEntry} to forward to this implementation.
*/
- @CheckForNull
- protected Entry<K, V> standardHigherEntry(@ParametricNullness K key) {
+ protected Entry<K, V> standardHigherEntry(K key) {
return tailMap(key, false).firstEntry();
}
@Override
- @CheckForNull
- public K higherKey(@ParametricNullness K key) {
+ public K higherKey(K key) {
return delegate().higherKey(key);
}
@@ -188,13 +171,11 @@
* {@code higherEntry}, you may wish to override {@code higherKey} to forward to this
* implementation.
*/
- @CheckForNull
- protected K standardHigherKey(@ParametricNullness K key) {
+ protected K standardHigherKey(K key) {
return keyOrNull(higherEntry(key));
}
@Override
- @CheckForNull
public Entry<K, V> firstEntry() {
return delegate().firstEntry();
}
@@ -204,7 +185,6 @@
* #entrySet}. If you override {@code entrySet}, you may wish to override {@code firstEntry} to
* forward to this implementation.
*/
- @CheckForNull
protected Entry<K, V> standardFirstEntry() {
return Iterables.getFirst(entrySet(), null);
}
@@ -224,7 +204,6 @@
}
@Override
- @CheckForNull
public Entry<K, V> lastEntry() {
return delegate().lastEntry();
}
@@ -234,7 +213,6 @@
* #entrySet} of {@link #descendingMap}. If you override {@code descendingMap}, you may wish to
* override {@code lastEntry} to forward to this implementation.
*/
- @CheckForNull
protected Entry<K, V> standardLastEntry() {
return Iterables.getFirst(descendingMap().entrySet(), null);
}
@@ -253,7 +231,6 @@
}
@Override
- @CheckForNull
public Entry<K, V> pollFirstEntry() {
return delegate().pollFirstEntry();
}
@@ -263,13 +240,11 @@
* entrySet}. If you override {@code entrySet}, you may wish to override {@code pollFirstEntry} to
* forward to this implementation.
*/
- @CheckForNull
protected Entry<K, V> standardPollFirstEntry() {
return Iterators.pollNext(entrySet().iterator());
}
@Override
- @CheckForNull
public Entry<K, V> pollLastEntry() {
return delegate().pollLastEntry();
}
@@ -279,7 +254,6 @@
* entrySet} of {@code descendingMap}. If you override {@code descendingMap}, you may wish to
* override {@code pollFirstEntry} to forward to this implementation.
*/
- @CheckForNull
protected Entry<K, V> standardPollLastEntry() {
return Iterators.pollNext(descendingMap().entrySet().iterator());
}
@@ -313,8 +287,8 @@
@Override
protected Iterator<Entry<K, V>> entryIterator() {
return new Iterator<Entry<K, V>>() {
- @CheckForNull private Entry<K, V> toRemove = null;
- @CheckForNull private Entry<K, V> nextOrNull = forward().lastEntry();
+ private Entry<K, V> toRemove = null;
+ private Entry<K, V> nextOrNull = forward().lastEntry();
@Override
public boolean hasNext() {
@@ -323,7 +297,7 @@
@Override
public java.util.Map.Entry<K, V> next() {
- if (nextOrNull == null) {
+ if (!hasNext()) {
throw new NoSuchElementException();
}
try {
@@ -336,9 +310,7 @@
@Override
public void remove() {
- if (toRemove == null) {
- throw new IllegalStateException("no calls to next() since the last call to remove()");
- }
+ checkRemove(toRemove != null);
forward().remove(toRemove.getKey());
toRemove = null;
}
@@ -390,27 +362,22 @@
* wish to override {@code subMap} to forward to this implementation.
*/
@Override
- protected SortedMap<K, V> standardSubMap(
- @ParametricNullness K fromKey, @ParametricNullness K toKey) {
+ protected SortedMap<K, V> standardSubMap(K fromKey, K toKey) {
return subMap(fromKey, true, toKey, false);
}
@Override
- public NavigableMap<K, V> subMap(
- @ParametricNullness K fromKey,
- boolean fromInclusive,
- @ParametricNullness K toKey,
- boolean toInclusive) {
+ public NavigableMap<K, V> subMap(K fromKey, boolean fromInclusive, K toKey, boolean toInclusive) {
return delegate().subMap(fromKey, fromInclusive, toKey, toInclusive);
}
@Override
- public NavigableMap<K, V> headMap(@ParametricNullness K toKey, boolean inclusive) {
+ public NavigableMap<K, V> headMap(K toKey, boolean inclusive) {
return delegate().headMap(toKey, inclusive);
}
@Override
- public NavigableMap<K, V> tailMap(@ParametricNullness K fromKey, boolean inclusive) {
+ public NavigableMap<K, V> tailMap(K fromKey, boolean inclusive) {
return delegate().tailMap(fromKey, inclusive);
}
@@ -419,7 +386,7 @@
* boolean)}. If you override {@code headMap(K, boolean)}, you may wish to override {@code
* headMap} to forward to this implementation.
*/
- protected SortedMap<K, V> standardHeadMap(@ParametricNullness K toKey) {
+ protected SortedMap<K, V> standardHeadMap(K toKey) {
return headMap(toKey, false);
}
@@ -428,7 +395,7 @@
* boolean)}. If you override {@code tailMap(K, boolean)}, you may wish to override {@code
* tailMap} to forward to this implementation.
*/
- protected SortedMap<K, V> standardTailMap(@ParametricNullness K fromKey) {
+ protected SortedMap<K, V> standardTailMap(K fromKey) {
return tailMap(fromKey, true);
}
}
diff --git a/android/guava/src/com/google/common/collect/ForwardingNavigableSet.java b/android/guava/src/com/google/common/collect/ForwardingNavigableSet.java
index 6822aa8..827698e 100644
--- a/android/guava/src/com/google/common/collect/ForwardingNavigableSet.java
+++ b/android/guava/src/com/google/common/collect/ForwardingNavigableSet.java
@@ -21,8 +21,6 @@
import java.util.Iterator;
import java.util.NavigableSet;
import java.util.SortedSet;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* A navigable set which forwards all its method calls to another navigable set. Subclasses should
@@ -51,9 +49,8 @@
* @since 12.0
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
-public abstract class ForwardingNavigableSet<E extends @Nullable Object>
- extends ForwardingSortedSet<E> implements NavigableSet<E> {
+public abstract class ForwardingNavigableSet<E> extends ForwardingSortedSet<E>
+ implements NavigableSet<E> {
/** Constructor for use by subclasses. */
protected ForwardingNavigableSet() {}
@@ -62,8 +59,7 @@
protected abstract NavigableSet<E> delegate();
@Override
- @CheckForNull
- public E lower(@ParametricNullness E e) {
+ public E lower(E e) {
return delegate().lower(e);
}
@@ -72,14 +68,12 @@
* {@link #headSet(Object, boolean)}. If you override {@link #headSet(Object, boolean)}, you may
* wish to override {@link #lower} to forward to this implementation.
*/
- @CheckForNull
- protected E standardLower(@ParametricNullness E e) {
+ protected E standardLower(E e) {
return Iterators.getNext(headSet(e, false).descendingIterator(), null);
}
@Override
- @CheckForNull
- public E floor(@ParametricNullness E e) {
+ public E floor(E e) {
return delegate().floor(e);
}
@@ -88,14 +82,12 @@
* {@link #headSet(Object, boolean)}. If you override {@link #headSet(Object, boolean)}, you may
* wish to override {@link #floor} to forward to this implementation.
*/
- @CheckForNull
- protected E standardFloor(@ParametricNullness E e) {
+ protected E standardFloor(E e) {
return Iterators.getNext(headSet(e, true).descendingIterator(), null);
}
@Override
- @CheckForNull
- public E ceiling(@ParametricNullness E e) {
+ public E ceiling(E e) {
return delegate().ceiling(e);
}
@@ -104,14 +96,12 @@
* #tailSet(Object, boolean)}. If you override {@link #tailSet(Object, boolean)}, you may wish to
* override {@link #ceiling} to forward to this implementation.
*/
- @CheckForNull
- protected E standardCeiling(@ParametricNullness E e) {
+ protected E standardCeiling(E e) {
return Iterators.getNext(tailSet(e, true).iterator(), null);
}
@Override
- @CheckForNull
- public E higher(@ParametricNullness E e) {
+ public E higher(E e) {
return delegate().higher(e);
}
@@ -120,13 +110,11 @@
* #tailSet(Object, boolean)}. If you override {@link #tailSet(Object, boolean)}, you may wish to
* override {@link #higher} to forward to this implementation.
*/
- @CheckForNull
- protected E standardHigher(@ParametricNullness E e) {
+ protected E standardHigher(E e) {
return Iterators.getNext(tailSet(e, false).iterator(), null);
}
@Override
- @CheckForNull
public E pollFirst() {
return delegate().pollFirst();
}
@@ -136,13 +124,11 @@
* override {@link #iterator} you may wish to override {@link #pollFirst} to forward to this
* implementation.
*/
- @CheckForNull
protected E standardPollFirst() {
return Iterators.pollNext(iterator());
}
@Override
- @CheckForNull
public E pollLast() {
return delegate().pollLast();
}
@@ -152,17 +138,14 @@
* If you override {@link #descendingIterator} you may wish to override {@link #pollLast} to
* forward to this implementation.
*/
- @CheckForNull
protected E standardPollLast() {
return Iterators.pollNext(descendingIterator());
}
- @ParametricNullness
protected E standardFirst() {
return iterator().next();
}
- @ParametricNullness
protected E standardLast() {
return descendingIterator().next();
}
@@ -196,10 +179,7 @@
@Override
public NavigableSet<E> subSet(
- @ParametricNullness E fromElement,
- boolean fromInclusive,
- @ParametricNullness E toElement,
- boolean toInclusive) {
+ E fromElement, boolean fromInclusive, E toElement, boolean toInclusive) {
return delegate().subSet(fromElement, fromInclusive, toElement, toInclusive);
}
@@ -210,10 +190,7 @@
*/
@Beta
protected NavigableSet<E> standardSubSet(
- @ParametricNullness E fromElement,
- boolean fromInclusive,
- @ParametricNullness E toElement,
- boolean toInclusive) {
+ E fromElement, boolean fromInclusive, E toElement, boolean toInclusive) {
return tailSet(fromElement, fromInclusive).headSet(toElement, toInclusive);
}
@@ -224,13 +201,12 @@
* implementation.
*/
@Override
- protected SortedSet<E> standardSubSet(
- @ParametricNullness E fromElement, @ParametricNullness E toElement) {
+ protected SortedSet<E> standardSubSet(E fromElement, E toElement) {
return subSet(fromElement, true, toElement, false);
}
@Override
- public NavigableSet<E> headSet(@ParametricNullness E toElement, boolean inclusive) {
+ public NavigableSet<E> headSet(E toElement, boolean inclusive) {
return delegate().headSet(toElement, inclusive);
}
@@ -239,12 +215,12 @@
* boolean)} method. If you override {@link #headSet(Object, boolean)}, you may wish to override
* {@link #headSet(Object)} to forward to this implementation.
*/
- protected SortedSet<E> standardHeadSet(@ParametricNullness E toElement) {
+ protected SortedSet<E> standardHeadSet(E toElement) {
return headSet(toElement, false);
}
@Override
- public NavigableSet<E> tailSet(@ParametricNullness E fromElement, boolean inclusive) {
+ public NavigableSet<E> tailSet(E fromElement, boolean inclusive) {
return delegate().tailSet(fromElement, inclusive);
}
@@ -253,7 +229,7 @@
* boolean)} method. If you override {@link #tailSet(Object, boolean)}, you may wish to override
* {@link #tailSet(Object)} to forward to this implementation.
*/
- protected SortedSet<E> standardTailSet(@ParametricNullness E fromElement) {
+ protected SortedSet<E> standardTailSet(E fromElement) {
return tailSet(fromElement, true);
}
}
diff --git a/android/guava/src/com/google/common/collect/ForwardingObject.java b/android/guava/src/com/google/common/collect/ForwardingObject.java
index 64af908..712b14f 100644
--- a/android/guava/src/com/google/common/collect/ForwardingObject.java
+++ b/android/guava/src/com/google/common/collect/ForwardingObject.java
@@ -44,7 +44,6 @@
* @since 2.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
public abstract class ForwardingObject {
/** Constructor for use by subclasses. */
diff --git a/android/guava/src/com/google/common/collect/ForwardingQueue.java b/android/guava/src/com/google/common/collect/ForwardingQueue.java
index 43c2eaa..f77e560 100644
--- a/android/guava/src/com/google/common/collect/ForwardingQueue.java
+++ b/android/guava/src/com/google/common/collect/ForwardingQueue.java
@@ -20,8 +20,6 @@
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import java.util.NoSuchElementException;
import java.util.Queue;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* A queue which forwards all its method calls to another queue. Subclasses should override one or
@@ -46,9 +44,7 @@
* @since 2.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-public abstract class ForwardingQueue<E extends @Nullable Object> extends ForwardingCollection<E>
- implements Queue<E> {
+public abstract class ForwardingQueue<E> extends ForwardingCollection<E> implements Queue<E> {
/** Constructor for use by subclasses. */
protected ForwardingQueue() {}
@@ -58,32 +54,28 @@
@CanIgnoreReturnValue // TODO(cpovirk): Consider removing this?
@Override
- public boolean offer(@ParametricNullness E o) {
+ public boolean offer(E o) {
return delegate().offer(o);
}
@CanIgnoreReturnValue // TODO(cpovirk): Consider removing this?
@Override
- @CheckForNull
public E poll() {
return delegate().poll();
}
@CanIgnoreReturnValue
@Override
- @ParametricNullness
public E remove() {
return delegate().remove();
}
@Override
- @CheckForNull
public E peek() {
return delegate().peek();
}
@Override
- @ParametricNullness
public E element() {
return delegate().element();
}
@@ -94,7 +86,7 @@
*
* @since 7.0
*/
- protected boolean standardOffer(@ParametricNullness E e) {
+ protected boolean standardOffer(E e) {
try {
return add(e);
} catch (IllegalStateException caught) {
@@ -108,7 +100,6 @@
*
* @since 7.0
*/
- @CheckForNull
protected E standardPeek() {
try {
return element();
@@ -123,7 +114,6 @@
*
* @since 7.0
*/
- @CheckForNull
protected E standardPoll() {
try {
return remove();
diff --git a/android/guava/src/com/google/common/collect/ForwardingSet.java b/android/guava/src/com/google/common/collect/ForwardingSet.java
index bc27272..73b1413 100644
--- a/android/guava/src/com/google/common/collect/ForwardingSet.java
+++ b/android/guava/src/com/google/common/collect/ForwardingSet.java
@@ -21,8 +21,7 @@
import com.google.common.annotations.GwtCompatible;
import java.util.Collection;
import java.util.Set;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* A set which forwards all its method calls to another set. Subclasses should override one or more
@@ -47,9 +46,7 @@
* @since 2.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-public abstract class ForwardingSet<E extends @Nullable Object> extends ForwardingCollection<E>
- implements Set<E> {
+public abstract class ForwardingSet<E> extends ForwardingCollection<E> implements Set<E> {
// TODO(lowasser): identify places where thread safety is actually lost
/** Constructor for use by subclasses. */
@@ -59,7 +56,7 @@
protected abstract Set<E> delegate();
@Override
- public boolean equals(@CheckForNull Object object) {
+ public boolean equals(@NullableDecl Object object) {
return object == this || delegate().equals(object);
}
@@ -87,7 +84,7 @@
*
* @since 7.0
*/
- protected boolean standardEquals(@CheckForNull Object object) {
+ protected boolean standardEquals(@NullableDecl Object object) {
return Sets.equalsImpl(this, object);
}
diff --git a/android/guava/src/com/google/common/collect/ForwardingSetMultimap.java b/android/guava/src/com/google/common/collect/ForwardingSetMultimap.java
index 5077c68..61a0de2 100644
--- a/android/guava/src/com/google/common/collect/ForwardingSetMultimap.java
+++ b/android/guava/src/com/google/common/collect/ForwardingSetMultimap.java
@@ -20,8 +20,7 @@
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import java.util.Map.Entry;
import java.util.Set;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* A set multimap which forwards all its method calls to another set multimap. Subclasses should
@@ -36,9 +35,8 @@
* @since 3.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-public abstract class ForwardingSetMultimap<K extends @Nullable Object, V extends @Nullable Object>
- extends ForwardingMultimap<K, V> implements SetMultimap<K, V> {
+public abstract class ForwardingSetMultimap<K, V> extends ForwardingMultimap<K, V>
+ implements SetMultimap<K, V> {
@Override
protected abstract SetMultimap<K, V> delegate();
@@ -49,19 +47,19 @@
}
@Override
- public Set<V> get(@ParametricNullness K key) {
+ public Set<V> get(@NullableDecl K key) {
return delegate().get(key);
}
@CanIgnoreReturnValue
@Override
- public Set<V> removeAll(@CheckForNull Object key) {
+ public Set<V> removeAll(@NullableDecl Object key) {
return delegate().removeAll(key);
}
@CanIgnoreReturnValue
@Override
- public Set<V> replaceValues(@ParametricNullness K key, Iterable<? extends V> values) {
+ public Set<V> replaceValues(K key, Iterable<? extends V> values) {
return delegate().replaceValues(key, values);
}
}
diff --git a/android/guava/src/com/google/common/collect/ForwardingSortedMap.java b/android/guava/src/com/google/common/collect/ForwardingSortedMap.java
index e0882ab..4866fb9 100644
--- a/android/guava/src/com/google/common/collect/ForwardingSortedMap.java
+++ b/android/guava/src/com/google/common/collect/ForwardingSortedMap.java
@@ -23,8 +23,7 @@
import java.util.Comparator;
import java.util.NoSuchElementException;
import java.util.SortedMap;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* A sorted map which forwards all its method calls to another sorted map. Subclasses should
@@ -52,9 +51,8 @@
* @since 2.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-public abstract class ForwardingSortedMap<K extends @Nullable Object, V extends @Nullable Object>
- extends ForwardingMap<K, V> implements SortedMap<K, V> {
+public abstract class ForwardingSortedMap<K, V> extends ForwardingMap<K, V>
+ implements SortedMap<K, V> {
// TODO(lowasser): identify places where thread safety is actually lost
/** Constructor for use by subclasses. */
@@ -64,35 +62,32 @@
protected abstract SortedMap<K, V> delegate();
@Override
- @CheckForNull
public Comparator<? super K> comparator() {
return delegate().comparator();
}
@Override
- @ParametricNullness
public K firstKey() {
return delegate().firstKey();
}
@Override
- public SortedMap<K, V> headMap(@ParametricNullness K toKey) {
+ public SortedMap<K, V> headMap(K toKey) {
return delegate().headMap(toKey);
}
@Override
- @ParametricNullness
public K lastKey() {
return delegate().lastKey();
}
@Override
- public SortedMap<K, V> subMap(@ParametricNullness K fromKey, @ParametricNullness K toKey) {
+ public SortedMap<K, V> subMap(K fromKey, K toKey) {
return delegate().subMap(fromKey, toKey);
}
@Override
- public SortedMap<K, V> tailMap(@ParametricNullness K fromKey) {
+ public SortedMap<K, V> tailMap(K fromKey) {
return delegate().tailMap(fromKey);
}
@@ -111,14 +106,14 @@
}
}
- // unsafe, but worst case is a CCE or NPE is thrown, which callers will be expecting
- @SuppressWarnings({"unchecked", "nullness"})
- static int unsafeCompare(
- @CheckForNull Comparator<?> comparator, @CheckForNull Object o1, @CheckForNull Object o2) {
+ // unsafe, but worst case is a CCE is thrown, which callers will be expecting
+ @SuppressWarnings("unchecked")
+ private int unsafeCompare(Object k1, Object k2) {
+ Comparator<? super K> comparator = comparator();
if (comparator == null) {
- return ((Comparable<@Nullable Object>) o1).compareTo(o2);
+ return ((Comparable<Object>) k1).compareTo(k2);
} else {
- return ((Comparator<@Nullable Object>) comparator).compare(o1, o2);
+ return ((Comparator<Object>) comparator).compare(k1, k2);
}
}
@@ -131,13 +126,13 @@
*/
@Override
@Beta
- protected boolean standardContainsKey(@CheckForNull Object key) {
+ protected boolean standardContainsKey(@NullableDecl Object key) {
try {
- // any CCE or NPE will be caught
- @SuppressWarnings({"unchecked", "nullness"})
- SortedMap<@Nullable Object, V> self = (SortedMap<@Nullable Object, V>) this;
+ // any CCE will be caught
+ @SuppressWarnings("unchecked")
+ SortedMap<Object, V> self = (SortedMap<Object, V>) this;
Object ceilingKey = self.tailMap(key).firstKey();
- return unsafeCompare(comparator(), ceilingKey, key) == 0;
+ return unsafeCompare(ceilingKey, key) == 0;
} catch (ClassCastException | NoSuchElementException | NullPointerException e) {
return false;
}
@@ -152,7 +147,7 @@
*/
@Beta
protected SortedMap<K, V> standardSubMap(K fromKey, K toKey) {
- checkArgument(unsafeCompare(comparator(), fromKey, toKey) <= 0, "fromKey must be <= toKey");
+ checkArgument(unsafeCompare(fromKey, toKey) <= 0, "fromKey must be <= toKey");
return tailMap(fromKey).headMap(toKey);
}
}
diff --git a/android/guava/src/com/google/common/collect/ForwardingSortedMultiset.java b/android/guava/src/com/google/common/collect/ForwardingSortedMultiset.java
index 4626d31..1d34fb3 100644
--- a/android/guava/src/com/google/common/collect/ForwardingSortedMultiset.java
+++ b/android/guava/src/com/google/common/collect/ForwardingSortedMultiset.java
@@ -19,8 +19,6 @@
import java.util.Comparator;
import java.util.Iterator;
import java.util.NavigableSet;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* A sorted multiset which forwards all its method calls to another sorted multiset. Subclasses
@@ -46,9 +44,8 @@
*/
@Beta
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
-public abstract class ForwardingSortedMultiset<E extends @Nullable Object>
- extends ForwardingMultiset<E> implements SortedMultiset<E> {
+public abstract class ForwardingSortedMultiset<E> extends ForwardingMultiset<E>
+ implements SortedMultiset<E> {
/** Constructor for use by subclasses. */
protected ForwardingSortedMultiset() {}
@@ -113,7 +110,6 @@
}
@Override
- @CheckForNull
public Entry<E> firstEntry() {
return delegate().firstEntry();
}
@@ -124,7 +120,6 @@
* <p>If you override {@link #entrySet()}, you may wish to override {@link #firstEntry()} to
* forward to this implementation.
*/
- @CheckForNull
protected Entry<E> standardFirstEntry() {
Iterator<Entry<E>> entryIterator = entrySet().iterator();
if (!entryIterator.hasNext()) {
@@ -135,7 +130,6 @@
}
@Override
- @CheckForNull
public Entry<E> lastEntry() {
return delegate().lastEntry();
}
@@ -147,7 +141,6 @@
* <p>If you override {@link #descendingMultiset} or {@link #entrySet()}, you may wish to override
* {@link #firstEntry()} to forward to this implementation.
*/
- @CheckForNull
protected Entry<E> standardLastEntry() {
Iterator<Entry<E>> entryIterator = descendingMultiset().entrySet().iterator();
if (!entryIterator.hasNext()) {
@@ -158,7 +151,6 @@
}
@Override
- @CheckForNull
public Entry<E> pollFirstEntry() {
return delegate().pollFirstEntry();
}
@@ -169,7 +161,6 @@
* <p>If you override {@link #entrySet()}, you may wish to override {@link #pollFirstEntry()} to
* forward to this implementation.
*/
- @CheckForNull
protected Entry<E> standardPollFirstEntry() {
Iterator<Entry<E>> entryIterator = entrySet().iterator();
if (!entryIterator.hasNext()) {
@@ -182,7 +173,6 @@
}
@Override
- @CheckForNull
public Entry<E> pollLastEntry() {
return delegate().pollLastEntry();
}
@@ -194,7 +184,6 @@
* <p>If you override {@link #descendingMultiset()} or {@link #entrySet()}, you may wish to
* override {@link #pollLastEntry()} to forward to this implementation.
*/
- @CheckForNull
protected Entry<E> standardPollLastEntry() {
Iterator<Entry<E>> entryIterator = descendingMultiset().entrySet().iterator();
if (!entryIterator.hasNext()) {
@@ -207,16 +196,13 @@
}
@Override
- public SortedMultiset<E> headMultiset(@ParametricNullness E upperBound, BoundType boundType) {
+ public SortedMultiset<E> headMultiset(E upperBound, BoundType boundType) {
return delegate().headMultiset(upperBound, boundType);
}
@Override
public SortedMultiset<E> subMultiset(
- @ParametricNullness E lowerBound,
- BoundType lowerBoundType,
- @ParametricNullness E upperBound,
- BoundType upperBoundType) {
+ E lowerBound, BoundType lowerBoundType, E upperBound, BoundType upperBoundType) {
return delegate().subMultiset(lowerBound, lowerBoundType, upperBound, upperBoundType);
}
@@ -229,15 +215,12 @@
* #subMultiset(Object, BoundType, Object, BoundType)} to forward to this implementation.
*/
protected SortedMultiset<E> standardSubMultiset(
- @ParametricNullness E lowerBound,
- BoundType lowerBoundType,
- @ParametricNullness E upperBound,
- BoundType upperBoundType) {
+ E lowerBound, BoundType lowerBoundType, E upperBound, BoundType upperBoundType) {
return tailMultiset(lowerBound, lowerBoundType).headMultiset(upperBound, upperBoundType);
}
@Override
- public SortedMultiset<E> tailMultiset(@ParametricNullness E lowerBound, BoundType boundType) {
+ public SortedMultiset<E> tailMultiset(E lowerBound, BoundType boundType) {
return delegate().tailMultiset(lowerBound, boundType);
}
}
diff --git a/android/guava/src/com/google/common/collect/ForwardingSortedSet.java b/android/guava/src/com/google/common/collect/ForwardingSortedSet.java
index 32625af..9879944 100644
--- a/android/guava/src/com/google/common/collect/ForwardingSortedSet.java
+++ b/android/guava/src/com/google/common/collect/ForwardingSortedSet.java
@@ -16,16 +16,13 @@
package com.google.common.collect;
-import static com.google.common.collect.ForwardingSortedMap.unsafeCompare;
-
import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtCompatible;
import java.util.Comparator;
import java.util.Iterator;
import java.util.NoSuchElementException;
import java.util.SortedSet;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* A sorted set which forwards all its method calls to another sorted set. Subclasses should
@@ -55,9 +52,7 @@
* @since 2.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-public abstract class ForwardingSortedSet<E extends @Nullable Object> extends ForwardingSet<E>
- implements SortedSet<E> {
+public abstract class ForwardingSortedSet<E> extends ForwardingSet<E> implements SortedSet<E> {
/** Constructor for use by subclasses. */
protected ForwardingSortedSet() {}
@@ -66,38 +61,44 @@
protected abstract SortedSet<E> delegate();
@Override
- @CheckForNull
public Comparator<? super E> comparator() {
return delegate().comparator();
}
@Override
- @ParametricNullness
public E first() {
return delegate().first();
}
@Override
- public SortedSet<E> headSet(@ParametricNullness E toElement) {
+ public SortedSet<E> headSet(E toElement) {
return delegate().headSet(toElement);
}
@Override
- @ParametricNullness
public E last() {
return delegate().last();
}
@Override
- public SortedSet<E> subSet(@ParametricNullness E fromElement, @ParametricNullness E toElement) {
+ public SortedSet<E> subSet(E fromElement, E toElement) {
return delegate().subSet(fromElement, toElement);
}
@Override
- public SortedSet<E> tailSet(@ParametricNullness E fromElement) {
+ public SortedSet<E> tailSet(E fromElement) {
return delegate().tailSet(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) {
+ Comparator<? super E> comparator = comparator();
+ return (comparator == null)
+ ? ((Comparable<Object>) o1).compareTo(o2)
+ : ((Comparator<Object>) comparator).compare(o1, o2);
+ }
+
/**
* A sensible definition of {@link #contains} in terms of the {@code first()} method of {@link
* #tailSet}. If you override {@link #tailSet}, you may wish to override {@link #contains} to
@@ -107,13 +108,13 @@
*/
@Override
@Beta
- protected boolean standardContains(@CheckForNull Object object) {
+ protected boolean standardContains(@NullableDecl Object object) {
try {
- // any ClassCastExceptions and NullPointerExceptions are caught
- @SuppressWarnings({"unchecked", "nullness"})
- SortedSet<@Nullable Object> self = (SortedSet<@Nullable Object>) this;
+ // any ClassCastExceptions are caught
+ @SuppressWarnings("unchecked")
+ SortedSet<Object> self = (SortedSet<Object>) this;
Object ceiling = self.tailSet(object).first();
- return unsafeCompare(comparator(), ceiling, object) == 0;
+ return unsafeCompare(ceiling, object) == 0;
} catch (ClassCastException | NoSuchElementException | NullPointerException e) {
return false;
}
@@ -128,15 +129,15 @@
*/
@Override
@Beta
- protected boolean standardRemove(@CheckForNull Object object) {
+ protected boolean standardRemove(@NullableDecl Object object) {
try {
- // any ClassCastExceptions and NullPointerExceptions are caught
- @SuppressWarnings({"unchecked", "nullness"})
- SortedSet<@Nullable Object> self = (SortedSet<@Nullable Object>) this;
- Iterator<?> iterator = self.tailSet(object).iterator();
+ // any ClassCastExceptions are caught
+ @SuppressWarnings("unchecked")
+ SortedSet<Object> self = (SortedSet<Object>) this;
+ Iterator<Object> iterator = self.tailSet(object).iterator();
if (iterator.hasNext()) {
Object ceiling = iterator.next();
- if (unsafeCompare(comparator(), ceiling, object) == 0) {
+ if (unsafeCompare(ceiling, object) == 0) {
iterator.remove();
return true;
}
@@ -155,8 +156,7 @@
* @since 7.0
*/
@Beta
- protected SortedSet<E> standardSubSet(
- @ParametricNullness E fromElement, @ParametricNullness E toElement) {
+ protected SortedSet<E> standardSubSet(E fromElement, E toElement) {
return tailSet(fromElement).headSet(toElement);
}
}
diff --git a/android/guava/src/com/google/common/collect/ForwardingSortedSetMultimap.java b/android/guava/src/com/google/common/collect/ForwardingSortedSetMultimap.java
index b91a68b..78319a7 100644
--- a/android/guava/src/com/google/common/collect/ForwardingSortedSetMultimap.java
+++ b/android/guava/src/com/google/common/collect/ForwardingSortedSetMultimap.java
@@ -19,8 +19,7 @@
import com.google.common.annotations.GwtCompatible;
import java.util.Comparator;
import java.util.SortedSet;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* A sorted set multimap which forwards all its method calls to another sorted set multimap.
@@ -35,10 +34,8 @@
* @since 3.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-public abstract class ForwardingSortedSetMultimap<
- K extends @Nullable Object, V extends @Nullable Object>
- extends ForwardingSetMultimap<K, V> implements SortedSetMultimap<K, V> {
+public abstract class ForwardingSortedSetMultimap<K, V> extends ForwardingSetMultimap<K, V>
+ implements SortedSetMultimap<K, V> {
/** Constructor for use by subclasses. */
protected ForwardingSortedSetMultimap() {}
@@ -47,22 +44,21 @@
protected abstract SortedSetMultimap<K, V> delegate();
@Override
- public SortedSet<V> get(@ParametricNullness K key) {
+ public SortedSet<V> get(@NullableDecl K key) {
return delegate().get(key);
}
@Override
- public SortedSet<V> removeAll(@CheckForNull Object key) {
+ public SortedSet<V> removeAll(@NullableDecl Object key) {
return delegate().removeAll(key);
}
@Override
- public SortedSet<V> replaceValues(@ParametricNullness K key, Iterable<? extends V> values) {
+ public SortedSet<V> replaceValues(K key, Iterable<? extends V> values) {
return delegate().replaceValues(key, values);
}
@Override
- @CheckForNull
public Comparator<? super V> valueComparator() {
return delegate().valueComparator();
}
diff --git a/android/guava/src/com/google/common/collect/ForwardingTable.java b/android/guava/src/com/google/common/collect/ForwardingTable.java
index 4fcb858..71a54cf 100644
--- a/android/guava/src/com/google/common/collect/ForwardingTable.java
+++ b/android/guava/src/com/google/common/collect/ForwardingTable.java
@@ -21,8 +21,6 @@
import java.util.Collection;
import java.util.Map;
import java.util.Set;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* A table which forwards all its method calls to another table. Subclasses should override one or
@@ -33,10 +31,7 @@
* @since 7.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-public abstract class ForwardingTable<
- R extends @Nullable Object, C extends @Nullable Object, V extends @Nullable Object>
- extends ForwardingObject implements Table<R, C, V> {
+public abstract class ForwardingTable<R, C, V> extends ForwardingObject implements Table<R, C, V> {
/** Constructor for use by subclasses. */
protected ForwardingTable() {}
@@ -54,7 +49,7 @@
}
@Override
- public Map<R, V> column(@ParametricNullness C columnKey) {
+ public Map<R, V> column(C columnKey) {
return delegate().column(columnKey);
}
@@ -69,28 +64,27 @@
}
@Override
- public boolean contains(@CheckForNull Object rowKey, @CheckForNull Object columnKey) {
+ public boolean contains(Object rowKey, Object columnKey) {
return delegate().contains(rowKey, columnKey);
}
@Override
- public boolean containsColumn(@CheckForNull Object columnKey) {
+ public boolean containsColumn(Object columnKey) {
return delegate().containsColumn(columnKey);
}
@Override
- public boolean containsRow(@CheckForNull Object rowKey) {
+ public boolean containsRow(Object rowKey) {
return delegate().containsRow(rowKey);
}
@Override
- public boolean containsValue(@CheckForNull Object value) {
+ public boolean containsValue(Object value) {
return delegate().containsValue(value);
}
@Override
- @CheckForNull
- public V get(@CheckForNull Object rowKey, @CheckForNull Object columnKey) {
+ public V get(Object rowKey, Object columnKey) {
return delegate().get(rowKey, columnKey);
}
@@ -101,9 +95,7 @@
@CanIgnoreReturnValue
@Override
- @CheckForNull
- public V put(
- @ParametricNullness R rowKey, @ParametricNullness C columnKey, @ParametricNullness V value) {
+ public V put(R rowKey, C columnKey, V value) {
return delegate().put(rowKey, columnKey, value);
}
@@ -114,13 +106,12 @@
@CanIgnoreReturnValue
@Override
- @CheckForNull
- public V remove(@CheckForNull Object rowKey, @CheckForNull Object columnKey) {
+ public V remove(Object rowKey, Object columnKey) {
return delegate().remove(rowKey, columnKey);
}
@Override
- public Map<C, V> row(@ParametricNullness R rowKey) {
+ public Map<C, V> row(R rowKey) {
return delegate().row(rowKey);
}
@@ -145,7 +136,7 @@
}
@Override
- public boolean equals(@CheckForNull Object obj) {
+ public boolean equals(Object obj) {
return (obj == this) || delegate().equals(obj);
}
diff --git a/android/guava/src/com/google/common/collect/GeneralRange.java b/android/guava/src/com/google/common/collect/GeneralRange.java
index 20cf4fb..6956187 100644
--- a/android/guava/src/com/google/common/collect/GeneralRange.java
+++ b/android/guava/src/com/google/common/collect/GeneralRange.java
@@ -18,14 +18,12 @@
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.collect.BoundType.CLOSED;
import static com.google.common.collect.BoundType.OPEN;
-import static com.google.common.collect.NullnessCasts.uncheckedCastNullableTToT;
import com.google.common.annotations.GwtCompatible;
import com.google.common.base.Objects;
import java.io.Serializable;
import java.util.Comparator;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* A generalized interval on any ordering, for internal use. Supports {@code null}. Unlike {@link
@@ -37,14 +35,13 @@
* @author Louis Wasserman
*/
@GwtCompatible(serializable = true)
-@ElementTypesAreNonnullByDefault
-final class GeneralRange<T extends @Nullable Object> implements Serializable {
+final class GeneralRange<T> implements Serializable {
/** Converts a Range to a GeneralRange. */
static <T extends Comparable> GeneralRange<T> from(Range<T> range) {
- T lowerEndpoint = range.hasLowerBound() ? range.lowerEndpoint() : null;
+ @NullableDecl T lowerEndpoint = range.hasLowerBound() ? range.lowerEndpoint() : null;
BoundType lowerBoundType = range.hasLowerBound() ? range.lowerBoundType() : OPEN;
- T upperEndpoint = range.hasUpperBound() ? range.upperEndpoint() : null;
+ @NullableDecl T upperEndpoint = range.hasUpperBound() ? range.upperEndpoint() : null;
BoundType upperBoundType = range.hasUpperBound() ? range.upperBoundType() : OPEN;
return new GeneralRange<T>(
Ordering.natural(),
@@ -57,7 +54,7 @@
}
/** Returns the whole range relative to the specified comparator. */
- static <T extends @Nullable Object> GeneralRange<T> all(Comparator<? super T> comparator) {
+ static <T> GeneralRange<T> all(Comparator<? super T> comparator) {
return new GeneralRange<T>(comparator, false, null, OPEN, false, null, OPEN);
}
@@ -65,8 +62,8 @@
* Returns everything above the endpoint relative to the specified comparator, with the specified
* endpoint behavior.
*/
- static <T extends @Nullable Object> GeneralRange<T> downTo(
- Comparator<? super T> comparator, @ParametricNullness T endpoint, BoundType boundType) {
+ static <T> GeneralRange<T> downTo(
+ Comparator<? super T> comparator, @NullableDecl T endpoint, BoundType boundType) {
return new GeneralRange<T>(comparator, true, endpoint, boundType, false, null, OPEN);
}
@@ -74,8 +71,8 @@
* Returns everything below the endpoint relative to the specified comparator, with the specified
* endpoint behavior.
*/
- static <T extends @Nullable Object> GeneralRange<T> upTo(
- Comparator<? super T> comparator, @ParametricNullness T endpoint, BoundType boundType) {
+ static <T> GeneralRange<T> upTo(
+ Comparator<? super T> comparator, @NullableDecl T endpoint, BoundType boundType) {
return new GeneralRange<T>(comparator, false, null, OPEN, true, endpoint, boundType);
}
@@ -83,30 +80,30 @@
* Returns everything between the endpoints relative to the specified comparator, with the
* specified endpoint behavior.
*/
- static <T extends @Nullable Object> GeneralRange<T> range(
+ static <T> GeneralRange<T> range(
Comparator<? super T> comparator,
- @ParametricNullness T lower,
+ @NullableDecl T lower,
BoundType lowerType,
- @ParametricNullness T upper,
+ @NullableDecl T upper,
BoundType upperType) {
return new GeneralRange<T>(comparator, true, lower, lowerType, true, upper, upperType);
}
private final Comparator<? super T> comparator;
private final boolean hasLowerBound;
- @CheckForNull private final T lowerEndpoint;
+ @NullableDecl private final T lowerEndpoint;
private final BoundType lowerBoundType;
private final boolean hasUpperBound;
- @CheckForNull private final T upperEndpoint;
+ @NullableDecl private final T upperEndpoint;
private final BoundType upperBoundType;
private GeneralRange(
Comparator<? super T> comparator,
boolean hasLowerBound,
- @CheckForNull T lowerEndpoint,
+ @NullableDecl T lowerEndpoint,
BoundType lowerBoundType,
boolean hasUpperBound,
- @CheckForNull T upperEndpoint,
+ @NullableDecl T upperEndpoint,
BoundType upperBoundType) {
this.comparator = checkNotNull(comparator);
this.hasLowerBound = hasLowerBound;
@@ -116,24 +113,14 @@
this.upperEndpoint = upperEndpoint;
this.upperBoundType = checkNotNull(upperBoundType);
- // Trigger any exception that the comparator would throw for the endpoints.
- /*
- * uncheckedCastNullableTToT is safe as long as the callers are careful to pass a "real" T
- * whenever they pass `true` for the matching `has*Bound` parameter.
- */
if (hasLowerBound) {
- comparator.compare(
- uncheckedCastNullableTToT(lowerEndpoint), uncheckedCastNullableTToT(lowerEndpoint));
+ comparator.compare(lowerEndpoint, lowerEndpoint);
}
if (hasUpperBound) {
- comparator.compare(
- uncheckedCastNullableTToT(upperEndpoint), uncheckedCastNullableTToT(upperEndpoint));
+ comparator.compare(upperEndpoint, upperEndpoint);
}
-
if (hasLowerBound && hasUpperBound) {
- int cmp =
- comparator.compare(
- uncheckedCastNullableTToT(lowerEndpoint), uncheckedCastNullableTToT(upperEndpoint));
+ int cmp = comparator.compare(lowerEndpoint, upperEndpoint);
// be consistent with Range
checkArgument(
cmp <= 0, "lowerEndpoint (%s) > upperEndpoint (%s)", lowerEndpoint, upperEndpoint);
@@ -156,45 +143,41 @@
}
boolean isEmpty() {
- // The casts are safe because of the has*Bound() checks.
- return (hasUpperBound() && tooLow(uncheckedCastNullableTToT(getUpperEndpoint())))
- || (hasLowerBound() && tooHigh(uncheckedCastNullableTToT(getLowerEndpoint())));
+ return (hasUpperBound() && tooLow(getUpperEndpoint()))
+ || (hasLowerBound() && tooHigh(getLowerEndpoint()));
}
- boolean tooLow(@ParametricNullness T t) {
+ boolean tooLow(@NullableDecl T t) {
if (!hasLowerBound()) {
return false;
}
- // The cast is safe because of the hasLowerBound() check.
- T lbound = uncheckedCastNullableTToT(getLowerEndpoint());
+ T lbound = getLowerEndpoint();
int cmp = comparator.compare(t, lbound);
return cmp < 0 | (cmp == 0 & getLowerBoundType() == OPEN);
}
- boolean tooHigh(@ParametricNullness T t) {
+ boolean tooHigh(@NullableDecl T t) {
if (!hasUpperBound()) {
return false;
}
- // The cast is safe because of the hasUpperBound() check.
- T ubound = uncheckedCastNullableTToT(getUpperEndpoint());
+ T ubound = getUpperEndpoint();
int cmp = comparator.compare(t, ubound);
return cmp > 0 | (cmp == 0 & getUpperBoundType() == OPEN);
}
- boolean contains(@ParametricNullness T t) {
+ boolean contains(@NullableDecl T t) {
return !tooLow(t) && !tooHigh(t);
}
/**
* Returns the intersection of the two ranges, or an empty range if their intersection is empty.
*/
- @SuppressWarnings("nullness") // TODO(cpovirk): Add casts as needed. Will be noisy and annoying...
GeneralRange<T> intersect(GeneralRange<T> other) {
checkNotNull(other);
checkArgument(comparator.equals(other.comparator));
boolean hasLowBound = this.hasLowerBound;
- T lowEnd = getLowerEndpoint();
+ @NullableDecl T lowEnd = getLowerEndpoint();
BoundType lowType = getLowerBoundType();
if (!hasLowerBound()) {
hasLowBound = other.hasLowerBound;
@@ -209,7 +192,7 @@
}
boolean hasUpBound = this.hasUpperBound;
- T upEnd = getUpperEndpoint();
+ @NullableDecl T upEnd = getUpperEndpoint();
BoundType upType = getUpperBoundType();
if (!hasUpperBound()) {
hasUpBound = other.hasUpperBound;
@@ -237,7 +220,7 @@
}
@Override
- public boolean equals(@CheckForNull Object obj) {
+ public boolean equals(@NullableDecl Object obj) {
if (obj instanceof GeneralRange) {
GeneralRange<?> r = (GeneralRange<?>) obj;
return comparator.equals(r.comparator)
@@ -261,7 +244,7 @@
getUpperBoundType());
}
- @CheckForNull private transient GeneralRange<T> reverse;
+ @NullableDecl private transient GeneralRange<T> reverse;
/** Returns the same range relative to the reversed comparator. */
GeneralRange<T> reverse() {
@@ -293,7 +276,6 @@
+ (upperBoundType == CLOSED ? ']' : ')');
}
- @CheckForNull
T getLowerEndpoint() {
return lowerEndpoint;
}
@@ -302,7 +284,6 @@
return lowerBoundType;
}
- @CheckForNull
T getUpperEndpoint() {
return upperEndpoint;
}
diff --git a/android/guava/src/com/google/common/collect/GwtTransient.java b/android/guava/src/com/google/common/collect/GwtTransient.java
index ce5ea48..9c09c53 100644
--- a/android/guava/src/com/google/common/collect/GwtTransient.java
+++ b/android/guava/src/com/google/common/collect/GwtTransient.java
@@ -33,5 +33,4 @@
@GwtCompatible
@Retention(RUNTIME)
@Target(FIELD)
-@ElementTypesAreNonnullByDefault
@interface GwtTransient {}
diff --git a/android/guava/src/com/google/common/collect/HashBasedTable.java b/android/guava/src/com/google/common/collect/HashBasedTable.java
index c8ba50f..07c144f 100644
--- a/android/guava/src/com/google/common/collect/HashBasedTable.java
+++ b/android/guava/src/com/google/common/collect/HashBasedTable.java
@@ -20,9 +20,11 @@
import com.google.common.annotations.GwtCompatible;
import com.google.common.base.Supplier;
+import com.google.errorprone.annotations.CanIgnoreReturnValue;
import java.io.Serializable;
import java.util.LinkedHashMap;
import java.util.Map;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* Implementation of {@link Table} using linked hash tables. This guarantees predictable iteration
@@ -47,7 +49,6 @@
* @since 7.0
*/
@GwtCompatible(serializable = true)
-@ElementTypesAreNonnullByDefault
public class HashBasedTable<R, C, V> extends StandardTable<R, C, V> {
private static class Factory<C, V> implements Supplier<Map<C, V>>, Serializable {
final int expectedSize;
@@ -102,5 +103,43 @@
super(backingMap, factory);
}
+ // Overriding so NullPointerTester test passes.
+
+ @Override
+ public boolean contains(@NullableDecl Object rowKey, @NullableDecl Object columnKey) {
+ return super.contains(rowKey, columnKey);
+ }
+
+ @Override
+ public boolean containsColumn(@NullableDecl Object columnKey) {
+ return super.containsColumn(columnKey);
+ }
+
+ @Override
+ public boolean containsRow(@NullableDecl Object rowKey) {
+ return super.containsRow(rowKey);
+ }
+
+ @Override
+ public boolean containsValue(@NullableDecl Object value) {
+ return super.containsValue(value);
+ }
+
+ @Override
+ public V get(@NullableDecl Object rowKey, @NullableDecl Object columnKey) {
+ return super.get(rowKey, columnKey);
+ }
+
+ @Override
+ public boolean equals(@NullableDecl Object obj) {
+ return super.equals(obj);
+ }
+
+ @CanIgnoreReturnValue
+ @Override
+ public V remove(@NullableDecl Object rowKey, @NullableDecl Object columnKey) {
+ return super.remove(rowKey, columnKey);
+ }
+
private static final long serialVersionUID = 0;
}
diff --git a/android/guava/src/com/google/common/collect/HashBiMap.java b/android/guava/src/com/google/common/collect/HashBiMap.java
index 010f73c..18951fe 100644
--- a/android/guava/src/com/google/common/collect/HashBiMap.java
+++ b/android/guava/src/com/google/common/collect/HashBiMap.java
@@ -15,8 +15,6 @@
package com.google.common.collect;
import static com.google.common.base.Preconditions.checkArgument;
-import static com.google.common.collect.NullnessCasts.uncheckedCastNullableTToT;
-import static com.google.common.collect.NullnessCasts.unsafeNull;
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.GwtIncompatible;
@@ -36,8 +34,7 @@
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Set;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* A {@link BiMap} backed by two hash tables. This implementation allows null keys and values. A
@@ -53,12 +50,10 @@
* @since 2.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-public final class HashBiMap<K extends @Nullable Object, V extends @Nullable Object>
- extends AbstractMap<K, V> implements BiMap<K, V>, Serializable {
+public final class HashBiMap<K, V> extends AbstractMap<K, V> implements BiMap<K, V>, Serializable {
/** Returns a new, empty {@code HashBiMap} with the default initial capacity (16). */
- public static <K extends @Nullable Object, V extends @Nullable Object> HashBiMap<K, V> create() {
+ public static <K, V> HashBiMap<K, V> create() {
return create(16);
}
@@ -68,8 +63,7 @@
* @param expectedSize the expected number of entries
* @throws IllegalArgumentException if the specified expected size is negative
*/
- public static <K extends @Nullable Object, V extends @Nullable Object> HashBiMap<K, V> create(
- int expectedSize) {
+ public static <K, V> HashBiMap<K, V> create(int expectedSize) {
return new HashBiMap<>(expectedSize);
}
@@ -77,8 +71,7 @@
* Constructs a new bimap containing initial values from {@code map}. The bimap is created with an
* initial capacity sufficient to hold the mappings in the specified map.
*/
- public static <K extends @Nullable Object, V extends @Nullable Object> HashBiMap<K, V> create(
- Map<? extends K, ? extends V> map) {
+ public static <K, V> HashBiMap<K, V> create(Map<? extends K, ? extends V> map) {
HashBiMap<K, V> bimap = create(map.size());
bimap.putAll(map);
return bimap;
@@ -88,9 +81,9 @@
private static final int ENDPOINT = -2;
/** Maps an "entry" to the key of that entry. */
- transient @Nullable K[] keys;
+ transient K[] keys;
/** Maps an "entry" to the value of that entry. */
- transient @Nullable V[] values;
+ transient V[] values;
transient int size;
transient int modCount;
@@ -103,9 +96,9 @@
/** Maps an "entry" to the "entry" that follows it in its bucket. */
private transient int[] nextInBucketVToK;
/** The "entry" of the first element in insertion order. */
- private transient int firstInInsertionOrder;
+ @NullableDecl private transient int firstInInsertionOrder;
/** The "entry" of the last element in insertion order. */
- private transient int lastInInsertionOrder;
+ @NullableDecl private transient int lastInInsertionOrder;
/** Maps an "entry" to the "entry" that precedes it in insertion order. */
private transient int[] prevInInsertionOrder;
/** Maps an "entry" to the "entry" that follows it in insertion order. */
@@ -200,19 +193,19 @@
}
/** Given a key, returns the index of the entry in the tables, or ABSENT if not found. */
- int findEntryByKey(@CheckForNull Object key) {
+ int findEntryByKey(@NullableDecl Object key) {
return findEntryByKey(key, Hashing.smearedHash(key));
}
/**
* Given a key and its hash, returns the index of the entry in the tables, or ABSENT if not found.
*/
- int findEntryByKey(@CheckForNull Object key, int keyHash) {
+ int findEntryByKey(@NullableDecl Object key, int keyHash) {
return findEntry(key, keyHash, hashTableKToV, nextInBucketKToV, keys);
}
/** Given a value, returns the index of the entry in the tables, or ABSENT if not found. */
- int findEntryByValue(@CheckForNull Object value) {
+ int findEntryByValue(@NullableDecl Object value) {
return findEntryByValue(value, Hashing.smearedHash(value));
}
@@ -220,16 +213,12 @@
* Given a value and its hash, returns the index of the entry in the tables, or ABSENT if not
* found.
*/
- int findEntryByValue(@CheckForNull Object value, int valueHash) {
+ int findEntryByValue(@NullableDecl Object value, int valueHash) {
return findEntry(value, valueHash, hashTableVToK, nextInBucketVToK, values);
}
int findEntry(
- @CheckForNull Object o,
- int oHash,
- int[] hashTable,
- int[] nextInBucket,
- @Nullable Object[] array) {
+ @NullableDecl Object o, int oHash, int[] hashTable, int[] nextInBucket, Object[] array) {
for (int entry = hashTable[bucket(oHash)]; entry != ABSENT; entry = nextInBucket[entry]) {
if (Objects.equal(array[entry], o)) {
return entry;
@@ -239,7 +228,7 @@
}
@Override
- public boolean containsKey(@CheckForNull Object key) {
+ public boolean containsKey(@NullableDecl Object key) {
return findEntryByKey(key) != ABSENT;
}
@@ -254,32 +243,31 @@
* @return true if a mapping exists from a key to the specified value
*/
@Override
- public boolean containsValue(@CheckForNull Object value) {
+ public boolean containsValue(@NullableDecl Object value) {
return findEntryByValue(value) != ABSENT;
}
@Override
- @CheckForNull
- public V get(@CheckForNull Object key) {
+ @NullableDecl
+ public V get(@NullableDecl Object key) {
int entry = findEntryByKey(key);
return (entry == ABSENT) ? null : values[entry];
}
- @CheckForNull
- K getInverse(@CheckForNull Object value) {
+ @NullableDecl
+ K getInverse(@NullableDecl Object value) {
int entry = findEntryByValue(value);
return (entry == ABSENT) ? null : keys[entry];
}
@Override
@CanIgnoreReturnValue
- @CheckForNull
- public V put(@ParametricNullness K key, @ParametricNullness V value) {
+ public V put(@NullableDecl K key, @NullableDecl V value) {
return put(key, value, false);
}
- @CheckForNull
- V put(@ParametricNullness K key, @ParametricNullness V value, boolean force) {
+ @NullableDecl
+ V put(@NullableDecl K key, @NullableDecl V value, boolean force) {
int keyHash = Hashing.smearedHash(key);
int entryForKey = findEntryByKey(key, keyHash);
if (entryForKey != ABSENT) {
@@ -318,14 +306,13 @@
@Override
@CanIgnoreReturnValue
- @CheckForNull
- public V forcePut(@ParametricNullness K key, @ParametricNullness V value) {
+ @NullableDecl
+ public V forcePut(@NullableDecl K key, @NullableDecl V value) {
return put(key, value, true);
}
- @CanIgnoreReturnValue
- @CheckForNull
- K putInverse(@ParametricNullness V value, @ParametricNullness K key, boolean force) {
+ @NullableDecl
+ K putInverse(@NullableDecl V value, @NullableDecl K key, boolean force) {
int valueHash = Hashing.smearedHash(value);
int entryForValue = findEntryByValue(value, valueHash);
if (entryForValue != ABSENT) {
@@ -470,7 +457,7 @@
* Updates the specified entry to point to the new value: removes the old value from the V-to-K
* mapping and puts the new one in. The entry does not move in the insertion order of the bimap.
*/
- private void replaceValueInEntry(int entry, @ParametricNullness V newValue, boolean force) {
+ private void replaceValueInEntry(int entry, @NullableDecl V newValue, boolean force) {
checkArgument(entry != ABSENT);
int newValueHash = Hashing.smearedHash(newValue);
int newValueIndex = findEntryByValue(newValue, newValueHash);
@@ -495,7 +482,7 @@
* mapping and puts the new one in. The entry is moved to the end of the insertion order, or to
* the position of the new key if it was previously present.
*/
- private void replaceKeyInEntry(int entry, @ParametricNullness K newKey, boolean force) {
+ private void replaceKeyInEntry(int entry, @NullableDecl K newKey, boolean force) {
checkArgument(entry != ABSENT);
int newKeyHash = Hashing.smearedHash(newKey);
int newKeyIndex = findEntryByKey(newKey, newKeyHash);
@@ -541,27 +528,27 @@
@Override
@CanIgnoreReturnValue
- @CheckForNull
- public V remove(@CheckForNull Object key) {
+ @NullableDecl
+ public V remove(@NullableDecl Object key) {
int keyHash = Hashing.smearedHash(key);
int entry = findEntryByKey(key, keyHash);
if (entry == ABSENT) {
return null;
} else {
- V value = values[entry];
+ @NullableDecl V value = values[entry];
removeEntryKeyHashKnown(entry, keyHash);
return value;
}
}
- @CheckForNull
- K removeInverse(@CheckForNull Object value) {
+ @NullableDecl
+ K removeInverse(@NullableDecl Object value) {
int valueHash = Hashing.smearedHash(value);
int entry = findEntryByValue(value, valueHash);
if (entry == ABSENT) {
return null;
} else {
- K key = keys[entry];
+ @NullableDecl K key = keys[entry];
removeEntryValueHashKnown(entry, valueHash);
return key;
}
@@ -676,16 +663,13 @@
}
/** Shared supertype of keySet, values, entrySet, and inverse.entrySet. */
- abstract static class View<
- K extends @Nullable Object, V extends @Nullable Object, T extends @Nullable Object>
- extends AbstractSet<T> {
+ abstract static class View<K, V, T> extends AbstractSet<T> {
final HashBiMap<K, V> biMap;
View(HashBiMap<K, V> biMap) {
this.biMap = biMap;
}
- @ParametricNullness
abstract T forEntry(int entry);
@Override
@@ -712,7 +696,6 @@
}
@Override
- @ParametricNullness
public T next() {
if (!hasNext()) {
throw new NoSuchElementException();
@@ -763,19 +746,17 @@
}
@Override
- @ParametricNullness
K forEntry(int entry) {
- // The cast is safe because we call forEntry only for indexes that contain entries.
- return uncheckedCastNullableTToT(keys[entry]);
+ return keys[entry];
}
@Override
- public boolean contains(@CheckForNull Object o) {
+ public boolean contains(@NullableDecl Object o) {
return HashBiMap.this.containsKey(o);
}
@Override
- public boolean remove(@CheckForNull Object o) {
+ public boolean remove(@NullableDecl Object o) {
int oHash = Hashing.smearedHash(o);
int entry = findEntryByKey(o, oHash);
if (entry != ABSENT) {
@@ -801,19 +782,17 @@
}
@Override
- @ParametricNullness
V forEntry(int entry) {
- // The cast is safe because we call forEntry only for indexes that contain entries.
- return uncheckedCastNullableTToT(values[entry]);
+ return values[entry];
}
@Override
- public boolean contains(@CheckForNull Object o) {
+ public boolean contains(@NullableDecl Object o) {
return HashBiMap.this.containsValue(o);
}
@Override
- public boolean remove(@CheckForNull Object o) {
+ public boolean remove(@NullableDecl Object o) {
int oHash = Hashing.smearedHash(o);
int entry = findEntryByValue(o, oHash);
if (entry != ABSENT) {
@@ -839,11 +818,11 @@
}
@Override
- public boolean contains(@CheckForNull Object o) {
+ public boolean contains(@NullableDecl Object o) {
if (o instanceof Entry) {
Entry<?, ?> e = (Entry<?, ?>) o;
- Object k = e.getKey();
- Object v = e.getValue();
+ @NullableDecl Object k = e.getKey();
+ @NullableDecl Object v = e.getValue();
int eIndex = findEntryByKey(k);
return eIndex != ABSENT && Objects.equal(v, values[eIndex]);
}
@@ -852,11 +831,11 @@
@Override
@CanIgnoreReturnValue
- public boolean remove(@CheckForNull Object o) {
+ public boolean remove(@NullableDecl Object o) {
if (o instanceof Entry) {
Entry<?, ?> e = (Entry<?, ?>) o;
- Object k = e.getKey();
- Object v = e.getValue();
+ @NullableDecl Object k = e.getKey();
+ @NullableDecl Object v = e.getValue();
int kHash = Hashing.smearedHash(k);
int eIndex = findEntryByKey(k, kHash);
if (eIndex != ABSENT && Objects.equal(v, values[eIndex])) {
@@ -876,17 +855,14 @@
/**
* An {@code Entry} implementation that attempts to follow its key around the map -- that is, if
* the key is moved, deleted, or reinserted, it will account for that -- while not doing any extra
- * work if the key has not moved. One quirk: The {@link #getValue()} method can return {@code
- * null} even for a map which supposedly does not contain null elements, if the key is not present
- * when {@code getValue()} is called.
+ * work if the key has not moved.
*/
final class EntryForKey extends AbstractMapEntry<K, V> {
- @ParametricNullness final K key;
+ @NullableDecl final K key;
int index;
EntryForKey(int index) {
- // The cast is safe because we call forEntry only for indexes that contain entries.
- this.key = uncheckedCastNullableTToT(keys[index]);
+ this.key = keys[index];
this.index = index;
}
@@ -897,43 +873,24 @@
}
@Override
- @ParametricNullness
public K getKey() {
return key;
}
@Override
- @ParametricNullness
+ @NullableDecl
public V getValue() {
updateIndex();
- /*
- * If the entry has been removed from the map, we return null, even though that might not be a
- * valid value. That's the best we can do, short of holding a reference to the most recently
- * seen value. And while we *could* do that, we aren't required to: Map.Entry explicitly says
- * that behavior is undefined when the backing map is modified through another API. (It even
- * permits us to throw IllegalStateException. Maybe we should have done that, but we probably
- * shouldn't change now for fear of breaking people.)
- *
- * If the entry is still in the map, then updateIndex ensured that `index` points to the right
- * element. Because that element is present, uncheckedCastNullableTToT is safe.
- */
- return (index == ABSENT) ? unsafeNull() : uncheckedCastNullableTToT(values[index]);
+ return (index == ABSENT) ? null : values[index];
}
@Override
- @ParametricNullness
- public V setValue(@ParametricNullness V value) {
+ public V setValue(V value) {
updateIndex();
if (index == ABSENT) {
- HashBiMap.this.put(key, value);
- return unsafeNull(); // See the discussion in getValue().
+ return HashBiMap.this.put(key, value);
}
- /*
- * The cast is safe because updateIndex found the entry for this key. (If it hadn't, then we
- * would have returned above.) Thus, we know that it and its corresponding value are in
- * position `index`.
- */
- V oldValue = uncheckedCastNullableTToT(values[index]);
+ V oldValue = values[index];
if (Objects.equal(oldValue, value)) {
return value;
}
@@ -942,7 +899,7 @@
}
}
- @LazyInit @RetainedWith @CheckForNull private transient BiMap<V, K> inverse;
+ @LazyInit @RetainedWith @NullableDecl private transient BiMap<V, K> inverse;
@Override
public BiMap<V, K> inverse() {
@@ -950,8 +907,7 @@
return (result == null) ? inverse = new Inverse<K, V>(this) : result;
}
- static class Inverse<K extends @Nullable Object, V extends @Nullable Object>
- extends AbstractMap<V, K> implements BiMap<V, K>, Serializable {
+ static class Inverse<K, V> extends AbstractMap<V, K> implements BiMap<V, K>, Serializable {
private final HashBiMap<K, V> forward;
Inverse(HashBiMap<K, V> forward) {
@@ -964,32 +920,32 @@
}
@Override
- public boolean containsKey(@CheckForNull Object key) {
+ public boolean containsKey(@NullableDecl Object key) {
return forward.containsValue(key);
}
@Override
- @CheckForNull
- public K get(@CheckForNull Object key) {
+ @NullableDecl
+ public K get(@NullableDecl Object key) {
return forward.getInverse(key);
}
@Override
- public boolean containsValue(@CheckForNull Object value) {
+ public boolean containsValue(@NullableDecl Object value) {
return forward.containsKey(value);
}
@Override
@CanIgnoreReturnValue
- @CheckForNull
- public K put(@ParametricNullness V value, @ParametricNullness K key) {
+ @NullableDecl
+ public K put(@NullableDecl V value, @NullableDecl K key) {
return forward.putInverse(value, key, false);
}
@Override
@CanIgnoreReturnValue
- @CheckForNull
- public K forcePut(@ParametricNullness V value, @ParametricNullness K key) {
+ @NullableDecl
+ public K forcePut(@NullableDecl V value, @NullableDecl K key) {
return forward.putInverse(value, key, true);
}
@@ -1000,8 +956,8 @@
@Override
@CanIgnoreReturnValue
- @CheckForNull
- public K remove(@CheckForNull Object value) {
+ @NullableDecl
+ public K remove(@NullableDecl Object value) {
return forward.removeInverse(value);
}
@@ -1035,14 +991,13 @@
}
}
- static class InverseEntrySet<K extends @Nullable Object, V extends @Nullable Object>
- extends View<K, V, Entry<V, K>> {
+ static class InverseEntrySet<K, V> extends View<K, V, Entry<V, K>> {
InverseEntrySet(HashBiMap<K, V> biMap) {
super(biMap);
}
@Override
- public boolean contains(@CheckForNull Object o) {
+ public boolean contains(@NullableDecl Object o) {
if (o instanceof Entry) {
Entry<?, ?> e = (Entry<?, ?>) o;
Object v = e.getKey();
@@ -1054,7 +1009,7 @@
}
@Override
- public boolean remove(@CheckForNull Object o) {
+ public boolean remove(Object o) {
if (o instanceof Entry) {
Entry<?, ?> e = (Entry<?, ?>) o;
Object v = e.getKey();
@@ -1080,16 +1035,14 @@
* the value is moved, deleted, or reinserted, it will account for that -- while not doing any
* extra work if the value has not moved.
*/
- static final class EntryForValue<K extends @Nullable Object, V extends @Nullable Object>
- extends AbstractMapEntry<V, K> {
+ static final class EntryForValue<K, V> extends AbstractMapEntry<V, K> {
final HashBiMap<K, V> biMap;
- @ParametricNullness final V value;
+ final V value;
int index;
EntryForValue(HashBiMap<K, V> biMap, int index) {
this.biMap = biMap;
- // The cast is safe because we call forEntry only for indexes that contain entries.
- this.value = uncheckedCastNullableTToT(biMap.values[index]);
+ this.value = biMap.values[index];
this.index = index;
}
@@ -1100,28 +1053,23 @@
}
@Override
- @ParametricNullness
public V getKey() {
return value;
}
@Override
- @ParametricNullness
public K getValue() {
updateIndex();
- // For discussion of unsafeNull() and uncheckedCastNullableTToT(), see EntryForKey.getValue().
- return (index == ABSENT) ? unsafeNull() : uncheckedCastNullableTToT(biMap.keys[index]);
+ return (index == ABSENT) ? null : biMap.keys[index];
}
@Override
- @ParametricNullness
- public K setValue(@ParametricNullness K key) {
+ public K setValue(K key) {
updateIndex();
if (index == ABSENT) {
- biMap.putInverse(value, key, false);
- return unsafeNull(); // see EntryForKey.setValue()
+ return biMap.putInverse(value, key, false);
}
- K oldKey = uncheckedCastNullableTToT(biMap.keys[index]); // see EntryForKey.setValue()
+ K oldKey = biMap.keys[index];
if (Objects.equal(oldKey, key)) {
return key;
}
diff --git a/android/guava/src/com/google/common/collect/HashMultimap.java b/android/guava/src/com/google/common/collect/HashMultimap.java
index 9e4c1c2..9297260 100644
--- a/android/guava/src/com/google/common/collect/HashMultimap.java
+++ b/android/guava/src/com/google/common/collect/HashMultimap.java
@@ -26,7 +26,6 @@
import java.util.Collection;
import java.util.Map;
import java.util.Set;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Implementation of {@link Multimap} using hash tables.
@@ -42,16 +41,11 @@
* concurrent update operations, wrap your multimap with a call to {@link
* Multimaps#synchronizedSetMultimap}.
*
- * <p><b>Warning:</b> Do not modify either a key <i>or a value</i> of a {@code HashMultimap} in a
- * way that affects its {@link Object#equals} behavior. Undefined behavior and bugs will result.
- *
* @author Jared Levy
* @since 2.0
*/
@GwtCompatible(serializable = true, emulated = true)
-@ElementTypesAreNonnullByDefault
-public final class HashMultimap<K extends @Nullable Object, V extends @Nullable Object>
- extends HashMultimapGwtSerializationDependencies<K, V> {
+public final class HashMultimap<K, V> extends HashMultimapGwtSerializationDependencies<K, V> {
private static final int DEFAULT_VALUES_PER_KEY = 2;
@VisibleForTesting transient int expectedValuesPerKey = DEFAULT_VALUES_PER_KEY;
@@ -62,8 +56,7 @@
* <p>This method will soon be deprecated in favor of {@code
* MultimapBuilder.hashKeys().hashSetValues().build()}.
*/
- public static <K extends @Nullable Object, V extends @Nullable Object>
- HashMultimap<K, V> create() {
+ public static <K, V> HashMultimap<K, V> create() {
return new HashMultimap<>();
}
@@ -79,8 +72,7 @@
* @throws IllegalArgumentException if {@code expectedKeys} or {@code expectedValuesPerKey} is
* negative
*/
- public static <K extends @Nullable Object, V extends @Nullable Object> HashMultimap<K, V> create(
- int expectedKeys, int expectedValuesPerKey) {
+ public static <K, V> HashMultimap<K, V> create(int expectedKeys, int expectedValuesPerKey) {
return new HashMultimap<>(expectedKeys, expectedValuesPerKey);
}
@@ -94,8 +86,7 @@
*
* @param multimap the multimap whose contents are copied to this multimap
*/
- public static <K extends @Nullable Object, V extends @Nullable Object> HashMultimap<K, V> create(
- Multimap<? extends K, ? extends V> multimap) {
+ public static <K, V> HashMultimap<K, V> create(Multimap<? extends K, ? extends V> multimap) {
return new HashMultimap<>(multimap);
}
diff --git a/android/guava/src/com/google/common/collect/HashMultiset.java b/android/guava/src/com/google/common/collect/HashMultiset.java
index 0748e68..a78c691 100644
--- a/android/guava/src/com/google/common/collect/HashMultiset.java
+++ b/android/guava/src/com/google/common/collect/HashMultiset.java
@@ -18,7 +18,6 @@
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.GwtIncompatible;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Multiset implementation that uses hashing for key and entry access.
@@ -28,11 +27,10 @@
* @since 2.0
*/
@GwtCompatible(serializable = true, emulated = true)
-@ElementTypesAreNonnullByDefault
-public final class HashMultiset<E extends @Nullable Object> extends AbstractMapBasedMultiset<E> {
+public class HashMultiset<E> extends AbstractMapBasedMultiset<E> {
/** Creates a new, empty {@code HashMultiset} using the default initial capacity. */
- public static <E extends @Nullable Object> HashMultiset<E> create() {
+ public static <E> HashMultiset<E> create() {
return create(ObjectCountHashMap.DEFAULT_SIZE);
}
@@ -43,7 +41,7 @@
* @param distinctElements the expected number of distinct elements
* @throws IllegalArgumentException if {@code distinctElements} is negative
*/
- public static <E extends @Nullable Object> HashMultiset<E> create(int distinctElements) {
+ public static <E> HashMultiset<E> create(int distinctElements) {
return new HashMultiset<E>(distinctElements);
}
@@ -54,8 +52,7 @@
*
* @param elements the elements that the multiset should contain
*/
- public static <E extends @Nullable Object> HashMultiset<E> create(
- Iterable<? extends E> elements) {
+ public static <E> HashMultiset<E> create(Iterable<? extends E> elements) {
HashMultiset<E> multiset = create(Multisets.inferDistinctElements(elements));
Iterables.addAll(multiset, elements);
return multiset;
@@ -66,8 +63,8 @@
}
@Override
- ObjectCountHashMap<E> newBackingMap(int distinctElements) {
- return new ObjectCountHashMap<>(distinctElements);
+ void init(int distinctElements) {
+ backingMap = new ObjectCountHashMap<>(distinctElements);
}
@GwtIncompatible // Not needed in emulated source.
diff --git a/android/guava/src/com/google/common/collect/Hashing.java b/android/guava/src/com/google/common/collect/Hashing.java
index 81ef67e..d5cab1f 100644
--- a/android/guava/src/com/google/common/collect/Hashing.java
+++ b/android/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 javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* Static methods for implementing hash-based collections.
@@ -28,7 +28,6 @@
* @author Austin Appleby
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
final class Hashing {
private Hashing() {}
@@ -51,7 +50,7 @@
return (int) (C2 * Integer.rotateLeft((int) (hashCode * C1), 15));
}
- static int smearedHash(@CheckForNull Object o) {
+ static int smearedHash(@NullableDecl Object o) {
return smear((o == null) ? 0 : o.hashCode());
}
diff --git a/android/guava/src/com/google/common/collect/ImmutableAsList.java b/android/guava/src/com/google/common/collect/ImmutableAsList.java
index c397479..528a8dc 100644
--- a/android/guava/src/com/google/common/collect/ImmutableAsList.java
+++ b/android/guava/src/com/google/common/collect/ImmutableAsList.java
@@ -21,7 +21,6 @@
import java.io.InvalidObjectException;
import java.io.ObjectInputStream;
import java.io.Serializable;
-import javax.annotation.CheckForNull;
/**
* List returned by {@link ImmutableCollection#asList} that delegates {@code contains} checks to the
@@ -32,12 +31,11 @@
*/
@GwtCompatible(serializable = true, emulated = true)
@SuppressWarnings("serial")
-@ElementTypesAreNonnullByDefault
abstract class ImmutableAsList<E> extends ImmutableList<E> {
abstract ImmutableCollection<E> delegateCollection();
@Override
- public boolean contains(@CheckForNull Object target) {
+ public boolean contains(Object target) {
// The collection's contains() is at least as fast as ImmutableList's
// and is often faster.
return delegateCollection().contains(target);
diff --git a/android/guava/src/com/google/common/collect/ImmutableBiMap.java b/android/guava/src/com/google/common/collect/ImmutableBiMap.java
index bbae036..691ee4f 100644
--- a/android/guava/src/com/google/common/collect/ImmutableBiMap.java
+++ b/android/guava/src/com/google/common/collect/ImmutableBiMap.java
@@ -22,12 +22,9 @@
import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtCompatible;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
-import com.google.errorprone.annotations.DoNotCall;
-import java.util.Arrays;
import java.util.Collection;
import java.util.Comparator;
import java.util.Map;
-import javax.annotation.CheckForNull;
/**
* A {@link BiMap} whose contents will never change, with many other important properties detailed
@@ -37,14 +34,9 @@
* @since 2.0
*/
@GwtCompatible(serializable = true, emulated = true)
-@ElementTypesAreNonnullByDefault
public abstract class ImmutableBiMap<K, V> extends ImmutableMap<K, V> implements BiMap<K, V> {
- /**
- * Returns the empty bimap.
- *
- * <p><b>Performance note:</b> the instance returned is a singleton.
- */
+ /** Returns the empty bimap. */
// Casting to any type is safe because the set will never hold any elements.
@SuppressWarnings("unchecked")
public static <K, V> ImmutableBiMap<K, V> of() {
@@ -109,170 +101,7 @@
new Object[] {k1, v1, k2, v2, k3, v3, k4, v4, k5, v5}, 5);
}
- /**
- * Returns an immutable map containing the given entries, in order.
- *
- * @throws IllegalArgumentException if duplicate keys or values are added
- * @since 31.0
- */
- public static <K, V> ImmutableBiMap<K, V> of(
- K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6) {
- checkEntryNotNull(k1, v1);
- checkEntryNotNull(k2, v2);
- checkEntryNotNull(k3, v3);
- checkEntryNotNull(k4, v4);
- checkEntryNotNull(k5, v5);
- checkEntryNotNull(k6, v6);
- return new RegularImmutableBiMap<K, V>(
- new Object[] {k1, v1, k2, v2, k3, v3, k4, v4, k5, v5, k6, v6}, 6);
- }
- /**
- * Returns an immutable map containing the given entries, in order.
- *
- * @throws IllegalArgumentException if duplicate keys or values are added
- * @since 31.0
- */
- public static <K, V> ImmutableBiMap<K, V> of(
- K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6, K k7, V v7) {
- checkEntryNotNull(k1, v1);
- checkEntryNotNull(k2, v2);
- checkEntryNotNull(k3, v3);
- checkEntryNotNull(k4, v4);
- checkEntryNotNull(k5, v5);
- checkEntryNotNull(k6, v6);
- checkEntryNotNull(k7, v7);
- return new RegularImmutableBiMap<K, V>(
- new Object[] {k1, v1, k2, v2, k3, v3, k4, v4, k5, v5, k6, v6, k7, v7}, 7);
- }
- /**
- * Returns an immutable map containing the given entries, in order.
- *
- * @throws IllegalArgumentException if duplicate keys or values are added
- * @since 31.0
- */
- public static <K, V> ImmutableBiMap<K, V> of(
- K k1,
- V v1,
- K k2,
- V v2,
- K k3,
- V v3,
- K k4,
- V v4,
- K k5,
- V v5,
- K k6,
- V v6,
- K k7,
- V v7,
- K k8,
- V v8) {
- checkEntryNotNull(k1, v1);
- checkEntryNotNull(k2, v2);
- checkEntryNotNull(k3, v3);
- checkEntryNotNull(k4, v4);
- checkEntryNotNull(k5, v5);
- checkEntryNotNull(k6, v6);
- checkEntryNotNull(k7, v7);
- checkEntryNotNull(k8, v8);
- return new RegularImmutableBiMap<K, V>(
- new Object[] {k1, v1, k2, v2, k3, v3, k4, v4, k5, v5, k6, v6, k7, v7, k8, v8}, 8);
- }
- /**
- * Returns an immutable map containing the given entries, in order.
- *
- * @throws IllegalArgumentException if duplicate keys or values are added
- * @since 31.0
- */
- public static <K, V> ImmutableBiMap<K, V> of(
- K k1,
- V v1,
- K k2,
- V v2,
- K k3,
- V v3,
- K k4,
- V v4,
- K k5,
- V v5,
- K k6,
- V v6,
- K k7,
- V v7,
- K k8,
- V v8,
- K k9,
- V v9) {
- checkEntryNotNull(k1, v1);
- checkEntryNotNull(k2, v2);
- checkEntryNotNull(k3, v3);
- checkEntryNotNull(k4, v4);
- checkEntryNotNull(k5, v5);
- checkEntryNotNull(k6, v6);
- checkEntryNotNull(k7, v7);
- checkEntryNotNull(k8, v8);
- checkEntryNotNull(k9, v9);
- return new RegularImmutableBiMap<K, V>(
- new Object[] {k1, v1, k2, v2, k3, v3, k4, v4, k5, v5, k6, v6, k7, v7, k8, v8, k9, v9}, 9);
- }
- /**
- * Returns an immutable map containing the given entries, in order.
- *
- * @throws IllegalArgumentException if duplicate keys or values are added
- * @since 31.0
- */
- public static <K, V> ImmutableBiMap<K, V> of(
- K k1,
- V v1,
- K k2,
- V v2,
- K k3,
- V v3,
- K k4,
- V v4,
- K k5,
- V v5,
- K k6,
- V v6,
- K k7,
- V v7,
- K k8,
- V v8,
- K k9,
- V v9,
- K k10,
- V v10) {
- checkEntryNotNull(k1, v1);
- checkEntryNotNull(k2, v2);
- checkEntryNotNull(k3, v3);
- checkEntryNotNull(k4, v4);
- checkEntryNotNull(k5, v5);
- checkEntryNotNull(k6, v6);
- checkEntryNotNull(k7, v7);
- checkEntryNotNull(k8, v8);
- checkEntryNotNull(k9, v9);
- checkEntryNotNull(k10, v10);
- return new RegularImmutableBiMap<K, V>(
- new Object[] {
- k1, v1, k2, v2, k3, v3, k4, v4, k5, v5, k6, v6, k7, v7, k8, v8, k9, v9, k10, v10
- },
- 10);
- }
-
- // looking for of() with > 10 entries? Use the builder or ofEntries instead.
-
- /**
- * Returns an immutable map containing the given entries, in order.
- *
- * @throws IllegalArgumentException if duplicate keys or values are provided
- * @since 31.0
- */
- @SafeVarargs
- public static <K, V> ImmutableBiMap<K, V> ofEntries(Entry<? extends K, ? extends V>... entries) {
- @SuppressWarnings("unchecked") // we will only ever read these
- Entry<K, V>[] entries2 = (Entry<K, V>[]) entries;
- return copyOf(Arrays.asList(entries2));
- }
+ // looking for of() with > 5 entries? Use the builder instead.
/**
* Returns a new builder. The generated builder is equivalent to the builder created by the {@link
@@ -310,7 +139,7 @@
* .put("one", 1)
* .put("two", 2)
* .put("three", 3)
- * .buildOrThrow();
+ * .build();
* }</pre>
*
* <p>For <i>small</i> immutable bimaps, the {@code ImmutableBiMap.of()} methods are even more
@@ -323,8 +152,8 @@
* want a different order, consider using {@link #orderEntriesByValue(Comparator)}, which changes
* this builder to sort entries by value.
*
- * <p>Builder instances can be reused - it is safe to call {@link #buildOrThrow} multiple times to
- * build multiple bimaps in series. Each bimap is a superset of the bimaps created before it.
+ * <p>Builder instances can be reused - it is safe to call {@link #build} multiple times to build
+ * multiple bimaps in series. Each bimap is a superset of the bimaps created before it.
*
* @since 2.0
*/
@@ -411,40 +240,15 @@
return this;
}
- @Override
- @CanIgnoreReturnValue
- Builder<K, V> combine(ImmutableMap.Builder<K, V> builder) {
- super.combine(builder);
- return this;
- }
-
/**
* Returns a newly-created immutable bimap. The iteration order of the returned bimap is the
* order in which entries were inserted into the builder, unless {@link #orderEntriesByValue}
* was called, in which case entries are sorted by value.
*
- * <p>Prefer the equivalent method {@link #buildOrThrow()} to make it explicit that the method
- * will throw an exception if there are duplicate keys or values. The {@code build()} method
- * will soon be deprecated.
- *
* @throws IllegalArgumentException if duplicate keys or values were added
*/
@Override
public ImmutableBiMap<K, V> build() {
- return buildOrThrow();
- }
-
- /**
- * Returns a newly-created immutable bimap, or throws an exception if any key or value was added
- * more than once. The iteration order of the returned bimap is the order in which entries were
- * inserted into the builder, unless {@link #orderEntriesByValue} was called, in which case
- * entries are sorted by value.
- *
- * @throws IllegalArgumentException if duplicate keys or values were added
- * @since 31.0
- */
- @Override
- public ImmutableBiMap<K, V> buildOrThrow() {
if (size == 0) {
return of();
}
@@ -535,9 +339,7 @@
@CanIgnoreReturnValue
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
- @CheckForNull
- public final V forcePut(K key, V value) {
+ public V forcePut(K key, V value) {
throw new UnsupportedOperationException();
}
diff --git a/android/guava/src/com/google/common/collect/ImmutableClassToInstanceMap.java b/android/guava/src/com/google/common/collect/ImmutableClassToInstanceMap.java
index aeabe5d..4836384 100644
--- a/android/guava/src/com/google/common/collect/ImmutableClassToInstanceMap.java
+++ b/android/guava/src/com/google/common/collect/ImmutableClassToInstanceMap.java
@@ -21,11 +21,10 @@
import com.google.common.annotations.GwtIncompatible;
import com.google.common.primitives.Primitives;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
-import com.google.errorprone.annotations.DoNotCall;
import com.google.errorprone.annotations.Immutable;
import java.io.Serializable;
import java.util.Map;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* A {@link ClassToInstanceMap} whose contents will never change, with many other important
@@ -36,7 +35,6 @@
*/
@Immutable(containerOf = "B")
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public final class ImmutableClassToInstanceMap<B> extends ForwardingMap<Class<? extends B>, B>
implements ClassToInstanceMap<B>, Serializable {
@@ -46,8 +44,6 @@
/**
* Returns an empty {@code ImmutableClassToInstanceMap}.
*
- * <p><b>Performance note:</b> the instance returned is a singleton.
- *
* @since 19.0
*/
@SuppressWarnings("unchecked")
@@ -174,7 +170,7 @@
@Override
@SuppressWarnings("unchecked") // value could not get in if not a T
- @CheckForNull
+ @NullableDecl
public <T extends B> T getInstance(Class<T> type) {
return (T) delegate.get(checkNotNull(type));
}
@@ -188,8 +184,6 @@
@CanIgnoreReturnValue
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
- @CheckForNull
public <T extends B> T putInstance(Class<T> type, T value) {
throw new UnsupportedOperationException();
}
diff --git a/android/guava/src/com/google/common/collect/ImmutableCollection.java b/android/guava/src/com/google/common/collect/ImmutableCollection.java
index b5ac2a1..31528d7 100644
--- a/android/guava/src/com/google/common/collect/ImmutableCollection.java
+++ b/android/guava/src/com/google/common/collect/ImmutableCollection.java
@@ -22,7 +22,6 @@
import com.google.common.annotations.GwtCompatible;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
-import com.google.errorprone.annotations.DoNotCall;
import com.google.errorprone.annotations.DoNotMock;
import java.io.Serializable;
import java.util.AbstractCollection;
@@ -32,8 +31,7 @@
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* A {@link Collection} whose contents will never change, and which offers a few additional
@@ -163,7 +161,6 @@
@DoNotMock("Use ImmutableList.of or another implementation")
@GwtCompatible(emulated = true)
@SuppressWarnings("serial") // we're overriding default serialization
-@ElementTypesAreNonnullByDefault
// TODO(kevinb): I think we should push everything down to "BaseImmutableCollection" or something,
// just to do everything we can to emphasize the "practically an interface" nature of this class.
public abstract class ImmutableCollection<E> extends AbstractCollection<E> implements Serializable {
@@ -183,20 +180,7 @@
@CanIgnoreReturnValue
@Override
- /*
- * This suppression is here for two reasons:
- *
- * 1. b/192354773 in our checker affects toArray declarations.
- *
- * 2. `other[size] = null` is unsound. We could "fix" this by requiring callers to pass in an
- * array with a nullable element type. But probably they usually want an array with a non-nullable
- * type. That said, we could *accept* a `@Nullable T[]` (which, given that we treat arrays as
- * covariant, would still permit a plain `T[]`) and return a plain `T[]`. But of course that would
- * require its own suppression, since it is also unsound. toArray(T[]) is just a mess from a
- * nullness perspective. The signature below at least has the virtue of being relatively simple.
- */
- @SuppressWarnings("nullness")
- public final <T extends @Nullable Object> T[] toArray(T[] other) {
+ public final <T> T[] toArray(T[] other) {
checkNotNull(other);
int size = size();
@@ -214,8 +198,7 @@
}
/** If this collection is backed by an array of its elements in insertion order, returns it. */
- @CheckForNull
- @Nullable
+ @NullableDecl
Object[] internalArray() {
return null;
}
@@ -237,7 +220,7 @@
}
@Override
- public abstract boolean contains(@CheckForNull Object object);
+ public abstract boolean contains(@NullableDecl Object object);
/**
* Guaranteed to throw an exception and leave the collection unmodified.
@@ -248,7 +231,6 @@
@CanIgnoreReturnValue
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
public final boolean add(E e) {
throw new UnsupportedOperationException();
}
@@ -262,8 +244,7 @@
@CanIgnoreReturnValue
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
- public final boolean remove(@CheckForNull Object object) {
+ public final boolean remove(Object object) {
throw new UnsupportedOperationException();
}
@@ -276,7 +257,6 @@
@CanIgnoreReturnValue
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
public final boolean addAll(Collection<? extends E> newElements) {
throw new UnsupportedOperationException();
}
@@ -290,7 +270,6 @@
@CanIgnoreReturnValue
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
public final boolean removeAll(Collection<?> oldElements) {
throw new UnsupportedOperationException();
}
@@ -304,7 +283,6 @@
@CanIgnoreReturnValue
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
public final boolean retainAll(Collection<?> elementsToKeep) {
throw new UnsupportedOperationException();
}
@@ -317,7 +295,6 @@
*/
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
public final void clear() {
throw new UnsupportedOperationException();
}
@@ -349,7 +326,7 @@
* offset. Returns {@code offset + size()}.
*/
@CanIgnoreReturnValue
- int copyIntoArray(@Nullable Object[] dst, int offset) {
+ int copyIntoArray(Object[] dst, int offset) {
for (E e : this) {
dst[offset++] = e;
}
@@ -465,14 +442,13 @@
}
abstract static class ArrayBasedBuilder<E> extends ImmutableCollection.Builder<E> {
- // The first `size` elements are non-null.
- @Nullable Object[] contents;
+ Object[] contents;
int size;
boolean forceCopy;
ArrayBasedBuilder(int initialCapacity) {
checkNonnegative(initialCapacity, "initialCapacity");
- this.contents = new @Nullable Object[initialCapacity];
+ this.contents = new Object[initialCapacity];
this.size = 0;
}
@@ -504,25 +480,13 @@
@CanIgnoreReturnValue
@Override
public Builder<E> add(E... elements) {
- addAll(elements, elements.length);
+ checkElementsNotNull(elements);
+ getReadyToExpandTo(size + elements.length);
+ System.arraycopy(elements, 0, contents, size, elements.length);
+ size += elements.length;
return this;
}
- final void addAll(@Nullable Object[] elements, int n) {
- checkElementsNotNull(elements, n);
- getReadyToExpandTo(size + n);
- /*
- * The following call is not statically checked, since arraycopy accepts plain Object for its
- * parameters. If it were statically checked, the checker would still be OK with it, since
- * we're copying into a `contents` array whose type allows it to contain nulls. Still, it's
- * worth noting that we promise not to put nulls into the array in the first `size` elements.
- * We uphold that promise here because our callers promise that `elements` will not contain
- * nulls in its first `n` elements.
- */
- System.arraycopy(elements, 0, contents, size, n);
- size += n;
- }
-
@CanIgnoreReturnValue
@Override
public Builder<E> addAll(Iterable<? extends E> elements) {
diff --git a/android/guava/src/com/google/common/collect/ImmutableEntry.java b/android/guava/src/com/google/common/collect/ImmutableEntry.java
index edc25f4..cc869b3 100644
--- a/android/guava/src/com/google/common/collect/ImmutableEntry.java
+++ b/android/guava/src/com/google/common/collect/ImmutableEntry.java
@@ -18,36 +18,33 @@
import com.google.common.annotations.GwtCompatible;
import java.io.Serializable;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/** @see com.google.common.collect.Maps#immutableEntry(Object, Object) */
@GwtCompatible(serializable = true)
-@ElementTypesAreNonnullByDefault
-class ImmutableEntry<K extends @Nullable Object, V extends @Nullable Object>
- extends AbstractMapEntry<K, V> implements Serializable {
- @ParametricNullness final K key;
- @ParametricNullness final V value;
+class ImmutableEntry<K, V> extends AbstractMapEntry<K, V> implements Serializable {
+ @NullableDecl final K key;
+ @NullableDecl final V value;
- ImmutableEntry(@ParametricNullness K key, @ParametricNullness V value) {
+ ImmutableEntry(@NullableDecl K key, @NullableDecl V value) {
this.key = key;
this.value = value;
}
@Override
- @ParametricNullness
+ @NullableDecl
public final K getKey() {
return key;
}
@Override
- @ParametricNullness
+ @NullableDecl
public final V getValue() {
return value;
}
@Override
- @ParametricNullness
- public final V setValue(@ParametricNullness V value) {
+ public final V setValue(V value) {
throw new UnsupportedOperationException();
}
diff --git a/android/guava/src/com/google/common/collect/ImmutableEnumMap.java b/android/guava/src/com/google/common/collect/ImmutableEnumMap.java
index 66680f0..beab47a 100644
--- a/android/guava/src/com/google/common/collect/ImmutableEnumMap.java
+++ b/android/guava/src/com/google/common/collect/ImmutableEnumMap.java
@@ -22,7 +22,7 @@
import com.google.common.collect.ImmutableMap.IteratorBasedImmutableMap;
import java.io.Serializable;
import java.util.EnumMap;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* Implementation of {@link ImmutableMap} backed by a non-empty {@link java.util.EnumMap}.
@@ -31,7 +31,6 @@
*/
@GwtCompatible(serializable = true, emulated = true)
@SuppressWarnings("serial") // we're overriding default serialization
-@ElementTypesAreNonnullByDefault
final class ImmutableEnumMap<K extends Enum<K>, V> extends IteratorBasedImmutableMap<K, V> {
static <K extends Enum<K>, V> ImmutableMap<K, V> asImmutable(EnumMap<K, V> map) {
switch (map.size()) {
@@ -63,18 +62,17 @@
}
@Override
- public boolean containsKey(@CheckForNull Object key) {
+ public boolean containsKey(@NullableDecl Object key) {
return delegate.containsKey(key);
}
@Override
- @CheckForNull
- public V get(@CheckForNull Object key) {
+ public V get(Object key) {
return delegate.get(key);
}
@Override
- public boolean equals(@CheckForNull Object object) {
+ public boolean equals(Object object) {
if (object == this) {
return true;
}
diff --git a/android/guava/src/com/google/common/collect/ImmutableEnumSet.java b/android/guava/src/com/google/common/collect/ImmutableEnumSet.java
index 90787e5..4e189ff 100644
--- a/android/guava/src/com/google/common/collect/ImmutableEnumSet.java
+++ b/android/guava/src/com/google/common/collect/ImmutableEnumSet.java
@@ -21,7 +21,6 @@
import java.io.Serializable;
import java.util.Collection;
import java.util.EnumSet;
-import javax.annotation.CheckForNull;
/**
* Implementation of {@link ImmutableSet} backed by a non-empty {@link java.util.EnumSet}.
@@ -30,7 +29,6 @@
*/
@GwtCompatible(serializable = true, emulated = true)
@SuppressWarnings("serial") // we're overriding default serialization
-@ElementTypesAreNonnullByDefault
final class ImmutableEnumSet<E extends Enum<E>> extends ImmutableSet<E> {
@SuppressWarnings("rawtypes") // necessary to compile against Java 8
static ImmutableSet asImmutable(EnumSet set) {
@@ -74,7 +72,7 @@
}
@Override
- public boolean contains(@CheckForNull Object object) {
+ public boolean contains(Object object) {
return delegate.contains(object);
}
@@ -92,7 +90,7 @@
}
@Override
- public boolean equals(@CheckForNull Object object) {
+ public boolean equals(Object object) {
if (object == this) {
return true;
}
diff --git a/android/guava/src/com/google/common/collect/ImmutableList.java b/android/guava/src/com/google/common/collect/ImmutableList.java
index 6ebd733..d86fe4f 100644
--- a/android/guava/src/com/google/common/collect/ImmutableList.java
+++ b/android/guava/src/com/google/common/collect/ImmutableList.java
@@ -28,8 +28,6 @@
import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtCompatible;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
-import com.google.errorprone.annotations.DoNotCall;
-import com.google.errorprone.annotations.InlineMe;
import java.io.InvalidObjectException;
import java.io.ObjectInputStream;
import java.io.Serializable;
@@ -40,8 +38,7 @@
import java.util.Iterator;
import java.util.List;
import java.util.RandomAccess;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* A {@link List} whose contents will never change, with many other important properties detailed at
@@ -57,15 +54,12 @@
*/
@GwtCompatible(serializable = true, emulated = true)
@SuppressWarnings("serial") // we're overriding default serialization
-@ElementTypesAreNonnullByDefault
public abstract class ImmutableList<E> extends ImmutableCollection<E>
implements List<E>, RandomAccess {
/**
* Returns the empty immutable list. This list behaves and performs comparably to {@link
* Collections#emptyList}, and is preferable mainly for consistency and maintainability of your
* code.
- *
- * <p><b>Performance note:</b> the instance returned is a singleton.
*/
// Casting to any type is safe because the list will never hold any elements.
@SuppressWarnings("unchecked")
@@ -342,7 +336,7 @@
}
/** Views the array as an immutable list. Does not check for nulls. */
- static <E> ImmutableList<E> asImmutableList(@Nullable Object[] elements, int length) {
+ static <E> ImmutableList<E> asImmutableList(Object[] elements, int length) {
if (length == 0) {
return of();
}
@@ -393,17 +387,17 @@
}
@Override
- public int indexOf(@CheckForNull Object object) {
+ public int indexOf(@NullableDecl Object object) {
return (object == null) ? -1 : Lists.indexOfImpl(this, object);
}
@Override
- public int lastIndexOf(@CheckForNull Object object) {
+ public int lastIndexOf(@NullableDecl Object object) {
return (object == null) ? -1 : Lists.lastIndexOfImpl(this, object);
}
@Override
- public boolean contains(@CheckForNull Object object) {
+ public boolean contains(@NullableDecl Object object) {
return indexOf(object) >= 0;
}
@@ -450,8 +444,6 @@
}
@Override
- @CheckForNull
- @Nullable
Object[] internalArray() {
return ImmutableList.this.internalArray();
}
@@ -493,7 +485,6 @@
@CanIgnoreReturnValue
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
public final boolean addAll(int index, Collection<? extends E> newElements) {
throw new UnsupportedOperationException();
}
@@ -507,7 +498,6 @@
@CanIgnoreReturnValue
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
public final E set(int index, E element) {
throw new UnsupportedOperationException();
}
@@ -520,7 +510,6 @@
*/
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
public final void add(int index, E element) {
throw new UnsupportedOperationException();
}
@@ -534,7 +523,6 @@
@CanIgnoreReturnValue
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
public final E remove(int index) {
throw new UnsupportedOperationException();
}
@@ -543,17 +531,14 @@
* Returns this list instance.
*
* @since 2.0
- * @deprecated There is no reason to use this; it always returns {@code this}.
*/
- @InlineMe(replacement = "this")
- @Deprecated
@Override
public final ImmutableList<E> asList() {
return this;
}
@Override
- int copyIntoArray(@Nullable Object[] dst, int offset) {
+ int copyIntoArray(Object[] dst, int offset) {
// this loop is faster for RandomAccess instances, which ImmutableLists are
int size = size();
for (int i = 0; i < size; i++) {
@@ -594,18 +579,18 @@
}
@Override
- public boolean contains(@CheckForNull Object object) {
+ public boolean contains(@NullableDecl Object object) {
return forwardList.contains(object);
}
@Override
- public int indexOf(@CheckForNull Object object) {
+ public int indexOf(@NullableDecl Object object) {
int index = forwardList.lastIndexOf(object);
return (index >= 0) ? reverseIndex(index) : -1;
}
@Override
- public int lastIndexOf(@CheckForNull Object object) {
+ public int lastIndexOf(@NullableDecl Object object) {
int index = forwardList.indexOf(object);
return (index >= 0) ? reverseIndex(index) : -1;
}
@@ -634,7 +619,7 @@
}
@Override
- public boolean equals(@CheckForNull Object obj) {
+ public boolean equals(@NullableDecl Object obj) {
return Lists.equalsImpl(this, obj);
}
@@ -793,12 +778,6 @@
return this;
}
- @CanIgnoreReturnValue
- Builder<E> combine(Builder<E> other) {
- addAll(other.contents, other.size);
- return this;
- }
-
/**
* Returns a newly-created {@code ImmutableList} based on the contents of the {@code Builder}.
*/
diff --git a/android/guava/src/com/google/common/collect/ImmutableListMultimap.java b/android/guava/src/com/google/common/collect/ImmutableListMultimap.java
index cc0a910..7893a74 100644
--- a/android/guava/src/com/google/common/collect/ImmutableListMultimap.java
+++ b/android/guava/src/com/google/common/collect/ImmutableListMultimap.java
@@ -20,7 +20,6 @@
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.GwtIncompatible;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
-import com.google.errorprone.annotations.DoNotCall;
import com.google.errorprone.annotations.concurrent.LazyInit;
import com.google.j2objc.annotations.RetainedWith;
import java.io.IOException;
@@ -31,8 +30,7 @@
import java.util.Comparator;
import java.util.Map;
import java.util.Map.Entry;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* A {@link ListMultimap} whose contents will never change, with many other important properties
@@ -45,15 +43,10 @@
* @since 2.0
*/
@GwtCompatible(serializable = true, emulated = true)
-@ElementTypesAreNonnullByDefault
public class ImmutableListMultimap<K, V> extends ImmutableMultimap<K, V>
implements ListMultimap<K, V> {
- /**
- * Returns the empty multimap.
- *
- * <p><b>Performance note:</b> the instance returned is a singleton.
- */
+ /** Returns the empty multimap. */
// Casting is safe because the multimap will never hold any elements.
@SuppressWarnings("unchecked")
public static <K, V> ImmutableListMultimap<K, V> of() {
@@ -220,13 +213,6 @@
return this;
}
- @CanIgnoreReturnValue
- @Override
- Builder<K, V> combine(ImmutableMultimap.Builder<K, V> other) {
- super.combine(other);
- return this;
- }
-
/** Returns a newly-created immutable list multimap. */
@Override
public ImmutableListMultimap<K, V> build() {
@@ -280,7 +266,7 @@
/** Creates an ImmutableListMultimap from an asMap.entrySet. */
static <K, V> ImmutableListMultimap<K, V> fromMapEntries(
Collection<? extends Map.Entry<? extends K, ? extends Collection<? extends V>>> mapEntries,
- @Nullable Comparator<? super V> valueComparator) {
+ @NullableDecl Comparator<? super V> valueComparator) {
if (mapEntries.isEmpty()) {
return of();
}
@@ -316,13 +302,13 @@
* parameters used to build this multimap.
*/
@Override
- public ImmutableList<V> get(K key) {
+ public ImmutableList<V> get(@NullableDecl K key) {
// This cast is safe as its type is known in constructor.
ImmutableList<V> list = (ImmutableList<V>) map.get(key);
return (list == null) ? ImmutableList.<V>of() : list;
}
- @LazyInit @RetainedWith @CheckForNull private transient ImmutableListMultimap<V, K> inverse;
+ @LazyInit @RetainedWith private transient ImmutableListMultimap<V, K> inverse;
/**
* {@inheritDoc}
@@ -358,8 +344,7 @@
@CanIgnoreReturnValue
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
- public final ImmutableList<V> removeAll(@CheckForNull Object key) {
+ public ImmutableList<V> removeAll(Object key) {
throw new UnsupportedOperationException();
}
@@ -372,8 +357,7 @@
@CanIgnoreReturnValue
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
- public final ImmutableList<V> replaceValues(K key, Iterable<? extends V> values) {
+ public ImmutableList<V> replaceValues(K key, Iterable<? extends V> values) {
throw new UnsupportedOperationException();
}
diff --git a/android/guava/src/com/google/common/collect/ImmutableMap.java b/android/guava/src/com/google/common/collect/ImmutableMap.java
index fd87e0b..4464137 100644
--- a/android/guava/src/com/google/common/collect/ImmutableMap.java
+++ b/android/guava/src/com/google/common/collect/ImmutableMap.java
@@ -20,12 +20,10 @@
import static com.google.common.base.Preconditions.checkState;
import static com.google.common.collect.CollectPreconditions.checkEntryNotNull;
import static com.google.common.collect.CollectPreconditions.checkNonnegative;
-import static java.util.Objects.requireNonNull;
import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtCompatible;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
-import com.google.errorprone.annotations.DoNotCall;
import com.google.errorprone.annotations.DoNotMock;
import com.google.errorprone.annotations.concurrent.LazyInit;
import com.google.j2objc.annotations.RetainedWith;
@@ -40,8 +38,7 @@
import java.util.Map;
import java.util.Map.Entry;
import java.util.SortedMap;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* A {@link Map} whose contents will never change, with many other important properties detailed at
@@ -57,15 +54,12 @@
@DoNotMock("Use ImmutableMap.of or another implementation")
@GwtCompatible(serializable = true, emulated = true)
@SuppressWarnings("serial") // we're overriding default serialization
-@ElementTypesAreNonnullByDefault
public abstract class ImmutableMap<K, V> implements Map<K, V>, Serializable {
/**
* Returns the empty map. This map behaves and performs comparably to {@link
* Collections#emptyMap}, and is preferable mainly for consistency and maintainability of your
* code.
- *
- * <p><b>Performance note:</b> the instance returned is a singleton.
*/
@SuppressWarnings("unchecked")
public static <K, V> ImmutableMap<K, V> of() {
@@ -133,170 +127,7 @@
return RegularImmutableMap.create(5, new Object[] {k1, v1, k2, v2, k3, v3, k4, v4, k5, v5});
}
- /**
- * Returns an immutable map containing the given entries, in order.
- *
- * @throws IllegalArgumentException if duplicate keys are provided
- * @since 31.0
- */
- public static <K, V> ImmutableMap<K, V> of(
- K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6) {
- checkEntryNotNull(k1, v1);
- checkEntryNotNull(k2, v2);
- checkEntryNotNull(k3, v3);
- checkEntryNotNull(k4, v4);
- checkEntryNotNull(k5, v5);
- checkEntryNotNull(k6, v6);
- return RegularImmutableMap.create(
- 6, new Object[] {k1, v1, k2, v2, k3, v3, k4, v4, k5, v5, k6, v6});
- }
- /**
- * Returns an immutable map containing the given entries, in order.
- *
- * @throws IllegalArgumentException if duplicate keys are provided
- * @since 31.0
- */
- public static <K, V> ImmutableMap<K, V> of(
- K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6, K k7, V v7) {
- checkEntryNotNull(k1, v1);
- checkEntryNotNull(k2, v2);
- checkEntryNotNull(k3, v3);
- checkEntryNotNull(k4, v4);
- checkEntryNotNull(k5, v5);
- checkEntryNotNull(k6, v6);
- checkEntryNotNull(k7, v7);
- return RegularImmutableMap.create(
- 7, new Object[] {k1, v1, k2, v2, k3, v3, k4, v4, k5, v5, k6, v6, k7, v7});
- }
- /**
- * Returns an immutable map containing the given entries, in order.
- *
- * @throws IllegalArgumentException if duplicate keys are provided
- * @since 31.0
- */
- public static <K, V> ImmutableMap<K, V> of(
- K k1,
- V v1,
- K k2,
- V v2,
- K k3,
- V v3,
- K k4,
- V v4,
- K k5,
- V v5,
- K k6,
- V v6,
- K k7,
- V v7,
- K k8,
- V v8) {
- checkEntryNotNull(k1, v1);
- checkEntryNotNull(k2, v2);
- checkEntryNotNull(k3, v3);
- checkEntryNotNull(k4, v4);
- checkEntryNotNull(k5, v5);
- checkEntryNotNull(k6, v6);
- checkEntryNotNull(k7, v7);
- checkEntryNotNull(k8, v8);
- return RegularImmutableMap.create(
- 8, new Object[] {k1, v1, k2, v2, k3, v3, k4, v4, k5, v5, k6, v6, k7, v7, k8, v8});
- }
- /**
- * Returns an immutable map containing the given entries, in order.
- *
- * @throws IllegalArgumentException if duplicate keys are provided
- * @since 31.0
- */
- public static <K, V> ImmutableMap<K, V> of(
- K k1,
- V v1,
- K k2,
- V v2,
- K k3,
- V v3,
- K k4,
- V v4,
- K k5,
- V v5,
- K k6,
- V v6,
- K k7,
- V v7,
- K k8,
- V v8,
- K k9,
- V v9) {
- checkEntryNotNull(k1, v1);
- checkEntryNotNull(k2, v2);
- checkEntryNotNull(k3, v3);
- checkEntryNotNull(k4, v4);
- checkEntryNotNull(k5, v5);
- checkEntryNotNull(k6, v6);
- checkEntryNotNull(k7, v7);
- checkEntryNotNull(k8, v8);
- checkEntryNotNull(k9, v9);
- return RegularImmutableMap.create(
- 9, new Object[] {k1, v1, k2, v2, k3, v3, k4, v4, k5, v5, k6, v6, k7, v7, k8, v8, k9, v9});
- }
- /**
- * Returns an immutable map containing the given entries, in order.
- *
- * @throws IllegalArgumentException if duplicate keys are provided
- * @since 31.0
- */
- public static <K, V> ImmutableMap<K, V> of(
- K k1,
- V v1,
- K k2,
- V v2,
- K k3,
- V v3,
- K k4,
- V v4,
- K k5,
- V v5,
- K k6,
- V v6,
- K k7,
- V v7,
- K k8,
- V v8,
- K k9,
- V v9,
- K k10,
- V v10) {
- checkEntryNotNull(k1, v1);
- checkEntryNotNull(k2, v2);
- checkEntryNotNull(k3, v3);
- checkEntryNotNull(k4, v4);
- checkEntryNotNull(k5, v5);
- checkEntryNotNull(k6, v6);
- checkEntryNotNull(k7, v7);
- checkEntryNotNull(k8, v8);
- checkEntryNotNull(k9, v9);
- checkEntryNotNull(k10, v10);
- return RegularImmutableMap.create(
- 10,
- new Object[] {
- k1, v1, k2, v2, k3, v3, k4, v4, k5, v5, k6, v6, k7, v7, k8, v8, k9, v9, k10, v10
- });
- }
-
- // looking for of() with > 10 entries? Use the builder or ofEntries instead.
-
- /**
- * Returns an immutable map containing the given entries, in order.
- *
- * @throws IllegalArgumentException if duplicate keys are provided
- * @since 31.0
- */
- @SafeVarargs
- public static <K, V> ImmutableMap<K, V> ofEntries(Entry<? extends K, ? extends V>... entries) {
- @SuppressWarnings("unchecked") // we will only ever read these
- Entry<K, V>[] entries2 = (Entry<K, V>[]) entries;
- return copyOf(Arrays.asList(entries2));
- }
+ // looking for of() with > 5 entries? Use the builder instead.
/**
* Verifies that {@code key} and {@code value} are non-null, and returns a new immutable entry
@@ -359,7 +190,7 @@
* .put("one", 1)
* .put("two", 2)
* .put("three", 3)
- * .buildOrThrow();
+ * .build();
* }</pre>
*
* <p>For <i>small</i> immutable maps, the {@code ImmutableMap.of()} methods are even more
@@ -373,15 +204,15 @@
* sort by keys, or call {@link #orderEntriesByValue(Comparator)}, which changes this builder to
* sort entries by value.
*
- * <p>Builder instances can be reused - it is safe to call {@link #buildOrThrow} multiple times to
- * build multiple maps in series. Each map is a superset of the maps created before it.
+ * <p>Builder instances can be reused - it is safe to call {@link #build} multiple times to build
+ * multiple maps in series. Each map is a superset of the maps created before it.
*
* @since 2.0
*/
@DoNotMock
public static class Builder<K, V> {
- @CheckForNull Comparator<? super V> valueComparator;
- @Nullable Object[] alternatingKeysAndValues;
+ @NullableDecl Comparator<? super V> valueComparator;
+ Object[] alternatingKeysAndValues;
int size;
boolean entriesUsed;
@@ -393,9 +224,9 @@
this(ImmutableCollection.Builder.DEFAULT_INITIAL_CAPACITY);
}
- @SuppressWarnings({"unchecked", "rawtypes"})
+ @SuppressWarnings("unchecked")
Builder(int initialCapacity) {
- this.alternatingKeysAndValues = new @Nullable Object[2 * initialCapacity];
+ this.alternatingKeysAndValues = new Object[2 * initialCapacity];
this.size = 0;
this.entriesUsed = false;
}
@@ -484,20 +315,6 @@
return this;
}
- @CanIgnoreReturnValue
- Builder<K, V> combine(Builder<K, V> other) {
- checkNotNull(other);
- ensureCapacity(this.size + other.size);
- System.arraycopy(
- other.alternatingKeysAndValues,
- 0,
- this.alternatingKeysAndValues,
- this.size * 2,
- other.size * 2);
- this.size += other.size;
- return this;
- }
-
/*
* TODO(kevinb): Should build() and the ImmutableBiMap & ImmutableSortedMap
* versions throw an IllegalStateException instead?
@@ -508,27 +325,10 @@
* in which entries were inserted into the builder, unless {@link #orderEntriesByValue} was
* called, in which case entries are sorted by value.
*
- * <p>Prefer the equivalent method {@link #buildOrThrow()} to make it explicit that the method
- * will throw an exception if there are duplicate keys. The {@code build()} method will soon be
- * deprecated.
- *
* @throws IllegalArgumentException if duplicate keys were added
*/
- public ImmutableMap<K, V> build() {
- return buildOrThrow();
- }
-
- /**
- * Returns a newly-created immutable map, or throws an exception if any key was added more than
- * once. The iteration order of the returned map is the order in which entries were inserted
- * into the builder, unless {@link #orderEntriesByValue} was called, in which case entries are
- * sorted by value.
- *
- * @throws IllegalArgumentException if duplicate keys were added
- * @since 31.0
- */
@SuppressWarnings("unchecked")
- public ImmutableMap<K, V> buildOrThrow() {
+ public ImmutableMap<K, V> build() {
/*
* If entries is full, then this implementation may end up using the entries array
* directly and writing over the entry objects with non-terminal entries, but this is
@@ -548,11 +348,9 @@
}
Entry<K, V>[] entries = new Entry[size];
for (int i = 0; i < size; i++) {
- // requireNonNull is safe because the first `2*size` elements have been filled in.
entries[i] =
new AbstractMap.SimpleImmutableEntry<K, V>(
- (K) requireNonNull(alternatingKeysAndValues[2 * i]),
- (V) requireNonNull(alternatingKeysAndValues[2 * i + 1]));
+ (K) alternatingKeysAndValues[2 * i], (V) alternatingKeysAndValues[2 * i + 1]);
}
Arrays.sort(
entries, 0, size, Ordering.from(valueComparator).onResultOf(Maps.<V>valueFunction()));
@@ -650,8 +448,6 @@
@CanIgnoreReturnValue
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
- @CheckForNull
public final V put(K k, V v) {
throw new UnsupportedOperationException();
}
@@ -665,8 +461,7 @@
@CanIgnoreReturnValue
@Deprecated
@Override
- @CheckForNull
- public final V remove(@CheckForNull Object o) {
+ public final V remove(Object o) {
throw new UnsupportedOperationException();
}
@@ -678,7 +473,6 @@
*/
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
public final void putAll(Map<? extends K, ? extends V> map) {
throw new UnsupportedOperationException();
}
@@ -691,7 +485,6 @@
*/
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
public final void clear() {
throw new UnsupportedOperationException();
}
@@ -702,19 +495,18 @@
}
@Override
- public boolean containsKey(@CheckForNull Object key) {
+ public boolean containsKey(@NullableDecl Object key) {
return get(key) != null;
}
@Override
- public boolean containsValue(@CheckForNull Object value) {
+ public boolean containsValue(@NullableDecl Object value) {
return values().contains(value);
}
// Overriding to mark it Nullable
@Override
- @CheckForNull
- public abstract V get(@CheckForNull Object key);
+ public abstract V get(@NullableDecl Object key);
/**
* {@inheritDoc}
@@ -728,18 +520,12 @@
* Note that API Level 24 users can call this method with any version of Guava.
*/
// @Override under Java 8 / API Level 24
- @CheckForNull
- public final V getOrDefault(@CheckForNull Object key, @CheckForNull V defaultValue) {
+ public final V getOrDefault(@NullableDecl Object key, @NullableDecl V defaultValue) {
V result = get(key);
- // TODO(b/192579700): Use a ternary once it no longer confuses our nullness checker.
- if (result != null) {
- return result;
- } else {
- return defaultValue;
- }
+ return (result != null) ? result : defaultValue;
}
- @LazyInit @RetainedWith @CheckForNull private transient ImmutableSet<Entry<K, V>> entrySet;
+ @LazyInit @RetainedWith private transient ImmutableSet<Entry<K, V>> entrySet;
/**
* Returns an immutable set of the mappings in this map. The iteration order is specified by the
@@ -753,7 +539,7 @@
abstract ImmutableSet<Entry<K, V>> createEntrySet();
- @LazyInit @RetainedWith @CheckForNull private transient ImmutableSet<K> keySet;
+ @LazyInit @RetainedWith private transient ImmutableSet<K> keySet;
/**
* Returns an immutable set of the keys in this map, in the same order that they appear in {@link
@@ -787,7 +573,7 @@
};
}
- @LazyInit @RetainedWith @CheckForNull private transient ImmutableCollection<V> values;
+ @LazyInit @RetainedWith private transient ImmutableCollection<V> values;
/**
* Returns an immutable collection of the values in this map, in the same order that they appear
@@ -807,7 +593,7 @@
abstract ImmutableCollection<V> createValues();
// cached so that this.multimapView().inverse() only computes inverse once
- @LazyInit @CheckForNull private transient ImmutableSetMultimap<K, V> multimapView;
+ @LazyInit private transient ImmutableSetMultimap<K, V> multimapView;
/**
* Returns a multimap view of the map.
@@ -840,13 +626,12 @@
}
@Override
- public boolean containsKey(@CheckForNull Object key) {
+ public boolean containsKey(@NullableDecl Object key) {
return ImmutableMap.this.containsKey(key);
}
@Override
- @CheckForNull
- public ImmutableSet<V> get(@CheckForNull Object key) {
+ public ImmutableSet<V> get(@NullableDecl Object key) {
V outerValue = ImmutableMap.this.get(key);
return (outerValue == null) ? null : ImmutableSet.of(outerValue);
}
@@ -896,7 +681,7 @@
}
@Override
- public boolean equals(@CheckForNull Object object) {
+ public boolean equals(@NullableDecl Object object) {
return Maps.equalsImpl(this, object);
}
@@ -937,8 +722,7 @@
Object[] keys = new Object[map.size()];
Object[] values = new Object[map.size()];
int i = 0;
- // "extends Object" works around https://github.com/typetools/checker-framework/issues/3013
- for (Entry<? extends Object, ? extends Object> entry : map.entrySet()) {
+ for (Entry<?, ?> entry : map.entrySet()) {
keys[i] = entry.getKey();
values[i] = entry.getValue();
i++;
diff --git a/android/guava/src/com/google/common/collect/ImmutableMapEntrySet.java b/android/guava/src/com/google/common/collect/ImmutableMapEntrySet.java
index 7ae6422..72fc5cf 100644
--- a/android/guava/src/com/google/common/collect/ImmutableMapEntrySet.java
+++ b/android/guava/src/com/google/common/collect/ImmutableMapEntrySet.java
@@ -20,8 +20,7 @@
import com.google.common.annotations.GwtIncompatible;
import java.io.Serializable;
import java.util.Map.Entry;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* {@code entrySet()} implementation for {@link ImmutableMap}.
@@ -30,7 +29,6 @@
* @author Kevin Bourrillion
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
abstract class ImmutableMapEntrySet<K, V> extends ImmutableSet<Entry<K, V>> {
static final class RegularEntrySet<K, V> extends ImmutableMapEntrySet<K, V> {
private final transient ImmutableMap<K, V> map;
@@ -52,7 +50,7 @@
@Override
@GwtIncompatible("not used in GWT")
- int copyIntoArray(@Nullable Object[] dst, int offset) {
+ int copyIntoArray(Object[] dst, int offset) {
return entries.copyIntoArray(dst, offset);
}
@@ -77,7 +75,7 @@
}
@Override
- public boolean contains(@CheckForNull Object object) {
+ public boolean contains(@NullableDecl Object object) {
if (object instanceof Entry) {
Entry<?, ?> entry = (Entry<?, ?>) object;
V value = map().get(entry.getKey());
diff --git a/android/guava/src/com/google/common/collect/ImmutableMapKeySet.java b/android/guava/src/com/google/common/collect/ImmutableMapKeySet.java
index 9bd1d43..77babc2 100644
--- a/android/guava/src/com/google/common/collect/ImmutableMapKeySet.java
+++ b/android/guava/src/com/google/common/collect/ImmutableMapKeySet.java
@@ -19,7 +19,7 @@
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.GwtIncompatible;
import java.io.Serializable;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* {@code keySet()} implementation for {@link ImmutableMap}.
@@ -28,7 +28,6 @@
* @author Kevin Bourrillion
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
final class ImmutableMapKeySet<K, V> extends IndexedImmutableSet<K> {
private final ImmutableMap<K, V> map;
@@ -47,7 +46,7 @@
}
@Override
- public boolean contains(@CheckForNull Object object) {
+ public boolean contains(@NullableDecl Object object) {
return map.containsKey(object);
}
diff --git a/android/guava/src/com/google/common/collect/ImmutableMapValues.java b/android/guava/src/com/google/common/collect/ImmutableMapValues.java
index 8b7284d..4a0e396 100644
--- a/android/guava/src/com/google/common/collect/ImmutableMapValues.java
+++ b/android/guava/src/com/google/common/collect/ImmutableMapValues.java
@@ -20,7 +20,7 @@
import com.google.common.annotations.GwtIncompatible;
import java.io.Serializable;
import java.util.Map.Entry;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* {@code values()} implementation for {@link ImmutableMap}.
@@ -29,7 +29,6 @@
* @author Kevin Bourrillion
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
final class ImmutableMapValues<K, V> extends ImmutableCollection<V> {
private final ImmutableMap<K, V> map;
@@ -60,7 +59,7 @@
}
@Override
- public boolean contains(@CheckForNull Object object) {
+ public boolean contains(@NullableDecl Object object) {
return object != null && Iterators.contains(iterator(), object);
}
diff --git a/android/guava/src/com/google/common/collect/ImmutableMultimap.java b/android/guava/src/com/google/common/collect/ImmutableMultimap.java
index 04a6c4a..9234b1c 100644
--- a/android/guava/src/com/google/common/collect/ImmutableMultimap.java
+++ b/android/guava/src/com/google/common/collect/ImmutableMultimap.java
@@ -18,14 +18,11 @@
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.collect.CollectPreconditions.checkEntryNotNull;
-import static com.google.common.collect.Maps.immutableEntry;
-import static java.util.Objects.requireNonNull;
import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.GwtIncompatible;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
-import com.google.errorprone.annotations.DoNotCall;
import com.google.errorprone.annotations.DoNotMock;
import com.google.j2objc.annotations.Weak;
import com.google.j2objc.annotations.WeakOuter;
@@ -38,8 +35,7 @@
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* A {@link Multimap} whose contents will never change, with many other important properties
@@ -68,15 +64,10 @@
* @since 2.0
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
public abstract class ImmutableMultimap<K, V> extends BaseImmutableMultimap<K, V>
implements Serializable {
- /**
- * Returns an empty multimap.
- *
- * <p><b>Performance note:</b> the instance returned is a singleton.
- */
+ /** Returns an empty multimap. */
public static <K, V> ImmutableMultimap<K, V> of() {
return ImmutableListMultimap.of();
}
@@ -147,9 +138,9 @@
*/
@DoNotMock
public static class Builder<K, V> {
- final Map<K, Collection<V>> builderMap;
- @CheckForNull Comparator<? super K> keyComparator;
- @CheckForNull Comparator<? super V> valueComparator;
+ Map<K, Collection<V>> builderMap;
+ @NullableDecl Comparator<? super K> keyComparator;
+ @NullableDecl Comparator<? super V> valueComparator;
/**
* Creates a new builder. The returned builder is equivalent to the builder generated by {@link
@@ -365,11 +356,7 @@
@CanIgnoreReturnValue
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
- // DoNotCall wants this to be final, but we want to override it to return more specific types.
- // Inheritance is closed, and all subtypes are @DoNotCall, so this is safe to suppress.
- @SuppressWarnings("DoNotCall")
- public ImmutableCollection<V> removeAll(@CheckForNull Object key) {
+ public ImmutableCollection<V> removeAll(Object key) {
throw new UnsupportedOperationException();
}
@@ -382,10 +369,6 @@
@CanIgnoreReturnValue
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
- // DoNotCall wants this to be final, but we want to override it to return more specific types.
- // Inheritance is closed, and all subtypes are @DoNotCall, so this is safe to suppress.
- @SuppressWarnings("DoNotCall")
public ImmutableCollection<V> replaceValues(K key, Iterable<? extends V> values) {
throw new UnsupportedOperationException();
}
@@ -398,8 +381,7 @@
*/
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
- public final void clear() {
+ public void clear() {
throw new UnsupportedOperationException();
}
@@ -428,8 +410,7 @@
@CanIgnoreReturnValue
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
- public final boolean put(K key, V value) {
+ public boolean put(K key, V value) {
throw new UnsupportedOperationException();
}
@@ -442,8 +423,7 @@
@CanIgnoreReturnValue
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
- public final boolean putAll(K key, Iterable<? extends V> values) {
+ public boolean putAll(K key, Iterable<? extends V> values) {
throw new UnsupportedOperationException();
}
@@ -456,8 +436,7 @@
@CanIgnoreReturnValue
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
- public final boolean putAll(Multimap<? extends K, ? extends V> multimap) {
+ public boolean putAll(Multimap<? extends K, ? extends V> multimap) {
throw new UnsupportedOperationException();
}
@@ -470,8 +449,7 @@
@CanIgnoreReturnValue
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
- public final boolean remove(@CheckForNull Object key, @CheckForNull Object value) {
+ public boolean remove(Object key, Object value) {
throw new UnsupportedOperationException();
}
@@ -488,12 +466,12 @@
// accessors
@Override
- public boolean containsKey(@CheckForNull Object key) {
+ public boolean containsKey(@NullableDecl Object key) {
return map.containsKey(key);
}
@Override
- public boolean containsValue(@CheckForNull Object value) {
+ public boolean containsValue(@NullableDecl Object value) {
return value != null && super.containsValue(value);
}
@@ -567,7 +545,7 @@
}
@Override
- public boolean contains(@CheckForNull Object object) {
+ public boolean contains(Object object) {
if (object instanceof Entry) {
Entry<?, ?> entry = (Entry<?, ?>) object;
return multimap.containsEntry(entry.getKey(), entry.getValue());
@@ -583,7 +561,7 @@
return new UnmodifiableIterator<Entry<K, V>>() {
final Iterator<? extends Entry<K, ? extends ImmutableCollection<V>>> asMapItr =
map.entrySet().iterator();
- @CheckForNull K currentKey = null;
+ K currentKey = null;
Iterator<V> valueItr = Iterators.emptyIterator();
@Override
@@ -598,11 +576,7 @@
currentKey = entry.getKey();
valueItr = entry.getValue().iterator();
}
- /*
- * requireNonNull is safe: The first call to this method always enters the !hasNext() case
- * and populates currentKey, after which it's never cleared.
- */
- return immutableEntry(requireNonNull(currentKey), valueItr.next());
+ return Maps.immutableEntry(currentKey, valueItr.next());
}
};
}
@@ -626,12 +600,12 @@
@WeakOuter
class Keys extends ImmutableMultiset<K> {
@Override
- public boolean contains(@CheckForNull Object object) {
+ public boolean contains(@NullableDecl Object object) {
return containsKey(object);
}
@Override
- public int count(@CheckForNull Object element) {
+ public int count(@NullableDecl Object element) {
Collection<V> values = map.get(element);
return (values == null) ? 0 : values.size();
}
@@ -720,7 +694,7 @@
}
@Override
- public boolean contains(@CheckForNull Object object) {
+ public boolean contains(@NullableDecl Object object) {
return multimap.containsValue(object);
}
@@ -731,7 +705,7 @@
@GwtIncompatible // not present in emulated superclass
@Override
- int copyIntoArray(@Nullable Object[] dst, int offset) {
+ int copyIntoArray(Object[] dst, int offset) {
for (ImmutableCollection<V> valueCollection : multimap.map.values()) {
offset = valueCollection.copyIntoArray(dst, offset);
}
diff --git a/android/guava/src/com/google/common/collect/ImmutableMultiset.java b/android/guava/src/com/google/common/collect/ImmutableMultiset.java
index d7febe2..f559850 100644
--- a/android/guava/src/com/google/common/collect/ImmutableMultiset.java
+++ b/android/guava/src/com/google/common/collect/ImmutableMultiset.java
@@ -17,12 +17,10 @@
package com.google.common.collect;
import static com.google.common.base.Preconditions.checkNotNull;
-import static java.util.Objects.requireNonNull;
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.GwtIncompatible;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
-import com.google.errorprone.annotations.DoNotCall;
import com.google.errorprone.annotations.concurrent.LazyInit;
import com.google.j2objc.annotations.WeakOuter;
import java.io.Serializable;
@@ -30,7 +28,7 @@
import java.util.Collection;
import java.util.Iterator;
import java.util.Set;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* A {@link Multiset} whose contents will never change, with many other important properties
@@ -49,14 +47,9 @@
*/
@GwtCompatible(serializable = true, emulated = true)
@SuppressWarnings("serial") // we're overriding default serialization
-@ElementTypesAreNonnullByDefault
public abstract class ImmutableMultiset<E> extends ImmutableMultisetGwtSerializationDependencies<E>
implements Multiset<E> {
- /**
- * Returns the empty immutable multiset.
- *
- * <p><b>Performance note:</b> the instance returned is a singleton.
- */
+ /** Returns the empty immutable multiset. */
@SuppressWarnings("unchecked") // all supported methods are covariant
public static <E> ImmutableMultiset<E> of() {
return (ImmutableMultiset<E>) RegularImmutableMultiset.EMPTY;
@@ -68,6 +61,7 @@
* @throws NullPointerException if {@code element} is null
* @since 6.0 (source-compatible since 2.0)
*/
+ @SuppressWarnings("unchecked") // generic array created but never written
public static <E> ImmutableMultiset<E> of(E element) {
return copyFromElements(element);
}
@@ -78,6 +72,7 @@
* @throws NullPointerException if any element is null
* @since 6.0 (source-compatible since 2.0)
*/
+ @SuppressWarnings("unchecked") //
public static <E> ImmutableMultiset<E> of(E e1, E e2) {
return copyFromElements(e1, e2);
}
@@ -89,6 +84,7 @@
* @throws NullPointerException if any element is null
* @since 6.0 (source-compatible since 2.0)
*/
+ @SuppressWarnings("unchecked") //
public static <E> ImmutableMultiset<E> of(E e1, E e2, E e3) {
return copyFromElements(e1, e2, e3);
}
@@ -100,6 +96,7 @@
* @throws NullPointerException if any element is null
* @since 6.0 (source-compatible since 2.0)
*/
+ @SuppressWarnings("unchecked") //
public static <E> ImmutableMultiset<E> of(E e1, E e2, E e3, E e4) {
return copyFromElements(e1, e2, e3, e4);
}
@@ -111,6 +108,7 @@
* @throws NullPointerException if any element is null
* @since 6.0 (source-compatible since 2.0)
*/
+ @SuppressWarnings("unchecked") //
public static <E> ImmutableMultiset<E> of(E e1, E e2, E e3, E e4, E e5) {
return copyFromElements(e1, e2, e3, e4, e5);
}
@@ -122,6 +120,7 @@
* @throws NullPointerException if any element is null
* @since 6.0 (source-compatible since 2.0)
*/
+ @SuppressWarnings("unchecked") //
public static <E> ImmutableMultiset<E> of(E e1, E e2, E e3, E e4, E e5, E e6, E... others) {
return new Builder<E>().add(e1).add(e2).add(e3).add(e4).add(e5).add(e6).add(others).build();
}
@@ -187,7 +186,7 @@
final Iterator<Entry<E>> entryIterator = entrySet().iterator();
return new UnmodifiableIterator<E>() {
int remaining;
- @CheckForNull E element;
+ @NullableDecl E element;
@Override
public boolean hasNext() {
@@ -202,16 +201,12 @@
remaining = entry.getCount();
}
remaining--;
- /*
- * requireNonNull is safe because `remaining` starts at 0, forcing us to initialize
- * `element` above. After that, we never clear it.
- */
- return requireNonNull(element);
+ return element;
}
};
}
- @LazyInit @CheckForNull private transient ImmutableList<E> asList;
+ @LazyInit private transient ImmutableList<E> asList;
@Override
public ImmutableList<E> asList() {
@@ -220,7 +215,7 @@
}
@Override
- public boolean contains(@CheckForNull Object object) {
+ public boolean contains(@NullableDecl Object object) {
return count(object) > 0;
}
@@ -233,7 +228,6 @@
@CanIgnoreReturnValue
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
public final int add(E element, int occurrences) {
throw new UnsupportedOperationException();
}
@@ -247,8 +241,7 @@
@CanIgnoreReturnValue
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
- public final int remove(@CheckForNull Object element, int occurrences) {
+ public final int remove(Object element, int occurrences) {
throw new UnsupportedOperationException();
}
@@ -261,7 +254,6 @@
@CanIgnoreReturnValue
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
public final int setCount(E element, int count) {
throw new UnsupportedOperationException();
}
@@ -275,7 +267,6 @@
@CanIgnoreReturnValue
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
public final boolean setCount(E element, int oldCount, int newCount) {
throw new UnsupportedOperationException();
}
@@ -291,7 +282,7 @@
}
@Override
- public boolean equals(@CheckForNull Object object) {
+ public boolean equals(@NullableDecl Object object) {
return Multisets.equalsImpl(this, object);
}
@@ -309,7 +300,7 @@
@Override
public abstract ImmutableSet<E> elementSet();
- @LazyInit @CheckForNull private transient ImmutableSet<Entry<E>> entrySet;
+ @LazyInit private transient ImmutableSet<Entry<E>> entrySet;
@Override
public ImmutableSet<Entry<E>> entrySet() {
@@ -341,7 +332,7 @@
}
@Override
- public boolean contains(@CheckForNull Object o) {
+ public boolean contains(Object o) {
if (o instanceof Entry) {
Entry<?> entry = (Entry<?>) o;
if (entry.getCount() <= 0) {
@@ -412,12 +403,7 @@
* @since 2.0
*/
public static class Builder<E> extends ImmutableCollection.Builder<E> {
- /*
- * `contents` is null only for instances of the subclass, ImmutableSortedMultiset.Builder. That
- * subclass overrides all the methods that access it here. Thus, all the methods here can safely
- * assume that this field is non-null.
- */
- @CheckForNull ObjectCountHashMap<E> contents;
+ ObjectCountHashMap<E> contents;
/**
* If build() has been called on the current contents multiset, we need to copy it on any future
@@ -488,7 +474,6 @@
*/
@CanIgnoreReturnValue
public Builder<E> addCopies(E element, int occurrences) {
- requireNonNull(contents); // see the comment on the field
if (occurrences == 0) {
return this;
}
@@ -514,7 +499,6 @@
*/
@CanIgnoreReturnValue
public Builder<E> setCount(E element, int count) {
- requireNonNull(contents); // see the comment on the field
if (count == 0 && !isLinkedHash) {
contents = new ObjectCountLinkedHashMap<E>(contents);
isLinkedHash = true;
@@ -544,7 +528,6 @@
@CanIgnoreReturnValue
@Override
public Builder<E> addAll(Iterable<? extends E> elements) {
- requireNonNull(contents); // see the comment on the field
if (elements instanceof Multiset) {
Multiset<? extends E> multiset = Multisets.cast(elements);
ObjectCountHashMap<? extends E> backingMap = tryGetMap(multiset);
@@ -585,7 +568,7 @@
* efficient to iterate over it by index rather than an entry iterator, which will need to
* allocate an object for each entry, so we check for that.
*/
- @CheckForNull
+ @NullableDecl
static <T> ObjectCountHashMap<T> tryGetMap(Iterable<T> multiset) {
if (multiset instanceof RegularImmutableMultiset) {
return ((RegularImmutableMultiset<T>) multiset).contents;
@@ -602,7 +585,6 @@
*/
@Override
public ImmutableMultiset<E> build() {
- requireNonNull(contents); // see the comment on the field
if (contents.size() == 0) {
return of();
}
diff --git a/android/guava/src/com/google/common/collect/ImmutableMultisetGwtSerializationDependencies.java b/android/guava/src/com/google/common/collect/ImmutableMultisetGwtSerializationDependencies.java
index 2469a18..a8b1899 100644
--- a/android/guava/src/com/google/common/collect/ImmutableMultisetGwtSerializationDependencies.java
+++ b/android/guava/src/com/google/common/collect/ImmutableMultisetGwtSerializationDependencies.java
@@ -37,5 +37,4 @@
* and make types non-final.
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
abstract class ImmutableMultisetGwtSerializationDependencies<E> extends ImmutableCollection<E> {}
diff --git a/android/guava/src/com/google/common/collect/ImmutableRangeMap.java b/android/guava/src/com/google/common/collect/ImmutableRangeMap.java
index 8a47796..aa0495c 100644
--- a/android/guava/src/com/google/common/collect/ImmutableRangeMap.java
+++ b/android/guava/src/com/google/common/collect/ImmutableRangeMap.java
@@ -23,7 +23,6 @@
import com.google.common.collect.SortedLists.KeyAbsentBehavior;
import com.google.common.collect.SortedLists.KeyPresentBehavior;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
-import com.google.errorprone.annotations.DoNotCall;
import com.google.errorprone.annotations.DoNotMock;
import java.io.Serializable;
import java.util.Collections;
@@ -31,7 +30,7 @@
import java.util.Map;
import java.util.Map.Entry;
import java.util.NoSuchElementException;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* A {@link RangeMap} whose contents will never change, with many other important properties
@@ -42,17 +41,12 @@
*/
@Beta
@GwtIncompatible // NavigableMap
-@ElementTypesAreNonnullByDefault
public class ImmutableRangeMap<K extends Comparable<?>, V> implements RangeMap<K, V>, Serializable {
private static final ImmutableRangeMap<Comparable<?>, Object> EMPTY =
new ImmutableRangeMap<>(ImmutableList.<Range<Comparable<?>>>of(), ImmutableList.of());
- /**
- * Returns an empty immutable range map.
- *
- * <p><b>Performance note:</b> the instance returned is a singleton.
- */
+ /** Returns an empty immutable range map. */
@SuppressWarnings("unchecked")
public static <K extends Comparable<?>, V> ImmutableRangeMap<K, V> of() {
return (ImmutableRangeMap<K, V>) EMPTY;
@@ -120,12 +114,6 @@
return this;
}
- @CanIgnoreReturnValue
- Builder<K, V> combine(Builder<K, V> builder) {
- entries.addAll(builder.entries);
- return this;
- }
-
/**
* Returns an {@code ImmutableRangeMap} containing the associations previously added to this
* builder.
@@ -161,7 +149,7 @@
}
@Override
- @CheckForNull
+ @NullableDecl
public V get(K key) {
int index =
SortedLists.binarySearch(
@@ -179,7 +167,7 @@
}
@Override
- @CheckForNull
+ @NullableDecl
public Entry<Range<K>, V> getEntry(K key) {
int index =
SortedLists.binarySearch(
@@ -214,8 +202,7 @@
*/
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
- public final void put(Range<K> range, V value) {
+ public void put(Range<K> range, V value) {
throw new UnsupportedOperationException();
}
@@ -227,8 +214,7 @@
*/
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
- public final void putCoalescing(Range<K> range, V value) {
+ public void putCoalescing(Range<K> range, V value) {
throw new UnsupportedOperationException();
}
@@ -240,8 +226,7 @@
*/
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
- public final void putAll(RangeMap<K, V> rangeMap) {
+ public void putAll(RangeMap<K, V> rangeMap) {
throw new UnsupportedOperationException();
}
@@ -253,8 +238,7 @@
*/
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
- public final void clear() {
+ public void clear() {
throw new UnsupportedOperationException();
}
@@ -266,8 +250,7 @@
*/
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
- public final void remove(Range<K> range) {
+ public void remove(Range<K> range) {
throw new UnsupportedOperationException();
}
@@ -358,7 +341,7 @@
}
@Override
- public boolean equals(@CheckForNull Object o) {
+ public boolean equals(@NullableDecl Object o) {
if (o instanceof RangeMap) {
RangeMap<?, ?> rangeMap = (RangeMap<?, ?>) o;
return asMapOfRanges().equals(rangeMap.asMapOfRanges());
diff --git a/android/guava/src/com/google/common/collect/ImmutableRangeSet.java b/android/guava/src/com/google/common/collect/ImmutableRangeSet.java
index a0eb5b5..e512be7 100644
--- a/android/guava/src/com/google/common/collect/ImmutableRangeSet.java
+++ b/android/guava/src/com/google/common/collect/ImmutableRangeSet.java
@@ -20,7 +20,6 @@
import static com.google.common.collect.SortedLists.KeyAbsentBehavior.NEXT_HIGHER;
import static com.google.common.collect.SortedLists.KeyAbsentBehavior.NEXT_LOWER;
import static com.google.common.collect.SortedLists.KeyPresentBehavior.ANY_PRESENT;
-import static java.util.Objects.requireNonNull;
import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtIncompatible;
@@ -28,7 +27,6 @@
import com.google.common.collect.SortedLists.KeyPresentBehavior;
import com.google.common.primitives.Ints;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
-import com.google.errorprone.annotations.DoNotCall;
import com.google.errorprone.annotations.concurrent.LazyInit;
import java.io.Serializable;
import java.util.Collections;
@@ -36,7 +34,7 @@
import java.util.List;
import java.util.NoSuchElementException;
import java.util.Set;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* A {@link RangeSet} whose contents will never change, with many other important properties
@@ -47,7 +45,6 @@
*/
@Beta
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public final class ImmutableRangeSet<C extends Comparable> extends AbstractRangeSet<C>
implements Serializable {
@@ -57,11 +54,7 @@
private static final ImmutableRangeSet<Comparable<?>> ALL =
new ImmutableRangeSet<>(ImmutableList.of(Range.<Comparable<?>>all()));
- /**
- * Returns an empty immutable range set.
- *
- * <p><b>Performance note:</b> the instance returned is a singleton.
- */
+ /** Returns an empty immutable range set. */
@SuppressWarnings("unchecked")
public static <C extends Comparable> ImmutableRangeSet<C> of() {
return (ImmutableRangeSet<C>) EMPTY;
@@ -175,7 +168,6 @@
}
@Override
- @CheckForNull
public Range<C> rangeContaining(C value) {
int index =
SortedLists.binarySearch(
@@ -213,7 +205,6 @@
*/
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
public void add(Range<C> range) {
throw new UnsupportedOperationException();
}
@@ -226,7 +217,6 @@
*/
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
public void addAll(RangeSet<C> other) {
throw new UnsupportedOperationException();
}
@@ -239,7 +229,6 @@
*/
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
public void addAll(Iterable<Range<C>> other) {
throw new UnsupportedOperationException();
}
@@ -252,7 +241,6 @@
*/
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
public void remove(Range<C> range) {
throw new UnsupportedOperationException();
}
@@ -265,7 +253,6 @@
*/
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
public void removeAll(RangeSet<C> other) {
throw new UnsupportedOperationException();
}
@@ -278,7 +265,6 @@
*/
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
public void removeAll(Iterable<Range<C>> other) {
throw new UnsupportedOperationException();
}
@@ -299,7 +285,7 @@
return new RegularImmutableSortedSet<>(ranges.reverse(), Range.<C>rangeLexOrdering().reverse());
}
- @LazyInit @CheckForNull private transient ImmutableRangeSet<C> complement;
+ @LazyInit private transient ImmutableRangeSet<C> complement;
private final class ComplementRanges extends ImmutableList<Range<C>> {
// True if the "positive" range set is empty or bounded below.
@@ -541,7 +527,7 @@
this.domain = domain;
}
- @CheckForNull private transient Integer size;
+ @NullableDecl private transient Integer size;
@Override
public int size() {
@@ -567,7 +553,6 @@
Iterator<C> elemItr = Iterators.emptyIterator();
@Override
- @CheckForNull
protected C computeNext() {
while (!elemItr.hasNext()) {
if (rangeItr.hasNext()) {
@@ -589,7 +574,6 @@
Iterator<C> elemItr = Iterators.emptyIterator();
@Override
- @CheckForNull
protected C computeNext() {
while (!elemItr.hasNext()) {
if (rangeItr.hasNext()) {
@@ -630,7 +614,7 @@
}
@Override
- public boolean contains(@CheckForNull Object o) {
+ public boolean contains(@NullableDecl Object o) {
if (o == null) {
return false;
}
@@ -644,10 +628,10 @@
}
@Override
- int indexOf(@CheckForNull Object target) {
+ int indexOf(Object target) {
if (contains(target)) {
@SuppressWarnings("unchecked") // if it's contained, it's definitely a C
- C c = (C) requireNonNull(target);
+ C c = (C) target;
long total = 0;
for (Range<C> range : ranges) {
if (range.contains(c)) {
@@ -763,12 +747,6 @@
return this;
}
- @CanIgnoreReturnValue
- Builder<C> combine(Builder<C> builder) {
- addAll(builder.ranges);
- return this;
- }
-
/**
* Returns an {@code ImmutableRangeSet} containing the ranges added to this builder.
*
diff --git a/android/guava/src/com/google/common/collect/ImmutableSet.java b/android/guava/src/com/google/common/collect/ImmutableSet.java
index 1ff54e2..21d8144 100644
--- a/android/guava/src/com/google/common/collect/ImmutableSet.java
+++ b/android/guava/src/com/google/common/collect/ImmutableSet.java
@@ -20,7 +20,6 @@
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.collect.CollectPreconditions.checkNonnegative;
import static com.google.common.collect.ObjectArrays.checkElementNotNull;
-import static java.util.Objects.requireNonNull;
import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtCompatible;
@@ -36,8 +35,7 @@
import java.util.Iterator;
import java.util.Set;
import java.util.SortedSet;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* A {@link Set} whose contents will never change, with many other important properties detailed at
@@ -47,13 +45,10 @@
*/
@GwtCompatible(serializable = true, emulated = true)
@SuppressWarnings("serial") // we're overriding default serialization
-@ElementTypesAreNonnullByDefault
public abstract class ImmutableSet<E> extends ImmutableCollection<E> implements Set<E> {
/**
* Returns the empty immutable set. Preferred over {@link Collections#emptySet} for code
* consistency, and because the return type conveys the immutability guarantee.
- *
- * <p><b>Performance note:</b> the instance returned is a singleton.
*/
@SuppressWarnings({"unchecked"}) // fully variant implementation (never actually produces any Es)
public static <E> ImmutableSet<E> of() {
@@ -143,14 +138,13 @@
*
* @throws NullPointerException if any of the first {@code n} elements of {@code elements} is null
*/
- private static <E> ImmutableSet<E> construct(int n, @Nullable Object... elements) {
+ private static <E> ImmutableSet<E> construct(int n, Object... elements) {
switch (n) {
case 0:
return of();
case 1:
@SuppressWarnings("unchecked") // safe; elements contains only E's
- // requireNonNull is safe because the first `n` elements are non-null.
- E elem = (E) requireNonNull(elements[0]);
+ E elem = (E) elements[0];
return of(elem);
default:
// continue below to handle the general case
@@ -181,14 +175,12 @@
if (uniques == 1) {
// There is only one element or elements are all duplicates
@SuppressWarnings("unchecked") // we are careful to only pass in E
- // requireNonNull is safe because the first `uniques` elements are non-null.
- E element = (E) requireNonNull(elements[0]);
- return new SingletonImmutableSet<E>(element);
+ E element = (E) elements[0];
+ return new SingletonImmutableSet<E>(element, hashCode);
} else if (chooseTableSize(uniques) < tableSize / 2) {
// Resize the table when the array includes too many duplicates.
return construct(uniques, elements);
} else {
- @Nullable
Object[] uniqueElements =
shouldTrim(uniques, elements.length) ? Arrays.copyOf(elements, uniques) : elements;
return new RegularImmutableSet<E>(uniqueElements, hashCode, table, mask, uniques);
@@ -323,11 +315,10 @@
}
@Override
- public boolean equals(@CheckForNull Object object) {
+ public boolean equals(@NullableDecl Object object) {
if (object == this) {
return true;
- }
- if (object instanceof ImmutableSet
+ } else if (object instanceof ImmutableSet
&& isHashCodeFast()
&& ((ImmutableSet<?>) object).isHashCodeFast()
&& hashCode() != object.hashCode()) {
@@ -346,7 +337,7 @@
@Override
public abstract UnmodifiableIterator<E> iterator();
- @LazyInit @RetainedWith @CheckForNull private transient ImmutableList<E> asList;
+ @LazyInit @RetainedWith @NullableDecl private transient ImmutableList<E> asList;
@Override
public ImmutableList<E> asList() {
@@ -429,7 +420,7 @@
* @since 2.0
*/
public static class Builder<E> extends ImmutableCollection.ArrayBasedBuilder<E> {
- @VisibleForTesting @CheckForNull @Nullable Object[] hashTable;
+ @NullableDecl @VisibleForTesting Object[] hashTable;
private int hashCode;
/**
@@ -442,7 +433,7 @@
Builder(int capacity) {
super(capacity);
- this.hashTable = new @Nullable Object[chooseTableSize(capacity)];
+ this.hashTable = new Object[chooseTableSize(capacity)];
}
/**
@@ -490,7 +481,6 @@
}
private void addDeduping(E element) {
- requireNonNull(hashTable); // safe because we check for null before calling this method
int mask = hashTable.length - 1;
int hash = element.hashCode();
for (int i = Hashing.smear(hash); ; i++) {
@@ -547,20 +537,6 @@
return this;
}
- @CanIgnoreReturnValue
- @SuppressWarnings("unchecked") // ArrayBasedBuilder stores its elements as Object.
- Builder<E> combine(Builder<E> other) {
- if (hashTable != null) {
- for (int i = 0; i < other.size; ++i) {
- // requireNonNull is safe because the first `size` elements are non-null.
- add((E) requireNonNull(other.contents[i]));
- }
- } else {
- addAll(other.contents, other.size);
- }
- return this;
- }
-
/**
* Returns a newly-created {@code ImmutableSet} based on the contents of the {@code Builder}.
*/
@@ -571,15 +547,10 @@
case 0:
return of();
case 1:
- /*
- * requireNonNull is safe because we ensure that the first `size` elements have been
- * populated.
- */
- return (ImmutableSet<E>) of(requireNonNull(contents[0]));
+ return (ImmutableSet<E>) of(contents[0]);
default:
ImmutableSet<E> result;
if (hashTable != null && chooseTableSize(size) == hashTable.length) {
- @Nullable
Object[] uniqueElements =
shouldTrim(size, contents.length) ? Arrays.copyOf(contents, size) : contents;
result =
diff --git a/android/guava/src/com/google/common/collect/ImmutableSetMultimap.java b/android/guava/src/com/google/common/collect/ImmutableSetMultimap.java
index 18cb2ef..622556c 100644
--- a/android/guava/src/com/google/common/collect/ImmutableSetMultimap.java
+++ b/android/guava/src/com/google/common/collect/ImmutableSetMultimap.java
@@ -23,7 +23,6 @@
import com.google.common.annotations.GwtIncompatible;
import com.google.common.base.MoreObjects;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
-import com.google.errorprone.annotations.DoNotCall;
import com.google.errorprone.annotations.concurrent.LazyInit;
import com.google.j2objc.annotations.RetainedWith;
import com.google.j2objc.annotations.Weak;
@@ -36,16 +35,12 @@
import java.util.Comparator;
import java.util.Map;
import java.util.Map.Entry;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* A {@link SetMultimap} whose contents will never change, with many other important properties
* detailed at {@link ImmutableCollection}.
*
- * <p><b>Warning:</b> As in all {@link SetMultimap}s, do not modify either a key <i>or a value</i>
- * of a {@code ImmutableSetMultimap} in a way that affects its {@link Object#equals} behavior.
- * Undefined behavior and bugs will result.
- *
* <p>See the Guava User Guide article on <a href=
* "https://github.com/google/guava/wiki/ImmutableCollectionsExplained"> immutable collections</a>.
*
@@ -53,15 +48,10 @@
* @since 2.0
*/
@GwtCompatible(serializable = true, emulated = true)
-@ElementTypesAreNonnullByDefault
public class ImmutableSetMultimap<K, V> extends ImmutableMultimap<K, V>
implements SetMultimap<K, V> {
- /**
- * Returns the empty multimap.
- *
- * <p><b>Performance note:</b> the instance returned is a singleton.
- */
+ /** Returns the empty multimap. */
// Casting is safe because the multimap will never hold any elements.
@SuppressWarnings("unchecked")
public static <K, V> ImmutableSetMultimap<K, V> of() {
@@ -223,13 +213,6 @@
return this;
}
- @CanIgnoreReturnValue
- @Override
- Builder<K, V> combine(ImmutableMultimap.Builder<K, V> other) {
- super.combine(other);
- return this;
- }
-
/**
* {@inheritDoc}
*
@@ -289,8 +272,7 @@
}
private static <K, V> ImmutableSetMultimap<K, V> copyOf(
- Multimap<? extends K, ? extends V> multimap,
- @CheckForNull Comparator<? super V> valueComparator) {
+ Multimap<? extends K, ? extends V> multimap, Comparator<? super V> valueComparator) {
checkNotNull(multimap); // eager for GWT
if (multimap.isEmpty() && valueComparator == null) {
return of();
@@ -325,7 +307,7 @@
/** Creates an ImmutableSetMultimap from an asMap.entrySet. */
static <K, V> ImmutableSetMultimap<K, V> fromMapEntries(
Collection<? extends Map.Entry<? extends K, ? extends Collection<? extends V>>> mapEntries,
- @CheckForNull Comparator<? super V> valueComparator) {
+ @NullableDecl Comparator<? super V> valueComparator) {
if (mapEntries.isEmpty()) {
return of();
}
@@ -355,7 +337,7 @@
ImmutableSetMultimap(
ImmutableMap<K, ImmutableSet<V>> map,
int size,
- @CheckForNull Comparator<? super V> valueComparator) {
+ @NullableDecl Comparator<? super V> valueComparator) {
super(map, size);
this.emptySet = emptySet(valueComparator);
}
@@ -368,13 +350,13 @@
* parameters used to build this multimap.
*/
@Override
- public ImmutableSet<V> get(K key) {
+ public ImmutableSet<V> get(@NullableDecl K key) {
// This cast is safe as its type is known in constructor.
ImmutableSet<V> set = (ImmutableSet<V>) map.get(key);
return MoreObjects.firstNonNull(set, emptySet);
}
- @LazyInit @RetainedWith @CheckForNull private transient ImmutableSetMultimap<V, K> inverse;
+ @LazyInit @RetainedWith @NullableDecl private transient ImmutableSetMultimap<V, K> inverse;
/**
* {@inheritDoc}
@@ -408,8 +390,7 @@
@CanIgnoreReturnValue
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
- public final ImmutableSet<V> removeAll(@CheckForNull Object key) {
+ public ImmutableSet<V> removeAll(Object key) {
throw new UnsupportedOperationException();
}
@@ -422,12 +403,11 @@
@CanIgnoreReturnValue
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
- public final ImmutableSet<V> replaceValues(K key, Iterable<? extends V> values) {
+ public ImmutableSet<V> replaceValues(K key, Iterable<? extends V> values) {
throw new UnsupportedOperationException();
}
- @LazyInit @RetainedWith @CheckForNull private transient ImmutableSet<Entry<K, V>> entries;
+ @LazyInit @RetainedWith @NullableDecl private transient ImmutableSet<Entry<K, V>> entries;
/**
* Returns an immutable collection of all key-value pairs in the multimap. Its iterator traverses
@@ -447,7 +427,7 @@
}
@Override
- public boolean contains(@CheckForNull Object object) {
+ public boolean contains(@NullableDecl Object object) {
if (object instanceof Entry) {
Entry<?, ?> entry = (Entry<?, ?>) object;
return multimap.containsEntry(entry.getKey(), entry.getValue());
@@ -472,20 +452,20 @@
}
private static <V> ImmutableSet<V> valueSet(
- @CheckForNull Comparator<? super V> valueComparator, Collection<? extends V> values) {
+ @NullableDecl Comparator<? super V> valueComparator, Collection<? extends V> values) {
return (valueComparator == null)
? ImmutableSet.copyOf(values)
: ImmutableSortedSet.copyOf(valueComparator, values);
}
- private static <V> ImmutableSet<V> emptySet(@CheckForNull Comparator<? super V> valueComparator) {
+ private static <V> ImmutableSet<V> emptySet(@NullableDecl Comparator<? super V> valueComparator) {
return (valueComparator == null)
? ImmutableSet.<V>of()
: ImmutableSortedSet.<V>emptySet(valueComparator);
}
private static <V> ImmutableSet.Builder<V> valuesBuilder(
- @CheckForNull Comparator<? super V> valueComparator) {
+ @NullableDecl Comparator<? super V> valueComparator) {
return (valueComparator == null)
? new ImmutableSet.Builder<V>()
: new ImmutableSortedSet.Builder<V>(valueComparator);
@@ -502,7 +482,7 @@
Serialization.writeMultimap(this, stream);
}
- @CheckForNull
+ @NullableDecl
Comparator<? super V> valueComparator() {
return emptySet instanceof ImmutableSortedSet
? ((ImmutableSortedSet<V>) emptySet).comparator()
diff --git a/android/guava/src/com/google/common/collect/ImmutableSortedMap.java b/android/guava/src/com/google/common/collect/ImmutableSortedMap.java
index ac5f0bc..a2f996c 100644
--- a/android/guava/src/com/google/common/collect/ImmutableSortedMap.java
+++ b/android/guava/src/com/google/common/collect/ImmutableSortedMap.java
@@ -20,12 +20,10 @@
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.collect.CollectPreconditions.checkEntryNotNull;
import static com.google.common.collect.Maps.keyOrNull;
-import static java.util.Objects.requireNonNull;
import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtCompatible;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
-import com.google.errorprone.annotations.DoNotCall;
import java.util.AbstractMap;
import java.util.Arrays;
import java.util.Comparator;
@@ -33,8 +31,7 @@
import java.util.NavigableMap;
import java.util.SortedMap;
import java.util.TreeMap;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* A {@link NavigableMap} whose contents will never change, with many other important properties
@@ -54,7 +51,6 @@
* @since 2.0 (implements {@code NavigableMap} since 12.0)
*/
@GwtCompatible(serializable = true, emulated = true)
-@ElementTypesAreNonnullByDefault
public final class ImmutableSortedMap<K, V> extends ImmutableSortedMapFauxverideShim<K, V>
implements NavigableMap<K, V> {
@@ -77,11 +73,7 @@
}
}
- /**
- * Returns the empty sorted map.
- *
- * <p><b>Performance note:</b> the instance returned is a singleton.
- */
+ /** Returns the empty sorted map. */
@SuppressWarnings("unchecked")
// unsafe, comparator() returns a comparator on the specified type
// TODO(kevinb): evaluate whether or not of().comparator() should return null
@@ -110,7 +102,7 @@
@SuppressWarnings("unchecked")
public static <K extends Comparable<? super K>, V> ImmutableSortedMap<K, V> of(
K k1, V v1, K k2, V v2) {
- return fromEntries(entryOf(k1, v1), entryOf(k2, v2));
+ return ofEntries(entryOf(k1, v1), entryOf(k2, v2));
}
/**
@@ -122,7 +114,7 @@
@SuppressWarnings("unchecked")
public static <K extends Comparable<? super K>, V> ImmutableSortedMap<K, V> of(
K k1, V v1, K k2, V v2, K k3, V v3) {
- return fromEntries(entryOf(k1, v1), entryOf(k2, v2), entryOf(k3, v3));
+ return ofEntries(entryOf(k1, v1), entryOf(k2, v2), entryOf(k3, v3));
}
/**
@@ -134,7 +126,7 @@
@SuppressWarnings("unchecked")
public static <K extends Comparable<? super K>, V> ImmutableSortedMap<K, V> of(
K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4) {
- return fromEntries(entryOf(k1, v1), entryOf(k2, v2), entryOf(k3, v3), entryOf(k4, v4));
+ return ofEntries(entryOf(k1, v1), entryOf(k2, v2), entryOf(k3, v3), entryOf(k4, v4));
}
/**
@@ -146,164 +138,13 @@
@SuppressWarnings("unchecked")
public static <K extends Comparable<? super K>, V> ImmutableSortedMap<K, V> of(
K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5) {
- return fromEntries(
+ return ofEntries(
entryOf(k1, v1), entryOf(k2, v2), entryOf(k3, v3), entryOf(k4, v4), entryOf(k5, v5));
}
- /**
- * Returns an immutable sorted map containing the given entries, sorted by the natural ordering of
- * their keys.
- *
- * @throws IllegalArgumentException if any two keys are equal according to their natural ordering
- * @since 31.0
- */
- @SuppressWarnings("unchecked")
- public static <K extends Comparable<? super K>, V> ImmutableSortedMap<K, V> of(
- K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6) {
- return fromEntries(
- entryOf(k1, v1),
- entryOf(k2, v2),
- entryOf(k3, v3),
- entryOf(k4, v4),
- entryOf(k5, v5),
- entryOf(k6, v6));
- }
-
- /**
- * Returns an immutable sorted map containing the given entries, sorted by the natural ordering of
- * their keys.
- *
- * @throws IllegalArgumentException if any two keys are equal according to their natural ordering
- * @since 31.0
- */
- @SuppressWarnings("unchecked")
- public static <K extends Comparable<? super K>, V> ImmutableSortedMap<K, V> of(
- K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6, K k7, V v7) {
- return fromEntries(
- entryOf(k1, v1),
- entryOf(k2, v2),
- entryOf(k3, v3),
- entryOf(k4, v4),
- entryOf(k5, v5),
- entryOf(k6, v6),
- entryOf(k7, v7));
- }
-
- /**
- * Returns an immutable sorted map containing the given entries, sorted by the natural ordering of
- * their keys.
- *
- * @throws IllegalArgumentException if any two keys are equal according to their natural ordering
- * @since 31.0
- */
- @SuppressWarnings("unchecked")
- public static <K extends Comparable<? super K>, V> ImmutableSortedMap<K, V> of(
- K k1,
- V v1,
- K k2,
- V v2,
- K k3,
- V v3,
- K k4,
- V v4,
- K k5,
- V v5,
- K k6,
- V v6,
- K k7,
- V v7,
- K k8,
- V v8) {
- return fromEntries(
- entryOf(k1, v1),
- entryOf(k2, v2),
- entryOf(k3, v3),
- entryOf(k4, v4),
- entryOf(k5, v5),
- entryOf(k6, v6),
- entryOf(k7, v7),
- entryOf(k8, v8));
- }
-
- /**
- * Returns an immutable sorted map containing the given entries, sorted by the natural ordering of
- * their keys.
- *
- * @throws IllegalArgumentException if any two keys are equal according to their natural ordering
- * @since 31.0
- */
- @SuppressWarnings("unchecked")
- public static <K extends Comparable<? super K>, V> ImmutableSortedMap<K, V> of(
- K k1,
- V v1,
- K k2,
- V v2,
- K k3,
- V v3,
- K k4,
- V v4,
- K k5,
- V v5,
- K k6,
- V v6,
- K k7,
- V v7,
- K k8,
- V v8,
- K k9,
- V v9) {
- return fromEntries(
- entryOf(k1, v1),
- entryOf(k2, v2),
- entryOf(k3, v3),
- entryOf(k4, v4),
- entryOf(k5, v5),
- entryOf(k6, v6),
- entryOf(k7, v7),
- entryOf(k8, v8),
- entryOf(k9, v9));
- }
-
- /**
- * Returns an immutable sorted map containing the given entries, sorted by the natural ordering of
- * their keys.
- *
- * @throws IllegalArgumentException if any two keys are equal according to their natural ordering
- * @since 31.0
- */
- @SuppressWarnings("unchecked")
- public static <K extends Comparable<? super K>, V> ImmutableSortedMap<K, V> of(
- K k1,
- V v1,
- K k2,
- V v2,
- K k3,
- V v3,
- K k4,
- V v4,
- K k5,
- V v5,
- K k6,
- V v6,
- K k7,
- V v7,
- K k8,
- V v8,
- K k9,
- V v9,
- K k10,
- V v10) {
- return fromEntries(
- entryOf(k1, v1),
- entryOf(k2, v2),
- entryOf(k3, v3),
- entryOf(k4, v4),
- entryOf(k5, v5),
- entryOf(k6, v6),
- entryOf(k7, v7),
- entryOf(k8, v8),
- entryOf(k9, v9),
- entryOf(k10, v10));
+ private static <K extends Comparable<? super K>, V> ImmutableSortedMap<K, V> ofEntries(
+ Entry<K, V>... entries) {
+ return fromEntries(Ordering.natural(), false, entries, entries.length);
}
/**
@@ -346,8 +187,8 @@
}
/**
- * Returns an immutable map containing the given entries, with keys sorted by their natural
- * ordering.
+ * Returns an immutable map containing the given entries, with keys sorted by the provided
+ * comparator.
*
* <p>This method is not type-safe, as it may be called on a map with keys that are not mutually
* comparable.
@@ -433,11 +274,6 @@
return fromEntries(comparator, sameComparator, map.entrySet());
}
- private static <K extends Comparable<? super K>, V> ImmutableSortedMap<K, V> fromEntries(
- Entry<K, V>... entries) {
- return fromEntries(Ordering.natural(), false, entries, entries.length);
- }
-
/**
* Accepts a collection of possibly-null entries. If {@code sameComparator}, then it is assumed
* that they do not need to be sorted or checked for dupes.
@@ -457,25 +293,22 @@
private static <K, V> ImmutableSortedMap<K, V> fromEntries(
final Comparator<? super K> comparator,
boolean sameComparator,
- @Nullable Entry<K, V>[] entryArray,
+ Entry<K, V>[] entryArray,
int size) {
switch (size) {
case 0:
return emptyMap(comparator);
case 1:
- // requireNonNull is safe because the first `size` elements have been filled in.
- Entry<K, V> onlyEntry = requireNonNull(entryArray[0]);
- return of(comparator, onlyEntry.getKey(), onlyEntry.getValue());
+ return ImmutableSortedMap.<K, V>of(
+ comparator, entryArray[0].getKey(), entryArray[0].getValue());
default:
Object[] keys = new Object[size];
Object[] values = new Object[size];
if (sameComparator) {
// Need to check for nulls, but don't need to sort or validate.
for (int i = 0; i < size; i++) {
- // requireNonNull is safe because the first `size` elements have been filled in.
- Entry<K, V> entry = requireNonNull(entryArray[i]);
- Object key = entry.getKey();
- Object value = entry.getValue();
+ Object key = entryArray[i].getKey();
+ Object value = entryArray[i].getValue();
checkEntryNotNull(key, value);
keys[i] = key;
values[i] = value;
@@ -488,31 +321,24 @@
entryArray,
0,
size,
- new Comparator<@Nullable Entry<K, V>>() {
+ new Comparator<Entry<K, V>>() {
@Override
- public int compare(@CheckForNull Entry<K, V> e1, @CheckForNull Entry<K, V> e2) {
- // requireNonNull is safe because the first `size` elements have been filled in.
- requireNonNull(e1);
- requireNonNull(e2);
+ public int compare(Entry<K, V> e1, Entry<K, V> e2) {
return comparator.compare(e1.getKey(), e2.getKey());
}
});
- // requireNonNull is safe because the first `size` elements have been filled in.
- Entry<K, V> firstEntry = requireNonNull(entryArray[0]);
- K prevKey = firstEntry.getKey();
+ K prevKey = entryArray[0].getKey();
keys[0] = prevKey;
- values[0] = firstEntry.getValue();
+ values[0] = entryArray[0].getValue();
checkEntryNotNull(keys[0], values[0]);
for (int i = 1; i < size; i++) {
- // requireNonNull is safe because the first `size` elements have been filled in.
- Entry<K, V> prevEntry = requireNonNull(entryArray[i - 1]);
- Entry<K, V> entry = requireNonNull(entryArray[i]);
- K key = entry.getKey();
- V value = entry.getValue();
+ K key = entryArray[i].getKey();
+ V value = entryArray[i].getValue();
checkEntryNotNull(key, value);
keys[i] = key;
values[i] = value;
- checkNoConflict(comparator.compare(prevKey, key) != 0, "key", prevEntry, entry);
+ checkNoConflict(
+ comparator.compare(prevKey, key) != 0, "key", entryArray[i - 1], entryArray[i]);
prevKey = key;
}
}
@@ -560,20 +386,20 @@
* .put(1, "one")
* .put(2, "two")
* .put(3, "three")
- * .buildOrThrow();
+ * .build();
* }</pre>
*
* <p>For <i>small</i> immutable sorted maps, the {@code ImmutableSortedMap.of()} methods are even
* more convenient.
*
- * <p>Builder instances can be reused - it is safe to call {@link #buildOrThrow} multiple times to
- * build multiple maps in series. Each map is a superset of the maps created before it.
+ * <p>Builder instances can be reused - it is safe to call {@link #build} multiple times to build
+ * multiple maps in series. Each map is a superset of the maps created before it.
*
* @since 2.0
*/
public static class Builder<K, V> extends ImmutableMap.Builder<K, V> {
- private transient @Nullable Object[] keys;
- private transient @Nullable Object[] values;
+ private transient Object[] keys;
+ private transient Object[] values;
private final Comparator<? super K> comparator;
/**
@@ -587,8 +413,8 @@
private Builder(Comparator<? super K> comparator, int initialCapacity) {
this.comparator = checkNotNull(comparator);
- this.keys = new @Nullable Object[initialCapacity];
- this.values = new @Nullable Object[initialCapacity];
+ this.keys = new Object[initialCapacity];
+ this.values = new Object[initialCapacity];
}
private void ensureCapacity(int minCapacity) {
@@ -669,51 +495,23 @@
@Beta
@Override
@Deprecated
- @DoNotCall("Always throws UnsupportedOperationException")
- public final Builder<K, V> orderEntriesByValue(Comparator<? super V> valueComparator) {
+ public Builder<K, V> orderEntriesByValue(Comparator<? super V> valueComparator) {
throw new UnsupportedOperationException("Not available on ImmutableSortedMap.Builder");
}
- @CanIgnoreReturnValue
- Builder<K, V> combine(ImmutableSortedMap.Builder<K, V> other) {
- ensureCapacity(size + other.size);
- System.arraycopy(other.keys, 0, this.keys, this.size, other.size);
- System.arraycopy(other.values, 0, this.values, this.size, other.size);
- size += other.size;
- return this;
- }
-
/**
* Returns a newly-created immutable sorted map.
*
- * <p>Prefer the equivalent method {@link #buildOrThrow()} to make it explicit that the method
- * will throw an exception if there are duplicate keys. The {@code build()} method will soon be
- * deprecated.
- *
* @throws IllegalArgumentException if any two keys are equal according to the comparator (which
* might be the keys' natural order)
*/
@Override
public ImmutableSortedMap<K, V> build() {
- return buildOrThrow();
- }
-
- /**
- * Returns a newly-created immutable sorted map, or throws an exception if any two keys are
- * equal.
- *
- * @throws IllegalArgumentException if any two keys are equal according to the comparator (which
- * might be the keys' natural order)
- * @since 31.0
- */
- @Override
- public ImmutableSortedMap<K, V> buildOrThrow() {
switch (size) {
case 0:
return emptyMap(comparator);
case 1:
- // requireNonNull is safe because the first `size` elements have been filled in.
- return of(comparator, (K) requireNonNull(keys[0]), (V) requireNonNull(values[0]));
+ return of(comparator, (K) keys[0], (V) values[0]);
default:
Object[] sortedKeys = Arrays.copyOf(keys, size);
Arrays.sort((K[]) sortedKeys, comparator);
@@ -731,10 +529,8 @@
+ " and "
+ sortedKeys[i]);
}
- // requireNonNull is safe because the first `size` elements have been filled in.
- int index =
- Arrays.binarySearch((K[]) sortedKeys, (K) requireNonNull(keys[i]), comparator);
- sortedValues[index] = requireNonNull(values[i]);
+ int index = Arrays.binarySearch((K[]) sortedKeys, (K) keys[i], comparator);
+ sortedValues[index] = values[i];
}
return new ImmutableSortedMap<K, V>(
new RegularImmutableSortedSet<K>(
@@ -746,7 +542,7 @@
private final transient RegularImmutableSortedSet<K> keySet;
private final transient ImmutableList<V> valueList;
- @CheckForNull private transient ImmutableSortedMap<K, V> descendingMap;
+ private transient ImmutableSortedMap<K, V> descendingMap;
ImmutableSortedMap(RegularImmutableSortedSet<K> keySet, ImmutableList<V> valueList) {
this(keySet, valueList, null);
@@ -755,7 +551,7 @@
ImmutableSortedMap(
RegularImmutableSortedSet<K> keySet,
ImmutableList<V> valueList,
- @CheckForNull ImmutableSortedMap<K, V> descendingMap) {
+ ImmutableSortedMap<K, V> descendingMap) {
this.keySet = keySet;
this.valueList = valueList;
this.descendingMap = descendingMap;
@@ -767,8 +563,7 @@
}
@Override
- @CheckForNull
- public V get(@CheckForNull Object key) {
+ public V get(@NullableDecl Object key) {
int index = keySet.indexOf(key);
return (index == -1) ? null : valueList.get(index);
}
@@ -979,61 +774,51 @@
}
@Override
- @CheckForNull
public Entry<K, V> lowerEntry(K key) {
return headMap(key, false).lastEntry();
}
@Override
- @CheckForNull
public K lowerKey(K key) {
return keyOrNull(lowerEntry(key));
}
@Override
- @CheckForNull
public Entry<K, V> floorEntry(K key) {
return headMap(key, true).lastEntry();
}
@Override
- @CheckForNull
public K floorKey(K key) {
return keyOrNull(floorEntry(key));
}
@Override
- @CheckForNull
public Entry<K, V> ceilingEntry(K key) {
return tailMap(key, true).firstEntry();
}
@Override
- @CheckForNull
public K ceilingKey(K key) {
return keyOrNull(ceilingEntry(key));
}
@Override
- @CheckForNull
public Entry<K, V> higherEntry(K key) {
return tailMap(key, false).firstEntry();
}
@Override
- @CheckForNull
public K higherKey(K key) {
return keyOrNull(higherEntry(key));
}
@Override
- @CheckForNull
public Entry<K, V> firstEntry() {
return isEmpty() ? null : entrySet().asList().get(0);
}
@Override
- @CheckForNull
public Entry<K, V> lastEntry() {
return isEmpty() ? null : entrySet().asList().get(size() - 1);
}
@@ -1047,8 +832,6 @@
@CanIgnoreReturnValue
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
- @CheckForNull
public final Entry<K, V> pollFirstEntry() {
throw new UnsupportedOperationException();
}
@@ -1062,8 +845,6 @@
@CanIgnoreReturnValue
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
- @CheckForNull
public final Entry<K, V> pollLastEntry() {
throw new UnsupportedOperationException();
}
diff --git a/android/guava/src/com/google/common/collect/ImmutableSortedMapFauxverideShim.java b/android/guava/src/com/google/common/collect/ImmutableSortedMapFauxverideShim.java
index 9b40f55..1e875a3 100644
--- a/android/guava/src/com/google/common/collect/ImmutableSortedMapFauxverideShim.java
+++ b/android/guava/src/com/google/common/collect/ImmutableSortedMapFauxverideShim.java
@@ -17,7 +17,6 @@
package com.google.common.collect;
import com.google.common.annotations.GwtIncompatible;
-import com.google.errorprone.annotations.DoNotCall;
/**
* "Overrides" the {@link ImmutableMap} static methods that lack {@link ImmutableSortedMap}
@@ -27,7 +26,6 @@
* @author Chris Povirk
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
abstract class ImmutableSortedMapFauxverideShim<K, V> extends ImmutableMap<K, V> {
/**
* Not supported. Use {@link ImmutableSortedMap#naturalOrder}, which offers better type-safety,
@@ -37,7 +35,6 @@
* @throws UnsupportedOperationException always
* @deprecated Use {@link ImmutableSortedMap#naturalOrder}, which offers better type-safety.
*/
- @DoNotCall("Use naturalOrder")
@Deprecated
public static <K, V> ImmutableSortedMap.Builder<K, V> builder() {
throw new UnsupportedOperationException();
@@ -49,7 +46,6 @@
* @throws UnsupportedOperationException always
* @deprecated Not supported for ImmutableSortedMap.
*/
- @DoNotCall("Use naturalOrder (which does not accept an expected size)")
@Deprecated
public static <K, V> ImmutableSortedMap.Builder<K, V> builderWithExpectedSize(int expectedSize) {
throw new UnsupportedOperationException();
@@ -64,7 +60,6 @@
* @deprecated <b>Pass a key of type {@code Comparable} to use {@link
* ImmutableSortedMap#of(Comparable, Object)}.</b>
*/
- @DoNotCall("Pass a key of type Comparable")
@Deprecated
public static <K, V> ImmutableSortedMap<K, V> of(K k1, V v1) {
throw new UnsupportedOperationException();
@@ -79,7 +74,6 @@
* @deprecated <b>Pass keys of type {@code Comparable} to use {@link
* ImmutableSortedMap#of(Comparable, Object, Comparable, Object)}.</b>
*/
- @DoNotCall("Pass keys of type Comparable")
@Deprecated
public static <K, V> ImmutableSortedMap<K, V> of(K k1, V v1, K k2, V v2) {
throw new UnsupportedOperationException();
@@ -94,7 +88,6 @@
* @deprecated <b>Pass keys of type {@code Comparable} to use {@link
* ImmutableSortedMap#of(Comparable, Object, Comparable, Object, Comparable, Object)}.</b>
*/
- @DoNotCall("Pass keys of type Comparable")
@Deprecated
public static <K, V> ImmutableSortedMap<K, V> of(K k1, V v1, K k2, V v2, K k3, V v3) {
throw new UnsupportedOperationException();
@@ -110,7 +103,6 @@
* ImmutableSortedMap#of(Comparable, Object, Comparable, Object, Comparable, Object,
* Comparable, Object)}.</b>
*/
- @DoNotCall("Pass keys of type Comparable")
@Deprecated
public static <K, V> ImmutableSortedMap<K, V> of(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4) {
throw new UnsupportedOperationException();
@@ -126,160 +118,11 @@
* ImmutableSortedMap#of(Comparable, Object, Comparable, Object, Comparable, Object,
* Comparable, Object, Comparable, Object)}.</b>
*/
- @DoNotCall("Pass keys of type Comparable")
@Deprecated
public static <K, V> ImmutableSortedMap<K, V> of(
K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5) {
throw new UnsupportedOperationException();
}
- /**
- * Not supported. <b>You are attempting to create a map that may contain non-{@code Comparable}
- * keys.</b> Proper calls will resolve to the version in {@code ImmutableSortedMap}, not this
- * dummy version.
- *
- * @throws UnsupportedOperationException always
- * @deprecated <b>Pass keys of type {@code Comparable} to use {@link
- * ImmutableSortedMap#of(Comparable, Object, Comparable, Object, Comparable, Object,
- * Comparable, Object, Comparable, Object)}.</b>
- */
- @DoNotCall("Pass keys of type Comparable")
- @Deprecated
- public static <K, V> ImmutableSortedMap<K, V> of(
- K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Not supported. <b>You are attempting to create a map that may contain non-{@code Comparable}
- * keys.</b> Proper calls will resolve to the version in {@code ImmutableSortedMap}, not this
- * dummy version.
- *
- * @throws UnsupportedOperationException always
- * @deprecated <b>Pass keys of type {@code Comparable} to use {@link
- * ImmutableSortedMap#of(Comparable, Object, Comparable, Object, Comparable, Object,
- * Comparable, Object, Comparable, Object)}.</b>
- */
- @DoNotCall("Pass keys of type Comparable")
- @Deprecated
- public static <K, V> ImmutableSortedMap<K, V> of(
- K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6, K k7, V v7) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Not supported. <b>You are attempting to create a map that may contain non-{@code Comparable}
- * keys.</b> Proper calls will resolve to the version in {@code ImmutableSortedMap}, not this
- * dummy version.
- *
- * @throws UnsupportedOperationException always
- * @deprecated <b>Pass keys of type {@code Comparable} to use {@link
- * ImmutableSortedMap#of(Comparable, Object, Comparable, Object, Comparable, Object,
- * Comparable, Object, Comparable, Object)}.</b>
- */
- @DoNotCall("Pass keys of type Comparable")
- @Deprecated
- public static <K, V> ImmutableSortedMap<K, V> of(
- K k1,
- V v1,
- K k2,
- V v2,
- K k3,
- V v3,
- K k4,
- V v4,
- K k5,
- V v5,
- K k6,
- V v6,
- K k7,
- V v7,
- K k8,
- V v8) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Not supported. <b>You are attempting to create a map that may contain non-{@code Comparable}
- * keys.</b> Proper calls will resolve to the version in {@code ImmutableSortedMap}, not this
- * dummy version.
- *
- * @throws UnsupportedOperationException always
- * @deprecated <b>Pass keys of type {@code Comparable} to use {@link
- * ImmutableSortedMap#of(Comparable, Object, Comparable, Object, Comparable, Object,
- * Comparable, Object, Comparable, Object)}.</b>
- */
- @DoNotCall("Pass keys of type Comparable")
- @Deprecated
- public static <K, V> ImmutableSortedMap<K, V> of(
- K k1,
- V v1,
- K k2,
- V v2,
- K k3,
- V v3,
- K k4,
- V v4,
- K k5,
- V v5,
- K k6,
- V v6,
- K k7,
- V v7,
- K k8,
- V v8,
- K k9,
- V v9) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Not supported. <b>You are attempting to create a map that may contain non-{@code Comparable}
- * keys.</b> Proper calls will resolve to the version in {@code ImmutableSortedMap}, not this
- * dummy version.
- *
- * @throws UnsupportedOperationException always
- * @deprecated <b>Pass keys of type {@code Comparable} to use {@link
- * ImmutableSortedMap#of(Comparable, Object, Comparable, Object, Comparable, Object,
- * Comparable, Object, Comparable, Object)}.</b>
- */
- @DoNotCall("Pass keys of type Comparable")
- @Deprecated
- public static <K, V> ImmutableSortedMap<K, V> of(
- K k1,
- V v1,
- K k2,
- V v2,
- K k3,
- V v3,
- K k4,
- V v4,
- K k5,
- V v5,
- K k6,
- V v6,
- K k7,
- V v7,
- K k8,
- V v8,
- K k9,
- V v9,
- K k10,
- V v10) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Not supported. Use {@code ImmutableSortedMap.copyOf(ImmutableMap.ofEntries(...))}.
- *
- * @deprecated Use {@code ImmutableSortedMap.copyOf(ImmutableMap.ofEntries(...))}.
- */
- @DoNotCall("ImmutableSortedMap.ofEntries not currently available; use ImmutableSortedMap.copyOf")
- @Deprecated
- public static <K, V> ImmutableSortedMap<K, V> ofEntries(
- Entry<? extends K, ? extends V>... entries) {
- throw new UnsupportedOperationException();
- }
-
// No copyOf() fauxveride; see ImmutableSortedSetFauxverideShim.
}
diff --git a/android/guava/src/com/google/common/collect/ImmutableSortedMultiset.java b/android/guava/src/com/google/common/collect/ImmutableSortedMultiset.java
index 5a7529e..1b4cec7 100644
--- a/android/guava/src/com/google/common/collect/ImmutableSortedMultiset.java
+++ b/android/guava/src/com/google/common/collect/ImmutableSortedMultiset.java
@@ -21,7 +21,6 @@
import com.google.common.annotations.VisibleForTesting;
import com.google.common.math.IntMath;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
-import com.google.errorprone.annotations.DoNotCall;
import com.google.errorprone.annotations.concurrent.LazyInit;
import java.io.Serializable;
import java.util.Arrays;
@@ -30,7 +29,6 @@
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
-import javax.annotation.CheckForNull;
/**
* A {@link SortedMultiset} whose contents will never change, with many other important properties
@@ -49,16 +47,11 @@
* @since 12.0
*/
@GwtIncompatible // hasn't been tested yet
-@ElementTypesAreNonnullByDefault
public abstract class ImmutableSortedMultiset<E> extends ImmutableSortedMultisetFauxverideShim<E>
implements SortedMultiset<E> {
// TODO(lowasser): GWT compatibility
- /**
- * Returns the empty immutable sorted multiset.
- *
- * <p><b>Performance note:</b> the instance returned is a singleton.
- */
+ /** Returns the empty immutable sorted multiset. */
@SuppressWarnings("unchecked")
public static <E> ImmutableSortedMultiset<E> of() {
return (ImmutableSortedMultiset) RegularImmutableSortedMultiset.NATURAL_EMPTY_MULTISET;
@@ -78,6 +71,7 @@
*
* @throws NullPointerException if any element is null
*/
+ @SuppressWarnings("unchecked")
public static <E extends Comparable<? super E>> ImmutableSortedMultiset<E> of(E e1, E e2) {
return copyOf(Ordering.natural(), Arrays.asList(e1, e2));
}
@@ -88,6 +82,7 @@
*
* @throws NullPointerException if any element is null
*/
+ @SuppressWarnings("unchecked")
public static <E extends Comparable<? super E>> ImmutableSortedMultiset<E> of(E e1, E e2, E e3) {
return copyOf(Ordering.natural(), Arrays.asList(e1, e2, e3));
}
@@ -98,6 +93,7 @@
*
* @throws NullPointerException if any element is null
*/
+ @SuppressWarnings("unchecked")
public static <E extends Comparable<? super E>> ImmutableSortedMultiset<E> of(
E e1, E e2, E e3, E e4) {
return copyOf(Ordering.natural(), Arrays.asList(e1, e2, e3, e4));
@@ -109,6 +105,7 @@
*
* @throws NullPointerException if any element is null
*/
+ @SuppressWarnings("unchecked")
public static <E extends Comparable<? super E>> ImmutableSortedMultiset<E> of(
E e1, E e2, E e3, E e4, E e5) {
return copyOf(Ordering.natural(), Arrays.asList(e1, e2, e3, e4, e5));
@@ -120,6 +117,7 @@
*
* @throws NullPointerException if any element is null
*/
+ @SuppressWarnings("unchecked")
public static <E extends Comparable<? super E>> ImmutableSortedMultiset<E> of(
E e1, E e2, E e3, E e4, E e5, E e6, E... remaining) {
int size = remaining.length + 6;
@@ -283,7 +281,7 @@
@Override
public abstract ImmutableSortedSet<E> elementSet();
- @LazyInit @CheckForNull transient ImmutableSortedMultiset<E> descendingMultiset;
+ @LazyInit transient ImmutableSortedMultiset<E> descendingMultiset;
@Override
public ImmutableSortedMultiset<E> descendingMultiset() {
@@ -308,8 +306,6 @@
@CanIgnoreReturnValue
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
- @CheckForNull
public final Entry<E> pollFirstEntry() {
throw new UnsupportedOperationException();
}
@@ -325,8 +321,6 @@
@CanIgnoreReturnValue
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
- @CheckForNull
public final Entry<E> pollLastEntry() {
throw new UnsupportedOperationException();
}
diff --git a/android/guava/src/com/google/common/collect/ImmutableSortedMultisetFauxverideShim.java b/android/guava/src/com/google/common/collect/ImmutableSortedMultisetFauxverideShim.java
index c8a7ed7..39d41ed 100644
--- a/android/guava/src/com/google/common/collect/ImmutableSortedMultisetFauxverideShim.java
+++ b/android/guava/src/com/google/common/collect/ImmutableSortedMultisetFauxverideShim.java
@@ -15,7 +15,6 @@
package com.google.common.collect;
import com.google.common.annotations.GwtIncompatible;
-import com.google.errorprone.annotations.DoNotCall;
/**
* "Overrides" the {@link ImmutableMultiset} static methods that lack {@link
@@ -35,7 +34,6 @@
* @author Louis Wasserman
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
abstract class ImmutableSortedMultisetFauxverideShim<E> extends ImmutableMultiset<E> {
/**
* Not supported. Use {@link ImmutableSortedMultiset#naturalOrder}, which offers better
@@ -45,7 +43,6 @@
* @throws UnsupportedOperationException always
* @deprecated Use {@link ImmutableSortedMultiset#naturalOrder}, which offers better type-safety.
*/
- @DoNotCall("Use naturalOrder.")
@Deprecated
public static <E> ImmutableSortedMultiset.Builder<E> builder() {
throw new UnsupportedOperationException();
@@ -60,7 +57,6 @@
* @deprecated <b>Pass a parameter of type {@code Comparable} to use {@link
* ImmutableSortedMultiset#of(Comparable)}.</b>
*/
- @DoNotCall("Elements must be Comparable. (Or, pass a Comparator to orderedBy or copyOf.)")
@Deprecated
public static <E> ImmutableSortedMultiset<E> of(E element) {
throw new UnsupportedOperationException();
@@ -75,7 +71,6 @@
* @deprecated <b>Pass the parameters of type {@code Comparable} to use {@link
* ImmutableSortedMultiset#of(Comparable, Comparable)}.</b>
*/
- @DoNotCall("Elements must be Comparable. (Or, pass a Comparator to orderedBy or copyOf.)")
@Deprecated
public static <E> ImmutableSortedMultiset<E> of(E e1, E e2) {
throw new UnsupportedOperationException();
@@ -90,7 +85,6 @@
* @deprecated <b>Pass the parameters of type {@code Comparable} to use {@link
* ImmutableSortedMultiset#of(Comparable, Comparable, Comparable)}.</b>
*/
- @DoNotCall("Elements must be Comparable. (Or, pass a Comparator to orderedBy or copyOf.)")
@Deprecated
public static <E> ImmutableSortedMultiset<E> of(E e1, E e2, E e3) {
throw new UnsupportedOperationException();
@@ -105,7 +99,6 @@
* @deprecated <b>Pass the parameters of type {@code Comparable} to use {@link
* ImmutableSortedMultiset#of(Comparable, Comparable, Comparable, Comparable)}. </b>
*/
- @DoNotCall("Elements must be Comparable. (Or, pass a Comparator to orderedBy or copyOf.)")
@Deprecated
public static <E> ImmutableSortedMultiset<E> of(E e1, E e2, E e3, E e4) {
throw new UnsupportedOperationException();
@@ -121,7 +114,6 @@
* ImmutableSortedMultiset#of(Comparable, Comparable, Comparable, Comparable, Comparable)} .
* </b>
*/
- @DoNotCall("Elements must be Comparable. (Or, pass a Comparator to orderedBy or copyOf.)")
@Deprecated
public static <E> ImmutableSortedMultiset<E> of(E e1, E e2, E e3, E e4, E e5) {
throw new UnsupportedOperationException();
@@ -137,7 +129,6 @@
* ImmutableSortedMultiset#of(Comparable, Comparable, Comparable, Comparable, Comparable,
* Comparable, Comparable...)} . </b>
*/
- @DoNotCall("Elements must be Comparable. (Or, pass a Comparator to orderedBy or copyOf.)")
@Deprecated
public static <E> ImmutableSortedMultiset<E> of(
E e1, E e2, E e3, E e4, E e5, E e6, E... remaining) {
@@ -153,7 +144,6 @@
* @deprecated <b>Pass parameters of type {@code Comparable} to use {@link
* ImmutableSortedMultiset#copyOf(Comparable[])}.</b>
*/
- @DoNotCall("Elements must be Comparable. (Or, pass a Comparator to orderedBy or copyOf.)")
@Deprecated
public static <E> ImmutableSortedMultiset<E> copyOf(E[] elements) {
throw new UnsupportedOperationException();
diff --git a/android/guava/src/com/google/common/collect/ImmutableSortedSet.java b/android/guava/src/com/google/common/collect/ImmutableSortedSet.java
index fabf599..485bfa5 100644
--- a/android/guava/src/com/google/common/collect/ImmutableSortedSet.java
+++ b/android/guava/src/com/google/common/collect/ImmutableSortedSet.java
@@ -23,7 +23,6 @@
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.GwtIncompatible;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
-import com.google.errorprone.annotations.DoNotCall;
import com.google.errorprone.annotations.concurrent.LazyInit;
import java.io.InvalidObjectException;
import java.io.ObjectInputStream;
@@ -35,8 +34,7 @@
import java.util.Iterator;
import java.util.NavigableSet;
import java.util.SortedSet;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* A {@link NavigableSet} whose contents will never change, with many other important properties
@@ -58,7 +56,6 @@
// TODO(benyu): benchmark and optimize all creation paths, which are a mess now
@GwtCompatible(serializable = true, emulated = true)
@SuppressWarnings("serial") // we're overriding default serialization
-@ElementTypesAreNonnullByDefault
public abstract class ImmutableSortedSet<E> extends ImmutableSortedSetFauxverideShim<E>
implements NavigableSet<E>, SortedIterable<E> {
static <E> RegularImmutableSortedSet<E> emptySet(Comparator<? super E> comparator) {
@@ -69,11 +66,7 @@
}
}
- /**
- * Returns the empty immutable sorted set.
- *
- * <p><b>Performance note:</b> the instance returned is a singleton.
- */
+ /** Returns the empty immutable sorted set. */
public static <E> ImmutableSortedSet<E> of() {
return (ImmutableSortedSet<E>) RegularImmutableSortedSet.NATURAL_EMPTY_SET;
}
@@ -487,13 +480,6 @@
return this;
}
- @CanIgnoreReturnValue
- @Override
- Builder<E> combine(ImmutableSet.Builder<E> builder) {
- super.combine(builder);
- return this;
- }
-
/**
* Returns a newly-created {@code ImmutableSortedSet} based on the contents of the {@code
* Builder} and its comparator.
@@ -509,16 +495,16 @@
}
}
- int unsafeCompare(Object a, @CheckForNull Object b) {
+ int unsafeCompare(Object a, Object b) {
return unsafeCompare(comparator, a, b);
}
- static int unsafeCompare(Comparator<?> comparator, Object a, @CheckForNull Object b) {
+ static int unsafeCompare(Comparator<?> comparator, Object a, Object b) {
// Pretend the comparator can compare anything. If it turns out it can't
- // compare a and b, we should get a CCE or NPE on the subsequent line. Only methods
- // that are spec'd to throw CCE and NPE should call this.
- @SuppressWarnings({"unchecked", "nullness"})
- Comparator<@Nullable Object> unsafeComparator = (Comparator<@Nullable Object>) comparator;
+ // compare a and b, we should get a CCE on the subsequent line. Only methods
+ // that are spec'd to throw CCE should call this.
+ @SuppressWarnings("unchecked")
+ Comparator<Object> unsafeComparator = (Comparator<Object>) comparator;
return unsafeComparator.compare(a, b);
}
@@ -625,21 +611,18 @@
/** @since 12.0 */
@GwtIncompatible // NavigableSet
@Override
- @CheckForNull
public E lower(E e) {
return Iterators.getNext(headSet(e, false).descendingIterator(), null);
}
/** @since 12.0 */
@Override
- @CheckForNull
public E floor(E e) {
return Iterators.getNext(headSet(e, true).descendingIterator(), null);
}
/** @since 12.0 */
@Override
- @CheckForNull
public E ceiling(E e) {
return Iterables.getFirst(tailSet(e, true), null);
}
@@ -647,7 +630,6 @@
/** @since 12.0 */
@GwtIncompatible // NavigableSet
@Override
- @CheckForNull
public E higher(E e) {
return Iterables.getFirst(tailSet(e, false), null);
}
@@ -673,8 +655,6 @@
@Deprecated
@GwtIncompatible // NavigableSet
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
- @CheckForNull
public final E pollFirst() {
throw new UnsupportedOperationException();
}
@@ -690,15 +670,12 @@
@Deprecated
@GwtIncompatible // NavigableSet
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
- @CheckForNull
public final E pollLast() {
throw new UnsupportedOperationException();
}
@GwtIncompatible // NavigableSet
@LazyInit
- @CheckForNull
transient ImmutableSortedSet<E> descendingSet;
/** @since 12.0 */
@@ -726,7 +703,7 @@
public abstract UnmodifiableIterator<E> descendingIterator();
/** Returns the position of an element within the set, or -1 if not present. */
- abstract int indexOf(@CheckForNull Object target);
+ abstract int indexOf(@NullableDecl Object target);
/*
* This class is used to serialize all ImmutableSortedSet instances,
diff --git a/android/guava/src/com/google/common/collect/ImmutableSortedSetFauxverideShim.java b/android/guava/src/com/google/common/collect/ImmutableSortedSetFauxverideShim.java
index ca19d79..9d2af2c 100644
--- a/android/guava/src/com/google/common/collect/ImmutableSortedSetFauxverideShim.java
+++ b/android/guava/src/com/google/common/collect/ImmutableSortedSetFauxverideShim.java
@@ -17,7 +17,6 @@
package com.google.common.collect;
import com.google.common.annotations.GwtIncompatible;
-import com.google.errorprone.annotations.DoNotCall;
/**
* "Overrides" the {@link ImmutableSet} static methods that lack {@link ImmutableSortedSet}
@@ -37,7 +36,6 @@
* @author Chris Povirk
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
abstract class ImmutableSortedSetFauxverideShim<E> extends ImmutableSet<E> {
/**
* Not supported. Use {@link ImmutableSortedSet#naturalOrder}, which offers better type-safety,
@@ -47,7 +45,6 @@
* @throws UnsupportedOperationException always
* @deprecated Use {@link ImmutableSortedSet#naturalOrder}, which offers better type-safety.
*/
- @DoNotCall("Use naturalOrder")
@Deprecated
public static <E> ImmutableSortedSet.Builder<E> builder() {
throw new UnsupportedOperationException();
@@ -60,7 +57,6 @@
* @throws UnsupportedOperationException always
* @deprecated Not supported by ImmutableSortedSet.
*/
- @DoNotCall("Use naturalOrder (which does not accept an expected size)")
@Deprecated
public static <E> ImmutableSortedSet.Builder<E> builderWithExpectedSize(int expectedSize) {
throw new UnsupportedOperationException();
@@ -75,7 +71,6 @@
* @deprecated <b>Pass a parameter of type {@code Comparable} to use {@link
* ImmutableSortedSet#of(Comparable)}.</b>
*/
- @DoNotCall("Pass a parameter of type Comparable")
@Deprecated
public static <E> ImmutableSortedSet<E> of(E element) {
throw new UnsupportedOperationException();
@@ -90,7 +85,6 @@
* @deprecated <b>Pass the parameters of type {@code Comparable} to use {@link
* ImmutableSortedSet#of(Comparable, Comparable)}.</b>
*/
- @DoNotCall("Pass parameters of type Comparable")
@Deprecated
public static <E> ImmutableSortedSet<E> of(E e1, E e2) {
throw new UnsupportedOperationException();
@@ -105,7 +99,6 @@
* @deprecated <b>Pass the parameters of type {@code Comparable} to use {@link
* ImmutableSortedSet#of(Comparable, Comparable, Comparable)}.</b>
*/
- @DoNotCall("Pass parameters of type Comparable")
@Deprecated
public static <E> ImmutableSortedSet<E> of(E e1, E e2, E e3) {
throw new UnsupportedOperationException();
@@ -120,7 +113,6 @@
* @deprecated <b>Pass the parameters of type {@code Comparable} to use {@link
* ImmutableSortedSet#of(Comparable, Comparable, Comparable, Comparable)}. </b>
*/
- @DoNotCall("Pass parameters of type Comparable")
@Deprecated
public static <E> ImmutableSortedSet<E> of(E e1, E e2, E e3, E e4) {
throw new UnsupportedOperationException();
@@ -135,7 +127,6 @@
* @deprecated <b>Pass the parameters of type {@code Comparable} to use {@link
* ImmutableSortedSet#of( Comparable, Comparable, Comparable, Comparable, Comparable)}. </b>
*/
- @DoNotCall("Pass parameters of type Comparable")
@Deprecated
public static <E> ImmutableSortedSet<E> of(E e1, E e2, E e3, E e4, E e5) {
throw new UnsupportedOperationException();
@@ -151,7 +142,6 @@
* ImmutableSortedSet#of(Comparable, Comparable, Comparable, Comparable, Comparable,
* Comparable, Comparable...)}. </b>
*/
- @DoNotCall("Pass parameters of type Comparable")
@Deprecated
public static <E> ImmutableSortedSet<E> of(E e1, E e2, E e3, E e4, E e5, E e6, E... remaining) {
throw new UnsupportedOperationException();
@@ -166,7 +156,6 @@
* @deprecated <b>Pass parameters of type {@code Comparable} to use {@link
* ImmutableSortedSet#copyOf(Comparable[])}.</b>
*/
- @DoNotCall("Pass parameters of type Comparable")
@Deprecated
public static <E> ImmutableSortedSet<E> copyOf(E[] elements) {
throw new UnsupportedOperationException();
diff --git a/android/guava/src/com/google/common/collect/ImmutableTable.java b/android/guava/src/com/google/common/collect/ImmutableTable.java
index 9dcb50c..a833423 100644
--- a/android/guava/src/com/google/common/collect/ImmutableTable.java
+++ b/android/guava/src/com/google/common/collect/ImmutableTable.java
@@ -21,14 +21,13 @@
import com.google.common.annotations.GwtCompatible;
import com.google.common.base.MoreObjects;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
-import com.google.errorprone.annotations.DoNotCall;
import com.google.errorprone.annotations.DoNotMock;
import java.io.Serializable;
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* A {@link Table} whose contents will never change, with many other important properties detailed
@@ -41,15 +40,9 @@
* @since 11.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
public abstract class ImmutableTable<R, C, V> extends AbstractTable<R, C, V>
implements Serializable {
-
- /**
- * Returns an empty immutable table.
- *
- * <p><b>Performance note:</b> the instance returned is a singleton.
- */
+ /** Returns an empty immutable table. */
@SuppressWarnings("unchecked")
public static <R, C, V> ImmutableTable<R, C, V> of() {
return (ImmutableTable<R, C, V>) SparseImmutableTable.EMPTY;
@@ -84,7 +77,7 @@
}
}
- static <R, C, V> ImmutableTable<R, C, V> copyOf(
+ private static <R, C, V> ImmutableTable<R, C, V> copyOf(
Iterable<? extends Cell<? extends R, ? extends C, ? extends V>> cells) {
ImmutableTable.Builder<R, C, V> builder = ImmutableTable.builder();
for (Cell<? extends R, ? extends C, ? extends V> cell : cells) {
@@ -122,7 +115,7 @@
* .put(1, 'A', "foo")
* .put(1, 'B', "bar")
* .put(2, 'A', "baz")
- * .buildOrThrow();
+ * .build();
* }</pre>
*
* <p>By default, the order in which cells are added to the builder determines the iteration
@@ -133,16 +126,16 @@
* <p>For empty or single-cell immutable tables, {@link #of()} and {@link #of(Object, Object,
* Object)} are even more convenient.
*
- * <p>Builder instances can be reused - it is safe to call {@link #buildOrThrow} multiple times to
- * build multiple tables in series. Each table is a superset of the tables created before it.
+ * <p>Builder instances can be reused - it is safe to call {@link #build} multiple times to build
+ * multiple tables in series. Each table is a superset of the tables created before it.
*
* @since 11.0
*/
@DoNotMock
public static final class Builder<R, C, V> {
private final List<Cell<R, C, V>> cells = Lists.newArrayList();
- @CheckForNull private Comparator<? super R> rowComparator;
- @CheckForNull private Comparator<? super C> columnComparator;
+ @NullableDecl private Comparator<? super R> rowComparator;
+ @NullableDecl private Comparator<? super C> columnComparator;
/**
* Creates a new builder. The returned builder is equivalent to the builder generated by {@link
@@ -207,33 +200,12 @@
return this;
}
- @CanIgnoreReturnValue
- Builder<R, C, V> combine(Builder<R, C, V> other) {
- this.cells.addAll(other.cells);
- return this;
- }
-
/**
* Returns a newly-created immutable table.
*
- * <p>Prefer the equivalent method {@link #buildOrThrow()} to make it explicit that the method
- * will throw an exception if there are duplicate key pairs. The {@code build()} method will
- * soon be deprecated.
- *
* @throws IllegalArgumentException if duplicate key pairs were added
*/
public ImmutableTable<R, C, V> build() {
- return buildOrThrow();
- }
-
- /**
- * Returns a newly-created immutable table, or throws an exception if duplicate key pairs were
- * added.
- *
- * @throws IllegalArgumentException if duplicate key pairs were added
- * @since 31.0
- */
- public ImmutableTable<R, C, V> buildOrThrow() {
int size = cells.size();
switch (size) {
case 0:
@@ -327,12 +299,12 @@
public abstract ImmutableMap<R, Map<C, V>> rowMap();
@Override
- public boolean contains(@CheckForNull Object rowKey, @CheckForNull Object columnKey) {
+ public boolean contains(@NullableDecl Object rowKey, @NullableDecl Object columnKey) {
return get(rowKey, columnKey) != null;
}
@Override
- public boolean containsValue(@CheckForNull Object value) {
+ public boolean containsValue(@NullableDecl Object value) {
return values().contains(value);
}
@@ -344,7 +316,6 @@
*/
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
public final void clear() {
throw new UnsupportedOperationException();
}
@@ -358,8 +329,6 @@
@CanIgnoreReturnValue
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
- @CheckForNull
public final V put(R rowKey, C columnKey, V value) {
throw new UnsupportedOperationException();
}
@@ -372,7 +341,6 @@
*/
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
public final void putAll(Table<? extends R, ? extends C, ? extends V> table) {
throw new UnsupportedOperationException();
}
@@ -386,9 +354,7 @@
@CanIgnoreReturnValue
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
- @CheckForNull
- public final V remove(@CheckForNull Object rowKey, @CheckForNull Object columnKey) {
+ public final V remove(Object rowKey, Object columnKey) {
throw new UnsupportedOperationException();
}
diff --git a/android/guava/src/com/google/common/collect/IndexedImmutableSet.java b/android/guava/src/com/google/common/collect/IndexedImmutableSet.java
index 25aae94..a31d3b2 100644
--- a/android/guava/src/com/google/common/collect/IndexedImmutableSet.java
+++ b/android/guava/src/com/google/common/collect/IndexedImmutableSet.java
@@ -18,10 +18,8 @@
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.GwtIncompatible;
-import org.checkerframework.checker.nullness.qual.Nullable;
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
abstract class IndexedImmutableSet<E> extends ImmutableSet<E> {
abstract E get(int index);
@@ -32,7 +30,7 @@
@Override
@GwtIncompatible
- int copyIntoArray(@Nullable Object[] dst, int offset) {
+ int copyIntoArray(Object[] dst, int offset) {
return asList().copyIntoArray(dst, offset);
}
diff --git a/android/guava/src/com/google/common/collect/Interner.java b/android/guava/src/com/google/common/collect/Interner.java
index bfc2035..310bfca 100644
--- a/android/guava/src/com/google/common/collect/Interner.java
+++ b/android/guava/src/com/google/common/collect/Interner.java
@@ -16,6 +16,7 @@
package com.google.common.collect;
+import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtIncompatible;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import com.google.errorprone.annotations.DoNotMock;
@@ -31,9 +32,9 @@
* @author Kevin Bourrillion
* @since 3.0
*/
+@Beta
@DoNotMock("Use Interners.new*Interner")
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public interface Interner<E> {
/**
* Chooses and returns the representative instance for any of a collection of instances that are
diff --git a/android/guava/src/com/google/common/collect/Interners.java b/android/guava/src/com/google/common/collect/Interners.java
index a3ae374..061a1cf 100644
--- a/android/guava/src/com/google/common/collect/Interners.java
+++ b/android/guava/src/com/google/common/collect/Interners.java
@@ -16,13 +16,13 @@
import static com.google.common.base.Preconditions.checkNotNull;
+import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtIncompatible;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Equivalence;
import com.google.common.base.Function;
import com.google.common.collect.MapMaker.Dummy;
import com.google.common.collect.MapMakerInternalMap.InternalEntry;
-import javax.annotation.CheckForNull;
/**
* Contains static methods pertaining to instances of {@link Interner}.
@@ -30,8 +30,8 @@
* @author Kevin Bourrillion
* @since 3.0
*/
+@Beta
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public final class Interners {
private Interners() {}
@@ -124,15 +124,11 @@
public E intern(E sample) {
while (true) {
// trying to read the canonical...
- @SuppressWarnings("rawtypes") // using raw types to avoid a bug in our nullness checker :(
- InternalEntry entry = map.getEntry(sample);
+ InternalEntry<E, Dummy, ?> entry = map.getEntry(sample);
if (entry != null) {
- Object canonical = entry.getKey();
+ E canonical = entry.getKey();
if (canonical != null) { // only matters if weak/soft keys are used
- // The compiler would know this is safe if not for our use of raw types (see above).
- @SuppressWarnings("unchecked")
- E result = (E) canonical;
- return result;
+ return canonical;
}
}
@@ -180,7 +176,7 @@
}
@Override
- public boolean equals(@CheckForNull Object other) {
+ public boolean equals(Object other) {
if (other instanceof InternerFunction) {
InternerFunction<?> that = (InternerFunction<?>) other;
return interner.equals(that.interner);
diff --git a/android/guava/src/com/google/common/collect/Iterables.java b/android/guava/src/com/google/common/collect/Iterables.java
index 2b4edb2..08df7f2 100644
--- a/android/guava/src/com/google/common/collect/Iterables.java
+++ b/android/guava/src/com/google/common/collect/Iterables.java
@@ -36,8 +36,7 @@
import java.util.Queue;
import java.util.RandomAccess;
import java.util.Set;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* An assortment of mainly legacy static utility methods that operate on or return objects of type
@@ -62,13 +61,11 @@
* @since 2.0
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
public final class Iterables {
private Iterables() {}
/** Returns an unmodifiable view of {@code iterable}. */
- public static <T extends @Nullable Object> Iterable<T> unmodifiableIterable(
- final Iterable<? extends T> iterable) {
+ public static <T> Iterable<T> unmodifiableIterable(final Iterable<? extends T> iterable) {
checkNotNull(iterable);
if (iterable instanceof UnmodifiableIterable || iterable instanceof ImmutableCollection) {
@SuppressWarnings("unchecked") // Since it's unmodifiable, the covariant cast is safe
@@ -89,8 +86,7 @@
return checkNotNull(iterable);
}
- private static final class UnmodifiableIterable<T extends @Nullable Object>
- extends FluentIterable<T> {
+ private static final class UnmodifiableIterable<T> extends FluentIterable<T> {
private final Iterable<? extends T> iterable;
private UnmodifiableIterable(Iterable<? extends T> iterable) {
@@ -122,9 +118,7 @@
* cases where {@link Collection#contains} might throw {@link NullPointerException} or {@link
* ClassCastException}.
*/
- // <? extends @Nullable Object> instead of <?> because of Kotlin b/189937072, discussed in Joiner.
- public static boolean contains(
- Iterable<? extends @Nullable Object> iterable, @CheckForNull Object element) {
+ public static boolean contains(Iterable<?> iterable, @NullableDecl Object element) {
if (iterable instanceof Collection) {
Collection<?> collection = (Collection<?>) iterable;
return Collections2.safeContains(collection, element);
@@ -180,15 +174,14 @@
* @since 2.0
*/
@CanIgnoreReturnValue
- public static <T extends @Nullable Object> boolean removeIf(
- Iterable<T> removeFrom, Predicate<? super T> predicate) {
+ public static <T> boolean removeIf(Iterable<T> removeFrom, Predicate<? super T> predicate) {
if (removeFrom instanceof RandomAccess && removeFrom instanceof List) {
return removeIfFromRandomAccessList((List<T>) removeFrom, checkNotNull(predicate));
}
return Iterators.removeIf(removeFrom.iterator(), predicate);
}
- private static <T extends @Nullable Object> boolean removeIfFromRandomAccessList(
+ private static <T> boolean removeIfFromRandomAccessList(
List<T> list, Predicate<? super T> predicate) {
// Note: Not all random access lists support set(). Additionally, it's possible
// for a list to reject setting an element, such as when the list does not permit
@@ -220,7 +213,7 @@
return from != to;
}
- private static <T extends @Nullable Object> void slowRemoveIfForRemainingElements(
+ private static <T> void slowRemoveIfForRemainingElements(
List<T> list, Predicate<? super T> predicate, int to, int from) {
// Here we know that:
// * (to < from) and that both are valid indices.
@@ -244,9 +237,8 @@
}
/** Removes and returns the first matching element, or returns {@code null} if there is none. */
- @CheckForNull
- static <T extends @Nullable Object> T removeFirstMatching(
- Iterable<T> removeFrom, Predicate<? super T> predicate) {
+ @NullableDecl
+ static <T> T removeFirstMatching(Iterable<T> removeFrom, Predicate<? super T> predicate) {
checkNotNull(predicate);
Iterator<T> iterator = removeFrom.iterator();
while (iterator.hasNext()) {
@@ -296,8 +288,7 @@
* @throws NoSuchElementException if the iterable is empty
* @throws IllegalArgumentException if the iterable contains multiple elements
*/
- @ParametricNullness
- public static <T extends @Nullable Object> T getOnlyElement(Iterable<T> iterable) {
+ public static <T> T getOnlyElement(Iterable<T> iterable) {
return Iterators.getOnlyElement(iterable.iterator());
}
@@ -310,9 +301,8 @@
*
* @throws IllegalArgumentException if the iterator contains multiple elements
*/
- @ParametricNullness
- public static <T extends @Nullable Object> T getOnlyElement(
- Iterable<? extends T> iterable, @ParametricNullness T defaultValue) {
+ @NullableDecl
+ public static <T> T getOnlyElement(Iterable<? extends T> iterable, @NullableDecl T defaultValue) {
return Iterators.getOnlyElement(iterable.iterator(), defaultValue);
}
@@ -324,16 +314,11 @@
* @return a newly-allocated array into which all the elements of the iterable have been copied
*/
@GwtIncompatible // Array.newInstance(Class, int)
- /*
- * If we could express Class<@Nonnull T>, we could generalize the type parameter to <T extends
- * @Nullable Object>, and then we could accept an Iterable<? extends T> and return a plain T[]
- * instead of a @Nullable T[].
- */
- public static <T> @Nullable T[] toArray(Iterable<? extends @Nullable T> iterable, Class<T> type) {
+ public static <T> T[] toArray(Iterable<? extends T> iterable, Class<T> type) {
return toArray(iterable, ObjectArrays.newArray(type, 0));
}
- static <T extends @Nullable Object> T[] toArray(Iterable<? extends T> iterable, T[] array) {
+ static <T> T[] toArray(Iterable<? extends T> iterable, T[] array) {
Collection<? extends T> collection = castOrCopyToCollection(iterable);
return collection.toArray(array);
}
@@ -344,7 +329,7 @@
* @param iterable the iterable to copy
* @return a newly-allocated array into which all the elements of the iterable have been copied
*/
- static @Nullable Object[] toArray(Iterable<?> iterable) {
+ static Object[] toArray(Iterable<?> iterable) {
return castOrCopyToCollection(iterable).toArray();
}
@@ -353,8 +338,7 @@
* returned. Otherwise, an {@link java.util.ArrayList} is created with the contents of the
* iterable in the same iteration order.
*/
- private static <E extends @Nullable Object> Collection<E> castOrCopyToCollection(
- Iterable<E> iterable) {
+ private static <E> Collection<E> castOrCopyToCollection(Iterable<E> iterable) {
return (iterable instanceof Collection)
? (Collection<E>) iterable
: Lists.newArrayList(iterable.iterator());
@@ -366,8 +350,7 @@
* @return {@code true} if {@code collection} was modified as a result of this operation.
*/
@CanIgnoreReturnValue
- public static <T extends @Nullable Object> boolean addAll(
- Collection<T> addTo, Iterable<? extends T> elementsToAdd) {
+ public static <T> boolean addAll(Collection<T> addTo, Iterable<? extends T> elementsToAdd) {
if (elementsToAdd instanceof Collection) {
Collection<? extends T> c = (Collection<? extends T>) elementsToAdd;
return addTo.addAll(c);
@@ -386,7 +369,7 @@
* @see java.util.Collections#frequency(Collection, Object) Collections.frequency(Collection,
* Object)
*/
- public static int frequency(Iterable<?> iterable, @CheckForNull Object element) {
+ public static int frequency(Iterable<?> iterable, @NullableDecl Object element) {
if ((iterable instanceof Multiset)) {
return ((Multiset<?>) iterable).count(element);
} else if ((iterable instanceof Set)) {
@@ -413,7 +396,7 @@
* <p><b>Java 8 users:</b> The {@code Stream} equivalent of this method is {@code
* Stream.generate(() -> iterable).flatMap(Streams::stream)}.
*/
- public static <T extends @Nullable Object> Iterable<T> cycle(final Iterable<T> iterable) {
+ public static <T> Iterable<T> cycle(final Iterable<T> iterable) {
checkNotNull(iterable);
return new FluentIterable<T>() {
@Override
@@ -449,7 +432,7 @@
* and use {@code Stream.generate(() -> collection).flatMap(Collection::stream)}.
*/
@SafeVarargs
- public static <T extends @Nullable Object> Iterable<T> cycle(T... elements) {
+ public static <T> Iterable<T> cycle(T... elements) {
return cycle(Lists.newArrayList(elements));
}
@@ -464,8 +447,7 @@
* <p><b>Java 8 users:</b> The {@code Stream} equivalent of this method is {@code Stream.concat(a,
* b)}.
*/
- public static <T extends @Nullable Object> Iterable<T> concat(
- Iterable<? extends T> a, Iterable<? extends T> b) {
+ public static <T> Iterable<T> concat(Iterable<? extends T> a, Iterable<? extends T> b) {
return FluentIterable.concat(a, b);
}
@@ -480,7 +462,7 @@
* <p><b>Java 8 users:</b> The {@code Stream} equivalent of this method is {@code
* Streams.concat(a, b, c)}.
*/
- public static <T extends @Nullable Object> Iterable<T> concat(
+ public static <T> Iterable<T> concat(
Iterable<? extends T> a, Iterable<? extends T> b, Iterable<? extends T> c) {
return FluentIterable.concat(a, b, c);
}
@@ -497,7 +479,7 @@
* <p><b>Java 8 users:</b> The {@code Stream} equivalent of this method is {@code
* Streams.concat(a, b, c, d)}.
*/
- public static <T extends @Nullable Object> Iterable<T> concat(
+ public static <T> Iterable<T> concat(
Iterable<? extends T> a,
Iterable<? extends T> b,
Iterable<? extends T> c,
@@ -519,7 +501,7 @@
* @throws NullPointerException if any of the provided iterables is null
*/
@SafeVarargs
- public static <T extends @Nullable Object> Iterable<T> concat(Iterable<? extends T>... inputs) {
+ public static <T> Iterable<T> concat(Iterable<? extends T>... inputs) {
return FluentIterable.concat(inputs);
}
@@ -535,8 +517,7 @@
* <p><b>Java 8 users:</b> The {@code Stream} equivalent of this method is {@code
* streamOfStreams.flatMap(s -> s)}.
*/
- public static <T extends @Nullable Object> Iterable<T> concat(
- Iterable<? extends Iterable<? extends T>> inputs) {
+ public static <T> Iterable<T> concat(Iterable<? extends Iterable<? extends T>> inputs) {
return FluentIterable.concat(inputs);
}
@@ -558,8 +539,7 @@
* into partitions
* @throws IllegalArgumentException if {@code size} is nonpositive
*/
- public static <T extends @Nullable Object> Iterable<List<T>> partition(
- final Iterable<T> iterable, final int size) {
+ public static <T> Iterable<List<T>> partition(final Iterable<T> iterable, final int size) {
checkNotNull(iterable);
checkArgument(size > 0);
return new FluentIterable<List<T>>() {
@@ -585,13 +565,12 @@
* into partitions (the final iterable may have trailing null elements)
* @throws IllegalArgumentException if {@code size} is nonpositive
*/
- public static <T extends @Nullable Object> Iterable<List<@Nullable T>> paddedPartition(
- final Iterable<T> iterable, final int size) {
+ public static <T> Iterable<List<T>> paddedPartition(final Iterable<T> iterable, final int size) {
checkNotNull(iterable);
checkArgument(size > 0);
- return new FluentIterable<List<@Nullable T>>() {
+ return new FluentIterable<List<T>>() {
@Override
- public Iterator<List<@Nullable T>> iterator() {
+ public Iterator<List<T>> iterator() {
return Iterators.paddedPartition(iterable.iterator(), size);
}
};
@@ -603,7 +582,7 @@
*
* <p><b>{@code Stream} equivalent:</b> {@link Stream#filter}.
*/
- public static <T extends @Nullable Object> Iterable<T> filter(
+ public static <T> Iterable<T> filter(
final Iterable<T> unfiltered, final Predicate<? super T> retainIfTrue) {
checkNotNull(unfiltered);
checkNotNull(retainIfTrue);
@@ -642,8 +621,7 @@
*
* <p><b>{@code Stream} equivalent:</b> {@link Stream#anyMatch}.
*/
- public static <T extends @Nullable Object> boolean any(
- Iterable<T> iterable, Predicate<? super T> predicate) {
+ public static <T> boolean any(Iterable<T> iterable, Predicate<? super T> predicate) {
return Iterators.any(iterable.iterator(), predicate);
}
@@ -653,8 +631,7 @@
*
* <p><b>{@code Stream} equivalent:</b> {@link Stream#allMatch}.
*/
- public static <T extends @Nullable Object> boolean all(
- Iterable<T> iterable, Predicate<? super T> predicate) {
+ public static <T> boolean all(Iterable<T> iterable, Predicate<? super T> predicate) {
return Iterators.all(iterable.iterator(), predicate);
}
@@ -667,9 +644,7 @@
*
* @throws NoSuchElementException if no element in {@code iterable} matches the given predicate
*/
- @ParametricNullness
- public static <T extends @Nullable Object> T find(
- Iterable<T> iterable, Predicate<? super T> predicate) {
+ public static <T> T find(Iterable<T> iterable, Predicate<? super T> predicate) {
return Iterators.find(iterable.iterator(), predicate);
}
@@ -683,26 +658,11 @@
*
* @since 7.0
*/
- // The signature we really want here is...
- //
- // <T extends @Nullable Object> @JointlyNullable T find(
- // Iterable<? extends T> iterable,
- // Predicate<? super T> predicate,
- // @JointlyNullable T defaultValue);
- //
- // ...where "@JointlyNullable" is similar to @PolyNull but slightly different:
- //
- // - @PolyNull means "@Nullable or @Nonnull"
- // (That would be unsound for an input Iterable<@Nullable Foo>. So, if we wanted to use
- // @PolyNull, we would have to restrict this method to non-null <T>. But it has users who pass
- // iterables with null elements.)
- //
- // - @JointlyNullable means "@Nullable or no annotation"
- @CheckForNull
- public static <T extends @Nullable Object> T find(
+ @NullableDecl
+ public static <T> T find(
Iterable<? extends T> iterable,
Predicate<? super T> predicate,
- @CheckForNull T defaultValue) {
+ @NullableDecl T defaultValue) {
return Iterators.find(iterable.iterator(), predicate, defaultValue);
}
@@ -731,8 +691,7 @@
*
* @since 2.0
*/
- public static <T extends @Nullable Object> int indexOf(
- Iterable<T> iterable, Predicate<? super T> predicate) {
+ public static <T> int indexOf(Iterable<T> iterable, Predicate<? super T> predicate) {
return Iterators.indexOf(iterable.iterator(), predicate);
}
@@ -749,7 +708,7 @@
*
* <p><b>{@code Stream} equivalent:</b> {@link Stream#map}
*/
- public static <F extends @Nullable Object, T extends @Nullable Object> Iterable<T> transform(
+ public static <F, T> Iterable<T> transform(
final Iterable<F> fromIterable, final Function<? super F, ? extends T> function) {
checkNotNull(fromIterable);
checkNotNull(function);
@@ -772,8 +731,7 @@
* @throws IndexOutOfBoundsException if {@code position} is negative or greater than or equal to
* the size of {@code iterable}
*/
- @ParametricNullness
- public static <T extends @Nullable Object> T get(Iterable<T> iterable, int position) {
+ public static <T> T get(Iterable<T> iterable, int position) {
checkNotNull(iterable);
return (iterable instanceof List)
? ((List<T>) iterable).get(position)
@@ -795,9 +753,9 @@
* @throws IndexOutOfBoundsException if {@code position} is negative
* @since 4.0
*/
- @ParametricNullness
- public static <T extends @Nullable Object> T get(
- Iterable<? extends T> iterable, int position, @ParametricNullness T defaultValue) {
+ @NullableDecl
+ public static <T> T get(
+ Iterable<? extends T> iterable, int position, @NullableDecl T defaultValue) {
checkNotNull(iterable);
Iterators.checkNonnegative(position);
if (iterable instanceof List) {
@@ -827,9 +785,8 @@
* @return the first element of {@code iterable} or the default value
* @since 7.0
*/
- @ParametricNullness
- public static <T extends @Nullable Object> T getFirst(
- Iterable<? extends T> iterable, @ParametricNullness T defaultValue) {
+ @NullableDecl
+ public static <T> T getFirst(Iterable<? extends T> iterable, @NullableDecl T defaultValue) {
return Iterators.getNext(iterable.iterator(), defaultValue);
}
@@ -842,8 +799,7 @@
* @return the last element of {@code iterable}
* @throws NoSuchElementException if the iterable is empty
*/
- @ParametricNullness
- public static <T extends @Nullable Object> T getLast(Iterable<T> iterable) {
+ public static <T> T getLast(Iterable<T> iterable) {
// TODO(kevinb): Support a concurrently modified collection?
if (iterable instanceof List) {
List<T> list = (List<T>) iterable;
@@ -867,9 +823,8 @@
* @return the last element of {@code iterable} or the default value
* @since 3.0
*/
- @ParametricNullness
- public static <T extends @Nullable Object> T getLast(
- Iterable<? extends T> iterable, @ParametricNullness T defaultValue) {
+ @NullableDecl
+ public static <T> T getLast(Iterable<? extends T> iterable, @NullableDecl T defaultValue) {
if (iterable instanceof Collection) {
Collection<? extends T> c = (Collection<? extends T>) iterable;
if (c.isEmpty()) {
@@ -882,8 +837,7 @@
return Iterators.getLast(iterable.iterator(), defaultValue);
}
- @ParametricNullness
- private static <T extends @Nullable Object> T getLastInNonemptyList(List<T> list) {
+ private static <T> T getLastInNonemptyList(List<T> list) {
return list.get(list.size() - 1);
}
@@ -906,8 +860,7 @@
*
* @since 3.0
*/
- public static <T extends @Nullable Object> Iterable<T> skip(
- final Iterable<T> iterable, final int numberToSkip) {
+ public static <T> Iterable<T> skip(final Iterable<T> iterable, final int numberToSkip) {
checkNotNull(iterable);
checkArgument(numberToSkip >= 0, "number to skip cannot be negative");
@@ -937,7 +890,6 @@
}
@Override
- @ParametricNullness
public T next() {
T result = iterator.next();
atStart = false; // not called if next() fails
@@ -967,8 +919,7 @@
* @throws IllegalArgumentException if {@code limitSize} is negative
* @since 3.0
*/
- public static <T extends @Nullable Object> Iterable<T> limit(
- final Iterable<T> iterable, final int limitSize) {
+ public static <T> Iterable<T> limit(final Iterable<T> iterable, final int limitSize) {
checkNotNull(iterable);
checkArgument(limitSize >= 0, "limit is negative");
return new FluentIterable<T>() {
@@ -995,8 +946,7 @@
* @see Iterators#consumingIterator(Iterator)
* @since 2.0
*/
- public static <T extends @Nullable Object> Iterable<T> consumingIterable(
- final Iterable<T> iterable) {
+ public static <T> Iterable<T> consumingIterable(final Iterable<T> iterable) {
checkNotNull(iterable);
return new FluentIterable<T>() {
@@ -1047,7 +997,7 @@
* @since 11.0
*/
@Beta
- public static <T extends @Nullable Object> Iterable<T> mergeSorted(
+ public static <T> Iterable<T> mergeSorted(
final Iterable<? extends Iterable<? extends T>> iterables,
final Comparator<? super T> comparator) {
checkNotNull(iterables, "iterables");
@@ -1065,8 +1015,7 @@
// TODO(user): Is this the best place for this? Move to fluent functions?
// Useful as a public method?
- static <T extends @Nullable Object>
- Function<Iterable<? extends T>, Iterator<? extends T>> toIterator() {
+ static <T> Function<Iterable<? extends T>, Iterator<? extends T>> toIterator() {
return new Function<Iterable<? extends T>, Iterator<? extends T>>() {
@Override
public Iterator<? extends T> apply(Iterable<? extends T> iterable) {
diff --git a/android/guava/src/com/google/common/collect/Iterators.java b/android/guava/src/com/google/common/collect/Iterators.java
index 5ea2da9..ac36b20 100644
--- a/android/guava/src/com/google/common/collect/Iterators.java
+++ b/android/guava/src/com/google/common/collect/Iterators.java
@@ -21,8 +21,6 @@
import static com.google.common.base.Preconditions.checkState;
import static com.google.common.base.Predicates.instanceOf;
import static com.google.common.collect.CollectPreconditions.checkRemove;
-import static com.google.common.collect.NullnessCasts.uncheckedCastNullableTToT;
-import static java.util.Objects.requireNonNull;
import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtCompatible;
@@ -47,8 +45,7 @@
import java.util.NoSuchElementException;
import java.util.PriorityQueue;
import java.util.Queue;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* This class contains static utility methods that operate on or return objects of type {@link
@@ -68,7 +65,6 @@
* @since 2.0
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
public final class Iterators {
private Iterators() {}
@@ -77,7 +73,7 @@
*
* <p>The {@link Iterable} equivalent of this method is {@link ImmutableSet#of()}.
*/
- static <T extends @Nullable Object> UnmodifiableIterator<T> emptyIterator() {
+ static <T> UnmodifiableIterator<T> emptyIterator() {
return emptyListIterator();
}
@@ -88,7 +84,7 @@
*/
// Casting to any type is safe since there are no actual elements.
@SuppressWarnings("unchecked")
- static <T extends @Nullable Object> UnmodifiableListIterator<T> emptyListIterator() {
+ static <T> UnmodifiableListIterator<T> emptyListIterator() {
return (UnmodifiableListIterator<T>) ArrayItr.EMPTY;
}
@@ -121,12 +117,12 @@
*/
// Casting to any type is safe since there are no actual elements.
@SuppressWarnings("unchecked")
- static <T extends @Nullable Object> Iterator<T> emptyModifiableIterator() {
+ static <T> Iterator<T> emptyModifiableIterator() {
return (Iterator<T>) EmptyModifiableIterator.INSTANCE;
}
/** Returns an unmodifiable view of {@code iterator}. */
- public static <T extends @Nullable Object> UnmodifiableIterator<T> unmodifiableIterator(
+ public static <T> UnmodifiableIterator<T> unmodifiableIterator(
final Iterator<? extends T> iterator) {
checkNotNull(iterator);
if (iterator instanceof UnmodifiableIterator) {
@@ -141,7 +137,6 @@
}
@Override
- @ParametricNullness
public T next() {
return iterator.next();
}
@@ -155,8 +150,7 @@
* @since 10.0
*/
@Deprecated
- public static <T extends @Nullable Object> UnmodifiableIterator<T> unmodifiableIterator(
- UnmodifiableIterator<T> iterator) {
+ public static <T> UnmodifiableIterator<T> unmodifiableIterator(UnmodifiableIterator<T> iterator) {
return checkNotNull(iterator);
}
@@ -174,7 +168,7 @@
}
/** Returns {@code true} if {@code iterator} contains {@code element}. */
- public static boolean contains(Iterator<?> iterator, @CheckForNull Object element) {
+ public static boolean contains(Iterator<?> iterator, @NullableDecl Object element) {
if (element == null) {
while (iterator.hasNext()) {
if (iterator.next() == null) {
@@ -222,8 +216,7 @@
* @since 2.0
*/
@CanIgnoreReturnValue
- public static <T extends @Nullable Object> boolean removeIf(
- Iterator<T> removeFrom, Predicate<? super T> predicate) {
+ public static <T> boolean removeIf(Iterator<T> removeFrom, Predicate<? super T> predicate) {
checkNotNull(predicate);
boolean modified = false;
while (removeFrom.hasNext()) {
@@ -304,8 +297,7 @@
* @throws IllegalArgumentException if the iterator contains multiple elements. The state of the
* iterator is unspecified.
*/
- @ParametricNullness
- public static <T extends @Nullable Object> T getOnlyElement(Iterator<T> iterator) {
+ public static <T> T getOnlyElement(Iterator<T> iterator) {
T first = iterator.next();
if (!iterator.hasNext()) {
return first;
@@ -330,9 +322,8 @@
* @throws IllegalArgumentException if the iterator contains multiple elements. The state of the
* iterator is unspecified.
*/
- @ParametricNullness
- public static <T extends @Nullable Object> T getOnlyElement(
- Iterator<? extends T> iterator, @ParametricNullness T defaultValue) {
+ @NullableDecl
+ public static <T> T getOnlyElement(Iterator<? extends T> iterator, @NullableDecl T defaultValue) {
return iterator.hasNext() ? getOnlyElement(iterator) : defaultValue;
}
@@ -345,9 +336,8 @@
* @return a newly-allocated array into which all the elements of the iterator have been copied
*/
@GwtIncompatible // Array.newInstance(Class, int)
- // For discussion of this signature, see the corresponding overload of *Iterables*.toArray.
- public static <T> @Nullable T[] toArray(Iterator<? extends @Nullable T> iterator, Class<T> type) {
- List<@Nullable T> list = Lists.newArrayList(iterator);
+ public static <T> T[] toArray(Iterator<? extends T> iterator, Class<T> type) {
+ List<T> list = Lists.newArrayList(iterator);
return Iterables.toArray(list, type);
}
@@ -358,8 +348,7 @@
* @return {@code true} if {@code collection} was modified as a result of this operation
*/
@CanIgnoreReturnValue
- public static <T extends @Nullable Object> boolean addAll(
- Collection<T> addTo, Iterator<? extends T> iterator) {
+ public static <T> boolean addAll(Collection<T> addTo, Iterator<? extends T> iterator) {
checkNotNull(addTo);
checkNotNull(iterator);
boolean wasModified = false;
@@ -375,7 +364,7 @@
*
* @see Collections#frequency
*/
- public static int frequency(Iterator<?> iterator, @CheckForNull Object element) {
+ public static int frequency(Iterator<?> iterator, @NullableDecl 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,
@@ -397,7 +386,7 @@
* should use an explicit {@code break} or be certain that you will eventually remove all the
* elements.
*/
- public static <T extends @Nullable Object> Iterator<T> cycle(final Iterable<T> iterable) {
+ public static <T> Iterator<T> cycle(final Iterable<T> iterable) {
checkNotNull(iterable);
return new Iterator<T>() {
Iterator<T> iterator = emptyModifiableIterator();
@@ -417,7 +406,6 @@
}
@Override
- @ParametricNullness
public T next() {
if (!iterator.hasNext()) {
iterator = iterable.iterator();
@@ -448,7 +436,7 @@
* elements.
*/
@SafeVarargs
- public static <T extends @Nullable Object> Iterator<T> cycle(T... elements) {
+ public static <T> Iterator<T> cycle(T... elements) {
return cycle(Lists.newArrayList(elements));
}
@@ -456,15 +444,10 @@
* Returns an Iterator that walks the specified array, nulling out elements behind it. This can
* avoid memory leaks when an element is no longer necessary.
*
- * <p>This method accepts an array with element type {@code @Nullable T}, but callers must pass an
- * array whose contents are initially non-null. The {@code @Nullable} annotation indicates that
- * this method will write nulls into the array during iteration.
- *
* <p>This is mainly just to avoid the intermediate ArrayDeque in ConsumingQueueIterator.
*/
- private static <I extends Iterator<?>> Iterator<I> consumingForArray(
- final @Nullable I... elements) {
- return new UnmodifiableIterator<I>() {
+ private static <T> Iterator<T> consumingForArray(final T... elements) {
+ return new UnmodifiableIterator<T>() {
int index = 0;
@Override
@@ -473,15 +456,11 @@
}
@Override
- public I next() {
+ public T next() {
if (!hasNext()) {
throw new NoSuchElementException();
}
- /*
- * requireNonNull is safe because our callers always pass non-null arguments. Each element
- * of the array becomes null only when we iterate past it and then clear it.
- */
- I result = requireNonNull(elements[index]);
+ T result = elements[index];
elements[index] = null;
index++;
return result;
@@ -497,8 +476,7 @@
* <p>The returned iterator supports {@code remove()} when the corresponding input iterator
* supports it.
*/
- public static <T extends @Nullable Object> Iterator<T> concat(
- Iterator<? extends T> a, Iterator<? extends T> b) {
+ public static <T> Iterator<T> concat(Iterator<? extends T> a, Iterator<? extends T> b) {
checkNotNull(a);
checkNotNull(b);
return concat(consumingForArray(a, b));
@@ -512,7 +490,7 @@
* <p>The returned iterator supports {@code remove()} when the corresponding input iterator
* supports it.
*/
- public static <T extends @Nullable Object> Iterator<T> concat(
+ public static <T> Iterator<T> concat(
Iterator<? extends T> a, Iterator<? extends T> b, Iterator<? extends T> c) {
checkNotNull(a);
checkNotNull(b);
@@ -529,7 +507,7 @@
* <p>The returned iterator supports {@code remove()} when the corresponding input iterator
* supports it.
*/
- public static <T extends @Nullable Object> Iterator<T> concat(
+ public static <T> Iterator<T> concat(
Iterator<? extends T> a,
Iterator<? extends T> b,
Iterator<? extends T> c,
@@ -551,7 +529,7 @@
*
* @throws NullPointerException if any of the provided iterators is null
*/
- public static <T extends @Nullable Object> Iterator<T> concat(Iterator<? extends T>... inputs) {
+ public static <T> Iterator<T> concat(Iterator<? extends T>... inputs) {
return concatNoDefensiveCopy(Arrays.copyOf(inputs, inputs.length));
}
@@ -564,14 +542,12 @@
* supports it. The methods of the returned iterator may throw {@code NullPointerException} if any
* of the input iterators is null.
*/
- public static <T extends @Nullable Object> Iterator<T> concat(
- Iterator<? extends Iterator<? extends T>> inputs) {
+ public static <T> Iterator<T> concat(Iterator<? extends Iterator<? extends T>> inputs) {
return new ConcatenatedIterator<T>(inputs);
}
/** Concats a varargs array of iterators without making a defensive copy of the array. */
- static <T extends @Nullable Object> Iterator<T> concatNoDefensiveCopy(
- Iterator<? extends T>... inputs) {
+ static <T> Iterator<T> concatNoDefensiveCopy(Iterator<? extends T>... inputs) {
for (Iterator<? extends T> input : checkNotNull(inputs)) {
checkNotNull(input);
}
@@ -592,8 +568,7 @@
* partitions
* @throws IllegalArgumentException if {@code size} is nonpositive
*/
- public static <T extends @Nullable Object> UnmodifiableIterator<List<T>> partition(
- Iterator<T> iterator, int size) {
+ public static <T> UnmodifiableIterator<List<T>> partition(Iterator<T> iterator, int size) {
return partitionImpl(iterator, size, false);
}
@@ -611,29 +586,26 @@
* partitions (the final iterable may have trailing null elements)
* @throws IllegalArgumentException if {@code size} is nonpositive
*/
- public static <T extends @Nullable Object>
- UnmodifiableIterator<List<@Nullable T>> paddedPartition(Iterator<T> iterator, int size) {
+ public static <T> UnmodifiableIterator<List<T>> paddedPartition(Iterator<T> iterator, int size) {
return partitionImpl(iterator, size, true);
}
- private static <T extends @Nullable Object> UnmodifiableIterator<List<@Nullable T>> partitionImpl(
+ private static <T> UnmodifiableIterator<List<T>> partitionImpl(
final Iterator<T> iterator, final int size, final boolean pad) {
checkNotNull(iterator);
checkArgument(size > 0);
- return new UnmodifiableIterator<List<@Nullable T>>() {
+ return new UnmodifiableIterator<List<T>>() {
@Override
public boolean hasNext() {
return iterator.hasNext();
}
@Override
- public List<@Nullable T> next() {
+ public List<T> next() {
if (!hasNext()) {
throw new NoSuchElementException();
}
- @SuppressWarnings("unchecked") // we only put Ts in it
- @Nullable
- T[] array = (@Nullable T[]) new Object[size];
+ Object[] array = new Object[size];
int count = 0;
for (; count < size && iterator.hasNext(); count++) {
array[count] = iterator.next();
@@ -642,13 +614,9 @@
array[i] = null; // for GWT
}
- List<@Nullable T> list = Collections.unmodifiableList(Arrays.asList(array));
- // TODO(b/192579700): Use a ternary once it no longer confuses our nullness checker.
- if (pad || count == size) {
- return list;
- } else {
- return list.subList(0, count);
- }
+ @SuppressWarnings("unchecked") // we only put Ts in it
+ List<T> list = Collections.unmodifiableList((List<T>) Arrays.asList(array));
+ return (pad || count == size) ? list : list.subList(0, count);
}
};
}
@@ -657,13 +625,12 @@
* Returns a view of {@code unfiltered} containing all elements that satisfy the input predicate
* {@code retainIfTrue}.
*/
- public static <T extends @Nullable Object> UnmodifiableIterator<T> filter(
+ public static <T> UnmodifiableIterator<T> filter(
final Iterator<T> unfiltered, final Predicate<? super T> retainIfTrue) {
checkNotNull(unfiltered);
checkNotNull(retainIfTrue);
return new AbstractIterator<T>() {
@Override
- @CheckForNull
protected T computeNext() {
while (unfiltered.hasNext()) {
T element = unfiltered.next();
@@ -690,8 +657,7 @@
* Returns {@code true} if one or more elements returned by {@code iterator} satisfy the given
* predicate.
*/
- public static <T extends @Nullable Object> boolean any(
- Iterator<T> iterator, Predicate<? super T> predicate) {
+ public static <T> boolean any(Iterator<T> iterator, Predicate<? super T> predicate) {
return indexOf(iterator, predicate) != -1;
}
@@ -699,8 +665,7 @@
* Returns {@code true} if every element returned by {@code iterator} satisfies the given
* predicate. If {@code iterator} is empty, {@code true} is returned.
*/
- public static <T extends @Nullable Object> boolean all(
- Iterator<T> iterator, Predicate<? super T> predicate) {
+ public static <T> boolean all(Iterator<T> iterator, Predicate<? super T> predicate) {
checkNotNull(predicate);
while (iterator.hasNext()) {
T element = iterator.next();
@@ -720,9 +685,7 @@
*
* @throws NoSuchElementException if no element in {@code iterator} matches the given predicate
*/
- @ParametricNullness
- public static <T extends @Nullable Object> T find(
- Iterator<T> iterator, Predicate<? super T> predicate) {
+ public static <T> T find(Iterator<T> iterator, Predicate<? super T> predicate) {
checkNotNull(iterator);
checkNotNull(predicate);
while (iterator.hasNext()) {
@@ -742,12 +705,11 @@
*
* @since 7.0
*/
- // For discussion of this signature, see the corresponding overload of *Iterables*.find.
- @CheckForNull
- public static <T extends @Nullable Object> T find(
+ @NullableDecl
+ public static <T> T find(
Iterator<? extends T> iterator,
Predicate<? super T> predicate,
- @CheckForNull T defaultValue) {
+ @NullableDecl T defaultValue) {
checkNotNull(iterator);
checkNotNull(predicate);
while (iterator.hasNext()) {
@@ -796,8 +758,7 @@
*
* @since 2.0
*/
- public static <T extends @Nullable Object> int indexOf(
- Iterator<T> iterator, Predicate<? super T> predicate) {
+ public static <T> int indexOf(Iterator<T> iterator, Predicate<? super T> predicate) {
checkNotNull(predicate, "predicate");
for (int i = 0; iterator.hasNext(); i++) {
T current = iterator.next();
@@ -816,13 +777,12 @@
* successful {@code remove()} call, {@code fromIterator} no longer contains the corresponding
* element.
*/
- public static <F extends @Nullable Object, T extends @Nullable Object> Iterator<T> transform(
+ public static <F, T> Iterator<T> transform(
final Iterator<F> fromIterator, final Function<? super F, ? extends T> function) {
checkNotNull(function);
return new TransformedIterator<F, T>(fromIterator) {
- @ParametricNullness
@Override
- T transform(@ParametricNullness F from) {
+ T transform(F from) {
return function.apply(from);
}
};
@@ -837,8 +797,7 @@
* @throws IndexOutOfBoundsException if {@code position} is negative or greater than or equal to
* the number of elements remaining in {@code iterator}
*/
- @ParametricNullness
- public static <T extends @Nullable Object> T get(Iterator<T> iterator, int position) {
+ public static <T> T get(Iterator<T> iterator, int position) {
checkNonnegative(position);
int skipped = advance(iterator, position);
if (!iterator.hasNext()) {
@@ -864,9 +823,9 @@
* @throws IndexOutOfBoundsException if {@code position} is negative
* @since 4.0
*/
- @ParametricNullness
- public static <T extends @Nullable Object> T get(
- Iterator<? extends T> iterator, int position, @ParametricNullness T defaultValue) {
+ @NullableDecl
+ public static <T> T get(
+ Iterator<? extends T> iterator, int position, @NullableDecl T defaultValue) {
checkNonnegative(position);
advance(iterator, position);
return getNext(iterator, defaultValue);
@@ -886,9 +845,8 @@
* @return the next element of {@code iterator} or the default value
* @since 7.0
*/
- @ParametricNullness
- public static <T extends @Nullable Object> T getNext(
- Iterator<? extends T> iterator, @ParametricNullness T defaultValue) {
+ @NullableDecl
+ public static <T> T getNext(Iterator<? extends T> iterator, @NullableDecl T defaultValue) {
return iterator.hasNext() ? iterator.next() : defaultValue;
}
@@ -898,8 +856,7 @@
* @return the last element of {@code iterator}
* @throws NoSuchElementException if the iterator is empty
*/
- @ParametricNullness
- public static <T extends @Nullable Object> T getLast(Iterator<T> iterator) {
+ public static <T> T getLast(Iterator<T> iterator) {
while (true) {
T current = iterator.next();
if (!iterator.hasNext()) {
@@ -916,9 +873,8 @@
* @return the last element of {@code iterator}
* @since 3.0
*/
- @ParametricNullness
- public static <T extends @Nullable Object> T getLast(
- Iterator<? extends T> iterator, @ParametricNullness T defaultValue) {
+ @NullableDecl
+ public static <T> T getLast(Iterator<? extends T> iterator, @NullableDecl T defaultValue) {
return iterator.hasNext() ? getLast(iterator) : defaultValue;
}
@@ -951,8 +907,7 @@
* @throws IllegalArgumentException if {@code limitSize} is negative
* @since 3.0
*/
- public static <T extends @Nullable Object> Iterator<T> limit(
- final Iterator<T> iterator, final int limitSize) {
+ public static <T> Iterator<T> limit(final Iterator<T> iterator, final int limitSize) {
checkNotNull(iterator);
checkArgument(limitSize >= 0, "limit is negative");
return new Iterator<T>() {
@@ -964,7 +919,6 @@
}
@Override
- @ParametricNullness
public T next() {
if (!hasNext()) {
throw new NoSuchElementException();
@@ -991,8 +945,7 @@
* @return an iterator that removes and returns elements from the supplied iterator
* @since 2.0
*/
- public static <T extends @Nullable Object> Iterator<T> consumingIterator(
- final Iterator<T> iterator) {
+ public static <T> Iterator<T> consumingIterator(final Iterator<T> iterator) {
checkNotNull(iterator);
return new UnmodifiableIterator<T>() {
@Override
@@ -1001,7 +954,6 @@
}
@Override
- @ParametricNullness
public T next() {
T next = iterator.next();
iterator.remove();
@@ -1019,8 +971,8 @@
* Deletes and returns the next value from the iterator, or returns {@code null} if there is no
* such value.
*/
- @CheckForNull
- static <T extends @Nullable Object> T pollNext(Iterator<T> iterator) {
+ @NullableDecl
+ static <T> T pollNext(Iterator<T> iterator) {
if (iterator.hasNext()) {
T result = iterator.next();
iterator.remove();
@@ -1052,7 +1004,7 @@
* {@link ImmutableList#copyOf(Object[])}}, or {@link ImmutableList#of}.
*/
@SafeVarargs
- public static <T extends @Nullable Object> UnmodifiableIterator<T> forArray(final T... array) {
+ public static <T> UnmodifiableIterator<T> forArray(final T... array) {
return forArray(array, 0, array.length, 0);
}
@@ -1063,7 +1015,7 @@
* <p>The {@code Iterable} equivalent of this method is {@code
* Arrays.asList(array).subList(offset, offset + length).listIterator(index)}.
*/
- static <T extends @Nullable Object> UnmodifiableListIterator<T> forArray(
+ static <T> UnmodifiableListIterator<T> forArray(
final T[] array, final int offset, int length, int index) {
checkArgument(length >= 0);
int end = offset + length;
@@ -1077,8 +1029,7 @@
return new ArrayItr<T>(array, offset, length, index);
}
- private static final class ArrayItr<T extends @Nullable Object>
- extends AbstractIndexedListIterator<T> {
+ private static final class ArrayItr<T> extends AbstractIndexedListIterator<T> {
static final UnmodifiableListIterator<Object> EMPTY = new ArrayItr<>(new Object[0], 0, 0, 0);
private final T[] array;
@@ -1091,7 +1042,6 @@
}
@Override
- @ParametricNullness
protected T get(int index) {
return array[offset + index];
}
@@ -1102,8 +1052,7 @@
*
* <p>The {@link Iterable} equivalent of this method is {@link Collections#singleton}.
*/
- public static <T extends @Nullable Object> UnmodifiableIterator<T> singletonIterator(
- @ParametricNullness final T value) {
+ public static <T> UnmodifiableIterator<T> singletonIterator(@NullableDecl final T value) {
return new UnmodifiableIterator<T>() {
boolean done;
@@ -1113,7 +1062,6 @@
}
@Override
- @ParametricNullness
public T next() {
if (done) {
throw new NoSuchElementException();
@@ -1134,8 +1082,7 @@
* <p><b>Java 9 users:</b> use {@code enumeration.asIterator()} instead, unless it is important to
* return an {@code UnmodifiableIterator} instead of a plain {@code Iterator}.
*/
- public static <T extends @Nullable Object> UnmodifiableIterator<T> forEnumeration(
- final Enumeration<T> enumeration) {
+ public static <T> UnmodifiableIterator<T> forEnumeration(final Enumeration<T> enumeration) {
checkNotNull(enumeration);
return new UnmodifiableIterator<T>() {
@Override
@@ -1144,7 +1091,6 @@
}
@Override
- @ParametricNullness
public T next() {
return enumeration.nextElement();
}
@@ -1157,8 +1103,7 @@
* <p>The {@code Iterable} equivalent of this method is either {@link Collections#enumeration} (if
* you have a {@link Collection}), or {@code Iterators.asEnumeration(collection.iterator())}.
*/
- public static <T extends @Nullable Object> Enumeration<T> asEnumeration(
- final Iterator<T> iterator) {
+ public static <T> Enumeration<T> asEnumeration(final Iterator<T> iterator) {
checkNotNull(iterator);
return new Enumeration<T>() {
@Override
@@ -1167,7 +1112,6 @@
}
@Override
- @ParametricNullness
public T nextElement() {
return iterator.next();
}
@@ -1175,11 +1119,11 @@
}
/** Implementation of PeekingIterator that avoids peeking unless necessary. */
- private static class PeekingImpl<E extends @Nullable Object> implements PeekingIterator<E> {
+ private static class PeekingImpl<E> implements PeekingIterator<E> {
private final Iterator<? extends E> iterator;
private boolean hasPeeked;
- @CheckForNull private E peekedElement;
+ @NullableDecl private E peekedElement;
public PeekingImpl(Iterator<? extends E> iterator) {
this.iterator = checkNotNull(iterator);
@@ -1191,13 +1135,11 @@
}
@Override
- @ParametricNullness
public E next() {
if (!hasPeeked) {
return iterator.next();
}
- // The cast is safe because of the hasPeeked check.
- E result = uncheckedCastNullableTToT(peekedElement);
+ E result = peekedElement;
hasPeeked = false;
peekedElement = null;
return result;
@@ -1210,14 +1152,12 @@
}
@Override
- @ParametricNullness
public E peek() {
if (!hasPeeked) {
peekedElement = iterator.next();
hasPeeked = true;
}
- // The cast is safe because of the hasPeeked check.
- return uncheckedCastNullableTToT(peekedElement);
+ return peekedElement;
}
}
@@ -1257,8 +1197,7 @@
* @return a peeking iterator backed by that iterator. Apart from the additional {@link
* PeekingIterator#peek()} method, this iterator behaves exactly the same as {@code iterator}.
*/
- public static <T extends @Nullable Object> PeekingIterator<T> peekingIterator(
- Iterator<? extends T> iterator) {
+ public static <T> PeekingIterator<T> peekingIterator(Iterator<? extends T> iterator) {
if (iterator instanceof PeekingImpl) {
// Safe to cast <? extends T> to <T> because PeekingImpl only uses T
// covariantly (and cannot be subclassed to add non-covariant uses).
@@ -1276,8 +1215,7 @@
* @since 10.0
*/
@Deprecated
- public static <T extends @Nullable Object> PeekingIterator<T> peekingIterator(
- PeekingIterator<T> iterator) {
+ public static <T> PeekingIterator<T> peekingIterator(PeekingIterator<T> iterator) {
return checkNotNull(iterator);
}
@@ -1294,7 +1232,7 @@
* @since 11.0
*/
@Beta
- public static <T extends @Nullable Object> UnmodifiableIterator<T> mergeSorted(
+ public static <T> UnmodifiableIterator<T> mergeSorted(
Iterable<? extends Iterator<? extends T>> iterators, Comparator<? super T> comparator) {
checkNotNull(iterators, "iterators");
checkNotNull(comparator, "comparator");
@@ -1311,7 +1249,7 @@
* iterators. (Retrieving all elements takes approximately O(N*log(M)) time, where N is the total
* number of elements.)
*/
- private static class MergingIterator<T extends @Nullable Object> extends UnmodifiableIterator<T> {
+ private static class MergingIterator<T> extends UnmodifiableIterator<T> {
final Queue<PeekingIterator<T>> queue;
public MergingIterator(
@@ -1342,7 +1280,6 @@
}
@Override
- @ParametricNullness
public T next() {
PeekingIterator<T> nextIter = queue.remove();
T next = nextIter.next();
@@ -1353,9 +1290,9 @@
}
}
- private static class ConcatenatedIterator<T extends @Nullable Object> implements Iterator<T> {
+ private static class ConcatenatedIterator<T> implements Iterator<T> {
/* The last iterator to return an element. Calls to remove() go to this iterator. */
- @CheckForNull private Iterator<? extends T> toRemove;
+ @NullableDecl private Iterator<? extends T> toRemove;
/* The iterator currently returning elements. */
private Iterator<? extends T> iterator;
@@ -1367,10 +1304,10 @@
* operation O(1).
*/
- @CheckForNull private Iterator<? extends Iterator<? extends T>> topMetaIterator;
+ private Iterator<? extends Iterator<? extends T>> topMetaIterator;
// Only becomes nonnull if we encounter nested concatenations.
- @CheckForNull private Deque<Iterator<? extends Iterator<? extends T>>> metaIterators;
+ @NullableDecl private Deque<Iterator<? extends Iterator<? extends T>>> metaIterators;
ConcatenatedIterator(Iterator<? extends Iterator<? extends T>> metaIterator) {
iterator = emptyIterator();
@@ -1378,7 +1315,7 @@
}
// Returns a nonempty meta-iterator or, if all meta-iterators are empty, null.
- @CheckForNull
+ @NullableDecl
private Iterator<? extends Iterator<? extends T>> getTopMetaIterator() {
while (topMetaIterator == null || !topMetaIterator.hasNext()) {
if (metaIterators != null && !metaIterators.isEmpty()) {
@@ -1429,7 +1366,6 @@
}
@Override
- @ParametricNullness
public T next() {
if (hasNext()) {
toRemove = iterator;
@@ -1441,16 +1377,14 @@
@Override
public void remove() {
- if (toRemove == null) {
- throw new IllegalStateException("no calls to next() since the last call to remove()");
- }
+ CollectPreconditions.checkRemove(toRemove != null);
toRemove.remove();
toRemove = null;
}
}
/** Used to avoid http://bugs.sun.com/view_bug.do?bug_id=6558557 */
- static <T extends @Nullable Object> ListIterator<T> cast(Iterator<T> iterator) {
+ static <T> ListIterator<T> cast(Iterator<T> iterator) {
return (ListIterator<T>) iterator;
}
}
diff --git a/android/guava/src/com/google/common/collect/LexicographicalOrdering.java b/android/guava/src/com/google/common/collect/LexicographicalOrdering.java
index 91fc7bf..0e6c196 100644
--- a/android/guava/src/com/google/common/collect/LexicographicalOrdering.java
+++ b/android/guava/src/com/google/common/collect/LexicographicalOrdering.java
@@ -20,14 +20,11 @@
import java.io.Serializable;
import java.util.Comparator;
import java.util.Iterator;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/** An ordering which sorts iterables by comparing corresponding elements pairwise. */
@GwtCompatible(serializable = true)
-@ElementTypesAreNonnullByDefault
-final class LexicographicalOrdering<T extends @Nullable Object> extends Ordering<Iterable<T>>
- implements Serializable {
+final class LexicographicalOrdering<T> extends Ordering<Iterable<T>> implements Serializable {
final Comparator<? super T> elementOrder;
LexicographicalOrdering(Comparator<? super T> elementOrder) {
@@ -54,7 +51,7 @@
}
@Override
- public boolean equals(@CheckForNull Object object) {
+ public boolean equals(@NullableDecl Object object) {
if (object == this) {
return true;
}
diff --git a/android/guava/src/com/google/common/collect/LinkedHashMultimap.java b/android/guava/src/com/google/common/collect/LinkedHashMultimap.java
index b0f1302..3616617 100644
--- a/android/guava/src/com/google/common/collect/LinkedHashMultimap.java
+++ b/android/guava/src/com/google/common/collect/LinkedHashMultimap.java
@@ -16,9 +16,8 @@
package com.google.common.collect;
-import static com.google.common.base.Preconditions.checkState;
import static com.google.common.collect.CollectPreconditions.checkNonnegative;
-import static java.util.Objects.requireNonNull;
+import static com.google.common.collect.CollectPreconditions.checkRemove;
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.GwtIncompatible;
@@ -37,8 +36,7 @@
import java.util.Map.Entry;
import java.util.NoSuchElementException;
import java.util.Set;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* Implementation of {@code Multimap} that does not allow duplicate key-value entries and that
@@ -67,10 +65,6 @@
* read operations will work correctly. To allow concurrent update operations, wrap your multimap
* with a call to {@link Multimaps#synchronizedSetMultimap}.
*
- * <p><b>Warning:</b> Do not modify either a key <i>or a value</i> of a {@code LinkedHashMultimap}
- * in a way that affects its {@link Object#equals} behavior. Undefined behavior and bugs will
- * result.
- *
* <p>See the Guava User Guide article on <a href=
* "https://github.com/google/guava/wiki/NewCollectionTypesExplained#multimap"> {@code
* Multimap}</a>.
@@ -80,13 +74,11 @@
* @since 2.0
*/
@GwtCompatible(serializable = true, emulated = true)
-@ElementTypesAreNonnullByDefault
-public final class LinkedHashMultimap<K extends @Nullable Object, V extends @Nullable Object>
+public final class LinkedHashMultimap<K, V>
extends LinkedHashMultimapGwtSerializationDependencies<K, V> {
/** Creates a new, empty {@code LinkedHashMultimap} with the default initial capacities. */
- public static <K extends @Nullable Object, V extends @Nullable Object>
- LinkedHashMultimap<K, V> create() {
+ public static <K, V> LinkedHashMultimap<K, V> create() {
return new LinkedHashMultimap<>(DEFAULT_KEY_CAPACITY, DEFAULT_VALUE_SET_CAPACITY);
}
@@ -99,8 +91,7 @@
* @throws IllegalArgumentException if {@code expectedKeys} or {@code expectedValuesPerKey} is
* negative
*/
- public static <K extends @Nullable Object, V extends @Nullable Object>
- LinkedHashMultimap<K, V> create(int expectedKeys, int expectedValuesPerKey) {
+ public static <K, V> LinkedHashMultimap<K, V> create(int expectedKeys, int expectedValuesPerKey) {
return new LinkedHashMultimap<>(
Maps.capacity(expectedKeys), Maps.capacity(expectedValuesPerKey));
}
@@ -113,14 +104,14 @@
*
* @param multimap the multimap whose contents are copied to this multimap
*/
- public static <K extends @Nullable Object, V extends @Nullable Object>
- LinkedHashMultimap<K, V> create(Multimap<? extends K, ? extends V> multimap) {
+ public static <K, V> LinkedHashMultimap<K, V> create(
+ Multimap<? extends K, ? extends V> multimap) {
LinkedHashMultimap<K, V> result = create(multimap.keySet().size(), DEFAULT_VALUE_SET_CAPACITY);
result.putAll(multimap);
return result;
}
- private interface ValueSetLink<K extends @Nullable Object, V extends @Nullable Object> {
+ private interface ValueSetLink<K, V> {
ValueSetLink<K, V> getPredecessorInValueSet();
ValueSetLink<K, V> getSuccessorInValueSet();
@@ -130,25 +121,21 @@
void setSuccessorInValueSet(ValueSetLink<K, V> entry);
}
- private static <K extends @Nullable Object, V extends @Nullable Object> void succeedsInValueSet(
- ValueSetLink<K, V> pred, ValueSetLink<K, V> succ) {
+ private static <K, V> void succeedsInValueSet(ValueSetLink<K, V> pred, ValueSetLink<K, V> succ) {
pred.setSuccessorInValueSet(succ);
succ.setPredecessorInValueSet(pred);
}
- private static <K extends @Nullable Object, V extends @Nullable Object> void succeedsInMultimap(
- ValueEntry<K, V> pred, ValueEntry<K, V> succ) {
+ private static <K, V> void succeedsInMultimap(ValueEntry<K, V> pred, ValueEntry<K, V> succ) {
pred.setSuccessorInMultimap(succ);
succ.setPredecessorInMultimap(pred);
}
- private static <K extends @Nullable Object, V extends @Nullable Object> void deleteFromValueSet(
- ValueSetLink<K, V> entry) {
+ private static <K, V> void deleteFromValueSet(ValueSetLink<K, V> entry) {
succeedsInValueSet(entry.getPredecessorInValueSet(), entry.getSuccessorInValueSet());
}
- private static <K extends @Nullable Object, V extends @Nullable Object> void deleteFromMultimap(
- ValueEntry<K, V> entry) {
+ private static <K, V> void deleteFromMultimap(ValueEntry<K, V> entry) {
succeedsInMultimap(entry.getPredecessorInMultimap(), entry.getSuccessorInMultimap());
}
@@ -159,69 +146,39 @@
* whole.
*/
@VisibleForTesting
- static final class ValueEntry<K extends @Nullable Object, V extends @Nullable Object>
- extends ImmutableEntry<K, V> implements ValueSetLink<K, V> {
+ static final class ValueEntry<K, V> extends ImmutableEntry<K, V> implements ValueSetLink<K, V> {
final int smearedValueHash;
- @CheckForNull ValueEntry<K, V> nextInValueBucket;
- /*
- * The *InValueSet and *InMultimap fields below are null after construction, but we almost
- * always call succeedsIn*() to initialize them immediately thereafter.
- *
- * The exception is the *InValueSet fields of multimapHeaderEntry, which are never set. (That
- * works out fine as long as we continue to be careful not to try delete them or iterate past
- * them.)
- *
- * We could consider "lying" and omitting @CheckNotNull from all these fields. Normally, I'm not
- * a fan of that: What if we someday implement (presumably to be enabled during tests only)
- * bytecode rewriting that checks for any null value that passes through an API with a
- * known-non-null type? But that particular problem might not arise here, since we're not
- * actually reading from the fields in any case in which they might be null (as proven by the
- * requireNonNull checks below). Plus, we're *already* lying here, since newHeader passes a null
- * key and value, which we pass to the superconstructor, even though the key and value type for
- * a given entry might not include null. The right fix for the header problems is probably to
- * define a separate MultimapLink interface with a separate "header" implementation, which
- * hopefully could avoid implementing Entry or ValueSetLink at all. (But note that that approach
- * requires us to define extra classes -- unfortunate under Android.) *Then* we could consider
- * lying about the fields below on the grounds that we always initialize them just after the
- * constructor -- an example of the kind of lying that our hypotheticaly bytecode rewriter would
- * already have to deal with, thanks to DI frameworks that perform field and method injection,
- * frameworks like Android that define post-construct hooks like Activity.onCreate, etc.
- */
+ @NullableDecl ValueEntry<K, V> nextInValueBucket;
- @CheckForNull ValueSetLink<K, V> predecessorInValueSet;
- @CheckForNull ValueSetLink<K, V> successorInValueSet;
+ @NullableDecl ValueSetLink<K, V> predecessorInValueSet;
+ @NullableDecl ValueSetLink<K, V> successorInValueSet;
- @CheckForNull ValueEntry<K, V> predecessorInMultimap;
- @CheckForNull ValueEntry<K, V> successorInMultimap;
+ @NullableDecl ValueEntry<K, V> predecessorInMultimap;
+ @NullableDecl ValueEntry<K, V> successorInMultimap;
ValueEntry(
- @ParametricNullness K key,
- @ParametricNullness V value,
+ @NullableDecl K key,
+ @NullableDecl V value,
int smearedValueHash,
- @CheckForNull ValueEntry<K, V> nextInValueBucket) {
+ @NullableDecl ValueEntry<K, V> nextInValueBucket) {
super(key, value);
this.smearedValueHash = smearedValueHash;
this.nextInValueBucket = nextInValueBucket;
}
- @SuppressWarnings("nullness") // see the comment on the class fields, especially about newHeader
- static <K extends @Nullable Object, V extends @Nullable Object> ValueEntry<K, V> newHeader() {
- return new ValueEntry<>(null, null, 0, null);
- }
-
- boolean matchesValue(@CheckForNull Object v, int smearedVHash) {
+ boolean matchesValue(@NullableDecl Object v, int smearedVHash) {
return smearedValueHash == smearedVHash && Objects.equal(getValue(), v);
}
@Override
public ValueSetLink<K, V> getPredecessorInValueSet() {
- return requireNonNull(predecessorInValueSet); // see the comment on the class fields
+ return predecessorInValueSet;
}
@Override
public ValueSetLink<K, V> getSuccessorInValueSet() {
- return requireNonNull(successorInValueSet); // see the comment on the class fields
+ return successorInValueSet;
}
@Override
@@ -235,11 +192,11 @@
}
public ValueEntry<K, V> getPredecessorInMultimap() {
- return requireNonNull(predecessorInMultimap); // see the comment on the class fields
+ return predecessorInMultimap;
}
public ValueEntry<K, V> getSuccessorInMultimap() {
- return requireNonNull(successorInMultimap); // see the comment on the class fields
+ return successorInMultimap;
}
public void setSuccessorInMultimap(ValueEntry<K, V> multimapSuccessor) {
@@ -263,7 +220,7 @@
checkNonnegative(valueSetCapacity, "expectedValuesPerKey");
this.valueSetCapacity = valueSetCapacity;
- this.multimapHeaderEntry = ValueEntry.newHeader();
+ this.multimapHeaderEntry = new ValueEntry<>(null, null, 0, null);
succeedsInMultimap(multimapHeaderEntry, multimapHeaderEntry);
}
@@ -289,7 +246,7 @@
* @return a new decorated set containing a collection of values for one key
*/
@Override
- Collection<V> createCollection(@ParametricNullness K key) {
+ Collection<V> createCollection(K key) {
return new ValueSet(key, valueSetCapacity);
}
@@ -302,7 +259,7 @@
*/
@CanIgnoreReturnValue
@Override
- public Set<V> replaceValues(@ParametricNullness K key, Iterable<? extends V> values) {
+ public Set<V> replaceValues(@NullableDecl K key, Iterable<? extends V> values) {
return super.replaceValues(key, values);
}
@@ -357,8 +314,8 @@
* consumption.
*/
- @ParametricNullness private final K key;
- @VisibleForTesting @Nullable ValueEntry<K, V>[] hashTable;
+ private final K key;
+ @VisibleForTesting ValueEntry<K, V>[] hashTable;
private int size = 0;
private int modCount = 0;
@@ -367,16 +324,15 @@
private ValueSetLink<K, V> firstEntry;
private ValueSetLink<K, V> lastEntry;
- ValueSet(@ParametricNullness K key, int expectedValues) {
+ ValueSet(K key, int expectedValues) {
this.key = key;
this.firstEntry = this;
this.lastEntry = this;
// Round expected values up to a power of 2 to get the table size.
int tableSize = Hashing.closedTableSize(expectedValues, VALUE_SET_LOAD_FACTOR);
- @SuppressWarnings({"rawtypes", "unchecked"})
- @Nullable
- ValueEntry<K, V>[] hashTable = new @Nullable ValueEntry[tableSize];
+ @SuppressWarnings("unchecked")
+ ValueEntry<K, V>[] hashTable = new ValueEntry[tableSize];
this.hashTable = hashTable;
}
@@ -408,7 +364,7 @@
public Iterator<V> iterator() {
return new Iterator<V>() {
ValueSetLink<K, V> nextEntry = firstEntry;
- @CheckForNull ValueEntry<K, V> toRemove;
+ @NullableDecl ValueEntry<K, V> toRemove;
int expectedModCount = modCount;
private void checkForComodification() {
@@ -424,7 +380,6 @@
}
@Override
- @ParametricNullness
public V next() {
if (!hasNext()) {
throw new NoSuchElementException();
@@ -439,7 +394,7 @@
@Override
public void remove() {
checkForComodification();
- checkState(toRemove != null, "no calls to next() since the last call to remove()");
+ checkRemove(toRemove != null);
ValueSet.this.remove(toRemove.getValue());
expectedModCount = modCount;
toRemove = null;
@@ -453,7 +408,7 @@
}
@Override
- public boolean contains(@CheckForNull Object o) {
+ public boolean contains(@NullableDecl Object o) {
int smearedHash = Hashing.smearedHash(o);
for (ValueEntry<K, V> entry = hashTable[smearedHash & mask()];
entry != null;
@@ -466,7 +421,7 @@
}
@Override
- public boolean add(@ParametricNullness V value) {
+ public boolean add(@NullableDecl V value) {
int smearedHash = Hashing.smearedHash(value);
int bucket = smearedHash & mask();
ValueEntry<K, V> rowHead = hashTable[bucket];
@@ -507,7 +462,7 @@
@CanIgnoreReturnValue
@Override
- public boolean remove(@CheckForNull Object o) {
+ public boolean remove(@NullableDecl Object o) {
int smearedHash = Hashing.smearedHash(o);
int bucket = smearedHash & mask();
ValueEntry<K, V> prev = null;
@@ -549,8 +504,8 @@
@Override
Iterator<Entry<K, V>> entryIterator() {
return new Iterator<Entry<K, V>>() {
- ValueEntry<K, V> nextEntry = multimapHeaderEntry.getSuccessorInMultimap();
- @CheckForNull ValueEntry<K, V> toRemove;
+ ValueEntry<K, V> nextEntry = multimapHeaderEntry.successorInMultimap;
+ @NullableDecl ValueEntry<K, V> toRemove;
@Override
public boolean hasNext() {
@@ -564,13 +519,13 @@
}
ValueEntry<K, V> result = nextEntry;
toRemove = result;
- nextEntry = nextEntry.getSuccessorInMultimap();
+ nextEntry = nextEntry.successorInMultimap;
return result;
}
@Override
public void remove() {
- checkState(toRemove != null, "no calls to next() since the last call to remove()");
+ checkRemove(toRemove != null);
LinkedHashMultimap.this.remove(toRemove.getKey(), toRemove.getValue());
toRemove = null;
}
@@ -609,7 +564,7 @@
@GwtIncompatible // java.io.ObjectInputStream
private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {
stream.defaultReadObject();
- multimapHeaderEntry = ValueEntry.newHeader();
+ multimapHeaderEntry = new ValueEntry<>(null, null, 0, null);
succeedsInMultimap(multimapHeaderEntry, multimapHeaderEntry);
valueSetCapacity = DEFAULT_VALUE_SET_CAPACITY;
int distinctKeys = stream.readInt();
@@ -625,11 +580,7 @@
K key = (K) stream.readObject();
@SuppressWarnings("unchecked")
V value = (V) stream.readObject();
- /*
- * requireNonNull is safe for a properly serialized multimap: We've already inserted a
- * collection for each key that we expect.
- */
- requireNonNull(map.get(key)).add(value);
+ map.get(key).add(value);
}
setMap(map);
}
diff --git a/android/guava/src/com/google/common/collect/LinkedHashMultiset.java b/android/guava/src/com/google/common/collect/LinkedHashMultiset.java
index 9630786..6f95d4d 100644
--- a/android/guava/src/com/google/common/collect/LinkedHashMultiset.java
+++ b/android/guava/src/com/google/common/collect/LinkedHashMultiset.java
@@ -17,7 +17,6 @@
package com.google.common.collect;
import com.google.common.annotations.GwtCompatible;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* A {@code Multiset} implementation with predictable iteration order. Its iterator orders elements
@@ -35,12 +34,10 @@
* @since 2.0
*/
@GwtCompatible(serializable = true, emulated = true)
-@ElementTypesAreNonnullByDefault
-public final class LinkedHashMultiset<E extends @Nullable Object>
- extends AbstractMapBasedMultiset<E> {
+public final class LinkedHashMultiset<E> extends AbstractMapBasedMultiset<E> {
/** Creates a new, empty {@code LinkedHashMultiset} using the default initial capacity. */
- public static <E extends @Nullable Object> LinkedHashMultiset<E> create() {
+ public static <E> LinkedHashMultiset<E> create() {
return create(ObjectCountHashMap.DEFAULT_SIZE);
}
@@ -51,7 +48,7 @@
* @param distinctElements the expected number of distinct elements
* @throws IllegalArgumentException if {@code distinctElements} is negative
*/
- public static <E extends @Nullable Object> LinkedHashMultiset<E> create(int distinctElements) {
+ public static <E> LinkedHashMultiset<E> create(int distinctElements) {
return new LinkedHashMultiset<E>(distinctElements);
}
@@ -62,8 +59,7 @@
*
* @param elements the elements that the multiset should contain
*/
- public static <E extends @Nullable Object> LinkedHashMultiset<E> create(
- Iterable<? extends E> elements) {
+ public static <E> LinkedHashMultiset<E> create(Iterable<? extends E> elements) {
LinkedHashMultiset<E> multiset = create(Multisets.inferDistinctElements(elements));
Iterables.addAll(multiset, elements);
return multiset;
@@ -74,7 +70,7 @@
}
@Override
- ObjectCountHashMap<E> newBackingMap(int distinctElements) {
- return new ObjectCountLinkedHashMap<>(distinctElements);
+ void init(int distinctElements) {
+ backingMap = new ObjectCountLinkedHashMap<>(distinctElements);
}
}
diff --git a/android/guava/src/com/google/common/collect/LinkedListMultimap.java b/android/guava/src/com/google/common/collect/LinkedListMultimap.java
index 31874b2..3aa1efd 100644
--- a/android/guava/src/com/google/common/collect/LinkedListMultimap.java
+++ b/android/guava/src/com/google/common/collect/LinkedListMultimap.java
@@ -18,8 +18,8 @@
import static com.google.common.base.Preconditions.checkPositionIndex;
import static com.google.common.base.Preconditions.checkState;
+import static com.google.common.collect.CollectPreconditions.checkRemove;
import static java.util.Collections.unmodifiableList;
-import static java.util.Objects.requireNonNull;
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.GwtIncompatible;
@@ -39,8 +39,7 @@
import java.util.Map.Entry;
import java.util.NoSuchElementException;
import java.util.Set;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* An implementation of {@code ListMultimap} that supports deterministic iteration order for both
@@ -95,9 +94,8 @@
* @since 2.0
*/
@GwtCompatible(serializable = true, emulated = true)
-@ElementTypesAreNonnullByDefault
-public class LinkedListMultimap<K extends @Nullable Object, V extends @Nullable Object>
- extends AbstractMultimap<K, V> implements ListMultimap<K, V>, Serializable {
+public class LinkedListMultimap<K, V> extends AbstractMultimap<K, V>
+ implements ListMultimap<K, V>, Serializable {
/*
* Order is maintained using a linked list containing all key-value pairs. In
* addition, a series of disjoint linked lists of "siblings", each containing
@@ -105,42 +103,38 @@
* ValueForKeyIterator} in constant time.
*/
- private static final class Node<K extends @Nullable Object, V extends @Nullable Object>
- extends AbstractMapEntry<K, V> {
- @ParametricNullness final K key;
- @ParametricNullness V value;
- @CheckForNull Node<K, V> next; // the next node (with any key)
- @CheckForNull Node<K, V> previous; // the previous node (with any key)
- @CheckForNull Node<K, V> nextSibling; // the next node with the same key
- @CheckForNull Node<K, V> previousSibling; // the previous node with the same key
+ private static final class Node<K, V> extends AbstractMapEntry<K, V> {
+ @NullableDecl final K key;
+ @NullableDecl V value;
+ @NullableDecl Node<K, V> next; // the next node (with any key)
+ @NullableDecl Node<K, V> previous; // the previous node (with any key)
+ @NullableDecl Node<K, V> nextSibling; // the next node with the same key
+ @NullableDecl Node<K, V> previousSibling; // the previous node with the same key
- Node(@ParametricNullness K key, @ParametricNullness V value) {
+ Node(@NullableDecl K key, @NullableDecl V value) {
this.key = key;
this.value = value;
}
@Override
- @ParametricNullness
public K getKey() {
return key;
}
@Override
- @ParametricNullness
public V getValue() {
return value;
}
@Override
- @ParametricNullness
- public V setValue(@ParametricNullness V newValue) {
+ public V setValue(@NullableDecl V newValue) {
V result = value;
this.value = newValue;
return result;
}
}
- private static class KeyList<K extends @Nullable Object, V extends @Nullable Object> {
+ private static class KeyList<K, V> {
Node<K, V> head;
Node<K, V> tail;
int count;
@@ -154,8 +148,8 @@
}
}
- @CheckForNull private transient Node<K, V> head; // the head for all keys
- @CheckForNull private transient Node<K, V> tail; // the tail for all keys
+ @NullableDecl private transient Node<K, V> head; // the head for all keys
+ @NullableDecl private transient Node<K, V> tail; // the tail for all keys
private transient Map<K, KeyList<K, V>> keyToKeyList;
private transient int size;
@@ -167,8 +161,7 @@
private transient int modCount;
/** Creates a new, empty {@code LinkedListMultimap} with the default initial capacity. */
- public static <K extends @Nullable Object, V extends @Nullable Object>
- LinkedListMultimap<K, V> create() {
+ public static <K, V> LinkedListMultimap<K, V> create() {
return new LinkedListMultimap<>();
}
@@ -179,8 +172,7 @@
* @param expectedKeys the expected number of distinct keys
* @throws IllegalArgumentException if {@code expectedKeys} is negative
*/
- public static <K extends @Nullable Object, V extends @Nullable Object>
- LinkedListMultimap<K, V> create(int expectedKeys) {
+ public static <K, V> LinkedListMultimap<K, V> create(int expectedKeys) {
return new LinkedListMultimap<>(expectedKeys);
}
@@ -191,8 +183,8 @@
*
* @param multimap the multimap whose contents are copied to this multimap
*/
- public static <K extends @Nullable Object, V extends @Nullable Object>
- LinkedListMultimap<K, V> create(Multimap<? extends K, ? extends V> multimap) {
+ public static <K, V> LinkedListMultimap<K, V> create(
+ Multimap<? extends K, ? extends V> multimap) {
return new LinkedListMultimap<>(multimap);
}
@@ -216,17 +208,14 @@
*/
@CanIgnoreReturnValue
private Node<K, V> addNode(
- @ParametricNullness K key,
- @ParametricNullness V value,
- @CheckForNull Node<K, V> nextSibling) {
+ @NullableDecl K key, @NullableDecl V value, @NullableDecl Node<K, V> nextSibling) {
Node<K, V> node = new Node<>(key, value);
if (head == null) { // empty list
head = tail = node;
keyToKeyList.put(key, new KeyList<K, V>(node));
modCount++;
} else if (nextSibling == null) { // non-empty list, add to tail
- // requireNonNull is safe because the list is non-empty.
- requireNonNull(tail).next = node;
+ tail.next = node;
node.previous = tail;
tail = node;
KeyList<K, V> keyList = keyToKeyList.get(key);
@@ -241,19 +230,14 @@
keyList.tail = node;
}
} else { // non-empty list, insert before nextSibling
- /*
- * requireNonNull is safe as long as callers pass a nextSibling that (a) has the same key and
- * (b) is present in the multimap. (And they do, except maybe in case of concurrent
- * modification, in which case all bets are off.)
- */
- KeyList<K, V> keyList = requireNonNull(keyToKeyList.get(key));
+ KeyList<K, V> keyList = keyToKeyList.get(key);
keyList.count++;
node.previous = nextSibling.previous;
node.previousSibling = nextSibling.previousSibling;
node.next = nextSibling;
node.nextSibling = nextSibling;
if (nextSibling.previousSibling == null) { // nextSibling was key head
- keyList.head = node;
+ keyToKeyList.get(key).head = node;
} else {
nextSibling.previousSibling.nextSibling = node;
}
@@ -285,29 +269,21 @@
tail = node.previous;
}
if (node.previousSibling == null && node.nextSibling == null) {
- /*
- * requireNonNull is safe as long as we call removeNode only for nodes that are still in the
- * Multimap. This should be the case (except in case of concurrent modification, when all bets
- * are off).
- */
- KeyList<K, V> keyList = requireNonNull(keyToKeyList.remove(node.key));
+ KeyList<K, V> keyList = keyToKeyList.remove(node.key);
keyList.count = 0;
modCount++;
} else {
- // requireNonNull is safe (under the conditions listed in the comment in the branch above).
- KeyList<K, V> keyList = requireNonNull(keyToKeyList.get(node.key));
+ KeyList<K, V> keyList = keyToKeyList.get(node.key);
keyList.count--;
if (node.previousSibling == null) {
- // requireNonNull is safe because we checked that not *both* siblings were null.
- keyList.head = requireNonNull(node.nextSibling);
+ keyList.head = node.nextSibling;
} else {
node.previousSibling.nextSibling = node.nextSibling;
}
if (node.nextSibling == null) {
- // requireNonNull is safe because we checked that not *both* siblings were null.
- keyList.tail = requireNonNull(node.previousSibling);
+ keyList.tail = node.previousSibling;
} else {
node.nextSibling.previousSibling = node.previousSibling;
}
@@ -316,16 +292,23 @@
}
/** Removes all nodes for the specified key. */
- private void removeAllNodes(@ParametricNullness K key) {
+ private void removeAllNodes(@NullableDecl Object key) {
Iterators.clear(new ValueForKeyIterator(key));
}
+ /** Helper method for verifying that an iterator element is present. */
+ private static void checkElement(@NullableDecl Object node) {
+ if (node == null) {
+ throw new NoSuchElementException();
+ }
+ }
+
/** An {@code Iterator} over all nodes. */
private class NodeIterator implements ListIterator<Entry<K, V>> {
int nextIndex;
- @CheckForNull Node<K, V> next;
- @CheckForNull Node<K, V> current;
- @CheckForNull Node<K, V> previous;
+ @NullableDecl Node<K, V> next;
+ @NullableDecl Node<K, V> current;
+ @NullableDecl Node<K, V> previous;
int expectedModCount = modCount;
NodeIterator(int index) {
@@ -362,9 +345,7 @@
@Override
public Node<K, V> next() {
checkForConcurrentModification();
- if (next == null) {
- throw new NoSuchElementException();
- }
+ checkElement(next);
previous = current = next;
next = next.next;
nextIndex++;
@@ -374,7 +355,7 @@
@Override
public void remove() {
checkForConcurrentModification();
- checkState(current != null, "no calls to next() since the last call to remove()");
+ checkRemove(current != null);
if (current != next) { // after call to next()
previous = current.previous;
nextIndex--;
@@ -396,9 +377,7 @@
@Override
public Node<K, V> previous() {
checkForConcurrentModification();
- if (previous == null) {
- throw new NoSuchElementException();
- }
+ checkElement(previous);
next = current = previous;
previous = previous.previous;
nextIndex--;
@@ -425,7 +404,7 @@
throw new UnsupportedOperationException();
}
- void setValue(@ParametricNullness V value) {
+ void setValue(V value) {
checkState(current != null);
current.value = value;
}
@@ -434,8 +413,8 @@
/** An {@code Iterator} over distinct keys in key head order. */
private class DistinctKeyIterator implements Iterator<K> {
final Set<K> seenKeys = Sets.<K>newHashSetWithExpectedSize(keySet().size());
- @CheckForNull Node<K, V> next = head;
- @CheckForNull Node<K, V> current;
+ Node<K, V> next = head;
+ @NullableDecl Node<K, V> current;
int expectedModCount = modCount;
private void checkForConcurrentModification() {
@@ -451,12 +430,9 @@
}
@Override
- @ParametricNullness
public K next() {
checkForConcurrentModification();
- if (next == null) {
- throw new NoSuchElementException();
- }
+ checkElement(next);
current = next;
seenKeys.add(current.key);
do { // skip ahead to next unseen key
@@ -468,7 +444,7 @@
@Override
public void remove() {
checkForConcurrentModification();
- checkState(current != null, "no calls to next() since the last call to remove()");
+ checkRemove(current != null);
removeAllNodes(current.key);
current = null;
expectedModCount = modCount;
@@ -477,14 +453,14 @@
/** A {@code ListIterator} over values for a specified key. */
private class ValueForKeyIterator implements ListIterator<V> {
- @ParametricNullness final K key;
+ @NullableDecl final Object key;
int nextIndex;
- @CheckForNull Node<K, V> next;
- @CheckForNull Node<K, V> current;
- @CheckForNull Node<K, V> previous;
+ @NullableDecl Node<K, V> next;
+ @NullableDecl Node<K, V> current;
+ @NullableDecl Node<K, V> previous;
/** Constructs a new iterator over all values for the specified key. */
- ValueForKeyIterator(@ParametricNullness K key) {
+ ValueForKeyIterator(@NullableDecl Object key) {
this.key = key;
KeyList<K, V> keyList = keyToKeyList.get(key);
next = (keyList == null) ? null : keyList.head;
@@ -498,7 +474,7 @@
*
* @throws IndexOutOfBoundsException if index is invalid
*/
- public ValueForKeyIterator(@ParametricNullness K key, int index) {
+ public ValueForKeyIterator(@NullableDecl Object key, int index) {
KeyList<K, V> keyList = keyToKeyList.get(key);
int size = (keyList == null) ? 0 : keyList.count;
checkPositionIndex(index, size);
@@ -525,11 +501,8 @@
@CanIgnoreReturnValue
@Override
- @ParametricNullness
public V next() {
- if (next == null) {
- throw new NoSuchElementException();
- }
+ checkElement(next);
previous = current = next;
next = next.nextSibling;
nextIndex++;
@@ -543,11 +516,8 @@
@CanIgnoreReturnValue
@Override
- @ParametricNullness
public V previous() {
- if (previous == null) {
- throw new NoSuchElementException();
- }
+ checkElement(previous);
next = current = previous;
previous = previous.previousSibling;
nextIndex--;
@@ -566,7 +536,7 @@
@Override
public void remove() {
- checkState(current != null, "no calls to next() since the last call to remove()");
+ checkRemove(current != null);
if (current != next) { // after call to next()
previous = current.previousSibling;
nextIndex--;
@@ -578,14 +548,15 @@
}
@Override
- public void set(@ParametricNullness V value) {
+ public void set(V value) {
checkState(current != null);
current.value = value;
}
@Override
- public void add(@ParametricNullness V value) {
- previous = addNode(key, value, next);
+ @SuppressWarnings("unchecked")
+ public void add(V value) {
+ previous = addNode((K) key, value, next);
nextIndex++;
current = null;
}
@@ -604,12 +575,12 @@
}
@Override
- public boolean containsKey(@CheckForNull Object key) {
+ public boolean containsKey(@NullableDecl Object key) {
return keyToKeyList.containsKey(key);
}
@Override
- public boolean containsValue(@CheckForNull Object value) {
+ public boolean containsValue(@NullableDecl Object value) {
return values().contains(value);
}
@@ -624,7 +595,7 @@
*/
@CanIgnoreReturnValue
@Override
- public boolean put(@ParametricNullness K key, @ParametricNullness V value) {
+ public boolean put(@NullableDecl K key, @NullableDecl V value) {
addNode(key, value, null);
return true;
}
@@ -641,7 +612,7 @@
*/
@CanIgnoreReturnValue
@Override
- public List<V> replaceValues(@ParametricNullness K key, Iterable<? extends V> values) {
+ public List<V> replaceValues(@NullableDecl K key, Iterable<? extends V> values) {
List<V> oldValues = getCopy(key);
ListIterator<V> keyValues = new ValueForKeyIterator(key);
Iterator<? extends V> newValues = values.iterator();
@@ -666,7 +637,7 @@
return oldValues;
}
- private List<V> getCopy(@ParametricNullness K key) {
+ private List<V> getCopy(@NullableDecl Object key) {
return unmodifiableList(Lists.newArrayList(new ValueForKeyIterator(key)));
}
@@ -677,16 +648,9 @@
*/
@CanIgnoreReturnValue
@Override
- public List<V> removeAll(@Nullable Object key) {
- /*
- * Safe because all we do is remove values for the key, not add them. (If we wanted to make sure
- * to call getCopy and removeAllNodes only with a true K, then we could check containsKey first.
- * But that check wouldn't eliminate the warnings.)
- */
- @SuppressWarnings({"unchecked", "nullness"})
- K castKey = (K) key;
- List<V> oldValues = getCopy(castKey);
- removeAllNodes(castKey);
+ public List<V> removeAll(@NullableDecl Object key) {
+ List<V> oldValues = getCopy(key);
+ removeAllNodes(key);
return oldValues;
}
@@ -711,7 +675,7 @@
* <p>The returned list is not serializable and does not have random access.
*/
@Override
- public List<V> get(@ParametricNullness final K key) {
+ public List<V> get(@NullableDecl final K key) {
return new AbstractSequentialList<V>() {
@Override
public int size() {
@@ -741,12 +705,12 @@
}
@Override
- public boolean contains(@CheckForNull Object key) { // for performance
+ public boolean contains(Object key) { // for performance
return containsKey(key);
}
@Override
- public boolean remove(@CheckForNull Object o) { // for performance
+ public boolean remove(Object o) { // for performance
return !LinkedListMultimap.this.removeAll(o).isEmpty();
}
}
@@ -785,13 +749,12 @@
final NodeIterator nodeItr = new NodeIterator(index);
return new TransformedListIterator<Entry<K, V>, V>(nodeItr) {
@Override
- @ParametricNullness
V transform(Entry<K, V> entry) {
return entry.getValue();
}
@Override
- public void set(@ParametricNullness V value) {
+ public void set(V value) {
nodeItr.setValue(value);
}
};
diff --git a/android/guava/src/com/google/common/collect/ListMultimap.java b/android/guava/src/com/google/common/collect/ListMultimap.java
index 1686068..46c18ac 100644
--- a/android/guava/src/com/google/common/collect/ListMultimap.java
+++ b/android/guava/src/com/google/common/collect/ListMultimap.java
@@ -21,8 +21,7 @@
import java.util.Collection;
import java.util.List;
import java.util.Map;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* A {@code Multimap} that can hold duplicate key-value pairs and that maintains the insertion
@@ -41,9 +40,7 @@
* @since 2.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-public interface ListMultimap<K extends @Nullable Object, V extends @Nullable Object>
- extends Multimap<K, V> {
+public interface ListMultimap<K, V> extends Multimap<K, V> {
/**
* {@inheritDoc}
*
@@ -52,7 +49,7 @@
* the {@link Multimap} interface.
*/
@Override
- List<V> get(@ParametricNullness K key);
+ List<V> get(@NullableDecl K key);
/**
* {@inheritDoc}
@@ -63,7 +60,7 @@
*/
@CanIgnoreReturnValue
@Override
- List<V> removeAll(@CheckForNull Object key);
+ List<V> removeAll(@NullableDecl Object key);
/**
* {@inheritDoc}
@@ -74,7 +71,7 @@
*/
@CanIgnoreReturnValue
@Override
- List<V> replaceValues(@ParametricNullness K key, Iterable<? extends V> values);
+ List<V> replaceValues(K key, Iterable<? extends V> values);
/**
* {@inheritDoc}
@@ -96,5 +93,5 @@
* empty {@code SetMultimap}.
*/
@Override
- boolean equals(@CheckForNull Object obj);
+ boolean equals(@NullableDecl Object obj);
}
diff --git a/android/guava/src/com/google/common/collect/Lists.java b/android/guava/src/com/google/common/collect/Lists.java
index a583950..33f6533 100644
--- a/android/guava/src/com/google/common/collect/Lists.java
+++ b/android/guava/src/com/google/common/collect/Lists.java
@@ -48,8 +48,7 @@
import java.util.NoSuchElementException;
import java.util.RandomAccess;
import java.util.concurrent.CopyOnWriteArrayList;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* Static utility methods pertaining to {@link List} instances. Also see this class's counterparts
@@ -64,7 +63,6 @@
* @since 2.0
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
public final class Lists {
private Lists() {}
@@ -80,7 +78,7 @@
* directly, taking advantage of the new <a href="http://goo.gl/iz2Wi">"diamond" syntax</a>.
*/
@GwtCompatible(serializable = true)
- public static <E extends @Nullable Object> ArrayList<E> newArrayList() {
+ public static <E> ArrayList<E> newArrayList() {
return new ArrayList<>();
}
@@ -100,7 +98,7 @@
*/
@SafeVarargs
@GwtCompatible(serializable = true)
- public static <E extends @Nullable Object> ArrayList<E> newArrayList(E... elements) {
+ public static <E> ArrayList<E> newArrayList(E... elements) {
checkNotNull(elements); // for GWT
// Avoid integer overflow when a large array is passed in
int capacity = computeArrayListCapacity(elements.length);
@@ -123,8 +121,7 @@
* syntax</a>.
*/
@GwtCompatible(serializable = true)
- public static <E extends @Nullable Object> ArrayList<E> newArrayList(
- Iterable<? extends E> elements) {
+ public static <E> ArrayList<E> newArrayList(Iterable<? extends E> elements) {
checkNotNull(elements); // for GWT
// Let ArrayList's sizing logic work, if possible
return (elements instanceof Collection)
@@ -140,8 +137,7 @@
* ImmutableList#copyOf(Iterator)} instead.
*/
@GwtCompatible(serializable = true)
- public static <E extends @Nullable Object> ArrayList<E> newArrayList(
- Iterator<? extends E> elements) {
+ public static <E> ArrayList<E> newArrayList(Iterator<? extends E> elements) {
ArrayList<E> list = newArrayList();
Iterators.addAll(list, elements);
return list;
@@ -172,8 +168,7 @@
* @throws IllegalArgumentException if {@code initialArraySize} is negative
*/
@GwtCompatible(serializable = true)
- public static <E extends @Nullable Object> ArrayList<E> newArrayListWithCapacity(
- int initialArraySize) {
+ public static <E> ArrayList<E> newArrayListWithCapacity(int initialArraySize) {
checkNonnegative(initialArraySize, "initialArraySize"); // for GWT.
return new ArrayList<>(initialArraySize);
}
@@ -192,8 +187,7 @@
* @throws IllegalArgumentException if {@code estimatedSize} is negative
*/
@GwtCompatible(serializable = true)
- public static <E extends @Nullable Object> ArrayList<E> newArrayListWithExpectedSize(
- int estimatedSize) {
+ public static <E> ArrayList<E> newArrayListWithExpectedSize(int estimatedSize) {
return new ArrayList<>(computeArrayListCapacity(estimatedSize));
}
@@ -215,7 +209,7 @@
* syntax</a>.
*/
@GwtCompatible(serializable = true)
- public static <E extends @Nullable Object> LinkedList<E> newLinkedList() {
+ public static <E> LinkedList<E> newLinkedList() {
return new LinkedList<>();
}
@@ -237,8 +231,7 @@
* syntax</a>.
*/
@GwtCompatible(serializable = true)
- public static <E extends @Nullable Object> LinkedList<E> newLinkedList(
- Iterable<? extends E> elements) {
+ public static <E> LinkedList<E> newLinkedList(Iterable<? extends E> elements) {
LinkedList<E> list = newLinkedList();
Iterables.addAll(list, elements);
return list;
@@ -254,7 +247,7 @@
* @since 12.0
*/
@GwtIncompatible // CopyOnWriteArrayList
- public static <E extends @Nullable Object> CopyOnWriteArrayList<E> newCopyOnWriteArrayList() {
+ public static <E> CopyOnWriteArrayList<E> newCopyOnWriteArrayList() {
return new CopyOnWriteArrayList<>();
}
@@ -266,7 +259,7 @@
* @since 12.0
*/
@GwtIncompatible // CopyOnWriteArrayList
- public static <E extends @Nullable Object> CopyOnWriteArrayList<E> newCopyOnWriteArrayList(
+ public static <E> CopyOnWriteArrayList<E> newCopyOnWriteArrayList(
Iterable<? extends E> elements) {
// We copy elements to an ArrayList first, rather than incurring the
// quadratic cost of adding them to the COWAL directly.
@@ -291,7 +284,7 @@
* @param rest an array of additional elements, possibly empty
* @return an unmodifiable list containing the specified elements
*/
- public static <E extends @Nullable Object> List<E> asList(@ParametricNullness E first, E[] rest) {
+ public static <E> List<E> asList(@NullableDecl E first, E[] rest) {
return new OnePlusArrayList<>(first, rest);
}
@@ -311,18 +304,17 @@
* @param rest an array of additional elements, possibly empty
* @return an unmodifiable list containing the specified elements
*/
- public static <E extends @Nullable Object> List<E> asList(
- @ParametricNullness E first, @ParametricNullness E second, E[] rest) {
+ public static <E> List<E> asList(@NullableDecl E first, @NullableDecl E second, E[] rest) {
return new TwoPlusArrayList<>(first, second, rest);
}
/** @see Lists#asList(Object, Object[]) */
- private static class OnePlusArrayList<E extends @Nullable Object> extends AbstractList<E>
+ private static class OnePlusArrayList<E> extends AbstractList<E>
implements Serializable, RandomAccess {
- @ParametricNullness final E first;
+ @NullableDecl final E first;
final E[] rest;
- OnePlusArrayList(@ParametricNullness E first, E[] rest) {
+ OnePlusArrayList(@NullableDecl E first, E[] rest) {
this.first = first;
this.rest = checkNotNull(rest);
}
@@ -333,7 +325,6 @@
}
@Override
- @ParametricNullness
public E get(int index) {
// check explicitly so the IOOBE will have the right message
checkElementIndex(index, size());
@@ -344,13 +335,13 @@
}
/** @see Lists#asList(Object, Object, Object[]) */
- private static class TwoPlusArrayList<E extends @Nullable Object> extends AbstractList<E>
+ private static class TwoPlusArrayList<E> extends AbstractList<E>
implements Serializable, RandomAccess {
- @ParametricNullness final E first;
- @ParametricNullness final E second;
+ @NullableDecl final E first;
+ @NullableDecl final E second;
final E[] rest;
- TwoPlusArrayList(@ParametricNullness E first, @ParametricNullness E second, E[] rest) {
+ TwoPlusArrayList(@NullableDecl E first, @NullableDecl E second, E[] rest) {
this.first = first;
this.second = second;
this.rest = checkNotNull(rest);
@@ -362,7 +353,6 @@
}
@Override
- @ParametricNullness
public E get(int index) {
switch (index) {
case 0:
@@ -528,7 +518,7 @@
* java.util.stream.Stream#map}. This method is not being deprecated, but we gently encourage you
* to migrate to streams.
*/
- public static <F extends @Nullable Object, T extends @Nullable Object> List<T> transform(
+ public static <F, T> List<T> transform(
List<F> fromList, Function<? super F, ? extends T> function) {
return (fromList instanceof RandomAccess)
? new TransformingRandomAccessList<>(fromList, function)
@@ -540,9 +530,8 @@
*
* @see Lists#transform
*/
- private static class TransformingSequentialList<
- F extends @Nullable Object, T extends @Nullable Object>
- extends AbstractSequentialList<T> implements Serializable {
+ private static class TransformingSequentialList<F, T> extends AbstractSequentialList<T>
+ implements Serializable {
final List<F> fromList;
final Function<? super F, ? extends T> function;
@@ -569,8 +558,7 @@
public ListIterator<T> listIterator(final int index) {
return new TransformedListIterator<F, T>(fromList.listIterator(index)) {
@Override
- @ParametricNullness
- T transform(@ParametricNullness F from) {
+ T transform(F from) {
return function.apply(from);
}
};
@@ -586,9 +574,8 @@
*
* @see Lists#transform
*/
- private static class TransformingRandomAccessList<
- F extends @Nullable Object, T extends @Nullable Object>
- extends AbstractList<T> implements RandomAccess, Serializable {
+ private static class TransformingRandomAccessList<F, T> extends AbstractList<T>
+ implements RandomAccess, Serializable {
final List<F> fromList;
final Function<? super F, ? extends T> function;
@@ -603,7 +590,6 @@
}
@Override
- @ParametricNullness
public T get(int index) {
return function.apply(fromList.get(index));
}
@@ -656,7 +642,7 @@
* @return a list of consecutive sublists
* @throws IllegalArgumentException if {@code partitionSize} is nonpositive
*/
- public static <T extends @Nullable Object> List<List<T>> partition(List<T> list, int size) {
+ public static <T> List<List<T>> partition(List<T> list, int size) {
checkNotNull(list);
checkArgument(size > 0);
return (list instanceof RandomAccess)
@@ -664,7 +650,7 @@
: new Partition<>(list, size);
}
- private static class Partition<T extends @Nullable Object> extends AbstractList<List<T>> {
+ private static class Partition<T> extends AbstractList<List<T>> {
final List<T> list;
final int size;
@@ -692,8 +678,7 @@
}
}
- private static class RandomAccessPartition<T extends @Nullable Object> extends Partition<T>
- implements RandomAccess {
+ private static class RandomAccessPartition<T> extends Partition<T> implements RandomAccess {
RandomAccessPartition(List<T> list, int size) {
super(list, size);
}
@@ -732,12 +717,12 @@
}
@Override
- public int indexOf(@CheckForNull Object object) {
+ public int indexOf(@NullableDecl Object object) {
return (object instanceof Character) ? string.indexOf((Character) object) : -1;
}
@Override
- public int lastIndexOf(@CheckForNull Object object) {
+ public int lastIndexOf(@NullableDecl Object object) {
return (object instanceof Character) ? string.lastIndexOf((Character) object) : -1;
}
@@ -794,13 +779,9 @@
*
* @since 7.0
*/
- public static <T extends @Nullable Object> List<T> reverse(List<T> list) {
+ public static <T> List<T> reverse(List<T> list) {
if (list instanceof ImmutableList) {
- // Avoid nullness warnings.
- List<?> reversed = ((ImmutableList<?>) list).reverse();
- @SuppressWarnings("unchecked")
- List<T> result = (List<T>) reversed;
- return result;
+ return ((ImmutableList<T>) list).reverse();
} else if (list instanceof ReverseList) {
return ((ReverseList<T>) list).getForwardList();
} else if (list instanceof RandomAccess) {
@@ -810,7 +791,7 @@
}
}
- private static class ReverseList<T extends @Nullable Object> extends AbstractList<T> {
+ private static class ReverseList<T> extends AbstractList<T> {
private final List<T> forwardList;
ReverseList(List<T> forwardList) {
@@ -834,7 +815,7 @@
}
@Override
- public void add(int index, @ParametricNullness T element) {
+ public void add(int index, @NullableDecl T element) {
forwardList.add(reversePosition(index), element);
}
@@ -844,7 +825,6 @@
}
@Override
- @ParametricNullness
public T remove(int index) {
return forwardList.remove(reverseIndex(index));
}
@@ -855,13 +835,11 @@
}
@Override
- @ParametricNullness
- public T set(int index, @ParametricNullness T element) {
+ public T set(int index, @NullableDecl T element) {
return forwardList.set(reverseIndex(index), element);
}
@Override
- @ParametricNullness
public T get(int index) {
return forwardList.get(reverseIndex(index));
}
@@ -891,7 +869,7 @@
boolean canRemoveOrSet;
@Override
- public void add(@ParametricNullness T e) {
+ public void add(T e) {
forwardIterator.add(e);
forwardIterator.previous();
canRemoveOrSet = false;
@@ -908,7 +886,6 @@
}
@Override
- @ParametricNullness
public T next() {
if (!hasNext()) {
throw new NoSuchElementException();
@@ -923,7 +900,6 @@
}
@Override
- @ParametricNullness
public T previous() {
if (!hasPrevious()) {
throw new NoSuchElementException();
@@ -945,7 +921,7 @@
}
@Override
- public void set(@ParametricNullness T e) {
+ public void set(T e) {
checkState(canRemoveOrSet);
forwardIterator.set(e);
}
@@ -953,8 +929,7 @@
}
}
- private static class RandomAccessReverseList<T extends @Nullable Object> extends ReverseList<T>
- implements RandomAccess {
+ private static class RandomAccessReverseList<T> extends ReverseList<T> implements RandomAccess {
RandomAccessReverseList(List<T> forwardList) {
super(forwardList);
}
@@ -974,7 +949,7 @@
}
/** An implementation of {@link List#equals(Object)}. */
- static boolean equalsImpl(List<?> thisList, @CheckForNull Object other) {
+ static boolean equalsImpl(List<?> thisList, @NullableDecl Object other) {
if (other == checkNotNull(thisList)) {
return true;
}
@@ -1000,8 +975,7 @@
}
/** An implementation of {@link List#addAll(int, Collection)}. */
- static <E extends @Nullable Object> boolean addAllImpl(
- List<E> list, int index, Iterable<? extends E> elements) {
+ static <E> boolean addAllImpl(List<E> list, int index, Iterable<? extends E> elements) {
boolean changed = false;
ListIterator<E> listIterator = list.listIterator(index);
for (E e : elements) {
@@ -1012,7 +986,7 @@
}
/** An implementation of {@link List#indexOf(Object)}. */
- static int indexOfImpl(List<?> list, @CheckForNull Object element) {
+ static int indexOfImpl(List<?> list, @NullableDecl Object element) {
if (list instanceof RandomAccess) {
return indexOfRandomAccess(list, element);
} else {
@@ -1026,7 +1000,7 @@
}
}
- private static int indexOfRandomAccess(List<?> list, @CheckForNull Object element) {
+ private static int indexOfRandomAccess(List<?> list, @NullableDecl Object element) {
int size = list.size();
if (element == null) {
for (int i = 0; i < size; i++) {
@@ -1045,7 +1019,7 @@
}
/** An implementation of {@link List#lastIndexOf(Object)}. */
- static int lastIndexOfImpl(List<?> list, @CheckForNull Object element) {
+ static int lastIndexOfImpl(List<?> list, @NullableDecl Object element) {
if (list instanceof RandomAccess) {
return lastIndexOfRandomAccess(list, element);
} else {
@@ -1059,7 +1033,7 @@
}
}
- private static int lastIndexOfRandomAccess(List<?> list, @CheckForNull Object element) {
+ private static int lastIndexOfRandomAccess(List<?> list, @NullableDecl Object element) {
if (element == null) {
for (int i = list.size() - 1; i >= 0; i--) {
if (list.get(i) == null) {
@@ -1077,13 +1051,12 @@
}
/** Returns an implementation of {@link List#listIterator(int)}. */
- static <E extends @Nullable Object> ListIterator<E> listIteratorImpl(List<E> list, int index) {
+ static <E> ListIterator<E> listIteratorImpl(List<E> list, int index) {
return new AbstractListWrapper<>(list).listIterator(index);
}
/** An implementation of {@link List#subList(int, int)}. */
- static <E extends @Nullable Object> List<E> subListImpl(
- final List<E> list, int fromIndex, int toIndex) {
+ static <E> List<E> subListImpl(final List<E> list, int fromIndex, int toIndex) {
List<E> wrapper;
if (list instanceof RandomAccess) {
wrapper =
@@ -1109,7 +1082,7 @@
return wrapper.subList(fromIndex, toIndex);
}
- private static class AbstractListWrapper<E extends @Nullable Object> extends AbstractList<E> {
+ private static class AbstractListWrapper<E> extends AbstractList<E> {
final List<E> backingList;
AbstractListWrapper(List<E> backingList) {
@@ -1117,7 +1090,7 @@
}
@Override
- public void add(int index, @ParametricNullness E element) {
+ public void add(int index, E element) {
backingList.add(index, element);
}
@@ -1127,25 +1100,22 @@
}
@Override
- @ParametricNullness
public E get(int index) {
return backingList.get(index);
}
@Override
- @ParametricNullness
public E remove(int index) {
return backingList.remove(index);
}
@Override
- @ParametricNullness
- public E set(int index, @ParametricNullness E element) {
+ public E set(int index, E element) {
return backingList.set(index, element);
}
@Override
- public boolean contains(@CheckForNull Object o) {
+ public boolean contains(Object o) {
return backingList.contains(o);
}
@@ -1155,15 +1125,15 @@
}
}
- private static class RandomAccessListWrapper<E extends @Nullable Object>
- extends AbstractListWrapper<E> implements RandomAccess {
+ private static class RandomAccessListWrapper<E> extends AbstractListWrapper<E>
+ implements RandomAccess {
RandomAccessListWrapper(List<E> backingList) {
super(backingList);
}
}
/** Used to avoid http://bugs.sun.com/view_bug.do?bug_id=6558557 */
- static <T extends @Nullable Object> List<T> cast(Iterable<T> iterable) {
+ static <T> List<T> cast(Iterable<T> iterable) {
return (List<T>) iterable;
}
}
diff --git a/android/guava/src/com/google/common/collect/MapDifference.java b/android/guava/src/com/google/common/collect/MapDifference.java
index 5000e4b..9933770 100644
--- a/android/guava/src/com/google/common/collect/MapDifference.java
+++ b/android/guava/src/com/google/common/collect/MapDifference.java
@@ -19,8 +19,7 @@
import com.google.common.annotations.GwtCompatible;
import com.google.errorprone.annotations.DoNotMock;
import java.util.Map;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* An object representing the differences between two maps.
@@ -30,8 +29,7 @@
*/
@DoNotMock("Use Maps.difference")
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-public interface MapDifference<K extends @Nullable Object, V extends @Nullable Object> {
+public interface MapDifference<K, V> {
/**
* Returns {@code true} if there are no differences between the two maps; that is, if the maps are
* equal.
@@ -69,7 +67,7 @@
* #entriesDiffering()} of the two instances are equal.
*/
@Override
- boolean equals(@CheckForNull Object object);
+ boolean equals(@NullableDecl Object object);
/**
* Returns the hash code for this instance. This is defined as the hash code of
@@ -89,13 +87,11 @@
* @since 2.0
*/
@DoNotMock("Use Maps.difference")
- interface ValueDifference<V extends @Nullable Object> {
+ interface ValueDifference<V> {
/** Returns the value from the left map (possibly null). */
- @ParametricNullness
V leftValue();
/** Returns the value from the right map (possibly null). */
- @ParametricNullness
V rightValue();
/**
@@ -103,7 +99,7 @@
* {@link #rightValue()} values are also equal.
*/
@Override
- boolean equals(@CheckForNull Object other);
+ boolean equals(@NullableDecl Object other);
/**
* The hash code equals the value {@code Arrays.asList(leftValue(), rightValue()).hashCode()}.
diff --git a/android/guava/src/com/google/common/collect/MapMaker.java b/android/guava/src/com/google/common/collect/MapMaker.java
index a2612c1..4f837a0 100644
--- a/android/guava/src/com/google/common/collect/MapMaker.java
+++ b/android/guava/src/com/google/common/collect/MapMaker.java
@@ -30,7 +30,7 @@
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* A builder of {@link ConcurrentMap} instances that can have keys or values automatically wrapped
@@ -86,7 +86,6 @@
* @since 2.0
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
public final class MapMaker {
private static final int DEFAULT_INITIAL_CAPACITY = 16;
private static final int DEFAULT_CONCURRENCY_LEVEL = 4;
@@ -99,10 +98,10 @@
int initialCapacity = UNSET_INT;
int concurrencyLevel = UNSET_INT;
- @CheckForNull Strength keyStrength;
- @CheckForNull Strength valueStrength;
+ @NullableDecl Strength keyStrength;
+ @NullableDecl Strength valueStrength;
- @CheckForNull Equivalence<Object> keyEquivalence;
+ @NullableDecl Equivalence<Object> keyEquivalence;
/**
* Constructs a new {@code MapMaker} instance with default settings, including strong keys, strong
diff --git a/android/guava/src/com/google/common/collect/MapMakerInternalMap.java b/android/guava/src/com/google/common/collect/MapMakerInternalMap.java
index 4e66a84..b72d0ea 100644
--- a/android/guava/src/com/google/common/collect/MapMakerInternalMap.java
+++ b/android/guava/src/com/google/common/collect/MapMakerInternalMap.java
@@ -65,11 +65,7 @@
*/
// TODO(kak): Consider removing @CanIgnoreReturnValue from this class.
@GwtIncompatible
-@SuppressWarnings({
- "GuardedBy", // TODO(b/35466881): Fix or suppress.
- "nullness", // too much trouble for the payoff
-})
-// TODO(cpovirk): Annotate for nullness.
+@SuppressWarnings("GuardedBy") // TODO(b/35466881): Fix or suppress.
class MapMakerInternalMap<
K,
V,
diff --git a/android/guava/src/com/google/common/collect/Maps.java b/android/guava/src/com/google/common/collect/Maps.java
index b415f25..f0bac2a 100644
--- a/android/guava/src/com/google/common/collect/Maps.java
+++ b/android/guava/src/com/google/common/collect/Maps.java
@@ -21,8 +21,6 @@
import static com.google.common.base.Predicates.compose;
import static com.google.common.collect.CollectPreconditions.checkEntryNotNull;
import static com.google.common.collect.CollectPreconditions.checkNonnegative;
-import static com.google.common.collect.NullnessCasts.uncheckedCastNullableTToT;
-import static java.util.Objects.requireNonNull;
import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtCompatible;
@@ -63,8 +61,7 @@
import java.util.TreeMap;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* Static utility methods pertaining to {@link Map} instances (including instances of {@link
@@ -81,21 +78,20 @@
* @since 2.0
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
public final class Maps {
private Maps() {}
- private enum EntryFunction implements Function<Entry<?, ?>, @Nullable Object> {
+ private enum EntryFunction implements Function<Entry<?, ?>, Object> {
KEY {
@Override
- @CheckForNull
+ @NullableDecl
public Object apply(Entry<?, ?> entry) {
return entry.getKey();
}
},
VALUE {
@Override
- @CheckForNull
+ @NullableDecl
public Object apply(Entry<?, ?> entry) {
return entry.getValue();
}
@@ -103,31 +99,27 @@
}
@SuppressWarnings("unchecked")
- static <K extends @Nullable Object> Function<Entry<K, ?>, K> keyFunction() {
+ static <K> Function<Entry<K, ?>, K> keyFunction() {
return (Function) EntryFunction.KEY;
}
@SuppressWarnings("unchecked")
- static <V extends @Nullable Object> Function<Entry<?, V>, V> valueFunction() {
+ static <V> Function<Entry<?, V>, V> valueFunction() {
return (Function) EntryFunction.VALUE;
}
- static <K extends @Nullable Object, V extends @Nullable Object> Iterator<K> keyIterator(
- Iterator<Entry<K, V>> entryIterator) {
+ static <K, V> Iterator<K> keyIterator(Iterator<Entry<K, V>> entryIterator) {
return new TransformedIterator<Entry<K, V>, K>(entryIterator) {
@Override
- @ParametricNullness
K transform(Entry<K, V> entry) {
return entry.getKey();
}
};
}
- static <K extends @Nullable Object, V extends @Nullable Object> Iterator<V> valueIterator(
- Iterator<Entry<K, V>> entryIterator) {
+ static <K, V> Iterator<V> valueIterator(Iterator<Entry<K, V>> entryIterator) {
return new TransformedIterator<Entry<K, V>, V>(entryIterator) {
@Override
- @ParametricNullness
V transform(Entry<K, V> entry) {
return entry.getValue();
}
@@ -187,8 +179,7 @@
*
* @return a new, empty {@code HashMap}
*/
- public static <K extends @Nullable Object, V extends @Nullable Object>
- HashMap<K, V> newHashMap() {
+ public static <K, V> HashMap<K, V> newHashMap() {
return new HashMap<>();
}
@@ -206,8 +197,7 @@
* @param map the mappings to be placed in the new map
* @return a new {@code HashMap} initialized with the mappings from {@code map}
*/
- public static <K extends @Nullable Object, V extends @Nullable Object> HashMap<K, V> newHashMap(
- Map<? extends K, ? extends V> map) {
+ public static <K, V> HashMap<K, V> newHashMap(Map<? extends K, ? extends V> map) {
return new HashMap<>(map);
}
@@ -222,8 +212,7 @@
* without resizing
* @throws IllegalArgumentException if {@code expectedSize} is negative
*/
- public static <K extends @Nullable Object, V extends @Nullable Object>
- HashMap<K, V> newHashMapWithExpectedSize(int expectedSize) {
+ public static <K, V> HashMap<K, V> newHashMapWithExpectedSize(int expectedSize) {
return new HashMap<>(capacity(expectedSize));
}
@@ -256,8 +245,7 @@
*
* @return a new, empty {@code LinkedHashMap}
*/
- public static <K extends @Nullable Object, V extends @Nullable Object>
- LinkedHashMap<K, V> newLinkedHashMap() {
+ public static <K, V> LinkedHashMap<K, V> newLinkedHashMap() {
return new LinkedHashMap<>();
}
@@ -274,8 +262,7 @@
* @param map the mappings to be placed in the new map
* @return a new, {@code LinkedHashMap} initialized with the mappings from {@code map}
*/
- public static <K extends @Nullable Object, V extends @Nullable Object>
- LinkedHashMap<K, V> newLinkedHashMap(Map<? extends K, ? extends V> map) {
+ public static <K, V> LinkedHashMap<K, V> newLinkedHashMap(Map<? extends K, ? extends V> map) {
return new LinkedHashMap<>(map);
}
@@ -291,8 +278,7 @@
* @throws IllegalArgumentException if {@code expectedSize} is negative
* @since 19.0
*/
- public static <K extends @Nullable Object, V extends @Nullable Object>
- LinkedHashMap<K, V> newLinkedHashMapWithExpectedSize(int expectedSize) {
+ public static <K, V> LinkedHashMap<K, V> newLinkedHashMapWithExpectedSize(int expectedSize) {
return new LinkedHashMap<>(capacity(expectedSize));
}
@@ -317,7 +303,7 @@
*
* @return a new, empty {@code TreeMap}
*/
- public static <K extends Comparable, V extends @Nullable Object> TreeMap<K, V> newTreeMap() {
+ public static <K extends Comparable, V> TreeMap<K, V> newTreeMap() {
return new TreeMap<>();
}
@@ -337,8 +323,7 @@
* @return a new {@code TreeMap} initialized with the mappings from {@code map} and using the
* comparator of {@code map}
*/
- public static <K extends @Nullable Object, V extends @Nullable Object> TreeMap<K, V> newTreeMap(
- SortedMap<K, ? extends V> map) {
+ public static <K, V> TreeMap<K, V> newTreeMap(SortedMap<K, ? extends V> map) {
return new TreeMap<>(map);
}
@@ -355,8 +340,8 @@
* @param comparator the comparator to sort the keys with
* @return a new, empty {@code TreeMap}
*/
- public static <C extends @Nullable Object, K extends C, V extends @Nullable Object>
- TreeMap<K, V> newTreeMap(@CheckForNull Comparator<C> comparator) {
+ public static <C, K extends C, V> TreeMap<K, V> newTreeMap(
+ @NullableDecl Comparator<C> 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:
@@ -371,8 +356,7 @@
* @param type the key type for this map
* @return a new, empty {@code EnumMap}
*/
- public static <K extends Enum<K>, V extends @Nullable Object> EnumMap<K, V> newEnumMap(
- Class<K> type) {
+ public static <K extends Enum<K>, V> EnumMap<K, V> newEnumMap(Class<K> type) {
return new EnumMap<>(checkNotNull(type));
}
@@ -388,8 +372,7 @@
* @throws IllegalArgumentException if {@code m} is not an {@code EnumMap} instance and contains
* no mappings
*/
- public static <K extends Enum<K>, V extends @Nullable Object> EnumMap<K, V> newEnumMap(
- Map<K, ? extends V> map) {
+ public static <K extends Enum<K>, V> EnumMap<K, V> newEnumMap(Map<K, ? extends V> map) {
return new EnumMap<>(map);
}
@@ -402,8 +385,7 @@
*
* @return a new, empty {@code IdentityHashMap}
*/
- public static <K extends @Nullable Object, V extends @Nullable Object>
- IdentityHashMap<K, V> newIdentityHashMap() {
+ public static <K, V> IdentityHashMap<K, V> newIdentityHashMap() {
return new IdentityHashMap<>();
}
@@ -423,27 +405,13 @@
* @return the difference between the two maps
*/
@SuppressWarnings("unchecked")
- public static <K extends @Nullable Object, V extends @Nullable Object>
- MapDifference<K, V> difference(
- Map<? extends K, ? extends V> left, Map<? extends K, ? extends V> right) {
+ public static <K, V> MapDifference<K, V> difference(
+ Map<? extends K, ? extends V> left, Map<? extends K, ? extends V> right) {
if (left instanceof SortedMap) {
SortedMap<K, ? extends V> sortedLeft = (SortedMap<K, ? extends V>) left;
return difference(sortedLeft, right);
}
- /*
- * This cast is safe: The Equivalence-accepting overload of difference() (which we call below)
- * has a weird signature because Equivalence is itself a little weird. Still, we know that
- * Equivalence.equals() can handle all inputs, and we know that the resulting MapDifference will
- * contain only Ks and Vs (as opposed to possibly containing @Nullable objects even when K and V
- * are *not* @Nullable).
- *
- * An alternative to suppressing the warning would be to inline the body of the other
- * difference() method into this one.
- */
- @SuppressWarnings("nullness")
- MapDifference<K, V> result =
- (MapDifference<K, V>) difference(left, right, Equivalence.equals());
- return result;
+ return difference(left, right, Equivalence.equals());
}
/**
@@ -460,33 +428,7 @@
* @return the difference between the two maps
* @since 10.0
*/
- /*
- * This method should really be annotated to accept maps with @Nullable value types. Fortunately,
- * no existing Google callers appear to pass null values (much less pass null values *and* run a
- * nullness checker).
- *
- * Still, if we decide that we want to make that work, we'd need to introduce a new type parameter
- * for the Equivalence input type:
- *
- * <E, K extends @Nullable Object, V extends @Nullable E> ... difference(..., Equivalence<E> ...)
- *
- * Maybe we should, even though it will break source compatibility.
- *
- * Alternatively, this is a case in which it would be useful to be able to express Equivalence<?
- * super @Nonnull T>).
- *
- * As things stand now, though, we have to either:
- *
- * - require non-null inputs so that we can guarantee non-null outputs
- *
- * - accept nullable inputs but force users to cope with nullable outputs
- *
- * And the non-null option is far more useful to existing users.
- *
- * (Vaguely related: Another thing we could consider is an overload that accepts a BiPredicate:
- * https://github.com/google/guava/issues/3913)
- */
- public static <K extends @Nullable Object, V> MapDifference<K, V> difference(
+ public static <K, V> MapDifference<K, V> difference(
Map<? extends K, ? extends V> left,
Map<? extends K, ? extends V> right,
Equivalence<? super V> valueEquivalence) {
@@ -517,9 +459,8 @@
* @return the difference between the two maps
* @since 11.0
*/
- public static <K extends @Nullable Object, V extends @Nullable Object>
- SortedMapDifference<K, V> difference(
- SortedMap<K, ? extends V> left, Map<? extends K, ? extends V> right) {
+ public static <K, V> SortedMapDifference<K, V> difference(
+ SortedMap<K, ? extends V> left, Map<? extends K, ? extends V> right) {
checkNotNull(left);
checkNotNull(right);
Comparator<? super K> comparator = orNaturalOrder(left.comparator());
@@ -532,7 +473,7 @@
return new SortedMapDifferenceImpl<>(onlyOnLeft, onlyOnRight, onBoth, differences);
}
- private static <K extends @Nullable Object, V extends @Nullable Object> void doDifference(
+ private static <K, V> void doDifference(
Map<? extends K, ? extends V> left,
Map<? extends K, ? extends V> right,
Equivalence<? super V> valueEquivalence,
@@ -544,17 +485,7 @@
K leftKey = entry.getKey();
V leftValue = entry.getValue();
if (right.containsKey(leftKey)) {
- /*
- * The cast is safe because onlyOnRight contains all the keys of right.
- *
- * TODO(cpovirk): Consider checking onlyOnRight.containsKey instead of right.containsKey.
- * That could change behavior if the input maps use different equivalence relations (and so
- * a key that appears once in `right` might appear multiple times in `left`). We don't
- * guarantee behavior in that case, anyway, and the current behavior is likely undesirable.
- * So that's either a reason to feel free to change it or a reason to not bother thinking
- * further about this.
- */
- V rightValue = uncheckedCastNullableTToT(onlyOnRight.remove(leftKey));
+ V rightValue = onlyOnRight.remove(leftKey);
if (valueEquivalence.equivalent(leftValue, rightValue)) {
onBoth.put(leftKey, leftValue);
} else {
@@ -566,8 +497,7 @@
}
}
- private static <K extends @Nullable Object, V extends @Nullable Object> Map<K, V> unmodifiableMap(
- Map<K, ? extends V> map) {
+ private static <K, V> Map<K, V> unmodifiableMap(Map<K, ? extends V> map) {
if (map instanceof SortedMap) {
return Collections.unmodifiableSortedMap((SortedMap<K, ? extends V>) map);
} else {
@@ -575,8 +505,7 @@
}
}
- static class MapDifferenceImpl<K extends @Nullable Object, V extends @Nullable Object>
- implements MapDifference<K, V> {
+ static class MapDifferenceImpl<K, V> implements MapDifference<K, V> {
final Map<K, V> onlyOnLeft;
final Map<K, V> onlyOnRight;
final Map<K, V> onBoth;
@@ -619,7 +548,7 @@
}
@Override
- public boolean equals(@CheckForNull Object object) {
+ public boolean equals(Object object) {
if (object == this) {
return true;
}
@@ -659,35 +588,31 @@
}
}
- static class ValueDifferenceImpl<V extends @Nullable Object>
- implements MapDifference.ValueDifference<V> {
- @ParametricNullness private final V left;
- @ParametricNullness private final V right;
+ static class ValueDifferenceImpl<V> implements MapDifference.ValueDifference<V> {
+ @NullableDecl private final V left;
+ @NullableDecl private final V right;
- static <V extends @Nullable Object> ValueDifference<V> create(
- @ParametricNullness V left, @ParametricNullness V right) {
+ static <V> ValueDifference<V> create(@NullableDecl V left, @NullableDecl V right) {
return new ValueDifferenceImpl<V>(left, right);
}
- private ValueDifferenceImpl(@ParametricNullness V left, @ParametricNullness V right) {
+ private ValueDifferenceImpl(@NullableDecl V left, @NullableDecl V right) {
this.left = left;
this.right = right;
}
@Override
- @ParametricNullness
public V leftValue() {
return left;
}
@Override
- @ParametricNullness
public V rightValue() {
return right;
}
@Override
- public boolean equals(@CheckForNull Object object) {
+ public boolean equals(@NullableDecl Object object) {
if (object instanceof MapDifference.ValueDifference) {
MapDifference.ValueDifference<?> that = (MapDifference.ValueDifference<?>) object;
return Objects.equal(this.left, that.leftValue())
@@ -707,8 +632,8 @@
}
}
- static class SortedMapDifferenceImpl<K extends @Nullable Object, V extends @Nullable Object>
- extends MapDifferenceImpl<K, V> implements SortedMapDifference<K, V> {
+ static class SortedMapDifferenceImpl<K, V> extends MapDifferenceImpl<K, V>
+ implements SortedMapDifference<K, V> {
SortedMapDifferenceImpl(
SortedMap<K, V> onlyOnLeft,
SortedMap<K, V> onlyOnRight,
@@ -744,8 +669,7 @@
* ugly type-casting in one place.
*/
@SuppressWarnings("unchecked")
- static <E extends @Nullable Object> Comparator<? super E> orNaturalOrder(
- @CheckForNull Comparator<? super E> comparator) {
+ static <E> Comparator<? super E> orNaturalOrder(@NullableDecl Comparator<? super E> comparator) {
if (comparator != null) { // can't use ? : because of javac bug 5080917
return comparator;
}
@@ -776,8 +700,7 @@
*
* @since 14.0
*/
- public static <K extends @Nullable Object, V extends @Nullable Object> Map<K, V> asMap(
- Set<K> set, Function<? super K, V> function) {
+ public static <K, V> Map<K, V> asMap(Set<K> set, Function<? super K, V> function) {
return new AsMapView<>(set, function);
}
@@ -804,8 +727,7 @@
*
* @since 14.0
*/
- public static <K extends @Nullable Object, V extends @Nullable Object> SortedMap<K, V> asMap(
- SortedSet<K> set, Function<? super K, V> function) {
+ public static <K, V> SortedMap<K, V> asMap(SortedSet<K> set, Function<? super K, V> function) {
return new SortedAsMapView<>(set, function);
}
@@ -833,13 +755,12 @@
* @since 14.0
*/
@GwtIncompatible // NavigableMap
- public static <K extends @Nullable Object, V extends @Nullable Object> NavigableMap<K, V> asMap(
+ public static <K, V> NavigableMap<K, V> asMap(
NavigableSet<K> set, Function<? super K, V> function) {
return new NavigableAsMapView<>(set, function);
}
- private static class AsMapView<K extends @Nullable Object, V extends @Nullable Object>
- extends ViewCachingAbstractMap<K, V> {
+ private static class AsMapView<K, V> extends ViewCachingAbstractMap<K, V> {
private final Set<K> set;
final Function<? super K, V> function;
@@ -869,13 +790,12 @@
}
@Override
- public boolean containsKey(@CheckForNull Object key) {
+ public boolean containsKey(@NullableDecl Object key) {
return backingSet().contains(key);
}
@Override
- @CheckForNull
- public V get(@CheckForNull Object key) {
+ public V get(@NullableDecl Object key) {
if (Collections2.safeContains(backingSet(), key)) {
@SuppressWarnings("unchecked") // unsafe, but Javadoc warns about it
K k = (K) key;
@@ -886,8 +806,7 @@
}
@Override
- @CheckForNull
- public V remove(@CheckForNull Object key) {
+ public V remove(@NullableDecl Object key) {
if (backingSet().remove(key)) {
@SuppressWarnings("unchecked") // unsafe, but Javadoc warns about it
K k = (K) key;
@@ -920,18 +839,17 @@
}
}
- static <K extends @Nullable Object, V extends @Nullable Object>
- Iterator<Entry<K, V>> asMapEntryIterator(Set<K> set, final Function<? super K, V> function) {
+ static <K, V> Iterator<Entry<K, V>> asMapEntryIterator(
+ Set<K> set, final Function<? super K, V> function) {
return new TransformedIterator<K, Entry<K, V>>(set.iterator()) {
@Override
- Entry<K, V> transform(@ParametricNullness final K key) {
+ Entry<K, V> transform(final K key) {
return immutableEntry(key, function.apply(key));
}
};
}
- private static class SortedAsMapView<K extends @Nullable Object, V extends @Nullable Object>
- extends AsMapView<K, V> implements SortedMap<K, V> {
+ private static class SortedAsMapView<K, V> extends AsMapView<K, V> implements SortedMap<K, V> {
SortedAsMapView(SortedSet<K> set, Function<? super K, V> function) {
super(set, function);
@@ -943,7 +861,6 @@
}
@Override
- @CheckForNull
public Comparator<? super K> comparator() {
return backingSet().comparator();
}
@@ -954,37 +871,33 @@
}
@Override
- public SortedMap<K, V> subMap(@ParametricNullness K fromKey, @ParametricNullness K toKey) {
+ public SortedMap<K, V> subMap(K fromKey, K toKey) {
return asMap(backingSet().subSet(fromKey, toKey), function);
}
@Override
- public SortedMap<K, V> headMap(@ParametricNullness K toKey) {
+ public SortedMap<K, V> headMap(K toKey) {
return asMap(backingSet().headSet(toKey), function);
}
@Override
- public SortedMap<K, V> tailMap(@ParametricNullness K fromKey) {
+ public SortedMap<K, V> tailMap(K fromKey) {
return asMap(backingSet().tailSet(fromKey), function);
}
@Override
- @ParametricNullness
public K firstKey() {
return backingSet().first();
}
@Override
- @ParametricNullness
public K lastKey() {
return backingSet().last();
}
}
@GwtIncompatible // NavigableMap
- private static final class NavigableAsMapView<
- K extends @Nullable Object, V extends @Nullable Object>
- extends AbstractNavigableMap<K, V> {
+ private static final class NavigableAsMapView<K, V> extends AbstractNavigableMap<K, V> {
/*
* Using AbstractNavigableMap is simpler than extending SortedAsMapView and rewriting all the
* NavigableMap methods.
@@ -1000,32 +913,28 @@
@Override
public NavigableMap<K, V> subMap(
- @ParametricNullness K fromKey,
- boolean fromInclusive,
- @ParametricNullness K toKey,
- boolean toInclusive) {
+ K fromKey, boolean fromInclusive, K toKey, boolean toInclusive) {
return asMap(set.subSet(fromKey, fromInclusive, toKey, toInclusive), function);
}
@Override
- public NavigableMap<K, V> headMap(@ParametricNullness K toKey, boolean inclusive) {
+ public NavigableMap<K, V> headMap(K toKey, boolean inclusive) {
return asMap(set.headSet(toKey, inclusive), function);
}
@Override
- public NavigableMap<K, V> tailMap(@ParametricNullness K fromKey, boolean inclusive) {
+ public NavigableMap<K, V> tailMap(K fromKey, boolean inclusive) {
return asMap(set.tailSet(fromKey, inclusive), function);
}
@Override
- @CheckForNull
public Comparator<? super K> comparator() {
return set.comparator();
}
@Override
- @CheckForNull
- public V get(@CheckForNull Object key) {
+ @NullableDecl
+ public V get(@NullableDecl Object key) {
if (Collections2.safeContains(set, key)) {
@SuppressWarnings("unchecked") // unsafe, but Javadoc warns about it
K k = (K) key;
@@ -1066,7 +975,7 @@
}
}
- private static <E extends @Nullable Object> Set<E> removeOnlySet(final Set<E> set) {
+ private static <E> Set<E> removeOnlySet(final Set<E> set) {
return new ForwardingSet<E>() {
@Override
protected Set<E> delegate() {
@@ -1074,7 +983,7 @@
}
@Override
- public boolean add(@ParametricNullness E element) {
+ public boolean add(E element) {
throw new UnsupportedOperationException();
}
@@ -1085,8 +994,7 @@
};
}
- private static <E extends @Nullable Object> SortedSet<E> removeOnlySortedSet(
- final SortedSet<E> set) {
+ private static <E> SortedSet<E> removeOnlySortedSet(final SortedSet<E> set) {
return new ForwardingSortedSet<E>() {
@Override
protected SortedSet<E> delegate() {
@@ -1094,7 +1002,7 @@
}
@Override
- public boolean add(@ParametricNullness E element) {
+ public boolean add(E element) {
throw new UnsupportedOperationException();
}
@@ -1104,26 +1012,24 @@
}
@Override
- public SortedSet<E> headSet(@ParametricNullness E toElement) {
+ public SortedSet<E> headSet(E toElement) {
return removeOnlySortedSet(super.headSet(toElement));
}
@Override
- public SortedSet<E> subSet(
- @ParametricNullness E fromElement, @ParametricNullness E toElement) {
+ public SortedSet<E> subSet(E fromElement, E toElement) {
return removeOnlySortedSet(super.subSet(fromElement, toElement));
}
@Override
- public SortedSet<E> tailSet(@ParametricNullness E fromElement) {
+ public SortedSet<E> tailSet(E fromElement) {
return removeOnlySortedSet(super.tailSet(fromElement));
}
};
}
@GwtIncompatible // NavigableSet
- private static <E extends @Nullable Object> NavigableSet<E> removeOnlyNavigableSet(
- final NavigableSet<E> set) {
+ private static <E> NavigableSet<E> removeOnlyNavigableSet(final NavigableSet<E> set) {
return new ForwardingNavigableSet<E>() {
@Override
protected NavigableSet<E> delegate() {
@@ -1131,7 +1037,7 @@
}
@Override
- public boolean add(@ParametricNullness E element) {
+ public boolean add(E element) {
throw new UnsupportedOperationException();
}
@@ -1141,38 +1047,34 @@
}
@Override
- public SortedSet<E> headSet(@ParametricNullness E toElement) {
+ public SortedSet<E> headSet(E toElement) {
return removeOnlySortedSet(super.headSet(toElement));
}
@Override
- public NavigableSet<E> headSet(@ParametricNullness E toElement, boolean inclusive) {
+ public NavigableSet<E> headSet(E toElement, boolean inclusive) {
return removeOnlyNavigableSet(super.headSet(toElement, inclusive));
}
@Override
- public SortedSet<E> subSet(
- @ParametricNullness E fromElement, @ParametricNullness E toElement) {
+ public SortedSet<E> subSet(E fromElement, E toElement) {
return removeOnlySortedSet(super.subSet(fromElement, toElement));
}
@Override
public NavigableSet<E> subSet(
- @ParametricNullness E fromElement,
- boolean fromInclusive,
- @ParametricNullness E toElement,
- boolean toInclusive) {
+ E fromElement, boolean fromInclusive, E toElement, boolean toInclusive) {
return removeOnlyNavigableSet(
super.subSet(fromElement, fromInclusive, toElement, toInclusive));
}
@Override
- public SortedSet<E> tailSet(@ParametricNullness E fromElement) {
+ public SortedSet<E> tailSet(E fromElement) {
return removeOnlySortedSet(super.tailSet(fromElement));
}
@Override
- public NavigableSet<E> tailSet(@ParametricNullness E fromElement, boolean inclusive) {
+ public NavigableSet<E> tailSet(E fromElement, boolean inclusive) {
return removeOnlyNavigableSet(super.tailSet(fromElement, inclusive));
}
@@ -1318,42 +1220,16 @@
*
* @param properties a {@code Properties} object to be converted
* @return an immutable map containing all the entries in {@code properties}
- * @throws ClassCastException if any key in {@code properties} is not a {@code String}
- * @throws NullPointerException if any key or value in {@code properties} is null
+ * @throws ClassCastException if any key in {@code Properties} is not a {@code String}
+ * @throws NullPointerException if any key or value in {@code Properties} is null
*/
@GwtIncompatible // java.util.Properties
public static ImmutableMap<String, String> fromProperties(Properties properties) {
ImmutableMap.Builder<String, String> builder = ImmutableMap.builder();
for (Enumeration<?> e = properties.propertyNames(); e.hasMoreElements(); ) {
- /*
- * requireNonNull is safe because propertyNames contains only non-null elements.
- *
- * Accordingly, we have it annotated as returning `Enumeration<? extends Object>` in our
- * prototype checker's JDK. However, the checker still sees the return type as plain
- * `Enumeration<?>`, probably because of one of the following two bugs (and maybe those two
- * bugs are themselves just symptoms of the same underlying problem):
- *
- * https://github.com/typetools/checker-framework/issues/3030
- *
- * https://github.com/typetools/checker-framework/issues/3236
- */
- String key = (String) requireNonNull(e.nextElement());
- /*
- * requireNonNull is safe because the key came from propertyNames...
- *
- * ...except that it's possible for users to insert a string key with a non-string value, and
- * in that case, getProperty *will* return null.
- *
- * TODO(b/192002623): Handle that case: Either:
- *
- * - Skip non-string keys and values entirely, as proposed in the linked bug.
- *
- * - Throw ClassCastException instead of NullPointerException, as documented in the current
- * Javadoc. (Note that we can't necessarily "just" change our call to `getProperty` to `get`
- * because `get` does not consult the default properties.)
- */
- builder.put(key, requireNonNull(properties.getProperty(key)));
+ String key = (String) e.nextElement();
+ builder.put(key, properties.getProperty(key));
}
return builder.build();
@@ -1372,8 +1248,7 @@
* @param value the value to be associated with the returned entry
*/
@GwtCompatible(serializable = true)
- public static <K extends @Nullable Object, V extends @Nullable Object> Entry<K, V> immutableEntry(
- @ParametricNullness K key, @ParametricNullness V value) {
+ public static <K, V> Entry<K, V> immutableEntry(@NullableDecl K key, @NullableDecl V value) {
return new ImmutableEntry<>(key, value);
}
@@ -1385,8 +1260,7 @@
* @param entrySet the entries for which to return an unmodifiable view
* @return an unmodifiable view of the entries
*/
- static <K extends @Nullable Object, V extends @Nullable Object>
- Set<Entry<K, V>> unmodifiableEntrySet(Set<Entry<K, V>> entrySet) {
+ static <K, V> Set<Entry<K, V>> unmodifiableEntrySet(Set<Entry<K, V>> entrySet) {
return new UnmodifiableEntrySet<>(Collections.unmodifiableSet(entrySet));
}
@@ -1399,27 +1273,23 @@
* @param entry the entry for which to return an unmodifiable view
* @return an unmodifiable view of the entry
*/
- static <K extends @Nullable Object, V extends @Nullable Object> Entry<K, V> unmodifiableEntry(
- final Entry<? extends K, ? extends V> entry) {
+ static <K, V> Entry<K, V> unmodifiableEntry(final Entry<? extends K, ? extends V> entry) {
checkNotNull(entry);
return new AbstractMapEntry<K, V>() {
@Override
- @ParametricNullness
public K getKey() {
return entry.getKey();
}
@Override
- @ParametricNullness
public V getValue() {
return entry.getValue();
}
};
}
- static <K extends @Nullable Object, V extends @Nullable Object>
- UnmodifiableIterator<Entry<K, V>> unmodifiableEntryIterator(
- final Iterator<Entry<K, V>> entryIterator) {
+ static <K, V> UnmodifiableIterator<Entry<K, V>> unmodifiableEntryIterator(
+ final Iterator<Entry<K, V>> entryIterator) {
return new UnmodifiableIterator<Entry<K, V>>() {
@Override
public boolean hasNext() {
@@ -1434,8 +1304,7 @@
}
/** @see Multimaps#unmodifiableEntries */
- static class UnmodifiableEntries<K extends @Nullable Object, V extends @Nullable Object>
- extends ForwardingCollection<Entry<K, V>> {
+ static class UnmodifiableEntries<K, V> extends ForwardingCollection<Entry<K, V>> {
private final Collection<Entry<K, V>> entries;
UnmodifiableEntries(Collection<Entry<K, V>> entries) {
@@ -1456,26 +1325,18 @@
@Override
public Object[] toArray() {
- /*
- * standardToArray returns `@Nullable Object[]` rather than `Object[]` but only because it can
- * be used with collections that may contain null. This collection never contains nulls, so we
- * can treat it as a plain `Object[]`.
- */
- @SuppressWarnings("nullness")
- Object[] result = standardToArray();
- return result;
+ return standardToArray();
}
@Override
- @SuppressWarnings("nullness") // b/192354773 in our checker affects toArray declarations
- public <T extends @Nullable Object> T[] toArray(T[] array) {
+ public <T> T[] toArray(T[] array) {
return standardToArray(array);
}
}
/** @see Maps#unmodifiableEntrySet(Set) */
- static class UnmodifiableEntrySet<K extends @Nullable Object, V extends @Nullable Object>
- extends UnmodifiableEntries<K, V> implements Set<Entry<K, V>> {
+ static class UnmodifiableEntrySet<K, V> extends UnmodifiableEntries<K, V>
+ implements Set<Entry<K, V>> {
UnmodifiableEntrySet(Set<Entry<K, V>> entries) {
super(entries);
}
@@ -1483,7 +1344,7 @@
// See java.util.Collections.UnmodifiableEntrySet for details on attacks.
@Override
- public boolean equals(@CheckForNull Object object) {
+ public boolean equals(@NullableDecl Object object) {
return Sets.equalsImpl(this, object);
}
@@ -1531,7 +1392,7 @@
}
@Override
- public boolean equals(@CheckForNull Object object) {
+ public boolean equals(@NullableDecl Object object) {
if (object instanceof BiMapConverter) {
BiMapConverter<?, ?> that = (BiMapConverter<?, ?>) object;
return this.bimap.equals(that.bimap);
@@ -1582,8 +1443,7 @@
* @param bimap the bimap to be wrapped in a synchronized view
* @return a synchronized view of the specified bimap
*/
- public static <K extends @Nullable Object, V extends @Nullable Object>
- BiMap<K, V> synchronizedBiMap(BiMap<K, V> bimap) {
+ public static <K, V> BiMap<K, V> synchronizedBiMap(BiMap<K, V> bimap) {
return Synchronized.biMap(bimap, null);
}
@@ -1598,20 +1458,19 @@
* @param bimap the bimap for which an unmodifiable view is to be returned
* @return an unmodifiable view of the specified bimap
*/
- public static <K extends @Nullable Object, V extends @Nullable Object>
- BiMap<K, V> unmodifiableBiMap(BiMap<? extends K, ? extends V> bimap) {
+ public static <K, V> BiMap<K, V> unmodifiableBiMap(BiMap<? extends K, ? extends V> bimap) {
return new UnmodifiableBiMap<>(bimap, null);
}
/** @see Maps#unmodifiableBiMap(BiMap) */
- private static class UnmodifiableBiMap<K extends @Nullable Object, V extends @Nullable Object>
- extends ForwardingMap<K, V> implements BiMap<K, V>, Serializable {
+ private static class UnmodifiableBiMap<K, V> extends ForwardingMap<K, V>
+ implements BiMap<K, V>, Serializable {
final Map<K, V> unmodifiableMap;
final BiMap<? extends K, ? extends V> delegate;
- @RetainedWith @CheckForNull BiMap<V, K> inverse;
- @CheckForNull transient Set<V> values;
+ @RetainedWith @NullableDecl BiMap<V, K> inverse;
+ @NullableDecl transient Set<V> values;
- UnmodifiableBiMap(BiMap<? extends K, ? extends V> delegate, @CheckForNull BiMap<V, K> inverse) {
+ UnmodifiableBiMap(BiMap<? extends K, ? extends V> delegate, @NullableDecl BiMap<V, K> inverse) {
unmodifiableMap = Collections.unmodifiableMap(delegate);
this.delegate = delegate;
this.inverse = inverse;
@@ -1623,8 +1482,7 @@
}
@Override
- @CheckForNull
- public V forcePut(@ParametricNullness K key, @ParametricNullness V value) {
+ public V forcePut(K key, V value) {
throw new UnsupportedOperationException();
}
@@ -1678,9 +1536,8 @@
* function} should be fast. To avoid lazy evaluation when the returned map doesn't need to be a
* view, copy the returned map into a new map of your choosing.
*/
- public static <
- K extends @Nullable Object, V1 extends @Nullable Object, V2 extends @Nullable Object>
- Map<K, V2> transformValues(Map<K, V1> fromMap, Function<? super V1, V2> function) {
+ public static <K, V1, V2> Map<K, V2> transformValues(
+ Map<K, V1> fromMap, Function<? super V1, V2> function) {
return transformEntries(fromMap, asEntryTransformer(function));
}
@@ -1720,10 +1577,8 @@
*
* @since 11.0
*/
- public static <
- K extends @Nullable Object, V1 extends @Nullable Object, V2 extends @Nullable Object>
- SortedMap<K, V2> transformValues(
- SortedMap<K, V1> fromMap, Function<? super V1, V2> function) {
+ public static <K, V1, V2> SortedMap<K, V2> transformValues(
+ SortedMap<K, V1> fromMap, Function<? super V1, V2> function) {
return transformEntries(fromMap, asEntryTransformer(function));
}
@@ -1766,10 +1621,8 @@
* @since 13.0
*/
@GwtIncompatible // NavigableMap
- public static <
- K extends @Nullable Object, V1 extends @Nullable Object, V2 extends @Nullable Object>
- NavigableMap<K, V2> transformValues(
- NavigableMap<K, V1> fromMap, Function<? super V1, V2> function) {
+ public static <K, V1, V2> NavigableMap<K, V2> transformValues(
+ NavigableMap<K, V1> fromMap, Function<? super V1, V2> function) {
return transformEntries(fromMap, asEntryTransformer(function));
}
@@ -1820,10 +1673,8 @@
*
* @since 7.0
*/
- public static <
- K extends @Nullable Object, V1 extends @Nullable Object, V2 extends @Nullable Object>
- Map<K, V2> transformEntries(
- Map<K, V1> fromMap, EntryTransformer<? super K, ? super V1, V2> transformer) {
+ public static <K, V1, V2> Map<K, V2> transformEntries(
+ Map<K, V1> fromMap, EntryTransformer<? super K, ? super V1, V2> transformer) {
return new TransformedEntriesMap<>(fromMap, transformer);
}
@@ -1874,10 +1725,8 @@
*
* @since 11.0
*/
- public static <
- K extends @Nullable Object, V1 extends @Nullable Object, V2 extends @Nullable Object>
- SortedMap<K, V2> transformEntries(
- SortedMap<K, V1> fromMap, EntryTransformer<? super K, ? super V1, V2> transformer) {
+ public static <K, V1, V2> SortedMap<K, V2> transformEntries(
+ SortedMap<K, V1> fromMap, EntryTransformer<? super K, ? super V1, V2> transformer) {
return new TransformedEntriesSortedMap<>(fromMap, transformer);
}
@@ -1930,10 +1779,8 @@
* @since 13.0
*/
@GwtIncompatible // NavigableMap
- public static <
- K extends @Nullable Object, V1 extends @Nullable Object, V2 extends @Nullable Object>
- NavigableMap<K, V2> transformEntries(
- NavigableMap<K, V1> fromMap, EntryTransformer<? super K, ? super V1, V2> transformer) {
+ public static <K, V1, V2> NavigableMap<K, V2> transformEntries(
+ NavigableMap<K, V1> fromMap, EntryTransformer<? super K, ? super V1, V2> transformer) {
return new TransformedEntriesNavigableMap<>(fromMap, transformer);
}
@@ -1946,8 +1793,7 @@
* @param <V2> the value type of the output entry
* @since 7.0
*/
- public interface EntryTransformer<
- K extends @Nullable Object, V1 extends @Nullable Object, V2 extends @Nullable Object> {
+ public interface EntryTransformer<K, V1, V2> {
/**
* Determines an output value based on a key-value pair. This method is <i>generally
* expected</i>, but not absolutely required, to have the following properties:
@@ -1962,43 +1808,38 @@
* @throws NullPointerException if the key or value is null and this transformer does not accept
* null arguments
*/
- V2 transformEntry(@ParametricNullness K key, @ParametricNullness V1 value);
+ V2 transformEntry(@NullableDecl K key, @NullableDecl V1 value);
}
/** Views a function as an entry transformer that ignores the entry key. */
- static <K extends @Nullable Object, V1 extends @Nullable Object, V2 extends @Nullable Object>
- EntryTransformer<K, V1, V2> asEntryTransformer(final Function<? super V1, V2> function) {
+ static <K, V1, V2> EntryTransformer<K, V1, V2> asEntryTransformer(
+ final Function<? super V1, V2> function) {
checkNotNull(function);
return new EntryTransformer<K, V1, V2>() {
@Override
- @ParametricNullness
- public V2 transformEntry(@ParametricNullness K key, @ParametricNullness V1 value) {
+ public V2 transformEntry(K key, V1 value) {
return function.apply(value);
}
};
}
- static <K extends @Nullable Object, V1 extends @Nullable Object, V2 extends @Nullable Object>
- Function<V1, V2> asValueToValueFunction(
- final EntryTransformer<? super K, V1, V2> transformer, @ParametricNullness final K key) {
+ static <K, V1, V2> Function<V1, V2> asValueToValueFunction(
+ final EntryTransformer<? super K, V1, V2> transformer, final K key) {
checkNotNull(transformer);
return new Function<V1, V2>() {
@Override
- @ParametricNullness
- public V2 apply(@ParametricNullness V1 v1) {
+ public V2 apply(@NullableDecl V1 v1) {
return transformer.transformEntry(key, v1);
}
};
}
/** Views an entry transformer as a function from {@code Entry} to values. */
- static <K extends @Nullable Object, V1 extends @Nullable Object, V2 extends @Nullable Object>
- Function<Entry<K, V1>, V2> asEntryToValueFunction(
- final EntryTransformer<? super K, ? super V1, V2> transformer) {
+ static <K, V1, V2> Function<Entry<K, V1>, V2> asEntryToValueFunction(
+ final EntryTransformer<? super K, ? super V1, V2> transformer) {
checkNotNull(transformer);
return new Function<Entry<K, V1>, V2>() {
@Override
- @ParametricNullness
public V2 apply(Entry<K, V1> entry) {
return transformer.transformEntry(entry.getKey(), entry.getValue());
}
@@ -2006,20 +1847,17 @@
}
/** Returns a view of an entry transformed by the specified transformer. */
- static <V2 extends @Nullable Object, K extends @Nullable Object, V1 extends @Nullable Object>
- Entry<K, V2> transformEntry(
- final EntryTransformer<? super K, ? super V1, V2> transformer, final Entry<K, V1> entry) {
+ static <V2, K, V1> Entry<K, V2> transformEntry(
+ final EntryTransformer<? super K, ? super V1, V2> transformer, final Entry<K, V1> entry) {
checkNotNull(transformer);
checkNotNull(entry);
return new AbstractMapEntry<K, V2>() {
@Override
- @ParametricNullness
public K getKey() {
return entry.getKey();
}
@Override
- @ParametricNullness
public V2 getValue() {
return transformer.transformEntry(entry.getKey(), entry.getValue());
}
@@ -2027,9 +1865,8 @@
}
/** Views an entry transformer as a function from entries to entries. */
- static <K extends @Nullable Object, V1 extends @Nullable Object, V2 extends @Nullable Object>
- Function<Entry<K, V1>, Entry<K, V2>> asEntryToEntryFunction(
- final EntryTransformer<? super K, ? super V1, V2> transformer) {
+ static <K, V1, V2> Function<Entry<K, V1>, Entry<K, V2>> asEntryToEntryFunction(
+ final EntryTransformer<? super K, ? super V1, V2> transformer) {
checkNotNull(transformer);
return new Function<Entry<K, V1>, Entry<K, V2>>() {
@Override
@@ -2039,9 +1876,7 @@
};
}
- static class TransformedEntriesMap<
- K extends @Nullable Object, V1 extends @Nullable Object, V2 extends @Nullable Object>
- extends IteratorBasedAbstractMap<K, V2> {
+ static class TransformedEntriesMap<K, V1, V2> extends IteratorBasedAbstractMap<K, V2> {
final Map<K, V1> fromMap;
final EntryTransformer<? super K, ? super V1, V2> transformer;
@@ -2057,31 +1892,26 @@
}
@Override
- public boolean containsKey(@CheckForNull Object key) {
+ public boolean containsKey(Object key) {
return fromMap.containsKey(key);
}
// safe as long as the user followed the <b>Warning</b> in the javadoc
@SuppressWarnings("unchecked")
@Override
- @CheckForNull
- public V2 get(@CheckForNull Object key) {
+ public V2 get(Object key) {
V1 value = fromMap.get(key);
- if (value != null || fromMap.containsKey(key)) {
- // The cast is safe because of the containsKey check.
- return transformer.transformEntry((K) key, uncheckedCastNullableTToT(value));
- }
- return null;
+ return (value != null || fromMap.containsKey(key))
+ ? transformer.transformEntry((K) key, value)
+ : null;
}
// safe as long as the user followed the <b>Warning</b> in the javadoc
@SuppressWarnings("unchecked")
@Override
- @CheckForNull
- public V2 remove(@CheckForNull Object key) {
+ public V2 remove(Object key) {
return fromMap.containsKey(key)
- // The cast is safe because of the containsKey check.
- ? transformer.transformEntry((K) key, uncheckedCastNullableTToT(fromMap.remove(key)))
+ ? transformer.transformEntry((K) key, fromMap.remove(key))
: null;
}
@@ -2107,9 +1937,8 @@
}
}
- static class TransformedEntriesSortedMap<
- K extends @Nullable Object, V1 extends @Nullable Object, V2 extends @Nullable Object>
- extends TransformedEntriesMap<K, V1, V2> implements SortedMap<K, V2> {
+ static class TransformedEntriesSortedMap<K, V1, V2> extends TransformedEntriesMap<K, V1, V2>
+ implements SortedMap<K, V2> {
protected SortedMap<K, V1> fromMap() {
return (SortedMap<K, V1>) fromMap;
@@ -2121,42 +1950,38 @@
}
@Override
- @CheckForNull
public Comparator<? super K> comparator() {
return fromMap().comparator();
}
@Override
- @ParametricNullness
public K firstKey() {
return fromMap().firstKey();
}
@Override
- public SortedMap<K, V2> headMap(@ParametricNullness K toKey) {
+ public SortedMap<K, V2> headMap(K toKey) {
return transformEntries(fromMap().headMap(toKey), transformer);
}
@Override
- @ParametricNullness
public K lastKey() {
return fromMap().lastKey();
}
@Override
- public SortedMap<K, V2> subMap(@ParametricNullness K fromKey, @ParametricNullness K toKey) {
+ public SortedMap<K, V2> subMap(K fromKey, K toKey) {
return transformEntries(fromMap().subMap(fromKey, toKey), transformer);
}
@Override
- public SortedMap<K, V2> tailMap(@ParametricNullness K fromKey) {
+ public SortedMap<K, V2> tailMap(K fromKey) {
return transformEntries(fromMap().tailMap(fromKey), transformer);
}
}
@GwtIncompatible // NavigableMap
- private static class TransformedEntriesNavigableMap<
- K extends @Nullable Object, V1 extends @Nullable Object, V2 extends @Nullable Object>
+ private static class TransformedEntriesNavigableMap<K, V1, V2>
extends TransformedEntriesSortedMap<K, V1, V2> implements NavigableMap<K, V2> {
TransformedEntriesNavigableMap(
@@ -2165,14 +1990,12 @@
}
@Override
- @CheckForNull
- public Entry<K, V2> ceilingEntry(@ParametricNullness K key) {
+ public Entry<K, V2> ceilingEntry(K key) {
return transformEntry(fromMap().ceilingEntry(key));
}
@Override
- @CheckForNull
- public K ceilingKey(@ParametricNullness K key) {
+ public K ceilingKey(K key) {
return fromMap().ceilingKey(key);
}
@@ -2187,60 +2010,52 @@
}
@Override
- @CheckForNull
public Entry<K, V2> firstEntry() {
return transformEntry(fromMap().firstEntry());
}
@Override
- @CheckForNull
- public Entry<K, V2> floorEntry(@ParametricNullness K key) {
+ public Entry<K, V2> floorEntry(K key) {
return transformEntry(fromMap().floorEntry(key));
}
@Override
- @CheckForNull
- public K floorKey(@ParametricNullness K key) {
+ public K floorKey(K key) {
return fromMap().floorKey(key);
}
@Override
- public NavigableMap<K, V2> headMap(@ParametricNullness K toKey) {
+ public NavigableMap<K, V2> headMap(K toKey) {
return headMap(toKey, false);
}
@Override
- public NavigableMap<K, V2> headMap(@ParametricNullness K toKey, boolean inclusive) {
+ public NavigableMap<K, V2> headMap(K toKey, boolean inclusive) {
return transformEntries(fromMap().headMap(toKey, inclusive), transformer);
}
@Override
- @CheckForNull
- public Entry<K, V2> higherEntry(@ParametricNullness K key) {
+ public Entry<K, V2> higherEntry(K key) {
return transformEntry(fromMap().higherEntry(key));
}
@Override
- @CheckForNull
- public K higherKey(@ParametricNullness K key) {
+ public K higherKey(K key) {
return fromMap().higherKey(key);
}
@Override
- @CheckForNull
public Entry<K, V2> lastEntry() {
return transformEntry(fromMap().lastEntry());
}
@Override
- @CheckForNull
- public Entry<K, V2> lowerEntry(@ParametricNullness K key) {
+ public Entry<K, V2> lowerEntry(K key) {
return transformEntry(fromMap().lowerEntry(key));
}
@Override
- @CheckForNull
- public K lowerKey(@ParametricNullness K key) {
+ public K lowerKey(K key) {
return fromMap().lowerKey(key);
}
@@ -2250,44 +2065,39 @@
}
@Override
- @CheckForNull
public Entry<K, V2> pollFirstEntry() {
return transformEntry(fromMap().pollFirstEntry());
}
@Override
- @CheckForNull
public Entry<K, V2> pollLastEntry() {
return transformEntry(fromMap().pollLastEntry());
}
@Override
public NavigableMap<K, V2> subMap(
- @ParametricNullness K fromKey,
- boolean fromInclusive,
- @ParametricNullness K toKey,
- boolean toInclusive) {
+ K fromKey, boolean fromInclusive, K toKey, boolean toInclusive) {
return transformEntries(
fromMap().subMap(fromKey, fromInclusive, toKey, toInclusive), transformer);
}
@Override
- public NavigableMap<K, V2> subMap(@ParametricNullness K fromKey, @ParametricNullness K toKey) {
+ public NavigableMap<K, V2> subMap(K fromKey, K toKey) {
return subMap(fromKey, true, toKey, false);
}
@Override
- public NavigableMap<K, V2> tailMap(@ParametricNullness K fromKey) {
+ public NavigableMap<K, V2> tailMap(K fromKey) {
return tailMap(fromKey, true);
}
@Override
- public NavigableMap<K, V2> tailMap(@ParametricNullness K fromKey, boolean inclusive) {
+ public NavigableMap<K, V2> tailMap(K fromKey, boolean inclusive) {
return transformEntries(fromMap().tailMap(fromKey, inclusive), transformer);
}
- @CheckForNull
- private Entry<K, V2> transformEntry(@CheckForNull Entry<K, V1> entry) {
+ @NullableDecl
+ private Entry<K, V2> transformEntry(@NullableDecl Entry<K, V1> entry) {
return (entry == null) ? null : Maps.transformEntry(transformer, entry);
}
@@ -2297,13 +2107,11 @@
}
}
- static <K extends @Nullable Object> Predicate<Entry<K, ?>> keyPredicateOnEntries(
- Predicate<? super K> keyPredicate) {
+ static <K> Predicate<Entry<K, ?>> keyPredicateOnEntries(Predicate<? super K> keyPredicate) {
return compose(keyPredicate, Maps.<K>keyFunction());
}
- static <V extends @Nullable Object> Predicate<Entry<?, V>> valuePredicateOnEntries(
- Predicate<? super V> valuePredicate) {
+ static <V> Predicate<Entry<?, V>> valuePredicateOnEntries(Predicate<? super V> valuePredicate) {
return compose(valuePredicate, Maps.<V>valueFunction());
}
@@ -2330,7 +2138,7 @@
* {@link Predicate#apply}. Do not provide a predicate such as {@code
* Predicates.instanceOf(ArrayList.class)}, which is inconsistent with equals.
*/
- public static <K extends @Nullable Object, V extends @Nullable Object> Map<K, V> filterKeys(
+ public static <K, V> Map<K, V> filterKeys(
Map<K, V> unfiltered, final Predicate<? super K> keyPredicate) {
checkNotNull(keyPredicate);
Predicate<Entry<K, ?>> entryPredicate = keyPredicateOnEntries(keyPredicate);
@@ -2365,7 +2173,7 @@
*
* @since 11.0
*/
- public static <K extends @Nullable Object, V extends @Nullable Object> SortedMap<K, V> filterKeys(
+ public static <K, V> SortedMap<K, V> filterKeys(
SortedMap<K, V> unfiltered, final Predicate<? super K> keyPredicate) {
// TODO(lowasser): Return a subclass of Maps.FilteredKeyMap for slightly better
// performance.
@@ -2399,9 +2207,8 @@
* @since 14.0
*/
@GwtIncompatible // NavigableMap
- public static <K extends @Nullable Object, V extends @Nullable Object>
- NavigableMap<K, V> filterKeys(
- NavigableMap<K, V> unfiltered, final Predicate<? super K> keyPredicate) {
+ public static <K, V> NavigableMap<K, V> filterKeys(
+ NavigableMap<K, V> unfiltered, final Predicate<? super K> keyPredicate) {
// TODO(lowasser): Return a subclass of Maps.FilteredKeyMap for slightly better
// performance.
return filterEntries(unfiltered, Maps.<K>keyPredicateOnEntries(keyPredicate));
@@ -2431,7 +2238,7 @@
*
* @since 14.0
*/
- public static <K extends @Nullable Object, V extends @Nullable Object> BiMap<K, V> filterKeys(
+ public static <K, V> BiMap<K, V> filterKeys(
BiMap<K, V> unfiltered, final Predicate<? super K> keyPredicate) {
checkNotNull(keyPredicate);
return filterEntries(unfiltered, Maps.<K>keyPredicateOnEntries(keyPredicate));
@@ -2460,7 +2267,7 @@
* at {@link Predicate#apply}. Do not provide a predicate such as {@code
* Predicates.instanceOf(ArrayList.class)}, which is inconsistent with equals.
*/
- public static <K extends @Nullable Object, V extends @Nullable Object> Map<K, V> filterValues(
+ public static <K, V> Map<K, V> filterValues(
Map<K, V> unfiltered, final Predicate<? super V> valuePredicate) {
return filterEntries(unfiltered, Maps.<V>valuePredicateOnEntries(valuePredicate));
}
@@ -2491,9 +2298,8 @@
*
* @since 11.0
*/
- public static <K extends @Nullable Object, V extends @Nullable Object>
- SortedMap<K, V> filterValues(
- SortedMap<K, V> unfiltered, final Predicate<? super V> valuePredicate) {
+ public static <K, V> SortedMap<K, V> filterValues(
+ SortedMap<K, V> unfiltered, final Predicate<? super V> valuePredicate) {
return filterEntries(unfiltered, Maps.<V>valuePredicateOnEntries(valuePredicate));
}
@@ -2524,9 +2330,8 @@
* @since 14.0
*/
@GwtIncompatible // NavigableMap
- public static <K extends @Nullable Object, V extends @Nullable Object>
- NavigableMap<K, V> filterValues(
- NavigableMap<K, V> unfiltered, final Predicate<? super V> valuePredicate) {
+ public static <K, V> NavigableMap<K, V> filterValues(
+ NavigableMap<K, V> unfiltered, final Predicate<? super V> valuePredicate) {
return filterEntries(unfiltered, Maps.<V>valuePredicateOnEntries(valuePredicate));
}
@@ -2557,7 +2362,7 @@
*
* @since 14.0
*/
- public static <K extends @Nullable Object, V extends @Nullable Object> BiMap<K, V> filterValues(
+ public static <K, V> BiMap<K, V> filterValues(
BiMap<K, V> unfiltered, final Predicate<? super V> valuePredicate) {
return filterEntries(unfiltered, Maps.<V>valuePredicateOnEntries(valuePredicate));
}
@@ -2586,7 +2391,7 @@
* <p><b>Warning:</b> {@code entryPredicate} must be <i>consistent with equals</i>, as documented
* at {@link Predicate#apply}.
*/
- public static <K extends @Nullable Object, V extends @Nullable Object> Map<K, V> filterEntries(
+ public static <K, V> Map<K, V> filterEntries(
Map<K, V> unfiltered, Predicate<? super Entry<K, V>> entryPredicate) {
checkNotNull(entryPredicate);
return (unfiltered instanceof AbstractFilteredMap)
@@ -2620,9 +2425,8 @@
*
* @since 11.0
*/
- public static <K extends @Nullable Object, V extends @Nullable Object>
- SortedMap<K, V> filterEntries(
- SortedMap<K, V> unfiltered, Predicate<? super Entry<K, V>> entryPredicate) {
+ public static <K, V> SortedMap<K, V> filterEntries(
+ SortedMap<K, V> unfiltered, Predicate<? super Entry<K, V>> entryPredicate) {
checkNotNull(entryPredicate);
return (unfiltered instanceof FilteredEntrySortedMap)
? filterFiltered((FilteredEntrySortedMap<K, V>) unfiltered, entryPredicate)
@@ -2656,9 +2460,8 @@
* @since 14.0
*/
@GwtIncompatible // NavigableMap
- public static <K extends @Nullable Object, V extends @Nullable Object>
- NavigableMap<K, V> filterEntries(
- NavigableMap<K, V> unfiltered, Predicate<? super Entry<K, V>> entryPredicate) {
+ public static <K, V> NavigableMap<K, V> filterEntries(
+ NavigableMap<K, V> unfiltered, Predicate<? super Entry<K, V>> entryPredicate) {
checkNotNull(entryPredicate);
return (unfiltered instanceof FilteredEntryNavigableMap)
? filterFiltered((FilteredEntryNavigableMap<K, V>) unfiltered, entryPredicate)
@@ -2692,7 +2495,7 @@
*
* @since 14.0
*/
- public static <K extends @Nullable Object, V extends @Nullable Object> BiMap<K, V> filterEntries(
+ public static <K, V> BiMap<K, V> filterEntries(
BiMap<K, V> unfiltered, Predicate<? super Entry<K, V>> entryPredicate) {
checkNotNull(unfiltered);
checkNotNull(entryPredicate);
@@ -2705,7 +2508,7 @@
* Support {@code clear()}, {@code removeAll()}, and {@code retainAll()} when filtering a filtered
* map.
*/
- private static <K extends @Nullable Object, V extends @Nullable Object> Map<K, V> filterFiltered(
+ private static <K, V> Map<K, V> filterFiltered(
AbstractFilteredMap<K, V> map, Predicate<? super Entry<K, V>> entryPredicate) {
return new FilteredEntryMap<>(
map.unfiltered, Predicates.<Entry<K, V>>and(map.predicate, entryPredicate));
@@ -2715,9 +2518,8 @@
* Support {@code clear()}, {@code removeAll()}, and {@code retainAll()} when filtering a filtered
* sorted map.
*/
- private static <K extends @Nullable Object, V extends @Nullable Object>
- SortedMap<K, V> filterFiltered(
- FilteredEntrySortedMap<K, V> map, Predicate<? super Entry<K, V>> entryPredicate) {
+ private static <K, V> SortedMap<K, V> filterFiltered(
+ FilteredEntrySortedMap<K, V> map, Predicate<? super Entry<K, V>> entryPredicate) {
Predicate<Entry<K, V>> predicate = Predicates.<Entry<K, V>>and(map.predicate, entryPredicate);
return new FilteredEntrySortedMap<>(map.sortedMap(), predicate);
}
@@ -2727,9 +2529,8 @@
* navigable map.
*/
@GwtIncompatible // NavigableMap
- private static <K extends @Nullable Object, V extends @Nullable Object>
- NavigableMap<K, V> filterFiltered(
- FilteredEntryNavigableMap<K, V> map, Predicate<? super Entry<K, V>> entryPredicate) {
+ private static <K, V> NavigableMap<K, V> filterFiltered(
+ FilteredEntryNavigableMap<K, V> map, Predicate<? super Entry<K, V>> entryPredicate) {
Predicate<Entry<K, V>> predicate =
Predicates.<Entry<K, V>>and(map.entryPredicate, entryPredicate);
return new FilteredEntryNavigableMap<>(map.unfiltered, predicate);
@@ -2739,16 +2540,13 @@
* Support {@code clear()}, {@code removeAll()}, and {@code retainAll()} when filtering a filtered
* map.
*/
- private static <K extends @Nullable Object, V extends @Nullable Object>
- BiMap<K, V> filterFiltered(
- FilteredEntryBiMap<K, V> map, Predicate<? super Entry<K, V>> entryPredicate) {
+ private static <K, V> BiMap<K, V> filterFiltered(
+ FilteredEntryBiMap<K, V> map, Predicate<? super Entry<K, V>> entryPredicate) {
Predicate<Entry<K, V>> predicate = Predicates.<Entry<K, V>>and(map.predicate, entryPredicate);
return new FilteredEntryBiMap<>(map.unfiltered(), predicate);
}
- private abstract static class AbstractFilteredMap<
- K extends @Nullable Object, V extends @Nullable Object>
- extends ViewCachingAbstractMap<K, V> {
+ private abstract static class AbstractFilteredMap<K, V> extends ViewCachingAbstractMap<K, V> {
final Map<K, V> unfiltered;
final Predicate<? super Entry<K, V>> predicate;
@@ -2757,17 +2555,16 @@
this.predicate = predicate;
}
- boolean apply(@CheckForNull Object key, @ParametricNullness V value) {
- // This method is called only when the key is in the map (or about to be added to the map),
- // implying that key is a K.
- @SuppressWarnings({"unchecked", "nullness"})
+ boolean apply(@NullableDecl Object key, @NullableDecl V value) {
+ // This method is called only when the key is in the map, implying that
+ // key is a K.
+ @SuppressWarnings("unchecked")
K k = (K) key;
return predicate.apply(Maps.immutableEntry(k, value));
}
@Override
- @CheckForNull
- public V put(@ParametricNullness K key, @ParametricNullness V value) {
+ public V put(K key, V value) {
checkArgument(apply(key, value));
return unfiltered.put(key, value);
}
@@ -2781,13 +2578,12 @@
}
@Override
- public boolean containsKey(@CheckForNull Object key) {
+ public boolean containsKey(Object key) {
return unfiltered.containsKey(key) && apply(key, unfiltered.get(key));
}
@Override
- @CheckForNull
- public V get(@CheckForNull Object key) {
+ public V get(Object key) {
V value = unfiltered.get(key);
return ((value != null) && apply(key, value)) ? value : null;
}
@@ -2798,8 +2594,7 @@
}
@Override
- @CheckForNull
- public V remove(@CheckForNull Object key) {
+ public V remove(Object key) {
return containsKey(key) ? unfiltered.remove(key) : null;
}
@@ -2809,9 +2604,7 @@
}
}
- private static final class FilteredMapValues<
- K extends @Nullable Object, V extends @Nullable Object>
- extends Maps.Values<K, V> {
+ private static final class FilteredMapValues<K, V> extends Maps.Values<K, V> {
final Map<K, V> unfiltered;
final Predicate<? super Entry<K, V>> predicate;
@@ -2823,7 +2616,7 @@
}
@Override
- public boolean remove(@CheckForNull Object o) {
+ public boolean remove(Object o) {
Iterator<Entry<K, V>> entryItr = unfiltered.entrySet().iterator();
while (entryItr.hasNext()) {
Entry<K, V> entry = entryItr.next();
@@ -2864,20 +2657,18 @@
}
@Override
- public @Nullable Object[] toArray() {
+ public Object[] toArray() {
// creating an ArrayList so filtering happens once
return Lists.newArrayList(iterator()).toArray();
}
@Override
- @SuppressWarnings("nullness") // b/192354773 in our checker affects toArray declarations
- public <T extends @Nullable Object> T[] toArray(T[] array) {
+ public <T> T[] toArray(T[] array) {
return Lists.newArrayList(iterator()).toArray(array);
}
}
- private static class FilteredKeyMap<K extends @Nullable Object, V extends @Nullable Object>
- extends AbstractFilteredMap<K, V> {
+ private static class FilteredKeyMap<K, V> extends AbstractFilteredMap<K, V> {
final Predicate<? super K> keyPredicate;
FilteredKeyMap(
@@ -2902,13 +2693,12 @@
// that key is a K.
@Override
@SuppressWarnings("unchecked")
- public boolean containsKey(@CheckForNull Object key) {
+ public boolean containsKey(Object key) {
return unfiltered.containsKey(key) && keyPredicate.apply((K) key);
}
}
- static class FilteredEntryMap<K extends @Nullable Object, V extends @Nullable Object>
- extends AbstractFilteredMap<K, V> {
+ static class FilteredEntryMap<K, V> extends AbstractFilteredMap<K, V> {
/**
* Entries in this set satisfy the predicate, but they don't validate the input to {@code
* Entry.setValue()}.
@@ -2944,8 +2734,7 @@
}
@Override
- @ParametricNullness
- public V setValue(@ParametricNullness V newValue) {
+ public V setValue(V newValue) {
checkArgument(apply(getKey(), newValue));
return super.setValue(newValue);
}
@@ -2960,7 +2749,7 @@
return new KeySet();
}
- static <K extends @Nullable Object, V extends @Nullable Object> boolean removeAllKeys(
+ static <K, V> boolean removeAllKeys(
Map<K, V> map, Predicate<? super Entry<K, V>> entryPredicate, Collection<?> keyCollection) {
Iterator<Entry<K, V>> entryItr = map.entrySet().iterator();
boolean result = false;
@@ -2974,7 +2763,7 @@
return result;
}
- static <K extends @Nullable Object, V extends @Nullable Object> boolean retainAllKeys(
+ static <K, V> boolean retainAllKeys(
Map<K, V> map, Predicate<? super Entry<K, V>> entryPredicate, Collection<?> keyCollection) {
Iterator<Entry<K, V>> entryItr = map.entrySet().iterator();
boolean result = false;
@@ -2995,7 +2784,7 @@
}
@Override
- public boolean remove(@CheckForNull Object o) {
+ public boolean remove(Object o) {
if (containsKey(o)) {
unfiltered.remove(o);
return true;
@@ -3014,22 +2803,20 @@
}
@Override
- public @Nullable Object[] toArray() {
+ public Object[] toArray() {
// creating an ArrayList so filtering happens once
return Lists.newArrayList(iterator()).toArray();
}
@Override
- @SuppressWarnings("nullness") // b/192354773 in our checker affects toArray declarations
- public <T extends @Nullable Object> T[] toArray(T[] array) {
+ public <T> T[] toArray(T[] array) {
return Lists.newArrayList(iterator()).toArray(array);
}
}
}
- private static class FilteredEntrySortedMap<
- K extends @Nullable Object, V extends @Nullable Object>
- extends FilteredEntryMap<K, V> implements SortedMap<K, V> {
+ private static class FilteredEntrySortedMap<K, V> extends FilteredEntryMap<K, V>
+ implements SortedMap<K, V> {
FilteredEntrySortedMap(
SortedMap<K, V> unfiltered, Predicate<? super Entry<K, V>> entryPredicate) {
@@ -3053,62 +2840,54 @@
@WeakOuter
class SortedKeySet extends KeySet implements SortedSet<K> {
@Override
- @CheckForNull
public Comparator<? super K> comparator() {
return sortedMap().comparator();
}
@Override
- public SortedSet<K> subSet(
- @ParametricNullness K fromElement, @ParametricNullness K toElement) {
+ public SortedSet<K> subSet(K fromElement, K toElement) {
return (SortedSet<K>) subMap(fromElement, toElement).keySet();
}
@Override
- public SortedSet<K> headSet(@ParametricNullness K toElement) {
+ public SortedSet<K> headSet(K toElement) {
return (SortedSet<K>) headMap(toElement).keySet();
}
@Override
- public SortedSet<K> tailSet(@ParametricNullness K fromElement) {
+ public SortedSet<K> tailSet(K fromElement) {
return (SortedSet<K>) tailMap(fromElement).keySet();
}
@Override
- @ParametricNullness
public K first() {
return firstKey();
}
@Override
- @ParametricNullness
public K last() {
return lastKey();
}
}
@Override
- @CheckForNull
public Comparator<? super K> comparator() {
return sortedMap().comparator();
}
@Override
- @ParametricNullness
public K firstKey() {
// correctly throws NoSuchElementException when filtered map is empty.
return keySet().iterator().next();
}
@Override
- @ParametricNullness
public K lastKey() {
SortedMap<K, V> headMap = sortedMap();
while (true) {
// correctly throws NoSuchElementException when filtered map is empty.
K key = headMap.lastKey();
- // The cast is safe because the key is taken from the map.
- if (apply(key, uncheckedCastNullableTToT(unfiltered.get(key)))) {
+ if (apply(key, unfiltered.get(key))) {
return key;
}
headMap = sortedMap().headMap(key);
@@ -3116,25 +2895,23 @@
}
@Override
- public SortedMap<K, V> headMap(@ParametricNullness K toKey) {
+ public SortedMap<K, V> headMap(K toKey) {
return new FilteredEntrySortedMap<>(sortedMap().headMap(toKey), predicate);
}
@Override
- public SortedMap<K, V> subMap(@ParametricNullness K fromKey, @ParametricNullness K toKey) {
+ public SortedMap<K, V> subMap(K fromKey, K toKey) {
return new FilteredEntrySortedMap<>(sortedMap().subMap(fromKey, toKey), predicate);
}
@Override
- public SortedMap<K, V> tailMap(@ParametricNullness K fromKey) {
+ public SortedMap<K, V> tailMap(K fromKey) {
return new FilteredEntrySortedMap<>(sortedMap().tailMap(fromKey), predicate);
}
}
@GwtIncompatible // NavigableMap
- private static class FilteredEntryNavigableMap<
- K extends @Nullable Object, V extends @Nullable Object>
- extends AbstractNavigableMap<K, V> {
+ private static class FilteredEntryNavigableMap<K, V> extends AbstractNavigableMap<K, V> {
/*
* It's less code to extend AbstractNavigableMap and forward the filtering logic to
* FilteredEntryMap than to extend FilteredEntrySortedMap and reimplement all the NavigableMap
@@ -3153,7 +2930,6 @@
}
@Override
- @CheckForNull
public Comparator<? super K> comparator() {
return unfiltered.comparator();
}
@@ -3199,25 +2975,23 @@
}
@Override
- @CheckForNull
- public V get(@CheckForNull Object key) {
+ @NullableDecl
+ public V get(@NullableDecl Object key) {
return filteredDelegate.get(key);
}
@Override
- public boolean containsKey(@CheckForNull Object key) {
+ public boolean containsKey(@NullableDecl Object key) {
return filteredDelegate.containsKey(key);
}
@Override
- @CheckForNull
- public V put(@ParametricNullness K key, @ParametricNullness V value) {
+ public V put(K key, V value) {
return filteredDelegate.put(key, value);
}
@Override
- @CheckForNull
- public V remove(@CheckForNull Object key) {
+ public V remove(@NullableDecl Object key) {
return filteredDelegate.remove(key);
}
@@ -3237,13 +3011,11 @@
}
@Override
- @CheckForNull
public Entry<K, V> pollFirstEntry() {
return Iterables.removeFirstMatching(unfiltered.entrySet(), entryPredicate);
}
@Override
- @CheckForNull
public Entry<K, V> pollLastEntry() {
return Iterables.removeFirstMatching(unfiltered.descendingMap().entrySet(), entryPredicate);
}
@@ -3255,32 +3027,28 @@
@Override
public NavigableMap<K, V> subMap(
- @ParametricNullness K fromKey,
- boolean fromInclusive,
- @ParametricNullness K toKey,
- boolean toInclusive) {
+ K fromKey, boolean fromInclusive, K toKey, boolean toInclusive) {
return filterEntries(
unfiltered.subMap(fromKey, fromInclusive, toKey, toInclusive), entryPredicate);
}
@Override
- public NavigableMap<K, V> headMap(@ParametricNullness K toKey, boolean inclusive) {
+ public NavigableMap<K, V> headMap(K toKey, boolean inclusive) {
return filterEntries(unfiltered.headMap(toKey, inclusive), entryPredicate);
}
@Override
- public NavigableMap<K, V> tailMap(@ParametricNullness K fromKey, boolean inclusive) {
+ public NavigableMap<K, V> tailMap(K fromKey, boolean inclusive) {
return filterEntries(unfiltered.tailMap(fromKey, inclusive), entryPredicate);
}
}
- static final class FilteredEntryBiMap<K extends @Nullable Object, V extends @Nullable Object>
- extends FilteredEntryMap<K, V> implements BiMap<K, V> {
+ static final class FilteredEntryBiMap<K, V> extends FilteredEntryMap<K, V>
+ implements BiMap<K, V> {
@RetainedWith private final BiMap<V, K> inverse;
- private static <K extends @Nullable Object, V extends @Nullable Object>
- Predicate<Entry<V, K>> inversePredicate(
- final Predicate<? super Entry<K, V>> forwardPredicate) {
+ private static <K, V> Predicate<Entry<V, K>> inversePredicate(
+ final Predicate<? super Entry<K, V>> forwardPredicate) {
return new Predicate<Entry<V, K>>() {
@Override
public boolean apply(Entry<V, K> input) {
@@ -3306,8 +3074,7 @@
}
@Override
- @CheckForNull
- public V forcePut(@ParametricNullness K key, @ParametricNullness V value) {
+ public V forcePut(@NullableDecl K key, @NullableDecl V value) {
checkArgument(apply(key, value));
return unfiltered().forcePut(key, value);
}
@@ -3342,8 +3109,8 @@
* @since 12.0
*/
@GwtIncompatible // NavigableMap
- public static <K extends @Nullable Object, V extends @Nullable Object>
- NavigableMap<K, V> unmodifiableNavigableMap(NavigableMap<K, ? extends V> map) {
+ public static <K, V> NavigableMap<K, V> unmodifiableNavigableMap(
+ NavigableMap<K, ? extends V> map) {
checkNotNull(map);
if (map instanceof UnmodifiableNavigableMap) {
@SuppressWarnings("unchecked") // covariant
@@ -3354,15 +3121,14 @@
}
}
- @CheckForNull
- private static <K extends @Nullable Object, V extends @Nullable Object>
- Entry<K, V> unmodifiableOrNull(@CheckForNull Entry<K, ? extends V> entry) {
+ @NullableDecl
+ private static <K, V> Entry<K, V> unmodifiableOrNull(@NullableDecl Entry<K, ? extends V> entry) {
return (entry == null) ? null : Maps.unmodifiableEntry(entry);
}
@GwtIncompatible // NavigableMap
- static class UnmodifiableNavigableMap<K extends @Nullable Object, V extends @Nullable Object>
- extends ForwardingSortedMap<K, V> implements NavigableMap<K, V>, Serializable {
+ static class UnmodifiableNavigableMap<K, V> extends ForwardingSortedMap<K, V>
+ implements NavigableMap<K, V>, Serializable {
private final NavigableMap<K, ? extends V> delegate;
UnmodifiableNavigableMap(NavigableMap<K, ? extends V> delegate) {
@@ -3381,78 +3147,66 @@
}
@Override
- @CheckForNull
- public Entry<K, V> lowerEntry(@ParametricNullness K key) {
+ public Entry<K, V> lowerEntry(K key) {
return unmodifiableOrNull(delegate.lowerEntry(key));
}
@Override
- @CheckForNull
- public K lowerKey(@ParametricNullness K key) {
+ public K lowerKey(K key) {
return delegate.lowerKey(key);
}
@Override
- @CheckForNull
- public Entry<K, V> floorEntry(@ParametricNullness K key) {
+ public Entry<K, V> floorEntry(K key) {
return unmodifiableOrNull(delegate.floorEntry(key));
}
@Override
- @CheckForNull
- public K floorKey(@ParametricNullness K key) {
+ public K floorKey(K key) {
return delegate.floorKey(key);
}
@Override
- @CheckForNull
- public Entry<K, V> ceilingEntry(@ParametricNullness K key) {
+ public Entry<K, V> ceilingEntry(K key) {
return unmodifiableOrNull(delegate.ceilingEntry(key));
}
@Override
- @CheckForNull
- public K ceilingKey(@ParametricNullness K key) {
+ public K ceilingKey(K key) {
return delegate.ceilingKey(key);
}
@Override
- @CheckForNull
- public Entry<K, V> higherEntry(@ParametricNullness K key) {
+ public Entry<K, V> higherEntry(K key) {
return unmodifiableOrNull(delegate.higherEntry(key));
}
@Override
- @CheckForNull
- public K higherKey(@ParametricNullness K key) {
+ public K higherKey(K key) {
return delegate.higherKey(key);
}
@Override
- @CheckForNull
public Entry<K, V> firstEntry() {
return unmodifiableOrNull(delegate.firstEntry());
}
@Override
- @CheckForNull
public Entry<K, V> lastEntry() {
return unmodifiableOrNull(delegate.lastEntry());
}
@Override
- @CheckForNull
public final Entry<K, V> pollFirstEntry() {
throw new UnsupportedOperationException();
}
@Override
- @CheckForNull
public final Entry<K, V> pollLastEntry() {
throw new UnsupportedOperationException();
}
- @CheckForNull private transient UnmodifiableNavigableMap<K, V> descendingMap;
+ @NullableDecl private transient UnmodifiableNavigableMap<K, V> descendingMap;
@Override
public NavigableMap<K, V> descendingMap() {
@@ -3478,37 +3232,34 @@
}
@Override
- public SortedMap<K, V> subMap(@ParametricNullness K fromKey, @ParametricNullness K toKey) {
+ public SortedMap<K, V> subMap(K fromKey, K toKey) {
return subMap(fromKey, true, toKey, false);
}
@Override
public NavigableMap<K, V> subMap(
- @ParametricNullness K fromKey,
- boolean fromInclusive,
- @ParametricNullness K toKey,
- boolean toInclusive) {
+ K fromKey, boolean fromInclusive, K toKey, boolean toInclusive) {
return Maps.unmodifiableNavigableMap(
delegate.subMap(fromKey, fromInclusive, toKey, toInclusive));
}
@Override
- public SortedMap<K, V> headMap(@ParametricNullness K toKey) {
+ public SortedMap<K, V> headMap(K toKey) {
return headMap(toKey, false);
}
@Override
- public NavigableMap<K, V> headMap(@ParametricNullness K toKey, boolean inclusive) {
+ public NavigableMap<K, V> headMap(K toKey, boolean inclusive) {
return Maps.unmodifiableNavigableMap(delegate.headMap(toKey, inclusive));
}
@Override
- public SortedMap<K, V> tailMap(@ParametricNullness K fromKey) {
+ public SortedMap<K, V> tailMap(K fromKey) {
return tailMap(fromKey, true);
}
@Override
- public NavigableMap<K, V> tailMap(@ParametricNullness K fromKey, boolean inclusive) {
+ public NavigableMap<K, V> tailMap(K fromKey, boolean inclusive) {
return Maps.unmodifiableNavigableMap(delegate.tailMap(fromKey, inclusive));
}
}
@@ -3563,8 +3314,8 @@
* @since 13.0
*/
@GwtIncompatible // NavigableMap
- public static <K extends @Nullable Object, V extends @Nullable Object>
- NavigableMap<K, V> synchronizedNavigableMap(NavigableMap<K, V> navigableMap) {
+ public static <K, V> NavigableMap<K, V> synchronizedNavigableMap(
+ NavigableMap<K, V> navigableMap) {
return Synchronized.navigableMap(navigableMap);
}
@@ -3573,16 +3324,14 @@
* entrySet views.
*/
@GwtCompatible
- abstract static class ViewCachingAbstractMap<
- K extends @Nullable Object, V extends @Nullable Object>
- extends AbstractMap<K, V> {
+ abstract static class ViewCachingAbstractMap<K, V> extends AbstractMap<K, V> {
/**
* Creates the entry set to be returned by {@link #entrySet()}. This method is invoked at most
* once on a given map, at the time when {@code entrySet} is first called.
*/
abstract Set<Entry<K, V>> createEntrySet();
- @CheckForNull private transient Set<Entry<K, V>> entrySet;
+ @NullableDecl private transient Set<Entry<K, V>> entrySet;
@Override
public Set<Entry<K, V>> entrySet() {
@@ -3590,7 +3339,7 @@
return (result == null) ? entrySet = createEntrySet() : result;
}
- @CheckForNull private transient Set<K> keySet;
+ @NullableDecl private transient Set<K> keySet;
@Override
public Set<K> keySet() {
@@ -3602,7 +3351,7 @@
return new KeySet<>(this);
}
- @CheckForNull private transient Collection<V> values;
+ @NullableDecl private transient Collection<V> values;
@Override
public Collection<V> values() {
@@ -3615,9 +3364,7 @@
}
}
- abstract static class IteratorBasedAbstractMap<
- K extends @Nullable Object, V extends @Nullable Object>
- extends AbstractMap<K, V> {
+ abstract static class IteratorBasedAbstractMap<K, V> extends AbstractMap<K, V> {
@Override
public abstract int size();
@@ -3648,8 +3395,7 @@
* Delegates to {@link Map#get}. Returns {@code null} on {@code ClassCastException} and {@code
* NullPointerException}.
*/
- @CheckForNull
- static <V extends @Nullable Object> V safeGet(Map<?, V> map, @CheckForNull Object key) {
+ static <V> V safeGet(Map<?, V> map, @NullableDecl Object key) {
checkNotNull(map);
try {
return map.get(key);
@@ -3662,7 +3408,7 @@
* Delegates to {@link Map#containsKey}. Returns {@code false} on {@code ClassCastException} and
* {@code NullPointerException}.
*/
- static boolean safeContainsKey(Map<?, ?> map, @CheckForNull Object key) {
+ static boolean safeContainsKey(Map<?, ?> map, Object key) {
checkNotNull(map);
try {
return map.containsKey(key);
@@ -3675,8 +3421,7 @@
* Delegates to {@link Map#remove}. Returns {@code null} on {@code ClassCastException} and {@code
* NullPointerException}.
*/
- @CheckForNull
- static <V extends @Nullable Object> V safeRemove(Map<?, V> map, @CheckForNull Object key) {
+ static <V> V safeRemove(Map<?, V> map, Object key) {
checkNotNull(map);
try {
return map.remove(key);
@@ -3686,12 +3431,12 @@
}
/** An admittedly inefficient implementation of {@link Map#containsKey}. */
- static boolean containsKeyImpl(Map<?, ?> map, @CheckForNull Object key) {
+ static boolean containsKeyImpl(Map<?, ?> map, @NullableDecl Object key) {
return Iterators.contains(keyIterator(map.entrySet().iterator()), key);
}
/** An implementation of {@link Map#containsValue}. */
- static boolean containsValueImpl(Map<?, ?> map, @CheckForNull Object value) {
+ static boolean containsValueImpl(Map<?, ?> map, @NullableDecl Object value) {
return Iterators.contains(valueIterator(map.entrySet().iterator()), value);
}
@@ -3707,8 +3452,7 @@
* @param o the object that might be contained in {@code c}
* @return {@code true} if {@code c} contains {@code o}
*/
- static <K extends @Nullable Object, V extends @Nullable Object> boolean containsEntryImpl(
- Collection<Entry<K, V>> c, @CheckForNull Object o) {
+ static <K, V> boolean containsEntryImpl(Collection<Entry<K, V>> c, Object o) {
if (!(o instanceof Entry)) {
return false;
}
@@ -3726,8 +3470,7 @@
* @param o the object to remove from {@code c}
* @return {@code true} if {@code c} was changed
*/
- static <K extends @Nullable Object, V extends @Nullable Object> boolean removeEntryImpl(
- Collection<Entry<K, V>> c, @CheckForNull Object o) {
+ static <K, V> boolean removeEntryImpl(Collection<Entry<K, V>> c, Object o) {
if (!(o instanceof Entry)) {
return false;
}
@@ -3735,7 +3478,7 @@
}
/** An implementation of {@link Map#equals}. */
- static boolean equalsImpl(Map<?, ?> map, @CheckForNull Object object) {
+ static boolean equalsImpl(Map<?, ?> map, Object object) {
if (map == object) {
return true;
} else if (object instanceof Map) {
@@ -3760,15 +3503,13 @@
}
/** An implementation of {@link Map#putAll}. */
- static <K extends @Nullable Object, V extends @Nullable Object> void putAllImpl(
- Map<K, V> self, Map<? extends K, ? extends V> map) {
+ static <K, V> void putAllImpl(Map<K, V> self, Map<? extends K, ? extends V> map) {
for (Entry<? extends K, ? extends V> entry : map.entrySet()) {
self.put(entry.getKey(), entry.getValue());
}
}
- static class KeySet<K extends @Nullable Object, V extends @Nullable Object>
- extends Sets.ImprovedAbstractSet<K> {
+ static class KeySet<K, V> extends Sets.ImprovedAbstractSet<K> {
@Weak final Map<K, V> map;
KeySet(Map<K, V> map) {
@@ -3795,12 +3536,12 @@
}
@Override
- public boolean contains(@CheckForNull Object o) {
+ public boolean contains(Object o) {
return map().containsKey(o);
}
@Override
- public boolean remove(@CheckForNull Object o) {
+ public boolean remove(Object o) {
if (contains(o)) {
map().remove(o);
return true;
@@ -3814,18 +3555,17 @@
}
}
- @CheckForNull
- static <K extends @Nullable Object> K keyOrNull(@CheckForNull Entry<K, ?> entry) {
+ @NullableDecl
+ static <K> K keyOrNull(@NullableDecl Entry<K, ?> entry) {
return (entry == null) ? null : entry.getKey();
}
- @CheckForNull
- static <V extends @Nullable Object> V valueOrNull(@CheckForNull Entry<?, V> entry) {
+ @NullableDecl
+ static <V> V valueOrNull(@NullableDecl Entry<?, V> entry) {
return (entry == null) ? null : entry.getValue();
}
- static class SortedKeySet<K extends @Nullable Object, V extends @Nullable Object>
- extends KeySet<K, V> implements SortedSet<K> {
+ static class SortedKeySet<K, V> extends KeySet<K, V> implements SortedSet<K> {
SortedKeySet(SortedMap<K, V> map) {
super(map);
}
@@ -3836,42 +3576,38 @@
}
@Override
- @CheckForNull
public Comparator<? super K> comparator() {
return map().comparator();
}
@Override
- public SortedSet<K> subSet(@ParametricNullness K fromElement, @ParametricNullness K toElement) {
+ public SortedSet<K> subSet(K fromElement, K toElement) {
return new SortedKeySet<>(map().subMap(fromElement, toElement));
}
@Override
- public SortedSet<K> headSet(@ParametricNullness K toElement) {
+ public SortedSet<K> headSet(K toElement) {
return new SortedKeySet<>(map().headMap(toElement));
}
@Override
- public SortedSet<K> tailSet(@ParametricNullness K fromElement) {
+ public SortedSet<K> tailSet(K fromElement) {
return new SortedKeySet<>(map().tailMap(fromElement));
}
@Override
- @ParametricNullness
public K first() {
return map().firstKey();
}
@Override
- @ParametricNullness
public K last() {
return map().lastKey();
}
}
@GwtIncompatible // NavigableMap
- static class NavigableKeySet<K extends @Nullable Object, V extends @Nullable Object>
- extends SortedKeySet<K, V> implements NavigableSet<K> {
+ static class NavigableKeySet<K, V> extends SortedKeySet<K, V> implements NavigableSet<K> {
NavigableKeySet(NavigableMap<K, V> map) {
super(map);
}
@@ -3882,37 +3618,31 @@
}
@Override
- @CheckForNull
- public K lower(@ParametricNullness K e) {
+ public K lower(K e) {
return map().lowerKey(e);
}
@Override
- @CheckForNull
- public K floor(@ParametricNullness K e) {
+ public K floor(K e) {
return map().floorKey(e);
}
@Override
- @CheckForNull
- public K ceiling(@ParametricNullness K e) {
+ public K ceiling(K e) {
return map().ceilingKey(e);
}
@Override
- @CheckForNull
- public K higher(@ParametricNullness K e) {
+ public K higher(K e) {
return map().higherKey(e);
}
@Override
- @CheckForNull
public K pollFirst() {
return keyOrNull(map().pollFirstEntry());
}
@Override
- @CheckForNull
public K pollLast() {
return keyOrNull(map().pollLastEntry());
}
@@ -3929,41 +3659,37 @@
@Override
public NavigableSet<K> subSet(
- @ParametricNullness K fromElement,
- boolean fromInclusive,
- @ParametricNullness K toElement,
- boolean toInclusive) {
+ K fromElement, boolean fromInclusive, K toElement, boolean toInclusive) {
return map().subMap(fromElement, fromInclusive, toElement, toInclusive).navigableKeySet();
}
@Override
- public SortedSet<K> subSet(@ParametricNullness K fromElement, @ParametricNullness K toElement) {
+ public SortedSet<K> subSet(K fromElement, K toElement) {
return subSet(fromElement, true, toElement, false);
}
@Override
- public NavigableSet<K> headSet(@ParametricNullness K toElement, boolean inclusive) {
+ public NavigableSet<K> headSet(K toElement, boolean inclusive) {
return map().headMap(toElement, inclusive).navigableKeySet();
}
@Override
- public SortedSet<K> headSet(@ParametricNullness K toElement) {
+ public SortedSet<K> headSet(K toElement) {
return headSet(toElement, false);
}
@Override
- public NavigableSet<K> tailSet(@ParametricNullness K fromElement, boolean inclusive) {
+ public NavigableSet<K> tailSet(K fromElement, boolean inclusive) {
return map().tailMap(fromElement, inclusive).navigableKeySet();
}
@Override
- public SortedSet<K> tailSet(@ParametricNullness K fromElement) {
+ public SortedSet<K> tailSet(K fromElement) {
return tailSet(fromElement, true);
}
}
- static class Values<K extends @Nullable Object, V extends @Nullable Object>
- extends AbstractCollection<V> {
+ static class Values<K, V> extends AbstractCollection<V> {
@Weak final Map<K, V> map;
Values(Map<K, V> map) {
@@ -3980,7 +3706,7 @@
}
@Override
- public boolean remove(@CheckForNull Object o) {
+ public boolean remove(Object o) {
try {
return super.remove(o);
} catch (UnsupportedOperationException e) {
@@ -4035,7 +3761,7 @@
}
@Override
- public boolean contains(@CheckForNull Object o) {
+ public boolean contains(@NullableDecl Object o) {
return map().containsValue(o);
}
@@ -4045,8 +3771,7 @@
}
}
- abstract static class EntrySet<K extends @Nullable Object, V extends @Nullable Object>
- extends Sets.ImprovedAbstractSet<Entry<K, V>> {
+ abstract static class EntrySet<K, V> extends Sets.ImprovedAbstractSet<Entry<K, V>> {
abstract Map<K, V> map();
@Override
@@ -4060,7 +3785,7 @@
}
@Override
- public boolean contains(@CheckForNull Object o) {
+ public boolean contains(Object o) {
if (o instanceof Entry) {
Entry<?, ?> entry = (Entry<?, ?>) o;
Object key = entry.getKey();
@@ -4076,12 +3801,8 @@
}
@Override
- public boolean remove(@CheckForNull Object o) {
- /*
- * `o instanceof Entry` is guaranteed by `contains`, but we check it here to satisfy our
- * nullness checker.
- */
- if (contains(o) && o instanceof Entry) {
+ public boolean remove(Object o) {
+ if (contains(o)) {
Entry<?, ?> entry = (Entry<?, ?>) o;
return map().keySet().remove(entry.getKey());
}
@@ -4104,13 +3825,9 @@
return super.retainAll(checkNotNull(c));
} catch (UnsupportedOperationException e) {
// if the iterators don't support remove
- Set<@Nullable Object> keys = Sets.newHashSetWithExpectedSize(c.size());
+ Set<Object> keys = Sets.newHashSetWithExpectedSize(c.size());
for (Object o : c) {
- /*
- * `o instanceof Entry` is guaranteed by `contains`, but we check it here to satisfy our
- * nullness checker.
- */
- if (contains(o) && o instanceof Entry) {
+ if (contains(o)) {
Entry<?, ?> entry = (Entry<?, ?>) o;
keys.add(entry.getKey());
}
@@ -4121,8 +3838,8 @@
}
@GwtIncompatible // NavigableMap
- abstract static class DescendingMap<K extends @Nullable Object, V extends @Nullable Object>
- extends ForwardingMap<K, V> implements NavigableMap<K, V> {
+ abstract static class DescendingMap<K, V> extends ForwardingMap<K, V>
+ implements NavigableMap<K, V> {
abstract NavigableMap<K, V> forward();
@@ -4131,7 +3848,7 @@
return forward();
}
- @CheckForNull private transient Comparator<? super K> comparator;
+ @NullableDecl private transient Comparator<? super K> comparator;
@SuppressWarnings("unchecked")
@Override
@@ -4148,90 +3865,76 @@
}
// If we inline this, we get a javac error.
- private static <T extends @Nullable Object> Ordering<T> reverse(Comparator<T> forward) {
+ private static <T> Ordering<T> reverse(Comparator<T> forward) {
return Ordering.from(forward).reverse();
}
@Override
- @ParametricNullness
public K firstKey() {
return forward().lastKey();
}
@Override
- @ParametricNullness
public K lastKey() {
return forward().firstKey();
}
@Override
- @CheckForNull
- public Entry<K, V> lowerEntry(@ParametricNullness K key) {
+ public Entry<K, V> lowerEntry(K key) {
return forward().higherEntry(key);
}
@Override
- @CheckForNull
- public K lowerKey(@ParametricNullness K key) {
+ public K lowerKey(K key) {
return forward().higherKey(key);
}
@Override
- @CheckForNull
- public Entry<K, V> floorEntry(@ParametricNullness K key) {
+ public Entry<K, V> floorEntry(K key) {
return forward().ceilingEntry(key);
}
@Override
- @CheckForNull
- public K floorKey(@ParametricNullness K key) {
+ public K floorKey(K key) {
return forward().ceilingKey(key);
}
@Override
- @CheckForNull
- public Entry<K, V> ceilingEntry(@ParametricNullness K key) {
+ public Entry<K, V> ceilingEntry(K key) {
return forward().floorEntry(key);
}
@Override
- @CheckForNull
- public K ceilingKey(@ParametricNullness K key) {
+ public K ceilingKey(K key) {
return forward().floorKey(key);
}
@Override
- @CheckForNull
- public Entry<K, V> higherEntry(@ParametricNullness K key) {
+ public Entry<K, V> higherEntry(K key) {
return forward().lowerEntry(key);
}
@Override
- @CheckForNull
- public K higherKey(@ParametricNullness K key) {
+ public K higherKey(K key) {
return forward().lowerKey(key);
}
@Override
- @CheckForNull
public Entry<K, V> firstEntry() {
return forward().lastEntry();
}
@Override
- @CheckForNull
public Entry<K, V> lastEntry() {
return forward().firstEntry();
}
@Override
- @CheckForNull
public Entry<K, V> pollFirstEntry() {
return forward().pollLastEntry();
}
@Override
- @CheckForNull
public Entry<K, V> pollLastEntry() {
return forward().pollFirstEntry();
}
@@ -4241,7 +3944,7 @@
return forward();
}
- @CheckForNull private transient Set<Entry<K, V>> entrySet;
+ @NullableDecl private transient Set<Entry<K, V>> entrySet;
@Override
public Set<Entry<K, V>> entrySet() {
@@ -4272,7 +3975,7 @@
return navigableKeySet();
}
- @CheckForNull private transient NavigableSet<K> navigableKeySet;
+ @NullableDecl private transient NavigableSet<K> navigableKeySet;
@Override
public NavigableSet<K> navigableKeySet() {
@@ -4287,35 +3990,32 @@
@Override
public NavigableMap<K, V> subMap(
- @ParametricNullness K fromKey,
- boolean fromInclusive,
- @ParametricNullness K toKey,
- boolean toInclusive) {
+ K fromKey, boolean fromInclusive, K toKey, boolean toInclusive) {
return forward().subMap(toKey, toInclusive, fromKey, fromInclusive).descendingMap();
}
@Override
- public SortedMap<K, V> subMap(@ParametricNullness K fromKey, @ParametricNullness K toKey) {
+ public SortedMap<K, V> subMap(K fromKey, K toKey) {
return subMap(fromKey, true, toKey, false);
}
@Override
- public NavigableMap<K, V> headMap(@ParametricNullness K toKey, boolean inclusive) {
+ public NavigableMap<K, V> headMap(K toKey, boolean inclusive) {
return forward().tailMap(toKey, inclusive).descendingMap();
}
@Override
- public SortedMap<K, V> headMap(@ParametricNullness K toKey) {
+ public SortedMap<K, V> headMap(K toKey) {
return headMap(toKey, false);
}
@Override
- public NavigableMap<K, V> tailMap(@ParametricNullness K fromKey, boolean inclusive) {
+ public NavigableMap<K, V> tailMap(K fromKey, boolean inclusive) {
return forward().headMap(fromKey, inclusive).descendingMap();
}
@Override
- public SortedMap<K, V> tailMap(@ParametricNullness K fromKey) {
+ public SortedMap<K, V> tailMap(K fromKey) {
return tailMap(fromKey, true);
}
@@ -4358,8 +4058,8 @@
*/
@Beta
@GwtIncompatible // NavigableMap
- public static <K extends Comparable<? super K>, V extends @Nullable Object>
- NavigableMap<K, V> subMap(NavigableMap<K, V> map, Range<K> range) {
+ public static <K extends Comparable<? super K>, V> NavigableMap<K, V> subMap(
+ NavigableMap<K, V> map, Range<K> range) {
if (map.comparator() != null
&& map.comparator() != Ordering.natural()
&& range.hasLowerBound()
diff --git a/android/guava/src/com/google/common/collect/MinMaxPriorityQueue.java b/android/guava/src/com/google/common/collect/MinMaxPriorityQueue.java
index cd01279..639775c 100644
--- a/android/guava/src/com/google/common/collect/MinMaxPriorityQueue.java
+++ b/android/guava/src/com/google/common/collect/MinMaxPriorityQueue.java
@@ -21,7 +21,6 @@
import static com.google.common.base.Preconditions.checkPositionIndex;
import static com.google.common.base.Preconditions.checkState;
import static com.google.common.collect.CollectPreconditions.checkRemove;
-import static java.util.Objects.requireNonNull;
import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtCompatible;
@@ -42,8 +41,7 @@
import java.util.NoSuchElementException;
import java.util.PriorityQueue;
import java.util.Queue;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* A double-ended priority queue, which provides constant-time access to both its least element and
@@ -100,7 +98,6 @@
*/
@Beta
@GwtCompatible
-@ElementTypesAreNonnullByDefault
public final class MinMaxPriorityQueue<E> extends AbstractQueue<E> {
/**
@@ -124,12 +121,6 @@
* Creates and returns a new builder, configured to build {@code MinMaxPriorityQueue} instances
* that use {@code comparator} to determine the least and greatest elements.
*/
- /*
- * TODO(cpovirk): Change to Comparator<? super B> to permit Comparator<@Nullable ...> and
- * Comparator<SupertypeOfB>? What we have here matches the immutable collections, but those also
- * expose a public Builder constructor that accepts "? super." So maybe we should do *that*
- * instead.
- */
public static <B> Builder<B> orderedBy(Comparator<B> comparator) {
return new Builder<B>(comparator);
}
@@ -233,7 +224,7 @@
private final Heap minHeap;
private final Heap maxHeap;
@VisibleForTesting final int maximumSize;
- private @Nullable Object[] queue;
+ private Object[] queue;
private int size;
private int modCount;
@@ -301,22 +292,16 @@
@CanIgnoreReturnValue
@Override
- @CheckForNull
public E poll() {
return isEmpty() ? null : removeAndGet(0);
}
@SuppressWarnings("unchecked") // we must carefully only allow Es to get in
E elementData(int index) {
- /*
- * requireNonNull is safe as long as we're careful to call this method only with populated
- * indexes.
- */
- return (E) requireNonNull(queue[index]);
+ return (E) queue[index];
}
@Override
- @CheckForNull
public E peek() {
return isEmpty() ? null : elementData(0);
}
@@ -340,7 +325,6 @@
* empty.
*/
@CanIgnoreReturnValue
- @CheckForNull
public E pollFirst() {
return poll();
}
@@ -359,7 +343,6 @@
* Retrieves, but does not remove, the least element of this queue, or returns {@code null} if the
* queue is empty.
*/
- @CheckForNull
public E peekFirst() {
return peek();
}
@@ -369,7 +352,6 @@
* empty.
*/
@CanIgnoreReturnValue
- @CheckForNull
public E pollLast() {
return isEmpty() ? null : removeAndGet(getMaxElementIndex());
}
@@ -391,7 +373,6 @@
* Retrieves, but does not remove, the greatest element of this queue, or returns {@code null} if
* the queue is empty.
*/
- @CheckForNull
public E peekLast() {
return isEmpty() ? null : elementData(getMaxElementIndex());
}
@@ -411,7 +392,6 @@
*/
@VisibleForTesting
@CanIgnoreReturnValue
- @CheckForNull
MoveDesc<E> removeAt(int index) {
checkPositionIndex(index, size);
modCount++;
@@ -447,7 +427,6 @@
return changes;
}
- @CheckForNull
private MoveDesc<E> fillHole(int index, E toTrickle) {
Heap heap = heapForIndex(index);
// We consider elementData(index) a "hole", and we want to fill it
@@ -525,7 +504,7 @@
@WeakOuter
private class Heap {
final Ordering<E> ordering;
- @Weak Heap otherHeap; // always initialized immediately after construction
+ @Weak @NullableDecl Heap otherHeap;
Heap(Ordering<E> ordering) {
this.ordering = ordering;
@@ -539,7 +518,6 @@
* Tries to move {@code toTrickle} from a min to a max level and bubble up there. If it moved
* before {@code removeIndex} this method returns a pair as described in {@link #removeAt}.
*/
- @CheckForNull
MoveDesc<E> tryCrossOverAndBubbleUp(int removeIndex, int vacated, E toTrickle) {
int crossOver = crossOver(vacated, toTrickle);
if (crossOver == vacated) {
@@ -773,9 +751,9 @@
private int expectedModCount = modCount;
// The same element is not allowed in both forgetMeNot and skipMe, but duplicates are allowed in
// either of them, up to the same multiplicity as the queue.
- @CheckForNull private Queue<E> forgetMeNot;
- @CheckForNull private List<E> skipMe;
- @CheckForNull private E lastFromForgetMeNot;
+ @NullableDecl private Queue<E> forgetMeNot;
+ @NullableDecl private List<E> skipMe;
+ @NullableDecl private E lastFromForgetMeNot;
private boolean canRemove;
@Override
@@ -813,8 +791,7 @@
if (cursor < size()) {
MoveDesc<E> moved = removeAt(cursor);
if (moved != null) {
- // Either both are null or neither is, but we check both to satisfy the nullness checker.
- if (forgetMeNot == null || skipMe == null) {
+ if (forgetMeNot == null) {
forgetMeNot = new ArrayDeque<E>();
skipMe = new ArrayList<E>(3);
}
@@ -828,7 +805,7 @@
cursor--;
nextCursor--;
} else { // we must have set lastFromForgetMeNot in next()
- checkState(removeExact(requireNonNull(lastFromForgetMeNot)));
+ checkState(removeExact(lastFromForgetMeNot));
lastFromForgetMeNot = null;
}
}
diff --git a/android/guava/src/com/google/common/collect/Multimap.java b/android/guava/src/com/google/common/collect/Multimap.java
index 09aa287..cdfa0f6 100644
--- a/android/guava/src/com/google/common/collect/Multimap.java
+++ b/android/guava/src/com/google/common/collect/Multimap.java
@@ -25,8 +25,7 @@
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* A collection that maps keys to values, similar to {@link Map}, but in which each key may be
@@ -159,8 +158,7 @@
*/
@DoNotMock("Use ImmutableMultimap, HashMultimap, or another implementation")
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-public interface Multimap<K extends @Nullable Object, V extends @Nullable Object> {
+public interface Multimap<K, V> {
// Query Operations
/**
@@ -182,21 +180,21 @@
* Returns {@code true} if this multimap contains at least one key-value pair with the key {@code
* key}.
*/
- boolean containsKey(@CompatibleWith("K") @CheckForNull Object key);
+ boolean containsKey(@CompatibleWith("K") @NullableDecl Object key);
/**
* Returns {@code true} if this multimap contains at least one key-value pair with the value
* {@code value}.
*/
- boolean containsValue(@CompatibleWith("V") @CheckForNull Object value);
+ boolean containsValue(@CompatibleWith("V") @NullableDecl 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") @CheckForNull Object key,
- @CompatibleWith("V") @CheckForNull Object value);
+ @CompatibleWith("K") @NullableDecl Object key,
+ @CompatibleWith("V") @NullableDecl Object value);
// Modification Operations
@@ -211,7 +209,7 @@
* multimap already contained the key-value pair and doesn't allow duplicates
*/
@CanIgnoreReturnValue
- boolean put(@ParametricNullness K key, @ParametricNullness V value);
+ boolean put(@NullableDecl K key, @NullableDecl V value);
/**
* Removes a single key-value pair with the key {@code key} and the value {@code value} from this
@@ -222,8 +220,8 @@
*/
@CanIgnoreReturnValue
boolean remove(
- @CompatibleWith("K") @CheckForNull Object key,
- @CompatibleWith("V") @CheckForNull Object value);
+ @CompatibleWith("K") @NullableDecl Object key,
+ @CompatibleWith("V") @NullableDecl Object value);
// Bulk Operations
@@ -242,7 +240,7 @@
* @return {@code true} if the multimap changed
*/
@CanIgnoreReturnValue
- boolean putAll(@ParametricNullness K key, Iterable<? extends V> values);
+ boolean putAll(@NullableDecl K key, Iterable<? extends V> values);
/**
* Stores all key-value pairs of {@code multimap} in this multimap, in the order returned by
@@ -263,7 +261,7 @@
* no effect on the multimap.
*/
@CanIgnoreReturnValue
- Collection<V> replaceValues(@ParametricNullness K key, Iterable<? extends V> values);
+ Collection<V> replaceValues(@NullableDecl K key, Iterable<? extends V> values);
/**
* Removes all values associated with the key {@code key}.
@@ -275,7 +273,7 @@
* modifiable, but updating it will have no effect on the multimap.
*/
@CanIgnoreReturnValue
- Collection<V> removeAll(@CompatibleWith("K") @CheckForNull Object key);
+ Collection<V> removeAll(@CompatibleWith("K") @NullableDecl Object key);
/** Removes all key-value pairs from the multimap, leaving it {@linkplain #isEmpty empty}. */
void clear();
@@ -289,7 +287,7 @@
*
* <p>Changes to the returned collection will update the underlying multimap, and vice versa.
*/
- Collection<V> get(@ParametricNullness K key);
+ Collection<V> get(@NullableDecl K key);
/**
* Returns a view collection of all <i>distinct</i> keys contained in this multimap. Note that the
@@ -356,7 +354,7 @@
* multimaps are equal, because they both have empty {@link #asMap} views.
*/
@Override
- boolean equals(@CheckForNull Object obj);
+ boolean equals(@NullableDecl Object obj);
/**
* Returns the hash code for this multimap.
diff --git a/android/guava/src/com/google/common/collect/MultimapBuilder.java b/android/guava/src/com/google/common/collect/MultimapBuilder.java
index dddae28..161c29d 100644
--- a/android/guava/src/com/google/common/collect/MultimapBuilder.java
+++ b/android/guava/src/com/google/common/collect/MultimapBuilder.java
@@ -34,7 +34,6 @@
import java.util.SortedSet;
import java.util.TreeMap;
import java.util.TreeSet;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* A builder for a multimap implementation that allows customization of the backing map and value
@@ -62,8 +61,7 @@
* @since 16.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-public abstract class MultimapBuilder<K0 extends @Nullable Object, V0 extends @Nullable Object> {
+public abstract class MultimapBuilder<K0, V0> {
/*
* Leaving K and V as upper bounds rather than the actual key and value types allows type
* parameters to be left implicit more often. CacheBuilder uses the same technique.
@@ -74,7 +72,7 @@
private static final int DEFAULT_EXPECTED_KEYS = 8;
/** Uses a hash table to map keys to value collections. */
- public static MultimapBuilderWithKeys<@Nullable Object> hashKeys() {
+ public static MultimapBuilderWithKeys<Object> hashKeys() {
return hashKeys(DEFAULT_EXPECTED_KEYS);
}
@@ -84,11 +82,11 @@
*
* @throws IllegalArgumentException if {@code expectedKeys < 0}
*/
- public static MultimapBuilderWithKeys<@Nullable Object> hashKeys(final int expectedKeys) {
+ public static MultimapBuilderWithKeys<Object> hashKeys(final int expectedKeys) {
checkNonnegative(expectedKeys, "expectedKeys");
- return new MultimapBuilderWithKeys<@Nullable Object>() {
+ return new MultimapBuilderWithKeys<Object>() {
@Override
- <K extends @Nullable Object, V extends @Nullable Object> Map<K, Collection<V>> createMap() {
+ <K, V> Map<K, Collection<V>> createMap() {
return Platform.newHashMapWithExpectedSize(expectedKeys);
}
};
@@ -102,7 +100,7 @@
* multimap, save that if all values associated with a key are removed and then the key is added
* back into the multimap, that key will come last in the key iteration order.
*/
- public static MultimapBuilderWithKeys<@Nullable Object> linkedHashKeys() {
+ public static MultimapBuilderWithKeys<Object> linkedHashKeys() {
return linkedHashKeys(DEFAULT_EXPECTED_KEYS);
}
@@ -115,11 +113,11 @@
* multimap, save that if all values associated with a key are removed and then the key is added
* back into the multimap, that key will come last in the key iteration order.
*/
- public static MultimapBuilderWithKeys<@Nullable Object> linkedHashKeys(final int expectedKeys) {
+ public static MultimapBuilderWithKeys<Object> linkedHashKeys(final int expectedKeys) {
checkNonnegative(expectedKeys, "expectedKeys");
- return new MultimapBuilderWithKeys<@Nullable Object>() {
+ return new MultimapBuilderWithKeys<Object>() {
@Override
- <K extends @Nullable Object, V extends @Nullable Object> Map<K, Collection<V>> createMap() {
+ <K, V> Map<K, Collection<V>> createMap() {
return Platform.newLinkedHashMapWithExpectedSize(expectedKeys);
}
};
@@ -153,12 +151,11 @@
* <p>Multimaps generated by the resulting builder will not be serializable if {@code comparator}
* is not serializable.
*/
- public static <K0 extends @Nullable Object> MultimapBuilderWithKeys<K0> treeKeys(
- final Comparator<K0> comparator) {
+ public static <K0> MultimapBuilderWithKeys<K0> treeKeys(final Comparator<K0> comparator) {
checkNotNull(comparator);
return new MultimapBuilderWithKeys<K0>() {
@Override
- <K extends K0, V extends @Nullable Object> Map<K, Collection<V>> createMap() {
+ <K extends K0, V> Map<K, Collection<V>> createMap() {
return new TreeMap<>(comparator);
}
};
@@ -175,7 +172,7 @@
return new MultimapBuilderWithKeys<K0>() {
@SuppressWarnings("unchecked")
@Override
- <K extends K0, V extends @Nullable Object> Map<K, Collection<V>> createMap() {
+ <K extends K0, V> Map<K, Collection<V>> createMap() {
// K must actually be K0, since enums are effectively final
// (their subclasses are inaccessible)
return (Map<K, Collection<V>>) new EnumMap<K0, Collection<V>>(keyClass);
@@ -183,8 +180,7 @@
};
}
- private static final class ArrayListSupplier<V extends @Nullable Object>
- implements Supplier<List<V>>, Serializable {
+ private static final class ArrayListSupplier<V> implements Supplier<List<V>>, Serializable {
private final int expectedValuesPerKey;
ArrayListSupplier(int expectedValuesPerKey) {
@@ -197,10 +193,10 @@
}
}
- private enum LinkedListSupplier implements Supplier<List<?>> {
+ private enum LinkedListSupplier implements Supplier<List<Object>> {
INSTANCE;
- public static <V extends @Nullable Object> Supplier<List<V>> instance() {
+ public static <V> Supplier<List<V>> instance() {
// Each call generates a fresh LinkedList, which can serve as a List<V> for any V.
@SuppressWarnings({"rawtypes", "unchecked"})
Supplier<List<V>> result = (Supplier) INSTANCE;
@@ -208,13 +204,12 @@
}
@Override
- public List<?> get() {
+ public List<Object> get() {
return new LinkedList<>();
}
}
- private static final class HashSetSupplier<V extends @Nullable Object>
- implements Supplier<Set<V>>, Serializable {
+ private static final class HashSetSupplier<V> implements Supplier<Set<V>>, Serializable {
private final int expectedValuesPerKey;
HashSetSupplier(int expectedValuesPerKey) {
@@ -227,8 +222,7 @@
}
}
- private static final class LinkedHashSetSupplier<V extends @Nullable Object>
- implements Supplier<Set<V>>, Serializable {
+ private static final class LinkedHashSetSupplier<V> implements Supplier<Set<V>>, Serializable {
private final int expectedValuesPerKey;
LinkedHashSetSupplier(int expectedValuesPerKey) {
@@ -241,8 +235,7 @@
}
}
- private static final class TreeSetSupplier<V extends @Nullable Object>
- implements Supplier<SortedSet<V>>, Serializable {
+ private static final class TreeSetSupplier<V> implements Supplier<SortedSet<V>>, Serializable {
private final Comparator<? super V> comparator;
TreeSetSupplier(Comparator<? super V> comparator) {
@@ -276,16 +269,16 @@
* @param <K0> The upper bound on the key type of the generated multimap.
* @since 16.0
*/
- public abstract static class MultimapBuilderWithKeys<K0 extends @Nullable Object> {
+ public abstract static class MultimapBuilderWithKeys<K0> {
private static final int DEFAULT_EXPECTED_VALUES_PER_KEY = 2;
MultimapBuilderWithKeys() {}
- abstract <K extends K0, V extends @Nullable Object> Map<K, Collection<V>> createMap();
+ abstract <K extends K0, V> Map<K, Collection<V>> createMap();
/** Uses an {@link ArrayList} to store value collections. */
- public ListMultimapBuilder<K0, @Nullable Object> arrayListValues() {
+ public ListMultimapBuilder<K0, Object> arrayListValues() {
return arrayListValues(DEFAULT_EXPECTED_VALUES_PER_KEY);
}
@@ -295,12 +288,11 @@
*
* @throws IllegalArgumentException if {@code expectedValuesPerKey < 0}
*/
- public ListMultimapBuilder<K0, @Nullable Object> arrayListValues(
- final int expectedValuesPerKey) {
+ public ListMultimapBuilder<K0, Object> arrayListValues(final int expectedValuesPerKey) {
checkNonnegative(expectedValuesPerKey, "expectedValuesPerKey");
- return new ListMultimapBuilder<K0, @Nullable Object>() {
+ return new ListMultimapBuilder<K0, Object>() {
@Override
- public <K extends K0, V extends @Nullable Object> ListMultimap<K, V> build() {
+ public <K extends K0, V> ListMultimap<K, V> build() {
return Multimaps.newListMultimap(
MultimapBuilderWithKeys.this.<K, V>createMap(),
new ArrayListSupplier<V>(expectedValuesPerKey));
@@ -309,10 +301,10 @@
}
/** Uses a {@link LinkedList} to store value collections. */
- public ListMultimapBuilder<K0, @Nullable Object> linkedListValues() {
- return new ListMultimapBuilder<K0, @Nullable Object>() {
+ public ListMultimapBuilder<K0, Object> linkedListValues() {
+ return new ListMultimapBuilder<K0, Object>() {
@Override
- public <K extends K0, V extends @Nullable Object> ListMultimap<K, V> build() {
+ public <K extends K0, V> ListMultimap<K, V> build() {
return Multimaps.newListMultimap(
MultimapBuilderWithKeys.this.<K, V>createMap(), LinkedListSupplier.<V>instance());
}
@@ -320,7 +312,7 @@
}
/** Uses a hash-based {@code Set} to store value collections. */
- public SetMultimapBuilder<K0, @Nullable Object> hashSetValues() {
+ public SetMultimapBuilder<K0, Object> hashSetValues() {
return hashSetValues(DEFAULT_EXPECTED_VALUES_PER_KEY);
}
@@ -330,11 +322,11 @@
*
* @throws IllegalArgumentException if {@code expectedValuesPerKey < 0}
*/
- public SetMultimapBuilder<K0, @Nullable Object> hashSetValues(final int expectedValuesPerKey) {
+ public SetMultimapBuilder<K0, Object> hashSetValues(final int expectedValuesPerKey) {
checkNonnegative(expectedValuesPerKey, "expectedValuesPerKey");
- return new SetMultimapBuilder<K0, @Nullable Object>() {
+ return new SetMultimapBuilder<K0, Object>() {
@Override
- public <K extends K0, V extends @Nullable Object> SetMultimap<K, V> build() {
+ public <K extends K0, V> SetMultimap<K, V> build() {
return Multimaps.newSetMultimap(
MultimapBuilderWithKeys.this.<K, V>createMap(),
new HashSetSupplier<V>(expectedValuesPerKey));
@@ -343,7 +335,7 @@
}
/** Uses an insertion-ordered hash-based {@code Set} to store value collections. */
- public SetMultimapBuilder<K0, @Nullable Object> linkedHashSetValues() {
+ public SetMultimapBuilder<K0, Object> linkedHashSetValues() {
return linkedHashSetValues(DEFAULT_EXPECTED_VALUES_PER_KEY);
}
@@ -353,12 +345,11 @@
*
* @throws IllegalArgumentException if {@code expectedValuesPerKey < 0}
*/
- public SetMultimapBuilder<K0, @Nullable Object> linkedHashSetValues(
- final int expectedValuesPerKey) {
+ public SetMultimapBuilder<K0, Object> linkedHashSetValues(final int expectedValuesPerKey) {
checkNonnegative(expectedValuesPerKey, "expectedValuesPerKey");
- return new SetMultimapBuilder<K0, @Nullable Object>() {
+ return new SetMultimapBuilder<K0, Object>() {
@Override
- public <K extends K0, V extends @Nullable Object> SetMultimap<K, V> build() {
+ public <K extends K0, V> SetMultimap<K, V> build() {
return Multimaps.newSetMultimap(
MultimapBuilderWithKeys.this.<K, V>createMap(),
new LinkedHashSetSupplier<V>(expectedValuesPerKey));
@@ -378,8 +369,7 @@
* <p>Multimaps generated by the resulting builder will not be serializable if {@code
* comparator} is not serializable.
*/
- public <V0 extends @Nullable Object> SortedSetMultimapBuilder<K0, V0> treeSetValues(
- final Comparator<V0> comparator) {
+ public <V0> SortedSetMultimapBuilder<K0, V0> treeSetValues(final Comparator<V0> comparator) {
checkNotNull(comparator, "comparator");
return new SortedSetMultimapBuilder<K0, V0>() {
@Override
@@ -426,9 +416,7 @@
*
* @since 16.0
*/
- public abstract static class ListMultimapBuilder<
- K0 extends @Nullable Object, V0 extends @Nullable Object>
- extends MultimapBuilder<K0, V0> {
+ public abstract static class ListMultimapBuilder<K0, V0> extends MultimapBuilder<K0, V0> {
ListMultimapBuilder() {}
@Override
@@ -446,9 +434,7 @@
*
* @since 16.0
*/
- public abstract static class SetMultimapBuilder<
- K0 extends @Nullable Object, V0 extends @Nullable Object>
- extends MultimapBuilder<K0, V0> {
+ public abstract static class SetMultimapBuilder<K0, V0> extends MultimapBuilder<K0, V0> {
SetMultimapBuilder() {}
@Override
@@ -466,9 +452,7 @@
*
* @since 16.0
*/
- public abstract static class SortedSetMultimapBuilder<
- K0 extends @Nullable Object, V0 extends @Nullable Object>
- extends SetMultimapBuilder<K0, V0> {
+ public abstract static class SortedSetMultimapBuilder<K0, V0> extends SetMultimapBuilder<K0, V0> {
SortedSetMultimapBuilder() {}
@Override
diff --git a/android/guava/src/com/google/common/collect/Multimaps.java b/android/guava/src/com/google/common/collect/Multimaps.java
index b0577ea..1f65d56 100644
--- a/android/guava/src/com/google/common/collect/Multimaps.java
+++ b/android/guava/src/com/google/common/collect/Multimaps.java
@@ -19,8 +19,6 @@
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.collect.CollectPreconditions.checkNonnegative;
import static com.google.common.collect.CollectPreconditions.checkRemove;
-import static com.google.common.collect.NullnessCasts.uncheckedCastNullableTToT;
-import static java.util.Objects.requireNonNull;
import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtCompatible;
@@ -31,7 +29,6 @@
import com.google.common.base.Supplier;
import com.google.common.collect.Maps.EntryTransformer;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
-import com.google.errorprone.annotations.concurrent.LazyInit;
import com.google.j2objc.annotations.Weak;
import com.google.j2objc.annotations.WeakOuter;
import java.io.IOException;
@@ -51,8 +48,7 @@
import java.util.NoSuchElementException;
import java.util.Set;
import java.util.SortedSet;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* Provides static methods acting on or generating a {@code Multimap}.
@@ -68,7 +64,6 @@
* @since 2.0
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
public final class Multimaps {
private Multimaps() {}
@@ -108,13 +103,12 @@
* key
* @throws IllegalArgumentException if {@code map} is not empty
*/
- public static <K extends @Nullable Object, V extends @Nullable Object> Multimap<K, V> newMultimap(
+ public static <K, V> Multimap<K, V> newMultimap(
Map<K, Collection<V>> map, final Supplier<? extends Collection<V>> factory) {
return new CustomMultimap<>(map, factory);
}
- private static class CustomMultimap<K extends @Nullable Object, V extends @Nullable Object>
- extends AbstractMapBasedMultimap<K, V> {
+ private static class CustomMultimap<K, V> extends AbstractMapBasedMultimap<K, V> {
transient Supplier<? extends Collection<V>> factory;
CustomMultimap(Map<K, Collection<V>> map, Supplier<? extends Collection<V>> factory) {
@@ -138,8 +132,7 @@
}
@Override
- <E extends @Nullable Object> Collection<E> unmodifiableCollectionSubclass(
- Collection<E> collection) {
+ <E> Collection<E> unmodifiableCollectionSubclass(Collection<E> collection) {
if (collection instanceof NavigableSet) {
return Sets.unmodifiableNavigableSet((NavigableSet<E>) collection);
} else if (collection instanceof SortedSet) {
@@ -154,7 +147,7 @@
}
@Override
- Collection<V> wrapCollection(@ParametricNullness K key, Collection<V> collection) {
+ Collection<V> wrapCollection(K key, Collection<V> collection) {
if (collection instanceof List) {
return wrapList(key, (List<V>) collection, null);
} else if (collection instanceof NavigableSet) {
@@ -222,14 +215,12 @@
* @param factory supplier of new, empty lists that will each hold all values for a given key
* @throws IllegalArgumentException if {@code map} is not empty
*/
- public static <K extends @Nullable Object, V extends @Nullable Object>
- ListMultimap<K, V> newListMultimap(
- Map<K, Collection<V>> map, final Supplier<? extends List<V>> factory) {
+ public static <K, V> ListMultimap<K, V> newListMultimap(
+ Map<K, Collection<V>> map, final Supplier<? extends List<V>> factory) {
return new CustomListMultimap<>(map, factory);
}
- private static class CustomListMultimap<K extends @Nullable Object, V extends @Nullable Object>
- extends AbstractListMultimap<K, V> {
+ private static class CustomListMultimap<K, V> extends AbstractListMultimap<K, V> {
transient Supplier<? extends List<V>> factory;
CustomListMultimap(Map<K, Collection<V>> map, Supplier<? extends List<V>> factory) {
@@ -302,14 +293,12 @@
* @param factory supplier of new, empty sets that will each hold all values for a given key
* @throws IllegalArgumentException if {@code map} is not empty
*/
- public static <K extends @Nullable Object, V extends @Nullable Object>
- SetMultimap<K, V> newSetMultimap(
- Map<K, Collection<V>> map, final Supplier<? extends Set<V>> factory) {
+ public static <K, V> SetMultimap<K, V> newSetMultimap(
+ Map<K, Collection<V>> map, final Supplier<? extends Set<V>> factory) {
return new CustomSetMultimap<>(map, factory);
}
- private static class CustomSetMultimap<K extends @Nullable Object, V extends @Nullable Object>
- extends AbstractSetMultimap<K, V> {
+ private static class CustomSetMultimap<K, V> extends AbstractSetMultimap<K, V> {
transient Supplier<? extends Set<V>> factory;
CustomSetMultimap(Map<K, Collection<V>> map, Supplier<? extends Set<V>> factory) {
@@ -333,8 +322,7 @@
}
@Override
- <E extends @Nullable Object> Collection<E> unmodifiableCollectionSubclass(
- Collection<E> collection) {
+ <E> Collection<E> unmodifiableCollectionSubclass(Collection<E> collection) {
if (collection instanceof NavigableSet) {
return Sets.unmodifiableNavigableSet((NavigableSet<E>) collection);
} else if (collection instanceof SortedSet) {
@@ -345,7 +333,7 @@
}
@Override
- Collection<V> wrapCollection(@ParametricNullness K key, Collection<V> collection) {
+ Collection<V> wrapCollection(K key, Collection<V> collection) {
if (collection instanceof NavigableSet) {
return new WrappedNavigableSet(key, (NavigableSet<V>) collection, null);
} else if (collection instanceof SortedSet) {
@@ -405,17 +393,14 @@
* key
* @throws IllegalArgumentException if {@code map} is not empty
*/
- public static <K extends @Nullable Object, V extends @Nullable Object>
- SortedSetMultimap<K, V> newSortedSetMultimap(
- Map<K, Collection<V>> map, final Supplier<? extends SortedSet<V>> factory) {
+ public static <K, V> SortedSetMultimap<K, V> newSortedSetMultimap(
+ Map<K, Collection<V>> map, final Supplier<? extends SortedSet<V>> factory) {
return new CustomSortedSetMultimap<>(map, factory);
}
- private static class CustomSortedSetMultimap<
- K extends @Nullable Object, V extends @Nullable Object>
- extends AbstractSortedSetMultimap<K, V> {
+ private static class CustomSortedSetMultimap<K, V> extends AbstractSortedSetMultimap<K, V> {
transient Supplier<? extends SortedSet<V>> factory;
- @CheckForNull transient Comparator<? super V> valueComparator;
+ transient Comparator<? super V> valueComparator;
CustomSortedSetMultimap(Map<K, Collection<V>> map, Supplier<? extends SortedSet<V>> factory) {
super(map);
@@ -439,7 +424,6 @@
}
@Override
- @CheckForNull
public Comparator<? super V> valueComparator() {
return valueComparator;
}
@@ -478,8 +462,8 @@
* @return {@code dest}
*/
@CanIgnoreReturnValue
- public static <K extends @Nullable Object, V extends @Nullable Object, M extends Multimap<K, V>>
- M invertFrom(Multimap<? extends V, ? extends K> source, M dest) {
+ public static <K, V, M extends Multimap<K, V>> M invertFrom(
+ Multimap<? extends V, ? extends K> source, M dest) {
checkNotNull(dest);
for (Map.Entry<? extends V, ? extends K> entry : source.entries()) {
dest.put(entry.getValue(), entry.getKey());
@@ -519,8 +503,7 @@
* @param multimap the multimap to be wrapped in a synchronized view
* @return a synchronized view of the specified multimap
*/
- public static <K extends @Nullable Object, V extends @Nullable Object>
- Multimap<K, V> synchronizedMultimap(Multimap<K, V> multimap) {
+ public static <K, V> Multimap<K, V> synchronizedMultimap(Multimap<K, V> multimap) {
return Synchronized.multimap(multimap, null);
}
@@ -535,8 +518,7 @@
* @param delegate the multimap for which an unmodifiable view is to be returned
* @return an unmodifiable view of the specified multimap
*/
- public static <K extends @Nullable Object, V extends @Nullable Object>
- Multimap<K, V> unmodifiableMultimap(Multimap<K, V> delegate) {
+ public static <K, V> Multimap<K, V> unmodifiableMultimap(Multimap<K, V> delegate) {
if (delegate instanceof UnmodifiableMultimap || delegate instanceof ImmutableMultimap) {
return delegate;
}
@@ -554,14 +536,14 @@
return checkNotNull(delegate);
}
- private static class UnmodifiableMultimap<K extends @Nullable Object, V extends @Nullable Object>
- extends ForwardingMultimap<K, V> implements Serializable {
+ private static class UnmodifiableMultimap<K, V> extends ForwardingMultimap<K, V>
+ implements Serializable {
final Multimap<K, V> delegate;
- @LazyInit @CheckForNull transient Collection<Entry<K, V>> entries;
- @LazyInit @CheckForNull transient Multiset<K> keys;
- @LazyInit @CheckForNull transient Set<K> keySet;
- @LazyInit @CheckForNull transient Collection<V> values;
- @LazyInit @CheckForNull transient Map<K, Collection<V>> map;
+ @NullableDecl transient Collection<Entry<K, V>> entries;
+ @NullableDecl transient Multiset<K> keys;
+ @NullableDecl transient Set<K> keySet;
+ @NullableDecl transient Collection<V> values;
+ @NullableDecl transient Map<K, Collection<V>> map;
UnmodifiableMultimap(final Multimap<K, V> delegate) {
this.delegate = checkNotNull(delegate);
@@ -606,7 +588,7 @@
}
@Override
- public Collection<V> get(@ParametricNullness K key) {
+ public Collection<V> get(K key) {
return unmodifiableValueCollection(delegate.get(key));
}
@@ -629,12 +611,12 @@
}
@Override
- public boolean put(@ParametricNullness K key, @ParametricNullness V value) {
+ public boolean put(K key, V value) {
throw new UnsupportedOperationException();
}
@Override
- public boolean putAll(@ParametricNullness K key, Iterable<? extends V> values) {
+ public boolean putAll(K key, Iterable<? extends V> values) {
throw new UnsupportedOperationException();
}
@@ -644,17 +626,17 @@
}
@Override
- public boolean remove(@CheckForNull Object key, @CheckForNull Object value) {
+ public boolean remove(Object key, Object value) {
throw new UnsupportedOperationException();
}
@Override
- public Collection<V> removeAll(@CheckForNull Object key) {
+ public Collection<V> removeAll(Object key) {
throw new UnsupportedOperationException();
}
@Override
- public Collection<V> replaceValues(@ParametricNullness K key, Iterable<? extends V> values) {
+ public Collection<V> replaceValues(K key, Iterable<? extends V> values) {
throw new UnsupportedOperationException();
}
@@ -670,9 +652,8 @@
private static final long serialVersionUID = 0;
}
- private static class UnmodifiableListMultimap<
- K extends @Nullable Object, V extends @Nullable Object>
- extends UnmodifiableMultimap<K, V> implements ListMultimap<K, V> {
+ private static class UnmodifiableListMultimap<K, V> extends UnmodifiableMultimap<K, V>
+ implements ListMultimap<K, V> {
UnmodifiableListMultimap(ListMultimap<K, V> delegate) {
super(delegate);
}
@@ -683,26 +664,25 @@
}
@Override
- public List<V> get(@ParametricNullness K key) {
+ public List<V> get(K key) {
return Collections.unmodifiableList(delegate().get(key));
}
@Override
- public List<V> removeAll(@CheckForNull Object key) {
+ public List<V> removeAll(Object key) {
throw new UnsupportedOperationException();
}
@Override
- public List<V> replaceValues(@ParametricNullness K key, Iterable<? extends V> values) {
+ public List<V> replaceValues(K key, Iterable<? extends V> values) {
throw new UnsupportedOperationException();
}
private static final long serialVersionUID = 0;
}
- private static class UnmodifiableSetMultimap<
- K extends @Nullable Object, V extends @Nullable Object>
- extends UnmodifiableMultimap<K, V> implements SetMultimap<K, V> {
+ private static class UnmodifiableSetMultimap<K, V> extends UnmodifiableMultimap<K, V>
+ implements SetMultimap<K, V> {
UnmodifiableSetMultimap(SetMultimap<K, V> delegate) {
super(delegate);
}
@@ -713,7 +693,7 @@
}
@Override
- public Set<V> get(@ParametricNullness K key) {
+ public Set<V> get(K key) {
/*
* Note that this doesn't return a SortedSet when delegate is a
* SortedSetMultiset, unlike (SortedSet<V>) super.get().
@@ -727,21 +707,20 @@
}
@Override
- public Set<V> removeAll(@CheckForNull Object key) {
+ public Set<V> removeAll(Object key) {
throw new UnsupportedOperationException();
}
@Override
- public Set<V> replaceValues(@ParametricNullness K key, Iterable<? extends V> values) {
+ public Set<V> replaceValues(K key, Iterable<? extends V> values) {
throw new UnsupportedOperationException();
}
private static final long serialVersionUID = 0;
}
- private static class UnmodifiableSortedSetMultimap<
- K extends @Nullable Object, V extends @Nullable Object>
- extends UnmodifiableSetMultimap<K, V> implements SortedSetMultimap<K, V> {
+ private static class UnmodifiableSortedSetMultimap<K, V> extends UnmodifiableSetMultimap<K, V>
+ implements SortedSetMultimap<K, V> {
UnmodifiableSortedSetMultimap(SortedSetMultimap<K, V> delegate) {
super(delegate);
}
@@ -752,22 +731,21 @@
}
@Override
- public SortedSet<V> get(@ParametricNullness K key) {
+ public SortedSet<V> get(K key) {
return Collections.unmodifiableSortedSet(delegate().get(key));
}
@Override
- public SortedSet<V> removeAll(@CheckForNull Object key) {
+ public SortedSet<V> removeAll(Object key) {
throw new UnsupportedOperationException();
}
@Override
- public SortedSet<V> replaceValues(@ParametricNullness K key, Iterable<? extends V> values) {
+ public SortedSet<V> replaceValues(K key, Iterable<? extends V> values) {
throw new UnsupportedOperationException();
}
@Override
- @CheckForNull
public Comparator<? super V> valueComparator() {
return delegate().valueComparator();
}
@@ -785,8 +763,7 @@
* @param multimap the multimap to be wrapped
* @return a synchronized view of the specified multimap
*/
- public static <K extends @Nullable Object, V extends @Nullable Object>
- SetMultimap<K, V> synchronizedSetMultimap(SetMultimap<K, V> multimap) {
+ public static <K, V> SetMultimap<K, V> synchronizedSetMultimap(SetMultimap<K, V> multimap) {
return Synchronized.setMultimap(multimap, null);
}
@@ -801,8 +778,7 @@
* @param delegate the multimap for which an unmodifiable view is to be returned
* @return an unmodifiable view of the specified multimap
*/
- public static <K extends @Nullable Object, V extends @Nullable Object>
- SetMultimap<K, V> unmodifiableSetMultimap(SetMultimap<K, V> delegate) {
+ public static <K, V> SetMultimap<K, V> unmodifiableSetMultimap(SetMultimap<K, V> delegate) {
if (delegate instanceof UnmodifiableSetMultimap || delegate instanceof ImmutableSetMultimap) {
return delegate;
}
@@ -832,8 +808,8 @@
* @param multimap the multimap to be wrapped
* @return a synchronized view of the specified multimap
*/
- public static <K extends @Nullable Object, V extends @Nullable Object>
- SortedSetMultimap<K, V> synchronizedSortedSetMultimap(SortedSetMultimap<K, V> multimap) {
+ public static <K, V> SortedSetMultimap<K, V> synchronizedSortedSetMultimap(
+ SortedSetMultimap<K, V> multimap) {
return Synchronized.sortedSetMultimap(multimap, null);
}
@@ -848,8 +824,8 @@
* @param delegate the multimap for which an unmodifiable view is to be returned
* @return an unmodifiable view of the specified multimap
*/
- public static <K extends @Nullable Object, V extends @Nullable Object>
- SortedSetMultimap<K, V> unmodifiableSortedSetMultimap(SortedSetMultimap<K, V> delegate) {
+ public static <K, V> SortedSetMultimap<K, V> unmodifiableSortedSetMultimap(
+ SortedSetMultimap<K, V> delegate) {
if (delegate instanceof UnmodifiableSortedSetMultimap) {
return delegate;
}
@@ -864,8 +840,7 @@
* @param multimap the multimap to be wrapped
* @return a synchronized view of the specified multimap
*/
- public static <K extends @Nullable Object, V extends @Nullable Object>
- ListMultimap<K, V> synchronizedListMultimap(ListMultimap<K, V> multimap) {
+ public static <K, V> ListMultimap<K, V> synchronizedListMultimap(ListMultimap<K, V> multimap) {
return Synchronized.listMultimap(multimap, null);
}
@@ -880,8 +855,7 @@
* @param delegate the multimap for which an unmodifiable view is to be returned
* @return an unmodifiable view of the specified multimap
*/
- public static <K extends @Nullable Object, V extends @Nullable Object>
- ListMultimap<K, V> unmodifiableListMultimap(ListMultimap<K, V> delegate) {
+ public static <K, V> ListMultimap<K, V> unmodifiableListMultimap(ListMultimap<K, V> delegate) {
if (delegate instanceof UnmodifiableListMultimap || delegate instanceof ImmutableListMultimap) {
return delegate;
}
@@ -908,8 +882,7 @@
* @param collection the collection for which to return an unmodifiable view
* @return an unmodifiable view of the collection
*/
- private static <V extends @Nullable Object> Collection<V> unmodifiableValueCollection(
- Collection<V> collection) {
+ private static <V> Collection<V> unmodifiableValueCollection(Collection<V> collection) {
if (collection instanceof SortedSet) {
return Collections.unmodifiableSortedSet((SortedSet<V>) collection);
} else if (collection instanceof Set) {
@@ -928,8 +901,8 @@
* @param entries the entries for which to return an unmodifiable view
* @return an unmodifiable view of the entries
*/
- private static <K extends @Nullable Object, V extends @Nullable Object>
- Collection<Entry<K, V>> unmodifiableEntries(Collection<Entry<K, V>> entries) {
+ private static <K, V> Collection<Entry<K, V>> unmodifiableEntries(
+ Collection<Entry<K, V>> entries) {
if (entries instanceof Set) {
return Maps.unmodifiableEntrySet((Set<Entry<K, V>>) entries);
}
@@ -945,8 +918,7 @@
@Beta
@SuppressWarnings("unchecked")
// safe by specification of ListMultimap.asMap()
- public static <K extends @Nullable Object, V extends @Nullable Object> Map<K, List<V>> asMap(
- ListMultimap<K, V> multimap) {
+ public static <K, V> Map<K, List<V>> asMap(ListMultimap<K, V> multimap) {
return (Map<K, List<V>>) (Map<K, ?>) multimap.asMap();
}
@@ -959,8 +931,7 @@
@Beta
@SuppressWarnings("unchecked")
// safe by specification of SetMultimap.asMap()
- public static <K extends @Nullable Object, V extends @Nullable Object> Map<K, Set<V>> asMap(
- SetMultimap<K, V> multimap) {
+ public static <K, V> Map<K, Set<V>> asMap(SetMultimap<K, V> multimap) {
return (Map<K, Set<V>>) (Map<K, ?>) multimap.asMap();
}
@@ -973,8 +944,7 @@
@Beta
@SuppressWarnings("unchecked")
// safe by specification of SortedSetMultimap.asMap()
- public static <K extends @Nullable Object, V extends @Nullable Object> Map<K, SortedSet<V>> asMap(
- SortedSetMultimap<K, V> multimap) {
+ public static <K, V> Map<K, SortedSet<V>> asMap(SortedSetMultimap<K, V> multimap) {
return (Map<K, SortedSet<V>>) (Map<K, ?>) multimap.asMap();
}
@@ -985,8 +955,7 @@
* @since 15.0
*/
@Beta
- public static <K extends @Nullable Object, V extends @Nullable Object>
- Map<K, Collection<V>> asMap(Multimap<K, V> multimap) {
+ public static <K, V> Map<K, Collection<V>> asMap(Multimap<K, V> multimap) {
return multimap.asMap();
}
@@ -1005,14 +974,13 @@
*
* @param map the backing map for the returned multimap view
*/
- public static <K extends @Nullable Object, V extends @Nullable Object> SetMultimap<K, V> forMap(
- Map<K, V> map) {
+ public static <K, V> SetMultimap<K, V> forMap(Map<K, V> map) {
return new MapMultimap<>(map);
}
/** @see Multimaps#forMap */
- private static class MapMultimap<K extends @Nullable Object, V extends @Nullable Object>
- extends AbstractMultimap<K, V> implements SetMultimap<K, V>, Serializable {
+ private static class MapMultimap<K, V> extends AbstractMultimap<K, V>
+ implements SetMultimap<K, V>, Serializable {
final Map<K, V> map;
MapMultimap(Map<K, V> map) {
@@ -1025,22 +993,22 @@
}
@Override
- public boolean containsKey(@CheckForNull Object key) {
+ public boolean containsKey(Object key) {
return map.containsKey(key);
}
@Override
- public boolean containsValue(@CheckForNull Object value) {
+ public boolean containsValue(Object value) {
return map.containsValue(value);
}
@Override
- public boolean containsEntry(@CheckForNull Object key, @CheckForNull Object value) {
+ public boolean containsEntry(Object key, Object value) {
return map.entrySet().contains(Maps.immutableEntry(key, value));
}
@Override
- public Set<V> get(@ParametricNullness final K key) {
+ public Set<V> get(final K key) {
return new Sets.ImprovedAbstractSet<V>() {
@Override
public Iterator<V> iterator() {
@@ -1053,17 +1021,12 @@
}
@Override
- @ParametricNullness
public V next() {
if (!hasNext()) {
throw new NoSuchElementException();
}
i++;
- /*
- * The cast is safe because of the containsKey check in hasNext(). (That means it's
- * unsafe under concurrent modification, but all bets are off then, anyway.)
- */
- return uncheckedCastNullableTToT(map.get(key));
+ return map.get(key);
}
@Override
@@ -1083,12 +1046,12 @@
}
@Override
- public boolean put(@ParametricNullness K key, @ParametricNullness V value) {
+ public boolean put(K key, V value) {
throw new UnsupportedOperationException();
}
@Override
- public boolean putAll(@ParametricNullness K key, Iterable<? extends V> values) {
+ public boolean putAll(K key, Iterable<? extends V> values) {
throw new UnsupportedOperationException();
}
@@ -1098,17 +1061,17 @@
}
@Override
- public Set<V> replaceValues(@ParametricNullness K key, Iterable<? extends V> values) {
+ public Set<V> replaceValues(K key, Iterable<? extends V> values) {
throw new UnsupportedOperationException();
}
@Override
- public boolean remove(@CheckForNull Object key, @CheckForNull Object value) {
+ public boolean remove(Object key, Object value) {
return map.entrySet().remove(Maps.immutableEntry(key, value));
}
@Override
- public Set<V> removeAll(@CheckForNull Object key) {
+ public Set<V> removeAll(Object key) {
Set<V> values = new HashSet<V>(2);
if (!map.containsKey(key)) {
return values;
@@ -1206,10 +1169,8 @@
*
* @since 7.0
*/
- public static <
- K extends @Nullable Object, V1 extends @Nullable Object, V2 extends @Nullable Object>
- Multimap<K, V2> transformValues(
- Multimap<K, V1> fromMultimap, final Function<? super V1, V2> function) {
+ public static <K, V1, V2> Multimap<K, V2> transformValues(
+ Multimap<K, V1> fromMultimap, final Function<? super V1, V2> function) {
checkNotNull(function);
EntryTransformer<K, V1, V2> transformer = Maps.asEntryTransformer(function);
return transformEntries(fromMultimap, transformer);
@@ -1255,10 +1216,8 @@
*
* @since 7.0
*/
- public static <
- K extends @Nullable Object, V1 extends @Nullable Object, V2 extends @Nullable Object>
- ListMultimap<K, V2> transformValues(
- ListMultimap<K, V1> fromMultimap, final Function<? super V1, V2> function) {
+ public static <K, V1, V2> ListMultimap<K, V2> transformValues(
+ ListMultimap<K, V1> fromMultimap, final Function<? super V1, V2> function) {
checkNotNull(function);
EntryTransformer<K, V1, V2> transformer = Maps.asEntryTransformer(function);
return transformEntries(fromMultimap, transformer);
@@ -1315,10 +1274,8 @@
*
* @since 7.0
*/
- public static <
- K extends @Nullable Object, V1 extends @Nullable Object, V2 extends @Nullable Object>
- Multimap<K, V2> transformEntries(
- Multimap<K, V1> fromMap, EntryTransformer<? super K, ? super V1, V2> transformer) {
+ public static <K, V1, V2> Multimap<K, V2> transformEntries(
+ Multimap<K, V1> fromMap, EntryTransformer<? super K, ? super V1, V2> transformer) {
return new TransformedEntriesMultimap<>(fromMap, transformer);
}
@@ -1370,16 +1327,12 @@
*
* @since 7.0
*/
- public static <
- K extends @Nullable Object, V1 extends @Nullable Object, V2 extends @Nullable Object>
- ListMultimap<K, V2> transformEntries(
- ListMultimap<K, V1> fromMap, EntryTransformer<? super K, ? super V1, V2> transformer) {
+ public static <K, V1, V2> ListMultimap<K, V2> transformEntries(
+ ListMultimap<K, V1> fromMap, EntryTransformer<? super K, ? super V1, V2> transformer) {
return new TransformedEntriesListMultimap<>(fromMap, transformer);
}
- private static class TransformedEntriesMultimap<
- K extends @Nullable Object, V1 extends @Nullable Object, V2 extends @Nullable Object>
- extends AbstractMultimap<K, V2> {
+ private static class TransformedEntriesMultimap<K, V1, V2> extends AbstractMultimap<K, V2> {
final Multimap<K, V1> fromMultimap;
final EntryTransformer<? super K, ? super V1, V2> transformer;
@@ -1390,7 +1343,7 @@
this.transformer = checkNotNull(transformer);
}
- Collection<V2> transform(@ParametricNullness K key, Collection<V1> values) {
+ Collection<V2> transform(K key, Collection<V1> values) {
Function<? super V1, V2> function = Maps.asValueToValueFunction(transformer, key);
if (values instanceof List) {
return Lists.transform((List<V1>) values, function);
@@ -1405,7 +1358,7 @@
fromMultimap.asMap(),
new EntryTransformer<K, Collection<V1>, Collection<V2>>() {
@Override
- public Collection<V2> transformEntry(@ParametricNullness K key, Collection<V1> value) {
+ public Collection<V2> transformEntry(K key, Collection<V1> value) {
return transform(key, value);
}
});
@@ -1417,7 +1370,7 @@
}
@Override
- public boolean containsKey(@CheckForNull Object key) {
+ public boolean containsKey(Object key) {
return fromMultimap.containsKey(key);
}
@@ -1433,7 +1386,7 @@
}
@Override
- public Collection<V2> get(@ParametricNullness final K key) {
+ public Collection<V2> get(final K key) {
return transform(key, fromMultimap.get(key));
}
@@ -1453,12 +1406,12 @@
}
@Override
- public boolean put(@ParametricNullness K key, @ParametricNullness V2 value) {
+ public boolean put(K key, V2 value) {
throw new UnsupportedOperationException();
}
@Override
- public boolean putAll(@ParametricNullness K key, Iterable<? extends V2> values) {
+ public boolean putAll(K key, Iterable<? extends V2> values) {
throw new UnsupportedOperationException();
}
@@ -1469,18 +1422,18 @@
@SuppressWarnings("unchecked")
@Override
- public boolean remove(@CheckForNull Object key, @CheckForNull Object value) {
+ public boolean remove(Object key, Object value) {
return get((K) key).remove(value);
}
@SuppressWarnings("unchecked")
@Override
- public Collection<V2> removeAll(@CheckForNull Object key) {
+ public Collection<V2> removeAll(Object key) {
return transform((K) key, fromMultimap.removeAll(key));
}
@Override
- public Collection<V2> replaceValues(@ParametricNullness K key, Iterable<? extends V2> values) {
+ public Collection<V2> replaceValues(K key, Iterable<? extends V2> values) {
throw new UnsupportedOperationException();
}
@@ -1496,8 +1449,7 @@
}
}
- private static final class TransformedEntriesListMultimap<
- K extends @Nullable Object, V1 extends @Nullable Object, V2 extends @Nullable Object>
+ private static final class TransformedEntriesListMultimap<K, V1, V2>
extends TransformedEntriesMultimap<K, V1, V2> implements ListMultimap<K, V2> {
TransformedEntriesListMultimap(
@@ -1506,23 +1458,23 @@
}
@Override
- List<V2> transform(@ParametricNullness K key, Collection<V1> values) {
+ List<V2> transform(K key, Collection<V1> values) {
return Lists.transform((List<V1>) values, Maps.asValueToValueFunction(transformer, key));
}
@Override
- public List<V2> get(@ParametricNullness K key) {
+ public List<V2> get(K key) {
return transform(key, fromMultimap.get(key));
}
@SuppressWarnings("unchecked")
@Override
- public List<V2> removeAll(@CheckForNull Object key) {
+ public List<V2> removeAll(Object key) {
return transform((K) key, fromMultimap.removeAll(key));
}
@Override
- public List<V2> replaceValues(@ParametricNullness K key, Iterable<? extends V2> values) {
+ public List<V2> replaceValues(K key, Iterable<? extends V2> values) {
throw new UnsupportedOperationException();
}
}
@@ -1615,8 +1567,7 @@
return builder.build();
}
- static class Keys<K extends @Nullable Object, V extends @Nullable Object>
- extends AbstractMultiset<K> {
+ static class Keys<K, V> extends AbstractMultiset<K> {
@Weak final Multimap<K, V> multimap;
Keys(Multimap<K, V> multimap) {
@@ -1631,7 +1582,6 @@
Multiset.Entry<K> transform(final Map.Entry<K, Collection<V>> backingEntry) {
return new Multisets.AbstractEntry<K>() {
@Override
- @ParametricNullness
public K getElement() {
return backingEntry.getKey();
}
@@ -1656,7 +1606,7 @@
}
@Override
- public boolean contains(@CheckForNull Object element) {
+ public boolean contains(@NullableDecl Object element) {
return multimap.containsKey(element);
}
@@ -1666,13 +1616,13 @@
}
@Override
- public int count(@CheckForNull Object element) {
+ public int count(@NullableDecl Object element) {
Collection<V> values = Maps.safeGet(multimap.asMap(), element);
return (values == null) ? 0 : values.size();
}
@Override
- public int remove(@CheckForNull Object element, int occurrences) {
+ public int remove(@NullableDecl Object element, int occurrences) {
checkNonnegative(occurrences, "occurrences");
if (occurrences == 0) {
return count(element);
@@ -1714,8 +1664,7 @@
}
/** A skeleton implementation of {@link Multimap#entries()}. */
- abstract static class Entries<K extends @Nullable Object, V extends @Nullable Object>
- extends AbstractCollection<Map.Entry<K, V>> {
+ abstract static class Entries<K, V> extends AbstractCollection<Map.Entry<K, V>> {
abstract Multimap<K, V> multimap();
@Override
@@ -1724,7 +1673,7 @@
}
@Override
- public boolean contains(@CheckForNull Object o) {
+ public boolean contains(@NullableDecl Object o) {
if (o instanceof Map.Entry) {
Map.Entry<?, ?> entry = (Map.Entry<?, ?>) o;
return multimap().containsEntry(entry.getKey(), entry.getValue());
@@ -1733,7 +1682,7 @@
}
@Override
- public boolean remove(@CheckForNull Object o) {
+ public boolean remove(@NullableDecl Object o) {
if (o instanceof Map.Entry) {
Map.Entry<?, ?> entry = (Map.Entry<?, ?>) o;
return multimap().remove(entry.getKey(), entry.getValue());
@@ -1748,8 +1697,7 @@
}
/** A skeleton implementation of {@link Multimap#asMap()}. */
- static final class AsMap<K extends @Nullable Object, V extends @Nullable Object>
- extends Maps.ViewCachingAbstractMap<K, Collection<V>> {
+ static final class AsMap<K, V> extends Maps.ViewCachingAbstractMap<K, Collection<V>> {
@Weak private final Multimap<K, V> multimap;
AsMap(Multimap<K, V> multimap) {
@@ -1766,7 +1714,7 @@
return new EntrySet();
}
- void removeValuesForKey(@CheckForNull Object key) {
+ void removeValuesForKey(Object key) {
multimap.keySet().remove(key);
}
@@ -1783,19 +1731,18 @@
multimap.keySet(),
new Function<K, Collection<V>>() {
@Override
- public Collection<V> apply(@ParametricNullness K key) {
+ public Collection<V> apply(K key) {
return multimap.get(key);
}
});
}
@Override
- public boolean remove(@CheckForNull Object o) {
+ public boolean remove(Object o) {
if (!contains(o)) {
return false;
}
- // requireNonNull is safe because of the contains check.
- Map.Entry<?, ?> entry = requireNonNull((Map.Entry<?, ?>) o);
+ Map.Entry<?, ?> entry = (Map.Entry<?, ?>) o;
removeValuesForKey(entry.getKey());
return true;
}
@@ -1803,14 +1750,12 @@
@SuppressWarnings("unchecked")
@Override
- @CheckForNull
- public Collection<V> get(@CheckForNull Object key) {
+ public Collection<V> get(Object key) {
return containsKey(key) ? multimap.get((K) key) : null;
}
@Override
- @CheckForNull
- public Collection<V> remove(@CheckForNull Object key) {
+ public Collection<V> remove(Object key) {
return containsKey(key) ? multimap.removeAll(key) : null;
}
@@ -1825,7 +1770,7 @@
}
@Override
- public boolean containsKey(@CheckForNull Object key) {
+ public boolean containsKey(Object key) {
return multimap.containsKey(key);
}
@@ -1862,7 +1807,7 @@
*
* @since 11.0
*/
- public static <K extends @Nullable Object, V extends @Nullable Object> Multimap<K, V> filterKeys(
+ public static <K, V> Multimap<K, V> filterKeys(
Multimap<K, V> unfiltered, final Predicate<? super K> keyPredicate) {
if (unfiltered instanceof SetMultimap) {
return filterKeys((SetMultimap<K, V>) unfiltered, keyPredicate);
@@ -1907,9 +1852,8 @@
*
* @since 14.0
*/
- public static <K extends @Nullable Object, V extends @Nullable Object>
- SetMultimap<K, V> filterKeys(
- SetMultimap<K, V> unfiltered, final Predicate<? super K> keyPredicate) {
+ public static <K, V> SetMultimap<K, V> filterKeys(
+ SetMultimap<K, V> unfiltered, final Predicate<? super K> keyPredicate) {
if (unfiltered instanceof FilteredKeySetMultimap) {
FilteredKeySetMultimap<K, V> prev = (FilteredKeySetMultimap<K, V>) unfiltered;
return new FilteredKeySetMultimap<>(
@@ -1949,9 +1893,8 @@
*
* @since 14.0
*/
- public static <K extends @Nullable Object, V extends @Nullable Object>
- ListMultimap<K, V> filterKeys(
- ListMultimap<K, V> unfiltered, final Predicate<? super K> keyPredicate) {
+ public static <K, V> ListMultimap<K, V> filterKeys(
+ ListMultimap<K, V> unfiltered, final Predicate<? super K> keyPredicate) {
if (unfiltered instanceof FilteredKeyListMultimap) {
FilteredKeyListMultimap<K, V> prev = (FilteredKeyListMultimap<K, V>) unfiltered;
return new FilteredKeyListMultimap<>(
@@ -1988,9 +1931,8 @@
*
* @since 11.0
*/
- public static <K extends @Nullable Object, V extends @Nullable Object>
- Multimap<K, V> filterValues(
- Multimap<K, V> unfiltered, final Predicate<? super V> valuePredicate) {
+ public static <K, V> Multimap<K, V> filterValues(
+ Multimap<K, V> unfiltered, final Predicate<? super V> valuePredicate) {
return filterEntries(unfiltered, Maps.<V>valuePredicateOnEntries(valuePredicate));
}
@@ -2021,9 +1963,8 @@
*
* @since 14.0
*/
- public static <K extends @Nullable Object, V extends @Nullable Object>
- SetMultimap<K, V> filterValues(
- SetMultimap<K, V> unfiltered, final Predicate<? super V> valuePredicate) {
+ public static <K, V> SetMultimap<K, V> filterValues(
+ SetMultimap<K, V> unfiltered, final Predicate<? super V> valuePredicate) {
return filterEntries(unfiltered, Maps.<V>valuePredicateOnEntries(valuePredicate));
}
@@ -2052,9 +1993,8 @@
*
* @since 11.0
*/
- public static <K extends @Nullable Object, V extends @Nullable Object>
- Multimap<K, V> filterEntries(
- Multimap<K, V> unfiltered, Predicate<? super Entry<K, V>> entryPredicate) {
+ public static <K, V> Multimap<K, V> filterEntries(
+ Multimap<K, V> unfiltered, Predicate<? super Entry<K, V>> entryPredicate) {
checkNotNull(entryPredicate);
if (unfiltered instanceof SetMultimap) {
return filterEntries((SetMultimap<K, V>) unfiltered, entryPredicate);
@@ -2089,9 +2029,8 @@
*
* @since 14.0
*/
- public static <K extends @Nullable Object, V extends @Nullable Object>
- SetMultimap<K, V> filterEntries(
- SetMultimap<K, V> unfiltered, Predicate<? super Entry<K, V>> entryPredicate) {
+ public static <K, V> SetMultimap<K, V> filterEntries(
+ SetMultimap<K, V> unfiltered, Predicate<? super Entry<K, V>> entryPredicate) {
checkNotNull(entryPredicate);
return (unfiltered instanceof FilteredSetMultimap)
? filterFiltered((FilteredSetMultimap<K, V>) unfiltered, entryPredicate)
@@ -2104,9 +2043,8 @@
* lead to a multimap whose removal operations would fail. This method combines the predicates to
* avoid that problem.
*/
- private static <K extends @Nullable Object, V extends @Nullable Object>
- Multimap<K, V> filterFiltered(
- FilteredMultimap<K, V> multimap, Predicate<? super Entry<K, V>> entryPredicate) {
+ private static <K, V> Multimap<K, V> filterFiltered(
+ FilteredMultimap<K, V> multimap, Predicate<? super Entry<K, V>> entryPredicate) {
Predicate<Entry<K, V>> predicate =
Predicates.<Entry<K, V>>and(multimap.entryPredicate(), entryPredicate);
return new FilteredEntryMultimap<>(multimap.unfiltered(), predicate);
@@ -2118,15 +2056,14 @@
* lead to a multimap whose removal operations would fail. This method combines the predicates to
* avoid that problem.
*/
- private static <K extends @Nullable Object, V extends @Nullable Object>
- SetMultimap<K, V> filterFiltered(
- FilteredSetMultimap<K, V> multimap, Predicate<? super Entry<K, V>> entryPredicate) {
+ private static <K, V> SetMultimap<K, V> filterFiltered(
+ FilteredSetMultimap<K, V> multimap, Predicate<? super Entry<K, V>> entryPredicate) {
Predicate<Entry<K, V>> predicate =
Predicates.<Entry<K, V>>and(multimap.entryPredicate(), entryPredicate);
return new FilteredEntrySetMultimap<>(multimap.unfiltered(), predicate);
}
- static boolean equalsImpl(Multimap<?, ?> multimap, @CheckForNull Object object) {
+ static boolean equalsImpl(Multimap<?, ?> multimap, @NullableDecl Object object) {
if (object == multimap) {
return true;
}
diff --git a/android/guava/src/com/google/common/collect/Multiset.java b/android/guava/src/com/google/common/collect/Multiset.java
index 8dfb1af..faedb56 100644
--- a/android/guava/src/com/google/common/collect/Multiset.java
+++ b/android/guava/src/com/google/common/collect/Multiset.java
@@ -24,8 +24,7 @@
import java.util.Iterator;
import java.util.List;
import java.util.Set;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* A collection that supports order-independent equality, like {@link Set}, but may have duplicate
@@ -62,10 +61,6 @@
* <p>A multiset uses {@link Object#equals} to determine whether two instances should be considered
* "the same," <i>unless specified otherwise</i> by the implementation.
*
- * <p><b>Warning:</b> as with normal {@link Set}s, it is almost always a bad idea to modify an
- * element (in a way that affects its {@link Object#equals} behavior) while it is contained in a
- * multiset. Undefined behavior and bugs will result.
- *
* <p>Common implementations include {@link ImmutableMultiset}, {@link HashMultiset}, and {@link
* ConcurrentHashMultiset}.
*
@@ -81,8 +76,7 @@
* @since 2.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-public interface Multiset<E extends @Nullable Object> extends Collection<E> {
+public interface Multiset<E> extends Collection<E> {
// Query Operations
/**
@@ -107,7 +101,7 @@
* @return the number of occurrences of the element in this multiset; possibly zero but never
* negative
*/
- int count(@CompatibleWith("E") @CheckForNull Object element);
+ int count(@NullableDecl @CompatibleWith("E") Object element);
// Bulk Operations
@@ -130,7 +124,7 @@
* return normally.
*/
@CanIgnoreReturnValue
- int add(@ParametricNullness E element, int occurrences);
+ int add(@NullableDecl E element, int occurrences);
/**
* Adds a single occurrence of the specified element to this multiset.
@@ -153,7 +147,7 @@
*/
@CanIgnoreReturnValue
@Override
- boolean add(@ParametricNullness E element);
+ boolean add(E element);
/**
* Removes a number of occurrences of the specified element from this multiset. If the multiset
@@ -168,7 +162,7 @@
* @throws IllegalArgumentException if {@code occurrences} is negative
*/
@CanIgnoreReturnValue
- int remove(@CompatibleWith("E") @CheckForNull Object element, int occurrences);
+ int remove(@NullableDecl @CompatibleWith("E") Object element, int occurrences);
/**
* Removes a <i>single</i> occurrence of the specified element from this multiset, if present.
@@ -184,7 +178,7 @@
*/
@CanIgnoreReturnValue
@Override
- boolean remove(@CheckForNull Object element);
+ boolean remove(@NullableDecl Object element);
/**
* Adds or removes the necessary occurrences of an element such that the element attains the
@@ -200,7 +194,7 @@
* zero instead.
*/
@CanIgnoreReturnValue
- int setCount(@ParametricNullness E element, int count);
+ int setCount(E element, int count);
/**
* Conditionally sets the count of an element to a new value, as described in {@link
@@ -219,7 +213,7 @@
* implementor may optionally return {@code true} instead.
*/
@CanIgnoreReturnValue
- boolean setCount(@ParametricNullness E element, int oldCount, int newCount);
+ boolean setCount(E element, int oldCount, int newCount);
// Views
@@ -265,7 +259,7 @@
*
* @since 2.0
*/
- interface Entry<E extends @Nullable Object> {
+ interface Entry<E> {
/**
* Returns the multiset element corresponding to this entry. Multiple calls to this method
@@ -273,7 +267,6 @@
*
* @return the element corresponding to this entry
*/
- @ParametricNullness
E getElement();
/**
@@ -301,7 +294,7 @@
*/
@Override
// TODO(kevinb): check this wrt TreeMultiset?
- boolean equals(@CheckForNull Object o);
+ boolean equals(Object o);
/**
* {@inheritDoc}
@@ -335,7 +328,7 @@
*/
@Override
// TODO(kevinb): caveats about equivalence-relation?
- boolean equals(@CheckForNull Object object);
+ boolean equals(@NullableDecl Object object);
/**
* Returns the hash code for this multiset. This is defined as the sum of
@@ -381,7 +374,7 @@
* @return {@code true} if this multiset contains at least one occurrence of the element
*/
@Override
- boolean contains(@CheckForNull Object element);
+ boolean contains(@NullableDecl Object element);
/**
* Returns {@code true} if this multiset contains at least one occurrence of each element in the
diff --git a/android/guava/src/com/google/common/collect/Multisets.java b/android/guava/src/com/google/common/collect/Multisets.java
index 02febca..0f31b74 100644
--- a/android/guava/src/com/google/common/collect/Multisets.java
+++ b/android/guava/src/com/google/common/collect/Multisets.java
@@ -20,7 +20,6 @@
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.collect.CollectPreconditions.checkNonnegative;
import static com.google.common.collect.CollectPreconditions.checkRemove;
-import static java.util.Objects.requireNonNull;
import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtCompatible;
@@ -39,8 +38,7 @@
import java.util.Iterator;
import java.util.NoSuchElementException;
import java.util.Set;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* Provides static utility methods for creating and working with {@link Multiset} instances.
@@ -55,7 +53,6 @@
* @since 2.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
public final class Multisets {
private Multisets() {}
@@ -69,8 +66,7 @@
* @param multiset the multiset for which an unmodifiable view is to be generated
* @return an unmodifiable view of the multiset
*/
- public static <E extends @Nullable Object> Multiset<E> unmodifiableMultiset(
- Multiset<? extends E> multiset) {
+ public static <E> Multiset<E> unmodifiableMultiset(Multiset<? extends E> multiset) {
if (multiset instanceof UnmodifiableMultiset || multiset instanceof ImmutableMultiset) {
@SuppressWarnings("unchecked") // Since it's unmodifiable, the covariant cast is safe
Multiset<E> result = (Multiset<E>) multiset;
@@ -90,8 +86,7 @@
return checkNotNull(multiset);
}
- static class UnmodifiableMultiset<E extends @Nullable Object> extends ForwardingMultiset<E>
- implements Serializable {
+ static class UnmodifiableMultiset<E> extends ForwardingMultiset<E> implements Serializable {
final Multiset<? extends E> delegate;
UnmodifiableMultiset(Multiset<? extends E> delegate) {
@@ -105,7 +100,7 @@
return (Multiset<E>) delegate;
}
- @CheckForNull transient Set<E> elementSet;
+ @NullableDecl transient Set<E> elementSet;
Set<E> createElementSet() {
return Collections.<E>unmodifiableSet(delegate.elementSet());
@@ -117,7 +112,7 @@
return (es == null) ? elementSet = createElementSet() : es;
}
- @CheckForNull transient Set<Multiset.Entry<E>> entrySet;
+ @NullableDecl transient Set<Multiset.Entry<E>> entrySet;
@SuppressWarnings("unchecked")
@Override
@@ -136,12 +131,12 @@
}
@Override
- public boolean add(@ParametricNullness E element) {
+ public boolean add(E element) {
throw new UnsupportedOperationException();
}
@Override
- public int add(@ParametricNullness E element, int occurrences) {
+ public int add(E element, int occurences) {
throw new UnsupportedOperationException();
}
@@ -151,12 +146,12 @@
}
@Override
- public boolean remove(@CheckForNull Object element) {
+ public boolean remove(Object element) {
throw new UnsupportedOperationException();
}
@Override
- public int remove(@CheckForNull Object element, int occurrences) {
+ public int remove(Object element, int occurrences) {
throw new UnsupportedOperationException();
}
@@ -176,12 +171,12 @@
}
@Override
- public int setCount(@ParametricNullness E element, int count) {
+ public int setCount(E element, int count) {
throw new UnsupportedOperationException();
}
@Override
- public boolean setCount(@ParametricNullness E element, int oldCount, int newCount) {
+ public boolean setCount(E element, int oldCount, int newCount) {
throw new UnsupportedOperationException();
}
@@ -200,8 +195,7 @@
* @since 11.0
*/
@Beta
- public static <E extends @Nullable Object> SortedMultiset<E> unmodifiableSortedMultiset(
- SortedMultiset<E> sortedMultiset) {
+ public static <E> SortedMultiset<E> unmodifiableSortedMultiset(SortedMultiset<E> sortedMultiset) {
// it's in its own file so it can be emulated for GWT
return new UnmodifiableSortedMultiset<E>(checkNotNull(sortedMultiset));
}
@@ -214,24 +208,22 @@
* @param n the count to be associated with the returned entry
* @throws IllegalArgumentException if {@code n} is negative
*/
- public static <E extends @Nullable Object> Multiset.Entry<E> immutableEntry(
- @ParametricNullness E e, int n) {
+ public static <E> Multiset.Entry<E> immutableEntry(@NullableDecl E e, int n) {
return new ImmutableEntry<E>(e, n);
}
- static class ImmutableEntry<E extends @Nullable Object> extends AbstractEntry<E>
- implements Serializable {
- @ParametricNullness private final E element;
+ static class ImmutableEntry<E> extends AbstractEntry<E> implements Serializable {
+ @NullableDecl private final E element;
private final int count;
- ImmutableEntry(@ParametricNullness E element, int count) {
+ ImmutableEntry(@NullableDecl E element, int count) {
this.element = element;
this.count = count;
checkNonnegative(count, "count");
}
@Override
- @ParametricNullness
+ @NullableDecl
public final E getElement() {
return element;
}
@@ -241,7 +233,6 @@
return count;
}
- @CheckForNull
public ImmutableEntry<E> nextInBucket() {
return null;
}
@@ -275,8 +266,7 @@
* @since 14.0
*/
@Beta
- public static <E extends @Nullable Object> Multiset<E> filter(
- Multiset<E> unfiltered, Predicate<? super E> predicate) {
+ public static <E> Multiset<E> filter(Multiset<E> unfiltered, Predicate<? super E> predicate) {
if (unfiltered instanceof FilteredMultiset) {
// Support clear(), removeAll(), and retainAll() when filtering a filtered
// collection.
@@ -287,7 +277,7 @@
return new FilteredMultiset<E>(unfiltered, predicate);
}
- private static final class FilteredMultiset<E extends @Nullable Object> extends ViewMultiset<E> {
+ private static final class FilteredMultiset<E> extends ViewMultiset<E> {
final Multiset<E> unfiltered;
final Predicate<? super E> predicate;
@@ -329,7 +319,7 @@
}
@Override
- public int count(@CheckForNull Object element) {
+ public int count(@NullableDecl Object element) {
int count = unfiltered.count(element);
if (count > 0) {
@SuppressWarnings("unchecked") // element is equal to an E
@@ -340,14 +330,14 @@
}
@Override
- public int add(@ParametricNullness E element, int occurrences) {
+ public int add(@NullableDecl 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(@CheckForNull Object element, int occurrences) {
+ public int remove(@NullableDecl Object element, int occurrences) {
checkNonnegative(occurrences, "occurrences");
if (occurrences == 0) {
return count(element);
@@ -382,14 +372,14 @@
* @since 14.0
*/
@Beta
- public static <E extends @Nullable Object> Multiset<E> union(
+ public static <E> Multiset<E> union(
final Multiset<? extends E> multiset1, final Multiset<? extends E> multiset2) {
checkNotNull(multiset1);
checkNotNull(multiset2);
return new ViewMultiset<E>() {
@Override
- public boolean contains(@CheckForNull Object element) {
+ public boolean contains(@NullableDecl Object element) {
return multiset1.contains(element) || multiset2.contains(element);
}
@@ -399,7 +389,7 @@
}
@Override
- public int count(@CheckForNull Object element) {
+ public int count(Object element) {
return Math.max(multiset1.count(element), multiset2.count(element));
}
@@ -420,7 +410,6 @@
// TODO(lowasser): consider making the entries live views
return new AbstractIterator<Entry<E>>() {
@Override
- @CheckForNull
protected Entry<E> computeNext() {
if (iterator1.hasNext()) {
Entry<? extends E> entry1 = iterator1.next();
@@ -454,14 +443,14 @@
*
* @since 2.0
*/
- public static <E extends @Nullable Object> Multiset<E> intersection(
+ public static <E> Multiset<E> intersection(
final Multiset<E> multiset1, final Multiset<?> multiset2) {
checkNotNull(multiset1);
checkNotNull(multiset2);
return new ViewMultiset<E>() {
@Override
- public int count(@CheckForNull Object element) {
+ public int count(Object element) {
int count1 = multiset1.count(element);
return (count1 == 0) ? 0 : Math.min(count1, multiset2.count(element));
}
@@ -482,7 +471,6 @@
// TODO(lowasser): consider making the entries live views
return new AbstractIterator<Entry<E>>() {
@Override
- @CheckForNull
protected Entry<E> computeNext() {
while (iterator1.hasNext()) {
Entry<E> entry1 = iterator1.next();
@@ -512,7 +500,7 @@
* @since 14.0
*/
@Beta
- public static <E extends @Nullable Object> Multiset<E> sum(
+ public static <E> Multiset<E> sum(
final Multiset<? extends E> multiset1, final Multiset<? extends E> multiset2) {
checkNotNull(multiset1);
checkNotNull(multiset2);
@@ -520,7 +508,7 @@
// TODO(lowasser): consider making the entries live views
return new ViewMultiset<E>() {
@Override
- public boolean contains(@CheckForNull Object element) {
+ public boolean contains(@NullableDecl Object element) {
return multiset1.contains(element) || multiset2.contains(element);
}
@@ -535,7 +523,7 @@
}
@Override
- public int count(@CheckForNull Object element) {
+ public int count(Object element) {
return multiset1.count(element) + multiset2.count(element);
}
@@ -555,7 +543,6 @@
final Iterator<? extends Entry<? extends E>> iterator2 = multiset2.entrySet().iterator();
return new AbstractIterator<Entry<E>>() {
@Override
- @CheckForNull
protected Entry<E> computeNext() {
if (iterator1.hasNext()) {
Entry<? extends E> entry1 = iterator1.next();
@@ -590,7 +577,7 @@
* @since 14.0
*/
@Beta
- public static <E extends @Nullable Object> Multiset<E> difference(
+ public static <E> Multiset<E> difference(
final Multiset<E> multiset1, final Multiset<?> multiset2) {
checkNotNull(multiset1);
checkNotNull(multiset2);
@@ -598,7 +585,7 @@
// TODO(lowasser): consider making the entries live views
return new ViewMultiset<E>() {
@Override
- public int count(@CheckForNull Object element) {
+ public int count(@NullableDecl Object element) {
int count1 = multiset1.count(element);
return (count1 == 0) ? 0 : Math.max(0, count1 - multiset2.count(element));
}
@@ -613,7 +600,6 @@
final Iterator<Entry<E>> iterator1 = multiset1.entrySet().iterator();
return new AbstractIterator<E>() {
@Override
- @CheckForNull
protected E computeNext() {
while (iterator1.hasNext()) {
Entry<E> entry1 = iterator1.next();
@@ -632,7 +618,6 @@
final Iterator<Entry<E>> iterator1 = multiset1.entrySet().iterator();
return new AbstractIterator<Entry<E>>() {
@Override
- @CheckForNull
protected Entry<E> computeNext() {
while (iterator1.hasNext()) {
Entry<E> entry1 = iterator1.next();
@@ -696,7 +681,7 @@
}
/** Delegate implementation which cares about the element type. */
- private static <E extends @Nullable Object> boolean retainOccurrencesImpl(
+ private static <E> boolean retainOccurrencesImpl(
Multiset<E> multisetToModify, Multiset<?> occurrencesToRetain) {
checkNotNull(multisetToModify);
checkNotNull(occurrencesToRetain);
@@ -804,13 +789,13 @@
* Implementation of the {@code equals}, {@code hashCode}, and {@code toString} methods of {@link
* Multiset.Entry}.
*/
- abstract static class AbstractEntry<E extends @Nullable Object> implements Multiset.Entry<E> {
+ abstract static class AbstractEntry<E> implements Multiset.Entry<E> {
/**
* Indicates whether an object equals this entry, following the behavior specified in {@link
* Multiset.Entry#equals}.
*/
@Override
- public boolean equals(@CheckForNull Object object) {
+ public boolean equals(@NullableDecl Object object) {
if (object instanceof Multiset.Entry) {
Multiset.Entry<?> that = (Multiset.Entry<?>) object;
return this.getCount() == that.getCount()
@@ -844,7 +829,7 @@
}
/** An implementation of {@link Multiset#equals}. */
- static boolean equalsImpl(Multiset<?> multiset, @CheckForNull Object object) {
+ static boolean equalsImpl(Multiset<?> multiset, @NullableDecl Object object) {
if (object == multiset) {
return true;
}
@@ -870,8 +855,7 @@
}
/** An implementation of {@link Multiset#addAll}. */
- static <E extends @Nullable Object> boolean addAllImpl(
- Multiset<E> self, Collection<? extends E> elements) {
+ static <E> boolean addAllImpl(Multiset<E> self, Collection<? extends E> elements) {
checkNotNull(self);
checkNotNull(elements);
if (elements instanceof Multiset) {
@@ -884,8 +868,7 @@
}
/** A specialization of {@code addAllImpl} for when {@code elements} is itself a Multiset. */
- private static <E extends @Nullable Object> boolean addAllImpl(
- Multiset<E> self, Multiset<? extends E> elements) {
+ private static <E> boolean addAllImpl(Multiset<E> self, Multiset<? extends E> elements) {
// It'd be nice if we could specialize for ImmutableMultiset here without also retaining
// its code when it's not in scope...
if (elements instanceof AbstractMapBasedMultiset) {
@@ -904,7 +887,7 @@
* A specialization of {@code addAllImpl} for when {@code elements} is an
* AbstractMapBasedMultiset.
*/
- private static <E extends @Nullable Object> boolean addAllImpl(
+ private static <E> boolean addAllImpl(
Multiset<E> self, AbstractMapBasedMultiset<? extends E> elements) {
if (elements.isEmpty()) {
return false;
@@ -935,8 +918,7 @@
}
/** An implementation of {@link Multiset#setCount(Object, int)}. */
- static <E extends @Nullable Object> int setCountImpl(
- Multiset<E> self, @ParametricNullness E element, int count) {
+ static <E> int setCountImpl(Multiset<E> self, E element, int count) {
checkNonnegative(count, "count");
int oldCount = self.count(element);
@@ -952,8 +934,7 @@
}
/** An implementation of {@link Multiset#setCount(Object, int, int)}. */
- static <E extends @Nullable Object> boolean setCountImpl(
- Multiset<E> self, @ParametricNullness E element, int oldCount, int newCount) {
+ static <E> boolean setCountImpl(Multiset<E> self, E element, int oldCount, int newCount) {
checkNonnegative(oldCount, "oldCount");
checkNonnegative(newCount, "newCount");
@@ -965,18 +946,16 @@
}
}
- static <E extends @Nullable Object> Iterator<E> elementIterator(
- Iterator<Entry<E>> entryIterator) {
+ static <E> Iterator<E> elementIterator(Iterator<Entry<E>> entryIterator) {
return new TransformedIterator<Entry<E>, E>(entryIterator) {
@Override
- @ParametricNullness
E transform(Entry<E> entry) {
return entry.getElement();
}
};
}
- abstract static class ElementSet<E extends @Nullable Object> extends Sets.ImprovedAbstractSet<E> {
+ abstract static class ElementSet<E> extends Sets.ImprovedAbstractSet<E> {
abstract Multiset<E> multiset();
@Override
@@ -985,7 +964,7 @@
}
@Override
- public boolean contains(@CheckForNull Object o) {
+ public boolean contains(Object o) {
return multiset().contains(o);
}
@@ -1003,7 +982,7 @@
public abstract Iterator<E> iterator();
@Override
- public boolean remove(@CheckForNull Object o) {
+ public boolean remove(Object o) {
return multiset().remove(o, Integer.MAX_VALUE) > 0;
}
@@ -1013,12 +992,11 @@
}
}
- abstract static class EntrySet<E extends @Nullable Object>
- extends Sets.ImprovedAbstractSet<Entry<E>> {
+ abstract static class EntrySet<E> extends Sets.ImprovedAbstractSet<Entry<E>> {
abstract Multiset<E> multiset();
@Override
- public boolean contains(@CheckForNull Object o) {
+ public boolean contains(@NullableDecl Object o) {
if (o instanceof Entry) {
/*
* The GWT compiler wrongly issues a warning here.
@@ -1037,16 +1015,15 @@
// GWT compiler warning; see contains().
@SuppressWarnings("cast")
@Override
- public boolean remove(@CheckForNull Object object) {
+ public boolean remove(Object object) {
if (object instanceof Multiset.Entry) {
Entry<?> entry = (Entry<?>) object;
Object element = entry.getElement();
int entryCount = entry.getCount();
if (entryCount != 0) {
// Safe as long as we never add a new entry, which we won't.
- // (Presumably it can still throw CCE/NPE but only if the underlying Multiset does.)
- @SuppressWarnings({"unchecked", "nullness"})
- Multiset<@Nullable Object> multiset = (Multiset<@Nullable Object>) multiset();
+ @SuppressWarnings("unchecked")
+ Multiset<Object> multiset = (Multiset<Object>) multiset();
return multiset.setCount(element, entryCount, 0);
}
}
@@ -1060,14 +1037,14 @@
}
/** An implementation of {@link Multiset#iterator}. */
- static <E extends @Nullable Object> Iterator<E> iteratorImpl(Multiset<E> multiset) {
+ static <E> Iterator<E> iteratorImpl(Multiset<E> multiset) {
return new MultisetIteratorImpl<E>(multiset, multiset.entrySet().iterator());
}
- static final class MultisetIteratorImpl<E extends @Nullable Object> implements Iterator<E> {
+ static final class MultisetIteratorImpl<E> implements Iterator<E> {
private final Multiset<E> multiset;
private final Iterator<Entry<E>> entryIterator;
- @CheckForNull private Entry<E> currentEntry;
+ @NullableDecl private Entry<E> currentEntry;
/** Count of subsequent elements equal to current element */
private int laterCount;
@@ -1088,7 +1065,6 @@
}
@Override
- @ParametricNullness
public E next() {
if (!hasNext()) {
throw new NoSuchElementException();
@@ -1099,11 +1075,7 @@
}
laterCount--;
canRemove = true;
- /*
- * requireNonNull is safe because laterCount starts at 0, forcing us to initialize
- * currentEntry above. After that, we never clear it.
- */
- return requireNonNull(currentEntry).getElement();
+ return currentEntry.getElement();
}
@Override
@@ -1112,11 +1084,7 @@
if (totalCount == 1) {
entryIterator.remove();
} else {
- /*
- * requireNonNull is safe because canRemove is set to true only after we initialize
- * currentEntry (which we never subsequently clear).
- */
- multiset.remove(requireNonNull(currentEntry).getElement());
+ multiset.remove(currentEntry.getElement());
}
totalCount--;
canRemove = false;
@@ -1133,7 +1101,7 @@
}
/** Used to avoid http://bugs.sun.com/view_bug.do?bug_id=6558557 */
- static <T extends @Nullable Object> Multiset<T> cast(Iterable<T> iterable) {
+ static <T> Multiset<T> cast(Iterable<T> iterable) {
return (Multiset<T>) iterable;
}
@@ -1163,8 +1131,7 @@
* An {@link AbstractMultiset} with additional default implementations, some of them linear-time
* implementations in terms of {@code elementSet} and {@code entrySet}.
*/
- private abstract static class ViewMultiset<E extends @Nullable Object>
- extends AbstractMultiset<E> {
+ private abstract static class ViewMultiset<E> extends AbstractMultiset<E> {
@Override
public int size() {
return linearTimeSizeImpl(this);
diff --git a/android/guava/src/com/google/common/collect/MutableClassToInstanceMap.java b/android/guava/src/com/google/common/collect/MutableClassToInstanceMap.java
index 2fcf0d6..1f228a8 100644
--- a/android/guava/src/com/google/common/collect/MutableClassToInstanceMap.java
+++ b/android/guava/src/com/google/common/collect/MutableClassToInstanceMap.java
@@ -27,26 +27,20 @@
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* A mutable class-to-instance map backed by an arbitrary user-provided map. See also {@link
* ImmutableClassToInstanceMap}.
*
* <p>See the Guava User Guide article on <a href=
- * "https://github.com/google/guava/wiki/NewCollectionTypesExplained#classtoinstancemap">{@code
+ * "https://github.com/google/guava/wiki/NewCollectionTypesExplained#classtoinstancemap"> {@code
* ClassToInstanceMap}</a>.
*
- * <p>This implementation <i>does</i> support null values, despite how it is annotated; see
- * discussion at {@link ClassToInstanceMap}.
- *
* @author Kevin Bourrillion
* @since 2.0
*/
@GwtIncompatible
@SuppressWarnings("serial") // using writeReplace instead of standard serialization
-@ElementTypesAreNonnullByDefault
public final class MutableClassToInstanceMap<B> extends ForwardingMap<Class<? extends B>, B>
implements ClassToInstanceMap<B>, Serializable {
@@ -114,20 +108,11 @@
@Override
public Object[] toArray() {
- /*
- * standardToArray returns `@Nullable Object[]` rather than `Object[]` but only because it
- * can be used with collections that may contain null. This collection is a collection of
- * non-null Entry objects (Entry objects that might contain null values but are not
- * themselves null), so we can treat it as a plain `Object[]`.
- */
- @SuppressWarnings("nullness")
- Object[] result = standardToArray();
- return result;
+ return standardToArray();
}
@Override
- @SuppressWarnings("nullness") // b/192354773 in our checker affects toArray declarations
- public <T extends @Nullable Object> T[] toArray(T[] array) {
+ public <T> T[] toArray(T[] array) {
return standardToArray(array);
}
};
@@ -135,7 +120,6 @@
@Override
@CanIgnoreReturnValue
- @CheckForNull
public B put(Class<? extends B> key, B value) {
return super.put(key, cast(key, value));
}
@@ -151,20 +135,17 @@
@CanIgnoreReturnValue
@Override
- @CheckForNull
public <T extends B> T putInstance(Class<T> type, T value) {
return cast(type, put(type, value));
}
@Override
- @CheckForNull
public <T extends B> T getInstance(Class<T> type) {
return cast(type, get(type));
}
@CanIgnoreReturnValue
- @CheckForNull
- private static <B, T extends B> T cast(Class<T> type, @CheckForNull B value) {
+ private static <B, T extends B> T cast(Class<T> type, B value) {
return Primitives.wrap(type).cast(value);
}
diff --git a/android/guava/src/com/google/common/collect/NaturalOrdering.java b/android/guava/src/com/google/common/collect/NaturalOrdering.java
index 8cb8aef..d979276 100644
--- a/android/guava/src/com/google/common/collect/NaturalOrdering.java
+++ b/android/guava/src/com/google/common/collect/NaturalOrdering.java
@@ -20,46 +20,44 @@
import com.google.common.annotations.GwtCompatible;
import java.io.Serializable;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/** An ordering that uses the natural order of the values. */
@GwtCompatible(serializable = true)
@SuppressWarnings({"unchecked", "rawtypes"}) // TODO(kevinb): the right way to explain this??
-@ElementTypesAreNonnullByDefault
-final class NaturalOrdering extends Ordering<Comparable<?>> implements Serializable {
+final class NaturalOrdering extends Ordering<Comparable> implements Serializable {
static final NaturalOrdering INSTANCE = new NaturalOrdering();
- @CheckForNull private transient Ordering<@Nullable Comparable<?>> nullsFirst;
- @CheckForNull private transient Ordering<@Nullable Comparable<?>> nullsLast;
+ @NullableDecl private transient Ordering<Comparable> nullsFirst;
+ @NullableDecl private transient Ordering<Comparable> nullsLast;
@Override
- public int compare(Comparable<?> left, Comparable<?> right) {
+ public int compare(Comparable left, Comparable right) {
checkNotNull(left); // for GWT
checkNotNull(right);
- return ((Comparable<Object>) left).compareTo(right);
+ return left.compareTo(right);
}
@Override
- public <S extends Comparable<?>> Ordering<@Nullable S> nullsFirst() {
- Ordering<@Nullable Comparable<?>> result = nullsFirst;
+ public <S extends Comparable> Ordering<S> nullsFirst() {
+ Ordering<Comparable> result = nullsFirst;
if (result == null) {
- result = nullsFirst = super.<Comparable<?>>nullsFirst();
+ result = nullsFirst = super.nullsFirst();
}
- return (Ordering<@Nullable S>) result;
+ return (Ordering<S>) result;
}
@Override
- public <S extends Comparable<?>> Ordering<@Nullable S> nullsLast() {
- Ordering<@Nullable Comparable<?>> result = nullsLast;
+ public <S extends Comparable> Ordering<S> nullsLast() {
+ Ordering<Comparable> result = nullsLast;
if (result == null) {
- result = nullsLast = super.<Comparable<?>>nullsLast();
+ result = nullsLast = super.nullsLast();
}
- return (Ordering<@Nullable S>) result;
+ return (Ordering<S>) result;
}
@Override
- public <S extends Comparable<?>> Ordering<S> reverse() {
+ public <S extends Comparable> Ordering<S> reverse() {
return (Ordering<S>) ReverseNaturalOrdering.INSTANCE;
}
diff --git a/android/guava/src/com/google/common/collect/NullnessCasts.java b/android/guava/src/com/google/common/collect/NullnessCasts.java
deleted file mode 100644
index 6ceeda7..0000000
--- a/android/guava/src/com/google/common/collect/NullnessCasts.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright (C) 2021 The Guava Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
- * or implied. See the License for the specific language governing permissions and limitations under
- * the License.
- */
-
-package com.google.common.collect;
-
-import com.google.common.annotations.GwtCompatible;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
-
-/** A utility method to perform unchecked casts to suppress errors produced by nullness analyses. */
-@GwtCompatible
-@ElementTypesAreNonnullByDefault
-final class NullnessCasts {
- /**
- * Accepts a {@code @Nullable T} and returns a plain {@code T}, without performing any check that
- * that conversion is safe.
- *
- * <p>This method is intended to help with usages of type parameters that have {@linkplain
- * ParametricNullness parametric nullness}. If a type parameter instead ranges over only non-null
- * types (or if the type is a non-variable type, like {@code String}), then code should almost
- * never use this method, preferring instead to call {@code requireNonNull} so as to benefit from
- * its runtime check.
- *
- * <p>An example use case for this method is in implementing an {@code Iterator<T>} whose {@code
- * next} field is lazily initialized. The type of that field would be {@code @Nullable T}, and the
- * code would be responsible for populating a "real" {@code T} (which might still be the value
- * {@code null}!) before returning it to callers. Depending on how the code is structured, a
- * nullness analysis might not understand that the field has been populated. To avoid that problem
- * without having to add {@code @SuppressWarnings}, the code can call this method.
- *
- * <p>Why <i>not</i> just add {@code SuppressWarnings}? The problem is that this method is
- * typically useful for {@code return} statements. That leaves the code with two options: Either
- * add the suppression to the whole method (which turns off checking for a large section of code),
- * or extract a variable, and put the suppression on that. However, a local variable typically
- * doesn't work: Because nullness analyses typically infer the nullness of local variables,
- * there's no way to assign a {@code @Nullable T} to a field {@code T foo;} and instruct the
- * analysis that that means "plain {@code T}" rather than the inferred type {@code @Nullable T}.
- * (Even if supported added {@code @NonNull}, that would not help, since the problem case
- * addressed by this method is the case in which {@code T} has parametric nullness -- and thus its
- * value may be legitimately {@code null}.)
- */
- @ParametricNullness
- @SuppressWarnings("nullness")
- static <T extends @Nullable Object> T uncheckedCastNullableTToT(@CheckForNull T t) {
- return t;
- }
-
- /** Returns {@code null} as any type, even one that does not include {@code null}. */
- @SuppressWarnings({"nullness", "TypeParameterUnusedInFormals"})
- // The warnings are legitimate. Each time we use this method, we document why.
- @ParametricNullness
- static <T extends @Nullable Object> T unsafeNull() {
- return null;
- }
-
- private NullnessCasts() {}
-}
diff --git a/android/guava/src/com/google/common/collect/NullsFirstOrdering.java b/android/guava/src/com/google/common/collect/NullsFirstOrdering.java
index ce8be2f..2154036 100644
--- a/android/guava/src/com/google/common/collect/NullsFirstOrdering.java
+++ b/android/guava/src/com/google/common/collect/NullsFirstOrdering.java
@@ -18,14 +18,11 @@
import com.google.common.annotations.GwtCompatible;
import java.io.Serializable;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/** An ordering that treats {@code null} as less than all other values. */
@GwtCompatible(serializable = true)
-@ElementTypesAreNonnullByDefault
-final class NullsFirstOrdering<T extends @Nullable Object> extends Ordering<@Nullable T>
- implements Serializable {
+final class NullsFirstOrdering<T> extends Ordering<T> implements Serializable {
final Ordering<? super T> ordering;
NullsFirstOrdering(Ordering<? super T> ordering) {
@@ -33,7 +30,7 @@
}
@Override
- public int compare(@CheckForNull T left, @CheckForNull T right) {
+ public int compare(@NullableDecl T left, @NullableDecl T right) {
if (left == right) {
return 0;
}
@@ -47,25 +44,24 @@
}
@Override
- @SuppressWarnings("nullness") // should be safe, but not sure if we can avoid the warning
- public <S extends @Nullable T> Ordering<S> reverse() {
+ public <S extends T> Ordering<S> reverse() {
// ordering.reverse() might be optimized, so let it do its thing
return ordering.reverse().nullsLast();
}
@SuppressWarnings("unchecked") // still need the right way to explain this
@Override
- public <S extends T> Ordering<@Nullable S> nullsFirst() {
- return (Ordering<@Nullable S>) this;
+ public <S extends T> Ordering<S> nullsFirst() {
+ return (Ordering<S>) this;
}
@Override
- public <S extends T> Ordering<@Nullable S> nullsLast() {
- return ordering.<S>nullsLast();
+ public <S extends T> Ordering<S> nullsLast() {
+ return ordering.nullsLast();
}
@Override
- public boolean equals(@CheckForNull Object object) {
+ public boolean equals(@NullableDecl Object object) {
if (object == this) {
return true;
}
diff --git a/android/guava/src/com/google/common/collect/NullsLastOrdering.java b/android/guava/src/com/google/common/collect/NullsLastOrdering.java
index 6f8f74c..5dd8950 100644
--- a/android/guava/src/com/google/common/collect/NullsLastOrdering.java
+++ b/android/guava/src/com/google/common/collect/NullsLastOrdering.java
@@ -18,14 +18,11 @@
import com.google.common.annotations.GwtCompatible;
import java.io.Serializable;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/** An ordering that treats {@code null} as greater than all other values. */
@GwtCompatible(serializable = true)
-@ElementTypesAreNonnullByDefault
-final class NullsLastOrdering<T extends @Nullable Object> extends Ordering<@Nullable T>
- implements Serializable {
+final class NullsLastOrdering<T> extends Ordering<T> implements Serializable {
final Ordering<? super T> ordering;
NullsLastOrdering(Ordering<? super T> ordering) {
@@ -33,7 +30,7 @@
}
@Override
- public int compare(@CheckForNull T left, @CheckForNull T right) {
+ public int compare(@NullableDecl T left, @NullableDecl T right) {
if (left == right) {
return 0;
}
@@ -47,25 +44,24 @@
}
@Override
- @SuppressWarnings("nullness") // should be safe, but not sure if we can avoid the warning
- public <S extends @Nullable T> Ordering<S> reverse() {
+ public <S extends T> Ordering<S> reverse() {
// ordering.reverse() might be optimized, so let it do its thing
return ordering.reverse().nullsFirst();
}
@Override
- public <S extends T> Ordering<@Nullable S> nullsFirst() {
- return ordering.<S>nullsFirst();
+ public <S extends T> Ordering<S> nullsFirst() {
+ return ordering.nullsFirst();
}
@SuppressWarnings("unchecked") // still need the right way to explain this
@Override
- public <S extends T> Ordering<@Nullable S> nullsLast() {
- return (Ordering<@Nullable S>) this;
+ public <S extends T> Ordering<S> nullsLast() {
+ return (Ordering<S>) this;
}
@Override
- public boolean equals(@CheckForNull Object object) {
+ public boolean equals(@NullableDecl Object object) {
if (object == this) {
return true;
}
diff --git a/android/guava/src/com/google/common/collect/ObjectArrays.java b/android/guava/src/com/google/common/collect/ObjectArrays.java
index 0f928e1..e09fc69 100644
--- a/android/guava/src/com/google/common/collect/ObjectArrays.java
+++ b/android/guava/src/com/google/common/collect/ObjectArrays.java
@@ -24,8 +24,7 @@
import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.Collection;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* Static utility methods pertaining to object arrays.
@@ -34,7 +33,6 @@
* @since 2.0
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
public final class ObjectArrays {
private ObjectArrays() {}
@@ -57,7 +55,7 @@
* @param reference any array of the desired type
* @param length the length of the new array
*/
- public static <T extends @Nullable Object> T[] newArray(T[] reference, int length) {
+ public static <T> T[] newArray(T[] reference, int length) {
return Platform.newArray(reference, length);
}
@@ -84,7 +82,7 @@
* @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 extends @Nullable Object> T[] concat(@ParametricNullness T element, T[] array) {
+ public static <T> T[] concat(@NullableDecl T element, T[] array) {
T[] result = newArray(array, array.length + 1);
result[0] = element;
System.arraycopy(array, 0, result, 1, array.length);
@@ -99,7 +97,7 @@
* @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 extends @Nullable Object> T[] concat(T[] array, @ParametricNullness T element) {
+ public static <T> T[] concat(T[] array, @NullableDecl T element) {
T[] result = Arrays.copyOf(array, array.length + 1);
result[array.length] = element;
return result;
@@ -126,15 +124,14 @@
* @throws ArrayStoreException if the runtime type of the specified array is not a supertype of
* the runtime type of every element in the specified collection
*/
- static <T extends @Nullable Object> T[] toArrayImpl(Collection<?> c, T[] array) {
+ static <T> T[] toArrayImpl(Collection<?> c, T[] array) {
int size = c.size();
if (array.length < size) {
array = newArray(array, size);
}
fillArray(c, array);
if (array.length > size) {
- @Nullable Object[] unsoundlyCovariantArray = array;
- unsoundlyCovariantArray[size] = null;
+ array[size] = null;
}
return array;
}
@@ -150,14 +147,12 @@
* collection is set to {@code null}. This is useful in determining the length of the collection
* <i>only</i> if the caller knows that the collection does not contain any null elements.
*/
- static <T extends @Nullable Object> T[] toArrayImpl(
- @Nullable Object[] src, int offset, int len, T[] dst) {
+ static <T> T[] toArrayImpl(Object[] src, int offset, int len, T[] dst) {
checkPositionIndexes(offset, offset + len, src.length);
if (dst.length < len) {
dst = newArray(dst, len);
} else if (dst.length > len) {
- @Nullable Object[] unsoundlyCovariantArray = dst;
- unsoundlyCovariantArray[len] = null;
+ dst[len] = null;
}
System.arraycopy(src, offset, dst, 0, len);
return dst;
@@ -175,7 +170,7 @@
*
* @param c the collection for which to return an array of elements
*/
- static @Nullable Object[] toArrayImpl(Collection<?> c) {
+ static Object[] toArrayImpl(Collection<?> c) {
return fillArray(c, new Object[c.size()]);
}
@@ -183,18 +178,18 @@
* Returns a copy of the specified subrange of the specified array that is literally an Object[],
* and not e.g. a {@code String[]}.
*/
- static @Nullable Object[] copyAsObjectArray(@Nullable Object[] elements, int offset, int length) {
+ static Object[] copyAsObjectArray(Object[] elements, int offset, int length) {
checkPositionIndexes(offset, offset + length, elements.length);
if (length == 0) {
return new Object[0];
}
- @Nullable Object[] result = new Object[length];
+ Object[] result = new Object[length];
System.arraycopy(elements, offset, result, 0, length);
return result;
}
@CanIgnoreReturnValue
- private static @Nullable Object[] fillArray(Iterable<?> elements, @Nullable Object[] array) {
+ private static Object[] fillArray(Iterable<?> elements, Object[] array) {
int i = 0;
for (Object element : elements) {
array[i++] = element;
@@ -211,12 +206,11 @@
@CanIgnoreReturnValue
static Object[] checkElementsNotNull(Object... array) {
- checkElementsNotNull(array, array.length);
- return array;
+ return checkElementsNotNull(array, array.length);
}
@CanIgnoreReturnValue
- static @Nullable Object[] checkElementsNotNull(@Nullable Object[] array, int length) {
+ static Object[] checkElementsNotNull(Object[] array, int length) {
for (int i = 0; i < length; i++) {
checkElementNotNull(array[i], i);
}
@@ -226,7 +220,7 @@
// We do this instead of Preconditions.checkNotNull to save boxing and array
// creation cost.
@CanIgnoreReturnValue
- static Object checkElementNotNull(@CheckForNull Object element, int index) {
+ static Object checkElementNotNull(Object element, int index) {
if (element == null) {
throw new NullPointerException("at index " + index);
}
diff --git a/android/guava/src/com/google/common/collect/ObjectCountHashMap.java b/android/guava/src/com/google/common/collect/ObjectCountHashMap.java
index 29d5bcd..8f6003f 100644
--- a/android/guava/src/com/google/common/collect/ObjectCountHashMap.java
+++ b/android/guava/src/com/google/common/collect/ObjectCountHashMap.java
@@ -28,22 +28,21 @@
import com.google.common.collect.Multisets.AbstractEntry;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import java.util.Arrays;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
- * {@code ObjectCountHashMap} uses arrays to store key objects and count values. Comparing to using
- * a traditional {@code HashMap} implementation which stores keys and count values as map entries,
- * {@code ObjectCountHashMap} minimizes object allocation and reduces memory footprint.
+ * ObjectCountHashMap is an implementation of {@code AbstractObjectCountMap} that uses arrays to
+ * store key objects and count values. Comparing to using a traditional {@code HashMap}
+ * implementation which stores keys and count values as map entries, {@code ObjectCountHashMap}
+ * minimizes object allocation and reduces memory footprint.
*
* <p>In the absence of element deletions, this will iterate over elements in insertion order.
*/
@GwtCompatible(serializable = true, emulated = true)
-@ElementTypesAreNonnullByDefault
-class ObjectCountHashMap<K extends @Nullable Object> {
+class ObjectCountHashMap<K> {
/** Creates an empty {@code ObjectCountHashMap} instance. */
- static <K extends @Nullable Object> ObjectCountHashMap<K> create() {
+ public static <K> ObjectCountHashMap<K> create() {
return new ObjectCountHashMap<K>();
}
@@ -56,8 +55,7 @@
* expectedSize} elements without resizing
* @throws IllegalArgumentException if {@code expectedSize} is negative
*/
- static <K extends @Nullable Object> ObjectCountHashMap<K> createWithExpectedSize(
- int expectedSize) {
+ public static <K> ObjectCountHashMap<K> createWithExpectedSize(int expectedSize) {
return new ObjectCountHashMap<K>(expectedSize);
}
@@ -76,13 +74,8 @@
// used to indicate blank table entries
static final int UNSET = -1;
- /*
- * The array fields below are not initialized directly in the constructor, but they're initialized
- * by init(), which the constructor calls.
- */
-
/** The keys of the entries in the map. */
- transient @Nullable Object[] keys;
+ transient Object[] keys;
/** The values of the entries in the map. */
transient int[] values;
@@ -147,7 +140,7 @@
this.table = newTable(buckets);
this.loadFactor = loadFactor;
- this.keys = new @Nullable Object[expectedSize];
+ this.keys = new Object[expectedSize];
this.values = new int[expectedSize];
this.entries = newEntries(expectedSize);
@@ -187,7 +180,6 @@
}
@SuppressWarnings("unchecked")
- @ParametricNullness
K getKey(int index) {
checkElementIndex(index, size);
return (K) keys[index];
@@ -209,7 +201,7 @@
}
class MapEntry extends AbstractEntry<K> {
- @ParametricNullness final K key;
+ @NullableDecl final K key;
int lastKnownIndex;
@@ -220,7 +212,6 @@
}
@Override
- @ParametricNullness
public K getElement() {
return key;
}
@@ -280,10 +271,10 @@
}
@CanIgnoreReturnValue
- public int put(@ParametricNullness K key, int value) {
+ public int put(@NullableDecl K key, int value) {
checkPositive(value, "count");
long[] entries = this.entries;
- @Nullable Object[] keys = this.keys;
+ Object[] keys = this.keys;
int[] values = this.values;
int hash = smearedHash(key);
@@ -325,7 +316,7 @@
/**
* Creates a fresh entry with the specified object at the specified position in the entry array.
*/
- void insertEntry(int entryIndex, @ParametricNullness K key, int value, int hash) {
+ void insertEntry(int entryIndex, @NullableDecl K key, int value, int hash) {
this.entries[entryIndex] = ((long) hash << 32) | (NEXT_MASK & UNSET);
this.keys[entryIndex] = key;
this.values[entryIndex] = value;
@@ -386,7 +377,7 @@
this.table = newTable;
}
- int indexOf(@CheckForNull Object key) {
+ int indexOf(@NullableDecl Object key) {
int hash = smearedHash(key);
int next = table[hash & hashTableMask()];
while (next != UNSET) {
@@ -399,21 +390,21 @@
return -1;
}
- public boolean containsKey(@CheckForNull Object key) {
+ public boolean containsKey(@NullableDecl Object key) {
return indexOf(key) != -1;
}
- public int get(@CheckForNull Object key) {
+ public int get(@NullableDecl Object key) {
int index = indexOf(key);
return (index == -1) ? 0 : values[index];
}
@CanIgnoreReturnValue
- public int remove(@CheckForNull Object key) {
+ public int remove(@NullableDecl Object key) {
return remove(key, smearedHash(key));
}
- private int remove(@CheckForNull Object key, int hash) {
+ private int remove(@NullableDecl Object key, int hash) {
int tableIndex = hash & hashTableMask();
int next = table[tableIndex];
if (next == UNSET) { // empty bucket
diff --git a/android/guava/src/com/google/common/collect/ObjectCountLinkedHashMap.java b/android/guava/src/com/google/common/collect/ObjectCountLinkedHashMap.java
index 266606a..5a5a476 100644
--- a/android/guava/src/com/google/common/collect/ObjectCountLinkedHashMap.java
+++ b/android/guava/src/com/google/common/collect/ObjectCountLinkedHashMap.java
@@ -18,20 +18,18 @@
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.VisibleForTesting;
import java.util.Arrays;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
- * {@code ObjectCountLinkedHashMap} is a subclass of {@code ObjectCountHashMap} with insertion
+ * ObjectCountLinkedHashMap is an implementation of {@code AbstractObjectCountMap} with insertion
* iteration order, and uses arrays to store key objects and count values. Comparing to using a
* traditional {@code LinkedHashMap} implementation which stores keys and count values as map
* entries, {@code ObjectCountLinkedHashMap} minimizes object allocation and reduces memory
* footprint.
*/
@GwtCompatible(serializable = true, emulated = true)
-@ElementTypesAreNonnullByDefault
-class ObjectCountLinkedHashMap<K extends @Nullable Object> extends ObjectCountHashMap<K> {
+class ObjectCountLinkedHashMap<K> extends ObjectCountHashMap<K> {
/** Creates an empty {@code ObjectCountLinkedHashMap} instance. */
- static <K extends @Nullable Object> ObjectCountLinkedHashMap<K> create() {
+ public static <K> ObjectCountLinkedHashMap<K> create() {
return new ObjectCountLinkedHashMap<K>();
}
@@ -44,18 +42,12 @@
* expectedSize} elements without resizing
* @throws IllegalArgumentException if {@code expectedSize} is negative
*/
- static <K extends @Nullable Object> ObjectCountLinkedHashMap<K> createWithExpectedSize(
- int expectedSize) {
+ public static <K> ObjectCountLinkedHashMap<K> createWithExpectedSize(int expectedSize) {
return new ObjectCountLinkedHashMap<K>(expectedSize);
}
private static final int ENDPOINT = -2;
- /*
- * The links field is not initialized directly in the constructor, but it's initialized by init(),
- * which the superconstructor calls.
- */
-
/**
* Contains the link pointers corresponding with the entries, in the range of [0, size()). The
* high 32 bits of each long is the "prev" pointer, whereas the low 32 bits is the "succ" pointer
@@ -149,7 +141,7 @@
}
@Override
- void insertEntry(int entryIndex, @ParametricNullness K key, int value, int hash) {
+ void insertEntry(int entryIndex, K key, int value, int hash) {
super.insertEntry(entryIndex, key, value, hash);
setSucceeds(lastEntry, entryIndex);
setSucceeds(entryIndex, ENDPOINT);
diff --git a/android/guava/src/com/google/common/collect/Ordering.java b/android/guava/src/com/google/common/collect/Ordering.java
index 025f95f..187aacf 100644
--- a/android/guava/src/com/google/common/collect/Ordering.java
+++ b/android/guava/src/com/google/common/collect/Ordering.java
@@ -38,8 +38,7 @@
import java.util.TreeSet;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.atomic.AtomicInteger;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* A comparator, with additional methods to support common operations. This is an "enriched" version
@@ -145,8 +144,7 @@
* @since 2.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-public abstract class Ordering<T extends @Nullable Object> implements Comparator<T> {
+public abstract class Ordering<T> implements Comparator<T> {
// Natural order
/**
@@ -180,7 +178,7 @@
* wraps that comparator
*/
@GwtCompatible(serializable = true)
- public static <T extends @Nullable Object> Ordering<T> from(Comparator<T> comparator) {
+ public static <T> Ordering<T> from(Comparator<T> comparator) {
return (comparator instanceof Ordering)
? (Ordering<T>) comparator
: new ComparatorOrdering<T>(comparator);
@@ -193,7 +191,7 @@
*/
@GwtCompatible(serializable = true)
@Deprecated
- public static <T extends @Nullable Object> Ordering<T> from(Ordering<T> ordering) {
+ public static <T> Ordering<T> from(Ordering<T> ordering) {
return checkNotNull(ordering);
}
@@ -280,7 +278,7 @@
*/
@GwtCompatible(serializable = true)
@SuppressWarnings("unchecked")
- public static Ordering<@Nullable Object> allEqual() {
+ public static Ordering<Object> allEqual() {
return AllEqualOrdering.INSTANCE;
}
@@ -313,16 +311,16 @@
* @since 2.0
*/
// TODO(kevinb): copy to Comparators, etc.
- public static Ordering<@Nullable Object> arbitrary() {
+ public static Ordering<Object> arbitrary() {
return ArbitraryOrderingHolder.ARBITRARY_ORDERING;
}
private static class ArbitraryOrderingHolder {
- static final Ordering<@Nullable Object> ARBITRARY_ORDERING = new ArbitraryOrdering();
+ static final Ordering<Object> ARBITRARY_ORDERING = new ArbitraryOrdering();
}
@VisibleForTesting
- static class ArbitraryOrdering extends Ordering<@Nullable Object> {
+ static class ArbitraryOrdering extends Ordering<Object> {
private final AtomicInteger counter = new AtomicInteger(0);
private final ConcurrentMap<Object, Integer> uids =
@@ -344,7 +342,7 @@
}
@Override
- public int compare(@CheckForNull Object left, @CheckForNull Object right) {
+ public int compare(Object left, Object right) {
if (left == right) {
return 0;
} else if (left == null) {
@@ -416,7 +414,7 @@
// type parameter <S> lets us avoid the extra <String> in statements like:
// Ordering<String> o = Ordering.<String>natural().nullsFirst();
@GwtCompatible(serializable = true)
- public <S extends T> Ordering<@Nullable S> nullsFirst() {
+ public <S extends T> Ordering<S> nullsFirst() {
return new NullsFirstOrdering<S>(this);
}
@@ -429,7 +427,7 @@
// type parameter <S> lets us avoid the extra <String> in statements like:
// Ordering<String> o = Ordering.<String>natural().nullsLast();
@GwtCompatible(serializable = true)
- public <S extends T> Ordering<@Nullable S> nullsLast() {
+ public <S extends T> Ordering<S> nullsLast() {
return new NullsLastOrdering<S>(this);
}
@@ -447,7 +445,7 @@
* can omit the comparator if it is the natural order).
*/
@GwtCompatible(serializable = true)
- public <F extends @Nullable Object> Ordering<F> onResultOf(Function<F, ? extends T> function) {
+ public <F> Ordering<F> onResultOf(Function<F, ? extends T> function) {
return new ByFunctionOrdering<>(function, this);
}
@@ -493,8 +491,7 @@
* @param comparators the comparators to try in order
*/
@GwtCompatible(serializable = true)
- public static <T extends @Nullable Object> Ordering<T> compound(
- Iterable<? extends Comparator<? super T>> comparators) {
+ public static <T> Ordering<T> compound(Iterable<? extends Comparator<? super T>> comparators) {
return new CompoundOrdering<T>(comparators);
}
@@ -530,9 +527,10 @@
// Regular instance methods
+ // Override to add @NullableDecl
@CanIgnoreReturnValue // TODO(kak): Consider removing this
@Override
- public abstract int compare(@ParametricNullness T left, @ParametricNullness T right);
+ public abstract int compare(@NullableDecl T left, @NullableDecl T right);
/**
* Returns the least of the specified values according to this ordering. If there are multiple
@@ -548,7 +546,6 @@
* ordering.
* @since 11.0
*/
- @ParametricNullness
public <E extends T> E min(Iterator<E> iterator) {
// let this throw NoSuchElementException as necessary
E minSoFar = iterator.next();
@@ -574,7 +571,6 @@
* @throws ClassCastException if the parameters are not <i>mutually comparable</i> under this
* ordering.
*/
- @ParametricNullness
public <E extends T> E min(Iterable<E> iterable) {
return min(iterable.iterator());
}
@@ -594,8 +590,7 @@
* @throws ClassCastException if the parameters are not <i>mutually comparable</i> under this
* ordering.
*/
- @ParametricNullness
- public <E extends T> E min(@ParametricNullness E a, @ParametricNullness E b) {
+ public <E extends T> E min(@NullableDecl E a, @NullableDecl E b) {
return (compare(a, b) <= 0) ? a : b;
}
@@ -613,9 +608,7 @@
* @throws ClassCastException if the parameters are not <i>mutually comparable</i> under this
* ordering.
*/
- @ParametricNullness
- public <E extends T> E min(
- @ParametricNullness E a, @ParametricNullness E b, @ParametricNullness E c, E... rest) {
+ public <E extends T> E min(@NullableDecl E a, @NullableDecl E b, @NullableDecl E c, E... rest) {
E minSoFar = min(min(a, b), c);
for (E r : rest) {
@@ -639,7 +632,6 @@
* ordering.
* @since 11.0
*/
- @ParametricNullness
public <E extends T> E max(Iterator<E> iterator) {
// let this throw NoSuchElementException as necessary
E maxSoFar = iterator.next();
@@ -665,7 +657,6 @@
* @throws ClassCastException if the parameters are not <i>mutually comparable</i> under this
* ordering.
*/
- @ParametricNullness
public <E extends T> E max(Iterable<E> iterable) {
return max(iterable.iterator());
}
@@ -685,8 +676,7 @@
* @throws ClassCastException if the parameters are not <i>mutually comparable</i> under this
* ordering.
*/
- @ParametricNullness
- public <E extends T> E max(@ParametricNullness E a, @ParametricNullness E b) {
+ public <E extends T> E max(@NullableDecl E a, @NullableDecl E b) {
return (compare(a, b) >= 0) ? a : b;
}
@@ -704,9 +694,7 @@
* @throws ClassCastException if the parameters are not <i>mutually comparable</i> under this
* ordering.
*/
- @ParametricNullness
- public <E extends T> E max(
- @ParametricNullness E a, @ParametricNullness E b, @ParametricNullness E c, E... rest) {
+ public <E extends T> E max(@NullableDecl E a, @NullableDecl E b, @NullableDecl E c, E... rest) {
E maxSoFar = max(max(a, b), c);
for (E r : rest) {
@@ -871,7 +859,6 @@
* @since 3.0
*/
// TODO(kevinb): rerun benchmarks including new options
- @SuppressWarnings("nullness") // unsafe, but there's not much we can do about it now
public <E extends T> ImmutableList<E> immutableSortedCopy(Iterable<E> elements) {
return ImmutableList.sortedCopyOf(this, elements);
}
@@ -933,8 +920,7 @@
* @deprecated Use {@link Collections#binarySearch(List, Object, Comparator)} directly.
*/
@Deprecated
- public int binarySearch(
- List<? extends T> sortedList, @ParametricNullness T key) {
+ public int binarySearch(List<? extends T> sortedList, @NullableDecl T key) {
return Collections.binarySearch(sortedList, key, this);
}
diff --git a/android/guava/src/com/google/common/collect/ParametricNullness.java b/android/guava/src/com/google/common/collect/ParametricNullness.java
deleted file mode 100644
index b1cda48..0000000
--- a/android/guava/src/com/google/common/collect/ParametricNullness.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2021 The Guava Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.common.collect;
-
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.PARAMETER;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-import static javax.annotation.meta.When.UNKNOWN;
-
-import com.google.common.annotations.GwtCompatible;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-import javax.annotation.Nonnull;
-import javax.annotation.meta.TypeQualifierNickname;
-
-/**
- * Marks a "top-level" type-variable usage as (a) a Kotlin platform type when the type argument is
- * non-nullable and (b) nullable when the type argument is nullable. This is the closest we can get
- * to "non-nullable when non-nullable; nullable when nullable" (like the Android <a
- * href="https://android.googlesource.com/platform/libcore/+/master/luni/src/main/java/libcore/util/NullFromTypeParam.java">{@code
- * NullFromTypeParam}</a>). We use this to "undo" {@link ElementTypesAreNonnullByDefault}.
- */
-@GwtCompatible
-@Retention(RUNTIME)
-@Target({FIELD, METHOD, PARAMETER})
-@TypeQualifierNickname
-@Nonnull(when = UNKNOWN)
-@interface ParametricNullness {}
diff --git a/android/guava/src/com/google/common/collect/PeekingIterator.java b/android/guava/src/com/google/common/collect/PeekingIterator.java
index a274fe4..5a6c60b 100644
--- a/android/guava/src/com/google/common/collect/PeekingIterator.java
+++ b/android/guava/src/com/google/common/collect/PeekingIterator.java
@@ -21,7 +21,6 @@
import com.google.errorprone.annotations.DoNotMock;
import java.util.Iterator;
import java.util.NoSuchElementException;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* An iterator that supports a one-element lookahead while iterating.
@@ -35,8 +34,7 @@
*/
@DoNotMock("Use Iterators.peekingIterator")
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-public interface PeekingIterator<E extends @Nullable Object> extends Iterator<E> {
+public interface PeekingIterator<E> extends Iterator<E> {
/**
* Returns the next element in the iteration, without advancing the iteration.
*
@@ -46,7 +44,6 @@
* @throws NoSuchElementException if the iteration has no more elements according to {@link
* #hasNext()}
*/
- @ParametricNullness
E peek();
/**
@@ -57,7 +54,6 @@
*/
@CanIgnoreReturnValue
@Override
- @ParametricNullness
E next();
/**
diff --git a/android/guava/src/com/google/common/collect/Platform.java b/android/guava/src/com/google/common/collect/Platform.java
index 0b18e1f..e4d1c4c 100644
--- a/android/guava/src/com/google/common/collect/Platform.java
+++ b/android/guava/src/com/google/common/collect/Platform.java
@@ -21,7 +21,6 @@
import java.util.Arrays;
import java.util.Map;
import java.util.Set;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Methods factored out so that they can be emulated differently in GWT.
@@ -29,11 +28,9 @@
* @author Hayward Chan
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
final class Platform {
/** Returns the platform preferred implementation of a map based on a hash table. */
- static <K extends @Nullable Object, V extends @Nullable Object>
- Map<K, V> newHashMapWithExpectedSize(int expectedSize) {
+ static <K, V> Map<K, V> newHashMapWithExpectedSize(int expectedSize) {
return CompactHashMap.createWithExpectedSize(expectedSize);
}
@@ -41,13 +38,12 @@
* Returns the platform preferred implementation of an insertion ordered map based on a hash
* table.
*/
- static <K extends @Nullable Object, V extends @Nullable Object>
- Map<K, V> newLinkedHashMapWithExpectedSize(int expectedSize) {
+ static <K, V> Map<K, V> newLinkedHashMapWithExpectedSize(int expectedSize) {
return CompactLinkedHashMap.createWithExpectedSize(expectedSize);
}
/** Returns the platform preferred implementation of a set based on a hash table. */
- static <E extends @Nullable Object> Set<E> newHashSetWithExpectedSize(int expectedSize) {
+ static <E> Set<E> newHashSetWithExpectedSize(int expectedSize) {
return CompactHashSet.createWithExpectedSize(expectedSize);
}
@@ -55,7 +51,7 @@
* Returns the platform preferred implementation of an insertion ordered set based on a hash
* table.
*/
- static <E extends @Nullable Object> Set<E> newLinkedHashSetWithExpectedSize(int expectedSize) {
+ static <E> Set<E> newLinkedHashSetWithExpectedSize(int expectedSize) {
return CompactLinkedHashSet.createWithExpectedSize(expectedSize);
}
@@ -63,8 +59,7 @@
* Returns the platform preferred map implementation that preserves insertion order when used only
* for insertions.
*/
- static <K extends @Nullable Object, V extends @Nullable Object>
- Map<K, V> preservesInsertionOrderOnPutsMap() {
+ static <K, V> Map<K, V> preservesInsertionOrderOnPutsMap() {
return CompactHashMap.create();
}
@@ -72,7 +67,7 @@
* Returns the platform preferred set implementation that preserves insertion order when used only
* for insertions.
*/
- static <E extends @Nullable Object> Set<E> preservesInsertionOrderOnAddsSet() {
+ static <E> Set<E> preservesInsertionOrderOnAddsSet() {
return CompactHashSet.create();
}
@@ -82,13 +77,7 @@
* @param reference any array of the desired type
* @param length the length of the new array
*/
- /*
- * The new array contains nulls, even if the old array did not. If we wanted to be accurate, we
- * would declare a return type of `@Nullable T[]`. However, we've decided not to think too hard
- * about arrays for now, as they're a mess. (We previously discussed this in the review of
- * ObjectArrays, which is the main caller of this method.)
- */
- static <T extends @Nullable Object> T[] newArray(T[] reference, int length) {
+ static <T> T[] newArray(T[] reference, int length) {
Class<?> type = reference.getClass().getComponentType();
// the cast is safe because
@@ -99,16 +88,7 @@
}
/** Equivalent to Arrays.copyOfRange(source, from, to, arrayOfType.getClass()). */
- /*
- * Arrays are a mess from a nullness perspective, and Class instances for object-array types are
- * even worse. For now, we just suppress and move on with our lives.
- *
- * - https://github.com/jspecify/jspecify/issues/65
- *
- * - https://github.com/jspecify/jdk/commit/71d826792b8c7ef95d492c50a274deab938f2552
- */
- @SuppressWarnings("nullness")
- static <T extends @Nullable Object> T[] copy(Object[] source, int from, int to, T[] arrayOfType) {
+ static <T> T[] copy(Object[] source, int from, int to, T[] arrayOfType) {
return Arrays.copyOfRange(source, from, to, (Class<? extends T[]>) arrayOfType.getClass());
}
diff --git a/android/guava/src/com/google/common/collect/Queues.java b/android/guava/src/com/google/common/collect/Queues.java
index 6a4dbd2..fdeb369 100644
--- a/android/guava/src/com/google/common/collect/Queues.java
+++ b/android/guava/src/com/google/common/collect/Queues.java
@@ -32,7 +32,6 @@
import java.util.concurrent.PriorityBlockingQueue;
import java.util.concurrent.SynchronousQueue;
import java.util.concurrent.TimeUnit;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Static utility methods pertaining to {@link Queue} and {@link Deque} instances. Also see this
@@ -42,7 +41,6 @@
* @since 11.0
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
public final class Queues {
private Queues() {}
@@ -190,8 +188,7 @@
* Creates an empty {@code PriorityBlockingQueue} with the ordering given by its elements' natural
* ordering.
*
- * @since 11.0 (but the bound of {@code E} was changed from {@code Object} to {@code Comparable}
- * in 15.0)
+ * @since 11.0 (requires that {@code E} be {@code Comparable} since 15.0).
*/
@GwtIncompatible // PriorityBlockingQueue
public static <E extends Comparable> PriorityBlockingQueue<E> newPriorityBlockingQueue() {
@@ -204,8 +201,7 @@
* <p><b>Note:</b> If the specified iterable is a {@code SortedSet} or a {@code PriorityQueue},
* this priority queue will be ordered according to the same ordering.
*
- * @since 11.0 (but the bound of {@code E} was changed from {@code Object} to {@code Comparable}
- * in 15.0)
+ * @since 11.0 (requires that {@code E} be {@code Comparable} since 15.0).
*/
@GwtIncompatible // PriorityBlockingQueue
public static <E extends Comparable> PriorityBlockingQueue<E> newPriorityBlockingQueue(
@@ -224,8 +220,7 @@
* Creates an empty {@code PriorityQueue} with the ordering given by its elements' natural
* ordering.
*
- * @since 11.0 (but the bound of {@code E} was changed from {@code Object} to {@code Comparable}
- * in 15.0)
+ * @since 11.0 (requires that {@code E} be {@code Comparable} since 15.0).
*/
public static <E extends Comparable> PriorityQueue<E> newPriorityQueue() {
return new PriorityQueue<E>();
@@ -237,8 +232,7 @@
* <p><b>Note:</b> If the specified iterable is a {@code SortedSet} or a {@code PriorityQueue},
* this priority queue will be ordered according to the same ordering.
*
- * @since 11.0 (but the bound of {@code E} was changed from {@code Object} to {@code Comparable}
- * in 15.0)
+ * @since 11.0 (requires that {@code E} be {@code Comparable} since 15.0).
*/
public static <E extends Comparable> PriorityQueue<E> newPriorityQueue(
Iterable<? extends E> elements) {
@@ -391,7 +385,7 @@
* @return a synchronized view of the specified queue
* @since 14.0
*/
- public static <E extends @Nullable Object> Queue<E> synchronizedQueue(Queue<E> queue) {
+ public static <E> Queue<E> synchronizedQueue(Queue<E> queue) {
return Synchronized.queue(queue, null);
}
@@ -424,7 +418,7 @@
* @return a synchronized view of the specified deque
* @since 15.0
*/
- public static <E extends @Nullable Object> Deque<E> synchronizedDeque(Deque<E> deque) {
+ public static <E> Deque<E> synchronizedDeque(Deque<E> deque) {
return Synchronized.deque(deque, null);
}
}
diff --git a/android/guava/src/com/google/common/collect/Range.java b/android/guava/src/com/google/common/collect/Range.java
index ab5c077..5300b77 100644
--- a/android/guava/src/com/google/common/collect/Range.java
+++ b/android/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 javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* A range (or "interval") defines the <i>boundaries</i> around a contiguous span of values of some
@@ -117,7 +117,6 @@
*/
@GwtCompatible
@SuppressWarnings("rawtypes")
-@ElementTypesAreNonnullByDefault
public final class Range<C extends Comparable> extends RangeGwtSerializationDependencies
implements Predicate<C>, Serializable {
@@ -330,7 +329,7 @@
public static <C extends Comparable<?>> Range<C> encloseAll(Iterable<C> values) {
checkNotNull(values);
if (values instanceof SortedSet) {
- SortedSet<C> set = (SortedSet<C>) values;
+ SortedSet<? extends C> set = cast(values);
Comparator<?> comparator = set.comparator();
if (Ordering.natural().equals(comparator) || comparator == null) {
return closed(set.first(), set.last());
@@ -457,7 +456,7 @@
// this optimizes testing equality of two range-backed sets
if (values instanceof SortedSet) {
- SortedSet<? extends C> set = (SortedSet<? extends C>) values;
+ SortedSet<? extends C> set = cast(values);
Comparator<?> comparator = set.comparator();
if (Ordering.natural().equals(comparator) || comparator == null) {
return contains(set.first()) && contains(set.last());
@@ -664,7 +663,7 @@
* {@code [3..3)}, {@code (3..3]}, {@code (4..4]} are all unequal.
*/
@Override
- public boolean equals(@CheckForNull Object object) {
+ public boolean equals(@NullableDecl Object object) {
if (object instanceof Range) {
Range<?> other = (Range<?>) object;
return lowerBound.equals(other.lowerBound) && upperBound.equals(other.upperBound);
@@ -695,6 +694,11 @@
return sb.toString();
}
+ /** Used to avoid http://bugs.sun.com/view_bug.do?bug_id=6558557 */
+ private static <T> SortedSet<T> cast(Iterable<T> iterable) {
+ return (SortedSet<T>) iterable;
+ }
+
Object readResolve() {
if (this.equals(ALL)) {
return all();
diff --git a/android/guava/src/com/google/common/collect/RangeMap.java b/android/guava/src/com/google/common/collect/RangeMap.java
index 14adb00..e6c902e 100644
--- a/android/guava/src/com/google/common/collect/RangeMap.java
+++ b/android/guava/src/com/google/common/collect/RangeMap.java
@@ -23,7 +23,7 @@
import java.util.Map;
import java.util.Map.Entry;
import java.util.NoSuchElementException;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* A mapping from disjoint nonempty ranges to non-null values. Queries look up the value associated
@@ -38,27 +38,21 @@
@Beta
@DoNotMock("Use ImmutableRangeMap or TreeRangeMap")
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public interface RangeMap<K extends Comparable, V> {
- /*
- * TODO(cpovirk): These docs sometimes say "map" and sometimes say "range map." Pick one, or at
- * least decide on a policy for when to use which.
- */
-
/**
* Returns the value associated with the specified key, or {@code null} if there is no such value.
*
* <p>Specifically, if any range in this range map contains the specified key, the value
* associated with that range is returned.
*/
- @CheckForNull
+ @NullableDecl
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.
*/
- @CheckForNull
+ @NullableDecl
Entry<Range<K>, V> getEntry(K key);
/**
@@ -152,7 +146,6 @@
* <p>The returned range map will throw an {@link IllegalArgumentException} on an attempt to
* insert a range not {@linkplain Range#encloses(Range) enclosed} by {@code range}.
*/
- // TODO(cpovirk): Consider documenting that IAE on the various methods that can throw it.
RangeMap<K, V> subRangeMap(Range<K> range);
/**
@@ -160,7 +153,7 @@
* #asMapOfRanges()}.
*/
@Override
- boolean equals(@CheckForNull Object o);
+ boolean equals(@NullableDecl Object o);
/** Returns {@code asMapOfRanges().hashCode()}. */
@Override
diff --git a/android/guava/src/com/google/common/collect/RangeSet.java b/android/guava/src/com/google/common/collect/RangeSet.java
index edb0f79..06c149c 100644
--- a/android/guava/src/com/google/common/collect/RangeSet.java
+++ b/android/guava/src/com/google/common/collect/RangeSet.java
@@ -19,7 +19,7 @@
import com.google.errorprone.annotations.DoNotMock;
import java.util.NoSuchElementException;
import java.util.Set;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* A set comprising zero or more {@linkplain Range#isEmpty nonempty}, {@linkplain
@@ -52,7 +52,6 @@
@Beta
@DoNotMock("Use ImmutableRangeSet or TreeRangeSet")
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public interface RangeSet<C extends Comparable> {
// Query methods
@@ -64,7 +63,6 @@
* Returns the unique range from this range set that {@linkplain Range#contains contains} {@code
* value}, or {@code null} if this range set does not contain {@code value}.
*/
- @CheckForNull
Range<C> rangeContaining(C value);
/**
@@ -248,7 +246,7 @@
* according to {@link Range#equals(Object)}.
*/
@Override
- boolean equals(@CheckForNull Object obj);
+ boolean equals(@NullableDecl Object obj);
/** Returns {@code asRanges().hashCode()}. */
@Override
diff --git a/android/guava/src/com/google/common/collect/RegularContiguousSet.java b/android/guava/src/com/google/common/collect/RegularContiguousSet.java
index 913e2d7..d9a6330 100644
--- a/android/guava/src/com/google/common/collect/RegularContiguousSet.java
+++ b/android/guava/src/com/google/common/collect/RegularContiguousSet.java
@@ -18,13 +18,12 @@
import static com.google.common.base.Preconditions.checkElementIndex;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.collect.BoundType.CLOSED;
-import static java.util.Objects.requireNonNull;
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.GwtIncompatible;
import java.io.Serializable;
import java.util.Collection;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* An implementation of {@link ContiguousSet} that contains one or more elements.
@@ -33,7 +32,6 @@
*/
@GwtCompatible(emulated = true)
@SuppressWarnings("unchecked") // allow ungenerified Comparable types
-@ElementTypesAreNonnullByDefault
final class RegularContiguousSet<C extends Comparable> extends ContiguousSet<C> {
private final Range<C> range;
@@ -73,9 +71,8 @@
@GwtIncompatible // not used by GWT emulation
@Override
- int indexOf(@CheckForNull Object target) {
- // requireNonNull is safe because of the contains check.
- return contains(target) ? (int) domain.distance(first(), (C) requireNonNull(target)) : -1;
+ int indexOf(Object target) {
+ return contains(target) ? (int) domain.distance(first(), (C) target) : -1;
}
@Override
@@ -84,7 +81,6 @@
final C last = last();
@Override
- @CheckForNull
protected C computeNext(C previous) {
return equalsOrThrow(previous, last) ? null : domain.next(previous);
}
@@ -98,14 +94,13 @@
final C first = first();
@Override
- @CheckForNull
protected C computeNext(C previous) {
return equalsOrThrow(previous, first) ? null : domain.previous(previous);
}
};
}
- private static boolean equalsOrThrow(Comparable<?> left, @CheckForNull Comparable<?> right) {
+ private static boolean equalsOrThrow(Comparable<?> left, @NullableDecl Comparable<?> right) {
return right != null && Range.compareOrThrow(left, right) == 0;
}
@@ -116,14 +111,12 @@
@Override
public C first() {
- // requireNonNull is safe because we checked the range is not empty in ContiguousSet.create.
- return requireNonNull(range.lowerBound.leastValueAbove(domain));
+ return range.lowerBound.leastValueAbove(domain);
}
@Override
public C last() {
- // requireNonNull is safe because we checked the range is not empty in ContiguousSet.create.
- return requireNonNull(range.upperBound.greatestValueBelow(domain));
+ return range.upperBound.greatestValueBelow(domain);
}
@Override
@@ -153,7 +146,7 @@
}
@Override
- public boolean contains(@CheckForNull Object object) {
+ public boolean contains(@NullableDecl Object object) {
if (object == null) {
return false;
}
@@ -202,7 +195,7 @@
}
@Override
- public boolean equals(@CheckForNull Object object) {
+ public boolean equals(@NullableDecl Object object) {
if (object == this) {
return true;
} else if (object instanceof RegularContiguousSet) {
diff --git a/android/guava/src/com/google/common/collect/RegularImmutableAsList.java b/android/guava/src/com/google/common/collect/RegularImmutableAsList.java
index e344db1..01e5ddd 100644
--- a/android/guava/src/com/google/common/collect/RegularImmutableAsList.java
+++ b/android/guava/src/com/google/common/collect/RegularImmutableAsList.java
@@ -18,8 +18,6 @@
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.GwtIncompatible;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* An {@link ImmutableAsList} implementation specialized for when the delegate collection is already
@@ -29,7 +27,6 @@
*/
@GwtCompatible(emulated = true)
@SuppressWarnings("serial") // uses writeReplace, not default serialization
-@ElementTypesAreNonnullByDefault
class RegularImmutableAsList<E> extends ImmutableAsList<E> {
private final ImmutableCollection<E> delegate;
private final ImmutableList<? extends E> delegateList;
@@ -64,13 +61,11 @@
@GwtIncompatible // not present in emulated superclass
@Override
- int copyIntoArray(@Nullable Object[] dst, int offset) {
+ int copyIntoArray(Object[] dst, int offset) {
return delegateList.copyIntoArray(dst, offset);
}
@Override
- @CheckForNull
- @Nullable
Object[] internalArray() {
return delegateList.internalArray();
}
diff --git a/android/guava/src/com/google/common/collect/RegularImmutableBiMap.java b/android/guava/src/com/google/common/collect/RegularImmutableBiMap.java
index 4607477..2bdaf8b 100644
--- a/android/guava/src/com/google/common/collect/RegularImmutableBiMap.java
+++ b/android/guava/src/com/google/common/collect/RegularImmutableBiMap.java
@@ -18,8 +18,7 @@
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.VisibleForTesting;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* Bimap with zero or more mappings.
@@ -28,12 +27,11 @@
*/
@GwtCompatible(serializable = true, emulated = true)
@SuppressWarnings("serial") // uses writeReplace(), not default serialization
-@ElementTypesAreNonnullByDefault
final class RegularImmutableBiMap<K, V> extends ImmutableBiMap<K, V> {
static final RegularImmutableBiMap<Object, Object> EMPTY = new RegularImmutableBiMap<>();
- @CheckForNull private final transient Object keyHashTable;
- @VisibleForTesting final transient @Nullable Object[] alternatingKeysAndValues;
+ private final transient Object keyHashTable;
+ @VisibleForTesting final transient Object[] alternatingKeysAndValues;
private final transient int keyOffset; // 0 for K-to-V, 1 for V-to-K
private final transient int size;
private final transient RegularImmutableBiMap<V, K> inverse;
@@ -49,7 +47,7 @@
}
/** K-to-V constructor. */
- RegularImmutableBiMap(@Nullable Object[] alternatingKeysAndValues, int size) {
+ RegularImmutableBiMap(Object[] alternatingKeysAndValues, int size) {
this.alternatingKeysAndValues = alternatingKeysAndValues;
this.size = size;
this.keyOffset = 0;
@@ -64,8 +62,8 @@
/** V-to-K constructor. */
private RegularImmutableBiMap(
- @CheckForNull Object valueHashTable,
- @Nullable Object[] alternatingKeysAndValues,
+ Object valueHashTable,
+ Object[] alternatingKeysAndValues,
int size,
RegularImmutableBiMap<V, K> inverse) {
this.keyHashTable = valueHashTable;
@@ -87,19 +85,9 @@
@SuppressWarnings("unchecked")
@Override
- @CheckForNull
- public V get(@CheckForNull Object key) {
- Object result =
+ public V get(@NullableDecl Object key) {
+ return (V)
RegularImmutableMap.get(keyHashTable, alternatingKeysAndValues, size, keyOffset, key);
- /*
- * We can't simply cast the result of `RegularImmutableMap.get` to V because of a bug in our
- * nullness checker (resulting from https://github.com/jspecify/checker-framework/issues/8).
- */
- if (result == null) {
- return null;
- } else {
- return (V) result;
- }
}
@Override
diff --git a/android/guava/src/com/google/common/collect/RegularImmutableList.java b/android/guava/src/com/google/common/collect/RegularImmutableList.java
index baf1d66..44cbab7 100644
--- a/android/guava/src/com/google/common/collect/RegularImmutableList.java
+++ b/android/guava/src/com/google/common/collect/RegularImmutableList.java
@@ -17,11 +17,9 @@
package com.google.common.collect;
import static com.google.common.base.Preconditions.checkElementIndex;
-import static java.util.Objects.requireNonNull;
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.VisibleForTesting;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Implementation of {@link ImmutableList} backed by a simple array.
@@ -30,15 +28,13 @@
*/
@GwtCompatible(serializable = true, emulated = true)
@SuppressWarnings("serial") // uses writeReplace(), not default serialization
-@ElementTypesAreNonnullByDefault
class RegularImmutableList<E> extends ImmutableList<E> {
static final ImmutableList<Object> EMPTY = new RegularImmutableList<>(new Object[0], 0);
- // The first `size` elements are non-null.
- @VisibleForTesting final transient @Nullable Object[] array;
+ @VisibleForTesting final transient Object[] array;
private final transient int size;
- RegularImmutableList(@Nullable Object[] array, int size) {
+ RegularImmutableList(Object[] array, int size) {
this.array = array;
this.size = size;
}
@@ -54,7 +50,6 @@
}
@Override
- @Nullable
Object[] internalArray() {
return array;
}
@@ -70,7 +65,7 @@
}
@Override
- int copyIntoArray(@Nullable Object[] dst, int dstOff) {
+ int copyIntoArray(Object[] dst, int dstOff) {
System.arraycopy(array, 0, dst, dstOff, size);
return dstOff + size;
}
@@ -80,8 +75,7 @@
@SuppressWarnings("unchecked")
public E get(int index) {
checkElementIndex(index, size);
- // requireNonNull is safe because we guarantee that the first `size` elements are non-null.
- return (E) requireNonNull(array[index]);
+ return (E) array[index];
}
// TODO(lowasser): benchmark optimizations for equals() and see if they're worthwhile
diff --git a/android/guava/src/com/google/common/collect/RegularImmutableMap.java b/android/guava/src/com/google/common/collect/RegularImmutableMap.java
index d8f9f3b..4e1681e 100644
--- a/android/guava/src/com/google/common/collect/RegularImmutableMap.java
+++ b/android/guava/src/com/google/common/collect/RegularImmutableMap.java
@@ -19,15 +19,13 @@
import static com.google.common.base.Preconditions.checkElementIndex;
import static com.google.common.base.Preconditions.checkPositionIndex;
import static com.google.common.collect.CollectPreconditions.checkEntryNotNull;
-import static java.util.Objects.requireNonNull;
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.VisibleForTesting;
import java.util.AbstractMap;
import java.util.Arrays;
import java.util.Map.Entry;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* A hash-based implementation of {@link ImmutableMap}.
@@ -35,7 +33,6 @@
* @author Louis Wasserman
*/
@GwtCompatible(serializable = true, emulated = true)
-@ElementTypesAreNonnullByDefault
final class RegularImmutableMap<K, V> extends ImmutableMap<K, V> {
private static final byte ABSENT = -1;
@@ -67,19 +64,16 @@
* & (table.length - 1) instead of % table.length, though.
*/
- @CheckForNull private final transient Object hashTable;
- @VisibleForTesting final transient @Nullable Object[] alternatingKeysAndValues;
+ private final transient Object hashTable;
+ @VisibleForTesting final transient Object[] alternatingKeysAndValues;
private final transient int size;
@SuppressWarnings("unchecked")
- static <K, V> RegularImmutableMap<K, V> create(
- int n, @Nullable Object[] alternatingKeysAndValues) {
+ static <K, V> RegularImmutableMap<K, V> create(int n, Object[] alternatingKeysAndValues) {
if (n == 0) {
return (RegularImmutableMap<K, V>) EMPTY;
} else if (n == 1) {
- // requireNonNull is safe because the first `2*n` elements have been filled in.
- checkEntryNotNull(
- requireNonNull(alternatingKeysAndValues[0]), requireNonNull(alternatingKeysAndValues[1]));
+ checkEntryNotNull(alternatingKeysAndValues[0], alternatingKeysAndValues[1]);
return new RegularImmutableMap<K, V>(null, alternatingKeysAndValues, 1);
}
checkPositionIndex(n, alternatingKeysAndValues.length >> 1);
@@ -92,15 +86,12 @@
* Returns a hash table for the specified keys and values, and ensures that neither keys nor
* values are null.
*/
- @CheckForNull
static Object createHashTable(
- @Nullable Object[] alternatingKeysAndValues, int n, int tableSize, int keyOffset) {
+ Object[] alternatingKeysAndValues, int n, int tableSize, int keyOffset) {
if (n == 1) {
// for n=1 we don't create a hash table, but we need to do the checkEntryNotNull check!
- // requireNonNull is safe because the first `2*n` elements have been filled in.
checkEntryNotNull(
- requireNonNull(alternatingKeysAndValues[keyOffset]),
- requireNonNull(alternatingKeysAndValues[keyOffset ^ 1]));
+ alternatingKeysAndValues[keyOffset], alternatingKeysAndValues[keyOffset ^ 1]);
return null;
}
int mask = tableSize - 1;
@@ -116,9 +107,8 @@
for (int i = 0; i < n; i++) {
int keyIndex = 2 * i + keyOffset;
- // requireNonNull is safe because the first `2*n` elements have been filled in.
- Object key = requireNonNull(alternatingKeysAndValues[keyIndex]);
- Object value = requireNonNull(alternatingKeysAndValues[keyIndex ^ 1]);
+ Object key = alternatingKeysAndValues[keyIndex];
+ Object value = alternatingKeysAndValues[keyIndex ^ 1];
checkEntryNotNull(key, value);
for (int h = Hashing.smear(key.hashCode()); ; h++) {
h &= mask;
@@ -126,7 +116,7 @@
if (previousKeyIndex == BYTE_MASK) { // -1 signed becomes 255 unsigned
hashTable[h] = (byte) keyIndex;
break;
- } else if (key.equals(alternatingKeysAndValues[previousKeyIndex])) {
+ } else if (alternatingKeysAndValues[previousKeyIndex].equals(key)) {
throw duplicateKeyException(key, value, alternatingKeysAndValues, previousKeyIndex);
}
}
@@ -144,9 +134,8 @@
for (int i = 0; i < n; i++) {
int keyIndex = 2 * i + keyOffset;
- // requireNonNull is safe because the first `2*n` elements have been filled in.
- Object key = requireNonNull(alternatingKeysAndValues[keyIndex]);
- Object value = requireNonNull(alternatingKeysAndValues[keyIndex ^ 1]);
+ Object key = alternatingKeysAndValues[keyIndex];
+ Object value = alternatingKeysAndValues[keyIndex ^ 1];
checkEntryNotNull(key, value);
for (int h = Hashing.smear(key.hashCode()); ; h++) {
h &= mask;
@@ -154,7 +143,7 @@
if (previousKeyIndex == SHORT_MASK) { // -1 signed becomes 65_535 unsigned
hashTable[h] = (short) keyIndex;
break;
- } else if (key.equals(alternatingKeysAndValues[previousKeyIndex])) {
+ } else if (alternatingKeysAndValues[previousKeyIndex].equals(key)) {
throw duplicateKeyException(key, value, alternatingKeysAndValues, previousKeyIndex);
}
}
@@ -169,9 +158,8 @@
for (int i = 0; i < n; i++) {
int keyIndex = 2 * i + keyOffset;
- // requireNonNull is safe because the first `2*n` elements have been filled in.
- Object key = requireNonNull(alternatingKeysAndValues[keyIndex]);
- Object value = requireNonNull(alternatingKeysAndValues[keyIndex ^ 1]);
+ Object key = alternatingKeysAndValues[keyIndex];
+ Object value = alternatingKeysAndValues[keyIndex ^ 1];
checkEntryNotNull(key, value);
for (int h = Hashing.smear(key.hashCode()); ; h++) {
h &= mask;
@@ -179,7 +167,7 @@
if (previousKeyIndex == ABSENT) {
hashTable[h] = keyIndex;
break;
- } else if (key.equals(alternatingKeysAndValues[previousKeyIndex])) {
+ } else if (alternatingKeysAndValues[previousKeyIndex].equals(key)) {
throw duplicateKeyException(key, value, alternatingKeysAndValues, previousKeyIndex);
}
}
@@ -189,7 +177,7 @@
}
private static IllegalArgumentException duplicateKeyException(
- Object key, Object value, @Nullable Object[] alternatingKeysAndValues, int previousKeyIndex) {
+ Object key, Object value, Object[] alternatingKeysAndValues, int previousKeyIndex) {
return new IllegalArgumentException(
"Multiple entries with same key: "
+ key
@@ -201,8 +189,7 @@
+ alternatingKeysAndValues[previousKeyIndex ^ 1]);
}
- private RegularImmutableMap(
- @CheckForNull Object hashTable, @Nullable Object[] alternatingKeysAndValues, int size) {
+ private RegularImmutableMap(Object hashTable, Object[] alternatingKeysAndValues, int size) {
this.hashTable = hashTable;
this.alternatingKeysAndValues = alternatingKeysAndValues;
this.size = size;
@@ -215,33 +202,22 @@
@SuppressWarnings("unchecked")
@Override
- @CheckForNull
- public V get(@CheckForNull Object key) {
- Object result = get(hashTable, alternatingKeysAndValues, size, 0, key);
- /*
- * We can't simply cast the result of `RegularImmutableMap.get` to V because of a bug in our
- * nullness checker (resulting from https://github.com/jspecify/checker-framework/issues/8).
- */
- if (result == null) {
- return null;
- } else {
- return (V) result;
- }
+ @NullableDecl
+ public V get(@NullableDecl Object key) {
+ return (V) get(hashTable, alternatingKeysAndValues, size, 0, key);
}
- @CheckForNull
static Object get(
- @CheckForNull Object hashTableObject,
- @Nullable Object[] alternatingKeysAndValues,
+ @NullableDecl Object hashTableObject,
+ @NullableDecl Object[] alternatingKeysAndValues,
int size,
int keyOffset,
- @CheckForNull Object key) {
+ @NullableDecl Object key) {
if (key == null) {
return null;
} else if (size == 1) {
- // requireNonNull is safe because the first 2 elements have been filled in.
- return requireNonNull(alternatingKeysAndValues[keyOffset]).equals(key)
- ? requireNonNull(alternatingKeysAndValues[keyOffset ^ 1])
+ return alternatingKeysAndValues[keyOffset].equals(key)
+ ? alternatingKeysAndValues[keyOffset ^ 1]
: null;
} else if (hashTableObject == null) {
return null;
@@ -254,7 +230,7 @@
int keyIndex = hashTable[h] & BYTE_MASK; // unsigned read
if (keyIndex == BYTE_MASK) { // -1 signed becomes 255 unsigned
return null;
- } else if (key.equals(alternatingKeysAndValues[keyIndex])) {
+ } else if (alternatingKeysAndValues[keyIndex].equals(key)) {
return alternatingKeysAndValues[keyIndex ^ 1];
}
}
@@ -266,7 +242,7 @@
int keyIndex = hashTable[h] & SHORT_MASK; // unsigned read
if (keyIndex == SHORT_MASK) { // -1 signed becomes 65_535 unsigned
return null;
- } else if (key.equals(alternatingKeysAndValues[keyIndex])) {
+ } else if (alternatingKeysAndValues[keyIndex].equals(key)) {
return alternatingKeysAndValues[keyIndex ^ 1];
}
}
@@ -278,7 +254,7 @@
int keyIndex = hashTable[h];
if (keyIndex == ABSENT) {
return null;
- } else if (key.equals(alternatingKeysAndValues[keyIndex])) {
+ } else if (alternatingKeysAndValues[keyIndex].equals(key)) {
return alternatingKeysAndValues[keyIndex ^ 1];
}
}
@@ -292,15 +268,11 @@
static class EntrySet<K, V> extends ImmutableSet<Entry<K, V>> {
private final transient ImmutableMap<K, V> map;
- private final transient @Nullable Object[] alternatingKeysAndValues;
+ private final transient Object[] alternatingKeysAndValues;
private final transient int keyOffset;
private final transient int size;
- EntrySet(
- ImmutableMap<K, V> map,
- @Nullable Object[] alternatingKeysAndValues,
- int keyOffset,
- int size) {
+ EntrySet(ImmutableMap<K, V> map, Object[] alternatingKeysAndValues, int keyOffset, int size) {
this.map = map;
this.alternatingKeysAndValues = alternatingKeysAndValues;
this.keyOffset = keyOffset;
@@ -323,14 +295,10 @@
@Override
public Entry<K, V> get(int index) {
checkElementIndex(index, size);
- /*
- * requireNonNull is safe because the first `2*(size+keyOffset)` elements have been filled
- * in.
- */
@SuppressWarnings("unchecked")
- K key = (K) requireNonNull(alternatingKeysAndValues[2 * index + keyOffset]);
+ K key = (K) alternatingKeysAndValues[2 * index + keyOffset];
@SuppressWarnings("unchecked")
- V value = (V) requireNonNull(alternatingKeysAndValues[2 * index + (keyOffset ^ 1)]);
+ V value = (V) alternatingKeysAndValues[2 * index + (keyOffset ^ 1)];
return new AbstractMap.SimpleImmutableEntry<K, V>(key, value);
}
@@ -347,7 +315,7 @@
}
@Override
- public boolean contains(@CheckForNull Object object) {
+ public boolean contains(Object object) {
if (object instanceof Entry) {
Entry<?, ?> entry = (Entry<?, ?>) object;
Object k = entry.getKey();
@@ -377,11 +345,11 @@
}
static final class KeysOrValuesAsList extends ImmutableList<Object> {
- private final transient @Nullable Object[] alternatingKeysAndValues;
+ private final transient Object[] alternatingKeysAndValues;
private final transient int offset;
private final transient int size;
- KeysOrValuesAsList(@Nullable Object[] alternatingKeysAndValues, int offset, int size) {
+ KeysOrValuesAsList(Object[] alternatingKeysAndValues, int offset, int size) {
this.alternatingKeysAndValues = alternatingKeysAndValues;
this.offset = offset;
this.size = size;
@@ -390,8 +358,7 @@
@Override
public Object get(int index) {
checkElementIndex(index, size);
- // requireNonNull is safe because the first `2*(size+offset)` elements have been filled in.
- return requireNonNull(alternatingKeysAndValues[2 * index + offset]);
+ return alternatingKeysAndValues[2 * index + offset];
}
@Override
@@ -430,7 +397,7 @@
}
@Override
- public boolean contains(@CheckForNull Object object) {
+ public boolean contains(@NullableDecl Object object) {
return map.get(object) != null;
}
diff --git a/android/guava/src/com/google/common/collect/RegularImmutableMultiset.java b/android/guava/src/com/google/common/collect/RegularImmutableMultiset.java
index 6fbc099..3beec6f 100644
--- a/android/guava/src/com/google/common/collect/RegularImmutableMultiset.java
+++ b/android/guava/src/com/google/common/collect/RegularImmutableMultiset.java
@@ -21,7 +21,7 @@
import com.google.errorprone.annotations.concurrent.LazyInit;
import com.google.j2objc.annotations.WeakOuter;
import java.io.Serializable;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* Implementation of {@link ImmutableMultiset} with zero or more elements.
@@ -31,7 +31,6 @@
*/
@GwtCompatible(emulated = true, serializable = true)
@SuppressWarnings("serial") // uses writeReplace(), not default serialization
-@ElementTypesAreNonnullByDefault
class RegularImmutableMultiset<E> extends ImmutableMultiset<E> {
static final RegularImmutableMultiset<Object> EMPTY =
new RegularImmutableMultiset<>(ObjectCountHashMap.create());
@@ -39,7 +38,7 @@
final transient ObjectCountHashMap<E> contents;
private final transient int size;
- @LazyInit @CheckForNull private transient ImmutableSet<E> elementSet;
+ @LazyInit private transient ImmutableSet<E> elementSet;
RegularImmutableMultiset(ObjectCountHashMap<E> contents) {
this.contents = contents;
@@ -56,7 +55,7 @@
}
@Override
- public int count(@CheckForNull Object element) {
+ public int count(@NullableDecl Object element) {
return contents.get(element);
}
@@ -80,7 +79,7 @@
}
@Override
- public boolean contains(@CheckForNull Object object) {
+ public boolean contains(@NullableDecl Object object) {
return RegularImmutableMultiset.this.contains(object);
}
@@ -105,13 +104,12 @@
final Object[] elements;
final int[] counts;
- // "extends Object" works around https://github.com/typetools/checker-framework/issues/3013
- SerializedForm(Multiset<? extends Object> multiset) {
+ SerializedForm(Multiset<?> multiset) {
int distinct = multiset.entrySet().size();
elements = new Object[distinct];
counts = new int[distinct];
int i = 0;
- for (Entry<? extends Object> entry : multiset.entrySet()) {
+ for (Entry<?> entry : multiset.entrySet()) {
elements[i] = entry.getElement();
counts[i] = entry.getCount();
i++;
diff --git a/android/guava/src/com/google/common/collect/RegularImmutableSet.java b/android/guava/src/com/google/common/collect/RegularImmutableSet.java
index 2382ef6..b7202f8 100644
--- a/android/guava/src/com/google/common/collect/RegularImmutableSet.java
+++ b/android/guava/src/com/google/common/collect/RegularImmutableSet.java
@@ -18,8 +18,7 @@
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.VisibleForTesting;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* Implementation of {@link ImmutableSet} with two or more elements.
@@ -28,34 +27,30 @@
*/
@GwtCompatible(serializable = true, emulated = true)
@SuppressWarnings("serial") // uses writeReplace(), not default serialization
-@ElementTypesAreNonnullByDefault
final class RegularImmutableSet<E> extends ImmutableSet<E> {
- private static final Object[] EMPTY_ARRAY = new Object[0];
static final RegularImmutableSet<Object> EMPTY =
- new RegularImmutableSet<>(EMPTY_ARRAY, 0, EMPTY_ARRAY, 0, 0);
+ new RegularImmutableSet<>(new Object[0], 0, null, 0, 0);
- // The first `size` elements are non-null.
- @VisibleForTesting final transient @Nullable Object[] elements;
- private final transient int hashCode;
- // the same values as `elements` in hashed positions (plus nulls)
- @VisibleForTesting final transient @Nullable Object[] table;
+ @VisibleForTesting final transient Object[] elements;
+ // the same elements in hashed positions (plus nulls)
+ @VisibleForTesting final transient Object[] table;
// 'and' with an int to get a valid table index.
private final transient int mask;
+ private final transient int hashCode;
private final transient int size;
- RegularImmutableSet(
- @Nullable Object[] elements, int hashCode, @Nullable Object[] table, int mask, int size) {
+ RegularImmutableSet(Object[] elements, int hashCode, Object[] table, int mask, int size) {
this.elements = elements;
- this.hashCode = hashCode;
this.table = table;
this.mask = mask;
+ this.hashCode = hashCode;
this.size = size;
}
@Override
- public boolean contains(@CheckForNull Object target) {
- @Nullable Object[] table = this.table;
- if (target == null || table.length == 0) {
+ public boolean contains(@NullableDecl Object target) {
+ Object[] table = this.table;
+ if (target == null || table == null) {
return false;
}
for (int i = Hashing.smearedHash(target); ; i++) {
@@ -80,7 +75,6 @@
}
@Override
- @Nullable
Object[] internalArray() {
return elements;
}
@@ -96,7 +90,7 @@
}
@Override
- int copyIntoArray(@Nullable Object[] dst, int offset) {
+ int copyIntoArray(Object[] dst, int offset) {
System.arraycopy(elements, 0, dst, offset, size);
return offset + size;
}
diff --git a/android/guava/src/com/google/common/collect/RegularImmutableSortedMultiset.java b/android/guava/src/com/google/common/collect/RegularImmutableSortedMultiset.java
index 3b6d79c..c1d739f 100644
--- a/android/guava/src/com/google/common/collect/RegularImmutableSortedMultiset.java
+++ b/android/guava/src/com/google/common/collect/RegularImmutableSortedMultiset.java
@@ -22,7 +22,7 @@
import com.google.common.annotations.VisibleForTesting;
import com.google.common.primitives.Ints;
import java.util.Comparator;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* An immutable sorted multiset with one or more distinct elements.
@@ -31,7 +31,6 @@
*/
@SuppressWarnings("serial") // uses writeReplace, not default serialization
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
final class RegularImmutableSortedMultiset<E> extends ImmutableSortedMultiset<E> {
private static final long[] ZERO_CUMULATIVE_COUNTS = {0};
@@ -68,19 +67,17 @@
}
@Override
- @CheckForNull
public Entry<E> firstEntry() {
return isEmpty() ? null : getEntry(0);
}
@Override
- @CheckForNull
public Entry<E> lastEntry() {
return isEmpty() ? null : getEntry(length - 1);
}
@Override
- public int count(@CheckForNull Object element) {
+ public int count(@NullableDecl Object element) {
int index = elementSet.indexOf(element);
return (index >= 0) ? getCount(index) : 0;
}
diff --git a/android/guava/src/com/google/common/collect/RegularImmutableSortedSet.java b/android/guava/src/com/google/common/collect/RegularImmutableSortedSet.java
index dd98798..d70d8fb 100644
--- a/android/guava/src/com/google/common/collect/RegularImmutableSortedSet.java
+++ b/android/guava/src/com/google/common/collect/RegularImmutableSortedSet.java
@@ -27,8 +27,7 @@
import java.util.Iterator;
import java.util.NoSuchElementException;
import java.util.Set;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* An immutable sorted set with one or more elements. TODO(jlevy): Consider separate class for a
@@ -39,7 +38,6 @@
*/
@GwtCompatible(serializable = true, emulated = true)
@SuppressWarnings({"serial", "rawtypes"})
-@ElementTypesAreNonnullByDefault
final class RegularImmutableSortedSet<E> extends ImmutableSortedSet<E> {
static final RegularImmutableSortedSet<Comparable> NATURAL_EMPTY_SET =
new RegularImmutableSortedSet<>(ImmutableList.<Comparable>of(), Ordering.natural());
@@ -52,8 +50,6 @@
}
@Override
- @CheckForNull
- @Nullable
Object[] internalArray() {
return elements.internalArray();
}
@@ -85,7 +81,7 @@
}
@Override
- public boolean contains(@CheckForNull Object o) {
+ public boolean contains(@NullableDecl Object o) {
try {
return o != null && unsafeBinarySearch(o) >= 0;
} catch (ClassCastException e) {
@@ -160,7 +156,7 @@
}
@Override
- public boolean equals(@CheckForNull Object object) {
+ public boolean equals(@NullableDecl Object object) {
if (object == this) {
return true;
}
@@ -213,28 +209,24 @@
}
@Override
- @CheckForNull
public E lower(E element) {
int index = headIndex(element, false) - 1;
return (index == -1) ? null : elements.get(index);
}
@Override
- @CheckForNull
public E floor(E element) {
int index = headIndex(element, true) - 1;
return (index == -1) ? null : elements.get(index);
}
@Override
- @CheckForNull
public E ceiling(E element) {
int index = tailIndex(element, true);
return (index == size()) ? null : elements.get(index);
}
@Override
- @CheckForNull
public E higher(E element) {
int index = tailIndex(element, false);
return (index == size()) ? null : elements.get(index);
@@ -294,7 +286,7 @@
}
@Override
- int indexOf(@CheckForNull Object target) {
+ int indexOf(@NullableDecl Object target) {
if (target == null) {
return -1;
}
diff --git a/android/guava/src/com/google/common/collect/RegularImmutableTable.java b/android/guava/src/com/google/common/collect/RegularImmutableTable.java
index 24434c5..6c35ee4 100644
--- a/android/guava/src/com/google/common/collect/RegularImmutableTable.java
+++ b/android/guava/src/com/google/common/collect/RegularImmutableTable.java
@@ -24,7 +24,7 @@
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* An implementation of {@link ImmutableTable} holding an arbitrary number of cells.
@@ -32,7 +32,6 @@
* @author Gregory Kick
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
abstract class RegularImmutableTable<R, C, V> extends ImmutableTable<R, C, V> {
RegularImmutableTable() {}
@@ -56,7 +55,7 @@
}
@Override
- public boolean contains(@CheckForNull Object object) {
+ public boolean contains(@NullableDecl Object object) {
if (object instanceof Cell) {
Cell<?, ?, ?> cell = (Cell<?, ?, ?>) object;
Object value = RegularImmutableTable.this.get(cell.getRowKey(), cell.getColumnKey());
@@ -98,8 +97,8 @@
static <R, C, V> RegularImmutableTable<R, C, V> forCells(
List<Cell<R, C, V>> cells,
- @CheckForNull final Comparator<? super R> rowComparator,
- @CheckForNull final Comparator<? super C> columnComparator) {
+ @NullableDecl final Comparator<? super R> rowComparator,
+ @NullableDecl final Comparator<? super C> columnComparator) {
checkNotNull(cells);
if (rowComparator != null || columnComparator != null) {
/*
@@ -136,8 +135,8 @@
private static <R, C, V> RegularImmutableTable<R, C, V> forCellsInternal(
Iterable<Cell<R, C, V>> cells,
- @CheckForNull Comparator<? super R> rowComparator,
- @CheckForNull Comparator<? super C> columnComparator) {
+ @NullableDecl Comparator<? super R> rowComparator,
+ @NullableDecl Comparator<? super C> columnComparator) {
Set<R> rowSpaceBuilder = new LinkedHashSet<>();
Set<C> columnSpaceBuilder = new LinkedHashSet<>();
ImmutableList<Cell<R, C, V>> cellList = ImmutableList.copyOf(cells);
@@ -175,7 +174,7 @@
* We could have declared this method 'static' but the additional compile-time checks achieved by
* referencing the type variables seem worthwhile.
*/
- final void checkNoDuplicate(R rowKey, C columnKey, @CheckForNull V existingValue, V newValue) {
+ final void checkNoDuplicate(R rowKey, C columnKey, V existingValue, V newValue) {
checkArgument(
existingValue == null,
"Duplicate key: (row=%s, column=%s), values: [%s, %s].",
diff --git a/android/guava/src/com/google/common/collect/ReverseNaturalOrdering.java b/android/guava/src/com/google/common/collect/ReverseNaturalOrdering.java
index f0c40cb..612d846 100644
--- a/android/guava/src/com/google/common/collect/ReverseNaturalOrdering.java
+++ b/android/guava/src/com/google/common/collect/ReverseNaturalOrdering.java
@@ -25,64 +25,63 @@
/** An ordering that uses the reverse of the natural order of the values. */
@GwtCompatible(serializable = true)
@SuppressWarnings({"unchecked", "rawtypes"}) // TODO(kevinb): the right way to explain this??
-@ElementTypesAreNonnullByDefault
-final class ReverseNaturalOrdering extends Ordering<Comparable<?>> implements Serializable {
+final class ReverseNaturalOrdering extends Ordering<Comparable> implements Serializable {
static final ReverseNaturalOrdering INSTANCE = new ReverseNaturalOrdering();
@Override
- public int compare(Comparable<?> left, Comparable<?> right) {
+ public int compare(Comparable left, Comparable right) {
checkNotNull(left); // right null is caught later
if (left == right) {
return 0;
}
- return ((Comparable<Object>) right).compareTo(left);
+ return right.compareTo(left);
}
@Override
- public <S extends Comparable<?>> Ordering<S> reverse() {
+ public <S extends Comparable> Ordering<S> reverse() {
return Ordering.natural();
}
// Override the min/max methods to "hoist" delegation outside loops
@Override
- public <E extends Comparable<?>> E min(E a, E b) {
+ public <E extends Comparable> E min(E a, E b) {
return NaturalOrdering.INSTANCE.max(a, b);
}
@Override
- public <E extends Comparable<?>> E min(E a, E b, E c, E... rest) {
+ public <E extends Comparable> E min(E a, E b, E c, E... rest) {
return NaturalOrdering.INSTANCE.max(a, b, c, rest);
}
@Override
- public <E extends Comparable<?>> E min(Iterator<E> iterator) {
+ public <E extends Comparable> E min(Iterator<E> iterator) {
return NaturalOrdering.INSTANCE.max(iterator);
}
@Override
- public <E extends Comparable<?>> E min(Iterable<E> iterable) {
+ public <E extends Comparable> E min(Iterable<E> iterable) {
return NaturalOrdering.INSTANCE.max(iterable);
}
@Override
- public <E extends Comparable<?>> E max(E a, E b) {
+ public <E extends Comparable> E max(E a, E b) {
return NaturalOrdering.INSTANCE.min(a, b);
}
@Override
- public <E extends Comparable<?>> E max(E a, E b, E c, E... rest) {
+ public <E extends Comparable> E max(E a, E b, E c, E... rest) {
return NaturalOrdering.INSTANCE.min(a, b, c, rest);
}
@Override
- public <E extends Comparable<?>> E max(Iterator<E> iterator) {
+ public <E extends Comparable> E max(Iterator<E> iterator) {
return NaturalOrdering.INSTANCE.min(iterator);
}
@Override
- public <E extends Comparable<?>> E max(Iterable<E> iterable) {
+ public <E extends Comparable> E max(Iterable<E> iterable) {
return NaturalOrdering.INSTANCE.min(iterable);
}
diff --git a/android/guava/src/com/google/common/collect/ReverseOrdering.java b/android/guava/src/com/google/common/collect/ReverseOrdering.java
index 6c1e74d..9f65e59 100644
--- a/android/guava/src/com/google/common/collect/ReverseOrdering.java
+++ b/android/guava/src/com/google/common/collect/ReverseOrdering.java
@@ -21,14 +21,11 @@
import com.google.common.annotations.GwtCompatible;
import java.io.Serializable;
import java.util.Iterator;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/** An ordering that uses the reverse of a given order. */
@GwtCompatible(serializable = true)
-@ElementTypesAreNonnullByDefault
-final class ReverseOrdering<T extends @Nullable Object> extends Ordering<T>
- implements Serializable {
+final class ReverseOrdering<T> extends Ordering<T> implements Serializable {
final Ordering<? super T> forwardOrder;
ReverseOrdering(Ordering<? super T> forwardOrder) {
@@ -36,7 +33,7 @@
}
@Override
- public int compare(@ParametricNullness T a, @ParametricNullness T b) {
+ public int compare(T a, T b) {
return forwardOrder.compare(b, a);
}
@@ -49,13 +46,12 @@
// Override the min/max methods to "hoist" delegation outside loops
@Override
- public <E extends T> E min(@ParametricNullness E a, @ParametricNullness E b) {
+ public <E extends T> E min(E a, E b) {
return forwardOrder.max(a, b);
}
@Override
- public <E extends T> E min(
- @ParametricNullness E a, @ParametricNullness E b, @ParametricNullness E c, E... rest) {
+ public <E extends T> E min(E a, E b, E c, E... rest) {
return forwardOrder.max(a, b, c, rest);
}
@@ -70,13 +66,12 @@
}
@Override
- public <E extends T> E max(@ParametricNullness E a, @ParametricNullness E b) {
+ public <E extends T> E max(E a, E b) {
return forwardOrder.min(a, b);
}
@Override
- public <E extends T> E max(
- @ParametricNullness E a, @ParametricNullness E b, @ParametricNullness E c, E... rest) {
+ public <E extends T> E max(E a, E b, E c, E... rest) {
return forwardOrder.min(a, b, c, rest);
}
@@ -96,7 +91,7 @@
}
@Override
- public boolean equals(@CheckForNull Object object) {
+ public boolean equals(@NullableDecl Object object) {
if (object == this) {
return true;
}
diff --git a/android/guava/src/com/google/common/collect/RowSortedTable.java b/android/guava/src/com/google/common/collect/RowSortedTable.java
index 2c2d773..9cdae79 100644
--- a/android/guava/src/com/google/common/collect/RowSortedTable.java
+++ b/android/guava/src/com/google/common/collect/RowSortedTable.java
@@ -21,7 +21,6 @@
import java.util.Set;
import java.util.SortedMap;
import java.util.SortedSet;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Interface that extends {@code Table} and whose rows are sorted.
@@ -34,10 +33,7 @@
* @since 8.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-public interface RowSortedTable<
- R extends @Nullable Object, C extends @Nullable Object, V extends @Nullable Object>
- extends Table<R, C, V> {
+public interface RowSortedTable<R, C, V> extends Table<R, C, V> {
/**
* {@inheritDoc}
*
diff --git a/android/guava/src/com/google/common/collect/Serialization.java b/android/guava/src/com/google/common/collect/Serialization.java
index 5e88067..929a48f 100644
--- a/android/guava/src/com/google/common/collect/Serialization.java
+++ b/android/guava/src/com/google/common/collect/Serialization.java
@@ -23,7 +23,6 @@
import java.lang.reflect.Field;
import java.util.Collection;
import java.util.Map;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Provides static methods for serializing collection classes.
@@ -34,7 +33,6 @@
* @author Jared Levy
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
final class Serialization {
private Serialization() {}
@@ -56,8 +54,7 @@
* <p>The serialized output consists of the number of entries, first key, first value, second key,
* second value, and so on.
*/
- static <K extends @Nullable Object, V extends @Nullable Object> void writeMap(
- Map<K, V> map, ObjectOutputStream stream) throws IOException {
+ static <K, V> void writeMap(Map<K, V> map, ObjectOutputStream stream) throws IOException {
stream.writeInt(map.size());
for (Map.Entry<K, V> entry : map.entrySet()) {
stream.writeObject(entry.getKey());
@@ -69,8 +66,8 @@
* Populates a map by reading an input stream, as part of deserialization. See {@link #writeMap}
* for the data format.
*/
- static <K extends @Nullable Object, V extends @Nullable Object> void populateMap(
- Map<K, V> map, ObjectInputStream stream) throws IOException, ClassNotFoundException {
+ static <K, V> void populateMap(Map<K, V> map, ObjectInputStream stream)
+ throws IOException, ClassNotFoundException {
int size = stream.readInt();
populateMap(map, stream, size);
}
@@ -79,8 +76,7 @@
* Populates a map by reading an input stream, as part of deserialization. See {@link #writeMap}
* for the data format. The size is determined by a prior call to {@link #readCount}.
*/
- static <K extends @Nullable Object, V extends @Nullable Object> void populateMap(
- Map<K, V> map, ObjectInputStream stream, int size)
+ static <K, V> void populateMap(Map<K, V> map, ObjectInputStream stream, int size)
throws IOException, ClassNotFoundException {
for (int i = 0; i < size; i++) {
@SuppressWarnings("unchecked") // reading data stored by writeMap
@@ -98,8 +94,8 @@
* <p>The serialized output consists of the number of distinct elements, the first element, its
* count, the second element, its count, and so on.
*/
- static <E extends @Nullable Object> void writeMultiset(
- Multiset<E> multiset, ObjectOutputStream stream) throws IOException {
+ static <E> void writeMultiset(Multiset<E> multiset, ObjectOutputStream stream)
+ throws IOException {
int entryCount = multiset.entrySet().size();
stream.writeInt(entryCount);
for (Multiset.Entry<E> entry : multiset.entrySet()) {
@@ -112,8 +108,8 @@
* Populates a multiset by reading an input stream, as part of deserialization. See {@link
* #writeMultiset} for the data format.
*/
- static <E extends @Nullable Object> void populateMultiset(
- Multiset<E> multiset, ObjectInputStream stream) throws IOException, ClassNotFoundException {
+ static <E> void populateMultiset(Multiset<E> multiset, ObjectInputStream stream)
+ throws IOException, ClassNotFoundException {
int distinctElements = stream.readInt();
populateMultiset(multiset, stream, distinctElements);
}
@@ -123,7 +119,7 @@
* #writeMultiset} for the data format. The number of distinct elements is determined by a prior
* call to {@link #readCount}.
*/
- static <E extends @Nullable Object> void populateMultiset(
+ static <E> void populateMultiset(
Multiset<E> multiset, ObjectInputStream stream, int distinctElements)
throws IOException, ClassNotFoundException {
for (int i = 0; i < distinctElements; i++) {
@@ -142,8 +138,8 @@
* <p>The serialized output consists of the number of distinct keys, and then for each distinct
* key: the key, the number of values for that key, and the key's values.
*/
- static <K extends @Nullable Object, V extends @Nullable Object> void writeMultimap(
- Multimap<K, V> multimap, ObjectOutputStream stream) throws IOException {
+ static <K, V> void writeMultimap(Multimap<K, V> multimap, ObjectOutputStream stream)
+ throws IOException {
stream.writeInt(multimap.asMap().size());
for (Map.Entry<K, Collection<V>> entry : multimap.asMap().entrySet()) {
stream.writeObject(entry.getKey());
@@ -158,8 +154,7 @@
* Populates a multimap by reading an input stream, as part of deserialization. See {@link
* #writeMultimap} for the data format.
*/
- static <K extends @Nullable Object, V extends @Nullable Object> void populateMultimap(
- Multimap<K, V> multimap, ObjectInputStream stream)
+ static <K, V> void populateMultimap(Multimap<K, V> multimap, ObjectInputStream stream)
throws IOException, ClassNotFoundException {
int distinctKeys = stream.readInt();
populateMultimap(multimap, stream, distinctKeys);
@@ -170,7 +165,7 @@
* #writeMultimap} for the data format. The number of distinct keys is determined by a prior call
* to {@link #readCount}.
*/
- static <K extends @Nullable Object, V extends @Nullable Object> void populateMultimap(
+ static <K, V> void populateMultimap(
Multimap<K, V> multimap, ObjectInputStream stream, int distinctKeys)
throws IOException, ClassNotFoundException {
for (int i = 0; i < distinctKeys; i++) {
diff --git a/android/guava/src/com/google/common/collect/SetMultimap.java b/android/guava/src/com/google/common/collect/SetMultimap.java
index 216533e..f2c6b57 100644
--- a/android/guava/src/com/google/common/collect/SetMultimap.java
+++ b/android/guava/src/com/google/common/collect/SetMultimap.java
@@ -22,8 +22,7 @@
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* A {@code Multimap} that cannot hold duplicate key-value pairs. Adding a key-value pair that's
@@ -42,9 +41,6 @@
* {@code equals} comparisons. Use caution if mutable objects are used as keys or values in a {@code
* SetMultimap}.
*
- * <p><b>Warning:</b> Do not modify either a key <i>or a value</i> of a {@code SetMultimap} in a way
- * that affects its {@link Object#equals} behavior. Undefined behavior and bugs will result.
- *
* <p>See the Guava User Guide article on <a href=
* "https://github.com/google/guava/wiki/NewCollectionTypesExplained#multimap"> {@code
* Multimap}</a>.
@@ -53,9 +49,7 @@
* @since 2.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-public interface SetMultimap<K extends @Nullable Object, V extends @Nullable Object>
- extends Multimap<K, V> {
+public interface SetMultimap<K, V> extends Multimap<K, V> {
/**
* {@inheritDoc}
*
@@ -64,7 +58,7 @@
* interface.
*/
@Override
- Set<V> get(@ParametricNullness K key);
+ Set<V> get(@NullableDecl K key);
/**
* {@inheritDoc}
@@ -75,7 +69,7 @@
*/
@CanIgnoreReturnValue
@Override
- Set<V> removeAll(@CheckForNull Object key);
+ Set<V> removeAll(@NullableDecl Object key);
/**
* {@inheritDoc}
@@ -88,7 +82,7 @@
*/
@CanIgnoreReturnValue
@Override
- Set<V> replaceValues(@ParametricNullness K key, Iterable<? extends V> values);
+ Set<V> replaceValues(K key, Iterable<? extends V> values);
/**
* {@inheritDoc}
@@ -120,5 +114,5 @@
* empty {@code ListMultimap}.
*/
@Override
- boolean equals(@CheckForNull Object obj);
+ boolean equals(@NullableDecl Object obj);
}
diff --git a/android/guava/src/com/google/common/collect/Sets.java b/android/guava/src/com/google/common/collect/Sets.java
index dde21cb..3fe27ba 100644
--- a/android/guava/src/com/google/common/collect/Sets.java
+++ b/android/guava/src/com/google/common/collect/Sets.java
@@ -28,7 +28,6 @@
import com.google.common.collect.Collections2.FilteredCollection;
import com.google.common.math.IntMath;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
-import com.google.errorprone.annotations.DoNotCall;
import java.io.Serializable;
import java.util.AbstractSet;
import java.util.Arrays;
@@ -49,8 +48,7 @@
import java.util.TreeSet;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArraySet;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* Static utility methods pertaining to {@link Set} instances. Also see this class's counterparts
@@ -65,7 +63,6 @@
* @since 2.0
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
public final class Sets {
private Sets() {}
@@ -73,7 +70,7 @@
* {@link AbstractSet} substitute without the potentially-quadratic {@code removeAll}
* implementation.
*/
- abstract static class ImprovedAbstractSet<E extends @Nullable Object> extends AbstractSet<E> {
+ abstract static class ImprovedAbstractSet<E> extends AbstractSet<E> {
@Override
public boolean removeAll(Collection<?> c) {
return removeAllImpl(this, c);
@@ -163,7 +160,7 @@
* deprecated. Instead, use the {@code HashSet} constructor directly, taking advantage of the new
* <a href="http://goo.gl/iz2Wi">"diamond" syntax</a>.
*/
- public static <E extends @Nullable Object> HashSet<E> newHashSet() {
+ public static <E> HashSet<E> newHashSet() {
return new HashSet<E>();
}
@@ -180,7 +177,7 @@
* asList}{@code (...))}, or for creating an empty set then calling {@link Collections#addAll}.
* This method is not actually very useful and will likely be deprecated in the future.
*/
- public static <E extends @Nullable Object> HashSet<E> newHashSet(E... elements) {
+ public static <E> HashSet<E> newHashSet(E... elements) {
HashSet<E> set = newHashSetWithExpectedSize(elements.length);
Collections.addAll(set, elements);
return set;
@@ -204,7 +201,7 @@
*
* <p>Overall, this method is not very useful and will likely be deprecated in the future.
*/
- public static <E extends @Nullable Object> HashSet<E> newHashSet(Iterable<? extends E> elements) {
+ public static <E> HashSet<E> newHashSet(Iterable<? extends E> elements) {
return (elements instanceof Collection)
? new HashSet<E>((Collection<? extends E>) elements)
: newHashSet(elements.iterator());
@@ -222,7 +219,7 @@
*
* <p>Overall, this method is not very useful and will likely be deprecated in the future.
*/
- public static <E extends @Nullable Object> HashSet<E> newHashSet(Iterator<? extends E> elements) {
+ public static <E> HashSet<E> newHashSet(Iterator<? extends E> elements) {
HashSet<E> set = newHashSet();
Iterators.addAll(set, elements);
return set;
@@ -240,8 +237,7 @@
* without resizing
* @throws IllegalArgumentException if {@code expectedSize} is negative
*/
- public static <E extends @Nullable Object> HashSet<E> newHashSetWithExpectedSize(
- int expectedSize) {
+ public static <E> HashSet<E> newHashSetWithExpectedSize(int expectedSize) {
return new HashSet<E>(Maps.capacity(expectedSize));
}
@@ -291,7 +287,7 @@
*
* @return a new, empty {@code LinkedHashSet}
*/
- public static <E extends @Nullable Object> LinkedHashSet<E> newLinkedHashSet() {
+ public static <E> LinkedHashSet<E> newLinkedHashSet() {
return new LinkedHashSet<E>();
}
@@ -310,8 +306,7 @@
* @param elements the elements that the set should contain, in order
* @return a new {@code LinkedHashSet} containing those elements (minus duplicates)
*/
- public static <E extends @Nullable Object> LinkedHashSet<E> newLinkedHashSet(
- Iterable<? extends E> elements) {
+ public static <E> LinkedHashSet<E> newLinkedHashSet(Iterable<? extends E> elements) {
if (elements instanceof Collection) {
return new LinkedHashSet<E>((Collection<? extends E>) elements);
}
@@ -332,8 +327,7 @@
* @throws IllegalArgumentException if {@code expectedSize} is negative
* @since 11.0
*/
- public static <E extends @Nullable Object> LinkedHashSet<E> newLinkedHashSetWithExpectedSize(
- int expectedSize) {
+ public static <E> LinkedHashSet<E> newLinkedHashSetWithExpectedSize(int expectedSize) {
return new LinkedHashSet<E>(Maps.capacity(expectedSize));
}
@@ -398,8 +392,7 @@
* @return a new, empty {@code TreeSet}
* @throws NullPointerException if {@code comparator} is null
*/
- public static <E extends @Nullable Object> TreeSet<E> newTreeSet(
- Comparator<? super E> comparator) {
+ public static <E> TreeSet<E> newTreeSet(Comparator<? super E> comparator) {
return new TreeSet<E>(checkNotNull(comparator));
}
@@ -412,7 +405,7 @@
*
* @since 8.0
*/
- public static <E extends @Nullable Object> Set<E> newIdentityHashSet() {
+ public static <E> Set<E> newIdentityHashSet() {
return Collections.newSetFromMap(Maps.<E, Boolean>newIdentityHashMap());
}
@@ -426,7 +419,7 @@
* @since 12.0
*/
@GwtIncompatible // CopyOnWriteArraySet
- public static <E extends @Nullable Object> CopyOnWriteArraySet<E> newCopyOnWriteArraySet() {
+ public static <E> CopyOnWriteArraySet<E> newCopyOnWriteArraySet() {
return new CopyOnWriteArraySet<E>();
}
@@ -438,8 +431,7 @@
* @since 12.0
*/
@GwtIncompatible // CopyOnWriteArraySet
- public static <E extends @Nullable Object> CopyOnWriteArraySet<E> newCopyOnWriteArraySet(
- Iterable<? extends E> elements) {
+ public static <E> CopyOnWriteArraySet<E> newCopyOnWriteArraySet(Iterable<? extends E> elements) {
// We copy elements to an ArrayList first, rather than incurring the
// quadratic cost of adding them to the COWAS directly.
Collection<? extends E> elementsCollection =
@@ -527,8 +519,7 @@
* @deprecated Use {@link Collections#newSetFromMap} instead.
*/
@Deprecated
- public static <E extends @Nullable Object> Set<E> newSetFromMap(
- Map<E, Boolean> map) {
+ public static <E> Set<E> newSetFromMap(Map<E, Boolean> map) {
return Collections.newSetFromMap(map);
}
@@ -541,7 +532,7 @@
*
* @since 2.0
*/
- public abstract static class SetView<E extends @Nullable Object> extends AbstractSet<E> {
+ public abstract static class SetView<E> extends AbstractSet<E> {
private SetView() {} // no subclasses but our own
/**
@@ -552,7 +543,6 @@
* nonstandard notion of equivalence, for example if it is a {@link TreeSet} using a comparator
* that is inconsistent with {@link Object#equals(Object)}.
*/
- @SuppressWarnings("nullness") // Unsafe, but we can't fix it now.
public ImmutableSet<E> immutableCopy() {
return ImmutableSet.copyOf(this);
}
@@ -581,8 +571,7 @@
@CanIgnoreReturnValue
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
- public final boolean add(@ParametricNullness E e) {
+ public final boolean add(E e) {
throw new UnsupportedOperationException();
}
@@ -595,8 +584,7 @@
@CanIgnoreReturnValue
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
- public final boolean remove(@CheckForNull Object object) {
+ public final boolean remove(Object object) {
throw new UnsupportedOperationException();
}
@@ -609,7 +597,6 @@
@CanIgnoreReturnValue
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
public final boolean addAll(Collection<? extends E> newElements) {
throw new UnsupportedOperationException();
}
@@ -623,7 +610,6 @@
@CanIgnoreReturnValue
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
public final boolean removeAll(Collection<?> oldElements) {
throw new UnsupportedOperationException();
}
@@ -637,7 +623,6 @@
@CanIgnoreReturnValue
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
public final boolean retainAll(Collection<?> elementsToKeep) {
throw new UnsupportedOperationException();
}
@@ -650,7 +635,6 @@
*/
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
public final void clear() {
throw new UnsupportedOperationException();
}
@@ -671,11 +655,10 @@
* that is not contained in {@code set1}.
*
* <p>Results are undefined if {@code set1} and {@code set2} are sets based on different
- * equivalence relations, for example if {@code set1} is a {@link HashSet} and {@code set2} is a
- * {@link TreeSet} or the {@link Map#keySet} of an {@code IdentityHashMap}.
+ * equivalence relations (as {@link HashSet}, {@link TreeSet}, and the {@link Map#keySet} of an
+ * {@code IdentityHashMap} all are).
*/
- public static <E extends @Nullable Object> SetView<E> union(
- final Set<? extends E> set1, final Set<? extends E> set2) {
+ public static <E> SetView<E> union(final Set<? extends E> set1, final Set<? extends E> set2) {
checkNotNull(set1, "set1");
checkNotNull(set2, "set2");
@@ -703,7 +686,6 @@
final Iterator<? extends E> itr2 = set2.iterator();
@Override
- @CheckForNull
protected E computeNext() {
if (itr1.hasNext()) {
return itr1.next();
@@ -720,7 +702,7 @@
}
@Override
- public boolean contains(@CheckForNull Object object) {
+ public boolean contains(Object object) {
return set1.contains(object) || set2.contains(object);
}
@@ -732,7 +714,6 @@
}
@Override
- @SuppressWarnings("nullness") // see supertype
public ImmutableSet<E> immutableCopy() {
return new ImmutableSet.Builder<E>().addAll(set1).addAll(set2).build();
}
@@ -745,8 +726,8 @@
* matches that of {@code set1}.
*
* <p>Results are undefined if {@code set1} and {@code set2} are sets based on different
- * equivalence relations, for example if {@code set1} is a {@link HashSet} and {@code set2} is a
- * {@link TreeSet} or the {@link Map#keySet} of an {@code IdentityHashMap}.
+ * equivalence relations (as {@code HashSet}, {@code TreeSet}, and the keySet of an {@code
+ * IdentityHashMap} all are).
*
* <p><b>Note:</b> The returned view performs slightly better when {@code set1} is the smaller of
* the two sets. If you have reason to believe one of your sets will generally be smaller than the
@@ -766,8 +747,7 @@
*
* <p>This is unfortunate, but should come up only very rarely.
*/
- public static <E extends @Nullable Object> SetView<E> intersection(
- final Set<E> set1, final Set<?> set2) {
+ public static <E> SetView<E> intersection(final Set<E> set1, final Set<?> set2) {
checkNotNull(set1, "set1");
checkNotNull(set2, "set2");
@@ -778,7 +758,6 @@
final Iterator<E> itr = set1.iterator();
@Override
- @CheckForNull
protected E computeNext() {
while (itr.hasNext()) {
E e = itr.next();
@@ -808,7 +787,7 @@
}
@Override
- public boolean contains(@CheckForNull Object object) {
+ public boolean contains(Object object) {
return set1.contains(object) && set2.contains(object);
}
@@ -826,11 +805,10 @@
* order of the returned set matches that of {@code set1}.
*
* <p>Results are undefined if {@code set1} and {@code set2} are sets based on different
- * equivalence relations, for example if {@code set1} is a {@link HashSet} and {@code set2} is a
- * {@link TreeSet} or the {@link Map#keySet} of an {@code IdentityHashMap}.
+ * equivalence relations (as {@code HashSet}, {@code TreeSet}, and the keySet of an {@code
+ * IdentityHashMap} all are).
*/
- public static <E extends @Nullable Object> SetView<E> difference(
- final Set<E> set1, final Set<?> set2) {
+ public static <E> SetView<E> difference(final Set<E> set1, final Set<?> set2) {
checkNotNull(set1, "set1");
checkNotNull(set2, "set2");
@@ -841,7 +819,6 @@
final Iterator<E> itr = set1.iterator();
@Override
- @CheckForNull
protected E computeNext() {
while (itr.hasNext()) {
E e = itr.next();
@@ -871,7 +848,7 @@
}
@Override
- public boolean contains(@CheckForNull Object element) {
+ public boolean contains(Object element) {
return set1.contains(element) && !set2.contains(element);
}
};
@@ -883,12 +860,12 @@
* both. The iteration order of the returned set is undefined.
*
* <p>Results are undefined if {@code set1} and {@code set2} are sets based on different
- * equivalence relations, for example if {@code set1} is a {@link HashSet} and {@code set2} is a
- * {@link TreeSet} or the {@link Map#keySet} of an {@code IdentityHashMap}.
+ * equivalence relations (as {@code HashSet}, {@code TreeSet}, and the keySet of an {@code
+ * IdentityHashMap} all are).
*
* @since 3.0
*/
- public static <E extends @Nullable Object> SetView<E> symmetricDifference(
+ public static <E> SetView<E> symmetricDifference(
final Set<? extends E> set1, final Set<? extends E> set2) {
checkNotNull(set1, "set1");
checkNotNull(set2, "set2");
@@ -900,7 +877,6 @@
final Iterator<? extends E> itr2 = set2.iterator();
return new AbstractIterator<E>() {
@Override
- @CheckForNull
public E computeNext() {
while (itr1.hasNext()) {
E elem1 = itr1.next();
@@ -941,7 +917,7 @@
}
@Override
- public boolean contains(@CheckForNull Object element) {
+ public boolean contains(Object element) {
return set1.contains(element) ^ set2.contains(element);
}
};
@@ -974,8 +950,7 @@
* you to migrate to streams.
*/
// TODO(kevinb): how to omit that last sentence when building GWT javadoc?
- public static <E extends @Nullable Object> Set<E> filter(
- Set<E> unfiltered, Predicate<? super E> predicate) {
+ public static <E> Set<E> filter(Set<E> unfiltered, Predicate<? super E> predicate) {
if (unfiltered instanceof SortedSet) {
return filter((SortedSet<E>) unfiltered, predicate);
}
@@ -1014,8 +989,7 @@
*
* @since 11.0
*/
- public static <E extends @Nullable Object> SortedSet<E> filter(
- SortedSet<E> unfiltered, Predicate<? super E> predicate) {
+ public static <E> SortedSet<E> filter(SortedSet<E> unfiltered, Predicate<? super E> predicate) {
if (unfiltered instanceof FilteredSet) {
// Support clear(), removeAll(), and retainAll() when filtering a filtered
// collection.
@@ -1053,7 +1027,7 @@
*/
@GwtIncompatible // NavigableSet
@SuppressWarnings("unchecked")
- public static <E extends @Nullable Object> NavigableSet<E> filter(
+ public static <E> NavigableSet<E> filter(
NavigableSet<E> unfiltered, Predicate<? super E> predicate) {
if (unfiltered instanceof FilteredSet) {
// Support clear(), removeAll(), and retainAll() when filtering a filtered
@@ -1066,14 +1040,13 @@
return new FilteredNavigableSet<E>(checkNotNull(unfiltered), checkNotNull(predicate));
}
- private static class FilteredSet<E extends @Nullable Object> extends FilteredCollection<E>
- implements Set<E> {
+ private static class FilteredSet<E> extends FilteredCollection<E> implements Set<E> {
FilteredSet(Set<E> unfiltered, Predicate<? super E> predicate) {
super(unfiltered, predicate);
}
@Override
- public boolean equals(@CheckForNull Object object) {
+ public boolean equals(@NullableDecl Object object) {
return equalsImpl(this, object);
}
@@ -1083,43 +1056,39 @@
}
}
- private static class FilteredSortedSet<E extends @Nullable Object> extends FilteredSet<E>
- implements SortedSet<E> {
+ private static class FilteredSortedSet<E> extends FilteredSet<E> implements SortedSet<E> {
FilteredSortedSet(SortedSet<E> unfiltered, Predicate<? super E> predicate) {
super(unfiltered, predicate);
}
@Override
- @CheckForNull
public Comparator<? super E> comparator() {
return ((SortedSet<E>) unfiltered).comparator();
}
@Override
- public SortedSet<E> subSet(@ParametricNullness E fromElement, @ParametricNullness E toElement) {
+ public SortedSet<E> subSet(E fromElement, E toElement) {
return new FilteredSortedSet<E>(
((SortedSet<E>) unfiltered).subSet(fromElement, toElement), predicate);
}
@Override
- public SortedSet<E> headSet(@ParametricNullness E toElement) {
+ public SortedSet<E> headSet(E toElement) {
return new FilteredSortedSet<E>(((SortedSet<E>) unfiltered).headSet(toElement), predicate);
}
@Override
- public SortedSet<E> tailSet(@ParametricNullness E fromElement) {
+ public SortedSet<E> tailSet(E fromElement) {
return new FilteredSortedSet<E>(((SortedSet<E>) unfiltered).tailSet(fromElement), predicate);
}
@Override
- @ParametricNullness
public E first() {
return Iterators.find(unfiltered.iterator(), predicate);
}
@Override
- @ParametricNullness
public E last() {
SortedSet<E> sortedUnfiltered = (SortedSet<E>) unfiltered;
while (true) {
@@ -1133,7 +1102,7 @@
}
@GwtIncompatible // NavigableSet
- private static class FilteredNavigableSet<E extends @Nullable Object> extends FilteredSortedSet<E>
+ private static class FilteredNavigableSet<E> extends FilteredSortedSet<E>
implements NavigableSet<E> {
FilteredNavigableSet(NavigableSet<E> unfiltered, Predicate<? super E> predicate) {
super(unfiltered, predicate);
@@ -1144,37 +1113,33 @@
}
@Override
- @CheckForNull
- public E lower(@ParametricNullness E e) {
+ @NullableDecl
+ public E lower(E e) {
return Iterators.find(unfiltered().headSet(e, false).descendingIterator(), predicate, null);
}
@Override
- @CheckForNull
- public E floor(@ParametricNullness E e) {
+ @NullableDecl
+ public E floor(E e) {
return Iterators.find(unfiltered().headSet(e, true).descendingIterator(), predicate, null);
}
@Override
- @CheckForNull
- public E ceiling(@ParametricNullness E e) {
+ public E ceiling(E e) {
return Iterables.find(unfiltered().tailSet(e, true), predicate, null);
}
@Override
- @CheckForNull
- public E higher(@ParametricNullness E e) {
+ public E higher(E e) {
return Iterables.find(unfiltered().tailSet(e, false), predicate, null);
}
@Override
- @CheckForNull
public E pollFirst() {
return Iterables.removeFirstMatching(unfiltered(), predicate);
}
@Override
- @CheckForNull
public E pollLast() {
return Iterables.removeFirstMatching(unfiltered().descendingSet(), predicate);
}
@@ -1190,28 +1155,24 @@
}
@Override
- @ParametricNullness
public E last() {
return Iterators.find(unfiltered().descendingIterator(), predicate);
}
@Override
public NavigableSet<E> subSet(
- @ParametricNullness E fromElement,
- boolean fromInclusive,
- @ParametricNullness E toElement,
- boolean toInclusive) {
+ E fromElement, boolean fromInclusive, E toElement, boolean toInclusive) {
return filter(
unfiltered().subSet(fromElement, fromInclusive, toElement, toInclusive), predicate);
}
@Override
- public NavigableSet<E> headSet(@ParametricNullness E toElement, boolean inclusive) {
+ public NavigableSet<E> headSet(E toElement, boolean inclusive) {
return filter(unfiltered().headSet(toElement, inclusive), predicate);
}
@Override
- public NavigableSet<E> tailSet(@ParametricNullness E fromElement, boolean inclusive) {
+ public NavigableSet<E> tailSet(E fromElement, boolean inclusive) {
return filter(unfiltered().tailSet(fromElement, inclusive), predicate);
}
}
@@ -1377,7 +1338,7 @@
}
@Override
- public boolean contains(@CheckForNull Object object) {
+ public boolean contains(@NullableDecl Object object) {
if (!(object instanceof List)) {
return false;
}
@@ -1396,7 +1357,7 @@
}
@Override
- public boolean equals(@CheckForNull Object object) {
+ public boolean equals(@NullableDecl 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) {
@@ -1496,7 +1457,7 @@
}
@Override
- public boolean contains(@CheckForNull Object o) {
+ public boolean contains(@NullableDecl Object o) {
Integer index = inputSet.get(o);
return index != null && (mask & (1 << index)) != 0;
}
@@ -1532,7 +1493,7 @@
}
@Override
- public boolean contains(@CheckForNull Object obj) {
+ public boolean contains(@NullableDecl Object obj) {
if (obj instanceof Set) {
Set<?> set = (Set<?>) obj;
return inputSet.keySet().containsAll(set);
@@ -1541,7 +1502,7 @@
}
@Override
- public boolean equals(@CheckForNull Object obj) {
+ public boolean equals(@NullableDecl Object obj) {
if (obj instanceof PowerSet) {
PowerSet<?> that = (PowerSet<?>) obj;
return inputSet.keySet().equals(that.inputSet.keySet());
@@ -1601,7 +1562,7 @@
}
return new AbstractSet<Set<E>>() {
@Override
- public boolean contains(@CheckForNull Object o) {
+ public boolean contains(@NullableDecl Object o) {
if (o instanceof Set) {
Set<?> s = (Set<?>) o;
return s.size() == size && index.keySet().containsAll(s);
@@ -1615,7 +1576,6 @@
final BitSet bits = new BitSet(index.size());
@Override
- @CheckForNull
protected Set<E> computeNext() {
if (bits.isEmpty()) {
bits.set(0, size);
@@ -1646,7 +1606,7 @@
final BitSet copy = (BitSet) bits.clone();
return new AbstractSet<E>() {
@Override
- public boolean contains(@CheckForNull Object o) {
+ public boolean contains(@NullableDecl Object o) {
Integer i = index.get(o);
return i != null && copy.get(i);
}
@@ -1657,7 +1617,6 @@
int i = -1;
@Override
- @CheckForNull
protected E computeNext() {
i = copy.nextSetBit(i + 1);
if (i == -1) {
@@ -1702,7 +1661,7 @@
}
/** An implementation for {@link Set#equals(Object)}. */
- static boolean equalsImpl(Set<?> s, @CheckForNull Object object) {
+ static boolean equalsImpl(Set<?> s, @NullableDecl Object object) {
if (s == object) {
return true;
}
@@ -1731,16 +1690,15 @@
* @return an unmodifiable view of the specified navigable set
* @since 12.0
*/
- public static <E extends @Nullable Object> NavigableSet<E> unmodifiableNavigableSet(
- NavigableSet<E> set) {
+ public static <E> NavigableSet<E> unmodifiableNavigableSet(NavigableSet<E> set) {
if (set instanceof ImmutableCollection || set instanceof UnmodifiableNavigableSet) {
return set;
}
return new UnmodifiableNavigableSet<E>(set);
}
- static final class UnmodifiableNavigableSet<E extends @Nullable Object>
- extends ForwardingSortedSet<E> implements NavigableSet<E>, Serializable {
+ static final class UnmodifiableNavigableSet<E> extends ForwardingSortedSet<E>
+ implements NavigableSet<E>, Serializable {
private final NavigableSet<E> delegate;
private final SortedSet<E> unmodifiableDelegate;
@@ -1755,42 +1713,36 @@
}
@Override
- @CheckForNull
- public E lower(@ParametricNullness E e) {
+ public E lower(E e) {
return delegate.lower(e);
}
@Override
- @CheckForNull
- public E floor(@ParametricNullness E e) {
+ public E floor(E e) {
return delegate.floor(e);
}
@Override
- @CheckForNull
- public E ceiling(@ParametricNullness E e) {
+ public E ceiling(E e) {
return delegate.ceiling(e);
}
@Override
- @CheckForNull
- public E higher(@ParametricNullness E e) {
+ public E higher(E e) {
return delegate.higher(e);
}
@Override
- @CheckForNull
public E pollFirst() {
throw new UnsupportedOperationException();
}
@Override
- @CheckForNull
public E pollLast() {
throw new UnsupportedOperationException();
}
- @CheckForNull private transient UnmodifiableNavigableSet<E> descendingSet;
+ @NullableDecl private transient UnmodifiableNavigableSet<E> descendingSet;
@Override
public NavigableSet<E> descendingSet() {
@@ -1809,21 +1761,18 @@
@Override
public NavigableSet<E> subSet(
- @ParametricNullness E fromElement,
- boolean fromInclusive,
- @ParametricNullness E toElement,
- boolean toInclusive) {
+ E fromElement, boolean fromInclusive, E toElement, boolean toInclusive) {
return unmodifiableNavigableSet(
delegate.subSet(fromElement, fromInclusive, toElement, toInclusive));
}
@Override
- public NavigableSet<E> headSet(@ParametricNullness E toElement, boolean inclusive) {
+ public NavigableSet<E> headSet(E toElement, boolean inclusive) {
return unmodifiableNavigableSet(delegate.headSet(toElement, inclusive));
}
@Override
- public NavigableSet<E> tailSet(@ParametricNullness E fromElement, boolean inclusive) {
+ public NavigableSet<E> tailSet(E fromElement, boolean inclusive) {
return unmodifiableNavigableSet(delegate.tailSet(fromElement, inclusive));
}
@@ -1876,8 +1825,7 @@
* @since 13.0
*/
@GwtIncompatible // NavigableSet
- public static <E extends @Nullable Object> NavigableSet<E> synchronizedNavigableSet(
- NavigableSet<E> navigableSet) {
+ public static <E> NavigableSet<E> synchronizedNavigableSet(NavigableSet<E> navigableSet) {
return Synchronized.navigableSet(navigableSet);
}
@@ -1910,7 +1858,7 @@
}
@GwtIncompatible // NavigableSet
- static class DescendingSet<E extends @Nullable Object> extends ForwardingNavigableSet<E> {
+ static class DescendingSet<E> extends ForwardingNavigableSet<E> {
private final NavigableSet<E> forward;
DescendingSet(NavigableSet<E> forward) {
@@ -1923,37 +1871,31 @@
}
@Override
- @CheckForNull
- public E lower(@ParametricNullness E e) {
+ public E lower(E e) {
return forward.higher(e);
}
@Override
- @CheckForNull
- public E floor(@ParametricNullness E e) {
+ public E floor(E e) {
return forward.ceiling(e);
}
@Override
- @CheckForNull
- public E ceiling(@ParametricNullness E e) {
+ public E ceiling(E e) {
return forward.floor(e);
}
@Override
- @CheckForNull
- public E higher(@ParametricNullness E e) {
+ public E higher(E e) {
return forward.lower(e);
}
@Override
- @CheckForNull
public E pollFirst() {
return forward.pollLast();
}
@Override
- @CheckForNull
public E pollLast() {
return forward.pollFirst();
}
@@ -1970,35 +1912,32 @@
@Override
public NavigableSet<E> subSet(
- @ParametricNullness E fromElement,
- boolean fromInclusive,
- @ParametricNullness E toElement,
- boolean toInclusive) {
+ E fromElement, boolean fromInclusive, E toElement, boolean toInclusive) {
return forward.subSet(toElement, toInclusive, fromElement, fromInclusive).descendingSet();
}
@Override
- public SortedSet<E> subSet(@ParametricNullness E fromElement, @ParametricNullness E toElement) {
+ public SortedSet<E> subSet(E fromElement, E toElement) {
return standardSubSet(fromElement, toElement);
}
@Override
- public NavigableSet<E> headSet(@ParametricNullness E toElement, boolean inclusive) {
+ public NavigableSet<E> headSet(E toElement, boolean inclusive) {
return forward.tailSet(toElement, inclusive).descendingSet();
}
@Override
- public SortedSet<E> headSet(@ParametricNullness E toElement) {
+ public SortedSet<E> headSet(E toElement) {
return standardHeadSet(toElement);
}
@Override
- public NavigableSet<E> tailSet(@ParametricNullness E fromElement, boolean inclusive) {
+ public NavigableSet<E> tailSet(E fromElement, boolean inclusive) {
return forward.headSet(fromElement, inclusive).descendingSet();
}
@Override
- public SortedSet<E> tailSet(@ParametricNullness E fromElement) {
+ public SortedSet<E> tailSet(E fromElement) {
return standardTailSet(fromElement);
}
@@ -2014,18 +1953,16 @@
}
// If we inline this, we get a javac error.
- private static <T extends @Nullable Object> Ordering<T> reverse(Comparator<T> forward) {
+ private static <T> Ordering<T> reverse(Comparator<T> forward) {
return Ordering.from(forward).reverse();
}
@Override
- @ParametricNullness
public E first() {
return forward.last();
}
@Override
- @ParametricNullness
public E last() {
return forward.first();
}
@@ -2036,13 +1973,12 @@
}
@Override
- public @Nullable Object[] toArray() {
+ public Object[] toArray() {
return standardToArray();
}
@Override
- @SuppressWarnings("nullness") // b/192354773 in our checker affects toArray declarations
- public <T extends @Nullable Object> T[] toArray(T[] array) {
+ public <T> T[] toArray(T[] array) {
return standardToArray(array);
}
diff --git a/android/guava/src/com/google/common/collect/SingletonImmutableSet.java b/android/guava/src/com/google/common/collect/SingletonImmutableSet.java
index 088cb80..0f882b3 100644
--- a/android/guava/src/com/google/common/collect/SingletonImmutableSet.java
+++ b/android/guava/src/com/google/common/collect/SingletonImmutableSet.java
@@ -18,8 +18,7 @@
import com.google.common.annotations.GwtCompatible;
import com.google.common.base.Preconditions;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import com.google.errorprone.annotations.concurrent.LazyInit;
/**
* Implementation of {@link ImmutableSet} with exactly one element.
@@ -29,24 +28,35 @@
*/
@GwtCompatible(serializable = true, emulated = true)
@SuppressWarnings("serial") // uses writeReplace(), not default serialization
-@ElementTypesAreNonnullByDefault
final class SingletonImmutableSet<E> extends ImmutableSet<E> {
- // We deliberately avoid caching the asList and hashCode here, to ensure that with
- // compressed oops, a SingletonImmutableSet packs all the way down to the optimal 16 bytes.
final transient E element;
+ // This is transient because it will be recalculated on the first
+ // call to hashCode().
+ //
+ // A race condition is avoided since threads will either see that the value
+ // is zero and recalculate it themselves, or two threads will see it at
+ // the same time, and both recalculate it. If the cachedHashCode is 0,
+ // it will always be recalculated, unfortunately.
+ @LazyInit private transient int cachedHashCode;
SingletonImmutableSet(E element) {
this.element = Preconditions.checkNotNull(element);
}
+ SingletonImmutableSet(E element, int hashCode) {
+ // Guaranteed to be non-null by the presence of the pre-computed hash code.
+ this.element = element;
+ cachedHashCode = hashCode;
+ }
+
@Override
public int size() {
return 1;
}
@Override
- public boolean contains(@CheckForNull Object target) {
+ public boolean contains(Object target) {
return element.equals(target);
}
@@ -56,7 +66,7 @@
}
@Override
- public ImmutableList<E> asList() {
+ ImmutableList<E> createAsList() {
return ImmutableList.of(element);
}
@@ -66,14 +76,24 @@
}
@Override
- int copyIntoArray(@Nullable Object[] dst, int offset) {
+ int copyIntoArray(Object[] dst, int offset) {
dst[offset] = element;
return offset + 1;
}
@Override
public final int hashCode() {
- return element.hashCode();
+ // Racy single-check.
+ int code = cachedHashCode;
+ if (code == 0) {
+ cachedHashCode = code = element.hashCode();
+ }
+ return code;
+ }
+
+ @Override
+ boolean isHashCodeFast() {
+ return cachedHashCode != 0;
}
@Override
diff --git a/android/guava/src/com/google/common/collect/SingletonImmutableTable.java b/android/guava/src/com/google/common/collect/SingletonImmutableTable.java
index cfaeadb..58a182c 100644
--- a/android/guava/src/com/google/common/collect/SingletonImmutableTable.java
+++ b/android/guava/src/com/google/common/collect/SingletonImmutableTable.java
@@ -27,7 +27,6 @@
* @author Gregory Kick
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
class SingletonImmutableTable<R, C, V> extends ImmutableTable<R, C, V> {
final R singleRowKey;
final C singleColumnKey;
diff --git a/android/guava/src/com/google/common/collect/SortedIterable.java b/android/guava/src/com/google/common/collect/SortedIterable.java
index 64ec08e..d46e8af 100644
--- a/android/guava/src/com/google/common/collect/SortedIterable.java
+++ b/android/guava/src/com/google/common/collect/SortedIterable.java
@@ -17,7 +17,6 @@
import com.google.common.annotations.GwtCompatible;
import java.util.Comparator;
import java.util.Iterator;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* An {@code Iterable} whose elements are sorted relative to a {@code Comparator}, typically
@@ -26,8 +25,7 @@
* @author Louis Wasserman
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-interface SortedIterable<T extends @Nullable Object> extends Iterable<T> {
+interface SortedIterable<T> extends Iterable<T> {
/**
* Returns the {@code Comparator} by which the elements of this iterable are ordered, or {@code
* Ordering.natural()} if the elements are ordered by their natural ordering.
diff --git a/android/guava/src/com/google/common/collect/SortedIterables.java b/android/guava/src/com/google/common/collect/SortedIterables.java
index 68b231a..2c0aa7c 100644
--- a/android/guava/src/com/google/common/collect/SortedIterables.java
+++ b/android/guava/src/com/google/common/collect/SortedIterables.java
@@ -19,7 +19,6 @@
import com.google.common.annotations.GwtCompatible;
import java.util.Comparator;
import java.util.SortedSet;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Utilities for dealing with sorted collections of all types.
@@ -27,7 +26,6 @@
* @author Louis Wasserman
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
final class SortedIterables {
private SortedIterables() {}
@@ -51,8 +49,7 @@
@SuppressWarnings("unchecked")
// if sortedSet.comparator() is null, the set must be naturally ordered
- public static <E extends @Nullable Object> Comparator<? super E> comparator(
- SortedSet<E> sortedSet) {
+ public static <E> Comparator<? super E> comparator(SortedSet<E> sortedSet) {
Comparator<? super E> result = sortedSet.comparator();
if (result == null) {
result = (Comparator<? super E>) Ordering.natural();
diff --git a/android/guava/src/com/google/common/collect/SortedLists.java b/android/guava/src/com/google/common/collect/SortedLists.java
index 0ebaab2..67c5a3b 100644
--- a/android/guava/src/com/google/common/collect/SortedLists.java
+++ b/android/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.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* Static methods pertaining to sorted {@link List} instances.
@@ -35,38 +35,29 @@
* @author Louis Wasserman
*/
@GwtCompatible
-@Beta
-@ElementTypesAreNonnullByDefault
-final class SortedLists {
+@Beta final class SortedLists {
private SortedLists() {}
/**
* A specification for which index to return if the list contains at least one element that
* compares as equal to the key.
- */
- enum KeyPresentBehavior {
+ */ enum KeyPresentBehavior {
/**
* Return the index of any list element that compares as equal to the key. No guarantees are
* made as to which index is returned, if more than one element compares as equal to the key.
*/
ANY_PRESENT {
@Override
- <E extends @Nullable Object> int resultIndex(
- Comparator<? super E> comparator,
- @ParametricNullness E key,
- List<? extends E> list,
- int foundIndex) {
+ <E> int resultIndex(
+ Comparator<? super E> comparator, E key, List<? extends E> list, int foundIndex) {
return foundIndex;
}
},
/** Return the index of the last list element that compares as equal to the key. */
LAST_PRESENT {
@Override
- <E extends @Nullable Object> int resultIndex(
- Comparator<? super E> comparator,
- @ParametricNullness E key,
- List<? extends E> list,
- int foundIndex) {
+ <E> int resultIndex(
+ Comparator<? super E> comparator, E key, List<? extends E> list, int foundIndex) {
// Of course, we have to use binary search to find the precise
// breakpoint...
int lower = foundIndex;
@@ -87,11 +78,8 @@
/** Return the index of the first list element that compares as equal to the key. */
FIRST_PRESENT {
@Override
- <E extends @Nullable Object> int resultIndex(
- Comparator<? super E> comparator,
- @ParametricNullness E key,
- List<? extends E> list,
- int foundIndex) {
+ <E> int resultIndex(
+ Comparator<? super E> comparator, E key, List<? extends E> list, int foundIndex) {
// Of course, we have to use binary search to find the precise
// breakpoint...
int lower = 0;
@@ -116,11 +104,8 @@
*/
FIRST_AFTER {
@Override
- public <E extends @Nullable Object> int resultIndex(
- Comparator<? super E> comparator,
- @ParametricNullness E key,
- List<? extends E> list,
- int foundIndex) {
+ public <E> int resultIndex(
+ Comparator<? super E> comparator, E key, List<? extends E> list, int foundIndex) {
return LAST_PRESENT.resultIndex(comparator, key, list, foundIndex) + 1;
}
},
@@ -130,27 +115,20 @@
*/
LAST_BEFORE {
@Override
- public <E extends @Nullable Object> int resultIndex(
- Comparator<? super E> comparator,
- @ParametricNullness E key,
- List<? extends E> list,
- int foundIndex) {
+ public <E> int resultIndex(
+ Comparator<? super E> comparator, E key, List<? extends E> list, int foundIndex) {
return FIRST_PRESENT.resultIndex(comparator, key, list, foundIndex) - 1;
}
};
- abstract <E extends @Nullable Object> int resultIndex(
- Comparator<? super E> comparator,
- @ParametricNullness E key,
- List<? extends E> list,
- int foundIndex);
+ abstract <E> int resultIndex(
+ Comparator<? super E> comparator, E key, List<? extends E> list, int foundIndex);
}
/**
* A specification for which index to return if the list contains no elements that compare as
* equal to the key.
- */
- enum KeyAbsentBehavior {
+ */ enum KeyAbsentBehavior {
/**
* Return the index of the next lower element in the list, or {@code -1} if there is no such
* element.
@@ -215,13 +193,12 @@
* <p>Equivalent to {@link #binarySearch(List, Function, Object, Comparator, KeyPresentBehavior,
* KeyAbsentBehavior)} using {@link Ordering#natural}.
*/
- public static <E extends @Nullable Object, K extends Comparable> int binarySearch(
+ public static <E, K extends Comparable> int binarySearch(
List<E> list,
Function<? super E, K> keyFunction,
- K key,
+ @NullableDecl K key,
KeyPresentBehavior presentBehavior,
KeyAbsentBehavior absentBehavior) {
- checkNotNull(key);
return binarySearch(
list, keyFunction, key, Ordering.natural(), presentBehavior, absentBehavior);
}
@@ -233,10 +210,10 @@
* KeyAbsentBehavior)} using {@link Lists#transform(List, Function) Lists.transform(list,
* keyFunction)}.
*/
- public static <E extends @Nullable Object, K extends @Nullable Object> int binarySearch(
+ public static <E, K> int binarySearch(
List<E> list,
Function<? super E, K> keyFunction,
- @ParametricNullness K key,
+ @NullableDecl K key,
Comparator<? super K> keyComparator,
KeyPresentBehavior presentBehavior,
KeyAbsentBehavior absentBehavior) {
@@ -267,9 +244,9 @@
* @return the index determined by the {@code KeyPresentBehavior}, if the key is in the list;
* otherwise the index determined by the {@code KeyAbsentBehavior}.
*/
- public static <E extends @Nullable Object> int binarySearch(
+ public static <E> int binarySearch(
List<? extends E> list,
- @ParametricNullness E key,
+ @NullableDecl E key,
Comparator<? super E> comparator,
KeyPresentBehavior presentBehavior,
KeyAbsentBehavior absentBehavior) {
diff --git a/android/guava/src/com/google/common/collect/SortedMapDifference.java b/android/guava/src/com/google/common/collect/SortedMapDifference.java
index 46cac8a..4715e93 100644
--- a/android/guava/src/com/google/common/collect/SortedMapDifference.java
+++ b/android/guava/src/com/google/common/collect/SortedMapDifference.java
@@ -18,7 +18,6 @@
import com.google.common.annotations.GwtCompatible;
import java.util.SortedMap;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* An object representing the differences between two sorted maps.
@@ -27,9 +26,7 @@
* @since 8.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-public interface SortedMapDifference<K extends @Nullable Object, V extends @Nullable Object>
- extends MapDifference<K, V> {
+public interface SortedMapDifference<K, V> extends MapDifference<K, V> {
@Override
SortedMap<K, V> entriesOnlyOnLeft();
diff --git a/android/guava/src/com/google/common/collect/SortedMultiset.java b/android/guava/src/com/google/common/collect/SortedMultiset.java
index 68932f5..2635b37 100644
--- a/android/guava/src/com/google/common/collect/SortedMultiset.java
+++ b/android/guava/src/com/google/common/collect/SortedMultiset.java
@@ -22,8 +22,6 @@
import java.util.Iterator;
import java.util.NavigableSet;
import java.util.Set;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* A {@link Multiset} which maintains the ordering of its elements, according to either their
@@ -44,9 +42,7 @@
* @since 11.0
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
-public interface SortedMultiset<E extends @Nullable Object>
- extends SortedMultisetBridge<E>, SortedIterable<E> {
+public interface SortedMultiset<E> extends SortedMultisetBridge<E>, SortedIterable<E> {
/**
* Returns the comparator that orders this multiset, or {@link Ordering#natural()} if the natural
* ordering of the elements is used.
@@ -58,28 +54,24 @@
* Returns the entry of the first element in this multiset, or {@code null} if this multiset is
* empty.
*/
- @CheckForNull
Entry<E> firstEntry();
/**
* Returns the entry of the last element in this multiset, or {@code null} if this multiset is
* empty.
*/
- @CheckForNull
Entry<E> lastEntry();
/**
* Returns and removes the entry associated with the lowest element in this multiset, or returns
* {@code null} if this multiset is empty.
*/
- @CheckForNull
Entry<E> pollFirstEntry();
/**
* Returns and removes the entry associated with the greatest element in this multiset, or returns
* {@code null} if this multiset is empty.
*/
- @CheckForNull
Entry<E> pollLastEntry();
/**
@@ -123,7 +115,7 @@
* <p>The returned multiset will throw an {@link IllegalArgumentException} on attempts to add
* elements outside its range.
*/
- SortedMultiset<E> headMultiset(@ParametricNullness E upperBound, BoundType boundType);
+ SortedMultiset<E> headMultiset(E upperBound, BoundType boundType);
/**
* Returns a view of this multiset restricted to the range between {@code lowerBound} and {@code
@@ -138,10 +130,7 @@
* lowerBoundType).headMultiset(upperBound, upperBoundType)}.
*/
SortedMultiset<E> subMultiset(
- @ParametricNullness E lowerBound,
- BoundType lowerBoundType,
- @ParametricNullness E upperBound,
- BoundType upperBoundType);
+ E lowerBound, BoundType lowerBoundType, E upperBound, BoundType upperBoundType);
/**
* Returns a view of this multiset restricted to the elements greater than {@code lowerBound},
@@ -152,5 +141,5 @@
* <p>The returned multiset will throw an {@link IllegalArgumentException} on attempts to add
* elements outside its range.
*/
- SortedMultiset<E> tailMultiset(@ParametricNullness E lowerBound, BoundType boundType);
+ SortedMultiset<E> tailMultiset(E lowerBound, BoundType boundType);
}
diff --git a/android/guava/src/com/google/common/collect/SortedMultisetBridge.java b/android/guava/src/com/google/common/collect/SortedMultisetBridge.java
index 72d50be..064cb75 100644
--- a/android/guava/src/com/google/common/collect/SortedMultisetBridge.java
+++ b/android/guava/src/com/google/common/collect/SortedMultisetBridge.java
@@ -18,7 +18,6 @@
import com.google.common.annotations.GwtIncompatible;
import java.util.SortedSet;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Superinterface of {@link SortedMultiset} to introduce a bridge method for {@code elementSet()},
@@ -28,8 +27,7 @@
* @author Louis Wasserman
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
-interface SortedMultisetBridge<E extends @Nullable Object> extends Multiset<E> {
+interface SortedMultisetBridge<E> extends Multiset<E> {
@Override
SortedSet<E> elementSet();
}
diff --git a/android/guava/src/com/google/common/collect/SortedMultisets.java b/android/guava/src/com/google/common/collect/SortedMultisets.java
index 1d1940c..3c45c9f 100644
--- a/android/guava/src/com/google/common/collect/SortedMultisets.java
+++ b/android/guava/src/com/google/common/collect/SortedMultisets.java
@@ -28,8 +28,7 @@
import java.util.NavigableSet;
import java.util.NoSuchElementException;
import java.util.SortedSet;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* Provides static utility methods for creating and working with {@link SortedMultiset} instances.
@@ -37,14 +36,11 @@
* @author Louis Wasserman
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
final class SortedMultisets {
private SortedMultisets() {}
/** A skeleton implementation for {@link SortedMultiset#elementSet}. */
- @SuppressWarnings("JdkObsolete") // TODO(b/6160855): Switch GWT emulations to NavigableSet.
- static class ElementSet<E extends @Nullable Object> extends Multisets.ElementSet<E>
- implements SortedSet<E> {
+ static class ElementSet<E> extends Multisets.ElementSet<E> implements SortedSet<E> {
@Weak private final SortedMultiset<E> multiset;
ElementSet(SortedMultiset<E> multiset) {
@@ -67,28 +63,26 @@
}
@Override
- public SortedSet<E> subSet(@ParametricNullness E fromElement, @ParametricNullness E toElement) {
+ public SortedSet<E> subSet(E fromElement, E toElement) {
return multiset().subMultiset(fromElement, CLOSED, toElement, OPEN).elementSet();
}
@Override
- public SortedSet<E> headSet(@ParametricNullness E toElement) {
+ public SortedSet<E> headSet(E toElement) {
return multiset().headMultiset(toElement, OPEN).elementSet();
}
@Override
- public SortedSet<E> tailSet(@ParametricNullness E fromElement) {
+ public SortedSet<E> tailSet(E fromElement) {
return multiset().tailMultiset(fromElement, CLOSED).elementSet();
}
@Override
- @ParametricNullness
public E first() {
return getElementOrThrow(multiset().firstEntry());
}
@Override
- @ParametricNullness
public E last() {
return getElementOrThrow(multiset().lastEntry());
}
@@ -96,33 +90,28 @@
/** A skeleton navigable implementation for {@link SortedMultiset#elementSet}. */
@GwtIncompatible // Navigable
- static class NavigableElementSet<E extends @Nullable Object> extends ElementSet<E>
- implements NavigableSet<E> {
+ static class NavigableElementSet<E> extends ElementSet<E> implements NavigableSet<E> {
NavigableElementSet(SortedMultiset<E> multiset) {
super(multiset);
}
@Override
- @CheckForNull
- public E lower(@ParametricNullness E e) {
+ public E lower(E e) {
return getElementOrNull(multiset().headMultiset(e, OPEN).lastEntry());
}
@Override
- @CheckForNull
- public E floor(@ParametricNullness E e) {
+ public E floor(E e) {
return getElementOrNull(multiset().headMultiset(e, CLOSED).lastEntry());
}
@Override
- @CheckForNull
- public E ceiling(@ParametricNullness E e) {
+ public E ceiling(E e) {
return getElementOrNull(multiset().tailMultiset(e, CLOSED).firstEntry());
}
@Override
- @CheckForNull
- public E higher(@ParametricNullness E e) {
+ public E higher(E e) {
return getElementOrNull(multiset().tailMultiset(e, OPEN).firstEntry());
}
@@ -137,23 +126,18 @@
}
@Override
- @CheckForNull
public E pollFirst() {
return getElementOrNull(multiset().pollFirstEntry());
}
@Override
- @CheckForNull
public E pollLast() {
return getElementOrNull(multiset().pollLastEntry());
}
@Override
public NavigableSet<E> subSet(
- @ParametricNullness E fromElement,
- boolean fromInclusive,
- @ParametricNullness E toElement,
- boolean toInclusive) {
+ E fromElement, boolean fromInclusive, E toElement, boolean toInclusive) {
return new NavigableElementSet<E>(
multiset()
.subMultiset(
@@ -162,27 +146,26 @@
}
@Override
- public NavigableSet<E> headSet(@ParametricNullness E toElement, boolean inclusive) {
+ public NavigableSet<E> headSet(E toElement, boolean inclusive) {
return new NavigableElementSet<E>(
multiset().headMultiset(toElement, BoundType.forBoolean(inclusive)));
}
@Override
- public NavigableSet<E> tailSet(@ParametricNullness E fromElement, boolean inclusive) {
+ public NavigableSet<E> tailSet(E fromElement, boolean inclusive) {
return new NavigableElementSet<E>(
multiset().tailMultiset(fromElement, BoundType.forBoolean(inclusive)));
}
}
- private static <E extends @Nullable Object> E getElementOrThrow(@CheckForNull Entry<E> entry) {
+ private static <E> E getElementOrThrow(Entry<E> entry) {
if (entry == null) {
throw new NoSuchElementException();
}
return entry.getElement();
}
- @CheckForNull
- private static <E extends @Nullable Object> E getElementOrNull(@CheckForNull Entry<E> entry) {
+ private static <E> E getElementOrNull(@NullableDecl Entry<E> entry) {
return (entry == null) ? null : entry.getElement();
}
}
diff --git a/android/guava/src/com/google/common/collect/SortedSetMultimap.java b/android/guava/src/com/google/common/collect/SortedSetMultimap.java
index 8449014..33be3d0 100644
--- a/android/guava/src/com/google/common/collect/SortedSetMultimap.java
+++ b/android/guava/src/com/google/common/collect/SortedSetMultimap.java
@@ -24,8 +24,7 @@
import java.util.Set;
import java.util.SortedMap;
import java.util.SortedSet;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* A {@code SetMultimap} whose set of values for a given key are kept sorted; that is, they comprise
@@ -38,10 +37,6 @@
* Though the method signature doesn't say so explicitly, the map returned by {@link #asMap} has
* {@code SortedSet} values.
*
- * <p><b>Warning:</b> As in all {@link SetMultimap}s, do not modify either a key <i>or a value</i>
- * of a {@code SortedSetMultimap} in a way that affects its {@link Object#equals} behavior (or its
- * position in the order of the values). Undefined behavior and bugs will result.
- *
* <p>See the Guava User Guide article on <a href=
* "https://github.com/google/guava/wiki/NewCollectionTypesExplained#multimap"> {@code
* Multimap}</a>.
@@ -50,9 +45,7 @@
* @since 2.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-public interface SortedSetMultimap<K extends @Nullable Object, V extends @Nullable Object>
- extends SetMultimap<K, V> {
+public interface SortedSetMultimap<K, V> extends SetMultimap<K, V> {
// Following Javadoc copied from Multimap.
/**
@@ -66,7 +59,7 @@
* {@link Multimap} interface.
*/
@Override
- SortedSet<V> get(@ParametricNullness K key);
+ SortedSet<V> get(@NullableDecl K key);
/**
* Removes all values associated with a given key.
@@ -77,7 +70,7 @@
*/
@CanIgnoreReturnValue
@Override
- SortedSet<V> removeAll(@CheckForNull Object key);
+ SortedSet<V> removeAll(@NullableDecl Object key);
/**
* Stores a collection of values with the same key, replacing any existing values for that key.
@@ -90,7 +83,7 @@
*/
@CanIgnoreReturnValue
@Override
- SortedSet<V> replaceValues(@ParametricNullness K key, Iterable<? extends V> values);
+ SortedSet<V> replaceValues(K key, Iterable<? extends V> values);
/**
* Returns a map view that associates each key with the corresponding values in the multimap.
@@ -116,6 +109,5 @@
* Returns the comparator that orders the multimap values, with {@code null} indicating that
* natural ordering is used.
*/
- @CheckForNull
Comparator<? super V> valueComparator();
}
diff --git a/android/guava/src/com/google/common/collect/SparseImmutableTable.java b/android/guava/src/com/google/common/collect/SparseImmutableTable.java
index b314f7b..a7fe85d 100644
--- a/android/guava/src/com/google/common/collect/SparseImmutableTable.java
+++ b/android/guava/src/com/google/common/collect/SparseImmutableTable.java
@@ -14,8 +14,6 @@
package com.google.common.collect;
-import static java.util.Objects.requireNonNull;
-
import com.google.common.annotations.GwtCompatible;
import com.google.errorprone.annotations.Immutable;
import java.util.LinkedHashMap;
@@ -25,7 +23,6 @@
/** A {@code RegularImmutableTable} optimized for sparse data. */
@GwtCompatible
@Immutable(containerOf = {"R", "C", "V"})
-@ElementTypesAreNonnullByDefault
final class SparseImmutableTable<R, C, V> extends RegularImmutableTable<R, C, V> {
static final ImmutableTable<Object, Object, Object> EMPTY =
new SparseImmutableTable<>(
@@ -64,16 +61,12 @@
C columnKey = cell.getColumnKey();
V value = cell.getValue();
- /*
- * These requireNonNull calls are safe because we construct the maps to hold all the provided
- * cells.
- */
- cellRowIndices[i] = requireNonNull(rowIndex.get(rowKey));
- Map<C, V> thisRow = requireNonNull(rows.get(rowKey));
+ cellRowIndices[i] = rowIndex.get(rowKey);
+ Map<C, V> thisRow = rows.get(rowKey);
cellColumnInRowIndices[i] = thisRow.size();
V oldValue = thisRow.put(columnKey, value);
checkNoDuplicate(rowKey, columnKey, oldValue, value);
- requireNonNull(columns.get(columnKey)).put(rowKey, value);
+ columns.get(columnKey).put(rowKey, value);
}
this.cellRowIndices = cellRowIndices;
this.cellColumnInRowIndices = cellColumnInRowIndices;
@@ -135,8 +128,7 @@
int[] cellColumnIndices = new int[cellSet().size()];
int i = 0;
for (Cell<R, C, V> cell : cellSet()) {
- // requireNonNull is safe because the cell exists in the table.
- cellColumnIndices[i++] = requireNonNull(columnKeyToIndex.get(cell.getColumnKey()));
+ cellColumnIndices[i++] = columnKeyToIndex.get(cell.getColumnKey());
}
return SerializedForm.create(this, cellRowIndices, cellColumnIndices);
}
diff --git a/android/guava/src/com/google/common/collect/StandardRowSortedTable.java b/android/guava/src/com/google/common/collect/StandardRowSortedTable.java
index bea5b7b..19a14c3 100644
--- a/android/guava/src/com/google/common/collect/StandardRowSortedTable.java
+++ b/android/guava/src/com/google/common/collect/StandardRowSortedTable.java
@@ -26,7 +26,6 @@
import java.util.Set;
import java.util.SortedMap;
import java.util.SortedSet;
-import javax.annotation.CheckForNull;
/**
* Implementation of {@code Table} whose iteration ordering across row keys is sorted by their
@@ -46,7 +45,6 @@
* @author Jared Levy
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
class StandardRowSortedTable<R, C, V> extends StandardTable<R, C, V>
implements RowSortedTable<R, C, V> {
/*
@@ -104,7 +102,6 @@
}
@Override
- @CheckForNull
public Comparator<? super R> comparator() {
return sortedBackingMap().comparator();
}
diff --git a/android/guava/src/com/google/common/collect/StandardTable.java b/android/guava/src/com/google/common/collect/StandardTable.java
index 4c1ffe1..efed27a 100644
--- a/android/guava/src/com/google/common/collect/StandardTable.java
+++ b/android/guava/src/com/google/common/collect/StandardTable.java
@@ -23,8 +23,6 @@
import static com.google.common.base.Predicates.not;
import static com.google.common.collect.Maps.safeContainsKey;
import static com.google.common.collect.Maps.safeGet;
-import static com.google.common.collect.NullnessCasts.uncheckedCastNullableTToT;
-import static java.util.Objects.requireNonNull;
import com.google.common.annotations.GwtCompatible;
import com.google.common.base.Function;
@@ -42,7 +40,7 @@
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* {@link Table} implementation backed by a map that associates row keys with column key / value
@@ -64,7 +62,6 @@
* @author Jared Levy
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
class StandardTable<R, C, V> extends AbstractTable<R, C, V> implements Serializable {
@GwtTransient final Map<R, Map<C, V>> backingMap;
@GwtTransient final Supplier<? extends Map<C, V>> factory;
@@ -77,12 +74,12 @@
// Accessors
@Override
- public boolean contains(@CheckForNull Object rowKey, @CheckForNull Object columnKey) {
+ public boolean contains(@NullableDecl Object rowKey, @NullableDecl Object columnKey) {
return rowKey != null && columnKey != null && super.contains(rowKey, columnKey);
}
@Override
- public boolean containsColumn(@CheckForNull Object columnKey) {
+ public boolean containsColumn(@NullableDecl Object columnKey) {
if (columnKey == null) {
return false;
}
@@ -95,18 +92,17 @@
}
@Override
- public boolean containsRow(@CheckForNull Object rowKey) {
+ public boolean containsRow(@NullableDecl Object rowKey) {
return rowKey != null && safeContainsKey(backingMap, rowKey);
}
@Override
- public boolean containsValue(@CheckForNull Object value) {
+ public boolean containsValue(@NullableDecl Object value) {
return value != null && super.containsValue(value);
}
@Override
- @CheckForNull
- public V get(@CheckForNull Object rowKey, @CheckForNull Object columnKey) {
+ public V get(@NullableDecl Object rowKey, @NullableDecl Object columnKey) {
return (rowKey == null || columnKey == null) ? null : super.get(rowKey, columnKey);
}
@@ -142,7 +138,6 @@
@CanIgnoreReturnValue
@Override
- @CheckForNull
public V put(R rowKey, C columnKey, V value) {
checkNotNull(rowKey);
checkNotNull(columnKey);
@@ -152,8 +147,7 @@
@CanIgnoreReturnValue
@Override
- @CheckForNull
- public V remove(@CheckForNull Object rowKey, @CheckForNull Object columnKey) {
+ public V remove(@NullableDecl Object rowKey, @NullableDecl Object columnKey) {
if ((rowKey == null) || (columnKey == null)) {
return null;
}
@@ -169,7 +163,7 @@
}
@CanIgnoreReturnValue
- private Map<R, V> removeColumn(@CheckForNull Object column) {
+ private Map<R, V> removeColumn(Object column) {
Map<R, V> output = new LinkedHashMap<>();
Iterator<Entry<R, Map<C, V>>> iterator = backingMap.entrySet().iterator();
while (iterator.hasNext()) {
@@ -185,14 +179,12 @@
return output;
}
- private boolean containsMapping(
- @CheckForNull Object rowKey, @CheckForNull Object columnKey, @CheckForNull Object value) {
+ private boolean containsMapping(Object rowKey, Object columnKey, Object value) {
return value != null && value.equals(get(rowKey, columnKey));
}
/** Remove a row key / column key / value mapping, if present. */
- private boolean removeMapping(
- @CheckForNull Object rowKey, @CheckForNull Object columnKey, @CheckForNull Object value) {
+ private boolean removeMapping(Object rowKey, Object columnKey, Object value) {
if (containsMapping(rowKey, columnKey, value)) {
remove(rowKey, columnKey);
return true;
@@ -240,7 +232,7 @@
private class CellIterator implements Iterator<Cell<R, C, V>> {
final Iterator<Entry<R, Map<C, V>>> rowIterator = backingMap.entrySet().iterator();
- @CheckForNull Entry<R, Map<C, V>> rowEntry;
+ @NullableDecl Entry<R, Map<C, V>> rowEntry;
Iterator<Entry<C, V>> columnIterator = Iterators.emptyModifiableIterator();
@Override
@@ -254,20 +246,6 @@
rowEntry = rowIterator.next();
columnIterator = rowEntry.getValue().entrySet().iterator();
}
- /*
- * requireNonNull is safe because:
- *
- * - columnIterator started off pointing to an empty iterator, so we must have entered the
- * `if` body above at least once. Thus, if we got this far, that `if` body initialized
- * rowEntry at least once.
- *
- * - The only case in which rowEntry is cleared (during remove() below) happens only if the
- * caller removed every element from columnIterator. During that process, we would have had
- * to iterate it to exhaustion. Then we can apply the logic above about an empty
- * columnIterator. (This assumes no concurrent modification, but behavior under concurrent
- * modification is undefined, anyway.)
- */
- requireNonNull(rowEntry);
Entry<C, V> columnEntry = columnIterator.next();
return Tables.immutableCell(rowEntry.getKey(), columnEntry.getKey(), columnEntry.getValue());
}
@@ -275,17 +253,7 @@
@Override
public void remove() {
columnIterator.remove();
- /*
- * requireNonNull is safe because:
- *
- * - columnIterator.remove() succeeded, so it must have returned a value, so it must have been
- * initialized by next() -- which initializes rowEntry, too.
- *
- * - rowEntry isn't cleared except below. If it was cleared below, then either
- * columnIterator.remove() would have failed above (if the user hasn't called next() since
- * then) or rowEntry would have been initialized by next() (as discussed above).
- */
- if (requireNonNull(rowEntry).getValue().isEmpty()) {
+ if (rowEntry.getValue().isEmpty()) {
rowIterator.remove();
rowEntry = null;
}
@@ -304,43 +272,39 @@
this.rowKey = checkNotNull(rowKey);
}
- @CheckForNull Map<C, V> backingRowMap;
+ @NullableDecl Map<C, V> backingRowMap;
- final void updateBackingRowMapField() {
- if (backingRowMap == null || (backingRowMap.isEmpty() && backingMap.containsKey(rowKey))) {
- backingRowMap = computeBackingRowMap();
- }
+ Map<C, V> backingRowMap() {
+ return (backingRowMap == null || (backingRowMap.isEmpty() && backingMap.containsKey(rowKey)))
+ ? backingRowMap = computeBackingRowMap()
+ : backingRowMap;
}
- @CheckForNull
Map<C, V> computeBackingRowMap() {
return backingMap.get(rowKey);
}
// Call this every time we perform a removal.
void maintainEmptyInvariant() {
- updateBackingRowMapField();
- if (backingRowMap != null && backingRowMap.isEmpty()) {
+ if (backingRowMap() != null && backingRowMap.isEmpty()) {
backingMap.remove(rowKey);
backingRowMap = null;
}
}
@Override
- public boolean containsKey(@CheckForNull Object key) {
- updateBackingRowMapField();
+ public boolean containsKey(Object key) {
+ Map<C, V> backingRowMap = backingRowMap();
return (key != null && backingRowMap != null) && Maps.safeContainsKey(backingRowMap, key);
}
@Override
- @CheckForNull
- public V get(@CheckForNull Object key) {
- updateBackingRowMapField();
+ public V get(Object key) {
+ Map<C, V> backingRowMap = backingRowMap();
return (key != null && backingRowMap != null) ? Maps.safeGet(backingRowMap, key) : null;
}
@Override
- @CheckForNull
public V put(C key, V value) {
checkNotNull(key);
checkNotNull(value);
@@ -351,9 +315,8 @@
}
@Override
- @CheckForNull
- public V remove(@CheckForNull Object key) {
- updateBackingRowMapField();
+ public V remove(Object key) {
+ Map<C, V> backingRowMap = backingRowMap();
if (backingRowMap == null) {
return null;
}
@@ -364,7 +327,7 @@
@Override
public void clear() {
- updateBackingRowMapField();
+ Map<C, V> backingRowMap = backingRowMap();
if (backingRowMap != null) {
backingRowMap.clear();
}
@@ -373,17 +336,17 @@
@Override
public int size() {
- updateBackingRowMapField();
- return (backingRowMap == null) ? 0 : backingRowMap.size();
+ Map<C, V> map = backingRowMap();
+ return (map == null) ? 0 : map.size();
}
@Override
Iterator<Entry<C, V>> entryIterator() {
- updateBackingRowMapField();
- if (backingRowMap == null) {
+ final Map<C, V> map = backingRowMap();
+ if (map == null) {
return Iterators.emptyModifiableIterator();
}
- final Iterator<Entry<C, V>> iterator = backingRowMap.entrySet().iterator();
+ final Iterator<Entry<C, V>> iterator = map.entrySet().iterator();
return new Iterator<Entry<C, V>>() {
@Override
public boolean hasNext() {
@@ -416,7 +379,7 @@
}
@Override
- public boolean equals(@CheckForNull Object object) {
+ public boolean equals(Object object) {
// TODO(lowasser): identify why this affects GWT tests
return standardEquals(object);
}
@@ -442,25 +405,22 @@
}
@Override
- @CheckForNull
public V put(R key, V value) {
return StandardTable.this.put(key, columnKey, value);
}
@Override
- @CheckForNull
- public V get(@CheckForNull Object key) {
+ public V get(Object key) {
return StandardTable.this.get(key, columnKey);
}
@Override
- public boolean containsKey(@CheckForNull Object key) {
+ public boolean containsKey(Object key) {
return StandardTable.this.contains(key, columnKey);
}
@Override
- @CheckForNull
- public V remove(@CheckForNull Object key) {
+ public V remove(Object key) {
return StandardTable.this.remove(key, columnKey);
}
@@ -518,7 +478,7 @@
}
@Override
- public boolean contains(@CheckForNull Object o) {
+ public boolean contains(Object o) {
if (o instanceof Entry) {
Entry<?, ?> entry = (Entry<?, ?>) o;
return containsMapping(entry.getKey(), columnKey, entry.getValue());
@@ -527,7 +487,7 @@
}
@Override
- public boolean remove(@CheckForNull Object obj) {
+ public boolean remove(Object obj) {
if (obj instanceof Entry) {
Entry<?, ?> entry = (Entry<?, ?>) obj;
return removeMapping(entry.getKey(), columnKey, entry.getValue());
@@ -545,7 +505,6 @@
final Iterator<Entry<R, Map<C, V>>> iterator = backingMap.entrySet().iterator();
@Override
- @CheckForNull
protected Entry<R, V> computeNext() {
while (iterator.hasNext()) {
final Entry<R, Map<C, V>> entry = iterator.next();
@@ -564,22 +523,7 @@
@Override
public V setValue(V value) {
- /*
- * The cast is safe because of the containsKey check above. (Well, it's possible for
- * the map to change between that call and this one. But if that happens, the
- * behavior is undefined because of the concurrent mutation.)
- *
- * (Our prototype checker happens to be "smart" enough to understand this for the
- * *get* call in getValue but not for the *put* call here.)
- *
- * (Arguably we should use requireNonNull rather than uncheckedCastNullableTToT: We
- * know that V is a non-null type because that's the only kind of value type that
- * StandardTable supports. Thus, requireNonNull is safe as long as the cell is still
- * present. (And if it's not present, behavior is undefined.) However, that's a
- * behavior change relative to the old code, so it didn't seem worth risking.)
- */
- return uncheckedCastNullableTToT(
- entry.getValue().put(columnKey, checkNotNull(value)));
+ return entry.getValue().put(columnKey, checkNotNull(value));
}
}
return new EntryImpl();
@@ -601,12 +545,12 @@
}
@Override
- public boolean contains(@CheckForNull Object obj) {
+ public boolean contains(Object obj) {
return StandardTable.this.contains(obj, columnKey);
}
@Override
- public boolean remove(@CheckForNull Object obj) {
+ public boolean remove(Object obj) {
return StandardTable.this.remove(obj, columnKey) != null;
}
@@ -628,7 +572,7 @@
}
@Override
- public boolean remove(@CheckForNull Object obj) {
+ public boolean remove(Object obj) {
return obj != null && removeFromColumnIf(Maps.<V>valuePredicateOnEntries(equalTo(obj)));
}
@@ -649,7 +593,7 @@
return rowMap().keySet();
}
- @CheckForNull private transient Set<C> columnKeySet;
+ @NullableDecl private transient Set<C> columnKeySet;
/**
* {@inheritDoc}
@@ -678,7 +622,7 @@
}
@Override
- public boolean remove(@CheckForNull Object obj) {
+ public boolean remove(Object obj) {
if (obj == null) {
return false;
}
@@ -733,7 +677,7 @@
}
@Override
- public boolean contains(@CheckForNull Object obj) {
+ public boolean contains(Object obj) {
return containsColumn(obj);
}
}
@@ -751,7 +695,6 @@
Iterator<Entry<C, V>> entryIterator = Iterators.emptyIterator();
@Override
- @CheckForNull
protected C computeNext() {
while (true) {
if (entryIterator.hasNext()) {
@@ -780,7 +723,7 @@
return super.values();
}
- @CheckForNull private transient Map<R, Map<C, V>> rowMap;
+ @NullableDecl private transient Map<R, Map<C, V>> rowMap;
@Override
public Map<R, Map<C, V>> rowMap() {
@@ -795,22 +738,19 @@
@WeakOuter
class RowMap extends ViewCachingAbstractMap<R, Map<C, V>> {
@Override
- public boolean containsKey(@CheckForNull Object key) {
+ public boolean containsKey(Object key) {
return containsRow(key);
}
// performing cast only when key is in backing map and has the correct type
@SuppressWarnings("unchecked")
@Override
- @CheckForNull
- public Map<C, V> get(@CheckForNull Object key) {
- // requireNonNull is safe because of the containsRow check.
- return containsRow(key) ? row((R) requireNonNull(key)) : null;
+ public Map<C, V> get(Object key) {
+ return containsRow(key) ? row((R) key) : null;
}
@Override
- @CheckForNull
- public Map<C, V> remove(@CheckForNull Object key) {
+ public Map<C, V> remove(Object key) {
return (key == null) ? null : backingMap.remove(key);
}
@@ -839,7 +779,7 @@
}
@Override
- public boolean contains(@CheckForNull Object obj) {
+ public boolean contains(Object obj) {
if (obj instanceof Entry) {
Entry<?, ?> entry = (Entry<?, ?>) obj;
return entry.getKey() != null
@@ -850,7 +790,7 @@
}
@Override
- public boolean remove(@CheckForNull Object obj) {
+ public boolean remove(Object obj) {
if (obj instanceof Entry) {
Entry<?, ?> entry = (Entry<?, ?>) obj;
return entry.getKey() != null
@@ -862,7 +802,7 @@
}
}
- @CheckForNull private transient ColumnMap columnMap;
+ @NullableDecl private transient ColumnMap columnMap;
@Override
public Map<C, Map<R, V>> columnMap() {
@@ -876,20 +816,17 @@
// has the correct type.
@SuppressWarnings("unchecked")
@Override
- @CheckForNull
- public Map<R, V> get(@CheckForNull Object key) {
- // requireNonNull is safe because of the containsColumn check.
- return containsColumn(key) ? column((C) requireNonNull(key)) : null;
+ public Map<R, V> get(Object key) {
+ return containsColumn(key) ? column((C) key) : null;
}
@Override
- public boolean containsKey(@CheckForNull Object key) {
+ public boolean containsKey(Object key) {
return containsColumn(key);
}
@Override
- @CheckForNull
- public Map<R, V> remove(@CheckForNull Object key) {
+ public Map<R, V> remove(Object key) {
return containsColumn(key) ? removeColumn(key) : null;
}
@@ -928,24 +865,23 @@
}
@Override
- public boolean contains(@CheckForNull Object obj) {
+ public boolean contains(Object obj) {
if (obj instanceof Entry) {
Entry<?, ?> entry = (Entry<?, ?>) obj;
if (containsColumn(entry.getKey())) {
- // requireNonNull is safe because of the containsColumn check.
- return requireNonNull(get(entry.getKey())).equals(entry.getValue());
+ // The cast to C occurs only when the key is in the map, implying
+ // that it has the correct type.
+ @SuppressWarnings("unchecked")
+ C columnKey = (C) entry.getKey();
+ return get(columnKey).equals(entry.getValue());
}
}
return false;
}
@Override
- public boolean remove(@CheckForNull Object obj) {
- /*
- * `o instanceof Entry` is guaranteed by `contains`, but we check it here to satisfy our
- * nullness checker.
- */
- if (contains(obj) && obj instanceof Entry) {
+ public boolean remove(Object obj) {
+ if (contains(obj)) {
Entry<?, ?> entry = (Entry<?, ?>) obj;
removeColumn(entry.getKey());
return true;
@@ -986,7 +922,7 @@
}
@Override
- public boolean remove(@CheckForNull Object obj) {
+ public boolean remove(Object obj) {
for (Entry<C, Map<R, V>> entry : ColumnMap.this.entrySet()) {
if (entry.getValue().equals(obj)) {
removeColumn(entry.getKey());
diff --git a/android/guava/src/com/google/common/collect/Synchronized.java b/android/guava/src/com/google/common/collect/Synchronized.java
index 42bf611..c4cdb17 100644
--- a/android/guava/src/com/google/common/collect/Synchronized.java
+++ b/android/guava/src/com/google/common/collect/Synchronized.java
@@ -32,6 +32,7 @@
import java.util.List;
import java.util.ListIterator;
import java.util.Map;
+import java.util.Map.Entry;
import java.util.NavigableMap;
import java.util.NavigableSet;
import java.util.Queue;
@@ -39,8 +40,7 @@
import java.util.Set;
import java.util.SortedMap;
import java.util.SortedSet;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* Synchronized collection views. The returned synchronized collection views are serializable if the
@@ -55,16 +55,6 @@
* @author Jared Levy
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
-/*
- * I have decided not to bother adding @ParametricNullness annotations in this class. Adding them is
- * a lot of busy work, and the annotation matters only when the APIs to be annotated are visible to
- * Kotlin code. In this class, nothing is publicly visible (nor exposed indirectly through a
- * publicly visible subclass), and I doubt any of our current or future Kotlin extensions for the
- * package will refer to the class. Plus, @ParametricNullness is only a temporary workaround,
- * anyway, so we just need to get by without the annotations here until Kotlin better understands
- * our other nullness annotations.
- */
final class Synchronized {
private Synchronized() {}
@@ -72,7 +62,7 @@
final Object delegate;
final Object mutex;
- SynchronizedObject(Object delegate, @CheckForNull Object mutex) {
+ SynchronizedObject(Object delegate, @NullableDecl Object mutex) {
this.delegate = checkNotNull(delegate);
this.mutex = (mutex == null) ? this : mutex;
}
@@ -106,15 +96,14 @@
private static final long serialVersionUID = 0;
}
- private static <E extends @Nullable Object> Collection<E> collection(
- Collection<E> collection, @CheckForNull Object mutex) {
+ private static <E> Collection<E> collection(
+ Collection<E> collection, @NullableDecl Object mutex) {
return new SynchronizedCollection<E>(collection, mutex);
}
@VisibleForTesting
- static class SynchronizedCollection<E extends @Nullable Object> extends SynchronizedObject
- implements Collection<E> {
- private SynchronizedCollection(Collection<E> delegate, @CheckForNull Object mutex) {
+ static class SynchronizedCollection<E> extends SynchronizedObject implements Collection<E> {
+ private SynchronizedCollection(Collection<E> delegate, @NullableDecl Object mutex) {
super(delegate, mutex);
}
@@ -146,7 +135,7 @@
}
@Override
- public boolean contains(@CheckForNull Object o) {
+ public boolean contains(Object o) {
synchronized (mutex) {
return delegate().contains(o);
}
@@ -172,7 +161,7 @@
}
@Override
- public boolean remove(@CheckForNull Object o) {
+ public boolean remove(Object o) {
synchronized (mutex) {
return delegate().remove(o);
}
@@ -200,15 +189,14 @@
}
@Override
- public @Nullable Object[] toArray() {
+ public Object[] toArray() {
synchronized (mutex) {
return delegate().toArray();
}
}
@Override
- @SuppressWarnings("nullness") // b/192354773 in our checker affects toArray declarations
- public <T extends @Nullable Object> T[] toArray(T[] a) {
+ public <T> T[] toArray(T[] a) {
synchronized (mutex) {
return delegate().toArray(a);
}
@@ -218,14 +206,13 @@
}
@VisibleForTesting
- static <E extends @Nullable Object> Set<E> set(Set<E> set, @CheckForNull Object mutex) {
+ static <E> Set<E> set(Set<E> set, @NullableDecl Object mutex) {
return new SynchronizedSet<E>(set, mutex);
}
- static class SynchronizedSet<E extends @Nullable Object> extends SynchronizedCollection<E>
- implements Set<E> {
+ static class SynchronizedSet<E> extends SynchronizedCollection<E> implements Set<E> {
- SynchronizedSet(Set<E> delegate, @CheckForNull Object mutex) {
+ SynchronizedSet(Set<E> delegate, @NullableDecl Object mutex) {
super(delegate, mutex);
}
@@ -235,7 +222,7 @@
}
@Override
- public boolean equals(@CheckForNull Object o) {
+ public boolean equals(Object o) {
if (o == this) {
return true;
}
@@ -254,14 +241,12 @@
private static final long serialVersionUID = 0;
}
- private static <E extends @Nullable Object> SortedSet<E> sortedSet(
- SortedSet<E> set, @CheckForNull Object mutex) {
+ private static <E> SortedSet<E> sortedSet(SortedSet<E> set, @NullableDecl Object mutex) {
return new SynchronizedSortedSet<E>(set, mutex);
}
- static class SynchronizedSortedSet<E extends @Nullable Object> extends SynchronizedSet<E>
- implements SortedSet<E> {
- SynchronizedSortedSet(SortedSet<E> delegate, @CheckForNull Object mutex) {
+ static class SynchronizedSortedSet<E> extends SynchronizedSet<E> implements SortedSet<E> {
+ SynchronizedSortedSet(SortedSet<E> delegate, @NullableDecl Object mutex) {
super(delegate, mutex);
}
@@ -271,7 +256,6 @@
}
@Override
- @CheckForNull
public Comparator<? super E> comparator() {
synchronized (mutex) {
return delegate().comparator();
@@ -316,16 +300,14 @@
private static final long serialVersionUID = 0;
}
- private static <E extends @Nullable Object> List<E> list(
- List<E> list, @CheckForNull Object mutex) {
+ private static <E> List<E> list(List<E> list, @NullableDecl Object mutex) {
return (list instanceof RandomAccess)
? new SynchronizedRandomAccessList<E>(list, mutex)
: new SynchronizedList<E>(list, mutex);
}
- private static class SynchronizedList<E extends @Nullable Object>
- extends SynchronizedCollection<E> implements List<E> {
- SynchronizedList(List<E> delegate, @CheckForNull Object mutex) {
+ private static class SynchronizedList<E> extends SynchronizedCollection<E> implements List<E> {
+ SynchronizedList(List<E> delegate, @NullableDecl Object mutex) {
super(delegate, mutex);
}
@@ -356,14 +338,14 @@
}
@Override
- public int indexOf(@CheckForNull Object o) {
+ public int indexOf(Object o) {
synchronized (mutex) {
return delegate().indexOf(o);
}
}
@Override
- public int lastIndexOf(@CheckForNull Object o) {
+ public int lastIndexOf(Object o) {
synchronized (mutex) {
return delegate().lastIndexOf(o);
}
@@ -401,7 +383,7 @@
}
@Override
- public boolean equals(@CheckForNull Object o) {
+ public boolean equals(Object o) {
if (o == this) {
return true;
}
@@ -420,29 +402,28 @@
private static final long serialVersionUID = 0;
}
- private static class SynchronizedRandomAccessList<E extends @Nullable Object>
- extends SynchronizedList<E> implements RandomAccess {
- SynchronizedRandomAccessList(List<E> list, @CheckForNull Object mutex) {
+ private static class SynchronizedRandomAccessList<E> extends SynchronizedList<E>
+ implements RandomAccess {
+ SynchronizedRandomAccessList(List<E> list, @NullableDecl Object mutex) {
super(list, mutex);
}
private static final long serialVersionUID = 0;
}
- static <E extends @Nullable Object> Multiset<E> multiset(
- Multiset<E> multiset, @CheckForNull Object mutex) {
+ static <E> Multiset<E> multiset(Multiset<E> multiset, @NullableDecl Object mutex) {
if (multiset instanceof SynchronizedMultiset || multiset instanceof ImmutableMultiset) {
return multiset;
}
return new SynchronizedMultiset<E>(multiset, mutex);
}
- private static class SynchronizedMultiset<E extends @Nullable Object>
- extends SynchronizedCollection<E> implements Multiset<E> {
- @CheckForNull transient Set<E> elementSet;
- @CheckForNull transient Set<Multiset.Entry<E>> entrySet;
+ private static class SynchronizedMultiset<E> extends SynchronizedCollection<E>
+ implements Multiset<E> {
+ @NullableDecl transient Set<E> elementSet;
+ @NullableDecl transient Set<Entry<E>> entrySet;
- SynchronizedMultiset(Multiset<E> delegate, @CheckForNull Object mutex) {
+ SynchronizedMultiset(Multiset<E> delegate, @NullableDecl Object mutex) {
super(delegate, mutex);
}
@@ -452,7 +433,7 @@
}
@Override
- public int count(@CheckForNull Object o) {
+ public int count(Object o) {
synchronized (mutex) {
return delegate().count(o);
}
@@ -466,7 +447,7 @@
}
@Override
- public int remove(@CheckForNull Object o, int n) {
+ public int remove(Object o, int n) {
synchronized (mutex) {
return delegate().remove(o, n);
}
@@ -497,7 +478,7 @@
}
@Override
- public Set<Multiset.Entry<E>> entrySet() {
+ public Set<Entry<E>> entrySet() {
synchronized (mutex) {
if (entrySet == null) {
entrySet = typePreservingSet(delegate().entrySet(), mutex);
@@ -507,7 +488,7 @@
}
@Override
- public boolean equals(@CheckForNull Object o) {
+ public boolean equals(Object o) {
if (o == this) {
return true;
}
@@ -526,21 +507,20 @@
private static final long serialVersionUID = 0;
}
- static <K extends @Nullable Object, V extends @Nullable Object> Multimap<K, V> multimap(
- Multimap<K, V> multimap, @CheckForNull Object mutex) {
+ static <K, V> Multimap<K, V> multimap(Multimap<K, V> multimap, @NullableDecl Object mutex) {
if (multimap instanceof SynchronizedMultimap || multimap instanceof BaseImmutableMultimap) {
return multimap;
}
return new SynchronizedMultimap<>(multimap, mutex);
}
- private static class SynchronizedMultimap<K extends @Nullable Object, V extends @Nullable Object>
- extends SynchronizedObject implements Multimap<K, V> {
- @CheckForNull transient Set<K> keySet;
- @CheckForNull transient Collection<V> valuesCollection;
- @CheckForNull transient Collection<Map.Entry<K, V>> entries;
- @CheckForNull transient Map<K, Collection<V>> asMap;
- @CheckForNull transient Multiset<K> keys;
+ private static class SynchronizedMultimap<K, V> extends SynchronizedObject
+ implements Multimap<K, V> {
+ @NullableDecl transient Set<K> keySet;
+ @NullableDecl transient Collection<V> valuesCollection;
+ @NullableDecl transient Collection<Entry<K, V>> entries;
+ @NullableDecl transient Map<K, Collection<V>> asMap;
+ @NullableDecl transient Multiset<K> keys;
@SuppressWarnings("unchecked")
@Override
@@ -548,7 +528,7 @@
return (Multimap<K, V>) super.delegate();
}
- SynchronizedMultimap(Multimap<K, V> delegate, @CheckForNull Object mutex) {
+ SynchronizedMultimap(Multimap<K, V> delegate, @NullableDecl Object mutex) {
super(delegate, mutex);
}
@@ -567,21 +547,21 @@
}
@Override
- public boolean containsKey(@CheckForNull Object key) {
+ public boolean containsKey(Object key) {
synchronized (mutex) {
return delegate().containsKey(key);
}
}
@Override
- public boolean containsValue(@CheckForNull Object value) {
+ public boolean containsValue(Object value) {
synchronized (mutex) {
return delegate().containsValue(value);
}
}
@Override
- public boolean containsEntry(@CheckForNull Object key, @CheckForNull Object value) {
+ public boolean containsEntry(Object key, Object value) {
synchronized (mutex) {
return delegate().containsEntry(key, value);
}
@@ -623,14 +603,14 @@
}
@Override
- public boolean remove(@CheckForNull Object key, @CheckForNull Object value) {
+ public boolean remove(Object key, Object value) {
synchronized (mutex) {
return delegate().remove(key, value);
}
}
@Override
- public Collection<V> removeAll(@CheckForNull Object key) {
+ public Collection<V> removeAll(Object key) {
synchronized (mutex) {
return delegate().removeAll(key); // copy not synchronized
}
@@ -664,7 +644,7 @@
}
@Override
- public Collection<Map.Entry<K, V>> entries() {
+ public Collection<Entry<K, V>> entries() {
synchronized (mutex) {
if (entries == null) {
entries = typePreservingCollection(delegate().entries(), mutex);
@@ -694,7 +674,7 @@
}
@Override
- public boolean equals(@CheckForNull Object o) {
+ public boolean equals(Object o) {
if (o == this) {
return true;
}
@@ -713,18 +693,17 @@
private static final long serialVersionUID = 0;
}
- static <K extends @Nullable Object, V extends @Nullable Object> ListMultimap<K, V> listMultimap(
- ListMultimap<K, V> multimap, @CheckForNull Object mutex) {
+ static <K, V> ListMultimap<K, V> listMultimap(
+ ListMultimap<K, V> multimap, @NullableDecl Object mutex) {
if (multimap instanceof SynchronizedListMultimap || multimap instanceof BaseImmutableMultimap) {
return multimap;
}
return new SynchronizedListMultimap<>(multimap, mutex);
}
- private static class SynchronizedListMultimap<
- K extends @Nullable Object, V extends @Nullable Object>
- extends SynchronizedMultimap<K, V> implements ListMultimap<K, V> {
- SynchronizedListMultimap(ListMultimap<K, V> delegate, @CheckForNull Object mutex) {
+ private static class SynchronizedListMultimap<K, V> extends SynchronizedMultimap<K, V>
+ implements ListMultimap<K, V> {
+ SynchronizedListMultimap(ListMultimap<K, V> delegate, @NullableDecl Object mutex) {
super(delegate, mutex);
}
@@ -741,7 +720,7 @@
}
@Override
- public List<V> removeAll(@CheckForNull Object key) {
+ public List<V> removeAll(Object key) {
synchronized (mutex) {
return delegate().removeAll(key); // copy not synchronized
}
@@ -757,20 +736,19 @@
private static final long serialVersionUID = 0;
}
- static <K extends @Nullable Object, V extends @Nullable Object> SetMultimap<K, V> setMultimap(
- SetMultimap<K, V> multimap, @CheckForNull Object mutex) {
+ static <K, V> SetMultimap<K, V> setMultimap(
+ SetMultimap<K, V> multimap, @NullableDecl Object mutex) {
if (multimap instanceof SynchronizedSetMultimap || multimap instanceof BaseImmutableMultimap) {
return multimap;
}
return new SynchronizedSetMultimap<>(multimap, mutex);
}
- private static class SynchronizedSetMultimap<
- K extends @Nullable Object, V extends @Nullable Object>
- extends SynchronizedMultimap<K, V> implements SetMultimap<K, V> {
- @CheckForNull transient Set<Map.Entry<K, V>> entrySet;
+ private static class SynchronizedSetMultimap<K, V> extends SynchronizedMultimap<K, V>
+ implements SetMultimap<K, V> {
+ @NullableDecl transient Set<Entry<K, V>> entrySet;
- SynchronizedSetMultimap(SetMultimap<K, V> delegate, @CheckForNull Object mutex) {
+ SynchronizedSetMultimap(SetMultimap<K, V> delegate, @NullableDecl Object mutex) {
super(delegate, mutex);
}
@@ -787,7 +765,7 @@
}
@Override
- public Set<V> removeAll(@CheckForNull Object key) {
+ public Set<V> removeAll(Object key) {
synchronized (mutex) {
return delegate().removeAll(key); // copy not synchronized
}
@@ -801,7 +779,7 @@
}
@Override
- public Set<Map.Entry<K, V>> entries() {
+ public Set<Entry<K, V>> entries() {
synchronized (mutex) {
if (entrySet == null) {
entrySet = set(delegate().entries(), mutex);
@@ -813,19 +791,17 @@
private static final long serialVersionUID = 0;
}
- static <K extends @Nullable Object, V extends @Nullable Object>
- SortedSetMultimap<K, V> sortedSetMultimap(
- SortedSetMultimap<K, V> multimap, @CheckForNull Object mutex) {
+ static <K, V> SortedSetMultimap<K, V> sortedSetMultimap(
+ SortedSetMultimap<K, V> multimap, @NullableDecl Object mutex) {
if (multimap instanceof SynchronizedSortedSetMultimap) {
return multimap;
}
return new SynchronizedSortedSetMultimap<>(multimap, mutex);
}
- private static class SynchronizedSortedSetMultimap<
- K extends @Nullable Object, V extends @Nullable Object>
- extends SynchronizedSetMultimap<K, V> implements SortedSetMultimap<K, V> {
- SynchronizedSortedSetMultimap(SortedSetMultimap<K, V> delegate, @CheckForNull Object mutex) {
+ private static class SynchronizedSortedSetMultimap<K, V> extends SynchronizedSetMultimap<K, V>
+ implements SortedSetMultimap<K, V> {
+ SynchronizedSortedSetMultimap(SortedSetMultimap<K, V> delegate, @NullableDecl Object mutex) {
super(delegate, mutex);
}
@@ -842,7 +818,7 @@
}
@Override
- public SortedSet<V> removeAll(@CheckForNull Object key) {
+ public SortedSet<V> removeAll(Object key) {
synchronized (mutex) {
return delegate().removeAll(key); // copy not synchronized
}
@@ -856,7 +832,6 @@
}
@Override
- @CheckForNull
public Comparator<? super V> valueComparator() {
synchronized (mutex) {
return delegate().valueComparator();
@@ -866,8 +841,8 @@
private static final long serialVersionUID = 0;
}
- private static <E extends @Nullable Object> Collection<E> typePreservingCollection(
- Collection<E> collection, @CheckForNull Object mutex) {
+ private static <E> Collection<E> typePreservingCollection(
+ Collection<E> collection, @NullableDecl Object mutex) {
if (collection instanceof SortedSet) {
return sortedSet((SortedSet<E>) collection, mutex);
}
@@ -880,8 +855,7 @@
return collection(collection, mutex);
}
- private static <E extends @Nullable Object> Set<E> typePreservingSet(
- Set<E> set, @CheckForNull Object mutex) {
+ private static <E> Set<E> typePreservingSet(Set<E> set, @NullableDecl Object mutex) {
if (set instanceof SortedSet) {
return sortedSet((SortedSet<E>) set, mutex);
} else {
@@ -889,24 +863,22 @@
}
}
- private static class SynchronizedAsMapEntries<
- K extends @Nullable Object, V extends @Nullable Object>
- extends SynchronizedSet<Map.Entry<K, Collection<V>>> {
- SynchronizedAsMapEntries(
- Set<Map.Entry<K, Collection<V>>> delegate, @CheckForNull Object mutex) {
+ private static class SynchronizedAsMapEntries<K, V>
+ extends SynchronizedSet<Entry<K, Collection<V>>> {
+ SynchronizedAsMapEntries(Set<Entry<K, Collection<V>>> delegate, @NullableDecl Object mutex) {
super(delegate, mutex);
}
@Override
- public Iterator<Map.Entry<K, Collection<V>>> iterator() {
+ public Iterator<Entry<K, Collection<V>>> iterator() {
// Must be manually synchronized.
- return new TransformedIterator<Map.Entry<K, Collection<V>>, Map.Entry<K, Collection<V>>>(
+ return new TransformedIterator<Entry<K, Collection<V>>, Entry<K, Collection<V>>>(
super.iterator()) {
@Override
- Map.Entry<K, Collection<V>> transform(final Map.Entry<K, Collection<V>> entry) {
+ Entry<K, Collection<V>> transform(final Entry<K, Collection<V>> entry) {
return new ForwardingMapEntry<K, Collection<V>>() {
@Override
- protected Map.Entry<K, Collection<V>> delegate() {
+ protected Entry<K, Collection<V>> delegate() {
return entry;
}
@@ -924,27 +896,19 @@
@Override
public Object[] toArray() {
synchronized (mutex) {
- /*
- * toArrayImpl returns `@Nullable Object[]` rather than `Object[]` but only because it can
- * be used with collections that may contain null. This collection never contains nulls, so
- * we can treat it as a plain `Object[]`.
- */
- @SuppressWarnings("nullness")
- Object[] result = (Object[]) ObjectArrays.toArrayImpl(delegate());
- return result;
+ return ObjectArrays.toArrayImpl(delegate());
}
}
@Override
- @SuppressWarnings("nullness") // b/192354773 in our checker affects toArray declarations
- public <T extends @Nullable Object> T[] toArray(T[] array) {
+ public <T> T[] toArray(T[] array) {
synchronized (mutex) {
return ObjectArrays.toArrayImpl(delegate(), array);
}
}
@Override
- public boolean contains(@CheckForNull Object o) {
+ public boolean contains(Object o) {
synchronized (mutex) {
return Maps.containsEntryImpl(delegate(), o);
}
@@ -958,7 +922,7 @@
}
@Override
- public boolean equals(@CheckForNull Object o) {
+ public boolean equals(Object o) {
if (o == this) {
return true;
}
@@ -968,7 +932,7 @@
}
@Override
- public boolean remove(@CheckForNull Object o) {
+ public boolean remove(Object o) {
synchronized (mutex) {
return Maps.removeEntryImpl(delegate(), o);
}
@@ -992,18 +956,16 @@
}
@VisibleForTesting
- static <K extends @Nullable Object, V extends @Nullable Object> Map<K, V> map(
- Map<K, V> map, @CheckForNull Object mutex) {
+ static <K, V> Map<K, V> map(Map<K, V> map, @NullableDecl Object mutex) {
return new SynchronizedMap<>(map, mutex);
}
- private static class SynchronizedMap<K extends @Nullable Object, V extends @Nullable Object>
- extends SynchronizedObject implements Map<K, V> {
- @CheckForNull transient Set<K> keySet;
- @CheckForNull transient Collection<V> values;
- @CheckForNull transient Set<Map.Entry<K, V>> entrySet;
+ private static class SynchronizedMap<K, V> extends SynchronizedObject implements Map<K, V> {
+ @NullableDecl transient Set<K> keySet;
+ @NullableDecl transient Collection<V> values;
+ @NullableDecl transient Set<Entry<K, V>> entrySet;
- SynchronizedMap(Map<K, V> delegate, @CheckForNull Object mutex) {
+ SynchronizedMap(Map<K, V> delegate, @NullableDecl Object mutex) {
super(delegate, mutex);
}
@@ -1021,21 +983,21 @@
}
@Override
- public boolean containsKey(@CheckForNull Object key) {
+ public boolean containsKey(Object key) {
synchronized (mutex) {
return delegate().containsKey(key);
}
}
@Override
- public boolean containsValue(@CheckForNull Object value) {
+ public boolean containsValue(Object value) {
synchronized (mutex) {
return delegate().containsValue(value);
}
}
@Override
- public Set<Map.Entry<K, V>> entrySet() {
+ public Set<Entry<K, V>> entrySet() {
synchronized (mutex) {
if (entrySet == null) {
entrySet = set(delegate().entrySet(), mutex);
@@ -1045,8 +1007,7 @@
}
@Override
- @CheckForNull
- public V get(@CheckForNull Object key) {
+ public V get(Object key) {
synchronized (mutex) {
return delegate().get(key);
}
@@ -1070,7 +1031,6 @@
}
@Override
- @CheckForNull
public V put(K key, V value) {
synchronized (mutex) {
return delegate().put(key, value);
@@ -1085,8 +1045,7 @@
}
@Override
- @CheckForNull
- public V remove(@CheckForNull Object key) {
+ public V remove(Object key) {
synchronized (mutex) {
return delegate().remove(key);
}
@@ -1110,7 +1069,7 @@
}
@Override
- public boolean equals(@CheckForNull Object o) {
+ public boolean equals(Object o) {
if (o == this) {
return true;
}
@@ -1129,15 +1088,14 @@
private static final long serialVersionUID = 0;
}
- static <K extends @Nullable Object, V extends @Nullable Object> SortedMap<K, V> sortedMap(
- SortedMap<K, V> sortedMap, @CheckForNull Object mutex) {
+ static <K, V> SortedMap<K, V> sortedMap(SortedMap<K, V> sortedMap, @NullableDecl Object mutex) {
return new SynchronizedSortedMap<>(sortedMap, mutex);
}
- static class SynchronizedSortedMap<K extends @Nullable Object, V extends @Nullable Object>
- extends SynchronizedMap<K, V> implements SortedMap<K, V> {
+ static class SynchronizedSortedMap<K, V> extends SynchronizedMap<K, V>
+ implements SortedMap<K, V> {
- SynchronizedSortedMap(SortedMap<K, V> delegate, @CheckForNull Object mutex) {
+ SynchronizedSortedMap(SortedMap<K, V> delegate, @NullableDecl Object mutex) {
super(delegate, mutex);
}
@@ -1147,7 +1105,6 @@
}
@Override
- @CheckForNull
public Comparator<? super K> comparator() {
synchronized (mutex) {
return delegate().comparator();
@@ -1192,8 +1149,7 @@
private static final long serialVersionUID = 0;
}
- static <K extends @Nullable Object, V extends @Nullable Object> BiMap<K, V> biMap(
- BiMap<K, V> bimap, @CheckForNull Object mutex) {
+ static <K, V> BiMap<K, V> biMap(BiMap<K, V> bimap, @NullableDecl Object mutex) {
if (bimap instanceof SynchronizedBiMap || bimap instanceof ImmutableBiMap) {
return bimap;
}
@@ -1201,13 +1157,13 @@
}
@VisibleForTesting
- static class SynchronizedBiMap<K extends @Nullable Object, V extends @Nullable Object>
- extends SynchronizedMap<K, V> implements BiMap<K, V>, Serializable {
- @CheckForNull private transient Set<V> valueSet;
- @RetainedWith @CheckForNull private transient BiMap<V, K> inverse;
+ static class SynchronizedBiMap<K, V> extends SynchronizedMap<K, V>
+ implements BiMap<K, V>, Serializable {
+ @NullableDecl private transient Set<V> valueSet;
+ @RetainedWith @NullableDecl private transient BiMap<V, K> inverse;
private SynchronizedBiMap(
- BiMap<K, V> delegate, @CheckForNull Object mutex, @CheckForNull BiMap<V, K> inverse) {
+ BiMap<K, V> delegate, @NullableDecl Object mutex, @NullableDecl BiMap<V, K> inverse) {
super(delegate, mutex);
this.inverse = inverse;
}
@@ -1228,7 +1184,6 @@
}
@Override
- @CheckForNull
public V forcePut(K key, V value) {
synchronized (mutex) {
return delegate().forcePut(key, value);
@@ -1248,18 +1203,16 @@
private static final long serialVersionUID = 0;
}
- private static class SynchronizedAsMap<K extends @Nullable Object, V extends @Nullable Object>
- extends SynchronizedMap<K, Collection<V>> {
- @CheckForNull transient Set<Map.Entry<K, Collection<V>>> asMapEntrySet;
- @CheckForNull transient Collection<Collection<V>> asMapValues;
+ private static class SynchronizedAsMap<K, V> extends SynchronizedMap<K, Collection<V>> {
+ @NullableDecl transient Set<Entry<K, Collection<V>>> asMapEntrySet;
+ @NullableDecl transient Collection<Collection<V>> asMapValues;
- SynchronizedAsMap(Map<K, Collection<V>> delegate, @CheckForNull Object mutex) {
+ SynchronizedAsMap(Map<K, Collection<V>> delegate, @NullableDecl Object mutex) {
super(delegate, mutex);
}
@Override
- @CheckForNull
- public Collection<V> get(@CheckForNull Object key) {
+ public Collection<V> get(Object key) {
synchronized (mutex) {
Collection<V> collection = super.get(key);
return (collection == null) ? null : typePreservingCollection(collection, mutex);
@@ -1267,7 +1220,7 @@
}
@Override
- public Set<Map.Entry<K, Collection<V>>> entrySet() {
+ public Set<Entry<K, Collection<V>>> entrySet() {
synchronized (mutex) {
if (asMapEntrySet == null) {
asMapEntrySet = new SynchronizedAsMapEntries<>(delegate().entrySet(), mutex);
@@ -1287,7 +1240,7 @@
}
@Override
- public boolean containsValue(@CheckForNull Object o) {
+ public boolean containsValue(Object o) {
// values() and its contains() method are both synchronized.
return values().contains(o);
}
@@ -1295,9 +1248,8 @@
private static final long serialVersionUID = 0;
}
- private static class SynchronizedAsMapValues<V extends @Nullable Object>
- extends SynchronizedCollection<Collection<V>> {
- SynchronizedAsMapValues(Collection<Collection<V>> delegate, @CheckForNull Object mutex) {
+ private static class SynchronizedAsMapValues<V> extends SynchronizedCollection<Collection<V>> {
+ SynchronizedAsMapValues(Collection<Collection<V>> delegate, @NullableDecl Object mutex) {
super(delegate, mutex);
}
@@ -1317,9 +1269,9 @@
@GwtIncompatible // NavigableSet
@VisibleForTesting
- static class SynchronizedNavigableSet<E extends @Nullable Object> extends SynchronizedSortedSet<E>
+ static class SynchronizedNavigableSet<E> extends SynchronizedSortedSet<E>
implements NavigableSet<E> {
- SynchronizedNavigableSet(NavigableSet<E> delegate, @CheckForNull Object mutex) {
+ SynchronizedNavigableSet(NavigableSet<E> delegate, @NullableDecl Object mutex) {
super(delegate, mutex);
}
@@ -1329,7 +1281,6 @@
}
@Override
- @CheckForNull
public E ceiling(E e) {
synchronized (mutex) {
return delegate().ceiling(e);
@@ -1341,7 +1292,7 @@
return delegate().descendingIterator(); // manually synchronized
}
- @CheckForNull transient NavigableSet<E> descendingSet;
+ @NullableDecl transient NavigableSet<E> descendingSet;
@Override
public NavigableSet<E> descendingSet() {
@@ -1356,7 +1307,6 @@
}
@Override
- @CheckForNull
public E floor(E e) {
synchronized (mutex) {
return delegate().floor(e);
@@ -1376,7 +1326,6 @@
}
@Override
- @CheckForNull
public E higher(E e) {
synchronized (mutex) {
return delegate().higher(e);
@@ -1384,7 +1333,6 @@
}
@Override
- @CheckForNull
public E lower(E e) {
synchronized (mutex) {
return delegate().lower(e);
@@ -1392,7 +1340,6 @@
}
@Override
- @CheckForNull
public E pollFirst() {
synchronized (mutex) {
return delegate().pollFirst();
@@ -1400,7 +1347,6 @@
}
@Override
- @CheckForNull
public E pollLast() {
synchronized (mutex) {
return delegate().pollLast();
@@ -1437,34 +1383,33 @@
}
@GwtIncompatible // NavigableSet
- static <E extends @Nullable Object> NavigableSet<E> navigableSet(
- NavigableSet<E> navigableSet, @CheckForNull Object mutex) {
+ static <E> NavigableSet<E> navigableSet(
+ NavigableSet<E> navigableSet, @NullableDecl Object mutex) {
return new SynchronizedNavigableSet<E>(navigableSet, mutex);
}
@GwtIncompatible // NavigableSet
- static <E extends @Nullable Object> NavigableSet<E> navigableSet(NavigableSet<E> navigableSet) {
+ static <E> NavigableSet<E> navigableSet(NavigableSet<E> navigableSet) {
return navigableSet(navigableSet, null);
}
@GwtIncompatible // NavigableMap
- static <K extends @Nullable Object, V extends @Nullable Object> NavigableMap<K, V> navigableMap(
- NavigableMap<K, V> navigableMap) {
+ static <K, V> NavigableMap<K, V> navigableMap(NavigableMap<K, V> navigableMap) {
return navigableMap(navigableMap, null);
}
@GwtIncompatible // NavigableMap
- static <K extends @Nullable Object, V extends @Nullable Object> NavigableMap<K, V> navigableMap(
- NavigableMap<K, V> navigableMap, @CheckForNull Object mutex) {
+ static <K, V> NavigableMap<K, V> navigableMap(
+ NavigableMap<K, V> navigableMap, @NullableDecl Object mutex) {
return new SynchronizedNavigableMap<>(navigableMap, mutex);
}
@GwtIncompatible // NavigableMap
@VisibleForTesting
- static class SynchronizedNavigableMap<K extends @Nullable Object, V extends @Nullable Object>
- extends SynchronizedSortedMap<K, V> implements NavigableMap<K, V> {
+ static class SynchronizedNavigableMap<K, V> extends SynchronizedSortedMap<K, V>
+ implements NavigableMap<K, V> {
- SynchronizedNavigableMap(NavigableMap<K, V> delegate, @CheckForNull Object mutex) {
+ SynchronizedNavigableMap(NavigableMap<K, V> delegate, @NullableDecl Object mutex) {
super(delegate, mutex);
}
@@ -1474,22 +1419,20 @@
}
@Override
- @CheckForNull
- public Map.Entry<K, V> ceilingEntry(K key) {
+ public Entry<K, V> ceilingEntry(K key) {
synchronized (mutex) {
return nullableSynchronizedEntry(delegate().ceilingEntry(key), mutex);
}
}
@Override
- @CheckForNull
public K ceilingKey(K key) {
synchronized (mutex) {
return delegate().ceilingKey(key);
}
}
- @CheckForNull transient NavigableSet<K> descendingKeySet;
+ @NullableDecl transient NavigableSet<K> descendingKeySet;
@Override
public NavigableSet<K> descendingKeySet() {
@@ -1501,7 +1444,7 @@
}
}
- @CheckForNull transient NavigableMap<K, V> descendingMap;
+ @NullableDecl transient NavigableMap<K, V> descendingMap;
@Override
public NavigableMap<K, V> descendingMap() {
@@ -1514,23 +1457,20 @@
}
@Override
- @CheckForNull
- public Map.Entry<K, V> firstEntry() {
+ public Entry<K, V> firstEntry() {
synchronized (mutex) {
return nullableSynchronizedEntry(delegate().firstEntry(), mutex);
}
}
@Override
- @CheckForNull
- public Map.Entry<K, V> floorEntry(K key) {
+ public Entry<K, V> floorEntry(K key) {
synchronized (mutex) {
return nullableSynchronizedEntry(delegate().floorEntry(key), mutex);
}
}
@Override
- @CheckForNull
public K floorKey(K key) {
synchronized (mutex) {
return delegate().floorKey(key);
@@ -1550,15 +1490,13 @@
}
@Override
- @CheckForNull
- public Map.Entry<K, V> higherEntry(K key) {
+ public Entry<K, V> higherEntry(K key) {
synchronized (mutex) {
return nullableSynchronizedEntry(delegate().higherEntry(key), mutex);
}
}
@Override
- @CheckForNull
public K higherKey(K key) {
synchronized (mutex) {
return delegate().higherKey(key);
@@ -1566,23 +1504,20 @@
}
@Override
- @CheckForNull
- public Map.Entry<K, V> lastEntry() {
+ public Entry<K, V> lastEntry() {
synchronized (mutex) {
return nullableSynchronizedEntry(delegate().lastEntry(), mutex);
}
}
@Override
- @CheckForNull
- public Map.Entry<K, V> lowerEntry(K key) {
+ public Entry<K, V> lowerEntry(K key) {
synchronized (mutex) {
return nullableSynchronizedEntry(delegate().lowerEntry(key), mutex);
}
}
@Override
- @CheckForNull
public K lowerKey(K key) {
synchronized (mutex) {
return delegate().lowerKey(key);
@@ -1594,7 +1529,7 @@
return navigableKeySet();
}
- @CheckForNull transient NavigableSet<K> navigableKeySet;
+ @NullableDecl transient NavigableSet<K> navigableKeySet;
@Override
public NavigableSet<K> navigableKeySet() {
@@ -1607,16 +1542,14 @@
}
@Override
- @CheckForNull
- public Map.Entry<K, V> pollFirstEntry() {
+ public Entry<K, V> pollFirstEntry() {
synchronized (mutex) {
return nullableSynchronizedEntry(delegate().pollFirstEntry(), mutex);
}
}
@Override
- @CheckForNull
- public Map.Entry<K, V> pollLastEntry() {
+ public Entry<K, V> pollLastEntry() {
synchronized (mutex) {
return nullableSynchronizedEntry(delegate().pollLastEntry(), mutex);
}
@@ -1651,10 +1584,8 @@
}
@GwtIncompatible // works but is needed only for NavigableMap
- @CheckForNull
- private static <K extends @Nullable Object, V extends @Nullable Object>
- Map.Entry<K, V> nullableSynchronizedEntry(
- @CheckForNull Map.Entry<K, V> entry, @CheckForNull Object mutex) {
+ private static <K, V> Entry<K, V> nullableSynchronizedEntry(
+ @NullableDecl Entry<K, V> entry, @NullableDecl Object mutex) {
if (entry == null) {
return null;
}
@@ -1662,21 +1593,20 @@
}
@GwtIncompatible // works but is needed only for NavigableMap
- private static class SynchronizedEntry<K extends @Nullable Object, V extends @Nullable Object>
- extends SynchronizedObject implements Map.Entry<K, V> {
+ private static class SynchronizedEntry<K, V> extends SynchronizedObject implements Entry<K, V> {
- SynchronizedEntry(Map.Entry<K, V> delegate, @CheckForNull Object mutex) {
+ SynchronizedEntry(Entry<K, V> delegate, @NullableDecl Object mutex) {
super(delegate, mutex);
}
@SuppressWarnings("unchecked") // guaranteed by the constructor
@Override
- Map.Entry<K, V> delegate() {
- return (Map.Entry<K, V>) super.delegate();
+ Entry<K, V> delegate() {
+ return (Entry<K, V>) super.delegate();
}
@Override
- public boolean equals(@CheckForNull Object obj) {
+ public boolean equals(Object obj) {
synchronized (mutex) {
return delegate().equals(obj);
}
@@ -1713,14 +1643,13 @@
private static final long serialVersionUID = 0;
}
- static <E extends @Nullable Object> Queue<E> queue(Queue<E> queue, @CheckForNull Object mutex) {
+ static <E> Queue<E> queue(Queue<E> queue, @NullableDecl Object mutex) {
return (queue instanceof SynchronizedQueue) ? queue : new SynchronizedQueue<E>(queue, mutex);
}
- private static class SynchronizedQueue<E extends @Nullable Object>
- extends SynchronizedCollection<E> implements Queue<E> {
+ private static class SynchronizedQueue<E> extends SynchronizedCollection<E> implements Queue<E> {
- SynchronizedQueue(Queue<E> delegate, @CheckForNull Object mutex) {
+ SynchronizedQueue(Queue<E> delegate, @NullableDecl Object mutex) {
super(delegate, mutex);
}
@@ -1744,7 +1673,6 @@
}
@Override
- @CheckForNull
public E peek() {
synchronized (mutex) {
return delegate().peek();
@@ -1752,7 +1680,6 @@
}
@Override
- @CheckForNull
public E poll() {
synchronized (mutex) {
return delegate().poll();
@@ -1769,14 +1696,13 @@
private static final long serialVersionUID = 0;
}
- static <E extends @Nullable Object> Deque<E> deque(Deque<E> deque, @CheckForNull Object mutex) {
+ static <E> Deque<E> deque(Deque<E> deque, @NullableDecl Object mutex) {
return new SynchronizedDeque<E>(deque, mutex);
}
- private static final class SynchronizedDeque<E extends @Nullable Object>
- extends SynchronizedQueue<E> implements Deque<E> {
+ private static final class SynchronizedDeque<E> extends SynchronizedQueue<E> implements Deque<E> {
- SynchronizedDeque(Deque<E> delegate, @CheckForNull Object mutex) {
+ SynchronizedDeque(Deque<E> delegate, @NullableDecl Object mutex) {
super(delegate, mutex);
}
@@ -1828,7 +1754,6 @@
}
@Override
- @CheckForNull
public E pollFirst() {
synchronized (mutex) {
return delegate().pollFirst();
@@ -1836,7 +1761,6 @@
}
@Override
- @CheckForNull
public E pollLast() {
synchronized (mutex) {
return delegate().pollLast();
@@ -1858,7 +1782,6 @@
}
@Override
- @CheckForNull
public E peekFirst() {
synchronized (mutex) {
return delegate().peekFirst();
@@ -1866,7 +1789,6 @@
}
@Override
- @CheckForNull
public E peekLast() {
synchronized (mutex) {
return delegate().peekLast();
@@ -1874,14 +1796,14 @@
}
@Override
- public boolean removeFirstOccurrence(@CheckForNull Object o) {
+ public boolean removeFirstOccurrence(Object o) {
synchronized (mutex) {
return delegate().removeFirstOccurrence(o);
}
}
@Override
- public boolean removeLastOccurrence(@CheckForNull Object o) {
+ public boolean removeLastOccurrence(Object o) {
synchronized (mutex) {
return delegate().removeLastOccurrence(o);
}
@@ -1911,16 +1833,14 @@
private static final long serialVersionUID = 0;
}
- static <R extends @Nullable Object, C extends @Nullable Object, V extends @Nullable Object>
- Table<R, C, V> table(Table<R, C, V> table, @CheckForNull Object mutex) {
+ static <R, C, V> Table<R, C, V> table(Table<R, C, V> table, Object mutex) {
return new SynchronizedTable<>(table, mutex);
}
- private static final class SynchronizedTable<
- R extends @Nullable Object, C extends @Nullable Object, V extends @Nullable Object>
- extends SynchronizedObject implements Table<R, C, V> {
+ private static final class SynchronizedTable<R, C, V> extends SynchronizedObject
+ implements Table<R, C, V> {
- SynchronizedTable(Table<R, C, V> delegate, @CheckForNull Object mutex) {
+ SynchronizedTable(Table<R, C, V> delegate, Object mutex) {
super(delegate, mutex);
}
@@ -1931,36 +1851,35 @@
}
@Override
- public boolean contains(@CheckForNull Object rowKey, @CheckForNull Object columnKey) {
+ public boolean contains(@NullableDecl Object rowKey, @NullableDecl Object columnKey) {
synchronized (mutex) {
return delegate().contains(rowKey, columnKey);
}
}
@Override
- public boolean containsRow(@CheckForNull Object rowKey) {
+ public boolean containsRow(@NullableDecl Object rowKey) {
synchronized (mutex) {
return delegate().containsRow(rowKey);
}
}
@Override
- public boolean containsColumn(@CheckForNull Object columnKey) {
+ public boolean containsColumn(@NullableDecl Object columnKey) {
synchronized (mutex) {
return delegate().containsColumn(columnKey);
}
}
@Override
- public boolean containsValue(@CheckForNull Object value) {
+ public boolean containsValue(@NullableDecl Object value) {
synchronized (mutex) {
return delegate().containsValue(value);
}
}
@Override
- @CheckForNull
- public V get(@CheckForNull Object rowKey, @CheckForNull Object columnKey) {
+ public V get(@NullableDecl Object rowKey, @NullableDecl Object columnKey) {
synchronized (mutex) {
return delegate().get(rowKey, columnKey);
}
@@ -1988,8 +1907,7 @@
}
@Override
- @CheckForNull
- public V put(R rowKey, C columnKey, V value) {
+ public V put(@NullableDecl R rowKey, @NullableDecl C columnKey, @NullableDecl V value) {
synchronized (mutex) {
return delegate().put(rowKey, columnKey, value);
}
@@ -2003,22 +1921,21 @@
}
@Override
- @CheckForNull
- public V remove(@CheckForNull Object rowKey, @CheckForNull Object columnKey) {
+ public V remove(@NullableDecl Object rowKey, @NullableDecl Object columnKey) {
synchronized (mutex) {
return delegate().remove(rowKey, columnKey);
}
}
@Override
- public Map<C, V> row(R rowKey) {
+ public Map<C, V> row(@NullableDecl R rowKey) {
synchronized (mutex) {
return map(delegate().row(rowKey), mutex);
}
}
@Override
- public Map<R, V> column(C columnKey) {
+ public Map<R, V> column(@NullableDecl C columnKey) {
synchronized (mutex) {
return map(delegate().column(columnKey), mutex);
}
@@ -2092,7 +2009,7 @@
}
@Override
- public boolean equals(@CheckForNull Object obj) {
+ public boolean equals(@NullableDecl Object obj) {
if (this == obj) {
return true;
}
diff --git a/android/guava/src/com/google/common/collect/Table.java b/android/guava/src/com/google/common/collect/Table.java
index 97d3f70..1348794 100644
--- a/android/guava/src/com/google/common/collect/Table.java
+++ b/android/guava/src/com/google/common/collect/Table.java
@@ -24,8 +24,7 @@
import java.util.Collection;
import java.util.Map;
import java.util.Set;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* A collection that associates an ordered pair of keys, called a row key and a column key, with a
@@ -56,9 +55,7 @@
*/
@DoNotMock("Use ImmutableTable, HashBasedTable, or another implementation")
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-public interface Table<
- R extends @Nullable Object, C extends @Nullable Object, V extends @Nullable Object> {
+public interface Table<R, C, V> {
// TODO(jlevy): Consider adding methods similar to ConcurrentMap methods.
// Accessors
@@ -70,29 +67,29 @@
* @param columnKey key of column to search for
*/
boolean contains(
- @CompatibleWith("R") @CheckForNull Object rowKey,
- @CompatibleWith("C") @CheckForNull Object columnKey);
+ @NullableDecl @CompatibleWith("R") Object rowKey,
+ @NullableDecl @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(@CompatibleWith("R") @CheckForNull Object rowKey);
+ boolean containsRow(@NullableDecl @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(@CompatibleWith("C") @CheckForNull Object columnKey);
+ boolean containsColumn(@NullableDecl @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(@CompatibleWith("V") @CheckForNull Object value);
+ boolean containsValue(@NullableDecl @CompatibleWith("V") Object value);
/**
* Returns the value corresponding to the given row and column keys, or {@code null} if no such
@@ -101,10 +98,10 @@
* @param rowKey key of row to search for
* @param columnKey key of column to search for
*/
- @CheckForNull
+ @NullableDecl
V get(
- @CompatibleWith("R") @CheckForNull Object rowKey,
- @CompatibleWith("C") @CheckForNull Object columnKey);
+ @NullableDecl @CompatibleWith("R") Object rowKey,
+ @NullableDecl @CompatibleWith("C") Object columnKey);
/** Returns {@code true} if the table contains no mappings. */
boolean isEmpty();
@@ -117,7 +114,7 @@
* cell views, as returned by {@link #cellSet}, are equal.
*/
@Override
- boolean equals(@CheckForNull Object obj);
+ boolean equals(@NullableDecl Object obj);
/**
* Returns the hash code for this table. The hash code of a table is defined as the hash code of
@@ -142,8 +139,8 @@
* for the keys
*/
@CanIgnoreReturnValue
- @CheckForNull
- V put(@ParametricNullness R rowKey, @ParametricNullness C columnKey, @ParametricNullness V value);
+ @NullableDecl
+ V put(R rowKey, C columnKey, V value);
/**
* Copies all mappings from the specified table to this table. The effect is equivalent to calling
@@ -161,10 +158,10 @@
* @return the value previously associated with the keys, or {@code null} if no such value existed
*/
@CanIgnoreReturnValue
- @CheckForNull
+ @NullableDecl
V remove(
- @CompatibleWith("R") @CheckForNull Object rowKey,
- @CompatibleWith("C") @CheckForNull Object columnKey);
+ @NullableDecl @CompatibleWith("R") Object rowKey,
+ @NullableDecl @CompatibleWith("C") Object columnKey);
// Views
@@ -178,7 +175,7 @@
* @param rowKey key of row to search for in the table
* @return the corresponding map from column keys to values
*/
- Map<C, V> row(@ParametricNullness R rowKey);
+ Map<C, V> row(R rowKey);
/**
* Returns a view of all mappings that have the given column key. For each row key / column key /
@@ -190,7 +187,7 @@
* @param columnKey key of column to search for in the table
* @return the corresponding map from row keys to values
*/
- Map<R, V> column(@ParametricNullness C columnKey);
+ Map<R, V> column(C columnKey);
/**
* Returns a set of all row key / column key / value triplets. Changes to the returned set will
@@ -256,18 +253,17 @@
*
* @since 7.0
*/
- interface Cell<
- R extends @Nullable Object, C extends @Nullable Object, V extends @Nullable Object> {
+ interface Cell<R, C, V> {
/** Returns the row key of this cell. */
- @ParametricNullness
+ @NullableDecl
R getRowKey();
/** Returns the column key of this cell. */
- @ParametricNullness
+ @NullableDecl
C getColumnKey();
/** Returns the value of this cell. */
- @ParametricNullness
+ @NullableDecl
V getValue();
/**
@@ -275,7 +271,7 @@
* equal row keys, column keys, and values.
*/
@Override
- boolean equals(@CheckForNull Object obj);
+ boolean equals(@NullableDecl Object obj);
/**
* Returns the hash code of this cell.
diff --git a/android/guava/src/com/google/common/collect/Tables.java b/android/guava/src/com/google/common/collect/Tables.java
index 772a75d..77c920c 100644
--- a/android/guava/src/com/google/common/collect/Tables.java
+++ b/android/guava/src/com/google/common/collect/Tables.java
@@ -18,7 +18,6 @@
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.collect.NullnessCasts.uncheckedCastNullableTToT;
import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtCompatible;
@@ -34,8 +33,7 @@
import java.util.Set;
import java.util.SortedMap;
import java.util.SortedSet;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* Provides static methods that involve a {@code Table}.
@@ -48,7 +46,6 @@
* @since 7.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
public final class Tables {
private Tables() {}
@@ -61,44 +58,33 @@
* @param columnKey the column key to be associated with the returned cell
* @param value the value to be associated with the returned cell
*/
- public static <R extends @Nullable Object, C extends @Nullable Object, V extends @Nullable Object>
- Cell<R, C, V> immutableCell(
- @ParametricNullness R rowKey,
- @ParametricNullness C columnKey,
- @ParametricNullness V value) {
+ public static <R, C, V> Cell<R, C, V> immutableCell(
+ @NullableDecl R rowKey, @NullableDecl C columnKey, @NullableDecl V value) {
return new ImmutableCell<>(rowKey, columnKey, value);
}
- static final class ImmutableCell<
- R extends @Nullable Object, C extends @Nullable Object, V extends @Nullable Object>
- extends AbstractCell<R, C, V> implements Serializable {
- @ParametricNullness private final R rowKey;
- @ParametricNullness private final C columnKey;
- @ParametricNullness private final V value;
+ static final class ImmutableCell<R, C, V> extends AbstractCell<R, C, V> implements Serializable {
+ @NullableDecl private final R rowKey;
+ @NullableDecl private final C columnKey;
+ @NullableDecl private final V value;
- ImmutableCell(
- @ParametricNullness R rowKey,
- @ParametricNullness C columnKey,
- @ParametricNullness V value) {
+ ImmutableCell(@NullableDecl R rowKey, @NullableDecl C columnKey, @NullableDecl V value) {
this.rowKey = rowKey;
this.columnKey = columnKey;
this.value = value;
}
@Override
- @ParametricNullness
public R getRowKey() {
return rowKey;
}
@Override
- @ParametricNullness
public C getColumnKey() {
return columnKey;
}
@Override
- @ParametricNullness
public V getValue() {
return value;
}
@@ -106,14 +92,12 @@
private static final long serialVersionUID = 0;
}
- abstract static class AbstractCell<
- R extends @Nullable Object, C extends @Nullable Object, V extends @Nullable Object>
- implements Cell<R, C, V> {
+ abstract static class AbstractCell<R, C, V> implements Cell<R, C, V> {
// needed for serialization
AbstractCell() {}
@Override
- public boolean equals(@CheckForNull Object obj) {
+ public boolean equals(Object obj) {
if (obj == this) {
return true;
}
@@ -149,16 +133,13 @@
* columnKeySet().iterator()} doesn't. With a transposed {@link HashBasedTable}, it's the other
* way around.
*/
- public static <R extends @Nullable Object, C extends @Nullable Object, V extends @Nullable Object>
- Table<C, R, V> transpose(Table<R, C, V> table) {
+ public static <R, C, V> Table<C, R, V> transpose(Table<R, C, V> table) {
return (table instanceof TransposeTable)
? ((TransposeTable<R, C, V>) table).original
: new TransposeTable<C, R, V>(table);
}
- private static class TransposeTable<
- C extends @Nullable Object, R extends @Nullable Object, V extends @Nullable Object>
- extends AbstractTable<C, R, V> {
+ private static class TransposeTable<C, R, V> extends AbstractTable<C, R, V> {
final Table<R, C, V> original;
TransposeTable(Table<R, C, V> original) {
@@ -171,7 +152,7 @@
}
@Override
- public Map<C, V> column(@ParametricNullness R columnKey) {
+ public Map<C, V> column(R columnKey) {
return original.row(columnKey);
}
@@ -186,37 +167,32 @@
}
@Override
- public boolean contains(@CheckForNull Object rowKey, @CheckForNull Object columnKey) {
+ public boolean contains(@NullableDecl Object rowKey, @NullableDecl Object columnKey) {
return original.contains(columnKey, rowKey);
}
@Override
- public boolean containsColumn(@CheckForNull Object columnKey) {
+ public boolean containsColumn(@NullableDecl Object columnKey) {
return original.containsRow(columnKey);
}
@Override
- public boolean containsRow(@CheckForNull Object rowKey) {
+ public boolean containsRow(@NullableDecl Object rowKey) {
return original.containsColumn(rowKey);
}
@Override
- public boolean containsValue(@CheckForNull Object value) {
+ public boolean containsValue(@NullableDecl Object value) {
return original.containsValue(value);
}
@Override
- @CheckForNull
- public V get(@CheckForNull Object rowKey, @CheckForNull Object columnKey) {
+ public V get(@NullableDecl Object rowKey, @NullableDecl Object columnKey) {
return original.get(columnKey, rowKey);
}
@Override
- @CheckForNull
- public V put(
- @ParametricNullness C rowKey,
- @ParametricNullness R columnKey,
- @ParametricNullness V value) {
+ public V put(C rowKey, R columnKey, V value) {
return original.put(columnKey, rowKey, value);
}
@@ -226,13 +202,12 @@
}
@Override
- @CheckForNull
- public V remove(@CheckForNull Object rowKey, @CheckForNull Object columnKey) {
+ public V remove(@NullableDecl Object rowKey, @NullableDecl Object columnKey) {
return original.remove(columnKey, rowKey);
}
@Override
- public Map<R, V> row(@ParametricNullness C rowKey) {
+ public Map<R, V> row(C rowKey) {
return original.column(rowKey);
}
@@ -341,22 +316,12 @@
* @since 10.0
*/
@Beta
- public static <
- R extends @Nullable Object,
- C extends @Nullable Object,
- V1 extends @Nullable Object,
- V2 extends @Nullable Object>
- Table<R, C, V2> transformValues(
- Table<R, C, V1> fromTable, Function<? super V1, V2> function) {
+ public static <R, C, V1, V2> Table<R, C, V2> transformValues(
+ Table<R, C, V1> fromTable, Function<? super V1, V2> function) {
return new TransformedTable<>(fromTable, function);
}
- private static class TransformedTable<
- R extends @Nullable Object,
- C extends @Nullable Object,
- V1 extends @Nullable Object,
- V2 extends @Nullable Object>
- extends AbstractTable<R, C, V2> {
+ private static class TransformedTable<R, C, V1, V2> extends AbstractTable<R, C, V2> {
final Table<R, C, V1> fromTable;
final Function<? super V1, V2> function;
@@ -366,19 +331,15 @@
}
@Override
- public boolean contains(@CheckForNull Object rowKey, @CheckForNull Object columnKey) {
+ public boolean contains(Object rowKey, Object columnKey) {
return fromTable.contains(rowKey, columnKey);
}
@Override
- @CheckForNull
- public V2 get(@CheckForNull Object rowKey, @CheckForNull Object columnKey) {
+ public V2 get(Object rowKey, Object columnKey) {
// The function is passed a null input only when the table contains a null
// value.
- // The cast is safe because of the contains() check.
- return contains(rowKey, columnKey)
- ? function.apply(uncheckedCastNullableTToT(fromTable.get(rowKey, columnKey)))
- : null;
+ return contains(rowKey, columnKey) ? function.apply(fromTable.get(rowKey, columnKey)) : null;
}
@Override
@@ -392,11 +353,7 @@
}
@Override
- @CheckForNull
- public V2 put(
- @ParametricNullness R rowKey,
- @ParametricNullness C columnKey,
- @ParametricNullness V2 value) {
+ public V2 put(R rowKey, C columnKey, V2 value) {
throw new UnsupportedOperationException();
}
@@ -406,21 +363,19 @@
}
@Override
- @CheckForNull
- public V2 remove(@CheckForNull Object rowKey, @CheckForNull Object columnKey) {
+ public V2 remove(Object rowKey, Object columnKey) {
return contains(rowKey, columnKey)
- // The cast is safe because of the contains() check.
- ? function.apply(uncheckedCastNullableTToT(fromTable.remove(rowKey, columnKey)))
+ ? function.apply(fromTable.remove(rowKey, columnKey))
: null;
}
@Override
- public Map<C, V2> row(@ParametricNullness R rowKey) {
+ public Map<C, V2> row(R rowKey) {
return Maps.transformValues(fromTable.row(rowKey), function);
}
@Override
- public Map<R, V2> column(@ParametricNullness C columnKey) {
+ public Map<R, V2> column(C columnKey) {
return Maps.transformValues(fromTable.column(columnKey), function);
}
@@ -491,14 +446,13 @@
*
* @since 11.0
*/
- public static <R extends @Nullable Object, C extends @Nullable Object, V extends @Nullable Object>
- Table<R, C, V> unmodifiableTable(Table<? extends R, ? extends C, ? extends V> table) {
+ public static <R, C, V> Table<R, C, V> unmodifiableTable(
+ Table<? extends R, ? extends C, ? extends V> table) {
return new UnmodifiableTable<>(table);
}
- private static class UnmodifiableTable<
- R extends @Nullable Object, C extends @Nullable Object, V extends @Nullable Object>
- extends ForwardingTable<R, C, V> implements Serializable {
+ private static class UnmodifiableTable<R, C, V> extends ForwardingTable<R, C, V>
+ implements Serializable {
final Table<? extends R, ? extends C, ? extends V> delegate;
UnmodifiableTable(Table<? extends R, ? extends C, ? extends V> delegate) {
@@ -522,7 +476,7 @@
}
@Override
- public Map<R, V> column(@ParametricNullness C columnKey) {
+ public Map<R, V> column(@NullableDecl C columnKey) {
return Collections.unmodifiableMap(super.column(columnKey));
}
@@ -538,11 +492,7 @@
}
@Override
- @CheckForNull
- public V put(
- @ParametricNullness R rowKey,
- @ParametricNullness C columnKey,
- @ParametricNullness V value) {
+ public V put(@NullableDecl R rowKey, @NullableDecl C columnKey, @NullableDecl V value) {
throw new UnsupportedOperationException();
}
@@ -552,13 +502,12 @@
}
@Override
- @CheckForNull
- public V remove(@CheckForNull Object rowKey, @CheckForNull Object columnKey) {
+ public V remove(@NullableDecl Object rowKey, @NullableDecl Object columnKey) {
throw new UnsupportedOperationException();
}
@Override
- public Map<C, V> row(@ParametricNullness R rowKey) {
+ public Map<C, V> row(@NullableDecl R rowKey) {
return Collections.unmodifiableMap(super.row(rowKey));
}
@@ -594,9 +543,8 @@
* @since 11.0
*/
@Beta
- public static <R extends @Nullable Object, C extends @Nullable Object, V extends @Nullable Object>
- RowSortedTable<R, C, V> unmodifiableRowSortedTable(
- RowSortedTable<R, ? extends C, ? extends V> table) {
+ public static <R, C, V> RowSortedTable<R, C, V> unmodifiableRowSortedTable(
+ RowSortedTable<R, ? extends C, ? extends V> table) {
/*
* It's not ? extends R, because it's technically not covariant in R. Specifically,
* table.rowMap().comparator() could return a comparator that only works for the ? extends R.
@@ -605,9 +553,8 @@
return new UnmodifiableRowSortedMap<>(table);
}
- static final class UnmodifiableRowSortedMap<
- R extends @Nullable Object, C extends @Nullable Object, V extends @Nullable Object>
- extends UnmodifiableTable<R, C, V> implements RowSortedTable<R, C, V> {
+ static final class UnmodifiableRowSortedMap<R, C, V> extends UnmodifiableTable<R, C, V>
+ implements RowSortedTable<R, C, V> {
public UnmodifiableRowSortedMap(RowSortedTable<R, ? extends C, ? extends V> delegate) {
super(delegate);
@@ -633,8 +580,7 @@
}
@SuppressWarnings("unchecked")
- private static <K extends @Nullable Object, V extends @Nullable Object>
- Function<Map<K, V>, Map<K, V>> unmodifiableWrapper() {
+ private static <K, V> Function<Map<K, V>, Map<K, V>> unmodifiableWrapper() {
return (Function) UNMODIFIABLE_WRAPPER;
}
@@ -675,12 +621,11 @@
* @return a synchronized view of the specified table
* @since 22.0
*/
- public static <R extends @Nullable Object, C extends @Nullable Object, V extends @Nullable Object>
- Table<R, C, V> synchronizedTable(Table<R, C, V> table) {
+ public static <R, C, V> Table<R, C, V> synchronizedTable(Table<R, C, V> table) {
return Synchronized.table(table, null);
}
- static boolean equalsImpl(Table<?, ?, ?> table, @CheckForNull Object obj) {
+ static boolean equalsImpl(Table<?, ?, ?> table, @NullableDecl Object obj) {
if (obj == table) {
return true;
} else if (obj instanceof Table) {
diff --git a/android/guava/src/com/google/common/collect/TopKSelector.java b/android/guava/src/com/google/common/collect/TopKSelector.java
index f8cca0d..5e4b200 100644
--- a/android/guava/src/com/google/common/collect/TopKSelector.java
+++ b/android/guava/src/com/google/common/collect/TopKSelector.java
@@ -18,7 +18,6 @@
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.collect.NullnessCasts.uncheckedCastNullableTToT;
import com.google.common.annotations.GwtCompatible;
import com.google.common.math.IntMath;
@@ -28,8 +27,7 @@
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* An accumulator that selects the "top" {@code k} elements added to it, relative to a provided
@@ -52,10 +50,7 @@
*
* @author Louis Wasserman
*/
-@GwtCompatible
-@ElementTypesAreNonnullByDefault
-final class TopKSelector<
- T extends @Nullable Object> {
+@GwtCompatible final class TopKSelector<T> {
/**
* Returns a {@code TopKSelector} that collects the lowest {@code k} elements added to it,
@@ -74,8 +69,7 @@
*
* @throws IllegalArgumentException if {@code k < 0} or {@code k > Integer.MAX_VALUE / 2}
*/
- public static <T extends @Nullable Object> TopKSelector<T> least(
- int k, Comparator<? super T> comparator) {
+ public static <T> TopKSelector<T> least(int k, Comparator<? super T> comparator) {
return new TopKSelector<T>(comparator, k);
}
@@ -96,8 +90,7 @@
*
* @throws IllegalArgumentException if {@code k < 0} or {@code k > Integer.MAX_VALUE / 2}
*/
- public static <T extends @Nullable Object> TopKSelector<T> greatest(
- int k, Comparator<? super T> comparator) {
+ public static <T> TopKSelector<T> greatest(int k, Comparator<? super T> comparator) {
return new TopKSelector<T>(Ordering.from(comparator).reverse(), k);
}
@@ -109,14 +102,14 @@
* for the top k elements. Whenever the buffer is filled, we quickselect the top k elements to the
* range [0, k) and ignore the remaining elements.
*/
- private final @Nullable T[] buffer;
+ private final T[] buffer;
private int bufferSize;
/**
* 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.
*/
- @CheckForNull private T threshold;
+ @NullableDecl private T threshold;
private TopKSelector(Comparator<? super T> comparator, int k) {
this.comparator = checkNotNull(comparator, "comparator");
@@ -132,7 +125,7 @@
* Adds {@code elem} as a candidate for the top {@code k} elements. This operation takes amortized
* O(1) time.
*/
- public void offer(@ParametricNullness T elem) {
+ public void offer(@NullableDecl T elem) {
if (k == 0) {
return;
} else if (bufferSize == 0) {
@@ -141,12 +134,10 @@
bufferSize = 1;
} else if (bufferSize < k) {
buffer[bufferSize++] = elem;
- // uncheckedCastNullableTToT is safe because bufferSize > 0.
- if (comparator.compare(elem, uncheckedCastNullableTToT(threshold)) > 0) {
+ if (comparator.compare(elem, threshold) > 0) {
threshold = elem;
}
- // uncheckedCastNullableTToT is safe because bufferSize > 0.
- } else if (comparator.compare(elem, uncheckedCastNullableTToT(threshold)) < 0) {
+ } else if (comparator.compare(elem, threshold) < 0) {
// Otherwise, we can ignore elem; we've seen k better elements.
buffer[bufferSize++] = elem;
if (bufferSize == 2 * k) {
@@ -185,17 +176,15 @@
iterations++;
if (iterations >= maxIterations) {
// We've already taken O(k log k), let's make sure we don't take longer than O(k log k).
- Arrays.sort(buffer, left, right + 1, comparator);
+ Arrays.sort(buffer, left, right, comparator);
break;
}
}
bufferSize = k;
- threshold = uncheckedCastNullableTToT(buffer[minThresholdPosition]);
+ threshold = buffer[minThresholdPosition];
for (int i = minThresholdPosition + 1; i < k; i++) {
- if (comparator.compare(
- uncheckedCastNullableTToT(buffer[i]), uncheckedCastNullableTToT(threshold))
- > 0) {
+ if (comparator.compare(buffer[i], threshold) > 0) {
threshold = buffer[i];
}
}
@@ -208,12 +197,12 @@
* (pivotNewIndex, right] is greater than pivotValue.
*/
private int partition(int left, int right, int pivotIndex) {
- T pivotValue = uncheckedCastNullableTToT(buffer[pivotIndex]);
+ T pivotValue = buffer[pivotIndex];
buffer[pivotIndex] = buffer[right];
int pivotNewIndex = left;
for (int i = left; i < right; i++) {
- if (comparator.compare(uncheckedCastNullableTToT(buffer[i]), pivotValue) < 0) {
+ if (comparator.compare(buffer[i], pivotValue) < 0) {
swap(pivotNewIndex, i);
pivotNewIndex++;
}
diff --git a/android/guava/src/com/google/common/collect/TransformedIterator.java b/android/guava/src/com/google/common/collect/TransformedIterator.java
index 2456cec..b7214b8 100644
--- a/android/guava/src/com/google/common/collect/TransformedIterator.java
+++ b/android/guava/src/com/google/common/collect/TransformedIterator.java
@@ -20,7 +20,6 @@
import com.google.common.annotations.GwtCompatible;
import java.util.Iterator;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* An iterator that transforms a backing iterator; for internal use. This avoids the object overhead
@@ -29,17 +28,14 @@
* @author Louis Wasserman
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-abstract class TransformedIterator<F extends @Nullable Object, T extends @Nullable Object>
- implements Iterator<T> {
+abstract class TransformedIterator<F, T> implements Iterator<T> {
final Iterator<? extends F> backingIterator;
TransformedIterator(Iterator<? extends F> backingIterator) {
this.backingIterator = checkNotNull(backingIterator);
}
- @ParametricNullness
- abstract T transform(@ParametricNullness F from);
+ abstract T transform(F from);
@Override
public final boolean hasNext() {
@@ -47,7 +43,6 @@
}
@Override
- @ParametricNullness
public final T next() {
return transform(backingIterator.next());
}
diff --git a/android/guava/src/com/google/common/collect/TransformedListIterator.java b/android/guava/src/com/google/common/collect/TransformedListIterator.java
index 66b42e4..ac2eea1 100644
--- a/android/guava/src/com/google/common/collect/TransformedListIterator.java
+++ b/android/guava/src/com/google/common/collect/TransformedListIterator.java
@@ -19,7 +19,6 @@
import com.google.common.annotations.GwtCompatible;
import com.google.common.base.Function;
import java.util.ListIterator;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* An iterator that transforms a backing list iterator; for internal use. This avoids the object
@@ -28,9 +27,8 @@
* @author Louis Wasserman
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-abstract class TransformedListIterator<F extends @Nullable Object, T extends @Nullable Object>
- extends TransformedIterator<F, T> implements ListIterator<T> {
+abstract class TransformedListIterator<F, T> extends TransformedIterator<F, T>
+ implements ListIterator<T> {
TransformedListIterator(ListIterator<? extends F> backingIterator) {
super(backingIterator);
}
@@ -45,7 +43,6 @@
}
@Override
- @ParametricNullness
public final T previous() {
return transform(backingIterator().previous());
}
@@ -61,12 +58,12 @@
}
@Override
- public void set(@ParametricNullness T element) {
+ public void set(T element) {
throw new UnsupportedOperationException();
}
@Override
- public void add(@ParametricNullness T element) {
+ public void add(T element) {
throw new UnsupportedOperationException();
}
}
diff --git a/android/guava/src/com/google/common/collect/TreeBasedTable.java b/android/guava/src/com/google/common/collect/TreeBasedTable.java
index 315404a..dc665eb 100644
--- a/android/guava/src/com/google/common/collect/TreeBasedTable.java
+++ b/android/guava/src/com/google/common/collect/TreeBasedTable.java
@@ -18,7 +18,6 @@
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
-import static java.util.Objects.requireNonNull;
import com.google.common.annotations.GwtCompatible;
import com.google.common.base.Function;
@@ -32,7 +31,7 @@
import java.util.SortedMap;
import java.util.SortedSet;
import java.util.TreeMap;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* Implementation of {@code Table} whose row keys and column keys are ordered by their natural
@@ -67,7 +66,6 @@
* @since 7.0
*/
@GwtCompatible(serializable = true)
-@ElementTypesAreNonnullByDefault
public class TreeBasedTable<R, C, V> extends StandardRowSortedTable<R, C, V> {
private final Comparator<? super C> columnComparator;
@@ -137,11 +135,7 @@
*/
@Deprecated
public Comparator<? super R> rowComparator() {
- /*
- * requireNonNull is safe because the factories require non-null Comparators, which they pass on
- * to the backing collections.
- */
- return requireNonNull(rowKeySet().comparator());
+ return rowKeySet().comparator();
}
/**
@@ -175,14 +169,14 @@
}
private class TreeRow extends Row implements SortedMap<C, V> {
- @CheckForNull final C lowerBound;
- @CheckForNull final C upperBound;
+ @NullableDecl final C lowerBound;
+ @NullableDecl final C upperBound;
TreeRow(R rowKey) {
this(rowKey, null, null);
}
- TreeRow(R rowKey, @CheckForNull C lowerBound, @CheckForNull C upperBound) {
+ TreeRow(R rowKey, @NullableDecl C lowerBound, @NullableDecl C upperBound) {
super(rowKey);
this.lowerBound = lowerBound;
this.upperBound = upperBound;
@@ -207,7 +201,7 @@
return cmp.compare(a, b);
}
- boolean rangeContains(@CheckForNull Object o) {
+ boolean rangeContains(@NullableDecl Object o) {
return o != null
&& (lowerBound == null || compare(lowerBound, o) <= 0)
&& (upperBound == null || compare(upperBound, o) > 0);
@@ -233,36 +227,43 @@
@Override
public C firstKey() {
- updateBackingRowMapField();
- if (backingRowMap == null) {
+ SortedMap<C, V> backing = backingRowMap();
+ if (backing == null) {
throw new NoSuchElementException();
}
- return ((SortedMap<C, V>) backingRowMap).firstKey();
+ return backingRowMap().firstKey();
}
@Override
public C lastKey() {
- updateBackingRowMapField();
- if (backingRowMap == null) {
+ SortedMap<C, V> backing = backingRowMap();
+ if (backing == null) {
throw new NoSuchElementException();
}
- return ((SortedMap<C, V>) backingRowMap).lastKey();
+ return backingRowMap().lastKey();
}
- @CheckForNull transient SortedMap<C, V> wholeRow;
+ @NullableDecl transient SortedMap<C, V> wholeRow;
- // If the row was previously empty, we check if there's a new row here every time we're queried.
- void updateWholeRowField() {
+ /*
+ * If the row was previously empty, we check if there's a new row here every
+ * time we're queried.
+ */
+ SortedMap<C, V> wholeRow() {
if (wholeRow == null || (wholeRow.isEmpty() && backingMap.containsKey(rowKey))) {
wholeRow = (SortedMap<C, V>) backingMap.get(rowKey);
}
+ return wholeRow;
}
@Override
- @CheckForNull
+ SortedMap<C, V> backingRowMap() {
+ return (SortedMap<C, V>) super.backingRowMap();
+ }
+
+ @Override
SortedMap<C, V> computeBackingRowMap() {
- updateWholeRowField();
- SortedMap<C, V> map = wholeRow;
+ SortedMap<C, V> map = wholeRow();
if (map != null) {
if (lowerBound != null) {
map = map.tailMap(lowerBound);
@@ -277,8 +278,7 @@
@Override
void maintainEmptyInvariant() {
- updateWholeRowField();
- if (wholeRow != null && wholeRow.isEmpty()) {
+ if (wholeRow() != null && wholeRow.isEmpty()) {
backingMap.remove(rowKey);
wholeRow = null;
backingRowMap = null;
@@ -286,12 +286,11 @@
}
@Override
- public boolean containsKey(@CheckForNull Object key) {
+ public boolean containsKey(Object key) {
return rangeContains(key) && super.containsKey(key);
}
@Override
- @CheckForNull
public V put(C key, V value) {
checkArgument(rangeContains(checkNotNull(key)));
return super.put(key, value);
@@ -328,10 +327,9 @@
comparator);
return new AbstractIterator<C>() {
- @CheckForNull C lastValue;
+ @NullableDecl C lastValue;
@Override
- @CheckForNull
protected C computeNext() {
while (merged.hasNext()) {
C next = merged.next();
diff --git a/android/guava/src/com/google/common/collect/TreeMultimap.java b/android/guava/src/com/google/common/collect/TreeMultimap.java
index 04ae207..85531e3 100644
--- a/android/guava/src/com/google/common/collect/TreeMultimap.java
+++ b/android/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.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* Implementation of {@code Multimap} whose keys and values are ordered by their natural ordering or
@@ -72,9 +72,7 @@
* @since 2.0
*/
@GwtCompatible(serializable = true, emulated = true)
-@ElementTypesAreNonnullByDefault
-public class TreeMultimap<K extends @Nullable Object, V extends @Nullable Object>
- extends AbstractSortedKeySortedSetMultimap<K, V> {
+public class TreeMultimap<K, V> extends AbstractSortedKeySortedSetMultimap<K, V> {
private transient Comparator<? super K> keyComparator;
private transient Comparator<? super V> valueComparator;
@@ -92,7 +90,7 @@
* @param keyComparator the comparator that determines the key ordering
* @param valueComparator the comparator that determines the value ordering
*/
- public static <K extends @Nullable Object, V extends @Nullable Object> TreeMultimap<K, V> create(
+ public static <K, V> TreeMultimap<K, V> create(
Comparator<? super K> keyComparator, Comparator<? super V> valueComparator) {
return new TreeMultimap<>(checkNotNull(keyComparator), checkNotNull(valueComparator));
}
@@ -140,7 +138,7 @@
}
@Override
- Collection<V> createCollection(@ParametricNullness K key) {
+ Collection<V> createCollection(@NullableDecl K key) {
if (key == null) {
keyComparator().compare(key, key);
}
@@ -165,7 +163,7 @@
/** @since 14.0 (present with return type {@code SortedSet} since 2.0) */
@Override
@GwtIncompatible // NavigableSet
- public NavigableSet<V> get(@ParametricNullness K key) {
+ public NavigableSet<V> get(@NullableDecl K key) {
return (NavigableSet<V>) super.get(key);
}
diff --git a/android/guava/src/com/google/common/collect/TreeMultiset.java b/android/guava/src/com/google/common/collect/TreeMultiset.java
index c64c35a..dac0eab 100644
--- a/android/guava/src/com/google/common/collect/TreeMultiset.java
+++ b/android/guava/src/com/google/common/collect/TreeMultiset.java
@@ -19,8 +19,7 @@
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkState;
import static com.google.common.collect.CollectPreconditions.checkNonnegative;
-import static com.google.common.collect.NullnessCasts.uncheckedCastNullableTToT;
-import static java.util.Objects.requireNonNull;
+import static com.google.common.collect.CollectPreconditions.checkRemove;
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.GwtIncompatible;
@@ -35,8 +34,7 @@
import java.util.ConcurrentModificationException;
import java.util.Iterator;
import java.util.NoSuchElementException;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* A multiset which maintains the ordering of its elements, according to either their natural order
@@ -57,9 +55,7 @@
* @since 2.0
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
-public final class TreeMultiset<E extends @Nullable Object> extends AbstractSortedMultiset<E>
- implements Serializable {
+public final class TreeMultiset<E> extends AbstractSortedMultiset<E> implements Serializable {
/**
* Creates a new, empty multiset, sorted according to the elements' natural order. All elements
@@ -89,8 +85,7 @@
* indicates that the elements' <i>natural ordering</i> should be used.
*/
@SuppressWarnings("unchecked")
- public static <E extends @Nullable Object> TreeMultiset<E> create(
- @CheckForNull Comparator<? super E> comparator) {
+ public static <E> TreeMultiset<E> create(@NullableDecl Comparator<? super E> comparator) {
return (comparator == null)
? new TreeMultiset<E>((Comparator) Ordering.natural())
: new TreeMultiset<E>(comparator);
@@ -125,7 +120,7 @@
TreeMultiset(Comparator<? super E> comparator) {
super(comparator);
this.range = GeneralRange.all(comparator);
- this.header = new AvlNode<>();
+ this.header = new AvlNode<E>(null, 1);
successor(header, header);
this.rootReference = new Reference<>();
}
@@ -139,7 +134,7 @@
}
@Override
- long treeAggregate(@CheckForNull AvlNode<?> root) {
+ long treeAggregate(@NullableDecl AvlNode<?> root) {
return (root == null) ? 0 : root.totalCount;
}
},
@@ -150,14 +145,14 @@
}
@Override
- long treeAggregate(@CheckForNull AvlNode<?> root) {
+ long treeAggregate(@NullableDecl AvlNode<?> root) {
return (root == null) ? 0 : root.distinctElements;
}
};
abstract int nodeAggregate(AvlNode<?> node);
- abstract long treeAggregate(@CheckForNull AvlNode<?> root);
+ abstract long treeAggregate(@NullableDecl AvlNode<?> root);
}
private long aggregateForEntries(Aggregate aggr) {
@@ -172,14 +167,11 @@
return total;
}
- private long aggregateBelowRange(Aggregate aggr, @CheckForNull AvlNode<E> node) {
+ private long aggregateBelowRange(Aggregate aggr, @NullableDecl AvlNode<E> node) {
if (node == null) {
return 0;
}
- // The cast is safe because we call this method only if hasLowerBound().
- int cmp =
- comparator()
- .compare(uncheckedCastNullableTToT(range.getLowerEndpoint()), node.getElement());
+ int cmp = comparator().compare(range.getLowerEndpoint(), node.elem);
if (cmp < 0) {
return aggregateBelowRange(aggr, node.left);
} else if (cmp == 0) {
@@ -198,14 +190,11 @@
}
}
- private long aggregateAboveRange(Aggregate aggr, @CheckForNull AvlNode<E> node) {
+ private long aggregateAboveRange(Aggregate aggr, @NullableDecl AvlNode<E> node) {
if (node == null) {
return 0;
}
- // The cast is safe because we call this method only if hasUpperBound().
- int cmp =
- comparator()
- .compare(uncheckedCastNullableTToT(range.getUpperEndpoint()), node.getElement());
+ int cmp = comparator().compare(range.getUpperEndpoint(), node.elem);
if (cmp > 0) {
return aggregateAboveRange(aggr, node.right);
} else if (cmp == 0) {
@@ -234,12 +223,12 @@
return Ints.saturatedCast(aggregateForEntries(Aggregate.DISTINCT));
}
- static int distinctElements(@CheckForNull AvlNode<?> node) {
+ static int distinctElements(@NullableDecl AvlNode<?> node) {
return (node == null) ? 0 : node.distinctElements;
}
@Override
- public int count(@CheckForNull Object element) {
+ public int count(@NullableDecl Object element) {
try {
@SuppressWarnings("unchecked")
E e = (E) element;
@@ -255,7 +244,7 @@
@CanIgnoreReturnValue
@Override
- public int add(@ParametricNullness E element, int occurrences) {
+ public int add(@NullableDecl E element, int occurrences) {
checkNonnegative(occurrences, "occurrences");
if (occurrences == 0) {
return count(element);
@@ -277,7 +266,7 @@
@CanIgnoreReturnValue
@Override
- public int remove(@CheckForNull Object element, int occurrences) {
+ public int remove(@NullableDecl Object element, int occurrences) {
checkNonnegative(occurrences, "occurrences");
if (occurrences == 0) {
return count(element);
@@ -301,7 +290,7 @@
@CanIgnoreReturnValue
@Override
- public int setCount(@ParametricNullness E element, int count) {
+ public int setCount(@NullableDecl E element, int count) {
checkNonnegative(count, "count");
if (!range.contains(element)) {
checkArgument(count == 0);
@@ -323,7 +312,7 @@
@CanIgnoreReturnValue
@Override
- public boolean setCount(@ParametricNullness E element, int oldCount, int newCount) {
+ public boolean setCount(@NullableDecl E element, int oldCount, int newCount) {
checkNonnegative(newCount, "newCount");
checkNonnegative(oldCount, "oldCount");
checkArgument(range.contains(element));
@@ -349,8 +338,8 @@
public void clear() {
if (!range.hasLowerBound() && !range.hasUpperBound()) {
// We can do this in O(n) rather than removing one by one, which could force rebalancing.
- for (AvlNode<E> current = header.succ(); current != header; ) {
- AvlNode<E> next = current.succ();
+ for (AvlNode<E> current = header.succ; current != header; ) {
+ AvlNode<E> next = current.succ;
current.elemCount = 0;
// Also clear these fields so that one deleted Entry doesn't retain all elements.
@@ -372,7 +361,6 @@
private Entry<E> wrapEntry(final AvlNode<E> baseEntry) {
return new Multisets.AbstractEntry<E>() {
@Override
- @ParametricNullness
public E getElement() {
return baseEntry.getElement();
}
@@ -390,7 +378,7 @@
}
/** Returns the first node in the tree that is in range. */
- @CheckForNull
+ @NullableDecl
private AvlNode<E> firstNode() {
AvlNode<E> root = rootReference.get();
if (root == null) {
@@ -398,23 +386,22 @@
}
AvlNode<E> node;
if (range.hasLowerBound()) {
- // The cast is safe because of the hasLowerBound check.
- E endpoint = uncheckedCastNullableTToT(range.getLowerEndpoint());
- node = root.ceiling(comparator(), endpoint);
+ E endpoint = range.getLowerEndpoint();
+ node = rootReference.get().ceiling(comparator(), endpoint);
if (node == null) {
return null;
}
if (range.getLowerBoundType() == BoundType.OPEN
&& comparator().compare(endpoint, node.getElement()) == 0) {
- node = node.succ();
+ node = node.succ;
}
} else {
- node = header.succ();
+ node = header.succ;
}
return (node == header || !range.contains(node.getElement())) ? null : node;
}
- @CheckForNull
+ @NullableDecl
private AvlNode<E> lastNode() {
AvlNode<E> root = rootReference.get();
if (root == null) {
@@ -422,18 +409,17 @@
}
AvlNode<E> node;
if (range.hasUpperBound()) {
- // The cast is safe because of the hasUpperBound check.
- E endpoint = uncheckedCastNullableTToT(range.getUpperEndpoint());
- node = root.floor(comparator(), endpoint);
+ E endpoint = range.getUpperEndpoint();
+ node = rootReference.get().floor(comparator(), endpoint);
if (node == null) {
return null;
}
if (range.getUpperBoundType() == BoundType.OPEN
&& comparator().compare(endpoint, node.getElement()) == 0) {
- node = node.pred();
+ node = node.pred;
}
} else {
- node = header.pred();
+ node = header.pred;
}
return (node == header || !range.contains(node.getElement())) ? null : node;
}
@@ -446,8 +432,8 @@
@Override
Iterator<Entry<E>> entryIterator() {
return new Iterator<Entry<E>>() {
- @CheckForNull AvlNode<E> current = firstNode();
- @CheckForNull Entry<E> prevEntry;
+ AvlNode<E> current = firstNode();
+ @NullableDecl Entry<E> prevEntry;
@Override
public boolean hasNext() {
@@ -466,20 +452,19 @@
if (!hasNext()) {
throw new NoSuchElementException();
}
- // requireNonNull is safe because current is only nulled out after iteration is complete.
- Entry<E> result = wrapEntry(requireNonNull(current));
+ Entry<E> result = wrapEntry(current);
prevEntry = result;
- if (current.succ() == header) {
+ if (current.succ == header) {
current = null;
} else {
- current = current.succ();
+ current = current.succ;
}
return result;
}
@Override
public void remove() {
- checkState(prevEntry != null, "no calls to next() since the last call to remove()");
+ checkRemove(prevEntry != null);
setCount(prevEntry.getElement(), 0);
prevEntry = null;
}
@@ -489,8 +474,8 @@
@Override
Iterator<Entry<E>> descendingEntryIterator() {
return new Iterator<Entry<E>>() {
- @CheckForNull AvlNode<E> current = lastNode();
- @CheckForNull Entry<E> prevEntry = null;
+ AvlNode<E> current = lastNode();
+ Entry<E> prevEntry = null;
@Override
public boolean hasNext() {
@@ -509,21 +494,19 @@
if (!hasNext()) {
throw new NoSuchElementException();
}
- // requireNonNull is safe because current is only nulled out after iteration is complete.
- requireNonNull(current);
Entry<E> result = wrapEntry(current);
prevEntry = result;
- if (current.pred() == header) {
+ if (current.pred == header) {
current = null;
} else {
- current = current.pred();
+ current = current.pred;
}
return result;
}
@Override
public void remove() {
- checkState(prevEntry != null, "no calls to next() since the last call to remove()");
+ checkRemove(prevEntry != null);
setCount(prevEntry.getElement(), 0);
prevEntry = null;
}
@@ -536,7 +519,7 @@
}
@Override
- public SortedMultiset<E> headMultiset(@ParametricNullness E upperBound, BoundType boundType) {
+ public SortedMultiset<E> headMultiset(@NullableDecl E upperBound, BoundType boundType) {
return new TreeMultiset<E>(
rootReference,
range.intersect(GeneralRange.upTo(comparator(), upperBound, boundType)),
@@ -544,7 +527,7 @@
}
@Override
- public SortedMultiset<E> tailMultiset(@ParametricNullness E lowerBound, BoundType boundType) {
+ public SortedMultiset<E> tailMultiset(@NullableDecl E lowerBound, BoundType boundType) {
return new TreeMultiset<E>(
rootReference,
range.intersect(GeneralRange.downTo(comparator(), lowerBound, boundType)),
@@ -552,14 +535,14 @@
}
private static final class Reference<T> {
- @CheckForNull private T value;
+ @NullableDecl private T value;
- @CheckForNull
+ @NullableDecl
public T get() {
return value;
}
- public void checkAndSet(@CheckForNull T expected, @CheckForNull T newValue) {
+ public void checkAndSet(@NullableDecl T expected, T newValue) {
if (value != expected) {
throw new ConcurrentModificationException();
}
@@ -571,18 +554,8 @@
}
}
- private static final class AvlNode<E extends @Nullable Object> {
- /*
- * For "normal" nodes, the type of this field is `E`, not `@Nullable E` (though note that E is a
- * type that can include null, as in a TreeMultiset<@Nullable String>).
- *
- * For the header node, though, this field contains `null`, regardless of the type of the
- * multiset.
- *
- * Most code that operates on an AvlNode never operates on the header node. Such code can access
- * the elem field without a null check by calling getElement().
- */
- @CheckForNull private final E elem;
+ private static final class AvlNode<E> {
+ @NullableDecl private final E elem;
// elemCount is 0 iff this node has been deleted.
private int elemCount;
@@ -590,23 +563,12 @@
private int distinctElements;
private long totalCount;
private int height;
- @CheckForNull private AvlNode<E> left;
- @CheckForNull private AvlNode<E> right;
- /*
- * pred and succ are nullable after construction, but we always call successor() to initialize
- * them immediately thereafter.
- *
- * They may be subsequently nulled out by TreeMultiset.clear(). I think that the only place that
- * we can reference a node whose fields have been cleared is inside the iterator (and presumably
- * only under concurrent modification).
- *
- * To access these fields when you know that they are not null, call the pred() and succ()
- * methods, which perform null checks before returning the fields.
- */
- @CheckForNull private AvlNode<E> pred;
- @CheckForNull private AvlNode<E> succ;
+ @NullableDecl private AvlNode<E> left;
+ @NullableDecl private AvlNode<E> right;
+ @NullableDecl private AvlNode<E> pred;
+ @NullableDecl private AvlNode<E> succ;
- AvlNode(@ParametricNullness E elem, int elemCount) {
+ AvlNode(@NullableDecl E elem, int elemCount) {
checkArgument(elemCount > 0);
this.elem = elem;
this.elemCount = elemCount;
@@ -617,24 +579,8 @@
this.right = null;
}
- /** Constructor for the header node. */
- AvlNode() {
- this.elem = null;
- this.elemCount = 1;
- }
-
- // For discussion of pred() and succ(), see the comment on the pred and succ fields.
-
- private AvlNode<E> pred() {
- return requireNonNull(pred);
- }
-
- private AvlNode<E> succ() {
- return requireNonNull(succ);
- }
-
- int count(Comparator<? super E> comparator, @ParametricNullness E e) {
- int cmp = comparator.compare(e, getElement());
+ public int count(Comparator<? super E> comparator, E e) {
+ int cmp = comparator.compare(e, elem);
if (cmp < 0) {
return (left == null) ? 0 : left.count(comparator, e);
} else if (cmp > 0) {
@@ -644,31 +590,30 @@
}
}
- private AvlNode<E> addRightChild(@ParametricNullness E e, int count) {
+ private AvlNode<E> addRightChild(E e, int count) {
right = new AvlNode<E>(e, count);
- successor(this, right, succ());
+ successor(this, right, succ);
height = Math.max(2, height);
distinctElements++;
totalCount += count;
return this;
}
- private AvlNode<E> addLeftChild(@ParametricNullness E e, int count) {
+ private AvlNode<E> addLeftChild(E e, int count) {
left = new AvlNode<E>(e, count);
- successor(pred(), left, this);
+ successor(pred, left, this);
height = Math.max(2, height);
distinctElements++;
totalCount += count;
return this;
}
- AvlNode<E> add(
- Comparator<? super E> comparator, @ParametricNullness E e, int count, int[] result) {
+ AvlNode<E> add(Comparator<? super E> comparator, @NullableDecl 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. =(
*/
- int cmp = comparator.compare(e, getElement());
+ int cmp = comparator.compare(e, elem);
if (cmp < 0) {
AvlNode<E> initLeft = left;
if (initLeft == null) {
@@ -708,10 +653,9 @@
return this;
}
- @CheckForNull
AvlNode<E> remove(
- Comparator<? super E> comparator, @ParametricNullness E e, int count, int[] result) {
- int cmp = comparator.compare(e, getElement());
+ Comparator<? super E> comparator, @NullableDecl E e, int count, int[] result) {
+ int cmp = comparator.compare(e, elem);
if (cmp < 0) {
AvlNode<E> initLeft = left;
if (initLeft == null) {
@@ -761,10 +705,9 @@
}
}
- @CheckForNull
AvlNode<E> setCount(
- Comparator<? super E> comparator, @ParametricNullness E e, int count, int[] result) {
- int cmp = comparator.compare(e, getElement());
+ Comparator<? super E> comparator, @NullableDecl E e, int count, int[] result) {
+ int cmp = comparator.compare(e, elem);
if (cmp < 0) {
AvlNode<E> initLeft = left;
if (initLeft == null) {
@@ -811,14 +754,13 @@
return this;
}
- @CheckForNull
AvlNode<E> setCount(
Comparator<? super E> comparator,
- @ParametricNullness E e,
+ @NullableDecl E e,
int expectedCount,
int newCount,
int[] result) {
- int cmp = comparator.compare(e, getElement());
+ int cmp = comparator.compare(e, elem);
if (cmp < 0) {
AvlNode<E> initLeft = left;
if (initLeft == null) {
@@ -875,17 +817,16 @@
return this;
}
- @CheckForNull
private AvlNode<E> deleteMe() {
int oldElemCount = this.elemCount;
this.elemCount = 0;
- successor(pred(), succ());
+ successor(pred, succ);
if (left == null) {
return right;
} else if (right == null) {
return left;
} else if (left.height >= right.height) {
- AvlNode<E> newTop = pred();
+ AvlNode<E> newTop = pred;
// newTop is the maximum node in my left subtree
newTop.left = left.removeMax(newTop);
newTop.right = right;
@@ -893,7 +834,7 @@
newTop.totalCount = totalCount - oldElemCount;
return newTop.rebalance();
} else {
- AvlNode<E> newTop = succ();
+ AvlNode<E> newTop = succ;
newTop.right = right.removeMin(newTop);
newTop.left = left;
newTop.distinctElements = distinctElements - 1;
@@ -903,7 +844,6 @@
}
// Removes the minimum node from this subtree to be reused elsewhere
- @CheckForNull
private AvlNode<E> removeMin(AvlNode<E> node) {
if (left == null) {
return right;
@@ -916,7 +856,6 @@
}
// Removes the maximum node from this subtree to be reused elsewhere
- @CheckForNull
private AvlNode<E> removeMax(AvlNode<E> node) {
if (right == null) {
return left;
@@ -946,15 +885,11 @@
private AvlNode<E> rebalance() {
switch (balanceFactor()) {
case -2:
- // requireNonNull is safe because right must exist in order to get a negative factor.
- requireNonNull(right);
if (right.balanceFactor() > 0) {
right = right.rotateRight();
}
return rotateLeft();
case 2:
- // requireNonNull is safe because left must exist in order to get a positive factor.
- requireNonNull(left);
if (left.balanceFactor() < 0) {
left = left.rotateLeft();
}
@@ -993,17 +928,17 @@
return newTop;
}
- private static long totalCount(@CheckForNull AvlNode<?> node) {
+ private static long totalCount(@NullableDecl AvlNode<?> node) {
return (node == null) ? 0 : node.totalCount;
}
- private static int height(@CheckForNull AvlNode<?> node) {
+ private static int height(@NullableDecl AvlNode<?> node) {
return (node == null) ? 0 : node.height;
}
- @CheckForNull
- private AvlNode<E> ceiling(Comparator<? super E> comparator, @ParametricNullness E e) {
- int cmp = comparator.compare(e, getElement());
+ @NullableDecl
+ private AvlNode<E> ceiling(Comparator<? super E> comparator, E e) {
+ int cmp = comparator.compare(e, elem);
if (cmp < 0) {
return (left == null) ? this : MoreObjects.firstNonNull(left.ceiling(comparator, e), this);
} else if (cmp == 0) {
@@ -1013,9 +948,9 @@
}
}
- @CheckForNull
- private AvlNode<E> floor(Comparator<? super E> comparator, @ParametricNullness E e) {
- int cmp = comparator.compare(e, getElement());
+ @NullableDecl
+ private AvlNode<E> floor(Comparator<? super E> comparator, E e) {
+ int cmp = comparator.compare(e, elem);
if (cmp > 0) {
return (right == null) ? this : MoreObjects.firstNonNull(right.floor(comparator, e), this);
} else if (cmp == 0) {
@@ -1025,10 +960,8 @@
}
}
- @ParametricNullness
E getElement() {
- // For discussion of this cast, see the comment on the elem field.
- return uncheckedCastNullableTToT(elem);
+ return elem;
}
int getCount() {
@@ -1041,13 +974,12 @@
}
}
- private static <T extends @Nullable Object> void successor(AvlNode<T> a, AvlNode<T> b) {
+ private static <T> void successor(AvlNode<T> a, AvlNode<T> b) {
a.succ = b;
b.pred = a;
}
- private static <T extends @Nullable Object> void successor(
- AvlNode<T> a, AvlNode<T> b, AvlNode<T> c) {
+ private static <T> void successor(AvlNode<T> a, AvlNode<T> b, AvlNode<T> c) {
successor(a, b);
successor(b, c);
}
@@ -1080,7 +1012,7 @@
.set(this, GeneralRange.all(comparator));
Serialization.getFieldSetter(TreeMultiset.class, "rootReference")
.set(this, new Reference<AvlNode<E>>());
- AvlNode<E> header = new AvlNode<>();
+ AvlNode<E> header = new AvlNode<E>(null, 1);
Serialization.getFieldSetter(TreeMultiset.class, "header").set(this, header);
successor(header, header);
Serialization.populateMultiset(this, stream);
diff --git a/android/guava/src/com/google/common/collect/TreeRangeMap.java b/android/guava/src/com/google/common/collect/TreeRangeMap.java
index 0ce8e89..8cb31b7 100644
--- a/android/guava/src/com/google/common/collect/TreeRangeMap.java
+++ b/android/guava/src/com/google/common/collect/TreeRangeMap.java
@@ -21,7 +21,6 @@
import static com.google.common.base.Predicates.compose;
import static com.google.common.base.Predicates.in;
import static com.google.common.base.Predicates.not;
-import static java.util.Objects.requireNonNull;
import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtIncompatible;
@@ -38,7 +37,7 @@
import java.util.NavigableMap;
import java.util.NoSuchElementException;
import java.util.Set;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* An implementation of {@code RangeMap} based on a {@code TreeMap}, supporting all optional
@@ -51,7 +50,6 @@
*/
@Beta
@GwtIncompatible // NavigableMap
-@ElementTypesAreNonnullByDefault
public final class TreeRangeMap<K extends Comparable, V> implements RangeMap<K, V> {
private final NavigableMap<Cut<K>, RangeMapEntry<K, V>> entriesByLowerBound;
@@ -102,14 +100,14 @@
}
@Override
- @CheckForNull
+ @NullableDecl
public V get(K key) {
Entry<Range<K>, V> entry = getEntry(key);
return (entry == null) ? null : entry.getValue();
}
@Override
- @CheckForNull
+ @NullableDecl
public Entry<Range<K>, V> getEntry(K key) {
Entry<Cut<K>, RangeMapEntry<K, V>> mapEntry =
entriesByLowerBound.floorEntry(Cut.belowValue(key));
@@ -157,7 +155,7 @@
/** Returns the range that spans the given range and entry, if the entry can be coalesced. */
private static <K extends Comparable, V> Range<K> coalesce(
- Range<K> range, V value, @CheckForNull Entry<Cut<K>, RangeMapEntry<K, V>> entry) {
+ Range<K> range, V value, @NullableDecl Entry<Cut<K>, RangeMapEntry<K, V>> entry) {
if (entry != null
&& entry.getValue().getKey().isConnected(range)
&& entry.getValue().getValue().equals(value)) {
@@ -182,8 +180,7 @@
public Range<K> span() {
Entry<Cut<K>, RangeMapEntry<K, V>> firstEntry = entriesByLowerBound.firstEntry();
Entry<Cut<K>, RangeMapEntry<K, V>> lastEntry = entriesByLowerBound.lastEntry();
- // Either both are null or neither is, but we check both to satisfy the nullness checker.
- if (firstEntry == null || lastEntry == null) {
+ if (firstEntry == null) {
throw new NoSuchElementException();
}
return Range.create(
@@ -264,13 +261,12 @@
}
@Override
- public boolean containsKey(@CheckForNull Object key) {
+ public boolean containsKey(@NullableDecl Object key) {
return get(key) != null;
}
@Override
- @CheckForNull
- public V get(@CheckForNull Object key) {
+ public V get(@NullableDecl Object key) {
if (key instanceof Range) {
Range<?> range = (Range<?>) key;
RangeMapEntry<K, V> rangeMapEntry = entriesByLowerBound.get(range.lowerBound);
@@ -303,45 +299,44 @@
@SuppressWarnings("unchecked")
private RangeMap<K, V> emptySubRangeMap() {
- return (RangeMap<K, V>) (RangeMap<?, ?>) EMPTY_SUB_RANGE_MAP;
+ return EMPTY_SUB_RANGE_MAP;
}
- @SuppressWarnings("ConstantCaseForConstants") // This RangeMap is immutable.
- private static final RangeMap<Comparable<?>, Object> EMPTY_SUB_RANGE_MAP =
- new RangeMap<Comparable<?>, Object>() {
+ private static final RangeMap EMPTY_SUB_RANGE_MAP =
+ new RangeMap() {
@Override
- @CheckForNull
- public Object get(Comparable<?> key) {
+ @NullableDecl
+ public Object get(Comparable key) {
return null;
}
@Override
- @CheckForNull
- public Entry<Range<Comparable<?>>, Object> getEntry(Comparable<?> key) {
+ @NullableDecl
+ public Entry<Range, Object> getEntry(Comparable key) {
return null;
}
@Override
- public Range<Comparable<?>> span() {
+ public Range span() {
throw new NoSuchElementException();
}
@Override
- public void put(Range<Comparable<?>> range, Object value) {
+ public void put(Range range, Object value) {
checkNotNull(range);
throw new IllegalArgumentException(
"Cannot insert range " + range + " into an empty subRangeMap");
}
@Override
- public void putCoalescing(Range<Comparable<?>> range, Object value) {
+ public void putCoalescing(Range range, Object value) {
checkNotNull(range);
throw new IllegalArgumentException(
"Cannot insert range " + range + " into an empty subRangeMap");
}
@Override
- public void putAll(RangeMap<Comparable<?>, Object> rangeMap) {
+ public void putAll(RangeMap rangeMap) {
if (!rangeMap.asMapOfRanges().isEmpty()) {
throw new IllegalArgumentException(
"Cannot putAll(nonEmptyRangeMap) into an empty subRangeMap");
@@ -352,22 +347,22 @@
public void clear() {}
@Override
- public void remove(Range<Comparable<?>> range) {
+ public void remove(Range range) {
checkNotNull(range);
}
@Override
- public Map<Range<Comparable<?>>, Object> asMapOfRanges() {
+ public Map<Range, Object> asMapOfRanges() {
return Collections.emptyMap();
}
@Override
- public Map<Range<Comparable<?>>, Object> asDescendingMapOfRanges() {
+ public Map<Range, Object> asDescendingMapOfRanges() {
return Collections.emptyMap();
}
@Override
- public RangeMap<Comparable<?>, Object> subRangeMap(Range<Comparable<?>> range) {
+ public RangeMap subRangeMap(Range range) {
checkNotNull(range);
return this;
}
@@ -382,13 +377,13 @@
}
@Override
- @CheckForNull
+ @NullableDecl
public V get(K key) {
return subRange.contains(key) ? TreeRangeMap.this.get(key) : null;
}
@Override
- @CheckForNull
+ @NullableDecl
public Entry<Range<K>, V> getEntry(K key) {
if (subRange.contains(key)) {
Entry<Range<K>, V> entry = TreeRangeMap.this.getEntry(key);
@@ -504,7 +499,6 @@
return new AbstractIterator<Entry<Range<K>, V>>() {
@Override
- @CheckForNull
protected Entry<Range<K>, V> computeNext() {
if (backingItr.hasNext()) {
RangeMapEntry<K, V> entry = backingItr.next();
@@ -521,7 +515,7 @@
}
@Override
- public boolean equals(@CheckForNull Object o) {
+ public boolean equals(@NullableDecl Object o) {
if (o instanceof RangeMap) {
RangeMap<?, ?> rangeMap = (RangeMap<?, ?>) o;
return asMapOfRanges().equals(rangeMap.asMapOfRanges());
@@ -542,13 +536,12 @@
class SubRangeMapAsMap extends AbstractMap<Range<K>, V> {
@Override
- public boolean containsKey(@CheckForNull Object key) {
+ public boolean containsKey(Object key) {
return get(key) != null;
}
@Override
- @CheckForNull
- public V get(@CheckForNull Object key) {
+ public V get(Object key) {
try {
if (key instanceof Range) {
@SuppressWarnings("unchecked") // we catch ClassCastExceptions
@@ -581,13 +574,11 @@
}
@Override
- @CheckForNull
- public V remove(@CheckForNull Object key) {
+ public V remove(Object key) {
V value = get(key);
if (value != null) {
- // it's definitely in the map, so the cast and requireNonNull are safe
- @SuppressWarnings("unchecked")
- Range<K> range = (Range<K>) requireNonNull(key);
+ @SuppressWarnings("unchecked") // it's definitely in the map, so safe
+ Range<K> range = (Range<K>) key;
TreeRangeMap.this.remove(range);
return value;
}
@@ -616,7 +607,7 @@
public Set<Range<K>> keySet() {
return new Maps.KeySet<Range<K>, V>(SubRangeMapAsMap.this) {
@Override
- public boolean remove(@CheckForNull Object o) {
+ public boolean remove(@NullableDecl Object o) {
return SubRangeMapAsMap.this.remove(o) != null;
}
@@ -669,7 +660,6 @@
return new AbstractIterator<Entry<Range<K>, V>>() {
@Override
- @CheckForNull
protected Entry<Range<K>, V> computeNext() {
while (backingItr.hasNext()) {
RangeMapEntry<K, V> entry = backingItr.next();
@@ -703,7 +693,7 @@
}
@Override
- public boolean equals(@CheckForNull Object o) {
+ public boolean equals(@NullableDecl Object o) {
if (o instanceof RangeMap) {
RangeMap<?, ?> rangeMap = (RangeMap<?, ?>) o;
return asMapOfRanges().equals(rangeMap.asMapOfRanges());
diff --git a/android/guava/src/com/google/common/collect/TreeRangeSet.java b/android/guava/src/com/google/common/collect/TreeRangeSet.java
index 8308880..c5a438a 100644
--- a/android/guava/src/com/google/common/collect/TreeRangeSet.java
+++ b/android/guava/src/com/google/common/collect/TreeRangeSet.java
@@ -30,7 +30,7 @@
import java.util.NoSuchElementException;
import java.util.Set;
import java.util.TreeMap;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* An implementation of {@link RangeSet} backed by a {@link TreeMap}.
@@ -40,7 +40,6 @@
*/
@Beta
@GwtIncompatible // uses NavigableMap
-@ElementTypesAreNonnullByDefault
public class TreeRangeSet<C extends Comparable<?>> extends AbstractRangeSet<C>
implements Serializable {
@@ -77,8 +76,8 @@
this.rangesByLowerBound = rangesByLowerCut;
}
- @CheckForNull private transient Set<Range<C>> asRanges;
- @CheckForNull private transient Set<Range<C>> asDescendingSetOfRanges;
+ @NullableDecl private transient Set<Range<C>> asRanges;
+ @NullableDecl private transient Set<Range<C>> asDescendingSetOfRanges;
@Override
public Set<Range<C>> asRanges() {
@@ -113,13 +112,13 @@
}
@Override
- public boolean equals(@CheckForNull Object o) {
+ public boolean equals(@NullableDecl Object o) {
return Sets.equalsImpl(this, o);
}
}
@Override
- @CheckForNull
+ @NullableDecl
public Range<C> rangeContaining(C value) {
checkNotNull(value);
Entry<Cut<C>, Range<C>> floorEntry = rangesByLowerBound.floorEntry(Cut.belowValue(value));
@@ -153,7 +152,7 @@
return floorEntry != null && floorEntry.getValue().encloses(range);
}
- @CheckForNull
+ @NullableDecl
private Range<C> rangeEnclosing(Range<C> range) {
checkNotNull(range);
Entry<Cut<C>, Range<C>> floorEntry = rangesByLowerBound.floorEntry(range.lowerBound);
@@ -166,11 +165,7 @@
public Range<C> span() {
Entry<Cut<C>, Range<C>> firstEntry = rangesByLowerBound.firstEntry();
Entry<Cut<C>, Range<C>> lastEntry = rangesByLowerBound.lastEntry();
- if (firstEntry == null || lastEntry == null) {
- /*
- * Either both are null or neither is: Either the set is empty, or it's not. But we check both
- * to make the nullness checker happy.
- */
+ if (firstEntry == null) {
throw new NoSuchElementException();
}
return Range.create(firstEntry.getValue().lowerBound, lastEntry.getValue().upperBound);
@@ -274,7 +269,7 @@
}
}
- @CheckForNull private transient RangeSet<C> complement;
+ @NullableDecl private transient RangeSet<C> complement;
@Override
public RangeSet<C> complement() {
@@ -337,13 +332,12 @@
}
@Override
- public boolean containsKey(@CheckForNull Object key) {
+ public boolean containsKey(@NullableDecl Object key) {
return get(key) != null;
}
@Override
- @CheckForNull
- public Range<C> get(@CheckForNull Object key) {
+ public Range<C> get(@NullableDecl Object key) {
if (key instanceof Cut) {
try {
@SuppressWarnings("unchecked") // we catch CCEs
@@ -388,7 +382,6 @@
}
return new AbstractIterator<Entry<Cut<C>, Range<C>>>() {
@Override
- @CheckForNull
protected Entry<Cut<C>, Range<C>> computeNext() {
if (!backingItr.hasNext()) {
return endOfData();
@@ -422,7 +415,6 @@
}
return new AbstractIterator<Entry<Cut<C>, Range<C>>>() {
@Override
- @CheckForNull
protected Entry<Cut<C>, Range<C>> computeNext() {
if (!backingItr.hasNext()) {
return endOfData();
@@ -544,7 +536,6 @@
Cut<C> nextComplementRangeLowerBound = firstComplementRangeLowerBound;
@Override
- @CheckForNull
protected Entry<Cut<C>, Range<C>> computeNext() {
if (complementLowerBoundWindow.upperBound.isLessThan(nextComplementRangeLowerBound)
|| nextComplementRangeLowerBound == Cut.<C>aboveAll()) {
@@ -606,7 +597,6 @@
Cut<C> nextComplementRangeUpperBound = firstComplementRangeUpperBound;
@Override
- @CheckForNull
protected Entry<Cut<C>, Range<C>> computeNext() {
if (nextComplementRangeUpperBound == Cut.<C>belowAll()) {
return endOfData();
@@ -634,8 +624,8 @@
}
@Override
- @CheckForNull
- public Range<C> get(@CheckForNull Object key) {
+ @NullableDecl
+ public Range<C> get(Object key) {
if (key instanceof Cut) {
try {
@SuppressWarnings("unchecked")
@@ -653,7 +643,7 @@
}
@Override
- public boolean containsKey(@CheckForNull Object key) {
+ public boolean containsKey(Object key) {
return get(key) != null;
}
}
@@ -747,13 +737,13 @@
}
@Override
- public boolean containsKey(@CheckForNull Object key) {
+ public boolean containsKey(@NullableDecl Object key) {
return get(key) != null;
}
@Override
- @CheckForNull
- public Range<C> get(@CheckForNull Object key) {
+ @NullableDecl
+ public Range<C> get(@NullableDecl Object key) {
if (key instanceof Cut) {
try {
@SuppressWarnings("unchecked") // we catch CCE's
@@ -808,7 +798,6 @@
.min(lowerBoundWindow.upperBound, Cut.belowValue(restriction.upperBound));
return new AbstractIterator<Entry<Cut<C>, Range<C>>>() {
@Override
- @CheckForNull
protected Entry<Cut<C>, Range<C>> computeNext() {
if (!completeRangeItr.hasNext()) {
return endOfData();
@@ -842,7 +831,6 @@
.iterator();
return new AbstractIterator<Entry<Cut<C>, Range<C>>>() {
@Override
- @CheckForNull
protected Entry<Cut<C>, Range<C>> computeNext() {
if (!completeRangeItr.hasNext()) {
return endOfData();
@@ -892,7 +880,7 @@
}
@Override
- @CheckForNull
+ @NullableDecl
public Range<C> rangeContaining(C value) {
if (!restriction.contains(value)) {
return null;
diff --git a/android/guava/src/com/google/common/collect/TreeTraverser.java b/android/guava/src/com/google/common/collect/TreeTraverser.java
index 73f8154..550cdfc 100644
--- a/android/guava/src/com/google/common/collect/TreeTraverser.java
+++ b/android/guava/src/com/google/common/collect/TreeTraverser.java
@@ -25,7 +25,6 @@
import java.util.Deque;
import java.util.Iterator;
import java.util.Queue;
-import javax.annotation.CheckForNull;
/**
* Views elements of a type {@code T} as nodes in a tree, and provides methods to traverse the trees
@@ -74,7 +73,6 @@
@Deprecated
@Beta
@GwtCompatible
-@ElementTypesAreNonnullByDefault
public abstract class TreeTraverser<T> {
/**
@@ -199,7 +197,6 @@
}
@Override
- @CheckForNull
protected T computeNext() {
while (!stack.isEmpty()) {
PostOrderNode<T> top = stack.getLast();
diff --git a/android/guava/src/com/google/common/collect/UnmodifiableIterator.java b/android/guava/src/com/google/common/collect/UnmodifiableIterator.java
index 03e52aa..f0f76b2 100644
--- a/android/guava/src/com/google/common/collect/UnmodifiableIterator.java
+++ b/android/guava/src/com/google/common/collect/UnmodifiableIterator.java
@@ -17,9 +17,7 @@
package com.google.common.collect;
import com.google.common.annotations.GwtCompatible;
-import com.google.errorprone.annotations.DoNotCall;
import java.util.Iterator;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* An iterator that does not support {@link #remove}.
@@ -32,8 +30,7 @@
* @since 2.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-public abstract class UnmodifiableIterator<E extends @Nullable Object> implements Iterator<E> {
+public abstract class UnmodifiableIterator<E> implements Iterator<E> {
/** Constructor for use by subclasses. */
protected UnmodifiableIterator() {}
@@ -45,7 +42,6 @@
*/
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
public final void remove() {
throw new UnsupportedOperationException();
}
diff --git a/android/guava/src/com/google/common/collect/UnmodifiableListIterator.java b/android/guava/src/com/google/common/collect/UnmodifiableListIterator.java
index f3d3b92..ec4219c 100644
--- a/android/guava/src/com/google/common/collect/UnmodifiableListIterator.java
+++ b/android/guava/src/com/google/common/collect/UnmodifiableListIterator.java
@@ -17,9 +17,7 @@
package com.google.common.collect;
import com.google.common.annotations.GwtCompatible;
-import com.google.errorprone.annotations.DoNotCall;
import java.util.ListIterator;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* A list iterator that does not support {@link #remove}, {@link #add}, or {@link #set}.
@@ -28,9 +26,8 @@
* @author Louis Wasserman
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-public abstract class UnmodifiableListIterator<E extends @Nullable Object>
- extends UnmodifiableIterator<E> implements ListIterator<E> {
+public abstract class UnmodifiableListIterator<E> extends UnmodifiableIterator<E>
+ implements ListIterator<E> {
/** Constructor for use by subclasses. */
protected UnmodifiableListIterator() {}
@@ -42,8 +39,7 @@
*/
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
- public final void add(@ParametricNullness E e) {
+ public final void add(E e) {
throw new UnsupportedOperationException();
}
@@ -55,8 +51,7 @@
*/
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
- public final void set(@ParametricNullness E e) {
+ public final void set(E e) {
throw new UnsupportedOperationException();
}
}
diff --git a/android/guava/src/com/google/common/collect/UnmodifiableSortedMultiset.java b/android/guava/src/com/google/common/collect/UnmodifiableSortedMultiset.java
index 59bd2ce..20286af 100644
--- a/android/guava/src/com/google/common/collect/UnmodifiableSortedMultiset.java
+++ b/android/guava/src/com/google/common/collect/UnmodifiableSortedMultiset.java
@@ -20,8 +20,7 @@
import com.google.common.collect.Multisets.UnmodifiableMultiset;
import java.util.Comparator;
import java.util.NavigableSet;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* Implementation of {@link Multisets#unmodifiableSortedMultiset(SortedMultiset)}, split out into
@@ -31,8 +30,7 @@
* @author Louis Wasserman
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
-final class UnmodifiableSortedMultiset<E extends @Nullable Object> extends UnmodifiableMultiset<E>
+final class UnmodifiableSortedMultiset<E> extends UnmodifiableMultiset<E>
implements SortedMultiset<E> {
UnmodifiableSortedMultiset(SortedMultiset<E> delegate) {
super(delegate);
@@ -58,7 +56,7 @@
return (NavigableSet<E>) super.elementSet();
}
- @CheckForNull private transient UnmodifiableSortedMultiset<E> descendingMultiset;
+ @NullableDecl private transient UnmodifiableSortedMultiset<E> descendingMultiset;
@Override
public SortedMultiset<E> descendingMultiset() {
@@ -72,46 +70,39 @@
}
@Override
- @CheckForNull
public Entry<E> firstEntry() {
return delegate().firstEntry();
}
@Override
- @CheckForNull
public Entry<E> lastEntry() {
return delegate().lastEntry();
}
@Override
- @CheckForNull
public Entry<E> pollFirstEntry() {
throw new UnsupportedOperationException();
}
@Override
- @CheckForNull
public Entry<E> pollLastEntry() {
throw new UnsupportedOperationException();
}
@Override
- public SortedMultiset<E> headMultiset(@ParametricNullness E upperBound, BoundType boundType) {
+ public SortedMultiset<E> headMultiset(E upperBound, BoundType boundType) {
return Multisets.unmodifiableSortedMultiset(delegate().headMultiset(upperBound, boundType));
}
@Override
public SortedMultiset<E> subMultiset(
- @ParametricNullness E lowerBound,
- BoundType lowerBoundType,
- @ParametricNullness E upperBound,
- BoundType upperBoundType) {
+ E lowerBound, BoundType lowerBoundType, E upperBound, BoundType upperBoundType) {
return Multisets.unmodifiableSortedMultiset(
delegate().subMultiset(lowerBound, lowerBoundType, upperBound, upperBoundType));
}
@Override
- public SortedMultiset<E> tailMultiset(@ParametricNullness E lowerBound, BoundType boundType) {
+ public SortedMultiset<E> tailMultiset(E lowerBound, BoundType boundType) {
return Multisets.unmodifiableSortedMultiset(delegate().tailMultiset(lowerBound, boundType));
}
diff --git a/android/guava/src/com/google/common/collect/UsingToStringOrdering.java b/android/guava/src/com/google/common/collect/UsingToStringOrdering.java
index 3443b43..3167946 100644
--- a/android/guava/src/com/google/common/collect/UsingToStringOrdering.java
+++ b/android/guava/src/com/google/common/collect/UsingToStringOrdering.java
@@ -21,7 +21,6 @@
/** An ordering that uses the natural order of the string representation of the values. */
@GwtCompatible(serializable = true)
-@ElementTypesAreNonnullByDefault
final class UsingToStringOrdering extends Ordering<Object> implements Serializable {
static final UsingToStringOrdering INSTANCE = new UsingToStringOrdering();
diff --git a/android/guava/src/com/google/common/collect/package-info.java b/android/guava/src/com/google/common/collect/package-info.java
index d46e65f..f9f6758 100644
--- a/android/guava/src/com/google/common/collect/package-info.java
+++ b/android/guava/src/com/google/common/collect/package-info.java
@@ -97,7 +97,6 @@
*
* <ul>
* <li>{@link com.google.common.collect.ImmutableMultiset}
- * <li>{@link com.google.common.collect.ImmutableSortedMultiset}
* <li>{@link com.google.common.collect.HashMultiset}
* <li>{@link com.google.common.collect.LinkedHashMultiset}
* <li>{@link com.google.common.collect.TreeMultiset}
diff --git a/android/guava/src/com/google/common/escape/ArrayBasedCharEscaper.java b/android/guava/src/com/google/common/escape/ArrayBasedCharEscaper.java
index 20e8563..91e48e6 100644
--- a/android/guava/src/com/google/common/escape/ArrayBasedCharEscaper.java
+++ b/android/guava/src/com/google/common/escape/ArrayBasedCharEscaper.java
@@ -19,7 +19,6 @@
import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtCompatible;
import java.util.Map;
-import javax.annotation.CheckForNull;
/**
* A {@link CharEscaper} that uses an array to quickly look up replacement characters for a given
@@ -43,7 +42,6 @@
*/
@Beta
@GwtCompatible
-@ElementTypesAreNonnullByDefault
public abstract class ArrayBasedCharEscaper extends CharEscaper {
// The replacement array (see ArrayBasedEscaperMap).
private final char[][] replacements;
@@ -119,11 +117,8 @@
* Escapes a single character using the replacement array and safe range values. If the given
* character does not have an explicit replacement and lies outside the safe range then {@link
* #escapeUnsafe} is called.
- *
- * @return the replacement characters, or {@code null} if no escaping was required
*/
@Override
- @CheckForNull
protected final char[] escape(char c) {
if (c < replacementsLength) {
char[] chars = replacements[c];
@@ -150,6 +145,5 @@
* @return the replacement characters, or {@code null} if no escaping was required
*/
// TODO(dbeaumont,cpovirk): Rename this something better once refactoring done
- @CheckForNull
protected abstract char[] escapeUnsafe(char c);
}
diff --git a/android/guava/src/com/google/common/escape/ArrayBasedEscaperMap.java b/android/guava/src/com/google/common/escape/ArrayBasedEscaperMap.java
index a0883fe..400c3b1 100644
--- a/android/guava/src/com/google/common/escape/ArrayBasedEscaperMap.java
+++ b/android/guava/src/com/google/common/escape/ArrayBasedEscaperMap.java
@@ -38,7 +38,6 @@
*/
@Beta
@GwtCompatible
-@ElementTypesAreNonnullByDefault
public final class ArrayBasedEscaperMap {
/**
* Returns a new ArrayBasedEscaperMap for creating ArrayBasedCharEscaper or
@@ -74,7 +73,7 @@
}
char max = Collections.max(map.keySet());
char[][] replacements = new char[max + 1][];
- for (Character c : map.keySet()) {
+ for (char c : map.keySet()) {
replacements[c] = map.get(c).toCharArray();
}
return replacements;
diff --git a/android/guava/src/com/google/common/escape/ArrayBasedUnicodeEscaper.java b/android/guava/src/com/google/common/escape/ArrayBasedUnicodeEscaper.java
index 5ea7807..46057e9 100644
--- a/android/guava/src/com/google/common/escape/ArrayBasedUnicodeEscaper.java
+++ b/android/guava/src/com/google/common/escape/ArrayBasedUnicodeEscaper.java
@@ -19,8 +19,7 @@
import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtCompatible;
import java.util.Map;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* A {@link UnicodeEscaper} that uses an array to quickly look up replacement characters for a given
@@ -43,7 +42,6 @@
*/
@Beta
@GwtCompatible
-@ElementTypesAreNonnullByDefault
public abstract class ArrayBasedUnicodeEscaper extends UnicodeEscaper {
// The replacement array (see ArrayBasedEscaperMap).
private final char[][] replacements;
@@ -75,7 +73,7 @@
Map<Character, String> replacementMap,
int safeMin,
int safeMax,
- @Nullable String unsafeReplacement) {
+ @NullableDecl String unsafeReplacement) {
this(ArrayBasedEscaperMap.create(replacementMap), safeMin, safeMax, unsafeReplacement);
}
@@ -98,7 +96,7 @@
ArrayBasedEscaperMap escaperMap,
int safeMin,
int safeMax,
- @Nullable String unsafeReplacement) {
+ @NullableDecl String unsafeReplacement) {
checkNotNull(escaperMap); // GWT specific check (do not optimize)
this.replacements = escaperMap.getReplacementArray();
this.replacementsLength = replacements.length;
@@ -159,11 +157,8 @@
* Escapes a single Unicode code point using the replacement array and safe range values. If the
* given character does not have an explicit replacement and lies outside the safe range then
* {@link #escapeUnsafe} is called.
- *
- * @return the replacement characters, or {@code null} if no escaping was required
*/
@Override
- @CheckForNull
protected final char[] escape(int cp) {
if (cp < replacementsLength) {
char[] chars = replacements[cp];
@@ -204,6 +199,5 @@
* @param cp the Unicode code point to escape
* @return the replacement characters, or {@code null} if no escaping was required
*/
- @CheckForNull
protected abstract char[] escapeUnsafe(int cp);
}
diff --git a/android/guava/src/com/google/common/escape/CharEscaper.java b/android/guava/src/com/google/common/escape/CharEscaper.java
index 55090f6..b8ffee3 100644
--- a/android/guava/src/com/google/common/escape/CharEscaper.java
+++ b/android/guava/src/com/google/common/escape/CharEscaper.java
@@ -18,7 +18,6 @@
import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtCompatible;
-import javax.annotation.CheckForNull;
/**
* An object that converts literal text into a format safe for inclusion in a particular context
@@ -42,7 +41,6 @@
*/
@Beta
@GwtCompatible
-@ElementTypesAreNonnullByDefault
public abstract class CharEscaper extends Escaper {
/** Constructor for use by subclasses. */
protected CharEscaper() {}
@@ -82,7 +80,6 @@
* @param c the character to escape if necessary
* @return the replacement characters, or {@code null} if no escaping was needed
*/
- @CheckForNull
protected abstract char[] escape(char c);
/**
diff --git a/android/guava/src/com/google/common/escape/CharEscaperBuilder.java b/android/guava/src/com/google/common/escape/CharEscaperBuilder.java
index cbe6958..dba855f 100644
--- a/android/guava/src/com/google/common/escape/CharEscaperBuilder.java
+++ b/android/guava/src/com/google/common/escape/CharEscaperBuilder.java
@@ -22,8 +22,6 @@
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Simple helper class to build a "sparse" array of objects based on the indexes that were added to
@@ -36,17 +34,16 @@
*/
@Beta
@GwtCompatible
-@ElementTypesAreNonnullByDefault
public final class CharEscaperBuilder {
/**
* Simple decorator that turns an array of replacement char[]s into a CharEscaper, this results in
* a very fast escape method.
*/
private static class CharArrayDecorator extends CharEscaper {
- private final char[] @Nullable [] replacements;
+ private final char[][] replacements;
private final int replaceLength;
- CharArrayDecorator(char[] @Nullable [] replacements) {
+ CharArrayDecorator(char[][] replacements) {
this.replacements = replacements;
this.replaceLength = replacements.length;
}
@@ -68,7 +65,6 @@
}
@Override
- @CheckForNull
protected char[] escape(char c) {
return c < replaceLength ? replacements[c] : null;
}
@@ -112,7 +108,7 @@
*
* @return a "sparse" array that holds the replacement mappings.
*/
- public char[] @Nullable [] toArray() {
+ public char[][] toArray() {
char[][] result = new char[max + 1][];
for (Entry<Character, String> entry : map.entrySet()) {
result[entry.getKey()] = entry.getValue().toCharArray();
diff --git a/android/guava/src/com/google/common/escape/ElementTypesAreNonnullByDefault.java b/android/guava/src/com/google/common/escape/ElementTypesAreNonnullByDefault.java
deleted file mode 100644
index 992c9a3..0000000
--- a/android/guava/src/com/google/common/escape/ElementTypesAreNonnullByDefault.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) 2021 The Guava Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.common.escape;
-
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.PARAMETER;
-import static java.lang.annotation.ElementType.TYPE;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-import com.google.common.annotations.GwtCompatible;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-import javax.annotation.Nonnull;
-import javax.annotation.meta.TypeQualifierDefault;
-
-/**
- * Marks all "top-level" types as non-null in a way that is recognized by Kotlin. Note that this
- * unfortunately includes type-variable usages, so we also provide {@link ParametricNullness} to
- * "undo" it as best we can.
- */
-@GwtCompatible
-@Retention(RUNTIME)
-@Target(TYPE)
-@TypeQualifierDefault({FIELD, METHOD, PARAMETER})
-@Nonnull
-@interface ElementTypesAreNonnullByDefault {}
diff --git a/android/guava/src/com/google/common/escape/Escaper.java b/android/guava/src/com/google/common/escape/Escaper.java
index cdfe4e9..0d32a09 100644
--- a/android/guava/src/com/google/common/escape/Escaper.java
+++ b/android/guava/src/com/google/common/escape/Escaper.java
@@ -56,7 +56,6 @@
*/
@DoNotMock("Use Escapers.nullEscaper() or another methods from the *Escapers classes")
@GwtCompatible
-@ElementTypesAreNonnullByDefault
public abstract class Escaper {
// TODO(dbeaumont): evaluate custom implementations, considering package private constructor.
/** Constructor for use by subclasses. */
diff --git a/android/guava/src/com/google/common/escape/Escapers.java b/android/guava/src/com/google/common/escape/Escapers.java
index 41af668..5de338a 100644
--- a/android/guava/src/com/google/common/escape/Escapers.java
+++ b/android/guava/src/com/google/common/escape/Escapers.java
@@ -21,8 +21,7 @@
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import java.util.HashMap;
import java.util.Map;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* Static utility methods pertaining to {@link Escaper} instances.
@@ -33,7 +32,6 @@
*/
@Beta
@GwtCompatible
-@ElementTypesAreNonnullByDefault
public final class Escapers {
private Escapers() {}
@@ -54,7 +52,6 @@
}
@Override
- @CheckForNull
protected char[] escape(char c) {
// TODO: Fix tests not to call this directly and make it throw an error.
return null;
@@ -98,7 +95,7 @@
private final Map<Character, String> replacementMap = new HashMap<>();
private char safeMin = Character.MIN_VALUE;
private char safeMax = Character.MAX_VALUE;
- @CheckForNull private String unsafeReplacement = null;
+ private String unsafeReplacement = null;
// The constructor is exposed via the builder() method above.
private Builder() {}
@@ -128,7 +125,7 @@
* @return the builder instance
*/
@CanIgnoreReturnValue
- public Builder setUnsafeReplacement(@Nullable String unsafeReplacement) {
+ public Builder setUnsafeReplacement(@NullableDecl String unsafeReplacement) {
this.unsafeReplacement = unsafeReplacement;
return this;
}
@@ -154,12 +151,10 @@
/** Returns a new escaper based on the current state of the builder. */
public Escaper build() {
return new ArrayBasedCharEscaper(replacementMap, safeMin, safeMax) {
- @CheckForNull
private final char[] replacementChars =
unsafeReplacement != null ? unsafeReplacement.toCharArray() : null;
@Override
- @CheckForNull
protected char[] escapeUnsafe(char c) {
return replacementChars;
}
@@ -203,7 +198,6 @@
* @param c the character to escape if necessary
* @return the replacement string, or {@code null} if no escaping was needed
*/
- @CheckForNull
public static String computeReplacement(CharEscaper escaper, char c) {
return stringOrNull(escaper.escape(c));
}
@@ -217,13 +211,11 @@
* @param cp the Unicode code point to escape if necessary
* @return the replacement string, or {@code null} if no escaping was needed
*/
- @CheckForNull
public static String computeReplacement(UnicodeEscaper escaper, int cp) {
return stringOrNull(escaper.escape(cp));
}
- @CheckForNull
- private static String stringOrNull(@CheckForNull char[] in) {
+ private static String stringOrNull(char[] in) {
return (in == null) ? null : new String(in);
}
@@ -231,7 +223,6 @@
private static UnicodeEscaper wrap(final CharEscaper escaper) {
return new UnicodeEscaper() {
@Override
- @CheckForNull
protected char[] escape(int cp) {
// If a code point maps to a single character, just escape that.
if (cp < Character.MIN_SUPPLEMENTARY_CODE_POINT) {
diff --git a/android/guava/src/com/google/common/escape/ParametricNullness.java b/android/guava/src/com/google/common/escape/ParametricNullness.java
deleted file mode 100644
index 2f03d59..0000000
--- a/android/guava/src/com/google/common/escape/ParametricNullness.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2021 The Guava Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.common.escape;
-
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.PARAMETER;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-import static javax.annotation.meta.When.UNKNOWN;
-
-import com.google.common.annotations.GwtCompatible;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-import javax.annotation.Nonnull;
-import javax.annotation.meta.TypeQualifierNickname;
-
-/**
- * Marks a "top-level" type-variable usage as (a) a Kotlin platform type when the type argument is
- * non-nullable and (b) nullable when the type argument is nullable. This is the closest we can get
- * to "non-nullable when non-nullable; nullable when nullable" (like the Android <a
- * href="https://android.googlesource.com/platform/libcore/+/master/luni/src/main/java/libcore/util/NullFromTypeParam.java">{@code
- * NullFromTypeParam}</a>). We use this to "undo" {@link ElementTypesAreNonnullByDefault}.
- */
-@GwtCompatible
-@Retention(RUNTIME)
-@Target({FIELD, METHOD, PARAMETER})
-@TypeQualifierNickname
-@Nonnull(when = UNKNOWN)
-@interface ParametricNullness {}
diff --git a/android/guava/src/com/google/common/escape/Platform.java b/android/guava/src/com/google/common/escape/Platform.java
index dc6610c..99a7d4f 100644
--- a/android/guava/src/com/google/common/escape/Platform.java
+++ b/android/guava/src/com/google/common/escape/Platform.java
@@ -22,7 +22,6 @@
* @author Jesse Wilson
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
final class Platform {
private Platform() {}
diff --git a/android/guava/src/com/google/common/escape/UnicodeEscaper.java b/android/guava/src/com/google/common/escape/UnicodeEscaper.java
index c10ae34..0642162 100644
--- a/android/guava/src/com/google/common/escape/UnicodeEscaper.java
+++ b/android/guava/src/com/google/common/escape/UnicodeEscaper.java
@@ -18,7 +18,6 @@
import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtCompatible;
-import javax.annotation.CheckForNull;
/**
* An {@link Escaper} that converts literal text into a format safe for inclusion in a particular
@@ -52,7 +51,6 @@
*/
@Beta
@GwtCompatible
-@ElementTypesAreNonnullByDefault
public abstract class UnicodeEscaper extends Escaper {
/** The amount of padding (chars) to use when growing the escape buffer. */
private static final int DEST_PAD = 32;
@@ -79,7 +77,6 @@
* @param cp the Unicode code point to escape if necessary
* @return the replacement characters, or {@code null} if no escaping was needed
*/
- @CheckForNull
protected abstract char[] escape(int cp);
/**
diff --git a/android/guava/src/com/google/common/eventbus/AllowConcurrentEvents.java b/android/guava/src/com/google/common/eventbus/AllowConcurrentEvents.java
index 28bc4b2..4c749b4 100644
--- a/android/guava/src/com/google/common/eventbus/AllowConcurrentEvents.java
+++ b/android/guava/src/com/google/common/eventbus/AllowConcurrentEvents.java
@@ -14,6 +14,7 @@
package com.google.common.eventbus;
+import com.google.common.annotations.Beta;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -30,5 +31,5 @@
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
-@ElementTypesAreNonnullByDefault
+@Beta
public @interface AllowConcurrentEvents {}
diff --git a/android/guava/src/com/google/common/eventbus/AsyncEventBus.java b/android/guava/src/com/google/common/eventbus/AsyncEventBus.java
index 4f387a7..8650a8d 100644
--- a/android/guava/src/com/google/common/eventbus/AsyncEventBus.java
+++ b/android/guava/src/com/google/common/eventbus/AsyncEventBus.java
@@ -14,6 +14,7 @@
package com.google.common.eventbus;
+import com.google.common.annotations.Beta;
import java.util.concurrent.Executor;
/**
@@ -23,7 +24,7 @@
* @author Cliff Biffle
* @since 10.0
*/
-@ElementTypesAreNonnullByDefault
+@Beta
public class AsyncEventBus extends EventBus {
/**
diff --git a/android/guava/src/com/google/common/eventbus/DeadEvent.java b/android/guava/src/com/google/common/eventbus/DeadEvent.java
index 2cdb23f..6dbfee5 100644
--- a/android/guava/src/com/google/common/eventbus/DeadEvent.java
+++ b/android/guava/src/com/google/common/eventbus/DeadEvent.java
@@ -16,6 +16,7 @@
import static com.google.common.base.Preconditions.checkNotNull;
+import com.google.common.annotations.Beta;
import com.google.common.base.MoreObjects;
/**
@@ -27,7 +28,7 @@
* @author Cliff Biffle
* @since 10.0
*/
-@ElementTypesAreNonnullByDefault
+@Beta
public class DeadEvent {
private final Object source;
diff --git a/android/guava/src/com/google/common/eventbus/Dispatcher.java b/android/guava/src/com/google/common/eventbus/Dispatcher.java
index ff1ae2a..11e2de1 100644
--- a/android/guava/src/com/google/common/eventbus/Dispatcher.java
+++ b/android/guava/src/com/google/common/eventbus/Dispatcher.java
@@ -31,7 +31,6 @@
*
* @author Colin Decker
*/
-@ElementTypesAreNonnullByDefault
abstract class Dispatcher {
/**
diff --git a/android/guava/src/com/google/common/eventbus/ElementTypesAreNonnullByDefault.java b/android/guava/src/com/google/common/eventbus/ElementTypesAreNonnullByDefault.java
deleted file mode 100644
index e8542bb..0000000
--- a/android/guava/src/com/google/common/eventbus/ElementTypesAreNonnullByDefault.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) 2021 The Guava Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.common.eventbus;
-
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.PARAMETER;
-import static java.lang.annotation.ElementType.TYPE;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-import com.google.common.annotations.GwtCompatible;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-import javax.annotation.Nonnull;
-import javax.annotation.meta.TypeQualifierDefault;
-
-/**
- * Marks all "top-level" types as non-null in a way that is recognized by Kotlin. Note that this
- * unfortunately includes type-variable usages, so we also provide {@link ParametricNullness} to
- * "undo" it as best we can.
- */
-@GwtCompatible
-@Retention(RUNTIME)
-@Target(TYPE)
-@TypeQualifierDefault({FIELD, METHOD, PARAMETER})
-@Nonnull
-@interface ElementTypesAreNonnullByDefault {}
diff --git a/android/guava/src/com/google/common/eventbus/EventBus.java b/android/guava/src/com/google/common/eventbus/EventBus.java
index 4afc197..e505399 100644
--- a/android/guava/src/com/google/common/eventbus/EventBus.java
+++ b/android/guava/src/com/google/common/eventbus/EventBus.java
@@ -16,6 +16,7 @@
import static com.google.common.base.Preconditions.checkNotNull;
+import com.google.common.annotations.Beta;
import com.google.common.base.MoreObjects;
import com.google.common.util.concurrent.MoreExecutors;
import java.lang.reflect.Method;
@@ -28,62 +29,6 @@
/**
* Dispatches events to listeners, and provides ways for listeners to register themselves.
*
- * <h2>Avoid EventBus</h2>
- *
- * <p><b>We recommend against using EventBus.</b> It was designed many years ago, and newer
- * libraries offer better ways to decouple components and react to events.
- *
- * <p>To decouple components, we recommend a dependency-injection framework. For Android code, most
- * apps use <a href="https://dagger.dev">Dagger</a>. For server code, common options include <a
- * href="https://github.com/google/guice/wiki/Motivation">Guice</a> and <a
- * href="https://docs.spring.io/spring-framework/docs/current/reference/html/core.html#beans-introduction">Spring</a>.
- * Frameworks typically offer a way to register multiple listeners independently and then request
- * them together as a set (<a href="https://dagger.dev/dev-guide/multibindings">Dagger</a>, <a
- * href="https://github.com/google/guice/wiki/Multibindings">Guice</a>, <a
- * href="https://docs.spring.io/spring-framework/docs/current/reference/html/core.html#beans-autowired-annotation">Spring</a>).
- *
- * <p>To react to events, we recommend a reactive-streams framework like <a
- * href="https://github.com/ReactiveX/RxJava/wiki">RxJava</a> (supplemented with its <a
- * href="https://github.com/ReactiveX/RxAndroid">RxAndroid</a> extension if you are building for
- * Android) or <a href="https://projectreactor.io/">Project Reactor</a>. (For the basics of
- * translating code from using an event bus to using a reactive-streams framework, see these two
- * guides: <a href="https://blog.jkl.gg/implementing-an-event-bus-with-rxjava-rxbus/">1</a>, <a
- * href="https://lorentzos.com/rxjava-as-event-bus-the-right-way-10a36bdd49ba">2</a>.) Some usages
- * of EventBus may be better written using <a
- * href="https://kotlinlang.org/docs/coroutines-guide.html">Kotlin coroutines</a>, including <a
- * href="https://kotlinlang.org/docs/flow.html">Flow</a> and <a
- * href="https://kotlinlang.org/docs/channels.html">Channels</a>. Yet other usages are better served
- * by individual libraries that provide specialized support for particular use cases.
- *
- * <p>Disadvantages of EventBus include:
- *
- * <ul>
- * <li>It makes the cross-references between producer and subscriber harder to find. This can
- * complicate debugging, lead to unintentional reentrant calls, and force apps to eagerly
- * initialize all possible subscribers at startup time.
- * <li>It uses reflection in ways that break when code is processed by optimizers/minimizers like
- * <a href="https://developer.android.com/studio/build/shrink-code">R8 and Proguard</a>.
- * <li>It doesn't offer a way to wait for multiple events before taking action. For example, it
- * doesn't offer a way to wait for multiple producers to all report that they're "ready," nor
- * does it offer a way to batch multiple events from a single producer together.
- * <li>It doesn't support backpressure and other features needed for resilience.
- * <li>It doesn't provide much control of threading.
- * <li>It doesn't offer much monitoring.
- * <li>It doesn't propagate exceptions, so apps don't have a way to react to them.
- * <li>It doesn't interoperate well with RxJava, coroutines, and other more commonly used
- * alternatives.
- * <li>It imposes requirements on the lifecycle of its subscribers. For example, if an event
- * occurs between when one subscriber is removed and the next subscriber is added, the event
- * is dropped.
- * <li>Its performance is suboptimal, especially under Android.
- * <li>It <a href="https://github.com/google/guava/issues/1431">doesn't support parameterized
- * types</a>.
- * <li>With the introduction of lambdas in Java 8, EventBus went from less verbose than listeners
- * to <a href="https://github.com/google/guava/issues/3311">more verbose</a>.
- * </ul>
- *
- * <h2>EventBus Summary</h2>
- *
* <p>The EventBus allows publish-subscribe-style communication between components without requiring
* the components to explicitly register with one another (and thus be aware of each other). It is
* designed exclusively to replace traditional Java in-process event distribution using explicit
@@ -147,7 +92,7 @@
* @author Cliff Biffle
* @since 10.0
*/
-@ElementTypesAreNonnullByDefault
+@Beta
public class EventBus {
private static final Logger logger = Logger.getLogger(EventBus.class.getName());
diff --git a/android/guava/src/com/google/common/eventbus/ParametricNullness.java b/android/guava/src/com/google/common/eventbus/ParametricNullness.java
deleted file mode 100644
index fc5bb17..0000000
--- a/android/guava/src/com/google/common/eventbus/ParametricNullness.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2021 The Guava Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.common.eventbus;
-
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.PARAMETER;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-import static javax.annotation.meta.When.UNKNOWN;
-
-import com.google.common.annotations.GwtCompatible;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-import javax.annotation.Nonnull;
-import javax.annotation.meta.TypeQualifierNickname;
-
-/**
- * Marks a "top-level" type-variable usage as (a) a Kotlin platform type when the type argument is
- * non-nullable and (b) nullable when the type argument is nullable. This is the closest we can get
- * to "non-nullable when non-nullable; nullable when nullable" (like the Android <a
- * href="https://android.googlesource.com/platform/libcore/+/master/luni/src/main/java/libcore/util/NullFromTypeParam.java">{@code
- * NullFromTypeParam}</a>). We use this to "undo" {@link ElementTypesAreNonnullByDefault}.
- */
-@GwtCompatible
-@Retention(RUNTIME)
-@Target({FIELD, METHOD, PARAMETER})
-@TypeQualifierNickname
-@Nonnull(when = UNKNOWN)
-@interface ParametricNullness {}
diff --git a/android/guava/src/com/google/common/eventbus/Subscribe.java b/android/guava/src/com/google/common/eventbus/Subscribe.java
index 88477f1..52b999d 100644
--- a/android/guava/src/com/google/common/eventbus/Subscribe.java
+++ b/android/guava/src/com/google/common/eventbus/Subscribe.java
@@ -14,6 +14,7 @@
package com.google.common.eventbus;
+import com.google.common.annotations.Beta;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -35,5 +36,5 @@
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
-@ElementTypesAreNonnullByDefault
+@Beta
public @interface Subscribe {}
diff --git a/android/guava/src/com/google/common/eventbus/Subscriber.java b/android/guava/src/com/google/common/eventbus/Subscriber.java
index 73e7f42..42a63f2 100644
--- a/android/guava/src/com/google/common/eventbus/Subscriber.java
+++ b/android/guava/src/com/google/common/eventbus/Subscriber.java
@@ -21,7 +21,7 @@
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.concurrent.Executor;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* A subscriber method on a specific object, plus the executor that should be used for dispatching
@@ -32,7 +32,6 @@
*
* @author Colin Decker
*/
-@ElementTypesAreNonnullByDefault
class Subscriber {
/** Creates a {@code Subscriber} for {@code method} on {@code listener}. */
@@ -109,7 +108,7 @@
}
@Override
- public final boolean equals(@CheckForNull Object obj) {
+ public final boolean equals(@NullableDecl Object obj) {
if (obj instanceof Subscriber) {
Subscriber that = (Subscriber) obj;
// Use == so that different equal instances will still receive events.
diff --git a/android/guava/src/com/google/common/eventbus/SubscriberExceptionContext.java b/android/guava/src/com/google/common/eventbus/SubscriberExceptionContext.java
index 63c7d55..6ddd86f 100644
--- a/android/guava/src/com/google/common/eventbus/SubscriberExceptionContext.java
+++ b/android/guava/src/com/google/common/eventbus/SubscriberExceptionContext.java
@@ -23,7 +23,6 @@
*
* @since 16.0
*/
-@ElementTypesAreNonnullByDefault
public class SubscriberExceptionContext {
private final EventBus eventBus;
private final Object event;
@@ -32,7 +31,7 @@
/**
* @param eventBus The {@link EventBus} that handled the event and the subscriber. Useful for
- * broadcasting a new event based on the error.
+ * broadcasting a a new event based on the error.
* @param event The event object that caused the subscriber to throw.
* @param subscriber The source subscriber context.
* @param subscriberMethod the subscribed method.
@@ -47,7 +46,7 @@
/**
* @return The {@link EventBus} that handled the event and the subscriber. Useful for broadcasting
- * a new event based on the error.
+ * a a new event based on the error.
*/
public EventBus getEventBus() {
return eventBus;
diff --git a/android/guava/src/com/google/common/eventbus/SubscriberExceptionHandler.java b/android/guava/src/com/google/common/eventbus/SubscriberExceptionHandler.java
index 1c2fbb1..c239ad7 100644
--- a/android/guava/src/com/google/common/eventbus/SubscriberExceptionHandler.java
+++ b/android/guava/src/com/google/common/eventbus/SubscriberExceptionHandler.java
@@ -14,13 +14,11 @@
package com.google.common.eventbus;
-
/**
* Handler for exceptions thrown by event subscribers.
*
* @since 16.0
*/
-@ElementTypesAreNonnullByDefault
public interface SubscriberExceptionHandler {
/** Handles exceptions thrown by subscribers. */
void handleException(Throwable exception, SubscriberExceptionContext context);
diff --git a/android/guava/src/com/google/common/eventbus/SubscriberRegistry.java b/android/guava/src/com/google/common/eventbus/SubscriberRegistry.java
index 46e9820..6a6ceac 100644
--- a/android/guava/src/com/google/common/eventbus/SubscriberRegistry.java
+++ b/android/guava/src/com/google/common/eventbus/SubscriberRegistry.java
@@ -46,14 +46,13 @@
import java.util.Set;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.CopyOnWriteArraySet;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* Registry of subscribers to a single event bus.
*
* @author Colin Decker
*/
-@ElementTypesAreNonnullByDefault
final class SubscriberRegistry {
/**
@@ -259,7 +258,7 @@
}
@Override
- public boolean equals(@CheckForNull Object o) {
+ public boolean equals(@NullableDecl Object o) {
if (o instanceof MethodIdentifier) {
MethodIdentifier ident = (MethodIdentifier) o;
return name.equals(ident.name) && parameterTypes.equals(ident.parameterTypes);
diff --git a/android/guava/src/com/google/common/graph/AbstractBaseGraph.java b/android/guava/src/com/google/common/graph/AbstractBaseGraph.java
index c4be6b6..b68656b 100644
--- a/android/guava/src/com/google/common/graph/AbstractBaseGraph.java
+++ b/android/guava/src/com/google/common/graph/AbstractBaseGraph.java
@@ -30,7 +30,7 @@
import com.google.common.primitives.Ints;
import java.util.AbstractSet;
import java.util.Set;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* This class provides a skeletal implementation of {@link BaseGraph}.
@@ -41,7 +41,6 @@
* @author James Sexton
* @param <N> Node parameter type
*/
-@ElementTypesAreNonnullByDefault
abstract class AbstractBaseGraph<N> implements BaseGraph<N> {
/**
@@ -77,7 +76,7 @@
}
@Override
- public boolean remove(@CheckForNull Object o) {
+ public boolean remove(Object o) {
throw new UnsupportedOperationException();
}
@@ -86,7 +85,7 @@
// Graph<LinkedList>.
@SuppressWarnings("unchecked")
@Override
- public boolean contains(@CheckForNull Object obj) {
+ public boolean contains(@NullableDecl Object obj) {
if (!(obj instanceof EndpointPair)) {
return false;
}
diff --git a/android/guava/src/com/google/common/graph/AbstractDirectedNetworkConnections.java b/android/guava/src/com/google/common/graph/AbstractDirectedNetworkConnections.java
index ac452d4..8335d0c 100644
--- a/android/guava/src/com/google/common/graph/AbstractDirectedNetworkConnections.java
+++ b/android/guava/src/com/google/common/graph/AbstractDirectedNetworkConnections.java
@@ -20,7 +20,6 @@
import static com.google.common.base.Preconditions.checkState;
import static com.google.common.graph.Graphs.checkNonNegative;
import static com.google.common.graph.Graphs.checkPositive;
-import static java.util.Objects.requireNonNull;
import com.google.common.collect.Iterables;
import com.google.common.collect.Iterators;
@@ -31,7 +30,7 @@
import java.util.Collections;
import java.util.Map;
import java.util.Set;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* A base implementation of {@link NetworkConnections} for directed networks.
@@ -40,17 +39,17 @@
* @param <N> Node parameter type
* @param <E> Edge parameter type
*/
-@ElementTypesAreNonnullByDefault
abstract class AbstractDirectedNetworkConnections<N, E> implements NetworkConnections<N, E> {
/** Keys are edges incoming to the origin node, values are the source node. */
- final Map<E, N> inEdgeMap;
+ protected final Map<E, N> inEdgeMap;
/** Keys are edges outgoing from the origin node, values are the target node. */
- final Map<E, N> outEdgeMap;
+ protected final Map<E, N> outEdgeMap;
private int selfLoopCount;
- AbstractDirectedNetworkConnections(Map<E, N> inEdgeMap, Map<E, N> outEdgeMap, int selfLoopCount) {
+ protected AbstractDirectedNetworkConnections(
+ Map<E, N> inEdgeMap, Map<E, N> outEdgeMap, int selfLoopCount) {
this.inEdgeMap = checkNotNull(inEdgeMap);
this.outEdgeMap = checkNotNull(outEdgeMap);
this.selfLoopCount = checkNonNegative(selfLoopCount);
@@ -80,7 +79,7 @@
}
@Override
- public boolean contains(@CheckForNull Object obj) {
+ public boolean contains(@NullableDecl Object obj) {
return inEdgeMap.containsKey(obj) || outEdgeMap.containsKey(obj);
}
};
@@ -100,8 +99,7 @@
public N adjacentNode(E edge) {
// Since the reference node is defined to be 'source' for directed graphs,
// we can assume this edge lives in the set of outgoing edges.
- // (We're relying on callers to call this method only with an edge that's in the graph.)
- return requireNonNull(outEdgeMap.get(edge));
+ return checkNotNull(outEdgeMap.get(edge));
}
@Override
@@ -110,15 +108,13 @@
checkNonNegative(--selfLoopCount);
}
N previousNode = inEdgeMap.remove(edge);
- // We're relying on callers to call this method only with an edge that's in the graph.
- return requireNonNull(previousNode);
+ return checkNotNull(previousNode);
}
@Override
public N removeOutEdge(E edge) {
N previousNode = outEdgeMap.remove(edge);
- // We're relying on callers to call this method only with an edge that's in the graph.
- return requireNonNull(previousNode);
+ return checkNotNull(previousNode);
}
@Override
diff --git a/android/guava/src/com/google/common/graph/AbstractGraph.java b/android/guava/src/com/google/common/graph/AbstractGraph.java
index 9402be5..fc71345 100644
--- a/android/guava/src/com/google/common/graph/AbstractGraph.java
+++ b/android/guava/src/com/google/common/graph/AbstractGraph.java
@@ -17,7 +17,7 @@
package com.google.common.graph;
import com.google.common.annotations.Beta;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* This class provides a skeletal implementation of {@link Graph}. It is recommended to extend this
@@ -28,11 +28,10 @@
* @since 20.0
*/
@Beta
-@ElementTypesAreNonnullByDefault
public abstract class AbstractGraph<N> extends AbstractBaseGraph<N> implements Graph<N> {
@Override
- public final boolean equals(@CheckForNull Object obj) {
+ public final boolean equals(@NullableDecl Object obj) {
if (obj == this) {
return true;
}
diff --git a/android/guava/src/com/google/common/graph/AbstractGraphBuilder.java b/android/guava/src/com/google/common/graph/AbstractGraphBuilder.java
index a4e1543..84e461a 100644
--- a/android/guava/src/com/google/common/graph/AbstractGraphBuilder.java
+++ b/android/guava/src/com/google/common/graph/AbstractGraphBuilder.java
@@ -23,7 +23,6 @@
*
* @author James Sexton
*/
-@ElementTypesAreNonnullByDefault
abstract class AbstractGraphBuilder<N> {
final boolean directed;
boolean allowsSelfLoops = false;
diff --git a/android/guava/src/com/google/common/graph/AbstractNetwork.java b/android/guava/src/com/google/common/graph/AbstractNetwork.java
index 9afbb03..fad1514 100644
--- a/android/guava/src/com/google/common/graph/AbstractNetwork.java
+++ b/android/guava/src/com/google/common/graph/AbstractNetwork.java
@@ -34,7 +34,7 @@
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* This class provides a skeletal implementation of {@link Network}. It is recommended to extend
@@ -49,7 +49,6 @@
* @since 20.0
*/
@Beta
-@ElementTypesAreNonnullByDefault
public abstract class AbstractNetwork<N, E> implements Network<N, E> {
@Override
@@ -90,7 +89,7 @@
// Network<LinkedList>.
@SuppressWarnings("unchecked")
@Override
- public boolean contains(@CheckForNull Object obj) {
+ public boolean contains(@NullableDecl Object obj) {
if (!(obj instanceof EndpointPair)) {
return false;
}
@@ -195,7 +194,7 @@
}
@Override
- @CheckForNull
+ @NullableDecl
public E edgeConnectingOrNull(N nodeU, N nodeV) {
Set<E> edgesConnecting = edgesConnecting(nodeU, nodeV);
switch (edgesConnecting.size()) {
@@ -209,7 +208,7 @@
}
@Override
- @CheckForNull
+ @NullableDecl
public E edgeConnectingOrNull(EndpointPair<N> endpoints) {
validateEndpoints(endpoints);
return edgeConnectingOrNull(endpoints.nodeU(), endpoints.nodeV());
@@ -245,7 +244,7 @@
}
@Override
- public final boolean equals(@CheckForNull Object obj) {
+ public final boolean equals(@NullableDecl Object obj) {
if (obj == this) {
return true;
}
diff --git a/android/guava/src/com/google/common/graph/AbstractUndirectedNetworkConnections.java b/android/guava/src/com/google/common/graph/AbstractUndirectedNetworkConnections.java
index 8f736d7..03279d0 100644
--- a/android/guava/src/com/google/common/graph/AbstractUndirectedNetworkConnections.java
+++ b/android/guava/src/com/google/common/graph/AbstractUndirectedNetworkConnections.java
@@ -18,12 +18,10 @@
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkState;
-import static java.util.Objects.requireNonNull;
import java.util.Collections;
import java.util.Map;
import java.util.Set;
-import javax.annotation.CheckForNull;
/**
* A base implementation of {@link NetworkConnections} for undirected networks.
@@ -32,12 +30,11 @@
* @param <N> Node parameter type
* @param <E> Edge parameter type
*/
-@ElementTypesAreNonnullByDefault
abstract class AbstractUndirectedNetworkConnections<N, E> implements NetworkConnections<N, E> {
/** Keys are edges incident to the origin node, values are the node at the other end. */
- final Map<E, N> incidentEdgeMap;
+ protected final Map<E, N> incidentEdgeMap;
- AbstractUndirectedNetworkConnections(Map<E, N> incidentEdgeMap) {
+ protected AbstractUndirectedNetworkConnections(Map<E, N> incidentEdgeMap) {
this.incidentEdgeMap = checkNotNull(incidentEdgeMap);
}
@@ -68,12 +65,10 @@
@Override
public N adjacentNode(E edge) {
- // We're relying on callers to call this method only with an edge that's in the graph.
- return requireNonNull(incidentEdgeMap.get(edge));
+ return checkNotNull(incidentEdgeMap.get(edge));
}
@Override
- @CheckForNull
public N removeInEdge(E edge, boolean isSelfLoop) {
if (!isSelfLoop) {
return removeOutEdge(edge);
@@ -84,8 +79,7 @@
@Override
public N removeOutEdge(E edge) {
N previousNode = incidentEdgeMap.remove(edge);
- // We're relying on callers to call this method only with an edge that's in the graph.
- return requireNonNull(previousNode);
+ return checkNotNull(previousNode);
}
@Override
diff --git a/android/guava/src/com/google/common/graph/AbstractValueGraph.java b/android/guava/src/com/google/common/graph/AbstractValueGraph.java
index 940aeff..be2b7cc 100644
--- a/android/guava/src/com/google/common/graph/AbstractValueGraph.java
+++ b/android/guava/src/com/google/common/graph/AbstractValueGraph.java
@@ -16,14 +16,12 @@
package com.google.common.graph;
-import static java.util.Objects.requireNonNull;
-
import com.google.common.annotations.Beta;
import com.google.common.base.Function;
import com.google.common.collect.Maps;
import java.util.Map;
import java.util.Set;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* This class provides a skeletal implementation of {@link ValueGraph}. It is recommended to extend
@@ -38,7 +36,6 @@
* @since 20.0
*/
@Beta
-@ElementTypesAreNonnullByDefault
public abstract class AbstractValueGraph<N, V> extends AbstractBaseGraph<N>
implements ValueGraph<N, V> {
@@ -108,7 +105,7 @@
}
@Override
- public final boolean equals(@CheckForNull Object obj) {
+ public final boolean equals(@NullableDecl Object obj) {
if (obj == this) {
return true;
}
@@ -145,8 +142,7 @@
new Function<EndpointPair<N>, V>() {
@Override
public V apply(EndpointPair<N> edge) {
- // requireNonNull is safe because the endpoint pair comes from the graph.
- return requireNonNull(graph.edgeValueOrDefault(edge.nodeU(), edge.nodeV(), null));
+ return graph.edgeValueOrDefault(edge.nodeU(), edge.nodeV(), null);
}
};
return Maps.asMap(graph.edges(), edgeToValueFn);
diff --git a/android/guava/src/com/google/common/graph/BaseGraph.java b/android/guava/src/com/google/common/graph/BaseGraph.java
index 68813e1..1df5de7 100644
--- a/android/guava/src/com/google/common/graph/BaseGraph.java
+++ b/android/guava/src/com/google/common/graph/BaseGraph.java
@@ -24,7 +24,6 @@
* @author James Sexton
* @param <N> Node parameter type
*/
-@ElementTypesAreNonnullByDefault
interface BaseGraph<N> extends SuccessorsFunction<N>, PredecessorsFunction<N> {
//
// Graph-level accessors
diff --git a/android/guava/src/com/google/common/graph/DirectedGraphConnections.java b/android/guava/src/com/google/common/graph/DirectedGraphConnections.java
index 23083da..12887b7 100644
--- a/android/guava/src/com/google/common/graph/DirectedGraphConnections.java
+++ b/android/guava/src/com/google/common/graph/DirectedGraphConnections.java
@@ -40,7 +40,7 @@
import java.util.Map.Entry;
import java.util.Set;
import java.util.concurrent.atomic.AtomicBoolean;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* An implementation of {@link GraphConnections} for directed graphs.
@@ -50,7 +50,6 @@
* @param <N> Node parameter type
* @param <V> Value parameter type
*/
-@ElementTypesAreNonnullByDefault
final class DirectedGraphConnections<N, V> implements GraphConnections<N, V> {
/**
* A wrapper class to indicate a node is both a predecessor and successor while still providing
@@ -83,7 +82,7 @@
}
@Override
- public boolean equals(@CheckForNull Object that) {
+ public boolean equals(Object that) {
if (that instanceof Pred) {
return this.node.equals(((Pred<?>) that).node);
} else {
@@ -104,7 +103,7 @@
}
@Override
- public boolean equals(@CheckForNull Object that) {
+ public boolean equals(Object that) {
if (that instanceof Succ) {
return this.node.equals(((Succ<?>) that).node);
} else {
@@ -134,14 +133,14 @@
* LinkedHashMap combines two such edges into a single node-value pair, even though the edges may
* not have been inserted consecutively.
*/
- @CheckForNull private final List<NodeConnection<N>> orderedNodeConnections;
+ @NullableDecl private final List<NodeConnection<N>> orderedNodeConnections;
private int predecessorCount;
private int successorCount;
private DirectedGraphConnections(
Map<N, Object> adjacentNodeValues,
- @CheckForNull List<NodeConnection<N>> orderedNodeConnections,
+ @NullableDecl List<NodeConnection<N>> orderedNodeConnections,
int predecessorCount,
int successorCount) {
this.adjacentNodeValues = checkNotNull(adjacentNodeValues);
@@ -243,7 +242,6 @@
final Set<N> seenNodes = new HashSet<>();
return new AbstractIterator<N>() {
@Override
- @CheckForNull
protected N computeNext() {
while (nodeConnections.hasNext()) {
NodeConnection<N> nodeConnection = nodeConnections.next();
@@ -263,7 +261,7 @@
}
@Override
- public boolean contains(@CheckForNull Object obj) {
+ public boolean contains(@NullableDecl Object obj) {
return adjacentNodeValues.containsKey(obj);
}
};
@@ -279,7 +277,6 @@
final Iterator<Entry<N, Object>> entries = adjacentNodeValues.entrySet().iterator();
return new AbstractIterator<N>() {
@Override
- @CheckForNull
protected N computeNext() {
while (entries.hasNext()) {
Entry<N, Object> entry = entries.next();
@@ -294,7 +291,6 @@
final Iterator<NodeConnection<N>> nodeConnections = orderedNodeConnections.iterator();
return new AbstractIterator<N>() {
@Override
- @CheckForNull
protected N computeNext() {
while (nodeConnections.hasNext()) {
NodeConnection<N> nodeConnection = nodeConnections.next();
@@ -314,7 +310,7 @@
}
@Override
- public boolean contains(@CheckForNull Object obj) {
+ public boolean contains(@NullableDecl Object obj) {
return isPredecessor(adjacentNodeValues.get(obj));
}
};
@@ -329,7 +325,6 @@
final Iterator<Entry<N, Object>> entries = adjacentNodeValues.entrySet().iterator();
return new AbstractIterator<N>() {
@Override
- @CheckForNull
protected N computeNext() {
while (entries.hasNext()) {
Entry<N, Object> entry = entries.next();
@@ -344,7 +339,6 @@
final Iterator<NodeConnection<N>> nodeConnections = orderedNodeConnections.iterator();
return new AbstractIterator<N>() {
@Override
- @CheckForNull
protected N computeNext() {
while (nodeConnections.hasNext()) {
NodeConnection<N> nodeConnection = nodeConnections.next();
@@ -364,7 +358,7 @@
}
@Override
- public boolean contains(@CheckForNull Object obj) {
+ public boolean contains(@NullableDecl Object obj) {
return isSuccessor(adjacentNodeValues.get(obj));
}
};
@@ -413,7 +407,6 @@
final AtomicBoolean alreadySeenSelfLoop = new AtomicBoolean(false);
return new AbstractIterator<EndpointPair<N>>() {
@Override
- @CheckForNull
protected EndpointPair<N> computeNext() {
while (resultWithDoubleSelfLoop.hasNext()) {
EndpointPair<N> edge = resultWithDoubleSelfLoop.next();
@@ -432,7 +425,6 @@
@SuppressWarnings("unchecked")
@Override
- @CheckForNull
public V value(N node) {
checkNotNull(node);
Object value = adjacentNodeValues.get(node);
@@ -474,7 +466,6 @@
@SuppressWarnings("unchecked")
@Override
- @CheckForNull
public V removeSuccessor(Object node) {
checkNotNull(node);
Object previousValue = adjacentNodeValues.get(node);
@@ -498,14 +489,7 @@
}
}
- /*
- * TODO(cpovirk): `return (V) removedValue` once our checker permits that.
- *
- * (We promoted a class of warnings into errors because sometimes they indicate real problems.
- * But now we need to "undo" some instance of spurious errors, as discussed in
- * https://github.com/jspecify/checker-framework/issues/8.)
- */
- return removedValue == null ? null : (V) removedValue;
+ return (V) removedValue;
}
@Override
@@ -538,7 +522,6 @@
@SuppressWarnings("unchecked")
@Override
- @CheckForNull
public V addSuccessor(N node, V value) {
Object previousValue = adjacentNodeValues.put(node, value);
Object previousSuccessor;
@@ -563,15 +546,14 @@
}
}
- // See the comment on the similar cast in removeSuccessor.
- return previousSuccessor == null ? null : (V) previousSuccessor;
+ return (V) previousSuccessor;
}
- private static boolean isPredecessor(@CheckForNull Object value) {
+ private static boolean isPredecessor(@NullableDecl Object value) {
return (value == PRED) || (value instanceof PredAndSucc);
}
- private static boolean isSuccessor(@CheckForNull Object value) {
+ private static boolean isSuccessor(@NullableDecl Object value) {
return (value != PRED) && (value != null);
}
}
diff --git a/android/guava/src/com/google/common/graph/DirectedMultiNetworkConnections.java b/android/guava/src/com/google/common/graph/DirectedMultiNetworkConnections.java
index 05f40c2..e1ed3cc 100644
--- a/android/guava/src/com/google/common/graph/DirectedMultiNetworkConnections.java
+++ b/android/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 javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* An implementation of {@link NetworkConnections} for directed networks with parallel edges.
@@ -39,7 +39,6 @@
* @param <N> Node parameter type
* @param <E> Edge parameter type
*/
-@ElementTypesAreNonnullByDefault
final class DirectedMultiNetworkConnections<N, E> extends AbstractDirectedNetworkConnections<N, E> {
private DirectedMultiNetworkConnections(
@@ -60,7 +59,7 @@
ImmutableMap.copyOf(inEdges), ImmutableMap.copyOf(outEdges), selfLoopCount);
}
- @CheckForNull @LazyInit private transient Reference<Multiset<N>> predecessorsReference;
+ @LazyInit private transient Reference<Multiset<N>> predecessorsReference;
@Override
public Set<N> predecessors() {
@@ -76,7 +75,7 @@
return predecessors;
}
- @CheckForNull @LazyInit private transient Reference<Multiset<N>> successorsReference;
+ @LazyInit private transient Reference<Multiset<N>> successorsReference;
@Override
public Set<N> successors() {
@@ -140,8 +139,8 @@
}
}
- @CheckForNull
- private static <T> T getReference(@CheckForNull Reference<T> reference) {
+ @NullableDecl
+ private static <T> T getReference(@NullableDecl Reference<T> reference) {
return (reference == null) ? null : reference.get();
}
}
diff --git a/android/guava/src/com/google/common/graph/DirectedNetworkConnections.java b/android/guava/src/com/google/common/graph/DirectedNetworkConnections.java
index c2a25a5..2a0b010 100644
--- a/android/guava/src/com/google/common/graph/DirectedNetworkConnections.java
+++ b/android/guava/src/com/google/common/graph/DirectedNetworkConnections.java
@@ -32,10 +32,10 @@
* @param <N> Node parameter type
* @param <E> Edge parameter type
*/
-@ElementTypesAreNonnullByDefault
final class DirectedNetworkConnections<N, E> extends AbstractDirectedNetworkConnections<N, E> {
- DirectedNetworkConnections(Map<E, N> inEdgeMap, Map<E, N> outEdgeMap, int selfLoopCount) {
+ protected DirectedNetworkConnections(
+ Map<E, N> inEdgeMap, Map<E, N> outEdgeMap, int selfLoopCount) {
super(inEdgeMap, outEdgeMap, selfLoopCount);
}
diff --git a/android/guava/src/com/google/common/graph/EdgesConnecting.java b/android/guava/src/com/google/common/graph/EdgesConnecting.java
index 797970b..d62eefa 100644
--- a/android/guava/src/com/google/common/graph/EdgesConnecting.java
+++ b/android/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 javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* A class to represent the set of edges connecting an (implicit) origin node to a target node.
@@ -34,7 +34,6 @@
* @author James Sexton
* @param <E> Edge parameter type
*/
-@ElementTypesAreNonnullByDefault
final class EdgesConnecting<E> extends AbstractSet<E> {
private final Map<?, E> nodeToOutEdge;
@@ -59,12 +58,12 @@
}
@Override
- public boolean contains(@CheckForNull Object edge) {
+ public boolean contains(@NullableDecl Object edge) {
E connectingEdge = getConnectingEdge();
return (connectingEdge != null && connectingEdge.equals(edge));
}
- @CheckForNull
+ @NullableDecl
private E getConnectingEdge() {
return nodeToOutEdge.get(targetNode);
}
diff --git a/android/guava/src/com/google/common/graph/ElementOrder.java b/android/guava/src/com/google/common/graph/ElementOrder.java
index ea13674..568fb42 100644
--- a/android/guava/src/com/google/common/graph/ElementOrder.java
+++ b/android/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 javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* Used to represent the order of elements in a data structure that supports different options for
@@ -46,12 +46,11 @@
*/
@Beta
@Immutable
-@ElementTypesAreNonnullByDefault
public final class ElementOrder<T> {
private final Type type;
@SuppressWarnings("Immutable") // Hopefully the comparator provided is immutable!
- @CheckForNull
+ @NullableDecl
private final Comparator<T> comparator;
/**
@@ -72,7 +71,7 @@
SORTED
}
- private ElementOrder(Type type, @CheckForNull Comparator<T> comparator) {
+ private ElementOrder(Type type, @NullableDecl Comparator<T> comparator) {
this.type = checkNotNull(type);
this.comparator = comparator;
checkState((type == Type.SORTED) == (comparator != null));
@@ -161,7 +160,7 @@
}
@Override
- public boolean equals(@CheckForNull Object obj) {
+ public boolean equals(@NullableDecl Object obj) {
if (obj == this) {
return true;
}
diff --git a/android/guava/src/com/google/common/graph/ElementTypesAreNonnullByDefault.java b/android/guava/src/com/google/common/graph/ElementTypesAreNonnullByDefault.java
deleted file mode 100644
index 0798de0..0000000
--- a/android/guava/src/com/google/common/graph/ElementTypesAreNonnullByDefault.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) 2021 The Guava Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.common.graph;
-
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.PARAMETER;
-import static java.lang.annotation.ElementType.TYPE;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-import com.google.common.annotations.GwtCompatible;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-import javax.annotation.Nonnull;
-import javax.annotation.meta.TypeQualifierDefault;
-
-/**
- * Marks all "top-level" types as non-null in a way that is recognized by Kotlin. Note that this
- * unfortunately includes type-variable usages, so we also provide {@link ParametricNullness} to
- * "undo" it as best we can.
- */
-@GwtCompatible
-@Retention(RUNTIME)
-@Target(TYPE)
-@TypeQualifierDefault({FIELD, METHOD, PARAMETER})
-@Nonnull
-@interface ElementTypesAreNonnullByDefault {}
diff --git a/android/guava/src/com/google/common/graph/EndpointPair.java b/android/guava/src/com/google/common/graph/EndpointPair.java
index 7aa3860..7caa43b 100644
--- a/android/guava/src/com/google/common/graph/EndpointPair.java
+++ b/android/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 javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* An immutable pair representing the two endpoints of an edge in a graph. The {@link EndpointPair}
@@ -39,7 +39,6 @@
*/
@Beta
@Immutable(containerOf = {"N"})
-@ElementTypesAreNonnullByDefault
public abstract class EndpointPair<N> implements Iterable<N> {
private final N nodeU;
private final N nodeV;
@@ -104,9 +103,8 @@
* Returns the node that is adjacent to {@code node} along the origin edge.
*
* @throws IllegalArgumentException if this {@link EndpointPair} does not contain {@code node}
- * @since 20.0 (but the argument type was changed from {@code Object} to {@code N} in 31.0)
*/
- public final N adjacentNode(N node) {
+ public final N adjacentNode(Object node) {
if (node.equals(nodeU)) {
return nodeV;
} else if (node.equals(nodeV)) {
@@ -134,7 +132,7 @@
* ordered {@link EndpointPair} is never equal to an unordered {@link EndpointPair}.
*/
@Override
- public abstract boolean equals(@CheckForNull Object obj);
+ public abstract boolean equals(@NullableDecl Object obj);
/**
* The hashcode of an ordered {@link EndpointPair} is equal to {@code Objects.hashCode(source(),
@@ -165,7 +163,7 @@
}
@Override
- public boolean equals(@CheckForNull Object obj) {
+ public boolean equals(@NullableDecl Object obj) {
if (obj == this) {
return true;
}
@@ -213,7 +211,7 @@
}
@Override
- public boolean equals(@CheckForNull Object obj) {
+ public boolean equals(@NullableDecl Object obj) {
if (obj == this) {
return true;
}
diff --git a/android/guava/src/com/google/common/graph/EndpointPairIterator.java b/android/guava/src/com/google/common/graph/EndpointPairIterator.java
index 7096dbe..c4e6e07 100644
--- a/android/guava/src/com/google/common/graph/EndpointPairIterator.java
+++ b/android/guava/src/com/google/common/graph/EndpointPairIterator.java
@@ -17,30 +17,24 @@
package com.google.common.graph;
import static com.google.common.base.Preconditions.checkState;
-import static java.util.Objects.requireNonNull;
import com.google.common.collect.AbstractIterator;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Sets;
import java.util.Iterator;
import java.util.Set;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* A class to facilitate the set returned by {@link Graph#edges()}.
*
* @author James Sexton
*/
-@ElementTypesAreNonnullByDefault
abstract class EndpointPairIterator<N> extends AbstractIterator<EndpointPair<N>> {
private final BaseGraph<N> graph;
private final Iterator<N> nodeIterator;
- @CheckForNull
- N node = null; // null is safe as an initial value because graphs don't allow null nodes
-
- Iterator<N> successorIterator = ImmutableSet.<N>of().iterator();
+ protected N node = null; // null is safe as an initial value because graphs don't allow null nodes
+ protected Iterator<N> successorIterator = ImmutableSet.<N>of().iterator();
static <N> EndpointPairIterator<N> of(BaseGraph<N> graph) {
return graph.isDirected() ? new Directed<N>(graph) : new Undirected<N>(graph);
@@ -55,7 +49,7 @@
* Called after {@link #successorIterator} is exhausted. Advances {@link #node} to the next node
* and updates {@link #successorIterator} to iterate through the successors of {@link #node}.
*/
- final boolean advance() {
+ protected final boolean advance() {
checkState(!successorIterator.hasNext());
if (!nodeIterator.hasNext()) {
return false;
@@ -75,12 +69,10 @@
}
@Override
- @CheckForNull
protected EndpointPair<N> computeNext() {
while (true) {
if (successorIterator.hasNext()) {
- // requireNonNull is safe because successorIterator is empty until we set this.node.
- return EndpointPair.ordered(requireNonNull(node), successorIterator.next());
+ return EndpointPair.ordered(node, successorIterator.next());
}
if (!advance()) {
return endOfData();
@@ -116,28 +108,20 @@
* </pre>
*/
private static final class Undirected<N> extends EndpointPairIterator<N> {
- // It's a little weird that we add `null` to this set, but it makes for slightly simpler code.
- @CheckForNull private Set<@Nullable N> visitedNodes;
+ private Set<N> visitedNodes;
private Undirected(BaseGraph<N> graph) {
super(graph);
- this.visitedNodes = Sets.newHashSetWithExpectedSize(graph.nodes().size() + 1);
+ this.visitedNodes = Sets.newHashSetWithExpectedSize(graph.nodes().size());
}
@Override
- @CheckForNull
protected EndpointPair<N> computeNext() {
while (true) {
- /*
- * requireNonNull is safe because visitedNodes isn't cleared until this method calls
- * endOfData() (after which this method is never called again).
- */
- requireNonNull(visitedNodes);
while (successorIterator.hasNext()) {
N otherNode = successorIterator.next();
if (!visitedNodes.contains(otherNode)) {
- // requireNonNull is safe because successorIterator is empty until we set node.
- return EndpointPair.unordered(requireNonNull(node), otherNode);
+ return EndpointPair.unordered(node, otherNode);
}
}
// Add to visited set *after* processing neighbors so we still include self-loops.
diff --git a/android/guava/src/com/google/common/graph/ForwardingGraph.java b/android/guava/src/com/google/common/graph/ForwardingGraph.java
index f4ddf42..4a3ab8c 100644
--- a/android/guava/src/com/google/common/graph/ForwardingGraph.java
+++ b/android/guava/src/com/google/common/graph/ForwardingGraph.java
@@ -24,10 +24,9 @@
*
* @author James Sexton
*/
-@ElementTypesAreNonnullByDefault
abstract class ForwardingGraph<N> extends AbstractGraph<N> {
- abstract BaseGraph<N> delegate();
+ protected abstract BaseGraph<N> delegate();
@Override
public Set<N> nodes() {
diff --git a/android/guava/src/com/google/common/graph/ForwardingNetwork.java b/android/guava/src/com/google/common/graph/ForwardingNetwork.java
index fd21152..89766dc 100644
--- a/android/guava/src/com/google/common/graph/ForwardingNetwork.java
+++ b/android/guava/src/com/google/common/graph/ForwardingNetwork.java
@@ -17,7 +17,6 @@
package com.google.common.graph;
import java.util.Set;
-import javax.annotation.CheckForNull;
/**
* A class to allow {@link Network} implementations to be backed by a provided delegate. This is not
@@ -26,10 +25,9 @@
* @author James Sexton
* @author Joshua O'Madadhain
*/
-@ElementTypesAreNonnullByDefault
abstract class ForwardingNetwork<N, E> extends AbstractNetwork<N, E> {
- abstract Network<N, E> delegate();
+ protected abstract Network<N, E> delegate();
@Override
public Set<N> nodes() {
@@ -132,13 +130,11 @@
}
@Override
- @CheckForNull
public E edgeConnectingOrNull(N nodeU, N nodeV) {
return delegate().edgeConnectingOrNull(nodeU, nodeV);
}
@Override
- @CheckForNull
public E edgeConnectingOrNull(EndpointPair<N> endpoints) {
return delegate().edgeConnectingOrNull(endpoints);
}
diff --git a/android/guava/src/com/google/common/graph/ForwardingValueGraph.java b/android/guava/src/com/google/common/graph/ForwardingValueGraph.java
index 70ed6e5..2507890 100644
--- a/android/guava/src/com/google/common/graph/ForwardingValueGraph.java
+++ b/android/guava/src/com/google/common/graph/ForwardingValueGraph.java
@@ -17,7 +17,7 @@
package com.google.common.graph;
import java.util.Set;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* A class to allow {@link ValueGraph} implementations to be backed by a provided delegate. This is
@@ -26,10 +26,9 @@
* @author James Sexton
* @author Joshua O'Madadhain
*/
-@ElementTypesAreNonnullByDefault
abstract class ForwardingValueGraph<N, V> extends AbstractValueGraph<N, V> {
- abstract ValueGraph<N, V> delegate();
+ protected abstract ValueGraph<N, V> delegate();
@Override
public Set<N> nodes() {
@@ -106,14 +105,14 @@
}
@Override
- @CheckForNull
- public V edgeValueOrDefault(N nodeU, N nodeV, @CheckForNull V defaultValue) {
+ @NullableDecl
+ public V edgeValueOrDefault(N nodeU, N nodeV, @NullableDecl V defaultValue) {
return delegate().edgeValueOrDefault(nodeU, nodeV, defaultValue);
}
@Override
- @CheckForNull
- public V edgeValueOrDefault(EndpointPair<N> endpoints, @CheckForNull V defaultValue) {
+ @NullableDecl
+ public V edgeValueOrDefault(EndpointPair<N> endpoints, @NullableDecl V defaultValue) {
return delegate().edgeValueOrDefault(endpoints, defaultValue);
}
}
diff --git a/android/guava/src/com/google/common/graph/Graph.java b/android/guava/src/com/google/common/graph/Graph.java
index 5dc0e71..8ed35fb 100644
--- a/android/guava/src/com/google/common/graph/Graph.java
+++ b/android/guava/src/com/google/common/graph/Graph.java
@@ -20,7 +20,7 @@
import com.google.errorprone.annotations.DoNotMock;
import java.util.Collection;
import java.util.Set;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* An interface for <a
@@ -103,7 +103,6 @@
*/
@Beta
@DoNotMock("Use GraphBuilder to create a real instance")
-@ElementTypesAreNonnullByDefault
public interface Graph<N> extends BaseGraph<N> {
//
// Graph-level accessors
@@ -290,7 +289,7 @@
* <p>A reference implementation of this is provided by {@link AbstractGraph#equals(Object)}.
*/
@Override
- boolean equals(@CheckForNull Object object);
+ boolean equals(@NullableDecl 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/android/guava/src/com/google/common/graph/GraphBuilder.java b/android/guava/src/com/google/common/graph/GraphBuilder.java
index d57ed37..f00d7b1 100644
--- a/android/guava/src/com/google/common/graph/GraphBuilder.java
+++ b/android/guava/src/com/google/common/graph/GraphBuilder.java
@@ -64,7 +64,6 @@
*/
@Beta
@DoNotMock
-@ElementTypesAreNonnullByDefault
public final class GraphBuilder<N> extends AbstractGraphBuilder<N> {
/** Creates a new instance with the specified edge directionality. */
diff --git a/android/guava/src/com/google/common/graph/GraphConnections.java b/android/guava/src/com/google/common/graph/GraphConnections.java
index 7d4f8f0..d783c78 100644
--- a/android/guava/src/com/google/common/graph/GraphConnections.java
+++ b/android/guava/src/com/google/common/graph/GraphConnections.java
@@ -19,7 +19,7 @@
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import java.util.Iterator;
import java.util.Set;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* An interface for representing and manipulating an origin node's adjacent nodes and edge values in
@@ -29,7 +29,6 @@
* @param <N> Node parameter type
* @param <V> Value parameter type
*/
-@ElementTypesAreNonnullByDefault
interface GraphConnections<N, V> {
Set<N> adjacentNodes();
@@ -49,7 +48,7 @@
* Returns the value associated with the edge connecting the origin node to {@code node}, or null
* if there is no such edge.
*/
- @CheckForNull
+ @NullableDecl
V value(N node);
/** Remove {@code node} from the set of predecessors. */
@@ -60,7 +59,6 @@
* the edge connecting the two nodes.
*/
@CanIgnoreReturnValue
- @CheckForNull
V removeSuccessor(N node);
/**
@@ -75,6 +73,5 @@
* the value previously associated with the edge connecting the two nodes.
*/
@CanIgnoreReturnValue
- @CheckForNull
V addSuccessor(N node, V value);
}
diff --git a/android/guava/src/com/google/common/graph/GraphConstants.java b/android/guava/src/com/google/common/graph/GraphConstants.java
index ae224fd..224c6d2 100644
--- a/android/guava/src/com/google/common/graph/GraphConstants.java
+++ b/android/guava/src/com/google/common/graph/GraphConstants.java
@@ -16,9 +16,7 @@
package com.google.common.graph;
-
/** A utility class to hold various constants used by the Guava Graph library. */
-@ElementTypesAreNonnullByDefault
final class GraphConstants {
private GraphConstants() {}
diff --git a/android/guava/src/com/google/common/graph/Graphs.java b/android/guava/src/com/google/common/graph/Graphs.java
index bad8580..c278c71 100644
--- a/android/guava/src/com/google/common/graph/Graphs.java
+++ b/android/guava/src/com/google/common/graph/Graphs.java
@@ -18,7 +18,6 @@
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.graph.GraphConstants.NODE_NOT_IN_GRAPH;
-import static java.util.Objects.requireNonNull;
import com.google.common.annotations.Beta;
import com.google.common.base.Function;
@@ -33,7 +32,7 @@
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* Static utility methods for {@link Graph}, {@link ValueGraph}, and {@link Network} instances.
@@ -43,7 +42,6 @@
* @since 20.0
*/
@Beta
-@ElementTypesAreNonnullByDefault
public final class Graphs {
private Graphs() {}
@@ -103,7 +101,7 @@
Graph<N> graph,
Map<Object, NodeVisitState> visitedNodes,
N node,
- @CheckForNull N previousNode) {
+ @NullableDecl N previousNode) {
NodeVisitState state = visitedNodes.get(node);
if (state == NodeVisitState.COMPLETE) {
return false;
@@ -130,7 +128,7 @@
* from B to A).
*/
private static boolean canTraverseWithoutReusingEdge(
- Graph<?> graph, Object nextNode, @CheckForNull Object previousNode) {
+ Graph<?> graph, Object nextNode, @NullableDecl Object previousNode) {
if (graph.isDirected() || !Objects.equal(previousNode, nextNode)) {
return true;
}
@@ -267,7 +265,7 @@
}
@Override
- Graph<N> delegate() {
+ protected Graph<N> delegate() {
return graph;
}
@@ -329,7 +327,7 @@
}
@Override
- ValueGraph<N, V> delegate() {
+ protected ValueGraph<N, V> delegate() {
return graph;
}
@@ -364,14 +362,14 @@
}
@Override
- @CheckForNull
- public V edgeValueOrDefault(N nodeU, N nodeV, @CheckForNull V defaultValue) {
+ @NullableDecl
+ public V edgeValueOrDefault(N nodeU, N nodeV, @NullableDecl V defaultValue) {
return delegate().edgeValueOrDefault(nodeV, nodeU, defaultValue); // transpose
}
@Override
- @CheckForNull
- public V edgeValueOrDefault(EndpointPair<N> endpoints, @CheckForNull V defaultValue) {
+ @NullableDecl
+ public V edgeValueOrDefault(EndpointPair<N> endpoints, @NullableDecl V defaultValue) {
return delegate().edgeValueOrDefault(transpose(endpoints), defaultValue);
}
}
@@ -384,7 +382,7 @@
}
@Override
- Network<N, E> delegate() {
+ protected Network<N, E> delegate() {
return network;
}
@@ -435,13 +433,11 @@
}
@Override
- @CheckForNull
public E edgeConnectingOrNull(N nodeU, N nodeV) {
return delegate().edgeConnectingOrNull(nodeV, nodeU); // transpose
}
@Override
- @CheckForNull
public E edgeConnectingOrNull(EndpointPair<N> endpoints) {
return delegate().edgeConnectingOrNull(transpose(endpoints));
}
@@ -504,11 +500,8 @@
for (N node : subgraph.nodes()) {
for (N successorNode : graph.successors(node)) {
if (subgraph.nodes().contains(successorNode)) {
- // requireNonNull is safe because the endpoint pair comes from the graph.
subgraph.putEdgeValue(
- node,
- successorNode,
- requireNonNull(graph.edgeValueOrDefault(node, successorNode, null)));
+ node, successorNode, graph.edgeValueOrDefault(node, successorNode, null));
}
}
}
@@ -563,11 +556,8 @@
copy.addNode(node);
}
for (EndpointPair<N> edge : graph.edges()) {
- // requireNonNull is safe because the endpoint pair comes from the graph.
copy.putEdgeValue(
- edge.nodeU(),
- edge.nodeV(),
- requireNonNull(graph.edgeValueOrDefault(edge.nodeU(), edge.nodeV(), null)));
+ edge.nodeU(), edge.nodeV(), graph.edgeValueOrDefault(edge.nodeU(), edge.nodeV(), null));
}
return copy;
}
diff --git a/android/guava/src/com/google/common/graph/ImmutableGraph.java b/android/guava/src/com/google/common/graph/ImmutableGraph.java
index afad211..4027ca8 100644
--- a/android/guava/src/com/google/common/graph/ImmutableGraph.java
+++ b/android/guava/src/com/google/common/graph/ImmutableGraph.java
@@ -45,7 +45,6 @@
*/
@Beta
@Immutable(containerOf = {"N"})
-@ElementTypesAreNonnullByDefault
public class ImmutableGraph<N> extends ForwardingGraph<N> {
@SuppressWarnings("Immutable") // The backing graph must be immutable.
private final BaseGraph<N> backingGraph;
@@ -101,7 +100,7 @@
}
@Override
- BaseGraph<N> delegate() {
+ protected BaseGraph<N> delegate() {
return backingGraph;
}
diff --git a/android/guava/src/com/google/common/graph/ImmutableNetwork.java b/android/guava/src/com/google/common/graph/ImmutableNetwork.java
index cb636aa..b35d722 100644
--- a/android/guava/src/com/google/common/graph/ImmutableNetwork.java
+++ b/android/guava/src/com/google/common/graph/ImmutableNetwork.java
@@ -46,7 +46,6 @@
@Beta
@Immutable(containerOf = {"N", "E"})
@SuppressWarnings("Immutable") // Extends StandardNetwork but uses ImmutableMaps.
-@ElementTypesAreNonnullByDefault
public final class ImmutableNetwork<N, E> extends StandardNetwork<N, E> {
private ImmutableNetwork(Network<N, E> network) {
diff --git a/android/guava/src/com/google/common/graph/ImmutableValueGraph.java b/android/guava/src/com/google/common/graph/ImmutableValueGraph.java
index a1567da..f2e2386 100644
--- a/android/guava/src/com/google/common/graph/ImmutableValueGraph.java
+++ b/android/guava/src/com/google/common/graph/ImmutableValueGraph.java
@@ -17,7 +17,6 @@
package com.google.common.graph;
import static com.google.common.base.Preconditions.checkNotNull;
-import static java.util.Objects.requireNonNull;
import com.google.common.annotations.Beta;
import com.google.common.base.Function;
@@ -44,7 +43,6 @@
@Beta
@Immutable(containerOf = {"N", "V"})
@SuppressWarnings("Immutable") // Extends StandardValueGraph but uses ImmutableMaps.
-@ElementTypesAreNonnullByDefault
public final class ImmutableValueGraph<N, V> extends StandardValueGraph<N, V> {
private ImmutableValueGraph(ValueGraph<N, V> graph) {
@@ -96,8 +94,7 @@
new Function<N, V>() {
@Override
public V apply(N successorNode) {
- // requireNonNull is safe because the endpoint pair comes from the graph.
- return requireNonNull(graph.edgeValueOrDefault(node, successorNode, null));
+ return graph.edgeValueOrDefault(node, successorNode, null);
}
};
return graph.isDirected()
diff --git a/android/guava/src/com/google/common/graph/IncidentEdgeSet.java b/android/guava/src/com/google/common/graph/IncidentEdgeSet.java
index ac94b65..ba91c3b 100644
--- a/android/guava/src/com/google/common/graph/IncidentEdgeSet.java
+++ b/android/guava/src/com/google/common/graph/IncidentEdgeSet.java
@@ -18,16 +18,15 @@
import java.util.AbstractSet;
import java.util.Set;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* Abstract base class for an incident edges set that allows different implementations of {@link
* AbstractSet#iterator()}.
*/
-@ElementTypesAreNonnullByDefault
abstract class IncidentEdgeSet<N> extends AbstractSet<EndpointPair<N>> {
- final N node;
- final BaseGraph<N> graph;
+ protected final N node;
+ protected final BaseGraph<N> graph;
IncidentEdgeSet(BaseGraph<N> graph, N node) {
this.graph = graph;
@@ -35,7 +34,7 @@
}
@Override
- public boolean remove(@CheckForNull Object o) {
+ public boolean remove(Object o) {
throw new UnsupportedOperationException();
}
@@ -51,7 +50,7 @@
}
@Override
- public boolean contains(@CheckForNull Object obj) {
+ public boolean contains(@NullableDecl Object obj) {
if (!(obj instanceof EndpointPair)) {
return false;
}
diff --git a/android/guava/src/com/google/common/graph/MapIteratorCache.java b/android/guava/src/com/google/common/graph/MapIteratorCache.java
index aae9187..e53a7cd 100644
--- a/android/guava/src/com/google/common/graph/MapIteratorCache.java
+++ b/android/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 javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* A map-like data structure that wraps a backing map and caches values while iterating through
@@ -41,7 +41,6 @@
*
* @author James Sexton
*/
-@ElementTypesAreNonnullByDefault
class MapIteratorCache<K, V> {
private final Map<K, V> backingMap;
@@ -54,57 +53,43 @@
* while writing to it in another. All it does is help with _reading_ from multiple threads
* concurrently. For more information, see AbstractNetworkTest.concurrentIteration.
*/
- @CheckForNull private transient volatile Entry<K, V> cacheEntry;
+ @NullableDecl private transient volatile Entry<K, V> cacheEntry;
MapIteratorCache(Map<K, V> backingMap) {
this.backingMap = checkNotNull(backingMap);
}
@CanIgnoreReturnValue
- @CheckForNull
- final V put(K key, V value) {
- checkNotNull(key);
- checkNotNull(value);
+ public final V put(@NullableDecl K key, @NullableDecl V value) {
clearCache();
return backingMap.put(key, value);
}
@CanIgnoreReturnValue
- @CheckForNull
- final V remove(Object key) {
- checkNotNull(key);
+ public final V remove(@NullableDecl Object key) {
clearCache();
return backingMap.remove(key);
}
- final void clear() {
+ public final void clear() {
clearCache();
backingMap.clear();
}
- @CheckForNull
- V get(Object key) {
- checkNotNull(key);
+ public V get(@NullableDecl Object key) {
V value = getIfCached(key);
- // TODO(b/192579700): Use a ternary once it no longer confuses our nullness checker.
- if (value == null) {
- return getWithoutCaching(key);
- } else {
- return value;
- }
+ return (value != null) ? value : getWithoutCaching(key);
}
- @CheckForNull
- final V getWithoutCaching(Object key) {
- checkNotNull(key);
+ public final V getWithoutCaching(@NullableDecl Object key) {
return backingMap.get(key);
}
- final boolean containsKey(@CheckForNull Object key) {
+ public final boolean containsKey(@NullableDecl Object key) {
return getIfCached(key) != null || backingMap.containsKey(key);
}
- final Set<K> unmodifiableKeySet() {
+ public final Set<K> unmodifiableKeySet() {
return new AbstractSet<K>() {
@Override
public UnmodifiableIterator<K> iterator() {
@@ -131,16 +116,15 @@
}
@Override
- public boolean contains(@CheckForNull Object key) {
+ public boolean contains(@NullableDecl Object key) {
return containsKey(key);
}
};
}
- // Internal methods (package-visible, but treat as only subclass-visible)
+ // Internal methods ('protected' is still package-visible, but treat as only subclass-visible)
- @CheckForNull
- V getIfCached(@CheckForNull Object key) {
+ protected V getIfCached(@NullableDecl Object key) {
Entry<K, V> entry = cacheEntry; // store local reference for thread-safety
// Check cache. We use == on purpose because it's cheaper and a cache miss is ok.
@@ -150,7 +134,7 @@
return null;
}
- void clearCache() {
+ protected void clearCache() {
cacheEntry = null;
}
}
diff --git a/android/guava/src/com/google/common/graph/MapRetrievalCache.java b/android/guava/src/com/google/common/graph/MapRetrievalCache.java
index ada78f2..01c45f7 100644
--- a/android/guava/src/com/google/common/graph/MapRetrievalCache.java
+++ b/android/guava/src/com/google/common/graph/MapRetrievalCache.java
@@ -16,10 +16,8 @@
package com.google.common.graph;
-import static com.google.common.base.Preconditions.checkNotNull;
-
import java.util.Map;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* A {@link MapIteratorCache} that adds additional caching. In addition to the caching provided by
@@ -27,11 +25,10 @@
*
* @author James Sexton
*/
-@ElementTypesAreNonnullByDefault
-final class MapRetrievalCache<K, V> extends MapIteratorCache<K, V> {
+class MapRetrievalCache<K, V> extends MapIteratorCache<K, V> {
// See the note about volatile in the superclass.
- @CheckForNull private transient volatile CacheEntry<K, V> cacheEntry1;
- @CheckForNull private transient volatile CacheEntry<K, V> cacheEntry2;
+ @NullableDecl private transient volatile CacheEntry<K, V> cacheEntry1;
+ @NullableDecl private transient volatile CacheEntry<K, V> cacheEntry2;
MapRetrievalCache(Map<K, V> backingMap) {
super(backingMap);
@@ -39,9 +36,7 @@
@SuppressWarnings("unchecked") // Safe because we only cast if key is found in map.
@Override
- @CheckForNull
- V get(Object key) {
- checkNotNull(key);
+ public V get(@NullableDecl Object key) {
V value = getIfCached(key);
if (value != null) {
return value;
@@ -54,11 +49,10 @@
return value;
}
- // Internal methods (package-visible, but treat as only subclass-visible)
+ // Internal methods ('protected' is still package-visible, but treat as only subclass-visible)
@Override
- @CheckForNull
- V getIfCached(@CheckForNull Object key) {
+ protected V getIfCached(@NullableDecl Object key) {
V value = super.getIfCached(key);
if (value != null) {
return value;
@@ -84,7 +78,7 @@
}
@Override
- void clearCache() {
+ protected void clearCache() {
super.clearCache();
cacheEntry1 = null;
cacheEntry2 = null;
diff --git a/android/guava/src/com/google/common/graph/MultiEdgesConnecting.java b/android/guava/src/com/google/common/graph/MultiEdgesConnecting.java
index 8a4250e..916c6dd 100644
--- a/android/guava/src/com/google/common/graph/MultiEdgesConnecting.java
+++ b/android/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 javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* A class to represent the set of edges connecting an (implicit) origin node to a target node.
@@ -35,7 +35,6 @@
* @author James Sexton
* @param <E> Edge parameter type
*/
-@ElementTypesAreNonnullByDefault
abstract class MultiEdgesConnecting<E> extends AbstractSet<E> {
private final Map<E, ?> outEdgeToNode;
@@ -51,7 +50,6 @@
final Iterator<? extends Entry<E, ?>> entries = outEdgeToNode.entrySet().iterator();
return new AbstractIterator<E>() {
@Override
- @CheckForNull
protected E computeNext() {
while (entries.hasNext()) {
Entry<E, ?> entry = entries.next();
@@ -65,7 +63,7 @@
}
@Override
- public boolean contains(@CheckForNull Object edge) {
+ public boolean contains(@NullableDecl Object edge) {
return targetNode.equals(outEdgeToNode.get(edge));
}
}
diff --git a/android/guava/src/com/google/common/graph/MutableGraph.java b/android/guava/src/com/google/common/graph/MutableGraph.java
index b1f3359..8324079 100644
--- a/android/guava/src/com/google/common/graph/MutableGraph.java
+++ b/android/guava/src/com/google/common/graph/MutableGraph.java
@@ -29,7 +29,6 @@
* @since 20.0
*/
@Beta
-@ElementTypesAreNonnullByDefault
public interface MutableGraph<N> extends Graph<N> {
/**
diff --git a/android/guava/src/com/google/common/graph/MutableNetwork.java b/android/guava/src/com/google/common/graph/MutableNetwork.java
index 64acb13..d702903 100644
--- a/android/guava/src/com/google/common/graph/MutableNetwork.java
+++ b/android/guava/src/com/google/common/graph/MutableNetwork.java
@@ -30,7 +30,6 @@
* @since 20.0
*/
@Beta
-@ElementTypesAreNonnullByDefault
public interface MutableNetwork<N, E> extends Network<N, E> {
/**
diff --git a/android/guava/src/com/google/common/graph/MutableValueGraph.java b/android/guava/src/com/google/common/graph/MutableValueGraph.java
index f32d2ee..70b286d 100644
--- a/android/guava/src/com/google/common/graph/MutableValueGraph.java
+++ b/android/guava/src/com/google/common/graph/MutableValueGraph.java
@@ -18,7 +18,6 @@
import com.google.common.annotations.Beta;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
-import javax.annotation.CheckForNull;
/**
* A subinterface of {@link ValueGraph} which adds mutation methods. When mutation is not required,
@@ -30,7 +29,6 @@
* @since 20.0
*/
@Beta
-@ElementTypesAreNonnullByDefault
public interface MutableValueGraph<N, V> extends ValueGraph<N, V> {
/**
@@ -61,7 +59,6 @@
* #allowsSelfLoops()}
*/
@CanIgnoreReturnValue
- @CheckForNull
V putEdgeValue(N nodeU, N nodeV, V value);
/**
@@ -86,7 +83,6 @@
* @since 27.1
*/
@CanIgnoreReturnValue
- @CheckForNull
V putEdgeValue(EndpointPair<N> endpoints, V value);
/**
@@ -104,7 +100,6 @@
* nodeV}, or null if there was no such edge.
*/
@CanIgnoreReturnValue
- @CheckForNull
V removeEdge(N nodeU, N nodeV);
/**
@@ -117,6 +112,5 @@
* @since 27.1
*/
@CanIgnoreReturnValue
- @CheckForNull
V removeEdge(EndpointPair<N> endpoints);
}
diff --git a/android/guava/src/com/google/common/graph/Network.java b/android/guava/src/com/google/common/graph/Network.java
index 70e39cd..a7c9086 100644
--- a/android/guava/src/com/google/common/graph/Network.java
+++ b/android/guava/src/com/google/common/graph/Network.java
@@ -19,7 +19,7 @@
import com.google.common.annotations.Beta;
import com.google.errorprone.annotations.DoNotMock;
import java.util.Set;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* An interface for <a
@@ -103,7 +103,6 @@
*/
@Beta
@DoNotMock("Use NetworkBuilder to create a real instance")
-@ElementTypesAreNonnullByDefault
public interface Network<N, E> extends SuccessorsFunction<N>, PredecessorsFunction<N> {
//
// Network-level accessors
@@ -319,7 +318,7 @@
* network
* @since 23.0
*/
- @CheckForNull
+ @NullableDecl
E edgeConnectingOrNull(N nodeU, N nodeV);
/**
@@ -334,7 +333,7 @@
* @throws IllegalArgumentException if the endpoints are unordered and the graph is directed
* @since 27.1
*/
- @CheckForNull
+ @NullableDecl
E edgeConnectingOrNull(EndpointPair<N> endpoints);
/**
@@ -386,7 +385,7 @@
* <p>A reference implementation of this is provided by {@link AbstractNetwork#equals(Object)}.
*/
@Override
- boolean equals(@CheckForNull Object object);
+ boolean equals(@NullableDecl Object object);
/**
* Returns the hash code for this network. The hash code of a network is defined as the hash code
diff --git a/android/guava/src/com/google/common/graph/NetworkBuilder.java b/android/guava/src/com/google/common/graph/NetworkBuilder.java
index 9689444..d289ee2 100644
--- a/android/guava/src/com/google/common/graph/NetworkBuilder.java
+++ b/android/guava/src/com/google/common/graph/NetworkBuilder.java
@@ -67,7 +67,6 @@
* @since 20.0
*/
@Beta
-@ElementTypesAreNonnullByDefault
public final class NetworkBuilder<N, E> extends AbstractGraphBuilder<N> {
boolean allowsParallelEdges = false;
ElementOrder<? super E> edgeOrder = ElementOrder.insertion();
diff --git a/android/guava/src/com/google/common/graph/NetworkConnections.java b/android/guava/src/com/google/common/graph/NetworkConnections.java
index 94d1780..16a68d6 100644
--- a/android/guava/src/com/google/common/graph/NetworkConnections.java
+++ b/android/guava/src/com/google/common/graph/NetworkConnections.java
@@ -18,7 +18,6 @@
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import java.util.Set;
-import javax.annotation.CheckForNull;
/**
* An interface for representing and manipulating an origin node's adjacent nodes and incident edges
@@ -28,7 +27,6 @@
* @param <N> Node parameter type
* @param <E> Edge parameter type
*/
-@ElementTypesAreNonnullByDefault
interface NetworkConnections<N, E> {
Set<N> adjacentNodes();
@@ -62,7 +60,6 @@
* <p>In the undirected case, returns {@code null} if {@code isSelfLoop} is true.
*/
@CanIgnoreReturnValue
- @CheckForNull
N removeInEdge(E edge, boolean isSelfLoop);
/** Remove {@code edge} from the set of outgoing edges. Returns the former successor node. */
diff --git a/android/guava/src/com/google/common/graph/ParametricNullness.java b/android/guava/src/com/google/common/graph/ParametricNullness.java
deleted file mode 100644
index 62534eb..0000000
--- a/android/guava/src/com/google/common/graph/ParametricNullness.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2021 The Guava Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.common.graph;
-
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.PARAMETER;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-import static javax.annotation.meta.When.UNKNOWN;
-
-import com.google.common.annotations.GwtCompatible;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-import javax.annotation.Nonnull;
-import javax.annotation.meta.TypeQualifierNickname;
-
-/**
- * Marks a "top-level" type-variable usage as (a) a Kotlin platform type when the type argument is
- * non-nullable and (b) nullable when the type argument is nullable. This is the closest we can get
- * to "non-nullable when non-nullable; nullable when nullable" (like the Android <a
- * href="https://android.googlesource.com/platform/libcore/+/master/luni/src/main/java/libcore/util/NullFromTypeParam.java">{@code
- * NullFromTypeParam}</a>). We use this to "undo" {@link ElementTypesAreNonnullByDefault}.
- */
-@GwtCompatible
-@Retention(RUNTIME)
-@Target({FIELD, METHOD, PARAMETER})
-@TypeQualifierNickname
-@Nonnull(when = UNKNOWN)
-@interface ParametricNullness {}
diff --git a/android/guava/src/com/google/common/graph/PredecessorsFunction.java b/android/guava/src/com/google/common/graph/PredecessorsFunction.java
index 750a8ac..f9ca48a 100644
--- a/android/guava/src/com/google/common/graph/PredecessorsFunction.java
+++ b/android/guava/src/com/google/common/graph/PredecessorsFunction.java
@@ -80,7 +80,6 @@
*/
@Beta
@DoNotMock("Implement with a lambda, or use GraphBuilder to build a Graph with the desired edges")
-@ElementTypesAreNonnullByDefault
public interface PredecessorsFunction<N> {
/**
diff --git a/android/guava/src/com/google/common/graph/StandardMutableGraph.java b/android/guava/src/com/google/common/graph/StandardMutableGraph.java
index 1be9640..41acccf 100644
--- a/android/guava/src/com/google/common/graph/StandardMutableGraph.java
+++ b/android/guava/src/com/google/common/graph/StandardMutableGraph.java
@@ -28,7 +28,6 @@
* @author James Sexton
* @param <N> Node parameter type
*/
-@ElementTypesAreNonnullByDefault
final class StandardMutableGraph<N> extends ForwardingGraph<N> implements MutableGraph<N> {
private final MutableValueGraph<N, Presence> backingValueGraph;
@@ -38,7 +37,7 @@
}
@Override
- BaseGraph<N> delegate() {
+ protected BaseGraph<N> delegate() {
return backingValueGraph;
}
diff --git a/android/guava/src/com/google/common/graph/StandardMutableNetwork.java b/android/guava/src/com/google/common/graph/StandardMutableNetwork.java
index c58b6d3..8cfe9c5 100644
--- a/android/guava/src/com/google/common/graph/StandardMutableNetwork.java
+++ b/android/guava/src/com/google/common/graph/StandardMutableNetwork.java
@@ -22,7 +22,6 @@
import static com.google.common.graph.GraphConstants.PARALLEL_EDGES_NOT_ALLOWED;
import static com.google.common.graph.GraphConstants.REUSING_EDGE;
import static com.google.common.graph.GraphConstants.SELF_LOOPS_NOT_ALLOWED;
-import static java.util.Objects.requireNonNull;
import com.google.common.collect.ImmutableList;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
@@ -40,7 +39,6 @@
* @param <N> Node parameter type
* @param <E> Edge parameter type
*/
-@ElementTypesAreNonnullByDefault
final class StandardMutableNetwork<N, E> extends StandardNetwork<N, E>
implements MutableNetwork<N, E> {
@@ -154,10 +152,9 @@
return false;
}
- // requireNonNull is safe because of the edgeToReferenceNode check above.
- NetworkConnections<N, E> connectionsU = requireNonNull(nodeConnections.get(nodeU));
+ NetworkConnections<N, E> connectionsU = nodeConnections.get(nodeU);
N nodeV = connectionsU.adjacentNode(edge);
- NetworkConnections<N, E> connectionsV = requireNonNull(nodeConnections.get(nodeV));
+ NetworkConnections<N, E> connectionsV = nodeConnections.get(nodeV);
connectionsU.removeOutEdge(edge);
connectionsV.removeInEdge(edge, allowsSelfLoops() && nodeU.equals(nodeV));
edgeToReferenceNode.remove(edge);
diff --git a/android/guava/src/com/google/common/graph/StandardMutableValueGraph.java b/android/guava/src/com/google/common/graph/StandardMutableValueGraph.java
index 0ea641a..558d8d6 100644
--- a/android/guava/src/com/google/common/graph/StandardMutableValueGraph.java
+++ b/android/guava/src/com/google/common/graph/StandardMutableValueGraph.java
@@ -22,10 +22,8 @@
import static com.google.common.graph.GraphConstants.SELF_LOOPS_NOT_ALLOWED;
import static com.google.common.graph.Graphs.checkNonNegative;
import static com.google.common.graph.Graphs.checkPositive;
-import static java.util.Objects.requireNonNull;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
-import javax.annotation.CheckForNull;
/**
* Standard implementation of {@link MutableValueGraph} that supports both directed and undirected
@@ -40,7 +38,6 @@
* @param <N> Node parameter type
* @param <V> Value parameter type
*/
-@ElementTypesAreNonnullByDefault
final class StandardMutableValueGraph<N, V> extends StandardValueGraph<N, V>
implements MutableValueGraph<N, V> {
@@ -84,7 +81,6 @@
@Override
@CanIgnoreReturnValue
- @CheckForNull
public V putEdgeValue(N nodeU, N nodeV, V value) {
checkNotNull(nodeU, "nodeU");
checkNotNull(nodeV, "nodeV");
@@ -112,7 +108,6 @@
@Override
@CanIgnoreReturnValue
- @CheckForNull
public V putEdgeValue(EndpointPair<N> endpoints, V value) {
validateEndpoints(endpoints);
return putEdgeValue(endpoints.nodeU(), endpoints.nodeV(), value);
@@ -137,16 +132,12 @@
}
for (N successor : connections.successors()) {
- // requireNonNull is safe because the node is a successor.
- requireNonNull(nodeConnections.getWithoutCaching(successor)).removePredecessor(node);
+ nodeConnections.getWithoutCaching(successor).removePredecessor(node);
--edgeCount;
}
if (isDirected()) { // In undirected graphs, the successor and predecessor sets are equal.
for (N predecessor : connections.predecessors()) {
- // requireNonNull is safe because the node is a predecessor.
- checkState(
- requireNonNull(nodeConnections.getWithoutCaching(predecessor)).removeSuccessor(node)
- != null);
+ checkState(nodeConnections.getWithoutCaching(predecessor).removeSuccessor(node) != null);
--edgeCount;
}
}
@@ -157,7 +148,6 @@
@Override
@CanIgnoreReturnValue
- @CheckForNull
public V removeEdge(N nodeU, N nodeV) {
checkNotNull(nodeU, "nodeU");
checkNotNull(nodeV, "nodeV");
@@ -178,7 +168,6 @@
@Override
@CanIgnoreReturnValue
- @CheckForNull
public V removeEdge(EndpointPair<N> endpoints) {
validateEndpoints(endpoints);
return removeEdge(endpoints.nodeU(), endpoints.nodeV());
diff --git a/android/guava/src/com/google/common/graph/StandardNetwork.java b/android/guava/src/com/google/common/graph/StandardNetwork.java
index 2aa103f..0fc292b 100644
--- a/android/guava/src/com/google/common/graph/StandardNetwork.java
+++ b/android/guava/src/com/google/common/graph/StandardNetwork.java
@@ -22,12 +22,12 @@
import static com.google.common.graph.GraphConstants.DEFAULT_NODE_COUNT;
import static com.google.common.graph.GraphConstants.EDGE_NOT_IN_GRAPH;
import static com.google.common.graph.GraphConstants.NODE_NOT_IN_GRAPH;
-import static java.util.Objects.requireNonNull;
import com.google.common.collect.ImmutableSet;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* Standard implementation of {@link Network} that supports the options supplied by {@link
@@ -48,7 +48,6 @@
* @param <N> Node parameter type
* @param <E> Edge parameter type
*/
-@ElementTypesAreNonnullByDefault
class StandardNetwork<N, E> extends AbstractNetwork<N, E> {
private final boolean isDirected;
private final boolean allowsParallelEdges;
@@ -56,11 +55,11 @@
private final ElementOrder<N> nodeOrder;
private final ElementOrder<E> edgeOrder;
- final MapIteratorCache<N, NetworkConnections<N, E>> nodeConnections;
+ protected final MapIteratorCache<N, NetworkConnections<N, E>> nodeConnections;
// We could make this a Map<E, EndpointPair<N>>. It would make incidentNodes(edge) slightly
// faster, but also make Networks consume 5 to 20+% (increasing with average degree) more memory.
- final MapIteratorCache<E, N> edgeToReferenceNode; // referenceNode == source if directed
+ protected final MapIteratorCache<E, N> edgeToReferenceNode; // referenceNode == source if directed
/** Constructs a graph with the properties specified in {@code builder}. */
StandardNetwork(NetworkBuilder<? super N, ? super E> builder) {
@@ -136,8 +135,7 @@
@Override
public EndpointPair<N> incidentNodes(E edge) {
N nodeU = checkedReferenceNode(edge);
- // requireNonNull is safe because checkedReferenceNode made sure the edge is in the network.
- N nodeV = requireNonNull(nodeConnections.get(nodeU)).adjacentNode(edge);
+ N nodeV = nodeConnections.get(nodeU).adjacentNode(edge);
return EndpointPair.of(this, nodeU, nodeV);
}
@@ -176,7 +174,7 @@
return checkedConnections(node).successors();
}
- final NetworkConnections<N, E> checkedConnections(N node) {
+ protected final NetworkConnections<N, E> checkedConnections(N node) {
NetworkConnections<N, E> connections = nodeConnections.get(node);
if (connections == null) {
checkNotNull(node);
@@ -185,7 +183,7 @@
return connections;
}
- final N checkedReferenceNode(E edge) {
+ protected final N checkedReferenceNode(E edge) {
N referenceNode = edgeToReferenceNode.get(edge);
if (referenceNode == null) {
checkNotNull(edge);
@@ -194,11 +192,11 @@
return referenceNode;
}
- final boolean containsNode(N node) {
+ protected final boolean containsNode(@NullableDecl N node) {
return nodeConnections.containsKey(node);
}
- final boolean containsEdge(E edge) {
+ protected final boolean containsEdge(@NullableDecl E edge) {
return edgeToReferenceNode.containsKey(edge);
}
}
diff --git a/android/guava/src/com/google/common/graph/StandardValueGraph.java b/android/guava/src/com/google/common/graph/StandardValueGraph.java
index f2c71bc..4eed0be 100644
--- a/android/guava/src/com/google/common/graph/StandardValueGraph.java
+++ b/android/guava/src/com/google/common/graph/StandardValueGraph.java
@@ -24,7 +24,7 @@
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* Standard implementation of {@link ValueGraph} that supports the options supplied by {@link
@@ -43,15 +43,14 @@
* @param <N> Node parameter type
* @param <V> Value parameter type
*/
-@ElementTypesAreNonnullByDefault
class StandardValueGraph<N, V> extends AbstractValueGraph<N, V> {
private final boolean isDirected;
private final boolean allowsSelfLoops;
private final ElementOrder<N> nodeOrder;
- final MapIteratorCache<N, GraphConnections<N, V>> nodeConnections;
+ protected final MapIteratorCache<N, GraphConnections<N, V>> nodeConnections;
- long edgeCount; // must be updated when edges are added or removed
+ protected long edgeCount; // must be updated when edges are added or removed
/** Constructs a graph with the properties specified in {@code builder}. */
StandardValueGraph(AbstractGraphBuilder<? super N> builder) {
@@ -130,27 +129,27 @@
@Override
public boolean hasEdgeConnecting(N nodeU, N nodeV) {
- return hasEdgeConnectingInternal(checkNotNull(nodeU), checkNotNull(nodeV));
+ return hasEdgeConnecting_internal(checkNotNull(nodeU), checkNotNull(nodeV));
}
@Override
public boolean hasEdgeConnecting(EndpointPair<N> endpoints) {
checkNotNull(endpoints);
return isOrderingCompatible(endpoints)
- && hasEdgeConnectingInternal(endpoints.nodeU(), endpoints.nodeV());
+ && hasEdgeConnecting_internal(endpoints.nodeU(), endpoints.nodeV());
}
@Override
- @CheckForNull
- public V edgeValueOrDefault(N nodeU, N nodeV, @CheckForNull V defaultValue) {
- return edgeValueOrDefaultInternal(checkNotNull(nodeU), checkNotNull(nodeV), defaultValue);
+ @NullableDecl
+ public V edgeValueOrDefault(N nodeU, N nodeV, @NullableDecl V defaultValue) {
+ return edgeValueOrDefault_internal(checkNotNull(nodeU), checkNotNull(nodeV), defaultValue);
}
@Override
- @CheckForNull
- public V edgeValueOrDefault(EndpointPair<N> endpoints, @CheckForNull V defaultValue) {
+ @NullableDecl
+ public V edgeValueOrDefault(EndpointPair<N> endpoints, @NullableDecl V defaultValue) {
validateEndpoints(endpoints);
- return edgeValueOrDefaultInternal(endpoints.nodeU(), endpoints.nodeV(), defaultValue);
+ return edgeValueOrDefault_internal(endpoints.nodeU(), endpoints.nodeV(), defaultValue);
}
@Override
@@ -158,7 +157,7 @@
return edgeCount;
}
- private final GraphConnections<N, V> checkedConnections(N node) {
+ protected final GraphConnections<N, V> checkedConnections(N node) {
GraphConnections<N, V> connections = nodeConnections.get(node);
if (connections == null) {
checkNotNull(node);
@@ -167,24 +166,18 @@
return connections;
}
- final boolean containsNode(@CheckForNull N node) {
+ protected final boolean containsNode(@NullableDecl N node) {
return nodeConnections.containsKey(node);
}
- private final boolean hasEdgeConnectingInternal(N nodeU, N nodeV) {
+ protected final boolean hasEdgeConnecting_internal(N nodeU, N nodeV) {
GraphConnections<N, V> connectionsU = nodeConnections.get(nodeU);
return (connectionsU != null) && connectionsU.successors().contains(nodeV);
}
- @CheckForNull
- private final V edgeValueOrDefaultInternal(N nodeU, N nodeV, @CheckForNull V defaultValue) {
+ protected final V edgeValueOrDefault_internal(N nodeU, N nodeV, V defaultValue) {
GraphConnections<N, V> connectionsU = nodeConnections.get(nodeU);
V value = (connectionsU == null) ? null : connectionsU.value(nodeV);
- // TODO(b/192579700): Use a ternary once it no longer confuses our nullness checker.
- if (value == null) {
- return defaultValue;
- } else {
- return value;
- }
+ return value == null ? defaultValue : value;
}
}
diff --git a/android/guava/src/com/google/common/graph/SuccessorsFunction.java b/android/guava/src/com/google/common/graph/SuccessorsFunction.java
index c29bb4b..f74f437 100644
--- a/android/guava/src/com/google/common/graph/SuccessorsFunction.java
+++ b/android/guava/src/com/google/common/graph/SuccessorsFunction.java
@@ -80,7 +80,6 @@
*/
@Beta
@DoNotMock("Implement with a lambda, or use GraphBuilder to build a Graph with the desired edges")
-@ElementTypesAreNonnullByDefault
public interface SuccessorsFunction<N> {
/**
diff --git a/android/guava/src/com/google/common/graph/Traverser.java b/android/guava/src/com/google/common/graph/Traverser.java
index 5a36f9f..0d8e6f9 100644
--- a/android/guava/src/com/google/common/graph/Traverser.java
+++ b/android/guava/src/com/google/common/graph/Traverser.java
@@ -18,7 +18,6 @@
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
-import static java.util.Objects.requireNonNull;
import com.google.common.annotations.Beta;
import com.google.common.collect.AbstractIterator;
@@ -29,7 +28,7 @@
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* An object that can traverse the nodes that are reachable from a specified (set of) start node(s)
@@ -64,7 +63,6 @@
@DoNotMock(
"Call forGraph or forTree, passing a lambda or a Graph with the desired edges (built with"
+ " GraphBuilder)")
-@ElementTypesAreNonnullByDefault
public abstract class Traverser<N> {
private final SuccessorsFunction<N> successorFunction;
@@ -385,20 +383,10 @@
final Set<N> visited = new HashSet<>();
return new Traversal<N>(graph) {
@Override
- @CheckForNull
N visitNext(Deque<Iterator<? extends N>> horizon) {
Iterator<? extends N> top = horizon.getFirst();
while (top.hasNext()) {
- N element = top.next();
- // requireNonNull is safe because horizon contains only graph nodes.
- /*
- * TODO(cpovirk): Replace these two statements with one (`N element =
- * requireNonNull(top.next())`) once our checker supports it.
- *
- * (The problem is likely
- * https://github.com/jspecify/nullness-checker-for-checker-framework/blob/61aafa4ae52594830cfc2d61c8b113009dbdb045/src/main/java/com/google/jspecify/nullness/NullSpecAnnotatedTypeFactory.java#L896)
- */
- requireNonNull(element);
+ N element = checkNotNull(top.next());
if (visited.add(element)) {
return element;
}
@@ -411,7 +399,6 @@
static <N> Traversal<N> inTree(SuccessorsFunction<N> tree) {
return new Traversal<N>(tree) {
- @CheckForNull
@Override
N visitNext(Deque<Iterator<? extends N>> horizon) {
Iterator<? extends N> top = horizon.getFirst();
@@ -443,7 +430,6 @@
horizon.add(startNodes);
return new AbstractIterator<N>() {
@Override
- @CheckForNull
protected N computeNext() {
do {
N next = visitNext(horizon);
@@ -468,7 +454,6 @@
horizon.add(startNodes);
return new AbstractIterator<N>() {
@Override
- @CheckForNull
protected N computeNext() {
for (N next = visitNext(horizon); next != null; next = visitNext(horizon)) {
Iterator<? extends N> successors = successorFunction.successors(next).iterator();
@@ -478,11 +463,7 @@
horizon.addFirst(successors);
ancestorStack.push(next);
}
- // TODO(b/192579700): Use a ternary once it no longer confuses our nullness checker.
- if (!ancestorStack.isEmpty()) {
- return ancestorStack.pop();
- }
- return endOfData();
+ return ancestorStack.isEmpty() ? endOfData() : ancestorStack.pop();
}
};
}
@@ -497,7 +478,7 @@
* into {@code horizon} between calls to {@code visitNext()}. This causes them to receive
* additional values interleaved with those shown above.)
*/
- @CheckForNull
+ @NullableDecl
abstract N visitNext(Deque<Iterator<? extends N>> horizon);
}
diff --git a/android/guava/src/com/google/common/graph/UndirectedGraphConnections.java b/android/guava/src/com/google/common/graph/UndirectedGraphConnections.java
index 085e3a7..49689f9 100644
--- a/android/guava/src/com/google/common/graph/UndirectedGraphConnections.java
+++ b/android/guava/src/com/google/common/graph/UndirectedGraphConnections.java
@@ -29,7 +29,6 @@
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;
-import javax.annotation.CheckForNull;
/**
* An implementation of {@link GraphConnections} for undirected graphs.
@@ -38,7 +37,6 @@
* @param <N> Node parameter type
* @param <V> Value parameter type
*/
-@ElementTypesAreNonnullByDefault
final class UndirectedGraphConnections<N, V> implements GraphConnections<N, V> {
private final Map<N, V> adjacentNodeValues;
@@ -91,7 +89,6 @@
}
@Override
- @CheckForNull
public V value(N node) {
return adjacentNodeValues.get(node);
}
@@ -103,7 +100,6 @@
}
@Override
- @CheckForNull
public V removeSuccessor(N node) {
return adjacentNodeValues.remove(node);
}
@@ -115,7 +111,6 @@
}
@Override
- @CheckForNull
public V addSuccessor(N node, V value) {
return adjacentNodeValues.put(node, value);
}
diff --git a/android/guava/src/com/google/common/graph/UndirectedMultiNetworkConnections.java b/android/guava/src/com/google/common/graph/UndirectedMultiNetworkConnections.java
index a5c45ca..a391379 100644
--- a/android/guava/src/com/google/common/graph/UndirectedMultiNetworkConnections.java
+++ b/android/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 javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* An implementation of {@link NetworkConnections} for undirected networks with parallel edges.
@@ -39,7 +39,6 @@
* @param <N> Node parameter type
* @param <E> Edge parameter type
*/
-@ElementTypesAreNonnullByDefault
final class UndirectedMultiNetworkConnections<N, E>
extends AbstractUndirectedNetworkConnections<N, E> {
@@ -56,7 +55,7 @@
return new UndirectedMultiNetworkConnections<>(ImmutableMap.copyOf(incidentEdges));
}
- @CheckForNull @LazyInit private transient Reference<Multiset<N>> adjacentNodesReference;
+ @LazyInit private transient Reference<Multiset<N>> adjacentNodesReference;
@Override
public Set<N> adjacentNodes() {
@@ -83,7 +82,6 @@
}
@Override
- @CheckForNull
public N removeInEdge(E edge, boolean isSelfLoop) {
if (!isSelfLoop) {
return removeOutEdge(edge);
@@ -117,8 +115,8 @@
}
}
- @CheckForNull
- private static <T> T getReference(@CheckForNull Reference<T> reference) {
+ @NullableDecl
+ private static <T> T getReference(@NullableDecl Reference<T> reference) {
return (reference == null) ? null : reference.get();
}
}
diff --git a/android/guava/src/com/google/common/graph/UndirectedNetworkConnections.java b/android/guava/src/com/google/common/graph/UndirectedNetworkConnections.java
index 38cb763..1e253dd 100644
--- a/android/guava/src/com/google/common/graph/UndirectedNetworkConnections.java
+++ b/android/guava/src/com/google/common/graph/UndirectedNetworkConnections.java
@@ -32,10 +32,9 @@
* @param <N> Node parameter type
* @param <E> Edge parameter type
*/
-@ElementTypesAreNonnullByDefault
final class UndirectedNetworkConnections<N, E> extends AbstractUndirectedNetworkConnections<N, E> {
- UndirectedNetworkConnections(Map<E, N> incidentEdgeMap) {
+ protected UndirectedNetworkConnections(Map<E, N> incidentEdgeMap) {
super(incidentEdgeMap);
}
diff --git a/android/guava/src/com/google/common/graph/ValueGraph.java b/android/guava/src/com/google/common/graph/ValueGraph.java
index bd3cf36..b7dd61c 100644
--- a/android/guava/src/com/google/common/graph/ValueGraph.java
+++ b/android/guava/src/com/google/common/graph/ValueGraph.java
@@ -19,7 +19,7 @@
import com.google.common.annotations.Beta;
import java.util.Collection;
import java.util.Set;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* An interface for <a
@@ -107,7 +107,6 @@
* @since 20.0
*/
@Beta
-@ElementTypesAreNonnullByDefault
public interface ValueGraph<N, V> extends BaseGraph<N> {
//
// ValueGraph-level accessors
@@ -286,8 +285,8 @@
* @throws IllegalArgumentException if {@code nodeU} or {@code nodeV} is not an element of this
* graph
*/
- @CheckForNull
- V edgeValueOrDefault(N nodeU, N nodeV, @CheckForNull V defaultValue);
+ @NullableDecl
+ V edgeValueOrDefault(N nodeU, N nodeV, @NullableDecl V defaultValue);
/**
* Returns the value of the edge that connects {@code endpoints} (in the order, if any, specified
@@ -299,8 +298,8 @@
* @throws IllegalArgumentException if the endpoints are unordered and the graph is directed
* @since 27.1
*/
- @CheckForNull
- V edgeValueOrDefault(EndpointPair<N> endpoints, @CheckForNull V defaultValue);
+ @NullableDecl
+ V edgeValueOrDefault(EndpointPair<N> endpoints, @NullableDecl V defaultValue);
//
// ValueGraph identity
@@ -327,7 +326,7 @@
* <p>A reference implementation of this is provided by {@link AbstractValueGraph#equals(Object)}.
*/
@Override
- boolean equals(@CheckForNull Object object);
+ boolean equals(@NullableDecl 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/android/guava/src/com/google/common/graph/ValueGraphBuilder.java b/android/guava/src/com/google/common/graph/ValueGraphBuilder.java
index ce146c3..4fc752d 100644
--- a/android/guava/src/com/google/common/graph/ValueGraphBuilder.java
+++ b/android/guava/src/com/google/common/graph/ValueGraphBuilder.java
@@ -66,7 +66,6 @@
* @since 20.0
*/
@Beta
-@ElementTypesAreNonnullByDefault
public final class ValueGraphBuilder<N, V> extends AbstractGraphBuilder<N> {
/** Creates a new instance with the specified edge directionality. */
diff --git a/android/guava/src/com/google/common/hash/AbstractByteHasher.java b/android/guava/src/com/google/common/hash/AbstractByteHasher.java
index 9f7e041..48d48c4 100644
--- a/android/guava/src/com/google/common/hash/AbstractByteHasher.java
+++ b/android/guava/src/com/google/common/hash/AbstractByteHasher.java
@@ -32,7 +32,6 @@
* @author Colin Decker
*/
@CanIgnoreReturnValue
-@ElementTypesAreNonnullByDefault
abstract class AbstractByteHasher extends AbstractHasher {
private final ByteBuffer scratch = ByteBuffer.allocate(8).order(ByteOrder.LITTLE_ENDIAN);
diff --git a/android/guava/src/com/google/common/hash/AbstractCompositeHashFunction.java b/android/guava/src/com/google/common/hash/AbstractCompositeHashFunction.java
index 4b69bb7..048e6c2 100644
--- a/android/guava/src/com/google/common/hash/AbstractCompositeHashFunction.java
+++ b/android/guava/src/com/google/common/hash/AbstractCompositeHashFunction.java
@@ -20,7 +20,6 @@
import com.google.errorprone.annotations.Immutable;
import java.nio.ByteBuffer;
import java.nio.charset.Charset;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* An abstract composition of multiple hash functions. {@linkplain #newHasher()} delegates to the
@@ -30,7 +29,6 @@
* @author Dimitris Andreou
*/
@Immutable
-@ElementTypesAreNonnullByDefault
abstract class AbstractCompositeHashFunction extends AbstractHashFunction {
@SuppressWarnings("Immutable") // array not modified after creation
@@ -179,8 +177,7 @@
}
@Override
- public <T extends @Nullable Object> Hasher putObject(
- @ParametricNullness T instance, Funnel<? super T> funnel) {
+ public <T> Hasher putObject(T instance, Funnel<? super T> funnel) {
for (Hasher hasher : hashers) {
hasher.putObject(instance, funnel);
}
diff --git a/android/guava/src/com/google/common/hash/AbstractHashFunction.java b/android/guava/src/com/google/common/hash/AbstractHashFunction.java
index 7308556..6184189 100644
--- a/android/guava/src/com/google/common/hash/AbstractHashFunction.java
+++ b/android/guava/src/com/google/common/hash/AbstractHashFunction.java
@@ -20,7 +20,6 @@
import com.google.errorprone.annotations.Immutable;
import java.nio.ByteBuffer;
import java.nio.charset.Charset;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Skeleton implementation of {@link HashFunction} in terms of {@link #newHasher()}.
@@ -28,11 +27,9 @@
* <p>TODO(lowasser): make public
*/
@Immutable
-@ElementTypesAreNonnullByDefault
abstract class AbstractHashFunction implements HashFunction {
@Override
- public <T extends @Nullable Object> HashCode hashObject(
- @ParametricNullness T instance, Funnel<? super T> funnel) {
+ public <T> HashCode hashObject(T instance, Funnel<? super T> funnel) {
return newHasher().putObject(instance, funnel).hash();
}
diff --git a/android/guava/src/com/google/common/hash/AbstractHasher.java b/android/guava/src/com/google/common/hash/AbstractHasher.java
index c72e05b..326aa8d 100644
--- a/android/guava/src/com/google/common/hash/AbstractHasher.java
+++ b/android/guava/src/com/google/common/hash/AbstractHasher.java
@@ -18,7 +18,6 @@
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import java.nio.ByteBuffer;
import java.nio.charset.Charset;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* An abstract implementation of {@link Hasher}, which only requires subtypes to implement {@link
@@ -27,7 +26,6 @@
* @author Dimitris Andreou
*/
@CanIgnoreReturnValue
-@ElementTypesAreNonnullByDefault
abstract class AbstractHasher implements Hasher {
@Override
public final Hasher putBoolean(boolean b) {
@@ -116,8 +114,7 @@
}
@Override
- public <T extends @Nullable Object> Hasher putObject(
- @ParametricNullness T instance, Funnel<? super T> funnel) {
+ public <T> Hasher putObject(T instance, Funnel<? super T> funnel) {
funnel.funnel(instance, this);
return this;
}
diff --git a/android/guava/src/com/google/common/hash/AbstractNonStreamingHashFunction.java b/android/guava/src/com/google/common/hash/AbstractNonStreamingHashFunction.java
index 4969e35..54c76de 100644
--- a/android/guava/src/com/google/common/hash/AbstractNonStreamingHashFunction.java
+++ b/android/guava/src/com/google/common/hash/AbstractNonStreamingHashFunction.java
@@ -30,7 +30,6 @@
* @author Dimitris Andreou
*/
@Immutable
-@ElementTypesAreNonnullByDefault
abstract class AbstractNonStreamingHashFunction extends AbstractHashFunction {
@Override
public Hasher newHasher() {
diff --git a/android/guava/src/com/google/common/hash/AbstractStreamingHasher.java b/android/guava/src/com/google/common/hash/AbstractStreamingHasher.java
index a987b48..67de74b 100644
--- a/android/guava/src/com/google/common/hash/AbstractStreamingHasher.java
+++ b/android/guava/src/com/google/common/hash/AbstractStreamingHasher.java
@@ -29,7 +29,6 @@
*/
// TODO(kevinb): this class still needs some design-and-document-for-inheritance love
@CanIgnoreReturnValue
-@ElementTypesAreNonnullByDefault
abstract class AbstractStreamingHasher extends AbstractHasher {
/** Buffer via which we pass data to the hash algorithm (the implementor) */
private final ByteBuffer buffer;
diff --git a/android/guava/src/com/google/common/hash/BloomFilter.java b/android/guava/src/com/google/common/hash/BloomFilter.java
index 6ffe583..27187f7 100644
--- a/android/guava/src/com/google/common/hash/BloomFilter.java
+++ b/android/guava/src/com/google/common/hash/BloomFilter.java
@@ -33,8 +33,7 @@
import java.io.OutputStream;
import java.io.Serializable;
import java.math.RoundingMode;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* A Bloom filter for instances of {@code T}. A Bloom filter offers an approximate containment test
@@ -42,7 +41,7 @@
* but if it claims that an element is <i>not</i> contained in it, then this is definitely true.
*
* <p>If you are unfamiliar with Bloom filters, this nice <a
- * href="http://llimllib.github.io/bloomfilter-tutorial/">tutorial</a> may help you understand how
+ * href="http://llimllib.github.com/bloomfilter-tutorial/">tutorial</a> may help you understand how
* they work.
*
* <p>The false positive probability ({@code FPP}) of a Bloom filter is defined as the probability
@@ -64,8 +63,7 @@
* @since 11.0 (thread-safe since 23.0)
*/
@Beta
-@ElementTypesAreNonnullByDefault
-public final class BloomFilter<T extends @Nullable Object> implements Predicate<T>, Serializable {
+public final class BloomFilter<T> implements Predicate<T>, Serializable {
/**
* A strategy to translate T instances, to {@code numHashFunctions} bit indexes.
*
@@ -78,21 +76,15 @@
*
* <p>Returns whether any bits changed as a result of this operation.
*/
- <T extends @Nullable Object> boolean put(
- @ParametricNullness T object,
- Funnel<? super T> funnel,
- int numHashFunctions,
- LockFreeBitArray bits);
+ <T> boolean put(
+ T object, Funnel<? super T> funnel, int numHashFunctions, LockFreeBitArray bits);
/**
* Queries {@code numHashFunctions} bits of the given bit array, by hashing a user element;
* returns {@code true} if and only if all selected bits are set.
*/
- <T extends @Nullable Object> boolean mightContain(
- @ParametricNullness T object,
- Funnel<? super T> funnel,
- int numHashFunctions,
- LockFreeBitArray bits);
+ <T> boolean mightContain(
+ T object, Funnel<? super T> funnel, int numHashFunctions, LockFreeBitArray bits);
/**
* Identifier used to encode this strategy, when marshalled as part of a BloomFilter. Only
@@ -142,7 +134,7 @@
* Returns {@code true} if the element <i>might</i> have been put in this Bloom filter, {@code
* false} if this is <i>definitely</i> not the case.
*/
- public boolean mightContain(@ParametricNullness T object) {
+ public boolean mightContain(T object) {
return strategy.mightContain(object, funnel, numHashFunctions, bits);
}
@@ -152,7 +144,7 @@
*/
@Deprecated
@Override
- public boolean apply(@ParametricNullness T input) {
+ public boolean apply(T input) {
return mightContain(input);
}
@@ -168,7 +160,7 @@
* @since 12.0 (present in 11.0 with {@code void} return type})
*/
@CanIgnoreReturnValue
- public boolean put(@ParametricNullness T object) {
+ public boolean put(T object) {
return strategy.put(object, funnel, numHashFunctions, bits);
}
@@ -275,7 +267,7 @@
}
@Override
- public boolean equals(@CheckForNull Object object) {
+ public boolean equals(@NullableDecl Object object) {
if (object == this) {
return true;
}
@@ -314,7 +306,7 @@
* @param fpp the desired false positive probability (must be positive and less than 1.0)
* @return a {@code BloomFilter}
*/
- public static <T extends @Nullable Object> BloomFilter<T> create(
+ public static <T> BloomFilter<T> create(
Funnel<? super T> funnel, int expectedInsertions, double fpp) {
return create(funnel, (long) expectedInsertions, fpp);
}
@@ -340,13 +332,13 @@
* @return a {@code BloomFilter}
* @since 19.0
*/
- public static <T extends @Nullable Object> BloomFilter<T> create(
+ public static <T> BloomFilter<T> create(
Funnel<? super T> funnel, long expectedInsertions, double fpp) {
return create(funnel, expectedInsertions, fpp, BloomFilterStrategies.MURMUR128_MITZ_64);
}
@VisibleForTesting
- static <T extends @Nullable Object> BloomFilter<T> create(
+ static <T> BloomFilter<T> create(
Funnel<? super T> funnel, long expectedInsertions, double fpp, Strategy strategy) {
checkNotNull(funnel);
checkArgument(
@@ -391,8 +383,7 @@
* BloomFilter}; must be positive
* @return a {@code BloomFilter}
*/
- public static <T extends @Nullable Object> BloomFilter<T> create(
- Funnel<? super T> funnel, int expectedInsertions) {
+ public static <T> BloomFilter<T> create(Funnel<? super T> funnel, int expectedInsertions) {
return create(funnel, (long) expectedInsertions);
}
@@ -416,8 +407,7 @@
* @return a {@code BloomFilter}
* @since 19.0
*/
- public static <T extends @Nullable Object> BloomFilter<T> create(
- Funnel<? super T> funnel, long expectedInsertions) {
+ public static <T> BloomFilter<T> create(Funnel<? super T> funnel, long expectedInsertions) {
return create(funnel, expectedInsertions, 0.03); // FYI, for 3%, we always get 5 hash functions
}
@@ -470,7 +460,7 @@
return new SerialForm<T>(this);
}
- private static class SerialForm<T extends @Nullable Object> implements Serializable {
+ private static class SerialForm<T> implements Serializable {
final long[] data;
final int numHashFunctions;
final Funnel<? super T> funnel;
@@ -523,8 +513,8 @@
* @throws IOException if the InputStream throws an {@code IOException}, or if its data does not
* appear to be a BloomFilter serialized using the {@linkplain #writeTo(OutputStream)} method.
*/
- public static <T extends @Nullable Object> BloomFilter<T> readFrom(
- InputStream in, Funnel<? super T> funnel) throws IOException {
+ public static <T> BloomFilter<T> readFrom(InputStream in, Funnel<? super T> funnel)
+ throws IOException {
checkNotNull(in, "InputStream");
checkNotNull(funnel, "Funnel");
int strategyOrdinal = -1;
diff --git a/android/guava/src/com/google/common/hash/BloomFilterStrategies.java b/android/guava/src/com/google/common/hash/BloomFilterStrategies.java
index 3a012f3..ade2940 100644
--- a/android/guava/src/com/google/common/hash/BloomFilterStrategies.java
+++ b/android/guava/src/com/google/common/hash/BloomFilterStrategies.java
@@ -22,8 +22,7 @@
import java.math.RoundingMode;
import java.util.Arrays;
import java.util.concurrent.atomic.AtomicLongArray;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* Collections of strategies of generating the k * log(M) bits required for an element to be mapped
@@ -37,7 +36,6 @@
* @author Dimitris Andreou
* @author Kurt Alfred Kluever
*/
-@ElementTypesAreNonnullByDefault
enum BloomFilterStrategies implements BloomFilter.Strategy {
/**
* See "Less Hashing, Same Performance: Building a Better Bloom Filter" by Adam Kirsch and Michael
@@ -46,11 +44,8 @@
*/
MURMUR128_MITZ_32() {
@Override
- public <T extends @Nullable Object> boolean put(
- @ParametricNullness T object,
- Funnel<? super T> funnel,
- int numHashFunctions,
- LockFreeBitArray bits) {
+ public <T> boolean put(
+ T object, Funnel<? super T> funnel, int numHashFunctions, LockFreeBitArray bits) {
long bitSize = bits.bitSize();
long hash64 = Hashing.murmur3_128().hashObject(object, funnel).asLong();
int hash1 = (int) hash64;
@@ -69,11 +64,8 @@
}
@Override
- public <T extends @Nullable Object> boolean mightContain(
- @ParametricNullness T object,
- Funnel<? super T> funnel,
- int numHashFunctions,
- LockFreeBitArray bits) {
+ public <T> boolean mightContain(
+ T object, Funnel<? super T> funnel, int numHashFunctions, LockFreeBitArray bits) {
long bitSize = bits.bitSize();
long hash64 = Hashing.murmur3_128().hashObject(object, funnel).asLong();
int hash1 = (int) hash64;
@@ -100,11 +92,8 @@
*/
MURMUR128_MITZ_64() {
@Override
- public <T extends @Nullable Object> boolean put(
- @ParametricNullness T object,
- Funnel<? super T> funnel,
- int numHashFunctions,
- LockFreeBitArray bits) {
+ public <T> boolean put(
+ T object, Funnel<? super T> funnel, int numHashFunctions, LockFreeBitArray bits) {
long bitSize = bits.bitSize();
byte[] bytes = Hashing.murmur3_128().hashObject(object, funnel).getBytesInternal();
long hash1 = lowerEight(bytes);
@@ -121,11 +110,8 @@
}
@Override
- public <T extends @Nullable Object> boolean mightContain(
- @ParametricNullness T object,
- Funnel<? super T> funnel,
- int numHashFunctions,
- LockFreeBitArray bits) {
+ public <T> boolean mightContain(
+ T object, Funnel<? super T> funnel, int numHashFunctions, LockFreeBitArray bits) {
long bitSize = bits.bitSize();
byte[] bytes = Hashing.murmur3_128().hashObject(object, funnel).getBytesInternal();
long hash1 = lowerEight(bytes);
@@ -285,7 +271,7 @@
}
@Override
- public boolean equals(@CheckForNull Object o) {
+ public boolean equals(@NullableDecl Object o) {
if (o instanceof LockFreeBitArray) {
LockFreeBitArray lockFreeBitArray = (LockFreeBitArray) o;
// TODO(lowasser): avoid allocation here
diff --git a/android/guava/src/com/google/common/hash/ChecksumHashFunction.java b/android/guava/src/com/google/common/hash/ChecksumHashFunction.java
index 159adbb..380c3a3 100644
--- a/android/guava/src/com/google/common/hash/ChecksumHashFunction.java
+++ b/android/guava/src/com/google/common/hash/ChecksumHashFunction.java
@@ -27,7 +27,6 @@
* @author Colin Decker
*/
@Immutable
-@ElementTypesAreNonnullByDefault
final class ChecksumHashFunction extends AbstractHashFunction implements Serializable {
private final ImmutableSupplier<? extends Checksum> checksumSupplier;
private final int bits;
diff --git a/android/guava/src/com/google/common/hash/Crc32cHashFunction.java b/android/guava/src/com/google/common/hash/Crc32cHashFunction.java
index 8e17e65..02db525 100644
--- a/android/guava/src/com/google/common/hash/Crc32cHashFunction.java
+++ b/android/guava/src/com/google/common/hash/Crc32cHashFunction.java
@@ -15,7 +15,6 @@
package com.google.common.hash;
import com.google.errorprone.annotations.Immutable;
-import java.nio.ByteBuffer;
/**
* This class generates a CRC32C checksum, defined by RFC 3720, Section 12.1. The generator
@@ -24,7 +23,6 @@
* @author Kurt Alfred Kluever
*/
@Immutable
-@ElementTypesAreNonnullByDefault
final class Crc32cHashFunction extends AbstractHashFunction {
static final HashFunction CRC_32_C = new Crc32cHashFunction();
@@ -43,332 +41,88 @@
return "Hashing.crc32c()";
}
- static final class Crc32cHasher extends AbstractStreamingHasher {
+ static final class Crc32cHasher extends AbstractByteHasher {
- /*
- * The striding algorithm works roughly as follows: it is universally the case that
- * CRC(x ^ y) == CRC(x) ^ CRC(y). The approach we take is to break the message as follows,
- * with each letter representing a 4-byte word: ABCDABCDABCDABCD... and to calculate
- * CRC(A000A000A000...), CRC(0B000B000B...), CRC(00C000C000C...), CRC(000D000D000D...)
- * and then to XOR them together. The STRIDE_TABLE enables us to hash an int followed by 12
- * zero bytes (3 ints), while the BYTE_TABLE is for advancing one byte at a time.
- * This algorithm is due to the paper "Everything we know about CRC but [are] afraid to forget"
- * by Kadatch and Jenkins, 2010.
- */
-
- Crc32cHasher() {
- super(16);
- }
-
- private boolean finished = false;
-
- /*
- * This trick allows us to avoid having separate states for "first four ints" and "all other
- * four int chunks." The state we want after the first four bytes is
- *
- * crc0 = ~int0
- * crc1 = int1
- * crc2 = int2
- * crc3 = int3
- *
- * ...so we set crc0 so that computeForWord(crc0) = -1 and xoring it with the first int
- * gives us the desired result. computeForWord(0) == 0, so all the others do the right thing.
- */
- private int crc0 = INVERSE_COMPUTE_FOR_WORD_OF_ALL_1S;
- private int crc1 = 0;
- private int crc2 = 0;
- private int crc3 = 0;
-
- @Override
- protected void process(ByteBuffer bb) {
- if (finished) {
- throw new IllegalStateException(
- "The behavior of calling any method after calling hash() is undefined.");
- }
- while (bb.remaining() >= 16) {
- crc0 = computeForWord(crc0);
- crc1 = computeForWord(crc1);
- crc2 = computeForWord(crc2);
- crc3 = computeForWord(crc3);
- crc0 ^= bb.getInt();
- crc1 ^= bb.getInt();
- crc2 ^= bb.getInt();
- crc3 ^= bb.getInt();
- }
- }
-
- @Override
- protected void processRemaining(ByteBuffer bb) {
- if (finished) {
- return;
- }
- crc0 = combine(0, crc0);
- crc0 = combine(crc0, crc1);
- crc0 = combine(crc0, crc2);
- crc0 = combine(crc0, crc3);
- while (bb.hasRemaining()) {
- crc0 = (crc0 >>> 8) ^ BYTE_TABLE[(bb.get() ^ crc0) & 0xFF];
- }
- finished = true;
- }
-
- @Override
- protected HashCode makeHash() {
- if (!finished) {
- // processRemaining does teardown we always want to do -- the folding together of the four
- // rolling CRCs. So we call it on an empty ByteBuffer if we didn't already.
- processRemaining(EMPTY);
- }
- return HashCode.fromInt(~crc0);
- }
-
- static final int[] BYTE_TABLE = {
- 0x00000000, 0xf26b8303, 0xe13b70f7, 0x1350f3f4, 0xc79a971f, 0x35f1141c,
- 0x26a1e7e8, 0xd4ca64eb, 0x8ad958cf, 0x78b2dbcc, 0x6be22838, 0x9989ab3b,
- 0x4d43cfd0, 0xbf284cd3, 0xac78bf27, 0x5e133c24, 0x105ec76f, 0xe235446c,
- 0xf165b798, 0x030e349b, 0xd7c45070, 0x25afd373, 0x36ff2087, 0xc494a384,
- 0x9a879fa0, 0x68ec1ca3, 0x7bbcef57, 0x89d76c54, 0x5d1d08bf, 0xaf768bbc,
- 0xbc267848, 0x4e4dfb4b, 0x20bd8ede, 0xd2d60ddd, 0xc186fe29, 0x33ed7d2a,
- 0xe72719c1, 0x154c9ac2, 0x061c6936, 0xf477ea35, 0xaa64d611, 0x580f5512,
- 0x4b5fa6e6, 0xb93425e5, 0x6dfe410e, 0x9f95c20d, 0x8cc531f9, 0x7eaeb2fa,
- 0x30e349b1, 0xc288cab2, 0xd1d83946, 0x23b3ba45, 0xf779deae, 0x05125dad,
- 0x1642ae59, 0xe4292d5a, 0xba3a117e, 0x4851927d, 0x5b016189, 0xa96ae28a,
- 0x7da08661, 0x8fcb0562, 0x9c9bf696, 0x6ef07595, 0x417b1dbc, 0xb3109ebf,
- 0xa0406d4b, 0x522bee48, 0x86e18aa3, 0x748a09a0, 0x67dafa54, 0x95b17957,
- 0xcba24573, 0x39c9c670, 0x2a993584, 0xd8f2b687, 0x0c38d26c, 0xfe53516f,
- 0xed03a29b, 0x1f682198, 0x5125dad3, 0xa34e59d0, 0xb01eaa24, 0x42752927,
- 0x96bf4dcc, 0x64d4cecf, 0x77843d3b, 0x85efbe38, 0xdbfc821c, 0x2997011f,
- 0x3ac7f2eb, 0xc8ac71e8, 0x1c661503, 0xee0d9600, 0xfd5d65f4, 0x0f36e6f7,
- 0x61c69362, 0x93ad1061, 0x80fde395, 0x72966096, 0xa65c047d, 0x5437877e,
- 0x4767748a, 0xb50cf789, 0xeb1fcbad, 0x197448ae, 0x0a24bb5a, 0xf84f3859,
- 0x2c855cb2, 0xdeeedfb1, 0xcdbe2c45, 0x3fd5af46, 0x7198540d, 0x83f3d70e,
- 0x90a324fa, 0x62c8a7f9, 0xb602c312, 0x44694011, 0x5739b3e5, 0xa55230e6,
- 0xfb410cc2, 0x092a8fc1, 0x1a7a7c35, 0xe811ff36, 0x3cdb9bdd, 0xceb018de,
- 0xdde0eb2a, 0x2f8b6829, 0x82f63b78, 0x709db87b, 0x63cd4b8f, 0x91a6c88c,
- 0x456cac67, 0xb7072f64, 0xa457dc90, 0x563c5f93, 0x082f63b7, 0xfa44e0b4,
- 0xe9141340, 0x1b7f9043, 0xcfb5f4a8, 0x3dde77ab, 0x2e8e845f, 0xdce5075c,
- 0x92a8fc17, 0x60c37f14, 0x73938ce0, 0x81f80fe3, 0x55326b08, 0xa759e80b,
- 0xb4091bff, 0x466298fc, 0x1871a4d8, 0xea1a27db, 0xf94ad42f, 0x0b21572c,
- 0xdfeb33c7, 0x2d80b0c4, 0x3ed04330, 0xccbbc033, 0xa24bb5a6, 0x502036a5,
- 0x4370c551, 0xb11b4652, 0x65d122b9, 0x97baa1ba, 0x84ea524e, 0x7681d14d,
- 0x2892ed69, 0xdaf96e6a, 0xc9a99d9e, 0x3bc21e9d, 0xef087a76, 0x1d63f975,
- 0x0e330a81, 0xfc588982, 0xb21572c9, 0x407ef1ca, 0x532e023e, 0xa145813d,
- 0x758fe5d6, 0x87e466d5, 0x94b49521, 0x66df1622, 0x38cc2a06, 0xcaa7a905,
- 0xd9f75af1, 0x2b9cd9f2, 0xff56bd19, 0x0d3d3e1a, 0x1e6dcdee, 0xec064eed,
- 0xc38d26c4, 0x31e6a5c7, 0x22b65633, 0xd0ddd530, 0x0417b1db, 0xf67c32d8,
- 0xe52cc12c, 0x1747422f, 0x49547e0b, 0xbb3ffd08, 0xa86f0efc, 0x5a048dff,
- 0x8ecee914, 0x7ca56a17, 0x6ff599e3, 0x9d9e1ae0, 0xd3d3e1ab, 0x21b862a8,
- 0x32e8915c, 0xc083125f, 0x144976b4, 0xe622f5b7, 0xf5720643, 0x07198540,
- 0x590ab964, 0xab613a67, 0xb831c993, 0x4a5a4a90, 0x9e902e7b, 0x6cfbad78,
- 0x7fab5e8c, 0x8dc0dd8f, 0xe330a81a, 0x115b2b19, 0x020bd8ed, 0xf0605bee,
- 0x24aa3f05, 0xd6c1bc06, 0xc5914ff2, 0x37faccf1, 0x69e9f0d5, 0x9b8273d6,
- 0x88d28022, 0x7ab90321, 0xae7367ca, 0x5c18e4c9, 0x4f48173d, 0xbd23943e,
- 0xf36e6f75, 0x0105ec76, 0x12551f82, 0xe03e9c81, 0x34f4f86a, 0xc69f7b69,
- 0xd5cf889d, 0x27a40b9e, 0x79b737ba, 0x8bdcb4b9, 0x988c474d, 0x6ae7c44e,
+ // The CRC table, generated from the polynomial 0x11EDC6F41.
+ static final int[] CRC_TABLE = {
+ 0x00000000, 0xf26b8303, 0xe13b70f7, 0x1350f3f4,
+ 0xc79a971f, 0x35f1141c, 0x26a1e7e8, 0xd4ca64eb,
+ 0x8ad958cf, 0x78b2dbcc, 0x6be22838, 0x9989ab3b,
+ 0x4d43cfd0, 0xbf284cd3, 0xac78bf27, 0x5e133c24,
+ 0x105ec76f, 0xe235446c, 0xf165b798, 0x030e349b,
+ 0xd7c45070, 0x25afd373, 0x36ff2087, 0xc494a384,
+ 0x9a879fa0, 0x68ec1ca3, 0x7bbcef57, 0x89d76c54,
+ 0x5d1d08bf, 0xaf768bbc, 0xbc267848, 0x4e4dfb4b,
+ 0x20bd8ede, 0xd2d60ddd, 0xc186fe29, 0x33ed7d2a,
+ 0xe72719c1, 0x154c9ac2, 0x061c6936, 0xf477ea35,
+ 0xaa64d611, 0x580f5512, 0x4b5fa6e6, 0xb93425e5,
+ 0x6dfe410e, 0x9f95c20d, 0x8cc531f9, 0x7eaeb2fa,
+ 0x30e349b1, 0xc288cab2, 0xd1d83946, 0x23b3ba45,
+ 0xf779deae, 0x05125dad, 0x1642ae59, 0xe4292d5a,
+ 0xba3a117e, 0x4851927d, 0x5b016189, 0xa96ae28a,
+ 0x7da08661, 0x8fcb0562, 0x9c9bf696, 0x6ef07595,
+ 0x417b1dbc, 0xb3109ebf, 0xa0406d4b, 0x522bee48,
+ 0x86e18aa3, 0x748a09a0, 0x67dafa54, 0x95b17957,
+ 0xcba24573, 0x39c9c670, 0x2a993584, 0xd8f2b687,
+ 0x0c38d26c, 0xfe53516f, 0xed03a29b, 0x1f682198,
+ 0x5125dad3, 0xa34e59d0, 0xb01eaa24, 0x42752927,
+ 0x96bf4dcc, 0x64d4cecf, 0x77843d3b, 0x85efbe38,
+ 0xdbfc821c, 0x2997011f, 0x3ac7f2eb, 0xc8ac71e8,
+ 0x1c661503, 0xee0d9600, 0xfd5d65f4, 0x0f36e6f7,
+ 0x61c69362, 0x93ad1061, 0x80fde395, 0x72966096,
+ 0xa65c047d, 0x5437877e, 0x4767748a, 0xb50cf789,
+ 0xeb1fcbad, 0x197448ae, 0x0a24bb5a, 0xf84f3859,
+ 0x2c855cb2, 0xdeeedfb1, 0xcdbe2c45, 0x3fd5af46,
+ 0x7198540d, 0x83f3d70e, 0x90a324fa, 0x62c8a7f9,
+ 0xb602c312, 0x44694011, 0x5739b3e5, 0xa55230e6,
+ 0xfb410cc2, 0x092a8fc1, 0x1a7a7c35, 0xe811ff36,
+ 0x3cdb9bdd, 0xceb018de, 0xdde0eb2a, 0x2f8b6829,
+ 0x82f63b78, 0x709db87b, 0x63cd4b8f, 0x91a6c88c,
+ 0x456cac67, 0xb7072f64, 0xa457dc90, 0x563c5f93,
+ 0x082f63b7, 0xfa44e0b4, 0xe9141340, 0x1b7f9043,
+ 0xcfb5f4a8, 0x3dde77ab, 0x2e8e845f, 0xdce5075c,
+ 0x92a8fc17, 0x60c37f14, 0x73938ce0, 0x81f80fe3,
+ 0x55326b08, 0xa759e80b, 0xb4091bff, 0x466298fc,
+ 0x1871a4d8, 0xea1a27db, 0xf94ad42f, 0x0b21572c,
+ 0xdfeb33c7, 0x2d80b0c4, 0x3ed04330, 0xccbbc033,
+ 0xa24bb5a6, 0x502036a5, 0x4370c551, 0xb11b4652,
+ 0x65d122b9, 0x97baa1ba, 0x84ea524e, 0x7681d14d,
+ 0x2892ed69, 0xdaf96e6a, 0xc9a99d9e, 0x3bc21e9d,
+ 0xef087a76, 0x1d63f975, 0x0e330a81, 0xfc588982,
+ 0xb21572c9, 0x407ef1ca, 0x532e023e, 0xa145813d,
+ 0x758fe5d6, 0x87e466d5, 0x94b49521, 0x66df1622,
+ 0x38cc2a06, 0xcaa7a905, 0xd9f75af1, 0x2b9cd9f2,
+ 0xff56bd19, 0x0d3d3e1a, 0x1e6dcdee, 0xec064eed,
+ 0xc38d26c4, 0x31e6a5c7, 0x22b65633, 0xd0ddd530,
+ 0x0417b1db, 0xf67c32d8, 0xe52cc12c, 0x1747422f,
+ 0x49547e0b, 0xbb3ffd08, 0xa86f0efc, 0x5a048dff,
+ 0x8ecee914, 0x7ca56a17, 0x6ff599e3, 0x9d9e1ae0,
+ 0xd3d3e1ab, 0x21b862a8, 0x32e8915c, 0xc083125f,
+ 0x144976b4, 0xe622f5b7, 0xf5720643, 0x07198540,
+ 0x590ab964, 0xab613a67, 0xb831c993, 0x4a5a4a90,
+ 0x9e902e7b, 0x6cfbad78, 0x7fab5e8c, 0x8dc0dd8f,
+ 0xe330a81a, 0x115b2b19, 0x020bd8ed, 0xf0605bee,
+ 0x24aa3f05, 0xd6c1bc06, 0xc5914ff2, 0x37faccf1,
+ 0x69e9f0d5, 0x9b8273d6, 0x88d28022, 0x7ab90321,
+ 0xae7367ca, 0x5c18e4c9, 0x4f48173d, 0xbd23943e,
+ 0xf36e6f75, 0x0105ec76, 0x12551f82, 0xe03e9c81,
+ 0x34f4f86a, 0xc69f7b69, 0xd5cf889d, 0x27a40b9e,
+ 0x79b737ba, 0x8bdcb4b9, 0x988c474d, 0x6ae7c44e,
0xbe2da0a5, 0x4c4623a6, 0x5f16d052, 0xad7d5351
};
- static final int[][] STRIDE_TABLE = {
- {
- 0x00000000, 0x30d23865, 0x61a470ca, 0x517648af, 0xc348e194, 0xf39ad9f1,
- 0xa2ec915e, 0x923ea93b, 0x837db5d9, 0xb3af8dbc, 0xe2d9c513, 0xd20bfd76,
- 0x4035544d, 0x70e76c28, 0x21912487, 0x11431ce2, 0x03171d43, 0x33c52526,
- 0x62b36d89, 0x526155ec, 0xc05ffcd7, 0xf08dc4b2, 0xa1fb8c1d, 0x9129b478,
- 0x806aa89a, 0xb0b890ff, 0xe1ced850, 0xd11ce035, 0x4322490e, 0x73f0716b,
- 0x228639c4, 0x125401a1, 0x062e3a86, 0x36fc02e3, 0x678a4a4c, 0x57587229,
- 0xc566db12, 0xf5b4e377, 0xa4c2abd8, 0x941093bd, 0x85538f5f, 0xb581b73a,
- 0xe4f7ff95, 0xd425c7f0, 0x461b6ecb, 0x76c956ae, 0x27bf1e01, 0x176d2664,
- 0x053927c5, 0x35eb1fa0, 0x649d570f, 0x544f6f6a, 0xc671c651, 0xf6a3fe34,
- 0xa7d5b69b, 0x97078efe, 0x8644921c, 0xb696aa79, 0xe7e0e2d6, 0xd732dab3,
- 0x450c7388, 0x75de4bed, 0x24a80342, 0x147a3b27, 0x0c5c750c, 0x3c8e4d69,
- 0x6df805c6, 0x5d2a3da3, 0xcf149498, 0xffc6acfd, 0xaeb0e452, 0x9e62dc37,
- 0x8f21c0d5, 0xbff3f8b0, 0xee85b01f, 0xde57887a, 0x4c692141, 0x7cbb1924,
- 0x2dcd518b, 0x1d1f69ee, 0x0f4b684f, 0x3f99502a, 0x6eef1885, 0x5e3d20e0,
- 0xcc0389db, 0xfcd1b1be, 0xada7f911, 0x9d75c174, 0x8c36dd96, 0xbce4e5f3,
- 0xed92ad5c, 0xdd409539, 0x4f7e3c02, 0x7fac0467, 0x2eda4cc8, 0x1e0874ad,
- 0x0a724f8a, 0x3aa077ef, 0x6bd63f40, 0x5b040725, 0xc93aae1e, 0xf9e8967b,
- 0xa89eded4, 0x984ce6b1, 0x890ffa53, 0xb9ddc236, 0xe8ab8a99, 0xd879b2fc,
- 0x4a471bc7, 0x7a9523a2, 0x2be36b0d, 0x1b315368, 0x096552c9, 0x39b76aac,
- 0x68c12203, 0x58131a66, 0xca2db35d, 0xfaff8b38, 0xab89c397, 0x9b5bfbf2,
- 0x8a18e710, 0xbacadf75, 0xebbc97da, 0xdb6eafbf, 0x49500684, 0x79823ee1,
- 0x28f4764e, 0x18264e2b, 0x18b8ea18, 0x286ad27d, 0x791c9ad2, 0x49cea2b7,
- 0xdbf00b8c, 0xeb2233e9, 0xba547b46, 0x8a864323, 0x9bc55fc1, 0xab1767a4,
- 0xfa612f0b, 0xcab3176e, 0x588dbe55, 0x685f8630, 0x3929ce9f, 0x09fbf6fa,
- 0x1baff75b, 0x2b7dcf3e, 0x7a0b8791, 0x4ad9bff4, 0xd8e716cf, 0xe8352eaa,
- 0xb9436605, 0x89915e60, 0x98d24282, 0xa8007ae7, 0xf9763248, 0xc9a40a2d,
- 0x5b9aa316, 0x6b489b73, 0x3a3ed3dc, 0x0aecebb9, 0x1e96d09e, 0x2e44e8fb,
- 0x7f32a054, 0x4fe09831, 0xddde310a, 0xed0c096f, 0xbc7a41c0, 0x8ca879a5,
- 0x9deb6547, 0xad395d22, 0xfc4f158d, 0xcc9d2de8, 0x5ea384d3, 0x6e71bcb6,
- 0x3f07f419, 0x0fd5cc7c, 0x1d81cddd, 0x2d53f5b8, 0x7c25bd17, 0x4cf78572,
- 0xdec92c49, 0xee1b142c, 0xbf6d5c83, 0x8fbf64e6, 0x9efc7804, 0xae2e4061,
- 0xff5808ce, 0xcf8a30ab, 0x5db49990, 0x6d66a1f5, 0x3c10e95a, 0x0cc2d13f,
- 0x14e49f14, 0x2436a771, 0x7540efde, 0x4592d7bb, 0xd7ac7e80, 0xe77e46e5,
- 0xb6080e4a, 0x86da362f, 0x97992acd, 0xa74b12a8, 0xf63d5a07, 0xc6ef6262,
- 0x54d1cb59, 0x6403f33c, 0x3575bb93, 0x05a783f6, 0x17f38257, 0x2721ba32,
- 0x7657f29d, 0x4685caf8, 0xd4bb63c3, 0xe4695ba6, 0xb51f1309, 0x85cd2b6c,
- 0x948e378e, 0xa45c0feb, 0xf52a4744, 0xc5f87f21, 0x57c6d61a, 0x6714ee7f,
- 0x3662a6d0, 0x06b09eb5, 0x12caa592, 0x22189df7, 0x736ed558, 0x43bced3d,
- 0xd1824406, 0xe1507c63, 0xb02634cc, 0x80f40ca9, 0x91b7104b, 0xa165282e,
- 0xf0136081, 0xc0c158e4, 0x52fff1df, 0x622dc9ba, 0x335b8115, 0x0389b970,
- 0x11ddb8d1, 0x210f80b4, 0x7079c81b, 0x40abf07e, 0xd2955945, 0xe2476120,
- 0xb331298f, 0x83e311ea, 0x92a00d08, 0xa272356d, 0xf3047dc2, 0xc3d645a7,
- 0x51e8ec9c, 0x613ad4f9, 0x304c9c56, 0x009ea433,
- },
- {
- 0x00000000, 0x54075546, 0xa80eaa8c, 0xfc09ffca, 0x55f123e9, 0x01f676af,
- 0xfdff8965, 0xa9f8dc23, 0xabe247d2, 0xffe51294, 0x03eced5e, 0x57ebb818,
- 0xfe13643b, 0xaa14317d, 0x561dceb7, 0x021a9bf1, 0x5228f955, 0x062fac13,
- 0xfa2653d9, 0xae21069f, 0x07d9dabc, 0x53de8ffa, 0xafd77030, 0xfbd02576,
- 0xf9cabe87, 0xadcdebc1, 0x51c4140b, 0x05c3414d, 0xac3b9d6e, 0xf83cc828,
- 0x043537e2, 0x503262a4, 0xa451f2aa, 0xf056a7ec, 0x0c5f5826, 0x58580d60,
- 0xf1a0d143, 0xa5a78405, 0x59ae7bcf, 0x0da92e89, 0x0fb3b578, 0x5bb4e03e,
- 0xa7bd1ff4, 0xf3ba4ab2, 0x5a429691, 0x0e45c3d7, 0xf24c3c1d, 0xa64b695b,
- 0xf6790bff, 0xa27e5eb9, 0x5e77a173, 0x0a70f435, 0xa3882816, 0xf78f7d50,
- 0x0b86829a, 0x5f81d7dc, 0x5d9b4c2d, 0x099c196b, 0xf595e6a1, 0xa192b3e7,
- 0x086a6fc4, 0x5c6d3a82, 0xa064c548, 0xf463900e, 0x4d4f93a5, 0x1948c6e3,
- 0xe5413929, 0xb1466c6f, 0x18beb04c, 0x4cb9e50a, 0xb0b01ac0, 0xe4b74f86,
- 0xe6add477, 0xb2aa8131, 0x4ea37efb, 0x1aa42bbd, 0xb35cf79e, 0xe75ba2d8,
- 0x1b525d12, 0x4f550854, 0x1f676af0, 0x4b603fb6, 0xb769c07c, 0xe36e953a,
- 0x4a964919, 0x1e911c5f, 0xe298e395, 0xb69fb6d3, 0xb4852d22, 0xe0827864,
- 0x1c8b87ae, 0x488cd2e8, 0xe1740ecb, 0xb5735b8d, 0x497aa447, 0x1d7df101,
- 0xe91e610f, 0xbd193449, 0x4110cb83, 0x15179ec5, 0xbcef42e6, 0xe8e817a0,
- 0x14e1e86a, 0x40e6bd2c, 0x42fc26dd, 0x16fb739b, 0xeaf28c51, 0xbef5d917,
- 0x170d0534, 0x430a5072, 0xbf03afb8, 0xeb04fafe, 0xbb36985a, 0xef31cd1c,
- 0x133832d6, 0x473f6790, 0xeec7bbb3, 0xbac0eef5, 0x46c9113f, 0x12ce4479,
- 0x10d4df88, 0x44d38ace, 0xb8da7504, 0xecdd2042, 0x4525fc61, 0x1122a927,
- 0xed2b56ed, 0xb92c03ab, 0x9a9f274a, 0xce98720c, 0x32918dc6, 0x6696d880,
- 0xcf6e04a3, 0x9b6951e5, 0x6760ae2f, 0x3367fb69, 0x317d6098, 0x657a35de,
- 0x9973ca14, 0xcd749f52, 0x648c4371, 0x308b1637, 0xcc82e9fd, 0x9885bcbb,
- 0xc8b7de1f, 0x9cb08b59, 0x60b97493, 0x34be21d5, 0x9d46fdf6, 0xc941a8b0,
- 0x3548577a, 0x614f023c, 0x635599cd, 0x3752cc8b, 0xcb5b3341, 0x9f5c6607,
- 0x36a4ba24, 0x62a3ef62, 0x9eaa10a8, 0xcaad45ee, 0x3eced5e0, 0x6ac980a6,
- 0x96c07f6c, 0xc2c72a2a, 0x6b3ff609, 0x3f38a34f, 0xc3315c85, 0x973609c3,
- 0x952c9232, 0xc12bc774, 0x3d2238be, 0x69256df8, 0xc0ddb1db, 0x94dae49d,
- 0x68d31b57, 0x3cd44e11, 0x6ce62cb5, 0x38e179f3, 0xc4e88639, 0x90efd37f,
- 0x39170f5c, 0x6d105a1a, 0x9119a5d0, 0xc51ef096, 0xc7046b67, 0x93033e21,
- 0x6f0ac1eb, 0x3b0d94ad, 0x92f5488e, 0xc6f21dc8, 0x3afbe202, 0x6efcb744,
- 0xd7d0b4ef, 0x83d7e1a9, 0x7fde1e63, 0x2bd94b25, 0x82219706, 0xd626c240,
- 0x2a2f3d8a, 0x7e2868cc, 0x7c32f33d, 0x2835a67b, 0xd43c59b1, 0x803b0cf7,
- 0x29c3d0d4, 0x7dc48592, 0x81cd7a58, 0xd5ca2f1e, 0x85f84dba, 0xd1ff18fc,
- 0x2df6e736, 0x79f1b270, 0xd0096e53, 0x840e3b15, 0x7807c4df, 0x2c009199,
- 0x2e1a0a68, 0x7a1d5f2e, 0x8614a0e4, 0xd213f5a2, 0x7beb2981, 0x2fec7cc7,
- 0xd3e5830d, 0x87e2d64b, 0x73814645, 0x27861303, 0xdb8fecc9, 0x8f88b98f,
- 0x267065ac, 0x727730ea, 0x8e7ecf20, 0xda799a66, 0xd8630197, 0x8c6454d1,
- 0x706dab1b, 0x246afe5d, 0x8d92227e, 0xd9957738, 0x259c88f2, 0x719bddb4,
- 0x21a9bf10, 0x75aeea56, 0x89a7159c, 0xdda040da, 0x74589cf9, 0x205fc9bf,
- 0xdc563675, 0x88516333, 0x8a4bf8c2, 0xde4cad84, 0x2245524e, 0x76420708,
- 0xdfbadb2b, 0x8bbd8e6d, 0x77b471a7, 0x23b324e1,
- },
- {
- 0x00000000, 0x678efd01, 0xcf1dfa02, 0xa8930703, 0x9bd782f5, 0xfc597ff4,
- 0x54ca78f7, 0x334485f6, 0x3243731b, 0x55cd8e1a, 0xfd5e8919, 0x9ad07418,
- 0xa994f1ee, 0xce1a0cef, 0x66890bec, 0x0107f6ed, 0x6486e636, 0x03081b37,
- 0xab9b1c34, 0xcc15e135, 0xff5164c3, 0x98df99c2, 0x304c9ec1, 0x57c263c0,
- 0x56c5952d, 0x314b682c, 0x99d86f2f, 0xfe56922e, 0xcd1217d8, 0xaa9cead9,
- 0x020fedda, 0x658110db, 0xc90dcc6c, 0xae83316d, 0x0610366e, 0x619ecb6f,
- 0x52da4e99, 0x3554b398, 0x9dc7b49b, 0xfa49499a, 0xfb4ebf77, 0x9cc04276,
- 0x34534575, 0x53ddb874, 0x60993d82, 0x0717c083, 0xaf84c780, 0xc80a3a81,
- 0xad8b2a5a, 0xca05d75b, 0x6296d058, 0x05182d59, 0x365ca8af, 0x51d255ae,
- 0xf94152ad, 0x9ecfafac, 0x9fc85941, 0xf846a440, 0x50d5a343, 0x375b5e42,
- 0x041fdbb4, 0x639126b5, 0xcb0221b6, 0xac8cdcb7, 0x97f7ee29, 0xf0791328,
- 0x58ea142b, 0x3f64e92a, 0x0c206cdc, 0x6bae91dd, 0xc33d96de, 0xa4b36bdf,
- 0xa5b49d32, 0xc23a6033, 0x6aa96730, 0x0d279a31, 0x3e631fc7, 0x59ede2c6,
- 0xf17ee5c5, 0x96f018c4, 0xf371081f, 0x94fff51e, 0x3c6cf21d, 0x5be20f1c,
- 0x68a68aea, 0x0f2877eb, 0xa7bb70e8, 0xc0358de9, 0xc1327b04, 0xa6bc8605,
- 0x0e2f8106, 0x69a17c07, 0x5ae5f9f1, 0x3d6b04f0, 0x95f803f3, 0xf276fef2,
- 0x5efa2245, 0x3974df44, 0x91e7d847, 0xf6692546, 0xc52da0b0, 0xa2a35db1,
- 0x0a305ab2, 0x6dbea7b3, 0x6cb9515e, 0x0b37ac5f, 0xa3a4ab5c, 0xc42a565d,
- 0xf76ed3ab, 0x90e02eaa, 0x387329a9, 0x5ffdd4a8, 0x3a7cc473, 0x5df23972,
- 0xf5613e71, 0x92efc370, 0xa1ab4686, 0xc625bb87, 0x6eb6bc84, 0x09384185,
- 0x083fb768, 0x6fb14a69, 0xc7224d6a, 0xa0acb06b, 0x93e8359d, 0xf466c89c,
- 0x5cf5cf9f, 0x3b7b329e, 0x2a03aaa3, 0x4d8d57a2, 0xe51e50a1, 0x8290ada0,
- 0xb1d42856, 0xd65ad557, 0x7ec9d254, 0x19472f55, 0x1840d9b8, 0x7fce24b9,
- 0xd75d23ba, 0xb0d3debb, 0x83975b4d, 0xe419a64c, 0x4c8aa14f, 0x2b045c4e,
- 0x4e854c95, 0x290bb194, 0x8198b697, 0xe6164b96, 0xd552ce60, 0xb2dc3361,
- 0x1a4f3462, 0x7dc1c963, 0x7cc63f8e, 0x1b48c28f, 0xb3dbc58c, 0xd455388d,
- 0xe711bd7b, 0x809f407a, 0x280c4779, 0x4f82ba78, 0xe30e66cf, 0x84809bce,
- 0x2c139ccd, 0x4b9d61cc, 0x78d9e43a, 0x1f57193b, 0xb7c41e38, 0xd04ae339,
- 0xd14d15d4, 0xb6c3e8d5, 0x1e50efd6, 0x79de12d7, 0x4a9a9721, 0x2d146a20,
- 0x85876d23, 0xe2099022, 0x878880f9, 0xe0067df8, 0x48957afb, 0x2f1b87fa,
- 0x1c5f020c, 0x7bd1ff0d, 0xd342f80e, 0xb4cc050f, 0xb5cbf3e2, 0xd2450ee3,
- 0x7ad609e0, 0x1d58f4e1, 0x2e1c7117, 0x49928c16, 0xe1018b15, 0x868f7614,
- 0xbdf4448a, 0xda7ab98b, 0x72e9be88, 0x15674389, 0x2623c67f, 0x41ad3b7e,
- 0xe93e3c7d, 0x8eb0c17c, 0x8fb73791, 0xe839ca90, 0x40aacd93, 0x27243092,
- 0x1460b564, 0x73ee4865, 0xdb7d4f66, 0xbcf3b267, 0xd972a2bc, 0xbefc5fbd,
- 0x166f58be, 0x71e1a5bf, 0x42a52049, 0x252bdd48, 0x8db8da4b, 0xea36274a,
- 0xeb31d1a7, 0x8cbf2ca6, 0x242c2ba5, 0x43a2d6a4, 0x70e65352, 0x1768ae53,
- 0xbffba950, 0xd8755451, 0x74f988e6, 0x137775e7, 0xbbe472e4, 0xdc6a8fe5,
- 0xef2e0a13, 0x88a0f712, 0x2033f011, 0x47bd0d10, 0x46bafbfd, 0x213406fc,
- 0x89a701ff, 0xee29fcfe, 0xdd6d7908, 0xbae38409, 0x1270830a, 0x75fe7e0b,
- 0x107f6ed0, 0x77f193d1, 0xdf6294d2, 0xb8ec69d3, 0x8ba8ec25, 0xec261124,
- 0x44b51627, 0x233beb26, 0x223c1dcb, 0x45b2e0ca, 0xed21e7c9, 0x8aaf1ac8,
- 0xb9eb9f3e, 0xde65623f, 0x76f6653c, 0x1178983d,
- },
- {
- 0x00000000, 0xf20c0dfe, 0xe1f46d0d, 0x13f860f3, 0xc604aceb, 0x3408a115,
- 0x27f0c1e6, 0xd5fccc18, 0x89e52f27, 0x7be922d9, 0x6811422a, 0x9a1d4fd4,
- 0x4fe183cc, 0xbded8e32, 0xae15eec1, 0x5c19e33f, 0x162628bf, 0xe42a2541,
- 0xf7d245b2, 0x05de484c, 0xd0228454, 0x222e89aa, 0x31d6e959, 0xc3dae4a7,
- 0x9fc30798, 0x6dcf0a66, 0x7e376a95, 0x8c3b676b, 0x59c7ab73, 0xabcba68d,
- 0xb833c67e, 0x4a3fcb80, 0x2c4c517e, 0xde405c80, 0xcdb83c73, 0x3fb4318d,
- 0xea48fd95, 0x1844f06b, 0x0bbc9098, 0xf9b09d66, 0xa5a97e59, 0x57a573a7,
- 0x445d1354, 0xb6511eaa, 0x63add2b2, 0x91a1df4c, 0x8259bfbf, 0x7055b241,
- 0x3a6a79c1, 0xc866743f, 0xdb9e14cc, 0x29921932, 0xfc6ed52a, 0x0e62d8d4,
- 0x1d9ab827, 0xef96b5d9, 0xb38f56e6, 0x41835b18, 0x527b3beb, 0xa0773615,
- 0x758bfa0d, 0x8787f7f3, 0x947f9700, 0x66739afe, 0x5898a2fc, 0xaa94af02,
- 0xb96ccff1, 0x4b60c20f, 0x9e9c0e17, 0x6c9003e9, 0x7f68631a, 0x8d646ee4,
- 0xd17d8ddb, 0x23718025, 0x3089e0d6, 0xc285ed28, 0x17792130, 0xe5752cce,
- 0xf68d4c3d, 0x048141c3, 0x4ebe8a43, 0xbcb287bd, 0xaf4ae74e, 0x5d46eab0,
- 0x88ba26a8, 0x7ab62b56, 0x694e4ba5, 0x9b42465b, 0xc75ba564, 0x3557a89a,
- 0x26afc869, 0xd4a3c597, 0x015f098f, 0xf3530471, 0xe0ab6482, 0x12a7697c,
- 0x74d4f382, 0x86d8fe7c, 0x95209e8f, 0x672c9371, 0xb2d05f69, 0x40dc5297,
- 0x53243264, 0xa1283f9a, 0xfd31dca5, 0x0f3dd15b, 0x1cc5b1a8, 0xeec9bc56,
- 0x3b35704e, 0xc9397db0, 0xdac11d43, 0x28cd10bd, 0x62f2db3d, 0x90fed6c3,
- 0x8306b630, 0x710abbce, 0xa4f677d6, 0x56fa7a28, 0x45021adb, 0xb70e1725,
- 0xeb17f41a, 0x191bf9e4, 0x0ae39917, 0xf8ef94e9, 0x2d1358f1, 0xdf1f550f,
- 0xcce735fc, 0x3eeb3802, 0xb13145f8, 0x433d4806, 0x50c528f5, 0xa2c9250b,
- 0x7735e913, 0x8539e4ed, 0x96c1841e, 0x64cd89e0, 0x38d46adf, 0xcad86721,
- 0xd92007d2, 0x2b2c0a2c, 0xfed0c634, 0x0cdccbca, 0x1f24ab39, 0xed28a6c7,
- 0xa7176d47, 0x551b60b9, 0x46e3004a, 0xb4ef0db4, 0x6113c1ac, 0x931fcc52,
- 0x80e7aca1, 0x72eba15f, 0x2ef24260, 0xdcfe4f9e, 0xcf062f6d, 0x3d0a2293,
- 0xe8f6ee8b, 0x1afae375, 0x09028386, 0xfb0e8e78, 0x9d7d1486, 0x6f711978,
- 0x7c89798b, 0x8e857475, 0x5b79b86d, 0xa975b593, 0xba8dd560, 0x4881d89e,
- 0x14983ba1, 0xe694365f, 0xf56c56ac, 0x07605b52, 0xd29c974a, 0x20909ab4,
- 0x3368fa47, 0xc164f7b9, 0x8b5b3c39, 0x795731c7, 0x6aaf5134, 0x98a35cca,
- 0x4d5f90d2, 0xbf539d2c, 0xacabfddf, 0x5ea7f021, 0x02be131e, 0xf0b21ee0,
- 0xe34a7e13, 0x114673ed, 0xc4babff5, 0x36b6b20b, 0x254ed2f8, 0xd742df06,
- 0xe9a9e704, 0x1ba5eafa, 0x085d8a09, 0xfa5187f7, 0x2fad4bef, 0xdda14611,
- 0xce5926e2, 0x3c552b1c, 0x604cc823, 0x9240c5dd, 0x81b8a52e, 0x73b4a8d0,
- 0xa64864c8, 0x54446936, 0x47bc09c5, 0xb5b0043b, 0xff8fcfbb, 0x0d83c245,
- 0x1e7ba2b6, 0xec77af48, 0x398b6350, 0xcb876eae, 0xd87f0e5d, 0x2a7303a3,
- 0x766ae09c, 0x8466ed62, 0x979e8d91, 0x6592806f, 0xb06e4c77, 0x42624189,
- 0x519a217a, 0xa3962c84, 0xc5e5b67a, 0x37e9bb84, 0x2411db77, 0xd61dd689,
- 0x03e11a91, 0xf1ed176f, 0xe215779c, 0x10197a62, 0x4c00995d, 0xbe0c94a3,
- 0xadf4f450, 0x5ff8f9ae, 0x8a0435b6, 0x78083848, 0x6bf058bb, 0x99fc5545,
- 0xd3c39ec5, 0x21cf933b, 0x3237f3c8, 0xc03bfe36, 0x15c7322e, 0xe7cb3fd0,
- 0xf4335f23, 0x063f52dd, 0x5a26b1e2, 0xa82abc1c, 0xbbd2dcef, 0x49ded111,
- 0x9c221d09, 0x6e2e10f7, 0x7dd67004, 0x8fda7dfa,
- },
- };
+ private int crc = 0;
- // Value x picked so computeForWord(x) == ~0, found by exhaustive search.
- static final int INVERSE_COMPUTE_FOR_WORD_OF_ALL_1S = 0xeee3ddcd;
-
- static int computeForWord(int word) {
- return STRIDE_TABLE[3][word & 0xFF]
- ^ STRIDE_TABLE[2][(word >>> 8) & 0xFF]
- ^ STRIDE_TABLE[1][(word >>> 16) & 0xFF]
- ^ STRIDE_TABLE[0][word >>> 24];
+ @Override
+ public void update(byte b) {
+ crc ^= 0xFFFFFFFF;
+ // See Hacker's Delight 2nd Edition, Figure 14-7.
+ crc = ~((crc >>> 8) ^ CRC_TABLE[(crc ^ b) & 0xFF]);
}
- static int combine(int csum, int crc) {
- csum ^= crc;
- for (int i = 0; i < 4; i++) {
- csum = (csum >>> 8) ^ BYTE_TABLE[csum & 0xFF];
- }
- return csum;
+ @Override
+ public HashCode hash() {
+ return HashCode.fromInt(crc);
}
-
- private static final ByteBuffer EMPTY = ByteBuffer.allocate(0);
}
}
diff --git a/android/guava/src/com/google/common/hash/ElementTypesAreNonnullByDefault.java b/android/guava/src/com/google/common/hash/ElementTypesAreNonnullByDefault.java
deleted file mode 100644
index a2382b3..0000000
--- a/android/guava/src/com/google/common/hash/ElementTypesAreNonnullByDefault.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) 2021 The Guava Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.common.hash;
-
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.PARAMETER;
-import static java.lang.annotation.ElementType.TYPE;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-import com.google.common.annotations.GwtCompatible;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-import javax.annotation.Nonnull;
-import javax.annotation.meta.TypeQualifierDefault;
-
-/**
- * Marks all "top-level" types as non-null in a way that is recognized by Kotlin. Note that this
- * unfortunately includes type-variable usages, so we also provide {@link ParametricNullness} to
- * "undo" it as best we can.
- */
-@GwtCompatible
-@Retention(RUNTIME)
-@Target(TYPE)
-@TypeQualifierDefault({FIELD, METHOD, PARAMETER})
-@Nonnull
-@interface ElementTypesAreNonnullByDefault {}
diff --git a/android/guava/src/com/google/common/hash/FarmHashFingerprint64.java b/android/guava/src/com/google/common/hash/FarmHashFingerprint64.java
index 7d6a398..30eab5f 100644
--- a/android/guava/src/com/google/common/hash/FarmHashFingerprint64.java
+++ b/android/guava/src/com/google/common/hash/FarmHashFingerprint64.java
@@ -38,7 +38,6 @@
* @author Kyle Maddison
* @author Geoff Pike
*/
-@ElementTypesAreNonnullByDefault
final class FarmHashFingerprint64 extends AbstractNonStreamingHashFunction {
static final HashFunction FARMHASH_FINGERPRINT_64 = new FarmHashFingerprint64();
diff --git a/android/guava/src/com/google/common/hash/Funnel.java b/android/guava/src/com/google/common/hash/Funnel.java
index 9d80dab..2c6a7b9 100644
--- a/android/guava/src/com/google/common/hash/Funnel.java
+++ b/android/guava/src/com/google/common/hash/Funnel.java
@@ -17,7 +17,6 @@
import com.google.common.annotations.Beta;
import com.google.errorprone.annotations.DoNotMock;
import java.io.Serializable;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* An object which can send data from an object of type {@code T} into a {@code PrimitiveSink}.
@@ -44,8 +43,7 @@
*/
@Beta
@DoNotMock("Implement with a lambda")
-@ElementTypesAreNonnullByDefault
-public interface Funnel<T extends @Nullable Object> extends Serializable {
+public interface Funnel<T> extends Serializable {
/**
* Sends a stream of data from the {@code from} object into the sink {@code into}. There is no
@@ -53,5 +51,5 @@
*
* @since 12.0 (in Guava 11.0, {@code PrimitiveSink} was named {@code Sink})
*/
- void funnel(@ParametricNullness T from, PrimitiveSink into);
+ void funnel(T from, PrimitiveSink into);
}
diff --git a/android/guava/src/com/google/common/hash/Funnels.java b/android/guava/src/com/google/common/hash/Funnels.java
index 6673836..afe60c1 100644
--- a/android/guava/src/com/google/common/hash/Funnels.java
+++ b/android/guava/src/com/google/common/hash/Funnels.java
@@ -19,8 +19,7 @@
import java.io.OutputStream;
import java.io.Serializable;
import java.nio.charset.Charset;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* Funnels for common types. All implementations are serializable.
@@ -29,7 +28,6 @@
* @since 11.0
*/
@Beta
-@ElementTypesAreNonnullByDefault
public final class Funnels {
private Funnels() {}
@@ -105,7 +103,7 @@
}
@Override
- public boolean equals(@CheckForNull Object o) {
+ public boolean equals(@NullableDecl Object o) {
if (o instanceof StringCharsetFunnel) {
StringCharsetFunnel funnel = (StringCharsetFunnel) o;
return this.charset.equals(funnel.charset);
@@ -166,13 +164,11 @@
*
* @since 15.0
*/
- public static <E extends @Nullable Object> Funnel<Iterable<? extends E>> sequentialFunnel(
- Funnel<E> elementFunnel) {
+ public static <E> Funnel<Iterable<? extends E>> sequentialFunnel(Funnel<E> elementFunnel) {
return new SequentialFunnel<E>(elementFunnel);
}
- private static class SequentialFunnel<E extends @Nullable Object>
- implements Funnel<Iterable<? extends E>>, Serializable {
+ private static class SequentialFunnel<E> implements Funnel<Iterable<? extends E>>, Serializable {
private final Funnel<E> elementFunnel;
SequentialFunnel(Funnel<E> elementFunnel) {
@@ -192,7 +188,7 @@
}
@Override
- public boolean equals(@CheckForNull Object o) {
+ public boolean equals(@NullableDecl Object o) {
if (o instanceof SequentialFunnel) {
SequentialFunnel<?> funnel = (SequentialFunnel<?>) o;
return elementFunnel.equals(funnel.elementFunnel);
diff --git a/android/guava/src/com/google/common/hash/HashCode.java b/android/guava/src/com/google/common/hash/HashCode.java
index fde2a86..560e41a 100644
--- a/android/guava/src/com/google/common/hash/HashCode.java
+++ b/android/guava/src/com/google/common/hash/HashCode.java
@@ -18,12 +18,13 @@
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkState;
+import com.google.common.annotations.Beta;
import com.google.common.base.Preconditions;
import com.google.common.primitives.Ints;
import com.google.common.primitives.UnsignedInts;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import java.io.Serializable;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* An immutable hash code of arbitrary bit length.
@@ -32,7 +33,7 @@
* @author Kurt Alfred Kluever
* @since 11.0
*/
-@ElementTypesAreNonnullByDefault
+@Beta
public abstract class HashCode {
HashCode() {}
@@ -368,7 +369,7 @@
* to protect against <a href="http://en.wikipedia.org/wiki/Timing_attack">timing attacks</a>.
*/
@Override
- public final boolean equals(@CheckForNull Object object) {
+ public final boolean equals(@NullableDecl Object object) {
if (object instanceof HashCode) {
HashCode that = (HashCode) object;
return bits() == that.bits() && equalsSameBits(that);
@@ -401,10 +402,10 @@
* Returns a string containing each byte of {@link #asBytes}, in order, as a two-digit unsigned
* hexadecimal number in lower case.
*
- * <p>Note that if the output is considered to be a single hexadecimal number, whether this string
- * is big-endian or little-endian depends on the byte order of {@link #asBytes}. This may be
- * surprising for implementations of {@code HashCode} that represent the number in big-endian
- * since everything else in the hashing API uniformly treats multibyte values as little-endian.
+ * <p>Note that if the output is considered to be a single hexadecimal number, this hash code's
+ * bytes are the <i>big-endian</i> representation of that number. This may be surprising since
+ * everything else in the hashing API uniformly treats multibyte values as little-endian. But this
+ * format conveniently matches that of utilities such as the UNIX {@code md5sum} command.
*
* <p>To create a {@code HashCode} from its string representation, see {@link #fromString}.
*/
diff --git a/android/guava/src/com/google/common/hash/HashFunction.java b/android/guava/src/com/google/common/hash/HashFunction.java
index d4b7f8a..7884259 100644
--- a/android/guava/src/com/google/common/hash/HashFunction.java
+++ b/android/guava/src/com/google/common/hash/HashFunction.java
@@ -14,11 +14,11 @@
package com.google.common.hash;
+import com.google.common.annotations.Beta;
import com.google.common.primitives.Ints;
import com.google.errorprone.annotations.Immutable;
import java.nio.ByteBuffer;
import java.nio.charset.Charset;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* A hash function is a collision-averse pure function that maps an arbitrary block of data to a
@@ -115,8 +115,8 @@
* @author Kevin Bourrillion
* @since 11.0
*/
+@Beta
@Immutable
-@ElementTypesAreNonnullByDefault
public interface HashFunction {
/**
* Begins a new hash code computation by returning an initialized, stateful {@code Hasher}
@@ -211,8 +211,7 @@
*
* @since 14.0
*/
- <T extends @Nullable Object> HashCode hashObject(
- @ParametricNullness T instance, Funnel<? super T> funnel);
+ <T> HashCode hashObject(T instance, Funnel<? super T> funnel);
/**
* Returns the number of bits (a multiple of 32) that each hash code produced by this hash
diff --git a/android/guava/src/com/google/common/hash/Hasher.java b/android/guava/src/com/google/common/hash/Hasher.java
index b3f24fa..ae9ae5f 100644
--- a/android/guava/src/com/google/common/hash/Hasher.java
+++ b/android/guava/src/com/google/common/hash/Hasher.java
@@ -18,7 +18,6 @@
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import java.nio.ByteBuffer;
import java.nio.charset.Charset;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* A {@link PrimitiveSink} that can compute a hash code after reading the input. Each hasher should
@@ -55,7 +54,6 @@
*/
@Beta
@CanIgnoreReturnValue
-@ElementTypesAreNonnullByDefault
public interface Hasher extends PrimitiveSink {
@Override
Hasher putByte(byte b);
@@ -121,8 +119,7 @@
Hasher putString(CharSequence charSequence, Charset charset);
/** A simple convenience for {@code funnel.funnel(object, this)}. */
- <T extends @Nullable Object> Hasher putObject(
- @ParametricNullness T instance, Funnel<? super T> funnel);
+ <T> Hasher putObject(T instance, Funnel<? super T> funnel);
/**
* Computes a hash code based on the data that have been provided to this hasher. The result is
diff --git a/android/guava/src/com/google/common/hash/Hashing.java b/android/guava/src/com/google/common/hash/Hashing.java
index dd65367..01480a2 100644
--- a/android/guava/src/com/google/common/hash/Hashing.java
+++ b/android/guava/src/com/google/common/hash/Hashing.java
@@ -27,8 +27,8 @@
import java.util.zip.Adler32;
import java.util.zip.CRC32;
import java.util.zip.Checksum;
-import javax.annotation.CheckForNull;
import javax.crypto.spec.SecretKeySpec;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* Static methods to obtain {@link HashFunction} instances, and other static hashing-related
@@ -43,7 +43,6 @@
* @since 11.0
*/
@Beta
-@ElementTypesAreNonnullByDefault
public final class Hashing {
/**
* Returns a general-purpose, <b>temporary-use</b>, non-cryptographic hash function. The algorithm
@@ -94,53 +93,12 @@
/**
* Returns a hash function implementing the <a
* href="https://github.com/aappleby/smhasher/blob/master/src/MurmurHash3.cpp">32-bit murmur3
- * algorithm, x86 variant</a> (little-endian variant), using the given seed value, <b>with a known
- * bug</b> as described in the deprecation text.
- *
- * <p>The C++ equivalent is the MurmurHash3_x86_32 function (Murmur3A), which however does not
- * have the bug.
- *
- * @deprecated This implementation produces incorrect hash values from the {@link
- * HashFunction#hashString} method if the string contains non-BMP characters. Use {@link
- * #murmur3_32_fixed(int)} instead.
- */
- @Deprecated
- public static HashFunction murmur3_32(int seed) {
- return new Murmur3_32HashFunction(seed, /* supplementaryPlaneFix= */ false);
- }
-
- /**
- * Returns a hash function implementing the <a
- * href="https://github.com/aappleby/smhasher/blob/master/src/MurmurHash3.cpp">32-bit murmur3
- * algorithm, x86 variant</a> (little-endian variant), using the given seed value, <b>with a known
- * bug</b> as described in the deprecation text.
- *
- * <p>The C++ equivalent is the MurmurHash3_x86_32 function (Murmur3A), which however does not
- * have the bug.
- *
- * @deprecated This implementation produces incorrect hash values from the {@link
- * HashFunction#hashString} method if the string contains non-BMP characters. Use {@link
- * #murmur3_32_fixed()} instead.
- */
- @Deprecated
- public static HashFunction murmur3_32() {
- return Murmur3_32HashFunction.MURMUR3_32;
- }
-
- /**
- * Returns a hash function implementing the <a
- * href="https://github.com/aappleby/smhasher/blob/master/src/MurmurHash3.cpp">32-bit murmur3
* algorithm, x86 variant</a> (little-endian variant), using the given seed value.
*
* <p>The exact C++ equivalent is the MurmurHash3_x86_32 function (Murmur3A).
- *
- * <p>This method is called {@code murmur3_32_fixed} because it fixes a bug in the {@code
- * HashFunction} returned by the original {@code murmur3_32} method.
- *
- * @since 31.0
*/
- public static HashFunction murmur3_32_fixed(int seed) {
- return new Murmur3_32HashFunction(seed, /* supplementaryPlaneFix= */ true);
+ public static HashFunction murmur3_32(int seed) {
+ return new Murmur3_32HashFunction(seed);
}
/**
@@ -149,14 +107,9 @@
* algorithm, x86 variant</a> (little-endian variant), using a seed value of zero.
*
* <p>The exact C++ equivalent is the MurmurHash3_x86_32 function (Murmur3A).
- *
- * <p>This method is called {@code murmur3_32_fixed} because it fixes a bug in the {@code
- * HashFunction} returned by the original {@code murmur3_32} method.
- *
- * @since 31.0
*/
- public static HashFunction murmur3_32_fixed() {
- return Murmur3_32HashFunction.MURMUR3_32_FIXED;
+ public static HashFunction murmur3_32() {
+ return Murmur3_32HashFunction.MURMUR3_32;
}
/**
@@ -281,6 +234,7 @@
* Returns a hash function implementing the Message Authentication Code (MAC) algorithm, using the
* MD5 (128 hash bits) hash function and the given secret key.
*
+ *
* @param key the secret key
* @throws IllegalArgumentException if the given key is inappropriate for initializing this MAC
* @since 20.0
@@ -294,6 +248,7 @@
* MD5 (128 hash bits) hash function and a {@link SecretKeySpec} created from the given byte array
* and the MD5 algorithm.
*
+ *
* @param key the key material of the secret key
* @since 20.0
*/
@@ -305,6 +260,7 @@
* Returns a hash function implementing the Message Authentication Code (MAC) algorithm, using the
* SHA-1 (160 hash bits) hash function and the given secret key.
*
+ *
* @param key the secret key
* @throws IllegalArgumentException if the given key is inappropriate for initializing this MAC
* @since 20.0
@@ -318,6 +274,7 @@
* SHA-1 (160 hash bits) hash function and a {@link SecretKeySpec} created from the given byte
* array and the SHA-1 algorithm.
*
+ *
* @param key the key material of the secret key
* @since 20.0
*/
@@ -329,6 +286,7 @@
* Returns a hash function implementing the Message Authentication Code (MAC) algorithm, using the
* SHA-256 (256 hash bits) hash function and the given secret key.
*
+ *
* @param key the secret key
* @throws IllegalArgumentException if the given key is inappropriate for initializing this MAC
* @since 20.0
@@ -342,6 +300,7 @@
* SHA-256 (256 hash bits) hash function and a {@link SecretKeySpec} created from the given byte
* array and the SHA-256 algorithm.
*
+ *
* @param key the key material of the secret key
* @since 20.0
*/
@@ -353,6 +312,7 @@
* Returns a hash function implementing the Message Authentication Code (MAC) algorithm, using the
* SHA-512 (512 hash bits) hash function and the given secret key.
*
+ *
* @param key the secret key
* @throws IllegalArgumentException if the given key is inappropriate for initializing this MAC
* @since 20.0
@@ -366,6 +326,7 @@
* SHA-512 (512 hash bits) hash function and a {@link SecretKeySpec} created from the given byte
* array and the SHA-512 algorithm.
*
+ *
* @param key the key material of the secret key
* @since 20.0
*/
@@ -496,6 +457,7 @@
* traffic to {@code charlie}, rather than letting {@code bravo} keep its traffic.
* </ul>
*
+ *
* <p>See the <a href="http://en.wikipedia.org/wiki/Consistent_hashing">Wikipedia article on
* consistent hashing</a> for more information.
*/
@@ -530,6 +492,7 @@
* traffic to {@code charlie}, rather than letting {@code bravo} keep its traffic.
* </ul>
*
+ *
* <p>See the <a href="http://en.wikipedia.org/wiki/Consistent_hashing">Wikipedia article on
* consistent hashing</a> for more information.
*/
@@ -680,7 +643,7 @@
}
@Override
- public boolean equals(@CheckForNull Object object) {
+ public boolean equals(@NullableDecl Object object) {
if (object instanceof ConcatenatedHashFunction) {
ConcatenatedHashFunction other = (ConcatenatedHashFunction) object;
return Arrays.equals(functions, other.functions);
diff --git a/android/guava/src/com/google/common/hash/HashingInputStream.java b/android/guava/src/com/google/common/hash/HashingInputStream.java
index bf9464c..f49dfd6 100644
--- a/android/guava/src/com/google/common/hash/HashingInputStream.java
+++ b/android/guava/src/com/google/common/hash/HashingInputStream.java
@@ -29,7 +29,6 @@
* @since 16.0
*/
@Beta
-@ElementTypesAreNonnullByDefault
public final class HashingInputStream extends FilterInputStream {
private final Hasher hasher;
diff --git a/android/guava/src/com/google/common/hash/HashingOutputStream.java b/android/guava/src/com/google/common/hash/HashingOutputStream.java
index f138bba..7a1c8d8 100644
--- a/android/guava/src/com/google/common/hash/HashingOutputStream.java
+++ b/android/guava/src/com/google/common/hash/HashingOutputStream.java
@@ -28,7 +28,6 @@
* @since 16.0
*/
@Beta
-@ElementTypesAreNonnullByDefault
public final class HashingOutputStream extends FilterOutputStream {
private final Hasher hasher;
diff --git a/android/guava/src/com/google/common/hash/ImmutableSupplier.java b/android/guava/src/com/google/common/hash/ImmutableSupplier.java
index 24f711a..f90352a 100644
--- a/android/guava/src/com/google/common/hash/ImmutableSupplier.java
+++ b/android/guava/src/com/google/common/hash/ImmutableSupplier.java
@@ -21,7 +21,5 @@
* Explicitly named subinterface of {@link Supplier} that can be marked {@literal @}{@link
* Immutable}.
*/
-// TODO(cpovirk): Should we just use ChecksumType directly instead of defining this type?
@Immutable
-@ElementTypesAreNonnullByDefault
interface ImmutableSupplier<T> extends Supplier<T> {}
diff --git a/android/guava/src/com/google/common/hash/Java8Compatibility.java b/android/guava/src/com/google/common/hash/Java8Compatibility.java
index c15f2b3..52f71e7 100644
--- a/android/guava/src/com/google/common/hash/Java8Compatibility.java
+++ b/android/guava/src/com/google/common/hash/Java8Compatibility.java
@@ -22,7 +22,6 @@
* https://github.com/google/guava/issues/3990
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
final class Java8Compatibility {
static void clear(Buffer b) {
b.clear();
diff --git a/android/guava/src/com/google/common/hash/LittleEndianByteArray.java b/android/guava/src/com/google/common/hash/LittleEndianByteArray.java
index 15d8b2c..22ef4f0 100644
--- a/android/guava/src/com/google/common/hash/LittleEndianByteArray.java
+++ b/android/guava/src/com/google/common/hash/LittleEndianByteArray.java
@@ -24,7 +24,6 @@
* @author Kevin Damm
* @author Kyle Maddison
*/
-@ElementTypesAreNonnullByDefault
final class LittleEndianByteArray {
/** The instance that actually does the work; delegates to Unsafe or a pure-Java fallback. */
diff --git a/android/guava/src/com/google/common/hash/LongAddable.java b/android/guava/src/com/google/common/hash/LongAddable.java
index 5c6a7f0..a95eece 100644
--- a/android/guava/src/com/google/common/hash/LongAddable.java
+++ b/android/guava/src/com/google/common/hash/LongAddable.java
@@ -14,13 +14,11 @@
package com.google.common.hash;
-
/**
* Abstract interface for objects that can concurrently add longs.
*
* @author Louis Wasserman
*/
-@ElementTypesAreNonnullByDefault
interface LongAddable {
void increment();
diff --git a/android/guava/src/com/google/common/hash/LongAddables.java b/android/guava/src/com/google/common/hash/LongAddables.java
index 370030d..d2768bc 100644
--- a/android/guava/src/com/google/common/hash/LongAddables.java
+++ b/android/guava/src/com/google/common/hash/LongAddables.java
@@ -22,7 +22,6 @@
*
* @author Louis Wasserman
*/
-@ElementTypesAreNonnullByDefault
final class LongAddables {
private static final Supplier<LongAddable> SUPPLIER;
diff --git a/android/guava/src/com/google/common/hash/LongAdder.java b/android/guava/src/com/google/common/hash/LongAdder.java
index dc864aa..bd08428 100644
--- a/android/guava/src/com/google/common/hash/LongAdder.java
+++ b/android/guava/src/com/google/common/hash/LongAdder.java
@@ -38,7 +38,6 @@
* @since 1.8
* @author Doug Lea
*/
-@ElementTypesAreNonnullByDefault
final class LongAdder extends Striped64 implements Serializable, LongAddable {
private static final long serialVersionUID = 7249069246863182397L;
diff --git a/android/guava/src/com/google/common/hash/MacHashFunction.java b/android/guava/src/com/google/common/hash/MacHashFunction.java
index 031b1c0..ed1841c 100644
--- a/android/guava/src/com/google/common/hash/MacHashFunction.java
+++ b/android/guava/src/com/google/common/hash/MacHashFunction.java
@@ -30,7 +30,6 @@
* @author Kurt Alfred Kluever
*/
@Immutable
-@ElementTypesAreNonnullByDefault
final class MacHashFunction extends AbstractHashFunction {
@SuppressWarnings("Immutable") // cloned before each use
diff --git a/android/guava/src/com/google/common/hash/MessageDigestHashFunction.java b/android/guava/src/com/google/common/hash/MessageDigestHashFunction.java
index 48b47b0..5c48c7d 100644
--- a/android/guava/src/com/google/common/hash/MessageDigestHashFunction.java
+++ b/android/guava/src/com/google/common/hash/MessageDigestHashFunction.java
@@ -32,7 +32,6 @@
* @author Dimitris Andreou
*/
@Immutable
-@ElementTypesAreNonnullByDefault
final class MessageDigestHashFunction extends AbstractHashFunction implements Serializable {
@SuppressWarnings("Immutable") // cloned before each use
diff --git a/android/guava/src/com/google/common/hash/Murmur3_128HashFunction.java b/android/guava/src/com/google/common/hash/Murmur3_128HashFunction.java
index d1304f8..4403b20 100644
--- a/android/guava/src/com/google/common/hash/Murmur3_128HashFunction.java
+++ b/android/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 javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* See MurmurHash3_x64_128 in <a href="http://smhasher.googlecode.com/svn/trunk/MurmurHash3.cpp">the
@@ -41,7 +41,6 @@
* @author Dimitris Andreou
*/
@Immutable
-@ElementTypesAreNonnullByDefault
final class Murmur3_128HashFunction extends AbstractHashFunction implements Serializable {
static final HashFunction MURMUR3_128 = new Murmur3_128HashFunction(0);
@@ -71,7 +70,7 @@
}
@Override
- public boolean equals(@CheckForNull Object object) {
+ public boolean equals(@NullableDecl Object object) {
if (object instanceof Murmur3_128HashFunction) {
Murmur3_128HashFunction other = (Murmur3_128HashFunction) object;
return seed == other.seed;
diff --git a/android/guava/src/com/google/common/hash/Murmur3_32HashFunction.java b/android/guava/src/com/google/common/hash/Murmur3_32HashFunction.java
index a47184b..373117e 100644
--- a/android/guava/src/com/google/common/hash/Murmur3_32HashFunction.java
+++ b/android/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 javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* See MurmurHash3_x86_32 in <a
@@ -51,17 +51,11 @@
* @author Kurt Alfred Kluever
*/
@Immutable
-@ElementTypesAreNonnullByDefault
final class Murmur3_32HashFunction extends AbstractHashFunction implements Serializable {
- static final HashFunction MURMUR3_32 =
- new Murmur3_32HashFunction(0, /* supplementaryPlaneFix= */ false);
- static final HashFunction MURMUR3_32_FIXED =
- new Murmur3_32HashFunction(0, /* supplementaryPlaneFix= */ true);
+ static final HashFunction MURMUR3_32 = new Murmur3_32HashFunction(0);
- // We can include the non-BMP fix here because Hashing.goodFastHash stresses that the hash is a
- // temporary-use one. Therefore it shouldn't be persisted.
static final HashFunction GOOD_FAST_HASH_32 =
- new Murmur3_32HashFunction(Hashing.GOOD_FAST_HASH_SEED, /* supplementaryPlaneFix= */ true);
+ new Murmur3_32HashFunction(Hashing.GOOD_FAST_HASH_SEED);
private static final int CHUNK_SIZE = 4;
@@ -69,11 +63,9 @@
private static final int C2 = 0x1b873593;
private final int seed;
- private final boolean supplementaryPlaneFix;
- Murmur3_32HashFunction(int seed, boolean supplementaryPlaneFix) {
+ Murmur3_32HashFunction(int seed) {
this.seed = seed;
- this.supplementaryPlaneFix = supplementaryPlaneFix;
}
@Override
@@ -92,10 +84,10 @@
}
@Override
- public boolean equals(@CheckForNull Object object) {
+ public boolean equals(@NullableDecl Object object) {
if (object instanceof Murmur3_32HashFunction) {
Murmur3_32HashFunction other = (Murmur3_32HashFunction) object;
- return seed == other.seed && supplementaryPlaneFix == other.supplementaryPlaneFix;
+ return seed == other.seed;
}
return false;
}
@@ -198,9 +190,6 @@
}
i++;
buffer |= codePointToFourUtf8Bytes(codePoint) << shift;
- if (supplementaryPlaneFix) { // bug compatibility: earlier versions did not have this add
- shift += 32;
- }
len += 4;
}
@@ -402,22 +391,20 @@
}
private static long codePointToFourUtf8Bytes(int codePoint) {
- // codePoint has at most 21 bits
- return ((0xFL << 4) | (codePoint >>> 18))
+ return (((0xFL << 4) | (codePoint >>> 18)) & 0xFF)
| ((0x80L | (0x3F & (codePoint >>> 12))) << 8)
| ((0x80L | (0x3F & (codePoint >>> 6))) << 16)
| ((0x80L | (0x3F & codePoint)) << 24);
}
private static long charToThreeUtf8Bytes(char c) {
- return ((0x7L << 5) | (c >>> 12))
+ return (((0xF << 5) | (c >>> 12)) & 0xFF)
| ((0x80 | (0x3F & (c >>> 6))) << 8)
| ((0x80 | (0x3F & c)) << 16);
}
private static long charToTwoUtf8Bytes(char c) {
- // c has at most 11 bits
- return ((0x3L << 6) | (c >>> 6)) | ((0x80 | (0x3F & c)) << 8);
+ return (((0xF << 6) | (c >>> 6)) & 0xFF) | ((0x80 | (0x3F & c)) << 8);
}
private static final long serialVersionUID = 0L;
diff --git a/android/guava/src/com/google/common/hash/ParametricNullness.java b/android/guava/src/com/google/common/hash/ParametricNullness.java
deleted file mode 100644
index 2ae8d42..0000000
--- a/android/guava/src/com/google/common/hash/ParametricNullness.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2021 The Guava Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.common.hash;
-
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.PARAMETER;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-import static javax.annotation.meta.When.UNKNOWN;
-
-import com.google.common.annotations.GwtCompatible;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-import javax.annotation.Nonnull;
-import javax.annotation.meta.TypeQualifierNickname;
-
-/**
- * Marks a "top-level" type-variable usage as (a) a Kotlin platform type when the type argument is
- * non-nullable and (b) nullable when the type argument is nullable. This is the closest we can get
- * to "non-nullable when non-nullable; nullable when nullable" (like the Android <a
- * href="https://android.googlesource.com/platform/libcore/+/master/luni/src/main/java/libcore/util/NullFromTypeParam.java">{@code
- * NullFromTypeParam}</a>). We use this to "undo" {@link ElementTypesAreNonnullByDefault}.
- */
-@GwtCompatible
-@Retention(RUNTIME)
-@Target({FIELD, METHOD, PARAMETER})
-@TypeQualifierNickname
-@Nonnull(when = UNKNOWN)
-@interface ParametricNullness {}
diff --git a/android/guava/src/com/google/common/hash/PrimitiveSink.java b/android/guava/src/com/google/common/hash/PrimitiveSink.java
index a29ba4e..ffeb8fd 100644
--- a/android/guava/src/com/google/common/hash/PrimitiveSink.java
+++ b/android/guava/src/com/google/common/hash/PrimitiveSink.java
@@ -27,7 +27,6 @@
*/
@Beta
@CanIgnoreReturnValue
-@ElementTypesAreNonnullByDefault
public interface PrimitiveSink {
/**
* Puts a byte into this sink.
diff --git a/android/guava/src/com/google/common/hash/SipHashFunction.java b/android/guava/src/com/google/common/hash/SipHashFunction.java
index a226b61..546fae2 100644
--- a/android/guava/src/com/google/common/hash/SipHashFunction.java
+++ b/android/guava/src/com/google/common/hash/SipHashFunction.java
@@ -24,7 +24,7 @@
import com.google.errorprone.annotations.Immutable;
import java.io.Serializable;
import java.nio.ByteBuffer;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* {@link HashFunction} implementation of SipHash-c-d.
@@ -34,7 +34,6 @@
* @author Daniel J. Bernstein
*/
@Immutable
-@ElementTypesAreNonnullByDefault
final class SipHashFunction extends AbstractHashFunction implements Serializable {
static final HashFunction SIP_HASH_24 =
new SipHashFunction(2, 4, 0x0706050403020100L, 0x0f0e0d0c0b0a0908L);
@@ -82,7 +81,7 @@
}
@Override
- public boolean equals(@CheckForNull Object object) {
+ public boolean equals(@NullableDecl Object object) {
if (object instanceof SipHashFunction) {
SipHashFunction other = (SipHashFunction) object;
return (c == other.c) && (d == other.d) && (k0 == other.k0) && (k1 == other.k1);
diff --git a/android/guava/src/com/google/common/hash/Striped64.java b/android/guava/src/com/google/common/hash/Striped64.java
index 1a0671c..9542bef 100644
--- a/android/guava/src/com/google/common/hash/Striped64.java
+++ b/android/guava/src/com/google/common/hash/Striped64.java
@@ -13,8 +13,7 @@
import com.google.common.annotations.GwtIncompatible;
import java.util.Random;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* A package-local class holding common representation and mechanics for classes supporting dynamic
@@ -22,7 +21,6 @@
* so.
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
abstract class Striped64 extends Number {
/*
* This class maintains a lazily-initialized table of atomically
@@ -127,7 +125,7 @@
* class, we use a suboptimal int[] representation to avoid introducing a new type that can impede
* class-unloading when ThreadLocals are not removed.
*/
- static final ThreadLocal<int @Nullable []> threadHashCode = new ThreadLocal<>();
+ static final ThreadLocal<int[]> threadHashCode = new ThreadLocal<>();
/** Generator of new random hash codes */
static final Random rng = new Random();
@@ -136,7 +134,7 @@
static final int NCPU = Runtime.getRuntime().availableProcessors();
/** Table of cells. When non-null, size is a power of 2. */
- @CheckForNull transient volatile Cell[] cells;
+ @NullableDecl transient volatile Cell[] cells;
/**
* Base value, used mainly when there is no contention, but also as a fallback during table
@@ -179,7 +177,7 @@
* @param hc the hash code holder
* @param wasUncontended false if CAS failed before call
*/
- final void retryUpdate(long x, @CheckForNull int[] hc, boolean wasUncontended) {
+ final void retryUpdate(long x, @NullableDecl int[] hc, boolean wasUncontended) {
int h;
if (hc == null) {
threadHashCode.set(hc = new int[1]); // Initialize randomly
diff --git a/android/guava/src/com/google/common/html/ElementTypesAreNonnullByDefault.java b/android/guava/src/com/google/common/html/ElementTypesAreNonnullByDefault.java
deleted file mode 100644
index a28b716..0000000
--- a/android/guava/src/com/google/common/html/ElementTypesAreNonnullByDefault.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) 2021 The Guava Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.common.html;
-
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.PARAMETER;
-import static java.lang.annotation.ElementType.TYPE;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-import com.google.common.annotations.GwtCompatible;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-import javax.annotation.Nonnull;
-import javax.annotation.meta.TypeQualifierDefault;
-
-/**
- * Marks all "top-level" types as non-null in a way that is recognized by Kotlin. Note that this
- * unfortunately includes type-variable usages, so we also provide {@link ParametricNullness} to
- * "undo" it as best we can.
- */
-@GwtCompatible
-@Retention(RUNTIME)
-@Target(TYPE)
-@TypeQualifierDefault({FIELD, METHOD, PARAMETER})
-@Nonnull
-@interface ElementTypesAreNonnullByDefault {}
diff --git a/android/guava/src/com/google/common/html/HtmlEscapers.java b/android/guava/src/com/google/common/html/HtmlEscapers.java
old mode 100644
new mode 100755
index c426388..29eebe8
--- a/android/guava/src/com/google/common/html/HtmlEscapers.java
+++ b/android/guava/src/com/google/common/html/HtmlEscapers.java
@@ -35,7 +35,6 @@
* @since 15.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
public final class HtmlEscapers {
/**
* Returns an {@link Escaper} instance that escapes HTML metacharacters as specified by <a
diff --git a/android/guava/src/com/google/common/html/ParametricNullness.java b/android/guava/src/com/google/common/html/ParametricNullness.java
deleted file mode 100644
index 9a62c35..0000000
--- a/android/guava/src/com/google/common/html/ParametricNullness.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2021 The Guava Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.common.html;
-
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.PARAMETER;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-import static javax.annotation.meta.When.UNKNOWN;
-
-import com.google.common.annotations.GwtCompatible;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-import javax.annotation.Nonnull;
-import javax.annotation.meta.TypeQualifierNickname;
-
-/**
- * Marks a "top-level" type-variable usage as (a) a Kotlin platform type when the type argument is
- * non-nullable and (b) nullable when the type argument is nullable. This is the closest we can get
- * to "non-nullable when non-nullable; nullable when nullable" (like the Android <a
- * href="https://android.googlesource.com/platform/libcore/+/master/luni/src/main/java/libcore/util/NullFromTypeParam.java">{@code
- * NullFromTypeParam}</a>). We use this to "undo" {@link ElementTypesAreNonnullByDefault}.
- */
-@GwtCompatible
-@Retention(RUNTIME)
-@Target({FIELD, METHOD, PARAMETER})
-@TypeQualifierNickname
-@Nonnull(when = UNKNOWN)
-@interface ParametricNullness {}
diff --git a/android/guava/src/com/google/common/html/package-info.java b/android/guava/src/com/google/common/html/package-info.java
old mode 100644
new mode 100755
diff --git a/android/guava/src/com/google/common/io/AppendableWriter.java b/android/guava/src/com/google/common/io/AppendableWriter.java
index d9aab34..6090bd3 100644
--- a/android/guava/src/com/google/common/io/AppendableWriter.java
+++ b/android/guava/src/com/google/common/io/AppendableWriter.java
@@ -21,7 +21,7 @@
import java.io.Flushable;
import java.io.IOException;
import java.io.Writer;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* Writer that places all output on an {@link Appendable} target. If the target is {@link Flushable}
@@ -32,7 +32,6 @@
* @since 1.0
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
class AppendableWriter extends Writer {
private final Appendable target;
private boolean closed;
@@ -69,15 +68,13 @@
}
@Override
- public void write(String str) throws IOException {
- checkNotNull(str);
+ public void write(@NullableDecl String str) throws IOException {
checkNotClosed();
target.append(str);
}
@Override
- public void write(String str, int off, int len) throws IOException {
- checkNotNull(str);
+ public void write(@NullableDecl String str, int off, int len) throws IOException {
checkNotClosed();
// tricky: append takes start, end pair...
target.append(str, off, off + len);
@@ -107,14 +104,14 @@
}
@Override
- public Writer append(@CheckForNull CharSequence charSeq) throws IOException {
+ public Writer append(@NullableDecl CharSequence charSeq) throws IOException {
checkNotClosed();
target.append(charSeq);
return this;
}
@Override
- public Writer append(@CheckForNull CharSequence charSeq, int start, int end) throws IOException {
+ public Writer append(@NullableDecl CharSequence charSeq, int start, int end) throws IOException {
checkNotClosed();
target.append(charSeq, start, end);
return this;
diff --git a/android/guava/src/com/google/common/io/BaseEncoding.java b/android/guava/src/com/google/common/io/BaseEncoding.java
index f42857c..f926c17 100644
--- a/android/guava/src/com/google/common/io/BaseEncoding.java
+++ b/android/guava/src/com/google/common/io/BaseEncoding.java
@@ -35,7 +35,7 @@
import java.io.Reader;
import java.io.Writer;
import java.util.Arrays;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* A binary encoding scheme for reversibly translating between byte sequences and printable ASCII
@@ -122,7 +122,6 @@
* @since 14.0
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
public abstract class BaseEncoding {
// TODO(lowasser): consider making encodeTo(Appendable, byte[], int, int) public.
@@ -191,10 +190,11 @@
private static byte[] extract(byte[] result, int length) {
if (length == result.length) {
return result;
+ } else {
+ byte[] trunc = new byte[length];
+ System.arraycopy(result, 0, trunc, 0, length);
+ return trunc;
}
- byte[] trunc = new byte[length];
- System.arraycopy(result, 0, trunc, 0, length);
- return trunc;
}
/**
@@ -226,8 +226,7 @@
*
* @throws DecodingException if the input is not a valid encoded string according to this
* encoding.
- */
- final byte[] decodeChecked(CharSequence chars)
+ */ final byte[] decodeChecked(CharSequence chars)
throws DecodingException {
chars = trimTrailingPadding(chars);
byte[] tmp = new byte[maxDecodedSize(chars.length())];
@@ -517,25 +516,27 @@
Alphabet upperCase() {
if (!hasLowerCase()) {
return this;
+ } else {
+ checkState(!hasUpperCase(), "Cannot call upperCase() on a mixed-case alphabet");
+ char[] upperCased = new char[chars.length];
+ for (int i = 0; i < chars.length; i++) {
+ upperCased[i] = Ascii.toUpperCase(chars[i]);
+ }
+ return new Alphabet(name + ".upperCase()", upperCased);
}
- checkState(!hasUpperCase(), "Cannot call upperCase() on a mixed-case alphabet");
- char[] upperCased = new char[chars.length];
- for (int i = 0; i < chars.length; i++) {
- upperCased[i] = Ascii.toUpperCase(chars[i]);
- }
- return new Alphabet(name + ".upperCase()", upperCased);
}
Alphabet lowerCase() {
if (!hasUpperCase()) {
return this;
+ } else {
+ checkState(!hasLowerCase(), "Cannot call lowerCase() on a mixed-case alphabet");
+ char[] lowerCased = new char[chars.length];
+ for (int i = 0; i < chars.length; i++) {
+ lowerCased[i] = Ascii.toLowerCase(chars[i]);
+ }
+ return new Alphabet(name + ".lowerCase()", lowerCased);
}
- checkState(!hasLowerCase(), "Cannot call lowerCase() on a mixed-case alphabet");
- char[] lowerCased = new char[chars.length];
- for (int i = 0; i < chars.length; i++) {
- lowerCased[i] = Ascii.toLowerCase(chars[i]);
- }
- return new Alphabet(name + ".lowerCase()", lowerCased);
}
public boolean matches(char c) {
@@ -548,7 +549,7 @@
}
@Override
- public boolean equals(@CheckForNull Object other) {
+ public boolean equals(@NullableDecl Object other) {
if (other instanceof Alphabet) {
Alphabet that = (Alphabet) other;
return Arrays.equals(this.chars, that.chars);
@@ -566,13 +567,13 @@
// TODO(lowasser): provide a useful toString
final Alphabet alphabet;
- @CheckForNull final Character paddingChar;
+ @NullableDecl final Character paddingChar;
- StandardBaseEncoding(String name, String alphabetChars, @CheckForNull Character paddingChar) {
+ StandardBaseEncoding(String name, String alphabetChars, @NullableDecl Character paddingChar) {
this(new Alphabet(name, alphabetChars.toCharArray()), paddingChar);
}
- StandardBaseEncoding(Alphabet alphabet, @CheckForNull Character paddingChar) {
+ StandardBaseEncoding(Alphabet alphabet, @NullableDecl Character paddingChar) {
this.alphabet = checkNotNull(alphabet);
checkArgument(
paddingChar == null || !alphabet.matches(paddingChar),
@@ -830,8 +831,8 @@
return new SeparatedBaseEncoding(this, separator, afterEveryChars);
}
- @LazyInit @CheckForNull private transient BaseEncoding upperCase;
- @LazyInit @CheckForNull private transient BaseEncoding lowerCase;
+ @LazyInit @NullableDecl private transient BaseEncoding upperCase;
+ @LazyInit @NullableDecl private transient BaseEncoding lowerCase;
@Override
public BaseEncoding upperCase() {
@@ -853,7 +854,7 @@
return result;
}
- BaseEncoding newInstance(Alphabet alphabet, @CheckForNull Character paddingChar) {
+ BaseEncoding newInstance(Alphabet alphabet, @NullableDecl Character paddingChar) {
return new StandardBaseEncoding(alphabet, paddingChar);
}
@@ -872,7 +873,7 @@
}
@Override
- public boolean equals(@CheckForNull Object other) {
+ public boolean equals(@NullableDecl Object other) {
if (other instanceof StandardBaseEncoding) {
StandardBaseEncoding that = (StandardBaseEncoding) other;
return this.alphabet.equals(that.alphabet)
@@ -929,17 +930,17 @@
}
@Override
- BaseEncoding newInstance(Alphabet alphabet, @CheckForNull Character paddingChar) {
+ BaseEncoding newInstance(Alphabet alphabet, @NullableDecl Character paddingChar) {
return new Base16Encoding(alphabet);
}
}
static final class Base64Encoding extends StandardBaseEncoding {
- Base64Encoding(String name, String alphabetChars, @CheckForNull Character paddingChar) {
+ Base64Encoding(String name, String alphabetChars, @NullableDecl Character paddingChar) {
this(new Alphabet(name, alphabetChars.toCharArray()), paddingChar);
}
- private Base64Encoding(Alphabet alphabet, @CheckForNull Character paddingChar) {
+ private Base64Encoding(Alphabet alphabet, @NullableDecl Character paddingChar) {
super(alphabet, paddingChar);
checkArgument(alphabet.chars.length == 64);
}
@@ -986,7 +987,7 @@
}
@Override
- BaseEncoding newInstance(Alphabet alphabet, @CheckForNull Character paddingChar) {
+ BaseEncoding newInstance(Alphabet alphabet, @NullableDecl Character paddingChar) {
return new Base64Encoding(alphabet, paddingChar);
}
}
@@ -1037,12 +1038,13 @@
}
@Override
- public Appendable append(@CheckForNull CharSequence chars, int off, int len) {
+ public Appendable append(@NullableDecl CharSequence chars, int off, int len)
+ throws IOException {
throw new UnsupportedOperationException();
}
@Override
- public Appendable append(@CheckForNull CharSequence chars) {
+ public Appendable append(@NullableDecl CharSequence chars) throws IOException {
throw new UnsupportedOperationException();
}
};
diff --git a/android/guava/src/com/google/common/io/ByteArrayDataInput.java b/android/guava/src/com/google/common/io/ByteArrayDataInput.java
index cf84fcc..bef1431 100644
--- a/android/guava/src/com/google/common/io/ByteArrayDataInput.java
+++ b/android/guava/src/com/google/common/io/ByteArrayDataInput.java
@@ -18,7 +18,6 @@
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import java.io.DataInput;
import java.io.IOException;
-import javax.annotation.CheckForNull;
/**
* An extension of {@code DataInput} for reading from in-memory byte arrays; its methods offer
@@ -33,7 +32,6 @@
* @since 1.0
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public interface ByteArrayDataInput extends DataInput {
@Override
void readFully(byte b[]);
@@ -88,7 +86,6 @@
@CanIgnoreReturnValue // to skip a line
@Override
- @CheckForNull
String readLine();
@CanIgnoreReturnValue // to skip a field
diff --git a/android/guava/src/com/google/common/io/ByteArrayDataOutput.java b/android/guava/src/com/google/common/io/ByteArrayDataOutput.java
index 3739073..e1ad6ab 100644
--- a/android/guava/src/com/google/common/io/ByteArrayDataOutput.java
+++ b/android/guava/src/com/google/common/io/ByteArrayDataOutput.java
@@ -26,7 +26,6 @@
* @since 1.0
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public interface ByteArrayDataOutput extends DataOutput {
@Override
void write(int b);
diff --git a/android/guava/src/com/google/common/io/ByteProcessor.java b/android/guava/src/com/google/common/io/ByteProcessor.java
index 98ea3ff..115c735 100644
--- a/android/guava/src/com/google/common/io/ByteProcessor.java
+++ b/android/guava/src/com/google/common/io/ByteProcessor.java
@@ -19,7 +19,6 @@
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import com.google.errorprone.annotations.DoNotMock;
import java.io.IOException;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* A callback interface to process bytes from a stream.
@@ -33,8 +32,7 @@
@Beta
@DoNotMock("Implement it normally")
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
-public interface ByteProcessor<T extends @Nullable Object> {
+public interface ByteProcessor<T> {
/**
* This method will be called for each chunk of bytes in an input stream. The implementation
* should process the bytes from {@code buf[off]} through {@code buf[off + len - 1]} (inclusive).
@@ -48,6 +46,5 @@
boolean processBytes(byte[] buf, int off, int len) throws IOException;
/** Return the result of processing all the bytes. */
- @ParametricNullness
T getResult();
}
diff --git a/android/guava/src/com/google/common/io/ByteSink.java b/android/guava/src/com/google/common/io/ByteSink.java
index 7a6af6f..ffba6e0 100644
--- a/android/guava/src/com/google/common/io/ByteSink.java
+++ b/android/guava/src/com/google/common/io/ByteSink.java
@@ -46,7 +46,6 @@
* @author Colin Decker
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public abstract class ByteSink {
/** Constructor for use by subclasses. */
diff --git a/android/guava/src/com/google/common/io/ByteSource.java b/android/guava/src/com/google/common/io/ByteSource.java
index c8da967..19f3a43 100644
--- a/android/guava/src/com/google/common/io/ByteSource.java
+++ b/android/guava/src/com/google/common/io/ByteSource.java
@@ -40,7 +40,6 @@
import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* A readable source of bytes, such as a file. Unlike an {@link InputStream}, a {@code ByteSource}
@@ -58,23 +57,10 @@
* doing something and finally closing the stream that was opened.
* </ul>
*
- * <p><b>Note:</b> In general, {@code ByteSource} is intended to be used for "file-like" sources
- * that provide streams that are:
- *
- * <ul>
- * <li><b>Finite:</b> Many operations, such as {@link #size()} and {@link #read()}, will either
- * block indefinitely or fail if the source creates an infinite stream.
- * <li><b>Non-destructive:</b> A <i>destructive</i> stream will consume or otherwise alter the
- * bytes of the source as they are read from it. A source that provides such streams will not
- * be reusable, and operations that read from the stream (including {@link #size()}, in some
- * implementations) will prevent further operations from completing as expected.
- * </ul>
- *
* @since 14.0
* @author Colin Decker
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public abstract class ByteSource {
/** Constructor for use by subclasses. */
@@ -316,7 +302,7 @@
*/
@Beta
@CanIgnoreReturnValue // some processors won't return a useful result
- public <T extends @Nullable Object> T read(ByteProcessor<T> processor) throws IOException {
+ public <T> T read(ByteProcessor<T> processor) throws IOException {
checkNotNull(processor);
Closer closer = Closer.create();
@@ -430,7 +416,7 @@
* Returns a view of the given byte array as a {@link ByteSource}. To view only a specific range
* in the array, use {@code ByteSource.wrap(b).slice(offset, length)}.
*
- * <p>Note that the given byte array may be passed directly to methods on, for example, {@code
+ * <p>Note that the given byte array may be be passed directly to methods on, for example, {@code
* OutputStream} (when {@code copyTo(OutputStream)} is called on the resulting {@code
* ByteSource}). This could allow a malicious {@code OutputStream} implementation to modify the
* contents of the array, but provides better performance in the normal case.
@@ -620,8 +606,7 @@
@SuppressWarnings("CheckReturnValue") // it doesn't matter what processBytes returns here
@Override
- @ParametricNullness
- public <T extends @Nullable Object> T read(ByteProcessor<T> processor) throws IOException {
+ public <T> T read(ByteProcessor<T> processor) throws IOException {
processor.processBytes(bytes, offset, length);
return processor.getResult();
}
diff --git a/android/guava/src/com/google/common/io/ByteStreams.java b/android/guava/src/com/google/common/io/ByteStreams.java
index 2f1f669..bdb24db 100644
--- a/android/guava/src/com/google/common/io/ByteStreams.java
+++ b/android/guava/src/com/google/common/io/ByteStreams.java
@@ -41,8 +41,6 @@
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Queue;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Provides utility methods for working with byte arrays and I/O streams.
@@ -52,7 +50,6 @@
* @since 1.0
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public final class ByteStreams {
private static final int BUFFER_SIZE = 8192;
@@ -441,7 +438,6 @@
}
@Override
- @CheckForNull
public String readLine() {
try {
return input.readLine();
@@ -873,9 +869,7 @@
*/
@Beta
@CanIgnoreReturnValue // some processors won't return a useful result
- @ParametricNullness
- public static <T extends @Nullable Object> T readBytes(
- InputStream input, ByteProcessor<T> processor) throws IOException {
+ public static <T> T readBytes(InputStream input, ByteProcessor<T> processor) throws IOException {
checkNotNull(input);
checkNotNull(processor);
diff --git a/android/guava/src/com/google/common/io/CharSequenceReader.java b/android/guava/src/com/google/common/io/CharSequenceReader.java
index 790e266..4cbeda1 100644
--- a/android/guava/src/com/google/common/io/CharSequenceReader.java
+++ b/android/guava/src/com/google/common/io/CharSequenceReader.java
@@ -17,13 +17,11 @@
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkPositionIndexes;
-import static java.util.Objects.requireNonNull;
import com.google.common.annotations.GwtIncompatible;
import java.io.IOException;
import java.io.Reader;
import java.nio.CharBuffer;
-import javax.annotation.CheckForNull;
/**
* A {@link Reader} that reads the characters in a {@link CharSequence}. Like {@code StringReader},
@@ -33,10 +31,9 @@
*/
// TODO(cgdecker): make this public? as a type, or a method in CharStreams?
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
final class CharSequenceReader extends Reader {
- @CheckForNull private CharSequence seq;
+ private CharSequence seq;
private int pos;
private int mark;
@@ -56,27 +53,13 @@
}
private int remaining() {
- requireNonNull(seq); // safe as long as we call this only after checkOpen
return seq.length() - pos;
}
- /*
- * To avoid the need to call requireNonNull so much, we could consider more clever approaches,
- * such as:
- *
- * - Make checkOpen return the non-null `seq`. Then callers can assign that to a local variable or
- * even back to `this.seq`. However, that may suggest that we're defending against concurrent
- * mutation, which is not an actual risk because we use `synchronized`.
- * - Make `remaining` require a non-null `seq` argument. But this is a bit weird because the
- * method, while it would avoid the instance field `seq` would still access the instance field
- * `pos`.
- */
-
@Override
public synchronized int read(CharBuffer target) throws IOException {
checkNotNull(target);
checkOpen();
- requireNonNull(seq); // safe because of checkOpen
if (!hasRemaining()) {
return -1;
}
@@ -90,7 +73,6 @@
@Override
public synchronized int read() throws IOException {
checkOpen();
- requireNonNull(seq); // safe because of checkOpen
return hasRemaining() ? seq.charAt(pos++) : -1;
}
@@ -98,7 +80,6 @@
public synchronized int read(char[] cbuf, int off, int len) throws IOException {
checkPositionIndexes(off, off + len, cbuf.length);
checkOpen();
- requireNonNull(seq); // safe because of checkOpen
if (!hasRemaining()) {
return -1;
}
diff --git a/android/guava/src/com/google/common/io/CharSink.java b/android/guava/src/com/google/common/io/CharSink.java
index bdf5f38..e615662 100644
--- a/android/guava/src/com/google/common/io/CharSink.java
+++ b/android/guava/src/com/google/common/io/CharSink.java
@@ -48,7 +48,6 @@
* @author Colin Decker
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public abstract class CharSink {
/** Constructor for use by subclasses. */
diff --git a/android/guava/src/com/google/common/io/CharSource.java b/android/guava/src/com/google/common/io/CharSource.java
index b7623ff..82110da 100644
--- a/android/guava/src/com/google/common/io/CharSource.java
+++ b/android/guava/src/com/google/common/io/CharSource.java
@@ -34,8 +34,7 @@
import java.nio.charset.Charset;
import java.util.Iterator;
import java.util.List;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* A readable source of characters, such as a text file. Unlike a {@link Reader}, a {@code
@@ -61,23 +60,10 @@
* <p>Any {@link ByteSource} containing text encoded with a specific {@linkplain Charset character
* encoding} may be viewed as a {@code CharSource} using {@link ByteSource#asCharSource(Charset)}.
*
- * <p><b>Note:</b> In general, {@code CharSource} is intended to be used for "file-like" sources
- * that provide readers that are:
- *
- * <ul>
- * <li><b>Finite:</b> Many operations, such as {@link #length()} and {@link #read()}, will either
- * block indefinitely or fail if the source creates an infinite reader.
- * <li><b>Non-destructive:</b> A <i>destructive</i> reader will consume or otherwise alter the
- * source as they are read from it. A source that provides such readers will not be reusable,
- * and operations that read from the stream (including {@link #length()}, in some
- * implementations) will prevent further operations from completing as expected.
- * </ul>
- *
* @since 14.0
* @author Colin Decker
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public abstract class CharSource {
/** Constructor for use by subclasses. */
@@ -262,7 +248,7 @@
*
* @throws IOException if an I/O error occurs while reading from this source
*/
- @CheckForNull
+ @NullableDecl
public String readFirstLine() throws IOException {
Closer closer = Closer.create();
try {
@@ -319,8 +305,7 @@
*/
@Beta
@CanIgnoreReturnValue // some processors won't return a useful result
- @ParametricNullness
- public <T extends @Nullable Object> T readLines(LineProcessor<T> processor) throws IOException {
+ public <T> T readLines(LineProcessor<T> processor) throws IOException {
checkNotNull(processor);
Closer closer = Closer.create();
@@ -509,7 +494,6 @@
Iterator<String> lines = LINE_SPLITTER.split(seq).iterator();
@Override
- @CheckForNull
protected String computeNext() {
if (lines.hasNext()) {
String next = lines.next();
@@ -524,7 +508,6 @@
}
@Override
- @CheckForNull
public String readFirstLine() {
Iterator<String> lines = linesIterator();
return lines.hasNext() ? lines.next() : null;
@@ -536,8 +519,7 @@
}
@Override
- @ParametricNullness
- public <T extends @Nullable Object> T readLines(LineProcessor<T> processor) throws IOException {
+ public <T> T readLines(LineProcessor<T> processor) throws IOException {
Iterator<String> lines = linesIterator();
while (lines.hasNext()) {
if (!processor.processLine(lines.next())) {
diff --git a/android/guava/src/com/google/common/io/CharStreams.java b/android/guava/src/com/google/common/io/CharStreams.java
index c414194..e54284e 100644
--- a/android/guava/src/com/google/common/io/CharStreams.java
+++ b/android/guava/src/com/google/common/io/CharStreams.java
@@ -28,8 +28,7 @@
import java.nio.CharBuffer;
import java.util.ArrayList;
import java.util.List;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* Provides utility methods for working with character streams.
@@ -46,7 +45,6 @@
* @since 1.0
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public final class CharStreams {
// 2K chars (4K bytes)
@@ -79,19 +77,19 @@
} else {
return copyReaderToWriter((Reader) from, asWriter(to));
}
+ } else {
+ checkNotNull(from);
+ checkNotNull(to);
+ long total = 0;
+ CharBuffer buf = createBuffer();
+ while (from.read(buf) != -1) {
+ Java8Compatibility.flip(buf);
+ to.append(buf);
+ total += buf.remaining();
+ Java8Compatibility.clear(buf);
+ }
+ return total;
}
-
- checkNotNull(from);
- checkNotNull(to);
- long total = 0;
- CharBuffer buf = createBuffer();
- while (from.read(buf) != -1) {
- Java8Compatibility.flip(buf);
- to.append(buf);
- total += buf.remaining();
- Java8Compatibility.clear(buf);
- }
- return total;
}
// TODO(lukes): consider allowing callers to pass in a buffer to use, some callers would be able
@@ -217,9 +215,7 @@
*/
@Beta
@CanIgnoreReturnValue // some processors won't return a useful result
- @ParametricNullness
- public static <T extends @Nullable Object> T readLines(
- Readable readable, LineProcessor<T> processor) throws IOException {
+ public static <T> T readLines(Readable readable, LineProcessor<T> processor) throws IOException {
checkNotNull(readable);
checkNotNull(processor);
@@ -311,12 +307,12 @@
}
@Override
- public Writer append(@CheckForNull CharSequence csq) {
+ public Writer append(@NullableDecl CharSequence csq) {
return this;
}
@Override
- public Writer append(@CheckForNull CharSequence csq, int start, int end) {
+ public Writer append(@NullableDecl CharSequence csq, int start, int end) {
checkPositionIndexes(start, end, csq == null ? "null".length() : csq.length());
return this;
}
diff --git a/android/guava/src/com/google/common/io/Closeables.java b/android/guava/src/com/google/common/io/Closeables.java
index b45f5f0..e7489a7 100644
--- a/android/guava/src/com/google/common/io/Closeables.java
+++ b/android/guava/src/com/google/common/io/Closeables.java
@@ -23,7 +23,7 @@
import java.io.Reader;
import java.util.logging.Level;
import java.util.logging.Logger;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* Utility methods for working with {@link Closeable} objects.
@@ -33,7 +33,6 @@
*/
@Beta
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public final class Closeables {
@VisibleForTesting static final Logger logger = Logger.getLogger(Closeables.class.getName());
@@ -70,7 +69,7 @@
* @throws IOException if {@code swallowIOException} is false and {@code close} throws an {@code
* IOException}.
*/
- public static void close(@CheckForNull Closeable closeable, boolean swallowIOException)
+ public static void close(@NullableDecl Closeable closeable, boolean swallowIOException)
throws IOException {
if (closeable == null) {
return;
@@ -100,7 +99,7 @@
* does nothing
* @since 17.0
*/
- public static void closeQuietly(@CheckForNull InputStream inputStream) {
+ public static void closeQuietly(@NullableDecl InputStream inputStream) {
try {
close(inputStream, true);
} catch (IOException impossible) {
@@ -121,7 +120,7 @@
* @param reader the reader to be closed, or {@code null} in which case this method does nothing
* @since 17.0
*/
- public static void closeQuietly(@CheckForNull Reader reader) {
+ public static void closeQuietly(@NullableDecl Reader reader) {
try {
close(reader, true);
} catch (IOException impossible) {
diff --git a/android/guava/src/com/google/common/io/Closer.java b/android/guava/src/com/google/common/io/Closer.java
index 12998ef..ff5db89 100644
--- a/android/guava/src/com/google/common/io/Closer.java
+++ b/android/guava/src/com/google/common/io/Closer.java
@@ -27,8 +27,7 @@
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.logging.Level;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* A {@link Closeable} that collects {@code Closeable} resources and closes them all when it is
@@ -89,16 +88,13 @@
// Coffee's for {@link Closer closers} only.
@Beta
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public final class Closer implements Closeable {
/** The suppressor implementation to use for the current Java version. */
- private static final Suppressor SUPPRESSOR;
-
- static {
- SuppressingSuppressor suppressingSuppressor = SuppressingSuppressor.tryCreate();
- SUPPRESSOR = suppressingSuppressor == null ? LoggingSuppressor.INSTANCE : suppressingSuppressor;
- }
+ private static final Suppressor SUPPRESSOR =
+ SuppressingSuppressor.isAvailable()
+ ? SuppressingSuppressor.INSTANCE
+ : LoggingSuppressor.INSTANCE;
/** Creates a new {@link Closer}. */
public static Closer create() {
@@ -109,7 +105,7 @@
// only need space for 2 elements in most cases, so try to use the smallest array possible
private final Deque<Closeable> stack = new ArrayDeque<>(4);
- @CheckForNull private Throwable thrown;
+ @NullableDecl private Throwable thrown;
@VisibleForTesting
Closer(Suppressor suppressor) {
@@ -124,8 +120,7 @@
*/
// close. this word no longer has any meaning to me.
@CanIgnoreReturnValue
- @ParametricNullness
- public <C extends @Nullable Closeable> C register(@ParametricNullness C closeable) {
+ public <C extends Closeable> C register(@NullableDecl C closeable) {
if (closeable != null) {
stack.addFirst(closeable);
}
@@ -262,21 +257,21 @@
*/
@VisibleForTesting
static final class SuppressingSuppressor implements Suppressor {
- @CheckForNull
- static SuppressingSuppressor tryCreate() {
- Method addSuppressed;
+
+ static final SuppressingSuppressor INSTANCE = new SuppressingSuppressor();
+
+ static boolean isAvailable() {
+ return addSuppressed != null;
+ }
+
+ static final Method addSuppressed = addSuppressedMethodOrNull();
+
+ private static Method addSuppressedMethodOrNull() {
try {
- addSuppressed = Throwable.class.getMethod("addSuppressed", Throwable.class);
+ return Throwable.class.getMethod("addSuppressed", Throwable.class);
} catch (Throwable e) {
return null;
}
- return new SuppressingSuppressor(addSuppressed);
- }
-
- private final Method addSuppressed;
-
- private SuppressingSuppressor(Method addSuppressed) {
- this.addSuppressed = addSuppressed;
}
@Override
diff --git a/android/guava/src/com/google/common/io/CountingInputStream.java b/android/guava/src/com/google/common/io/CountingInputStream.java
index a37807a..b015aca 100644
--- a/android/guava/src/com/google/common/io/CountingInputStream.java
+++ b/android/guava/src/com/google/common/io/CountingInputStream.java
@@ -30,7 +30,6 @@
*/
@Beta
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public final class CountingInputStream extends FilterInputStream {
private long count;
diff --git a/android/guava/src/com/google/common/io/CountingOutputStream.java b/android/guava/src/com/google/common/io/CountingOutputStream.java
index cf62b9c..8a3d170 100644
--- a/android/guava/src/com/google/common/io/CountingOutputStream.java
+++ b/android/guava/src/com/google/common/io/CountingOutputStream.java
@@ -16,6 +16,7 @@
import static com.google.common.base.Preconditions.checkNotNull;
+import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtIncompatible;
import java.io.FilterOutputStream;
import java.io.IOException;
@@ -27,8 +28,8 @@
* @author Chris Nokleberg
* @since 1.0
*/
+@Beta
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public final class CountingOutputStream extends FilterOutputStream {
private long count;
diff --git a/android/guava/src/com/google/common/io/ElementTypesAreNonnullByDefault.java b/android/guava/src/com/google/common/io/ElementTypesAreNonnullByDefault.java
deleted file mode 100644
index 48bc10f..0000000
--- a/android/guava/src/com/google/common/io/ElementTypesAreNonnullByDefault.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) 2021 The Guava Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.common.io;
-
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.PARAMETER;
-import static java.lang.annotation.ElementType.TYPE;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-import com.google.common.annotations.GwtCompatible;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-import javax.annotation.Nonnull;
-import javax.annotation.meta.TypeQualifierDefault;
-
-/**
- * Marks all "top-level" types as non-null in a way that is recognized by Kotlin. Note that this
- * unfortunately includes type-variable usages, so we also provide {@link ParametricNullness} to
- * "undo" it as best we can.
- */
-@GwtCompatible
-@Retention(RUNTIME)
-@Target(TYPE)
-@TypeQualifierDefault({FIELD, METHOD, PARAMETER})
-@Nonnull
-@interface ElementTypesAreNonnullByDefault {}
diff --git a/android/guava/src/com/google/common/io/FileBackedOutputStream.java b/android/guava/src/com/google/common/io/FileBackedOutputStream.java
index 9912e2f..b72c40e 100644
--- a/android/guava/src/com/google/common/io/FileBackedOutputStream.java
+++ b/android/guava/src/com/google/common/io/FileBackedOutputStream.java
@@ -14,8 +14,6 @@
package com.google.common.io;
-import static java.util.Objects.requireNonNull;
-
import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtIncompatible;
import com.google.common.annotations.VisibleForTesting;
@@ -28,7 +26,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* An {@link OutputStream} that starts buffering to a byte array, but switches to file buffering
@@ -52,22 +50,20 @@
*/
@Beta
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public final class FileBackedOutputStream extends OutputStream {
private final int fileThreshold;
private final boolean resetOnFinalize;
private final ByteSource source;
- @CheckForNull private final File parentDirectory;
+ @NullableDecl private final File parentDirectory;
@GuardedBy("this")
private OutputStream out;
@GuardedBy("this")
- @CheckForNull
private MemoryOutput memory;
@GuardedBy("this")
- @CheckForNull
+ @NullableDecl
private File file;
/** ByteArrayOutputStream that exposes its internals. */
@@ -83,7 +79,6 @@
/** Returns the file holding the data (possibly null). */
@VisibleForTesting
- @CheckForNull
synchronized File getFile() {
return file;
}
@@ -111,7 +106,7 @@
}
private FileBackedOutputStream(
- int fileThreshold, boolean resetOnFinalize, @CheckForNull File parentDirectory) {
+ int fileThreshold, boolean resetOnFinalize, @NullableDecl File parentDirectory) {
this.fileThreshold = fileThreshold;
this.resetOnFinalize = resetOnFinalize;
this.parentDirectory = parentDirectory;
@@ -159,8 +154,6 @@
if (file != null) {
return new FileInputStream(file);
} else {
- // requireNonNull is safe because we always have either `file` or `memory`.
- requireNonNull(memory);
return new ByteArrayInputStream(memory.getBuffer(), 0, memory.getCount());
}
}
@@ -224,24 +217,19 @@
*/
@GuardedBy("this")
private void update(int len) throws IOException {
- if (memory != null && (memory.getCount() + len > fileThreshold)) {
+ if (file == null && (memory.getCount() + len > fileThreshold)) {
File temp = File.createTempFile("FileBackedOutputStream", null, parentDirectory);
if (resetOnFinalize) {
// Finalizers are not guaranteed to be called on system shutdown;
// this is insurance.
temp.deleteOnExit();
}
- try {
- FileOutputStream transfer = new FileOutputStream(temp);
- transfer.write(memory.getBuffer(), 0, memory.getCount());
- transfer.flush();
- // We've successfully transferred the data; switch to writing to file
- out = transfer;
- } catch (IOException e) {
- temp.delete();
- throw e;
- }
+ FileOutputStream transfer = new FileOutputStream(temp);
+ transfer.write(memory.getBuffer(), 0, memory.getCount());
+ transfer.flush();
+ // We've successfully transferred the data; switch to writing to file
+ out = transfer;
file = temp;
memory = null;
}
diff --git a/android/guava/src/com/google/common/io/FileWriteMode.java b/android/guava/src/com/google/common/io/FileWriteMode.java
index 86872d1..2c69a2e 100644
--- a/android/guava/src/com/google/common/io/FileWriteMode.java
+++ b/android/guava/src/com/google/common/io/FileWriteMode.java
@@ -23,7 +23,6 @@
* @author Colin Decker
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public enum FileWriteMode {
/** Specifies that writes to the opened file should append to the end of the file. */
APPEND
diff --git a/android/guava/src/com/google/common/io/Files.java b/android/guava/src/com/google/common/io/Files.java
index bf6289e..73eb656 100644
--- a/android/guava/src/com/google/common/io/Files.java
+++ b/android/guava/src/com/google/common/io/Files.java
@@ -52,8 +52,6 @@
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Provides utility methods for working with {@linkplain File files}.
@@ -66,7 +64,6 @@
* @since 1.0
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public final class Files {
/** Maximum loop count when creating temp directories. */
@@ -532,7 +529,6 @@
*/
@Beta
@Deprecated
- @CheckForNull
public
static String readFirstLine(File file, Charset charset) throws IOException {
return asCharSource(file, charset).readFirstLine();
@@ -592,10 +588,8 @@
@Beta
@Deprecated
@CanIgnoreReturnValue // some processors won't return a useful result
- @ParametricNullness
public
- static <T extends @Nullable Object> T readLines(
- File file, Charset charset, LineProcessor<T> callback) throws IOException {
+ static <T> T readLines(File file, Charset charset, LineProcessor<T> callback) throws IOException {
return asCharSource(file, charset).readLines(callback);
}
@@ -614,10 +608,8 @@
@Beta
@Deprecated
@CanIgnoreReturnValue // some processors won't return a useful result
- @ParametricNullness
public
- static <T extends @Nullable Object> T readBytes(File file, ByteProcessor<T> processor)
- throws IOException {
+ static <T> T readBytes(File file, ByteProcessor<T> processor) throws IOException {
return asByteSource(file).read(processor);
}
diff --git a/android/guava/src/com/google/common/io/Flushables.java b/android/guava/src/com/google/common/io/Flushables.java
index 1f795a2..9b1d6a0 100644
--- a/android/guava/src/com/google/common/io/Flushables.java
+++ b/android/guava/src/com/google/common/io/Flushables.java
@@ -29,7 +29,6 @@
*/
@Beta
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public final class Flushables {
private static final Logger logger = Logger.getLogger(Flushables.class.getName());
diff --git a/android/guava/src/com/google/common/io/Java8Compatibility.java b/android/guava/src/com/google/common/io/Java8Compatibility.java
index 705d97b..62b5c2e 100644
--- a/android/guava/src/com/google/common/io/Java8Compatibility.java
+++ b/android/guava/src/com/google/common/io/Java8Compatibility.java
@@ -22,7 +22,6 @@
* https://github.com/google/guava/issues/3990
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
final class Java8Compatibility {
static void clear(Buffer b) {
b.clear();
@@ -36,17 +35,9 @@
b.limit(limit);
}
- static void mark(Buffer b) {
- b.mark();
- }
-
static void position(Buffer b, int position) {
b.position(position);
}
- static void reset(Buffer b) {
- b.reset();
- }
-
private Java8Compatibility() {}
}
diff --git a/android/guava/src/com/google/common/io/LineBuffer.java b/android/guava/src/com/google/common/io/LineBuffer.java
index f944abc..a8e775c 100644
--- a/android/guava/src/com/google/common/io/LineBuffer.java
+++ b/android/guava/src/com/google/common/io/LineBuffer.java
@@ -30,7 +30,6 @@
* @since 1.0
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
abstract class LineBuffer {
/** Holds partial line contents. */
private StringBuilder line = new StringBuilder();
diff --git a/android/guava/src/com/google/common/io/LineProcessor.java b/android/guava/src/com/google/common/io/LineProcessor.java
index e28bebc..65ded53 100644
--- a/android/guava/src/com/google/common/io/LineProcessor.java
+++ b/android/guava/src/com/google/common/io/LineProcessor.java
@@ -18,7 +18,6 @@
import com.google.common.annotations.GwtIncompatible;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import java.io.IOException;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* A callback to be used with the streaming {@code readLines} methods.
@@ -31,8 +30,7 @@
*/
@Beta
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
-public interface LineProcessor<T extends @Nullable Object> {
+public interface LineProcessor<T> {
/**
* This method will be called once for each line.
@@ -44,6 +42,5 @@
boolean processLine(String line) throws IOException;
/** Return the result of processing all the lines. */
- @ParametricNullness
T getResult();
}
diff --git a/android/guava/src/com/google/common/io/LineReader.java b/android/guava/src/com/google/common/io/LineReader.java
index 2c57ac4..1c8cef0 100644
--- a/android/guava/src/com/google/common/io/LineReader.java
+++ b/android/guava/src/com/google/common/io/LineReader.java
@@ -23,9 +23,9 @@
import java.io.IOException;
import java.io.Reader;
import java.nio.CharBuffer;
-import java.util.ArrayDeque;
+import java.util.LinkedList;
import java.util.Queue;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* A class for reading lines of text. Provides the same functionality as {@link
@@ -37,14 +37,13 @@
*/
@Beta
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public final class LineReader {
private final Readable readable;
- @CheckForNull private final Reader reader;
+ @NullableDecl private final Reader reader;
private final CharBuffer cbuf = createBuffer();
private final char[] buf = cbuf.array();
- private final Queue<String> lines = new ArrayDeque<>();
+ private final Queue<String> lines = new LinkedList<>();
private final LineBuffer lineBuf =
new LineBuffer() {
@Override
@@ -69,7 +68,6 @@
* @throws IOException if an I/O error occurs
*/
@CanIgnoreReturnValue // to skip a line
- @CheckForNull
public String readLine() throws IOException {
while (lines.peek() == null) {
Java8Compatibility.clear(cbuf);
diff --git a/android/guava/src/com/google/common/io/LittleEndianDataInputStream.java b/android/guava/src/com/google/common/io/LittleEndianDataInputStream.java
index 88c8e27..7d9c88b 100644
--- a/android/guava/src/com/google/common/io/LittleEndianDataInputStream.java
+++ b/android/guava/src/com/google/common/io/LittleEndianDataInputStream.java
@@ -20,7 +20,6 @@
import com.google.common.primitives.Ints;
import com.google.common.primitives.Longs;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
-import com.google.errorprone.annotations.DoNotCall;
import java.io.DataInput;
import java.io.DataInputStream;
import java.io.EOFException;
@@ -41,7 +40,6 @@
*/
@Beta
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public final class LittleEndianDataInputStream extends FilterInputStream implements DataInput {
/**
@@ -56,7 +54,6 @@
/** This method will throw an {@link UnsupportedOperationException}. */
@CanIgnoreReturnValue // to skip a line
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
public String readLine() {
throw new UnsupportedOperationException("readLine is not supported");
}
diff --git a/android/guava/src/com/google/common/io/LittleEndianDataOutputStream.java b/android/guava/src/com/google/common/io/LittleEndianDataOutputStream.java
index 6e51aff..e5e398f 100644
--- a/android/guava/src/com/google/common/io/LittleEndianDataOutputStream.java
+++ b/android/guava/src/com/google/common/io/LittleEndianDataOutputStream.java
@@ -37,7 +37,6 @@
*/
@Beta
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public final class LittleEndianDataOutputStream extends FilterOutputStream implements DataOutput {
/**
diff --git a/android/guava/src/com/google/common/io/MultiInputStream.java b/android/guava/src/com/google/common/io/MultiInputStream.java
index 9a7e0fd..bae8e39 100644
--- a/android/guava/src/com/google/common/io/MultiInputStream.java
+++ b/android/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 javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* An {@link InputStream} that concatenates multiple substreams. At most one stream will be open at
@@ -30,11 +30,10 @@
* @since 1.0
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
final class MultiInputStream extends InputStream {
private Iterator<? extends ByteSource> it;
- @CheckForNull private InputStream in;
+ @NullableDecl private InputStream in;
/**
* Creates a new instance.
@@ -91,8 +90,7 @@
}
@Override
- public int read(byte[] b, int off, int len) throws IOException {
- checkNotNull(b);
+ public int read(@NullableDecl byte[] b, int off, int len) throws IOException {
while (in != null) {
int result = in.read(b, off, len);
if (result != -1) {
diff --git a/android/guava/src/com/google/common/io/MultiReader.java b/android/guava/src/com/google/common/io/MultiReader.java
index cc36e52..d075727 100644
--- a/android/guava/src/com/google/common/io/MultiReader.java
+++ b/android/guava/src/com/google/common/io/MultiReader.java
@@ -14,14 +14,12 @@
package com.google.common.io;
-import static com.google.common.base.Preconditions.checkNotNull;
-
import com.google.common.annotations.GwtIncompatible;
import com.google.common.base.Preconditions;
import java.io.IOException;
import java.io.Reader;
import java.util.Iterator;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* A {@link Reader} that concatenates multiple readers.
@@ -30,10 +28,9 @@
* @since 1.0
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
class MultiReader extends Reader {
private final Iterator<? extends CharSource> it;
- @CheckForNull private Reader current;
+ @NullableDecl private Reader current;
MultiReader(Iterator<? extends CharSource> readers) throws IOException {
this.it = readers;
@@ -49,8 +46,7 @@
}
@Override
- public int read(char[] cbuf, int off, int len) throws IOException {
- checkNotNull(cbuf);
+ public int read(@NullableDecl char[] cbuf, int off, int len) throws IOException {
if (current == null) {
return -1;
}
diff --git a/android/guava/src/com/google/common/io/ParametricNullness.java b/android/guava/src/com/google/common/io/ParametricNullness.java
deleted file mode 100644
index afa0db1..0000000
--- a/android/guava/src/com/google/common/io/ParametricNullness.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2021 The Guava Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.common.io;
-
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.PARAMETER;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-import static javax.annotation.meta.When.UNKNOWN;
-
-import com.google.common.annotations.GwtCompatible;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-import javax.annotation.Nonnull;
-import javax.annotation.meta.TypeQualifierNickname;
-
-/**
- * Marks a "top-level" type-variable usage as (a) a Kotlin platform type when the type argument is
- * non-nullable and (b) nullable when the type argument is nullable. This is the closest we can get
- * to "non-nullable when non-nullable; nullable when nullable" (like the Android <a
- * href="https://android.googlesource.com/platform/libcore/+/master/luni/src/main/java/libcore/util/NullFromTypeParam.java">{@code
- * NullFromTypeParam}</a>). We use this to "undo" {@link ElementTypesAreNonnullByDefault}.
- */
-@GwtCompatible
-@Retention(RUNTIME)
-@Target({FIELD, METHOD, PARAMETER})
-@TypeQualifierNickname
-@Nonnull(when = UNKNOWN)
-@interface ParametricNullness {}
diff --git a/android/guava/src/com/google/common/io/PatternFilenameFilter.java b/android/guava/src/com/google/common/io/PatternFilenameFilter.java
index 3cb2371..43e4f30 100644
--- a/android/guava/src/com/google/common/io/PatternFilenameFilter.java
+++ b/android/guava/src/com/google/common/io/PatternFilenameFilter.java
@@ -21,6 +21,7 @@
import java.io.FilenameFilter;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* File name filter that only accepts files matching a regular expression. This class is thread-safe
@@ -31,7 +32,6 @@
*/
@Beta
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public final class PatternFilenameFilter implements FilenameFilter {
private final Pattern pattern;
@@ -55,21 +55,8 @@
this.pattern = Preconditions.checkNotNull(pattern);
}
- /*
- * Our implementation works fine with a null `dir`. However, there's nothing in the documentation
- * of the supertype that suggests that implementations are expected to tolerate null. That said, I
- * see calls in Google code that pass a null `dir` to a FilenameFilter.... So let's declare the
- * parameter as non-nullable (since passing null to a FilenameFilter is unsafe in general), but if
- * someone still manages to pass null, let's continue to have the method work.
- *
- * (PatternFilenameFilter is of course one of those classes that shouldn't be a publicly visible
- * class to begin with but rather something returned from a static factory method whose declared
- * return type is plain FilenameFilter. If we made such a change, then the annotation we choose
- * here would have no significance to end users, who would be forced to conform to the signature
- * used in FilenameFilter.)
- */
@Override
- public boolean accept(File dir, String fileName) {
+ public boolean accept(@NullableDecl File dir, String fileName) {
return pattern.matcher(fileName).matches();
}
}
diff --git a/android/guava/src/com/google/common/io/ReaderInputStream.java b/android/guava/src/com/google/common/io/ReaderInputStream.java
index 75f8a3e..eeb64e4 100644
--- a/android/guava/src/com/google/common/io/ReaderInputStream.java
+++ b/android/guava/src/com/google/common/io/ReaderInputStream.java
@@ -44,7 +44,6 @@
* @author Chris Nokleberg
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
final class ReaderInputStream extends InputStream {
private final Reader reader;
private final CharsetEncoder encoder;
diff --git a/android/guava/src/com/google/common/io/Resources.java b/android/guava/src/com/google/common/io/Resources.java
index cc595fc..d64bf3d 100644
--- a/android/guava/src/com/google/common/io/Resources.java
+++ b/android/guava/src/com/google/common/io/Resources.java
@@ -29,7 +29,6 @@
import java.net.URL;
import java.nio.charset.Charset;
import java.util.List;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Provides utility methods for working with resources in the classpath. Note that even though these
@@ -45,7 +44,6 @@
*/
@Beta
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public final class Resources {
private Resources() {}
@@ -123,9 +121,8 @@
* @throws IOException if an I/O error occurs
*/
@CanIgnoreReturnValue // some processors won't return a useful result
- @ParametricNullness
- public static <T extends @Nullable Object> T readLines(
- URL url, Charset charset, LineProcessor<T> callback) throws IOException {
+ public static <T> T readLines(URL url, Charset charset, LineProcessor<T> callback)
+ throws IOException {
return asCharSource(url, charset).readLines(callback);
}
diff --git a/android/guava/src/com/google/common/math/BigDecimalMath.java b/android/guava/src/com/google/common/math/BigDecimalMath.java
index 33a55d3..b5c23f8 100644
--- a/android/guava/src/com/google/common/math/BigDecimalMath.java
+++ b/android/guava/src/com/google/common/math/BigDecimalMath.java
@@ -25,7 +25,6 @@
* @since 30.0
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public class BigDecimalMath {
private BigDecimalMath() {}
diff --git a/android/guava/src/com/google/common/math/BigIntegerMath.java b/android/guava/src/com/google/common/math/BigIntegerMath.java
index 6ef1e81..bf443e9 100644
--- a/android/guava/src/com/google/common/math/BigIntegerMath.java
+++ b/android/guava/src/com/google/common/math/BigIntegerMath.java
@@ -48,7 +48,6 @@
* @since 11.0
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
public final class BigIntegerMath {
/**
* Returns the smallest power of two greater than or equal to {@code x}. This is equivalent to
diff --git a/android/guava/src/com/google/common/math/DoubleMath.java b/android/guava/src/com/google/common/math/DoubleMath.java
index cdd0a4b..8745e41 100644
--- a/android/guava/src/com/google/common/math/DoubleMath.java
+++ b/android/guava/src/com/google/common/math/DoubleMath.java
@@ -46,7 +46,6 @@
* @since 11.0
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
public final class DoubleMath {
/*
* This method returns a value y such that rounding y DOWN (towards zero) gives the same result as
@@ -433,7 +432,7 @@
@Deprecated
public static double mean(int... values) {
checkArgument(values.length > 0, "Cannot take mean of 0 values");
- // The upper bound on the length of an array and the bounds on the int values mean that, in
+ // The upper bound on the the length of an array and the bounds on the int values mean that, in
// this case only, we can compute the sum as a long without risking overflow or loss of
// precision. So we do that, as it's slightly quicker than the Knuth algorithm.
long sum = 0;
diff --git a/android/guava/src/com/google/common/math/DoubleUtils.java b/android/guava/src/com/google/common/math/DoubleUtils.java
index d4a07e9..4183195 100644
--- a/android/guava/src/com/google/common/math/DoubleUtils.java
+++ b/android/guava/src/com/google/common/math/DoubleUtils.java
@@ -33,7 +33,6 @@
* @author Louis Wasserman
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
final class DoubleUtils {
private DoubleUtils() {}
diff --git a/android/guava/src/com/google/common/math/ElementTypesAreNonnullByDefault.java b/android/guava/src/com/google/common/math/ElementTypesAreNonnullByDefault.java
deleted file mode 100644
index 84999ea..0000000
--- a/android/guava/src/com/google/common/math/ElementTypesAreNonnullByDefault.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) 2021 The Guava Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.common.math;
-
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.PARAMETER;
-import static java.lang.annotation.ElementType.TYPE;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-import com.google.common.annotations.GwtCompatible;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-import javax.annotation.Nonnull;
-import javax.annotation.meta.TypeQualifierDefault;
-
-/**
- * Marks all "top-level" types as non-null in a way that is recognized by Kotlin. Note that this
- * unfortunately includes type-variable usages, so we also provide {@link ParametricNullness} to
- * "undo" it as best we can.
- */
-@GwtCompatible
-@Retention(RUNTIME)
-@Target(TYPE)
-@TypeQualifierDefault({FIELD, METHOD, PARAMETER})
-@Nonnull
-@interface ElementTypesAreNonnullByDefault {}
diff --git a/android/guava/src/com/google/common/math/IntMath.java b/android/guava/src/com/google/common/math/IntMath.java
index 17a18c6..78aedda 100644
--- a/android/guava/src/com/google/common/math/IntMath.java
+++ b/android/guava/src/com/google/common/math/IntMath.java
@@ -48,7 +48,6 @@
* @since 11.0
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
public final class IntMath {
// NOTE: Whenever both tests are cheap and functional, it's faster to use &, | instead of &&, ||
diff --git a/android/guava/src/com/google/common/math/LinearTransformation.java b/android/guava/src/com/google/common/math/LinearTransformation.java
index 4cc1eb8..485b046 100644
--- a/android/guava/src/com/google/common/math/LinearTransformation.java
+++ b/android/guava/src/com/google/common/math/LinearTransformation.java
@@ -21,7 +21,6 @@
import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtIncompatible;
import com.google.errorprone.annotations.concurrent.LazyInit;
-import javax.annotation.CheckForNull;
/**
* The representation of a linear transformation between real numbers {@code x} and {@code y}.
@@ -36,7 +35,6 @@
*/
@Beta
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public abstract class LinearTransformation {
/**
@@ -163,7 +161,7 @@
final double slope;
final double yIntercept;
- @CheckForNull @LazyInit LinearTransformation inverse;
+ @LazyInit LinearTransformation inverse;
RegularLinearTransformation(double slope, double yIntercept) {
this.slope = slope;
@@ -221,7 +219,7 @@
final double x;
- @CheckForNull @LazyInit LinearTransformation inverse;
+ @LazyInit LinearTransformation inverse;
VerticalLinearTransformation(double x) {
this.x = x;
diff --git a/android/guava/src/com/google/common/math/LongMath.java b/android/guava/src/com/google/common/math/LongMath.java
index 1e67812..420b48a 100644
--- a/android/guava/src/com/google/common/math/LongMath.java
+++ b/android/guava/src/com/google/common/math/LongMath.java
@@ -49,7 +49,6 @@
* @since 11.0
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
public final class LongMath {
// NOTE: Whenever both tests are cheap and functional, it's faster to use &, | instead of &&, ||
diff --git a/android/guava/src/com/google/common/math/MathPreconditions.java b/android/guava/src/com/google/common/math/MathPreconditions.java
index 37d608a..5f925d3 100644
--- a/android/guava/src/com/google/common/math/MathPreconditions.java
+++ b/android/guava/src/com/google/common/math/MathPreconditions.java
@@ -18,6 +18,7 @@
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import java.math.BigInteger;
import java.math.RoundingMode;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* A collection of preconditions for math functions.
@@ -26,51 +27,50 @@
*/
@GwtCompatible
@CanIgnoreReturnValue
-@ElementTypesAreNonnullByDefault
final class MathPreconditions {
- static int checkPositive(String role, int x) {
+ static int checkPositive(@NullableDecl String role, int x) {
if (x <= 0) {
throw new IllegalArgumentException(role + " (" + x + ") must be > 0");
}
return x;
}
- static long checkPositive(String role, long x) {
+ static long checkPositive(@NullableDecl String role, long x) {
if (x <= 0) {
throw new IllegalArgumentException(role + " (" + x + ") must be > 0");
}
return x;
}
- static BigInteger checkPositive(String role, BigInteger x) {
+ static BigInteger checkPositive(@NullableDecl String role, BigInteger x) {
if (x.signum() <= 0) {
throw new IllegalArgumentException(role + " (" + x + ") must be > 0");
}
return x;
}
- static int checkNonNegative(String role, int x) {
+ static int checkNonNegative(@NullableDecl String role, int x) {
if (x < 0) {
throw new IllegalArgumentException(role + " (" + x + ") must be >= 0");
}
return x;
}
- static long checkNonNegative(String role, long x) {
+ static long checkNonNegative(@NullableDecl String role, long x) {
if (x < 0) {
throw new IllegalArgumentException(role + " (" + x + ") must be >= 0");
}
return x;
}
- static BigInteger checkNonNegative(String role, BigInteger x) {
+ static BigInteger checkNonNegative(@NullableDecl String role, BigInteger x) {
if (x.signum() < 0) {
throw new IllegalArgumentException(role + " (" + x + ") must be >= 0");
}
return x;
}
- static double checkNonNegative(String role, double x) {
+ static double checkNonNegative(@NullableDecl 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/android/guava/src/com/google/common/math/PairedStats.java b/android/guava/src/com/google/common/math/PairedStats.java
index 31ab9b7..a636e51 100644
--- a/android/guava/src/com/google/common/math/PairedStats.java
+++ b/android/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 javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* An immutable value object capturing some basic statistics about a collection of paired double
@@ -39,7 +39,6 @@
*/
@Beta
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public final class PairedStats implements Serializable {
private final Stats xStats;
@@ -214,7 +213,7 @@
* guarantees {@code strictfp}-like semantics.)
*/
@Override
- public boolean equals(@CheckForNull Object obj) {
+ public boolean equals(@NullableDecl Object obj) {
if (obj == null) {
return false;
}
diff --git a/android/guava/src/com/google/common/math/PairedStatsAccumulator.java b/android/guava/src/com/google/common/math/PairedStatsAccumulator.java
index 072ef13..a988495 100644
--- a/android/guava/src/com/google/common/math/PairedStatsAccumulator.java
+++ b/android/guava/src/com/google/common/math/PairedStatsAccumulator.java
@@ -32,7 +32,6 @@
*/
@Beta
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public final class PairedStatsAccumulator {
// These fields must satisfy the requirements of PairedStats' constructor as well as those of the
diff --git a/android/guava/src/com/google/common/math/ParametricNullness.java b/android/guava/src/com/google/common/math/ParametricNullness.java
deleted file mode 100644
index c079b97..0000000
--- a/android/guava/src/com/google/common/math/ParametricNullness.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2021 The Guava Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.common.math;
-
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.PARAMETER;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-import static javax.annotation.meta.When.UNKNOWN;
-
-import com.google.common.annotations.GwtCompatible;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-import javax.annotation.Nonnull;
-import javax.annotation.meta.TypeQualifierNickname;
-
-/**
- * Marks a "top-level" type-variable usage as (a) a Kotlin platform type when the type argument is
- * non-nullable and (b) nullable when the type argument is nullable. This is the closest we can get
- * to "non-nullable when non-nullable; nullable when nullable" (like the Android <a
- * href="https://android.googlesource.com/platform/libcore/+/master/luni/src/main/java/libcore/util/NullFromTypeParam.java">{@code
- * NullFromTypeParam}</a>). We use this to "undo" {@link ElementTypesAreNonnullByDefault}.
- */
-@GwtCompatible
-@Retention(RUNTIME)
-@Target({FIELD, METHOD, PARAMETER})
-@TypeQualifierNickname
-@Nonnull(when = UNKNOWN)
-@interface ParametricNullness {}
diff --git a/android/guava/src/com/google/common/math/Quantiles.java b/android/guava/src/com/google/common/math/Quantiles.java
index 6ddea9b..7aac58f 100644
--- a/android/guava/src/com/google/common/math/Quantiles.java
+++ b/android/guava/src/com/google/common/math/Quantiles.java
@@ -128,7 +128,6 @@
*/
@Beta
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public final class Quantiles {
/** Specifies the computation of a median (i.e. the 1st 2-quantile). */
diff --git a/android/guava/src/com/google/common/math/Stats.java b/android/guava/src/com/google/common/math/Stats.java
index c083749..9493938 100644
--- a/android/guava/src/com/google/common/math/Stats.java
+++ b/android/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 javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* A bundle of statistical summary values -- sum, count, mean/average, min and max, and several
@@ -60,7 +60,6 @@
*/
@Beta
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public final class Stats implements Serializable {
private final long count;
@@ -341,7 +340,7 @@
* {@code strictfp}-like semantics.)
*/
@Override
- public boolean equals(@CheckForNull Object obj) {
+ public boolean equals(@NullableDecl Object obj) {
if (obj == null) {
return false;
}
diff --git a/android/guava/src/com/google/common/math/StatsAccumulator.java b/android/guava/src/com/google/common/math/StatsAccumulator.java
index f7d7a62..54468cf 100644
--- a/android/guava/src/com/google/common/math/StatsAccumulator.java
+++ b/android/guava/src/com/google/common/math/StatsAccumulator.java
@@ -34,7 +34,6 @@
*/
@Beta
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public final class StatsAccumulator {
// These fields must satisfy the requirements of Stats' constructor as well as those of the stat
diff --git a/android/guava/src/com/google/common/math/ToDoubleRounder.java b/android/guava/src/com/google/common/math/ToDoubleRounder.java
index 2e7e7fa..7525e3f 100644
--- a/android/guava/src/com/google/common/math/ToDoubleRounder.java
+++ b/android/guava/src/com/google/common/math/ToDoubleRounder.java
@@ -25,7 +25,6 @@
* a {@link RoundingMode}.
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
abstract class ToDoubleRounder<X extends Number & Comparable<X>> {
/**
* Returns x rounded to either the greatest double less than or equal to the precise value of x,
diff --git a/android/guava/src/com/google/common/net/ElementTypesAreNonnullByDefault.java b/android/guava/src/com/google/common/net/ElementTypesAreNonnullByDefault.java
deleted file mode 100644
index d8cfd73..0000000
--- a/android/guava/src/com/google/common/net/ElementTypesAreNonnullByDefault.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) 2021 The Guava Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.common.net;
-
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.PARAMETER;
-import static java.lang.annotation.ElementType.TYPE;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-import com.google.common.annotations.GwtCompatible;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-import javax.annotation.Nonnull;
-import javax.annotation.meta.TypeQualifierDefault;
-
-/**
- * Marks all "top-level" types as non-null in a way that is recognized by Kotlin. Note that this
- * unfortunately includes type-variable usages, so we also provide {@link ParametricNullness} to
- * "undo" it as best we can.
- */
-@GwtCompatible
-@Retention(RUNTIME)
-@Target(TYPE)
-@TypeQualifierDefault({FIELD, METHOD, PARAMETER})
-@Nonnull
-@interface ElementTypesAreNonnullByDefault {}
diff --git a/android/guava/src/com/google/common/net/HostAndPort.java b/android/guava/src/com/google/common/net/HostAndPort.java
index 19e6b67..df8ded4 100644
--- a/android/guava/src/com/google/common/net/HostAndPort.java
+++ b/android/guava/src/com/google/common/net/HostAndPort.java
@@ -20,12 +20,11 @@
import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtCompatible;
-import com.google.common.base.CharMatcher;
import com.google.common.base.Objects;
import com.google.common.base.Strings;
import com.google.errorprone.annotations.Immutable;
import java.io.Serializable;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* An immutable representation of a host and port.
@@ -63,7 +62,6 @@
@Beta
@Immutable
@GwtCompatible
-@ElementTypesAreNonnullByDefault
public final class HostAndPort implements Serializable {
/** Magic value indicating the absence of a port number. */
private static final int NO_PORT = -1;
@@ -191,10 +189,7 @@
if (!Strings.isNullOrEmpty(portString)) {
// Try to parse the whole port string as a number.
// JDK7 accepts leading plus signs. We don't want to.
- checkArgument(
- !portString.startsWith("+") && CharMatcher.ascii().matchesAllOf(portString),
- "Unparseable port number: %s",
- hostPortString);
+ checkArgument(!portString.startsWith("+"), "Unparseable port number: %s", hostPortString);
try {
port = Integer.parseInt(portString);
} catch (NumberFormatException e) {
@@ -214,12 +209,14 @@
* @throws IllegalArgumentException if parsing the bracketed host-port string fails.
*/
private static String[] getHostAndPortFromBracketedHost(String hostPortString) {
+ int colonIndex = 0;
+ int closeBracketIndex = 0;
checkArgument(
hostPortString.charAt(0) == '[',
"Bracketed host-port string must start with a bracket: %s",
hostPortString);
- int colonIndex = hostPortString.indexOf(':');
- int closeBracketIndex = hostPortString.lastIndexOf(']');
+ colonIndex = hostPortString.indexOf(':');
+ closeBracketIndex = hostPortString.lastIndexOf(']');
checkArgument(
colonIndex > -1 && closeBracketIndex > colonIndex,
"Invalid bracketed host/port: %s",
@@ -280,7 +277,7 @@
}
@Override
- public boolean equals(@CheckForNull Object other) {
+ public boolean equals(@NullableDecl Object other) {
if (this == other) {
return true;
}
diff --git a/android/guava/src/com/google/common/net/HostSpecifier.java b/android/guava/src/com/google/common/net/HostSpecifier.java
index 7448944..3f6f569 100644
--- a/android/guava/src/com/google/common/net/HostSpecifier.java
+++ b/android/guava/src/com/google/common/net/HostSpecifier.java
@@ -19,7 +19,7 @@
import com.google.common.base.Preconditions;
import java.net.InetAddress;
import java.text.ParseException;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* A syntactically valid host specifier, suitable for use in a URI. This may be either a numeric IP
@@ -43,7 +43,6 @@
*/
@Beta
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public final class HostSpecifier {
private final String canonicalForm;
@@ -138,7 +137,7 @@
}
@Override
- public boolean equals(@CheckForNull Object other) {
+ public boolean equals(@NullableDecl Object other) {
if (this == other) {
return true;
}
diff --git a/android/guava/src/com/google/common/net/HttpHeaders.java b/android/guava/src/com/google/common/net/HttpHeaders.java
index f318da1..11a5b50 100644
--- a/android/guava/src/com/google/common/net/HttpHeaders.java
+++ b/android/guava/src/com/google/common/net/HttpHeaders.java
@@ -28,11 +28,11 @@
* <li><a href="http://www.ietf.org/rfc/rfc5988.txt">RFC 5988</a>
* </ul>
*
+ *
* @author Kurt Alfred Kluever
* @since 11.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
public final class HttpHeaders {
private HttpHeaders() {}
@@ -129,13 +129,6 @@
public static final String MAX_FORWARDS = "Max-Forwards";
/** The HTTP {@code Origin} header field name. */
public static final String ORIGIN = "Origin";
- /**
- * The HTTP <a href="https://github.com/WICG/origin-isolation">{@code Origin-Isolation}</a> header
- * field name.
- *
- * @since 30.1
- */
- public static final String ORIGIN_ISOLATION = "Origin-Isolation";
/** The HTTP {@code Proxy-Authorization} header field name. */
public static final String PROXY_AUTHORIZATION = "Proxy-Authorization";
/** The HTTP {@code Range} header field name. */
@@ -305,12 +298,6 @@
/** The HTTP {@code Location} header field name. */
public static final String LOCATION = "Location";
/**
- * The HTTP {@code Keep-Alive} header field name.
- *
- * @since 31.0
- */
- public static final String KEEP_ALIVE = "Keep-Alive";
- /**
* The HTTP <a href="https://googlechrome.github.io/OriginTrials/#header">{@code Origin-Trial}</a>
* header field name.
*
@@ -388,45 +375,6 @@
public static final String DNT = "DNT";
/** The HTTP {@code X-Content-Type-Options} header field name. */
public static final String X_CONTENT_TYPE_OPTIONS = "X-Content-Type-Options";
- /**
- * The HTTP <a
- * href="https://iabtechlab.com/wp-content/uploads/2019/06/VAST_4.2_final_june26.pdf">{@code
- * X-Device-IP}</a> header field name. Header used for VAST requests to provide the IP address of
- * the device on whose behalf the request is being made.
- *
- * @since 31.0
- */
- public static final String X_DEVICE_IP = "X-Device-IP";
- /**
- * The HTTP <a
- * href="https://iabtechlab.com/wp-content/uploads/2019/06/VAST_4.2_final_june26.pdf">{@code
- * X-Device-Referer}</a> header field name. Header used for VAST requests to provide the {@link
- * #REFERER} header value that the on-behalf-of client would have used when making a request
- * itself.
- *
- * @since 31.0
- */
- public static final String X_DEVICE_REFERER = "X-Device-Referer";
- /**
- * The HTTP <a
- * href="https://iabtechlab.com/wp-content/uploads/2019/06/VAST_4.2_final_june26.pdf">{@code
- * X-Device-Accept-Language}</a> header field name. Header used for VAST requests to provide the
- * {@link #ACCEPT_LANGUAGE} header value that the on-behalf-of client would have used when making
- * a request itself.
- *
- * @since 31.0
- */
- public static final String X_DEVICE_ACCEPT_LANGUAGE = "X-Device-Accept-Language";
- /**
- * The HTTP <a
- * href="https://iabtechlab.com/wp-content/uploads/2019/06/VAST_4.2_final_june26.pdf">{@code
- * X-Device-Requested-With}</a> header field name. Header used for VAST requests to provide the
- * {@link #X_REQUESTED_WITH} header value that the on-behalf-of client would have used when making
- * a request itself.
- *
- * @since 31.0
- */
- public static final String X_DEVICE_REQUESTED_WITH = "X-Device-Requested-With";
/** The HTTP {@code X-Do-Not-Track} header field name. */
public static final String X_DO_NOT_TRACK = "X-Do-Not-Track";
/** The HTTP {@code X-Forwarded-For} header field name (superseded by {@code Forwarded}). */
@@ -463,12 +411,6 @@
* @since 15.0
*/
@Beta public static final String PUBLIC_KEY_PINS_REPORT_ONLY = "Public-Key-Pins-Report-Only";
- /**
- * The HTTP {@code X-Request-ID} header field name.
- *
- * @since 30.1
- */
- public static final String X_REQUEST_ID = "X-Request-ID";
/** The HTTP {@code X-Requested-With} header field name. */
public static final String X_REQUESTED_WITH = "X-Requested-With";
/** The HTTP {@code X-User-IP} header field name. */
@@ -533,100 +475,6 @@
public static final String X_MOZ = "X-Moz";
/**
- * The HTTP <a
- * href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Device-Memory">{@code
- * Device-Memory}</a> header field name.
- *
- * @since 31.0
- */
- public static final String DEVICE_MEMORY = "Device-Memory";
-
- /**
- * The HTTP <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Downlink">{@code
- * Downlink}</a> header field name.
- *
- * @since 31.0
- */
- public static final String DOWNLINK = "Downlink";
-
- /**
- * The HTTP <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/ECT">{@code
- * ECT}</a> header field name.
- *
- * @since 31.0
- */
- public static final String ECT = "ECT";
-
- /**
- * The HTTP <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/RTT">{@code
- * RTT}</a> header field name.
- *
- * @since 31.0
- */
- public static final String RTT = "RTT";
-
- /**
- * The HTTP <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Save-Data">{@code
- * Save-Data}</a> header field name.
- *
- * @since 31.0
- */
- public static final String SAVE_DATA = "Save-Data";
-
- /**
- * The HTTP <a
- * href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Viewport-Width">{@code
- * Viewport-Width}</a> header field name.
- *
- * @since 31.0
- */
- public static final String VIEWPORT_WIDTH = "Viewport-Width";
-
- /**
- * The HTTP <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Width">{@code
- * Width}</a> header field name.
- *
- * @since 31.0
- */
- public static final String WIDTH = "Width";
-
- /**
- * The HTTP <a href="https://www.w3.org/TR/permissions-policy-1/">{@code Permissions-Policy}</a>
- * header field name.
- *
- * @since 31.0
- */
- public static final String PERMISSIONS_POLICY = "Permissions-Policy";
-
- /**
- * The HTTP <a
- * href="https://wicg.github.io/user-preference-media-features-headers/#sec-ch-prefers-color-scheme">{@code
- * Sec-CH-Prefers-Color-Scheme}</a> header field name.
- *
- * <p>This header is experimental.
- *
- * @since 31.0
- */
- public static final String SEC_CH_PREFERS_COLOR_SCHEME = "Sec-CH-Prefers-Color-Scheme";
-
- /**
- * The HTTP <a
- * href="https://www.rfc-editor.org/rfc/rfc8942#name-the-accept-ch-response-head">{@code
- * Accept-CH}</a> header field name.
- *
- * @since 31.0
- */
- public static final String ACCEPT_CH = "Accept-CH";
- /**
- * The HTTP <a
- * href="https://datatracker.ietf.org/doc/html/draft-davidben-http-client-hint-reliability-03.txt#section-3">{@code
- * Critical-CH}</a> header field name.
- *
- * @since 31.0
- */
- public static final String CRITICAL_CH = "Critical-CH";
-
- /**
* The HTTP <a href="https://wicg.github.io/ua-client-hints/#sec-ch-ua">{@code Sec-CH-UA}</a>
* header field name.
*
@@ -634,54 +482,47 @@
*/
public static final String SEC_CH_UA = "Sec-CH-UA";
/**
- * The HTTP <a href="https://wicg.github.io/ua-client-hints/#sec-ch-ua-arch">{@code
+ * The HTTP <a href="https://wicg.github.io/ua-client-hints/#sec-ch-arch">{@code
* Sec-CH-UA-Arch}</a> header field name.
*
* @since 30.0
*/
public static final String SEC_CH_UA_ARCH = "Sec-CH-UA-Arch";
/**
- * The HTTP <a href="https://wicg.github.io/ua-client-hints/#sec-ch-ua-model">{@code
+ * The HTTP <a href="https://wicg.github.io/ua-client-hints/#sec-ch-model">{@code
* Sec-CH-UA-Model}</a> header field name.
*
* @since 30.0
*/
public static final String SEC_CH_UA_MODEL = "Sec-CH-UA-Model";
/**
- * The HTTP <a href="https://wicg.github.io/ua-client-hints/#sec-ch-ua-platform">{@code
+ * The HTTP <a href="https://wicg.github.io/ua-client-hints/#sec-ch-platform">{@code
* Sec-CH-UA-Platform}</a> header field name.
*
* @since 30.0
*/
public static final String SEC_CH_UA_PLATFORM = "Sec-CH-UA-Platform";
/**
- * The HTTP <a href="https://wicg.github.io/ua-client-hints/#sec-ch-ua-platform-version">{@code
+ * The HTTP <a href="https://wicg.github.io/ua-client-hints/#sec-ch-platform-version">{@code
* Sec-CH-UA-Platform-Version}</a> header field name.
*
* @since 30.0
*/
public static final String SEC_CH_UA_PLATFORM_VERSION = "Sec-CH-UA-Platform-Version";
/**
- * The HTTP <a href="https://wicg.github.io/ua-client-hints/#sec-ch-ua-full-version">{@code
+ * The HTTP <a href="https://wicg.github.io/ua-client-hints/#sec-ch-full-version">{@code
* Sec-CH-UA-Full-Version}</a> header field name.
*
* @since 30.0
*/
public static final String SEC_CH_UA_FULL_VERSION = "Sec-CH-UA-Full-Version";
/**
- * The HTTP <a href="https://wicg.github.io/ua-client-hints/#sec-ch-ua-mobile">{@code
+ * The HTTP <a href="https://wicg.github.io/ua-client-hints/#sec-ch-mobile">{@code
* Sec-CH-UA-Mobile}</a> header field name.
*
* @since 30.0
*/
public static final String SEC_CH_UA_MOBILE = "Sec-CH-UA-Mobile";
- /**
- * The HTTP <a href="https://wicg.github.io/ua-client-hints/#sec-ch-ua-bitness">{@code
- * Sec-CH-UA-Bitness}</a> header field name.
- *
- * @since 31.0
- */
- public static final String SEC_CH_UA_BITNESS = "Sec-CH-UA-Bitness";
/**
* The HTTP <a href="https://w3c.github.io/webappsec-fetch-metadata/">{@code Sec-Fetch-Dest}</a>
diff --git a/android/guava/src/com/google/common/net/InetAddresses.java b/android/guava/src/com/google/common/net/InetAddresses.java
index 4e2aa69..a4a16e2 100644
--- a/android/guava/src/com/google/common/net/InetAddresses.java
+++ b/android/guava/src/com/google/common/net/InetAddresses.java
@@ -32,7 +32,7 @@
import java.nio.ByteBuffer;
import java.util.Arrays;
import java.util.Locale;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* Static utility methods pertaining to {@link InetAddress} instances.
@@ -97,7 +97,6 @@
*/
@Beta
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public final class InetAddresses {
private static final int IPV4_PART_COUNT = 4;
private static final int IPV6_PART_COUNT = 8;
@@ -134,11 +133,6 @@
*
* <p>Anything after a {@code %} in an IPv6 address is ignored (assumed to be a Scope ID).
*
- * <p>This method accepts non-ASCII digits, for example {@code "192.168.0.1"} (those are fullwidth
- * characters). That is consistent with {@link InetAddress}, but not with various RFCs. If you
- * want to accept ASCII digits only, you can use something like {@code
- * CharMatcher.ascii().matchesAllOf(ipString)}.
- *
* @param ipString {@code String} containing an IPv4 or IPv6 string literal, e.g. {@code
* "192.168.0.1"} or {@code "2001:db8::1"}
* @return {@link InetAddress} representing the argument
@@ -159,11 +153,6 @@
* Returns {@code true} if the supplied string is a valid IP string literal, {@code false}
* otherwise.
*
- * <p>This method accepts non-ASCII digits, for example {@code "192.168.0.1"} (those are fullwidth
- * characters). That is consistent with {@link InetAddress}, but not with various RFCs. If you
- * want to accept ASCII digits only, you can use something like {@code
- * CharMatcher.ascii().matchesAllOf(ipString)}.
- *
* @param ipString {@code String} to evaluated as an IP string literal
* @return {@code true} if the argument is a valid IP string literal
*/
@@ -172,9 +161,8 @@
}
/** Returns {@code null} if unable to parse into a {@code byte[]}. */
- @CheckForNull
- private static byte[] ipStringToBytes(String ipStringParam) {
- String ipString = ipStringParam;
+ @NullableDecl
+ private static byte[] ipStringToBytes(String ipString) {
// Make a first pass to categorize the characters in this string.
boolean hasColon = false;
boolean hasDot = false;
@@ -217,7 +205,7 @@
return null;
}
- @CheckForNull
+ @NullableDecl
private static byte[] textToNumericFormatV4(String ipString) {
if (IPV4_DELIMITER_MATCHER.countIn(ipString) + 1 != IPV4_PART_COUNT) {
return null; // Wrong number of parts
@@ -243,7 +231,7 @@
return bytes;
}
- @CheckForNull
+ @NullableDecl
private static byte[] textToNumericFormatV6(String ipString) {
// An address can have [2..8] colons.
int delimiterCount = IPV6_DELIMITER_MATCHER.countIn(ipString);
@@ -314,7 +302,7 @@
return rawBytes.array();
}
- @CheckForNull
+ @NullableDecl
private static String convertDottedQuadToHex(String ipString) {
int lastColon = ipString.lastIndexOf(':');
String initialPart = ipString.substring(0, lastColon + 1);
@@ -512,15 +500,10 @@
* Returns an InetAddress representing the literal IPv4 or IPv6 host portion of a URL, encoded in
* the format specified by RFC 3986 section 3.2.2.
*
- * <p>This method is similar to {@link InetAddresses#forString(String)}, however, it requires that
- * IPv6 addresses are surrounded by square brackets.
+ * <p>This function is similar to {@link InetAddresses#forString(String)}, however, it requires
+ * that IPv6 addresses are surrounded by square brackets.
*
- * <p>This method is the inverse of {@link InetAddresses#toUriString(java.net.InetAddress)}.
- *
- * <p>This method accepts non-ASCII digits, for example {@code "192.168.0.1"} (those are fullwidth
- * characters). That is consistent with {@link InetAddress}, but not with various RFCs. If you
- * want to accept ASCII digits only, you can use something like {@code
- * CharMatcher.ascii().matchesAllOf(ipString)}.
+ * <p>This function is the inverse of {@link InetAddresses#toUriString(java.net.InetAddress)}.
*
* @param hostAddr A RFC 3986 section 3.2.2 encoded IPv4 or IPv6 address
* @return an InetAddress representing the address in {@code hostAddr}
@@ -536,7 +519,7 @@
return addr;
}
- @CheckForNull
+ @NullableDecl
private static InetAddress forUriStringNoThrow(String hostAddr) {
checkNotNull(hostAddr);
@@ -564,11 +547,6 @@
* Returns {@code true} if the supplied string is a valid URI IP string literal, {@code false}
* otherwise.
*
- * <p>This method accepts non-ASCII digits, for example {@code "192.168.0.1"} (those are fullwidth
- * characters). That is consistent with {@link InetAddress}, but not with various RFCs. If you
- * want to accept ASCII digits only, you can use something like {@code
- * CharMatcher.ascii().matchesAllOf(ipString)}.
- *
* @param ipString {@code String} to evaluated as an IP URI host string literal
* @return {@code true} if the argument is a valid IP URI host
*/
@@ -685,7 +663,7 @@
*/
// TODO: why is this public?
public TeredoInfo(
- @CheckForNull Inet4Address server, @CheckForNull Inet4Address client, int port, int flags) {
+ @NullableDecl Inet4Address server, @NullableDecl Inet4Address client, int port, int flags) {
checkArgument(
(port >= 0) && (port <= 0xffff), "port '%s' is out of range (0 <= port <= 0xffff)", port);
checkArgument(
@@ -864,10 +842,6 @@
* obscure {@link Inet6Address} methods, but it would be unwise to depend on such a
* poorly-documented feature.)
*
- * <p>This method accepts non-ASCII digits. That is consistent with {@link InetAddress}, but not
- * with various RFCs. If you want to accept ASCII digits only, you can use something like {@code
- * CharMatcher.ascii().matchesAllOf(ipString)}.
- *
* @param ipString {@code String} to be examined for embedded IPv4-mapped IPv6 address format
* @return {@code true} if the argument is a valid "mapped" address
* @since 10.0
@@ -895,7 +869,7 @@
*
* <p>HACK: As long as applications continue to use IPv4 addresses for indexing into tables,
* accounting, et cetera, it may be necessary to <b>coerce</b> IPv6 addresses into IPv4 addresses.
- * This method does so by hashing 64 bits of the IPv6 address into {@code 224.0.0.0/3} (64 bits
+ * This function does so by hashing 64 bits of the IPv6 address into {@code 224.0.0.0/3} (64 bits
* into 29 bits):
*
* <ul>
@@ -905,7 +879,7 @@
*
* <p>A "coerced" IPv4 address is equivalent to itself.
*
- * <p>NOTE: This method is failsafe for security purposes: ALL IPv6 addresses (except localhost
+ * <p>NOTE: This function is failsafe for security purposes: ALL IPv6 addresses (except localhost
* (::1)) are hashed to avoid the security risk associated with extracting an embedded IPv4
* address that might permit elevated privileges.
*
@@ -943,7 +917,7 @@
}
// Many strategies for hashing are possible. This might suffice for now.
- int coercedHash = Hashing.murmur3_32_fixed().hashLong(addressAsLong).asInt();
+ int coercedHash = Hashing.murmur3_32().hashLong(addressAsLong).asInt();
// Squash into 224/4 Multicast and 240/4 Reserved space (i.e. 224/3).
coercedHash |= 0xe0000000;
@@ -1141,8 +1115,8 @@
*/
public static boolean isMaximum(InetAddress address) {
byte[] addr = address.getAddress();
- for (byte b : addr) {
- if (b != (byte) 0xff) {
+ for (int i = 0; i < addr.length; i++) {
+ if (addr[i] != (byte) 0xff) {
return false;
}
}
diff --git a/android/guava/src/com/google/common/net/InternetDomainName.java b/android/guava/src/com/google/common/net/InternetDomainName.java
index 5873449..cc7a36d 100644
--- a/android/guava/src/com/google/common/net/InternetDomainName.java
+++ b/android/guava/src/com/google/common/net/InternetDomainName.java
@@ -30,7 +30,7 @@
import com.google.thirdparty.publicsuffix.PublicSuffixPatterns;
import com.google.thirdparty.publicsuffix.PublicSuffixType;
import java.util.List;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* An immutable well-formed internet domain name, such as {@code com} or {@code foo.co.uk}. Only
@@ -74,7 +74,6 @@
@Beta
@GwtCompatible(emulated = true)
@Immutable
-@ElementTypesAreNonnullByDefault
public final class InternetDomainName {
private static final CharMatcher DOTS_MATCHER = CharMatcher.anyOf(".\u3002\uFF0E\uFF61");
@@ -201,6 +200,7 @@
* href="https://tools.ietf.org/html/rfc1123#section-2">RFC 1123</a>.
* </ul>
*
+ *
* @param domain A domain name (not IP address)
* @throws IllegalArgumentException if {@code domain} is not syntactically valid according to
* {@link #isValid}
@@ -354,7 +354,6 @@
*
* @since 6.0
*/
- @CheckForNull
public InternetDomainName publicSuffix() {
return hasPublicSuffix() ? ancestor(publicSuffixIndex) : null;
}
@@ -463,7 +462,6 @@
*
* @since 23.3
*/
- @CheckForNull
public InternetDomainName registrySuffix() {
return hasRegistrySuffix() ? ancestor(registrySuffixIndex) : null;
}
@@ -624,7 +622,7 @@
* version of the same domain name would not be considered equal.
*/
@Override
- public boolean equals(@CheckForNull Object object) {
+ public boolean equals(@NullableDecl Object object) {
if (object == this) {
return true;
}
diff --git a/android/guava/src/com/google/common/net/MediaType.java b/android/guava/src/com/google/common/net/MediaType.java
index ca47161..a5b710f 100644
--- a/android/guava/src/com/google/common/net/MediaType.java
+++ b/android/guava/src/com/google/common/net/MediaType.java
@@ -45,7 +45,7 @@
import java.util.Collection;
import java.util.Map;
import java.util.Map.Entry;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* Represents an <a href="http://en.wikipedia.org/wiki/Internet_media_type">Internet Media Type</a>
@@ -75,7 +75,6 @@
@Beta
@GwtCompatible
@Immutable
-@ElementTypesAreNonnullByDefault
public final class MediaType {
private static final String CHARSET_ATTRIBUTE = "charset";
private static final ImmutableListMultimap<String, String> UTF_8_CONSTANT_PARAMETERS =
@@ -764,11 +763,11 @@
private final String subtype;
private final ImmutableListMultimap<String, String> parameters;
- @LazyInit @CheckForNull private String toString;
+ @LazyInit private String toString;
@LazyInit private int hashCode;
- @LazyInit @CheckForNull private Optional<Charset> parsedCharset;
+ @LazyInit private Optional<Charset> parsedCharset;
private MediaType(String type, String subtype, ImmutableListMultimap<String, String> parameters) {
this.type = type;
@@ -1136,7 +1135,7 @@
}
@Override
- public boolean equals(@CheckForNull Object obj) {
+ public boolean equals(@NullableDecl Object obj) {
if (obj == this) {
return true;
} else if (obj instanceof MediaType) {
diff --git a/android/guava/src/com/google/common/net/ParametricNullness.java b/android/guava/src/com/google/common/net/ParametricNullness.java
deleted file mode 100644
index acc3eab..0000000
--- a/android/guava/src/com/google/common/net/ParametricNullness.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2021 The Guava Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.common.net;
-
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.PARAMETER;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-import static javax.annotation.meta.When.UNKNOWN;
-
-import com.google.common.annotations.GwtCompatible;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-import javax.annotation.Nonnull;
-import javax.annotation.meta.TypeQualifierNickname;
-
-/**
- * Marks a "top-level" type-variable usage as (a) a Kotlin platform type when the type argument is
- * non-nullable and (b) nullable when the type argument is nullable. This is the closest we can get
- * to "non-nullable when non-nullable; nullable when nullable" (like the Android <a
- * href="https://android.googlesource.com/platform/libcore/+/master/luni/src/main/java/libcore/util/NullFromTypeParam.java">{@code
- * NullFromTypeParam}</a>). We use this to "undo" {@link ElementTypesAreNonnullByDefault}.
- */
-@GwtCompatible
-@Retention(RUNTIME)
-@Target({FIELD, METHOD, PARAMETER})
-@TypeQualifierNickname
-@Nonnull(when = UNKNOWN)
-@interface ParametricNullness {}
diff --git a/android/guava/src/com/google/common/net/PercentEscaper.java b/android/guava/src/com/google/common/net/PercentEscaper.java
index 7c7de9b..554d04d 100644
--- a/android/guava/src/com/google/common/net/PercentEscaper.java
+++ b/android/guava/src/com/google/common/net/PercentEscaper.java
@@ -19,7 +19,6 @@
import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtCompatible;
import com.google.common.escape.UnicodeEscaper;
-import javax.annotation.CheckForNull;
/**
* A {@code UnicodeEscaper} that escapes some set of Java characters using a UTF-8 based percent
@@ -52,7 +51,6 @@
*/
@Beta
@GwtCompatible
-@ElementTypesAreNonnullByDefault
public final class PercentEscaper extends UnicodeEscaper {
// In some escapers spaces are escaped to '+'
@@ -157,7 +155,6 @@
/** Escapes the given Unicode code point in UTF-8. */
@Override
- @CheckForNull
protected char[] escape(int cp) {
// We should never get negative values here but if we do it will throw an
// IndexOutOfBoundsException, so at least it will get spotted.
diff --git a/android/guava/src/com/google/common/net/UrlEscapers.java b/android/guava/src/com/google/common/net/UrlEscapers.java
index c7e15ef..d4b9f94 100644
--- a/android/guava/src/com/google/common/net/UrlEscapers.java
+++ b/android/guava/src/com/google/common/net/UrlEscapers.java
@@ -24,12 +24,12 @@
* escaping with {@link com.google.common.html.HtmlEscapers} or {@link
* com.google.common.xml.XmlEscapers}.
*
+ *
* @author David Beaumont
* @author Chris Povirk
* @since 15.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
public final class UrlEscapers {
private UrlEscapers() {}
diff --git a/android/guava/src/com/google/common/primitives/Booleans.java b/android/guava/src/com/google/common/primitives/Booleans.java
index 522049b..787766d 100644
--- a/android/guava/src/com/google/common/primitives/Booleans.java
+++ b/android/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 javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* Static utility methods pertaining to {@code boolean} primitives, that are not already found in
@@ -42,7 +42,6 @@
* @since 1.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
public final class Booleans {
private Booleans() {}
@@ -409,14 +408,14 @@
}
@Override
- public boolean contains(@CheckForNull Object target) {
+ public boolean contains(Object target) {
// Overridden to prevent a ton of boxing
return (target instanceof Boolean)
&& Booleans.indexOf(array, (Boolean) target, start, end) != -1;
}
@Override
- public int indexOf(@CheckForNull Object target) {
+ public int indexOf(Object target) {
// Overridden to prevent a ton of boxing
if (target instanceof Boolean) {
int i = Booleans.indexOf(array, (Boolean) target, start, end);
@@ -428,7 +427,7 @@
}
@Override
- public int lastIndexOf(@CheckForNull Object target) {
+ public int lastIndexOf(Object target) {
// Overridden to prevent a ton of boxing
if (target instanceof Boolean) {
int i = Booleans.lastIndexOf(array, (Boolean) target, start, end);
@@ -459,7 +458,7 @@
}
@Override
- public boolean equals(@CheckForNull Object object) {
+ public boolean equals(@NullableDecl Object object) {
if (object == this) {
return true;
}
diff --git a/android/guava/src/com/google/common/primitives/Bytes.java b/android/guava/src/com/google/common/primitives/Bytes.java
index 62997f3..1071a0e 100644
--- a/android/guava/src/com/google/common/primitives/Bytes.java
+++ b/android/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 javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* Static utility methods pertaining to {@code byte} primitives, that are not already found in
@@ -44,7 +44,6 @@
// TODO(kevinb): how to prevent warning on UnsignedBytes when building GWT
// javadoc?
@GwtCompatible
-@ElementTypesAreNonnullByDefault
public final class Bytes {
private Bytes() {}
@@ -271,13 +270,13 @@
}
@Override
- public boolean contains(@CheckForNull Object target) {
+ public boolean contains(Object target) {
// Overridden to prevent a ton of boxing
return (target instanceof Byte) && Bytes.indexOf(array, (Byte) target, start, end) != -1;
}
@Override
- public int indexOf(@CheckForNull Object target) {
+ public int indexOf(Object target) {
// Overridden to prevent a ton of boxing
if (target instanceof Byte) {
int i = Bytes.indexOf(array, (Byte) target, start, end);
@@ -289,7 +288,7 @@
}
@Override
- public int lastIndexOf(@CheckForNull Object target) {
+ public int lastIndexOf(Object target) {
// Overridden to prevent a ton of boxing
if (target instanceof Byte) {
int i = Bytes.lastIndexOf(array, (Byte) target, start, end);
@@ -320,7 +319,7 @@
}
@Override
- public boolean equals(@CheckForNull Object object) {
+ public boolean equals(@NullableDecl Object object) {
if (object == this) {
return true;
}
diff --git a/android/guava/src/com/google/common/primitives/Chars.java b/android/guava/src/com/google/common/primitives/Chars.java
index 4a2e3a3..07fc62f 100644
--- a/android/guava/src/com/google/common/primitives/Chars.java
+++ b/android/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 javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* Static utility methods pertaining to {@code char} primitives, that are not already found in
@@ -46,7 +46,6 @@
* @since 1.0
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
public final class Chars {
private Chars() {}
@@ -541,14 +540,14 @@
}
@Override
- public boolean contains(@CheckForNull Object target) {
+ public boolean contains(Object target) {
// Overridden to prevent a ton of boxing
return (target instanceof Character)
&& Chars.indexOf(array, (Character) target, start, end) != -1;
}
@Override
- public int indexOf(@CheckForNull Object target) {
+ public int indexOf(Object target) {
// Overridden to prevent a ton of boxing
if (target instanceof Character) {
int i = Chars.indexOf(array, (Character) target, start, end);
@@ -560,7 +559,7 @@
}
@Override
- public int lastIndexOf(@CheckForNull Object target) {
+ public int lastIndexOf(Object target) {
// Overridden to prevent a ton of boxing
if (target instanceof Character) {
int i = Chars.lastIndexOf(array, (Character) target, start, end);
@@ -591,7 +590,7 @@
}
@Override
- public boolean equals(@CheckForNull Object object) {
+ public boolean equals(@NullableDecl Object object) {
if (object == this) {
return true;
}
diff --git a/android/guava/src/com/google/common/primitives/Doubles.java b/android/guava/src/com/google/common/primitives/Doubles.java
index ce5df2e..a886fe9 100644
--- a/android/guava/src/com/google/common/primitives/Doubles.java
+++ b/android/guava/src/com/google/common/primitives/Doubles.java
@@ -34,7 +34,7 @@
import java.util.Comparator;
import java.util.List;
import java.util.RandomAccess;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* Static utility methods pertaining to {@code double} primitives, that are not already found in
@@ -47,7 +47,6 @@
* @since 1.0
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
public final class Doubles extends DoublesMethodsForWeb {
private Doubles() {}
@@ -554,14 +553,14 @@
}
@Override
- public boolean contains(@CheckForNull Object target) {
+ public boolean contains(Object target) {
// Overridden to prevent a ton of boxing
return (target instanceof Double)
&& Doubles.indexOf(array, (Double) target, start, end) != -1;
}
@Override
- public int indexOf(@CheckForNull Object target) {
+ public int indexOf(Object target) {
// Overridden to prevent a ton of boxing
if (target instanceof Double) {
int i = Doubles.indexOf(array, (Double) target, start, end);
@@ -573,7 +572,7 @@
}
@Override
- public int lastIndexOf(@CheckForNull Object target) {
+ public int lastIndexOf(Object target) {
// Overridden to prevent a ton of boxing
if (target instanceof Double) {
int i = Doubles.lastIndexOf(array, (Double) target, start, end);
@@ -604,7 +603,7 @@
}
@Override
- public boolean equals(@CheckForNull Object object) {
+ public boolean equals(@NullableDecl Object object) {
if (object == this) {
return true;
}
@@ -703,7 +702,7 @@
*/
@Beta
@GwtIncompatible // regular expressions
- @CheckForNull
+ @NullableDecl
public static Double tryParse(String string) {
if (FLOATING_POINT_PATTERN.matcher(string).matches()) {
// TODO(lowasser): could be potentially optimized, but only with
diff --git a/android/guava/src/com/google/common/primitives/DoublesMethodsForWeb.java b/android/guava/src/com/google/common/primitives/DoublesMethodsForWeb.java
index 949cbe0..04d9651 100644
--- a/android/guava/src/com/google/common/primitives/DoublesMethodsForWeb.java
+++ b/android/guava/src/com/google/common/primitives/DoublesMethodsForWeb.java
@@ -21,5 +21,4 @@
* version.
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
abstract class DoublesMethodsForWeb {}
diff --git a/android/guava/src/com/google/common/primitives/ElementTypesAreNonnullByDefault.java b/android/guava/src/com/google/common/primitives/ElementTypesAreNonnullByDefault.java
deleted file mode 100644
index 44f6869..0000000
--- a/android/guava/src/com/google/common/primitives/ElementTypesAreNonnullByDefault.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) 2021 The Guava Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.common.primitives;
-
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.PARAMETER;
-import static java.lang.annotation.ElementType.TYPE;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-import com.google.common.annotations.GwtCompatible;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-import javax.annotation.Nonnull;
-import javax.annotation.meta.TypeQualifierDefault;
-
-/**
- * Marks all "top-level" types as non-null in a way that is recognized by Kotlin. Note that this
- * unfortunately includes type-variable usages, so we also provide {@link ParametricNullness} to
- * "undo" it as best we can.
- */
-@GwtCompatible
-@Retention(RUNTIME)
-@Target(TYPE)
-@TypeQualifierDefault({FIELD, METHOD, PARAMETER})
-@Nonnull
-@interface ElementTypesAreNonnullByDefault {}
diff --git a/android/guava/src/com/google/common/primitives/Floats.java b/android/guava/src/com/google/common/primitives/Floats.java
index b038cb2..e379ebd 100644
--- a/android/guava/src/com/google/common/primitives/Floats.java
+++ b/android/guava/src/com/google/common/primitives/Floats.java
@@ -34,7 +34,7 @@
import java.util.Comparator;
import java.util.List;
import java.util.RandomAccess;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* Static utility methods pertaining to {@code float} primitives, that are not already found in
@@ -47,7 +47,6 @@
* @since 1.0
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
public final class Floats extends FloatsMethodsForWeb {
private Floats() {}
@@ -548,13 +547,13 @@
}
@Override
- public boolean contains(@CheckForNull Object target) {
+ public boolean contains(Object target) {
// Overridden to prevent a ton of boxing
return (target instanceof Float) && Floats.indexOf(array, (Float) target, start, end) != -1;
}
@Override
- public int indexOf(@CheckForNull Object target) {
+ public int indexOf(Object target) {
// Overridden to prevent a ton of boxing
if (target instanceof Float) {
int i = Floats.indexOf(array, (Float) target, start, end);
@@ -566,7 +565,7 @@
}
@Override
- public int lastIndexOf(@CheckForNull Object target) {
+ public int lastIndexOf(Object target) {
// Overridden to prevent a ton of boxing
if (target instanceof Float) {
int i = Floats.lastIndexOf(array, (Float) target, start, end);
@@ -597,7 +596,7 @@
}
@Override
- public boolean equals(@CheckForNull Object object) {
+ public boolean equals(@NullableDecl Object object) {
if (object == this) {
return true;
}
@@ -662,7 +661,7 @@
*/
@Beta
@GwtIncompatible // regular expressions
- @CheckForNull
+ @NullableDecl
public static Float tryParse(String string) {
if (Doubles.FLOATING_POINT_PATTERN.matcher(string).matches()) {
// TODO(lowasser): could be potentially optimized, but only with
diff --git a/android/guava/src/com/google/common/primitives/FloatsMethodsForWeb.java b/android/guava/src/com/google/common/primitives/FloatsMethodsForWeb.java
index 801e2f3..acdb42f 100644
--- a/android/guava/src/com/google/common/primitives/FloatsMethodsForWeb.java
+++ b/android/guava/src/com/google/common/primitives/FloatsMethodsForWeb.java
@@ -21,5 +21,4 @@
* version.
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
abstract class FloatsMethodsForWeb {}
diff --git a/android/guava/src/com/google/common/primitives/ImmutableDoubleArray.java b/android/guava/src/com/google/common/primitives/ImmutableDoubleArray.java
index 1627fab..63efc45 100644
--- a/android/guava/src/com/google/common/primitives/ImmutableDoubleArray.java
+++ b/android/guava/src/com/google/common/primitives/ImmutableDoubleArray.java
@@ -28,7 +28,7 @@
import java.util.Collection;
import java.util.List;
import java.util.RandomAccess;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* An immutable array of {@code double} values, with an API resembling {@link List}.
@@ -80,7 +80,6 @@
@Beta
@GwtCompatible
@Immutable
-@ElementTypesAreNonnullByDefault
public final class ImmutableDoubleArray implements Serializable {
private static final ImmutableDoubleArray EMPTY = new ImmutableDoubleArray(new double[0]);
@@ -438,17 +437,17 @@
}
@Override
- public boolean contains(@CheckForNull Object target) {
+ public boolean contains(Object target) {
return indexOf(target) >= 0;
}
@Override
- public int indexOf(@CheckForNull Object target) {
+ public int indexOf(Object target) {
return target instanceof Double ? parent.indexOf((Double) target) : -1;
}
@Override
- public int lastIndexOf(@CheckForNull Object target) {
+ public int lastIndexOf(Object target) {
return target instanceof Double ? parent.lastIndexOf((Double) target) : -1;
}
@@ -458,7 +457,7 @@
}
@Override
- public boolean equals(@CheckForNull Object object) {
+ public boolean equals(@NullableDecl Object object) {
if (object instanceof AsList) {
AsList that = (AsList) object;
return this.parent.equals(that.parent);
@@ -498,7 +497,7 @@
* values as this one, in the same order. Values are compared as if by {@link Double#equals}.
*/
@Override
- public boolean equals(@CheckForNull Object object) {
+ public boolean equals(@NullableDecl Object object) {
if (object == this) {
return true;
}
diff --git a/android/guava/src/com/google/common/primitives/ImmutableIntArray.java b/android/guava/src/com/google/common/primitives/ImmutableIntArray.java
index 8f972c4..02d9b50 100644
--- a/android/guava/src/com/google/common/primitives/ImmutableIntArray.java
+++ b/android/guava/src/com/google/common/primitives/ImmutableIntArray.java
@@ -28,7 +28,7 @@
import java.util.Collection;
import java.util.List;
import java.util.RandomAccess;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* An immutable array of {@code int} values, with an API resembling {@link List}.
@@ -80,7 +80,6 @@
@Beta
@GwtCompatible
@Immutable
-@ElementTypesAreNonnullByDefault
public final class ImmutableIntArray implements Serializable {
private static final ImmutableIntArray EMPTY = new ImmutableIntArray(new int[0]);
@@ -433,17 +432,17 @@
}
@Override
- public boolean contains(@CheckForNull Object target) {
+ public boolean contains(Object target) {
return indexOf(target) >= 0;
}
@Override
- public int indexOf(@CheckForNull Object target) {
+ public int indexOf(Object target) {
return target instanceof Integer ? parent.indexOf((Integer) target) : -1;
}
@Override
- public int lastIndexOf(@CheckForNull Object target) {
+ public int lastIndexOf(Object target) {
return target instanceof Integer ? parent.lastIndexOf((Integer) target) : -1;
}
@@ -453,7 +452,7 @@
}
@Override
- public boolean equals(@CheckForNull Object object) {
+ public boolean equals(@NullableDecl Object object) {
if (object instanceof AsList) {
AsList that = (AsList) object;
return this.parent.equals(that.parent);
@@ -493,7 +492,7 @@
* values as this one, in the same order.
*/
@Override
- public boolean equals(@CheckForNull Object object) {
+ public boolean equals(@NullableDecl Object object) {
if (object == this) {
return true;
}
diff --git a/android/guava/src/com/google/common/primitives/ImmutableLongArray.java b/android/guava/src/com/google/common/primitives/ImmutableLongArray.java
index 4ebf5b4..ce0e4b6 100644
--- a/android/guava/src/com/google/common/primitives/ImmutableLongArray.java
+++ b/android/guava/src/com/google/common/primitives/ImmutableLongArray.java
@@ -28,7 +28,7 @@
import java.util.Collection;
import java.util.List;
import java.util.RandomAccess;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* An immutable array of {@code long} values, with an API resembling {@link List}.
@@ -80,7 +80,6 @@
@Beta
@GwtCompatible
@Immutable
-@ElementTypesAreNonnullByDefault
public final class ImmutableLongArray implements Serializable {
private static final ImmutableLongArray EMPTY = new ImmutableLongArray(new long[0]);
@@ -435,17 +434,17 @@
}
@Override
- public boolean contains(@CheckForNull Object target) {
+ public boolean contains(Object target) {
return indexOf(target) >= 0;
}
@Override
- public int indexOf(@CheckForNull Object target) {
+ public int indexOf(Object target) {
return target instanceof Long ? parent.indexOf((Long) target) : -1;
}
@Override
- public int lastIndexOf(@CheckForNull Object target) {
+ public int lastIndexOf(Object target) {
return target instanceof Long ? parent.lastIndexOf((Long) target) : -1;
}
@@ -455,7 +454,7 @@
}
@Override
- public boolean equals(@CheckForNull Object object) {
+ public boolean equals(@NullableDecl Object object) {
if (object instanceof AsList) {
AsList that = (AsList) object;
return this.parent.equals(that.parent);
@@ -495,7 +494,7 @@
* values as this one, in the same order.
*/
@Override
- public boolean equals(@CheckForNull Object object) {
+ public boolean equals(@NullableDecl Object object) {
if (object == this) {
return true;
}
diff --git a/android/guava/src/com/google/common/primitives/Ints.java b/android/guava/src/com/google/common/primitives/Ints.java
index e07bdd8..93b5ba0 100644
--- a/android/guava/src/com/google/common/primitives/Ints.java
+++ b/android/guava/src/com/google/common/primitives/Ints.java
@@ -31,7 +31,7 @@
import java.util.Comparator;
import java.util.List;
import java.util.RandomAccess;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* Static utility methods pertaining to {@code int} primitives, that are not already found in either
@@ -44,7 +44,6 @@
* @since 1.0
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
public final class Ints extends IntsMethodsForWeb {
private Ints() {}
@@ -594,13 +593,13 @@
}
@Override
- public boolean contains(@CheckForNull Object target) {
+ public boolean contains(Object target) {
// Overridden to prevent a ton of boxing
return (target instanceof Integer) && Ints.indexOf(array, (Integer) target, start, end) != -1;
}
@Override
- public int indexOf(@CheckForNull Object target) {
+ public int indexOf(Object target) {
// Overridden to prevent a ton of boxing
if (target instanceof Integer) {
int i = Ints.indexOf(array, (Integer) target, start, end);
@@ -612,7 +611,7 @@
}
@Override
- public int lastIndexOf(@CheckForNull Object target) {
+ public int lastIndexOf(Object target) {
// Overridden to prevent a ton of boxing
if (target instanceof Integer) {
int i = Ints.lastIndexOf(array, (Integer) target, start, end);
@@ -643,7 +642,7 @@
}
@Override
- public boolean equals(@CheckForNull Object object) {
+ public boolean equals(@NullableDecl Object object) {
if (object == this) {
return true;
}
@@ -707,7 +706,7 @@
* @since 11.0
*/
@Beta
- @CheckForNull
+ @NullableDecl
public static Integer tryParse(String string) {
return tryParse(string, 10);
}
@@ -733,7 +732,7 @@
* @since 19.0
*/
@Beta
- @CheckForNull
+ @NullableDecl
public static Integer tryParse(String string, int radix) {
Long result = Longs.tryParse(string, radix);
if (result == null || result.longValue() != result.intValue()) {
diff --git a/android/guava/src/com/google/common/primitives/IntsMethodsForWeb.java b/android/guava/src/com/google/common/primitives/IntsMethodsForWeb.java
index c59c6b0..cb87bd2 100644
--- a/android/guava/src/com/google/common/primitives/IntsMethodsForWeb.java
+++ b/android/guava/src/com/google/common/primitives/IntsMethodsForWeb.java
@@ -21,5 +21,4 @@
* version.
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
abstract class IntsMethodsForWeb {}
diff --git a/android/guava/src/com/google/common/primitives/Longs.java b/android/guava/src/com/google/common/primitives/Longs.java
index 6f60656..81838ce 100644
--- a/android/guava/src/com/google/common/primitives/Longs.java
+++ b/android/guava/src/com/google/common/primitives/Longs.java
@@ -30,7 +30,7 @@
import java.util.Comparator;
import java.util.List;
import java.util.RandomAccess;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* Static utility methods pertaining to {@code long} primitives, that are not already found in
@@ -43,7 +43,6 @@
* @since 1.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
public final class Longs {
private Longs() {}
@@ -362,7 +361,7 @@
* @since 14.0
*/
@Beta
- @CheckForNull
+ @NullableDecl
public static Long tryParse(String string) {
return tryParse(string, 10);
}
@@ -388,7 +387,7 @@
* @since 19.0
*/
@Beta
- @CheckForNull
+ @NullableDecl
public static Long tryParse(String string, int radix) {
if (checkNotNull(string).isEmpty()) {
return null;
@@ -690,13 +689,13 @@
}
@Override
- public boolean contains(@CheckForNull Object target) {
+ public boolean contains(Object target) {
// Overridden to prevent a ton of boxing
return (target instanceof Long) && Longs.indexOf(array, (Long) target, start, end) != -1;
}
@Override
- public int indexOf(@CheckForNull Object target) {
+ public int indexOf(Object target) {
// Overridden to prevent a ton of boxing
if (target instanceof Long) {
int i = Longs.indexOf(array, (Long) target, start, end);
@@ -708,7 +707,7 @@
}
@Override
- public int lastIndexOf(@CheckForNull Object target) {
+ public int lastIndexOf(Object target) {
// Overridden to prevent a ton of boxing
if (target instanceof Long) {
int i = Longs.lastIndexOf(array, (Long) target, start, end);
@@ -739,7 +738,7 @@
}
@Override
- public boolean equals(@CheckForNull Object object) {
+ public boolean equals(@NullableDecl Object object) {
if (object == this) {
return true;
}
diff --git a/android/guava/src/com/google/common/primitives/ParametricNullness.java b/android/guava/src/com/google/common/primitives/ParametricNullness.java
deleted file mode 100644
index 17d606c..0000000
--- a/android/guava/src/com/google/common/primitives/ParametricNullness.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2021 The Guava Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.common.primitives;
-
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.PARAMETER;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-import static javax.annotation.meta.When.UNKNOWN;
-
-import com.google.common.annotations.GwtCompatible;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-import javax.annotation.Nonnull;
-import javax.annotation.meta.TypeQualifierNickname;
-
-/**
- * Marks a "top-level" type-variable usage as (a) a Kotlin platform type when the type argument is
- * non-nullable and (b) nullable when the type argument is nullable. This is the closest we can get
- * to "non-nullable when non-nullable; nullable when nullable" (like the Android <a
- * href="https://android.googlesource.com/platform/libcore/+/master/luni/src/main/java/libcore/util/NullFromTypeParam.java">{@code
- * NullFromTypeParam}</a>). We use this to "undo" {@link ElementTypesAreNonnullByDefault}.
- */
-@GwtCompatible
-@Retention(RUNTIME)
-@Target({FIELD, METHOD, PARAMETER})
-@TypeQualifierNickname
-@Nonnull(when = UNKNOWN)
-@interface ParametricNullness {}
diff --git a/android/guava/src/com/google/common/primitives/ParseRequest.java b/android/guava/src/com/google/common/primitives/ParseRequest.java
index a102d69..97b0f1b 100644
--- a/android/guava/src/com/google/common/primitives/ParseRequest.java
+++ b/android/guava/src/com/google/common/primitives/ParseRequest.java
@@ -18,7 +18,6 @@
/** A string to be parsed as a number and the radix to interpret it in. */
@GwtCompatible
-@ElementTypesAreNonnullByDefault
final class ParseRequest {
final String rawValue;
final int radix;
diff --git a/android/guava/src/com/google/common/primitives/Platform.java b/android/guava/src/com/google/common/primitives/Platform.java
index 83b2485..82b902b 100644
--- a/android/guava/src/com/google/common/primitives/Platform.java
+++ b/android/guava/src/com/google/common/primitives/Platform.java
@@ -18,7 +18,6 @@
/** Methods factored out so that they can be emulated differently in GWT. */
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
final class Platform {
static void checkGwtRpcEnabled() {}
diff --git a/android/guava/src/com/google/common/primitives/Primitives.java b/android/guava/src/com/google/common/primitives/Primitives.java
index 7ceed03..1bdc740 100644
--- a/android/guava/src/com/google/common/primitives/Primitives.java
+++ b/android/guava/src/com/google/common/primitives/Primitives.java
@@ -30,7 +30,6 @@
* @since 1.0
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public final class Primitives {
private Primitives() {}
diff --git a/android/guava/src/com/google/common/primitives/Shorts.java b/android/guava/src/com/google/common/primitives/Shorts.java
index 09e0f7c..dc58138 100644
--- a/android/guava/src/com/google/common/primitives/Shorts.java
+++ b/android/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 javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* Static utility methods pertaining to {@code short} primitives, that are not already found in
@@ -44,7 +44,6 @@
* @since 1.0
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
public final class Shorts extends ShortsMethodsForWeb {
private Shorts() {}
@@ -593,13 +592,13 @@
}
@Override
- public boolean contains(@CheckForNull Object target) {
+ public boolean contains(@NullableDecl 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(@CheckForNull Object target) {
+ public int indexOf(@NullableDecl Object target) {
// Overridden to prevent a ton of boxing
if (target instanceof Short) {
int i = Shorts.indexOf(array, (Short) target, start, end);
@@ -611,7 +610,7 @@
}
@Override
- public int lastIndexOf(@CheckForNull Object target) {
+ public int lastIndexOf(@NullableDecl Object target) {
// Overridden to prevent a ton of boxing
if (target instanceof Short) {
int i = Shorts.lastIndexOf(array, (Short) target, start, end);
@@ -642,7 +641,7 @@
}
@Override
- public boolean equals(@CheckForNull Object object) {
+ public boolean equals(@NullableDecl Object object) {
if (object == this) {
return true;
}
diff --git a/android/guava/src/com/google/common/primitives/ShortsMethodsForWeb.java b/android/guava/src/com/google/common/primitives/ShortsMethodsForWeb.java
index bb0ff10..c362768 100644
--- a/android/guava/src/com/google/common/primitives/ShortsMethodsForWeb.java
+++ b/android/guava/src/com/google/common/primitives/ShortsMethodsForWeb.java
@@ -21,5 +21,4 @@
* version.
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
abstract class ShortsMethodsForWeb {}
diff --git a/android/guava/src/com/google/common/primitives/SignedBytes.java b/android/guava/src/com/google/common/primitives/SignedBytes.java
index 5fabaab..e475c41 100644
--- a/android/guava/src/com/google/common/primitives/SignedBytes.java
+++ b/android/guava/src/com/google/common/primitives/SignedBytes.java
@@ -36,7 +36,6 @@
// TODO(kevinb): how to prevent warning on UnsignedBytes when building GWT
// javadoc?
@GwtCompatible
-@ElementTypesAreNonnullByDefault
public final class SignedBytes {
private SignedBytes() {}
diff --git a/android/guava/src/com/google/common/primitives/UnsignedBytes.java b/android/guava/src/com/google/common/primitives/UnsignedBytes.java
index bf9a306..4275f8a 100644
--- a/android/guava/src/com/google/common/primitives/UnsignedBytes.java
+++ b/android/guava/src/com/google/common/primitives/UnsignedBytes.java
@@ -17,7 +17,6 @@
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkPositionIndexes;
-import static java.util.Objects.requireNonNull;
import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtIncompatible;
@@ -44,7 +43,6 @@
* @since 1.0
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public final class UnsignedBytes {
private UnsignedBytes() {}
@@ -439,12 +437,9 @@
try {
Class<?> theClass = Class.forName(UNSAFE_COMPARATOR_NAME);
- // requireNonNull is safe because the class is an enum.
- Object[] constants = requireNonNull(theClass.getEnumConstants());
-
// yes, UnsafeComparator does implement Comparator<byte[]>
@SuppressWarnings("unchecked")
- Comparator<byte[]> comparator = (Comparator<byte[]>) constants[0];
+ Comparator<byte[]> comparator = (Comparator<byte[]>) theClass.getEnumConstants()[0];
return comparator;
} catch (Throwable t) { // ensure we really catch *everything*
return lexicographicalComparatorJavaImpl();
diff --git a/android/guava/src/com/google/common/primitives/UnsignedInteger.java b/android/guava/src/com/google/common/primitives/UnsignedInteger.java
index 0b30cef..74740e9 100644
--- a/android/guava/src/com/google/common/primitives/UnsignedInteger.java
+++ b/android/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 javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* A wrapper class for unsigned {@code int} values, supporting arithmetic operations.
@@ -39,7 +39,6 @@
* @since 11.0
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
public final class UnsignedInteger extends Number implements Comparable<UnsignedInteger> {
public static final UnsignedInteger ZERO = fromIntBits(0);
public static final UnsignedInteger ONE = fromIntBits(1);
@@ -227,7 +226,7 @@
}
@Override
- public boolean equals(@CheckForNull Object obj) {
+ public boolean equals(@NullableDecl Object obj) {
if (obj instanceof UnsignedInteger) {
UnsignedInteger other = (UnsignedInteger) obj;
return value == other.value;
diff --git a/android/guava/src/com/google/common/primitives/UnsignedInts.java b/android/guava/src/com/google/common/primitives/UnsignedInts.java
index ec6474e..9eda969 100644
--- a/android/guava/src/com/google/common/primitives/UnsignedInts.java
+++ b/android/guava/src/com/google/common/primitives/UnsignedInts.java
@@ -47,7 +47,6 @@
*/
@Beta
@GwtCompatible
-@ElementTypesAreNonnullByDefault
public final class UnsignedInts {
static final long INT_MASK = 0xffffffffL;
diff --git a/android/guava/src/com/google/common/primitives/UnsignedLong.java b/android/guava/src/com/google/common/primitives/UnsignedLong.java
index d803634..4485790 100644
--- a/android/guava/src/com/google/common/primitives/UnsignedLong.java
+++ b/android/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 javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* A wrapper class for unsigned {@code long} values, supporting arithmetic operations.
@@ -38,7 +38,6 @@
* @since 11.0
*/
@GwtCompatible(serializable = true)
-@ElementTypesAreNonnullByDefault
public final class UnsignedLong extends Number implements Comparable<UnsignedLong>, Serializable {
private static final long UNSIGNED_MASK = 0x7fffffffffffffffL;
@@ -196,12 +195,12 @@
*/
@Override
public float floatValue() {
- if (value >= 0) {
- return (float) value;
+ @SuppressWarnings("cast")
+ float fValue = (float) (value & UNSIGNED_MASK);
+ if (value < 0) {
+ fValue += 0x1.0p63f;
}
- // The top bit is set, which means that the float value is going to come from the top 24 bits.
- // So we can ignore the bottom 8, except for rounding. See doubleValue() for more.
- return (float) ((value >>> 1) | (value & 1)) * 2f;
+ return fValue;
}
/**
@@ -210,15 +209,12 @@
*/
@Override
public double doubleValue() {
- if (value >= 0) {
- return (double) value;
+ @SuppressWarnings("cast")
+ double dValue = (double) (value & UNSIGNED_MASK);
+ if (value < 0) {
+ dValue += 0x1.0p63;
}
- // The top bit is set, which means that the double value is going to come from the top 53 bits.
- // So we can ignore the bottom 11, except for rounding. We can unsigned-shift right 1, aka
- // unsigned-divide by 2, and convert that. Then we'll get exactly half of the desired double
- // value. But in the specific case where the bottom two bits of the original number are 01, we
- // want to replace that with 1 in the shifted value for correct rounding.
- return (double) ((value >>> 1) | (value & 1)) * 2.0;
+ return dValue;
}
/** Returns the value of this {@code UnsignedLong} as a {@link BigInteger}. */
@@ -242,7 +238,7 @@
}
@Override
- public boolean equals(@CheckForNull Object obj) {
+ public boolean equals(@NullableDecl Object obj) {
if (obj instanceof UnsignedLong) {
UnsignedLong other = (UnsignedLong) obj;
return value == other.value;
diff --git a/android/guava/src/com/google/common/primitives/UnsignedLongs.java b/android/guava/src/com/google/common/primitives/UnsignedLongs.java
index 31c51cc..a1fccc2 100644
--- a/android/guava/src/com/google/common/primitives/UnsignedLongs.java
+++ b/android/guava/src/com/google/common/primitives/UnsignedLongs.java
@@ -50,7 +50,6 @@
*/
@Beta
@GwtCompatible
-@ElementTypesAreNonnullByDefault
public final class UnsignedLongs {
private UnsignedLongs() {}
diff --git a/android/guava/src/com/google/common/reflect/AbstractInvocationHandler.java b/android/guava/src/com/google/common/reflect/AbstractInvocationHandler.java
index 4666f99..67655da 100644
--- a/android/guava/src/com/google/common/reflect/AbstractInvocationHandler.java
+++ b/android/guava/src/com/google/common/reflect/AbstractInvocationHandler.java
@@ -19,8 +19,7 @@
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.Arrays;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* Abstract implementation of {@link InvocationHandler} that handles {@link Object#equals}, {@link
@@ -40,7 +39,6 @@
* @since 12.0
*/
@Beta
-@ElementTypesAreNonnullByDefault
public abstract class AbstractInvocationHandler implements InvocationHandler {
private static final Object[] NO_ARGS = {};
@@ -61,8 +59,7 @@
* </ul>
*/
@Override
- @CheckForNull
- public final Object invoke(Object proxy, Method method, @CheckForNull @Nullable Object[] args)
+ public final Object invoke(Object proxy, Method method, @NullableDecl Object[] args)
throws Throwable {
if (args == null) {
args = NO_ARGS;
@@ -97,8 +94,7 @@
* <p>Unlike {@link #invoke}, {@code args} will never be null. When the method has no parameter,
* an empty array is passed in.
*/
- @CheckForNull
- protected abstract Object handleInvocation(Object proxy, Method method, @Nullable Object[] args)
+ protected abstract Object handleInvocation(Object proxy, Method method, Object[] args)
throws Throwable;
/**
@@ -113,7 +109,7 @@
* <p>Subclasses can override this method to provide custom equality.
*/
@Override
- public boolean equals(@CheckForNull Object obj) {
+ public boolean equals(Object obj) {
return super.equals(obj);
}
diff --git a/android/guava/src/com/google/common/reflect/ClassPath.java b/android/guava/src/com/google/common/reflect/ClassPath.java
index de693da..427914c 100644
--- a/android/guava/src/com/google/common/reflect/ClassPath.java
+++ b/android/guava/src/com/google/common/reflect/ClassPath.java
@@ -30,6 +30,9 @@
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Maps;
+import com.google.common.collect.MultimapBuilder;
+import com.google.common.collect.SetMultimap;
+import com.google.common.collect.Sets;
import com.google.common.io.ByteSource;
import com.google.common.io.CharSource;
import com.google.common.io.Resources;
@@ -51,40 +54,19 @@
import java.util.jar.JarFile;
import java.util.jar.Manifest;
import java.util.logging.Logger;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* Scans the source of a {@link ClassLoader} and finds all loadable classes and resources.
*
- * <h2>Prefer <a href="https://github.com/classgraph/classgraph/wiki">ClassGraph</a> over {@code
- * ClassPath}</h2>
- *
- * <p>We recommend using <a href="https://github.com/classgraph/classgraph/wiki">ClassGraph</a>
- * instead of {@code ClassPath}. ClassGraph improves upon {@code ClassPath} in several ways,
- * including addressing many of its limitations. Limitations of {@code ClassPath} include:
+ * <p><b>Warning:</b> Current limitations:
*
* <ul>
- * <li>It looks only for files and JARs in URLs available from {@link URLClassLoader} instances or
- * the {@linkplain ClassLoader#getSystemClassLoader() system class loader}. This means it does
- * not look for classes in the <i>module path</i>.
- * <li>It understands only {@code file:} URLs. This means that it does not understand <a
- * href="https://openjdk.java.net/jeps/220">{@code jrt:/} URLs</a>, among <a
- * href="https://github.com/classgraph/classgraph/wiki/Classpath-specification-mechanisms">others</a>.
- * <li>It does not know how to look for classes when running under an Android VM. (ClassGraph does
- * not support this directly, either, but ClassGraph documents how to <a
- * href="https://github.com/classgraph/classgraph/wiki/Build-Time-Scanning">perform build-time
- * classpath scanning and make the results available to an Android app</a>.)
- * <li>Like all of Guava, it is not tested under Windows. We have gotten <a
- * href="https://github.com/google/guava/issues/2130">a report of a specific bug under
- * Windows</a>.
- * <li>It <a href="https://github.com/google/guava/issues/2712">returns only one resource for a
- * given path</a>, even if resources with that path appear in multiple jars or directories.
- * <li>It assumes that <a href="https://github.com/google/guava/issues/3349">any class with a
- * {@code $} in its name is a nested class</a>.
+ * <li>Looks only for files and JARs in URLs available from {@link URLClassLoader} instances or
+ * the {@linkplain ClassLoader#getSystemClassLoader() system class loader}.
+ * <li>Only understands {@code file:} URLs.
* </ul>
*
- * <h2>{@code ClassPath} and symlinks</h2>
- *
* <p>In the case of directory classloaders, symlinks are supported but cycles are not traversed.
* This guarantees discovery of each <em>unique</em> loadable resource. However, not all possible
* aliases for resources on cyclic paths will be listed.
@@ -93,10 +75,17 @@
* @since 14.0
*/
@Beta
-@ElementTypesAreNonnullByDefault
public final class ClassPath {
private static final Logger logger = Logger.getLogger(ClassPath.class.getName());
+ private static final Predicate<ClassInfo> IS_TOP_LEVEL =
+ new Predicate<ClassInfo>() {
+ @Override
+ public boolean apply(ClassInfo info) {
+ return info.className.indexOf('$') == -1;
+ }
+ };
+
/** Separator for the Class-Path manifest attribute value in jar files. */
private static final Splitter CLASS_PATH_ATTRIBUTE_SEPARATOR =
Splitter.on(" ").omitEmptyStrings();
@@ -126,21 +115,9 @@
* failed.
*/
public static ClassPath from(ClassLoader classloader) throws IOException {
- ImmutableSet<LocationInfo> locations = locationsFrom(classloader);
-
- // Add all locations to the scanned set so that in a classpath [jar1, jar2], where jar1 has a
- // manifest with Class-Path pointing to jar2, we won't scan jar2 twice.
- Set<File> scanned = new HashSet<>();
- for (LocationInfo location : locations) {
- scanned.add(location.file());
- }
-
- // Scan all locations
- ImmutableSet.Builder<ResourceInfo> builder = ImmutableSet.builder();
- for (LocationInfo location : locations) {
- builder.addAll(location.scanResources(scanned));
- }
- return new ClassPath(builder.build());
+ DefaultScanner scanner = new DefaultScanner();
+ scanner.scan(classloader);
+ return new ClassPath(scanner.getResources());
}
/**
@@ -160,21 +137,9 @@
return FluentIterable.from(resources).filter(ClassInfo.class).toSet();
}
- /**
- * Returns all top level classes loadable from the current class path. Note that "top-level-ness"
- * is determined heuristically by class name (see {@link ClassInfo#isTopLevel}).
- */
+ /** Returns all top level classes loadable from the current class path. */
public ImmutableSet<ClassInfo> getTopLevelClasses() {
- return FluentIterable.from(resources)
- .filter(ClassInfo.class)
- .filter(
- new Predicate<ClassInfo>() {
- @Override
- public boolean apply(ClassInfo info) {
- return info.isTopLevel();
- }
- })
- .toSet();
+ return FluentIterable.from(resources).filter(ClassInfo.class).filter(IS_TOP_LEVEL).toSet();
}
/** Returns all top level classes whose package name is {@code packageName}. */
@@ -287,7 +252,7 @@
}
@Override
- public boolean equals(@CheckForNull Object obj) {
+ public boolean equals(Object obj) {
if (obj instanceof ResourceInfo) {
ResourceInfo that = (ResourceInfo) obj;
return resourceName.equals(that.resourceName) && loader == that.loader;
@@ -319,13 +284,8 @@
/**
* Returns the package name of the class, without attempting to load the class.
*
- * <p>Behaves similarly to {@code class.getPackage().}{@link Package#getName() getName()} but
- * does not require the class (or package) to be loaded.
- *
- * <p>But note that this method may behave differently for a class in the default package: For
- * such classes, this method always returns an empty string. But under some version of Java,
- * {@code class.getPackage().getName()} produces a {@code NullPointerException} because {@code
- * class.getPackage()} returns {@code null}.
+ * <p>Behaves identically to {@link Package#getName()} but does not require the class (or
+ * package) to be loaded.
*/
public String getPackageName() {
return Reflection.getPackageName(className);
@@ -334,11 +294,8 @@
/**
* Returns the simple name of the underlying class as given in the source code.
*
- * <p>Behaves similarly to {@link Class#getSimpleName()} but does not require the class to be
+ * <p>Behaves identically to {@link Class#getSimpleName()} but does not require the class to be
* loaded.
- *
- * <p>But note that this class uses heuristics to identify the simple name. See a related
- * discussion in <a href="https://github.com/google/guava/issues/3349">issue 3349</a>.
*/
public String getSimpleName() {
int lastDollarSign = className.lastIndexOf('$');
@@ -368,18 +325,6 @@
}
/**
- * Returns true if the class name "looks to be" top level (not nested), that is, it includes no
- * '$' in the name. This method may return false for a top-level class that's intentionally
- * named with the '$' character. If this is a concern, you could use {@link #load} and then
- * check on the loaded {@link Class} object instead.
- *
- * @since 30.1
- */
- public boolean isTopLevel() {
- return className.indexOf('$') == -1;
- }
-
- /**
* Loads (but doesn't link or initialize) the class.
*
* @throws LinkageError when there were errors in loading classes that this class depends on.
@@ -401,64 +346,36 @@
}
/**
- * Returns all locations that {@code classloader} and parent loaders load classes and resources
- * from. Callers can {@linkplain LocationInfo#scanResources scan} individual locations selectively
- * or even in parallel.
+ * Abstract class that scans through the class path represented by a {@link ClassLoader} and calls
+ * {@link #scanDirectory} and {@link #scanJarFile} for directories and jar files on the class path
+ * respectively.
*/
- static ImmutableSet<LocationInfo> locationsFrom(ClassLoader classloader) {
- ImmutableSet.Builder<LocationInfo> builder = ImmutableSet.builder();
- for (Map.Entry<File, ClassLoader> entry : getClassPathEntries(classloader).entrySet()) {
- builder.add(new LocationInfo(entry.getKey(), entry.getValue()));
- }
- return builder.build();
- }
+ abstract static class Scanner {
- /**
- * Represents a single location (a directory or a jar file) in the class path and is responsible
- * for scanning resources from this location.
- */
- static final class LocationInfo {
- final File home;
- private final ClassLoader classloader;
+ // We only scan each file once independent of the classloader that resource might be associated
+ // with. Use concurrent set so that subclasses can be thread-safe.
+ private final Set<File> scannedUris = Sets.newConcurrentHashSet();
- LocationInfo(File home, ClassLoader classloader) {
- this.home = checkNotNull(home);
- this.classloader = checkNotNull(classloader);
+ public final void scan(ClassLoader classloader) throws IOException {
+ for (Map.Entry<File, ClassLoader> entry : getClassPathEntries(classloader).entrySet()) {
+ scan(entry.getKey(), entry.getValue());
+ }
}
- /** Returns the file this location is from. */
- public final File file() {
- return home;
- }
-
- /** Scans this location and returns all scanned resources. */
- public ImmutableSet<ResourceInfo> scanResources() throws IOException {
- return scanResources(new HashSet<File>());
+ @VisibleForTesting
+ final void scan(File file, ClassLoader classloader) throws IOException {
+ if (scannedUris.add(file.getCanonicalFile())) {
+ scanFrom(file, classloader);
+ }
}
/**
- * Scans this location and returns all scanned resources.
- *
- * <p>This file and jar files from "Class-Path" entry in the scanned manifest files will be
- * added to {@code scannedFiles}.
- *
- * <p>A file will be scanned at most once even if specified multiple times by one or multiple
- * jar files' "Class-Path" manifest entries. Particularly, if a jar file from the "Class-Path"
- * manifest entry is already in {@code scannedFiles}, either because it was scanned earlier, or
- * it was intentionally added to the set by the caller, it will not be scanned again.
- *
- * <p>Note that when you call {@code location.scanResources(scannedFiles)}, the location will
- * always be scanned even if {@code scannedFiles} already contains it.
+ * Called each time a resource (uniqueness not guaranteed if the class path includes redundant
+ * entries)
*/
- public ImmutableSet<ResourceInfo> scanResources(Set<File> scannedFiles) throws IOException {
- ImmutableSet.Builder<ResourceInfo> builder = ImmutableSet.builder();
- scannedFiles.add(home);
- scan(home, scannedFiles, builder);
- return builder.build();
- }
+ protected abstract void scanResource(ResourceInfo resource) throws IOException;
- private void scan(File file, Set<File> scannedUris, ImmutableSet.Builder<ResourceInfo> builder)
- throws IOException {
+ protected void scanFrom(File file, ClassLoader classloader) throws IOException {
try {
if (!file.exists()) {
return;
@@ -469,15 +386,13 @@
return;
}
if (file.isDirectory()) {
- scanDirectory(file, builder);
+ scanDirectory(classloader, file);
} else {
- scanJar(file, scannedUris, builder);
+ scanJar(file, classloader);
}
}
- private void scanJar(
- File file, Set<File> scannedUris, ImmutableSet.Builder<ResourceInfo> builder)
- throws IOException {
+ private void scanJar(File file, ClassLoader classloader) throws IOException {
JarFile jarFile;
try {
jarFile = new JarFile(file);
@@ -487,37 +402,128 @@
}
try {
for (File path : getClassPathFromManifest(file, jarFile.getManifest())) {
- // We only scan each file once independent of the classloader that file might be
- // associated with.
- if (scannedUris.add(path.getCanonicalFile())) {
- scan(path, scannedUris, builder);
- }
+ scan(path, classloader);
}
- scanJarFile(jarFile, builder);
+ scanJarFile(classloader, jarFile);
} finally {
try {
jarFile.close();
- } catch (IOException ignored) { // similar to try-with-resources, but don't fail scanning
+ } catch (IOException ignored) {
}
}
}
- private void scanJarFile(JarFile file, ImmutableSet.Builder<ResourceInfo> builder) {
+ /**
+ * Returns the class path URIs specified by the {@code Class-Path} manifest attribute, according
+ * to <a
+ * href="http://docs.oracle.com/javase/8/docs/technotes/guides/jar/jar.html#Main_Attributes">JAR
+ * File Specification</a>. If {@code manifest} is null, it means the jar file has no manifest,
+ * and an empty set will be returned.
+ */
+ @VisibleForTesting
+ static ImmutableSet<File> getClassPathFromManifest(
+ File jarFile, @NullableDecl Manifest manifest) {
+ if (manifest == null) {
+ return ImmutableSet.of();
+ }
+ ImmutableSet.Builder<File> builder = ImmutableSet.builder();
+ String classpathAttribute =
+ manifest.getMainAttributes().getValue(Attributes.Name.CLASS_PATH.toString());
+ if (classpathAttribute != null) {
+ for (String path : CLASS_PATH_ATTRIBUTE_SEPARATOR.split(classpathAttribute)) {
+ URL url;
+ try {
+ url = getClassPathEntry(jarFile, path);
+ } catch (MalformedURLException e) {
+ // Ignore bad entry
+ logger.warning("Invalid Class-Path entry: " + path);
+ continue;
+ }
+ if (url.getProtocol().equals("file")) {
+ builder.add(toFile(url));
+ }
+ }
+ }
+ return builder.build();
+ }
+
+ @VisibleForTesting
+ static ImmutableMap<File, ClassLoader> getClassPathEntries(ClassLoader classloader) {
+ LinkedHashMap<File, ClassLoader> entries = Maps.newLinkedHashMap();
+ // Search parent first, since it's the order ClassLoader#loadClass() uses.
+ ClassLoader parent = classloader.getParent();
+ if (parent != null) {
+ entries.putAll(getClassPathEntries(parent));
+ }
+ for (URL url : getClassLoaderUrls(classloader)) {
+ if (url.getProtocol().equals("file")) {
+ File file = toFile(url);
+ if (!entries.containsKey(file)) {
+ entries.put(file, classloader);
+ }
+ }
+ }
+ return ImmutableMap.copyOf(entries);
+ }
+
+ private static ImmutableList<URL> getClassLoaderUrls(ClassLoader classloader) {
+ if (classloader instanceof URLClassLoader) {
+ return ImmutableList.copyOf(((URLClassLoader) classloader).getURLs());
+ }
+ if (classloader.equals(ClassLoader.getSystemClassLoader())) {
+ return parseJavaClassPath();
+ }
+ return ImmutableList.of();
+ }
+
+ /**
+ * Returns the URLs in the class path specified by the {@code java.class.path} {@linkplain
+ * System#getProperty system property}.
+ */
+ @VisibleForTesting // TODO(b/65488446): Make this a public API.
+ static ImmutableList<URL> parseJavaClassPath() {
+ ImmutableList.Builder<URL> urls = ImmutableList.builder();
+ for (String entry : Splitter.on(PATH_SEPARATOR.value()).split(JAVA_CLASS_PATH.value())) {
+ try {
+ try {
+ urls.add(new File(entry).toURI().toURL());
+ } catch (SecurityException e) { // File.toURI checks to see if the file is a directory
+ urls.add(new URL("file", null, new File(entry).getAbsolutePath()));
+ }
+ } catch (MalformedURLException e) {
+ logger.log(WARNING, "malformed classpath entry: " + entry, e);
+ }
+ }
+ return urls.build();
+ }
+
+ /**
+ * Returns the absolute uri of the Class-Path entry value as specified in <a
+ * href="http://docs.oracle.com/javase/8/docs/technotes/guides/jar/jar.html#Main_Attributes">JAR
+ * File Specification</a>. Even though the specification only talks about relative urls,
+ * absolute urls are actually supported too (for example, in Maven surefire plugin).
+ */
+ @VisibleForTesting
+ static URL getClassPathEntry(File jarFile, String path) throws MalformedURLException {
+ return new URL(jarFile.toURI().toURL(), path);
+ }
+
+ @VisibleForTesting
+ void scanJarFile(ClassLoader classloader, JarFile file) throws IOException {
Enumeration<JarEntry> entries = file.entries();
while (entries.hasMoreElements()) {
JarEntry entry = entries.nextElement();
if (entry.isDirectory() || entry.getName().equals(JarFile.MANIFEST_NAME)) {
continue;
}
- builder.add(ResourceInfo.of(new File(file.getName()), entry.getName(), classloader));
+ scanResource(ResourceInfo.of(new File(file.getName()), entry.getName(), classloader));
}
}
- private void scanDirectory(File directory, ImmutableSet.Builder<ResourceInfo> builder)
- throws IOException {
+ private void scanDirectory(ClassLoader classloader, File directory) throws IOException {
Set<File> currentPath = new HashSet<>();
currentPath.add(directory.getCanonicalFile());
- scanDirectory(directory, "", currentPath, builder);
+ scanDirectory(directory, classloader, "", currentPath);
}
/**
@@ -526,16 +532,14 @@
* cycles; otherwise symlinks are traversed.
*
* @param directory the root of the directory to scan
+ * @param classloader the classloader that includes resources found in {@code directory}
* @param packagePrefix resource path prefix inside {@code classloader} for any files found
* under {@code directory}
* @param currentPath canonical files already visited in the current directory tree path, for
* cycle elimination
*/
private void scanDirectory(
- File directory,
- String packagePrefix,
- Set<File> currentPath,
- ImmutableSet.Builder<ResourceInfo> builder)
+ File directory, ClassLoader classloader, String packagePrefix, Set<File> currentPath)
throws IOException {
File[] files = directory.listFiles();
if (files == null) {
@@ -548,131 +552,32 @@
if (f.isDirectory()) {
File deref = f.getCanonicalFile();
if (currentPath.add(deref)) {
- scanDirectory(deref, packagePrefix + name + "/", currentPath, builder);
+ scanDirectory(deref, classloader, packagePrefix + name + "/", currentPath);
currentPath.remove(deref);
}
} else {
String resourceName = packagePrefix + name;
if (!resourceName.equals(JarFile.MANIFEST_NAME)) {
- builder.add(ResourceInfo.of(f, resourceName, classloader));
+ scanResource(ResourceInfo.of(f, resourceName, classloader));
}
}
}
}
-
- @Override
- public boolean equals(@CheckForNull Object obj) {
- if (obj instanceof LocationInfo) {
- LocationInfo that = (LocationInfo) obj;
- return home.equals(that.home) && classloader.equals(that.classloader);
- }
- return false;
- }
-
- @Override
- public int hashCode() {
- return home.hashCode();
- }
-
- @Override
- public String toString() {
- return home.toString();
- }
- }
-
- /**
- * Returns the class path URIs specified by the {@code Class-Path} manifest attribute, according
- * to <a
- * href="http://docs.oracle.com/javase/8/docs/technotes/guides/jar/jar.html#Main_Attributes">JAR
- * File Specification</a>. If {@code manifest} is null, it means the jar file has no manifest, and
- * an empty set will be returned.
- */
- @VisibleForTesting
- static ImmutableSet<File> getClassPathFromManifest(
- File jarFile, @CheckForNull Manifest manifest) {
- if (manifest == null) {
- return ImmutableSet.of();
- }
- ImmutableSet.Builder<File> builder = ImmutableSet.builder();
- String classpathAttribute =
- manifest.getMainAttributes().getValue(Attributes.Name.CLASS_PATH.toString());
- if (classpathAttribute != null) {
- for (String path : CLASS_PATH_ATTRIBUTE_SEPARATOR.split(classpathAttribute)) {
- URL url;
- try {
- url = getClassPathEntry(jarFile, path);
- } catch (MalformedURLException e) {
- // Ignore bad entry
- logger.warning("Invalid Class-Path entry: " + path);
- continue;
- }
- if (url.getProtocol().equals("file")) {
- builder.add(toFile(url));
- }
- }
- }
- return builder.build();
}
@VisibleForTesting
- static ImmutableMap<File, ClassLoader> getClassPathEntries(ClassLoader classloader) {
- LinkedHashMap<File, ClassLoader> entries = Maps.newLinkedHashMap();
- // Search parent first, since it's the order ClassLoader#loadClass() uses.
- ClassLoader parent = classloader.getParent();
- if (parent != null) {
- entries.putAll(getClassPathEntries(parent));
- }
- for (URL url : getClassLoaderUrls(classloader)) {
- if (url.getProtocol().equals("file")) {
- File file = toFile(url);
- if (!entries.containsKey(file)) {
- entries.put(file, classloader);
- }
- }
- }
- return ImmutableMap.copyOf(entries);
- }
+ static final class DefaultScanner extends Scanner {
+ private final SetMultimap<ClassLoader, ResourceInfo> resources =
+ MultimapBuilder.hashKeys().linkedHashSetValues().build();
- private static ImmutableList<URL> getClassLoaderUrls(ClassLoader classloader) {
- if (classloader instanceof URLClassLoader) {
- return ImmutableList.copyOf(((URLClassLoader) classloader).getURLs());
+ ImmutableSet<ResourceInfo> getResources() {
+ return ImmutableSet.copyOf(resources.values());
}
- if (classloader.equals(ClassLoader.getSystemClassLoader())) {
- return parseJavaClassPath();
- }
- return ImmutableList.of();
- }
- /**
- * Returns the URLs in the class path specified by the {@code java.class.path} {@linkplain
- * System#getProperty system property}.
- */
- @VisibleForTesting // TODO(b/65488446): Make this a public API.
- static ImmutableList<URL> parseJavaClassPath() {
- ImmutableList.Builder<URL> urls = ImmutableList.builder();
- for (String entry : Splitter.on(PATH_SEPARATOR.value()).split(JAVA_CLASS_PATH.value())) {
- try {
- try {
- urls.add(new File(entry).toURI().toURL());
- } catch (SecurityException e) { // File.toURI checks to see if the file is a directory
- urls.add(new URL("file", null, new File(entry).getAbsolutePath()));
- }
- } catch (MalformedURLException e) {
- logger.log(WARNING, "malformed classpath entry: " + entry, e);
- }
+ @Override
+ protected void scanResource(ResourceInfo resource) {
+ resources.put(resource.loader, resource);
}
- return urls.build();
- }
-
- /**
- * Returns the absolute uri of the Class-Path entry value as specified in <a
- * href="http://docs.oracle.com/javase/8/docs/technotes/guides/jar/jar.html#Main_Attributes">JAR
- * File Specification</a>. Even though the specification only talks about relative urls, absolute
- * urls are actually supported too (for example, in Maven surefire plugin).
- */
- @VisibleForTesting
- static URL getClassPathEntry(File jarFile, String path) throws MalformedURLException {
- return new URL(jarFile.toURI().toURL(), path);
}
@VisibleForTesting
diff --git a/android/guava/src/com/google/common/reflect/Element.java b/android/guava/src/com/google/common/reflect/Element.java
new file mode 100644
index 0000000..e2b9652
--- /dev/null
+++ b/android/guava/src/com/google/common/reflect/Element.java
@@ -0,0 +1,178 @@
+/*
+ * Copyright (C) 2012 The Guava Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package com.google.common.reflect;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.AccessibleObject;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.Member;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
+
+/**
+ * Represents either a {@link Field}, a {@link Method} or a {@link Constructor}. Provides
+ * convenience methods such as {@link #isPublic} and {@link #isPackagePrivate}.
+ *
+ * @author Ben Yu
+ */
+class Element extends AccessibleObject implements Member {
+
+ private final AccessibleObject accessibleObject;
+ private final Member member;
+
+ <M extends AccessibleObject & Member> Element(M member) {
+ checkNotNull(member);
+ this.accessibleObject = member;
+ this.member = member;
+ }
+
+ public TypeToken<?> getOwnerType() {
+ return TypeToken.of(getDeclaringClass());
+ }
+
+ @Override
+ public final boolean isAnnotationPresent(Class<? extends Annotation> annotationClass) {
+ return accessibleObject.isAnnotationPresent(annotationClass);
+ }
+
+ @Override
+ public final <A extends Annotation> A getAnnotation(Class<A> annotationClass) {
+ return accessibleObject.getAnnotation(annotationClass);
+ }
+
+ @Override
+ public final Annotation[] getAnnotations() {
+ return accessibleObject.getAnnotations();
+ }
+
+ @Override
+ public final Annotation[] getDeclaredAnnotations() {
+ return accessibleObject.getDeclaredAnnotations();
+ }
+
+ @Override
+ public final void setAccessible(boolean flag) throws SecurityException {
+ accessibleObject.setAccessible(flag);
+ }
+
+ @Override
+ public final boolean isAccessible() {
+ return accessibleObject.isAccessible();
+ }
+
+ @Override
+ public Class<?> getDeclaringClass() {
+ return member.getDeclaringClass();
+ }
+
+ @Override
+ public final String getName() {
+ return member.getName();
+ }
+
+ @Override
+ public final int getModifiers() {
+ return member.getModifiers();
+ }
+
+ @Override
+ public final boolean isSynthetic() {
+ return member.isSynthetic();
+ }
+
+ /** Returns true if the element is public. */
+ public final boolean isPublic() {
+ return Modifier.isPublic(getModifiers());
+ }
+
+ /** Returns true if the element is protected. */
+ public final boolean isProtected() {
+ return Modifier.isProtected(getModifiers());
+ }
+
+ /** Returns true if the element is package-private. */
+ public final boolean isPackagePrivate() {
+ return !isPrivate() && !isPublic() && !isProtected();
+ }
+
+ /** Returns true if the element is private. */
+ public final boolean isPrivate() {
+ return Modifier.isPrivate(getModifiers());
+ }
+
+ /** Returns true if the element is static. */
+ public final boolean isStatic() {
+ return Modifier.isStatic(getModifiers());
+ }
+
+ /**
+ * Returns {@code true} if this method is final, per {@code Modifier.isFinal(getModifiers())}.
+ *
+ * <p>Note that a method may still be effectively "final", or non-overridable when it has no
+ * {@code final} keyword. For example, it could be private, or it could be declared by a final
+ * class. To tell whether a method is overridable, use {@link Invokable#isOverridable}.
+ */
+ public final boolean isFinal() {
+ return Modifier.isFinal(getModifiers());
+ }
+
+ /** Returns true if the method is abstract. */
+ public final boolean isAbstract() {
+ return Modifier.isAbstract(getModifiers());
+ }
+
+ /** Returns true if the element is native. */
+ public final boolean isNative() {
+ return Modifier.isNative(getModifiers());
+ }
+
+ /** Returns true if the method is synchronized. */
+ public final boolean isSynchronized() {
+ return Modifier.isSynchronized(getModifiers());
+ }
+
+ /** Returns true if the field is volatile. */
+ final boolean isVolatile() {
+ return Modifier.isVolatile(getModifiers());
+ }
+
+ /** Returns true if the field is transient. */
+ final boolean isTransient() {
+ return Modifier.isTransient(getModifiers());
+ }
+
+ @Override
+ public boolean equals(@NullableDecl Object obj) {
+ if (obj instanceof Element) {
+ Element that = (Element) obj;
+ return getOwnerType().equals(that.getOwnerType()) && member.equals(that.member);
+ }
+ return false;
+ }
+
+ @Override
+ public int hashCode() {
+ return member.hashCode();
+ }
+
+ @Override
+ public String toString() {
+ return member.toString();
+ }
+}
diff --git a/android/guava/src/com/google/common/reflect/ElementTypesAreNonnullByDefault.java b/android/guava/src/com/google/common/reflect/ElementTypesAreNonnullByDefault.java
deleted file mode 100644
index 0e8ef3c..0000000
--- a/android/guava/src/com/google/common/reflect/ElementTypesAreNonnullByDefault.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) 2021 The Guava Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.common.reflect;
-
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.PARAMETER;
-import static java.lang.annotation.ElementType.TYPE;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-import com.google.common.annotations.GwtCompatible;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-import javax.annotation.Nonnull;
-import javax.annotation.meta.TypeQualifierDefault;
-
-/**
- * Marks all "top-level" types as non-null in a way that is recognized by Kotlin. Note that this
- * unfortunately includes type-variable usages, so we also provide {@link ParametricNullness} to
- * "undo" it as best we can.
- */
-@GwtCompatible
-@Retention(RUNTIME)
-@Target(TYPE)
-@TypeQualifierDefault({FIELD, METHOD, PARAMETER})
-@Nonnull
-@interface ElementTypesAreNonnullByDefault {}
diff --git a/android/guava/src/com/google/common/reflect/ImmutableTypeToInstanceMap.java b/android/guava/src/com/google/common/reflect/ImmutableTypeToInstanceMap.java
index 7fad5de..354fd19 100644
--- a/android/guava/src/com/google/common/reflect/ImmutableTypeToInstanceMap.java
+++ b/android/guava/src/com/google/common/reflect/ImmutableTypeToInstanceMap.java
@@ -18,7 +18,6 @@
import com.google.common.collect.ForwardingMap;
import com.google.common.collect.ImmutableMap;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
-import com.google.errorprone.annotations.DoNotCall;
import java.util.Map;
/**
@@ -120,7 +119,6 @@
@CanIgnoreReturnValue
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
public <T extends B> T putInstance(TypeToken<T> type, T value) {
throw new UnsupportedOperationException();
}
@@ -134,7 +132,6 @@
@CanIgnoreReturnValue
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
public <T extends B> T putInstance(Class<T> type, T value) {
throw new UnsupportedOperationException();
}
@@ -148,7 +145,6 @@
@CanIgnoreReturnValue
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
public B put(TypeToken<? extends B> key, B value) {
throw new UnsupportedOperationException();
}
@@ -161,7 +157,6 @@
*/
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
public void putAll(Map<? extends TypeToken<? extends B>, ? extends B> map) {
throw new UnsupportedOperationException();
}
diff --git a/android/guava/src/com/google/common/reflect/Invokable.java b/android/guava/src/com/google/common/reflect/Invokable.java
index 8e75aa8..3900244 100644
--- a/android/guava/src/com/google/common/reflect/Invokable.java
+++ b/android/guava/src/com/google/common/reflect/Invokable.java
@@ -21,8 +21,8 @@
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import java.lang.annotation.Annotation;
import java.lang.reflect.AccessibleObject;
-import java.lang.reflect.AnnotatedElement;
import java.lang.reflect.Constructor;
+import java.lang.reflect.GenericDeclaration;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Member;
import java.lang.reflect.Method;
@@ -30,8 +30,7 @@
import java.lang.reflect.Type;
import java.lang.reflect.TypeVariable;
import java.util.Arrays;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* Wrapper around either a {@link Method} or a {@link Constructor}. Convenience API is provided to
@@ -49,29 +48,17 @@
* assertEquals(new TypeToken<List<String>>() {}, invokable.getOwnerType());
* }</pre>
*
- * <p><b>Note:</b> earlier versions of this class inherited from {@link
- * java.lang.reflect.AccessibleObject AccessibleObject} and {@link
- * java.lang.reflect.GenericDeclaration GenericDeclaration}. Since version 31.0 that is no longer
- * the case. However, most methods from those types are present with the same signature in this
- * class.
- *
* @param <T> the type that owns this method or constructor.
* @param <R> the return type of (or supertype thereof) the method or the declaring type of the
* constructor.
* @author Ben Yu
- * @since 14.0 (no longer implements {@link AccessibleObject} or {@code GenericDeclaration} since
- * 31.0)
+ * @since 14.0
*/
@Beta
-@ElementTypesAreNonnullByDefault
-public abstract class Invokable<T, R> implements AnnotatedElement, Member {
- private final AccessibleObject accessibleObject;
- private final Member member;
+public abstract class Invokable<T, R> extends Element implements GenericDeclaration {
<M extends AccessibleObject & Member> Invokable(M member) {
- checkNotNull(member);
- this.accessibleObject = member;
- this.member = member;
+ super(member);
}
/** Returns {@link Invokable} of {@code method}. */
@@ -84,151 +71,6 @@
return new ConstructorInvokable<T>(constructor);
}
- @Override
- public final boolean isAnnotationPresent(Class<? extends Annotation> annotationClass) {
- return accessibleObject.isAnnotationPresent(annotationClass);
- }
-
- @Override
- @CheckForNull
- public final <A extends Annotation> A getAnnotation(Class<A> annotationClass) {
- return accessibleObject.getAnnotation(annotationClass);
- }
-
- @Override
- public final Annotation[] getAnnotations() {
- return accessibleObject.getAnnotations();
- }
-
- @Override
- public final Annotation[] getDeclaredAnnotations() {
- return accessibleObject.getDeclaredAnnotations();
- }
-
- // We ought to be able to implement GenericDeclaration instead its parent AnnotatedElement.
- // That would give us this method declaration. But for some reason, implementing
- // GenericDeclaration leads to weird errors in Android tests:
- // IncompatibleClassChangeError: interface not implemented
- /** See {@link java.lang.reflect.GenericDeclaration#getTypeParameters()}. */
- public abstract TypeVariable<?>[] getTypeParameters();
-
- /** See {@link java.lang.reflect.AccessibleObject#setAccessible(boolean)}. */
- public final void setAccessible(boolean flag) {
- accessibleObject.setAccessible(flag);
- }
-
- /** See {@link java.lang.reflect.AccessibleObject#trySetAccessible()}. */
- public final boolean trySetAccessible() {
- // We can't call accessibleObject.trySetAccessible since that was added in Java 9 and this code
- // should work on Java 8. So we emulate it this way.
- try {
- accessibleObject.setAccessible(true);
- return true;
- } catch (RuntimeException e) {
- return false;
- }
- }
-
- /** See {@link java.lang.reflect.AccessibleObject#isAccessible()}. */
- public final boolean isAccessible() {
- return accessibleObject.isAccessible();
- }
-
- @Override
- public final String getName() {
- return member.getName();
- }
-
- @Override
- public final int getModifiers() {
- return member.getModifiers();
- }
-
- @Override
- public final boolean isSynthetic() {
- return member.isSynthetic();
- }
-
- /** Returns true if the element is public. */
- public final boolean isPublic() {
- return Modifier.isPublic(getModifiers());
- }
-
- /** Returns true if the element is protected. */
- public final boolean isProtected() {
- return Modifier.isProtected(getModifiers());
- }
-
- /** Returns true if the element is package-private. */
- public final boolean isPackagePrivate() {
- return !isPrivate() && !isPublic() && !isProtected();
- }
-
- /** Returns true if the element is private. */
- public final boolean isPrivate() {
- return Modifier.isPrivate(getModifiers());
- }
-
- /** Returns true if the element is static. */
- public final boolean isStatic() {
- return Modifier.isStatic(getModifiers());
- }
-
- /**
- * Returns {@code true} if this method is final, per {@code Modifier.isFinal(getModifiers())}.
- *
- * <p>Note that a method may still be effectively "final", or non-overridable when it has no
- * {@code final} keyword. For example, it could be private, or it could be declared by a final
- * class. To tell whether a method is overridable, use {@link Invokable#isOverridable}.
- */
- public final boolean isFinal() {
- return Modifier.isFinal(getModifiers());
- }
-
- /** Returns true if the method is abstract. */
- public final boolean isAbstract() {
- return Modifier.isAbstract(getModifiers());
- }
-
- /** Returns true if the element is native. */
- public final boolean isNative() {
- return Modifier.isNative(getModifiers());
- }
-
- /** Returns true if the method is synchronized. */
- public final boolean isSynchronized() {
- return Modifier.isSynchronized(getModifiers());
- }
-
- /** Returns true if the field is volatile. */
- final boolean isVolatile() {
- return Modifier.isVolatile(getModifiers());
- }
-
- /** Returns true if the field is transient. */
- final boolean isTransient() {
- return Modifier.isTransient(getModifiers());
- }
-
- @Override
- public boolean equals(@CheckForNull Object obj) {
- if (obj instanceof Invokable) {
- Invokable<?, ?> that = (Invokable<?, ?>) obj;
- return getOwnerType().equals(that.getOwnerType()) && member.equals(that.member);
- }
- return false;
- }
-
- @Override
- public int hashCode() {
- return member.hashCode();
- }
-
- @Override
- public String toString() {
- return member.toString();
- }
-
/**
* Returns {@code true} if this is an overridable method. Constructors, private, static or final
* methods, or methods declared by final classes are not overridable.
@@ -251,11 +93,10 @@
* invocation conversion.
* @throws InvocationTargetException if the underlying method or constructor throws an exception.
*/
- // All subclasses are owned by us and we'll make sure to get the R type right, including nullness.
- @SuppressWarnings({"unchecked", "nullness"})
+ // All subclasses are owned by us and we'll make sure to get the R type right.
+ @SuppressWarnings("unchecked")
@CanIgnoreReturnValue
- @CheckForNull
- public final R invoke(@CheckForNull T receiver, @Nullable Object... args)
+ public final R invoke(@NullableDecl T receiver, Object... args)
throws InvocationTargetException, IllegalAccessException {
return (R) invokeInternal(receiver, checkNotNull(args));
}
@@ -321,18 +162,18 @@
@SuppressWarnings("unchecked") // The declaring class is T's raw class, or one of its supertypes.
@Override
public final Class<? super T> getDeclaringClass() {
- return (Class<? super T>) member.getDeclaringClass();
+ return (Class<? super T>) super.getDeclaringClass();
}
/** Returns the type of {@code T}. */
// Overridden in TypeToken#method() and TypeToken#constructor()
@SuppressWarnings("unchecked") // The declaring class is T.
+ @Override
public TypeToken<T> getOwnerType() {
return (TypeToken<T>) TypeToken.of(getDeclaringClass());
}
- @CheckForNull
- abstract Object invokeInternal(@CheckForNull Object receiver, @Nullable Object[] args)
+ abstract Object invokeInternal(@NullableDecl Object receiver, Object[] args)
throws InvocationTargetException, IllegalAccessException;
abstract Type[] getGenericParameterTypes();
@@ -354,8 +195,7 @@
}
@Override
- @CheckForNull
- final Object invokeInternal(@CheckForNull Object receiver, @Nullable Object[] args)
+ final Object invokeInternal(@NullableDecl Object receiver, Object[] args)
throws InvocationTargetException, IllegalAccessException {
return method.invoke(receiver, args);
}
@@ -409,7 +249,7 @@
}
@Override
- final Object invokeInternal(@CheckForNull Object receiver, @Nullable Object[] args)
+ final Object invokeInternal(@NullableDecl Object receiver, Object[] args)
throws InvocationTargetException, IllegalAccessException {
try {
return constructor.newInstance(args);
diff --git a/android/guava/src/com/google/common/reflect/MutableTypeToInstanceMap.java b/android/guava/src/com/google/common/reflect/MutableTypeToInstanceMap.java
index dccd298..3b88c9c 100644
--- a/android/guava/src/com/google/common/reflect/MutableTypeToInstanceMap.java
+++ b/android/guava/src/com/google/common/reflect/MutableTypeToInstanceMap.java
@@ -24,7 +24,6 @@
import com.google.common.collect.Iterators;
import com.google.common.collect.Maps;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
-import com.google.errorprone.annotations.DoNotCall;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
@@ -77,7 +76,6 @@
@CanIgnoreReturnValue
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
public B put(TypeToken<? extends B> key, B value) {
throw new UnsupportedOperationException("Please use putInstance() instead.");
}
@@ -90,7 +88,6 @@
*/
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
public void putAll(Map<? extends TypeToken<? extends B>, ? extends B> map) {
throw new UnsupportedOperationException("Please use putInstance() instead.");
}
diff --git a/android/guava/src/com/google/common/reflect/Parameter.java b/android/guava/src/com/google/common/reflect/Parameter.java
index a55734a..8f05ef6 100644
--- a/android/guava/src/com/google/common/reflect/Parameter.java
+++ b/android/guava/src/com/google/common/reflect/Parameter.java
@@ -21,8 +21,7 @@
import com.google.common.collect.ImmutableList;
import java.lang.annotation.Annotation;
import java.lang.reflect.AnnotatedElement;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* Represents a method or constructor parameter.
@@ -31,7 +30,6 @@
* @since 14.0
*/
@Beta
-@ElementTypesAreNonnullByDefault
public final class Parameter implements AnnotatedElement {
private final Invokable<?, ?> declaration;
@@ -63,7 +61,7 @@
}
@Override
- @CheckForNull
+ @NullableDecl
public <A extends Annotation> A getAnnotation(Class<A> annotationType) {
checkNotNull(annotationType);
for (Annotation annotation : annotations) {
@@ -94,7 +92,7 @@
/** @since 18.0 */
// @Override on JDK8
- @CheckForNull
+ @NullableDecl
public <A extends Annotation> A getDeclaredAnnotation(Class<A> annotationType) {
checkNotNull(annotationType);
return FluentIterable.from(annotations).filter(annotationType).first().orNull();
@@ -103,15 +101,11 @@
/** @since 18.0 */
// @Override on JDK8
public <A extends Annotation> A[] getDeclaredAnnotationsByType(Class<A> annotationType) {
- @Nullable
- A[] result = FluentIterable.from(annotations).filter(annotationType).toArray(annotationType);
- @SuppressWarnings("nullness") // safe because the input list contains no nulls
- A[] cast = (A[]) result;
- return cast;
+ return FluentIterable.from(annotations).filter(annotationType).toArray(annotationType);
}
@Override
- public boolean equals(@CheckForNull Object obj) {
+ public boolean equals(@NullableDecl Object obj) {
if (obj instanceof Parameter) {
Parameter that = (Parameter) obj;
return position == that.position && declaration.equals(that.declaration);
diff --git a/android/guava/src/com/google/common/reflect/ParametricNullness.java b/android/guava/src/com/google/common/reflect/ParametricNullness.java
deleted file mode 100644
index 588aa5f..0000000
--- a/android/guava/src/com/google/common/reflect/ParametricNullness.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2021 The Guava Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.common.reflect;
-
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.PARAMETER;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-import static javax.annotation.meta.When.UNKNOWN;
-
-import com.google.common.annotations.GwtCompatible;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-import javax.annotation.Nonnull;
-import javax.annotation.meta.TypeQualifierNickname;
-
-/**
- * Marks a "top-level" type-variable usage as (a) a Kotlin platform type when the type argument is
- * non-nullable and (b) nullable when the type argument is nullable. This is the closest we can get
- * to "non-nullable when non-nullable; nullable when nullable" (like the Android <a
- * href="https://android.googlesource.com/platform/libcore/+/master/luni/src/main/java/libcore/util/NullFromTypeParam.java">{@code
- * NullFromTypeParam}</a>). We use this to "undo" {@link ElementTypesAreNonnullByDefault}.
- */
-@GwtCompatible
-@Retention(RUNTIME)
-@Target({FIELD, METHOD, PARAMETER})
-@TypeQualifierNickname
-@Nonnull(when = UNKNOWN)
-@interface ParametricNullness {}
diff --git a/android/guava/src/com/google/common/reflect/Reflection.java b/android/guava/src/com/google/common/reflect/Reflection.java
index fa35f7f..4ad5dff 100644
--- a/android/guava/src/com/google/common/reflect/Reflection.java
+++ b/android/guava/src/com/google/common/reflect/Reflection.java
@@ -27,7 +27,6 @@
* @since 12.0
*/
@Beta
-@ElementTypesAreNonnullByDefault
public final class Reflection {
/**
diff --git a/android/guava/src/com/google/common/reflect/TypeCapture.java b/android/guava/src/com/google/common/reflect/TypeCapture.java
index 2be7b4f..effb382 100644
--- a/android/guava/src/com/google/common/reflect/TypeCapture.java
+++ b/android/guava/src/com/google/common/reflect/TypeCapture.java
@@ -24,7 +24,6 @@
*
* @author Ben Yu
*/
-@ElementTypesAreNonnullByDefault
abstract class TypeCapture<T> {
/** Returns the captured type. */
diff --git a/android/guava/src/com/google/common/reflect/TypeParameter.java b/android/guava/src/com/google/common/reflect/TypeParameter.java
index 9c64abb..2834941 100644
--- a/android/guava/src/com/google/common/reflect/TypeParameter.java
+++ b/android/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 javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* Captures a free type variable that can be used in {@link TypeToken#where}. For example:
@@ -35,17 +35,6 @@
* @since 12.0
*/
@Beta
-@ElementTypesAreNonnullByDefault
-/*
- * A nullable bound would let users create a TypeParameter instance for a parameter with a nullable
- * bound. However, it would also let them create `new TypeParameter<@Nullable T>() {}`, which
- * wouldn't behave as users might expect. Additionally, it's not clear how the TypeToken API could
- * support even a "normal" `TypeParameter<T>` when `<T>` has a nullable bound. (See the discussion
- * on TypeToken.where.) So, in the interest of failing fast and encouraging the user to switch to a
- * non-null bound if possible, let's require a non-null bound here.
- *
- * TODO(cpovirk): Elaborate on "wouldn't behave as users might expect."
- */
public abstract class TypeParameter<T> extends TypeCapture<T> {
final TypeVariable<?> typeVariable;
@@ -62,7 +51,7 @@
}
@Override
- public final boolean equals(@CheckForNull Object o) {
+ public final boolean equals(@NullableDecl Object o) {
if (o instanceof TypeParameter) {
TypeParameter<?> that = (TypeParameter<?>) o;
return typeVariable.equals(that.typeVariable);
diff --git a/android/guava/src/com/google/common/reflect/TypeResolver.java b/android/guava/src/com/google/common/reflect/TypeResolver.java
index fbe48c1..0c18a1d 100644
--- a/android/guava/src/com/google/common/reflect/TypeResolver.java
+++ b/android/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 javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* An object of this class encapsulates type mappings from type variables. Mappings are established
@@ -52,7 +52,6 @@
* @since 15.0
*/
@Beta
-@ElementTypesAreNonnullByDefault
public final class TypeResolver {
private final TypeTable typeTable;
@@ -509,7 +508,7 @@
@Override
TypeVariable<?> captureAsTypeVariable(Type[] upperBounds) {
Set<Type> combined = new LinkedHashSet<>(asList(upperBounds));
- // Since this is an artificially generated type variable, we don't bother checking
+ // Since this is an artifically generated type variable, we don't bother checking
// subtyping between declared type bound and actual type bound. So it's possible that we
// may generate something like <capture#1-of ? extends Foo&SubFoo>.
// Checking subtype between declared and actual type bounds
@@ -528,8 +527,7 @@
return new WildcardCapturer(id);
}
- @CheckForNull
- private Type captureNullable(@CheckForNull Type type) {
+ private Type captureNullable(@NullableDecl Type type) {
if (type == null) {
return null;
}
@@ -563,7 +561,7 @@
}
@Override
- public boolean equals(@CheckForNull Object obj) {
+ public boolean equals(Object obj) {
if (obj instanceof TypeVariableKey) {
TypeVariableKey that = (TypeVariableKey) obj;
return equalsTypeVariable(that.var);
@@ -578,7 +576,6 @@
}
/** Wraps {@code t} in a {@code TypeVariableKey} if it's a type variable. */
- @CheckForNull
static TypeVariableKey forLookup(Type t) {
if (t instanceof TypeVariable) {
return new TypeVariableKey((TypeVariable<?>) t);
diff --git a/android/guava/src/com/google/common/reflect/TypeToken.java b/android/guava/src/com/google/common/reflect/TypeToken.java
index f107b70..daf498c 100644
--- a/android/guava/src/com/google/common/reflect/TypeToken.java
+++ b/android/guava/src/com/google/common/reflect/TypeToken.java
@@ -17,7 +17,6 @@
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkState;
-import static java.util.Objects.requireNonNull;
import com.google.common.annotations.Beta;
import com.google.common.annotations.VisibleForTesting;
@@ -47,7 +46,7 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* A {@link Type} with generics.
@@ -99,16 +98,15 @@
*/
@Beta
@SuppressWarnings("serial") // SimpleTypeToken is the serialized form.
-@ElementTypesAreNonnullByDefault
public abstract class TypeToken<T> extends TypeCapture<T> implements Serializable {
private final Type runtimeType;
/** Resolver for resolving parameter and field types with {@link #runtimeType} as context. */
- @CheckForNull private transient TypeResolver invariantTypeResolver;
+ @NullableDecl private transient TypeResolver invariantTypeResolver;
/** Resolver for resolving covariant types with {@link #runtimeType} as context. */
- @CheckForNull private transient TypeResolver covariantTypeResolver;
+ @NullableDecl private transient TypeResolver covariantTypeResolver;
/**
* Constructs a new type token of {@code T}.
@@ -222,17 +220,6 @@
* @param typeParam the parameter type variable
* @param typeArg the actual type to substitute
*/
- /*
- * TODO(cpovirk): Is there any way for us to support TypeParameter instances for type parameters
- * that have nullable bounds? Unfortunately, if we change the parameter to TypeParameter<? extends
- * @Nullable X>, then users might pass a TypeParameter<Y>, where Y is a subtype of X, while still
- * passing a TypeToken<X>. This would be invalid. Maybe we could accept a TypeParameter<@PolyNull
- * X> if we support such a thing? It would be weird or misleading for users to be able to pass
- * `new TypeParameter<@Nullable T>() {}` and have it act as a plain `TypeParameter<T>`, but
- * hopefully no one would do that, anyway. See also the comment on TypeParameter itself.
- *
- * TODO(cpovirk): Elaborate on this / merge with other comment?
- */
public final <X> TypeToken<T> where(TypeParameter<X> typeParam, TypeToken<X> typeArg) {
TypeResolver resolver =
new TypeResolver()
@@ -261,10 +248,6 @@
* @param typeParam the parameter type variable
* @param typeArg the actual type to substitute
*/
- /*
- * TODO(cpovirk): Is there any way for us to support TypeParameter instances for type parameters
- * that have nullable bounds? See discussion on the other overload of this method.
- */
public final <X> TypeToken<T> where(TypeParameter<X> typeParam, Class<X> typeArg) {
return where(typeParam, of(typeArg));
}
@@ -305,7 +288,7 @@
* if the bound is a class or extends from a class. This means that the returned type could be a
* type variable too.
*/
- @CheckForNull
+ @NullableDecl
final TypeToken<? super T> getGenericSuperclass() {
if (runtimeType instanceof TypeVariable) {
// First bound is always the super class, if one exists.
@@ -324,7 +307,7 @@
return superToken;
}
- @CheckForNull
+ @NullableDecl
private TypeToken<? super T> boundAsSuperclass(Type bound) {
TypeToken<?> token = of(bound);
if (token.getRawType().isInterface()) {
@@ -577,7 +560,7 @@
* Returns the array component type if this type represents an array ({@code int[]}, {@code T[]},
* {@code <? extends Map<String, Integer>[]>} etc.), or else {@code null} is returned.
*/
- @CheckForNull
+ @NullableDecl
public final TypeToken<?> getComponentType() {
Type componentType = Types.getComponentType(runtimeType);
if (componentType == null) {
@@ -672,7 +655,7 @@
*/
public class TypeSet extends ForwardingSet<TypeToken<? super T>> implements Serializable {
- @CheckForNull private transient ImmutableSet<TypeToken<? super T>> types;
+ @NullableDecl private transient ImmutableSet<TypeToken<? super T>> types;
TypeSet() {}
@@ -718,7 +701,7 @@
private final class InterfaceSet extends TypeSet {
private final transient TypeSet allTypes;
- @CheckForNull private transient ImmutableSet<TypeToken<? super T>> interfaces;
+ @NullableDecl private transient ImmutableSet<TypeToken<? super T>> interfaces;
InterfaceSet(TypeSet allTypes) {
this.allTypes = allTypes;
@@ -771,7 +754,7 @@
private final class ClassSet extends TypeSet {
- @CheckForNull private transient ImmutableSet<TypeToken<? super T>> classes;
+ @NullableDecl private transient ImmutableSet<TypeToken<? super T>> classes;
@Override
protected Set<TypeToken<? super T>> delegate() {
@@ -836,7 +819,7 @@
* Returns true if {@code o} is another {@code TypeToken} that represents the same {@link Type}.
*/
@Override
- public boolean equals(@CheckForNull Object o) {
+ public boolean equals(@NullableDecl Object o) {
if (o instanceof TypeToken) {
TypeToken<?> that = (TypeToken<?>) o;
return runtimeType.equals(that.runtimeType);
@@ -1150,7 +1133,7 @@
* Returns the owner type of a {@link ParameterizedType} or enclosing class of a {@link Class}, or
* null otherwise.
*/
- @CheckForNull
+ @NullableDecl
private Type getOwnerTypeIfPresent() {
if (runtimeType instanceof ParameterizedType) {
return ((ParameterizedType) runtimeType).getOwnerType();
@@ -1240,19 +1223,11 @@
// with component type, we have lost generic type information
// Use raw type so that compiler allows us to call getSupertype()
@SuppressWarnings("rawtypes")
- TypeToken componentType = getComponentType();
- // TODO(cpovirk): checkArgument?
- if (componentType == null) {
- throw new IllegalArgumentException(supertype + " isn't a super type of " + this);
- }
+ TypeToken componentType =
+ checkNotNull(getComponentType(), "%s isn't a super type of %s", supertype, this);
// array is covariant. component type is super type, so is the array type.
@SuppressWarnings("unchecked") // going from raw type back to generics
- /*
- * requireNonNull is safe because we call getArraySupertype only after checking
- * supertype.isArray().
- */
- TypeToken<?> componentSupertype =
- componentType.getSupertype(requireNonNull(supertype.getComponentType()));
+ TypeToken<?> componentSupertype = componentType.getSupertype(supertype.getComponentType());
@SuppressWarnings("unchecked") // component type is super type, so is array type.
TypeToken<? super T> result =
(TypeToken<? super T>)
@@ -1262,14 +1237,8 @@
}
private TypeToken<? extends T> getArraySubtype(Class<?> subclass) {
- Class<?> subclassComponentType = subclass.getComponentType();
- if (subclassComponentType == null) {
- throw new IllegalArgumentException(subclass + " does not appear to be a subtype of " + this);
- }
// array is covariant. component type is subtype, so is the array type.
- // requireNonNull is safe because we call getArraySubtype only when isArray().
- TypeToken<?> componentSubtype =
- requireNonNull(getComponentType()).getSubtype(subclassComponentType);
+ TypeToken<?> componentSubtype = getComponentType().getSubtype(subclass.getComponentType());
@SuppressWarnings("unchecked") // component type is subtype, so is array type.
TypeToken<? extends T> result =
(TypeToken<? extends T>)
@@ -1342,7 +1311,7 @@
}
@Override
- @CheckForNull
+ @NullableDecl
TypeToken<?> getSuperclass(TypeToken<?> type) {
return type.getGenericSuperclass();
}
@@ -1361,7 +1330,7 @@
}
@Override
- @CheckForNull
+ @NullableDecl
Class<?> getSuperclass(Class<?> type) {
return type.getSuperclass();
}
@@ -1433,9 +1402,7 @@
new Ordering<K>() {
@Override
public int compare(K left, K right) {
- // requireNonNull is safe because we are passing keys in the map.
- return valueComparator.compare(
- requireNonNull(map.get(left)), requireNonNull(map.get(right)));
+ return valueComparator.compare(map.get(left), map.get(right));
}
};
return keyOrdering.immutableSortedCopy(map.keySet());
@@ -1445,7 +1412,7 @@
abstract Iterable<? extends K> getInterfaces(K type);
- @CheckForNull
+ @NullableDecl
abstract K getSuperclass(K type);
private static class ForwardingTypeCollector<K> extends TypeCollector<K> {
@@ -1467,7 +1434,6 @@
}
@Override
- @CheckForNull
K getSuperclass(K type) {
return delegate.getSuperclass(type);
}
diff --git a/android/guava/src/com/google/common/reflect/TypeVisitor.java b/android/guava/src/com/google/common/reflect/TypeVisitor.java
index 416397b..3e8436d 100644
--- a/android/guava/src/com/google/common/reflect/TypeVisitor.java
+++ b/android/guava/src/com/google/common/reflect/TypeVisitor.java
@@ -21,7 +21,6 @@
import java.lang.reflect.TypeVariable;
import java.lang.reflect.WildcardType;
import java.util.Set;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Based on what a {@link Type} is, dispatch it to the corresponding {@code visit*} method. By
@@ -54,7 +53,6 @@
*
* @author Ben Yu
*/
-@ElementTypesAreNonnullByDefault
abstract class TypeVisitor {
private final Set<Type> visited = Sets.newHashSet();
@@ -63,7 +61,7 @@
* Visits the given types. Null types are ignored. This allows subclasses to call {@code
* visit(parameterizedType.getOwnerType())} safely without having to check nulls.
*/
- public final void visit(@Nullable Type... types) {
+ public final void visit(Type... types) {
for (Type type : types) {
if (type == null || !visited.add(type)) {
// null owner type, or already visited;
diff --git a/android/guava/src/com/google/common/reflect/Types.java b/android/guava/src/com/google/common/reflect/Types.java
index 0dc327d..4fc3910 100644
--- a/android/guava/src/com/google/common/reflect/Types.java
+++ b/android/guava/src/com/google/common/reflect/Types.java
@@ -17,7 +17,6 @@
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.collect.Iterables.transform;
-import static java.util.Objects.requireNonNull;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Function;
@@ -45,15 +44,13 @@
import java.util.Collection;
import java.util.Map.Entry;
import java.util.concurrent.atomic.AtomicReference;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* Utilities for working with {@link Type}.
*
* @author Ben Yu
*/
-@ElementTypesAreNonnullByDefault
final class Types {
/** Class#toString without the "class " and "interface " prefixes */
@@ -89,7 +86,7 @@
* {@code ownerType}.
*/
static ParameterizedType newParameterizedTypeWithOwner(
- @CheckForNull Type ownerType, Class<?> rawType, Type... arguments) {
+ @NullableDecl Type ownerType, Class<?> rawType, Type... arguments) {
if (ownerType == null) {
return newParameterizedType(rawType, arguments);
}
@@ -109,14 +106,14 @@
private enum ClassOwnership {
OWNED_BY_ENCLOSING_CLASS {
@Override
- @CheckForNull
+ @NullableDecl
Class<?> getOwnerType(Class<?> rawType) {
return rawType.getEnclosingClass();
}
},
LOCAL_CLASS_HAS_NO_OWNER {
@Override
- @CheckForNull
+ @NullableDecl
Class<?> getOwnerType(Class<?> rawType) {
if (rawType.isLocalClass()) {
return null;
@@ -126,7 +123,7 @@
}
};
- @CheckForNull
+ @NullableDecl
abstract Class<?> getOwnerType(Class<?> rawType);
static final ClassOwnership JVM_BEHAVIOR = detectJvmBehavior();
@@ -134,9 +131,7 @@
private static ClassOwnership detectJvmBehavior() {
class LocalClass<T> {}
Class<?> subclass = new LocalClass<String>() {}.getClass();
- // requireNonNull is safe because we're examining a type that's known to have a superclass.
- ParameterizedType parameterizedType =
- requireNonNull((ParameterizedType) subclass.getGenericSuperclass());
+ ParameterizedType parameterizedType = (ParameterizedType) subclass.getGenericSuperclass();
for (ClassOwnership behavior : ClassOwnership.values()) {
if (behavior.getOwnerType(LocalClass.class) == parameterizedType.getOwnerType()) {
return behavior;
@@ -177,10 +172,10 @@
return (type instanceof Class) ? ((Class<?>) type).getName() : type.toString();
}
- @CheckForNull
+ @NullableDecl
static Type getComponentType(Type type) {
checkNotNull(type);
- final AtomicReference<@Nullable Type> result = new AtomicReference<>();
+ final AtomicReference<Type> result = new AtomicReference<>();
new TypeVisitor() {
@Override
void visitTypeVariable(TypeVariable<?> t) {
@@ -209,7 +204,7 @@
* Returns {@code ? extends X} if any of {@code bounds} is a subtype of {@code X[]}; or null
* otherwise.
*/
- @CheckForNull
+ @NullableDecl
private static Type subtypeOfComponentType(Type[] bounds) {
for (Type bound : bounds) {
Type componentType = getComponentType(bound);
@@ -252,7 +247,7 @@
}
@Override
- public boolean equals(@CheckForNull Object obj) {
+ public boolean equals(Object obj) {
if (obj instanceof GenericArrayType) {
GenericArrayType that = (GenericArrayType) obj;
return Objects.equal(getGenericComponentType(), that.getGenericComponentType());
@@ -265,11 +260,11 @@
private static final class ParameterizedTypeImpl implements ParameterizedType, Serializable {
- @CheckForNull private final Type ownerType;
+ @NullableDecl private final Type ownerType;
private final ImmutableList<Type> argumentsList;
private final Class<?> rawType;
- ParameterizedTypeImpl(@CheckForNull Type ownerType, Class<?> rawType, Type[] typeArguments) {
+ ParameterizedTypeImpl(@NullableDecl Type ownerType, Class<?> rawType, Type[] typeArguments) {
checkNotNull(rawType);
checkArgument(typeArguments.length == rawType.getTypeParameters().length);
disallowPrimitiveType(typeArguments, "type parameter");
@@ -289,7 +284,6 @@
}
@Override
- @CheckForNull
public Type getOwnerType() {
return ownerType;
}
@@ -316,7 +310,7 @@
}
@Override
- public boolean equals(@CheckForNull Object other) {
+ public boolean equals(Object other) {
if (!(other instanceof ParameterizedType)) {
return false;
}
@@ -392,9 +386,7 @@
}
@Override
- @CheckForNull
- public Object invoke(Object proxy, Method method, @CheckForNull @Nullable Object[] args)
- throws Throwable {
+ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
String methodName = method.getName();
Method typeVariableMethod = typeVariableMethods.get(methodName);
if (typeVariableMethod == null) {
@@ -449,7 +441,7 @@
}
@Override
- public boolean equals(@CheckForNull Object obj) {
+ public boolean equals(Object obj) {
if (NativeTypeVariableEquals.NATIVE_TYPE_VARIABLE_ONLY) {
// equal only to our TypeVariable implementation with identical bounds
if (obj != null
@@ -498,7 +490,7 @@
}
@Override
- public boolean equals(@CheckForNull Object obj) {
+ public boolean equals(Object obj) {
if (obj instanceof WildcardType) {
WildcardType that = (WildcardType) obj;
return lowerBounds.equals(Arrays.asList(that.getLowerBounds()))
diff --git a/android/guava/src/com/google/common/util/concurrent/AbstractCatchingFuture.java b/android/guava/src/com/google/common/util/concurrent/AbstractCatchingFuture.java
index 76eada2..740a0d5 100644
--- a/android/guava/src/com/google/common/util/concurrent/AbstractCatchingFuture.java
+++ b/android/guava/src/com/google/common/util/concurrent/AbstractCatchingFuture.java
@@ -17,7 +17,6 @@
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.util.concurrent.Futures.getDone;
import static com.google.common.util.concurrent.MoreExecutors.rejectionPropagatingExecutor;
-import static com.google.common.util.concurrent.NullnessCasts.uncheckedCastNullableTToT;
import static com.google.common.util.concurrent.Platform.isInstanceOfThrowableClass;
import com.google.common.annotations.GwtCompatible;
@@ -27,17 +26,13 @@
import com.google.errorprone.annotations.ForOverride;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executor;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/** Implementations of {@code Futures.catching*}. */
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-@SuppressWarnings("nullness") // TODO(b/147136275): Remove once our checker understands & and |.
-abstract class AbstractCatchingFuture<
- V extends @Nullable Object, X extends Throwable, F, T extends @Nullable Object>
+abstract class AbstractCatchingFuture<V, X extends Throwable, F, T>
extends FluentFuture.TrustedFuture<V> implements Runnable {
- static <V extends @Nullable Object, X extends Throwable> ListenableFuture<V> create(
+ static <V, X extends Throwable> ListenableFuture<V> create(
ListenableFuture<? extends V> input,
Class<X> exceptionType,
Function<? super X, ? extends V> fallback,
@@ -47,7 +42,7 @@
return future;
}
- static <X extends Throwable, V extends @Nullable Object> ListenableFuture<V> create(
+ static <X extends Throwable, V> ListenableFuture<V> create(
ListenableFuture<? extends V> input,
Class<X> exceptionType,
AsyncFunction<? super X, ? extends V> fallback,
@@ -61,9 +56,9 @@
* 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.
*/
- @CheckForNull ListenableFuture<? extends V> inputFuture;
- @CheckForNull Class<X> exceptionType;
- @CheckForNull F fallback;
+ @NullableDecl ListenableFuture<? extends V> inputFuture;
+ @NullableDecl Class<X> exceptionType;
+ @NullableDecl F fallback;
AbstractCatchingFuture(
ListenableFuture<? extends V> inputFuture, Class<X> exceptionType, F fallback) {
@@ -112,11 +107,7 @@
}
if (throwable == null) {
- /*
- * The cast is safe: There was no exception, so the assignment from getDone must have
- * succeeded.
- */
- set(uncheckedCastNullableTToT(sourceResult));
+ set(sourceResult);
return;
}
@@ -143,7 +134,6 @@
}
@Override
- @CheckForNull
protected String pendingToString() {
ListenableFuture<? extends V> localInputFuture = inputFuture;
Class<X> localExceptionType = exceptionType;
@@ -168,12 +158,12 @@
/** Template method for subtypes to actually run the fallback. */
@ForOverride
- @ParametricNullness
+ @NullableDecl
abstract T doFallback(F fallback, X throwable) throws Exception;
/** Template method for subtypes to actually set the result. */
@ForOverride
- abstract void setResult(@ParametricNullness T result);
+ abstract void setResult(@NullableDecl T result);
@Override
protected final void afterDone() {
@@ -187,7 +177,7 @@
* An {@link AbstractCatchingFuture} that delegates to an {@link AsyncFunction} and {@link
* #setFuture(ListenableFuture)}.
*/
- private static final class AsyncCatchingFuture<V extends @Nullable Object, X extends Throwable>
+ private static final class AsyncCatchingFuture<V, X extends Throwable>
extends AbstractCatchingFuture<
V, X, AsyncFunction<? super X, ? extends V>, ListenableFuture<? extends V>> {
AsyncCatchingFuture(
@@ -219,7 +209,7 @@
* An {@link AbstractCatchingFuture} that delegates to a {@link Function} and {@link
* #set(Object)}.
*/
- private static final class CatchingFuture<V extends @Nullable Object, X extends Throwable>
+ private static final class CatchingFuture<V, X extends Throwable>
extends AbstractCatchingFuture<V, X, Function<? super X, ? extends V>, V> {
CatchingFuture(
ListenableFuture<? extends V> input,
@@ -229,13 +219,13 @@
}
@Override
- @ParametricNullness
+ @NullableDecl
V doFallback(Function<? super X, ? extends V> fallback, X cause) throws Exception {
return fallback.apply(cause);
}
@Override
- void setResult(@ParametricNullness V result) {
+ void setResult(@NullableDecl V result) {
set(result);
}
}
diff --git a/android/guava/src/com/google/common/util/concurrent/AbstractExecutionThreadService.java b/android/guava/src/com/google/common/util/concurrent/AbstractExecutionThreadService.java
index 0dbafd3..2bd392c 100644
--- a/android/guava/src/com/google/common/util/concurrent/AbstractExecutionThreadService.java
+++ b/android/guava/src/com/google/common/util/concurrent/AbstractExecutionThreadService.java
@@ -33,7 +33,6 @@
* @since 1.0
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public abstract class AbstractExecutionThreadService implements Service {
private static final Logger logger =
Logger.getLogger(AbstractExecutionThreadService.class.getName());
diff --git a/android/guava/src/com/google/common/util/concurrent/AbstractFuture.java b/android/guava/src/com/google/common/util/concurrent/AbstractFuture.java
index 624caa9..e799241 100644
--- a/android/guava/src/com/google/common/util/concurrent/AbstractFuture.java
+++ b/android/guava/src/com/google/common/util/concurrent/AbstractFuture.java
@@ -16,10 +16,8 @@
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Throwables.throwIfUnchecked;
-import static com.google.common.util.concurrent.NullnessCasts.uncheckedNull;
import static java.lang.Integer.toHexString;
import static java.lang.System.identityHashCode;
-import static java.util.Objects.requireNonNull;
import static java.util.concurrent.atomic.AtomicReferenceFieldUpdater.newUpdater;
import com.google.common.annotations.Beta;
@@ -45,8 +43,7 @@
import java.util.concurrent.locks.LockSupport;
import java.util.logging.Level;
import java.util.logging.Logger;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* An abstract implementation of {@link ListenableFuture}, intended for advanced users only. More
@@ -67,14 +64,10 @@
* @author Luke Sandberg
* @since 1.0
*/
-@SuppressWarnings({
- "ShortCircuitBoolean", // we use non-short circuiting comparisons intentionally
- "nullness", // TODO(b/147136275): Remove once our checker understands & and |.
-})
+@SuppressWarnings("ShortCircuitBoolean") // we use non-short circuiting comparisons intentionally
@GwtCompatible(emulated = true)
@ReflectionSupport(value = ReflectionSupport.Level.FULL)
-@ElementTypesAreNonnullByDefault
-public abstract class AbstractFuture<V extends @Nullable Object> extends InternalFutureFailureAccess
+public abstract class AbstractFuture<V> extends InternalFutureFailureAccess
implements ListenableFuture<V> {
// NOTE: Whenever both tests are cheap and functional, it's faster to use &, | instead of &&, ||
@@ -98,24 +91,21 @@
* of this interface must also be an AbstractFuture and must not override or expose for overriding
* any of the public methods of ListenableFuture.
*/
- interface Trusted<V extends @Nullable Object> extends ListenableFuture<V> {}
+ interface Trusted<V> extends ListenableFuture<V> {}
/**
* A less abstract subclass of AbstractFuture. This can be used to optimize setFuture by ensuring
* that {@link #get} calls exactly the implementation of {@link AbstractFuture#get}.
*/
- abstract static class TrustedFuture<V extends @Nullable Object> extends AbstractFuture<V>
- implements Trusted<V> {
+ abstract static class TrustedFuture<V> extends AbstractFuture<V> implements Trusted<V> {
@CanIgnoreReturnValue
@Override
- @ParametricNullness
public final V get() throws InterruptedException, ExecutionException {
return super.get();
}
@CanIgnoreReturnValue
@Override
- @ParametricNullness
public final V get(long timeout, TimeUnit unit)
throws InterruptedException, ExecutionException, TimeoutException {
return super.get(timeout, unit);
@@ -201,8 +191,8 @@
private static final class Waiter {
static final Waiter TOMBSTONE = new Waiter(false /* ignored param */);
- @CheckForNull volatile Thread thread;
- @CheckForNull volatile Waiter next;
+ @NullableDecl volatile Thread thread;
+ @NullableDecl volatile Waiter next;
/**
* Constructor for the TOMBSTONE, avoids use of ATOMIC_HELPER in case this class is loaded
@@ -217,7 +207,7 @@
// non-volatile write to the next field. Should be made visible by subsequent CAS on waiters
// field.
- void setNext(@CheckForNull Waiter next) {
+ void setNext(Waiter next) {
ATOMIC_HELPER.putNext(this, next);
}
@@ -274,24 +264,17 @@
/** Listeners also form a stack through the {@link #listeners} field. */
private static final class Listener {
- static final Listener TOMBSTONE = new Listener();
- @CheckForNull // null only for TOMBSTONE
+ static final Listener TOMBSTONE = new Listener(null, null);
final Runnable task;
- @CheckForNull // null only for TOMBSTONE
final Executor executor;
// writes to next are made visible by subsequent CAS's on the listeners field
- @CheckForNull Listener next;
+ @NullableDecl Listener next;
Listener(Runnable task, Executor executor) {
this.task = task;
this.executor = executor;
}
-
- Listener() {
- this.task = null;
- this.executor = null;
- }
}
/** A special value to represent {@code null}. */
@@ -317,8 +300,8 @@
/** A special value to represent cancellation and the 'wasInterrupted' bit. */
private static final class Cancellation {
// constants to use when GENERATE_CANCELLATION_CAUSES = false
- @CheckForNull static final Cancellation CAUSELESS_INTERRUPTED;
- @CheckForNull static final Cancellation CAUSELESS_CANCELLED;
+ static final Cancellation CAUSELESS_INTERRUPTED;
+ static final Cancellation CAUSELESS_CANCELLED;
static {
if (GENERATE_CANCELLATION_CAUSES) {
@@ -331,16 +314,16 @@
}
final boolean wasInterrupted;
- @CheckForNull final Throwable cause;
+ @NullableDecl final Throwable cause;
- Cancellation(boolean wasInterrupted, @CheckForNull Throwable cause) {
+ Cancellation(boolean wasInterrupted, @NullableDecl Throwable cause) {
this.wasInterrupted = wasInterrupted;
this.cause = cause;
}
}
/** A special value that encodes the 'setFuture' state. */
- private static final class SetFuture<V extends @Nullable Object> implements Runnable {
+ private static final class SetFuture<V> implements Runnable {
final AbstractFuture<V> owner;
final ListenableFuture<? extends V> future;
@@ -379,13 +362,13 @@
* argument.
* </ul>
*/
- @CheckForNull private volatile Object value;
+ @NullableDecl private volatile Object value;
/** All listeners. */
- @CheckForNull private volatile Listener listeners;
+ @NullableDecl private volatile Listener listeners;
/** All waiting threads. */
- @CheckForNull private volatile Waiter waiters;
+ @NullableDecl private volatile Waiter waiters;
/** Constructor for use by subclasses. */
protected AbstractFuture() {}
@@ -424,7 +407,6 @@
*/
@CanIgnoreReturnValue
@Override
- @ParametricNullness
public V get(long timeout, TimeUnit unit)
throws InterruptedException, TimeoutException, ExecutionException {
// NOTE: if timeout < 0, remainingNanos will be < 0 and we will fall into the while(true) loop
@@ -477,8 +459,7 @@
}
// re-read value, if we get here then we must have observed a TOMBSTONE while trying to add a
// waiter.
- // requireNonNull is safe because value is always set before TOMBSTONE.
- return getDoneValue(requireNonNull(value));
+ return getDoneValue(value);
}
// If we get here then we have remainingNanos < SPIN_THRESHOLD_NANOS and there is no node on the
// waiters list
@@ -537,7 +518,6 @@
*/
@CanIgnoreReturnValue
@Override
- @ParametricNullness
public V get() throws InterruptedException, ExecutionException {
if (Thread.interrupted()) {
throw new InterruptedException();
@@ -573,12 +553,10 @@
}
// re-read value, if we get here then we must have observed a TOMBSTONE while trying to add a
// waiter.
- // requireNonNull is safe because value is always set before TOMBSTONE.
- return getDoneValue(requireNonNull(value));
+ return getDoneValue(value);
}
/** Unboxes {@code obj}. Assumes that obj is not {@code null} or a {@link SetFuture}. */
- @ParametricNullness
private V getDoneValue(Object obj) throws ExecutionException {
// While this seems like it might be too branch-y, simple benchmarking proves it to be
// unmeasurable (comparing done AbstractFutures with immediateFuture)
@@ -587,11 +565,7 @@
} else if (obj instanceof Failure) {
throw new ExecutionException(((Failure) obj).exception);
} else if (obj == NULL) {
- /*
- * It's safe to return null because we would only have stored it in the first place if it were
- * a valid value for V.
- */
- return uncheckedNull();
+ return null;
} else {
@SuppressWarnings("unchecked") // this is the only other option
V asV = (V) obj;
@@ -639,20 +613,9 @@
GENERATE_CANCELLATION_CAUSES
? new Cancellation(
mayInterruptIfRunning, new CancellationException("Future.cancel() was called."))
- /*
- * requireNonNull is safe because we've initialized these if
- * !GENERATE_CANCELLATION_CAUSES.
- *
- * TODO(cpovirk): Maybe it would be cleaner to define a CancellationSupplier interface
- * with two implementations, one that contains causeless Cancellation instances and
- * the other of which creates new Cancellation instances each time it's called? Yet
- * another alternative is to fill in a non-null value for each of the fields no matter
- * what and to just not use it if !GENERATE_CANCELLATION_CAUSES.
- */
- : requireNonNull(
- mayInterruptIfRunning
- ? Cancellation.CAUSELESS_INTERRUPTED
- : Cancellation.CAUSELESS_CANCELLED);
+ : (mayInterruptIfRunning
+ ? Cancellation.CAUSELESS_INTERRUPTED
+ : Cancellation.CAUSELESS_CANCELLED);
AbstractFuture<?> abstractFuture = this;
while (true) {
if (ATOMIC_HELPER.casValue(abstractFuture, localValue, valueToSet)) {
@@ -777,7 +740,7 @@
* @return true if the attempt was accepted, completing the {@code Future}
*/
@CanIgnoreReturnValue
- protected boolean set(@ParametricNullness V value) {
+ protected boolean set(@NullableDecl V value) {
Object valueToSet = value == null ? NULL : value;
if (ATOMIC_HELPER.casValue(this, null, valueToSet)) {
complete(this);
@@ -853,7 +816,7 @@
}
return false;
}
- SetFuture<V> valueToSet = new SetFuture<V>(this, future);
+ SetFuture valueToSet = new SetFuture<V>(this, future);
if (ATOMIC_HELPER.casValue(this, null, valueToSet)) {
// the listener is responsible for calling completeWithFuture, directExecutor is appropriate
// since all we are doing is unpacking a completed future which should be fast.
@@ -910,8 +873,7 @@
: Cancellation.CAUSELESS_CANCELLED;
}
}
- // requireNonNull is safe as long as we call this method only on completed futures.
- return requireNonNull(v);
+ return v;
}
if (future instanceof InternalFutureFailureAccess) {
Throwable throwable =
@@ -923,11 +885,7 @@
boolean wasCancelled = future.isCancelled();
// Don't allocate a CancellationException if it's not necessary
if (!GENERATE_CANCELLATION_CAUSES & wasCancelled) {
- /*
- * requireNonNull is safe because we've initialized CAUSELESS_CANCELLED if
- * !GENERATE_CANCELLATION_CAUSES.
- */
- return requireNonNull(Cancellation.CAUSELESS_CANCELLED);
+ return Cancellation.CAUSELESS_CANCELLED;
}
// Otherwise calculate the value by calling .get()
try {
@@ -970,9 +928,7 @@
* An inlined private copy of {@link Uninterruptibles#getUninterruptibly} used to break an
* internal dependency on other /util/concurrent classes.
*/
- @ParametricNullness
- private static <V extends @Nullable Object> V getUninterruptibly(Future<V> future)
- throws ExecutionException {
+ private static <V> V getUninterruptibly(Future<V> future) throws ExecutionException {
boolean interrupted = false;
try {
while (true) {
@@ -990,10 +946,7 @@
}
/** Unblocks all threads and runs all listeners. */
- private static void complete(AbstractFuture<?> param) {
- // Declare a "true" local variable so that the Checker Framework will infer nullness.
- AbstractFuture<?> future = param;
-
+ private static void complete(AbstractFuture<?> future) {
Listener next = null;
outer:
while (true) {
@@ -1010,11 +963,7 @@
while (next != null) {
Listener curr = next;
next = next.next;
- /*
- * requireNonNull is safe because the listener stack never contains TOMBSTONE until after
- * clearListeners.
- */
- Runnable task = requireNonNull(curr.task);
+ Runnable task = curr.task;
if (task instanceof SetFuture) {
SetFuture<?> setFuture = (SetFuture<?>) task;
// We unwind setFuture specifically to avoid StackOverflowErrors in the case of long
@@ -1031,11 +980,7 @@
}
// other wise the future we were trying to set is already done.
} else {
- /*
- * requireNonNull is safe because the listener stack never contains TOMBSTONE until after
- * clearListeners.
- */
- executeListener(task, requireNonNull(curr.executor));
+ executeListener(task, curr.executor);
}
}
break;
@@ -1079,13 +1024,7 @@
* @since 27.0
*/
@Override
- /*
- * We should annotate the superclass, InternalFutureFailureAccess, to say that its copy of this
- * method returns @Nullable, too. However, we're not sure if we want to make any changes to that
- * class, since it's in a separate artifact that we planned to release only a single version of.
- */
- @SuppressWarnings("nullness")
- @CheckForNull
+ @NullableDecl
protected final Throwable tryInternalFastPathGetFailure() {
if (this instanceof Trusted) {
Object obj = value;
@@ -1100,7 +1039,7 @@
* If this future has been cancelled (and possibly interrupted), cancels (and possibly interrupts)
* the given future (if available).
*/
- final void maybePropagateCancellationTo(@CheckForNull Future<?> related) {
+ final void maybePropagateCancellationTo(@NullableDecl Future<?> related) {
if (related != null & isCancelled()) {
related.cancel(wasInterrupted());
}
@@ -1121,8 +1060,7 @@
* Clears the {@link #listeners} list and prepends its contents to {@code onto}, least recently
* added first.
*/
- @CheckForNull
- private Listener clearListeners(@CheckForNull Listener onto) {
+ private Listener clearListeners(Listener onto) {
// We need to
// 1. atomically swap the listeners with TOMBSTONE, this is because addListener uses that to
// to synchronize with us
@@ -1170,7 +1108,7 @@
* @return null if an explanation cannot be provided (e.g. because the future is done).
* @since 23.0
*/
- @CheckForNull
+ @NullableDecl
protected String pendingToString() {
// TODO(diamondm) consider moving this into addPendingString so it's always in the output
if (this instanceof ScheduledFuture) {
@@ -1236,7 +1174,7 @@
* implementation. Using a reconstruction of the default Object.toString() prevents OOMs and stack
* overflows, and helps avoid sensitive data inadvertently ending up in exception messages.
*/
- private void appendResultObject(StringBuilder builder, @CheckForNull Object o) {
+ private void appendResultObject(StringBuilder builder, Object o) {
if (o == null) {
builder.append("null");
} else if (o == this) {
@@ -1250,7 +1188,7 @@
}
/** Helper for printing user supplied objects into our toString method. */
- private void appendUserObject(StringBuilder builder, @CheckForNull Object o) {
+ private void appendUserObject(StringBuilder builder, Object o) {
// This is some basic recursion detection for when people create cycles via set/setFuture or
// when deep chains of futures exist resulting in a StackOverflowException. We could detect
// arbitrary cycles using a thread local but this should be a good enough solution (it is also
@@ -1291,18 +1229,16 @@
abstract void putThread(Waiter waiter, Thread newValue);
/** Non volatile write of the waiter to the {@link Waiter#next} field. */
- abstract void putNext(Waiter waiter, @CheckForNull Waiter newValue);
+ abstract void putNext(Waiter waiter, Waiter newValue);
/** Performs a CAS operation on the {@link #waiters} field. */
- abstract boolean casWaiters(
- AbstractFuture<?> future, @CheckForNull Waiter expect, @CheckForNull Waiter update);
+ abstract boolean casWaiters(AbstractFuture<?> future, Waiter expect, Waiter update);
/** Performs a CAS operation on the {@link #listeners} field. */
- abstract boolean casListeners(
- AbstractFuture<?> future, @CheckForNull Listener expect, Listener update);
+ abstract boolean casListeners(AbstractFuture<?> future, Listener expect, Listener update);
/** Performs a CAS operation on the {@link #value} field. */
- abstract boolean casValue(AbstractFuture<?> future, @CheckForNull Object expect, Object update);
+ abstract boolean casValue(AbstractFuture<?> future, Object expect, Object update);
}
/**
@@ -1311,7 +1247,6 @@
* <p>Static initialization of this class will fail if the {@link sun.misc.Unsafe} object cannot
* be accessed.
*/
- @SuppressWarnings("sunapi")
private static final class UnsafeAtomicHelper extends AtomicHelper {
static final sun.misc.Unsafe UNSAFE;
static final long LISTENERS_OFFSET;
@@ -1366,32 +1301,30 @@
}
@Override
- void putNext(Waiter waiter, @CheckForNull Waiter newValue) {
+ void putNext(Waiter waiter, Waiter newValue) {
UNSAFE.putObject(waiter, WAITER_NEXT_OFFSET, newValue);
}
/** Performs a CAS operation on the {@link #waiters} field. */
@Override
- boolean casWaiters(
- AbstractFuture<?> future, @CheckForNull Waiter expect, @CheckForNull Waiter update) {
+ boolean casWaiters(AbstractFuture<?> future, Waiter expect, Waiter update) {
return UNSAFE.compareAndSwapObject(future, WAITERS_OFFSET, expect, update);
}
/** Performs a CAS operation on the {@link #listeners} field. */
@Override
- boolean casListeners(AbstractFuture<?> future, @CheckForNull Listener expect, Listener update) {
+ boolean casListeners(AbstractFuture<?> future, Listener expect, Listener update) {
return UNSAFE.compareAndSwapObject(future, LISTENERS_OFFSET, expect, update);
}
/** Performs a CAS operation on the {@link #value} field. */
@Override
- boolean casValue(AbstractFuture<?> future, @CheckForNull Object expect, Object update) {
+ boolean casValue(AbstractFuture<?> future, Object expect, Object update) {
return UNSAFE.compareAndSwapObject(future, VALUE_OFFSET, expect, update);
}
}
/** {@link AtomicHelper} based on {@link AtomicReferenceFieldUpdater}. */
- @SuppressWarnings("rawtypes")
private static final class SafeAtomicHelper extends AtomicHelper {
final AtomicReferenceFieldUpdater<Waiter, Thread> waiterThreadUpdater;
final AtomicReferenceFieldUpdater<Waiter, Waiter> waiterNextUpdater;
@@ -1418,23 +1351,22 @@
}
@Override
- void putNext(Waiter waiter, @CheckForNull Waiter newValue) {
+ void putNext(Waiter waiter, Waiter newValue) {
waiterNextUpdater.lazySet(waiter, newValue);
}
@Override
- boolean casWaiters(
- AbstractFuture<?> future, @CheckForNull Waiter expect, @CheckForNull Waiter update) {
+ boolean casWaiters(AbstractFuture<?> future, Waiter expect, Waiter update) {
return waitersUpdater.compareAndSet(future, expect, update);
}
@Override
- boolean casListeners(AbstractFuture<?> future, @CheckForNull Listener expect, Listener update) {
+ boolean casListeners(AbstractFuture<?> future, Listener expect, Listener update) {
return listenersUpdater.compareAndSet(future, expect, update);
}
@Override
- boolean casValue(AbstractFuture<?> future, @CheckForNull Object expect, Object update) {
+ boolean casValue(AbstractFuture<?> future, Object expect, Object update) {
return valueUpdater.compareAndSet(future, expect, update);
}
}
@@ -1452,13 +1384,12 @@
}
@Override
- void putNext(Waiter waiter, @CheckForNull Waiter newValue) {
+ void putNext(Waiter waiter, Waiter newValue) {
waiter.next = newValue;
}
@Override
- boolean casWaiters(
- AbstractFuture<?> future, @CheckForNull Waiter expect, @CheckForNull Waiter update) {
+ boolean casWaiters(AbstractFuture<?> future, Waiter expect, Waiter update) {
synchronized (future) {
if (future.waiters == expect) {
future.waiters = update;
@@ -1469,7 +1400,7 @@
}
@Override
- boolean casListeners(AbstractFuture<?> future, @CheckForNull Listener expect, Listener update) {
+ boolean casListeners(AbstractFuture<?> future, Listener expect, Listener update) {
synchronized (future) {
if (future.listeners == expect) {
future.listeners = update;
@@ -1480,7 +1411,7 @@
}
@Override
- boolean casValue(AbstractFuture<?> future, @CheckForNull Object expect, Object update) {
+ boolean casValue(AbstractFuture<?> future, Object expect, Object update) {
synchronized (future) {
if (future.value == expect) {
future.value = update;
@@ -1492,7 +1423,7 @@
}
private static CancellationException cancellationExceptionWithCause(
- String message, @CheckForNull Throwable cause) {
+ @NullableDecl String message, @NullableDecl Throwable cause) {
CancellationException exception = new CancellationException(message);
exception.initCause(cause);
return exception;
diff --git a/android/guava/src/com/google/common/util/concurrent/AbstractIdleService.java b/android/guava/src/com/google/common/util/concurrent/AbstractIdleService.java
index 05bc4b9..7416a9b 100644
--- a/android/guava/src/com/google/common/util/concurrent/AbstractIdleService.java
+++ b/android/guava/src/com/google/common/util/concurrent/AbstractIdleService.java
@@ -31,7 +31,6 @@
* @since 1.0
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public abstract class AbstractIdleService implements Service {
/* Thread names will look like {@code "MyService STARTING"}. */
diff --git a/android/guava/src/com/google/common/util/concurrent/AbstractListeningExecutorService.java b/android/guava/src/com/google/common/util/concurrent/AbstractListeningExecutorService.java
index fd5c5c9..22157ba 100644
--- a/android/guava/src/com/google/common/util/concurrent/AbstractListeningExecutorService.java
+++ b/android/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.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* Abstract {@link ListeningExecutorService} implementation that creates {@link ListenableFuture}
@@ -36,20 +36,18 @@
@Beta
@CanIgnoreReturnValue
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public abstract class AbstractListeningExecutorService extends AbstractExecutorService
implements ListeningExecutorService {
/** @since 19.0 (present with return type {@code ListenableFutureTask} since 14.0) */
@Override
- protected final <T extends @Nullable Object> RunnableFuture<T> newTaskFor(
- Runnable runnable, @ParametricNullness T value) {
+ protected final <T> RunnableFuture<T> newTaskFor(Runnable runnable, T value) {
return TrustedListenableFutureTask.create(runnable, value);
}
/** @since 19.0 (present with return type {@code ListenableFutureTask} since 14.0) */
@Override
- protected final <T extends @Nullable Object> RunnableFuture<T> newTaskFor(Callable<T> callable) {
+ protected final <T> RunnableFuture<T> newTaskFor(Callable<T> callable) {
return TrustedListenableFutureTask.create(callable);
}
@@ -59,13 +57,12 @@
}
@Override
- public <T extends @Nullable Object> ListenableFuture<T> submit(
- Runnable task, @ParametricNullness T result) {
+ public <T> ListenableFuture<T> submit(Runnable task, @NullableDecl T result) {
return (ListenableFuture<T>) super.submit(task, result);
}
@Override
- public <T extends @Nullable Object> ListenableFuture<T> submit(Callable<T> task) {
+ public <T> ListenableFuture<T> submit(Callable<T> task) {
return (ListenableFuture<T>) super.submit(task);
}
}
diff --git a/android/guava/src/com/google/common/util/concurrent/AbstractScheduledService.java b/android/guava/src/com/google/common/util/concurrent/AbstractScheduledService.java
index 7288ba5..70d4fb7 100644
--- a/android/guava/src/com/google/common/util/concurrent/AbstractScheduledService.java
+++ b/android/guava/src/com/google/common/util/concurrent/AbstractScheduledService.java
@@ -16,9 +16,7 @@
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.util.concurrent.Futures.immediateCancelledFuture;
import static com.google.common.util.concurrent.MoreExecutors.directExecutor;
-import static java.util.Objects.requireNonNull;
import com.google.common.annotations.GwtIncompatible;
import com.google.common.base.Supplier;
@@ -30,15 +28,13 @@
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.concurrent.locks.ReentrantLock;
import java.util.logging.Level;
import java.util.logging.Logger;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* Base class for services that can implement {@link #startUp} and {@link #shutDown} but while in
@@ -98,7 +94,6 @@
* @since 11.0
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public abstract class AbstractScheduledService implements Service {
private static final Logger logger = Logger.getLogger(AbstractScheduledService.class.getName());
@@ -131,10 +126,9 @@
checkArgument(delay > 0, "delay must be > 0, found %s", delay);
return new Scheduler() {
@Override
- public Cancellable schedule(
+ public Future<?> schedule(
AbstractService service, ScheduledExecutorService executor, Runnable task) {
- return new FutureAsCancellable(
- executor.scheduleWithFixedDelay(task, initialDelay, delay, unit));
+ return executor.scheduleWithFixedDelay(task, initialDelay, delay, unit);
}
};
}
@@ -154,16 +148,15 @@
checkArgument(period > 0, "period must be > 0, found %s", period);
return new Scheduler() {
@Override
- public Cancellable schedule(
+ public Future<?> schedule(
AbstractService service, ScheduledExecutorService executor, Runnable task) {
- return new FutureAsCancellable(
- executor.scheduleAtFixedRate(task, initialDelay, period, unit));
+ return executor.scheduleAtFixedRate(task, initialDelay, period, unit);
}
};
}
/** Schedules the task to run on the provided executor on behalf of the service. */
- abstract Cancellable schedule(
+ abstract Future<?> schedule(
AbstractService service, ScheduledExecutorService executor, Runnable runnable);
private Scheduler() {}
@@ -177,8 +170,8 @@
// A handle to the running task so that we can stop it when a shutdown has been requested.
// These two fields are volatile because their values will be accessed from multiple threads.
- @CheckForNull private volatile Cancellable runningTask;
- @CheckForNull private volatile ScheduledExecutorService executorService;
+ @NullableDecl private volatile Future<?> runningTask;
+ @NullableDecl private volatile ScheduledExecutorService executorService;
// This lock protects the task so we can ensure that none of the template methods (startUp,
// shutDown or runOneIteration) run concurrently with one another.
@@ -192,11 +185,7 @@
public void run() {
lock.lock();
try {
- /*
- * requireNonNull is safe because Task isn't run (or at least it doesn't succeed in taking
- * the lock) until after it's scheduled and the runningTask field is set.
- */
- if (requireNonNull(runningTask).isCancelled()) {
+ if (runningTask.isCancelled()) {
// task may have been cancelled while blocked on the lock.
return;
}
@@ -211,8 +200,7 @@
ignored);
}
notifyFailed(t);
- // requireNonNull is safe now, just as it was above.
- requireNonNull(runningTask).cancel(false); // prevent future invocations.
+ runningTask.cancel(false); // prevent future invocations.
} finally {
lock.unlock();
}
@@ -256,9 +244,6 @@
@Override
protected final void doStop() {
- // Both requireNonNull calls are safe because doStop can run only after a successful doStart.
- requireNonNull(runningTask);
- requireNonNull(executorService);
runningTask.cancel(false);
executorService.execute(
new Runnable() {
@@ -331,9 +316,9 @@
* fails}. Subclasses may override this method to supply a custom {@link ScheduledExecutorService}
* instance. This method is guaranteed to only be called once.
*
- * <p>By default this returns a new {@link ScheduledExecutorService} with a single thread pool
- * that sets the name of the thread to the {@linkplain #serviceName() service name}. Also, the
- * pool will be {@linkplain ScheduledExecutorService#shutdown() shut down} when the service
+ * <p>By default this returns a new {@link ScheduledExecutorService} with a single thread thread
+ * pool that sets the name of the thread to the {@linkplain #serviceName() service name}. Also,
+ * the pool will be {@linkplain ScheduledExecutorService#shutdown() shut down} when the service
* {@linkplain Service.State#TERMINATED terminates} or {@linkplain Service.State#TERMINATED
* fails}.
*/
@@ -445,30 +430,6 @@
delegate.awaitTerminated(timeout, unit);
}
- interface Cancellable {
- void cancel(boolean mayInterruptIfRunning);
-
- boolean isCancelled();
- }
-
- private static final class FutureAsCancellable implements Cancellable {
- private final Future<?> delegate;
-
- FutureAsCancellable(Future<?> delegate) {
- this.delegate = delegate;
- }
-
- @Override
- public void cancel(boolean mayInterruptIfRunning) {
- delegate.cancel(mayInterruptIfRunning);
- }
-
- @Override
- public boolean isCancelled() {
- return delegate.isCancelled();
- }
- }
-
/**
* A {@link Scheduler} that provides a convenient way for the {@link AbstractScheduledService} to
* use a dynamically changing schedule. After every execution of the task, assuming it hasn't been
@@ -480,7 +441,7 @@
public abstract static class CustomScheduler extends Scheduler {
/** A callable class that can reschedule itself using a {@link CustomScheduler}. */
- private final class ReschedulableCallable implements Callable<@Nullable Void> {
+ private class ReschedulableCallable extends ForwardingFuture<Void> implements Callable<Void> {
/** The underlying task. */
private final Runnable wrappedRunnable;
@@ -492,27 +453,6 @@
* The service that is managing this callable. This is used so that failure can be reported
* properly.
*/
- /*
- * This reference is part of a reference cycle, which is typically something we want to avoid
- * under j2objc -- but it is not detected by our j2objc cycle test. The cycle:
- *
- * - CustomScheduler.service contains an instance of ServiceDelegate. (It needs it so that it
- * can call notifyFailed.)
- *
- * - ServiceDelegate.runningTask contains an instance of ReschedulableCallable (at least in
- * the case that the service is using CustomScheduler). (It needs it so that it can cancel
- * the task and detect whether it has been cancelled.)
- *
- * - ReschedulableCallable has a reference back to its enclosing CustomScheduler. (It needs it
- * so that it can call getNextSchedule).
- *
- * Maybe there is a way to avoid this cycle. But we think the cycle is safe enough to ignore:
- * Each task is retained for only as long as it is running -- so it's retained only as long as
- * it would already be retained by the underlying executor.
- *
- * If the cycle test starts reporting this cycle in the future, we should add an entry to
- * cycle_suppress_list.txt.
- */
private final AbstractService service;
/**
@@ -524,8 +464,8 @@
/** The future that represents the next execution of this task. */
@GuardedBy("lock")
- @CheckForNull
- private SupplantableFuture cancellationDelegate;
+ @NullableDecl
+ private Future<Void> currentFuture;
ReschedulableCallable(
AbstractService service, ScheduledExecutorService executor, Runnable runnable) {
@@ -535,36 +475,32 @@
}
@Override
- @CheckForNull
public Void call() throws Exception {
wrappedRunnable.run();
reschedule();
return null;
}
- /**
- * Atomically reschedules this task and assigns the new future to {@link
- * #cancellationDelegate}.
- */
- @CanIgnoreReturnValue
- public Cancellable reschedule() {
+ /** Atomically reschedules this task and assigns the new future to {@link #currentFuture}. */
+ public void reschedule() {
// invoke the callback outside the lock, prevents some shenanigans.
Schedule schedule;
try {
schedule = CustomScheduler.this.getNextSchedule();
} catch (Throwable t) {
service.notifyFailed(t);
- return new FutureAsCancellable(immediateCancelledFuture());
+ return;
}
// We reschedule ourselves with a lock held for two reasons. 1. we want to make sure that
// cancel calls cancel on the correct future. 2. we want to make sure that the assignment
// to currentFuture doesn't race with itself so that currentFuture is assigned in the
// correct order.
Throwable scheduleFailure = null;
- Cancellable toReturn;
lock.lock();
try {
- toReturn = initializeOrUpdateCancellationDelegate(schedule);
+ if (currentFuture == null || !currentFuture.isCancelled()) {
+ currentFuture = executor.schedule(this, schedule.delay, schedule.unit);
+ }
} catch (Throwable e) {
// If an exception is thrown by the subclass then we need to make sure that the service
// notices and transitions to the FAILED state. We do it by calling notifyFailed directly
@@ -575,7 +511,6 @@
// the AbstractService could monitor the future directly. Rescheduling is still hard...
// but it would help with some of these lock ordering issues.
scheduleFailure = e;
- toReturn = new FutureAsCancellable(immediateCancelledFuture());
} finally {
lock.unlock();
}
@@ -583,63 +518,16 @@
if (scheduleFailure != null) {
service.notifyFailed(scheduleFailure);
}
- return toReturn;
}
- @GuardedBy("lock")
- /*
- * The GuardedBy checker warns us that we're not holding cancellationDelegate.lock. But in
- * fact we are holding it because it is the same as this.lock, which we know we are holding,
- * thanks to @GuardedBy above. (cancellationDelegate.lock is initialized to this.lock in the
- * call to `new SupplantableFuture` below.)
- */
- @SuppressWarnings("GuardedBy")
- private Cancellable initializeOrUpdateCancellationDelegate(Schedule schedule) {
- if (cancellationDelegate == null) {
- return cancellationDelegate = new SupplantableFuture(lock, submitToExecutor(schedule));
- }
- if (!cancellationDelegate.currentFuture.isCancelled()) {
- cancellationDelegate.currentFuture = submitToExecutor(schedule);
- }
- return cancellationDelegate;
- }
-
- private ScheduledFuture<@Nullable Void> submitToExecutor(Schedule schedule) {
- return executor.schedule(this, schedule.delay, schedule.unit);
- }
- }
-
- /**
- * Contains the most recently submitted {@code Future}, which may be cancelled or updated,
- * always under a lock.
- */
- private static final class SupplantableFuture implements Cancellable {
- private final ReentrantLock lock;
-
- @GuardedBy("lock")
- private Future<@Nullable Void> currentFuture;
-
- SupplantableFuture(ReentrantLock lock, Future<@Nullable Void> currentFuture) {
- this.lock = lock;
- this.currentFuture = currentFuture;
- }
-
+ // N.B. Only protect cancel and isCancelled because those are the only methods that are
+ // invoked by the AbstractScheduledService.
@Override
- public void cancel(boolean mayInterruptIfRunning) {
- /*
- * Lock to ensure that a task cannot be rescheduled while a cancel is ongoing.
- *
- * In theory, cancel() could execute arbitrary listeners -- bad to do while holding a lock.
- * However, we don't expose currentFuture to users, so they can't attach listeners. And the
- * Future might not even be a ListenableFuture, just a plain Future. That said, similar
- * problems can exist with methods like FutureTask.done(), not to mention slow calls to
- * Thread.interrupt() (as discussed in InterruptibleTask). At the end of the day, it's
- * unlikely that cancel() will be slow, so we can probably get away with calling it while
- * holding a lock. Still, it would be nice to avoid somehow.
- */
+ public boolean cancel(boolean mayInterruptIfRunning) {
+ // Ensure that a task cannot be rescheduled while a cancel is ongoing.
lock.lock();
try {
- currentFuture.cancel(mayInterruptIfRunning);
+ return currentFuture.cancel(mayInterruptIfRunning);
} finally {
lock.unlock();
}
@@ -654,12 +542,20 @@
lock.unlock();
}
}
+
+ @Override
+ protected Future<Void> delegate() {
+ throw new UnsupportedOperationException(
+ "Only cancel and isCancelled is supported by this future");
+ }
}
@Override
- final Cancellable schedule(
+ final Future<?> schedule(
AbstractService service, ScheduledExecutorService executor, Runnable runnable) {
- return new ReschedulableCallable(service, executor, runnable).reschedule();
+ ReschedulableCallable task = new ReschedulableCallable(service, executor, runnable);
+ task.reschedule();
+ return task;
}
/**
diff --git a/android/guava/src/com/google/common/util/concurrent/AbstractService.java b/android/guava/src/com/google/common/util/concurrent/AbstractService.java
index 1cf31bf..733bf3b 100644
--- a/android/guava/src/com/google/common/util/concurrent/AbstractService.java
+++ b/android/guava/src/com/google/common/util/concurrent/AbstractService.java
@@ -23,7 +23,6 @@
import static com.google.common.util.concurrent.Service.State.STARTING;
import static com.google.common.util.concurrent.Service.State.STOPPING;
import static com.google.common.util.concurrent.Service.State.TERMINATED;
-import static java.util.Objects.requireNonNull;
import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtIncompatible;
@@ -36,7 +35,7 @@
import java.util.concurrent.Executor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* Base class for implementing services that can handle {@link #doStart} and {@link #doStop}
@@ -49,7 +48,6 @@
* @since 1.0
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public abstract class AbstractService implements Service {
private static final ListenerCallQueue.Event<Listener> STARTING_EVENT =
new ListenerCallQueue.Event<Listener>() {
@@ -171,7 +169,7 @@
@Override
public boolean isSatisfied() {
- return state().compareTo(TERMINATED) >= 0;
+ return state().isTerminal();
}
}
@@ -577,20 +575,20 @@
* The exception that caused this service to fail. This will be {@code null} unless the service
* has failed.
*/
- @CheckForNull final Throwable failure;
+ @NullableDecl final Throwable failure;
StateSnapshot(State internalState) {
this(internalState, false, null);
}
StateSnapshot(
- State internalState, boolean shutdownWhenStartupFinishes, @CheckForNull Throwable failure) {
+ State internalState, boolean shutdownWhenStartupFinishes, @NullableDecl Throwable failure) {
checkArgument(
!shutdownWhenStartupFinishes || internalState == STARTING,
"shutdownWhenStartupFinishes can only be set if state is STARTING. Got %s instead.",
internalState);
checkArgument(
- (failure != null) == (internalState == FAILED),
+ !(failure != null ^ internalState == FAILED),
"A failure cause should be set if and only if the state is failed. Got %s and %s "
+ "instead.",
internalState,
@@ -615,8 +613,7 @@
state == FAILED,
"failureCause() is only valid if the service has failed, service is %s",
state);
- // requireNonNull is safe because the constructor requires a non-null cause with state=FAILED.
- return requireNonNull(failure);
+ return failure;
}
}
}
diff --git a/android/guava/src/com/google/common/util/concurrent/AbstractTransformFuture.java b/android/guava/src/com/google/common/util/concurrent/AbstractTransformFuture.java
index dd68791..4b908dc 100644
--- a/android/guava/src/com/google/common/util/concurrent/AbstractTransformFuture.java
+++ b/android/guava/src/com/google/common/util/concurrent/AbstractTransformFuture.java
@@ -24,17 +24,13 @@
import java.util.concurrent.CancellationException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executor;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/** Implementations of {@code Futures.transform*}. */
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-@SuppressWarnings("nullness") // TODO(b/147136275): Remove once our checker understands & and |.
-abstract class AbstractTransformFuture<
- I extends @Nullable Object, O extends @Nullable Object, F, T extends @Nullable Object>
- extends FluentFuture.TrustedFuture<O> implements Runnable {
- static <I extends @Nullable Object, O extends @Nullable Object> ListenableFuture<O> create(
+abstract class AbstractTransformFuture<I, O, F, T> extends FluentFuture.TrustedFuture<O>
+ implements Runnable {
+ static <I, O> ListenableFuture<O> create(
ListenableFuture<I> input,
AsyncFunction<? super I, ? extends O> function,
Executor executor) {
@@ -44,7 +40,7 @@
return output;
}
- static <I extends @Nullable Object, O extends @Nullable Object> ListenableFuture<O> create(
+ static <I, O> ListenableFuture<O> create(
ListenableFuture<I> input, Function<? super I, ? extends O> function, Executor executor) {
checkNotNull(function);
TransformFuture<I, O> output = new TransformFuture<>(input, function);
@@ -56,8 +52,8 @@
* 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.
*/
- @CheckForNull ListenableFuture<? extends I> inputFuture;
- @CheckForNull F function;
+ @NullableDecl ListenableFuture<? extends I> inputFuture;
+ @NullableDecl F function;
AbstractTransformFuture(ListenableFuture<? extends I> inputFuture, F function) {
this.inputFuture = checkNotNull(inputFuture);
@@ -169,12 +165,12 @@
/** Template method for subtypes to actually run the transform. */
@ForOverride
- @ParametricNullness
- abstract T doTransform(F function, @ParametricNullness I result) throws Exception;
+ @NullableDecl
+ abstract T doTransform(F function, @NullableDecl I result) throws Exception;
/** Template method for subtypes to actually set the result. */
@ForOverride
- abstract void setResult(@ParametricNullness T result);
+ abstract void setResult(@NullableDecl T result);
@Override
protected final void afterDone() {
@@ -184,7 +180,6 @@
}
@Override
- @CheckForNull
protected String pendingToString() {
ListenableFuture<? extends I> localInputFuture = inputFuture;
F localFunction = function;
@@ -205,8 +200,7 @@
* An {@link AbstractTransformFuture} that delegates to an {@link AsyncFunction} and {@link
* #setFuture(ListenableFuture)}.
*/
- private static final class AsyncTransformFuture<
- I extends @Nullable Object, O extends @Nullable Object>
+ private static final class AsyncTransformFuture<I, O>
extends AbstractTransformFuture<
I, O, AsyncFunction<? super I, ? extends O>, ListenableFuture<? extends O>> {
AsyncTransformFuture(
@@ -216,8 +210,7 @@
@Override
ListenableFuture<? extends O> doTransform(
- AsyncFunction<? super I, ? extends O> function, @ParametricNullness I input)
- throws Exception {
+ AsyncFunction<? super I, ? extends O> function, @NullableDecl I input) throws Exception {
ListenableFuture<? extends O> outputFuture = function.apply(input);
checkNotNull(
outputFuture,
@@ -237,7 +230,7 @@
* An {@link AbstractTransformFuture} that delegates to a {@link Function} and {@link
* #set(Object)}.
*/
- private static final class TransformFuture<I extends @Nullable Object, O extends @Nullable Object>
+ private static final class TransformFuture<I, O>
extends AbstractTransformFuture<I, O, Function<? super I, ? extends O>, O> {
TransformFuture(
ListenableFuture<? extends I> inputFuture, Function<? super I, ? extends O> function) {
@@ -245,13 +238,13 @@
}
@Override
- @ParametricNullness
- O doTransform(Function<? super I, ? extends O> function, @ParametricNullness I input) {
+ @NullableDecl
+ O doTransform(Function<? super I, ? extends O> function, @NullableDecl I input) {
return function.apply(input);
}
@Override
- void setResult(@ParametricNullness O result) {
+ void setResult(@NullableDecl O result) {
set(result);
}
}
diff --git a/android/guava/src/com/google/common/util/concurrent/AggregateFuture.java b/android/guava/src/com/google/common/util/concurrent/AggregateFuture.java
index a32e76c..244f9fd 100644
--- a/android/guava/src/com/google/common/util/concurrent/AggregateFuture.java
+++ b/android/guava/src/com/google/common/util/concurrent/AggregateFuture.java
@@ -20,7 +20,6 @@
import static com.google.common.util.concurrent.AggregateFuture.ReleaseResourcesReason.OUTPUT_FUTURE_DONE;
import static com.google.common.util.concurrent.Futures.getDone;
import static com.google.common.util.concurrent.MoreExecutors.directExecutor;
-import static java.util.Objects.requireNonNull;
import static java.util.logging.Level.SEVERE;
import com.google.common.annotations.GwtCompatible;
@@ -31,8 +30,7 @@
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.logging.Logger;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* A future whose value is derived from a collection of input futures.
@@ -41,9 +39,7 @@
* @param <OutputT> the type of the output (i.e. this) future
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-abstract class AggregateFuture<InputT extends @Nullable Object, OutputT extends @Nullable Object>
- extends AggregateFutureState<OutputT> {
+abstract class AggregateFuture<InputT, OutputT> extends AggregateFutureState<OutputT> {
private static final Logger logger = Logger.getLogger(AggregateFuture.class.getName());
/**
@@ -56,7 +52,7 @@
* 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.
*/
- @CheckForNull private ImmutableCollection<? extends ListenableFuture<? extends InputT>> futures;
+ @NullableDecl private ImmutableCollection<? extends ListenableFuture<? extends InputT>> futures;
private final boolean allMustSucceed;
private final boolean collectsValues;
@@ -91,7 +87,6 @@
}
@Override
- @CheckForNull
protected final String pendingToString() {
ImmutableCollection<? extends Future<?>> localFutures = futures;
if (localFutures != null) {
@@ -108,13 +103,6 @@
* we're guaranteed to have properly initialized the subclass.
*/
final void init() {
- /*
- * requireNonNull is safe because this is called from the constructor after `futures` is set but
- * before releaseResources could be called (because we have not yet set up any of the listeners
- * that could call it, nor exposed this Future for users to call cancel() on).
- */
- requireNonNull(futures);
-
// Corner case: List is empty.
if (futures.isEmpty()) {
handleAllCompleted();
@@ -246,14 +234,8 @@
final void addInitialException(Set<Throwable> seen) {
checkNotNull(seen);
if (!isCancelled()) {
- /*
- * requireNonNull is safe because this is a TrustedFuture, and we're calling this method only
- * if it has failed.
- *
- * TODO(cpovirk): Think about whether we could/should use Verify to check the return value of
- * addCausalChain.
- */
- boolean unused = addCausalChain(seen, requireNonNull(tryInternalFastPathGetFailure()));
+ // TODO(cpovirk): Think about whether we could/should use Verify to check this.
+ boolean unused = addCausalChain(seen, tryInternalFastPathGetFailure());
}
}
@@ -273,7 +255,7 @@
}
private void decrementCountAndMaybeComplete(
- @CheckForNull
+ @NullableDecl
ImmutableCollection<? extends Future<? extends InputT>>
futuresIfNeedToCollectAtCompletion) {
int newRemaining = decrementRemainingAndGet();
@@ -284,7 +266,7 @@
}
private void processCompleted(
- @CheckForNull
+ @NullableDecl
ImmutableCollection<? extends Future<? extends InputT>>
futuresIfNeedToCollectAtCompletion) {
if (futuresIfNeedToCollectAtCompletion != null) {
@@ -340,15 +322,12 @@
* If {@code allMustSucceed} is true, called as each future completes; otherwise, if {@code
* collectsValues} is true, called for each future when all futures complete.
*/
- abstract void collectOneValue(int index, @ParametricNullness InputT returnValue);
+ abstract void collectOneValue(int index, @NullableDecl InputT returnValue);
abstract void handleAllCompleted();
/** Adds the chain to the seen set, and returns whether all the chain was new to us. */
- private static boolean addCausalChain(Set<Throwable> seen, Throwable param) {
- // Declare a "true" local variable so that the Checker Framework will infer nullness.
- Throwable t = param;
-
+ private static boolean addCausalChain(Set<Throwable> seen, Throwable t) {
for (; t != null; t = t.getCause()) {
boolean firstTimeSeen = seen.add(t);
if (!firstTimeSeen) {
diff --git a/android/guava/src/com/google/common/util/concurrent/AggregateFutureState.java b/android/guava/src/com/google/common/util/concurrent/AggregateFutureState.java
index ee23ca0..f8398d8 100644
--- a/android/guava/src/com/google/common/util/concurrent/AggregateFutureState.java
+++ b/android/guava/src/com/google/common/util/concurrent/AggregateFutureState.java
@@ -15,7 +15,6 @@
package com.google.common.util.concurrent;
import static com.google.common.collect.Sets.newConcurrentHashSet;
-import static java.util.Objects.requireNonNull;
import static java.util.concurrent.atomic.AtomicIntegerFieldUpdater.newUpdater;
import static java.util.concurrent.atomic.AtomicReferenceFieldUpdater.newUpdater;
@@ -26,8 +25,6 @@
import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;
import java.util.logging.Level;
import java.util.logging.Logger;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* A helper which does some thread-safe operations for aggregate futures, which must be implemented
@@ -40,12 +37,10 @@
*/
@GwtCompatible(emulated = true)
@ReflectionSupport(value = ReflectionSupport.Level.FULL)
-@ElementTypesAreNonnullByDefault
-abstract class AggregateFutureState<OutputT extends @Nullable Object>
- extends AbstractFuture.TrustedFuture<OutputT> {
+abstract class AggregateFutureState<OutputT> extends AbstractFuture.TrustedFuture<OutputT> {
// Lazily initialized the first time we see an exception; not released until all the input futures
// have completed and we have processed them all.
- @CheckForNull private volatile Set<Throwable> seenExceptions = null;
+ private volatile Set<Throwable> seenExceptions = null;
private volatile int remaining;
@@ -59,7 +54,7 @@
try {
helper =
new SafeAtomicHelper(
- newUpdater(AggregateFutureState.class, Set.class, "seenExceptions"),
+ newUpdater(AggregateFutureState.class, (Class) Set.class, "seenExceptions"),
newUpdater(AggregateFutureState.class, "remaining"));
} catch (Throwable reflectionFailure) {
// Some Android 5.0.x Samsung devices have bugs in JDK reflection APIs that cause
@@ -129,11 +124,8 @@
* other callers have added to it.
*
* This read is guaranteed to get us the right value because we only set this once (here).
- *
- * requireNonNull is safe because either our compareAndSet succeeded or it failed because
- * another thread did it for us.
*/
- seenExceptionsLocal = requireNonNull(seenExceptions);
+ seenExceptionsLocal = seenExceptions;
}
return seenExceptionsLocal;
}
@@ -152,37 +144,32 @@
private abstract static class AtomicHelper {
/** Atomic compare-and-set of the {@link AggregateFutureState#seenExceptions} field. */
abstract void compareAndSetSeenExceptions(
- AggregateFutureState<?> state, @CheckForNull Set<Throwable> expect, Set<Throwable> update);
+ AggregateFutureState state, Set<Throwable> expect, Set<Throwable> update);
/** Atomic decrement-and-get of the {@link AggregateFutureState#remaining} field. */
- abstract int decrementAndGetRemainingCount(AggregateFutureState<?> state);
+ abstract int decrementAndGetRemainingCount(AggregateFutureState state);
}
private static final class SafeAtomicHelper extends AtomicHelper {
- final AtomicReferenceFieldUpdater<AggregateFutureState<?>, Set<Throwable>>
- seenExceptionsUpdater;
+ final AtomicReferenceFieldUpdater<AggregateFutureState, Set<Throwable>> seenExceptionsUpdater;
- final AtomicIntegerFieldUpdater<AggregateFutureState<?>> remainingCountUpdater;
+ final AtomicIntegerFieldUpdater<AggregateFutureState> remainingCountUpdater;
- @SuppressWarnings({"rawtypes", "unchecked"}) // Unavoidable with reflection API
SafeAtomicHelper(
AtomicReferenceFieldUpdater seenExceptionsUpdater,
AtomicIntegerFieldUpdater remainingCountUpdater) {
- this.seenExceptionsUpdater =
- (AtomicReferenceFieldUpdater<AggregateFutureState<?>, Set<Throwable>>)
- seenExceptionsUpdater;
- this.remainingCountUpdater =
- (AtomicIntegerFieldUpdater<AggregateFutureState<?>>) remainingCountUpdater;
+ this.seenExceptionsUpdater = seenExceptionsUpdater;
+ this.remainingCountUpdater = remainingCountUpdater;
}
@Override
void compareAndSetSeenExceptions(
- AggregateFutureState<?> state, @CheckForNull Set<Throwable> expect, Set<Throwable> update) {
+ AggregateFutureState state, Set<Throwable> expect, Set<Throwable> update) {
seenExceptionsUpdater.compareAndSet(state, expect, update);
}
@Override
- int decrementAndGetRemainingCount(AggregateFutureState<?> state) {
+ int decrementAndGetRemainingCount(AggregateFutureState state) {
return remainingCountUpdater.decrementAndGet(state);
}
}
@@ -190,7 +177,7 @@
private static final class SynchronizedAtomicHelper extends AtomicHelper {
@Override
void compareAndSetSeenExceptions(
- AggregateFutureState<?> state, @CheckForNull Set<Throwable> expect, Set<Throwable> update) {
+ AggregateFutureState state, Set<Throwable> expect, Set<Throwable> update) {
synchronized (state) {
if (state.seenExceptions == expect) {
state.seenExceptions = update;
@@ -199,7 +186,7 @@
}
@Override
- int decrementAndGetRemainingCount(AggregateFutureState<?> state) {
+ int decrementAndGetRemainingCount(AggregateFutureState state) {
synchronized (state) {
return --state.remaining;
}
diff --git a/android/guava/src/com/google/common/util/concurrent/AsyncCallable.java b/android/guava/src/com/google/common/util/concurrent/AsyncCallable.java
index 7ee831e..99807de 100644
--- a/android/guava/src/com/google/common/util/concurrent/AsyncCallable.java
+++ b/android/guava/src/com/google/common/util/concurrent/AsyncCallable.java
@@ -17,7 +17,6 @@
import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtCompatible;
import java.util.concurrent.Future;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Computes a value, possibly asynchronously. For an example usage and more information, see {@link
@@ -30,8 +29,7 @@
*/
@Beta
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-public interface AsyncCallable<V extends @Nullable Object> {
+public interface AsyncCallable<V> {
/**
* Computes a result {@code Future}. The output {@code Future} need not be {@linkplain
* Future#isDone done}, making {@code AsyncCallable} suitable for asynchronous derivations.
diff --git a/android/guava/src/com/google/common/util/concurrent/AsyncFunction.java b/android/guava/src/com/google/common/util/concurrent/AsyncFunction.java
index cd70d20..67c3cc2 100644
--- a/android/guava/src/com/google/common/util/concurrent/AsyncFunction.java
+++ b/android/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.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* Transforms a value, possibly asynchronously. For an example usage and more information, see
@@ -26,8 +26,7 @@
* @since 11.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-public interface AsyncFunction<I extends @Nullable Object, O extends @Nullable Object> {
+public interface AsyncFunction<I, O> {
/**
* Returns an output {@code Future} to use in place of the given {@code input}. The output {@code
* Future} need not be {@linkplain Future#isDone done}, making {@code AsyncFunction} suitable for
@@ -35,5 +34,5 @@
*
* <p>Throwing an exception from this method is equivalent to returning a failing {@code Future}.
*/
- ListenableFuture<O> apply(@ParametricNullness I input) throws Exception;
+ ListenableFuture<O> apply(@NullableDecl I input) throws Exception;
}
diff --git a/android/guava/src/com/google/common/util/concurrent/AtomicDouble.java b/android/guava/src/com/google/common/util/concurrent/AtomicDouble.java
index 161fca8..563381b 100644
--- a/android/guava/src/com/google/common/util/concurrent/AtomicDouble.java
+++ b/android/guava/src/com/google/common/util/concurrent/AtomicDouble.java
@@ -49,7 +49,6 @@
* @author Martin Buchholz
* @since 11.0
*/
-@ElementTypesAreNonnullByDefault
public class AtomicDouble extends Number implements java.io.Serializable {
private static final long serialVersionUID = 0L;
diff --git a/android/guava/src/com/google/common/util/concurrent/AtomicDoubleArray.java b/android/guava/src/com/google/common/util/concurrent/AtomicDoubleArray.java
index 58407f5..5c4baa1 100644
--- a/android/guava/src/com/google/common/util/concurrent/AtomicDoubleArray.java
+++ b/android/guava/src/com/google/common/util/concurrent/AtomicDoubleArray.java
@@ -44,7 +44,6 @@
* @since 11.0
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public class AtomicDoubleArray implements java.io.Serializable {
private static final long serialVersionUID = 0L;
@@ -97,7 +96,7 @@
}
/**
- * Atomically sets the element at position {@code i} to the given value.
+ * Sets the element at position {@code i} to the given value.
*
* @param i the index
* @param newValue the new value
diff --git a/android/guava/src/com/google/common/util/concurrent/AtomicLongMap.java b/android/guava/src/com/google/common/util/concurrent/AtomicLongMap.java
index bac02c1..7fc58f4 100644
--- a/android/guava/src/com/google/common/util/concurrent/AtomicLongMap.java
+++ b/android/guava/src/com/google/common/util/concurrent/AtomicLongMap.java
@@ -28,7 +28,7 @@
import java.util.Map.Entry;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicLong;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* A map containing {@code long} values that can be atomically updated. While writes to a
@@ -54,7 +54,6 @@
* @since 11.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
public final class AtomicLongMap<K> implements Serializable {
private final ConcurrentHashMap<K, AtomicLong> map;
@@ -326,7 +325,7 @@
return sum;
}
- @CheckForNull private transient Map<K, Long> asMap;
+ @NullableDecl private transient Map<K, Long> asMap;
/** Returns a live, read-only view of the map backing this {@code AtomicLongMap}. */
public Map<K, Long> asMap() {
diff --git a/android/guava/src/com/google/common/util/concurrent/Atomics.java b/android/guava/src/com/google/common/util/concurrent/Atomics.java
index c1b6964..f6aafb7 100644
--- a/android/guava/src/com/google/common/util/concurrent/Atomics.java
+++ b/android/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.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* Static utility methods pertaining to classes in the {@code java.util.concurrent.atomic} package.
@@ -26,7 +26,6 @@
* @since 10.0
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public final class Atomics {
private Atomics() {}
@@ -35,8 +34,8 @@
*
* @return a new {@code AtomicReference} with no initial value
*/
- public static <V> AtomicReference<@Nullable V> newReference() {
- return new AtomicReference<>();
+ public static <V> AtomicReference<V> newReference() {
+ return new AtomicReference<V>();
}
/**
@@ -45,9 +44,8 @@
* @param initialValue the initial value
* @return a new {@code AtomicReference} with the given initial value
*/
- public static <V extends @Nullable Object> AtomicReference<V> newReference(
- @ParametricNullness V initialValue) {
- return new AtomicReference<>(initialValue);
+ public static <V> AtomicReference<V> newReference(@NullableDecl V initialValue) {
+ return new AtomicReference<V>(initialValue);
}
/**
@@ -56,8 +54,8 @@
* @param length the length of the array
* @return a new {@code AtomicReferenceArray} with the given length
*/
- public static <E> AtomicReferenceArray<@Nullable E> newReferenceArray(int length) {
- return new AtomicReferenceArray<>(length);
+ public static <E> AtomicReferenceArray<E> newReferenceArray(int length) {
+ return new AtomicReferenceArray<E>(length);
}
/**
@@ -67,7 +65,7 @@
* @param array the array to copy elements from
* @return a new {@code AtomicReferenceArray} copied from the given array
*/
- public static <E extends @Nullable Object> AtomicReferenceArray<E> newReferenceArray(E[] array) {
- return new AtomicReferenceArray<>(array);
+ public static <E> AtomicReferenceArray<E> newReferenceArray(E[] array) {
+ return new AtomicReferenceArray<E>(array);
}
}
diff --git a/android/guava/src/com/google/common/util/concurrent/Callables.java b/android/guava/src/com/google/common/util/concurrent/Callables.java
index 47b5264..c4caf36 100644
--- a/android/guava/src/com/google/common/util/concurrent/Callables.java
+++ b/android/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.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* Static utility methods pertaining to the {@link Callable} interface.
@@ -30,16 +30,13 @@
* @since 1.0
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
public final class Callables {
private Callables() {}
/** Creates a {@code Callable} which immediately returns a preset value each time it is called. */
- public static <T extends @Nullable Object> Callable<T> returning(
- @ParametricNullness final T value) {
+ public static <T> Callable<T> returning(@NullableDecl final T value) {
return new Callable<T>() {
@Override
- @ParametricNullness
public T call() {
return value;
}
@@ -56,7 +53,7 @@
*/
@Beta
@GwtIncompatible
- public static <T extends @Nullable Object> AsyncCallable<T> asAsyncCallable(
+ public static <T> AsyncCallable<T> asAsyncCallable(
final Callable<T> callable, final ListeningExecutorService listeningExecutorService) {
checkNotNull(callable);
checkNotNull(listeningExecutorService);
@@ -72,18 +69,18 @@
* Wraps the given callable such that for the duration of {@link Callable#call} the thread that is
* running will have the given name.
*
+ *
* @param callable The callable to wrap
* @param nameSupplier The supplier of thread names, {@link Supplier#get get} will be called once
* for each invocation of the wrapped callable.
*/
@GwtIncompatible // threads
- static <T extends @Nullable Object> Callable<T> threadRenaming(
+ static <T> Callable<T> threadRenaming(
final Callable<T> callable, final Supplier<String> nameSupplier) {
checkNotNull(nameSupplier);
checkNotNull(callable);
return new Callable<T>() {
@Override
- @ParametricNullness
public T call() throws Exception {
Thread currentThread = Thread.currentThread();
String oldName = currentThread.getName();
@@ -103,6 +100,7 @@
* Wraps the given runnable such that for the duration of {@link Runnable#run} the thread that is
* running with have the given name.
*
+ *
* @param task The Runnable to wrap
* @param nameSupplier The supplier of thread names, {@link Supplier#get get} will be called once
* for each invocation of the wrapped callable.
diff --git a/android/guava/src/com/google/common/util/concurrent/ClosingFuture.java b/android/guava/src/com/google/common/util/concurrent/ClosingFuture.java
index c5ce0c4..2e5b5c5 100644
--- a/android/guava/src/com/google/common/util/concurrent/ClosingFuture.java
+++ b/android/guava/src/com/google/common/util/concurrent/ClosingFuture.java
@@ -60,8 +60,7 @@
import java.util.concurrent.RejectedExecutionException;
import java.util.concurrent.atomic.AtomicReference;
import java.util.logging.Logger;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* A step in a pipeline of an asynchronous computation. When the last step in the computation is
@@ -138,9 +137,8 @@
* <h4>Automatically closing</h4>
*
* You can extract a {@link Future} that represents the result of the last step in the pipeline by
- * calling {@link #finishToFuture()}. All objects the pipeline has captured for closing will begin
- * to be closed asynchronously <b>after</b> the returned {@code Future} is done: the future
- * completes before closing starts, rather than once it has finished.
+ * calling {@link #finishToFuture()}. When that final {@link Future} is done, all objects captured
+ * by all steps in the pipeline will be closed.
*
* <pre>{@code
* FluentFuture<UserName> userName =
@@ -193,9 +191,8 @@
// TODO(dpb): Consider reusing one CloseableList for the entire pipeline, modulo combinations.
@Beta // @Beta for one release.
@DoNotMock("Use ClosingFuture.from(Futures.immediate*Future)")
-@ElementTypesAreNonnullByDefault
// TODO(dpb): GWT compatibility.
-public final class ClosingFuture<V extends @Nullable Object> {
+public final class ClosingFuture<V> {
private static final Logger logger = Logger.getLogger(ClosingFuture.class.getName());
@@ -234,10 +231,10 @@
* @return the first argument
*/
@CanIgnoreReturnValue
- @ParametricNullness
+ @NullableDecl
// TODO(b/163345357): Widen bound to AutoCloseable once we require API Level 19.
- public <C extends @Nullable Object & @Nullable Closeable> C eventuallyClose(
- @ParametricNullness C closeable, Executor closingExecutor) {
+ public <C extends Object & Closeable> C eventuallyClose(
+ @NullableDecl C closeable, Executor closingExecutor) {
checkNotNull(closingExecutor);
if (closeable != null) {
list.add(closeable, closingExecutor);
@@ -251,7 +248,7 @@
*
* @param <V> the type of the result
*/
- public interface ClosingCallable<V extends @Nullable Object> {
+ public interface ClosingCallable<V extends Object> {
/**
* Computes a result, or throws an exception if unable to do so.
*
@@ -259,34 +256,17 @@
* closer.eventuallyClose()} will be closed when the {@link ClosingFuture} pipeline is done (but
* not before this method completes), even if this method throws or the pipeline is cancelled.
*/
- @ParametricNullness
+ @NullableDecl
V call(DeferredCloser closer) throws Exception;
}
/**
- * An operation that computes a {@link ClosingFuture} of a result.
- *
- * @param <V> the type of the result
- * @since 30.1
- */
- public interface AsyncClosingCallable<V extends @Nullable Object> {
- /**
- * Computes a result, or throws an exception if unable to do so.
- *
- * <p>Any objects that are passed to {@link DeferredCloser#eventuallyClose(Closeable, Executor)
- * closer.eventuallyClose()} will be closed when the {@link ClosingFuture} pipeline is done (but
- * not before this method completes), even if this method throws or the pipeline is cancelled.
- */
- ClosingFuture<V> call(DeferredCloser closer) throws Exception;
- }
-
- /**
* A function from an input to a result.
*
* @param <T> the type of the input to the function
* @param <U> the type of the result of the function
*/
- public interface ClosingFunction<T extends @Nullable Object, U extends @Nullable Object> {
+ public interface ClosingFunction<T extends Object, U extends Object> {
/**
* Applies this function to an input, or throws an exception if unable to do so.
@@ -295,8 +275,8 @@
* closer.eventuallyClose()} will be closed when the {@link ClosingFuture} pipeline is done (but
* not before this method completes), even if this method throws or the pipeline is cancelled.
*/
- @ParametricNullness
- U apply(DeferredCloser closer, @ParametricNullness T input) throws Exception;
+ @NullableDecl
+ U apply(DeferredCloser closer, @NullableDecl T input) throws Exception;
}
/**
@@ -305,7 +285,7 @@
* @param <T> the type of the input to the function
* @param <U> the type of the result of the function
*/
- public interface AsyncClosingFunction<T extends @Nullable Object, U extends @Nullable Object> {
+ public interface AsyncClosingFunction<T extends Object, U extends Object> {
/**
* Applies this function to an input, or throws an exception if unable to do so.
*
@@ -313,7 +293,7 @@
* closer.eventuallyClose()} will be closed when the {@link ClosingFuture} pipeline is done (but
* not before this method completes), even if this method throws or the pipeline is cancelled.
*/
- ClosingFuture<U> apply(DeferredCloser closer, @ParametricNullness T input) throws Exception;
+ ClosingFuture<U> apply(DeferredCloser closer, @NullableDecl T input) throws Exception;
}
/**
@@ -326,7 +306,7 @@
* @param <V> the type of the value of a successful operation
* @see ClosingFuture#finishToValueAndCloser(ValueAndCloserConsumer, Executor)
*/
- public static final class ValueAndCloser<V extends @Nullable Object> {
+ public static final class ValueAndCloser<V> {
private final ClosingFuture<? extends V> closingFuture;
@@ -344,7 +324,7 @@
* @throws CancellationException if the computation was cancelled
* @throws ExecutionException if the computation threw an exception
*/
- @ParametricNullness
+ @NullableDecl
public V get() throws ExecutionException {
return getDone(closingFuture.future);
}
@@ -371,7 +351,7 @@
* @param <V> the type of the final value of a successful pipeline
* @see ClosingFuture#finishToValueAndCloser(ValueAndCloserConsumer, Executor)
*/
- public interface ValueAndCloserConsumer<V extends @Nullable Object> {
+ public interface ValueAndCloserConsumer<V> {
/** Accepts a {@link ValueAndCloser} for the last step in a {@link ClosingFuture} pipeline. */
void accept(ValueAndCloser<V> valueAndCloser);
@@ -383,22 +363,11 @@
* @throws java.util.concurrent.RejectedExecutionException if the task cannot be scheduled for
* execution
*/
- public static <V extends @Nullable Object> ClosingFuture<V> submit(
- ClosingCallable<V> callable, Executor executor) {
+ public static <V> ClosingFuture<V> submit(ClosingCallable<V> callable, Executor executor) {
return new ClosingFuture<>(callable, executor);
}
- /**
- * Starts a {@link ClosingFuture} pipeline by submitting a callable block to an executor.
- *
- * @throws java.util.concurrent.RejectedExecutionException if the task cannot be scheduled for
- * execution
- * @since 30.1
- */
- public static <V extends @Nullable Object> ClosingFuture<V> submitAsync(
- AsyncClosingCallable<V> callable, Executor executor) {
- return new ClosingFuture<>(callable, executor);
- }
+ // TODO(dpb, cpovirk): Do we need submitAsync?
/**
* Starts a {@link ClosingFuture} pipeline with a {@link ListenableFuture}.
@@ -407,7 +376,7 @@
* implements {@link Closeable}. In order to start a pipeline with a value that will be closed
* when the pipeline is done, use {@link #submit(ClosingCallable, Executor)} instead.
*/
- public static <V extends @Nullable Object> ClosingFuture<V> from(ListenableFuture<V> future) {
+ public static <V> ClosingFuture<V> from(ListenableFuture<V> future) {
return new ClosingFuture<V>(future);
}
@@ -434,16 +403,15 @@
*/
@Deprecated
// TODO(b/163345357): Widen bound to AutoCloseable once we require API Level 19.
- public static <C extends @Nullable Object & @Nullable Closeable>
- ClosingFuture<C> eventuallyClosing(
- ListenableFuture<C> future, final Executor closingExecutor) {
+ public static <C extends Object & Closeable> ClosingFuture<C> eventuallyClosing(
+ ListenableFuture<C> future, final Executor closingExecutor) {
checkNotNull(closingExecutor);
final ClosingFuture<C> closingFuture = new ClosingFuture<>(nonCancellationPropagating(future));
Futures.addCallback(
future,
- new FutureCallback<@Nullable Closeable>() {
+ new FutureCallback<Closeable>() {
@Override
- public void onSuccess(@CheckForNull Closeable result) {
+ public void onSuccess(@NullableDecl Closeable result) {
closingFuture.closeables.closer.eventuallyClose(result, closingExecutor);
}
@@ -496,8 +464,8 @@
* @throws IllegalStateException if a {@code ClosingFuture} has already been derived from any of
* the arguments, or if any has already been {@linkplain #finishToFuture() finished}
*/
- public static <V1 extends @Nullable Object, V2 extends @Nullable Object>
- Combiner2<V1, V2> whenAllSucceed(ClosingFuture<V1> future1, ClosingFuture<V2> future2) {
+ public static <V1, V2> Combiner2<V1, V2> whenAllSucceed(
+ ClosingFuture<V1> future1, ClosingFuture<V2> future2) {
return new Combiner2<>(future1, future2);
}
@@ -511,10 +479,8 @@
* @throws IllegalStateException if a {@code ClosingFuture} has already been derived from any of
* the arguments, or if any has already been {@linkplain #finishToFuture() finished}
*/
- public static <
- V1 extends @Nullable Object, V2 extends @Nullable Object, V3 extends @Nullable Object>
- Combiner3<V1, V2, V3> whenAllSucceed(
- ClosingFuture<V1> future1, ClosingFuture<V2> future2, ClosingFuture<V3> future3) {
+ public static <V1, V2, V3> Combiner3<V1, V2, V3> whenAllSucceed(
+ ClosingFuture<V1> future1, ClosingFuture<V2> future2, ClosingFuture<V3> future3) {
return new Combiner3<>(future1, future2, future3);
}
@@ -528,16 +494,11 @@
* @throws IllegalStateException if a {@code ClosingFuture} has already been derived from any of
* the arguments, or if any has already been {@linkplain #finishToFuture() finished}
*/
- public static <
- V1 extends @Nullable Object,
- V2 extends @Nullable Object,
- V3 extends @Nullable Object,
- V4 extends @Nullable Object>
- Combiner4<V1, V2, V3, V4> whenAllSucceed(
- ClosingFuture<V1> future1,
- ClosingFuture<V2> future2,
- ClosingFuture<V3> future3,
- ClosingFuture<V4> future4) {
+ public static <V1, V2, V3, V4> Combiner4<V1, V2, V3, V4> whenAllSucceed(
+ ClosingFuture<V1> future1,
+ ClosingFuture<V2> future2,
+ ClosingFuture<V3> future3,
+ ClosingFuture<V4> future4) {
return new Combiner4<>(future1, future2, future3, future4);
}
@@ -551,18 +512,12 @@
* @throws IllegalStateException if a {@code ClosingFuture} has already been derived from any of
* the arguments, or if any has already been {@linkplain #finishToFuture() finished}
*/
- public static <
- V1 extends @Nullable Object,
- V2 extends @Nullable Object,
- V3 extends @Nullable Object,
- V4 extends @Nullable Object,
- V5 extends @Nullable Object>
- Combiner5<V1, V2, V3, V4, V5> whenAllSucceed(
- ClosingFuture<V1> future1,
- ClosingFuture<V2> future2,
- ClosingFuture<V3> future3,
- ClosingFuture<V4> future4,
- ClosingFuture<V5> future5) {
+ public static <V1, V2, V3, V4, V5> Combiner5<V1, V2, V3, V4, V5> whenAllSucceed(
+ ClosingFuture<V1> future1,
+ ClosingFuture<V2> future2,
+ ClosingFuture<V3> future3,
+ ClosingFuture<V4> future4,
+ ClosingFuture<V5> future5) {
return new Combiner5<>(future1, future2, future3, future4, future5);
}
@@ -600,7 +555,6 @@
TrustedListenableFutureTask.create(
new Callable<V>() {
@Override
- @ParametricNullness
public V call() throws Exception {
return callable.call(closeables.closer);
}
@@ -614,32 +568,6 @@
this.future = task;
}
- private ClosingFuture(final AsyncClosingCallable<V> callable, Executor executor) {
- checkNotNull(callable);
- TrustedListenableFutureTask<V> task =
- TrustedListenableFutureTask.create(
- new AsyncCallable<V>() {
- @Override
- public ListenableFuture<V> call() throws Exception {
- CloseableList newCloseables = new CloseableList();
- try {
- ClosingFuture<V> closingFuture = callable.call(newCloseables.closer);
- closingFuture.becomeSubsumedInto(closeables);
- return closingFuture.future;
- } finally {
- closeables.add(newCloseables, directExecutor());
- }
- }
-
- @Override
- public String toString() {
- return callable.toString();
- }
- });
- executor.execute(task);
- this.future = task;
- }
-
/**
* Returns a future that finishes when this step does. Calling {@code get()} on the returned
* future returns {@code null} if the step is successful or throws the same exception that would
@@ -688,7 +616,7 @@
* one, or if this {@code ClosingFuture} has already been {@linkplain #finishToFuture()
* finished}
*/
- public <U extends @Nullable Object> ClosingFuture<U> transform(
+ public <U> ClosingFuture<U> transform(
final ClosingFunction<? super V, U> function, Executor executor) {
checkNotNull(function);
AsyncFunction<V, U> applyFunction =
@@ -782,7 +710,7 @@
* one, or if this {@code ClosingFuture} has already been {@linkplain #finishToFuture()
* finished}
*/
- public <U extends @Nullable Object> ClosingFuture<U> transformAsync(
+ public <U> ClosingFuture<U> transformAsync(
final AsyncClosingFunction<? super V, U> function, Executor executor) {
checkNotNull(function);
AsyncFunction<V, U> applyFunction =
@@ -826,8 +754,8 @@
* @param function transforms the value of a {@code ClosingFuture} step to a {@link
* ListenableFuture} with the value of a derived step
*/
- public static <V extends @Nullable Object, U extends @Nullable Object>
- AsyncClosingFunction<V, U> withoutCloser(final AsyncFunction<V, U> function) {
+ public static <V, U> AsyncClosingFunction<V, U> withoutCloser(
+ final AsyncFunction<V, U> function) {
checkNotNull(function);
return new AsyncClosingFunction<V, U>() {
@Override
@@ -1002,14 +930,9 @@
}
/**
- * Marks this step as the last step in the {@code ClosingFuture} pipeline.
- *
- * <p>The returned {@link Future} is completed when the pipeline's computation completes, or when
- * the pipeline is cancelled.
- *
- * <p>All objects the pipeline has captured for closing will begin to be closed asynchronously
- * <b>after</b> the returned {@code Future} is done: the future completes before closing starts,
- * rather than once it has finished.
+ * Marks this step as the last step in the {@code ClosingFuture} pipeline. When the returned
+ * {@link Future} is done, all objects captured for closing during the pipeline's computation will
+ * be closed.
*
* <p>After calling this method, you may not call {@link
* #finishToValueAndCloser(ValueAndCloserConsumer, Executor)}, this method, or any other
@@ -1096,7 +1019,7 @@
executor);
}
- private static <C extends @Nullable Object, V extends C> void provideValueAndCloser(
+ private static <C, V extends C> void provideValueAndCloser(
ValueAndCloserConsumer<C> consumer, ClosingFuture<V> closingFuture) {
consumer.accept(new ValueAndCloser<C>(closingFuture));
}
@@ -1132,7 +1055,7 @@
closeables.close();
}
- private <U extends @Nullable Object> ClosingFuture<U> derive(FluentFuture<U> future) {
+ private <U> ClosingFuture<U> derive(FluentFuture<U> future) {
ClosingFuture<U> derived = new ClosingFuture<>(future);
becomeSubsumedInto(derived.closeables);
return derived;
@@ -1168,17 +1091,17 @@
* CombiningCallable#call(DeferredCloser, Peeker)} or {@link
* AsyncCombiningCallable#call(DeferredCloser, Peeker)}
*/
- @ParametricNullness
- public final <D extends @Nullable Object> D getDone(ClosingFuture<D> closingFuture)
+ @NullableDecl
+ public final <D extends Object> D getDone(ClosingFuture<D> closingFuture)
throws ExecutionException {
checkState(beingCalled);
checkArgument(futures.contains(closingFuture));
return Futures.getDone(closingFuture.future);
}
- @ParametricNullness
- private <V extends @Nullable Object> V call(
- CombiningCallable<V> combiner, CloseableList closeables) throws Exception {
+ @NullableDecl
+ private <V extends Object> V call(CombiningCallable<V> combiner, CloseableList closeables)
+ throws Exception {
beingCalled = true;
CloseableList newCloseables = new CloseableList();
try {
@@ -1189,7 +1112,7 @@
}
}
- private <V extends @Nullable Object> FluentFuture<V> callAsync(
+ private <V extends Object> FluentFuture<V> callAsync(
AsyncCombiningCallable<V> combiner, CloseableList closeables) throws Exception {
beingCalled = true;
CloseableList newCloseables = new CloseableList();
@@ -1239,7 +1162,7 @@
*
* @param <V> the type of the result
*/
- public interface CombiningCallable<V extends @Nullable Object> {
+ public interface CombiningCallable<V extends Object> {
/**
* Computes a result, or throws an exception if unable to do so.
*
@@ -1250,7 +1173,7 @@
*
* @param peeker used to get the value of any of the input futures
*/
- @ParametricNullness
+ @NullableDecl
V call(DeferredCloser closer, Peeker peeker) throws Exception;
}
@@ -1259,7 +1182,7 @@
*
* @param <V> the type of the result
*/
- public interface AsyncCombiningCallable<V extends @Nullable Object> {
+ public interface AsyncCombiningCallable<V extends Object> {
/**
* Computes a {@link ClosingFuture} result, or throws an exception if unable to do so.
*
@@ -1298,12 +1221,11 @@
* <p>If the combiningCallable throws an {@code ExecutionException}, the cause of the thrown
* {@code ExecutionException} will be extracted and used as the failure of the derived step.
*/
- public <V extends @Nullable Object> ClosingFuture<V> call(
+ public <V> ClosingFuture<V> call(
final CombiningCallable<V> combiningCallable, Executor executor) {
Callable<V> callable =
new Callable<V>() {
@Override
- @ParametricNullness
public V call() throws Exception {
return new Peeker(inputs).call(combiningCallable, closeables);
}
@@ -1355,7 +1277,7 @@
* <p>The same warnings about doing heavyweight operations within {@link
* ClosingFuture#transformAsync(AsyncClosingFunction, Executor)} apply here.
*/
- public <V extends @Nullable Object> ClosingFuture<V> callAsync(
+ public <V> ClosingFuture<V> callAsync(
final AsyncCombiningCallable<V> combiningCallable, Executor executor) {
AsyncCallable<V> asyncCallable =
new AsyncCallable<V>() {
@@ -1375,7 +1297,7 @@
return derived;
}
- private FutureCombiner<@Nullable Object> futureCombiner() {
+ private FutureCombiner<Object> futureCombiner() {
return allMustSucceed
? Futures.whenAllSucceed(inputFutures())
: Futures.whenAllComplete(inputFutures());
@@ -1402,8 +1324,7 @@
* @param <V1> the type returned by the first future
* @param <V2> the type returned by the second future
*/
- public static final class Combiner2<V1 extends @Nullable Object, V2 extends @Nullable Object>
- extends Combiner {
+ public static final class Combiner2<V1 extends Object, V2 extends Object> extends Combiner {
/**
* A function that returns a value when applied to the values of the two futures passed to
@@ -1413,8 +1334,7 @@
* @param <V2> the type returned by the second future
* @param <U> the type returned by the function
*/
- public interface ClosingFunction2<
- V1 extends @Nullable Object, V2 extends @Nullable Object, U extends @Nullable Object> {
+ public interface ClosingFunction2<V1 extends Object, V2 extends Object, U extends Object> {
/**
* Applies this function to two inputs, or throws an exception if unable to do so.
@@ -1424,8 +1344,8 @@
* is done (but not before this method completes), even if this method throws or the pipeline
* is cancelled.
*/
- @ParametricNullness
- U apply(DeferredCloser closer, @ParametricNullness V1 value1, @ParametricNullness V2 value2)
+ @NullableDecl
+ U apply(DeferredCloser closer, @NullableDecl V1 value1, @NullableDecl V2 value2)
throws Exception;
}
@@ -1437,8 +1357,7 @@
* @param <V2> the type returned by the second future
* @param <U> the type returned by the function
*/
- public interface AsyncClosingFunction2<
- V1 extends @Nullable Object, V2 extends @Nullable Object, U extends @Nullable Object> {
+ public interface AsyncClosingFunction2<V1 extends Object, V2 extends Object, U extends Object> {
/**
* Applies this function to two inputs, or throws an exception if unable to do so.
@@ -1449,8 +1368,7 @@
* is cancelled.
*/
ClosingFuture<U> apply(
- DeferredCloser closer, @ParametricNullness V1 value1, @ParametricNullness V2 value2)
- throws Exception;
+ DeferredCloser closer, @NullableDecl V1 value1, @NullableDecl V2 value2) throws Exception;
}
private final ClosingFuture<V1> future1;
@@ -1475,12 +1393,12 @@
* <p>If the function throws an {@code ExecutionException}, the cause of the thrown {@code
* ExecutionException} will be extracted and used as the failure of the derived step.
*/
- public <U extends @Nullable Object> ClosingFuture<U> call(
+ public <U extends Object> ClosingFuture<U> call(
final ClosingFunction2<V1, V2, U> function, Executor executor) {
return call(
new CombiningCallable<U>() {
@Override
- @ParametricNullness
+ @NullableDecl
public U call(DeferredCloser closer, Peeker peeker) throws Exception {
return function.apply(closer, peeker.getDone(future1), peeker.getDone(future2));
}
@@ -1529,7 +1447,7 @@
* <p>The same warnings about doing heavyweight operations within {@link
* ClosingFuture#transformAsync(AsyncClosingFunction, Executor)} apply here.
*/
- public <U extends @Nullable Object> ClosingFuture<U> callAsync(
+ public <U extends Object> ClosingFuture<U> callAsync(
final AsyncClosingFunction2<V1, V2, U> function, Executor executor) {
return callAsync(
new AsyncCombiningCallable<U>() {
@@ -1556,8 +1474,7 @@
* @param <V2> the type returned by the second future
* @param <V3> the type returned by the third future
*/
- public static final class Combiner3<
- V1 extends @Nullable Object, V2 extends @Nullable Object, V3 extends @Nullable Object>
+ public static final class Combiner3<V1 extends Object, V2 extends Object, V3 extends Object>
extends Combiner {
/**
* A function that returns a value when applied to the values of the three futures passed to
@@ -1569,10 +1486,7 @@
* @param <U> the type returned by the function
*/
public interface ClosingFunction3<
- V1 extends @Nullable Object,
- V2 extends @Nullable Object,
- V3 extends @Nullable Object,
- U extends @Nullable Object> {
+ V1 extends Object, V2 extends Object, V3 extends Object, U extends Object> {
/**
* Applies this function to three inputs, or throws an exception if unable to do so.
*
@@ -1581,12 +1495,12 @@
* is done (but not before this method completes), even if this method throws or the pipeline
* is cancelled.
*/
- @ParametricNullness
+ @NullableDecl
U apply(
DeferredCloser closer,
- @ParametricNullness V1 value1,
- @ParametricNullness V2 value2,
- @ParametricNullness V3 value3)
+ @NullableDecl V1 value1,
+ @NullableDecl V2 value2,
+ @NullableDecl V3 v3)
throws Exception;
}
@@ -1600,10 +1514,7 @@
* @param <U> the type returned by the function
*/
public interface AsyncClosingFunction3<
- V1 extends @Nullable Object,
- V2 extends @Nullable Object,
- V3 extends @Nullable Object,
- U extends @Nullable Object> {
+ V1 extends Object, V2 extends Object, V3 extends Object, U extends Object> {
/**
* Applies this function to three inputs, or throws an exception if unable to do so.
*
@@ -1614,9 +1525,9 @@
*/
ClosingFuture<U> apply(
DeferredCloser closer,
- @ParametricNullness V1 value1,
- @ParametricNullness V2 value2,
- @ParametricNullness V3 value3)
+ @NullableDecl V1 value1,
+ @NullableDecl V2 value2,
+ @NullableDecl V3 value3)
throws Exception;
}
@@ -1645,12 +1556,12 @@
* <p>If the function throws an {@code ExecutionException}, the cause of the thrown {@code
* ExecutionException} will be extracted and used as the failure of the derived step.
*/
- public <U extends @Nullable Object> ClosingFuture<U> call(
+ public <U extends Object> ClosingFuture<U> call(
final ClosingFunction3<V1, V2, V3, U> function, Executor executor) {
return call(
new CombiningCallable<U>() {
@Override
- @ParametricNullness
+ @NullableDecl
public U call(DeferredCloser closer, Peeker peeker) throws Exception {
return function.apply(
closer,
@@ -1703,7 +1614,7 @@
* <p>The same warnings about doing heavyweight operations within {@link
* ClosingFuture#transformAsync(AsyncClosingFunction, Executor)} apply here.
*/
- public <U extends @Nullable Object> ClosingFuture<U> callAsync(
+ public <U extends Object> ClosingFuture<U> callAsync(
final AsyncClosingFunction3<V1, V2, V3, U> function, Executor executor) {
return callAsync(
new AsyncCombiningCallable<U>() {
@@ -1736,10 +1647,7 @@
* @param <V4> the type returned by the fourth future
*/
public static final class Combiner4<
- V1 extends @Nullable Object,
- V2 extends @Nullable Object,
- V3 extends @Nullable Object,
- V4 extends @Nullable Object>
+ V1 extends Object, V2 extends Object, V3 extends Object, V4 extends Object>
extends Combiner {
/**
* A function that returns a value when applied to the values of the four futures passed to
@@ -1752,11 +1660,11 @@
* @param <U> the type returned by the function
*/
public interface ClosingFunction4<
- V1 extends @Nullable Object,
- V2 extends @Nullable Object,
- V3 extends @Nullable Object,
- V4 extends @Nullable Object,
- U extends @Nullable Object> {
+ V1 extends Object,
+ V2 extends Object,
+ V3 extends Object,
+ V4 extends Object,
+ U extends Object> {
/**
* Applies this function to four inputs, or throws an exception if unable to do so.
*
@@ -1765,13 +1673,13 @@
* is done (but not before this method completes), even if this method throws or the pipeline
* is cancelled.
*/
- @ParametricNullness
+ @NullableDecl
U apply(
DeferredCloser closer,
- @ParametricNullness V1 value1,
- @ParametricNullness V2 value2,
- @ParametricNullness V3 value3,
- @ParametricNullness V4 value4)
+ @NullableDecl V1 value1,
+ @NullableDecl V2 value2,
+ @NullableDecl V3 value3,
+ @NullableDecl V4 value4)
throws Exception;
}
@@ -1787,11 +1695,11 @@
* @param <U> the type returned by the function
*/
public interface AsyncClosingFunction4<
- V1 extends @Nullable Object,
- V2 extends @Nullable Object,
- V3 extends @Nullable Object,
- V4 extends @Nullable Object,
- U extends @Nullable Object> {
+ V1 extends Object,
+ V2 extends Object,
+ V3 extends Object,
+ V4 extends Object,
+ U extends Object> {
/**
* Applies this function to four inputs, or throws an exception if unable to do so.
*
@@ -1802,10 +1710,10 @@
*/
ClosingFuture<U> apply(
DeferredCloser closer,
- @ParametricNullness V1 value1,
- @ParametricNullness V2 value2,
- @ParametricNullness V3 value3,
- @ParametricNullness V4 value4)
+ @NullableDecl V1 value1,
+ @NullableDecl V2 value2,
+ @NullableDecl V3 value3,
+ @NullableDecl V4 value4)
throws Exception;
}
@@ -1839,12 +1747,12 @@
* <p>If the function throws an {@code ExecutionException}, the cause of the thrown {@code
* ExecutionException} will be extracted and used as the failure of the derived step.
*/
- public <U extends @Nullable Object> ClosingFuture<U> call(
+ public <U extends Object> ClosingFuture<U> call(
final ClosingFunction4<V1, V2, V3, V4, U> function, Executor executor) {
return call(
new CombiningCallable<U>() {
@Override
- @ParametricNullness
+ @NullableDecl
public U call(DeferredCloser closer, Peeker peeker) throws Exception {
return function.apply(
closer,
@@ -1898,7 +1806,7 @@
* <p>The same warnings about doing heavyweight operations within {@link
* ClosingFuture#transformAsync(AsyncClosingFunction, Executor)} apply here.
*/
- public <U extends @Nullable Object> ClosingFuture<U> callAsync(
+ public <U extends Object> ClosingFuture<U> callAsync(
final AsyncClosingFunction4<V1, V2, V3, V4, U> function, Executor executor) {
return callAsync(
new AsyncCombiningCallable<U>() {
@@ -1933,11 +1841,11 @@
* @param <V5> the type returned by the fifth future
*/
public static final class Combiner5<
- V1 extends @Nullable Object,
- V2 extends @Nullable Object,
- V3 extends @Nullable Object,
- V4 extends @Nullable Object,
- V5 extends @Nullable Object>
+ V1 extends Object,
+ V2 extends Object,
+ V3 extends Object,
+ V4 extends Object,
+ V5 extends Object>
extends Combiner {
/**
* A function that returns a value when applied to the values of the five futures passed to
@@ -1952,12 +1860,12 @@
* @param <U> the type returned by the function
*/
public interface ClosingFunction5<
- V1 extends @Nullable Object,
- V2 extends @Nullable Object,
- V3 extends @Nullable Object,
- V4 extends @Nullable Object,
- V5 extends @Nullable Object,
- U extends @Nullable Object> {
+ V1 extends Object,
+ V2 extends Object,
+ V3 extends Object,
+ V4 extends Object,
+ V5 extends Object,
+ U extends Object> {
/**
* Applies this function to five inputs, or throws an exception if unable to do so.
*
@@ -1966,14 +1874,14 @@
* is done (but not before this method completes), even if this method throws or the pipeline
* is cancelled.
*/
- @ParametricNullness
+ @NullableDecl
U apply(
DeferredCloser closer,
- @ParametricNullness V1 value1,
- @ParametricNullness V2 value2,
- @ParametricNullness V3 value3,
- @ParametricNullness V4 value4,
- @ParametricNullness V5 value5)
+ @NullableDecl V1 value1,
+ @NullableDecl V2 value2,
+ @NullableDecl V3 value3,
+ @NullableDecl V4 value4,
+ @NullableDecl V5 value5)
throws Exception;
}
@@ -1990,12 +1898,12 @@
* @param <U> the type returned by the function
*/
public interface AsyncClosingFunction5<
- V1 extends @Nullable Object,
- V2 extends @Nullable Object,
- V3 extends @Nullable Object,
- V4 extends @Nullable Object,
- V5 extends @Nullable Object,
- U extends @Nullable Object> {
+ V1 extends Object,
+ V2 extends Object,
+ V3 extends Object,
+ V4 extends Object,
+ V5 extends Object,
+ U extends Object> {
/**
* Applies this function to five inputs, or throws an exception if unable to do so.
*
@@ -2006,11 +1914,11 @@
*/
ClosingFuture<U> apply(
DeferredCloser closer,
- @ParametricNullness V1 value1,
- @ParametricNullness V2 value2,
- @ParametricNullness V3 value3,
- @ParametricNullness V4 value4,
- @ParametricNullness V5 value5)
+ @NullableDecl V1 value1,
+ @NullableDecl V2 value2,
+ @NullableDecl V3 value3,
+ @NullableDecl V4 value4,
+ @NullableDecl V5 value5)
throws Exception;
}
@@ -2048,12 +1956,12 @@
* <p>If the function throws an {@code ExecutionException}, the cause of the thrown {@code
* ExecutionException} will be extracted and used as the failure of the derived step.
*/
- public <U extends @Nullable Object> ClosingFuture<U> call(
+ public <U extends Object> ClosingFuture<U> call(
final ClosingFunction5<V1, V2, V3, V4, V5, U> function, Executor executor) {
return call(
new CombiningCallable<U>() {
@Override
- @ParametricNullness
+ @NullableDecl
public U call(DeferredCloser closer, Peeker peeker) throws Exception {
return function.apply(
closer,
@@ -2109,7 +2017,7 @@
* <p>The same warnings about doing heavyweight operations within {@link
* ClosingFuture#transformAsync(AsyncClosingFunction, Executor)} apply here.
*/
- public <U extends @Nullable Object> ClosingFuture<U> callAsync(
+ public <U extends Object> ClosingFuture<U> callAsync(
final AsyncClosingFunction5<V1, V2, V3, V4, V5, U> function, Executor executor) {
return callAsync(
new AsyncCombiningCallable<U>() {
@@ -2147,7 +2055,7 @@
}
}
- private static void closeQuietly(@CheckForNull final Closeable closeable, Executor executor) {
+ private static void closeQuietly(final Closeable closeable, Executor executor) {
if (closeable == null) {
return;
}
@@ -2189,12 +2097,10 @@
implements Closeable {
private final DeferredCloser closer = new DeferredCloser(this);
private volatile boolean closed;
- @CheckForNull private volatile CountDownLatch whenClosed;
+ private volatile CountDownLatch whenClosed;
- <V extends @Nullable Object, U extends @Nullable Object>
- ListenableFuture<U> applyClosingFunction(
- ClosingFunction<? super V, U> transformation, @ParametricNullness V input)
- throws Exception {
+ <V, U> ListenableFuture<U> applyClosingFunction(
+ ClosingFunction<? super V, U> transformation, V input) throws Exception {
// TODO(dpb): Consider ways to defer closing without creating a separate CloseableList.
CloseableList newCloseables = new CloseableList();
try {
@@ -2204,10 +2110,8 @@
}
}
- <V extends @Nullable Object, U extends @Nullable Object>
- FluentFuture<U> applyAsyncClosingFunction(
- AsyncClosingFunction<V, U> transformation, @ParametricNullness V input)
- throws Exception {
+ <V, U> FluentFuture<U> applyAsyncClosingFunction(
+ AsyncClosingFunction<V, U> transformation, V input) throws Exception {
// TODO(dpb): Consider ways to defer closing without creating a separate CloseableList.
CloseableList newCloseables = new CloseableList();
try {
@@ -2239,7 +2143,7 @@
}
}
- void add(@CheckForNull Closeable closeable, Executor executor) {
+ void add(@NullableDecl Closeable closeable, Executor executor) {
checkNotNull(executor);
if (closeable == null) {
return;
diff --git a/android/guava/src/com/google/common/util/concurrent/CollectionFuture.java b/android/guava/src/com/google/common/util/concurrent/CollectionFuture.java
index c106c15..3ae5800 100644
--- a/android/guava/src/com/google/common/util/concurrent/CollectionFuture.java
+++ b/android/guava/src/com/google/common/util/concurrent/CollectionFuture.java
@@ -19,34 +19,32 @@
import com.google.common.annotations.GwtCompatible;
import com.google.common.collect.ImmutableCollection;
+import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
-import java.util.Collections;
import java.util.List;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import java.util.concurrent.Future;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/** Aggregate future that collects (stores) results of each future. */
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
-abstract class CollectionFuture<V extends @Nullable Object, C extends @Nullable Object>
- extends AggregateFuture<V, C> {
+abstract class CollectionFuture<V, C> extends AggregateFuture<V, C> {
/*
* We access this field racily but safely. For discussion of a similar situation, see the comments
* on the fields of TimeoutFuture. This field is slightly different than the fields discussed
* there: cancel() never reads this field, only writes to it. That makes the race here completely
* harmless, rather than just 99.99% harmless.
*/
- @CheckForNull private List<@Nullable Present<V>> values;
+ private List<Present<V>> values;
CollectionFuture(
ImmutableCollection<? extends ListenableFuture<? extends V>> futures,
boolean allMustSucceed) {
super(futures, allMustSucceed, true);
- List<@Nullable Present<V>> values =
+ List<Present<V>> values =
futures.isEmpty()
- ? Collections.<@Nullable Present<V>>emptyList()
- : Lists.<@Nullable Present<V>>newArrayListWithCapacity(futures.size());
+ ? ImmutableList.<Present<V>>of()
+ : Lists.<Present<V>>newArrayListWithCapacity(futures.size());
// Populate the results list with null initially.
for (int i = 0; i < futures.size(); ++i) {
@@ -57,8 +55,8 @@
}
@Override
- final void collectOneValue(int index, @ParametricNullness V returnValue) {
- List<@Nullable Present<V>> localValues = values;
+ final void collectOneValue(int index, @NullableDecl V returnValue) {
+ List<Present<V>> localValues = values;
if (localValues != null) {
localValues.set(index, new Present<>(returnValue));
}
@@ -66,7 +64,7 @@
@Override
final void handleAllCompleted() {
- List<@Nullable Present<V>> localValues = values;
+ List<Present<V>> localValues = values;
if (localValues != null) {
set(combine(localValues));
}
@@ -78,11 +76,10 @@
this.values = null;
}
- abstract C combine(List<@Nullable Present<V>> values);
+ abstract C combine(List<Present<V>> values);
/** Used for {@link Futures#allAsList} and {@link Futures#successfulAsList}. */
- static final class ListFuture<V extends @Nullable Object>
- extends CollectionFuture<V, List<@Nullable V>> {
+ static final class ListFuture<V> extends CollectionFuture<V, List<V>> {
ListFuture(
ImmutableCollection<? extends ListenableFuture<? extends V>> futures,
boolean allMustSucceed) {
@@ -91,8 +88,8 @@
}
@Override
- public List<@Nullable V> combine(List<@Nullable Present<V>> values) {
- List<@Nullable V> result = newArrayListWithCapacity(values.size());
+ public List<V> combine(List<Present<V>> values) {
+ List<V> result = newArrayListWithCapacity(values.size());
for (Present<V> element : values) {
result.add(element != null ? element.value : null);
}
@@ -101,7 +98,7 @@
}
/** The result of a successful {@code Future}. */
- private static final class Present<V extends @Nullable Object> {
+ private static final class Present<V> {
V value;
Present(V value) {
diff --git a/android/guava/src/com/google/common/util/concurrent/CombinedFuture.java b/android/guava/src/com/google/common/util/concurrent/CombinedFuture.java
index c222111..15a1c07 100644
--- a/android/guava/src/com/google/common/util/concurrent/CombinedFuture.java
+++ b/android/guava/src/com/google/common/util/concurrent/CombinedFuture.java
@@ -25,15 +25,12 @@
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executor;
import java.util.concurrent.RejectedExecutionException;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/** Aggregate future that computes its value by calling a callable. */
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-final class CombinedFuture<V extends @Nullable Object>
- extends AggregateFuture<@Nullable Object, V> {
- @CheckForNull private CombinedFutureInterruptibleTask<?> task;
+final class CombinedFuture<V> extends AggregateFuture<Object, V> {
+ private CombinedFutureInterruptibleTask<?> task;
CombinedFuture(
ImmutableCollection<? extends ListenableFuture<?>> futures,
@@ -56,7 +53,7 @@
}
@Override
- void collectOneValue(int index, @CheckForNull Object returnValue) {}
+ void collectOneValue(int index, @NullableDecl Object returnValue) {}
@Override
void handleAllCompleted() {
@@ -90,8 +87,7 @@
}
@WeakOuter
- private abstract class CombinedFutureInterruptibleTask<T extends @Nullable Object>
- extends InterruptibleTask<T> {
+ private abstract class CombinedFutureInterruptibleTask<T> extends InterruptibleTask<T> {
private final Executor listenerExecutor;
CombinedFutureInterruptibleTask(Executor listenerExecutor) {
@@ -112,7 +108,7 @@
}
@Override
- final void afterRanInterruptiblySuccess(@ParametricNullness T result) {
+ final void afterRanInterruptibly(T result, Throwable error) {
/*
* The future no longer needs to interrupt this task, so it no longer needs a reference to it.
*
@@ -126,28 +122,20 @@
*/
CombinedFuture.this.task = null;
- setValue(result);
- }
-
- @Override
- final void afterRanInterruptiblyFailure(Throwable error) {
- // See afterRanInterruptiblySuccess.
- CombinedFuture.this.task = null;
-
- if (error instanceof ExecutionException) {
- /*
- * Cast to ExecutionException to satisfy our nullness checker, which (unsoundly but
- * *usually* safely) assumes that getCause() returns non-null on an ExecutionException.
- */
- CombinedFuture.this.setException(((ExecutionException) error).getCause());
- } else if (error instanceof CancellationException) {
- cancel(false);
+ if (error != null) {
+ if (error instanceof ExecutionException) {
+ CombinedFuture.this.setException(error.getCause());
+ } else if (error instanceof CancellationException) {
+ cancel(false);
+ } else {
+ CombinedFuture.this.setException(error);
+ }
} else {
- CombinedFuture.this.setException(error);
+ setValue(result);
}
}
- abstract void setValue(@ParametricNullness T value);
+ abstract void setValue(T value);
}
@WeakOuter
@@ -191,13 +179,12 @@
}
@Override
- @ParametricNullness
V runInterruptibly() throws Exception {
return callable.call();
}
@Override
- void setValue(@ParametricNullness V value) {
+ void setValue(V value) {
CombinedFuture.this.set(value);
}
diff --git a/android/guava/src/com/google/common/util/concurrent/CycleDetectingLockFactory.java b/android/guava/src/com/google/common/util/concurrent/CycleDetectingLockFactory.java
index b6b161d..d6ea486 100644
--- a/android/guava/src/com/google/common/util/concurrent/CycleDetectingLockFactory.java
+++ b/android/guava/src/com/google/common/util/concurrent/CycleDetectingLockFactory.java
@@ -15,7 +15,6 @@
package com.google.common.util.concurrent;
import static com.google.common.base.Preconditions.checkNotNull;
-import static java.util.Objects.requireNonNull;
import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtIncompatible;
@@ -43,7 +42,7 @@
import java.util.concurrent.locks.ReentrantReadWriteLock;
import java.util.logging.Level;
import java.util.logging.Logger;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* The {@code CycleDetectingLockFactory} creates {@link ReentrantLock} instances and {@link
@@ -163,7 +162,6 @@
@Beta
@CanIgnoreReturnValue // TODO(cpovirk): Consider being more strict.
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public class CycleDetectingLockFactory {
/**
@@ -270,8 +268,7 @@
}
// A static mapping from an Enum type to its set of LockGraphNodes.
- private static final ConcurrentMap<
- Class<? extends Enum<?>>, Map<? extends Enum<?>, LockGraphNode>>
+ private static final ConcurrentMap<Class<? extends Enum>, Map<? extends Enum, LockGraphNode>>
lockGraphNodesPerType = new MapMaker().weakKeys().makeMap();
/** Creates a {@code CycleDetectingLockFactory.WithExplicitOrdering<E>}. */
@@ -286,15 +283,13 @@
return new WithExplicitOrdering<E>(policy, lockGraphNodes);
}
- @SuppressWarnings("unchecked")
- private static <E extends Enum<E>> Map<? extends E, LockGraphNode> getOrCreateNodes(
- Class<E> clazz) {
- Map<E, LockGraphNode> existing = (Map<E, LockGraphNode>) lockGraphNodesPerType.get(clazz);
+ private static Map<? extends Enum, LockGraphNode> getOrCreateNodes(Class<? extends Enum> clazz) {
+ Map<? extends Enum, LockGraphNode> existing = lockGraphNodesPerType.get(clazz);
if (existing != null) {
return existing;
}
- Map<E, LockGraphNode> created = createNodes(clazz);
- existing = (Map<E, LockGraphNode>) lockGraphNodesPerType.putIfAbsent(clazz, created);
+ Map<? extends Enum, LockGraphNode> created = createNodes(clazz);
+ existing = lockGraphNodesPerType.putIfAbsent(clazz, created);
return MoreObjects.firstNonNull(existing, created);
}
@@ -422,9 +417,7 @@
public ReentrantLock newReentrantLock(E rank, boolean fair) {
return policy == Policies.DISABLED
? new ReentrantLock(fair)
- // requireNonNull is safe because createNodes inserts an entry for every E.
- // (If the caller passes `null` for the `rank` parameter, this will throw, but that's OK.)
- : new CycleDetectingReentrantLock(requireNonNull(lockGraphNodes.get(rank)), fair);
+ : new CycleDetectingReentrantLock(lockGraphNodes.get(rank), fair);
}
/** Equivalent to {@code newReentrantReadWriteLock(rank, false)}. */
@@ -443,10 +436,7 @@
public ReentrantReadWriteLock newReentrantReadWriteLock(E rank, boolean fair) {
return policy == Policies.DISABLED
? new ReentrantReadWriteLock(fair)
- // requireNonNull is safe because createNodes inserts an entry for every E.
- // (If the caller passes `null` for the `rank` parameter, this will throw, but that's OK.)
- : new CycleDetectingReentrantReadWriteLock(
- requireNonNull(lockGraphNodes.get(rank)), fair);
+ : new CycleDetectingReentrantReadWriteLock(lockGraphNodes.get(rank), fair);
}
}
@@ -556,8 +546,7 @@
*/
@Override
public String getMessage() {
- // requireNonNull is safe because ExampleStackTrace sets a non-null message.
- StringBuilder message = new StringBuilder(requireNonNull(super.getMessage()));
+ StringBuilder message = new StringBuilder(super.getMessage());
for (Throwable t = conflictingStackTrace; t != null; t = t.getCause()) {
message.append(", ").append(t.getMessage());
}
@@ -610,8 +599,8 @@
}
void checkAcquiredLocks(Policy policy, List<LockGraphNode> acquiredLocks) {
- for (LockGraphNode acquiredLock : acquiredLocks) {
- checkAcquiredLock(policy, acquiredLock);
+ for (int i = 0, size = acquiredLocks.size(); i < size; i++) {
+ checkAcquiredLock(policy, acquiredLocks.get(i));
}
}
@@ -685,7 +674,7 @@
* @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.
*/
- @CheckForNull
+ @NullableDecl
private ExampleStackTrace findPathTo(LockGraphNode node, Set<LockGraphNode> seen) {
if (!seen.add(this)) {
return null; // Already traversed this node.
diff --git a/android/guava/src/com/google/common/util/concurrent/DirectExecutor.java b/android/guava/src/com/google/common/util/concurrent/DirectExecutor.java
index 0c3a46b..3022971 100644
--- a/android/guava/src/com/google/common/util/concurrent/DirectExecutor.java
+++ b/android/guava/src/com/google/common/util/concurrent/DirectExecutor.java
@@ -22,7 +22,6 @@
* execute}.
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
enum DirectExecutor implements Executor {
INSTANCE;
diff --git a/android/guava/src/com/google/common/util/concurrent/ElementTypesAreNonnullByDefault.java b/android/guava/src/com/google/common/util/concurrent/ElementTypesAreNonnullByDefault.java
deleted file mode 100644
index 3487125..0000000
--- a/android/guava/src/com/google/common/util/concurrent/ElementTypesAreNonnullByDefault.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) 2021 The Guava Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.common.util.concurrent;
-
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.PARAMETER;
-import static java.lang.annotation.ElementType.TYPE;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-import com.google.common.annotations.GwtCompatible;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-import javax.annotation.Nonnull;
-import javax.annotation.meta.TypeQualifierDefault;
-
-/**
- * Marks all "top-level" types as non-null in a way that is recognized by Kotlin. Note that this
- * unfortunately includes type-variable usages, so we also provide {@link ParametricNullness} to
- * "undo" it as best we can.
- */
-@GwtCompatible
-@Retention(RUNTIME)
-@Target(TYPE)
-@TypeQualifierDefault({FIELD, METHOD, PARAMETER})
-@Nonnull
-@interface ElementTypesAreNonnullByDefault {}
diff --git a/android/guava/src/com/google/common/util/concurrent/ExecutionError.java b/android/guava/src/com/google/common/util/concurrent/ExecutionError.java
index deaff15..dd25efb 100644
--- a/android/guava/src/com/google/common/util/concurrent/ExecutionError.java
+++ b/android/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 javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* {@link Error} variant of {@link java.util.concurrent.ExecutionException}. As with {@code
@@ -28,29 +28,22 @@
* @since 10.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
public class ExecutionError extends Error {
- /*
- * Ideally, this class would have exposed only constructors that require a non-null cause. We
- * might try to move in that direction, but there are complications. See
- * https://github.com/jspecify/nullness-checker-for-checker-framework/blob/61aafa4ae52594830cfc2d61c8b113009dbdb045/src/main/java/com/google/jspecify/nullness/NullSpecTransfer.java#L789
- */
-
/** Creates a new instance with {@code null} as its detail message. */
protected ExecutionError() {}
/** Creates a new instance with the given detail message. */
- protected ExecutionError(@CheckForNull String message) {
+ protected ExecutionError(@NullableDecl String message) {
super(message);
}
/** Creates a new instance with the given detail message and cause. */
- public ExecutionError(@CheckForNull String message, @CheckForNull Error cause) {
+ public ExecutionError(@NullableDecl String message, @NullableDecl Error cause) {
super(message, cause);
}
/** Creates a new instance with the given cause. */
- public ExecutionError(@CheckForNull Error cause) {
+ public ExecutionError(@NullableDecl Error cause) {
super(cause);
}
diff --git a/android/guava/src/com/google/common/util/concurrent/ExecutionList.java b/android/guava/src/com/google/common/util/concurrent/ExecutionList.java
index 96fc51c..153f425 100644
--- a/android/guava/src/com/google/common/util/concurrent/ExecutionList.java
+++ b/android/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 javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* A support class for {@code ListenableFuture} implementations to manage their listeners. An
@@ -40,7 +40,6 @@
* @since 1.0
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public final class ExecutionList {
/** Logger to log exceptions caught when running runnables. */
private static final Logger log = Logger.getLogger(ExecutionList.class.getName());
@@ -50,7 +49,7 @@
* RunnableExecutorPair#next} field.
*/
@GuardedBy("this")
- @CheckForNull
+ @NullableDecl
private RunnableExecutorPair runnables;
@GuardedBy("this")
@@ -155,10 +154,9 @@
private static final class RunnableExecutorPair {
final Runnable runnable;
final Executor executor;
- @CheckForNull RunnableExecutorPair next;
+ @NullableDecl RunnableExecutorPair next;
- RunnableExecutorPair(
- Runnable runnable, Executor executor, @CheckForNull RunnableExecutorPair next) {
+ RunnableExecutorPair(Runnable runnable, Executor executor, RunnableExecutorPair next) {
this.runnable = runnable;
this.executor = executor;
this.next = next;
diff --git a/android/guava/src/com/google/common/util/concurrent/ExecutionSequencer.java b/android/guava/src/com/google/common/util/concurrent/ExecutionSequencer.java
index 148f50b..f589e08 100644
--- a/android/guava/src/com/google/common/util/concurrent/ExecutionSequencer.java
+++ b/android/guava/src/com/google/common/util/concurrent/ExecutionSequencer.java
@@ -23,14 +23,11 @@
import static com.google.common.util.concurrent.Futures.immediateFuture;
import static com.google.common.util.concurrent.Futures.immediateVoidFuture;
import static com.google.common.util.concurrent.MoreExecutors.directExecutor;
-import static java.util.Objects.requireNonNull;
import com.google.common.annotations.Beta;
import java.util.concurrent.Callable;
import java.util.concurrent.Executor;
import java.util.concurrent.atomic.AtomicReference;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Serializes execution of tasks, somewhat like an "asynchronous {@code synchronized} block." Each
@@ -81,7 +78,6 @@
* @since 26.0
*/
@Beta
-@ElementTypesAreNonnullByDefault
public final class ExecutionSequencer {
private ExecutionSequencer() {}
@@ -92,7 +88,7 @@
}
/** This reference acts as a pointer tracking the head of a linked list of ListenableFutures. */
- private final AtomicReference<ListenableFuture<@Nullable Void>> ref =
+ private final AtomicReference<ListenableFuture<Void>> ref =
new AtomicReference<>(immediateVoidFuture());
private ThreadConfinedTaskQueue latestTaskQueue = new ThreadConfinedTaskQueue();
@@ -126,11 +122,11 @@
* All the states where thread != currentThread are identical for our purposes, and so even
* though it's racy, we don't care which of those values we get, so no need to synchronize.
*/
- @CheckForNull Thread thread;
+ Thread thread;
/** Only used by the thread associated with this object */
- @CheckForNull Runnable nextTask;
+ Runnable nextTask;
/** Only used by the thread associated with this object */
- @CheckForNull Executor nextExecutor;
+ Executor nextExecutor;
}
/**
@@ -140,8 +136,7 @@
* execute, but if the output future is cancelled before {@link Callable#call()} is invoked,
* {@link Callable#call()} will not be invoked.
*/
- public <T extends @Nullable Object> ListenableFuture<T> submit(
- final Callable<T> callable, Executor executor) {
+ public <T> ListenableFuture<T> submit(final Callable<T> callable, Executor executor) {
checkNotNull(callable);
checkNotNull(executor);
return submitAsync(
@@ -166,7 +161,7 @@
* callable} or a callable that has begun to execute, but if the output future is cancelled before
* {@link AsyncCallable#call()} is invoked, {@link AsyncCallable#call()} will not be invoked.
*/
- public <T extends @Nullable Object> ListenableFuture<T> submitAsync(
+ public <T> ListenableFuture<T> submitAsync(
final AsyncCallable<T> callable, final Executor executor) {
checkNotNull(callable);
checkNotNull(executor);
@@ -197,9 +192,9 @@
* have completed - namely after oldFuture is done, and taskFuture has either completed or been
* cancelled before the callable started execution.
*/
- final SettableFuture<@Nullable Void> newFuture = SettableFuture.create();
+ final SettableFuture<Void> newFuture = SettableFuture.create();
- final ListenableFuture<@Nullable Void> oldFuture = ref.getAndSet(newFuture);
+ final ListenableFuture<Void> oldFuture = ref.getAndSet(newFuture);
// Invoke our task once the previous future completes.
final TrustedListenableFutureTask<T> taskFuture = TrustedListenableFutureTask.create(task);
@@ -284,6 +279,7 @@
* properties; for example, calling WeakReference.get() on Android will block during an
* otherwise-concurrent GC cycle.
*/
+ @SuppressWarnings("ShouldNotSubclass") // Saving an allocation here is worth it
private static final class TaskNonReentrantExecutor extends AtomicReference<RunningState>
implements Executor, Runnable {
@@ -291,22 +287,22 @@
* Used to update and read the latestTaskQueue field. Set to null once the runnable has been run
* or queued.
*/
- @CheckForNull ExecutionSequencer sequencer;
+ ExecutionSequencer sequencer;
/**
* Executor the task was set to run on. Set to null when the task has been queued, run, or
* cancelled.
*/
- @CheckForNull Executor delegate;
+ Executor delegate;
/**
* Set before calling delegate.execute(); set to null once run, so that it can be GCed; this
* object may live on after, if submitAsync returns an incomplete future.
*/
- @CheckForNull Runnable task;
+ Runnable task;
/** Thread that called execute(). Set in execute, cleared when delegate.execute() returns. */
- @CheckForNull Thread submitting;
+ Thread submitting;
private TaskNonReentrantExecutor(Executor delegate, ExecutionSequencer sequencer) {
super(NOT_RUN);
@@ -331,18 +327,8 @@
return;
}
submitting = Thread.currentThread();
-
try {
- /*
- * requireNonNull is safe because we don't null out `sequencer` except:
- *
- * - above, where we return (in which case we never get here)
- *
- * - in `run`, which can't run until this Runnable is submitted to an executor, which
- * doesn't happen until below. (And this Executor -- yes, the object is both a Runnable
- * and an Executor -- is used for only a single `execute` call.)
- */
- ThreadConfinedTaskQueue submittingTaskQueue = requireNonNull(sequencer).latestTaskQueue;
+ ThreadConfinedTaskQueue submittingTaskQueue = sequencer.latestTaskQueue;
if (submittingTaskQueue.thread == submitting) {
sequencer = null;
// Submit from inside a reentrant submit. We don't know if this one will be reentrant (and
@@ -351,12 +337,10 @@
// execution.
checkState(submittingTaskQueue.nextTask == null);
submittingTaskQueue.nextTask = task;
- // requireNonNull(delegate) is safe for reasons similar to requireNonNull(sequencer).
- submittingTaskQueue.nextExecutor = requireNonNull(delegate);
+ submittingTaskQueue.nextExecutor = delegate;
delegate = null;
} else {
- // requireNonNull(delegate) is safe for reasons similar to requireNonNull(sequencer).
- Executor localDelegate = requireNonNull(delegate);
+ Executor localDelegate = delegate;
delegate = null;
this.task = task;
localDelegate.execute(this);
@@ -375,11 +359,7 @@
public void run() {
Thread currentThread = Thread.currentThread();
if (currentThread != submitting) {
- /*
- * requireNonNull is safe because we set `task` before submitting this Runnable to an
- * Executor, and we don't null it out until here.
- */
- Runnable localTask = requireNonNull(task);
+ Runnable localTask = task;
task = null;
localTask.run();
return;
@@ -389,18 +369,6 @@
// latestTaskQueue, and queue rather than calling execute() directly.
ThreadConfinedTaskQueue executingTaskQueue = new ThreadConfinedTaskQueue();
executingTaskQueue.thread = currentThread;
- /*
- * requireNonNull is safe because we don't null out `sequencer` except:
- *
- * - after the requireNonNull call below. (And this object has its Runnable.run override
- * called only once, just as it has its Executor.execute override called only once.)
- *
- * - if we return immediately from `execute` (in which case we never get here)
- *
- * - in the "reentrant submit" case of `execute` (in which case we must have started running a
- * user task -- which means that we already got past this code (or else we exited early
- * above))
- */
// Unconditionally set; there is no risk of throwing away a queued task from another thread,
// because in order for the current task to run on this executor the previous task must have
// already started execution. Because each task on a TaskNonReentrantExecutor can only produce
@@ -410,11 +378,10 @@
// otherwise have another task queued on to it. Note the exception to this, cancellation, is
// specially handled in execute() - execute() calls triggered by cancellation are no-ops, and
// thus don't count.
- requireNonNull(sequencer).latestTaskQueue = executingTaskQueue;
+ sequencer.latestTaskQueue = executingTaskQueue;
sequencer = null;
try {
- // requireNonNull is safe, as discussed above.
- Runnable localTask = requireNonNull(task);
+ Runnable localTask = task;
task = null;
localTask.run();
// Now check if our task attempted to reentrantly execute the next task.
diff --git a/android/guava/src/com/google/common/util/concurrent/FakeTimeLimiter.java b/android/guava/src/com/google/common/util/concurrent/FakeTimeLimiter.java
index ddc9440..9dad51b 100644
--- a/android/guava/src/com/google/common/util/concurrent/FakeTimeLimiter.java
+++ b/android/guava/src/com/google/common/util/concurrent/FakeTimeLimiter.java
@@ -22,7 +22,6 @@
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* A TimeLimiter implementation which actually does not attempt to limit time at all. This may be
@@ -37,7 +36,6 @@
@Beta
@CanIgnoreReturnValue
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public final class FakeTimeLimiter implements TimeLimiter {
@Override
public <T> T newProxy(
@@ -49,9 +47,8 @@
}
@Override
- @ParametricNullness
- public <T extends @Nullable Object> T callWithTimeout(
- Callable<T> callable, long timeoutDuration, TimeUnit timeoutUnit) throws ExecutionException {
+ public <T> T callWithTimeout(Callable<T> callable, long timeoutDuration, TimeUnit timeoutUnit)
+ throws ExecutionException {
checkNotNull(callable);
checkNotNull(timeoutUnit);
try {
@@ -70,8 +67,7 @@
}
@Override
- @ParametricNullness
- public <T extends @Nullable Object> T callUninterruptiblyWithTimeout(
+ public <T> T callUninterruptiblyWithTimeout(
Callable<T> callable, long timeoutDuration, TimeUnit timeoutUnit) throws ExecutionException {
return callWithTimeout(callable, timeoutDuration, timeoutUnit);
}
diff --git a/android/guava/src/com/google/common/util/concurrent/FluentFuture.java b/android/guava/src/com/google/common/util/concurrent/FluentFuture.java
index 2b6ef9f..070cb15 100644
--- a/android/guava/src/com/google/common/util/concurrent/FluentFuture.java
+++ b/android/guava/src/com/google/common/util/concurrent/FluentFuture.java
@@ -27,7 +27,6 @@
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* A {@link ListenableFuture} that supports fluent chains of operations. For example:
@@ -73,26 +72,22 @@
@Beta
@DoNotMock("Use FluentFuture.from(Futures.immediate*Future) or SettableFuture")
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
-public abstract class FluentFuture<V extends @Nullable Object>
- extends GwtFluentFutureCatchingSpecialization<V> {
+public abstract class FluentFuture<V> extends GwtFluentFutureCatchingSpecialization<V> {
/**
* A less abstract subclass of AbstractFuture. This can be used to optimize setFuture by ensuring
* that {@link #get} calls exactly the implementation of {@link AbstractFuture#get}.
*/
- abstract static class TrustedFuture<V extends @Nullable Object> extends FluentFuture<V>
+ abstract static class TrustedFuture<V> extends FluentFuture<V>
implements AbstractFuture.Trusted<V> {
@CanIgnoreReturnValue
@Override
- @ParametricNullness
public final V get() throws InterruptedException, ExecutionException {
return super.get();
}
@CanIgnoreReturnValue
@Override
- @ParametricNullness
public final V get(long timeout, TimeUnit unit)
throws InterruptedException, ExecutionException, TimeoutException {
return super.get(timeout, unit);
@@ -129,7 +124,7 @@
* directly. If not, it is wrapped in a {@code FluentFuture} that delegates all calls to the
* original {@code ListenableFuture}.
*/
- public static <V extends @Nullable Object> FluentFuture<V> from(ListenableFuture<V> future) {
+ public static <V> FluentFuture<V> from(ListenableFuture<V> future) {
return future instanceof FluentFuture
? (FluentFuture<V>) future
: new ForwardingFluentFuture<V>(future);
@@ -142,7 +137,7 @@
* @since 28.0
*/
@Deprecated
- public static <V extends @Nullable Object> FluentFuture<V> from(FluentFuture<V> future) {
+ public static <V> FluentFuture<V> from(FluentFuture<V> future) {
return checkNotNull(future);
}
@@ -309,7 +304,7 @@
* @return A future that holds result of the function (if the input succeeded) or the original
* input's failure (if not)
*/
- public final <T extends @Nullable Object> FluentFuture<T> transformAsync(
+ public final <T> FluentFuture<T> transformAsync(
AsyncFunction<? super V, T> function, Executor executor) {
return (FluentFuture<T>) Futures.transformAsync(this, function, executor);
}
@@ -346,8 +341,7 @@
* @param executor Executor to run the function in.
* @return A future that holds result of the transformation.
*/
- public final <T extends @Nullable Object> FluentFuture<T> transform(
- Function<? super V, T> function, Executor executor) {
+ public final <T> FluentFuture<T> transform(Function<? super V, T> function, Executor executor) {
return (FluentFuture<T>) Futures.transform(this, function, executor);
}
diff --git a/android/guava/src/com/google/common/util/concurrent/ForwardingBlockingDeque.java b/android/guava/src/com/google/common/util/concurrent/ForwardingBlockingDeque.java
index d0d72a8..2485966 100644
--- a/android/guava/src/com/google/common/util/concurrent/ForwardingBlockingDeque.java
+++ b/android/guava/src/com/google/common/util/concurrent/ForwardingBlockingDeque.java
@@ -21,7 +21,6 @@
import java.util.Collection;
import java.util.concurrent.BlockingDeque;
import java.util.concurrent.TimeUnit;
-import javax.annotation.CheckForNull;
/**
* A {@link BlockingDeque} which forwards all its method calls to another {@code BlockingDeque}.
@@ -45,7 +44,6 @@
* @since 21.0 (since 14.0 as {@link com.google.common.collect.ForwardingBlockingDeque})
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public abstract class ForwardingBlockingDeque<E> extends ForwardingDeque<E>
implements BlockingDeque<E> {
@@ -91,13 +89,11 @@
}
@Override
- @CheckForNull
public E pollFirst(long timeout, TimeUnit unit) throws InterruptedException {
return delegate().pollFirst(timeout, unit);
}
@Override
- @CheckForNull
public E pollLast(long timeout, TimeUnit unit) throws InterruptedException {
return delegate().pollLast(timeout, unit);
}
@@ -118,7 +114,6 @@
}
@Override
- @CheckForNull
public E poll(long timeout, TimeUnit unit) throws InterruptedException {
return delegate().poll(timeout, unit);
}
diff --git a/android/guava/src/com/google/common/util/concurrent/ForwardingBlockingQueue.java b/android/guava/src/com/google/common/util/concurrent/ForwardingBlockingQueue.java
index dc8511d..f5575a1 100644
--- a/android/guava/src/com/google/common/util/concurrent/ForwardingBlockingQueue.java
+++ b/android/guava/src/com/google/common/util/concurrent/ForwardingBlockingQueue.java
@@ -20,7 +20,6 @@
import java.util.Collection;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.TimeUnit;
-import javax.annotation.CheckForNull;
/**
* A {@link BlockingQueue} which forwards all its method calls to another {@link BlockingQueue}.
@@ -38,7 +37,6 @@
*/
@CanIgnoreReturnValue // TODO(cpovirk): Consider being more strict.
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public abstract class ForwardingBlockingQueue<E> extends ForwardingQueue<E>
implements BlockingQueue<E> {
@@ -64,7 +62,6 @@
}
@Override
- @CheckForNull
public E poll(long timeout, TimeUnit unit) throws InterruptedException {
return delegate().poll(timeout, unit);
}
diff --git a/android/guava/src/com/google/common/util/concurrent/ForwardingCondition.java b/android/guava/src/com/google/common/util/concurrent/ForwardingCondition.java
index d17f98c..62c4d4c 100644
--- a/android/guava/src/com/google/common/util/concurrent/ForwardingCondition.java
+++ b/android/guava/src/com/google/common/util/concurrent/ForwardingCondition.java
@@ -19,7 +19,6 @@
import java.util.concurrent.locks.Condition;
/** Forwarding wrapper around a {@code Condition}. */
-@ElementTypesAreNonnullByDefault
abstract class ForwardingCondition implements Condition {
abstract Condition delegate();
diff --git a/android/guava/src/com/google/common/util/concurrent/ForwardingExecutorService.java b/android/guava/src/com/google/common/util/concurrent/ForwardingExecutorService.java
index ed78b86..f9da1d4 100644
--- a/android/guava/src/com/google/common/util/concurrent/ForwardingExecutorService.java
+++ b/android/guava/src/com/google/common/util/concurrent/ForwardingExecutorService.java
@@ -25,7 +25,6 @@
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* An executor service which forwards all its method calls to another executor service. Subclasses
@@ -37,7 +36,6 @@
*/
@CanIgnoreReturnValue // TODO(cpovirk): Consider being more strict.
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public abstract class ForwardingExecutorService extends ForwardingObject
implements ExecutorService {
/** Constructor for use by subclasses. */
@@ -52,27 +50,26 @@
}
@Override
- public <T extends @Nullable Object> List<Future<T>> invokeAll(
- Collection<? extends Callable<T>> tasks) throws InterruptedException {
+ public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks)
+ throws InterruptedException {
return delegate().invokeAll(tasks);
}
@Override
- public <T extends @Nullable Object> List<Future<T>> invokeAll(
+ public <T> List<Future<T>> invokeAll(
Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit)
throws InterruptedException {
return delegate().invokeAll(tasks, timeout, unit);
}
@Override
- public <T extends @Nullable Object> T invokeAny(Collection<? extends Callable<T>> tasks)
+ public <T> T invokeAny(Collection<? extends Callable<T>> tasks)
throws InterruptedException, ExecutionException {
return delegate().invokeAny(tasks);
}
@Override
- public <T extends @Nullable Object> T invokeAny(
- Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit)
+ public <T> T invokeAny(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit)
throws InterruptedException, ExecutionException, TimeoutException {
return delegate().invokeAny(tasks, timeout, unit);
}
@@ -103,7 +100,7 @@
}
@Override
- public <T extends @Nullable Object> Future<T> submit(Callable<T> task) {
+ public <T> Future<T> submit(Callable<T> task) {
return delegate().submit(task);
}
@@ -113,8 +110,7 @@
}
@Override
- public <T extends @Nullable Object> Future<T> submit(
- Runnable task, @ParametricNullness T result) {
+ public <T> Future<T> submit(Runnable task, T result) {
return delegate().submit(task, result);
}
}
diff --git a/android/guava/src/com/google/common/util/concurrent/ForwardingFluentFuture.java b/android/guava/src/com/google/common/util/concurrent/ForwardingFluentFuture.java
index cb779c3..984fd68 100644
--- a/android/guava/src/com/google/common/util/concurrent/ForwardingFluentFuture.java
+++ b/android/guava/src/com/google/common/util/concurrent/ForwardingFluentFuture.java
@@ -21,7 +21,6 @@
import java.util.concurrent.Executor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* {@link FluentFuture} that forwards all calls to a delegate.
@@ -34,8 +33,7 @@
* forwards to that future and adds the desired methods.
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-final class ForwardingFluentFuture<V extends @Nullable Object> extends FluentFuture<V> {
+final class ForwardingFluentFuture<V> extends FluentFuture<V> {
private final ListenableFuture<V> delegate;
ForwardingFluentFuture(ListenableFuture<V> delegate) {
@@ -63,13 +61,11 @@
}
@Override
- @ParametricNullness
public V get() throws InterruptedException, ExecutionException {
return delegate.get();
}
@Override
- @ParametricNullness
public V get(long timeout, TimeUnit unit)
throws InterruptedException, ExecutionException, TimeoutException {
return delegate.get(timeout, unit);
diff --git a/android/guava/src/com/google/common/util/concurrent/ForwardingFuture.java b/android/guava/src/com/google/common/util/concurrent/ForwardingFuture.java
index 47002b0..165793b 100644
--- a/android/guava/src/com/google/common/util/concurrent/ForwardingFuture.java
+++ b/android/guava/src/com/google/common/util/concurrent/ForwardingFuture.java
@@ -22,7 +22,6 @@
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* A {@link Future} which forwards all its method calls to another future. Subclasses should
@@ -36,9 +35,7 @@
*/
@CanIgnoreReturnValue // TODO(cpovirk): Consider being more strict.
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-public abstract class ForwardingFuture<V extends @Nullable Object> extends ForwardingObject
- implements Future<V> {
+public abstract class ForwardingFuture<V> extends ForwardingObject implements Future<V> {
/** Constructor for use by subclasses. */
protected ForwardingFuture() {}
@@ -61,13 +58,11 @@
}
@Override
- @ParametricNullness
public V get() throws InterruptedException, ExecutionException {
return delegate().get();
}
@Override
- @ParametricNullness
public V get(long timeout, TimeUnit unit)
throws InterruptedException, ExecutionException, TimeoutException {
return delegate().get(timeout, unit);
@@ -80,8 +75,7 @@
*
* @since 9.0
*/
- public abstract static class SimpleForwardingFuture<V extends @Nullable Object>
- extends ForwardingFuture<V> {
+ public abstract static class SimpleForwardingFuture<V> extends ForwardingFuture<V> {
private final Future<V> delegate;
protected SimpleForwardingFuture(Future<V> delegate) {
diff --git a/android/guava/src/com/google/common/util/concurrent/ForwardingListenableFuture.java b/android/guava/src/com/google/common/util/concurrent/ForwardingListenableFuture.java
index 3868091..d3ed3c2 100644
--- a/android/guava/src/com/google/common/util/concurrent/ForwardingListenableFuture.java
+++ b/android/guava/src/com/google/common/util/concurrent/ForwardingListenableFuture.java
@@ -18,7 +18,6 @@
import com.google.common.base.Preconditions;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import java.util.concurrent.Executor;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* A {@link ListenableFuture} which forwards all its method calls to another future. Subclasses
@@ -32,9 +31,8 @@
*/
@CanIgnoreReturnValue // TODO(cpovirk): Consider being more strict.
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-public abstract class ForwardingListenableFuture<V extends @Nullable Object>
- extends ForwardingFuture<V> implements ListenableFuture<V> {
+public abstract class ForwardingListenableFuture<V> extends ForwardingFuture<V>
+ implements ListenableFuture<V> {
/** Constructor for use by subclasses. */
protected ForwardingListenableFuture() {}
@@ -54,7 +52,7 @@
*
* @since 9.0
*/
- public abstract static class SimpleForwardingListenableFuture<V extends @Nullable Object>
+ public abstract static class SimpleForwardingListenableFuture<V>
extends ForwardingListenableFuture<V> {
private final ListenableFuture<V> delegate;
diff --git a/android/guava/src/com/google/common/util/concurrent/ForwardingListeningExecutorService.java b/android/guava/src/com/google/common/util/concurrent/ForwardingListeningExecutorService.java
index fe25b86..48a49b8 100644
--- a/android/guava/src/com/google/common/util/concurrent/ForwardingListeningExecutorService.java
+++ b/android/guava/src/com/google/common/util/concurrent/ForwardingListeningExecutorService.java
@@ -17,7 +17,6 @@
import com.google.common.annotations.GwtIncompatible;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import java.util.concurrent.Callable;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* A listening executor service which forwards all its method calls to another listening executor
@@ -30,7 +29,6 @@
*/
@CanIgnoreReturnValue // TODO(cpovirk): Consider being more strict.
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public abstract class ForwardingListeningExecutorService extends ForwardingExecutorService
implements ListeningExecutorService {
/** Constructor for use by subclasses. */
@@ -40,7 +38,7 @@
protected abstract ListeningExecutorService delegate();
@Override
- public <T extends @Nullable Object> ListenableFuture<T> submit(Callable<T> task) {
+ public <T> ListenableFuture<T> submit(Callable<T> task) {
return delegate().submit(task);
}
@@ -50,8 +48,7 @@
}
@Override
- public <T extends @Nullable Object> ListenableFuture<T> submit(
- Runnable task, @ParametricNullness T result) {
+ public <T> ListenableFuture<T> submit(Runnable task, T result) {
return delegate().submit(task, result);
}
}
diff --git a/android/guava/src/com/google/common/util/concurrent/ForwardingLock.java b/android/guava/src/com/google/common/util/concurrent/ForwardingLock.java
index db2026a..8c50787 100644
--- a/android/guava/src/com/google/common/util/concurrent/ForwardingLock.java
+++ b/android/guava/src/com/google/common/util/concurrent/ForwardingLock.java
@@ -19,7 +19,6 @@
import java.util.concurrent.locks.Lock;
/** Forwarding wrapper around a {@code Lock}. */
-@ElementTypesAreNonnullByDefault
abstract class ForwardingLock implements Lock {
abstract Lock delegate();
diff --git a/android/guava/src/com/google/common/util/concurrent/FutureCallback.java b/android/guava/src/com/google/common/util/concurrent/FutureCallback.java
index f5684e7..a10f71b 100644
--- a/android/guava/src/com/google/common/util/concurrent/FutureCallback.java
+++ b/android/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.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* A callback for accepting the results of a {@link java.util.concurrent.Future} computation
@@ -29,10 +29,9 @@
* @since 10.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-public interface FutureCallback<V extends @Nullable Object> {
+public interface FutureCallback<V> {
/** Invoked with the result of the {@code Future} computation when it is successful. */
- void onSuccess(@ParametricNullness V result);
+ void onSuccess(@NullableDecl V result);
/**
* Invoked when a {@code Future} computation fails or is canceled.
diff --git a/android/guava/src/com/google/common/util/concurrent/Futures.java b/android/guava/src/com/google/common/util/concurrent/Futures.java
index e6bf7a7..d2ed5d9 100644
--- a/android/guava/src/com/google/common/util/concurrent/Futures.java
+++ b/android/guava/src/com/google/common/util/concurrent/Futures.java
@@ -18,7 +18,6 @@
import static com.google.common.base.Preconditions.checkState;
import static com.google.common.util.concurrent.MoreExecutors.directExecutor;
import static com.google.common.util.concurrent.Uninterruptibles.getUninterruptibly;
-import static java.util.Objects.requireNonNull;
import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtCompatible;
@@ -45,8 +44,7 @@
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicInteger;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* Static utility methods pertaining to the {@link Future} interface.
@@ -73,7 +71,6 @@
* @since 1.0
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
public final class Futures extends GwtFuturesCatchingSpecialization {
// A note on memory visibility.
@@ -128,8 +125,7 @@
* 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 <V extends @Nullable Object> ListenableFuture<V> immediateFuture(
- @ParametricNullness V value) {
+ public static <V> ListenableFuture<V> immediateFuture(@NullableDecl V value) {
if (value == null) {
// This cast is safe because null is assignable to V for all V (i.e. it is bivariant)
@SuppressWarnings("unchecked")
@@ -146,8 +142,8 @@
* @since 29.0
*/
@SuppressWarnings("unchecked")
- public static ListenableFuture<@Nullable Void> immediateVoidFuture() {
- return (ListenableFuture<@Nullable Void>) ImmediateFuture.NULL;
+ public static ListenableFuture<Void> immediateVoidFuture() {
+ return (ListenableFuture<Void>) ImmediateFuture.NULL;
}
/**
@@ -157,8 +153,7 @@
* returns {@code true}. Calling {@code get()} will immediately throw the provided {@code
* Throwable} wrapped in an {@code ExecutionException}.
*/
- public static <V extends @Nullable Object> ListenableFuture<V> immediateFailedFuture(
- Throwable throwable) {
+ public static <V> ListenableFuture<V> immediateFailedFuture(Throwable throwable) {
checkNotNull(throwable);
return new ImmediateFailedFuture<V>(throwable);
}
@@ -169,7 +164,7 @@
*
* @since 14.0
*/
- public static <V extends @Nullable Object> ListenableFuture<V> immediateCancelledFuture() {
+ public static <V> ListenableFuture<V> immediateCancelledFuture() {
return new ImmediateCancelledFuture<V>();
}
@@ -180,8 +175,7 @@
* @since 28.2
*/
@Beta
- public static <O extends @Nullable Object> ListenableFuture<O> submit(
- Callable<O> callable, Executor executor) {
+ public static <O> ListenableFuture<O> submit(Callable<O> callable, Executor executor) {
TrustedListenableFutureTask<O> task = TrustedListenableFutureTask.create(callable);
executor.execute(task);
return task;
@@ -195,9 +189,8 @@
* @since 28.2
*/
@Beta
- public static ListenableFuture<@Nullable Void> submit(Runnable runnable, Executor executor) {
- TrustedListenableFutureTask<@Nullable Void> task =
- TrustedListenableFutureTask.create(runnable, null);
+ public static ListenableFuture<Void> submit(Runnable runnable, Executor executor) {
+ TrustedListenableFutureTask<Void> task = TrustedListenableFutureTask.create(runnable, null);
executor.execute(task);
return task;
}
@@ -209,8 +202,7 @@
* @since 23.0
*/
@Beta
- public static <O extends @Nullable Object> ListenableFuture<O> submitAsync(
- AsyncCallable<O> callable, Executor executor) {
+ public static <O> ListenableFuture<O> submitAsync(AsyncCallable<O> callable, Executor executor) {
TrustedListenableFutureTask<O> task = TrustedListenableFutureTask.create(callable);
executor.execute(task);
return task;
@@ -225,7 +217,7 @@
@Beta
@GwtIncompatible // java.util.concurrent.ScheduledExecutorService
@SuppressWarnings("GoodTime") // should accept a java.time.Duration
- public static <O extends @Nullable Object> ListenableFuture<O> scheduleAsync(
+ public static <O> ListenableFuture<O> scheduleAsync(
AsyncCallable<O> callable,
long delay,
TimeUnit timeUnit,
@@ -282,7 +274,7 @@
*/
@Beta
@Partially.GwtIncompatible("AVAILABLE but requires exceptionType to be Throwable.class")
- public static <V extends @Nullable Object, X extends Throwable> ListenableFuture<V> catching(
+ public static <V, X extends Throwable> ListenableFuture<V> catching(
ListenableFuture<? extends V> input,
Class<X> exceptionType,
Function<? super X, ? extends V> fallback,
@@ -347,7 +339,7 @@
*/
@Beta
@Partially.GwtIncompatible("AVAILABLE but requires exceptionType to be Throwable.class")
- public static <V extends @Nullable Object, X extends Throwable> ListenableFuture<V> catchingAsync(
+ public static <V, X extends Throwable> ListenableFuture<V> catchingAsync(
ListenableFuture<? extends V> input,
Class<X> exceptionType,
AsyncFunction<? super X, ? extends V> fallback,
@@ -370,7 +362,7 @@
@Beta
@GwtIncompatible // java.util.concurrent.ScheduledExecutorService
@SuppressWarnings("GoodTime") // should accept a java.time.Duration
- public static <V extends @Nullable Object> ListenableFuture<V> withTimeout(
+ public static <V> ListenableFuture<V> withTimeout(
ListenableFuture<V> delegate,
long time,
TimeUnit unit,
@@ -414,11 +406,10 @@
* @since 19.0 (in 11.0 as {@code transform})
*/
@Beta
- public static <I extends @Nullable Object, O extends @Nullable Object>
- ListenableFuture<O> transformAsync(
- ListenableFuture<I> input,
- AsyncFunction<? super I, ? extends O> function,
- Executor executor) {
+ public static <I, O> ListenableFuture<O> transformAsync(
+ ListenableFuture<I> input,
+ AsyncFunction<? super I, ? extends O> function,
+ Executor executor) {
return AbstractTransformFuture.create(input, function, executor);
}
@@ -452,9 +443,8 @@
* @since 9.0 (in 2.0 as {@code compose})
*/
@Beta
- public static <I extends @Nullable Object, O extends @Nullable Object>
- ListenableFuture<O> transform(
- ListenableFuture<I> input, Function<? super I, ? extends O> function, Executor executor) {
+ public static <I, O> ListenableFuture<O> transform(
+ ListenableFuture<I> input, Function<? super I, ? extends O> function, Executor executor) {
return AbstractTransformFuture.create(input, function, executor);
}
@@ -480,7 +470,7 @@
*/
@Beta
@GwtIncompatible // TODO
- public static <I extends @Nullable Object, O extends @Nullable Object> Future<O> lazyTransform(
+ public static <I, O> Future<O> lazyTransform(
final Future<I> input, final Function<? super I, ? extends O> function) {
checkNotNull(input);
checkNotNull(function);
@@ -540,14 +530,8 @@
*/
@Beta
@SafeVarargs
- public static <V extends @Nullable Object> ListenableFuture<List<V>> allAsList(
- ListenableFuture<? extends V>... futures) {
- ListenableFuture<List<@Nullable V>> nullable =
- new ListFuture<V>(ImmutableList.copyOf(futures), true);
- // allAsList ensures that it fills the output list with V instances.
- @SuppressWarnings("nullness")
- ListenableFuture<List<V>> nonNull = nullable;
- return nonNull;
+ public static <V> ListenableFuture<List<V>> allAsList(ListenableFuture<? extends V>... futures) {
+ return new ListFuture<V>(ImmutableList.copyOf(futures), true);
}
/**
@@ -567,14 +551,9 @@
* @since 10.0
*/
@Beta
- public static <V extends @Nullable Object> ListenableFuture<List<V>> allAsList(
+ public static <V> ListenableFuture<List<V>> allAsList(
Iterable<? extends ListenableFuture<? extends V>> futures) {
- ListenableFuture<List<@Nullable V>> nullable =
- new ListFuture<V>(ImmutableList.copyOf(futures), true);
- // allAsList ensures that it fills the output list with V instances.
- @SuppressWarnings("nullness")
- ListenableFuture<List<V>> nonNull = nullable;
- return nonNull;
+ return new ListFuture<V>(ImmutableList.copyOf(futures), true);
}
/**
@@ -587,8 +566,7 @@
*/
@Beta
@SafeVarargs
- public static <V extends @Nullable Object> FutureCombiner<V> whenAllComplete(
- ListenableFuture<? extends V>... futures) {
+ public static <V> FutureCombiner<V> whenAllComplete(ListenableFuture<? extends V>... futures) {
return new FutureCombiner<V>(false, ImmutableList.copyOf(futures));
}
@@ -601,7 +579,7 @@
* @since 20.0
*/
@Beta
- public static <V extends @Nullable Object> FutureCombiner<V> whenAllComplete(
+ public static <V> FutureCombiner<V> whenAllComplete(
Iterable<? extends ListenableFuture<? extends V>> futures) {
return new FutureCombiner<V>(false, ImmutableList.copyOf(futures));
}
@@ -615,8 +593,7 @@
*/
@Beta
@SafeVarargs
- public static <V extends @Nullable Object> FutureCombiner<V> whenAllSucceed(
- ListenableFuture<? extends V>... futures) {
+ public static <V> FutureCombiner<V> whenAllSucceed(ListenableFuture<? extends V>... futures) {
return new FutureCombiner<V>(true, ImmutableList.copyOf(futures));
}
@@ -628,7 +605,7 @@
* @since 20.0
*/
@Beta
- public static <V extends @Nullable Object> FutureCombiner<V> whenAllSucceed(
+ public static <V> FutureCombiner<V> whenAllSucceed(
Iterable<? extends ListenableFuture<? extends V>> futures) {
return new FutureCombiner<V>(true, ImmutableList.copyOf(futures));
}
@@ -662,7 +639,7 @@
@Beta
@CanIgnoreReturnValue // TODO(cpovirk): Consider removing, especially if we provide run(Runnable)
@GwtCompatible
- public static final class FutureCombiner<V extends @Nullable Object> {
+ public static final class FutureCombiner<V> {
private final boolean allMustSucceed;
private final ImmutableList<ListenableFuture<? extends V>> futures;
@@ -686,8 +663,7 @@
*
* <p>Canceling this future will attempt to cancel all the component futures.
*/
- public <C extends @Nullable Object> ListenableFuture<C> callAsync(
- AsyncCallable<C> combiner, Executor executor) {
+ public <C> ListenableFuture<C> callAsync(AsyncCallable<C> combiner, Executor executor) {
return new CombinedFuture<C>(futures, allMustSucceed, executor, combiner);
}
@@ -706,8 +682,7 @@
* <p>Canceling this future will attempt to cancel all the component futures.
*/
@CanIgnoreReturnValue // TODO(cpovirk): Remove this
- public <C extends @Nullable Object> ListenableFuture<C> call(
- Callable<C> combiner, Executor executor) {
+ public <C> ListenableFuture<C> call(Callable<C> combiner, Executor executor) {
return new CombinedFuture<C>(futures, allMustSucceed, executor, combiner);
}
@@ -724,9 +699,8 @@
*/
public ListenableFuture<?> run(final Runnable combiner, Executor executor) {
return call(
- new Callable<@Nullable Void>() {
+ new Callable<Void>() {
@Override
- @CheckForNull
public Void call() throws Exception {
combiner.run();
return null;
@@ -744,8 +718,7 @@
* @since 15.0
*/
@Beta
- public static <V extends @Nullable Object> ListenableFuture<V> nonCancellationPropagating(
- ListenableFuture<V> future) {
+ public static <V> ListenableFuture<V> nonCancellationPropagating(ListenableFuture<V> future) {
if (future.isDone()) {
return future;
}
@@ -755,9 +728,9 @@
}
/** A wrapped future that does not propagate cancellation to its delegate. */
- private static final class NonCancellationPropagatingFuture<V extends @Nullable Object>
+ private static final class NonCancellationPropagatingFuture<V>
extends AbstractFuture.TrustedFuture<V> implements Runnable {
- @CheckForNull private ListenableFuture<V> delegate;
+ private ListenableFuture<V> delegate;
NonCancellationPropagatingFuture(final ListenableFuture<V> delegate) {
this.delegate = delegate;
@@ -774,7 +747,6 @@
}
@Override
- @CheckForNull
protected String pendingToString() {
ListenableFuture<V> localDelegate = delegate;
if (localDelegate != null) {
@@ -807,21 +779,9 @@
* @return a future that provides a list of the results of the component futures
* @since 10.0
*/
- /*
- * Another way to express this signature would be to bound <V> by @NonNull and accept LF<? extends
- * @Nullable V>. That might be better: There's currently no difference between the outputs users
- * get when calling this with <Foo> and calling it with <@Nullable Foo>. The only difference is
- * that calling it with <Foo> won't work when an input Future has a @Nullable type. So why even
- * make that error possible by giving callers the choice?
- *
- * On the other hand, the current signature is consistent with the similar allAsList method. And
- * eventually this method may go away entirely in favor of an API like
- * whenAllComplete().collectSuccesses(). That API would have a signature more like the current
- * one.
- */
@Beta
@SafeVarargs
- public static <V extends @Nullable Object> ListenableFuture<List<@Nullable V>> successfulAsList(
+ public static <V> ListenableFuture<List<V>> successfulAsList(
ListenableFuture<? extends V>... futures) {
return new ListFuture<V>(ImmutableList.copyOf(futures), false);
}
@@ -845,7 +805,7 @@
* @since 10.0
*/
@Beta
- public static <V extends @Nullable Object> ListenableFuture<List<@Nullable V>> successfulAsList(
+ public static <V> ListenableFuture<List<V>> successfulAsList(
Iterable<? extends ListenableFuture<? extends V>> futures) {
return new ListFuture<V>(ImmutableList.copyOf(futures), false);
}
@@ -872,12 +832,21 @@
* @since 17.0
*/
@Beta
- public static <T extends @Nullable Object> ImmutableList<ListenableFuture<T>> inCompletionOrder(
+ public static <T> ImmutableList<ListenableFuture<T>> inCompletionOrder(
Iterable<? extends ListenableFuture<? extends T>> futures) {
- ListenableFuture<? extends T>[] copy = gwtCompatibleToArray(futures);
+ // Can't use Iterables.toArray because it's not gwt compatible
+ final Collection<ListenableFuture<? extends T>> collection;
+ if (futures instanceof Collection) {
+ collection = (Collection<ListenableFuture<? extends T>>) futures;
+ } else {
+ collection = ImmutableList.copyOf(futures);
+ }
+ @SuppressWarnings("unchecked")
+ ListenableFuture<? extends T>[] copy =
+ (ListenableFuture<? extends T>[])
+ collection.toArray(new ListenableFuture[collection.size()]);
final InCompletionOrderState<T> state = new InCompletionOrderState<>(copy);
- ImmutableList.Builder<AbstractFuture<T>> delegatesBuilder =
- ImmutableList.builderWithExpectedSize(copy.length);
+ ImmutableList.Builder<AbstractFuture<T>> delegatesBuilder = ImmutableList.builder();
for (int i = 0; i < copy.length; i++) {
delegatesBuilder.add(new InCompletionOrderFuture<T>(state));
}
@@ -900,25 +869,11 @@
return delegatesCast;
}
- /** Can't use Iterables.toArray because it's not gwt compatible */
- @SuppressWarnings("unchecked")
- private static <T extends @Nullable Object> ListenableFuture<? extends T>[] gwtCompatibleToArray(
- Iterable<? extends ListenableFuture<? extends T>> futures) {
- final Collection<ListenableFuture<? extends T>> collection;
- if (futures instanceof Collection) {
- collection = (Collection<ListenableFuture<? extends T>>) futures;
- } else {
- collection = ImmutableList.copyOf(futures);
- }
- return (ListenableFuture<? extends T>[]) collection.toArray(new ListenableFuture<?>[0]);
- }
-
// This can't be a TrustedFuture, because TrustedFuture has clever optimizations that
// mean cancel won't be called if this Future is passed into setFuture, and then
// cancelled.
- private static final class InCompletionOrderFuture<T extends @Nullable Object>
- extends AbstractFuture<T> {
- @CheckForNull private InCompletionOrderState<T> state;
+ private static final class InCompletionOrderFuture<T> extends AbstractFuture<T> {
+ private InCompletionOrderState<T> state;
private InCompletionOrderFuture(InCompletionOrderState<T> state) {
this.state = state;
@@ -928,15 +883,7 @@
public boolean cancel(boolean interruptIfRunning) {
InCompletionOrderState<T> localState = state;
if (super.cancel(interruptIfRunning)) {
- /*
- * requireNonNull is generally safe: If cancel succeeded, then this Future was still
- * pending, so its `state` field hasn't been nulled out yet.
- *
- * OK, it's technically possible for this to fail in the presence of unsafe publishing, as
- * discussed in the comments in TimeoutFuture. TODO(cpovirk): Maybe check for null before
- * calling recordOutputCancellation?
- */
- requireNonNull(localState).recordOutputCancellation(interruptIfRunning);
+ localState.recordOutputCancellation(interruptIfRunning);
return true;
}
return false;
@@ -948,7 +895,6 @@
}
@Override
- @CheckForNull
protected String pendingToString() {
InCompletionOrderState<T> localState = state;
if (localState != null) {
@@ -964,15 +910,14 @@
}
}
- private static final class InCompletionOrderState<T extends @Nullable Object> {
+ private static final class InCompletionOrderState<T> {
// A happens-before edge between the writes of these fields and their reads exists, because
// in order to read these fields, the corresponding write to incompleteOutputCount must have
// been read.
private boolean wasCancelled = false;
private boolean shouldInterrupt = true;
private final AtomicInteger incompleteOutputCount;
- // We set the elements of the array to null as they complete.
- private final @Nullable ListenableFuture<? extends T>[] inputFutures;
+ private final ListenableFuture<? extends T>[] inputFutures;
private volatile int delegateIndex = 0;
private InCompletionOrderState(ListenableFuture<? extends T>[] inputFutures) {
@@ -992,11 +937,7 @@
private void recordInputCompletion(
ImmutableList<AbstractFuture<T>> delegates, int inputFutureIndex) {
- /*
- * requireNonNull is safe because we accepted an Iterable of non-null Future instances, and we
- * don't overwrite an element in the array until after reading it.
- */
- ListenableFuture<? extends T> inputFuture = requireNonNull(inputFutures[inputFutureIndex]);
+ ListenableFuture<? extends T> inputFuture = inputFutures[inputFutureIndex];
// Null out our reference to this future, so it can be GCed
inputFutures[inputFutureIndex] = null;
for (int i = delegateIndex; i < delegates.size(); i++) {
@@ -1015,7 +956,7 @@
private void recordCompletion() {
if (incompleteOutputCount.decrementAndGet() == 0 && wasCancelled) {
- for (ListenableFuture<? extends T> toCancel : inputFutures) {
+ for (ListenableFuture<?> toCancel : inputFutures) {
if (toCancel != null) {
toCancel.cancel(shouldInterrupt);
}
@@ -1065,7 +1006,7 @@
* @param executor The executor to run {@code callback} when the future completes.
* @since 10.0
*/
- public static <V extends @Nullable Object> void addCallback(
+ public static <V> void addCallback(
final ListenableFuture<V> future,
final FutureCallback<? super V> callback,
Executor executor) {
@@ -1074,7 +1015,7 @@
}
/** See {@link #addCallback(ListenableFuture, FutureCallback, Executor)} for behavioral notes. */
- private static final class CallbackListener<V extends @Nullable Object> implements Runnable {
+ private static final class CallbackListener<V> implements Runnable {
final Future<V> future;
final FutureCallback<? super V> callback;
@@ -1133,8 +1074,7 @@
*/
@CanIgnoreReturnValue
// TODO(cpovirk): Consider calling getDone() in our own code.
- @ParametricNullness
- public static <V extends @Nullable Object> V getDone(Future<V> future) throws ExecutionException {
+ public static <V> V getDone(Future<V> future) throws ExecutionException {
/*
* We throw IllegalStateException, since the call could succeed later. Perhaps we "should" throw
* IllegalArgumentException, since the call could succeed with a different argument. Those
@@ -1142,6 +1082,7 @@
* IllegalArgumentException here, in part to keep its recommendation simple: Static methods
* should throw IllegalStateException only when they use static state.
*
+ *
* Why do we deviate here? The answer: We want for fluentFuture.getDone() to throw the same
* exception as Futures.getDone(fluentFuture).
*/
@@ -1194,9 +1135,8 @@
@Beta
@CanIgnoreReturnValue
@GwtIncompatible // reflection
- @ParametricNullness
- public static <V extends @Nullable Object, X extends Exception> V getChecked(
- Future<V> future, Class<X> exceptionClass) throws X {
+ public static <V, X extends Exception> V getChecked(Future<V> future, Class<X> exceptionClass)
+ throws X {
return FuturesGetChecked.getChecked(future, exceptionClass);
}
@@ -1247,8 +1187,7 @@
@CanIgnoreReturnValue
@GwtIncompatible // reflection
@SuppressWarnings("GoodTime") // should accept a java.time.Duration
- @ParametricNullness
- public static <V extends @Nullable Object, X extends Exception> V getChecked(
+ public static <V, X extends Exception> V getChecked(
Future<V> future, Class<X> exceptionClass, long timeout, TimeUnit unit) throws X {
return FuturesGetChecked.getChecked(future, exceptionClass, timeout, unit);
}
@@ -1288,8 +1227,7 @@
* @since 10.0
*/
@CanIgnoreReturnValue
- @ParametricNullness
- public static <V extends @Nullable Object> V getUnchecked(Future<V> future) {
+ public static <V> V getUnchecked(Future<V> future) {
checkNotNull(future);
try {
return getUninterruptibly(future);
@@ -1319,7 +1257,7 @@
* the computation -- makes sense, and if we don't convert it, the user still has to write a
* try-catch block.
*
- * If you think you would use this method, let us know. You might also look into the
+ * If you think you would use this method, let us know. You might also also look into the
* Fork-Join framework: http://docs.oracle.com/javase/tutorial/essential/concurrency/forkjoin.html
*/
}
diff --git a/android/guava/src/com/google/common/util/concurrent/FuturesGetChecked.java b/android/guava/src/com/google/common/util/concurrent/FuturesGetChecked.java
index 04564f3..a5e9d32 100644
--- a/android/guava/src/com/google/common/util/concurrent/FuturesGetChecked.java
+++ b/android/guava/src/com/google/common/util/concurrent/FuturesGetChecked.java
@@ -23,6 +23,7 @@
import com.google.common.base.Function;
import com.google.common.collect.Ordering;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
+import com.google.j2objc.annotations.J2ObjCIncompatible;
import java.lang.ref.WeakReference;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
@@ -34,25 +35,20 @@
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/** Static methods used to implement {@link Futures#getChecked(Future, Class)}. */
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
final class FuturesGetChecked {
@CanIgnoreReturnValue
- @ParametricNullness
- static <V extends @Nullable Object, X extends Exception> V getChecked(
- Future<V> future, Class<X> exceptionClass) throws X {
+ static <V, X extends Exception> V getChecked(Future<V> future, Class<X> exceptionClass) throws X {
return getChecked(bestGetCheckedTypeValidator(), future, exceptionClass);
}
/** Implementation of {@link Futures#getChecked(Future, Class)}. */
@CanIgnoreReturnValue
@VisibleForTesting
- @ParametricNullness
- static <V extends @Nullable Object, X extends Exception> V getChecked(
+ static <V, X extends Exception> V getChecked(
GetCheckedTypeValidator validator, Future<V> future, Class<X> exceptionClass) throws X {
validator.validateClass(exceptionClass);
try {
@@ -68,8 +64,7 @@
/** Implementation of {@link Futures#getChecked(Future, Class, long, TimeUnit)}. */
@CanIgnoreReturnValue
- @ParametricNullness
- static <V extends @Nullable Object, X extends Exception> V getChecked(
+ static <V, X extends Exception> V getChecked(
Future<V> future, Class<X> exceptionClass, long timeout, TimeUnit unit) throws X {
// TODO(cpovirk): benchmark a version of this method that accepts a GetCheckedTypeValidator
bestGetCheckedTypeValidator().validateClass(exceptionClass);
@@ -100,6 +95,12 @@
return GetCheckedTypeValidatorHolder.WeakSetValidator.INSTANCE;
}
+ @J2ObjCIncompatible // ClassValue
+ @VisibleForTesting
+ static GetCheckedTypeValidator classValueValidator() {
+ return GetCheckedTypeValidatorHolder.ClassValueValidator.INSTANCE;
+ }
+
/**
* Provides a check of whether an exception type is valid for use with {@link
* FuturesGetChecked#getChecked(Future, Class)}, possibly using caching.
@@ -108,8 +109,35 @@
*/
@VisibleForTesting
static class GetCheckedTypeValidatorHolder {
+ static final String CLASS_VALUE_VALIDATOR_NAME =
+ GetCheckedTypeValidatorHolder.class.getName() + "$ClassValueValidator";
+
static final GetCheckedTypeValidator BEST_VALIDATOR = getBestValidator();
+ @IgnoreJRERequirement // getChecked falls back to another implementation if necessary
+ @J2ObjCIncompatible // ClassValue
+ enum ClassValueValidator implements GetCheckedTypeValidator {
+ INSTANCE;
+
+ /*
+ * Static final fields are presumed to be fastest, based on our experience with
+ * UnsignedBytesBenchmark. TODO(cpovirk): benchmark this
+ */
+ private static final ClassValue<Boolean> isValidClass =
+ new ClassValue<Boolean>() {
+ @Override
+ protected Boolean computeValue(Class<?> type) {
+ checkExceptionClassValidity(type.asSubclass(Exception.class));
+ return true;
+ }
+ };
+
+ @Override
+ public void validateClass(Class<? extends Exception> exceptionClass) {
+ isValidClass.get(exceptionClass); // throws if invalid; returns safely (and caches) if valid
+ }
+ }
+
enum WeakSetValidator implements GetCheckedTypeValidator {
INSTANCE;
@@ -156,7 +184,12 @@
* unable to do so.
*/
static GetCheckedTypeValidator getBestValidator() {
- return weakSetValidator();
+ try {
+ Class<?> theClass = Class.forName(CLASS_VALUE_VALIDATOR_NAME);
+ return (GetCheckedTypeValidator) theClass.getEnumConstants()[0];
+ } catch (Throwable t) { // ensure we really catch *everything*
+ return weakSetValidator();
+ }
}
}
@@ -192,7 +225,7 @@
@SuppressWarnings({"unchecked", "rawtypes"})
List<Constructor<X>> constructors = (List) Arrays.asList(exceptionClass.getConstructors());
for (Constructor<X> constructor : preferringStrings(constructors)) {
- X instance = newFromConstructor(constructor, cause);
+ @NullableDecl X instance = newFromConstructor(constructor, cause);
if (instance != null) {
if (instance.getCause() == null) {
instance.initCause(cause);
@@ -223,7 +256,7 @@
})
.reverse();
- @CheckForNull
+ @NullableDecl
private static <X> X newFromConstructor(Constructor<X> constructor, Throwable cause) {
Class<?>[] paramTypes = constructor.getParameterTypes();
Object[] params = new Object[paramTypes.length];
diff --git a/android/guava/src/com/google/common/util/concurrent/GwtFluentFutureCatchingSpecialization.java b/android/guava/src/com/google/common/util/concurrent/GwtFluentFutureCatchingSpecialization.java
index d29a673..e8acf62 100644
--- a/android/guava/src/com/google/common/util/concurrent/GwtFluentFutureCatchingSpecialization.java
+++ b/android/guava/src/com/google/common/util/concurrent/GwtFluentFutureCatchingSpecialization.java
@@ -15,7 +15,6 @@
package com.google.common.util.concurrent;
import com.google.common.annotations.GwtCompatible;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Hidden superclass of {@link FluentFuture} that provides us a place to declare special GWT
@@ -23,9 +22,7 @@
* FluentFuture.catching} family of methods. Those versions have slightly different signatures.
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
-abstract class GwtFluentFutureCatchingSpecialization<V extends @Nullable Object>
- extends AbstractFuture<V> {
+abstract class GwtFluentFutureCatchingSpecialization<V> extends AbstractFuture<V> {
/*
* This server copy of the class is empty. The corresponding GWT copy contains alternative
* versions of catching() and catchingAsync() with slightly different signatures from the ones
diff --git a/android/guava/src/com/google/common/util/concurrent/GwtFuturesCatchingSpecialization.java b/android/guava/src/com/google/common/util/concurrent/GwtFuturesCatchingSpecialization.java
index 95131ce..4626ce9 100644
--- a/android/guava/src/com/google/common/util/concurrent/GwtFuturesCatchingSpecialization.java
+++ b/android/guava/src/com/google/common/util/concurrent/GwtFuturesCatchingSpecialization.java
@@ -23,7 +23,6 @@
* different signatures.
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
abstract class GwtFuturesCatchingSpecialization {
/*
* This server copy of the class is empty. The corresponding GWT copy contains alternative
diff --git a/android/guava/src/com/google/common/util/concurrent/IgnoreJRERequirement.java b/android/guava/src/com/google/common/util/concurrent/IgnoreJRERequirement.java
new file mode 100644
index 0000000..b557ac6
--- /dev/null
+++ b/android/guava/src/com/google/common/util/concurrent/IgnoreJRERequirement.java
@@ -0,0 +1,17 @@
+/*
+ * Copyright 2019 The Guava Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package com.google.common.util.concurrent;
+
+@interface IgnoreJRERequirement {}
diff --git a/android/guava/src/com/google/common/util/concurrent/ImmediateFuture.java b/android/guava/src/com/google/common/util/concurrent/ImmediateFuture.java
index 81912f5..89b168b 100644
--- a/android/guava/src/com/google/common/util/concurrent/ImmediateFuture.java
+++ b/android/guava/src/com/google/common/util/concurrent/ImmediateFuture.java
@@ -23,20 +23,19 @@
import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
import java.util.logging.Logger;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/** Implementation of {@link Futures#immediateFuture}. */
@GwtCompatible
-@ElementTypesAreNonnullByDefault
// TODO(cpovirk): Make this final (but that may break Mockito spy calls).
-class ImmediateFuture<V extends @Nullable Object> implements ListenableFuture<V> {
- static final ListenableFuture<?> NULL = new ImmediateFuture<@Nullable Object>(null);
+class ImmediateFuture<V> implements ListenableFuture<V> {
+ static final ListenableFuture<?> NULL = new ImmediateFuture<>(null);
private static final Logger log = Logger.getLogger(ImmediateFuture.class.getName());
- @ParametricNullness private final V value;
+ @NullableDecl private final V value;
- ImmediateFuture(@ParametricNullness V value) {
+ ImmediateFuture(@NullableDecl V value) {
this.value = value;
}
@@ -63,13 +62,11 @@
// TODO(lukes): Consider throwing InterruptedException when appropriate.
@Override
- @ParametricNullness
public V get() {
return value;
}
@Override
- @ParametricNullness
public V get(long timeout, TimeUnit unit) throws ExecutionException {
checkNotNull(unit);
return get();
@@ -91,13 +88,13 @@
return super.toString() + "[status=SUCCESS, result=[" + value + "]]";
}
- static final class ImmediateFailedFuture<V extends @Nullable Object> extends TrustedFuture<V> {
+ static final class ImmediateFailedFuture<V> extends TrustedFuture<V> {
ImmediateFailedFuture(Throwable thrown) {
setException(thrown);
}
}
- static final class ImmediateCancelledFuture<V extends @Nullable Object> extends TrustedFuture<V> {
+ static final class ImmediateCancelledFuture<V> extends TrustedFuture<V> {
ImmediateCancelledFuture() {
cancel(false);
}
diff --git a/android/guava/src/com/google/common/util/concurrent/InterruptibleTask.java b/android/guava/src/com/google/common/util/concurrent/InterruptibleTask.java
index 168adf2..acebae4 100644
--- a/android/guava/src/com/google/common/util/concurrent/InterruptibleTask.java
+++ b/android/guava/src/com/google/common/util/concurrent/InterruptibleTask.java
@@ -14,26 +14,20 @@
package com.google.common.util.concurrent;
-import static com.google.common.util.concurrent.NullnessCasts.uncheckedCastNullableTToT;
-
import com.google.common.annotations.GwtCompatible;
-import com.google.common.annotations.VisibleForTesting;
import com.google.j2objc.annotations.ReflectionSupport;
import java.util.concurrent.atomic.AtomicReference;
-import java.util.concurrent.locks.AbstractOwnableSynchronizer;
import java.util.concurrent.locks.LockSupport;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
@GwtCompatible(emulated = true)
@ReflectionSupport(value = ReflectionSupport.Level.FULL)
-@ElementTypesAreNonnullByDefault
// Some Android 5.0.x Samsung devices have bugs in JDK reflection APIs that cause
// getDeclaredField to throw a NoSuchFieldException when the field is definitely there.
// Since this class only needs CAS on one field, we can avoid this bug by extending AtomicReference
// instead of using an AtomicReferenceFieldUpdater. This reference stores Thread instances
// and DONE/INTERRUPTED - they have a common ancestor of Runnable.
-abstract class InterruptibleTask<T extends @Nullable Object>
- extends AtomicReference<@Nullable Runnable> implements Runnable {
+abstract class InterruptibleTask<T> extends AtomicReference<Runnable> implements Runnable {
static {
// Prevent rare disastrous classloading in first call to LockSupport.park.
// See: https://bugs.openjdk.java.net/browse/JDK-8074773
@@ -48,6 +42,7 @@
// The thread executing the task publishes itself to the superclass' reference and the thread
// interrupting sets DONE when it has finished interrupting.
private static final Runnable DONE = new DoNothingRunnable();
+ private static final Runnable INTERRUPTING = new DoNothingRunnable();
private static final Runnable PARKED = new DoNothingRunnable();
// Why 1000? WHY NOT!
private static final int MAX_BUSY_WAIT_SPINS = 1000;
@@ -78,85 +73,68 @@
} finally {
// Attempt to set the task as done so that further attempts to interrupt will fail.
if (!compareAndSet(currentThread, DONE)) {
- waitForInterrupt(currentThread);
+ // If we were interrupted, it is possible that the interrupted bit hasn't been set yet. Wait
+ // for the interrupting thread to set DONE. See interruptTask().
+ // We want to wait so that we don't interrupt the _next_ thing run on the thread.
+ // Note: We don't reset the interrupted bit, just wait for it to be set.
+ // If this is a thread pool thread, the thread pool will reset it for us. Otherwise, the
+ // interrupted bit may have been intended for something else, so don't clear it.
+ boolean restoreInterruptedBit = false;
+ int spinCount = 0;
+ // Interrupting Cow Says:
+ // ______
+ // < Spin >
+ // ------
+ // \ ^__^
+ // \ (oo)\_______
+ // (__)\ )\/\
+ // ||----w |
+ // || ||
+ Runnable state = get();
+ while (state == INTERRUPTING || state == PARKED) {
+ spinCount++;
+ if (spinCount > MAX_BUSY_WAIT_SPINS) {
+ // If we have spun a lot just park ourselves.
+ // This will save CPU while we wait for a slow interrupting thread. In theory
+ // interruptTask() should be very fast but due to InterruptibleChannel and
+ // JavaLangAccess.blockedOn(Thread, Interruptible), it isn't predictable what work might
+ // be done. (e.g. close a file and flush buffers to disk). To protect ourselve from
+ // this we park ourselves and tell our interrupter that we did so.
+ if (state == PARKED || compareAndSet(INTERRUPTING, PARKED)) {
+ // Interrupting Cow Says:
+ // ______
+ // < Park >
+ // ------
+ // \ ^__^
+ // \ (oo)\_______
+ // (__)\ )\/\
+ // ||----w |
+ // || ||
+ // We need to clear the interrupted bit prior to calling park and maintain it in case
+ // we wake up spuriously.
+ restoreInterruptedBit = Thread.interrupted() || restoreInterruptedBit;
+ LockSupport.park(this);
+ }
+ } else {
+ Thread.yield();
+ }
+ state = get();
+ }
+ if (restoreInterruptedBit) {
+ currentThread.interrupt();
+ }
+ /*
+ * TODO(cpovirk): Clear interrupt status here? We currently don't, which means that an
+ * interrupt before, during, or after runInterruptibly() (unless it produced an
+ * InterruptedException caught above) can linger and affect listeners.
+ */
}
if (run) {
- if (error == null) {
- // The cast is safe because of the `run` and `error` checks.
- afterRanInterruptiblySuccess(uncheckedCastNullableTToT(result));
- } else {
- afterRanInterruptiblyFailure(error);
- }
+ afterRanInterruptibly(result, error);
}
}
}
- private void waitForInterrupt(Thread currentThread) {
- /*
- * If someone called cancel(true), it is possible that the interrupted bit hasn't been set yet.
- * Wait for the interrupting thread to set DONE. (See interruptTask().) We want to wait so that
- * the interrupting thread doesn't interrupt the _next_ thing to run on this thread.
- *
- * Note: We don't reset the interrupted bit, just wait for it to be set. If this is a thread
- * pool thread, the thread pool will reset it for us. Otherwise, the interrupted bit may have
- * been intended for something else, so don't clear it.
- */
- boolean restoreInterruptedBit = false;
- int spinCount = 0;
- // Interrupting Cow Says:
- // ______
- // < Spin >
- // ------
- // \ ^__^
- // \ (oo)\_______
- // (__)\ )\/\
- // ||----w |
- // || ||
- Runnable state = get();
- Blocker blocker = null;
- while (state instanceof Blocker || state == PARKED) {
- if (state instanceof Blocker) {
- blocker = (Blocker) state;
- }
- spinCount++;
- if (spinCount > MAX_BUSY_WAIT_SPINS) {
- /*
- * If we have spun a lot, just park ourselves. This will save CPU while we wait for a slow
- * interrupting thread. In theory, interruptTask() should be very fast, but due to
- * InterruptibleChannel and JavaLangAccess.blockedOn(Thread, Interruptible), it isn't
- * predictable what work might be done. (e.g., close a file and flush buffers to disk). To
- * protect ourselves from this, we park ourselves and tell our interrupter that we did so.
- */
- if (state == PARKED || compareAndSet(state, PARKED)) {
- // Interrupting Cow Says:
- // ______
- // < Park >
- // ------
- // \ ^__^
- // \ (oo)\_______
- // (__)\ )\/\
- // ||----w |
- // || ||
- // We need to clear the interrupted bit prior to calling park and maintain it in case we
- // wake up spuriously.
- restoreInterruptedBit = Thread.interrupted() || restoreInterruptedBit;
- LockSupport.park(blocker);
- }
- } else {
- Thread.yield();
- }
- state = get();
- }
- if (restoreInterruptedBit) {
- currentThread.interrupt();
- }
- /*
- * TODO(cpovirk): Clear interrupt status here? We currently don't, which means that an interrupt
- * before, during, or after runInterruptibly() (unless it produced an InterruptedException
- * caught above) can linger and affect listeners.
- */
- }
-
/**
* Called before runInterruptibly - if true, runInterruptibly and afterRanInterruptibly will not
* be called.
@@ -167,20 +145,13 @@
* Do interruptible work here - do not complete Futures here, as their listeners could be
* interrupted.
*/
- @ParametricNullness
abstract T runInterruptibly() throws Exception;
/**
* Any interruption that happens as a result of calling interruptTask will arrive before this
* method is called. Complete Futures here.
*/
- abstract void afterRanInterruptiblySuccess(@ParametricNullness T result);
-
- /**
- * Any interruption that happens as a result of calling interruptTask will arrive before this
- * method is called. Complete Futures here.
- */
- abstract void afterRanInterruptiblyFailure(Throwable error);
+ abstract void afterRanInterruptibly(@NullableDecl T result, @NullableDecl Throwable error);
/**
* Interrupts the running task. Because this internally calls {@link Thread#interrupt()} which can
@@ -191,59 +162,29 @@
// in this CAS, there's no risk of interrupting the wrong thread or interrupting a thread that
// isn't currently executing this task.
Runnable currentRunner = get();
- if (currentRunner instanceof Thread) {
- Blocker blocker = new Blocker(this);
- blocker.setOwner(Thread.currentThread());
- if (compareAndSet(currentRunner, blocker)) {
- // Thread.interrupt can throw arbitrary exceptions due to the nio InterruptibleChannel API
- // This will make sure that tasks don't get stuck busy waiting.
- // Some of this is fixed in jdk11 (see https://bugs.openjdk.java.net/browse/JDK-8198692) but
- // not all. See the test cases for examples on how this can happen.
- try {
- ((Thread) currentRunner).interrupt();
- } finally {
- Runnable prev = getAndSet(DONE);
- if (prev == PARKED) {
- LockSupport.unpark((Thread) currentRunner);
- }
+ if (currentRunner instanceof Thread && compareAndSet(currentRunner, INTERRUPTING)) {
+ // Thread.interrupt can throw aribitrary exceptions due to the nio InterruptibleChannel API
+ // This will make sure that tasks don't get stuck busy waiting.
+ // Some of this is fixed in jdk11 (see https://bugs.openjdk.java.net/browse/JDK-8198692) but
+ // not all. See the test cases for examples on how this can happen.
+ try {
+ ((Thread) currentRunner).interrupt();
+ } finally {
+ Runnable prev = getAndSet(DONE);
+ if (prev == PARKED) {
+ LockSupport.unpark((Thread) currentRunner);
}
}
}
}
- /**
- * Using this as the blocker object allows introspection and debugging tools to see that the
- * currentRunner thread is blocked on the progress of the interruptor thread, which can help
- * identify deadlocks.
- */
- @VisibleForTesting
- static final class Blocker extends AbstractOwnableSynchronizer implements Runnable {
- private final InterruptibleTask<?> task;
-
- private Blocker(InterruptibleTask<?> task) {
- this.task = task;
- }
-
- @Override
- public void run() {}
-
- private void setOwner(Thread thread) {
- super.setExclusiveOwnerThread(thread);
- }
-
- @Override
- public String toString() {
- return task.toString();
- }
- }
-
@Override
public final String toString() {
Runnable state = get();
final String result;
if (state == DONE) {
result = "running=[DONE]";
- } else if (state instanceof Blocker) {
+ } else if (state == INTERRUPTING) {
result = "running=[INTERRUPTED]";
} else if (state instanceof Thread) {
// getName is final on Thread, no need to worry about exceptions
diff --git a/android/guava/src/com/google/common/util/concurrent/JdkFutureAdapters.java b/android/guava/src/com/google/common/util/concurrent/JdkFutureAdapters.java
index 82f8d95..1b84302 100644
--- a/android/guava/src/com/google/common/util/concurrent/JdkFutureAdapters.java
+++ b/android/guava/src/com/google/common/util/concurrent/JdkFutureAdapters.java
@@ -24,7 +24,6 @@
import java.util.concurrent.Future;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.atomic.AtomicBoolean;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Utilities necessary for working with libraries that supply plain {@link Future} instances. Note
@@ -36,7 +35,6 @@
*/
@Beta
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public final class JdkFutureAdapters {
/**
* Assigns a thread to the given {@link Future} to provide {@link ListenableFuture} functionality.
@@ -51,8 +49,7 @@
* ListenableFutureTask}, {@link AbstractFuture}, and other utilities over creating plain {@code
* Future} instances to be upgraded to {@code ListenableFuture} after the fact.
*/
- public static <V extends @Nullable Object> ListenableFuture<V> listenInPoolThread(
- Future<V> future) {
+ public static <V> ListenableFuture<V> listenInPoolThread(Future<V> future) {
if (future instanceof ListenableFuture) {
return (ListenableFuture<V>) future;
}
@@ -79,8 +76,7 @@
*
* @since 12.0
*/
- public static <V extends @Nullable Object> ListenableFuture<V> listenInPoolThread(
- Future<V> future, Executor executor) {
+ public static <V> ListenableFuture<V> listenInPoolThread(Future<V> future, Executor executor) {
checkNotNull(executor);
if (future instanceof ListenableFuture) {
return (ListenableFuture<V>) future;
@@ -97,8 +93,8 @@
* <p>If the delegate future is interrupted or throws an unexpected unchecked exception, the
* listeners will not be invoked.
*/
- private static class ListenableFutureAdapter<V extends @Nullable Object>
- extends ForwardingFuture<V> implements ListenableFuture<V> {
+ private static class ListenableFutureAdapter<V> extends ForwardingFuture<V>
+ implements ListenableFuture<V> {
private static final ThreadFactory threadFactory =
new ThreadFactoryBuilder()
diff --git a/android/guava/src/com/google/common/util/concurrent/ListenableFuture.java b/android/guava/src/com/google/common/util/concurrent/ListenableFuture.java
index cf0199a..98e31ed 100644
--- a/android/guava/src/com/google/common/util/concurrent/ListenableFuture.java
+++ b/android/guava/src/com/google/common/util/concurrent/ListenableFuture.java
@@ -18,7 +18,6 @@
import java.util.concurrent.Executor;
import java.util.concurrent.Future;
import java.util.concurrent.RejectedExecutionException;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* A {@link Future} that accepts completion listeners. Each listener has an associated executor, and
@@ -100,32 +99,8 @@
* @author Nishant Thakkar
* @since 1.0
*/
-/*
- * Some of the annotations below were added after we released our separate
- * com.google.guava:listenablefuture:1.0 artifact. (For more on that artifact, see
- * https://github.com/google/guava/releases/tag/v27.0) This means that the copy of ListenableFuture
- * in com.google.guava:guava differs from the "frozen" copy in the listenablefuture artifact. This
- * could in principle cause problems for some users. Still, we expect that the benefits of the
- * nullness annotations in particular will outweigh the costs. (And it's worth noting that we have
- * released multiple ListenableFuture.class files that are not byte-for-byte compatible even from
- * the beginning, thanks to using different `-source -target` values for compiling our `-jre` and
- * `-android` "flavors.")
- *
- * (We could consider releasing a listenablefuture:1.0.1 someday. But we would want to look into how
- * that affects users, especially users of the Android Gradle Plugin, since the plugin developers
- * put in a special hack for us: https://issuetracker.google.com/issues/131431257)
- */
@DoNotMock("Use the methods in Futures (like immediateFuture) or SettableFuture")
-/*
- * It would make sense to also annotate this class with @ElementTypesAreNonnullByDefault. However,
- * it makes no difference because this class is already covered by the package-level
- * @ParametersAreNonnullByDefault, and this class declares only parameters, not return types or
- * fields. (Not to mention that we'll be removing all @*AreNonnullByDefault annotations after tools
- * understand .) And it's fortunate that the annotation makes no difference, because
- * we're seeing a breakage internally when we add that annotation :)
- *
- */
-public interface ListenableFuture<V extends @Nullable Object> extends Future<V> {
+public interface ListenableFuture<V> extends Future<V> {
/**
* Registers a listener to be {@linkplain Executor#execute(Runnable) run} on the given executor.
* The listener will run when the {@code Future}'s computation is {@linkplain Future#isDone()
diff --git a/android/guava/src/com/google/common/util/concurrent/ListenableFutureTask.java b/android/guava/src/com/google/common/util/concurrent/ListenableFutureTask.java
index 9fdcc53..9f6f7e3 100644
--- a/android/guava/src/com/google/common/util/concurrent/ListenableFutureTask.java
+++ b/android/guava/src/com/google/common/util/concurrent/ListenableFutureTask.java
@@ -25,7 +25,7 @@
import java.util.concurrent.FutureTask;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* A {@link FutureTask} that also implements the {@link ListenableFuture} interface. Unlike {@code
@@ -41,9 +41,7 @@
* @since 1.0
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
-public class ListenableFutureTask<V extends @Nullable Object> extends FutureTask<V>
- implements ListenableFuture<V> {
+public class ListenableFutureTask<V> extends FutureTask<V> implements ListenableFuture<V> {
// TODO(cpovirk): explore ways of making ListenableFutureTask final. There are some valid reasons
// such as BoundedQueueExecutorService to allow extends but it would be nice to make it final to
// avoid unintended usage.
@@ -58,7 +56,7 @@
* @param callable the callable task
* @since 10.0
*/
- public static <V extends @Nullable Object> ListenableFutureTask<V> create(Callable<V> callable) {
+ public static <V> ListenableFutureTask<V> create(Callable<V> callable) {
return new ListenableFutureTask<V>(callable);
}
@@ -72,8 +70,7 @@
* ListenableFutureTask.create(runnable, null)}
* @since 10.0
*/
- public static <V extends @Nullable Object> ListenableFutureTask<V> create(
- Runnable runnable, @ParametricNullness V result) {
+ public static <V> ListenableFutureTask<V> create(Runnable runnable, @NullableDecl V result) {
return new ListenableFutureTask<V>(runnable, result);
}
@@ -81,7 +78,7 @@
super(callable);
}
- ListenableFutureTask(Runnable runnable, @ParametricNullness V result) {
+ ListenableFutureTask(Runnable runnable, @NullableDecl V result) {
super(runnable, result);
}
@@ -92,7 +89,6 @@
@CanIgnoreReturnValue
@Override
- @ParametricNullness
public V get(long timeout, TimeUnit unit)
throws TimeoutException, InterruptedException, ExecutionException {
diff --git a/android/guava/src/com/google/common/util/concurrent/ListenableScheduledFuture.java b/android/guava/src/com/google/common/util/concurrent/ListenableScheduledFuture.java
index e5aa5e3..77fa5f7 100644
--- a/android/guava/src/com/google/common/util/concurrent/ListenableScheduledFuture.java
+++ b/android/guava/src/com/google/common/util/concurrent/ListenableScheduledFuture.java
@@ -17,7 +17,6 @@
import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtCompatible;
import java.util.concurrent.ScheduledFuture;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Helper interface to implement both {@link ListenableFuture} and {@link ScheduledFuture}.
@@ -27,6 +26,4 @@
*/
@Beta
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-public interface ListenableScheduledFuture<V extends @Nullable Object>
- extends ScheduledFuture<V>, ListenableFuture<V> {}
+public interface ListenableScheduledFuture<V> extends ScheduledFuture<V>, ListenableFuture<V> {}
diff --git a/android/guava/src/com/google/common/util/concurrent/ListenerCallQueue.java b/android/guava/src/com/google/common/util/concurrent/ListenerCallQueue.java
index ed8c906..ee6b5b9 100644
--- a/android/guava/src/com/google/common/util/concurrent/ListenerCallQueue.java
+++ b/android/guava/src/com/google/common/util/concurrent/ListenerCallQueue.java
@@ -53,7 +53,6 @@
* #dispatch} is expected to be called concurrently, it is idempotent.
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
final class ListenerCallQueue<L> {
// TODO(cpovirk): consider using the logger associated with listener.getClass().
private static final Logger logger = Logger.getLogger(ListenerCallQueue.class.getName());
@@ -124,7 +123,7 @@
/**
* A special purpose queue/executor that dispatches listener events serially on a configured
- * executor. Each event can be added and dispatched as separate phases.
+ * executor. Each event event can be added and dispatched as separate phases.
*
* <p>This class is very similar to {@link SequentialExecutor} with the exception that events can
* be added without necessarily executing immediately.
diff --git a/android/guava/src/com/google/common/util/concurrent/ListeningExecutorService.java b/android/guava/src/com/google/common/util/concurrent/ListeningExecutorService.java
index 83ea759..469eb67 100644
--- a/android/guava/src/com/google/common/util/concurrent/ListeningExecutorService.java
+++ b/android/guava/src/com/google/common/util/concurrent/ListeningExecutorService.java
@@ -23,7 +23,6 @@
import java.util.concurrent.Future;
import java.util.concurrent.RejectedExecutionException;
import java.util.concurrent.TimeUnit;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* An {@link ExecutorService} that returns {@link ListenableFuture} instances. To create an instance
@@ -37,14 +36,13 @@
"Use TestingExecutors.sameThreadScheduledExecutor, or wrap a real Executor from "
+ "java.util.concurrent.Executors with MoreExecutors.listeningDecorator")
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public interface ListeningExecutorService extends ExecutorService {
/**
* @return a {@code ListenableFuture} representing pending completion of the task
* @throws RejectedExecutionException {@inheritDoc}
*/
@Override
- <T extends @Nullable Object> ListenableFuture<T> submit(Callable<T> task);
+ <T> ListenableFuture<T> submit(Callable<T> task);
/**
* @return a {@code ListenableFuture} representing pending completion of the task
@@ -58,8 +56,7 @@
* @throws RejectedExecutionException {@inheritDoc}
*/
@Override
- <T extends @Nullable Object> ListenableFuture<T> submit(
- Runnable task, @ParametricNullness T result);
+ <T> ListenableFuture<T> submit(Runnable task, T result);
/**
* {@inheritDoc}
@@ -80,7 +77,7 @@
* @throws NullPointerException if any task is null
*/
@Override
- <T extends @Nullable Object> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks)
+ <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks)
throws InterruptedException;
/**
@@ -103,7 +100,7 @@
* @throws NullPointerException if any task is null
*/
@Override
- <T extends @Nullable Object> List<Future<T>> invokeAll(
+ <T> List<Future<T>> invokeAll(
Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit)
throws InterruptedException;
}
diff --git a/android/guava/src/com/google/common/util/concurrent/ListeningScheduledExecutorService.java b/android/guava/src/com/google/common/util/concurrent/ListeningScheduledExecutorService.java
index a6be949..959a2fc 100644
--- a/android/guava/src/com/google/common/util/concurrent/ListeningScheduledExecutorService.java
+++ b/android/guava/src/com/google/common/util/concurrent/ListeningScheduledExecutorService.java
@@ -18,7 +18,6 @@
import java.util.concurrent.Callable;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* A {@link ScheduledExecutorService} that returns {@link ListenableFuture} instances from its
@@ -30,7 +29,6 @@
* @since 10.0
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public interface ListeningScheduledExecutorService
extends ScheduledExecutorService, ListeningExecutorService {
@@ -40,8 +38,7 @@
/** @since 15.0 (previously returned ScheduledFuture) */
@Override
- <V extends @Nullable Object> ListenableScheduledFuture<V> schedule(
- Callable<V> callable, long delay, TimeUnit unit);
+ <V> ListenableScheduledFuture<V> schedule(Callable<V> callable, long delay, TimeUnit unit);
/** @since 15.0 (previously returned ScheduledFuture) */
@Override
diff --git a/android/guava/src/com/google/common/util/concurrent/Monitor.java b/android/guava/src/com/google/common/util/concurrent/Monitor.java
index d88a8bc..27ee85d 100644
--- a/android/guava/src/com/google/common/util/concurrent/Monitor.java
+++ b/android/guava/src/com/google/common/util/concurrent/Monitor.java
@@ -24,7 +24,7 @@
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.ReentrantLock;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* A synchronization abstraction supporting waiting on arbitrary boolean conditions.
@@ -200,7 +200,6 @@
@Beta
@GwtIncompatible
@SuppressWarnings("GuardedBy") // TODO(b/35466881): Fix or suppress.
-@ElementTypesAreNonnullByDefault
public final class Monitor {
// TODO(user): Use raw LockSupport or AbstractQueuedSynchronizer instead of ReentrantLock.
// TODO(user): "Port" jsr166 tests for ReentrantLock.
@@ -312,7 +311,7 @@
/** The next active guard */
@GuardedBy("monitor.lock")
- @CheckForNull
+ @NullableDecl
Guard next;
protected Guard(Monitor monitor) {
@@ -339,7 +338,6 @@
* A linked list threaded through the Guard.next field.
*/
@GuardedBy("lock")
- @CheckForNull
private Guard activeGuards = null;
/**
diff --git a/android/guava/src/com/google/common/util/concurrent/MoreExecutors.java b/android/guava/src/com/google/common/util/concurrent/MoreExecutors.java
index eaf6501..584e27a 100644
--- a/android/guava/src/com/google/common/util/concurrent/MoreExecutors.java
+++ b/android/guava/src/com/google/common/util/concurrent/MoreExecutors.java
@@ -49,7 +49,6 @@
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Factory and utility methods for {@link java.util.concurrent.Executor}, {@link ExecutorService},
@@ -61,7 +60,6 @@
* @since 3.0
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
public final class MoreExecutors {
private MoreExecutors() {}
@@ -394,12 +392,6 @@
* (In simple cases, callers can avoid this by registering all tasks with the same {@link
* MoreExecutors#newSequentialExecutor} wrapper around {@code directExecutor()}. More
* complex cases may require using thread pools or making deeper changes.)
- * <li>If an exception propagates out of a {@code Runnable}, it is not necessarily seen by any
- * {@code UncaughtExceptionHandler} for the thread. For example, if the callback passed to
- * {@link Futures#addCallback} throws an exception, that exception will be typically be
- * logged by the {@link ListenableFuture} implementation, even if the thread is configured
- * to do something different. In other cases, no code will catch the exception, and it may
- * terminate whichever thread happens to trigger the execution.
* </ul>
*
* Additionally, beware of executing tasks with {@code directExecutor} while holding a lock. Since
@@ -419,6 +411,7 @@
* <p>This should be preferred to {@link #newDirectExecutorService()} because implementing the
* {@link ExecutorService} subinterface necessitates significant performance overhead.
*
+ *
* @since 18.0
*/
public static Executor directExecutor() {
@@ -557,11 +550,6 @@
public final void execute(Runnable command) {
delegate.execute(command);
}
-
- @Override
- public final String toString() {
- return super.toString() + "[" + delegate + "]";
- }
}
@GwtIncompatible // TODO
@@ -577,14 +565,13 @@
@Override
public ListenableScheduledFuture<?> schedule(Runnable command, long delay, TimeUnit unit) {
- TrustedListenableFutureTask<@Nullable Void> task =
- TrustedListenableFutureTask.create(command, null);
+ TrustedListenableFutureTask<Void> task = TrustedListenableFutureTask.create(command, null);
ScheduledFuture<?> scheduled = delegate.schedule(task, delay, unit);
- return new ListenableScheduledTask<@Nullable Void>(task, scheduled);
+ return new ListenableScheduledTask<>(task, scheduled);
}
@Override
- public <V extends @Nullable Object> ListenableScheduledFuture<V> schedule(
+ public <V> ListenableScheduledFuture<V> schedule(
Callable<V> callable, long delay, TimeUnit unit) {
TrustedListenableFutureTask<V> task = TrustedListenableFutureTask.create(callable);
ScheduledFuture<?> scheduled = delegate.schedule(task, delay, unit);
@@ -596,7 +583,7 @@
Runnable command, long initialDelay, long period, TimeUnit unit) {
NeverSuccessfulListenableFutureTask task = new NeverSuccessfulListenableFutureTask(command);
ScheduledFuture<?> scheduled = delegate.scheduleAtFixedRate(task, initialDelay, period, unit);
- return new ListenableScheduledTask<@Nullable Void>(task, scheduled);
+ return new ListenableScheduledTask<>(task, scheduled);
}
@Override
@@ -605,10 +592,10 @@
NeverSuccessfulListenableFutureTask task = new NeverSuccessfulListenableFutureTask(command);
ScheduledFuture<?> scheduled =
delegate.scheduleWithFixedDelay(task, initialDelay, delay, unit);
- return new ListenableScheduledTask<@Nullable Void>(task, scheduled);
+ return new ListenableScheduledTask<>(task, scheduled);
}
- private static final class ListenableScheduledTask<V extends @Nullable Object>
+ private static final class ListenableScheduledTask<V>
extends SimpleForwardingListenableFuture<V> implements ListenableScheduledFuture<V> {
private final ScheduledFuture<?> scheduledDelegate;
@@ -644,7 +631,7 @@
@GwtIncompatible // TODO
private static final class NeverSuccessfulListenableFutureTask
- extends AbstractFuture.TrustedFuture<@Nullable Void> implements Runnable {
+ extends AbstractFuture.TrustedFuture<Void> implements Runnable {
private final Runnable delegate;
public NeverSuccessfulListenableFutureTask(Runnable delegate) {
@@ -660,11 +647,6 @@
throw Throwables.propagate(t);
}
}
-
- @Override
- protected String pendingToString() {
- return "task=[" + delegate + "]";
- }
}
}
@@ -684,9 +666,7 @@
* implementations.
*/
@SuppressWarnings("GoodTime") // should accept a java.time.Duration
- @GwtIncompatible
- @ParametricNullness
- static <T extends @Nullable Object> T invokeAnyImpl(
+ @GwtIncompatible static <T> T invokeAnyImpl(
ListeningExecutorService executorService,
Collection<? extends Callable<T>> tasks,
boolean timed,
@@ -766,7 +746,7 @@
* Submits the task and adds a listener that adds the future to {@code queue} when it completes.
*/
@GwtIncompatible // TODO
- private static <T extends @Nullable Object> ListenableFuture<T> submitAndAddQueueListener(
+ private static <T> ListenableFuture<T> submitAndAddQueueListener(
ListeningExecutorService executorService,
Callable<T> task,
final BlockingQueue<Future<T>> queue) {
@@ -878,6 +858,7 @@
* right before each task is run. The renaming is best effort, if a {@link SecurityManager}
* prevents the renaming then it will be skipped but the tasks will still execute.
*
+ *
* @param executor The executor to decorate
* @param nameSupplier The source of names for each task
*/
@@ -901,6 +882,7 @@
* right before each task is run. The renaming is best effort, if a {@link SecurityManager}
* prevents the renaming then it will be skipped but the tasks will still execute.
*
+ *
* @param service The executor to decorate
* @param nameSupplier The source of names for each task
*/
@@ -911,7 +893,7 @@
checkNotNull(nameSupplier);
return new WrappingExecutorService(service) {
@Override
- protected <T extends @Nullable Object> Callable<T> wrapTask(Callable<T> callable) {
+ protected <T> Callable<T> wrapTask(Callable<T> callable) {
return Callables.threadRenaming(callable, nameSupplier);
}
@@ -930,6 +912,7 @@
* right before each task is run. The renaming is best effort, if a {@link SecurityManager}
* prevents the renaming then it will be skipped but the tasks will still execute.
*
+ *
* @param service The executor to decorate
* @param nameSupplier The source of names for each task
*/
@@ -940,7 +923,7 @@
checkNotNull(nameSupplier);
return new WrappingScheduledExecutorService(service) {
@Override
- protected <T extends @Nullable Object> Callable<T> wrapTask(Callable<T> callable) {
+ protected <T> Callable<T> wrapTask(Callable<T> callable) {
return Callables.threadRenaming(callable, nameSupplier);
}
diff --git a/android/guava/src/com/google/common/util/concurrent/NullnessCasts.java b/android/guava/src/com/google/common/util/concurrent/NullnessCasts.java
deleted file mode 100644
index 0a0d719..0000000
--- a/android/guava/src/com/google/common/util/concurrent/NullnessCasts.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Copyright (C) 2021 The Guava Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
- * or implied. See the License for the specific language governing permissions and limitations under
- * the License.
- */
-
-package com.google.common.util.concurrent;
-
-import com.google.common.annotations.GwtCompatible;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
-
-/** A utility method to perform unchecked casts to suppress errors produced by nullness analyses. */
-@GwtCompatible
-@ElementTypesAreNonnullByDefault
-final class NullnessCasts {
- /**
- * Accepts a {@code @Nullable T} and returns a plain {@code T}, without performing any check that
- * that conversion is safe.
- *
- * <p>This method is intended to help with usages of type parameters that have {@linkplain
- * ParametricNullness parametric nullness}. If a type parameter instead ranges over only non-null
- * types (or if the type is a non-variable type, like {@code String}), then code should almost
- * never use this method, preferring instead to call {@code requireNonNull} so as to benefit from
- * its runtime check.
- *
- * <p>An example use case for this method is in implementing an {@code Iterator<T>} whose {@code
- * next} field is lazily initialized. The type of that field would be {@code @Nullable T}, and the
- * code would be responsible for populating a "real" {@code T} (which might still be the value
- * {@code null}!) before returning it to callers. Depending on how the code is structured, a
- * nullness analysis might not understand that the field has been populated. To avoid that problem
- * without having to add {@code @SuppressWarnings}, the code can call this method.
- *
- * <p>Why <i>not</i> just add {@code SuppressWarnings}? The problem is that this method is
- * typically useful for {@code return} statements. That leaves the code with two options: Either
- * add the suppression to the whole method (which turns off checking for a large section of code),
- * or extract a variable, and put the suppression on that. However, a local variable typically
- * doesn't work: Because nullness analyses typically infer the nullness of local variables,
- * there's no way to assign a {@code @Nullable T} to a field {@code T foo;} and instruct the
- * analysis that that means "plain {@code T}" rather than the inferred type {@code @Nullable T}.
- * (Even if supported added {@code @NonNull}, that would not help, since the problem case
- * addressed by this method is the case in which {@code T} has parametric nullness -- and thus its
- * value may be legitimately {@code null}.)
- */
- @SuppressWarnings("nullness")
- @ParametricNullness
- static <T extends @Nullable Object> T uncheckedCastNullableTToT(@CheckForNull T t) {
- return t;
- }
-
- /**
- * Returns {@code null} cast to any type.
- *
- * <p>This method is intended to help with usages of type parameters that have {@linkplain
- * ParametricNullness parametric nullness}. Sometimes, code may receive a null {@code T} but store
- * a "null sentinel" to take its place. When the time comes to convert it back to a {@code T} to
- * return to a caller, the code needs to a way to return {@code null} from a method that returns
- * "plain {@code T}." This API provides that.
- */
- @SuppressWarnings("nullness")
- @ParametricNullness
- static <T extends @Nullable Object> T uncheckedNull() {
- return null;
- }
-
- private NullnessCasts() {}
-}
diff --git a/android/guava/src/com/google/common/util/concurrent/OverflowAvoidingLockSupport.java b/android/guava/src/com/google/common/util/concurrent/OverflowAvoidingLockSupport.java
index 3038ab7..ae871e0 100644
--- a/android/guava/src/com/google/common/util/concurrent/OverflowAvoidingLockSupport.java
+++ b/android/guava/src/com/google/common/util/concurrent/OverflowAvoidingLockSupport.java
@@ -17,20 +17,19 @@
import static java.lang.Math.min;
import java.util.concurrent.locks.LockSupport;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* Works around an android bug, where parking for more than INT_MAX seconds can produce an abort
* signal on 32 bit devices running Android Q.
*/
-@ElementTypesAreNonnullByDefault
final class OverflowAvoidingLockSupport {
// Represents the max nanoseconds representable on a linux timespec with a 32 bit tv_sec
static final long MAX_NANOSECONDS_THRESHOLD = (1L + Integer.MAX_VALUE) * 1_000_000_000L - 1L;
private OverflowAvoidingLockSupport() {}
- static void parkNanos(@CheckForNull Object blocker, long nanos) {
+ static void parkNanos(@NullableDecl Object blocker, long nanos) {
// Even in the extremely unlikely event that a thread unblocks itself early after only 68 years,
// this is indistinguishable from a spurious wakeup, which LockSupport allows.
LockSupport.parkNanos(blocker, min(nanos, MAX_NANOSECONDS_THRESHOLD));
diff --git a/android/guava/src/com/google/common/util/concurrent/ParametricNullness.java b/android/guava/src/com/google/common/util/concurrent/ParametricNullness.java
deleted file mode 100644
index ebc5928..0000000
--- a/android/guava/src/com/google/common/util/concurrent/ParametricNullness.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2021 The Guava Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.common.util.concurrent;
-
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.PARAMETER;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-import static javax.annotation.meta.When.UNKNOWN;
-
-import com.google.common.annotations.GwtCompatible;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-import javax.annotation.Nonnull;
-import javax.annotation.meta.TypeQualifierNickname;
-
-/**
- * Marks a "top-level" type-variable usage as (a) a Kotlin platform type when the type argument is
- * non-nullable and (b) nullable when the type argument is nullable. This is the closest we can get
- * to "non-nullable when non-nullable; nullable when nullable" (like the Android <a
- * href="https://android.googlesource.com/platform/libcore/+/master/luni/src/main/java/libcore/util/NullFromTypeParam.java">{@code
- * NullFromTypeParam}</a>). We use this to "undo" {@link ElementTypesAreNonnullByDefault}.
- */
-@GwtCompatible
-@Retention(RUNTIME)
-@Target({FIELD, METHOD, PARAMETER})
-@TypeQualifierNickname
-@Nonnull(when = UNKNOWN)
-@interface ParametricNullness {}
diff --git a/android/guava/src/com/google/common/util/concurrent/Partially.java b/android/guava/src/com/google/common/util/concurrent/Partially.java
index 7aa16e7..c40ab4e 100644
--- a/android/guava/src/com/google/common/util/concurrent/Partially.java
+++ b/android/guava/src/com/google/common/util/concurrent/Partially.java
@@ -32,7 +32,6 @@
* version.
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
final class Partially {
/**
* The presence of this annotation on an API indicates that the method <i>may</i> be used with the
diff --git a/android/guava/src/com/google/common/util/concurrent/Platform.java b/android/guava/src/com/google/common/util/concurrent/Platform.java
index cfb96a0..94e6700 100644
--- a/android/guava/src/com/google/common/util/concurrent/Platform.java
+++ b/android/guava/src/com/google/common/util/concurrent/Platform.java
@@ -15,14 +15,13 @@
package com.google.common.util.concurrent;
import com.google.common.annotations.GwtCompatible;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/** Methods factored out so that they can be emulated differently in GWT. */
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
final class Platform {
static boolean isInstanceOfThrowableClass(
- @CheckForNull Throwable t, Class<? extends Throwable> expectedClass) {
+ @NullableDecl Throwable t, Class<? extends Throwable> expectedClass) {
return expectedClass.isInstance(t);
}
diff --git a/android/guava/src/com/google/common/util/concurrent/RateLimiter.java b/android/guava/src/com/google/common/util/concurrent/RateLimiter.java
index 9bcf118..99824ee 100644
--- a/android/guava/src/com/google/common/util/concurrent/RateLimiter.java
+++ b/android/guava/src/com/google/common/util/concurrent/RateLimiter.java
@@ -29,7 +29,7 @@
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import java.util.Locale;
import java.util.concurrent.TimeUnit;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* A rate limiter. Conceptually, a rate limiter distributes permits at a configurable rate. Each
@@ -92,7 +92,6 @@
// would mean a maximum rate of "1MB/s", which might be small in some cases.
@Beta
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public abstract class RateLimiter {
/**
* Creates a {@code RateLimiter} with the specified stable throughput, given as "permits per
@@ -185,7 +184,7 @@
private final SleepingStopwatch stopwatch;
// Can't be initialized in the constructor because mocks don't call the constructor.
- @CheckForNull private volatile Object mutexDoNotUseDirectly;
+ @NullableDecl private volatile Object mutexDoNotUseDirectly;
private Object mutex() {
Object mutex = mutexDoNotUseDirectly;
diff --git a/android/guava/src/com/google/common/util/concurrent/Runnables.java b/android/guava/src/com/google/common/util/concurrent/Runnables.java
index 5503f68..e1ebd23 100644
--- a/android/guava/src/com/google/common/util/concurrent/Runnables.java
+++ b/android/guava/src/com/google/common/util/concurrent/Runnables.java
@@ -24,7 +24,6 @@
*/
@Beta
@GwtCompatible
-@ElementTypesAreNonnullByDefault
public final class Runnables {
private static final Runnable EMPTY_RUNNABLE =
diff --git a/android/guava/src/com/google/common/util/concurrent/SequentialExecutor.java b/android/guava/src/com/google/common/util/concurrent/SequentialExecutor.java
index 052c7e0..5604175 100644
--- a/android/guava/src/com/google/common/util/concurrent/SequentialExecutor.java
+++ b/android/guava/src/com/google/common/util/concurrent/SequentialExecutor.java
@@ -31,7 +31,6 @@
import java.util.concurrent.RejectedExecutionException;
import java.util.logging.Level;
import java.util.logging.Logger;
-import javax.annotation.CheckForNull;
/**
* Executor ensuring that all Runnables submitted are executed in order, using the provided
@@ -48,7 +47,6 @@
* restarted by a call to {@link #execute}.
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
final class SequentialExecutor implements Executor {
private static final Logger log = Logger.getLogger(SequentialExecutor.class.getName());
@@ -93,7 +91,7 @@
* Adds a task to the queue and makes sure a worker thread is running.
*
* <p>If this method throws, e.g. a {@code RejectedExecutionException} from the delegate executor,
- * execution of tasks will stop until a call to this method is made.
+ * execution of tasks will stop until a call to this method or to {@link #resume()} is made.
*/
@Override
public void execute(final Runnable task) {
@@ -172,7 +170,7 @@
/** Worker that runs tasks from {@link #queue} until it is empty. */
private final class QueueWorker implements Runnable {
- @CheckForNull Runnable task;
+ Runnable task;
@Override
public void run() {
diff --git a/android/guava/src/com/google/common/util/concurrent/Service.java b/android/guava/src/com/google/common/util/concurrent/Service.java
index 0999a30..2c6cdab 100644
--- a/android/guava/src/com/google/common/util/concurrent/Service.java
+++ b/android/guava/src/com/google/common/util/concurrent/Service.java
@@ -53,7 +53,6 @@
*/
@DoNotMock("Create an AbstractIdleService")
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public interface Service {
/**
* If the service state is {@link State#NEW}, this initiates service startup and returns
@@ -176,28 +175,61 @@
*/
enum State {
/** A service in this state is inactive. It does minimal work and consumes minimal resources. */
- NEW,
+ NEW {
+ @Override
+ boolean isTerminal() {
+ return false;
+ }
+ },
/** A service in this state is transitioning to {@link #RUNNING}. */
- STARTING,
+ STARTING {
+ @Override
+ boolean isTerminal() {
+ return false;
+ }
+ },
/** A service in this state is operational. */
- RUNNING,
+ RUNNING {
+ @Override
+ boolean isTerminal() {
+ return false;
+ }
+ },
/** A service in this state is transitioning to {@link #TERMINATED}. */
- STOPPING,
+ STOPPING {
+ @Override
+ boolean isTerminal() {
+ return false;
+ }
+ },
/**
* A service in this state has completed execution normally. It does minimal work and consumes
* minimal resources.
*/
- TERMINATED,
+ TERMINATED {
+ @Override
+ boolean isTerminal() {
+ return true;
+ }
+ },
/**
* A service in this state has encountered a problem and may not be operational. It cannot be
* started nor stopped.
*/
- FAILED,
+ FAILED {
+ @Override
+ boolean isTerminal() {
+ return true;
+ }
+ };
+
+ /** Returns true if this state is terminal. */
+ abstract boolean isTerminal();
}
/**
diff --git a/android/guava/src/com/google/common/util/concurrent/ServiceManager.java b/android/guava/src/com/google/common/util/concurrent/ServiceManager.java
index 2e1c21a..e5c5e14 100644
--- a/android/guava/src/com/google/common/util/concurrent/ServiceManager.java
+++ b/android/guava/src/com/google/common/util/concurrent/ServiceManager.java
@@ -118,7 +118,6 @@
* @since 14.0
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public final class ServiceManager implements ServiceManagerBridge {
private static final Logger logger = Logger.getLogger(ServiceManager.class.getName());
private static final ListenerCallQueue.Event<Listener> HEALTHY_EVENT =
@@ -596,9 +595,9 @@
// N.B. There will only be an entry in the map if the service has started
for (Entry<Service, Stopwatch> entry : startupTimers.entrySet()) {
Service service = entry.getKey();
- Stopwatch stopwatch = entry.getValue();
- if (!stopwatch.isRunning() && !(service instanceof NoOpService)) {
- loadTimes.add(Maps.immutableEntry(service, stopwatch.elapsed(MILLISECONDS)));
+ Stopwatch stopWatch = entry.getValue();
+ if (!stopWatch.isRunning() && !(service instanceof NoOpService)) {
+ loadTimes.add(Maps.immutableEntry(service, stopWatch.elapsed(MILLISECONDS)));
}
}
} finally {
diff --git a/android/guava/src/com/google/common/util/concurrent/ServiceManagerBridge.java b/android/guava/src/com/google/common/util/concurrent/ServiceManagerBridge.java
index 7ae430e..a9300a6 100644
--- a/android/guava/src/com/google/common/util/concurrent/ServiceManagerBridge.java
+++ b/android/guava/src/com/google/common/util/concurrent/ServiceManagerBridge.java
@@ -26,7 +26,6 @@
* {@code servicesByState()} to return {@code ImmutableMultimap}.
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
interface ServiceManagerBridge {
ImmutableMultimap<State, Service> servicesByState();
}
diff --git a/android/guava/src/com/google/common/util/concurrent/SettableFuture.java b/android/guava/src/com/google/common/util/concurrent/SettableFuture.java
index 893161e..1c220e6 100644
--- a/android/guava/src/com/google/common/util/concurrent/SettableFuture.java
+++ b/android/guava/src/com/google/common/util/concurrent/SettableFuture.java
@@ -16,7 +16,7 @@
import com.google.common.annotations.GwtCompatible;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* A {@link ListenableFuture} whose result can be set by a {@link #set(Object)}, {@link
@@ -33,19 +33,17 @@
* @since 9.0 (in 1.0 as {@code ValueFuture})
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-public final class SettableFuture<V extends @Nullable Object>
- extends AbstractFuture.TrustedFuture<V> {
+public final class SettableFuture<V> extends AbstractFuture.TrustedFuture<V> {
/**
* Creates a new {@code SettableFuture} that can be completed or cancelled by a later method call.
*/
- public static <V extends @Nullable Object> SettableFuture<V> create() {
+ public static <V> SettableFuture<V> create() {
return new SettableFuture<V>();
}
@CanIgnoreReturnValue
@Override
- public boolean set(@ParametricNullness V value) {
+ public boolean set(@NullableDecl V value) {
return super.set(value);
}
diff --git a/android/guava/src/com/google/common/util/concurrent/SimpleTimeLimiter.java b/android/guava/src/com/google/common/util/concurrent/SimpleTimeLimiter.java
index 5a1969e..9d0b81b 100644
--- a/android/guava/src/com/google/common/util/concurrent/SimpleTimeLimiter.java
+++ b/android/guava/src/com/google/common/util/concurrent/SimpleTimeLimiter.java
@@ -34,8 +34,6 @@
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* A TimeLimiter that runs method calls in the background using an {@link ExecutorService}. If the
@@ -47,7 +45,6 @@
*/
@Beta
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public final class SimpleTimeLimiter implements TimeLimiter {
private final ExecutorService executor;
@@ -88,14 +85,11 @@
InvocationHandler handler =
new InvocationHandler() {
@Override
- @CheckForNull
- public Object invoke(
- Object obj, final Method method, @CheckForNull final @Nullable Object[] args)
+ public Object invoke(Object obj, final Method method, final Object[] args)
throws Throwable {
- Callable<@Nullable Object> callable =
- new Callable<@Nullable Object>() {
+ Callable<Object> callable =
+ new Callable<Object>() {
@Override
- @CheckForNull
public Object call() throws Exception {
try {
return method.invoke(target, args);
@@ -119,7 +113,7 @@
return interfaceType.cast(object);
}
- private <T extends @Nullable Object> T callWithTimeout(
+ private <T> T callWithTimeout(
Callable<T> callable, long timeoutDuration, TimeUnit timeoutUnit, boolean amInterruptible)
throws Exception {
checkNotNull(callable);
@@ -149,8 +143,7 @@
@CanIgnoreReturnValue
@Override
- public <T extends @Nullable Object> T callWithTimeout(
- Callable<T> callable, long timeoutDuration, TimeUnit timeoutUnit)
+ public <T> T callWithTimeout(Callable<T> callable, long timeoutDuration, TimeUnit timeoutUnit)
throws TimeoutException, InterruptedException, ExecutionException {
checkNotNull(callable);
checkNotNull(timeoutUnit);
@@ -171,7 +164,7 @@
@CanIgnoreReturnValue
@Override
- public <T extends @Nullable Object> T callUninterruptiblyWithTimeout(
+ public <T> T callUninterruptiblyWithTimeout(
Callable<T> callable, long timeoutDuration, TimeUnit timeoutUnit)
throws TimeoutException, ExecutionException {
checkNotNull(callable);
diff --git a/android/guava/src/com/google/common/util/concurrent/SmoothRateLimiter.java b/android/guava/src/com/google/common/util/concurrent/SmoothRateLimiter.java
index ca78905..d78d7da 100644
--- a/android/guava/src/com/google/common/util/concurrent/SmoothRateLimiter.java
+++ b/android/guava/src/com/google/common/util/concurrent/SmoothRateLimiter.java
@@ -22,15 +22,14 @@
import java.util.concurrent.TimeUnit;
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
abstract class SmoothRateLimiter extends RateLimiter {
/*
* How is the RateLimiter designed, and why?
*
- * The primary feature of a RateLimiter is its "stable rate", the maximum rate that it should
- * allow in normal conditions. This is enforced by "throttling" incoming requests as needed. For
- * example, we could compute the appropriate throttle time for an incoming request, and make the
- * calling thread wait for that time.
+ * The primary feature of a RateLimiter is its "stable rate", the maximum rate that is should
+ * allow at normal conditions. This is enforced by "throttling" incoming requests as needed, i.e.
+ * compute, for an incoming request, the appropriate throttle time, and make the calling thread
+ * wait as much.
*
* The simplest way to maintain a rate of QPS is to keep the timestamp of the last granted
* request, and ensure that (1/QPS) seconds have elapsed since then. For example, for a rate of
diff --git a/android/guava/src/com/google/common/util/concurrent/Striped.java b/android/guava/src/com/google/common/util/concurrent/Striped.java
index fc8bcd8..c9ba772 100644
--- a/android/guava/src/com/google/common/util/concurrent/Striped.java
+++ b/android/guava/src/com/google/common/util/concurrent/Striped.java
@@ -14,8 +14,6 @@
package com.google.common.util.concurrent;
-import static com.google.common.collect.Lists.newArrayList;
-
import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtIncompatible;
import com.google.common.annotations.VisibleForTesting;
@@ -23,6 +21,7 @@
import com.google.common.base.Preconditions;
import com.google.common.base.Supplier;
import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Iterables;
import com.google.common.collect.MapMaker;
import com.google.common.math.IntMath;
import com.google.common.primitives.Ints;
@@ -41,7 +40,6 @@
import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* A striped {@code Lock/Semaphore/ReadWriteLock}. This offers the underlying lock striping similar
@@ -84,7 +82,6 @@
*/
@Beta
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public abstract class Striped<L> {
/**
* If there are at least this many stripes, we assume the memory usage of a ConcurrentMap will be
@@ -139,26 +136,26 @@
* @return the stripes corresponding to the objects (one per each object, derived by delegating to
* {@link #get(Object)}; may contain duplicates), in an increasing index order.
*/
- public Iterable<L> bulkGet(Iterable<? extends Object> keys) {
- // Initially using the list to store the keys, then reusing it to store the respective L's
- List<Object> result = newArrayList(keys);
- if (result.isEmpty()) {
+ public Iterable<L> bulkGet(Iterable<?> keys) {
+ // Initially using the array to store the keys, then reusing it to store the respective L's
+ final Object[] array = Iterables.toArray(keys, Object.class);
+ if (array.length == 0) {
return ImmutableList.of();
}
- int[] stripes = new int[result.size()];
- for (int i = 0; i < result.size(); i++) {
- stripes[i] = indexFor(result.get(i));
+ int[] stripes = new int[array.length];
+ for (int i = 0; i < array.length; i++) {
+ stripes[i] = indexFor(array[i]);
}
Arrays.sort(stripes);
// optimize for runs of identical stripes
int previousStripe = stripes[0];
- result.set(0, getAt(previousStripe));
- for (int i = 1; i < result.size(); i++) {
+ array[0] = getAt(previousStripe);
+ for (int i = 1; i < array.length; i++) {
int currentStripe = stripes[i];
if (currentStripe == previousStripe) {
- result.set(i, result.get(i - 1));
+ array[i] = array[i - 1];
} else {
- result.set(i, getAt(currentStripe));
+ array[i] = getAt(currentStripe);
previousStripe = currentStripe;
}
}
@@ -180,8 +177,8 @@
* be garbage collected after locking them, ending up in a huge mess.
*/
@SuppressWarnings("unchecked") // we carefully replaced all keys with their respective L's
- List<L> asStripes = (List<L>) result;
- return Collections.unmodifiableList(asStripes);
+ List<L> asList = (List<L>) Arrays.asList(array);
+ return Collections.unmodifiableList(asList);
}
// Static factories
@@ -438,7 +435,7 @@
*/
@VisibleForTesting
static class SmallLazyStriped<L> extends PowerOfTwoStriped<L> {
- final AtomicReferenceArray<@Nullable ArrayReference<? extends L>> locks;
+ final AtomicReferenceArray<ArrayReference<? extends L>> locks;
final Supplier<L> supplier;
final int size;
final ReferenceQueue<L> queue = new ReferenceQueue<L>();
diff --git a/android/guava/src/com/google/common/util/concurrent/ThreadFactoryBuilder.java b/android/guava/src/com/google/common/util/concurrent/ThreadFactoryBuilder.java
index 1027f3c..f09ed4e 100644
--- a/android/guava/src/com/google/common/util/concurrent/ThreadFactoryBuilder.java
+++ b/android/guava/src/com/google/common/util/concurrent/ThreadFactoryBuilder.java
@@ -16,7 +16,6 @@
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
-import static java.util.Objects.requireNonNull;
import com.google.common.annotations.GwtIncompatible;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
@@ -26,7 +25,6 @@
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.atomic.AtomicLong;
-import javax.annotation.CheckForNull;
/**
* A ThreadFactory builder, providing any combination of these features:
@@ -47,13 +45,12 @@
*/
@CanIgnoreReturnValue
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public final class ThreadFactoryBuilder {
- @CheckForNull private String nameFormat = null;
- @CheckForNull private Boolean daemon = null;
- @CheckForNull private Integer priority = null;
- @CheckForNull private UncaughtExceptionHandler uncaughtExceptionHandler = null;
- @CheckForNull private ThreadFactory backingThreadFactory = null;
+ private String nameFormat = null;
+ private Boolean daemon = null;
+ private Integer priority = null;
+ private UncaughtExceptionHandler uncaughtExceptionHandler = null;
+ private ThreadFactory backingThreadFactory = null;
/** Creates a new {@link ThreadFactory} builder. */
public ThreadFactoryBuilder() {}
@@ -165,8 +162,7 @@
public Thread newThread(Runnable runnable) {
Thread thread = backingThreadFactory.newThread(runnable);
if (nameFormat != null) {
- // requireNonNull is safe because we create `count` if (and only if) we have a nameFormat.
- thread.setName(format(nameFormat, requireNonNull(count).getAndIncrement()));
+ thread.setName(format(nameFormat, count.getAndIncrement()));
}
if (daemon != null) {
thread.setDaemon(daemon);
diff --git a/android/guava/src/com/google/common/util/concurrent/TimeLimiter.java b/android/guava/src/com/google/common/util/concurrent/TimeLimiter.java
index 0883bcc..b841517 100644
--- a/android/guava/src/com/google/common/util/concurrent/TimeLimiter.java
+++ b/android/guava/src/com/google/common/util/concurrent/TimeLimiter.java
@@ -22,7 +22,6 @@
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Imposes a time limit on method calls.
@@ -35,7 +34,6 @@
@DoNotMock("Use FakeTimeLimiter")
@GwtIncompatible
@SuppressWarnings("GoodTime") // should have java.time.Duration overloads
-@ElementTypesAreNonnullByDefault
public interface TimeLimiter {
/**
@@ -99,8 +97,7 @@
* @since 22.0
*/
@CanIgnoreReturnValue
- <T extends @Nullable Object> T callWithTimeout(
- Callable<T> callable, long timeoutDuration, TimeUnit timeoutUnit)
+ <T> T callWithTimeout(Callable<T> callable, long timeoutDuration, TimeUnit timeoutUnit)
throws TimeoutException, InterruptedException, ExecutionException;
/**
@@ -123,7 +120,7 @@
* @since 22.0
*/
@CanIgnoreReturnValue
- <T extends @Nullable Object> T callUninterruptiblyWithTimeout(
+ <T> T callUninterruptiblyWithTimeout(
Callable<T> callable, long timeoutDuration, TimeUnit timeoutUnit)
throws TimeoutException, ExecutionException;
diff --git a/android/guava/src/com/google/common/util/concurrent/TimeoutFuture.java b/android/guava/src/com/google/common/util/concurrent/TimeoutFuture.java
index 219a098..a91bf67 100644
--- a/android/guava/src/com/google/common/util/concurrent/TimeoutFuture.java
+++ b/android/guava/src/com/google/common/util/concurrent/TimeoutFuture.java
@@ -24,8 +24,7 @@
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* Implementation of {@code Futures#withTimeout}.
@@ -35,9 +34,8 @@
* interrupted and cancelled if it times out.
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
-final class TimeoutFuture<V extends @Nullable Object> extends FluentFuture.TrustedFuture<V> {
- static <V extends @Nullable Object> ListenableFuture<V> create(
+final class TimeoutFuture<V> extends FluentFuture.TrustedFuture<V> {
+ static <V> ListenableFuture<V> create(
ListenableFuture<V> delegate,
long time,
TimeUnit unit,
@@ -73,16 +71,16 @@
* write-barriers).
*/
- @CheckForNull private ListenableFuture<V> delegateRef;
- @CheckForNull private ScheduledFuture<?> timer;
+ @NullableDecl private ListenableFuture<V> delegateRef;
+ @NullableDecl private ScheduledFuture<?> timer;
private TimeoutFuture(ListenableFuture<V> delegate) {
this.delegateRef = Preconditions.checkNotNull(delegate);
}
/** A runnable that is called when the delegate or the timer completes. */
- private static final class Fire<V extends @Nullable Object> implements Runnable {
- @CheckForNull TimeoutFuture<V> timeoutFutureRef;
+ private static final class Fire<V> implements Runnable {
+ @NullableDecl TimeoutFuture<V> timeoutFutureRef;
Fire(TimeoutFuture<V> timeoutFuture) {
this.timeoutFutureRef = timeoutFuture;
@@ -154,7 +152,6 @@
}
@Override
- @CheckForNull
protected String pendingToString() {
ListenableFuture<? extends V> localInputFuture = delegateRef;
ScheduledFuture<?> localTimer = timer;
diff --git a/android/guava/src/com/google/common/util/concurrent/TrustedListenableFutureTask.java b/android/guava/src/com/google/common/util/concurrent/TrustedListenableFutureTask.java
index a2c2115..3115502 100644
--- a/android/guava/src/com/google/common/util/concurrent/TrustedListenableFutureTask.java
+++ b/android/guava/src/com/google/common/util/concurrent/TrustedListenableFutureTask.java
@@ -21,8 +21,7 @@
import java.util.concurrent.Callable;
import java.util.concurrent.Executors;
import java.util.concurrent.RunnableFuture;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* A {@link RunnableFuture} that also implements the {@link ListenableFuture} interface.
@@ -31,16 +30,14 @@
* performance reasons.
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-class TrustedListenableFutureTask<V extends @Nullable Object> extends FluentFuture.TrustedFuture<V>
+class TrustedListenableFutureTask<V> extends FluentFuture.TrustedFuture<V>
implements RunnableFuture<V> {
- static <V extends @Nullable Object> TrustedListenableFutureTask<V> create(
- AsyncCallable<V> callable) {
+ static <V> TrustedListenableFutureTask<V> create(AsyncCallable<V> callable) {
return new TrustedListenableFutureTask<V>(callable);
}
- static <V extends @Nullable Object> TrustedListenableFutureTask<V> create(Callable<V> callable) {
+ static <V> TrustedListenableFutureTask<V> create(Callable<V> callable) {
return new TrustedListenableFutureTask<V>(callable);
}
@@ -53,8 +50,7 @@
* result, consider using constructions of the form: {@code ListenableFuture<?> f =
* ListenableFutureTask.create(runnable, null)}
*/
- static <V extends @Nullable Object> TrustedListenableFutureTask<V> create(
- Runnable runnable, @ParametricNullness V result) {
+ static <V> TrustedListenableFutureTask<V> create(Runnable runnable, @NullableDecl V result) {
return new TrustedListenableFutureTask<V>(Executors.callable(runnable, result));
}
@@ -65,7 +61,7 @@
* <p>{@code volatile} is required for j2objc transpiling:
* https://developers.google.com/j2objc/guides/j2objc-memory-model#atomicity
*/
- @CheckForNull private volatile InterruptibleTask<?> task;
+ private volatile InterruptibleTask<?> task;
TrustedListenableFutureTask(Callable<V> callable) {
this.task = new TrustedFutureInterruptibleTask(callable);
@@ -77,7 +73,7 @@
@Override
public void run() {
- InterruptibleTask<?> localTask = task;
+ InterruptibleTask localTask = task;
if (localTask != null) {
localTask.run();
}
@@ -93,7 +89,7 @@
super.afterDone();
if (wasInterrupted()) {
- InterruptibleTask<?> localTask = task;
+ InterruptibleTask localTask = task;
if (localTask != null) {
localTask.interruptTask();
}
@@ -103,9 +99,8 @@
}
@Override
- @CheckForNull
protected String pendingToString() {
- InterruptibleTask<?> localTask = task;
+ InterruptibleTask localTask = task;
if (localTask != null) {
return "task=[" + localTask + "]";
}
@@ -126,19 +121,17 @@
}
@Override
- @ParametricNullness
V runInterruptibly() throws Exception {
return callable.call();
}
@Override
- void afterRanInterruptiblySuccess(@ParametricNullness V result) {
- TrustedListenableFutureTask.this.set(result);
- }
-
- @Override
- void afterRanInterruptiblyFailure(Throwable error) {
- setException(error);
+ void afterRanInterruptibly(V result, Throwable error) {
+ if (error == null) {
+ TrustedListenableFutureTask.this.set(result);
+ } else {
+ setException(error);
+ }
}
@Override
@@ -171,13 +164,12 @@
}
@Override
- void afterRanInterruptiblySuccess(ListenableFuture<V> result) {
- setFuture(result);
- }
-
- @Override
- void afterRanInterruptiblyFailure(Throwable error) {
- setException(error);
+ void afterRanInterruptibly(ListenableFuture<V> result, Throwable error) {
+ if (error == null) {
+ setFuture(result);
+ } else {
+ setException(error);
+ }
}
@Override
diff --git a/android/guava/src/com/google/common/util/concurrent/UncaughtExceptionHandlers.java b/android/guava/src/com/google/common/util/concurrent/UncaughtExceptionHandlers.java
index a1add8b..c0c2600 100644
--- a/android/guava/src/com/google/common/util/concurrent/UncaughtExceptionHandlers.java
+++ b/android/guava/src/com/google/common/util/concurrent/UncaughtExceptionHandlers.java
@@ -29,7 +29,6 @@
* @since 8.0
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public final class UncaughtExceptionHandlers {
private UncaughtExceptionHandlers() {}
diff --git a/android/guava/src/com/google/common/util/concurrent/UncheckedExecutionException.java b/android/guava/src/com/google/common/util/concurrent/UncheckedExecutionException.java
index 713f4a6..3dde737 100644
--- a/android/guava/src/com/google/common/util/concurrent/UncheckedExecutionException.java
+++ b/android/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 javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* Unchecked variant of {@link java.util.concurrent.ExecutionException}. As with {@code
@@ -33,29 +33,22 @@
* @since 10.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
public class UncheckedExecutionException extends RuntimeException {
- /*
- * Ideally, this class would have exposed only constructors that require a non-null cause. We
- * might try to move in that direction, but there are complications. See
- * https://github.com/jspecify/nullness-checker-for-checker-framework/blob/61aafa4ae52594830cfc2d61c8b113009dbdb045/src/main/java/com/google/jspecify/nullness/NullSpecTransfer.java#L789
- */
-
/** Creates a new instance with {@code null} as its detail message. */
protected UncheckedExecutionException() {}
/** Creates a new instance with the given detail message. */
- protected UncheckedExecutionException(@CheckForNull String message) {
+ protected UncheckedExecutionException(@NullableDecl String message) {
super(message);
}
/** Creates a new instance with the given detail message and cause. */
- public UncheckedExecutionException(@CheckForNull String message, @CheckForNull Throwable cause) {
+ public UncheckedExecutionException(@NullableDecl String message, @NullableDecl Throwable cause) {
super(message, cause);
}
/** Creates a new instance with the given cause. */
- public UncheckedExecutionException(@CheckForNull Throwable cause) {
+ public UncheckedExecutionException(@NullableDecl Throwable cause) {
super(cause);
}
diff --git a/android/guava/src/com/google/common/util/concurrent/UncheckedTimeoutException.java b/android/guava/src/com/google/common/util/concurrent/UncheckedTimeoutException.java
index 8e30fca..a09a970 100644
--- a/android/guava/src/com/google/common/util/concurrent/UncheckedTimeoutException.java
+++ b/android/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 javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
/**
* Unchecked version of {@link java.util.concurrent.TimeoutException}.
@@ -24,19 +24,18 @@
* @since 1.0
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public class UncheckedTimeoutException extends RuntimeException {
public UncheckedTimeoutException() {}
- public UncheckedTimeoutException(@CheckForNull String message) {
+ public UncheckedTimeoutException(@NullableDecl String message) {
super(message);
}
- public UncheckedTimeoutException(@CheckForNull Throwable cause) {
+ public UncheckedTimeoutException(@NullableDecl Throwable cause) {
super(cause);
}
- public UncheckedTimeoutException(@CheckForNull String message, @CheckForNull Throwable cause) {
+ public UncheckedTimeoutException(@NullableDecl String message, @NullableDecl Throwable cause) {
super(message, cause);
}
diff --git a/android/guava/src/com/google/common/util/concurrent/Uninterruptibles.java b/android/guava/src/com/google/common/util/concurrent/Uninterruptibles.java
index a33ba82..4f46780 100644
--- a/android/guava/src/com/google/common/util/concurrent/Uninterruptibles.java
+++ b/android/guava/src/com/google/common/util/concurrent/Uninterruptibles.java
@@ -33,7 +33,6 @@
import java.util.concurrent.TimeoutException;
import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.Lock;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Utilities for treating interruptible operations as uninterruptible. In all cases, if a thread is
@@ -44,7 +43,6 @@
* @since 10.0
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
public final class Uninterruptibles {
// Implementation Note: As of 3-7-11, the logic for each blocking/timeout
@@ -195,9 +193,7 @@
* @throws CancellationException if the computation was cancelled
*/
@CanIgnoreReturnValue
- @ParametricNullness
- public static <V extends @Nullable Object> V getUninterruptibly(Future<V> future)
- throws ExecutionException {
+ public static <V> V getUninterruptibly(Future<V> future) throws ExecutionException {
boolean interrupted = false;
try {
while (true) {
@@ -235,9 +231,8 @@
@CanIgnoreReturnValue
@GwtIncompatible // TODO
@SuppressWarnings("GoodTime") // should accept a java.time.Duration
- @ParametricNullness
- public static <V extends @Nullable Object> V getUninterruptibly(
- Future<V> future, long timeout, TimeUnit unit) throws ExecutionException, TimeoutException {
+ public static <V> V getUninterruptibly(Future<V> future, long timeout, TimeUnit unit)
+ throws ExecutionException, TimeoutException {
boolean interrupted = false;
try {
long remainingNanos = unit.toNanos(timeout);
diff --git a/android/guava/src/com/google/common/util/concurrent/WrappingExecutorService.java b/android/guava/src/com/google/common/util/concurrent/WrappingExecutorService.java
index 03c08cc..217e0a7 100644
--- a/android/guava/src/com/google/common/util/concurrent/WrappingExecutorService.java
+++ b/android/guava/src/com/google/common/util/concurrent/WrappingExecutorService.java
@@ -29,7 +29,6 @@
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* An abstract {@code ExecutorService} that allows subclasses to {@linkplain #wrapTask(Callable)
@@ -43,7 +42,6 @@
*/
@CanIgnoreReturnValue // TODO(cpovirk): Consider being more strict.
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
abstract class WrappingExecutorService implements ExecutorService {
private final ExecutorService delegate;
@@ -55,7 +53,7 @@
* Wraps a {@code Callable} for submission to the underlying executor. This method is also applied
* to any {@code Runnable} passed to the default implementation of {@link #wrapTask(Runnable)}.
*/
- protected abstract <T extends @Nullable Object> Callable<T> wrapTask(Callable<T> callable);
+ protected abstract <T> Callable<T> wrapTask(Callable<T> callable);
/**
* Wraps a {@code Runnable} for submission to the underlying executor. The default implementation
@@ -81,8 +79,7 @@
*
* @throws NullPointerException if any element of {@code tasks} is null
*/
- private <T extends @Nullable Object> ImmutableList<Callable<T>> wrapTasks(
- Collection<? extends Callable<T>> tasks) {
+ private <T> ImmutableList<Callable<T>> wrapTasks(Collection<? extends Callable<T>> tasks) {
ImmutableList.Builder<Callable<T>> builder = ImmutableList.builder();
for (Callable<T> task : tasks) {
builder.add(wrapTask(task));
@@ -97,7 +94,7 @@
}
@Override
- public final <T extends @Nullable Object> Future<T> submit(Callable<T> task) {
+ public final <T> Future<T> submit(Callable<T> task) {
return delegate.submit(wrapTask(checkNotNull(task)));
}
@@ -107,33 +104,31 @@
}
@Override
- public final <T extends @Nullable Object> Future<T> submit(
- Runnable task, @ParametricNullness T result) {
+ public final <T> Future<T> submit(Runnable task, T result) {
return delegate.submit(wrapTask(task), result);
}
@Override
- public final <T extends @Nullable Object> List<Future<T>> invokeAll(
- Collection<? extends Callable<T>> tasks) throws InterruptedException {
+ public final <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks)
+ throws InterruptedException {
return delegate.invokeAll(wrapTasks(tasks));
}
@Override
- public final <T extends @Nullable Object> List<Future<T>> invokeAll(
+ public final <T> List<Future<T>> invokeAll(
Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit)
throws InterruptedException {
return delegate.invokeAll(wrapTasks(tasks), timeout, unit);
}
@Override
- public final <T extends @Nullable Object> T invokeAny(Collection<? extends Callable<T>> tasks)
+ public final <T> T invokeAny(Collection<? extends Callable<T>> tasks)
throws InterruptedException, ExecutionException {
return delegate.invokeAny(wrapTasks(tasks));
}
@Override
- public final <T extends @Nullable Object> T invokeAny(
- Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit)
+ public final <T> T invokeAny(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit)
throws InterruptedException, ExecutionException, TimeoutException {
return delegate.invokeAny(wrapTasks(tasks), timeout, unit);
}
diff --git a/android/guava/src/com/google/common/util/concurrent/WrappingScheduledExecutorService.java b/android/guava/src/com/google/common/util/concurrent/WrappingScheduledExecutorService.java
index 48f23c1..4ab700f 100644
--- a/android/guava/src/com/google/common/util/concurrent/WrappingScheduledExecutorService.java
+++ b/android/guava/src/com/google/common/util/concurrent/WrappingScheduledExecutorService.java
@@ -20,7 +20,6 @@
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* An abstract {@code ScheduledExecutorService} that allows subclasses to {@linkplain
@@ -32,7 +31,6 @@
*/
@CanIgnoreReturnValue // TODO(cpovirk): Consider being more strict.
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
abstract class WrappingScheduledExecutorService extends WrappingExecutorService
implements ScheduledExecutorService {
final ScheduledExecutorService delegate;
@@ -48,8 +46,7 @@
}
@Override
- public final <V extends @Nullable Object> ScheduledFuture<V> schedule(
- Callable<V> task, long delay, TimeUnit unit) {
+ public final <V> ScheduledFuture<V> schedule(Callable<V> task, long delay, TimeUnit unit) {
return delegate.schedule(wrapTask(task), delay, unit);
}
diff --git a/android/guava/src/com/google/common/xml/ElementTypesAreNonnullByDefault.java b/android/guava/src/com/google/common/xml/ElementTypesAreNonnullByDefault.java
deleted file mode 100644
index b4fb4e3..0000000
--- a/android/guava/src/com/google/common/xml/ElementTypesAreNonnullByDefault.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) 2021 The Guava Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.common.xml;
-
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.PARAMETER;
-import static java.lang.annotation.ElementType.TYPE;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-import com.google.common.annotations.GwtCompatible;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-import javax.annotation.Nonnull;
-import javax.annotation.meta.TypeQualifierDefault;
-
-/**
- * Marks all "top-level" types as non-null in a way that is recognized by Kotlin. Note that this
- * unfortunately includes type-variable usages, so we also provide {@link ParametricNullness} to
- * "undo" it as best we can.
- */
-@GwtCompatible
-@Retention(RUNTIME)
-@Target(TYPE)
-@TypeQualifierDefault({FIELD, METHOD, PARAMETER})
-@Nonnull
-@interface ElementTypesAreNonnullByDefault {}
diff --git a/android/guava/src/com/google/common/xml/ParametricNullness.java b/android/guava/src/com/google/common/xml/ParametricNullness.java
deleted file mode 100644
index a476558..0000000
--- a/android/guava/src/com/google/common/xml/ParametricNullness.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2021 The Guava Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.common.xml;
-
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.PARAMETER;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-import static javax.annotation.meta.When.UNKNOWN;
-
-import com.google.common.annotations.GwtCompatible;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-import javax.annotation.Nonnull;
-import javax.annotation.meta.TypeQualifierNickname;
-
-/**
- * Marks a "top-level" type-variable usage as (a) a Kotlin platform type when the type argument is
- * non-nullable and (b) nullable when the type argument is nullable. This is the closest we can get
- * to "non-nullable when non-nullable; nullable when nullable" (like the Android <a
- * href="https://android.googlesource.com/platform/libcore/+/master/luni/src/main/java/libcore/util/NullFromTypeParam.java">{@code
- * NullFromTypeParam}</a>). We use this to "undo" {@link ElementTypesAreNonnullByDefault}.
- */
-@GwtCompatible
-@Retention(RUNTIME)
-@Target({FIELD, METHOD, PARAMETER})
-@TypeQualifierNickname
-@Nonnull(when = UNKNOWN)
-@interface ParametricNullness {}
diff --git a/android/guava/src/com/google/common/xml/XmlEscapers.java b/android/guava/src/com/google/common/xml/XmlEscapers.java
old mode 100644
new mode 100755
index a1c637c..b25fcfc
--- a/android/guava/src/com/google/common/xml/XmlEscapers.java
+++ b/android/guava/src/com/google/common/xml/XmlEscapers.java
@@ -30,6 +30,7 @@
* non-ASCII characters to their numeric entity replacements. These XML escapers provide the minimal
* level of escaping to ensure that the output can be safely included in a Unicode XML document.
*
+ *
* <p>For details on the behavior of the escapers in this class, see sections <a
* href="http://www.w3.org/TR/2008/REC-xml-20081126/#charsets">2.2</a> and <a
* href="http://www.w3.org/TR/2008/REC-xml-20081126/#syntax">2.4</a> of the XML specification.
@@ -40,7 +41,6 @@
*/
@Beta
@GwtCompatible
-@ElementTypesAreNonnullByDefault
public class XmlEscapers {
private XmlEscapers() {}
diff --git a/android/guava/src/com/google/common/xml/package-info.java b/android/guava/src/com/google/common/xml/package-info.java
old mode 100644
new mode 100755
diff --git a/android/guava/src/com/google/thirdparty/publicsuffix/PublicSuffixPatterns.java b/android/guava/src/com/google/thirdparty/publicsuffix/PublicSuffixPatterns.java
old mode 100644
new mode 100755
index 9e5f173..475cabb
--- a/android/guava/src/com/google/thirdparty/publicsuffix/PublicSuffixPatterns.java
+++ b/android/guava/src/com/google/thirdparty/publicsuffix/PublicSuffixPatterns.java
@@ -30,7 +30,7 @@
* determining whether a given domain name is an effective top-level domain (public suffix).
*
* <p>Because this class is used in GWT, the data members are stored in a space-efficient manner.
- * See {@link TrieParser}.
+ * {@see TrieParser}.
*
* @since 16.0
*/
@@ -42,7 +42,7 @@
/** If a hostname is contained as a key in this map, it is a public suffix. */
public static final ImmutableMap<String, PublicSuffixType> EXACT =
TrieParser.parseTrie(
- "a&0&0trk9--nx?27qjf--nx?e9ebgn--nx?nbb0c7abgm--nx??1&2oa08--nx?apg6qpcbgm--nx?hbbgm--nx?rdceqa08--nx??2&8ugbgm--nx?eyh3la2ckx--nx?qbd9--nx??3&2wqq1--nx?60a0y8--nx??4x1d77xrck--nx?6&1f4a3abgm--nx?2yqyn--nx?3np8lv81qo3--nx?5b06t--nx?axq--nx?ec7q--nx?lbgw--nx??883xnn--nx?9d2c24--nx?a&a?it??b!.&gro?lim?moc?sr,t&en?opsgolb,?ude?vog??abila?c?ihsot?m?n??c!.&b&a?m?n??c&b?g?q??ep?fn?k&s?y??ln?no?oc,p&i-on,ohsdaerpsym,?sn?t&n?opsgolb,?un?ysrab,?i&ma?r&emarp?fa??sroc??naiva?s??d&ats?n&eit?oh??om?sa?tl??eg?f&c?ob??g!emo?naripi?oy??hskihs?i&cnal?dem?hs?k!on??sa!.snduolc,??jnin?k&aso?dov?ede?usto??l!.&c,gro?moc?ofni?r&ep?nb,?t&en?ni??ude?vog??irgnahs?le&nisiuc?rbmuder???m!.&ca?gro?oc?sserp?ten?vog??ahokoy?e00sf7vqn--nx?m??n!.&ac?cc?eman?gro?ibom?loohcs?moc?ni?o&c?fni?rp??r&d?o??s&u?w??vt?xm??av?is?olecrab?tea??p!.&bog?ca?d&em?ls??g&ni?ro??mo&c?n??oba?ten?ude??c?g7hyabgm--nx?ra!.&461e?6pi?iru?nru?rdda-ni?siri???s??q!.&eman?gro?hcs?lim?moc?t&en?opsgolb,?ude?vog???r&az?emac?f4a3abgm--nx?n!d5uhf8le58r4w--nx??u&kas?tan???s!.&bup?dem?gro?hcs?moc?ten?ude?vog??ac!.uban.iu,?iv??t&ad?elhta?led?oyot??u!.&a&cinniv?emirc?i&hzhziropaz?stynniv??s&edo?sedo??tlay?vatlop??bs?cc,d&argovorik?o!roghzu??tl,?e&hzhziropaz?nvir?t??f&i?ni,?g&l?ro??hk?i&stvinrehc?ykstynlemhk??k&c?m?s&nagul?t&enod?ul??v&iknarf-onavi?orteporp&end?ind?????l&iponret?opotsa&bes?ves??p??m&k?oc?s?yrk??n&c?d?i?osrehk?v?ylov??o&c,nvor??p&d?p,z??r&c?imotihz?k?ymotyhz??sk?t&en?l?z??ude?v:c?e&alokin?ik??i&alokym?hinrehc?krahk?vl?yk??k?l?o&g!inrehc??krahk??r?,xc,y&ikstinlemhk?mus?s&akrehc?sakrehc?tvonrehc???z&ib,u????v!aj?bb?et?iv??waniko?x&a?iacal??yogan?z&.&bew?c&a?i&n?rga???gro?l&im?oohcs??m&on?t??o&c!.topsgolb,?gn??radnorg?sin?t&en?la??ude?vog?wal??zip???b&00ave5a9iabgm--nx?1&25qhx--nx?68quv--nx?e2kc1--nx??2xtbgm--nx?3&b2kcc--nx?jca1d--nx??4&6&1rfz--nx?qif--nx??96rzc--nx??7w9u16qlj--nx?88uvor--nx?a&0dc4xbgm--nx?c?her?n?ra?t??b!.&erots?gro?moc?o&c?fni??ten?ude?v&og?t??zib??a??c&j?s??d&hesa08--nx?mi??g?l!.&gro?moc?ten?ude?vog??m??s!.&gro?moc?ten?ude?vog???tc-retarebsnegmrev--nx?u&lc!.&elej,snduolc,y&nop,srab,??smas??p!.ysrab,??wp-gnutarebsnegmrev--nx??c&1&1q54--nx?hbgw--nx??2e9c2czf--nx?4&4ub1km--nx?a1e--nx?byj9q--nx?erd5a9b1kcb--nx??8&4xx2g--nx?c9jrb2h--nx??9jr&b&2h--nx?54--nx?9s--nx??c&eg--nx?h3--nx?s2--nx???a!.&gro?lim?moc?rrd,ten?ude?vog??3a09--nx!.&ca1o--nx?gva1c--nx?h&ca1o--nx?za09--nx??ta1d--nx?ua08--nx???da??b&a?b?ci?f76a0c7ylqbgm--nx?sh??c!.&eugaelysatnaf,gnipparcs,liamwt,revres-emag,s&nduolc,otohpym,seccaptf,?xsc,?0atf7b45--nx?a1l--nx??e!.&21k?bog?dem?gro?lim?moc?nif?o&fni?rp??ten?ude?vog??beuq?n?smoc??fdh?i&l&buperananab?ohtac??n&agro?ilc?osanap??sum?tic??l!.&gro?moc?oc?ten?ude?vog?yo,?l??m!.&mt?ossa??p1akcq--nx??n!.&mon?ossa??i?p??relcel?s!.&gro?moc?ten?ude?vog??c??t!.&e&m,w,?hc,?s?w??v!.&e0,gro?lim?moc?ten?ude?v&g:.d,,og???q??wp?yn??d&2urzc--nx?3&1wrpk--nx?c&4b11--nx?9jrcpf--nx???5xq55--nx?697uto--nx?75yrpk--nx?9ctdvkce--nx?a!.mon?d?er?olnwod??b2babgm--nx?c!.vog?g9a2g2b0ae0chclc--nx??e&m!bulc??r!k??sopxe?timil?w??fc?g!.&ude?vog???h&d3tbgm--nx?p?t??i!.&ased?bew?ca?etrof,golbw,hcs?lim?o&c!.topsgolb,?g??palf,r&egolb,o??sepnop?ten?ym?zib??ar?b?ordna?p?rdam??l&iub?og?row??m!.&ed,ot,pj,t&a,opsgolb,???n&a&b?l!.citats:.&setis,ved,?,raas???ob?uf??o&of?rp??r&a&c&tiderc?yalcrab??ugnav??ef506w4b--nx?k!.&oc,ude,?jh3a1habgm--nx??of??s!.&dem?gro?moc?ofni?ten?ude?v&og?t???m!kcrem???t!.topsgolb,excwkcc--nx?l??uolc!.&a&bura-vnej.&1ti,abura.rue.1ti,?tcepsrep,xo:.&ku,nt,?,?bewilek:.sc,,citsalej.piv,drayknil,elej,gnitsohdnert.&ed,hc,?letemirp:.ku,,m&edaid,ialcer.&ac,ku,su,??n&evueluk,woru,?r&epolroov,o&pav,tnemele,??tenraxa.1-se,ululetoj,xelpciffart,??za5cbgn--nx??e&1&53wlf--nx?7a1hbbgm--nx?ta3kg--nx??2a6a1b6b1i--nx?3ma0e1cvr--nx?418txh--nx?707b0e3--nx?a!.&ca?gro?hcs?lim?oc?t&en?opsgolb,?vog??09--nx??b!.&ca?gnitsohbew,nevueluk.yxorpze,pohsdaerpsym,snoitulostsohretni.duolc,topsgolb,?ortal?ut!uoy???c&0krbd4--nx?a&lp!.oc,?ps!.&lla4sx,rebu,tsafym,?artxe??sla??i!ffo??n&a&d?iler?nif?rusni!efil?srelevart???eics!.oby,??rofria??d!.&1sndnyd,42pi-nyd,7erauqs,amil4,b&ow-nrefeilgitsng--nx,rb-ni,vz-nelletsebgitsng--nx,?decalpb,e&daregtmueart,mohsnd,nihcamyek,?hcierebsnoissuksid,keegnietsi,lsd-ni,moc,n&-i-g-o-l,aw-ym,e&lletsebgitsnüg,sgnutiel,?i&emtsi,lreb-n&i,yd,??oitatsksid-ygolonys,pv&-n&i,yd,?nyd,?refeilgitsnüg,?orp-ytinummoc,p&h21,iog:ol,,ohsdaerpsym,?r&e&ntrapdeeps.remotsuc,su&-lautriv,lautriv,?t&adpusnd,tub-ni,uor-ym,?vres&-e&bucl,mohym,?bew-emoh:.nyd,,luhcs,??ogiv-&niem,ym,??s&d-&onys,ygolonys,?nd&-&dd,nufiat,sehcsimanyd,tenretni,yard,?isoc.nyd,ps,yard,?oper-&nvs,tig,?sndd:.&nyd,sndnyd,?,?topsgolb,vresi-&niem,tset,?xi2,y&awetag-&llawerif,ym,?srab,tic-amil,?zten&mitbel,sadtretteuf,??a&lg?rt!.oby,??i&sdoow?ug??nil?on--nx??e!.&bil?dem?eif?gro?irp?kiir?moc!.topsgolb,?pia?ude?vog??ei?ffoc?gg?r&f?ged???f&a&c?s??il??g!.&gro?lim?moc?t&en?vp??ude?vog??a&f?gtrom?p!.&3xlh,kselp,sndp,tengam,xlh,ycvrp,??rots?yov??elloc?na&hcxe?ro??roeg?ug??i!.&pohsdaerpsym,topsgolb,vog??tilop?v&bba?om???j!.&fo,gro?oc?ten???k!.&c&a?s??e&m?n??ibom?o&c!.topsgolb,?fni?g??ro??i&b?l?n???l&a&dmrif?s!.rof,rof???b&a?i&b?dua???c&aro?ric??dnik?g!oog??i&bom?ms??l&asal?erauqa??ppa?uhcs?yts!efil???m!.&4&32i,pct,?66c,ailisarb,b&dnevar,g-raegelif,?ca?duolcsd,e&d-raegelif,i&-raegelif,lpad:.tsohlacol,,?pcm,?g&ro?s-raegelif,?hctilg,k&catsegde,uoc,?noitatsksid,o&bmoy,c!ku,?t&nigol,poh,??p&ion,j-raegelif,ohbew,?qbw,r&aegelif,idcm,ofsnd,?s&dym,ndd,ti!bt,?umhol,?t&en?s&acdnuos,ohon,??u&a-raegelif,de?tcn,?v&irp?og??y&golonys,olpedew,srab,??a&g?n!.&reh.togrof,sih.togrof,???em?i&rp?twohs??orhc?w??n!goloc?i&lno!.&egats-oree,oree,ysrab,??w??o!.&derno:.gnigats,,ecivres,knilemoh,r&ednu,of,??hp?latipac?ts&der?e&gdirb?rif???z!.&66duolc,amil,sh,???ruoblem??om?p!.&bog?gro?lim?mo&c?n??t&en?opsgolb,?ude??irg?yks??r!.&mo&c?n??ossa?topsgolb,?a&c!htlaeh??pmoc?wtfos??bc?eh?if?ots!.&e&rawpohs,saberots,?yflles,??taeht?u&ces?sni?t&inruf?necca??za???s!.&a!bap.us,?b!ibnal?rofmok??c!a??d!b?n&arb?ubroflanummok???e?f!noc,?g!ro??h!f??i!trap??k!shf??l?m!oc,t??n!mygskurbrutan??o?p!ohsdaerpsym,p??r!owebdluocti,?s!serp?yspoi,?t!opsgolb,?u?vhf?w?x!uvmok??y?z??a&c?el?hc??i&er?urc??nesemoh?roh?uoh??t&a&d?ts&e!laer??lla???is!.&areduolc,e&lej,nilnigol,r&etnim,ocevon,?winmo,?k&rowtenoilof,wnf,?laicosnepo,n&eyb,oyc,?spvtsaf,thrs,xulel,ysrab,?bew??ov?ra?t&ioled?ol??utitsni??u&lb?qi&nilc?tuob???v!.&21e?b&ew?og??ce&r?t??erots?gro?lim?m&oc?rif??o&c?fni??stra?t&en?ni??ude?vog??as?e3gerb2h--nx?i&l!.xlh,?rd?ssergorp??ol??w&kct--nx?r??xul?y!.&gro?lim?moc?ten?ude?vog????f&0f3rkcg--nx?198xim--nx?280xim--nx?7vqn--nx?a!.&gro?moc?ten?ude?vog???b!.vog?wa9bgm--nx??c!.topsgolb,a1p--nx!.&a14--nx,b8lea1j--nx,c&avc0aaa08--nx,ma09--nx,?f&a1a09--nx,ea1j--nx,?gva1c--nx,nha1h--nx,pda1j--nx,zila1h--nx,??ns??ea1j--nx?fo?g?iam?l&a1d--nx?og??n!.&bew?cer?erots?m&oc?rif??ofni?re&hto?p??stra?ten???orp?p!.&gro?moc?ude???rus?t!w??vd7ckaabgm--nx?w??g&2&4wq55--nx?8zrf6--nx??3&44sd3--nx?91w6j--nx!.&a5wqmg--nx?d&22svcw--nx?5xq55--nx??gla0do--nx?m1qtxm--nx?vta0cu--nx????455ses--nx?5mzt5--nx?69vqhr--nx?7&8a4d5a4prebgm--nx?rb2c--nx??a!.&gro?mo&c?n??oc?ten??vd??b!.&0?1?2?3?4?5?6?7?8?9?a?b?c?d?e?f?g?h?i?j?k?l?m?n?o?p?q?r?s?t!opsgolb,?u?v?w?x?y!srab,?z???c!b?za9a0cbgm--nx??e!.&eman?gro?ics?lim?moc!.topsgolb,?nue?ten?ude?vog??a??g!.&ayc,gro?lenap:.nomead,,oc?saak,ten???i&a?v??k!.&g&olb,ro??ku,lim?moc?oi,pj,su,ten?ude?v&og?t,???m!.&drp?gro?lim?m&o&c?n??t??oc?ude?vog??pk??n!.&dtl,eman?gro?hcs?i!bom??l&im?oc,?m&oc!.topsgolb,?rif,?neg,ogn,ten?ude?vog??aw?i!b!mulp??car?d&art?dew??h&sif?tolc??k&iv?oo&b?c???ls?n&aelc?iart??p!pohs??re&enigne?tac??t&ad?ekram!.&htiw,morf,??hgil?lusnoc?neg?ov?soh!.tfarcnepo,??vi&g?l???o!s??u&rehcisrev?smas?tarebsnegömrev???o&d?lb?og!.&duolc,etalsnart,???r&2n084qlj--nx?ebmoolb?o!.&77ndc.c:sr,,a&remacytirucesym,t&neimip,sivretla,?z,?bew-llams,d&ab-yrev-si,e&sufnocsim,vas-si,?nuof-si,oog-yrev-si,uolc&arfniarodef,mw,??e&a,cin-yrev-si,grof&loot,peh,?l&as-4-ffuts,poeparodef,?m&-morf,agevres,ohruoyslles,?n&ozdop,uma.elet,?r&ehwongniogyldlob,iwym,uces-77ndc.nigiro.lss,?t&adidnac-a-si,is&-ybboh,golb,???fehc-a-si,golbymdaer,k&eeg-a&-si,si,?h,nut,?l&i&amwt,ve-yrev-si,?lawerif&-ym,ym,?sd-ni,?m&acssecca,edom-elbac,?n&af&blm,cfu,egelloc,lfn,s&citlec-a-si,niurb-a-si,tap-a-si,?xos-a-si,?ibptth,o&itatsksid,rviop,?pv-ni,?o&jodsnd,tp&az,oh,??p&i&-on,fles,?o&hbew,tksedeerf,?tf&e&moh,vres,?ym,??r&e&gatop,ppepteews,su-xunil-a-si,?gmtrec,vdmac,?s&a&ila&nyd,snd,?nymsd,?b&alfmw,bevres,?dylimaf,eirfotatophcuoc,j,koob-daer,ltbup,nd&-won,deerf,emoh,golb,kcud,mood,nyd:.&emoh,og,?,ps,rvd,tog,uolc,?s&a-skcik,ndd,?tnemhcattaomb,u,?t&ce&jorparodef.&duolc,gts.so.ppa,so.ppa,?riderbew,?e&ews-yrev-si,nretni&ehtfodne,fodne,??hgink-a-si,igude,oi-allizom,s&ixetn&od,seod,?o&h-emag,l-si,?rifyam,??ue:.&a&-q,c,?cm,dc,e&b,d,e,i,m,s,?g&b,n,?hc,i&f,s,?k&d,m,s,u,?l&a,i,n,p,?n&c,i,?o&n,r,ssa,?pj,r&f,g,h,k,t,?s&e,i:rap,,u,?t&a,en,i,l,m,ni,p,?u&a,de,h,l,r,?vl,y&c,m,?z&c,n,??,vresnyd,x&inuemoh,unilemoh,?y&limafxut,srab,???ub&mah?oj???s!.&delacsne,gro?moc?rep?t&en?opsgolb,?ude?vog??gb639j43us5--nx??t?u!.&c&a?s??en?gro?moc?o&c?g??ro?topsgolb,??v!.ta,a1c--nx??wsa08--nx??h&0ee5a3ld2ckx--nx?4wc3o--nx!.&a&2xyc3o--nx?3j0hc3m--nx?ve4b3c0oc21--nx??id1kzuc3h--nx?l8bxi8ifc21--nx?rb0ef1c21--nx???8&8yvfe--nx?a7maabgm--nx??b!.&gro?moc?ten?ude?vog??mg??c!.&7erauqs,amil4,duolc-drayknil,gniksnd,p&h21,ohsdaerpsym,?sndtog,topsgolb,wolf.e&a.1pla,nigneppa,?xi2,ytic-amil,?aoc?et?ir!euz??r&aes!errecnac??uhc??sob?taw!s???d0sbgp--nx?f&2lpbgm--nx?k??g!.&gro?lim?moc?ude?vog???m!a1j--nx??ocir?p!.&gro?i?lim?moc?ogn?ten?ude?vog???s!.&g&nabhsah,ro??l&im?xv,?m&oc?roftalp.&cb,su,tne,ue,??pib,ten?vog?won,yolpedew,?a&c?nom??i&d?f?ri???t!.&ca?enilno,im?ni?o&c?g??pohs,ro?ten??iaf!.oby,?laeh!.arh,?orxer?ra&ba?e???vo!.lopdren,?zb??i&3tupk--nx?7a0oi--nx?a!.&ffo?gro?moc?ten?uwu,?1p--nx?bud?dnuyh?tnihc??b!.&gro?moc?oc?ro?ude??ahduba?o!m!.&duolcsd,ysrab,???s??c!.&ayb-tropora--nx?ca?d&e?m??esserp?gro?ln,moc?nif,o&c?g?ssa??ro?t&en?ni?roporéa??ude?vuog??cug?t??d&dk?ua??e&bhf--nx?piat??f!.&aw5-nenikkh--nx,dnala?iki,mroftalpduolc.if,nenikkäh,pohsdaerpsym,retnecatad.&omed,saap,?topsgolb,yd,?onas??g!.&d&om?tl??gro?moc?ude?vog???h&c&atih?ra??s&abodoy?ibustim???juohs?k!.&gro?moc?ofni?ten?ude?vog?zib??b4gc--nx?iw?nisleh?s?uzus??l!.&aac,topsgolb,?drahcir?iamsi??maim?n!.&b&ew?og??ca?gro?lim?mo&c?n??ni?o&c?fni??pp?t&en?ni??ude?zib??airpic?i&hgrobmal?m??re??om?rarref?s!.&egaptig,ppatig,topsgolb,?ed??t&aresam?i&c?nifni??rahb?tagub??ut?v!.&21k?gro?moc?oc?ten???wik?xa&rp?t??yf??j&6pqgza9iabgm--nx?8da1tabbgl--nx?b!.&ossa?topsgolb,uaerrab?vuog???d?f!.&ca?eman?gro?lim?moc?o&fni?rp??ten?vog?zib???nj?s?t!.&bew?c&a?in??eman?gro?lim?moc?o&c?g??t&en?ni?set??ude?vog?zib???yqx94qit--nx??k&8uxp3--nx?924tcf--nx?arfel?c&a&bdeef?lb??ebdnul?ilc?reme?ud??d!.&erots,ger,mrif,oc,pohsdaerpsym,topsgolb,zib,?t??e&es?samet??h!.&a&4ya0cu--nx?5wqmg--nx??b3qa0do--nx?cni,d&2&2svcw--nx?3rvcl--nx??5xq55--nx?tl,?g&a0nt--nx?la0do--nx?ro??i&050qmg--nx?7a0oi--nx?xa0km--nx??m&1qtxm--nx?oc??npqic--nx?saaces,t&en?opsgolb,?ude?v&di?og?ta0cu--nx??xva0fz--nx?人&个?個?箇??司公?府政?絡&網?网??織&組?组??织&組?组??络&網?网??育&敎?教???n??i&tsob?vdnas??l!.&bew?c&a?os??dtl?gro?hcs?letoh?moc?nssa?ogn?prg?t&en?ni??ude?vog??at?cd?is??m!.&eman?fni?gro?moc?t&en?opsgolb,?ude?vog???n&ab!cfdh?etats?mmoc?t&en?fos??u??i!l!.&noyc,pepym,??p???oob?p!.&b&ew?og??gro?kog?m&af?oc??nog?ofni?pog?sog?ten?ude?vog?zib???row!.&morf,ot,?ten!.&htumiza,nolt,o&c,vra,??doof???s!.topsgolb,?t?u!.&c&a?lp??d&om?tl??e&cilop?m??gro!.&gul:g,,sgul,??nnoc,o&c!.&bunsorter.tsuc,e&lddiwg,n&ilnoysrab,ozgniebllew,??krametyb.&hd,mv,?omida,p&i-on,ohsdaerpsym,?t&fihsreyal.j,opsgolb,?vres-hn,ysrab,??rpoc,?psoh,shn?t&en?nmyp,?vog!.eci&ffoemoh,vres,??ysrab,???l&04sr4w--nx?a!.&gro?lim?moc?t&en?opsgolb,?ude?vog??bolg?c?ed?g!el??i&c&nanif!.oc,lpl??os??romem?tnedurp??n&if?oitanretni??t&i&gid!.sppaduolc:.nodnol,,?p&ac?soh???ned?ot??utum!nretsewhtron???c!.&bog?lim?oc?topsgolb,vog???dil?e&datic?n&ahc?nahc!gnikooc?levart?rehtaew???t!ria?tam??vart??f&8f&pbgo--nx?tbgm--nx??a?n??g!.&gro?moc?oc?ten?ude?xx,zib,??h&d?op??i!.&21k?ca?fdi?gro?inum?oc!.&egapvar,topsgolb,??ten?vog??a&f?m&e?g?toh???m?r?xil??l&a&b&esab?t&eksab!.&sua,zn,??oof???c?mt??e&d?hs??ihmailliw?j??m!.&esserp?gro?moc?ten?ude?v&og?uog????n!.&n&iemodleeutriv,o&med,rtsic,??oc,pohsdaerpsym,retsulc-gnitsoh,topsgolb,wsma,yalphk,?o??o&a?btuf?l!.gmo,?o&c!.&ed,rotnemele,??hcs??rit?u??p!.&a&cin&diws?gel??d&g,ortso?urawon??i&dem?mraw?nydg,?k&elo&guld?rtso??slopolam?tsu?ytsyrut??l&ip?o&kzs?w&-awolats?oksnok????n&erapohs,img?zcel,?rog&-ai&bab?nelej??j?z??syn?tsaim?w&a&l&eib?i?o??zsraw??o&namil?tainop,??z&eiwolaib?mol???c&e&iw&alselob?o&nsos?rtso???le&im?zrogz???orw,p??d&em,ia?ragrats?uolc&inu,sds,??e&c&i&lrog?w&ilg,o&hc&arats?orp??klop?tak????yzreibok??i&csjuoniws?ksromop?saldop??l&ahdop?opo??napokaz,tatselaer?z&romop?swozam???g&alble?ezrbo&lok?nrat??ro??hcyzrblaw?i&csomohcurein?grat?klawus??k&e&rut?walcolw??in&byr?diws,sark,?le?o&nas?tsylaib??rob&el?lam??s&als?jazel?nadg,puls?rowezrp???l&colw?e&r?vart??i&am?m???m&o&c?dar?n?tyb??s&g?iruot??t!a???n&a&gaz?nzop,?i&bul?cezczs?lbul,molow?nok?zd&eb?obeiws???uleiw?y&tzslo?z&rtek?seic????o&c,fni?k&celo?zdolk??lkan?n&leim?pek?t&uk?yzczs??z&copo?eing?rowaj???rga?tua?w&ejarg?ogarm???p&e&eb,lks??klwwortso?ohs!daerpsym,??romophcaz?sos?t&aiwop?en?opos,ra,sezc??ude?v&irp?og!.&a&p?s!w???bni&p?w??ci?dtiw?essp?fiw?g&imu?u??hiiw?m&igu?rio?u!o???nds?o&ks?p!pu??s?wtsorats??p&a?sp!mk?pk?wk??u&m?p??wk?z??r&ksw?s??s&i?oiw?u?zu??talusnok?w&gzr?i&p?rg?w??m?opu?u!imzw???zouw????w&a&l&corw?sizdow??w??o&golg?k&ark,ul?zsurp??r&az?gew??t&rabul,sugua??z&coks?sezr????xes?y&buzsak?d&azczseib?ikseb??hcyt?n&jes?lod-zreimizak??pal?r&ogt?uzam??walup?zutrak??z&am-awar?c&aprak?iwol?zsogdyb??dalezc?ib?s&i&lak?p??uklo????l??r&as?f?s??s!.&gro?moc?ten?ude?vog???t!.vog??ubnatsi?x3b689qq6--nx?yc5rb54--nx??m&00tsb3--nx?1qtxm--nx?981rvj--nx?a!.&aayn,enummoc?gro?moc?o&c?idar,ken,?t&en?opsgolb,??c!bew??dretsma?e&rts?t!.&citsalej,esruocsid,???fma?xq--nx??b!.&gro?moc?ten?ude?vog??i??c!.&moc?oc?ten?vog???d!.&gro?moc?ten?ude?vog???f!.&gro?moc?oidar,ten?ude??i??g!vu96d8syzf--nx??h?i!.&ca?gro?moc?o&c!.&clp?dtl???r,?t&en?t??vt??k?rbg4--nx??k!.&drp?e&rianiretev?sserp??gro?lim?m&o&c?n??t??nicedem?ossa?pooc?s&eriaton?neicamrahp?sa??ude?v&og?uog????l&if?ohkcots??o!.&dem?gro?m&oc?uesum??o&c?rp??ten?ude?vog??b?c!.&2aq,3pmevres,5sndd,a&c&-morf,ir&bafno,fa,??g&-morf,oy-sehcaet,?i-morf,m&-morf,all&-a-si,amai,??p&-morf,c-a-si,?r&emacytirucesym,odih,?s,tadtsudgniht,v-morf,w-morf,z,?b&dnevarym,ew&-sndnyd,draiw.segap,ottad,?g,ildts.ipa,?c&amytirucesemoh,d-morf,esyrcs,itsalej.omed,n&-morf,vym,?p&kroweht,ytirucesemoh,?q,rievres,s-morf,?d&aerotffuts,e&calpb,ifitrec-&si,ton-si,?llortnocduolc,rewopenignepw:.sj,,tsohecapsppa,?i&-morf,rgevissam.saap,?m-morf,n&-morf,abeht-htiw-si,?s-morf,uolc&-noitatsyalp,hr,iafaw.&d&ej,yr,?nol,?meaeboda,panqym:-&ahpla,ved,?,smetsystuo,tekcilc,ved&j,pw,??vreser,wetomer,?e&butuoyhtiw,ciffo-sndnyd,d:-morf,o&celgoog,n&il.srebmem,neve.&1-&su,ue,?2-&su,ue,?3-&su,ue,?4-&su,ue,????,erf&-sndnyd,sndd,?filflahevres,gnahcxeevres,i&hcet-a-si,p-sekil,?k&auqevres,irtsretnuocevres,?l&bitpa-no,googhtiw,?m&agevres,ina-otni-si,oh-&sndnyd,ta-sndnyd,??n&-morf,ilno&-evreser,ysrab,?og-si,?r&alfduolcyrt,ehwynanohtyp:.ue,,ihcec,?srun-a-si,t&i&nuarepo,s&-ybboh,aloy,tipohs,xiw,??omer-sndnyd,upmocsma,ysgolb,?v&als-elcibuc-a-si,i&lsndd,tavresnoc-a-si,??z&amkcar,eelg,iig,??fehc-a-si,g&ni&gats-&raeghtua,swennwot,?ksndd,robsikrow,?o&fgp,lb&-sndnyd,pawodni,sihtsetirw,???h&n-morf,o-morf,?i&fiwehtno,h-morf,kiw-sndnyd,m-morf,pdetsoh,r-morf,w-morf,z&ihcppa,nilppa,??jn-morf,k&a&-morf,erfocsic,?cils-si,eeg&-a&-si,si,?sndd,?h,latsnaebcitsale:.&1-&htuos-pa,lartnec-&ac,ue,?ts&ae&-&as,su,?ht&ron-pa,uos-pa,??ew-&su,ue,vog-su,???2-ts&ae&-su,ht&ron-pa,uos-pa,??ew-&su,ue,??3-ts&aehtron-pa,ew-ue,??,o-morf,r&adhtiwtliub,ow&-&sndnyd,ta-sndnyd,?ten-orehkcats,??u,?l&a&-morf,colottad,rebil-a-si,?f-morf,i&-morf,am&-sndnyd,detsohpw,??l&ecelffaw,uf-ytnuob:.a&hpla,teb,?,?ppmswa,ru-&elpmis,taen,?ssukoreh,xegap,?m&n-morf,pml.ppa,rofererac-htlaeh,sacrasevres,uirarret-yltsaf,?n&a&cilbuper-a-si,f&-sllub-a-si,racsan-a-si,?i&cisum-a-si,ratrebil-a-si,??c,dc&hsums,umpw,xirtrepmi,?eerg-a-si,i-morf,m-morf,o&ehtnaptog,isam-al-a-tse,r&italik,tap-el-tse,?s&iam-al-a-tse,replausunu,??pj,t-morf,?o&bordym,c,hce-namtsop,jodsnd,m&-morf,ed-baltlow,?n:iloxip,,ttadym,?p&2pevres,aelutym,i&-sndnyd,fles,ogol,ruoy&esol,hctid,?ym&eerf,teg,??ohsdaerpsym,pa&-rettalp,anis:piv,,esaberif,k1,lortnocduolc,oifilauq,r&aegyks,oetem:.ue,,?tnorfegap,ukoreh,?t&fevres,thevres,??r&a:-morf,tskcor-a-si,,b,e&d&iv&erp-yb-detsoh.saap,orpnwo,?ner&.ppa,no,??e&bevres,nigne-na-si,?ggolb&-a-si,ndi,?h&caet-a-si,pargotohp-a-si,?krow-drah-a-si,n&gised-a-si,ia&rtlanosrep-a-si,tretne-na-si,??p&acsdnal-a-si,eekkoob-a-si,?retac-a-si,subq,tn&ecysrab,iap-a-si,uh-a-si,?vres&-&ki.&cpj-rev-duolcj,duolcj,?s&ndnyd,pvtsaf,??inim,nmad,sak,?y&alp-a-si,wal-a-si,?zilibomdeepsegap,?g,ituob,k,mgrp.nex,o&-morf,sivdalaicnanif-a-si,t&areleccalabolgswa,c&a-na-si,od-a-si,?susaym,??p-morf,u&as-o-nyd,e&tsoh.&duolc-gar,hc-duolc-gar,?ugolb-nom-tse,?omuhevres,??s&a&apod,ila&nyd,snd,?nymsd,vnacremarf,?bbevres,ci&p&-sndnyd,evres,?tcatytiruces,?dylimaf,e&cived-anelab,itilitu3,lahw-eht-sevas,mag-otni-si,t&isro,yskciuq,??i&ht2tniop,pa&elgoog,tneltneg,??jfac,k&-morf,aerf-ten,colb&egrof,pohsym,??m&-morf,cxolb,?n&d&-pmet,dyard,golb,mood,tog,?kselp,nyd,ootrac-otni-si,?o&-xobeerf,xobeerf,?ppa&raeghtua,tneg,?r&ac-otni-si,e&ntrap-paelut,tsohmaerd,??s&e&l-rof-slles,rtca-na-si,?ibodym,?tsaeb-cihtym.&a&llicno,zno,?ilay,lacarac,re&gitnef,motsuc,?sv,toleco,x:n&ihps,yl,?,?u,wanozama.&1-&htuos-pa&-3s,.&3s,etisbew-3s,kcatslaud.3s,??la&nretxe-3s,rtnec-&ac&-3s,.&3s,etisbew-3s,kcatslaud.3s,??ue&-3s,.&3s,etisbew-3s,kcatslaud.3s,????ts&ae&-&as&-&3s,etisbew-3s,?.kcatslaud.3s,?su:-etisbew-3s,.kcatslaud.3s,,?ht&ron-pa&-&3s,etisbew-3s,?.kcatslaud.3s,?uos-pa&-&3s,etisbew-3s,?.kcatslaud.3s,???ew-&su-&3s,etisbew-3s,?ue&-&3s,etisbew-3s,?.kcatslaud.3s,?vog-su-&3s,spif-3s,????2-ts&ae&-su&-3s,.&3s,etisbew-3s,kcatslaud.3s,??ht&ron-pa&-3s,.&3s,etisbew-3s,kcatslaud.3s,??uos-pa&-&3s,etisbew-3s,?.kcatslaud.3s,???ew-&su-&3s,etisbew-3s,?ue&-3s,.&3s,etisbew-3s,kcatslaud.3s,????3&-tsew-ue&-3s,.&3s,etisbew-3s,kcatslaud.3s,??s,???t&arcomed-a-si,c&-morf,etedatad.&ecnatsni,omed,??eel&-si,rebu-si,?hgilfhtiwletoh,m-morf,n&atnuocca-na-si,e&duts-a-si,r-ot-ecaps,tnocresu&buhtig,e&capsppa,lbavresbo.citats,?pl,???ops&edoc,golb,ppa,?s&i&hcrana-&a-si,na-si,?laicos-a-si,pareht-a-si,tra-na-si,xetn&od,seod,??oh&piym,sfn,??u&-morf,nyekcoh-asi,?v-morf,?u&-rof-slles,4,e,h,oynahtretramssi,r:ug-a-si,,?v&n-morf,w-morf,?w&o&lpwons-yrt,zok,?ww100,?x&bsbf.sppa,em,i&nuemoh,rtrepmi,?obaniateb,t-morf,unilemoh,?y&a&bnx:.&2u,lacol-2u,?,l&erottad,pezam,?wetag-llawerif,?dnacsekil,fipohsym,k&-morf,niksisnd,?rotceridevitcaym,u:goo,,w-morf,x&alagkeeg,orphsilbup,???inu??m!.&dna,rof,??or?tsla??p!.nwo,?raf!.jrots,etats??s?t!.&gro?lim?mo&c?n??oc?ten?ude?vog???u&esum!.&a&92chg-seacinumocelet-e-soierroc--nx?atnav?c&i&aduj?rfatsae??rollam??d&anac?enomaledasac?irolf??e&raaihpledalihp?srednu??g&hannavas?oonattahc??hamo?i&auhsu?bmuloc!hsitirb??dem?groeg?hpledalihp?l&artsua?etalif??n&igriv?rofilac??ssur?tsonod??ksa&la?rben??l&lojal?q-snl--nx?uossim!trof???m&a&bala?nap??enic?o&m?r???n&a&cirema?idni??edasap?ilorachtuos?olecrab??r&abrabatnas?ezzivs??su?t&nalta?osennim??zalp??c&dnotgnihsaw?ebeuq?i&depolcycne?ficap?hpargonaeco?lbup?sum?t&carporihc?lec?naltadim??vu??yn??d&a&dhgab?etsmraf?m?orliar??i&rdam?ulegnedleeb??leif?n&a!l&gne?nif?ragyduj?t&ocs?rop??yram???u&brofsdgybmeh?osdnaegami???r&augria?ofxo???e&c&a&l&ap?phtrib??ps??n&a&lubma?tsiser??e&fedlatsaoc?gilletni?ics!foyrotsih????pein?rof??d&nukneklov?revasem??e&rt?tsurt??f&atnas?ildliw??g&a&lliv?tireh!lanoitan???dirbmac?rog??i&cnum?nollaw??koorbrehs?l&ab?bib?cycrotom?i&ssim?txet??oks?tsac??m&affollah?it!iram??utsoc??n&golos?ilno?recul??r&a&uqs?waled!foetats???i&hs&acnal?kroy?pmahwen??otsih??omitlab?ut&an?cetihcra?inruf?luc!irga?su???vuol??s&abatad?iacnarf?sius?uoh!lum???t&a&locohc?rak?ts!e!yrtnuoc!su?????imesoy?tevroc??u&qihpargonaeco?velleb??vit&caretni?omotua???f&iuj?ohgrub??g&n&i&dliub?ginerevmuesum?kiv?lahw?nim?peekemit?vil??ulmmastsnuk??orf?r&ebnrats?u&b&ierf?le?m&ah?uan??ram?s&mailliw!lainoloc??naitsirhc?retepts??zlas??ob&irf?mexul?????h&atu?c&raeser?sirotsih?uot??g&ea1h--nx?rubsttip??si&tirb?wej??t&laeh?ro&n?wtrof??uo&mnom?y????i&d6glbhbd9--nx?iawah?k&nisleh?s??lad!rodavlas??sissa?tannicnic??k&c&nivleeg?olc!-dna-hctaw?dnahctaw???fj?inebis?l&is?ofron??na&rfenna?t??oorbnarc?r&am&ned?reiets??oy!wen????l&a&ci&dem?golo&eahcra?meg?oz??natob?rotsih??ertnom?iromem?noita&cude?n??oc?rutluc?trop?utriv?van??e&nurb?s&ab?surb??utriv??i&artnogero?sarb??l&a&besab?hsnoegrus??e&hs?rdnevle??i&b?m!dniw????o&bup?ohcs?tsirb???m&a&dretsma?ets?h&netlehc?rud???ct?elas!urej??l&if?ohkcots?u??raf?silanruoj?u&esumyrotsihlarutan?ira&tenalp?uqa??terobra???n&a&c!irema!evitan???gihcim?i&dni?tpyge??mfoelsi?wehctaksas??e&d&alokohcs?ews?rag!cinatob?lacinatob?s&nerdlihc?u????gahnepoc?hcneum?laftsew?ppahcsnetewruutan?r&dlihc?ednaalv?hu!dnutamieh???sseig??gised!dn&atra?utsnuk???h&ab!nesie??ojts??i&lreb?tsua??l&eok?ocnil??n&ob?urbneohcs??o&dnol?gero?i&s&iv&dnadnuos?elet??nam??t&a&c&inummoc?ude!tra???dnuof?erc?i&cossa?va??kinummokelet?nissassa?r&belectsevrah?oproc?tsulli??silivic?t&nalp?s??vres&erp?noclatnemnorivne??zilivic??c&elloc?if-ecneics??ibihxe???ri?s&dnah?imaj?reffej?sral??t&erbepac?nilc?sob???r&e&b?dom?tsew?uab?zul??obredap??vahnebeok?wot??o&2a6v-seacinumoc--nx?ablib?c&edtra?ixemwen?sicnarfnas??elap?g&a&cihc?to??eidnas??i&cadnuf?diserp?ratno??llecitnom?mitiram?nirot?r&htna?ienajedoir???pohskrow?qari?r&aw!dloc?livic??dd?e&b&ma?yc??irrac?llimsiwel?naksiznarf?papswen?t&aeht?exe?nec!ecneics?larutluc?muesum?tra??s&ehc&nam?or??neum??upmoc???ia!nepo??obal?u&asonid?obal?takirak???s&a&l&g?l&ad?eh???xet??di&k?pardnarg??e&cneics!larutan??dnal?hcsi&deuj?rotsih!nizidem?rutan??selhcs??itinamuh?l&aw?egnasol?l&e&rutansecneics?xurb??iasrev???r&e&em?ugif??tsac??suohcirotsih?u&en?q&adac?itna!nacirema?su????õçacinumoc!elet-e-soierroc???gnirpsmlap?htab?i&lopanaidni?rap?uoltnias?xa??l&essurb?lod??mraeriflanoitan?n&a&blats?l??erdlihc?oi&snam?tacinummoc!elet-dna-stsop???äl??re&dnalf?lttes?mraf?nim?tnececneics??s&alg?erp??t&farc!dnastra??nalp?olip?ra!e&nif?vitaroced!su???su?xuaeb???u&b!muloc??cric???t&agilltrop?cejorp?dats?e&esum?kramnaidni??iorted?ne&m&elttes?norivne?piuqemraf??vnoc??oped?r&a!drib?enif?gttuts?hsiwej?kcor?n&acirema?ootrac??tamsa?yraropmetnoc??op&aes?snart?wen??ufknarf??s&a&cdaorb?octsae??ewhtuos?ilayol?nuk?r&ohnemled?uhlyram??urt???u&a&bgreb?etalpodaroloc??rmyc??w&ocsom?rn??x&esse?ineohp?nam?tas??y&a&bekaepasehc?w&etag?liar???camrahp?doc?e&hsub?l&ekreb?l&av!eniwydnarb??ort???n&dys?om??rrus?s&nreug?rejwen???golo&e&ahcra?g??motne?nh&cet?te??oz?po&rhtna?t??roh??hpargotohp?l&etalihp?imaf??m&edaca?onortsa??n&atob?yn??ps?r&a&ropmetnoc?tilim??e&diorbme?llag!tra??vocsid??lewej?nosameerf?otsih!dnaecneics?ecneics?gnivil!su??la&col?rutan??retupmoc?su??tsudnidnaecneics??spelipe?t&eicos!lacirotsih??i&nummoc?srevinu??nuoc???z&arg?iewhcs?nil?ojadab?urcatnas??моки?םילשורי???rof??z!.&ca?gro?hcs?lim?moc?o&c?fni??ten?ude?vog?zib????n&315rmi--nx?a&brud?cilbuper?f?grompj?hkaga?idraug?m?ol?ssin?u&hix?qna??varac?yalo??b!.&gro?moc?oc,ten?ude?vog??c??c!.&ah?bh?c&a?s??d&5xq55--nx?g?s?uolctnatsni,?eh?g&la0do--nx?ro??h&a?q?s??i&7a0oi--nx?h??j&b?f?t?x?z??kh?l&h?im?j??m&n?oc!.swanozama.&1-htron-nc.3s,be.1-&htron-nc,tsewhtron-nc,????n&h?l?s?y??om?qc?s&g?j??ten?ude?vog?wt?x&g?j?n?s??z&g?x??司公?絡網?络网??b??d&g!.ypnc,?ka??e&drag?erg?fuak?gawsklov?hctik?i&libommi?w??m!.r&iaper,of,??po?r!ednaalv??sier?ves??g!.&ca?gro?moc?ten?ude?vog??is&ed!.ssb,?irev???h!.&bog?cc,gro?lim?moc?ten?ude???i!.&bew,c&a?in??dni?esabapus,gro?lim?mrif?neg?oc?s&er?nduolc,?t&en?opsgolb,?ude?vog?ysrab,?elknivlac?griv?ks?lreb?p?v?w!.taht,?x??k!.&gro?ten?ude?vog???l&eok?ocnil??m!.&cyn,gro?ude?vog???o&dnol!.&fo,ni,??i&hsaf!.fo,?n&o?utiderc??siv!orue??t&a&cude!.oc,?dnuof?tsyalp??c&etorp?u&a?rtsnoc?????kin?las?mrom?nac?p&q?uoc??s&iam?nhojcs?pe?scire??t&ron?sob??zama??p!.&gro?oc?ten?ude?vog??k??r&e&c?yab??op!.eidni,??s!.&gro?moc?osrep?t&opsgolb,ra??ude?v&inu?uog????t!.&d&ni?uolcegnaro,?esnefed?gro?ltni?m&oc!nim??siruot??n&erut?if??o&fni?srep??sn&e?r??t&an?en!irga?ude??rnr??unr?vog??m??u&f?r!.&bdnevar,lper,sh,tnempoleved,??stad?xamay?y??v!.&ca?eman?gro?htlaeh?moc?o&fni?rp??t&en?ni?opsgolb,?ude?vog?zib???wo&rc?t!epac????o&76i4orfy--nx?a!.&bp?de?go?oc?ti?vg??boat??b!.&a&ci&sum?tilop??i&c&arcomed?neic??golo&ce?ncet??m&edaca?onoce??rt&ap?sudni??vilob??n&egidni?icidem??serpme?tsiver?vitarepooc??b&ew?og??dulas?e&rbmon?tr&a?op&ed?snart????g&olb?ro??ikiw?l&a&noi&canirulp?seforp??rutan??im??moc?o&fni?lbeup?rga?tneimivom??saiciton?t&askt?en?ni??ude?vt??h?iew?olg??c!.&bew?cer?dr&c,rac,?esabapus,gro?ipym,l&im?per:.di,,?m&o&c!.topsgolb,?n??rif?udon,?ofni?s&egap&dael,l,?tra??t&4n,en?ni??ude?vog??a?e?in?mara?s&edarb?ic???d!.&b&ew?og??dls?gro?lim?moc?t&en?ra??ude?vog??agoba?if?zd7acbgm--nx??e&c?d&iv?or??morafla??f!ni!.&e&g&delwonk-fo-l&errab,lerrab,?ellocevoli,?ht-skorg,rom-rof-ereh,tadpusn:d,,?llatiswonk,macrvd,ofni-v,p&i&-on,fles,?ohbew,?ruo-rof,s&iht-skorg,nd&-cimanyd,nyd,uolc,??tsrifyam,ysrab,zmurof,???g&el?n!am?ib???hwsohw?i!.&35nyd,8302,a&minifed,tad-b,?b&altig,uhtig,?c&inone:.remotsuc,,zh,?d&in,u&olc&iaznab.ppa,ropav,?rd,??e&c&apsinu.1rf-duolc,ivedniser,?donppad.sndnyd,egipa,lej,nilnigol,sufxob,t&i&beulb,snoehtnap,?newtu,ybeeb.saap,??gni&gatsniser.secived,tsohytsoh,?k&coregrof.di,orgn,ramytefasresworb,?m&oc?udon,?n&mtsp:.kcom,,yded,?ot&oq,pyrctfihs,?p&opilol,pa&-arusah,e&nalpkcab,tybeeb.1dkes,???r&e&tsneum-hf,vres&cisab,lautriv,??ial.sppa,?s&codehtdaer,gnihtbew,nemeis-om,pparevelc,tacdnas,?t&e&kcubtib,notorp,?i&belet,detfihs,kecaps,?raedon.egats,s&ohg,udgniht.&cersid.&dvreser,tsuc,?dorp.tsuc,gnitset.&dvreser,tsuc,?ved.&dvreser,tsuc,????vgib.0ku,whs,x&bslprbv.g,cq,rotide,?y&olpedew,srab,??b?d&ar?u&a?ts???j?r?syhp??j!.&eman?gro?hcs?lim?moc?ten?ude?vog???ll&ag?o??m!.&gro?moc?ten?ude?vog??g?il?mi?orp??n!.&a&0&b-ekhgnark--nx?c-iehsrgev--nx?g-lksedlig--nx?k-negnanvk--nx??1&p-nedragy--nx?q-&asierrs--nx?grebsnt--nx?lado-rs--nx?n&egnidl--nx?orf-rs--nx??regnayh--nx?ssofenh--nx??r-datsgrt--nx?s-ladrjts--nx?v-y&senner--nx?vrejks--nx???3g-datsobegh--nx?4&5-&dnaleprj--nx?goksnerl--nx?tednalyh--nx??6-neladnjm--nx?s-&antouvachb--nx?impouvtalm--nx??y-&agrjnevvad--nx?ikhvlaraeb--nx???7k-antouvacchb--nx?8&k-rekie-erv--nx?l-ladrua-rs--nx?m-darehsdrk--nx??a!.sg??bct-eimeuvejsemn--nx?d&do?iisevvad?lov?narts?uas??f&1-&l--nx?s--nx??2-h--nx??g&10aq0-ineve--nx?av?ev?lot?r&ajn&evvad?u??ájn&evvad?u????h?iz-lf--nx?j&ddadab?sel??k&el?hoj&sarak?šárák??iiv&ag&na&el?g??ŋ&ael?ág???ran???l&f?lahrevo?o&ms?s??sennev?t-&ilm--nx?tom--nx??u&-edr--nx?s??øms??muar?n&0-tsr--nx?2-dob--nx?5-&asir--nx?tals--nx??a&r!-i-om?f?t??t??douvsatvid?kiv?m&os?øs??n&od?ød??ra?sen?t&aouvatheig?ouv&a&c&ch&ab?áb??h&ab?áb???n??i&ag?ág??sa&mo?ttvid??án???z-rey--nx?ær&f?t???o&p-&ladr--nx?sens--nx??q-nagv--nx?r-asns--nx?s-kjks--nx?v-murb--nx?w-&anr&f--nx?t--nx??ublk--nx???ppol?q&0-t&baol--nx?soum--nx?veib--nx??x-&ipphl--nx?r&embh--nx?imph--nx???y-tinks--nx??r&f-atsr--nx?g-&an&ms--nx?nd--nx??e&drf--nx?ngs--nx??murs--nx?netl--nx?olmb--nx?sorr--nx??h-&a&lms--nx?yrf--nx??emjt--nx??i&-&lboh--nx?rsir--nx?y&d&ar--nx?na--nx??ksa--nx?lem--nx?r&ul--nx?yd--nx????stu??j-&drav--nx?rolf--nx?sdav--nx??kua?l-&drojf--nx?lares--nx??m-tlohr--nx?n-esans--nx?olf?p-sdnil--nx?s-ladrl--nx?tih?v-rvsyt--nx??s&a&ns?ons??i&ar?er&dron?r&os?øs???ár??la&g?h??mor!t??sir?uf?åns??t&koulo&nka?ŋká??la?p-raddjb--nx?r-agrjnu--nx?s&aefr&ammah?ámmáh??orf?r&o?ø???u-vreiks--nx??u&h-dnusel--nx?i-&drojfk--nx?vleslm--nx??j-ekerom--nx?k-rekrem--nx?u-&dnalr--nx?goksr--nx?sensk--nx??v-nekyr--nx?w-&k&abrd--nx?ivjg--nx??oryso--nx??y-y&dnas--nx?mrak--nx?n&art--nx?nif--nx??reva--nx??z-smort--nx??v!.sg?ledatskork?reiks??wh-antouvn--nx?x&9-dlofts--nx.aoq-relv--nx?d-nmaherk--nx?f-dnalnks--nx?h-neltloh--nx?i-drgeppo--nx?j-gve&gnal--nx?lreb--nx??m-negnilr--nx?n-drojfvk--nx??y&7-ujdaehal--nx?8-antouvig--nx?b-&dlofrs--nx?goksmr--nx?kivryr--nx?retslj--nx??e-nejsom--nx?f-y&krajb--nx?re&dni--nx?tso--nx??stivk--nx??g-regark--nx?orf?ørf??z9-drojfstb--nx??b&25-akiivagael--nx?53ay7-olousech--nx?a&iy-gv--nx?le-tl&b--nx?s--nx??n0-ydr--nx??c&0-dnal-erdns--nx?z-netot-erts--nx??g&g-regnarav-rs--nx?o-nejssendnas--nx??ju-erdils-ertsy--nx?nj-dnalh-goksrua--nx?q&q-ladsmor-go-erm--nx.&ari-yreh--nx?ednas??s-neslahsladrjts--nx???ca&4s-atsaefrmmh--nx?8m-dnusynnrb--nx?il-tl--nx?le-slg--nx?n5-rdib--nx?op-drgl--nx?uw-ynnrb--nx??d&a&qx-tggrv--nx?reh!nnivk?sd&ork?ørk??uas??ts&e&bi?kkar?llyh?nnan??g&ort?ørt??k&alf?irderf??levev?mirg?obeg&ah?æh??r&ah?ejg????barm-jdddb--nx?ie!rah?s&etivk?ladman???lof&r&os?øs??ts&ev.ednas?o.relav?ø.relåv???n&a&l&-erd&n&os?øs??ron??adroh.so?dron.&a&g5-b--nx?ri-yreh--nx??ob?y&oreh?øreh??øb??e&m!lejh??pr&oj?øj??vi??gyb?n&aks?åks??o&h-goksrua?rf??r&o?ua?ø??tros?øh-goksrua??rts!e&devt?lab?mloh???s&ellil?naitsirk?rof???u&l!os??s!d&im?lejt??e&guah?l&a?å???kkoh?lavk?naitsirk?r&af?eg&e?ie???tef?y&onnorb?ønnørb?????r&a&blavs!.sg??g&eppo?la???o&j&f&a!dniv?k?vk??die?e&dnas?kkelf??llins?r&iel?ots??s&lab?t&ab?åb??yt??å!k??ævk??les??ts??åg&eppo?lå???ureksub.sen??e&ayb-yrettn--nx?d&ar?lom?r&of?øf??år??g&gyr?nats??i&meuv&ejsem&aan?åån??sekaal??rjea??j&d&ef?oks??les??k&er&aom?åom??hgna&ark?årk??iregnir?kot!s??s&ig?uaf???l&bmab?kyb?l&av?ehtats??oh??m&it?ojt?øjt??n&arg?g&os?øs??meh?reil?te?ummok?yrb??r&dils-erts&ev?y&o?ø???ua?vod??sa&ans?åns??t&robraa?spaav??urg??f&62ats-ugsrop--nx?a&10-ujvrekkhr--nx?7k-tajjrv-attm--nx??o!.sg?h??s!.sg??v!.sg???g&5aly-yr&n--nx?v--nx??a&llor?ve&gnal?lreb???n&av!snellu??org??oks&die?m&or?ør??ner&ol?øl??r&o?ø???r&eb!adnar?edyps?s&die?elf?gnok?n&ot?øt????obspras??uahatsla?åve&gnal?lreb???h&0alu-ysm--nx?7&4ay8-akiivagg--nx?5ay7-atkoulok--nx??a!.sg???i&e&hsr&agev?ågev??rf??k&h&avlaraeb?ávlaraeb??s??lm&a?å??mpouvtal&am?ám??pph&al?ál??rrounaddleid?ssaneve?ššáneve??j&0aoq-ysgv--nx?94bawh-akhojrk--nx??k&a&b&ord?ørd??jks?lleis??iv!aklejps?l&am?evs?u??mag?nel?ojg?r&a&l?n??epok?iel?y&or?ør???s&ah?kel?om??øjg??kabene?ojsarak?ram&deh.&aoq-relv--nx?rel&av?åv??so??e&let.&ag5-b--nx?ob?øb??ra???åjks??l&a!d&anrus?d&numurb?ron??e&gnard?nte?s&meh?sin??ttin??g&is?nyl??kro?l&em?l&ejfttah?of??u&ag-ertdim?s???n&am?era?gos?i&b?nroh?r??kos?nus?oj??o-&dron?r&os?øs???ppo?r&a!l?nram??e&gne?l?v??is?o&jts?ts??u&a-&dron?r&os?øs???h??å?æl?øjts??s&e&jg?nivk?ryf??kav?mor-go-er&om.&ednas?yoreh??øm.&ednas?yøreh???uag??t&las?rajh?suan??v&l&a?e-rots??u-go-eron??yt??ksedlig?res&a?å???bib&eklof?seklyf??es!dah??h!.sg??i&m?syrt??l&ejf?ov&etsua?gnit?ksa?sdie???n!.sg??o!.sg?boh?g?h??r!.sg??å!ksedlig??øboh??m&a&rah?vk??f!.sg??h!.sg??i&e&h&dnort?rtsua?ssej??rkrejb??ksa??ol?t!.sg??u&dom?esum?r&ab?drejg?evle?os?uh?æb?øs??ttals???n&a&g&av?okssman?åv??jlis?or?r&g?rev???e&d&do&sen?ton??lah?r&agy&o?ø??ojfsam???g&iets?n&a&l&as?lab??n&avk?ævk??t&arg?ddosen??v&al?essov???i&d&ol?øl??l&ar?ær???yl??reb??iks?k&srot?y&or?ør???l&a&d&gnos?n&er?ojm?øjm??om??tloh??ug?åtloh??mmard?ojs&om?sendnas??ppolg?s&lahsladr&ojts?øjts??o??t&o&l?t-erts&ev?o?ø???roh?øl??vly&kkys?nav??yam-naj!.sg??øjs&om?sendnas???g&orf?ujb??i&dnaort?vnarg??kob?ladendua?maherk&a?å??n&it?urgsrop??orf-&dron?r&os?øs???r&aieb?evats??sfev?uaks?yrts??o&6axi-ygvtsev--nx?c,d&ob?rav??ievs?kssouf?l&m&ob?øb??ous&adna?ech&ac?áč???so!.sg???msdeks?niekotuak?r&egark?olf?y&oso?øso???s&dav?mort???p&ed?ohsdaerpsym,p&akdron?elk???r&a&d&dj&ab?áb??iab??jtif?luag?mah?vsyt??e&gn&a&k&iel?ro??merb?n&at?mas??rav-r&os?øs??srop?talf?v&ats?el??y&oh?øh???ivsgnok??il?jkniets?k&a&nvej?rem?s&gnir?nellu???ie-er&den?v&o?ø???ram?sa?årem??la&jf?vh??m&b&ah?áh??mahellil??nnul?ts&l&oj?øj??ul??y&o?ø???imp&ah?áh??m!.sg??osir?t!.sg??ádiáb?ævsyt?øsir??s&adnil?en&dnas?e&dga?k&ri&b?k??som??ve??me&h?jg??nroh-go-ejve?s&a?ednil?k&o?ø??of?yt?å??tsev??gv?hf?igaval?o&r&or?ør??sman??so&fen&oh?øh??m?v??uh&lem?sreka.sen??å!dnil???t&a&baol?g&aov?grav??jjr&av-attam?áv-attám??l&a&b?s??ás??soum?ts?v&eib?our???e&dnaly&oh?øh??f?s&nyt?rokomsdeks?sen??vtpiks??in&aks?áks??loh&ar?år??n!.sg??o&m&a?å??psgolb,?s!.sg?efremmah?or?ør??terdi?á&baol?ggráv?lá&b?s??soum?veib???u&b!.sg?alk?e&dna?gnir?nner??les?ælk??dra&b?eb??g&nasrop?vi?ŋásrop??j&daehal&a?á??jedub?v&arekkhar?árekkhár???ksiouf?n&diaegadvoug?taed???v&irp?lesl&am?åm???y&b&essen?nart?sebel?tsev??o&d&ar?na!s??or??gavtsev?k&rajb?sa??lem?mrak?n&art?n&if?orb???r&a&mah?n?v??e&dni?t&so?ton??va??ul?yd??s&am?enner?gav?lrak?tivk??vrejks??ø&d&ar?na!s??ør??gåvtsev?k&rajb?sa??lem?mrak?n&art?n&if?ørb???r&e&dni?t&so?tøn??va??ul?yd?æ&n?v???s&enner?gåv?tivk?åm??vrejks???á&slág?tlá?vreiks??å&gåv?h?jddådåb?lf??ø&d&ob?rav??r&egark?olf??s&dav?mort????aki?i&sac?tal??u??o&b?f?g?hay?o?ttat??r!.&cer?erots?gro?m&o&c?n??rif?t??o&c,fni??pohs,stra?t&n?opsgolb,?www??e&a!.&a&ac?cgd?idem??bulc!orea??ci&ffartria?taborea??e&cn&a&l&lievrus-ria?ubma??netniam?rusni??erefnoc??gnahcxe?mordorea?ni&gne?lria?zagam??rawtfos??gni&d&art?ilg!arap?gnah???l&dnahdnuorg?ledom??noollab?retac?sael?t&lusnoc?uhcarap??vidyks??hcraeser?l&anruoj?euf?icnuoc?ortnoc!-ciffart-ria???n&gised?oi&nu?t&a&cifitrec?ercer?gi&tsevni-tnedicca?van??i&cossa!-regnessap??valivic??redef??cudorp?neverp-tnedicca????ograc?p&ihsnoipmahc?uorg!gnikrow???r&e&dart?enigne?korb?niart?trahc??o&htua?tacude???s&citsigol?e&civres?r??krow?serp!xe??tnega??t&farcr&ia?otor??hgil&f?orcim??liubemoh?n&atlusnoc?e&duts?m&esuma?n&iatretne?revog??piuqe????olip?ropria?si&lanruoj?tneics???w&erc?ohs??y&cnegreme?dobper?tefas????rref?z??p!.&a&aa?ca?pc??dem?ecartsnd.icb,gne?r&ab?uj??snduolc,t&acova?cca?hcer??wal?ysrab,???s!.&em?gro?hcs,moc?ten?ude?vog???t!.&116,ayo,gro?lim?moc?nayn,sulpnpv,t&cennockciuq.tcerid,en??ude?v&dr,og???o&hp?m?v?yk??tol?ua??v&iv?lov??xas?ykot??p&a&ehc?g?m?s??eej?g!.&gro?ibom?moc?ossa?ppa,ten?ude???i&r!.nalc,?v?z??j!.&a&3&5xq6f--nx?xqi0ostn--nx??5wtb6--nx?85uwuu--nx?9xtlk--nx?bihc!.&a&bihciakoy?don?ma&him?ye&ragan?tat???r&a&bom?gan?hihci??u&agedos?kas?ustak???s&os?ufomihs??t&amihcay?iran??w&a&g&im&anah?o??omak??kihci?zustum??ihsak??y&agamak?imonihci???e&akas?nagot??i&azni?esohc?h&asa?s&abanuf?ohc???ka&to?zok??musi?orihs?r&akihabihsokoy?o&dim?tak??ukujuk??usihs??nano&hc?yk??o&d&iakustoy?ustam??hsonhot?k&a&rihs?t??iba??nihsaran?sobimanim?tas&arihsimao?imot??uhc?yihcay??u&kujno?s&ayaru?t&imik?tuf???zarasik????g&as!.&a&gas?m&a&tamah?yik??ihsak??rat?t&a&gatik?hatik??ira!ihsin????e&kaira?nimimak??i&akneg?g&aruyk?o??h&c&amo?uo??siorihs??kaznak?modukuf?ra&gonihsoy?mi???nezih?u&k&at?ohuok??s&ot?tarak?????ihs!.&a&kok?m&a&hagan?yirom??ihsakat??rabiam?wagoton??e&miharot?nokih??houyr?i&azaihsin?esok?kustakat?moihsagih??na&mihcahimo?nok??o&hsia?mag?t&asoyot?ok?tir???us&ay?t&asuk?o??????k&aso!.&a&d&awihsik?eki??k&a&noyot?s&akaayahihc?oihsagih???oadat?uziak??m&ayas!akaso??odak??r&a&bustam?wihsak??ediijuf??t&akarih?i&k?us???wag&ayen?odoyihsagih???e&son?tawanojihs??honim?i&akas?h&cugirom?s&ayabadnot?i&a&kat?t??n??oyimusihsagih???k&a&rabi?sim??ustakat??muzi?r&ijat?otamuk???nan&ak?n&ah?es???o&ay?n&a&ganihcawak?simuzi?tak??eba?ikibah?oyot??t&anim?iad?omamihs??uhc??ust&oimuzi?tes????ou&kuf!.&a&d&amay?eos??g&no?ok?usak??hiku?k&awayim?uzii??ma&kan?y&asih?im???rawak?t&a&gon?ka&h?num?t???umo??wa&g&a&kan?nay?t??ias??ko!rih???y&ihsa?usak???e&m&ay?uruk??taruk?us??i&a&nohs?raihcat??goruk?h&cukuf?s&a&gih?hukuy??in???k&a&gako?muzim??iust?o?ustani??m&anim?otihsoynihs?u??r&ogo?ugasas??usu??ne&siek?zu&b?kihc???o&gukihc?h&ak?ot?ukihc??j&ono?ukihc??kayim?nihsukihc?to?uhc??u&fiazad?gnihs?stoyot????zihs!.&a&bmetog?d&amihs?eijuf?ihsoy?omihs??kouzihs?mihsim?ra&biah?honikam??tawi?wa&g&ekak?ukik??kijuf??yimonijuf??i&a&ra?sok??hcamirom?juf?kaz&eamo?ustam??ma&nnak?ta??nukonuzi?orukuf??nohenawak?o&nosus?ti??u&stamamah?z&a&mun?wak??i!ay?i&hs&agih?in??manim??mihs????????m&a&tias!.&a&d&ihsoy?ot?usah??k&a&dih?sa??o&arihs?s???m&a&tias?y&as?o&rom?tah??ustamihsagih???i&hsagurust?jawak??uri??ni?wa&g&e&ko?man??ikot?o??k&ara?i&hsoy?mak???ru?zorokot??y&a&g&amuk?ihsok?otah??kuf??imo??ziin??e&bakusak?ogawak?sogo?ttas?zokoy??i&baraw?h&cugawak?s&oyim?ubustam???iroy?k&ato?ihs?u&k?stawi???m&akoyr?i&hsoy?juf??uziimak???naznar?o&dakas?ihsay?jnoh?n&a&go?nim??imijuf?nah?oy??r&ihsayim?otagan??t&asim!ak??igus?omatik??zak??u&bihcihc!ihsagih??sonuok?ynah????y&ak&aw!.&a&d&ira?notimak??kadih?ma&h&arihs?im??y&a&kaw?tik??oduk???ru&ustakihcan?y??sauy?wa&g&a&dira?zok??orih??konik??yok?zok??e&banat?dawi??i&garustak?jiat?mani??naniak?o&bog?nimik?t&asim?omihs&ah?uk????ugnihs???o!.&a&jos?koasak?m&ay&ako?ust??ihsayah??r&abi?ukawaihsin??wi&aka?nam???e&gakay?kaw??i&gan?h&cu&kasa?otes??sahakat??k&asim?ihsaruk??miin??n&anemuk?ezib??o&hsotas?jnihs?n&amat?imagak??ohs?uhcibik?????ot!.&a&damay?got?koakat?may&etat?ot??nahoj?riat?waki&inakan?reman???eb&ayo?oruk??i&h&asa?ciimak?sahanuf??kuzanu?m&an&i?ot??ih???nezuyn?otnan?u&hcuf?stimukuf?z&imi?ou???????ihs&o&gak!.&a&m&ayuok?ihsogak??si?yonak??e&banawak?n&at&akan?imanim??uka??tomoonihsin??i&adnesamustas?k&azarukam?oih??m&ama?uzi??usuy??nesi?o&knik?os?tomustam??uzimurat???rih!.&a&ka&n?s??m&ayukuf?i&hsorihihsagih?j&ate?imakikaso????r&a&bohs?h&ekat?im???es??tiak?wiad??e&kato?ruk??i&h&ci&akustah?mono?nihs??s&inares?oyim???manimasa?uk??negokikesnij?o&gnoh?namuk??uhcuf????uk&ot!.&a&bihci?mi&hsu&kot?stamok??m??wagakan??egihsustam?i&gum?h&coganas?soyim??kijaw?m&anim?uzia??ukihsihs??nan&a?iak??o&nati?turan????uf!.&a&batuf?m&a&to?y&enak?irok???ihs&im?ukuf??os?uko??r&aboihsatik?uganat??ta&katik?mawak?rih??w&a&g&akus?emas?uy??k&a&mat?rihs?sa??ihsi??nah??ohs???e&gnabuzia?iman?ta&d?tii???i&adnab?enet?hs&agih?iimagak??k&a&wi?zimuzi??ubay??minuk?r&ook?ustamay???nihsiat?o&g&etomo?ihsin?nan?omihs??no!duruf?rih??rihsawani?ta&may?simuzia???u&rahim?stamakawuzia?zia&ihsin?nay???????nug!.&a&bawak?doyihc?k&anna?oi&hsoy?juf?mot???m&ayakat?ustagaihsagih??n&ihsatak?nak??r&ahonagan?nak?o?u&kati?mamat???t&amun?inomihs?o??w&akubihs?iem?ohs???i&hsa&beam?yabetat??kas&akat?esi??m&akanim?uzio??ogamust?rodim??o&jonakan?n&eu?oyikust??tnihs??u&komnan?stasuk?yrik?????ran!.&a&bihsak?d&akatotamay?u!o???guraki?m&ay&atik&imak?omihs??irokotamay??oki??ra&hihsak?n??wa&geson?knet???e&kayim?ozamay?sog?ustim??i&a&rukas?wak??garustak?h&ciomihs?sinawak??jo?ka&mnak?toruk??makawak?nos?r&net?otakat?ugeh???o&d&na?oyo??gnas?jnihs?nihsoy!ihsagih??tomarawat?yrok????t&ag&amay!.&a&dihsio?k&atarihs?ourust??may&a&kan?rum??enak?onimak??rukho?ta&ga&may?nuf??hakat?kas??wa&g&ekas?orumam??ki&hsin?m??z&anabo?enoy?ot???zuy??e&agas?bonamay?dii?nihsagih?o??i&a&gan?nohs??h&asa?sinawak??nugo??o&dnet?jnihs?ynan??ukohak???iin!.&a&ga?k&ium?oagan??munou!imanim??t&a&bihs?giin??ioy??w&a&gioti?kikes?zuy??irak??yijo??e&kustim?mabust??i&aniat?hcamakot?kaz&awihsak?omuzi??m&a&gat?karum??o???n&anust?esog??o&das?ihcot?jnas?k&ihay?oym??mak?naga?ries??u&ories?steoj?????i&ka!.&a&go?k&asok?oimak??t&ago!rihcah??ika!atik???w&aki?oyk???e&mojog?natim?suranihsagih?t&ado?okoy???i&hsoyirom?magatak?naokimak??nesiad?o&hakin?jnoh!iruy??nuzak?rihson?tasi&juf?m??yjnoh??u&kobmes?oppah????o!.&a&dakatognub?m&asah?ihsemih??su?t&ekat?i&h?o????e&onokok?ustimak??i&jih?k&asinuk?ias?usu??mukust??onoognub?u&fuy?juk?ppeb?suk??????wa&ga&k!.&a&mihsoan?rihotok?waga&kihsagih?ya???emaguram?i&j&nonak?ustnez??kunas?monihcu??o&hsonot?nnam?yotim??u&st&amakat?odat??zatu????nak!.&a&dustam?kus&okoy?tarih??maz?nibe?r&a&gihsaimanim?h&esi?imagas??wa&do?guy???u&im?kamak???tikamay?wa&k&ia?oyik?umas??sijuf??yimonin??e&nokah?saya??i&akan?esiak?gusta?hsuz?kasagihc?o?ukust??o&nadah?sio?tamay?????kihsi!.&a&danihcu?gak?kihs?mijaw?t&abust?ikawak??wazanak??i&gurust?hcionon?mon?ukah??nasukah?o&anan?ton!akan???u&kohak?stamok?z&imana?us?????niko!.&a&han?m&arat?ijemuk?uru??n&e&dak?zi??no??ra&hihsin?rih??wa&kihsi?niko??yehi?zonig??e&osaru?seay??i&hsagih?jomihs?k&a&gihsi?not??ihsakot??m&a&ginuk?kihsug?maz??igo?otekat??nuga!noy???n&a&moti?timoy?wonig??i&jikan?k???o&gan?jnan?tiad&atik?imanim???u&botom?kusug&akan!atik??imot??rab&anoy?eah???????c&204ugv--nx?462a0t7--nx?678z7vq5d--nx?94ptr5--nx?a??d&17sql1--nx?3thr--nx?5&20xbz--nx?40sj5--nx??7&87tlk--nx?ptlk--nx??861ti4--nx?a?e??e&16thr--nx?5&1a4m2--nx?9ny7k--nx??im!.&a&bot?k&asustam?uzus??m&a&him?y&emak?im???ihs??nawuk?wi&em?k???e&bani?ogawak?si!imanim???i&arataw?gusim?h&asa?ciakkoy??k&a&mat?sosik?t??iat??raban??o&dat?hik?n&amuk?ihseru?o&du?mok????ust???mihe!.&a&m&a&h&ataway?iin??yustam??ij&awu?imak???taki!man???ebot?i&anoh?kasam?rabami??n&ania?egokamuk?oot??o&jias?kihcu?nustam?uhcukokihs?yi!es???u&kohik?zo????n!.&nriheg,teniesa.resu,?amihs!.&a&d&amah?ho?usam??kustay?m&a?ihsoni&hsin?ko???wakih??e&namihs?ustam??i&g&aka?usay??konikak?mikih??nannu?o&mu&kay?zi!ihsagih?uko???nawust?tasim??u&stog?yamat?????tawi!.&a&bahay?d&amay?on??koirom?t&a&honat?katnezukir??imus??w&as&ijuf?uzim??ihs???e&hon&i&hci?n??uk??tawi??i&a&duf?murak?wak??h&custo?si&amak?ukuzihs???j&oboj?uk??k&a&m&anah?uzuk??sagenak??esonihci??m&akatik?uzia&rih?wi????o&kayim?no&rih?t??tanufo??uhso????g&3zsiu--nx?71qstn--nx?l??h&03pv23--nx?13ynr--nx?22tsiu--nx?61qqle--nx??i&54urkm--nx?g&ayim!.&a&dukak?m&a&goihs?kihs??ihsustam!ihsagih??unawi??r&awago?iho??ta&bihs?rum??w&a&gano?kuruf??iat??y&imot?ukaw???e&mot?nimes??i&hsiorihs?ka&monihsi?s&awak?o???mak?r&ataw?o&muram?tan????o&az?jagat?t&asim?omamay???u&fir?k&irnasimanim?uhsakihcihs?????ihcot!.&a&g&a&h?kihsa??ust??kom?m&ay&o?usarak??unak??r&a&boihsusan?watho??iho?ukas??t&akihsin?iay??wa&konimak?zenakat??y&imonustu?oihs???e&iiju?kustomihs?nufawi??i&akihci?g&etom?ihcot?on???o&k&ihsam?kin??nas?sioruk?tab??u&bim?san?????h&c&ia!.&a&dnah?m&a!h&akat?im??yuni??ihs&ibot?ust???r&a&hat?tihs??ik?u&ihsagih?kawi???t&ihc?o&k?yot???wa&koyot?zani??yi&monihci?rak???e&inak?k&aoyot?usa??manokot?noyot??i&a&gusak?kot?sia??eot?h&asairawo?cugo?s&ahoyot?oyim???k&a&mok?zako??ihssi??motay?rogamag??n&an&ikeh?ok??ihssin??o&got?ihsin?jna?rihsnihs?suf?tes??u&bo?raho?s&oyik?takihs??yrihc?zah????ok!.&a&dusay?kadih?mayotom?r&ah&im?usuy??umakan??sot!ihsin??wa&g&atik?odoyin??k&as?o????i&esieg?hco!k??jamu?k&a!sus??usto??ma&gak?k??rahan??o&mukus?n&i?ust!ihsagih???torum?yot!o???u&koknan?zimihsasot????ugamay!.&a&m&ayukot?ihso??toyot??e&bu?subat??i&gah?kesonomihs?nukawi?rakih??nanuhs?otagan?u&ba?foh?otim?stamaduk?uy?????sanamay!.&a&dihsoyijuf?mayabat?r&ahoneu?ustakihsin??w&a&k&ayah?ijuf??suran??ohs???egusok?i&ak?h&cimakan?s&anamay?od???k&asarin?u&feuf?sto????o&k&akanamay?ihcugawakijuf??nihso?t&asimawakihci?ukoh??uhc??spla-imanim?u&b&nan?onim??fok?hsok?rust?????ka&rabi!.&a&bukust?gok?kan!ihcatih??m&a&sak?timo?wi??ihsak?ustomihs??ni?r&a&hihcu?way??u&agimusak?ihcust???t&ag&amay?eman??oihcatih??w&ag&arukas?o??os??yi&moihcatih?rom???e&bomot?dirot?not?tadomihs??i&a&k&as?ot??rao??esukihc?gahakat?h&asa?catih??k&a&rabi?saguyr??ihsani?uy??ma?rukustamat??o&dnab?giad?him?kati?rihsijuf?soj?t&asorihs?im??yihcay??u&fius?kihsu?simak????sagan!.&a&m&abo?ihsust??natawak?r&abamihs?u&mo?ustam???wijihc?yahasi??i&akias?hies?k&asagan?i??masah??neznu?o&besas?darih?t&eso?og!imaknihs????ust&igot?onihcuk?uf????zayim!.&a&biihs?guyh?k&oebon?ustorom??mihsuk?r&emihsin?uatik??ta&katik?mim??wag&atik?odak??ya??e&banakat?sakog??i&hsayabok?kaza&kat?yim??m&animawak?ot&inuk?nihs????nanihcin?o&j&ik?onokayim??n&ibe?ust??tias??urahakat????ro&moa!.&a&dawot?turust?wasim??e&hon&ihc&ah?ihs??nas?og?ukor??sario??i&anarih?ganayati?hsioruk?jehon?kasorih?makihsah?nawo?r&amodakan?omoa???o&gnihs?kkat??u&ragust?stum????ttot!.&a&r&ahawak?uotok??sa&kaw?sim???egok?irottot?nanihcin?o&ganoy?nih?tanimiakas??u&bnan?z&ay?ihc??????ukuf!.&a&deki?gurust?ma&bo?h&akat?im??yustak??sakaw??eabas?i&akas?ho?jiehie?ukuf??nezihce!imanim??ono????k&26rtl8--nx?4&3qtr5--nx?ytjd--nx??522tin--nx?797ti4--nx??l33ussp--nx?m&11tqqq--nx?41s3c--nx??n&30sql1--nx?65zqhe--nx?n7p7qrt0--nx??o&131rot--nx?7qrbk--nx?c?diakkoh!.&a&deki?gakihset?hcebihs?k&adih?u&fib?narihs???m&ayiruk?hot?ihs&orihatik?ukuf??oras?usta??r&ib&a!ka??o?uruf??ozo?u&gakihsagih?oyot???sakim?ta&gikust?mun??w&a&ga&k&an?uf??nus!imak???k&aru?i&h&asa?sagih??kat?mak??omihs?um??zimawi??ine?oyk??yot??e&a&mustam?nan??b&a&kihs?yak??o&noroh?to???ian?k&ihsam?ufoto??nakami?ppoko!ihsin??sotihc?tad!okah??uonikat??i&a&bib?mokamot?n&a&k&kaw?oroh??wi??eomak?ihsatu?okik?usta&moruk?sakan????eib?h&c&ioy?u&bmek?irihs???s&ase?ekka?oknar?uesom???jufirihsir?k&amamihs?i&at?n???m&atik?otoyot??oa&kihs?rihs??r&a&hs?kihsi?mot??ihs&aba?ir??otarib???n&a&hctuk?rorum?se?tokahs??uber??o&kayot?m&ire?ukay??naruf!ima&k?nim???orih?r&ih&ibo?suk??o&bah?h&i&b?hsimak??sa??pnan?yan??umen??t&asoyik?eko?ukoh???u&bassa?kotnihs?m&assaw?uo??pp&akiin?en&ioto?nuk??ip??rato?s&akat?t&eb&e?i&a?hs!a??robon??m&e?o&m?takan???no&h?tamah??o&mik?s?t??u&kir?ppihc?st???onihsnihs?ufuras??uaru??yru!koh??zimihs!ok?????g!oyh!.&a&bmat?dnas?gusak?k&at?o&oyot?y??uzarakat??m&ayasas?irah??wa&g&ani?okak??k&i&hci?mak??oy???yi&hsa?monihsin???i&asak?hs&aka?i&at?nawak???j&awa!imanim??emih??k&a&goa?s&agama?ukuf??wihsin??i&hsog?m???mati?oia?rogimak??n&annas?esnonihs??o&gasa!kat??ka?n&ikat?o?ustat??rihsay?sihs?tomus?yas??u&bay?gnihs?????nagan!.&a&bukah?d&a&w?yim??e&ki?u??ii??k&a&s&ay?uki??zus??ihsoo?ousay??m&ay&akat?ii??i&hsukufosik?jii??ukihc??n&i!hsetat??uzii??r&ah?ugot??saim?t&agamay?oyim??w&a&g&a&kan?n??o??kustam?ziurak??onim!imanim??u&koo?s!omihs????ya&ko?rih???e&akas?nagamok?subo??i&gakat?h&asa?c&a!mo!nanihs???uonamay??sukagot??k&a&kas?mimanim?to??ia&atik?imanim??oa?uzihcom??m&akawak?ijuf?o!t???r&ato?ijoihs?omakat???n&ana?esnoawazon??o&hukas?n&a&gan?kan??i&hc?muza??ustat??romok?si&gan?k??tomustam??u&k&as?ohukihc??stamega????to&mamuk!.&a&gamay?rahihsin?sukama!imak??tamanim??enufim?i&hcukik?k&ihsam?u??nugo!imanim??romakat??o&ara?rihsustay?sa?t&amay?om&amuk?us??u!koyg???yohc??u&sagan?zo????yk!.&a&bmatoyk?k&ies?oemak?uzaw??mayi&h&cukuf?sagih??muk??nihsamay?rawatiju?t&away?ik???e&ba&nat!oyk??ya??di?ni??i&ju?kazamayo?manim??natnan?o&gnatoyk?kum?mak?rihsamayimanim?y&gakan?ka&koagan?s??oj???u&ruziam?z&ayim?ik??????wtc1--nx?ykot!.&a&d&i&hcam?mus??oyihc??k&atim?ihsustak??m&a&t!uko??yarumihsa&gih?sum???i&hs&agoa?ika?o!t??uzuok??ren???r&a&honih?wasago??iadok?umah??ssuf?t&ik?o??wa&g&anihs?ode??k&ara?ihcat???y&agates?ubihs???e&amok?donih?m&o?urukihsagih??soyik??i&enagok?gani?h&ca&da?tinuk??sabati??j&nubukok?oihcah??manigus??o&huzim?jihcah?n&akan?ih!sasum??urika??rugem?t&a&mayihsagih?nim??iat?ok??uhc?yknub??u&fohc?hcuf?kujnihs?????r&2xro6--nx?g?o??s&9nvfe--nx?xvp4--nx??t&netnocresu,opsgolb,?u&4rvp8--nx?fig!.&a&d&eki?ih??kimot?m&ayakat?ihsah??ne?raha&gi&kes?makak??sak??taga&may?tik??wa&g&ibi?ustakan??karihs!ihsagih????e&katim?uawak??i&gohakas?hc&apna?uonaw??k&ago?es?ot??m&anuzim?ijat??nak?urat??nanig?o&dog?jug?makonim?nim?roy?sihcih??u&fig?s&otom?t&amasak?oay???????x5ytlk--nx?yu6d27srjd--nx?z72thr--nx?井福?京東?分大?取鳥?口山?城&宮?茨??媛愛?山&富?岡?歌和??岡&福?静??島&児鹿?広?徳?福??崎&宮?長??川&奈神?石?香??庫兵?形山?手岩?木栃?本熊?根島?梨山?森青?潟新?玉埼?田秋?知&愛?高??縄沖?良奈?葉千?賀&佐?滋??道海北?都京?重三?野長?阜岐?阪大?馬群???k!.&art?gro?moc?per?ude?vog???l&eh?l??m!.uj,ac?j??nd?o&g?h&pih?s!.ysrab,??lnud?oc?t!.&lldtn,snd-won,???pa!.&0mroftalp,arusah,bew:erif,,e&niln&igol,okoob,?tupmocegde,?lecrev,n&aecolatigidno,ur:.a,,?poon,remarf,t&ibelet,xenw,?yfilten,??ra&a?hs??u&ekam?llag?org!.esruocsid,cts?kouk?nayalo???vsr?xece4ibgm--nx??q&a!3a9y--nx??g?i!.&gro?lim?moc?ten?ude?vog???m?se??r&a!.&acisum?bog?gro?lim?moc!.topsgolb,?rut?t&en?ni??ude?vog??4d5a4prebgm--nx?b?c?eydoog?los?t&at?s!uen???ugaj??b!.&21g?a&b&a&coros?iuc??itiruc??cnogoas?dicerapa?gniram?i&naiog?ramatnas??n&erom?irdnol??op?p&acam?irolf?ma&j?s???rief?tsivaob??b!aj?ib?mi?sb??c&ba?e&r?t??js?sp?t!e???d&em?mb?n&f?i??rt??e&dnarganipmac?ficer?ht?llivnioj?rdnaotnas??f&dj?ed?gg?n&e?i???g&e&l!.&a&b,m,p,?bp,c&a,s,?e&c,p,s,?fd,gm,ip,jr,la,ma,nr,o&g,r,t,?p&a,s,?r&p,r,?s&e,m,r,?tm,??s??l&s?z??n&c?e?o??ol!b?f?v??pp?ro??hvp?i&du?kiw?nana?oretin?r&c?eurab??sp?te?xat??l&at&an?rof??el?im?sq??m&a?da?e&gatnoc?leb??f?ic?oc!.&duolclautriv.elacs.sresu,topsgolb,???nce?o&ariebir?c&e?narboir?saso??d&o?ranreboas??e&g?t??i&b?dar?ecam?r??rp?t&a?erpoir???p&er?m!e?t??ooc?pa?se??qra?r&af?ga?o&davlas?j??tn?ut??s&a&ixac?mlap?nipmac??ed?u&anam?j?m???t&am?e&d?n?v??nc?o&f?n??ra?sf??u&caug9?de?ja?rg??v&da?ed?og!.&a&b?m?p??bp?c&a?s??e&c?p?s??fd?gm?ip?jr?la?ma?nr?o&g?r?t??p&a?s??r&p?r??s&e?m?r??tm???rs?t??xiv?z&hb?ls?o&c?f?????c!.&as?ca?de?if?o&c?g??ro???e&bew?ccos?dnik?e&b?n&igne?oip??rac??gni&arg?rheob??h&cor?sok?t&aew?orb???itnorf?k&col?o&p?rb???l&aed?ffeahcs??mal?nes?pinuj?t&a&eht?rebsnegömrev??law?nec?s&acnal?nom?ubkcolb??upmoc??v&o&c&sid?tfiws??rdnal??resbo??wulksretlow?ywal?zifp??f!.&aterg?bew-no,drp?e&c&itsuj-reissiuh?narf-ne-setsitned-sneigrurihc,?lipuog,rianiretev??hny,i&cc?rgabmahc??m&o&c?n??t??n&eicamrahp?icedem??ossa?pohsdaerpsym,s&e&lbatpmoc-strepxe?riaton?tsitned-sneigrurihc?uova??o&-x&bf,obeerf,?x&bf,obeerf,???t&acova?o&or-ne,psgolb,?r&epxe-ertemoeg?op!orea????vuog??avc7ylqbgm--nx?s??g!.&gro?moc?t&en?opsgolb,?ude?vog???h!.&e&erf,man??mo&c?rf??topsgolb,zi??ur??i!.&a&61f4a3abgm--nx?rf4a3abgm--nx??ca?di?gro?hcs?oc?ten?vog?نار&يا?یا???a&h?per??ew?lf??k!.&c&a?s??e&n?p?r??gk?iggnoeyg?kub&gn&oeyg?uhc??noej??l&im?uoes??man&gn&oeyg?uhc??noej??n&as&lu?ub??o&e&hcni?jead??wgnag???o&c?g??ro?s&e?h?m??topsgolb,u&gead?j&ej?gnawg????cilf??l!.&gro?moc?ten?ude?vog???m!.&topsgolb,vog???n!.&gro?moc?ofni?ten?ude?vog?zib???o&htua?odtnorf?t&c&a?od??laer???p!.&alsi?ca?eman?forp?gro?moc?o&fni?rp??t&en?se??ude?vog?zib???s?t!.&21k?bew?cn!.vog??eman?gro?kst?l&e&b?t??im?op??moc!.topsgolb,?neg?ofni?pek?rd?sbb?ten?ude?v&a?og?t??zib??f?m??ubad?vd??s&8sqif--nx?9zqif--nx?a!.vog?birappnb?gev?lliv?mtsirhc?s??b!.&ew,gro?moc?ten?ude?vog??c?oj?s?u??c&i&hparg?p?t&sigolyrrek?ylana???od??d&a?d?l?n&iwriaf?omaid??oogemoh?rac??e!.&bog?gro?mo&c!.topsgolb,?n??pohsdaerpsym,ude??civres!.enilnigol,?d&d2bgm--nx?oc??h&ctaw?guh??i&lppus?rtsudni?treporp!yrrek???jaiv?l&aw?cycrotom?etoh?gnis?pats??m&ag?oh?reh??nut?ohs?picer?r&it?ut&cip!.7331,?nev???s!i&rpretne?urc??ruoc??taicossa?vig??g!nidloh??h5c822qif--nx?i!.&ekacpuc,gro?moc?t&en?ni?opsgolb,?ude?vog??a09--nx?nnet?rap?targ??k&c&or!.&ecapsbew,snddym,ytic-amil,??us??hxda08--nx?row??l!.&c&a?s??ed,gro?o&c?fni??ten?ude?vog?zib??a&ed?tner??e&ssurb?toh!yrrek???lahsram?m?oot??m!.&bal,etisinim,gro?moc?ten?ude?vog??b?etsys!.tniopthgink,?ialc??n&a&f?gorf?ol??egassap?i&a&grab?mod??giro??o&it&acav?cudorp?ulos??puoc???o&dnoc?geuj?leuv?ppaz?t&ohp?ua???p!.&ces?gro?moc?olp?ten?ude?vog??i&hsralohcs?lihp?t??u??r!.&au,ca?gro?ni?oc?topsgolb,ude?vog?xo,yldnerb.pohs,?a&c?p?tiug??c?e&dliub!.etisduolc,?erac?gor?levart?mraf?n&niw?trap??wolf??ot&cartnoc?omatat??pj?uot??s!.&em?gro?hcs?moc?ten?ude?vog?zib??alg?e&n&isub!.oc,?tif??rp!xe!nacirema???xnal??iws??t&a&e&b?ytic??ob??ek&cit?ram??fig?h&cay?gilf??n&atnuocca?e&mt&rapa?sevni??ve!.oc,???rap??u!.&a&c!.&21k?bil?cc???g!.&21k?bil?cc???i!.&21k?bil?cc???l!.&21k?bil?cc???m!.&21k!.&hcorap?rthc?tvp???bil?cc???p!.&21k?bil?cc???si?v!.&21k?bil?cc???w!.&21k?bil?cc????c&d!.&21k?bil?cc???n!.&21k?bil?cc???s!.&21k?bil?cc????d&e&f?lacsne.xhp,?i!.&21k?bil?cc???m!.&21k?bil?cc???n!.&bil?cc???s!.&bil?cc???u&olcrim,rd,??e&d!.&21k?bil,cc???las-4-&dnal,ffuts,?m!.&21k?bil?cc???n!.&21k?bil?cc????h&n!.&21k?bil?cc???o!.&21k?bil?cc????i&h!.&bil?cc???m!.&21k?bil?c&c?et??goc?n&eg?otae??robra-nna?sum?tsd?wanethsaw???nd?r!.&bil?cc???v!.&21k?bil?cc???w!.&21k?bil?cc????jn!.&21k?bil?cc???k&a!.&21k?bil?cc???o!.&21k?bil?cc????l&a!.&21k?bil?cc???f!.&21k?bil?cc???i!.&21k?bil?cc????mn!.&21k?bil?cc???n&afflog,i!.&21k?bil?cc???m!.&21k?bil?cc???sn?t!.&21k?bil?cc????o&c!.&21k?bil?cc???m!.&21k?bil?cc???ttniop,?p&ion,rettalp,?r&a!.&21k?bil?cc???o!.&21k?bil?cc???p!.&21k?bil?cc????s&a!.&21k?bil?cc???dik?k!.&21k?bil?cc???m!.&21k?bil?cc???nd&deerf,uolc,??t&c!.&21k?bil?cc???m!.&21k?bil?cc???u!.&21k?bil?cc???v!.&21k?bil?cc????ug!.&21k?bil?cc???v&n!.&21k?bil?cc???w!.cc???x&ohparg,t!.&21k?bil?cc????y&b-si,k!.&21k?bil?cc???n!.&21k?bil?cc???w!.&21k?bil?cc????za!.&21k?bil?cc????ah!uab??bria?col?e!.ytrap.resu,?ineserf?lp?xe&l?n???vt?w!.&66duolc,gro?moc?s&ndnyd,tepym,?ten?ude?vog??a?e&iver?n!.elbaeciton,??odniw??y&alcrab?cam?ot???t&0srzc--nx?a!.&amil4,ca!.hts??gni&liamerutuf,tsoherutuf,?o&c!.topsgolb,?fni,?p&h21,ohsdaerpsym,?r&euefknuf.neiw,o??v&g?irp,?xi2,ytic-amil,zib,?c?e!s??hc?if?l!asite??mami?rcomed??b!.&gro?moc?ten?ude?vog??b?gl??c&atnoc?e&les?rid!txen????dimhcs?e!.&eman?gro?moc?ofni?ten?ude?vog?zib??b?em?grat?id?k&circ?ram??n!.&0&002cilc,rab,?1rab,2rab,5inu,6vnyd,7&7ndc.r,erauqs,?a&l&-morf,moob,?minifed,remacytirucesym,tadsyawla,z,?b&boi,g,lyltsaf:.pam,,?c&inagro-gnitae,paidemym,?d&ecalpb,irgevissam.saap.&1-&gs,nol,rf,yn,?2-&nol,yn,??nab-eht-ni,uolc&meaeboda,nievas.c&di-etsedron,itsalej,?xednay:.e&garots,tisbew,?,??e&c&narusnihtlaehezitavirp,rofelacs.j,?gdirbtib,ht-no-eciffo,l&acsnoom,ibom-eruza,?m&ecnuob,ohtanyd,tcerider,?n&ilno-evreser,ozdop,?rehurht,s:abapus,,tis-repparcs,zamkcar,?f&aeletis,crs.&cos,resu,?ehc-a-si,?g&ni&reesnes,sirkcilc,tsohnnylf,?olb&evres,tsaf,??k&catsvano,eeg-a&-si,si,?u,?l&acolottad,iamwt,s&d-ni,s-77ndc,??m&ac&asac,ih,?urofniem,?n&a&f&agp,lhn,?i&bed,llerk,??dcduabkcalb,i,pv-ni,?o&c-morf,duppa,jodsnd,rp-ytinummoc,ttadym,?p&i&-&etsef,on,?emoh,fles,nwo,?j,mac-dnab-ta,o&-oidar-mah,h&bew,sdaerpsym,??pa&duolc,egde,?tfe&moh,vres,?usnd,?r&e&tsulcyduolc,vres-xnk,?vdslennahc:.u,,?s&a&ila&nyd,snd,?nymsd,?bbevres,dylimaf,e&gde-ndc,suohsyub,t&isbeweruza,ys,??k&catstsaf,ekokohcs,?n&d&-won,d,golb,npv,?oitcnufduolc,?ppacitatseruza:.&2suts&ae,ew,?aisatsae,eporuetsew,sulartnec,?,s&a-skcik,ecca&-citats,duolc,???t&adies,ce&ffeym,jorprot:.segap,,?e&nretnifodne,smem,?farcenimevres,i-&ekorb,s&eod,lles,teg,??n&essidym,orfduolc,?r0p3l3t,s&ixetnod,oh&-spv:.citsalej.&cir,lta,sjn,?,gnik,???u&h,nyd,r:eakust.citsalej,,?ved-naissalta.dorp.ndc,x&inuemoh,spym,tsale.&1ots-slj,2ots-slj,3ots-slj,?unilemoh,?y&awetag-llawerif,ffijduolc:.&ed-1arf,su-1tsew,?,ltsaf.&dorp.&a,labolg,?lss.&a,b,labolg,?pam,slteerf,?n&-morf,ofipi,?srab,?z&a-morf,tirfym,???p?tcip?v??f&ig?o&l?sorcim???g!.&bog?dni?ed,g&olb,ro??lim?moc?ot,ten?ude???h!.&dem?gro?l&er?op??m&oc?rif??o&fni?rp?s&rep?sa???po&hs?oc??t&en?luda?ra??ude?vuog???i!.&a&2n-loritds--nx?7e-etsoaellav--nx?8&c-aneseclrof--nx?i-lrofanesec--nx??at?b?c!cul??dv?i&blo&-oipmet?oipmet??cserb?drabmol?g&gof?urep??l&gup?i&cis?me&-oigger?oigger???uig&-&aizenev&-iluirf?iluirf??ev&-iluirf?iluirf??v&-iluirf?iluirf???aizenev&-iluirf?iluirf??ev&-iluirf?iluirf??v&-iluirf?iluirf????n&a&brev?cul?pmac?tac??idras?obrac&-saiselgi?saiselgi??resi??otsip?r&b&alac!-oigger?oigger??mu??dna&-&attelrab-inart?inart-attelrab??attelrabinart?inartattelrab?ssela??epmi?ugil??tnelav&-obiv?obiv??vap?z&e&nev?ps&-al?al???irog???l&iuqa!l??leib??m&or?rap??n!acsot?e&dom?is?sec&-&ilrof?ìlrof??ilrof?ìlrof???g&amor&-ailime?ailime??edras?olob??i&ssem?tal??ne!var??o&cna?merc?rev?vas???oneg?p?r!a&csep?rr&ac&-assam?assam??ef??von??etam?tsailgo!-lled?lled???s!ip?sam&-ararrac?ararrac??u&caris?gar???t!a&cilisab?recam??resac?soa!-&d&-&ellav?lav??ellav?lav??ellav??d&-&ellav?lav??ellav?lav??ellav??te&lrab&-&airdna-inart?inart-airdna??airdnainart?inartairdna??ssinatlac???udap?v!o&dap?neg?tnam???zn&airb&-a&lled-e-aznom?znom??a&lledeaznom?znom??eaznom??e&c&aip?iv??soc?top??om???b&-&23,46,61,?3c-lorit-ds-onitnert--nx?be-etsoa&-ellav--nx?dellav--nx??c!f-anesec-lrof--nx?m-lrof-anesec--nx??he-etsoa-d-ellav--nx?m!u??o2-loritds-nezob--nx?sn-loritds&-nasl&ab--nx?ub--nx??nitnert--nx??v!6-lorit-dsnitnert--nx?7-loritds&-nitnert--nx?onitnert--nx???z&r-lorit-ds&-nitnert--nx?onitnert--nx??s-loritds-onitnert--nx???c&f?is?l?m?p?r?v??d&p?u!olcnys,??e&c!cel?inev?nerolf??f?g!ida&-&a&-onitnert?onitnert??otla!-onitnert?onitnert???a&-onitnert?onitnert??otla!-on&azlob?itnert??onitnert????hcram?l?m!or??n&idu?o&n&edrop?isorf??torc???p?r?s&erav?ilom??t!nomeip?s&eirt?oa!-&d-e&ellav?éllav??e&ellav?éllav???de&ellav?éllav??e&ellav?éllav?????v?znerif??g&a?b?f?il?o?p?r?up?vf??hc?i&b?c?dol?f?l!lecrev?opan?rof&-anesec?anesec???m?n&a&part?rt&-attelrab-airdna?attelrabairdna???imir?ret??p?r!a&b?ilgac?ssas???s!idnirb??t&ei&hc?r??sa??v??l&a!c??b?c?o&m?rit&-&d&eus&-&nitnert?onitnert??nitnert?onitnert??us&-&nitnert?onitnert??nitnert?onitnert??üs&-&nitnert?onitnert??nitnert?onitnert???s&-onitnert?onitnert???d&eus!-&n&asl&ab?ub??ezob?itnert??onitnert??nitnert?onitnert??us&-&n&asl&ab?ub??ezob?itnert??onitnert??nitnert?onitnert??üs!-&n&asl&ab?ub??ezob?itnert??onitnert??nitnert?onitnert???s&-onitnert?onitnert?????m&ac?f?i!t.nepo.citsalej.duolc,?ol?r??n&a!lim?sl&ab?ub???b?c?e!en.cj,v?zob??irut?m!p??p?r?t??o&a!v??b!retiv??c!cel??enuc?g!ivor??i&dem&-onadipmac?onadipmac??pmet&-aiblo?aiblo??rdnos?zal??l?m!a&greb?ret??oc?re&f?lap???n!a&dipmac&-oidem?oidem??lim?tsiro?zlob??ecip&-ilocsa?ilocsa??i&bru&-orasep?orasep??lleva?rot?tnert??r&elas?ovil??ulleb??p?r!a&sep&-onibru?onibru??znatac??oun??s!ivert?sabopmac??t!arp?e&nev?ssorg??n&arat?e&girga?rt?veneb????zz&era?urba???p&a?ohsdaerpsym,s?t??qa?r&a!m?s??b!a??c?f?g?k?me?o?p?s?t?v??s&a&b?iselgi&-ainobrac?ainobrac???b?c?elpan?i?m?ot?s?t?v??t&a?b?c?l?m?nomdeip?o!psgolb,?p?v??u&de?l?n?p??v&a?og?p?s?t?v??y&drabmol?ellav&-atsoa?atsoa??licis?nacsut??z&al?b?c?p??ìlrof&-anesec?anesec???derc?er?f?m!r??utni??je3a3abgm--nx?kh?l!.&topsgolb,vog??uda??m!.&gro?moc!.topsgolb,?ten?ude???n&a&morockivdnas?ruatser?tnuocca??e&g?m&eganam!.retuor,?piuqe??r??i!.ue?m?opdlog??opud?uocsid??o&b?cs!.&ude,vog:.ecivres,,??d?g?h?j?oferab?p&edemoh?s???p!.&emon?gro?lbup?moc?t&en?ni?opsgolb,?ude?vog???r&a!m&law?s???epxe?op&er?pus!.ysrab,?s???s!.&adaxiabme?e&motoas?picnirp?rots??gro?lim?moc?o&c?dalusnoc?hon,?ten?ude??a&cmoc?f??e&b?padub?r?uq??i!rolf?tned??o&h!.&duolc&p,rim,?e&lej,tiseerf,?flah,lrupmet,s&pvtsaf,seccaduolc,?tsafym,vedumpw,??p!sua???urt??t!.&eman?gro?ibom?levart?m&oc?uesum??o&c?fni?r&ea?p???pooc?sboj?t&en?ni??ude?vog?zib??ayh?n?o!bba?irram???uognah?xen?y!.gro,?ztej??u&2&5te9--nx?yssp--nx??a!.&a&s?w??civ?d&i?lq??fnoc?gro?moc!.&pohsdaerpsym,stelduolc.lem,topsgolb,??nsa?ofni?sat?t&ca?en?n??ude!.&a&s?w??ci&lohtac?v??dlq?sat?t&ca?n??wsn!.sloohcs????vog!.&a&s?w??civ?dlq?sat???wsn?zo??ti??c!.&fni?gro?moc?ten?ude?vog??i??d&e!.tir.segap-tig,?iab??e!.&dcym,enozgniebllew,noitatsksid,odagod.citsalej,snd&ps,uolc,?ysrab,??g!.&bew?gro?m&aug?oc??ofni?ten?ude?vog???h!.&0002?a&citore?idem?kitore??edszot?gro?ilus?letoh?m&alker?lif?t?urof??naltagni?o&c?ediv?fni?levynok?nisac??pohs?rarga?s&a&kal?zatu??emag?wen??t&lob?opsgolb,rops??virp?xe&s?zs??ytic?zsagoj??os?sut??l!.topsgolb,?m!.&ca?gro?moc?oc?ro?ten?vog???n!.&duolcesirpretne,eni&esrem,m,?tenkcahs,?em!.ysrab,??o&ggnaw?y!c???r!.&3kl,a&i&kymlak,rikhsab,vodrom,?yegyda,?bps,ca,duolcrim,e&niram,rpcm,?g&bc,nitsohurger.citsalej,ro,?ianatsuk,k&ihclan,s&m,rogitayp,??li&amdlc.bh,m,?moc,natsegad,onijym,pp,ri&b,d&cm:.spv,,orue,?midalv,?s&ar,itym,?t&en,ni,opsgolb,set,?u&4an,de,?vo&g,n,?ynzorg,zakvakidalv,?myc?p?ug??s!.&a&d&golov,nagarak,?gulak,i&groeg,kymlak,lerak,nemra,rikhsab,ssakahk,vodrom,zahkba,?lut,rahkub,vut,yegyda,znep,?bps,da&baghsa,rgonilest,?gunel,i&anatsuk,hcos,ovan,ttailgot,?k&alhsygnam,ihclan,s&legnahkra,m,n&a&mrum,yrb,?i&buytka,nbo,??tiort,vorkop,??l&ocarak,ybmaj,?na&gruk,jiabreza,ts&egad,hkazak-&htron,tsae,???ovonavi,r&adonsark,imidalv,?t&enxe,nek&hsat,mihc,??vo&hsalab,n,?ynzorg,z&akvakidalv,emret,??t&amok?i&juf?masih????v!.&em,g&olb,ro??moc?nc,ten?ude?ved,??ykuyr??v&b?c!.topsgolb,?ed!.&enilnigol,gnigats-oned,hcetaidem,lecrev,o&ned,tpyrctfihs,?ppa-rettalp,s&egap,rekrow,?vr&esi,uc,?weiverpbuhtig,ylf,??ih?l!.&di?fnoc?gro?lim?moc?nsa?ten?ude?vog???m!.&eman?gro?lim?m&oc?uesum??o&fni?r&ea?p???pooc?t&en?ni??ude?vog?zib???o&g?m??rt?s!.&bog?der?gro?moc?ude???t!.&bew-eht-no,naht-&esrow,retteb,?sndnyd,?d?gh?i?won??uqhv--nx??w&a!.moc?hs?l??b!.&gro?oc???c!.&gro?moc?ten?ude??cp??e&iver!.oby,?n?s??g?k!.&bme?dni?gro?moc?ten?ude?vog???m!.&ca?gro?m&oc?uesum??oc?pooc?t&en?ni??ude?vog?zib??b??o&csom?h!s??n?w??p!.&344x,de?en?o&c?g??ro?snduolc,ualeb???r!.&ca?gro?lim?oc?pooc?ten?vog??n??t!.&a46oa0fz--nx?b&82wrzc--nx?ulc??emag?gro?l&im?ru,?moc!.reliamym,?t&en?opsgolb,?ude?v&di?og?ta0cu--nx??zibe?業商?織組?路網???z!.&ca?gro?lim?oc?vog????x&a!.&cm,eb,gg,s&e,u,?tac,ue,yx,?t??c!.&hta,ofni,vog???e&d&ef?nay??ma!nab??rof?s??ilften?jt?m!.&bog?gro?moc?t&en?opsgolb,?ude??g?ma2ibgy--nx??o&b!x??f?rex??rbgn--nx?s!.vog??x&am&jt?kt??x???y&4punu--nx?7rr03--nx?a&d!i&loh?rfkcalb??ot??g?lp?p!ila??rot?ssin?wdaorb??b!.&duolcym,fo?hcetaidem,lim?moc!.topsgolb,?vog??ab?gur??c!.&ca?dtl?eman?gro?m&oc!.&ecrofelacs.j,topsgolb,??t??orp?s&egolke?serp??t&en?nemailrap??vog?zib??amrahp?nega??d&dadog?uts??e&kcoh?ltneb?n&dys?om?rotta??snikcm??g!.&eb,gro?moc?oc?ten?ude?vog??olonhcet!.oc,?rene??hpargotohp?id?k!.&gro?moc?ten?ude?vog??s??l!.&clp?d&em?i??gro?hcs?moc?ten?ude?vog??f?imaf!nacirema??l&a?il??ppus??m!.&eman?gro?lim?moc?t&en?opsgolb,?ude?vog?zib??edaca!.laiciffo,?ra??n&a&ffit?pmoc!ylimafa???os??o&j?s??p!.&gro?lim?moc?pooc?ten?ude?vog???r&e&corg?grus?llag?viled??lewej?otcerid?tnuoc?uxul??s!.&gro?lim?moc?ten?ude?vog??pil??t&efas?i&c?ledif?n&ifx?ummoc!.&bdnevar,gon,murofym,???r&ahc?uces??srevinu??laer?r&ap!.oby,?eporp??uaeb??u!.&bug?gro?lim?moc!.topsgolb,?ten?ude??b!tseb???van!dlo??xes??z&a!.&eman?gro?lim?moc?o&fni?rp??pp?t&en?ni??ude?vog?zib???b!.&az,gro?jsg,moc?ten?ude?vog???c!.&4e,inum.duolc.&rsu,tlf,?m&laer,urtnecatem.motsuc,?oc,topsgolb,??d!.&cos?gro?lop?m&oc?t??ossa?t&en?ra??ude?vog???ib!.&duolcsd,e&ht-rof,mos-rof,rom-rof,?izoj,nafamm,p&i&-on,fles,?ohbew,tfym,?retteb-rof,snd&nyd,uolc,?xro,?g??k!.&duolcj,gro?lim?moc?t&en?ropeletzak.saapu,?ude?vog???m!.&ca?gro?lim?oc?ten?ude?v&da?og????n!.&asq-irom--nx?ca?gro?htlaeh?i&r&c?o&am?ām???wi!k???keeg?l&im?oohcs??neg?oc!.topsgolb,?t&en?nemailrap?vog???a!niflla???rawhcs?s!.&ca?gro?oc???t!.&c&a?s??e&m?n??ibom?l&etoh?im??o&c?fni?g??ro?vt???u!.&gro?moc?oc?ten??rwon??yx!.&e&nozlacol,tisgolb,?gnitfarc,otpaz,??zub??λε?υε?авксом?брс!.&гро?до?ка?р&бо?п!у?????г&б?ро??дкм?зақ?итед?килотак?леб?мок?н&йално?ом??рку?сур!.&арамас,бпс,гро,зиб,ичос,ксм,м&ок,ырк,?рим,я,??тйас?фр?юе?յահ?לארשי?םוק?اي&روس?سيلم?ناتيروم??بر&ع?غملا??ة&كبش?ي&دوعسلا?روس??یدوعسلا??ت&ا&راما?لاصتا??را&ب?ڀ?ھب???ر&ئازجلا?ازاب?صم?طق??سنوت?عقوم?قارع?ك&تيب?يلوثاك??موك?ن&ا&تس&كاپ?کاپ??دوس?ر&يا?یا??مع?يلعلا??درالا?ميلا?ي&رحبلا?طسلف???ه&ارمه?يدوعسلا??وكمارا?يبظوبا?ۃیدوعسلا?टेन?त&राभ?ोराभ??नठगंस?मॉक?्मतराभ?ত&রাভ?ৰাভ??ালংাব?ਤਰਾਭ?તરાભ?ତରାଭ?ாயித்நஇ?ைக்ஙலஇ?்ரூப்பக்ஙிச?్తరాభ?ತರಾಭ?ംതരാഭ?ාකංල?มอค?ยทไ!.&จิกรุธ?ต็นเ?ร&ก์คงอ?าหท??ลาบฐัร?าษกึศ???ວາລ?ეგ?なんみ?アトス?トンイポ?ドウラク?ムコ?ル&グーグ?ーセ??ン&ゾマア?ョシッァフ??业企?东广?乐娱?亚基诺?你爱我?信中?务政?动移?博微?卦八?厅餐?司公?品食?善慈?团集?国中?國中?址网?坡加新?城商?尚时?山佛?店&商?网?酒大里嘉??府政?康健?息信?戏游?拉里格香?拿大?教主天?机手?构机!织组??标商?歌谷?浦利飞?港香!.&人個?司公?府政?絡網?織組?育教???湾台?灣&台?臺??物购?界世?益公?看点?科盈訊電?站网?籍書?线在?络网?网文中?聘招?販通?车汽众大?逊马亚?通联?里嘉?锡马淡?門澳?门澳?闻新?電家?국한?넷닷?성삼?컴닷??");
+ "a&0&0trk9--nx?27qjf--nx?e9ebgn--nx?nbb0c7abgm--nx??1&2oa08--nx?apg6qpcbgm--nx?hbbgm--nx?rdceqa08--nx??2&8ugbgm--nx?eyh3la2ckx--nx?qbd9--nx??3&2wqq1--nx?60a0y8--nx??4x1d77xrck--nx?6&1f4a3abgm--nx?2yqyn--nx?3np8lv81qo3--nx?5b06t--nx?axq--nx?ec7q--nx?lbgw--nx??883xnn--nx?9d2c24--nx?a&a?it??b!.&gro?lim?moc?t&en?opsgolb,?ude?vog??abila?c?ihsot?m?n??c!.&b&a?m?n??c&b?g?q??ep?fn?k&s?y??ln?no?oc,pi-on,sn?t&n?opsgolb,?un?ysrab,?i&ma?r&emarp?fa??sroc??naiva?s??d&ats?n&eit?oh??om?sa?tl??eg?f&c?ob??g!emo?naripi?oy??hskihs?i&cnal?dem?hs?k!on??sa!.snduolc,??jnin?k&aso?dov?ede?usto??l!.&c,gro?m&oc?yn,?ofni?r&ep?nb,?t&en?ni??ude?vog??irgnahs?le&nisiuc?rbmuder???m!.&ca?gro?oc?sserp?ten?vog??ahokoy?e00sf7vqn--nx?m??n!.&ac?cc?eman?gro?ibom?loohcs?moc?ni?o&c?fni?rp??r&d?o??s&u?w??vt?xm??av?is?olecrab?tea??p!.&bog?ca?d&em?ls??g&ni?ro??mo&c?n??oba?ten?ude??c?g7hyabgm--nx?ra!.&461e?6pi?iru?nru?rdda-ni?siri???s??q!.&eman?gro?hcs?lim?mo&c?n,?t&en?opsgolb,?ude?vog???r&az?emac?f4a3abgm--nx?n!d5uhf8le58r4w--nx??u&kas?tan???s!.&bup?dem?gro?hcs?moc?ten?ude?vog??ac!.uban.iu,?iv??t&ad?elhta?led?oyot??u!.&a&cinniv?emirc?i&hzhziropaz?stynniv??s&edo?sedo??tlay?vatlop??bs?cc,d&argovorik?o!roghzu??tl,?e&hzhziropaz?nvir?t??f&i?ni,?g&l?ro??hk?i&stvinrehc?ykstynlemhk??k&c?m?s&nagul?t&enod?ul??v&iknarf-onavi?orteporp&end?ind?????l&iponret?opotsa&bes?ves??p??m&k?oc?s?yrk??n&c?d?i?osrehk?v?ylov??o&c,nvor??p&d?p,z??r&c?imotihz?k?ymotyhz??sk?t&en?l?z??ude?v:c?e&alokin?ik??i&alokym?hinrehc?krahk?vl?yk??k?l?o&g!inrehc??krahk??r?,y&ikstinlemhk?mus?s&akrehc?sakrehc?tvonrehc???z&ib,u????v!aj?bb?et?iv??waniko?x&a?iacal??yogan?z&.&bew?c&a?i&n?rga???gro?l&im?oohcs??m&on?t??o&c!.topsgolb,?gn??radnorg?sin?t&en?la??ude?vog?wal??zip???b&00ave5a9iabgm--nx?1&25qhx--nx?68quv--nx?e2kc1--nx??2xtbgm--nx?3&b2kcc--nx?jca1d--nx??4&6&1rfz--nx?qif--nx??96rzc--nx??7w9u16qlj--nx?88uvor--nx?a&0dc4xbgm--nx?c?her?n?ra?t??b!.&erots?gro?moc?o&c?fni??ten?ude?v&og?t??zib??a??c&j?s??d&hesa08--nx?mi??ec?g?l!.&gro?moc?ten?ude?vog??m??s!.&gro?moc?ten?ude?vog???tc-retarebsnegmrev--nx?u&lc!.&elej,snduolc,y&nop,srab,??smas??p!.ysrab,??wp-gnutarebsnegmrev--nx??c&1&1q54--nx?hbgw--nx??2e9c2czf--nx?4&4ub1km--nx?a1e--nx?byj9q--nx?erd5a9b1kcb--nx??8&4xx2g--nx?c9jrb2h--nx??9jr&b&2h--nx?54--nx?9s--nx??c&eg--nx?h3--nx?s2--nx???a!.&gro?lim?moc?ten?ude?vog??3a09--nx!.&ca1o--nx?gva1c--nx?h&ca1o--nx?za09--nx??ta1d--nx?ua08--nx???da??b&a?b?ci?f76a0c7ylqbgm--nx?sh??c!.&eugaelysatnaf,gnipparcs,liamwt,revres-emag,s&nduolc,otohpym,seccaptf,?xsc,?0atf7b45--nx?a1l--nx??e!.&21k?bog?dem?gro?lim?m&oc?yn,?nif?o&fni?rp??ten?ude?vog??beuq?n?smoc??fdh?i&l&buperananab?ohtac??n&agro?ilc?osanap??tic??l!.&gro?m&oc?yn,?oc?ten?ude?vog?yo,?l??m!.&mt?ossa??p1akcq--nx??n!.&mon?ossa??i?p??relcel?s!.&gro?moc?ten?ude?vog??c??t!.&e&m,w,?hc,?s?w??v!.&e0,gro?lim?mo&c?n,?ten?ude?v&g:.d,,og???q??wp?yn??d&2urzc--nx?3&1wrpk--nx?c&4b11--nx?9jrcpf--nx???5xq55--nx?697uto--nx?75yrpk--nx?9ctdvkce--nx?a!.mon?d?er?olnwod??b2babgm--nx?c!.vog?g9a2g2b0ae0chclc--nx??e&m!bulc??r!k??sopxe?timil?w??fc?g!.&mon,ude?vog???h&d3tbgm--nx?p?t??i!.&ased?bew?ca?etrof,hcs?lim?o&c!.topsgolb,?g??ro?sepnop?ten?ym?zib??ar?b?ordna?p?rdam??l&iub?og?row??m!.&ed,ot,pj,t&a,opsgolb,???n&a&b?l!.citats:.&setis,ved,?,lohwen?raas???ob?uf??o&of?rp??r&a&c&tiderc?yalcrab??ugnav??ef506w4b--nx?k!.&oc,ude,?jh3a1habgm--nx??of??s!.&dem?gro?moc?ofni?ten?ude?v&og?t???m!kcrem???t!.topsgolb,excwkcc--nx?l??uolc!.&atcepsrep,citsalej.piv,drayknil,elej,nworu,r&epolroov,opav,?xelpciffart,??za5cbgn--nx??e&1&53wlf--nx?7a1hbbgm--nx?ta3kg--nx??2a6a1b6b1i--nx?3ma0e1cvr--nx?418txh--nx?707b0e3--nx?a!.&ca?gro?hcs?lim?mon,oc?t&en?opsgolb,?vog??09--nx??b!.&ca?gnitsohbew,topsgolb,?ortal?ut!uoy???c&a&lp!.oc,?ps!.&lla4sx,rebu,slootiknil,tsafym,?artxe??sla??i!ffo??n&a&d?iler?nif?rusni!efil?srelevart???eics!.oby,??rofria??d!.&1sndnyd,42pi-nyd,7erauqs,amil4,brb-ni,decalpb,e&daregtmueart,mohsnd,nihcamyek,?hcierebsnoissuksid,keegnietsi,lsd-ni,moc,n&-i-g-o-l,aw-ym,esgnutiel,i&emtsi,lreb-n&i,yd,??oitatsksid-ygolonys,pv&-n&i,yd,?nyd,??orp-ytinummoc,p&h21,iog:ol,,?r&e&ntrapdeeps.remotsuc,su&-lautriv,lautriv,?t&adpusnd,tub-ni,uor-ym,?vres&-e&bucl,mohym,?bew-emoh:.nyd,,luhcs,??ogiv-&niem,ym,??s&d-&onys,ygolonys,?nd&-&dd,nufiat,sehcsimanyd,tenretni,yard,?isoc.nyd,ps,yard,?oper-&nvs,tig,?sndd:.&nyd,sndnyd,?,?topsgolb,vresi-&niem,tset,?xi2,y&awetag-&llawerif,ym,?srab,tic-amil,?zten&mitbel,sadtretteuf,??a&lg?rt!.oby,??i&s&doow?ruoyno??ug?wnoitan??nil?on--nx??e!.&bil?dem?eif?gro?irp?kiir?moc!.topsgolb,?pia?ude?vog??ei?ffoc?gg?r&f?ged???f&a&c?s??il!tem???g!.&gro?lim?mo&c?n,?t&en?vp??ude?vog??a&f?gtrom?p!.&kselp,sndp,ycvrp,??rots?yov??elloc?na&hcxe?ro??roeg?ug??i!.&myn,topsgolb,vog??tilop?v&bba?om???j!.&gro?oc?ten???k!.&c&a?s??e&m?n??ibom?mon,o&c!.topsgolb,?fni?g??ro??i&b?l?n???l&a&dmrif?s!.rof,rof???b&a?i&b?dua???c&aro?ric??dnik?g!oog??i&bom?ms??l&asal?erauqa??ppa?uhcs?yts!efil???m!.&4&32i,pct,?66c,ailisarb,b&dnevar,g-raegelif,?ca?duolcsd,e&d-raegelif,i&-raegelif,lpad:.tsohlacol,,?pcm,?g&ro?s-raegelif,?hctilg,k&catsegde,uoc,?myn,noitatsksid,o&bmoy,c!ku,?t&nigol,poh,??p&ion,j-raegelif,ohbew,?r&aegelif,ofsnd,?s&dym,ndd,ti??t&en?s&acdnuos,ohon,??u&a-raegelif,de?tcn,?v&irp?og??y&golonys,olpedew,srab,??a&g?n!.&reh.togrof,sih.togrof,???em?i&rp?twohs??orhc?w??n!goloc?i&lno!.ysrab,?w??o!.&derno:.gnigats,,knilemoh,rof,?hp?latipac?ts&der?e&gdirb?rif???z!.&66duolc,amil,sh,???ruoblem??om?p!.&bog?gro?lim?m&o&c?n??yn,?t&en?opsgolb,?ude??irg?yks??r!.&mo&c?n??ossa?topsgolb,?a&c!htlaeh??pmoc?wtfos??bc?eh?if?ots!.erawpohs,?taeht?u&ces?sni?t&inruf?necca??za???s!.&a?b!ibnal?rofmok??c!a??d!b?n&arb?ubroflanummok???e?f!noc,?g!ro??h!f??i!trap??k!shf??l?m!oc,t??n!mygskurbrutan??o?p!p??r?s!serp??t!opsgolb,?u?vhf?w?x!uvmok??y?z??a&c?el?hc??i&er?urc??nesemoh?roh?uoh??t&a&d?ts&e!laer??lla???is!.&areduolc,e&lej,nilnigol,retnim,winmo,?k&rowtenoilof,wnf,?laicosnepo,n&eyb,oyc,?spvtsaf,xulel,ysrab,?bew??ov?ra?t&ioled?ol??utitsni??u&lb?qi&nilc?tuob???v!.&21e?b&ew?og??ce&r?t??erots?gro?lim?m&oc?rif??o&c?fni??stra?t&en?ni??ude?vog??as?e3gerb2h--nx?i&l?rd?ssergorp??ol??w&kct--nx?r??xul??f&0f3rkcg--nx?198xim--nx?280xim--nx?7vqn--nx?a!.&gro?mo&c?n,?ten?ude?vog???b!.vog?wa9bgm--nx??c!.topsgolb,a1p--nx?ns??ea1j--nx?fo?g?iam?l&a1d--nx?og??n!.&bew?cer?erots?m&oc?rif??ofni?re&hto?p??stra?ten???orp?p!.&gro?moc?ude???rus?t!w??vd7ckaabgm--nx?w??g&2&4wq55--nx?8zrf6--nx??3&44sd3--nx?91w6j--nx!.&a5wqmg--nx?d&22svcw--nx?5xq55--nx??gla0do--nx?m1qtxm--nx?vta0cu--nx????455ses--nx?5mzt5--nx?69vqhr--nx?7&8a4d5a4prebgm--nx?rb2c--nx??a!.&gro?mo&c?n??oc?ten??vd??b!.&0?1?2?3?4?5?6?7?8?9?a?b?c?d?e?f?g?h?i?j?k?l?m?n?o?p?q?r?s?t!opsgolb,?u?v?w?x?y!srab,?z???c!b?za9a0cbgm--nx??e!.&eman?gro?ics?lim?moc!.topsgolb,?nue?ten?ude?vog??a??g!.&ayc,gro?lenap:.nomead,,oc?saak,ten???i&a?v??k!.&g&olb,ro??ku,lim?moc?oi,pj,su,ten?ude?v&og?t,???m!.&drp?gro?lim?m&o&c?n??t??oc?ude?vog??pk??n!.&dtl,eman?gro?hcs?i!bom??l&im?oc,?m&oc!.topsgolb,?rif,?neg,ogn,ten?ude?vog??aw?i!b!mulp??car?d&art?dew??h&sif?tolc??k&iv?oo&b?c???ls?n&aelc?iart??p!pohs??re&enigne?tac??t&ad?ekram?hgil?lusnoc?neg?ov?soh!.tfarcnepo,?tebdaerps??vi&g?l???o!s??u&rehcisrev?smas?tarebsnegömrev???o&d?lb?og!.duolc,??r&2n084qlj--nx?ebmoolb?o!.&77ndc.c:sr,,a&remacytirucesym,t&neimip,sivretla,?z,?bew-llams,d&ab-yrev-si,e&sufnocsim,vas-si,?nuof-si,oog-yrev-si,uolc&arfniarodef,mw,??e&a,cin-yrev-si,grof&loot,peh,?l&as-4-ffuts,poeparodef,?m&-morf,agevres,ohruoyslles,?n&ozdop,uma.elet,?r&ehwongniogyldlob,iwym,uces-77ndc.nigiro.lss,?t&adidnac-a-si,is&-ybboh,golb,???fehc-a-si,golbymdaer,k&eeg-a&-si,si,?h,nut,?l&i&amwt,ve-yrev-si,?lawerif&-ym,ym,?sd-ni,?m&acssecca,edom-elbac,?n&af&blm,cfu,egelloc,lfn,s&citlec-a-si,niurb-a-si,tap-a-si,?xos-a-si,?o&itatsksid,rviop,?pv-ni,?o&jodsnd,tp&az,oh,??p&i&-on,fles,?o&hbew,tksedeerf,?tf&e&moh,vres,?ym,??r&e&gatop,ppepteews,su-xunil-a-si,?gmtrec,vdmac,?s&a&ila&nyd,snd,?nymsd,?b&alfmw,bevres,?dylimaf,eirfotatophcuoc,gulku,j,koob-daer,ltbup,nd&-won,deerf,emoh,golb,kcud,mood,nyd:.&emoh,og,?,ps,rvd,tog,uolc,?s&a-skcik,ndd,?tnemhcattaomb,u,?t&ce&jorparodef.&duolc,gts.so.ppa,so.ppa,?riderbew,?e&ews-yrev-si,nretni&ehtfodne,fodne,??hgink-a-si,igude,oi-allizom,s&ixetn&od,seod,?o&h-emag,l-si,?rifyam,??ue:.&a&-q,c,?cm,dc,e&b,d,e,i,m,s,?g&b,n,?hc,i&f,s,?k&d,m,s,u,?l&a,i,n,p,?n&c,i,?o&n,r,ssa,?pj,r&f,g,h,k,t,?s&e,i:rap,,u,?t&a,en,i,l,m,ni,p,?u&a,de,h,l,r,?vl,y&c,m,?z&c,n,??,vresnyd,x&inuemoh,unilemoh,?y&limafxut,srab,???ub&mah?oj???s!.&gro?moc?rep?t&en?opsgolb,?ude?vog??gb639j43us5--nx??t?u!.&c&a?s??en?gro?mo&c?n,?o&c?g??ro?topsgolb,??v!.&mon,ta,?a1c--nx??wsa08--nx??h&0ee5a3ld2ckx--nx?4wc3o--nx!.&a&2xyc3o--nx?3j0hc3m--nx?ve4b3c0oc21--nx??id1kzuc3h--nx?l8bxi8ifc21--nx?rb0ef1c21--nx???8&8yvfe--nx?a7maabgm--nx??b!.&gro?moc?ten?ude?vog??mg??c!.&7erauqs,amil4,duolc-drayknil,gniksnd,ph21,sndtog,topsgolb,wolf.enigneppa,xi2,ytic-amil,?aoc?et?ir!euz??r&aes!errecnac??uhc??sob?taw!s???d0sbgp--nx?f&2lpbgm--nx?k??g!.&gro?lim?moc?ude?vog???iesac?m!a1j--nx??ocir?p!.&gro?i?lim?moc?ogn?ten?ude?vog???s!.&g&nabhsah,ro??l&im?xv,?m&oc?roftalp.&cb,su,tne,ue,??ten?vog?won,yolpedew,?a&c?nom??i&d?f?ri???t!.&ca?enilno,im?ni?o&c?g??pohs,ro?ten??iaf!.oby,?laeh?orxer?ra&ba?e???vo!.lopdren,?zb??i&3tupk--nx?7a0oi--nx?a!.&ffo?gro?mo&c?n,?ten?uwu,?1p--nx?bud?dnuyh?tnihc??b!.&gro?moc?oc?ro?ude??ahduba?o!m!.&duolcsd,ysrab,???s??c!.&ayb-tropora--nx?ca?d&e?m??esserp?gro?ln,moc?nif,o&c?g?ssa??ro?t&en?ni?roporéa??ude?vuog??cug?t??d&dk?ua??e&bhf--nx?piat??f!.&aw5-nenikkh--nx,dnala?iki,mroftalpduolc.if,nenikkäh,retnecatad.saap,topsgolb,yd,?onas??g!.&d&om?tl??gro?moc?ude?vog???h&c&atih?ra??s&abodoy?ibustim???juohs?k!.&gro?moc?ofni?ten?ude?vog?zib??b4gc--nx?iw?nisleh?s?uzus??l!.&aac,m&on,yn,?topsgolb,?drahcir?iamsi??maim?n!.&b&ew?og??ca?gro?lim?mo&c?n??ni?o&c?fni??pp?t&en?ni??ude?zib??airpic?i&hgrobmal?m??re??om?rarref?s!.&egaptig,mon,topsgolb,?ed??t&aresam?i&c?nifni??rahb?tagub??ut?v!.&21k?gro?moc?oc?ten???wik?xa&rp?t??yf??j&6pqgza9iabgm--nx?8da1tabbgl--nx?b!.&ossa?topsgolb,uaerrab?vuog???d?f!.&ca?eman?gro?lim?moc?o&fni?rp??ten?vog?zib???nj?s?t!.&bew?c&a?in??eman?gro?lim?mo&c?n,?o&c?g??t&en?ni?set??ude?vog?zib???yqx94qit--nx??k&8uxp3--nx?924tcf--nx?arfel?c&a&bdeef?lb??ebdnul?ilc?reme?ud??d!.&erots,ger,mrif,oc,topsgolb,zib,?t??e&es?samet??h!.&a&4ya0cu--nx?5wqmg--nx??b3qa0do--nx?cni,d&2&2svcw--nx?3rvcl--nx??5xq55--nx?tl,?g&a0nt--nx?la0do--nx?ro??i&050qmg--nx?7a0oi--nx?xa0km--nx??m&1qtxm--nx?oc?yn,?npqic--nx?t&en?opsgolb,?ude?v&di?og?ta0cu--nx??xva0fz--nx?人&个?個?箇??司公?府政?絡&網?网??織&組?组??织&組?组??络&網?网??育&敎?教???n??i&tsob?vdnas??l!.&bew?c&a?os??dtl?gro?hcs?letoh?moc?nssa?ogn?prg?t&en?ni??ude?vog??at?cd?is??m!.&eman?fni?gro?mo&c?n,?t&en?opsgolb,?ude?vog???n&ab!cfdh?etats?mmoc?t&en?fos??u??i!.gn,l!.&noyc,pepym,??p???oob?p!.&b&ew?og??gro?kog?m&af?oc??nog?ofni?pog?sog?ten?ude?vog?zib???row!.&fo,ot,?ten!.&htumiza,o&c,vra,??doof???s!.&myn,topsgolb,??t?u!.&c&a?lp??d&om?tl??e&cilop?m??gro!.&gul:g,,sgul,??nnoc,o&c!.&bunsorter.tsuc,e&lddiwg,n&ilnoysrab,ozgniebllew,??krametyb.&hd,mv,?pi-on,t&fihsreyal.j,opsgolb,?vres-hn,ysrab,??rpoc,?shn?t&en?nmyp,?vog!.eci&ffoemoh,vres,??ysrab,???l&04sr4w--nx?a!.&gro?lim?mo&c?n,?t&en?opsgolb,?ude?vog??bolg?c?ed?g!el??i&c&nanif!.oc,lpl??os??romem?tnedurp??n&if?oitanretni??t&i&gid!.sppaduolc:.nodnol,,?p&ac?soh???ned?ot??utum!nretsewhtron???c!.&bog?lim?mon,oc?samednerpa?topsgolb,vog???dil?e&datic?n&ahc?nahc!gnikooc?levart?rehtaew???t!ni?ria?tam??vart??f&8f&pbgo--nx?tbgm--nx??a?n??g!.&gro?mo&c?n,?oc?ten?ude?xx,zib,??h&d?op??i!.&21k?ca?fdi?gro?inum?oc!.topsgolb,?ten?vog??a&f?m&e?g?toh???m?r?xil??l&a&b&esab?t&eksab!.&sua,zn,??oof!.fo,???c?mt??e&d?hs??ihmailliw?j??m!.&esserp?gro?moc?ten?ude?v&og?uog????n!.&n&iemodleeutriv,o&med,rtsic,??oc,retsulc-gnitsoh,topsgolb,wsma,yalphk,?o??o&a?btuf?l!.gmo,?o&c!.ed,?hcs!.gn,??rit?u??p!.&a&cin&diws?gel??d&g,ortso?urawon??i&dem?mraw?nydg,?k&elo&guld?rtso??slopolam?tsu?ytsyrut??l&ip?o&kzs?w&-awolats?oksnok????n&img?zcel,?rog&-ai&bab?nelej??j?z??syn?tsaim?w&a&l&eib?i?o??zsraw??o&namil?tainop,??z&eiwolaib?mol???c&e&iw&alselob?o&nsos?rtso???le&im?zrogz???orw,p??d&em,ia?ragrats??e&c&i&lrog?w&ilg,o&hc&arats?orp??klop?tak????yzreibok??i&csjuoniws?ksromop?saldop??l&ahdop?opo??napokaz,tatselaer?z&romop?swozam???g&alble?ezrbo&lok?nrat??ro??hcyzrblaw?i&csomohcurein?grat?klawus??k&e&rut?walcolw??in&byr?diws,sark,?le?o&nas?tsylaib??rob&el?lam??s&als?jazel?nadg,puls?rowezrp???l&colw?e&r?vart??i&am?m???m&o&c?dar?n?tyb??s&g?iruot??t!a???n&a&gaz?nzop,?i&bul?cezczs?lbul,molow?nok?zd&eb?obeiws???uleiw?y&tzslo?z&rtek?seic????o&c,fni?k&celo?zdolk??lkan?n&leim?pek?t&uk?yzczs??z&copo?eing?rowaj???rga?tua?w&ejarg?ogarm???p&e&eb,lks??klwwortso?ohs??romophcaz?sos?t&aiwop?en?opos,ra,sezc??ude?v&irp?og!.&a&p?s!w???bni&p?w??ci?dtiw?essp?fiw?g&imu?u??hiiw?m&igu?rio?u!o???nds?o&ks?p!pu??s?wtsorats??p&a?sp!mk?pk?wk??u&m?p??wk?z??r&ksw?s??s&i?oiw?u?zu??talusnok?w&gzr?i&p?rg?w??m?opu?u!imzw???zouw????w&a&l&corw?sizdow??w??o&golg?k&ark,ul?zsurp??r&az?gew??t&rabul,sugua??z&coks?sezr????xes?y&buzsak?d&azczseib?ikseb??hcyt?n&jes?lod-zreimizak??pal?r&ogt?uzam??walup?zutrak??z&am-awar?c&aprak?iwol?zsogdyb??dalezc?ib?s&i&lak?p??uklo????l??r&as?f?s??s!.&gro?moc?ten?ude?vog???t!.vog??ubnatsi?x3b689qq6--nx?yc5rb54--nx??m&00tsb3--nx?1qtxm--nx?981rvj--nx?a!.&aayn,enummoc?gro?moc?o&c?idar,ken,?t&en?opsgolb,??c!bew??dretsma?e&rts?t!.&citsalej,esruocsid,???fma?rirhs?xq--nx??b!.&gro?moc?ten?ude?vog??i??c!.&moc?oc?ten?vog???d!.&gro?moc?ten?ude?vog???f!.&gro?moc?oidar,ten?ude??i??g!vu96d8syzf--nx??h?i!.&ca?gro?mo&c?n,?o&c!.&clp?dtl???r,?t&en?t??vt??k?rbg4--nx??k!.&drp?e&rianiretev?sserp??gro?lim?m&o&c?n??t??nicedem?ossa?pooc?s&eriaton?neicamrahp?sa??ude?v&og?uog????l&if?ohkcots??o!.&dem?gro?m&oc?uesum??o&c?rp??ten?ude?vog??b?c!.&2aq,3pmevres,a&c&-morf,ir&bafno,fa,??g&-morf,oy-sehcaet,?i-morf,m&-morf,all&-a-si,amai,??p&-morf,c-a-si,?r&emacytirucesym,odih,?s,tadtsudgniht,v-morf,w-morf,z,?b&dnevarym,ew&-sndnyd,draiw.segap,ottad,?g,ildts.ipa,?c&amytirucesemoh,d-morf,esyrcs,itsalej.omed,n&-morf,vym,?p&kroweht,ytirucesemoh,?q,rievres,s-morf,?d&aerotffuts,e&calpb,ifitrec-&si,ton-si,?llortnocduolc,rewopenignepw,?i&-morf,rgevissam.saap,?m-morf,n&-morf,abeht-htiw-si,?s-morf,uolc&-noitatsyalp,hr,meaeboda,panqym:-&ahpla,ved,?,smetsystuo,ved&j,pw,??wetomer,?e&butuoyhtiw,ciffo-sndnyd,d:-morf,o&celgoog,n&il.srebmem,neve.&1-&su,ue,?2-&su,ue,?3-&su,ue,?4-&su,ue,????,erf&-sndnyd,sndd,?filflahevres,gnahcxeevres,i&hcet-a-si,p-sekil,?k&auqevres,irtsretnuocevres,?l&bitpa-no,googhtiw,?m&agevres,ina-otni-si,oh-&sndnyd,ta-sndnyd,??n&-morf,ilnoysrab,og-si,?r&alfduolcyrt,ihcec,uzanoppanex,?srun-a-si,t&i&nuarepo,s&-ybboh,aloy,tipohs,??omer-sndnyd,ysgolb,?v&als-elcibuc-a-si,i&lsndd,tavresnoc-a-si,??z&amkcar,eelg,iig,??fehc-a-si,g&ni&gats-swennwot,ksndd,robsikrow,?o&fgp,lb&-sndnyd,sihtsetirw,???h&n-morf,o-morf,?i&fiwehtno,h-morf,kiw-sndnyd,m-morf,pdetsoh,r-morf,w-morf,z&ihcppa,nilppa,??jn-morf,k&a&-morf,erfocsic,?cils-si,eeg&-a&-si,si,?sndd,?h,latsnaebcitsale:.&1-&htuos-pa,lartnec-&ac,ue,?ts&ae&-&as,su,?ht&ron-pa,uos-pa,??ew-&su,ue,vog-su,???2-ts&ae&-su,ht&ron-pa,uos-pa,??ew-&su,ue,??3-ts&aehtron-pa,ew-ue,??,o-morf,r&adhtiwtliub,ow&-&sndnyd,ta-sndnyd,?ten-orehkcats,??u,?l&a&-morf,colottad,rebil-a-si,?f-morf,i&-morf,am-sndnyd,?l&ecelffaw,uf-ytnuob:.a&hpla,teb,?,?ppmswa,ru-&elpmis,taen,?ssukoreh,xegap,?m&n-morf,pml.ppa,rofererac-htlaeh,sacrasevres,uirarret-yltsaf,?n&a&cilbuper-a-si,f&-sllub-a-si,racsan-a-si,?i&cisum-a-si,ratrebil-a-si,??c,dcxirtrepmi,eerg-a-si,i-morf,m-morf,o&ehtnaptog,isam-al-a-tse,rtap-el-tse,s&iam-al-a-tse,replausunu,??pj,t-morf,?o&bordym,c,jodsnd,m-morf,n:iloxip,,ttadym,?p&2pevres,aelutym,i&-sndnyd,fles,ogol,ruoy&esol,hctid,?ymteg,?pa&-rettalp,anis:piv,,esaberif,k1,lortnocduolc,oifilauq,r&aegyks,oetem:.ue,,?tnorfegap,ukoreh,?t&fevres,thevres,??r&a:-morf,tskcor-a-si,,b,e&d&ivorpnwo,ner&.ppa,no,??e&bevres,nigne-na-si,?ggolb-a-si,h&caet-a-si,pargotohp-a-si,?krow-drah-a-si,n&gised-a-si,ia&rtlanosrep-a-si,tretne-na-si,??p&acsdnal-a-si,eekkoob-a-si,?retac-a-si,subq,tn&ecysrab,iap-a-si,uh-a-si,?vres&-&ki.duolcj,s&ndnyd,pvtsaf,??inim,nmad,sak,?y&alp-a-si,wal-a-si,?zilibomdeepsegap,?g,k,mgrp.nex,o&-morf,sivdalaicnanif-a-si,t&c&a-na-si,od-a-si,?susaym,??p-morf,u&as-o-nyd,eugolb-nom-tse,omuhevres,??s&a&apod,ila&nyd,snd,?nymsd,?bbevres,ci&p&-sndnyd,evres,?tcatytiruces,?dylimaf,e&cived-anelab,itilitu3,lahw-eht-sevas,mag-otni-si,tyskciuq,?i&ht2tniop,pa&elgoog,tneltneg,??k&-morf,aerf-ten,colbpohsym,?m&-morf,cxolb,?n&d&-pmet,dyard,golb,mood,tog,?kselp,nyd,ootrac-otni-si,?o&-xobeerf,xobeerf,?ppatneg,r&ac-otni-si,etsohmaerd,?s&e&l-rof-slles,rtca-na-si,?ibodym,?tsaeb-cihtym.&azno,ilay,remotsuc,sv,toleco,x:n&ihps,yl,?,?u,wanozama.&1-&htuos-pa&-3s,.&3s,etisbew-3s,kcatslaud.3s,??la&nretxe-3s,rtnec-&ac&-3s,.&3s,etisbew-3s,kcatslaud.3s,??ue&-3s,.&3s,etisbew-3s,kcatslaud.3s,????ts&ae&-&as&-&3s,etisbew-3s,?.kcatslaud.3s,?su:-etisbew-3s,.kcatslaud.3s,,?ht&ron-pa&-&3s,etisbew-3s,?.kcatslaud.3s,?uos-pa&-&3s,etisbew-3s,?.kcatslaud.3s,???ew-&su-&3s,etisbew-3s,?ue&-&3s,etisbew-3s,?.kcatslaud.3s,?vog-su-&3s,spif-3s,????2-ts&ae&-su&-3s,.&3s,etisbew-3s,kcatslaud.3s,??ht&ron-pa&-3s,.&3s,etisbew-3s,kcatslaud.3s,??uos-pa&-&3s,etisbew-3s,?.kcatslaud.3s,???ew-&su-&3s,etisbew-3s,?ue&-3s,.&3s,etisbew-3s,kcatslaud.3s,????3&-tsew-ue&-3s,.&3s,etisbew-3s,kcatslaud.3s,??s,???t&arcomed-a-si,c-morf,eel&-si,rebu-si,?m-morf,n&atnuocca-na-si,e&duts-a-si,r-ot-ecaps,tnocresu&buhtig,elbavresbo.citats,pl,???ops&edoc,golb,ppa,?s&i&hcrana-&a-si,na-si,?laicos-a-si,pareht-a-si,tra-na-si,xetn&od,seod,??oh&piym,sfn,??u&-morf,nyekcoh-asi,?v-morf,?u&-rof-slles,4,e,h,oynahtretramssi,r:ug-a-si,,?v&n-morf,w-morf,?w&ozok,ww100,?x&bsbf.sppa,em,i&nuemoh,rtrepmi,?obaniateb,t-morf,unilemoh,?y&a&bnx:.&2u,lacol-2u,?,lerottad,wetag-llawerif,?dnacsekil,k&-morf,niksisnd,?rotceridevitcaym,u:goo,,w-morf,x&alagkeeg,orphsilbup,???inu??m!.&dna,rof,??or?tsla??p!.nwo,?raf!.jrots,etats??s?t!.&gro?lim?mo&c?n??oc?ten?ude?vog???u&esum!.&a&92chg-seacinumocelet-e-soierroc--nx?atnav?c&i&aduj?rfatsae??rollam??d&anac?enomaledasac?irolf??e&raaihpledalihp?srednu??g&hannavas?oonattahc??hamo?i&auhsu?bmuloc!hsitirb??dem?groeg?hpledalihp?l&artsua?etalif??n&igriv?rofilac??ssur?tsonod??ksa&la?rben??l&lojal?q-snl--nx?uossim!trof???m&a&bala?nap??enic?o&m?r???n&a&cirema?idni??edasap?ilorachtuos?olecrab??r&abrabatnas?ezzivs??su?t&nalta?osennim??zalp??c&dnotgnihsaw?ebeuq?i&depolcycne?ficap?hpargonaeco?lbup?sum?t&carporihc?lec?naltadim??vu??yn??d&a&dhgab?etsmraf?m?orliar??i&rdam?ulegnedleeb??leif?n&a!l&gne?nif?ragyduj?t&ocs?rop??yram???u&brofsdgybmeh?osdnaegami???r&augria?ofxo???e&c&a&l&ap?phtrib??ps??n&a&lubma?tsiser??e&fedlatsaoc?gilletni?ics!foyrotsih????pein?rof??d&nukneklov?revasem??e&rt?tsurt??f&atnas?ildliw??g&a&lliv?tireh!lanoitan???dirbmac?rog??i&cnum?nollaw??koorbrehs?l&ab?bib?cycrotom?i&ssim?txet??oks?tsac??m&affollah?it!iram??utsoc??n&golos?ilno?recul??r&a&uqs?waled!foetats???i&hs&acnal?kroy?pmahwen??otsih??omitlab?ut&an?cetihcra?inruf?luc!irga?su???vuol??s&abatad?iacnarf?sius?uoh!lum???t&a&locohc?rak?ts!e!yrtnuoc!su?????imesoy?tevroc??u&qihpargonaeco?velleb??vit&caretni?omotua???f&iuj?ohgrub??g&n&i&dliub?ginerevmuesum?kiv?lahw?nim?peekemit?vil??ulmmastsnuk??orf?r&ebnrats?u&b&ierf?le?m&ah?uan??ram?s&mailliw!lainoloc??naitsirhc?retepts??zlas??ob&irf?mexul?????h&atu?c&raeser?sirotsih?uot??g&ea1h--nx?rubsttip??si&tirb?wej??t&laeh?ro&n?wtrof??uo&mnom?y????i&d6glbhbd9--nx?iawah?k&nisleh?s??lad!rodavlas??sissa?tannicnic??k&c&nivleeg?olc!-dna-hctaw?dnahctaw???fj?inebis?l&is?ofron??na&rfenna?t??oorbnarc?r&am&ned?reiets??oy!wen????l&a&ci&dem?golo&eahcra?meg?oz??natob?rotsih??ertnom?iromem?noita&cude?n??oc?rutluc?trop?utriv?van??e&nurb?s&ab?surb??utriv??i&artnogero?sarb??l&a&besab?hsnoegrus??e&hs?rdnevle??i&b?m!dniw????o&bup?ohcs?tsirb???m&a&dretsma?ets?h&netlehc?rud???ct?elas!urej??l&if?ohkcots?u??raf?silanruoj?u&esumyrotsihlarutan?ira&tenalp?uqa??terobra???n&a&c!irema!evitan???gihcim?i&dni?tpyge??mfoelsi?wehctaksas??e&d&alokohcs?ews?rag!cinatob?lacinatob?s&nerdlihc?u????gahnepoc?hcneum?laftsew?ppahcsnetewruutan?r&dlihc?ednaalv?hu!dnutamieh???sseig??gised!dn&atra?utsnuk???h&ab!nesie??ojts??i&lreb?tsua??l&eok?ocnil??n&ob?urbneohcs??o&dnol?gero?i&s&iv&dnadnuos?elet??nam??t&a&c&inummoc?ude!tra???dnuof?erc?i&cossa?va??kinummokelet?nissassa?r&belectsevrah?oproc?tsulli??silivic?t&nalp?s??vres&erp?noclatnemnorivne??zilivic??c&elloc?if-ecneics??ibihxe???ri?s&dnah?imaj?reffej?sral??t&erbepac?nilc?sob???r&e&b?dom?tsew?uab?zul??obredap??vahnebeok?wot??o&2a6v-seacinumoc--nx?ablib?c&edtra?ixemwen?sicnarfnas??elap?g&a&cihc?to??eidnas??i&cadnuf?diserp?ratno??llecitnom?mitiram?nirot?r&htna?ienajedoir???pohskrow?qari?r&aw!dloc?livic??dd?e&b&ma?yc??irrac?llimsiwel?naksiznarf?papswen?t&aeht?exe?nec!ecneics?larutluc?muesum?tra??s&ehc&nam?or??neum??upmoc???ia!nepo??obal?u&asonid?obal?takirak???s&a&l&g?l&ad?eh???xet??di&k?pardnarg??e&cneics!larutan??dnal?hcsi&deuj?rotsih!nizidem?rutan??selhcs??itinamuh?l&aw?egnasol?l&e&rutansecneics?xurb??iasrev???r&e&em?ugif??tsac??suohcirotsih?u&en?q&adac?itna!nacirema?su????õçacinumoc!elet-e-soierroc???gnirpsmlap?htab?i&lopanaidni?rap?uoltnias?xa??l&essurb?lod??mraeriflanoitan?n&a&blats?l??erdlihc?oi&snam?tacinummoc!elet-dna-stsop???äl??re&dnalf?lttes?mraf?nim?tnececneics??s&alg?erp??t&farc!dnastra??nalp?olip?ra!e&nif?vitaroced!su???su?xuaeb???u&b!muloc??cric???t&agilltrop?cejorp?dats?e&esum?kramnaidni??iorted?ne&m&elttes?norivne?piuqemraf??vnoc??oped?r&a!drib?enif?gttuts?hsiwej?kcor?n&acirema?ootrac??tamsa?yraropmetnoc??op&aes?snart?wen??ufknarf??s&a&cdaorb?octsae??ewhtuos?ilayol?nuk?r&ohnemled?uhlyram??urt???u&a&bgreb?etalpodaroloc??rmyc??w&ocsom?rn??x&esse?ineohp?nam?tas??y&a&bekaepasehc?w&etag?liar???camrahp?doc?e&hsub?l&ekreb?l&av!eniwydnarb??ort???n&dys?om??rrus?s&nreug?rejwen???golo&e&ahcra?g??motne?nh&cet?te??oz?po&rhtna?t??roh??hpargotohp?l&etalihp?imaf??m&edaca?onortsa??n&atob?yn??ps?r&a&ropmetnoc?tilim??e&diorbme?llag!tra??vocsid??lewej?nosameerf?otsih!dnaecneics?ecneics?gnivil!su??la&col?rutan??retupmoc?su??tsudnidnaecneics??spelipe?t&eicos!lacirotsih??i&nummoc?srevinu??nuoc???z&arg?iewhcs?nil?ojadab?urcatnas??моки?םילשורי???rof??z!.&ca?gro?hcs?lim?moc?o&c?fni??ten?ude?vog?zib????n&315rmi--nx?a&brud?cilbuper?f?grompj?hkaga?idraug?m?ol?ssin?u&hix?qna??varac?yalo??b!.&gro?moc?oc,ten?ude?vog??c??c!.&ah?bh?c&a?s??d&5xq55--nx?g?s?uolctnatsni,?eh?g&la0do--nx?ro??h&a?q?s??i&7a0oi--nx?h??j&b?f?t?x?z??kh?l&h?im?j??m&n?oc!.swanozama.&1-htron-nc.3s,be.1-&htron-nc,tsewhtron-nc,????n&h?l?s?y??om?qc?s&g?j??ten?ude?vog?wt?x&g?j?n?s??z&g?x??司公?絡網?络网??b??d&g!.ypnc,?ka??e&drag?erg?fuak?gawsklov?hctik?i&libommi?w??m!.rof,?po?r!ednaalv??sier?ves??g!.&ca?gro?moc?ten?ude?vog??is&ed!.ssb,?irev???h!.&bog?cc,gro?lim?mo&c?n,?ten?ude???i!.&bew,c&a?in??dni?gro?lim?mrif?neg?oc?s&er?nduolc,?t&en?opsgolb,?ude?vog?ysrab,?elknivlac?griv?ks?lreb?p!ul??v?w?x??k!.&gro?ten?ude?vog???l&eok?ocnil??m!.&cyn,gro?myn,ude?vog???o&dnol!.&fo,ni,??i&hsaf!.&fo,no,??n&o?utiderc??siv!orue??t&a&cude!.oc,?dnuof?tsyalp??c&etorp?u&a?rtsnoc?????kin?las?mrom?nac?p&q?uoc??s&iam?nhojcs?pe?scire??t&ron?sob??zama??p!.&gro?oc?ten?ude?vog??k??r&e&c?yab??op!.eidni,??s!.&gro?moc?osrep?t&opsgolb,ra??ude?v&inu?uog????t!.&dni?esnefed?gro?ltni?m&oc!nim??siruot??n&erut?if??o&fni?srep??sn&e?r??t&an?en!irga?ude??rnr??unr?vog??m??u&f?r!.&bdnevar,lper,sh,tnempoleved,??stad?xamay?y??v!.&ca?eman?gro?htlaeh?moc?o&fni?rp??t&en?ni?opsgolb,?ude?vog?zib???wo&rc?t!epac????o&76i4orfy--nx?a!.&bp?de?go?oc?ti?vg??boat??b!.&a&ci&sum?tilop??i&c&arcomed?neic??golo&ce?ncet??m&edaca?onoce??rt&ap?sudni??vilob??n&egidni?icidem??serpme?tsiver?vitarepooc??b&ew?og??dulas?e&rbmon?tr&a?op&ed?snart????g&olb?ro??ikiw?l&a&noi&canirulp?seforp??rutan??im??moc?o&fni?lbeup?rga?tneimivom??saiciton?t&askt?en?ni??ude?vt??h?iew?olg??c!.&bew?cer?dr&c,rac,?gro?ipym,l&im?per,?m&o&c!.topsgolb,?n??rif?udon,?ofni?s&egap&dael,l,?tra??t&4n,en?ni??ude?vog??a?e!vi??in?mara?s&edarb?ic???d!.&b&ew?og??dls?gro?lim?moc?t&en?ra??ude?vog??agoba?if?zd7acbgm--nx??e&c?d&iv?or??morafla??f!ni!.&e&g&delwonk-fo-l&errab,lerrab,?ellocevoli,?ht-skorg,rom-rof-ereh,tadpusn:d,,?llatiswonk,macrvd,ofni-v,p&i&-on,fles,?ohbew,?ruo-rof,s&iht-skorg,nd&-cimanyd,nyd,uolc,??tsrifyam,ysrab,zmurof,???g&el?n!am?ib???hwsohw?i!.&35nyd,8302,a&minifed,tad-b,?b&altig,uhtig,?c&inone:.remotsuc,,zh,?d&in,u&olc&iaznab.ppa,noitacilppa,ropav,?rd,??e&civedniser,donppad.sndnyd,egipa,lej,nilnigol,sufxob,t&isnoehtnap,newtu,??gni&gatsniser.secived,tsohytsoh,?k&orgn,ramytefasresworb,?m&oc?udon,?nyded,p&opilol,pa&-arusah,cs,enalpkcab,??r&evres&cisab,lautriv,?ial.sppa,?s&codehtdaer,nemeis-om,pparevelc,tacdnas,?t&enotorp,i&belet,detfihs,kecaps,?raedon.egats,sudgniht.&cersid.tsuc,dorp.tsuc,gnitset.tsuc,ved.tsuc,??vgib.0ku,whs,x&bslprbv.g,cq,?y&olpedew,srab,??b?d&ar?u&a?ts???j?r?syhp??j!.&eman?gro?hcs?lim?moc?ten?ude?vog???ll&ag?o??m!.&gro?moc?ten?ude?vog??g?il?mi?orp??n!.&a&0&b-ekhgnark--nx?c-iehsrgev--nx?g-lksedlig--nx?k-negnanvk--nx??1&p-nedragy--nx?q-&asierrs--nx?grebsnt--nx?lado-rs--nx?n&egnidl--nx?orf-rs--nx??regnayh--nx?ssofenh--nx??r-datsgrt--nx?s-ladrjts--nx?v-y&senner--nx?vrejks--nx???3g-datsobegh--nx?4&5-&dnaleprj--nx?goksnerl--nx?tednalyh--nx??6-neladnjm--nx?s-&antouvachb--nx?impouvtalm--nx??y-&agrjnevvad--nx?ikhvlaraeb--nx???7k-antouvacchb--nx?8&k-rekie-erv--nx?l-ladrua-rs--nx?m-darehsdrk--nx??a!.sg??bct-eimeuvejsemn--nx?d&do?iisevvad?lov?narts?uas??f&1-&l--nx?s--nx??2-h--nx??g&10aq0-ineve--nx?av?ev?lot?r&ajn&evvad?u??ájn&evvad?u????h?iz-lf--nx?j&ddadab?sel??k&el?hoj&sarak?šárák??iiv&ag&na&el?g??ŋ&ael?ág???ran???l&f?lahrevo?o&ms?s??sennev?t-&ilm--nx?tom--nx??u&-edr--nx?s??øms??muar?n&0-tsr--nx?2-dob--nx?5-&asir--nx?tals--nx??a&r!-i-om?f?t??t??douvsatvid?kiv?m&os?øs??n&od?ød??ra?sen?t&aouvatheig?ouv&a&c&ch&ab?áb??h&ab?áb???n??i&ag?ág??sa&mo?ttvid??án???z-rey--nx?ær&f?t???o&p-&ladr--nx?sens--nx??q-nagv--nx?r-asns--nx?s-kjks--nx?v-murb--nx?w-&anr&f--nx?t--nx??ublk--nx???ppol?q&0-t&baol--nx?soum--nx?veib--nx??x-&ipphl--nx?r&embh--nx?imph--nx???y-tinks--nx??r&f-atsr--nx?g-&an&ms--nx?nd--nx??e&drf--nx?ngs--nx??murs--nx?netl--nx?olmb--nx?sorr--nx??h-&a&lms--nx?yrf--nx??emjt--nx??i&-&lboh--nx?rsir--nx?y&d&ar--nx?na--nx??ksa--nx?lem--nx?r&ul--nx?yd--nx????stu??j-&drav--nx?rolf--nx?sdav--nx??kua?l-&drojf--nx?lares--nx??m-tlohr--nx?n-esans--nx?olf?p-sdnil--nx?s-ladrl--nx?tih?v-rvsyt--nx??s&a&ns?ons??i&ar?er&dron?r&os?øs???ár??la&g?h??mor!t??sir?uf?åns??t&koulo&nka?ŋká??la?p-raddjb--nx?r-agrjnu--nx?s&aefr&ammah?ámmáh??orf?r&o?ø???u-vreiks--nx??u&h-dnusel--nx?i-&drojfk--nx?vleslm--nx??j-ekerom--nx?k-rekrem--nx?u-&dnalr--nx?goksr--nx?sensk--nx??v-nekyr--nx?w-&k&abrd--nx?ivjg--nx??oryso--nx??y-y&dnas--nx?mrak--nx?n&art--nx?nif--nx??reva--nx??z-smort--nx??v!.sg?ledatskork?reiks??wh-antouvn--nx?x&9-dlofts--nx.aoq-relv--nx?d-nmaherk--nx?f-dnalnks--nx?h-neltloh--nx?i-drgeppo--nx?j-gve&gnal--nx?lreb--nx??m-negnilr--nx?n-drojfvk--nx??y&7-ujdaehal--nx?8-antouvig--nx?b-&dlofrs--nx?goksmr--nx?kivryr--nx?retslj--nx??e-nejsom--nx?f-y&krajb--nx?re&dni--nx?tso--nx??stivk--nx??g-regark--nx?orf?ørf??z9-drojfstb--nx??b&25-akiivagael--nx?53ay7-olousech--nx?a&iy-gv--nx?le-tl&b--nx?s--nx??n0-ydr--nx??c&0-dnal-erdns--nx?z-netot-erts--nx??g&g-regnarav-rs--nx?o-nejssendnas--nx??ju-erdils-ertsy--nx?nj-dnalh-goksrua--nx?q&q-ladsmor-go-erm--nx.&ari-yreh--nx?ednas??s-neslahsladrjts--nx???ca&4s-atsaefrmmh--nx?8m-dnusynnrb--nx?il-tl--nx?le-slg--nx?n5-rdib--nx?op-drgl--nx?uw-ynnrb--nx??d&a&qx-tggrv--nx?reh!nnivk?sd&ork?ørk??uas??ts&e&bi?kkar?llyh?nnan??g&ort?ørt??k&alf?irderf??levev?mirg?obeg&ah?æh??r&ah?ejg????barm-jdddb--nx?ie!rah?s&etivk?ladman???lof&r&os?øs??ts&ev.ednas?o.relav?ø.relåv???n&a&l&-erd&n&os?øs??ron??adroh.so?dron.&a&g5-b--nx?ri-yreh--nx??ob?y&oreh?øreh??øb??e&m!lejh??pr&oj?øj??vi??gyb?n&aks?åks??o&h-goksrua?rf??r&o?ua?ø??tros?øh-goksrua??rts!e&devt?lab?mloh???s&ellil?naitsirk?rof???u&l!os??s!d&im?lejt??e&guah?l&a?å???kkoh?lavk?naitsirk?r&af?eg&e?ie???tef?y&onnorb?ønnørb?????r&a&blavs!.sg??g&eppo?la???o&j&f&a!dniv?k?vk??die?e&dnas?kkelf??llins?r&iel?ots??s&lab?t&ab?åb??yt??å!k??ævk??les??ts??åg&eppo?lå???ureksub.sen??e&ayb-yrettn--nx?d&ar?lom?r&of?øf??år??g&gyr?nats??i&meuv&ejsem&aan?åån??sekaal??rjea??j&d&ef?oks??les??k&er&aom?åom??hgna&ark?årk??iregnir?kot!s??s&ig?uaf???l&bmab?kyb?l&av?ehtats??oh??m&it?ojt?øjt??n&arg?g&os?øs??meh?reil?te?ummok?yrb??r&dils-erts&ev?y&o?ø???ua?vod??sa&ans?åns??t&robraa?spaav??urg??f&62ats-ugsrop--nx?a&10-ujvrekkhr--nx?7k-tajjrv-attm--nx??o!.sg?h??s!.sg??v!.sg???g&5aly-yr&n--nx?v--nx??a&llor?ve&gnal?lreb???n&av!snellu??org??oks&die?m&or?ør??ner&ol?øl??r&o?ø???r&eb!adnar?edyps?s&die?elf?gnok?n&ot?øt????obspras??uahatsla?åve&gnal?lreb???h&0alu-ysm--nx?7&4ay8-akiivagg--nx?5ay7-atkoulok--nx??a!.sg???i&e&hsr&agev?ågev??rf??k&h&avlaraeb?ávlaraeb??s??lm&a?å??mpouvtal&am?ám??pph&al?ál??rrounaddleid?ssaneve?ššáneve??j&0aoq-ysgv--nx?94bawh-akhojrk--nx??k&a&b&ord?ørd??jks?lleis??iv!aklejps?l&am?evs?u??mag?nel?ojg?r&a&l?n??epok?iel?y&or?ør???s&ah?kel?om??øjg??kabene?ojsarak?ram&deh.&aoq-relv--nx?rel&av?åv??so??e&let.&ag5-b--nx?ob?øb??ra???åjks??l&a!d&anrus?d&numurb?ron??e&gnard?nte?s&meh?sin??ttin??g&is?nyl??kro?l&em?l&ejfttah?of??u&ag-ertdim?s???n&am?era?gos?i&b?nroh?r??kos?nus?oj??o-&dron?r&os?øs???ppo?r&a!l?nram??e&gne?l?v??is?o&jts?ts??u&a-&dron?r&os?øs???h??å?æl?øjts??s&e&jg?nivk?ryf??kav?mor-go-er&om.&ednas?yoreh??øm.&ednas?yøreh???uag??t&las?rajh?suan??v&l&a?e-rots??u-go-eron??yt??ksedlig?res&a?å???bib&eklof?seklyf??es!dah??h!.sg??i&m?syrt??l&ejf?ov&etsua?gnit?ksa?sdie???n!.sg??o!.sg?boh?g?h??r!.sg??å!ksedlig??øboh??m&a&rah?vk??f!.sg??h!.sg??i&e&h&dnort?rtsua?ssej??rkrejb??ksa??ol?t!.sg??u&dom?esum?r&ab?drejg?evle?os?uh?æb?øs??ttals???n&a&g&av?okssman?åv??jlis?or?r&g?rev???e&d&do&sen?ton??lah?r&agy&o?ø??ojfsam???g&iets?n&a&l&as?lab??n&avk?ævk??t&arg?ddosen??v&al?essov???i&d&ol?øl??l&ar?ær???yl??reb??iks?k&srot?y&or?ør???l&a&d&gnos?n&er?ojm?øjm??om??tloh??ug?åtloh??mmard?ojs&om?sendnas??ppolg?s&lahsladr&ojts?øjts??o??t&o&l?t-erts&ev?o?ø???roh?øl??vly&kkys?nav??yam-naj!.sg??øjs&om?sendnas???g&orf?ujb??i&dnaort?vnarg??kob?ladendua?maherk&a?å??n&it?urgsrop??orf-&dron?r&os?øs???r&aieb?evats??sfev?uaks?yrts??o&6axi-ygvtsev--nx?c,d&ob?rav??ievs?kssouf?l&m&ob?øb??ous&adna?ech&ac?áč???so!.sg???msdeks?niekotuak?r&egark?olf?y&oso?øso???s&dav?mort???p&ed?p&akdron?elk???r&a&d&dj&ab?áb??iab??jtif?luag?mah?vsyt??e&gn&a&k&iel?ro??merb?n&at?mas??rav-r&os?øs??srop?talf?v&ats?el??y&oh?øh???ivsgnok??il?jkniets?k&a&nvej?rem?s&gnir?nellu???ie-er&den?v&o?ø???ram?sa?årem??la&jf?vh??m&b&ah?áh??mahellil??nnul?ts&l&oj?øj??ul??y&o?ø???imp&ah?áh??m!.sg??osir?t!.sg??ádiáb?ævsyt?øsir??s&adnil?en&dnas?e&dga?k&ri&b?k??som??ve??me&h?jg??nroh-go-ejve?s&a?ednil?k&o?ø??of?yt?å??tsev??gv?hf?igaval?o&r&or?ør??sman??so&fen&oh?øh??m?v??uh&lem?sreka.sen??å!dnil???t&a&baol?g&aov?grav??jjr&av-attam?áv-attám??l&a&b?s??ás??soum?ts?v&eib?our???e&dnaly&oh?øh??f?s&nyt?rokomsdeks?sen??vtpiks??in&aks?áks??loh&ar?år??n!.sg??o&m&a?å??psgolb,?s!.sg?efremmah?or?ør??terdi?á&baol?ggráv?lá&b?s??soum?veib???u&b!.sg?alk?e&dna?gnir?nner??les?ælk??dra&b?eb??g&nasrop?vi?ŋásrop??j&daehal&a?á??jedub?v&arekkhar?árekkhár???ksiouf?n&diaegadvoug?taed???v&irp?lesl&am?åm???y&b&essen?nart?sebel?tsev??o&d&ar?na!s??or??gavtsev?k&rajb?sa??lem?mrak?n&art?n&if?orb???r&a&mah?n?v??e&dni?t&so?ton??va??ul?yd??s&am?enner?gav?lrak?tivk??vrejks??ø&d&ar?na!s??ør??gåvtsev?k&rajb?sa??lem?mrak?n&art?n&if?ørb???r&e&dni?t&so?tøn??va??ul?yd?æ&n?v???s&enner?gåv?tivk?åm??vrejks???á&slág?tlá?vreiks??å&gåv?h?jddådåb?lf??ø&d&ob?rav??r&egark?olf??s&dav?mort????aki?i&sac?tal??u??o&b?f?g?hay?o?ttat??r!.&cer?erots?gro?m&o&c?n??rif?t?yn,?o&c,fni??pohs,stra?t&n?opsgolb,?www??e&a!.&a&ac?cgd?idem??bulc!orea??ci&ffartria?taborea??e&cn&a&l&lievrus-ria?ubma??netniam?rusni??erefnoc??gnahcxe?mordorea?ni&gne?lria?zagam??rawtfos??gni&d&art?ilg!arap?gnah???l&dnahdnuorg?ledom??noollab?retac?sael?t&lusnoc?uhcarap??vidyks??hcraeser?l&anruoj?euf?icnuoc?ortnoc!-ciffart-ria???n&gised?oi&nu?t&a&cifitrec?ercer?gi&tsevni-tnedicca?van??i&cossa!-regnessap??valivic??redef??cudorp?neverp-tnedicca????ograc?p&ihsnoipmahc?uorg!gnikrow???r&e&dart?enigne?korb?niart?trahc??o&htua?tacude???s&citsigol?e&civres?r??krow?serp!xe??tnega??t&farcr&ia?otor??hgil&f?orcim??liubemoh?n&atlusnoc?e&duts?m&esuma?n&iatretne?revog??piuqe????olip?ropria?si&lanruoj?tneics???w&erc?ohs??y&cnegreme?dobper?tefas????rref?z??p!.&a&aa?ca?pc??dem?ecartsnd.icb,gne?r&ab?uj??snduolc,t&acova?cca?hcer??wal?ysrab,???s!.&em?gro?hcs,moc?ten?ude?vog???t!.&116,ayo,gro?lim?moc?nayn,sulpnpv,t&cennockciuq.tcerid,en??ude?v&dr,og???o&hp?m?v?yk??tol?ua??v&iv?lov??xas?ykot??p&a&ehc?g?m?s??cj?eej?g!.&gro?ibom?moc?ossa?ppa,ten?ude???i&r!.nalc,?v?z??j!.&a&3&5xq6f--nx?xqi0ostn--nx??5wtb6--nx?85uwuu--nx?9xtlk--nx?bihc!.&a&bihciakoy?don?ma&him?ye&ragan?tat???r&a&bom?gan?hihci??u&agedos?kas?ustak???s&os?ufomihs??t&amihcay?iran??w&a&g&im&anah?o??omak??kihci?zustum??ihsak??y&agamak?imonihci???e&akas?nagot??i&azni?esohc?h&asa?s&abanuf?ohc???ka&to?zok??musi?orihs?r&akihabihsokoy?o&dim?tak??ukujuk??usihs??nano&hc?yk??o&d&iakustoy?ustam??hsonhot?k&a&rihs?t??iba??nihsaran?sobimanim?tas&arihsimao?imot??uhc?yihcay??u&kujno?s&ayaru?t&imik?tuf???zarasik????g&as!.&a&gas?m&a&tamah?yik??ihsak??rat?t&a&gatik?hatik??ira!ihsin????e&kaira?nimimak??i&akneg?g&aruyk?o??h&c&amo?uo??siorihs??kaznak?modukuf?ra&gonihsoy?mi???nezih?u&k&at?ohuok??s&ot?tarak?????ihs!.&a&kok?m&a&hagan?yirom??ihsakat??rabiam?wagoton??e&miharot?nokih??houyr?i&azaihsin?esok?kustakat?moihsagih??na&mihcahimo?nok??o&hsia?mag?t&asoyot?ok?tir???us&ay?t&asuk?o??????k&aso!.&a&d&awihsik?eki??k&a&noyot?s&akaayahihc?oihsagih???oadat?uziak??m&ayas!akaso??odak??r&a&bustam?wihsak??ediijuf??t&akarih?i&k?us???wag&ayen?odoyihsagih???e&son?tawanojihs??honim?i&akas?h&cugirom?s&ayabadnot?i&a&kat?t??n??oyimusihsagih???k&a&rabi?sim??ustakat??muzi?r&ijat?otamuk???nan&ak?n&ah?es???o&ay?n&a&ganihcawak?simuzi?tak??eba?ikibah?oyot??t&anim?iad?omamihs??uhc??ust&oimuzi?tes????ou&kuf!.&a&d&amay?eos??g&no?ok?usak??hiku?k&awayim?uzii??ma&kan?y&asih?im???rawak?t&a&gon?ka&h?num?t???umo??wa&g&a&kan?nay?t??ias??ko!rih???y&ihsa?usak???e&m&ay?uruk??taruk?us??i&a&nohs?raihcat??goruk?h&cukuf?s&a&gih?hukuy??in???k&a&gako?muzim??iust?o?ustani??m&anim?otihsoynihs?u??r&ogo?ugasas??usu??ne&siek?zu&b?kihc???o&gukihc?h&ak?ot?ukihc??j&ono?ukihc??kayim?nihsukihc?to?uhc??u&fiazad?gnihs?stoyot????zihs!.&a&bmetog?d&amihs?eijuf?ihsoy?omihs??kouzihs?mihsim?ra&biah?honikam??tawi?wa&g&ekak?ukik??kijuf??yimonijuf??i&a&ra?sok??hcamirom?juf?kaz&eamo?ustam??ma&nnak?ta??nukonuzi?orukuf??nohenawak?o&nosus?ti??u&stamamah?z&a&mun?wak??i!ay?i&hs&agih?in??manim??mihs????????m&a&tias!.&a&d&ihsoy?ot?usah??k&a&dih?sa??o&arihs?s???m&a&tias?y&as?o&rom?tah??ustamihsagih???i&hsagurust?jawak??uri??ni?wa&g&e&ko?man??ikot?o??k&ara?i&hsoy?mak???ru?zorokot??y&a&g&amuk?ihsok?otah??kuf??imo??ziin??e&bakusak?ogawak?sogo?ttas?zokoy??i&baraw?h&cugawak?s&oyim?ubustam???iroy?k&ato?ihs?u&k?stawi???m&akoyr?i&hsoy?juf??uziimak???naznar?o&dakas?ihsay?jnoh?n&a&go?nim??imijuf?nah?oy??r&ihsayim?otagan??t&asim!ak??igus?omatik??zak??u&bihcihc!ihsagih??sonuok?ynah????y&ak&aw!.&a&d&ira?notimak??kadih?ma&h&arihs?im??y&a&kaw?tik??oduk???ru&ustakihcan?y??sauy?wa&g&a&dira?zok??orih??konik??yok?zok??e&banat?dawi??i&garustak?jiat?mani??naniak?o&bog?nimik?t&asim?omihs&ah?uk????ugnihs???o!.&a&jos?koasak?m&ay&ako?ust??ihsayah??r&abi?ukawaihsin??wi&aka?nam???e&gakay?kaw??i&gan?h&cu&kasa?otes??sahakat??k&asim?ihsaruk??miin??n&anemuk?ezib??o&hsotas?jnihs?n&amat?imagak??ohs?uhcibik?????ot!.&a&damay?got?koakat?may&etat?ot??nahoj?riat?waki&inakan?reman???eb&ayo?oruk??i&h&asa?ciimak?sahanuf??kuzanu?m&an&i?ot??ih???nezuyn?otnan?u&hcuf?stimukuf?z&imi?ou???????ihs&o&gak!.&a&m&ayuok?ihsogak??si?yonak??e&banawak?n&at&akan?imanim??uka??tomoonihsin??i&adnesamustas?k&azarukam?oih??m&ama?uzi??usuy??nesi?o&knik?os?tomustam??uzimurat???rih!.&a&ka&n?s??m&ayukuf?i&hsorihihsagih?j&ate?imakikaso????r&a&bohs?h&ekat?im???es??tiak?wiad??e&kato?ruk??i&h&ci&akustah?mono?nihs??s&inares?oyim???manimasa?uk??negokikesnij?o&gnoh?namuk??uhcuf????uk&ot!.&a&bihci?mi&hsu&kot?stamok??m??wagakan??egihsustam?i&gum?h&coganas?soyim??kijaw?m&anim?uzia??ukihsihs??nan&a?iak??o&nati?turan????uf!.&a&batuf?m&a&to?y&enak?irok???ihs&im?ukuf??os?uko??r&aboihsatik?uganat??ta&katik?mawak?rih??w&a&g&akus?emas?uy??k&a&mat?rihs?sa??ihsi??nah??ohs???e&gnabuzia?iman?ta&d?tii???i&adnab?enet?hs&agih?iimagak??k&a&wi?zimuzi??ubay??minuk?r&ook?ustamay???nihsiat?o&g&etomo?ihsin?nan?omihs??no!duruf?rih??rihsawani?ta&may?simuzia???u&rahim?stamakawuzia?zia&ihsin?nay???????nug!.&a&bawak?doyihc?k&anna?oi&hsoy?juf?mot???m&ayakat?ustagaihsagih??n&ihsatak?nak??r&ahonagan?nak?o?u&kati?mamat???t&amun?inomihs?o??w&akubihs?iem?ohs???i&hsa&beam?yabetat??kas&akat?esi??m&akanim?uzio??ogamust?rodim??o&jonakan?n&eu?oyikust??tnihs??u&komnan?stasuk?yrik?????ran!.&a&bihsak?d&akatotamay?u!o???guraki?m&ay&atik&imak?omihs??irokotamay??oki??ra&hihsak?n??wa&geson?knet???e&kayim?ozamay?sog?ustim??i&a&rukas?wak??garustak?h&ciomihs?sinawak??jo?ka&mnak?toruk??makawak?nos?r&net?otakat?ugeh???o&d&na?oyo??gnas?jnihs?nihsoy!ihsagih??tomarawat?yrok????t&ag&amay!.&a&dihsio?k&atarihs?ourust??may&a&kan?rum??enak?onimak??rukho?ta&ga&may?nuf??hakat?kas??wa&g&ekas?orumam??ki&hsin?m??z&anabo?enoy?ot???zuy??e&agas?bonamay?dii?nihsagih?o??i&a&gan?nohs??h&asa?sinawak??nugo??o&dnet?jnihs?ynan??ukohak???iin!.&a&ga?k&ium?oagan??munou!imanim??t&a&bihs?giin??ioy??w&a&gioti?kikes?zuy??irak??yijo??e&kustim?mabust??i&aniat?hcamakot?kaz&awihsak?omuzi??m&a&gat?karum??o???n&anust?esog??o&das?ihcot?jnas?k&ihay?oym??mak?naga?ries??u&ories?steoj?????i&ka!.&a&go?k&asok?oimak??t&ago!rihcah??ika!atik???w&aki?oyk???e&mojog?natim?suranihsagih?t&ado?okoy???i&hsoyirom?magatak?naokimak??nesiad?o&hakin?jnoh!iruy??nuzak?rihson?tasi&juf?m??yjnoh??u&kobmes?oppah????o!.&a&dakatognub?m&asah?ihsemih??su?t&ekat?i&h?o????e&onokok?ustimak??i&jih?k&asinuk?ias?usu??mukust??onoognub?u&fuy?juk?ppeb?suk??????wa&ga&k!.&a&mihsoan?rihotok?waga&kihsagih?ya???emaguram?i&j&nonak?ustnez??kunas?monihcu??o&hsonot?nnam?yotim??u&st&amakat?odat??zatu????nak!.&a&dustam?kus&okoy?tarih??maz?nibe?r&a&gihsaimanim?h&esi?imagas??wa&do?guy???u&im?kamak???tikamay?wa&k&ia?oyik?umas??sijuf??yimonin??e&nokah?saya??i&akan?esiak?gusta?hsuz?kasagihc?o?ukust??o&nadah?sio?tamay?????kihsi!.&a&danihcu?gak?kihs?mijaw?t&abust?ikawak??wazanak??i&gurust?hcionon?mon?ukah??nasukah?o&anan?ton!akan???u&kohak?stamok?z&imana?us?????niko!.&a&han?m&arat?ijemuk?uru??n&e&dak?zi??no??ra&hihsin?rih??wa&kihsi?niko??yehi?zonig??e&osaru?seay??i&hsagih?jomihs?k&a&gihsi?not??ihsakot??m&a&ginuk?kihsug?maz??igo?otekat??nuga!noy???n&a&moti?timoy?wonig??i&jikan?k???o&gan?jnan?tiad&atik?imanim???u&botom?kusug&akan!atik??imot??rab&anoy?eah???????c&204ugv--nx?462a0t7--nx?678z7vq5d--nx?94ptr5--nx?a??d&17sql1--nx?3thr--nx?5&20xbz--nx?40sj5--nx??7&87tlk--nx?ptlk--nx??861ti4--nx?a?e??e&16thr--nx?5&1a4m2--nx?9ny7k--nx??im!.&a&bot?k&asustam?uzus??m&a&him?y&emak?im???ihs??nawuk?wi&em?k???e&bani?ogawak?si!imanim???i&arataw?gusim?h&asa?ciakkoy??k&a&mat?sosik?t??iat??raban??o&dat?hik?n&amuk?ihseru?o&du?mok????ust???mihe!.&a&m&a&h&ataway?iin??yustam??ij&awu?imak???taki!man???ebot?i&anoh?kasam?rabami??n&ania?egokamuk?oot??o&jias?kihcu?nustam?uhcukokihs?yi!es???u&kohik?zo????n!.&nriheg,teniesa.resu,?amihs!.&a&d&amah?ho?usam??kustay?m&a?ihsoni&hsin?ko???wakih??e&namihs?ustam??i&g&aka?usay??konikak?mikih??nannu?o&mu&kay?zi!ihsagih?uko???nawust?tasim??u&stog?yamat?????tawi!.&a&bahay?d&amay?on??koirom?t&a&honat?katnezukir??imus??w&as&ijuf?uzim??ihs???e&hon&i&hci?n??uk??tawi??i&a&duf?murak?wak??h&custo?si&amak?ukuzihs???j&oboj?uk??k&a&m&anah?uzuk??sagenak??esonihci??m&akatik?uzia&rih?wi????o&kayim?no&rih?t??tanufo??uhso????g&3zsiu--nx?71qstn--nx?l??h&03pv23--nx?13ynr--nx?22tsiu--nx?61qqle--nx??i&54urkm--nx?g&ayim!.&a&dukak?m&a&goihs?kihs??ihsustam!ihsagih??unawi??r&awago?iho??ta&bihs?rum??w&a&gano?kuruf??iat??y&imot?ukaw???e&mot?nimes??i&hsiorihs?ka&monihsi?s&awak?o???mak?r&ataw?o&muram?tan????o&az?jagat?t&asim?omamay???u&fir?k&irnasimanim?uhsakihcihs?????ihcot!.&a&g&a&h?kihsa??ust??kom?m&ay&o?usarak??unak??r&a&boihsusan?watho??iho?ukas??t&akihsin?iay??wa&konimak?zenakat??y&imonustu?oihs???e&iiju?kustomihs?nufawi??i&akihci?g&etom?ihcot?on???o&k&ihsam?kin??nas?sioruk?tab??u&bim?san?????h&c&ia!.&a&dnah?m&a!h&akat?im??yuni??ihs&ibot?ust???r&a&hat?tihs??ik?u&ihsagih?kawi???t&ihc?o&k?yot???wa&koyot?zani??yi&monihci?rak???e&inak?k&aoyot?usa??manokot?noyot??i&a&gusak?kot?sia??eot?h&asairawo?cugo?s&ahoyot?oyim???k&a&mok?zako??ihssi??motay?rogamag??n&an&ikeh?ok??ihssin??o&got?ihsin?jna?rihsnihs?suf?tes??u&bo?raho?s&oyik?takihs??yrihc?zah????ok!.&a&dusay?kadih?mayotom?r&ah&im?usuy??umakan??sot!ihsin??wa&g&atik?odoyin??k&as?o????i&esieg?hco!k??jamu?k&a!sus??usto??ma&gak?k??rahan??o&mukus?n&i?ust!ihsagih???torum?yot!o???u&koknan?zimihsasot????ugamay!.&a&m&ayukot?ihso??toyot??e&bu?subat??i&gah?kesonomihs?nukawi?rakih??nanuhs?otagan?u&ba?foh?otim?stamaduk?uy?????sanamay!.&a&dihsoyijuf?mayabat?r&ahoneu?ustakihsin??w&a&k&ayah?ijuf??suran??ohs???egusok?i&ak?h&cimakan?s&anamay?od???k&asarin?u&feuf?sto????o&k&akanamay?ihcugawakijuf??nihso?t&asimawakihci?ukoh??uhc??spla-imanim?u&b&nan?onim??fok?hsok?rust?????ka&rabi!.&a&bukust?gok?kan!ihcatih??m&a&sak?timo?wi??ihsak?ustomihs??ni?r&a&hihcu?way??u&agimusak?ihcust???t&ag&amay?eman??oihcatih??w&ag&arukas?o??os??yi&moihcatih?rom???e&bomot?dirot?not?tadomihs??i&a&k&as?ot??rao??esukihc?gahakat?h&asa?catih??k&a&rabi?saguyr??ihsani?uy??ma?rukustamat??o&dnab?giad?him?kati?rihsijuf?soj?t&asorihs?im??yihcay??u&fius?kihsu?simak????sagan!.&a&m&abo?ihsust??natawak?r&abamihs?u&mo?ustam???wijihc?yahasi??i&akias?hies?k&asagan?i??masah??neznu?o&besas?darih?t&eso?og!imaknihs????ust&igot?onihcuk?uf????zayim!.&a&biihs?guyh?k&oebon?ustorom??mihsuk?r&emihsin?uatik??ta&katik?mim??wag&atik?odak??ya??e&banakat?sakog??i&hsayabok?kaza&kat?yim??m&animawak?ot&inuk?nihs????nanihcin?o&j&ik?onokayim??n&ibe?ust??tias??urahakat????ro&moa!.&a&dawot?turust?wasim??e&hon&ihc&ah?ihs??nas?og?ukor??sario??i&anarih?ganayati?hsioruk?jehon?kasorih?makihsah?nawo?r&amodakan?omoa???o&gnihs?kkat??u&ragust?stum????ttot!.&a&r&ahawak?uotok??sa&kaw?sim???egok?irottot?nanihcin?o&ganoy?nih?tanimiakas??u&bnan?z&ay?ihc??????ukuf!.&a&deki?gurust?ma&bo?h&akat?im??yustak??sakaw??eabas?i&akas?ho?jiehie?ukuf??nezihce!imanim??ono????k&26rtl8--nx?4&3qtr5--nx?ytjd--nx??522tin--nx?797ti4--nx??l33ussp--nx?m&11tqqq--nx?41s3c--nx??n&30sql1--nx?65zqhe--nx?n7p7qrt0--nx??o&131rot--nx?7qrbk--nx?c?diakkoh!.&a&deki?gakihset?hcebihs?k&adih?u&fib?narihs???m&ayiruk?hot?ihs&orihatik?ukuf??oras?usta??r&ib&a!ka??o?uruf??ozo?u&gakihsagih?oyot???sakim?ta&gikust?mun??w&a&ga&k&an?uf??nus!imak???k&aru?i&h&asa?sagih??kat?mak??omihs?um??zimawi??ine?oyk??yot??e&a&mustam?nan??b&a&kihs?yak??o&noroh?to???ian?k&ihsam?ufoto??nakami?ppoko!ihsin??sotihc?tad!okah??uonikat??i&a&bib?mokamot?n&a&k&kaw?oroh??wi??eomak?ihsatu?okik?usta&moruk?sakan????eib?h&c&ioy?u&bmek?irihs???s&ase?ekka?oknar?uesom???jufirihsir?k&amamihs?i&at?n???m&atik?otoyot??oa&kihs?rihs??r&a&hs?kihsi?mot??ihs&aba?ir??otarib???n&a&hctuk?rorum?se?tokahs??uber??o&kayot?m&ire?ukay??naruf!ima&k?nim???orih?r&ih&ibo?suk??o&bah?h&i&b?hsimak??sa??pnan?yan??umen??t&asoyik?eko?ukoh???u&bassa?kotnihs?m&assaw?uo??pp&akiin?en&ioto?nuk??ip??rato?s&akat?t&eb&e?i&a?hs!a??robon??m&e?o&m?takan???no&h?tamah??o&mik?s?t??u&kir?ppihc?st???onihsnihs?ufuras??uaru??yru!koh??zimihs!ok?????g!oyh!.&a&bmat?dnas?gusak?k&at?o&oyot?y??uzarakat??m&ayasas?irah??wa&g&ani?okak??k&i&hci?mak??oy???yi&hsa?monihsin???i&asak?hs&aka?i&at?nawak???j&awa!imanim??emih??k&a&goa?s&agama?ukuf??wihsin??i&hsog?m???mati?oia?rogimak??n&annas?esnonihs??o&gasa!kat??ka?n&ikat?o?ustat??rihsay?sihs?tomus?yas??u&bay?gnihs?????nagan!.&a&bukah?d&a&w?yim??e&ki?u??ii??k&a&s&ay?uki??zus??ihsoo?ousay??m&ay&akat?ii??i&hsukufosik?jii??ukihc??n&i!hsetat??uzii??r&ah?ugot??saim?t&agamay?oyim??w&a&g&a&kan?n??o??kustam?ziurak??onim!imanim??u&koo?s!omihs????ya&ko?rih???e&akas?nagamok?subo??i&gakat?h&asa?c&a!mo!nanihs???uonamay??sukagot??k&a&kas?mimanim?to??ia&atik?imanim??oa?uzihcom??m&akawak?ijuf?o!t???r&ato?ijoihs?omakat???n&ana?esnoawazon??o&hukas?n&a&gan?kan??i&hc?muza??ustat??romok?si&gan?k??tomustam??u&k&as?ohukihc??stamega????to&mamuk!.&a&gamay?rahihsin?sukama!imak??tamanim??enufim?i&hcukik?k&ihsam?u??nugo!imanim??romakat??o&ara?rihsustay?sa?t&amay?om&amuk?us??u!koyg???yohc??u&sagan?zo????yk!.&a&bmatoyk?k&ies?oemak?uzaw??mayi&h&cukuf?sagih??muk??nihsamay?rawatiju?t&away?ik???e&ba&nat!oyk??ya??di?ni??i&ju?kazamayo?manim??natnan?o&gnatoyk?kum?mak?rihsamayimanim?y&gakan?ka&koagan?s??oj???u&ruziam?z&ayim?ik??????wtc1--nx?ykot!.&a&d&i&hcam?mus??oyihc??k&atim?ihsustak??m&a&t!uko??yarumihsa&gih?sum???i&hs&agoa?ika?o!t??uzuok??ren???r&a&honih?wasago??iadok?umah??ssuf?t&ik?o??wa&g&anihs?ode??k&ara?ihcat???y&agates?ubihs???e&amok?donih?m&o?urukihsagih??soyik??i&enagok?gani?h&ca&da?tinuk??sabati??j&nubukok?oihcah??manigus??o&huzim?jihcah?n&akan?ih!sasum??urika??rugem?t&a&mayihsagih?nim??iat?ok??uhc?yknub??u&fohc?hcuf?kujnihs?????r&2xro6--nx?g?o??s&9nvfe--nx?xvp4--nx??t&netnocresu,opsgolb,?u&4rvp8--nx?fig!.&a&d&eki?ih??kimot?m&ayakat?ihsah??ne?raha&gi&kes?makak??sak??taga&may?tik??wa&g&ibi?ustakan??karihs!ihsagih????e&katim?uawak??i&gohakas?hc&apna?uonaw??k&ago?es?ot??m&anuzim?ijat??nak?urat??nanig?o&dog?jug?makonim?nim?roy?sihcih??u&fig?s&otom?t&amasak?oay???????x5ytlk--nx?yu6d27srjd--nx?z72thr--nx?井福?京東?分大?取鳥?口山?城&宮?茨??媛愛?山&富?岡?歌和??岡&福?静??島&児鹿?広?徳?福??崎&宮?長??川&奈神?石?香??庫兵?形山?手岩?木栃?本熊?根島?梨山?森青?潟新?玉埼?田秋?知&愛?高??縄沖?良奈?葉千?賀&佐?滋??道海北?都京?重三?野長?阜岐?阪大?馬群???k!.&art?gro?moc?per?ude?vog???l&eh?l??m!ac?j??nd?o&g?h&pih?s!.ysrab,??lnud?oc?t!.&lldtn,snd-won,???pa!.&0mroftalp,arusah,bew,enilnigol,lecrev,nur:.a,,t&ibelet,xenw,?yfilten,??ra&a?hs??u&ekam?llag?org!.esruocsid,cts?kouk?nayalo???vsr?xece4ibgm--nx??q&a!3a9y--nx??g?i!.&gro?lim?moc?ten?ude?vog???m?se??r&a!.&acisum?bog?gro?lim?moc!.topsgolb,?rut?t&en?ni??ude?vog??4d5a4prebgm--nx?b?c?eydoog?los?t&at?s!uen???ugaj??b!.&21g?a&b&a&coros?iuc??itiruc??cnogoas?dicerapa?gniram?i&naiog?ramatnas??n&erom?irdnol??op?p&acam?irolf?ma&j?s???rief?tsivaob??b!aj?ib?mi?sb??c&ba?e&r?t??js?sp?t!e???d&em?mb?n&f?i??rt??e&dnarganipmac?ficer?ht?llivnioj?rdnaotnas??f&dj?ed?gg?n&e?i???g&e&l!.&a&b,m,p,?bp,c&a,s,?e&c,p,s,?fd,gm,ip,jr,la,ma,nr,o&g,r,t,?p&a,s,?r&p,r,?s&e,m,r,?tm,??s??l&s?z??n&c?e?o??ol!b?f?v??pp?ro??hvp?i&du?kiw?nana?oretin?r&c?eurab??sp?te?xat??l&at&an?rof??el?im?sq??m&a?da?e&gatnoc?leb??f?ic?oc!.topsgolb,??nce?o&ariebir?c&e?narboir?saso??d&o?ranreboas??e&g?t??i&b?dar?ecam?r??rp?t&a?erpoir???p&er?m!e?t??ooc?pa?se??qra?r&af?ga?o&davlas?j??tn?ut??s&a&ixac?mlap?nipmac??ed?u&anam?j?m???t&am?e&d?n?v??nc?o&f?n??ra?sf??u&caug9?de?ja?rg??v&da?ed?og!.&a&b?m?p??bp?c&a?s??e&c?p?s??fd?gm?ip?jr?la?ma?nr?o&g?r?t??p&a?s??r&p?r??s&e?m?r??tm???rs?t??xiv?z&hb?ls?o&c?f?????c!.&as?ca?de?if?o&c?g??ro???e&bew?ccos?dnik?e&b?n&igne?oip??rac??gni&arg?rheob??h&cor?sok?t&aew?orb???itnorf?k&col?o&p?rb???l&aed?ffeahcs??mal?nes?pinuj?t&a&eht?rebsnegömrev??law?nec?s&acnal?nom?ubkcolb??upmoc??v&o&c&sid?tfiws??rdnal??resbo??wulksretlow?ywal?zifp??f!.&aterg?bew-no,drp?e&c&itsuj-reissiuh?narf-ne-setsitned-sneigrurihc,?rianiretev??i&cc?rgabmahc??m&o&c?n??t??n&eicamrahp?icedem??ossa?s&e&lbatpmoc-strepxe?riaton?tsitned-sneigrurihc?uova??o&-x&bf,obeerf,?x&bf,obeerf,???t&acova?o&or-ne,psgolb,?r&epxe-ertemoeg?op!orea????vuog??avc7ylqbgm--nx?s??g!.&gro?m&oc?yn,?t&en?opsgolb,?ude?vog???h!.&e&erf,man??mo&c?rf??topsgolb,zi??ur??i!.&a&61f4a3abgm--nx?rf4a3abgm--nx??ca?di?gro?hcs?oc?ten?vog?نار&يا?یا???a&h?per??ew?lf??k!.&c&a?s??e&n?p?r??gk?iggnoeyg?kub&gn&oeyg?uhc??noej??l&im?uoes??man&gn&oeyg?uhc??noej??n&as&lu?ub??o&e&hcni?jead??wgnag???o&c?g??ro?s&e?h?m??topsgolb,u&gead?j&ej?gnawg????cilf??l!.&gro?moc?ten?ude?vog???m!.&topsgolb,vog???n!.&gro?moc?ofni?ten?ude?vog?zib???o&htua?odtnorf?t&c&a?od??laer???p!.&alsi?ca?eman?forp?gro?moc?o&fni?rp??t&en?se??ude?vog?zib???s?t!.&21k?bew?cn!.vog??eman?gro?kst?l&e&b?t??im?op??moc!.topsgolb,?neg?ofni?pek?rd?sbb?ten?ude?v&a?og?t??zib??f?m??ubad?vd??s&8sqif--nx?9zqif--nx?a!.vog?birappnb?gev?lliv?mtsirhc?s??b!.&ew,gro?moc?ten?ude?vog??c?oj?s?u??c&i&hparg?p?t&sigolyrrek?ylana???od??d&a?d?l?n&iwriaf?omaid??oogemoh?rac??e!.&bog?gro?mo&c!.topsgolb,?n??ude??civres!.enilnigol,?d&d2bgm--nx?oc??h&ctaw?guh??i&lppus?rtsudni?treporp!yrrek???jaiv?l&aw?cycrotom?etoh?gnis?pats??m&ag?oh?reh??nut?ohs?picer?r&it?ut&cip!.7331,?nev???s!i&rpretne?urc??ruoc??taicossa?vig??g!nidloh??h5c822qif--nx?i!.&ekacpuc,gro?moc?t&en?ni?opsgolb,?ude?vog??a09--nx?nnet?rap?targ??k&c&or!.&ecapsbew,snddym,ytic-amil,??us??hxda08--nx?row??l!.&c&a?s??ed,gro?o&c?fni??ten?ude?vog?zib??a&ed?tner??e&ssurb?toh!yrrek???lahsram?m?oot??m!.&bal,gro?moc?ten?ude?vog??b?etsys!.tniopthgink,?ialc??n&a&f?gorf?ol??egassap?i&a&grab?mod??giro??o&it&acav?cudorp?ulos??puoc???o&dnoc?geuj?leuv?ppaz?t&ohp?ua???p!.&ces?gro?moc?olp?ten?ude?vog??i&hsralohcs?lihp?t??u??r!.&au,ca?gro?mon,ni?oc?topsgolb,ude?vog?xo,?a&c?p?tiug??c?e&dliub?erac?gor?levart?mraf?n&niw?trap??wolf??ot&cartnoc?omatat??pj?uot??s!.&gro?moc?ten?ude?vog?zib??alg?e&n&isub!.oc,?tif??rp!xe!nacirema???xnal??iws??t&a&e&b?ytic??ob??ek&cit?ram??fig?h&cay?gilf??n&atnuocca?e&mt&rapa?sevni??ve!.oc,???rap??u!.&a&c!.&21k?bil?cc???g!.&21k?bil?cc???i!.&21k?bil?cc???l!.&21k?bil?cc???m!.&21k!.&hcorap?rthc?tvp???bil?cc???p!.&21k?bil?cc???si?v!.&21k?bil?cc???w!.&21k?bil?cc????c&d!.&21k?bil?cc???n!.&21k?bil?cc???s!.&21k?bil?cc????d&ef?i!.&21k?bil?cc???m!.&21k?bil?cc???n!.&bil?cc???s!.&bil?cc???urd,?e&d!.&21k?bil,cc???las-4-&dnal,ffuts,?m!.&21k?bil?cc???n!.&21k?bil?cc????h&n!.&21k?bil?cc???o!.&21k?bil?cc????i&h!.&bil?cc???m!.&21k?bil?c&c?et??goc?n&eg?otae??robra-nna?sum?tsd?wanethsaw???nd?r!.&bil?cc???v!.&21k?bil?cc???w!.&21k?bil?cc????jn!.&21k?bil?cc???k&a!.&21k?bil?cc???o!.&21k?bil?cc????l&a!.&21k?bil?cc???f!.&21k?bil?cc???i!.&21k?bil?cc????mn!.&21k?bil?cc???n&afflog,i!.&21k?bil?cc???m!.&21k?bil?cc???sn?t!.&21k?bil?cc????o&c!.&21k?bil?cc???m!.&21k?bil?cc???ttniop,?p&ion,rettalp,?r&a!.&21k?bil?cc???o!.&21k?bil?cc???p!.&21k?bil?cc????s&a!.&21k?bil?cc???dik?k!.&21k?bil?cc???m!.&21k?bil?cc???nd&deerf,uolc,??t&c!.&21k?bil?cc???m!.&21k?bil?cc???u!.&21k?bil?cc???v!.&21k?bil?cc????ug!.&21k?bil?cc???v&n!.&21k?bil?cc???w!.cc???x&ohparg,t!.&21k?bil?cc????y&b-si,k!.&21k?bil?cc???n!.&21k?bil?cc???w!.&21k?bil?cc????za!.&21k?bil?cc????ah!uab??bria?col?e!.ytrap.resu,?ineserf?lp?xe&l?n???vt?w!.&66duolc,gro?moc?s&ndnyd,tepym,?ten?ude?vog??a?e&iver?n??odniw??y&alcrab?cam?ot???t&0srzc--nx?a!.&amil4,ca!.hts??gni&liamerutuf,tsoherutuf,?o&c!.topsgolb,?fni,?ph21,r&euefknuf.neiw,o??v&g?irp,?xi2,ytic-amil,zib,?c?e!s??hc?if?l!asite??mami?rcomed??b!.&gro?moc?ten?ude?vog??b?gl??c&atnoc?e&les?rid!txen????dimhcs?e!.&eman?gro?moc?ofni?ten?ude?vog?zib??b?em?grat?id?k&circ?ram??n!.&0&002cilc,rab,?1rab,2rab,5inu,6vnyd,7&7ndc.r,erauqs,?a&l&-morf,moob,?minifed,remacytirucesym,tadsyawla,z,?b&boi,g,lyltsaf:.pam,,?c&inagro-gnitae,paidemym,?d&ecalpb,nab-eht-ni,uolc&meaeboda,nievas.citsalej,xednay:.e&garots,tisbew,?,??e&cnarusnihtlaehezitavirp,gdirbtib,ht-no-eciffo,l&acsnoom,ibom-eruza,?m&ecnuob,ohtanyd,tcerider,?nozdop,rehurht,s,tis-repparcs,zamkcar,?f&aeletis,crs.&cos,resu,?ehc-a-si,?g&ni&reesnes,tsohnnylf,?olbevres,?k&eeg-a&-si,si,?u,?l&acolottad,iamwt,s&d-ni,s-77ndc,??m&ac&asac,ih,?urofniem,?n&a&f&agp,lhn,?ibed,?dcduabkcalb,i,pv-ni,?o&c-morf,jodsnd,rp-ytinummoc,ttadym,?p&i&-&etsef,on,?emoh,fles,nwo,?j,mac-dnab-ta,o&-oidar-mah,hbew,?pa&duolc,egde,?tfe&moh,vres,?usnd,?r&e&tsulcyduolc,vres-xnk,?vdslennahc:.u,,?s&a&ila&nyd,snd,?nymsd,?bbevres,dylimaf,e&suohsyub,t&isbeweruza,ys,??kekokohcs,n&d&-won,d,golb,npv,?oitcnufduolc,?s&a-skcik,ecca&-citats,duolc,???t&adies,ceffeym,e&nretnifodne,smem,?farcenimevres,i-&ekorb,s&eod,lles,teg,??n&essidym,orfduolc,?r0p3l3t,s&ixetnod,ohgnik,??u&h,nyd,r,?x&inuemoh,spym,tsale.1ots-slj,unilemoh,?y&awetag-llawerif,ffijduolc,ltsaf.&dorp.&a,labolg,?lss.&a,b,labolg,?pam,slteerf,?n&-morf,ofipi,?srab,tieduolc,?z&a-morf,tirfym,???p?tcip?v??f&ig?o&l?sorcim???g!.&bog?dni?ed,g&olb,ro??lim?mo&c?n,?ot,ten?ude???h!.&dem?gro?l&er?op??m&oc?rif??o&fni?rp?s&rep?sa???po&hs?oc??t&en?luda?ra??ude?vuog???i!.&a&2n-loritds--nx?7e-etsoaellav--nx?8&c-aneseclrof--nx?i-lrofanesec--nx??at?b?c!cul??dv?i&blo&-oipmet?oipmet??cserb?drabmol?g&gof?urep??l&gup?i&cis?me&-oigger?oigger???uig&-&aizenev&-iluirf?iluirf??ev&-iluirf?iluirf??v&-iluirf?iluirf???aizenev&-iluirf?iluirf??ev&-iluirf?iluirf??v&-iluirf?iluirf????n&a&brev?cul?pmac?tac??idras?obrac&-saiselgi?saiselgi??resi??otsip?r&b&alac!-oigger?oigger??mu??dna&-&attelrab-inart?inart-attelrab??attelrabinart?inartattelrab?ssela??epmi?ugil??tnelav&-obiv?obiv??vap?z&e&nev?ps&-al?al???irog???l&iuqa!l??leib??m&or?rap??n!acsot?e&dom?is?sec&-&ilrof?ìlrof??ilrof?ìlrof???g&amor&-ailime?ailime??edras?olob??i&ssem?tal??ne!var??o&cna?merc?rev?vas???oneg?p?r!a&csep?rr&ac&-assam?assam??ef??von??etam?tsailgo!-lled?lled???s!ip?sam&-ararrac?ararrac??u&caris?gar???t!a&cilisab?recam??resac?soa!-&d&-&ellav?lav??ellav?lav??ellav??d&-&ellav?lav??ellav?lav??ellav??te&lrab&-&airdna-inart?inart-airdna??airdnainart?inartairdna??ssinatlac???udap?v!o&dap?neg?tnam???zn&airb&-a&lled-e-aznom?znom??a&lledeaznom?znom??eaznom??e&c&aip?iv??soc?top??om???b&-&23,46,61,?3c-lorit-ds-onitnert--nx?be-etsoa&-ellav--nx?dellav--nx??c!f-anesec-lrof--nx?m-lrof-anesec--nx??he-etsoa-d-ellav--nx?m!u??o2-loritds-nezob--nx?sn-loritds&-nasl&ab--nx?ub--nx??nitnert--nx??v!6-lorit-dsnitnert--nx?7-loritds&-nitnert--nx?onitnert--nx???z&r-lorit-ds&-nitnert--nx?onitnert--nx??s-loritds-onitnert--nx???c&f?is?l?m?p?r?v??d&p?u!olcnys,??e&c!cel?inev?nerolf??f?g!ida&-&a&-onitnert?onitnert??otla!-onitnert?onitnert???a&-onitnert?onitnert??otla!-on&azlob?itnert??onitnert????hcram?l?m!or??n&idu?o&n&edrop?isorf??torc???p?r?s&erav?ilom??t!nomeip?s&eirt?oa!-&d-e&ellav?éllav??e&ellav?éllav???de&ellav?éllav??e&ellav?éllav?????v?znerif??g&a?b?f?il?o?p?r?up?vf??hc?i&b?c?dol?f?l!lecrev?opan?rof&-anesec?anesec???m?n&a&part?rt&-attelrab-airdna?attelrabairdna???imir?ret??p?r!a&b?ilgac?ssas???s!idnirb??t&ei&hc?r??sa??v??l&a!c??b?c?o&m?rit&-&d&eus&-&nitnert?onitnert??nitnert?onitnert??us&-&nitnert?onitnert??nitnert?onitnert??üs&-&nitnert?onitnert??nitnert?onitnert???s&-onitnert?onitnert???d&eus!-&n&asl&ab?ub??ezob?itnert??onitnert??nitnert?onitnert??us&-&n&asl&ab?ub??ezob?itnert??onitnert??nitnert?onitnert??üs!-&n&asl&ab?ub??ezob?itnert??onitnert??nitnert?onitnert???s&-onitnert?onitnert?????m&ac?f?i?ol?r??n&a!lim?sl&ab?ub???b?c?e!v?zob??irut?m!p??p?r?t??o&a!v??b!retiv??c!cel??enuc?g!ivor??i&dem&-onadipmac?onadipmac??pmet&-aiblo?aiblo??rdnos?zal??l?m!a&greb?ret??oc?re&f?lap???n!a&dipmac&-oidem?oidem??lim?tsiro?zlob??ecip&-ilocsa?ilocsa??i&bru&-orasep?orasep??lleva?rot?tnert??r&elas?ovil??ulleb??p?r!a&sep&-onibru?onibru??znatac??oun??s!ivert?sabopmac??t!arp?e&nev?ssorg??n&arat?e&girga?rt?veneb????zz&era?urba???p&a?s?t??qa?r&a!m?s??b!a??c?f?g?k?me?o?p?s?t?v??s&a&b?iselgi&-ainobrac?ainobrac???b?c?elpan?i?m?ot?s?t?v??t&a?b?c?l?m?nomdeip?o!psgolb,?p?v??u&de?l?n?p??v&a?og?p?s?t?v??y&drabmol?ellav&-atsoa?atsoa??licis?nacsut??z&al?b?c?p??ìlrof&-anesec?anesec???derc?er?f!.sulptp,?m!r??utni??je3a3abgm--nx?kh?l!.&myn,topsgolb,vog??uda??m!.&gro?moc!.topsgolb,?ten?ude???n&a&morockivdnas?ruatser?tnuocca??e&g?m&eganam!.retuor,?piuqe??r??i!.ue?m?opdlog??opud?uocsid??o&b?cs!.vog,?d?g?h?j?oferab?p&edemoh?s???p!.&emon?gro?lbup?m&oc?yn,?t&en?ni?opsgolb,?ude?vog???r&a!m&law?s???epxe?op&er?pus!.ysrab,?s???s!.&adaxiabme?e&motoas?picnirp?rots??gro?lim?mo&c?n,?o&c?dalusnoc?hon,?ten?ude?vog??a&cmoc?f??e&b?padub?r?uq??i!rolf?tned??o&h!.&duolc&p,rim,?e&lej,tiseerf,?flah,s&pvtsaf,seccaduolc,?tsafym,??p!sua???urt??t!.&eman?gro?ibom?levart?m&oc?uesum??o&c?fni?r&ea?p???pooc?sboj?t&en?ni??ude?vog?zib??ayh?n?o!bba?irram???uognah?xen?y?ztej??u&2&5te9--nx?yssp--nx??a!.&a&s?w??civ?d&i?lq??fnoc?gro?moc!.topsgolb,?nsa?ofni?sat?t&ca?en?n??ude!.&a&s?w??ci&lohtac?v??dlq?sat?t&ca?n??wsn!.sloohcs????vog!.&a&s?w??civ?dlq?sat???wsn?zo??ti??c!.&fni?gro?moc?ten?ude?vog??i??d&e!.tir.segap-tig,?iab??e!.&dcym,enozgniebllew,noitatsksid,odagod.citsalej,snd&ps,uolc,?ysrab,??g!.&bew?gro?m&aug?oc??ofni?ten?ude?vog???h!.&0002?a&citore?idem?kitore??edszot?gro?ilus?letoh?m&alker?lif?t?urof??naltagni?o&c?ediv?fni?levynok?nisac??pohs?rarga?s&a&kal?zatu??emag?wen??t&lob?opsgolb,rops??virp?xe&s?zs??ytic?zsagoj??os?sut??l!.&myn,topsgolb,??m!.&ca?gro?moc?oc?ro?ten?vog???n!.&duolcesirpretne,eni&esrem,m,?mon,tenkcahs,uwu,?em!.ysrab,??o&ggnaw?y!c???r!.&a&i&kymlak,rikhsab,vodrom,?yegyda,?bps,ca,eniram,g&bc,nitsohurger.citsalej,ro,?ianatsuk,k&ihclan,s&m,rogitayp,??li&amdlc.bh,m,?moc,natsegad,onijym,pp,ri&b,dcm:.spv,,midalv,?s&ar,itym,?t&en,ni,opsgolb,set,?u&4an,de,?vo&g,n,?ynzorg,zakvakidalv,?myc?p?ug??s!.&a&d&golov,nagarak,?gulak,i&groeg,kymlak,lerak,nemra,rikhsab,ssakahk,vodrom,zahkba,?lut,rahkub,vut,yegyda,znep,?bps,da&baghsa,rgonilest,?gunel,i&anatsuk,hcos,ovan,ttailgot,?k&alhsygnam,ihclan,s&legnahkra,m,n&a&mrum,yrb,?i&buytka,nbo,??tiort,vorkop,??l&ocarak,ybmaj,?myn,na&gruk,jiabreza,ts&egad,hkazak-&htron,tsae,???ovonavi,r&adonsark,imidalv,?t&enxe,nek&hsat,mihc,??vo&hsalab,n,?ynzorg,z&akvakidalv,emret,??t&amok?i&juf?masih????v!.&em,g&olb,ro??moc?nc,ten?ude?ved,??ykuyr??v&b?c!.topsgolb,?ed!.&enilnigol,lecrev,ppa-rettalp,srekrow,vr&esi,uc,?ylf,??ih?l!.&di?fnoc?gro?lim?mo&c?n,?nsa?ten?ude?vog???m!.&eman?gro?lim?m&oc?uesum??o&fni?r&ea?p???pooc?t&en?ni??ude?vog?zib???o&g?m??rt?s!.&bog?der?gro?moc?ude???t!.&bew-eht-no,naht-&esrow,retteb,?sndnyd,?d?gh?i?won??uqhv--nx??w&a!.moc?hs?l??b!.&gro?oc???c!.&gro?moc?ten?ude??cp??e&iver!.oby,?n?s??g?k!.&bme?dni?gro?moc?ten?ude?vog???m!.&ca?gro?m&oc?uesum??oc?pooc?t&en?ni??ude?vog?zib??b??o&csom?h!s??n?w??p!.&344x,de?en?mon,o&c?g??ro?snduolc,ualeb???r!.&ca?gro?lim?oc?pooc?ten?vog??n??t!.&a46oa0fz--nx?b&82wrzc--nx?ulc??emag?gro?l&im?ru,?m&oc!.reliamym,?yn,?t&en?opsgolb,?ude?v&di?og?ta0cu--nx??zibe?業商?織組?路網???z!.&ca?gro?lim?oc?vog????x&a!.&cm,eb,gg,s&e,u,?tac,ue,yx,?t??c!.&hta,ofni,vog???e&d&ef?nay??ma!nab??rof?s??ilften?jt?m!.&bog?gro?m&oc?yn,?t&en?opsgolb,?ude??g?ma2ibgy--nx??o&b!x??f?rex!ijuf???rbgn--nx?s!.&myn,vog???x&am&jt?kt??x???y&4punu--nx?7rr03--nx?a&d!i&loh?rfkcalb??ot??g?lp?p!ila??rot?ssin?wdaorb??b!.&fo?lim?m&oc!.topsgolb,?yn,?vog??ab?gur??c!.&ca?dtl?eman?gro?m&oc!.&ecrofelacs.j,topsgolb,??t??orp?s&egolke?serp??t&en?nemailrap??vog?zib??amrahp?nega??d&dadog?uts??e&kcoh?ltneb?n&dys?om?rotta??snikcm??g!.&eb,gro?m&oc?yn,?oc?ten?ude?vog??olonhcet!.oc,?rene??hpargotohp?id?k!.&gro?moc?ten?ude?vog??s??l!.&clp?d&em?i??gro?hcs?moc?ten?ude?vog??f?imaf!nacirema??l&a?il??ppus??m!.&eman?gro?lim?moc?t&en?opsgolb,?ude?vog??edaca!.laiciffo,?ra??n&a&ffit?pmoc!ylimafa???os??o&j?s??p!.&gro?lim?moc?pooc?ten?ude?vog???r&e&corg?grus?llag?viled??lewej?otcerid?tnuoc?uxul??s!.&gro?lim?moc?ten?ude?vog??pil??t&efas?i&c!.gn,?ledif?n&ifx?ummoc!.&bdnevar,murofym,???r&ahc?uces??srevinu??laer?r&ap!.oby,?eporp??uaeb??u!.&bug?gro?lim?mo&c!.topsgolb,?n,?ten?ude??b!tseb???van!dlo??xes??z&a!.&eman?gro?lim?moc?o&fni?rp??pp?t&en?ni??ude?vog?zib???b!.&az,gro?m&o&c?n,?yn,?ten?ude?vog???c!.&4e,inum.duolc.&rsu,tlf,?m&laer,urtnecatem.motsuc,?oc,topsgolb,??d!.&gro?lop?moc?ossa?t&en?ra??ude?vog???ib!.&duolcsd,e&ht-rof,mos-rof,rom-rof,?izoj,lpb,nafamm,p&i&-on,fles,?ohbew,tfym,?retteb-rof,snd&nyd,uolc,?xro,?g??k!.&gro?lim?m&oc?yn,?ten?ude?vog???m!.&ca?gro?lim?oc?ten?ude?v&da?og????n!.&asq-irom--nx?ca?gro?htlaeh?i&r&c?o&am?ām???wi!k???keeg?l&im?oohcs??myn,neg?oc!.topsgolb,?t&en?nemailrap?vog???a!niflla???rawhcs?s!.&ca?gro?oc???t!.&c&a?s??e&m?n??ibom?l&etoh?im??o&c?fni?g??ro?vt???u!.&gro?moc?oc?ten??rwon??yx!.&etisgolb,gnitfarc,otpaz,ppahf,??zub??λε?υε?авксом?брс!.&гро?до?ка?р&бо?п!у?????г&б?ро??дкм?зақ?итед?килотак?леб?мок?н&йално?ом??рку?сур?тйас?фр?юе?յահ?םוק?اي&روس?سيلم?ناتيروم??بر&ع?غملا??ة&كبش?ي&دوعسلا?روس??یدوعسلا??ت&ا&راما?لاصتا??را&ب?ڀ?ھب???ر&ئازجلا?ازاب?صم?طق??سنوت?عقوم?قارع?ك&تيب?يلوثاك??موك?ن&ا&تس&كاپ?کاپ??دوس?ر&يا?یا??مع?يلعلا??درالا?ميلا?ي&رحبلا?طسلف???ه&ارمه?يدوعسلا??وكمارا?يبظوبا?ۃیدوعسلا?टेन?त&राभ?ोराभ??नठगंस?मॉक?्मतराभ?ত&রাভ?ৰাভ??ালংাব?ਤਰਾਭ?તરાભ?ତରାଭ?ாயித்நஇ?ைக்ஙலஇ?்ரூப்பக்ஙிச?్తరాభ?ತರಾಭ?ംതരാഭ?ාකංල?มอค?ยทไ!.&จิกรุธ?ต็นเ?ร&ก์คงอ?าหท??ลาบฐัร?าษกึศ???ວາລ?ეგ?なんみ?アトス?トンイポ?ドウラク?ムコ?ル&グーグ?ーセ??ン&ゾマア?ョシッァフ??业企?东广?乐娱?亚基诺?你爱我?信中?务政?动移?博微?卦八?厅餐?司公?品食?善慈?团集?国中?國中?址网?坡加新?城商?尚时?山佛?店&商?网?酒大里嘉??府政?康健?息信?戏游?拉里格香?拿大?教主天?机手?构机!织组??标商?歌谷?浦利飞?港香!.&人個?司公?府政?絡網?織組?育教???湾台?灣&台?臺??物购?界世?益公?看点?科盈訊電?站网?籍書?线在?络网?网文中?聘招?販通?车汽众大?逊马亚?通联?里嘉?锡马淡?門澳?门澳?闻新?電家?국한?넷닷?성삼?컴닷??");
/**
* If a hostname is not a key in the EXCLUDE map, and if removing its leftmost component results
@@ -50,7 +50,7 @@
*/
public static final ImmutableMap<String, PublicSuffixType> UNDER =
TrieParser.parseTrie(
- "ac.vedwa,d&b?uolc.&etiso&isnes,tnegam,?iaznab,rehcnar-no,scitats,??e&b.lrusnart,d.&ecapsrebu,yksurf,?noz.notirt,t&atse.etupmoc,is.&hsmroftalp,tst,???gp?h&c.tenerif:.cvs,,k?trae.sppad:.zzb,,?k&c?f?nil.bewd,rowten.secla,u.hcs??ln.lrusnart,m&j?m?oc.&duolcmeaeboda.ved,edonil.recnalabedon,ico-remotsuc:.&ico,pco,sco,?,lrihwyap,mme0,osseccandcved,s&t&cejboedonil,nemelepiuq,?wanozama.&1-etupmoc,ble,etupmoc,??t&neyoj.snc,opsppa.r,???n&c.moc.swanozama.&ble,etupmoc,?ur.edoc,?o&c.pato,i.&duolciaznab.sdraykcab,elacsnoom,oir-no,reniatnoceruza,s&3k-no,olots,?xcq.sys,y5s,??p&j.&a&mahokoy?yogan??ebok?i&adnes?kasawak??oroppas?uhsuykatik??n?pa.&knalfhtron,repoleved,??r&b.mon?e??s&edoc.owo,w.rosivda,?t&a.&ofnistro.&nednuk,xe,?smcerutuf:.&ni,xe,?,?en.&cimonotpyrc,hvo.&gnitsoh,saapbew,???u&e.lrusnart,r.onijym.&gni&dnal,tsoh,?murtceps,spv,??ved.&e&gats>s,lcl,?rahbew,?gts,lcl,yawetag,?z&c.murtnecatem.duolc,yx.tibelet,??");
+ "ac.vedwa,d&b?uolc.&etiso&isnes,tnegam,?iaznab,rehcnar-no,scitats,??e&b.lrusnart,d.ecapsrebu,noz.notirt,t&atse.etupmoc,is.hsmroftalp,?y??gp?h&c.tenerif:.cvs,,k?trae.sppad:.zzb,,?k&c?f?nil.bewd,rowten.secla,u.hcs??ln.lrusnart,m&j?m?oc.&aimhtirogla,duolcmeaeboda.ved,edonil.recnalabedon,ico-remotsuc:.&ico,pco,sco,?,mme0,s&t&cejboedonil,nemelepiuq,?wanozama.&1-etupmoc,ble,etupmoc,??t&neyoj.snc,opsppa.r,???nc.moc.swanozama.&ble,etupmoc,?o&c.pato,i.&duolciaznab.sdraykcab,elacsnoom,oir-no,reniatnoceruza,s&3k-no,olots,?xcq.sys,y5s,??p&j.&a&mahokoy?yogan??ebok?i&adnes?kasawak??oroppas?uhsuykatik??n??r&b.mon?e??s&edoc.owo,w.rosivda,?t&a.&ofnistro.&nednuk,xe,?smcerutuf:.&ni,xe,?,?en.cimonotpyrc,?u&e.lrusnart,r.onijym.&gni&dnal,tsoh,?murtceps,spv,??ved.&erahbew,gts,lcl,?z&c.murtnecatem.duolc,yx.tibelet,??");
/**
* The elements in this map would pass the UNDER test, but are known not to be public suffixes and
@@ -59,5 +59,5 @@
*/
public static final ImmutableMap<String, PublicSuffixType> EXCLUDED =
TrieParser.parseTrie(
- "kc.www?pj.&a&mahokoy.ytic?yogan.ytic??ebok.ytic?i&adnes.ytic?kasawak.ytic??oroppas.ytic?uhsuykatik.ytic???");
+ "kc.www?moc.aimhtirogla.&smaet,tset,?pj.&a&mahokoy.ytic?yogan.ytic??ebok.ytic?i&adnes.ytic?kasawak.ytic??oroppas.ytic?uhsuykatik.ytic???");
}
diff --git a/android/guava/src/com/google/thirdparty/publicsuffix/PublicSuffixType.java b/android/guava/src/com/google/thirdparty/publicsuffix/PublicSuffixType.java
old mode 100644
new mode 100755
index be1d07f..f0c5292
--- a/android/guava/src/com/google/thirdparty/publicsuffix/PublicSuffixType.java
+++ b/android/guava/src/com/google/thirdparty/publicsuffix/PublicSuffixType.java
@@ -62,4 +62,8 @@
}
throw new IllegalArgumentException("No enum corresponding to given code: " + code);
}
+
+ static PublicSuffixType fromIsPrivate(boolean isPrivate) {
+ return isPrivate ? PRIVATE : REGISTRY;
+ }
}
diff --git a/android/guava/src/com/google/thirdparty/publicsuffix/TrieParser.java b/android/guava/src/com/google/thirdparty/publicsuffix/TrieParser.java
old mode 100644
new mode 100755
index dd77780..9c387eb
--- a/android/guava/src/com/google/thirdparty/publicsuffix/TrieParser.java
+++ b/android/guava/src/com/google/thirdparty/publicsuffix/TrieParser.java
@@ -17,8 +17,8 @@
import com.google.common.annotations.GwtCompatible;
import com.google.common.base.Joiner;
import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.Queues;
-import java.util.Deque;
+import com.google.common.collect.Lists;
+import java.util.List;
/** Parser for a map of reversed domain names stored as a serialized radix tree. */
@GwtCompatible
@@ -34,7 +34,7 @@
int encodedLen = encoded.length();
int idx = 0;
while (idx < encodedLen) {
- idx += doParseTrieToBuilder(Queues.<CharSequence>newArrayDeque(), encoded, idx, builder);
+ idx += doParseTrieToBuilder(Lists.<CharSequence>newLinkedList(), encoded, idx, builder);
}
return builder.build();
}
@@ -50,7 +50,7 @@
* @return The number of characters consumed from {@code encoded}.
*/
private static int doParseTrieToBuilder(
- Deque<CharSequence> stack,
+ List<CharSequence> stack,
CharSequence encoded,
int start,
ImmutableMap.Builder<String, PublicSuffixType> builder) {
@@ -67,7 +67,7 @@
}
}
- stack.push(reverse(encoded.subSequence(start, idx)));
+ stack.add(0, reverse(encoded.subSequence(start, idx)));
if (c == '!' || c == '?' || c == ':' || c == ',') {
// '!' represents an interior node that represents a REGISTRY entry in the map.
@@ -92,7 +92,7 @@
}
}
}
- stack.pop();
+ stack.remove(0);
return idx - start;
}
diff --git a/android/pom.xml b/android/pom.xml
index 3620bb3..748d104 100644
--- a/android/pom.xml
+++ b/android/pom.xml
@@ -6,7 +6,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.google.guava</groupId>
<artifactId>guava-parent</artifactId>
- <version>31.0.1-android</version>
+ <version>30.0-android</version>
<packaging>pom</packaging>
<name>Guava Maven Parent</name>
<description>Parent for guava artifacts</description>
@@ -14,11 +14,10 @@
<properties>
<!-- Override this with -Dtest.include="**/SomeTest.java" on the CLI -->
<test.include>%regex[.*.class]</test.include>
- <truth.version>1.1.2</truth.version>
- <checker-framework.version>3.12.0</checker-framework.version>
- <animal.sniffer.version>1.20</animal.sniffer.version>
+ <truth.version>1.0</truth.version>
+ <animal.sniffer.version>1.18</animal.sniffer.version>
<maven-javadoc-plugin.version>3.1.0</maven-javadoc-plugin.version>
- <maven-source-plugin.version>3.2.1</maven-source-plugin.version>
+ <maven-source-plugin.version>3.2.0</maven-source-plugin.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<issueManagement>
@@ -53,8 +52,8 @@
</developer>
</developers>
<ciManagement>
- <system>GitHub Actions</system>
- <url>https://github.com/google/guava/actions</url>
+ <system>Travis CI</system>
+ <url>https://travis-ci.org/google/guava</url>
</ciManagement>
<modules>
<module>guava</module>
@@ -117,18 +116,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
- <source>1.8</source>
- <target>1.8</target>
- <compilerArgs>
- <!--
- Make includes/excludes fully work:
- https://issues.apache.org/jira/browse/MCOMPILER-174
-
- (Compare what guava-gwt has to do for maven-javadoc-plugin.)
- -->
- <arg>-sourcepath</arg>
- <arg>doesnotexist</arg>
- </compilerArgs>
+ <source>1.7</source>
+ <target>1.7</target>
</configuration>
</plugin>
<plugin>
@@ -151,7 +140,7 @@
<artifactId>animal-sniffer-maven-plugin</artifactId>
<version>${animal.sniffer.version}</version>
<configuration>
- <checkTestClasses>true</checkTestClasses>
+ <annotations>com.google.common.util.concurrent.IgnoreJRERequirement</annotations>
<signature>
<groupId>org.codehaus.mojo.signature</groupId>
<artifactId>java16-sun</artifactId>
@@ -231,7 +220,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
- <version>3.0.0-M3</version>
+ <version>3.0.0-M2</version>
</plugin>
</plugins>
</pluginManagement>
@@ -262,25 +251,13 @@
</dependency>
<dependency>
<groupId>org.checkerframework</groupId>
- <artifactId>checker-qual</artifactId>
- <version>${checker-framework.version}</version>
- </dependency>
- <dependency>
- <groupId>org.checkerframework</groupId>
- <artifactId>checker-qual</artifactId>
- <version>${checker-framework.version}</version>
- <classifier>sources</classifier>
- </dependency>
- <!-- TODO(cpovirk): Remove checker-compat-qual after we finish migrating to type annotations. -->
- <dependency>
- <groupId>org.checkerframework</groupId>
<artifactId>checker-compat-qual</artifactId>
<version>2.5.5</version>
</dependency>
<dependency>
<groupId>com.google.errorprone</groupId>
<artifactId>error_prone_annotations</artifactId>
- <version>2.7.1</version>
+ <version>2.3.4</version>
</dependency>
<dependency>
<groupId>com.google.j2objc</groupId>
@@ -290,25 +267,25 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
- <version>4.13.2</version>
+ <version>4.13</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.easymock</groupId>
<artifactId>easymock</artifactId>
- <version>4.3</version>
+ <version>3.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
- <version>3.9.0</version>
+ <version>2.19.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.jimfs</groupId>
<artifactId>jimfs</artifactId>
- <version>1.2</version>
+ <version>1.1</version>
<scope>test</scope>
</dependency>
<dependency>
diff --git a/cycle_suppress_list.txt b/cycle_whitelist.txt
similarity index 98%
rename from cycle_suppress_list.txt
rename to cycle_whitelist.txt
index ec0abc7..96c9e1b 100644
--- a/cycle_suppress_list.txt
+++ b/cycle_whitelist.txt
@@ -1,4 +1,4 @@
-# TODO(user): Resolve cycles
+# TODO(user,user): Resolve cycles
NAMESPACE com.google.common.collect.testing
NAMESPACE com.google.common.collect.testing.google
diff --git a/futures/listenablefuture1/src/com/google/common/util/concurrent/ListenableFuture.java b/futures/listenablefuture1/src/com/google/common/util/concurrent/ListenableFuture.java
index cf0199a..98e31ed 100644
--- a/futures/listenablefuture1/src/com/google/common/util/concurrent/ListenableFuture.java
+++ b/futures/listenablefuture1/src/com/google/common/util/concurrent/ListenableFuture.java
@@ -18,7 +18,6 @@
import java.util.concurrent.Executor;
import java.util.concurrent.Future;
import java.util.concurrent.RejectedExecutionException;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* A {@link Future} that accepts completion listeners. Each listener has an associated executor, and
@@ -100,32 +99,8 @@
* @author Nishant Thakkar
* @since 1.0
*/
-/*
- * Some of the annotations below were added after we released our separate
- * com.google.guava:listenablefuture:1.0 artifact. (For more on that artifact, see
- * https://github.com/google/guava/releases/tag/v27.0) This means that the copy of ListenableFuture
- * in com.google.guava:guava differs from the "frozen" copy in the listenablefuture artifact. This
- * could in principle cause problems for some users. Still, we expect that the benefits of the
- * nullness annotations in particular will outweigh the costs. (And it's worth noting that we have
- * released multiple ListenableFuture.class files that are not byte-for-byte compatible even from
- * the beginning, thanks to using different `-source -target` values for compiling our `-jre` and
- * `-android` "flavors.")
- *
- * (We could consider releasing a listenablefuture:1.0.1 someday. But we would want to look into how
- * that affects users, especially users of the Android Gradle Plugin, since the plugin developers
- * put in a special hack for us: https://issuetracker.google.com/issues/131431257)
- */
@DoNotMock("Use the methods in Futures (like immediateFuture) or SettableFuture")
-/*
- * It would make sense to also annotate this class with @ElementTypesAreNonnullByDefault. However,
- * it makes no difference because this class is already covered by the package-level
- * @ParametersAreNonnullByDefault, and this class declares only parameters, not return types or
- * fields. (Not to mention that we'll be removing all @*AreNonnullByDefault annotations after tools
- * understand .) And it's fortunate that the annotation makes no difference, because
- * we're seeing a breakage internally when we add that annotation :)
- *
- */
-public interface ListenableFuture<V extends @Nullable Object> extends Future<V> {
+public interface ListenableFuture<V> extends Future<V> {
/**
* Registers a listener to be {@linkplain Executor#execute(Runnable) run} on the given executor.
* The listener will run when the {@code Future}'s computation is {@linkplain Future#isDone()
diff --git a/guava-bom/pom.xml b/guava-bom/pom.xml
index 58c001e..1df9577 100644
--- a/guava-bom/pom.xml
+++ b/guava-bom/pom.xml
@@ -8,14 +8,13 @@
<groupId>com.google.guava</groupId>
<artifactId>guava-bom</artifactId>
- <version>31.0.1-jre</version>
+ <version>30.0-jre</version>
<packaging>pom</packaging>
<parent>
<groupId>org.sonatype.oss</groupId>
<artifactId>oss-parent</artifactId>
<version>9</version>
- <relativePath></relativePath>
</parent>
<name>Guava BOM</name>
diff --git a/guava-gwt/pom.xml b/guava-gwt/pom.xml
index 310cbdd..44db390 100644
--- a/guava-gwt/pom.xml
+++ b/guava-gwt/pom.xml
@@ -5,19 +5,19 @@
<parent>
<groupId>com.google.guava</groupId>
<artifactId>guava-parent</artifactId>
- <version>31.0.1-jre</version>
+ <version>30.0-jre</version>
</parent>
<artifactId>guava-gwt</artifactId>
<name>Guava GWT compatible libs</name>
<description>
Guava is a suite of core and expanded libraries that include
- utility classes, Google's collections, I/O classes, and
+ utility classes, google's collections, io classes, and much
much more.
This project includes GWT-friendly sources.
</description>
<properties>
- <gwt.version>2.9.0</gwt.version>
+ <gwt.version>2.8.2</gwt.version>
<gwt.plugin.version>2.8.2</gwt.plugin.version>
<gwt.logLevel>WARN</gwt.logLevel>
</properties>
@@ -55,7 +55,7 @@
<dependency>
<groupId>com.google.elemental2</groupId>
<artifactId>elemental2-promise</artifactId>
- <version>1.1.0</version>
+ <version>1.0.0-RC1</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
@@ -304,12 +304,6 @@
<contains text="@GwtCompatible"/>
</fileset>
</copy>
- <replace token="@Nullable" value="">
- <fileset dir="${project.build.directory}">
- <include name="guava-gwt-sources/**/*.java"/>
- <include name="guava-test-gwt-sources/**/*.java"/>
- </fileset>
- </replace>
</target>
</configuration>
</execution>
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 8530def..dba29ff 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
@@ -550,7 +550,7 @@
@Override
public Entry<K, V> next() {
if (nextEntry == null) {
- boolean unused = hasNext();
+ hasNext();
if (nextEntry == null) {
throw new NoSuchElementException();
diff --git a/guava-gwt/src-super/com/google/common/collect/super/com/google/common/collect/ImmutableBiMap.java b/guava-gwt/src-super/com/google/common/collect/super/com/google/common/collect/ImmutableBiMap.java
index ff98965..8236f00 100644
--- a/guava-gwt/src-super/com/google/common/collect/super/com/google/common/collect/ImmutableBiMap.java
+++ b/guava-gwt/src-super/com/google/common/collect/super/com/google/common/collect/ImmutableBiMap.java
@@ -65,93 +65,6 @@
return new RegularImmutableBiMap<K, V>(ImmutableMap.of(k1, v1, k2, v2, k3, v3, k4, v4, k5, v5));
}
- public static <K, V> ImmutableBiMap<K, V> of(
- K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6) {
- return new RegularImmutableBiMap<K, V>(
- ImmutableMap.of(k1, v1, k2, v2, k3, v3, k4, v4, k5, v5, k6, v6));
- }
-
- public static <K, V> ImmutableBiMap<K, V> of(
- K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6, K k7, V v7) {
- return new RegularImmutableBiMap<K, V>(
- ImmutableMap.of(k1, v1, k2, v2, k3, v3, k4, v4, k5, v5, k6, v6, k7, v7));
- }
-
- public static <K, V> ImmutableBiMap<K, V> of(
- K k1,
- V v1,
- K k2,
- V v2,
- K k3,
- V v3,
- K k4,
- V v4,
- K k5,
- V v5,
- K k6,
- V v6,
- K k7,
- V v7,
- K k8,
- V v8) {
- return new RegularImmutableBiMap<K, V>(
- ImmutableMap.of(k1, v1, k2, v2, k3, v3, k4, v4, k5, v5, k6, v6, k7, v7, k8, v8));
- }
-
- public static <K, V> ImmutableBiMap<K, V> of(
- K k1,
- V v1,
- K k2,
- V v2,
- K k3,
- V v3,
- K k4,
- V v4,
- K k5,
- V v5,
- K k6,
- V v6,
- K k7,
- V v7,
- K k8,
- V v8,
- K k9,
- V v9) {
- return new RegularImmutableBiMap<K, V>(
- ImmutableMap.of(k1, v1, k2, v2, k3, v3, k4, v4, k5, v5, k6, v6, k7, v7, k8, v8, k9, v9));
- }
-
- public static <K, V> ImmutableBiMap<K, V> of(
- K k1,
- V v1,
- K k2,
- V v2,
- K k3,
- V v3,
- K k4,
- V v4,
- K k5,
- V v5,
- K k6,
- V v6,
- K k7,
- V v7,
- K k8,
- V v8,
- K k9,
- V v9,
- K k10,
- V v10) {
- return new RegularImmutableBiMap<K, V>(
- ImmutableMap.of(
- k1, v1, k2, v2, k3, v3, k4, v4, k5, v5, k6, v6, k7, v7, k8, v8, k9, v9, k10, v10));
- }
-
- @SafeVarargs
- public static <K, V> ImmutableBiMap<K, V> ofEntries(Entry<? extends K, ? extends V>... entries) {
- return new RegularImmutableBiMap<K, V>(ImmutableMap.ofEntries(entries));
- }
-
public static <K, V> Builder<K, V> builder() {
return new Builder<K, V>();
}
@@ -200,16 +113,11 @@
@Override
public ImmutableBiMap<K, V> build() {
- return buildOrThrow();
- }
-
- @Override
- public ImmutableBiMap<K, V> buildOrThrow() {
- ImmutableMap<K, V> map = super.buildOrThrow();
+ ImmutableMap<K, V> map = super.build();
if (map.isEmpty()) {
return of();
}
- return new RegularImmutableBiMap<K, V>(super.buildOrThrow());
+ return new RegularImmutableBiMap<K, V>(super.build());
}
@Override
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 cef789a..550b7d1 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
@@ -117,128 +117,7 @@
entryOf(k1, v1), entryOf(k2, v2), entryOf(k3, v3), entryOf(k4, v4), entryOf(k5, v5));
}
- public static <K, V> ImmutableMap<K, V> of(
- K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6) {
- return new RegularImmutableMap<K, V>(
- entryOf(k1, v1),
- entryOf(k2, v2),
- entryOf(k3, v3),
- entryOf(k4, v4),
- entryOf(k5, v5),
- entryOf(k6, v6));
- }
-
- public static <K, V> ImmutableMap<K, V> of(
- K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6, K k7, V v7) {
- return new RegularImmutableMap<K, V>(
- entryOf(k1, v1),
- entryOf(k2, v2),
- entryOf(k3, v3),
- entryOf(k4, v4),
- entryOf(k5, v5),
- entryOf(k6, v6),
- entryOf(k7, v7));
- }
-
- public static <K, V> ImmutableMap<K, V> of(
- K k1,
- V v1,
- K k2,
- V v2,
- K k3,
- V v3,
- K k4,
- V v4,
- K k5,
- V v5,
- K k6,
- V v6,
- K k7,
- V v7,
- K k8,
- V v8) {
- return new RegularImmutableMap<K, V>(
- entryOf(k1, v1),
- entryOf(k2, v2),
- entryOf(k3, v3),
- entryOf(k4, v4),
- entryOf(k5, v5),
- entryOf(k6, v6),
- entryOf(k7, v7),
- entryOf(k8, v8));
- }
-
- public static <K, V> ImmutableMap<K, V> of(
- K k1,
- V v1,
- K k2,
- V v2,
- K k3,
- V v3,
- K k4,
- V v4,
- K k5,
- V v5,
- K k6,
- V v6,
- K k7,
- V v7,
- K k8,
- V v8,
- K k9,
- V v9) {
- return new RegularImmutableMap<K, V>(
- entryOf(k1, v1),
- entryOf(k2, v2),
- entryOf(k3, v3),
- entryOf(k4, v4),
- entryOf(k5, v5),
- entryOf(k6, v6),
- entryOf(k7, v7),
- entryOf(k8, v8),
- entryOf(k9, v9));
- }
-
- public static <K, V> ImmutableMap<K, V> of(
- K k1,
- V v1,
- K k2,
- V v2,
- K k3,
- V v3,
- K k4,
- V v4,
- K k5,
- V v5,
- K k6,
- V v6,
- K k7,
- V v7,
- K k8,
- V v8,
- K k9,
- V v9,
- K k10,
- V v10) {
- return new RegularImmutableMap<K, V>(
- entryOf(k1, v1),
- entryOf(k2, v2),
- entryOf(k3, v3),
- entryOf(k4, v4),
- entryOf(k5, v5),
- entryOf(k6, v6),
- entryOf(k7, v7),
- entryOf(k8, v8),
- entryOf(k9, v9),
- entryOf(k10, v10));
- }
-
- // looking for of() with > 10 entries? Use the builder instead.
-
- @SafeVarargs
- public static <K, V> ImmutableMap<K, V> ofEntries(Entry<? extends K, ? extends V>... entries) {
- return new RegularImmutableMap(entries);
- }
+ // looking for of() with > 5 entries? Use the builder instead.
public static <K, V> Builder<K, V> builder() {
return new Builder<K, V>();
@@ -307,10 +186,6 @@
}
public ImmutableMap<K, V> build() {
- return buildOrThrow();
- }
-
- public ImmutableMap<K, V> buildOrThrow() {
if (valueComparator != null) {
Collections.sort(
entries, Ordering.from(valueComparator).onResultOf(Maps.<V>valueFunction()));
diff --git a/guava-gwt/src-super/com/google/common/collect/super/com/google/common/collect/ImmutableSet.java b/guava-gwt/src-super/com/google/common/collect/super/com/google/common/collect/ImmutableSet.java
index d5a8dad..6d4b800 100644
--- a/guava-gwt/src-super/com/google/common/collect/super/com/google/common/collect/ImmutableSet.java
+++ b/guava-gwt/src-super/com/google/common/collect/super/com/google/common/collect/ImmutableSet.java
@@ -18,7 +18,6 @@
import static com.google.common.base.Preconditions.checkNotNull;
-import com.google.errorprone.annotations.concurrent.LazyInit;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@@ -175,24 +174,6 @@
@Override
public abstract UnmodifiableIterator<E> iterator();
- abstract static class CachingAsList<E> extends ImmutableSet<E> {
- @LazyInit private transient ImmutableList<E> asList;
-
- @Override
- public ImmutableList<E> asList() {
- ImmutableList<E> result = asList;
- if (result == null) {
- return asList = createAsList();
- } else {
- return result;
- }
- }
-
- ImmutableList<E> createAsList() {
- return new RegularImmutableAsList<E>(this, toArray());
- }
- }
-
abstract static class Indexed<E> extends ImmutableSet<E> {
abstract E get(int index);
diff --git a/guava-gwt/src-super/com/google/common/collect/super/com/google/common/collect/ImmutableSortedMap.java b/guava-gwt/src-super/com/google/common/collect/super/com/google/common/collect/ImmutableSortedMap.java
index fb626be..d255c35 100644
--- a/guava-gwt/src-super/com/google/common/collect/super/com/google/common/collect/ImmutableSortedMap.java
+++ b/guava-gwt/src-super/com/google/common/collect/super/com/google/common/collect/ImmutableSortedMap.java
@@ -129,127 +129,6 @@
.build();
}
- public static <K extends Comparable<? super K>, V> ImmutableSortedMap<K, V> of(
- K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6) {
- return new Builder<K, V>(Ordering.natural())
- .put(k1, v1)
- .put(k2, v2)
- .put(k3, v3)
- .put(k4, v4)
- .put(k5, v5)
- .put(k6, v6)
- .build();
- }
-
- public static <K extends Comparable<? super K>, V> ImmutableSortedMap<K, V> of(
- K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6, K k7, V v7) {
- return new Builder<K, V>(Ordering.natural())
- .put(k1, v1)
- .put(k2, v2)
- .put(k3, v3)
- .put(k4, v4)
- .put(k5, v5)
- .put(k6, v6)
- .put(k7, v7)
- .build();
- }
-
- public static <K extends Comparable<? super K>, V> ImmutableSortedMap<K, V> of(
- K k1,
- V v1,
- K k2,
- V v2,
- K k3,
- V v3,
- K k4,
- V v4,
- K k5,
- V v5,
- K k6,
- V v6,
- K k7,
- V v7,
- K k8,
- V v8) {
- return new Builder<K, V>(Ordering.natural())
- .put(k1, v1)
- .put(k2, v2)
- .put(k3, v3)
- .put(k4, v4)
- .put(k5, v5)
- .put(k6, v6)
- .put(k7, v7)
- .put(k8, v8)
- .build();
- }
-
- public static <K extends Comparable<? super K>, V> ImmutableSortedMap<K, V> of(
- K k1,
- V v1,
- K k2,
- V v2,
- K k3,
- V v3,
- K k4,
- V v4,
- K k5,
- V v5,
- K k6,
- V v6,
- K k7,
- V v7,
- K k8,
- V v8,
- K k9,
- V v9) {
- return new Builder<K, V>(Ordering.natural())
- .put(k1, v1)
- .put(k2, v2)
- .put(k3, v3)
- .put(k4, v4)
- .put(k5, v5)
- .put(k6, v6)
- .put(k7, v7)
- .put(k8, v8)
- .put(k9, v9)
- .build();
- }
-
- public static <K extends Comparable<? super K>, V> ImmutableSortedMap<K, V> of(
- K k1,
- V v1,
- K k2,
- V v2,
- K k3,
- V v3,
- K k4,
- V v4,
- K k5,
- V v5,
- K k6,
- V v6,
- K k7,
- V v7,
- K k8,
- V v8,
- K k9,
- V v9,
- K k10,
- V v10) {
- return new Builder<K, V>(Ordering.natural())
- .put(k1, v1)
- .put(k2, v2)
- .put(k3, v3)
- .put(k4, v4)
- .put(k5, v5)
- .put(k6, v6)
- .put(k7, v7)
- .put(k8, v8)
- .put(k9, v9)
- .put(k10, v10)
- .build();
- }
-
public static <K, V> ImmutableSortedMap<K, V> copyOf(Map<? extends K, ? extends V> map) {
return copyOfInternal((Map) map, (Ordering<K>) Ordering.natural());
}
@@ -379,11 +258,6 @@
@Override
public ImmutableSortedMap<K, V> build() {
- return buildOrThrow();
- }
-
- @Override
- public ImmutableSortedMap<K, V> buildOrThrow() {
SortedMap<K, V> delegate = newModifiableDelegate(comparator);
for (Entry<? extends K, ? extends V> entry : entries) {
putEntryWithChecks(delegate, entry);
diff --git a/guava-gwt/src-super/com/google/common/collect/super/com/google/common/collect/Platform.java b/guava-gwt/src-super/com/google/common/collect/super/com/google/common/collect/Platform.java
index 4b85849..bb9fc16 100644
--- a/guava-gwt/src-super/com/google/common/collect/super/com/google/common/collect/Platform.java
+++ b/guava-gwt/src-super/com/google/common/collect/super/com/google/common/collect/Platform.java
@@ -17,10 +17,8 @@
package com.google.common.collect;
import java.util.Arrays;
-import java.util.Collections;
import java.util.Map;
import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
import jsinterop.annotations.JsPackage;
import jsinterop.annotations.JsProperty;
import jsinterop.annotations.JsType;
@@ -45,14 +43,6 @@
return Sets.newHashSetWithExpectedSize(expectedSize);
}
- static <E> Set<E> newConcurrentHashSet() {
- // GWT's ConcurrentHashMap is a wrapper around HashMap, but it rejects null keys, which matches
- // the behaviour of the non-GWT implementation of newConcurrentHashSet().
- // On the other hand HashSet might be better for code size if apps aren't
- // already using Collections.newSetFromMap and ConcurrentHashMap.
- return Collections.newSetFromMap(new ConcurrentHashMap<E, Boolean>());
- }
-
static <E> Set<E> newLinkedHashSetWithExpectedSize(int expectedSize) {
return Sets.newLinkedHashSetWithExpectedSize(expectedSize);
}
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 0f22cac..900d5f7 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
@@ -36,7 +36,6 @@
import org.checkerframework.checker.nullness.qual.Nullable;
/** Emulation for AbstractFuture in GWT. */
-@SuppressWarnings("nullness") // TODO(b/147136275): Remove once our checker understands & and |.
public abstract class AbstractFuture<V> extends InternalFutureFailureAccess
implements ListenableFuture<V> {
diff --git a/guava-gwt/src-super/com/google/common/util/concurrent/super/com/google/common/util/concurrent/GwtFuturesCatchingSpecialization.java b/guava-gwt/src-super/com/google/common/util/concurrent/super/com/google/common/util/concurrent/GwtFuturesCatchingSpecialization.java
index 4ce990d..35cf502 100644
--- a/guava-gwt/src-super/com/google/common/util/concurrent/super/com/google/common/util/concurrent/GwtFuturesCatchingSpecialization.java
+++ b/guava-gwt/src-super/com/google/common/util/concurrent/super/com/google/common/util/concurrent/GwtFuturesCatchingSpecialization.java
@@ -14,6 +14,8 @@
package com.google.common.util.concurrent;
+import static com.google.common.util.concurrent.MoreExecutors.directExecutor;
+
import com.google.common.base.Function;
import java.util.concurrent.Executor;
@@ -29,6 +31,15 @@
* your own instanceof tests.
*/
+ /** @deprecated Use the overload that requires an executor. */
+ @Deprecated
+ public static <V> ListenableFuture<V> catching(
+ ListenableFuture<? extends V> input,
+ Class<Throwable> exceptionType,
+ Function<? super Throwable, ? extends V> fallback) {
+ return AbstractCatchingFuture.create(input, exceptionType, fallback, directExecutor());
+ }
+
public static <V> ListenableFuture<V> catching(
ListenableFuture<? extends V> input,
Class<Throwable> exceptionType,
@@ -37,6 +48,15 @@
return AbstractCatchingFuture.create(input, exceptionType, fallback, executor);
}
+ /** @deprecated Use the overload that requires an executor. */
+ @Deprecated
+ public static <V> ListenableFuture<V> catchingAsync(
+ ListenableFuture<? extends V> input,
+ Class<Throwable> exceptionType,
+ AsyncFunction<? super Throwable, ? extends V> fallback) {
+ return AbstractCatchingFuture.create(input, exceptionType, fallback, directExecutor());
+ }
+
public static <V> ListenableFuture<V> catchingAsync(
ListenableFuture<? extends V> input,
Class<Throwable> exceptionType,
diff --git a/guava-gwt/src-super/com/google/common/util/concurrent/super/com/google/common/util/concurrent/InterruptibleTask.java b/guava-gwt/src-super/com/google/common/util/concurrent/super/com/google/common/util/concurrent/InterruptibleTask.java
index 1cd9f3e..de2f062 100644
--- a/guava-gwt/src-super/com/google/common/util/concurrent/super/com/google/common/util/concurrent/InterruptibleTask.java
+++ b/guava-gwt/src-super/com/google/common/util/concurrent/super/com/google/common/util/concurrent/InterruptibleTask.java
@@ -16,14 +16,12 @@
package com.google.common.util.concurrent;
-import static com.google.common.util.concurrent.NullnessCasts.uncheckedCastNullableTToT;
-
/** Emulation for InterruptibleTask in GWT. */
-abstract class InterruptibleTask<T> implements Runnable {
+abstract class InterruptibleTask<V> implements Runnable {
@Override
public void run() {
- T result = null;
+ V result = null;
Throwable error = null;
if (isDone()) {
return;
@@ -33,21 +31,14 @@
} catch (Throwable t) {
error = t;
}
- if (error == null) {
- // The cast is safe because of the `run` and `error` checks.
- afterRanInterruptiblySuccess(uncheckedCastNullableTToT(result));
- } else {
- afterRanInterruptiblyFailure(error);
- }
+ afterRanInterruptibly(result, error);
}
abstract boolean isDone();
- abstract T runInterruptibly() throws Exception;
+ abstract V runInterruptibly() throws Exception;
- abstract void afterRanInterruptiblySuccess(T result);
-
- abstract void afterRanInterruptiblyFailure(Throwable error);
+ abstract void afterRanInterruptibly(V result, Throwable error);
final void interruptTask() {}
diff --git a/guava-gwt/src/com/google/common/annotations/Annotations.gwt.xml b/guava-gwt/src/com/google/common/annotations/Annotations.gwt.xml
index a281a1f..e284348 100644
--- a/guava-gwt/src/com/google/common/annotations/Annotations.gwt.xml
+++ b/guava-gwt/src/com/google/common/annotations/Annotations.gwt.xml
@@ -1,26 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
<module>
-<source path="">
- <!-- Hack to keep collect from hiding collect.testing supersource: -->
- <exclude name="**/testing/**"/>
-</source>
-
-<!--
- We used to set this only for packages that had manual supersource.
- That worked everywhere that I know of except for one place:
- when running the GWT util.concurrent tests under Guava.
- The problem is that GWT responds poorly to two .gwt.xml files in the same Java package:
- https://goo.gl/pRV3Yn
- The summary is that it ignores one file in favor of the other.
- util.concurrent, like nearly all our packages, has two .gwt.xml files: one for prod and one for tests.
- util.concurrent, unlike our other packages, has, as of this writing, test supersource but no prod supersource.
- GWT happens to use the prod .gwt.xml, so it looks for no supersource for tests, either.
- This causes it to fail to find AtomicLongMapTest.
- Our workaround is to tell GWT that util.concurrent and all other packages have prod supersource, even if they have none.
- GWT is happy to ignore us when we specify a nonexistent path.
- (I hope that this workaround does not cause its own problems in the future.)
--->
-<super-source path="super"/>
-
-<inherits name="com.google.gwt.core.Core" />
-<inherits name="com.google.gwt.user.User" />
+
+ <source path="">
+
+ <!-- Hack to keep collect from hiding collect.testing supersource: -->
+
+ <exclude name="**/testing/**"/>
+
+ </source>
+
+ <!-- We used to set this only for packages that had manual supersource. That worked everywhere that I know of except for one place: when running the GWT util.concurrent tests under Guava. The problem is that GWT responds poorly to two .gwt.xml files in the same Java package: https://goo.gl/pRV3Yn The summary is that it ignores one file in favor of the other. util.concurrent, like nearly all our packages, has two .gwt.xml files: one for prod and one for tests. util.concurrent, unlike our other packages, has, as of this writing, test supersource but no prod supersource. GWT happens to use the prod .gwt.xml, so it looks for no supersource for tests, either. This causes it to fail to find AtomicLongMapTest. Our workaround is to tell GWT that util.concurrent and all other packages have prod supersource, even if they have none. GWT is happy to ignore us when we specify a nonexistent path. (I hope that this workaround does not cause its own problems in the future.) -->
+
+ <super-source path="super"/>
+
+ <inherits name="com.google.gwt.user.User"/>
+
+ <inherits name="com.google.gwt.core.Core"/>
+
</module>
diff --git a/guava-gwt/src/com/google/common/base/Base.gwt.xml b/guava-gwt/src/com/google/common/base/Base.gwt.xml
index b8c0447..5ed0fb2 100644
--- a/guava-gwt/src/com/google/common/base/Base.gwt.xml
+++ b/guava-gwt/src/com/google/common/base/Base.gwt.xml
@@ -1,27 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
<module>
-<source path="">
- <!-- Hack to keep collect from hiding collect.testing supersource: -->
- <exclude name="**/testing/**"/>
-</source>
-
-<!--
- We used to set this only for packages that had manual supersource.
- That worked everywhere that I know of except for one place:
- when running the GWT util.concurrent tests under Guava.
- The problem is that GWT responds poorly to two .gwt.xml files in the same Java package:
- https://goo.gl/pRV3Yn
- The summary is that it ignores one file in favor of the other.
- util.concurrent, like nearly all our packages, has two .gwt.xml files: one for prod and one for tests.
- util.concurrent, unlike our other packages, has, as of this writing, test supersource but no prod supersource.
- GWT happens to use the prod .gwt.xml, so it looks for no supersource for tests, either.
- This causes it to fail to find AtomicLongMapTest.
- Our workaround is to tell GWT that util.concurrent and all other packages have prod supersource, even if they have none.
- GWT is happy to ignore us when we specify a nonexistent path.
- (I hope that this workaround does not cause its own problems in the future.)
--->
-<super-source path="super"/>
-
-<inherits name="com.google.common.annotations.Annotations" />
-<inherits name="com.google.gwt.core.Core" />
-<inherits name="com.google.gwt.user.User" />
+
+ <source path="">
+
+ <!-- Hack to keep collect from hiding collect.testing supersource: -->
+
+ <exclude name="**/testing/**"/>
+
+ </source>
+
+ <!-- We used to set this only for packages that had manual supersource. That worked everywhere that I know of except for one place: when running the GWT util.concurrent tests under Guava. The problem is that GWT responds poorly to two .gwt.xml files in the same Java package: https://goo.gl/pRV3Yn The summary is that it ignores one file in favor of the other. util.concurrent, like nearly all our packages, has two .gwt.xml files: one for prod and one for tests. util.concurrent, unlike our other packages, has, as of this writing, test supersource but no prod supersource. GWT happens to use the prod .gwt.xml, so it looks for no supersource for tests, either. This causes it to fail to find AtomicLongMapTest. Our workaround is to tell GWT that util.concurrent and all other packages have prod supersource, even if they have none. GWT is happy to ignore us when we specify a nonexistent path. (I hope that this workaround does not cause its own problems in the future.) -->
+
+ <super-source path="super"/>
+
+ <inherits name="com.google.gwt.user.User"/>
+
+ <inherits name="com.google.gwt.user.User"/>
+
+ <inherits name="com.google.common.annotations.Annotations"/>
+
+ <inherits name="com.google.gwt.core.Core"/>
+
</module>
diff --git a/guava-gwt/src/com/google/common/cache/Cache.gwt.xml b/guava-gwt/src/com/google/common/cache/Cache.gwt.xml
index fb58b997..615b95f 100644
--- a/guava-gwt/src/com/google/common/cache/Cache.gwt.xml
+++ b/guava-gwt/src/com/google/common/cache/Cache.gwt.xml
@@ -1,31 +1,30 @@
+<?xml version="1.0" encoding="utf-8"?>
<module>
-<source path="">
- <!-- Hack to keep collect from hiding collect.testing supersource: -->
- <exclude name="**/testing/**"/>
-</source>
-
-<!--
- We used to set this only for packages that had manual supersource.
- That worked everywhere that I know of except for one place:
- when running the GWT util.concurrent tests under Guava.
- The problem is that GWT responds poorly to two .gwt.xml files in the same Java package:
- https://goo.gl/pRV3Yn
- The summary is that it ignores one file in favor of the other.
- util.concurrent, like nearly all our packages, has two .gwt.xml files: one for prod and one for tests.
- util.concurrent, unlike our other packages, has, as of this writing, test supersource but no prod supersource.
- GWT happens to use the prod .gwt.xml, so it looks for no supersource for tests, either.
- This causes it to fail to find AtomicLongMapTest.
- Our workaround is to tell GWT that util.concurrent and all other packages have prod supersource, even if they have none.
- GWT is happy to ignore us when we specify a nonexistent path.
- (I hope that this workaround does not cause its own problems in the future.)
--->
-<super-source path="super"/>
-
-<inherits name="com.google.common.annotations.Annotations" />
-<inherits name="com.google.common.base.Base" />
-<inherits name="com.google.common.collect.Collect" />
-<inherits name="com.google.common.math.Math" />
-<inherits name="com.google.common.util.concurrent.Concurrent" />
-<inherits name="com.google.gwt.core.Core" />
-<inherits name="com.google.gwt.user.User" />
+
+ <source path="">
+
+ <!-- Hack to keep collect from hiding collect.testing supersource: -->
+
+ <exclude name="**/testing/**"/>
+
+ </source>
+
+ <!-- We used to set this only for packages that had manual supersource. That worked everywhere that I know of except for one place: when running the GWT util.concurrent tests under Guava. The problem is that GWT responds poorly to two .gwt.xml files in the same Java package: https://goo.gl/pRV3Yn The summary is that it ignores one file in favor of the other. util.concurrent, like nearly all our packages, has two .gwt.xml files: one for prod and one for tests. util.concurrent, unlike our other packages, has, as of this writing, test supersource but no prod supersource. GWT happens to use the prod .gwt.xml, so it looks for no supersource for tests, either. This causes it to fail to find AtomicLongMapTest. Our workaround is to tell GWT that util.concurrent and all other packages have prod supersource, even if they have none. GWT is happy to ignore us when we specify a nonexistent path. (I hope that this workaround does not cause its own problems in the future.) -->
+
+ <super-source path="super"/>
+
+ <inherits name="com.google.gwt.user.User"/>
+
+ <inherits name="com.google.common.annotations.Annotations"/>
+
+ <inherits name="com.google.common.base.Base"/>
+
+ <inherits name="com.google.common.collect.Collect"/>
+
+ <inherits name="com.google.common.math.Math"/>
+
+ <inherits name="com.google.common.util.concurrent.Concurrent"/>
+
+ <inherits name="com.google.gwt.core.Core"/>
+
</module>
diff --git a/guava-gwt/src/com/google/common/collect/Collect.gwt.xml b/guava-gwt/src/com/google/common/collect/Collect.gwt.xml
index cb2b654..765ac84 100644
--- a/guava-gwt/src/com/google/common/collect/Collect.gwt.xml
+++ b/guava-gwt/src/com/google/common/collect/Collect.gwt.xml
@@ -1,30 +1,30 @@
+<?xml version="1.0" encoding="utf-8"?>
<module>
-<source path="">
- <!-- Hack to keep collect from hiding collect.testing supersource: -->
- <exclude name="**/testing/**"/>
-</source>
-
-<!--
- We used to set this only for packages that had manual supersource.
- That worked everywhere that I know of except for one place:
- when running the GWT util.concurrent tests under Guava.
- The problem is that GWT responds poorly to two .gwt.xml files in the same Java package:
- https://goo.gl/pRV3Yn
- The summary is that it ignores one file in favor of the other.
- util.concurrent, like nearly all our packages, has two .gwt.xml files: one for prod and one for tests.
- util.concurrent, unlike our other packages, has, as of this writing, test supersource but no prod supersource.
- GWT happens to use the prod .gwt.xml, so it looks for no supersource for tests, either.
- This causes it to fail to find AtomicLongMapTest.
- Our workaround is to tell GWT that util.concurrent and all other packages have prod supersource, even if they have none.
- GWT is happy to ignore us when we specify a nonexistent path.
- (I hope that this workaround does not cause its own problems in the future.)
--->
-<super-source path="super"/>
-
-<inherits name="com.google.common.annotations.Annotations" />
-<inherits name="com.google.common.base.Base" />
-<inherits name="com.google.common.math.Math" />
-<inherits name="com.google.common.primitives.Primitives" />
-<inherits name="com.google.gwt.core.Core" />
-<inherits name="com.google.gwt.user.User" />
+
+ <source path="">
+
+ <!-- Hack to keep collect from hiding collect.testing supersource: -->
+
+ <exclude name="**/testing/**"/>
+
+ </source>
+
+ <!-- We used to set this only for packages that had manual supersource. That worked everywhere that I know of except for one place: when running the GWT util.concurrent tests under Guava. The problem is that GWT responds poorly to two .gwt.xml files in the same Java package: https://goo.gl/pRV3Yn The summary is that it ignores one file in favor of the other. util.concurrent, like nearly all our packages, has two .gwt.xml files: one for prod and one for tests. util.concurrent, unlike our other packages, has, as of this writing, test supersource but no prod supersource. GWT happens to use the prod .gwt.xml, so it looks for no supersource for tests, either. This causes it to fail to find AtomicLongMapTest. Our workaround is to tell GWT that util.concurrent and all other packages have prod supersource, even if they have none. GWT is happy to ignore us when we specify a nonexistent path. (I hope that this workaround does not cause its own problems in the future.) -->
+
+ <super-source path="super"/>
+
+ <inherits name="com.google.gwt.user.User"/>
+
+ <inherits name="com.google.gwt.user.User"/>
+
+ <inherits name="com.google.common.annotations.Annotations"/>
+
+ <inherits name="com.google.common.base.Base"/>
+
+ <inherits name="com.google.common.math.Math"/>
+
+ <inherits name="com.google.common.primitives.Primitives"/>
+
+ <inherits name="com.google.gwt.core.Core"/>
+
</module>
diff --git a/guava-gwt/src/com/google/common/escape/Escape.gwt.xml b/guava-gwt/src/com/google/common/escape/Escape.gwt.xml
index 5733706..d04c253 100644
--- a/guava-gwt/src/com/google/common/escape/Escape.gwt.xml
+++ b/guava-gwt/src/com/google/common/escape/Escape.gwt.xml
@@ -1,28 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
<module>
-<source path="">
- <!-- Hack to keep collect from hiding collect.testing supersource: -->
- <exclude name="**/testing/**"/>
-</source>
-
-<!--
- We used to set this only for packages that had manual supersource.
- That worked everywhere that I know of except for one place:
- when running the GWT util.concurrent tests under Guava.
- The problem is that GWT responds poorly to two .gwt.xml files in the same Java package:
- https://goo.gl/pRV3Yn
- The summary is that it ignores one file in favor of the other.
- util.concurrent, like nearly all our packages, has two .gwt.xml files: one for prod and one for tests.
- util.concurrent, unlike our other packages, has, as of this writing, test supersource but no prod supersource.
- GWT happens to use the prod .gwt.xml, so it looks for no supersource for tests, either.
- This causes it to fail to find AtomicLongMapTest.
- Our workaround is to tell GWT that util.concurrent and all other packages have prod supersource, even if they have none.
- GWT is happy to ignore us when we specify a nonexistent path.
- (I hope that this workaround does not cause its own problems in the future.)
--->
-<super-source path="super"/>
-
-<inherits name="com.google.common.annotations.Annotations" />
-<inherits name="com.google.common.base.Base" />
-<inherits name="com.google.gwt.core.Core" />
-<inherits name="com.google.gwt.user.User" />
+
+ <source path="">
+
+ <!-- Hack to keep collect from hiding collect.testing supersource: -->
+
+ <exclude name="**/testing/**"/>
+
+ </source>
+
+ <!-- We used to set this only for packages that had manual supersource. That worked everywhere that I know of except for one place: when running the GWT util.concurrent tests under Guava. The problem is that GWT responds poorly to two .gwt.xml files in the same Java package: https://goo.gl/pRV3Yn The summary is that it ignores one file in favor of the other. util.concurrent, like nearly all our packages, has two .gwt.xml files: one for prod and one for tests. util.concurrent, unlike our other packages, has, as of this writing, test supersource but no prod supersource. GWT happens to use the prod .gwt.xml, so it looks for no supersource for tests, either. This causes it to fail to find AtomicLongMapTest. Our workaround is to tell GWT that util.concurrent and all other packages have prod supersource, even if they have none. GWT is happy to ignore us when we specify a nonexistent path. (I hope that this workaround does not cause its own problems in the future.) -->
+
+ <super-source path="super"/>
+
+ <inherits name="com.google.gwt.user.User"/>
+
+ <inherits name="com.google.common.annotations.Annotations"/>
+
+ <inherits name="com.google.common.base.Base"/>
+
+ <inherits name="com.google.gwt.core.Core"/>
+
</module>
diff --git a/guava-gwt/src/com/google/common/html/Html.gwt.xml b/guava-gwt/src/com/google/common/html/Html.gwt.xml
index ca997f0..143da9b 100644
--- a/guava-gwt/src/com/google/common/html/Html.gwt.xml
+++ b/guava-gwt/src/com/google/common/html/Html.gwt.xml
@@ -1,28 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
<module>
-<source path="">
- <!-- Hack to keep collect from hiding collect.testing supersource: -->
- <exclude name="**/testing/**"/>
-</source>
-
-<!--
- We used to set this only for packages that had manual supersource.
- That worked everywhere that I know of except for one place:
- when running the GWT util.concurrent tests under Guava.
- The problem is that GWT responds poorly to two .gwt.xml files in the same Java package:
- https://goo.gl/pRV3Yn
- The summary is that it ignores one file in favor of the other.
- util.concurrent, like nearly all our packages, has two .gwt.xml files: one for prod and one for tests.
- util.concurrent, unlike our other packages, has, as of this writing, test supersource but no prod supersource.
- GWT happens to use the prod .gwt.xml, so it looks for no supersource for tests, either.
- This causes it to fail to find AtomicLongMapTest.
- Our workaround is to tell GWT that util.concurrent and all other packages have prod supersource, even if they have none.
- GWT is happy to ignore us when we specify a nonexistent path.
- (I hope that this workaround does not cause its own problems in the future.)
--->
-<super-source path="super"/>
-
-<inherits name="com.google.common.annotations.Annotations" />
-<inherits name="com.google.common.escape.Escape" />
-<inherits name="com.google.gwt.core.Core" />
-<inherits name="com.google.gwt.user.User" />
+
+ <source path="">
+
+ <!-- Hack to keep collect from hiding collect.testing supersource: -->
+
+ <exclude name="**/testing/**"/>
+
+ </source>
+
+ <!-- We used to set this only for packages that had manual supersource. That worked everywhere that I know of except for one place: when running the GWT util.concurrent tests under Guava. The problem is that GWT responds poorly to two .gwt.xml files in the same Java package: https://goo.gl/pRV3Yn The summary is that it ignores one file in favor of the other. util.concurrent, like nearly all our packages, has two .gwt.xml files: one for prod and one for tests. util.concurrent, unlike our other packages, has, as of this writing, test supersource but no prod supersource. GWT happens to use the prod .gwt.xml, so it looks for no supersource for tests, either. This causes it to fail to find AtomicLongMapTest. Our workaround is to tell GWT that util.concurrent and all other packages have prod supersource, even if they have none. GWT is happy to ignore us when we specify a nonexistent path. (I hope that this workaround does not cause its own problems in the future.) -->
+
+ <super-source path="super"/>
+
+ <inherits name="com.google.gwt.user.User"/>
+
+ <inherits name="com.google.common.annotations.Annotations"/>
+
+ <inherits name="com.google.common.escape.Escape"/>
+
+ <inherits name="com.google.gwt.core.Core"/>
+
</module>
diff --git a/guava-gwt/src/com/google/common/io/Io.gwt.xml b/guava-gwt/src/com/google/common/io/Io.gwt.xml
index cb2b654..7790655 100644
--- a/guava-gwt/src/com/google/common/io/Io.gwt.xml
+++ b/guava-gwt/src/com/google/common/io/Io.gwt.xml
@@ -1,30 +1,28 @@
+<?xml version="1.0" encoding="utf-8"?>
<module>
-<source path="">
- <!-- Hack to keep collect from hiding collect.testing supersource: -->
- <exclude name="**/testing/**"/>
-</source>
-
-<!--
- We used to set this only for packages that had manual supersource.
- That worked everywhere that I know of except for one place:
- when running the GWT util.concurrent tests under Guava.
- The problem is that GWT responds poorly to two .gwt.xml files in the same Java package:
- https://goo.gl/pRV3Yn
- The summary is that it ignores one file in favor of the other.
- util.concurrent, like nearly all our packages, has two .gwt.xml files: one for prod and one for tests.
- util.concurrent, unlike our other packages, has, as of this writing, test supersource but no prod supersource.
- GWT happens to use the prod .gwt.xml, so it looks for no supersource for tests, either.
- This causes it to fail to find AtomicLongMapTest.
- Our workaround is to tell GWT that util.concurrent and all other packages have prod supersource, even if they have none.
- GWT is happy to ignore us when we specify a nonexistent path.
- (I hope that this workaround does not cause its own problems in the future.)
--->
-<super-source path="super"/>
-
-<inherits name="com.google.common.annotations.Annotations" />
-<inherits name="com.google.common.base.Base" />
-<inherits name="com.google.common.math.Math" />
-<inherits name="com.google.common.primitives.Primitives" />
-<inherits name="com.google.gwt.core.Core" />
-<inherits name="com.google.gwt.user.User" />
+
+ <source path="">
+
+ <!-- Hack to keep collect from hiding collect.testing supersource: -->
+
+ <exclude name="**/testing/**"/>
+
+ </source>
+
+ <!-- We used to set this only for packages that had manual supersource. That worked everywhere that I know of except for one place: when running the GWT util.concurrent tests under Guava. The problem is that GWT responds poorly to two .gwt.xml files in the same Java package: https://goo.gl/pRV3Yn The summary is that it ignores one file in favor of the other. util.concurrent, like nearly all our packages, has two .gwt.xml files: one for prod and one for tests. util.concurrent, unlike our other packages, has, as of this writing, test supersource but no prod supersource. GWT happens to use the prod .gwt.xml, so it looks for no supersource for tests, either. This causes it to fail to find AtomicLongMapTest. Our workaround is to tell GWT that util.concurrent and all other packages have prod supersource, even if they have none. GWT is happy to ignore us when we specify a nonexistent path. (I hope that this workaround does not cause its own problems in the future.) -->
+
+ <super-source path="super"/>
+
+ <inherits name="com.google.gwt.user.User"/>
+
+ <inherits name="com.google.common.annotations.Annotations"/>
+
+ <inherits name="com.google.common.base.Base"/>
+
+ <inherits name="com.google.common.math.Math"/>
+
+ <inherits name="com.google.common.primitives.Primitives"/>
+
+ <inherits name="com.google.gwt.core.Core"/>
+
</module>
diff --git a/guava-gwt/src/com/google/common/math/Math.gwt.xml b/guava-gwt/src/com/google/common/math/Math.gwt.xml
index ff56f8e..f5f9879 100644
--- a/guava-gwt/src/com/google/common/math/Math.gwt.xml
+++ b/guava-gwt/src/com/google/common/math/Math.gwt.xml
@@ -1,29 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
<module>
-<source path="">
- <!-- Hack to keep collect from hiding collect.testing supersource: -->
- <exclude name="**/testing/**"/>
-</source>
-
-<!--
- We used to set this only for packages that had manual supersource.
- That worked everywhere that I know of except for one place:
- when running the GWT util.concurrent tests under Guava.
- The problem is that GWT responds poorly to two .gwt.xml files in the same Java package:
- https://goo.gl/pRV3Yn
- The summary is that it ignores one file in favor of the other.
- util.concurrent, like nearly all our packages, has two .gwt.xml files: one for prod and one for tests.
- util.concurrent, unlike our other packages, has, as of this writing, test supersource but no prod supersource.
- GWT happens to use the prod .gwt.xml, so it looks for no supersource for tests, either.
- This causes it to fail to find AtomicLongMapTest.
- Our workaround is to tell GWT that util.concurrent and all other packages have prod supersource, even if they have none.
- GWT is happy to ignore us when we specify a nonexistent path.
- (I hope that this workaround does not cause its own problems in the future.)
--->
-<super-source path="super"/>
-
-<inherits name="com.google.common.annotations.Annotations" />
-<inherits name="com.google.common.base.Base" />
-<inherits name="com.google.common.primitives.Primitives" />
-<inherits name="com.google.gwt.core.Core" />
-<inherits name="com.google.gwt.user.User" />
+
+ <source path="">
+
+ <!-- Hack to keep collect from hiding collect.testing supersource: -->
+
+ <exclude name="**/testing/**"/>
+
+ </source>
+
+ <!-- We used to set this only for packages that had manual supersource. That worked everywhere that I know of except for one place: when running the GWT util.concurrent tests under Guava. The problem is that GWT responds poorly to two .gwt.xml files in the same Java package: https://goo.gl/pRV3Yn The summary is that it ignores one file in favor of the other. util.concurrent, like nearly all our packages, has two .gwt.xml files: one for prod and one for tests. util.concurrent, unlike our other packages, has, as of this writing, test supersource but no prod supersource. GWT happens to use the prod .gwt.xml, so it looks for no supersource for tests, either. This causes it to fail to find AtomicLongMapTest. Our workaround is to tell GWT that util.concurrent and all other packages have prod supersource, even if they have none. GWT is happy to ignore us when we specify a nonexistent path. (I hope that this workaround does not cause its own problems in the future.) -->
+
+ <super-source path="super"/>
+
+ <inherits name="com.google.gwt.user.User"/>
+
+ <inherits name="com.google.common.annotations.Annotations"/>
+
+ <inherits name="com.google.common.base.Base"/>
+
+ <inherits name="com.google.common.primitives.Primitives"/>
+
+ <inherits name="com.google.gwt.core.Core"/>
+
</module>
diff --git a/guava-gwt/src/com/google/common/net/Net.gwt.xml b/guava-gwt/src/com/google/common/net/Net.gwt.xml
index 7024312..19a6cb6 100644
--- a/guava-gwt/src/com/google/common/net/Net.gwt.xml
+++ b/guava-gwt/src/com/google/common/net/Net.gwt.xml
@@ -1,32 +1,34 @@
+<?xml version="1.0" encoding="utf-8"?>
<module>
-<source path="">
- <!-- Hack to keep collect from hiding collect.testing supersource: -->
- <exclude name="**/testing/**"/>
-</source>
-
-<!--
- We used to set this only for packages that had manual supersource.
- That worked everywhere that I know of except for one place:
- when running the GWT util.concurrent tests under Guava.
- The problem is that GWT responds poorly to two .gwt.xml files in the same Java package:
- https://goo.gl/pRV3Yn
- The summary is that it ignores one file in favor of the other.
- util.concurrent, like nearly all our packages, has two .gwt.xml files: one for prod and one for tests.
- util.concurrent, unlike our other packages, has, as of this writing, test supersource but no prod supersource.
- GWT happens to use the prod .gwt.xml, so it looks for no supersource for tests, either.
- This causes it to fail to find AtomicLongMapTest.
- Our workaround is to tell GWT that util.concurrent and all other packages have prod supersource, even if they have none.
- GWT is happy to ignore us when we specify a nonexistent path.
- (I hope that this workaround does not cause its own problems in the future.)
--->
-<super-source path="super"/>
-
-<inherits name="com.google.common.annotations.Annotations" />
-<inherits name="com.google.common.base.Base" />
-<inherits name="com.google.common.collect.Collect" />
-<inherits name="com.google.common.escape.Escape" />
-<inherits name="com.google.gwt.core.Core" />
-<inherits name="com.google.gwt.user.User" />
-<inherits name="com.google.thirdparty.publicsuffix.PublicSuffixPatterns" />
-<inherits name="com.google.thirdparty.publicsuffix.PublicSuffixType" />
+
+ <source path="">
+
+ <!-- Hack to keep collect from hiding collect.testing supersource: -->
+
+ <exclude name="**/testing/**"/>
+
+ </source>
+
+ <!-- We used to set this only for packages that had manual supersource. That worked everywhere that I know of except for one place: when running the GWT util.concurrent tests under Guava. The problem is that GWT responds poorly to two .gwt.xml files in the same Java package: https://goo.gl/pRV3Yn The summary is that it ignores one file in favor of the other. util.concurrent, like nearly all our packages, has two .gwt.xml files: one for prod and one for tests. util.concurrent, unlike our other packages, has, as of this writing, test supersource but no prod supersource. GWT happens to use the prod .gwt.xml, so it looks for no supersource for tests, either. This causes it to fail to find AtomicLongMapTest. Our workaround is to tell GWT that util.concurrent and all other packages have prod supersource, even if they have none. GWT is happy to ignore us when we specify a nonexistent path. (I hope that this workaround does not cause its own problems in the future.) -->
+
+ <super-source path="super"/>
+
+ <inherits name="com.google.gwt.user.User"/>
+
+ <inherits name="com.google.gwt.user.User"/>
+
+ <inherits name="com.google.common.annotations.Annotations"/>
+
+ <inherits name="com.google.common.base.Base"/>
+
+ <inherits name="com.google.common.collect.Collect"/>
+
+ <inherits name="com.google.common.escape.Escape"/>
+
+ <inherits name="com.google.thirdparty.publicsuffix.PublicSuffixPatterns"/>
+
+ <inherits name="com.google.thirdparty.publicsuffix.PublicSuffixType"/>
+
+ <inherits name="com.google.gwt.core.Core"/>
+
</module>
diff --git a/guava-gwt/src/com/google/common/primitives/Primitives.gwt.xml b/guava-gwt/src/com/google/common/primitives/Primitives.gwt.xml
index 5733706..505f45c 100644
--- a/guava-gwt/src/com/google/common/primitives/Primitives.gwt.xml
+++ b/guava-gwt/src/com/google/common/primitives/Primitives.gwt.xml
@@ -1,28 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
<module>
-<source path="">
- <!-- Hack to keep collect from hiding collect.testing supersource: -->
- <exclude name="**/testing/**"/>
-</source>
-
-<!--
- We used to set this only for packages that had manual supersource.
- That worked everywhere that I know of except for one place:
- when running the GWT util.concurrent tests under Guava.
- The problem is that GWT responds poorly to two .gwt.xml files in the same Java package:
- https://goo.gl/pRV3Yn
- The summary is that it ignores one file in favor of the other.
- util.concurrent, like nearly all our packages, has two .gwt.xml files: one for prod and one for tests.
- util.concurrent, unlike our other packages, has, as of this writing, test supersource but no prod supersource.
- GWT happens to use the prod .gwt.xml, so it looks for no supersource for tests, either.
- This causes it to fail to find AtomicLongMapTest.
- Our workaround is to tell GWT that util.concurrent and all other packages have prod supersource, even if they have none.
- GWT is happy to ignore us when we specify a nonexistent path.
- (I hope that this workaround does not cause its own problems in the future.)
--->
-<super-source path="super"/>
-
-<inherits name="com.google.common.annotations.Annotations" />
-<inherits name="com.google.common.base.Base" />
-<inherits name="com.google.gwt.core.Core" />
-<inherits name="com.google.gwt.user.User" />
+
+ <source path="">
+
+ <!-- Hack to keep collect from hiding collect.testing supersource: -->
+
+ <exclude name="**/testing/**"/>
+
+ </source>
+
+ <!-- We used to set this only for packages that had manual supersource. That worked everywhere that I know of except for one place: when running the GWT util.concurrent tests under Guava. The problem is that GWT responds poorly to two .gwt.xml files in the same Java package: https://goo.gl/pRV3Yn The summary is that it ignores one file in favor of the other. util.concurrent, like nearly all our packages, has two .gwt.xml files: one for prod and one for tests. util.concurrent, unlike our other packages, has, as of this writing, test supersource but no prod supersource. GWT happens to use the prod .gwt.xml, so it looks for no supersource for tests, either. This causes it to fail to find AtomicLongMapTest. Our workaround is to tell GWT that util.concurrent and all other packages have prod supersource, even if they have none. GWT is happy to ignore us when we specify a nonexistent path. (I hope that this workaround does not cause its own problems in the future.) -->
+
+ <super-source path="super"/>
+
+ <inherits name="com.google.gwt.user.User"/>
+
+ <inherits name="com.google.gwt.user.User"/>
+
+ <inherits name="com.google.common.annotations.Annotations"/>
+
+ <inherits name="com.google.common.base.Base"/>
+
+ <inherits name="com.google.gwt.core.Core"/>
+
</module>
diff --git a/guava-gwt/src/com/google/common/util/concurrent/Concurrent.gwt.xml b/guava-gwt/src/com/google/common/util/concurrent/Concurrent.gwt.xml
index 92daff3..e80620d 100644
--- a/guava-gwt/src/com/google/common/util/concurrent/Concurrent.gwt.xml
+++ b/guava-gwt/src/com/google/common/util/concurrent/Concurrent.gwt.xml
@@ -1,30 +1,28 @@
+<?xml version="1.0" encoding="utf-8"?>
<module>
-<source path="">
- <!-- Hack to keep collect from hiding collect.testing supersource: -->
- <exclude name="**/testing/**"/>
-</source>
-
-<!--
- We used to set this only for packages that had manual supersource.
- That worked everywhere that I know of except for one place:
- when running the GWT util.concurrent tests under Guava.
- The problem is that GWT responds poorly to two .gwt.xml files in the same Java package:
- https://goo.gl/pRV3Yn
- The summary is that it ignores one file in favor of the other.
- util.concurrent, like nearly all our packages, has two .gwt.xml files: one for prod and one for tests.
- util.concurrent, unlike our other packages, has, as of this writing, test supersource but no prod supersource.
- GWT happens to use the prod .gwt.xml, so it looks for no supersource for tests, either.
- This causes it to fail to find AtomicLongMapTest.
- Our workaround is to tell GWT that util.concurrent and all other packages have prod supersource, even if they have none.
- GWT is happy to ignore us when we specify a nonexistent path.
- (I hope that this workaround does not cause its own problems in the future.)
--->
-<super-source path="super"/>
-
-<inherits name="com.google.common.annotations.Annotations" />
-<inherits name="com.google.common.base.Base" />
-<inherits name="com.google.common.collect.Collect" />
-<inherits name="com.google.gwt.core.Core" />
-<inherits name="com.google.gwt.user.User" />
-<inherits name="elemental2.promise.Promise" />
+
+ <source path="">
+
+ <!-- Hack to keep collect from hiding collect.testing supersource: -->
+
+ <exclude name="**/testing/**"/>
+
+ </source>
+
+ <!-- We used to set this only for packages that had manual supersource. That worked everywhere that I know of except for one place: when running the GWT util.concurrent tests under Guava. The problem is that GWT responds poorly to two .gwt.xml files in the same Java package: https://goo.gl/pRV3Yn The summary is that it ignores one file in favor of the other. util.concurrent, like nearly all our packages, has two .gwt.xml files: one for prod and one for tests. util.concurrent, unlike our other packages, has, as of this writing, test supersource but no prod supersource. GWT happens to use the prod .gwt.xml, so it looks for no supersource for tests, either. This causes it to fail to find AtomicLongMapTest. Our workaround is to tell GWT that util.concurrent and all other packages have prod supersource, even if they have none. GWT is happy to ignore us when we specify a nonexistent path. (I hope that this workaround does not cause its own problems in the future.) -->
+
+ <super-source path="super"/>
+
+ <inherits name="com.google.gwt.user.User"/>
+
+ <inherits name="com.google.common.annotations.Annotations"/>
+
+ <inherits name="com.google.common.base.Base"/>
+
+ <inherits name="com.google.common.collect.Collect"/>
+
+ <inherits name="elemental2.promise.Promise"/>
+
+ <inherits name="com.google.gwt.core.Core"/>
+
</module>
diff --git a/guava-gwt/src/com/google/common/xml/Xml.gwt.xml b/guava-gwt/src/com/google/common/xml/Xml.gwt.xml
index 8a9e3b8..d00c0ed 100644
--- a/guava-gwt/src/com/google/common/xml/Xml.gwt.xml
+++ b/guava-gwt/src/com/google/common/xml/Xml.gwt.xml
@@ -1,29 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
<module>
-<source path="">
- <!-- Hack to keep collect from hiding collect.testing supersource: -->
- <exclude name="**/testing/**"/>
-</source>
-
-<!--
- We used to set this only for packages that had manual supersource.
- That worked everywhere that I know of except for one place:
- when running the GWT util.concurrent tests under Guava.
- The problem is that GWT responds poorly to two .gwt.xml files in the same Java package:
- https://goo.gl/pRV3Yn
- The summary is that it ignores one file in favor of the other.
- util.concurrent, like nearly all our packages, has two .gwt.xml files: one for prod and one for tests.
- util.concurrent, unlike our other packages, has, as of this writing, test supersource but no prod supersource.
- GWT happens to use the prod .gwt.xml, so it looks for no supersource for tests, either.
- This causes it to fail to find AtomicLongMapTest.
- Our workaround is to tell GWT that util.concurrent and all other packages have prod supersource, even if they have none.
- GWT is happy to ignore us when we specify a nonexistent path.
- (I hope that this workaround does not cause its own problems in the future.)
--->
-<super-source path="super"/>
-
-<inherits name="com.google.common.annotations.Annotations" />
-<inherits name="com.google.common.base.Base" />
-<inherits name="com.google.common.escape.Escape" />
-<inherits name="com.google.gwt.core.Core" />
-<inherits name="com.google.gwt.user.User" />
+
+ <source path="">
+
+ <!-- Hack to keep collect from hiding collect.testing supersource: -->
+
+ <exclude name="**/testing/**"/>
+
+ </source>
+
+ <!-- We used to set this only for packages that had manual supersource. That worked everywhere that I know of except for one place: when running the GWT util.concurrent tests under Guava. The problem is that GWT responds poorly to two .gwt.xml files in the same Java package: https://goo.gl/pRV3Yn The summary is that it ignores one file in favor of the other. util.concurrent, like nearly all our packages, has two .gwt.xml files: one for prod and one for tests. util.concurrent, unlike our other packages, has, as of this writing, test supersource but no prod supersource. GWT happens to use the prod .gwt.xml, so it looks for no supersource for tests, either. This causes it to fail to find AtomicLongMapTest. Our workaround is to tell GWT that util.concurrent and all other packages have prod supersource, even if they have none. GWT is happy to ignore us when we specify a nonexistent path. (I hope that this workaround does not cause its own problems in the future.) -->
+
+ <super-source path="super"/>
+
+ <inherits name="com.google.gwt.user.User"/>
+
+ <inherits name="com.google.common.annotations.Annotations"/>
+
+ <inherits name="com.google.common.base.Base"/>
+
+ <inherits name="com.google.common.escape.Escape"/>
+
+ <inherits name="com.google.gwt.core.Core"/>
+
</module>
diff --git a/guava-gwt/src/com/google/thirdparty/publicsuffix/PublicSuffixPatterns.gwt.xml b/guava-gwt/src/com/google/thirdparty/publicsuffix/PublicSuffixPatterns.gwt.xml
index be70a5c..d5dd290 100644
--- a/guava-gwt/src/com/google/thirdparty/publicsuffix/PublicSuffixPatterns.gwt.xml
+++ b/guava-gwt/src/com/google/thirdparty/publicsuffix/PublicSuffixPatterns.gwt.xml
@@ -20,11 +20,11 @@
(I hope that this workaround does not cause its own problems in the future.)
-->
<super-source path="super"/>
+<inherits name="com.google.gwt.user.User" />
+<inherits name="com.google.thirdparty.publicsuffix.PublicSuffixType" />
<inherits name="com.google.common.annotations.Annotations" />
<inherits name="com.google.common.base.Base" />
<inherits name="com.google.common.collect.Collect" />
<inherits name="com.google.gwt.core.Core" />
-<inherits name="com.google.gwt.user.User" />
-<inherits name="com.google.thirdparty.publicsuffix.PublicSuffixType" />
</module>
diff --git a/guava-gwt/src/com/google/thirdparty/publicsuffix/PublicSuffixType.gwt.xml b/guava-gwt/src/com/google/thirdparty/publicsuffix/PublicSuffixType.gwt.xml
index b8c0447..ffbcaf1 100644
--- a/guava-gwt/src/com/google/thirdparty/publicsuffix/PublicSuffixType.gwt.xml
+++ b/guava-gwt/src/com/google/thirdparty/publicsuffix/PublicSuffixType.gwt.xml
@@ -20,8 +20,8 @@
(I hope that this workaround does not cause its own problems in the future.)
-->
<super-source path="super"/>
+<inherits name="com.google.gwt.user.User" />
<inherits name="com.google.common.annotations.Annotations" />
<inherits name="com.google.gwt.core.Core" />
-<inherits name="com.google.gwt.user.User" />
</module>
diff --git a/guava-gwt/test/com/google/common/GuavaTests.gwt.xml b/guava-gwt/test/com/google/common/GuavaTests.gwt.xml
new file mode 100644
index 0000000..40ba822
--- /dev/null
+++ b/guava-gwt/test/com/google/common/GuavaTests.gwt.xml
@@ -0,0 +1,25 @@
+<module>
+ <inherits name="com.google.common.collect.testing.Testing" />
+ <inherits name="com.google.common.collect.testing.google.Google" />
+ <inherits name="com.google.common.escape.testing.Testing" />
+ <inherits name="com.google.common.testing.Testing" />
+
+ <inherits name="com.google.common.base.testModule" />
+ <inherits name="com.google.common.cache.testModule" />
+ <inherits name="com.google.common.collect.testModule" />
+ <inherits name="com.google.common.collect.testing.testModule" />
+ <inherits name="com.google.common.escape.testModule" />
+ <inherits name="com.google.common.html.testModule" />
+ <inherits name="com.google.common.io.testModule" />
+ <inherits name="com.google.common.math.testModule" />
+ <inherits name="com.google.common.net.testModule" />
+ <inherits name="com.google.common.primitives.testModule" />
+ <inherits name="com.google.common.testing.testModule" />
+ <inherits name="com.google.common.util.concurrent.testModule" />
+ <inherits name="com.google.common.xml.testModule" />
+
+ <source path="">
+ <include name="GuavaTestsEntryPoint.java" />
+ </source>
+ <entry-point class="com.google.common.GuavaTestsEntryPoint" />
+</module>
diff --git a/guava-gwt/test/com/google/common/base/testModule.gwt.xml b/guava-gwt/test/com/google/common/base/testModule.gwt.xml
new file mode 100644
index 0000000..c87f3db
--- /dev/null
+++ b/guava-gwt/test/com/google/common/base/testModule.gwt.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<module>
+
+ <source path=""/>
+
+ <inherits name="com.google.gwt.user.User"/>
+
+ <inherits name="com.google.gwt.junit.JUnit"/>
+
+ <inherits name="com.google.common.annotations.Annotations"/>
+
+ <inherits name="com.google.common.base.Base"/>
+
+ <inherits name="com.google.common.collect.Collect"/>
+
+ <inherits name="com.google.common.testing.Testing"/>
+
+ <inherits name="com.google.common.truth.Truth"/>
+
+ <entry-point class="com.google.common.base.TestModuleEntryPoint"/>
+
+ <super-source path="super"/>
+
+</module>
diff --git a/guava-gwt/test/com/google/common/cache/testModule.gwt.xml b/guava-gwt/test/com/google/common/cache/testModule.gwt.xml
new file mode 100644
index 0000000..dae8396
--- /dev/null
+++ b/guava-gwt/test/com/google/common/cache/testModule.gwt.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="utf-8"?>
+<module>
+
+ <source path=""/>
+
+ <inherits name="com.google.gwt.user.User"/>
+
+ <inherits name="com.google.gwt.junit.JUnit"/>
+
+ <inherits name="com.google.common.annotations.Annotations"/>
+
+ <inherits name="com.google.common.base.Base"/>
+
+ <inherits name="com.google.common.cache.Cache"/>
+
+ <inherits name="com.google.common.collect.Collect"/>
+
+ <inherits name="com.google.common.testing.Testing"/>
+
+ <inherits name="com.google.common.util.concurrent.Concurrent"/>
+
+ <inherits name="com.google.common.truth.Truth"/>
+
+ <entry-point class="com.google.common.cache.TestModuleEntryPoint"/>
+
+ <super-source path="super"/>
+
+</module>
diff --git a/guava-gwt/test/com/google/common/collect/testModule.gwt.xml b/guava-gwt/test/com/google/common/collect/testModule.gwt.xml
new file mode 100644
index 0000000..a5f868d
--- /dev/null
+++ b/guava-gwt/test/com/google/common/collect/testModule.gwt.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="utf-8"?>
+<module>
+
+ <source path=""/>
+
+ <inherits name="com.google.gwt.user.User"/>
+
+ <inherits name="com.google.gwt.junit.JUnit"/>
+
+ <inherits name="com.google.common.annotations.Annotations"/>
+
+ <inherits name="com.google.common.base.Base"/>
+
+ <inherits name="com.google.common.collect.Collect"/>
+
+ <inherits name="com.google.common.collect.testing.Testing"/>
+
+ <inherits name="com.google.common.collect.testing.google.Google"/>
+
+ <inherits name="com.google.common.io.Io"/>
+
+ <inherits name="com.google.common.testing.Testing"/>
+
+ <inherits name="com.google.common.truth.Truth"/>
+
+ <entry-point class="com.google.common.collect.TestModuleEntryPoint"/>
+
+ <super-source path="super"/>
+
+</module>
diff --git a/guava-gwt/test/com/google/common/collect/testing/Testing.gwt.xml b/guava-gwt/test/com/google/common/collect/testing/Testing.gwt.xml
index 6d1e97b..d152637 100644
--- a/guava-gwt/test/com/google/common/collect/testing/Testing.gwt.xml
+++ b/guava-gwt/test/com/google/common/collect/testing/Testing.gwt.xml
@@ -1,32 +1,32 @@
+<?xml version="1.0" encoding="utf-8"?>
<module>
-<source path="">
- <!-- Hack to keep collect from hiding collect.testing supersource: -->
- <exclude name="**/testing/**"/>
-</source>
-
-<!--
- We used to set this only for packages that had manual supersource.
- That worked everywhere that I know of except for one place:
- when running the GWT util.concurrent tests under Guava.
- The problem is that GWT responds poorly to two .gwt.xml files in the same Java package:
- https://goo.gl/pRV3Yn
- The summary is that it ignores one file in favor of the other.
- util.concurrent, like nearly all our packages, has two .gwt.xml files: one for prod and one for tests.
- util.concurrent, unlike our other packages, has, as of this writing, test supersource but no prod supersource.
- GWT happens to use the prod .gwt.xml, so it looks for no supersource for tests, either.
- This causes it to fail to find AtomicLongMapTest.
- Our workaround is to tell GWT that util.concurrent and all other packages have prod supersource, even if they have none.
- GWT is happy to ignore us when we specify a nonexistent path.
- (I hope that this workaround does not cause its own problems in the future.)
--->
-<super-source path="super"/>
-
-<inherits name="com.google.common.annotations.Annotations" />
-<inherits name="com.google.common.base.Base" />
-<inherits name="com.google.common.collect.Collect" />
-<inherits name="com.google.common.primitives.Primitives" />
-<inherits name="com.google.common.testing.Testing" />
-<inherits name="com.google.gwt.core.Core" />
-<inherits name="com.google.gwt.junit.JUnit" />
-<inherits name="com.google.gwt.user.User" />
+
+ <source path="">
+
+ <!-- Hack to keep collect from hiding collect.testing supersource: -->
+
+ <exclude name="**/testing/**"/>
+
+ </source>
+
+ <!-- We used to set this only for packages that had manual supersource. That worked everywhere that I know of except for one place: when running the GWT util.concurrent tests under Guava. The problem is that GWT responds poorly to two .gwt.xml files in the same Java package: https://goo.gl/pRV3Yn The summary is that it ignores one file in favor of the other. util.concurrent, like nearly all our packages, has two .gwt.xml files: one for prod and one for tests. util.concurrent, unlike our other packages, has, as of this writing, test supersource but no prod supersource. GWT happens to use the prod .gwt.xml, so it looks for no supersource for tests, either. This causes it to fail to find AtomicLongMapTest. Our workaround is to tell GWT that util.concurrent and all other packages have prod supersource, even if they have none. GWT is happy to ignore us when we specify a nonexistent path. (I hope that this workaround does not cause its own problems in the future.) -->
+
+ <super-source path="super"/>
+
+ <inherits name="com.google.gwt.user.User"/>
+
+ <inherits name="com.google.gwt.junit.JUnit"/>
+
+ <inherits name="com.google.common.annotations.Annotations"/>
+
+ <inherits name="com.google.common.base.Base"/>
+
+ <inherits name="com.google.common.collect.Collect"/>
+
+ <inherits name="com.google.common.primitives.Primitives"/>
+
+ <inherits name="com.google.common.testing.Testing"/>
+
+ <inherits name="com.google.gwt.core.Core"/>
+
</module>
diff --git a/guava-gwt/test/com/google/common/collect/testing/google/Google.gwt.xml b/guava-gwt/test/com/google/common/collect/testing/google/Google.gwt.xml
index 5e90c31..5d88b92 100644
--- a/guava-gwt/test/com/google/common/collect/testing/google/Google.gwt.xml
+++ b/guava-gwt/test/com/google/common/collect/testing/google/Google.gwt.xml
@@ -1,33 +1,34 @@
+<?xml version="1.0" encoding="utf-8"?>
<module>
-<source path="">
- <!-- Hack to keep collect from hiding collect.testing supersource: -->
- <exclude name="**/testing/**"/>
-</source>
-
-<!--
- We used to set this only for packages that had manual supersource.
- That worked everywhere that I know of except for one place:
- when running the GWT util.concurrent tests under Guava.
- The problem is that GWT responds poorly to two .gwt.xml files in the same Java package:
- https://goo.gl/pRV3Yn
- The summary is that it ignores one file in favor of the other.
- util.concurrent, like nearly all our packages, has two .gwt.xml files: one for prod and one for tests.
- util.concurrent, unlike our other packages, has, as of this writing, test supersource but no prod supersource.
- GWT happens to use the prod .gwt.xml, so it looks for no supersource for tests, either.
- This causes it to fail to find AtomicLongMapTest.
- Our workaround is to tell GWT that util.concurrent and all other packages have prod supersource, even if they have none.
- GWT is happy to ignore us when we specify a nonexistent path.
- (I hope that this workaround does not cause its own problems in the future.)
--->
-<super-source path="super"/>
-
-<inherits name="com.google.common.annotations.Annotations" />
-<inherits name="com.google.common.base.Base" />
-<inherits name="com.google.common.collect.Collect" />
-<inherits name="com.google.common.collect.testing.Testing" />
-<inherits name="com.google.common.primitives.Primitives" />
-<inherits name="com.google.common.testing.Testing" />
-<inherits name="com.google.gwt.core.Core" />
-<inherits name="com.google.gwt.junit.JUnit" />
-<inherits name="com.google.gwt.user.User" />
+
+ <source path="">
+
+ <!-- Hack to keep collect from hiding collect.testing supersource: -->
+
+ <exclude name="**/testing/**"/>
+
+ </source>
+
+ <!-- We used to set this only for packages that had manual supersource. That worked everywhere that I know of except for one place: when running the GWT util.concurrent tests under Guava. The problem is that GWT responds poorly to two .gwt.xml files in the same Java package: https://goo.gl/pRV3Yn The summary is that it ignores one file in favor of the other. util.concurrent, like nearly all our packages, has two .gwt.xml files: one for prod and one for tests. util.concurrent, unlike our other packages, has, as of this writing, test supersource but no prod supersource. GWT happens to use the prod .gwt.xml, so it looks for no supersource for tests, either. This causes it to fail to find AtomicLongMapTest. Our workaround is to tell GWT that util.concurrent and all other packages have prod supersource, even if they have none. GWT is happy to ignore us when we specify a nonexistent path. (I hope that this workaround does not cause its own problems in the future.) -->
+
+ <super-source path="super"/>
+
+ <inherits name="com.google.gwt.user.User"/>
+
+ <inherits name="com.google.gwt.junit.JUnit"/>
+
+ <inherits name="com.google.common.annotations.Annotations"/>
+
+ <inherits name="com.google.common.base.Base"/>
+
+ <inherits name="com.google.common.collect.Collect"/>
+
+ <inherits name="com.google.common.collect.testing.Testing"/>
+
+ <inherits name="com.google.common.primitives.Primitives"/>
+
+ <inherits name="com.google.common.testing.Testing"/>
+
+ <inherits name="com.google.gwt.core.Core"/>
+
</module>
diff --git a/guava-gwt/test/com/google/common/collect/testing/testModule.gwt.xml b/guava-gwt/test/com/google/common/collect/testing/testModule.gwt.xml
new file mode 100644
index 0000000..42b4a60
--- /dev/null
+++ b/guava-gwt/test/com/google/common/collect/testing/testModule.gwt.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<module>
+
+ <source path=""/>
+
+ <inherits name="com.google.gwt.user.User"/>
+
+ <inherits name="com.google.gwt.junit.JUnit"/>
+
+ <inherits name="com.google.common.annotations.Annotations"/>
+
+ <inherits name="com.google.common.base.Base"/>
+
+ <inherits name="com.google.common.collect.Collect"/>
+
+ <inherits name="com.google.common.collect.testing.Testing"/>
+
+ <inherits name="com.google.common.testing.Testing"/>
+
+ <entry-point class="com.google.common.collect.testing.TestModuleEntryPoint"/>
+
+</module>
diff --git a/guava-gwt/test/com/google/common/escape/testModule.gwt.xml b/guava-gwt/test/com/google/common/escape/testModule.gwt.xml
new file mode 100644
index 0000000..e52723e
--- /dev/null
+++ b/guava-gwt/test/com/google/common/escape/testModule.gwt.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<module>
+
+ <source path=""/>
+
+ <inherits name="com.google.gwt.user.User"/>
+
+ <inherits name="com.google.gwt.junit.JUnit"/>
+
+ <inherits name="com.google.common.base.Base"/>
+
+ <inherits name="com.google.common.collect.Collect"/>
+
+ <inherits name="com.google.common.escape.Escape"/>
+
+ <inherits name="com.google.common.escape.testing.Testing"/>
+
+ <inherits name="com.google.common.html.Html"/>
+
+ <inherits name="com.google.common.testing.Testing"/>
+
+ <entry-point class="com.google.common.escape.TestModuleEntryPoint"/>
+
+</module>
diff --git a/guava-gwt/test/com/google/common/escape/testing/Testing.gwt.xml b/guava-gwt/test/com/google/common/escape/testing/Testing.gwt.xml
index c3a1bd4..85cb436 100644
--- a/guava-gwt/test/com/google/common/escape/testing/Testing.gwt.xml
+++ b/guava-gwt/test/com/google/common/escape/testing/Testing.gwt.xml
@@ -20,10 +20,10 @@
(I hope that this workaround does not cause its own problems in the future.)
-->
<super-source path="super"/>
+<inherits name="com.google.gwt.user.User" />
+<inherits name="com.google.gwt.junit.JUnit" />
<inherits name="com.google.common.annotations.Annotations" />
<inherits name="com.google.common.escape.Escape" />
<inherits name="com.google.gwt.core.Core" />
-<inherits name="com.google.gwt.junit.JUnit" />
-<inherits name="com.google.gwt.user.User" />
</module>
diff --git a/guava-gwt/test/com/google/common/html/testModule.gwt.xml b/guava-gwt/test/com/google/common/html/testModule.gwt.xml
new file mode 100644
index 0000000..57719c0
--- /dev/null
+++ b/guava-gwt/test/com/google/common/html/testModule.gwt.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<module>
+
+ <source path=""/>
+
+ <inherits name="com.google.gwt.user.User"/>
+
+ <inherits name="com.google.gwt.junit.JUnit"/>
+
+ <inherits name="com.google.common.base.Base"/>
+
+ <inherits name="com.google.common.escape.testing.Testing"/>
+
+ <inherits name="com.google.common.html.Html"/>
+
+ <inherits name="com.google.common.truth.Truth"/>
+
+ <entry-point class="com.google.common.html.TestModuleEntryPoint"/>
+
+</module>
diff --git a/guava-gwt/test/com/google/common/io/testModule.gwt.xml b/guava-gwt/test/com/google/common/io/testModule.gwt.xml
new file mode 100644
index 0000000..8b66886
--- /dev/null
+++ b/guava-gwt/test/com/google/common/io/testModule.gwt.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="utf-8"?>
+<module>
+
+ <source path=""/>
+
+ <inherits name="com.google.gwt.user.User"/>
+
+ <inherits name="com.google.gwt.junit.JUnit"/>
+
+ <inherits name="com.google.common.annotations.Annotations"/>
+
+ <inherits name="com.google.common.base.Base"/>
+
+ <inherits name="com.google.common.collect.Collect"/>
+
+ <inherits name="com.google.common.io.Io"/>
+
+ <inherits name="com.google.common.math.Math"/>
+
+ <inherits name="com.google.common.testing.Testing"/>
+
+ <inherits name="com.google.common.truth.Truth"/>
+
+ <entry-point class="com.google.common.io.TestModuleEntryPoint"/>
+
+ <super-source path="super"/>
+
+</module>
diff --git a/guava-gwt/test/com/google/common/math/testModule.gwt.xml b/guava-gwt/test/com/google/common/math/testModule.gwt.xml
new file mode 100644
index 0000000..af911d9
--- /dev/null
+++ b/guava-gwt/test/com/google/common/math/testModule.gwt.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<module>
+
+ <source path=""/>
+
+ <inherits name="com.google.gwt.user.User"/>
+
+ <inherits name="com.google.gwt.junit.JUnit"/>
+
+ <inherits name="com.google.common.annotations.Annotations"/>
+
+ <inherits name="com.google.common.base.Base"/>
+
+ <inherits name="com.google.common.collect.Collect"/>
+
+ <inherits name="com.google.common.math.Math"/>
+
+ <inherits name="com.google.common.testing.Testing"/>
+
+ <inherits name="com.google.common.truth.Truth"/>
+
+ <entry-point class="com.google.common.math.TestModuleEntryPoint"/>
+
+ <super-source path="super"/>
+
+</module>
diff --git a/guava-gwt/test/com/google/common/net/testModule.gwt.xml b/guava-gwt/test/com/google/common/net/testModule.gwt.xml
new file mode 100644
index 0000000..d0ae466
--- /dev/null
+++ b/guava-gwt/test/com/google/common/net/testModule.gwt.xml
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="utf-8"?>
+<module>
+
+ <source path=""/>
+
+ <inherits name="com.google.gwt.user.User"/>
+
+ <inherits name="com.google.gwt.junit.JUnit"/>
+
+ <inherits name="com.google.common.annotations.Annotations"/>
+
+ <inherits name="com.google.common.base.Base"/>
+
+ <inherits name="com.google.common.collect.Collect"/>
+
+ <inherits name="com.google.common.collect.testing.Testing"/>
+
+ <inherits name="com.google.common.collect.testing.google.Google"/>
+
+ <inherits name="com.google.common.escape.Escape"/>
+
+ <inherits name="com.google.common.escape.testing.Testing"/>
+
+ <inherits name="com.google.common.net.Net"/>
+
+ <inherits name="com.google.common.testing.Testing"/>
+
+ <inherits name="com.google.common.truth.Truth"/>
+
+ <entry-point class="com.google.common.net.TestModuleEntryPoint"/>
+
+ <super-source path="super"/>
+
+</module>
diff --git a/guava-gwt/test/com/google/common/primitives/testModule.gwt.xml b/guava-gwt/test/com/google/common/primitives/testModule.gwt.xml
new file mode 100644
index 0000000..e37c58f
--- /dev/null
+++ b/guava-gwt/test/com/google/common/primitives/testModule.gwt.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<module>
+
+ <source path=""/>
+
+ <inherits name="com.google.gwt.user.User"/>
+
+ <inherits name="com.google.gwt.junit.JUnit"/>
+
+ <inherits name="com.google.common.collect.testing.Testing"/>
+
+ <inherits name="com.google.common.primitives.Primitives"/>
+
+ <inherits name="com.google.common.testing.Testing"/>
+
+ <inherits name="com.google.common.truth.Truth"/>
+
+ <entry-point class="com.google.common.primitives.TestModuleEntryPoint"/>
+
+ <super-source path="super"/>
+
+</module>
diff --git a/guava-gwt/test/com/google/common/testing/Testing.gwt.xml b/guava-gwt/test/com/google/common/testing/Testing.gwt.xml
index 0c58567..9929e53 100644
--- a/guava-gwt/test/com/google/common/testing/Testing.gwt.xml
+++ b/guava-gwt/test/com/google/common/testing/Testing.gwt.xml
@@ -1,30 +1,28 @@
+<?xml version="1.0" encoding="utf-8"?>
<module>
-<source path="">
- <!-- Hack to keep collect from hiding collect.testing supersource: -->
- <exclude name="**/testing/**"/>
-</source>
-
-<!--
- We used to set this only for packages that had manual supersource.
- That worked everywhere that I know of except for one place:
- when running the GWT util.concurrent tests under Guava.
- The problem is that GWT responds poorly to two .gwt.xml files in the same Java package:
- https://goo.gl/pRV3Yn
- The summary is that it ignores one file in favor of the other.
- util.concurrent, like nearly all our packages, has two .gwt.xml files: one for prod and one for tests.
- util.concurrent, unlike our other packages, has, as of this writing, test supersource but no prod supersource.
- GWT happens to use the prod .gwt.xml, so it looks for no supersource for tests, either.
- This causes it to fail to find AtomicLongMapTest.
- Our workaround is to tell GWT that util.concurrent and all other packages have prod supersource, even if they have none.
- GWT is happy to ignore us when we specify a nonexistent path.
- (I hope that this workaround does not cause its own problems in the future.)
--->
-<super-source path="super"/>
-
-<inherits name="com.google.common.annotations.Annotations" />
-<inherits name="com.google.common.base.Base" />
-<inherits name="com.google.common.collect.Collect" />
-<inherits name="com.google.gwt.core.Core" />
-<inherits name="com.google.gwt.junit.JUnit" />
-<inherits name="com.google.gwt.user.User" />
+
+ <source path="">
+
+ <!-- Hack to keep collect from hiding collect.testing supersource: -->
+
+ <exclude name="**/testing/**"/>
+
+ </source>
+
+ <!-- We used to set this only for packages that had manual supersource. That worked everywhere that I know of except for one place: when running the GWT util.concurrent tests under Guava. The problem is that GWT responds poorly to two .gwt.xml files in the same Java package: https://goo.gl/pRV3Yn The summary is that it ignores one file in favor of the other. util.concurrent, like nearly all our packages, has two .gwt.xml files: one for prod and one for tests. util.concurrent, unlike our other packages, has, as of this writing, test supersource but no prod supersource. GWT happens to use the prod .gwt.xml, so it looks for no supersource for tests, either. This causes it to fail to find AtomicLongMapTest. Our workaround is to tell GWT that util.concurrent and all other packages have prod supersource, even if they have none. GWT is happy to ignore us when we specify a nonexistent path. (I hope that this workaround does not cause its own problems in the future.) -->
+
+ <super-source path="super"/>
+
+ <inherits name="com.google.gwt.user.User"/>
+
+ <inherits name="com.google.gwt.junit.JUnit"/>
+
+ <inherits name="com.google.common.annotations.Annotations"/>
+
+ <inherits name="com.google.common.base.Base"/>
+
+ <inherits name="com.google.common.collect.Collect"/>
+
+ <inherits name="com.google.gwt.core.Core"/>
+
</module>
diff --git a/guava-gwt/test/com/google/common/testing/testModule.gwt.xml b/guava-gwt/test/com/google/common/testing/testModule.gwt.xml
new file mode 100644
index 0000000..ed7645b
--- /dev/null
+++ b/guava-gwt/test/com/google/common/testing/testModule.gwt.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<module>
+
+ <source path=""/>
+
+ <inherits name="com.google.gwt.user.User"/>
+
+ <inherits name="com.google.gwt.junit.JUnit"/>
+
+ <inherits name="com.google.common.collect.Collect"/>
+
+ <inherits name="com.google.common.testing.Testing"/>
+
+ <inherits name="com.google.common.truth.Truth"/>
+
+ <entry-point class="com.google.common.testing.TestModuleEntryPoint"/>
+
+ <super-source path="super"/>
+
+</module>
diff --git a/guava-gwt/test/com/google/common/util/concurrent/testModule.gwt.xml b/guava-gwt/test/com/google/common/util/concurrent/testModule.gwt.xml
new file mode 100644
index 0000000..cea4250
--- /dev/null
+++ b/guava-gwt/test/com/google/common/util/concurrent/testModule.gwt.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<module>
+
+ <source path=""/>
+
+ <inherits name="com.google.gwt.user.User"/>
+
+ <inherits name="com.google.gwt.junit.JUnit"/>
+
+ <inherits name="com.google.common.annotations.Annotations"/>
+
+ <inherits name="com.google.common.base.Base"/>
+
+ <inherits name="com.google.common.collect.Collect"/>
+
+ <inherits name="com.google.common.testing.Testing"/>
+
+ <inherits name="com.google.common.util.concurrent.Concurrent"/>
+
+ <inherits name="com.google.common.truth.Truth"/>
+
+ <entry-point class="com.google.common.util.concurrent.TestModuleEntryPoint"/>
+
+ <super-source path="super"/>
+
+</module>
diff --git a/guava-gwt/test/com/google/common/xml/testModule.gwt.xml b/guava-gwt/test/com/google/common/xml/testModule.gwt.xml
new file mode 100644
index 0000000..7f48ca0
--- /dev/null
+++ b/guava-gwt/test/com/google/common/xml/testModule.gwt.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<module>
+
+ <source path=""/>
+
+ <inherits name="com.google.gwt.user.User"/>
+
+ <inherits name="com.google.gwt.junit.JUnit"/>
+
+ <inherits name="com.google.common.annotations.Annotations"/>
+
+ <inherits name="com.google.common.escape.Escape"/>
+
+ <inherits name="com.google.common.escape.testing.Testing"/>
+
+ <inherits name="com.google.common.xml.Xml"/>
+
+ <inherits name="com.google.common.truth.Truth"/>
+
+ <entry-point class="com.google.common.xml.TestModuleEntryPoint"/>
+
+</module>
diff --git a/guava-testlib/README.md b/guava-testlib/README.md
index 4368995..c33f421 100644
--- a/guava-testlib/README.md
+++ b/guava-testlib/README.md
@@ -13,7 +13,7 @@
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava-testlib</artifactId>
- <version>31.0.1-jre</version>
+ <version>30.0-jre</version>
<scope>test</scope>
</dependency>
```
@@ -22,7 +22,7 @@
```gradle
dependencies {
- test 'com.google.guava:guava-testlib:31.0.1-jre'
+ test 'com.google.guava:guava-testlib:30.0-jre'
}
```
@@ -48,3 +48,4 @@
<!-- References -->
[repackage]: https://github.com/google/guava/wiki/UseGuavaInYourBuild#what-if-i-want-to-use-beta-apis-from-a-library-that-people-use-as-a-dependency
+
diff --git a/guava-testlib/pom.xml b/guava-testlib/pom.xml
index aa812ae..9411f74 100644
--- a/guava-testlib/pom.xml
+++ b/guava-testlib/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>com.google.guava</groupId>
<artifactId>guava-parent</artifactId>
- <version>31.0.1-jre</version>
+ <version>30.0-jre</version>
</parent>
<artifactId>guava-testlib</artifactId>
<name>Guava Testing Library</name>
diff --git a/guava-testlib/src/com/google/common/collect/testing/CollectionTestSuiteBuilder.java b/guava-testlib/src/com/google/common/collect/testing/CollectionTestSuiteBuilder.java
index 5f9aff4..cf1ed23 100644
--- a/guava-testlib/src/com/google/common/collect/testing/CollectionTestSuiteBuilder.java
+++ b/guava-testlib/src/com/google/common/collect/testing/CollectionTestSuiteBuilder.java
@@ -57,8 +57,6 @@
.named(getName() + " reserialized")
.withFeatures(computeReserializedCollectionFeatures(parentBuilder.getFeatures()))
.suppressing(parentBuilder.getSuppressedTests())
- .withSetUp(parentBuilder.getSetUp())
- .withTearDown(parentBuilder.getTearDown())
.createTestSuite());
}
return derivedSuites;
diff --git a/guava-testlib/src/com/google/common/collect/testing/FeatureSpecificTestSuiteBuilder.java b/guava-testlib/src/com/google/common/collect/testing/FeatureSpecificTestSuiteBuilder.java
index b629fa9..0d921a5 100644
--- a/guava-testlib/src/com/google/common/collect/testing/FeatureSpecificTestSuiteBuilder.java
+++ b/guava-testlib/src/com/google/common/collect/testing/FeatureSpecificTestSuiteBuilder.java
@@ -81,7 +81,7 @@
return self();
}
- public Runnable getSetUp() {
+ protected Runnable getSetUp() {
return setUp;
}
@@ -90,13 +90,13 @@
return self();
}
- public Runnable getTearDown() {
+ protected Runnable getTearDown() {
return tearDown;
}
// Features
- private final Set<Feature<?>> features = new LinkedHashSet<>();
+ private Set<Feature<?>> features = new LinkedHashSet<>();
/**
* Configures this builder to produce tests appropriate for the given features. This method may be
@@ -138,7 +138,7 @@
// Test suppression
- private final Set<Method> suppressedTests = new HashSet<>();
+ private Set<Method> suppressedTests = new HashSet<>();
/**
* Prevents the given methods from being run as part of the test suite.
diff --git a/guava-testlib/src/com/google/common/collect/testing/ListTestSuiteBuilder.java b/guava-testlib/src/com/google/common/collect/testing/ListTestSuiteBuilder.java
index 492a50c..5355f48 100644
--- a/guava-testlib/src/com/google/common/collect/testing/ListTestSuiteBuilder.java
+++ b/guava-testlib/src/com/google/common/collect/testing/ListTestSuiteBuilder.java
@@ -114,8 +114,6 @@
.named(getName() + " reserialized")
.withFeatures(computeReserializedCollectionFeatures(parentBuilder.getFeatures()))
.suppressing(parentBuilder.getSuppressedTests())
- .withSetUp(parentBuilder.getSetUp())
- .withTearDown(parentBuilder.getTearDown())
.createTestSuite());
}
return derivedSuites;
diff --git a/guava-testlib/src/com/google/common/collect/testing/MapTestSuiteBuilder.java b/guava-testlib/src/com/google/common/collect/testing/MapTestSuiteBuilder.java
index d1ce341..0b02f3b 100644
--- a/guava-testlib/src/com/google/common/collect/testing/MapTestSuiteBuilder.java
+++ b/guava-testlib/src/com/google/common/collect/testing/MapTestSuiteBuilder.java
@@ -123,8 +123,6 @@
.withFeatures(computeReserializedMapFeatures(parentBuilder.getFeatures()))
.named(parentBuilder.getName() + " reserialized")
.suppressing(parentBuilder.getSuppressedTests())
- .withSetUp(parentBuilder.getSetUp())
- .withTearDown(parentBuilder.getTearDown())
.createTestSuite());
}
@@ -134,8 +132,6 @@
.withFeatures(computeEntrySetFeatures(parentBuilder.getFeatures()))
.named(parentBuilder.getName() + " entrySet")
.suppressing(parentBuilder.getSuppressedTests())
- .withSetUp(parentBuilder.getSetUp())
- .withTearDown(parentBuilder.getTearDown())
.createTestSuite());
derivedSuites.add(
@@ -143,8 +139,6 @@
.withFeatures(computeKeySetFeatures(parentBuilder.getFeatures()))
.named(parentBuilder.getName() + " keys")
.suppressing(parentBuilder.getSuppressedTests())
- .withSetUp(parentBuilder.getSetUp())
- .withTearDown(parentBuilder.getTearDown())
.createTestSuite());
derivedSuites.add(
@@ -153,8 +147,6 @@
.named(parentBuilder.getName() + " values")
.withFeatures(computeValuesCollectionFeatures(parentBuilder.getFeatures()))
.suppressing(parentBuilder.getSuppressedTests())
- .withSetUp(parentBuilder.getSetUp())
- .withTearDown(parentBuilder.getTearDown())
.createTestSuite());
return derivedSuites;
diff --git a/guava-testlib/src/com/google/common/collect/testing/SetTestSuiteBuilder.java b/guava-testlib/src/com/google/common/collect/testing/SetTestSuiteBuilder.java
index 4ac51a4..26a2870 100644
--- a/guava-testlib/src/com/google/common/collect/testing/SetTestSuiteBuilder.java
+++ b/guava-testlib/src/com/google/common/collect/testing/SetTestSuiteBuilder.java
@@ -78,8 +78,6 @@
.named(getName() + " reserialized")
.withFeatures(computeReserializedCollectionFeatures(parentBuilder.getFeatures()))
.suppressing(parentBuilder.getSuppressedTests())
- .withSetUp(parentBuilder.getSetUp())
- .withTearDown(parentBuilder.getTearDown())
.createTestSuite());
}
return derivedSuites;
diff --git a/guava-testlib/src/com/google/common/collect/testing/SortedMapTestSuiteBuilder.java b/guava-testlib/src/com/google/common/collect/testing/SortedMapTestSuiteBuilder.java
index aa1d6d5..e95383a 100644
--- a/guava-testlib/src/com/google/common/collect/testing/SortedMapTestSuiteBuilder.java
+++ b/guava-testlib/src/com/google/common/collect/testing/SortedMapTestSuiteBuilder.java
@@ -121,8 +121,6 @@
.named(parentBuilder.getName() + " subMap " + from + "-" + to)
.withFeatures(features)
.suppressing(parentBuilder.getSuppressedTests())
- .withSetUp(parentBuilder.getSetUp())
- .withTearDown(parentBuilder.getTearDown())
.createTestSuite();
}
diff --git a/guava-testlib/src/com/google/common/collect/testing/SortedSetTestSuiteBuilder.java b/guava-testlib/src/com/google/common/collect/testing/SortedSetTestSuiteBuilder.java
index 5092661..e97b08f 100644
--- a/guava-testlib/src/com/google/common/collect/testing/SortedSetTestSuiteBuilder.java
+++ b/guava-testlib/src/com/google/common/collect/testing/SortedSetTestSuiteBuilder.java
@@ -94,8 +94,6 @@
.named(parentBuilder.getName() + " subSet " + from + "-" + to)
.withFeatures(features)
.suppressing(parentBuilder.getSuppressedTests())
- .withSetUp(parentBuilder.getSetUp())
- .withTearDown(parentBuilder.getTearDown())
.createTestSuite();
}
diff --git a/guava-testlib/src/com/google/common/collect/testing/google/BiMapTestSuiteBuilder.java b/guava-testlib/src/com/google/common/collect/testing/google/BiMapTestSuiteBuilder.java
index 0821fb0..fa21a71 100644
--- a/guava-testlib/src/com/google/common/collect/testing/google/BiMapTestSuiteBuilder.java
+++ b/guava-testlib/src/com/google/common/collect/testing/google/BiMapTestSuiteBuilder.java
@@ -88,8 +88,6 @@
.suppressing(parentBuilder.getSuppressedTests())
.suppressing(SetCreationTester.class.getMethods())
// BiMap.entrySet() duplicate-handling behavior is too confusing for SetCreationTester
- .withSetUp(parentBuilder.getSetUp())
- .withTearDown(parentBuilder.getTearDown())
.createTestSuite());
/*
* TODO(cpovirk): the Map tests duplicate most of this effort by using a
@@ -103,8 +101,6 @@
.suppressing(parentBuilder.getSuppressedTests())
.suppressing(SetCreationTester.class.getMethods())
// BiMap.values() duplicate-handling behavior is too confusing for SetCreationTester
- .withSetUp(parentBuilder.getSetUp())
- .withTearDown(parentBuilder.getTearDown())
.createTestSuite());
if (!parentBuilder.getFeatures().contains(NoRecurse.INVERSE)) {
derived.add(
@@ -113,8 +109,6 @@
.withFeatures(computeInverseFeatures(parentBuilder.getFeatures()))
.named(parentBuilder.getName() + " inverse")
.suppressing(parentBuilder.getSuppressedTests())
- .withSetUp(parentBuilder.getSetUp())
- .withTearDown(parentBuilder.getTearDown())
.createTestSuite());
}
diff --git a/guava-testlib/src/com/google/common/collect/testing/google/MultimapTestSuiteBuilder.java b/guava-testlib/src/com/google/common/collect/testing/google/MultimapTestSuiteBuilder.java
index af9d261..6e5d5ed 100644
--- a/guava-testlib/src/com/google/common/collect/testing/google/MultimapTestSuiteBuilder.java
+++ b/guava-testlib/src/com/google/common/collect/testing/google/MultimapTestSuiteBuilder.java
@@ -116,8 +116,6 @@
.withFeatures(computeReserializedMultimapFeatures(parentBuilder.getFeatures()))
.named(parentBuilder.getName() + " reserialized")
.suppressing(parentBuilder.getSuppressedTests())
- .withSetUp(parentBuilder.getSetUp())
- .withTearDown(parentBuilder.getTearDown())
.createTestSuite());
}
@@ -126,8 +124,6 @@
.withFeatures(computeAsMapFeatures(parentBuilder.getFeatures()))
.named(parentBuilder.getName() + ".asMap")
.suppressing(parentBuilder.getSuppressedTests())
- .withSetUp(parentBuilder.getSetUp())
- .withTearDown(parentBuilder.getTearDown())
.createTestSuite());
derivedSuites.add(computeEntriesTestSuite(parentBuilder));
@@ -158,8 +154,6 @@
.withFeatures(computeEntriesFeatures(parentBuilder.getFeatures()))
.named(parentBuilder.getName() + ".entries")
.suppressing(parentBuilder.getSuppressedTests())
- .withSetUp(parentBuilder.getSetUp())
- .withTearDown(parentBuilder.getTearDown())
.createTestSuite();
}
@@ -171,8 +165,6 @@
.withFeatures(computeMultimapGetFeatures(parentBuilder.getFeatures()))
.named(parentBuilder.getName() + ".get[key]")
.suppressing(parentBuilder.getSuppressedTests())
- .withSetUp(parentBuilder.getSetUp())
- .withTearDown(parentBuilder.getTearDown())
.createTestSuite();
}
@@ -188,8 +180,6 @@
.withFeatures(features)
.named(parentBuilder.getName() + ".asMap[].get[key]")
.suppressing(parentBuilder.getSuppressedTests())
- .withSetUp(parentBuilder.getSetUp())
- .withTearDown(parentBuilder.getTearDown())
.createTestSuite();
}
}
@@ -202,8 +192,6 @@
.withFeatures(computeKeysFeatures(parentBuilder.getFeatures()))
.named(parentBuilder.getName() + ".keys")
.suppressing(parentBuilder.getSuppressedTests())
- .withSetUp(parentBuilder.getSetUp())
- .withTearDown(parentBuilder.getTearDown())
.createTestSuite();
}
diff --git a/guava-testlib/src/com/google/common/collect/testing/google/MultisetTestSuiteBuilder.java b/guava-testlib/src/com/google/common/collect/testing/google/MultisetTestSuiteBuilder.java
index 91d7a60..9e3d750 100644
--- a/guava-testlib/src/com/google/common/collect/testing/google/MultisetTestSuiteBuilder.java
+++ b/guava-testlib/src/com/google/common/collect/testing/google/MultisetTestSuiteBuilder.java
@@ -131,8 +131,6 @@
.named(getName() + ".entrySet")
.withFeatures(computeEntrySetFeatures(parentBuilder.getFeatures()))
.suppressing(parentBuilder.getSuppressedTests())
- .withSetUp(parentBuilder.getSetUp())
- .withTearDown(parentBuilder.getTearDown())
.createTestSuite());
}
@@ -143,8 +141,6 @@
.named(getName() + " reserialized")
.withFeatures(computeReserializedMultisetFeatures(parentBuilder.getFeatures()))
.suppressing(parentBuilder.getSuppressedTests())
- .withSetUp(parentBuilder.getSetUp())
- .withTearDown(parentBuilder.getTearDown())
.createTestSuite());
}
return derivedSuites;
@@ -158,8 +154,6 @@
.named(getName() + ".elementSet")
.withFeatures(computeElementSetFeatures(parentBuilder.getFeatures()))
.suppressing(parentBuilder.getSuppressedTests())
- .withSetUp(parentBuilder.getSetUp())
- .withTearDown(parentBuilder.getTearDown())
.createTestSuite();
}
diff --git a/guava-testlib/src/com/google/common/collect/testing/testers/CollectionToArrayTester.java b/guava-testlib/src/com/google/common/collect/testing/testers/CollectionToArrayTester.java
index b40fc36..83a4cea 100644
--- a/guava-testlib/src/com/google/common/collect/testing/testers/CollectionToArrayTester.java
+++ b/guava-testlib/src/com/google/common/collect/testing/testers/CollectionToArrayTester.java
@@ -48,8 +48,8 @@
}
/**
- * {@link Collection#toArray(Object[])} says: "Note that {@code toArray(new Object[0])} is
- * identical in function to {@code toArray()}."
+ * {@link Collection#toArray(Object[])} says: "Note that <tt>toArray(new Object[0])</tt> is
+ * identical in function to <tt>toArray()</tt>."
*
* <p>For maximum effect, the collection under test should be created from an element array of a
* type other than {@code Object[]}.
diff --git a/guava-testlib/src/com/google/common/testing/FreshValueGenerator.java b/guava-testlib/src/com/google/common/testing/FreshValueGenerator.java
index e34b399..a2fe93a 100644
--- a/guava-testlib/src/com/google/common/testing/FreshValueGenerator.java
+++ b/guava-testlib/src/com/google/common/testing/FreshValueGenerator.java
@@ -356,7 +356,7 @@
private @interface Empty {}
@Generates
- Class<?> generateClass() {
+ private Class<?> generateClass() {
return pickInstance(
ImmutableList.of(
int.class, long.class, void.class, Object.class, Object[].class, Iterable.class),
@@ -364,147 +364,147 @@
}
@Generates
- Object generateObject() {
+ private Object generateObject() {
return generateString();
}
@Generates
- Number generateNumber() {
+ private Number generateNumber() {
return generateInt();
}
@Generates
- int generateInt() {
+ private int generateInt() {
return freshness.get();
}
@Generates
- Integer generateInteger() {
+ private Integer generateInteger() {
return new Integer(generateInt());
}
@Generates
- long generateLong() {
+ private long generateLong() {
return generateInt();
}
@Generates
- Long generateLongObject() {
+ private Long generateLongObject() {
return new Long(generateLong());
}
@Generates
- float generateFloat() {
+ private float generateFloat() {
return generateInt();
}
@Generates
- Float generateFloatObject() {
+ private Float generateFloatObject() {
return new Float(generateFloat());
}
@Generates
- double generateDouble() {
+ private double generateDouble() {
return generateInt();
}
@Generates
- Double generateDoubleObject() {
+ private Double generateDoubleObject() {
return new Double(generateDouble());
}
@Generates
- short generateShort() {
+ private short generateShort() {
return (short) generateInt();
}
@Generates
- Short generateShortObject() {
+ private Short generateShortObject() {
return new Short(generateShort());
}
@Generates
- byte generateByte() {
+ private byte generateByte() {
return (byte) generateInt();
}
@Generates
- Byte generateByteObject() {
+ private Byte generateByteObject() {
return new Byte(generateByte());
}
@Generates
- char generateChar() {
+ private char generateChar() {
return generateString().charAt(0);
}
@Generates
- Character generateCharacter() {
+ private Character generateCharacter() {
return new Character(generateChar());
}
@Generates
- boolean generateBoolean() {
+ private boolean generateBoolean() {
return generateInt() % 2 == 0;
}
@Generates
- Boolean generateBooleanObject() {
+ private Boolean generateBooleanObject() {
return new Boolean(generateBoolean());
}
@Generates
- UnsignedInteger generateUnsignedInteger() {
+ private UnsignedInteger generateUnsignedInteger() {
return UnsignedInteger.fromIntBits(generateInt());
}
@Generates
- UnsignedLong generateUnsignedLong() {
+ private UnsignedLong generateUnsignedLong() {
return UnsignedLong.fromLongBits(generateLong());
}
@Generates
- BigInteger generateBigInteger() {
+ private BigInteger generateBigInteger() {
return BigInteger.valueOf(generateInt());
}
@Generates
- BigDecimal generateBigDecimal() {
+ private BigDecimal generateBigDecimal() {
return BigDecimal.valueOf(generateInt());
}
@Generates
- CharSequence generateCharSequence() {
+ private CharSequence generateCharSequence() {
return generateString();
}
@Generates
- String generateString() {
+ private String generateString() {
return Integer.toString(generateInt());
}
@Generates
- Comparable<?> generateComparable() {
+ private Comparable<?> generateComparable() {
return generateString();
}
@Generates
- Pattern generatePattern() {
+ private Pattern generatePattern() {
return Pattern.compile(generateString());
}
@Generates
- Charset generateCharset() {
+ private Charset generateCharset() {
return pickInstance(Charset.availableCharsets().values(), Charsets.UTF_8);
}
@Generates
- Locale generateLocale() {
+ private Locale generateLocale() {
return pickInstance(Locale.getAvailableLocales(), Locale.US);
}
@Generates
- Currency generateCurrency() {
+ private Currency generateCurrency() {
try {
Method method = Currency.class.getMethod("getAvailableCurrencies");
@SuppressWarnings("unchecked") // getAvailableCurrencies() returns Set<Currency>.
@@ -539,53 +539,53 @@
}
@Empty
- <T> Optional<T> generateJavaOptional() {
+ private <T> Optional<T> generateJavaOptional() {
return Optional.empty();
}
@Generates
- <T> Optional<T> generateJavaOptional(T value) {
+ private <T> Optional<T> generateJavaOptional(T value) {
return Optional.of(value);
}
@Generates
- OptionalInt generateOptionalInt() {
+ private OptionalInt generateOptionalInt() {
return OptionalInt.of(generateInt());
}
@Generates
- OptionalLong generateOptionalLong() {
+ private OptionalLong generateOptionalLong() {
return OptionalLong.of(generateLong());
}
@Generates
- OptionalDouble generateOptionalDouble() {
+ private OptionalDouble generateOptionalDouble() {
return OptionalDouble.of(generateDouble());
}
// common.base
@Empty
- <T> com.google.common.base.Optional<T> generateGoogleOptional() {
+ private <T> com.google.common.base.Optional<T> generateGoogleOptional() {
return com.google.common.base.Optional.absent();
}
@Generates
- <T> com.google.common.base.Optional<T> generateGoogleOptional(T value) {
+ private <T> com.google.common.base.Optional<T> generateGoogleOptional(T value) {
return com.google.common.base.Optional.of(value);
}
@Generates
- Joiner generateJoiner() {
+ private Joiner generateJoiner() {
return Joiner.on(generateString());
}
@Generates
- Splitter generateSplitter() {
+ private Splitter generateSplitter() {
return Splitter.on(generateString());
}
@Generates
- <T> Equivalence<T> generateEquivalence() {
+ private <T> Equivalence<T> generateEquivalence() {
return new Equivalence<T>() {
@Override
protected boolean doEquivalent(T a, T b) {
@@ -607,7 +607,7 @@
}
@Generates
- CharMatcher generateCharMatcher() {
+ private CharMatcher generateCharMatcher() {
return new CharMatcher() {
@Override
public boolean matches(char c) {
@@ -624,7 +624,7 @@
}
@Generates
- Ticker generateTicker() {
+ private Ticker generateTicker() {
return new Ticker() {
@Override
public long read() {
@@ -642,12 +642,12 @@
// collect
@Generates
- <T> Comparator<T> generateComparator() {
+ private <T> Comparator<T> generateComparator() {
return generateOrdering();
}
@Generates
- <T> Ordering<T> generateOrdering() {
+ private <T> Ordering<T> generateOrdering() {
return new Ordering<T>() {
@Override
public int compare(T left, T right) {
@@ -664,280 +664,279 @@
}
@Empty
- static <C extends Comparable<?>> Range<C> generateRange() {
+ private static <C extends Comparable<?>> Range<C> generateRange() {
return Range.all();
}
@Generates
- static <C extends Comparable<?>> Range<C> generateRange(C freshElement) {
+ private static <C extends Comparable<?>> Range<C> generateRange(C freshElement) {
return Range.singleton(freshElement);
}
@Generates
- static <E> Iterable<E> generateIterable(@Nullable E freshElement) {
+ private static <E> Iterable<E> generateIterable(E freshElement) {
return generateList(freshElement);
}
@Generates
- static <E> Collection<E> generateCollection(@Nullable E freshElement) {
+ private static <E> Collection<E> generateCollection(E freshElement) {
return generateList(freshElement);
}
@Generates
- static <E> List<E> generateList(@Nullable E freshElement) {
+ private static <E> List<E> generateList(E freshElement) {
return generateArrayList(freshElement);
}
@Generates
- static <E> ArrayList<E> generateArrayList(@Nullable E freshElement) {
+ private static <E> ArrayList<E> generateArrayList(E freshElement) {
ArrayList<E> list = Lists.newArrayList();
list.add(freshElement);
return list;
}
@Generates
- static <E> LinkedList<E> generateLinkedList(@Nullable E freshElement) {
+ private static <E> LinkedList<E> generateLinkedList(E freshElement) {
LinkedList<E> list = Lists.newLinkedList();
list.add(freshElement);
return list;
}
@Generates
- static <E> ImmutableList<E> generateImmutableList(E freshElement) {
+ private static <E> ImmutableList<E> generateImmutableList(E freshElement) {
return ImmutableList.of(freshElement);
}
@Generates
- static <E> ImmutableCollection<E> generateImmutableCollection(E freshElement) {
+ private static <E> ImmutableCollection<E> generateImmutableCollection(E freshElement) {
return generateImmutableList(freshElement);
}
@Generates
- static <E> Set<E> generateSet(@Nullable E freshElement) {
+ private static <E> Set<E> generateSet(E freshElement) {
return generateHashSet(freshElement);
}
@Generates
- static <E> HashSet<E> generateHashSet(@Nullable E freshElement) {
+ private static <E> HashSet<E> generateHashSet(E freshElement) {
return generateLinkedHashSet(freshElement);
}
@Generates
- static <E> LinkedHashSet<E> generateLinkedHashSet(@Nullable E freshElement) {
+ private static <E> LinkedHashSet<E> generateLinkedHashSet(E freshElement) {
LinkedHashSet<E> set = Sets.newLinkedHashSet();
set.add(freshElement);
return set;
}
@Generates
- static <E> ImmutableSet<E> generateImmutableSet(E freshElement) {
+ private static <E> ImmutableSet<E> generateImmutableSet(E freshElement) {
return ImmutableSet.of(freshElement);
}
@Generates
- static <E extends Comparable<? super E>> SortedSet<E> generateSortedSet(E freshElement) {
+ private static <E extends Comparable<? super E>> SortedSet<E> generateSortedSet(E freshElement) {
return generateNavigableSet(freshElement);
}
@Generates
- static <E extends Comparable<? super E>> NavigableSet<E> generateNavigableSet(E freshElement) {
+ private static <E extends Comparable<? super E>> NavigableSet<E> generateNavigableSet(
+ E freshElement) {
return generateTreeSet(freshElement);
}
@Generates
- static <E extends Comparable<? super E>> TreeSet<E> generateTreeSet(E freshElement) {
+ private static <E extends Comparable<? super E>> TreeSet<E> generateTreeSet(E freshElement) {
TreeSet<E> set = Sets.newTreeSet();
set.add(freshElement);
return set;
}
@Generates
- static <E extends Comparable<? super E>> ImmutableSortedSet<E> generateImmutableSortedSet(
+ private static <E extends Comparable<? super E>> ImmutableSortedSet<E> generateImmutableSortedSet(
E freshElement) {
return ImmutableSortedSet.of(freshElement);
}
@Generates
- static <E> Multiset<E> generateMultiset(@Nullable E freshElement) {
+ private static <E> Multiset<E> generateMultiset(E freshElement) {
return generateHashMultiset(freshElement);
}
@Generates
- static <E> HashMultiset<E> generateHashMultiset(@Nullable E freshElement) {
+ private static <E> HashMultiset<E> generateHashMultiset(E freshElement) {
HashMultiset<E> multiset = HashMultiset.create();
multiset.add(freshElement);
return multiset;
}
@Generates
- static <E> LinkedHashMultiset<E> generateLinkedHashMultiset(@Nullable E freshElement) {
+ private static <E> LinkedHashMultiset<E> generateLinkedHashMultiset(E freshElement) {
LinkedHashMultiset<E> multiset = LinkedHashMultiset.create();
multiset.add(freshElement);
return multiset;
}
@Generates
- static <E> ImmutableMultiset<E> generateImmutableMultiset(E freshElement) {
+ private static <E> ImmutableMultiset<E> generateImmutableMultiset(E freshElement) {
return ImmutableMultiset.of(freshElement);
}
@Generates
- static <E extends Comparable<E>> SortedMultiset<E> generateSortedMultiset(E freshElement) {
+ private static <E extends Comparable<E>> SortedMultiset<E> generateSortedMultiset(
+ E freshElement) {
return generateTreeMultiset(freshElement);
}
@Generates
- static <E extends Comparable<E>> TreeMultiset<E> generateTreeMultiset(E freshElement) {
+ private static <E extends Comparable<E>> TreeMultiset<E> generateTreeMultiset(E freshElement) {
TreeMultiset<E> multiset = TreeMultiset.create();
multiset.add(freshElement);
return multiset;
}
@Generates
- static <E extends Comparable<E>> ImmutableSortedMultiset<E> generateImmutableSortedMultiset(
- E freshElement) {
+ private static <E extends Comparable<E>>
+ ImmutableSortedMultiset<E> generateImmutableSortedMultiset(E freshElement) {
return ImmutableSortedMultiset.of(freshElement);
}
@Generates
- static <K, V> Map<K, V> generateMap(@Nullable K key, @Nullable V value) {
+ private static <K, V> Map<K, V> generateMap(K key, V value) {
return generateHashdMap(key, value);
}
@Generates
- static <K, V> HashMap<K, V> generateHashdMap(@Nullable K key, @Nullable V value) {
+ private static <K, V> HashMap<K, V> generateHashdMap(K key, V value) {
return generateLinkedHashMap(key, value);
}
@Generates
- static <K, V> LinkedHashMap<K, V> generateLinkedHashMap(@Nullable K key, @Nullable V value) {
+ private static <K, V> LinkedHashMap<K, V> generateLinkedHashMap(K key, V value) {
LinkedHashMap<K, V> map = Maps.newLinkedHashMap();
map.put(key, value);
return map;
}
@Generates
- static <K, V> ImmutableMap<K, V> generateImmutableMap(K key, V value) {
+ private static <K, V> ImmutableMap<K, V> generateImmutableMap(K key, V value) {
return ImmutableMap.of(key, value);
}
@Empty
- static <K, V> ConcurrentMap<K, V> generateConcurrentMap() {
+ private static <K, V> ConcurrentMap<K, V> generateConcurrentMap() {
return Maps.newConcurrentMap();
}
@Generates
- static <K, V> ConcurrentMap<K, V> generateConcurrentMap(K key, V value) {
+ private static <K, V> ConcurrentMap<K, V> generateConcurrentMap(K key, V value) {
ConcurrentMap<K, V> map = Maps.newConcurrentMap();
map.put(key, value);
return map;
}
@Generates
- static <K extends Comparable<? super K>, V> SortedMap<K, V> generateSortedMap(
- K key, @Nullable V value) {
+ private static <K extends Comparable<? super K>, V> SortedMap<K, V> generateSortedMap(
+ K key, V value) {
return generateNavigableMap(key, value);
}
@Generates
- static <K extends Comparable<? super K>, V> NavigableMap<K, V> generateNavigableMap(
- K key, @Nullable V value) {
+ private static <K extends Comparable<? super K>, V> NavigableMap<K, V> generateNavigableMap(
+ K key, V value) {
return generateTreeMap(key, value);
}
@Generates
- static <K extends Comparable<? super K>, V> TreeMap<K, V> generateTreeMap(
- K key, @Nullable V value) {
+ private static <K extends Comparable<? super K>, V> TreeMap<K, V> generateTreeMap(
+ K key, V value) {
TreeMap<K, V> map = Maps.newTreeMap();
map.put(key, value);
return map;
}
@Generates
- static <K extends Comparable<? super K>, V> ImmutableSortedMap<K, V> generateImmutableSortedMap(
- K key, V value) {
+ private static <K extends Comparable<? super K>, V>
+ ImmutableSortedMap<K, V> generateImmutableSortedMap(K key, V value) {
return ImmutableSortedMap.of(key, value);
}
@Generates
- static <K, V> Multimap<K, V> generateMultimap(@Nullable K key, @Nullable V value) {
+ private static <K, V> Multimap<K, V> generateMultimap(K key, V value) {
return generateListMultimap(key, value);
}
@Generates
- static <K, V> ImmutableMultimap<K, V> generateImmutableMultimap(K key, V value) {
+ private static <K, V> ImmutableMultimap<K, V> generateImmutableMultimap(K key, V value) {
return ImmutableMultimap.of(key, value);
}
@Generates
- static <K, V> ListMultimap<K, V> generateListMultimap(@Nullable K key, @Nullable V value) {
+ private static <K, V> ListMultimap<K, V> generateListMultimap(K key, V value) {
return generateArrayListMultimap(key, value);
}
@Generates
- static <K, V> ArrayListMultimap<K, V> generateArrayListMultimap(
- @Nullable K key, @Nullable V value) {
+ private static <K, V> ArrayListMultimap<K, V> generateArrayListMultimap(K key, V value) {
ArrayListMultimap<K, V> multimap = ArrayListMultimap.create();
multimap.put(key, value);
return multimap;
}
@Generates
- static <K, V> ImmutableListMultimap<K, V> generateImmutableListMultimap(K key, V value) {
+ private static <K, V> ImmutableListMultimap<K, V> generateImmutableListMultimap(K key, V value) {
return ImmutableListMultimap.of(key, value);
}
@Generates
- static <K, V> SetMultimap<K, V> generateSetMultimap(@Nullable K key, @Nullable V value) {
+ private static <K, V> SetMultimap<K, V> generateSetMultimap(K key, V value) {
return generateLinkedHashMultimap(key, value);
}
@Generates
- static <K, V> HashMultimap<K, V> generateHashMultimap(@Nullable K key, @Nullable V value) {
+ private static <K, V> HashMultimap<K, V> generateHashMultimap(K key, V value) {
HashMultimap<K, V> multimap = HashMultimap.create();
multimap.put(key, value);
return multimap;
}
@Generates
- static <K, V> LinkedHashMultimap<K, V> generateLinkedHashMultimap(
- @Nullable K key, @Nullable V value) {
+ private static <K, V> LinkedHashMultimap<K, V> generateLinkedHashMultimap(K key, V value) {
LinkedHashMultimap<K, V> multimap = LinkedHashMultimap.create();
multimap.put(key, value);
return multimap;
}
@Generates
- static <K, V> ImmutableSetMultimap<K, V> generateImmutableSetMultimap(K key, V value) {
+ private static <K, V> ImmutableSetMultimap<K, V> generateImmutableSetMultimap(K key, V value) {
return ImmutableSetMultimap.of(key, value);
}
@Generates
- static <K, V> BiMap<K, V> generateBimap(@Nullable K key, @Nullable V value) {
+ private static <K, V> BiMap<K, V> generateBimap(K key, V value) {
return generateHashBiMap(key, value);
}
@Generates
- static <K, V> HashBiMap<K, V> generateHashBiMap(@Nullable K key, @Nullable V value) {
+ private static <K, V> HashBiMap<K, V> generateHashBiMap(K key, V value) {
HashBiMap<K, V> bimap = HashBiMap.create();
bimap.put(key, value);
return bimap;
}
@Generates
- static <K, V> ImmutableBiMap<K, V> generateImmutableBimap(K key, V value) {
+ private static <K, V> ImmutableBiMap<K, V> generateImmutableBimap(K key, V value) {
return ImmutableBiMap.of(key, value);
}
@Generates
- static <R, C, V> Table<R, C, V> generateTable(
- @Nullable R row, @Nullable C column, @Nullable V value) {
+ private static <R, C, V> Table<R, C, V> generateTable(R row, C column, V value) {
return generateHashBasedTable(row, column, value);
}
@Generates
- static <R, C, V> HashBasedTable<R, C, V> generateHashBasedTable(
- @Nullable R row, @Nullable C column, @Nullable V value) {
+ private static <R, C, V> HashBasedTable<R, C, V> generateHashBasedTable(
+ R row, C column, V value) {
HashBasedTable<R, C, V> table = HashBasedTable.create();
table.put(row, column, value);
return table;
@@ -945,14 +944,14 @@
@SuppressWarnings("rawtypes") // TreeBasedTable.create() is defined as such
@Generates
- static <R extends Comparable, C extends Comparable, V>
+ private static <R extends Comparable, C extends Comparable, V>
RowSortedTable<R, C, V> generateRowSortedTable(R row, C column, V value) {
return generateTreeBasedTable(row, column, value);
}
@SuppressWarnings("rawtypes") // TreeBasedTable.create() is defined as such
@Generates
- static <R extends Comparable, C extends Comparable, V>
+ private static <R extends Comparable, C extends Comparable, V>
TreeBasedTable<R, C, V> generateTreeBasedTable(R row, C column, V value) {
TreeBasedTable<R, C, V> table = TreeBasedTable.create();
table.put(row, column, value);
@@ -960,84 +959,85 @@
}
@Generates
- static <R, C, V> ImmutableTable<R, C, V> generateImmutableTable(R row, C column, V value) {
+ private static <R, C, V> ImmutableTable<R, C, V> generateImmutableTable(
+ R row, C column, V value) {
return ImmutableTable.of(row, column, value);
}
// common.reflect
@Generates
- TypeToken<?> generateTypeToken() {
+ private TypeToken<?> generateTypeToken() {
return TypeToken.of(generateClass());
}
// io types
@Generates
- File generateFile() {
+ private File generateFile() {
return new File(generateString());
}
@Generates
- static ByteArrayInputStream generateByteArrayInputStream() {
+ private static ByteArrayInputStream generateByteArrayInputStream() {
return new ByteArrayInputStream(new byte[0]);
}
@Generates
- static InputStream generateInputStream() {
+ private static InputStream generateInputStream() {
return generateByteArrayInputStream();
}
@Generates
- StringReader generateStringReader() {
+ private StringReader generateStringReader() {
return new StringReader(generateString());
}
@Generates
- Reader generateReader() {
+ private Reader generateReader() {
return generateStringReader();
}
@Generates
- Readable generateReadable() {
+ private Readable generateReadable() {
return generateReader();
}
@Generates
- Buffer generateBuffer() {
+ private Buffer generateBuffer() {
return generateCharBuffer();
}
@Generates
- CharBuffer generateCharBuffer() {
+ private CharBuffer generateCharBuffer() {
return CharBuffer.allocate(generateInt());
}
@Generates
- ByteBuffer generateByteBuffer() {
+ private ByteBuffer generateByteBuffer() {
return ByteBuffer.allocate(generateInt());
}
@Generates
- ShortBuffer generateShortBuffer() {
+ private ShortBuffer generateShortBuffer() {
return ShortBuffer.allocate(generateInt());
}
@Generates
- IntBuffer generateIntBuffer() {
+ private IntBuffer generateIntBuffer() {
return IntBuffer.allocate(generateInt());
}
@Generates
- LongBuffer generateLongBuffer() {
+ private LongBuffer generateLongBuffer() {
return LongBuffer.allocate(generateInt());
}
@Generates
- FloatBuffer generateFloatBuffer() {
+ private FloatBuffer generateFloatBuffer() {
return FloatBuffer.allocate(generateInt());
}
@Generates
- DoubleBuffer generateDoubleBuffer() {
+ private DoubleBuffer generateDoubleBuffer() {
return DoubleBuffer.allocate(generateInt());
}
}
diff --git a/guava-testlib/src/com/google/common/testing/NullPointerTester.java b/guava-testlib/src/com/google/common/testing/NullPointerTester.java
index 8986d15..cd0dd15 100644
--- a/guava-testlib/src/com/google/common/testing/NullPointerTester.java
+++ b/guava-testlib/src/com/google/common/testing/NullPointerTester.java
@@ -34,7 +34,6 @@
import com.google.common.reflect.Reflection;
import com.google.common.reflect.TypeToken;
import java.lang.annotation.Annotation;
-import java.lang.reflect.AnnotatedType;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Member;
@@ -42,11 +41,9 @@
import java.lang.reflect.Modifier;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
-import java.lang.reflect.TypeVariable;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.ConcurrentMap;
-import java.util.function.Function;
import junit.framework.Assert;
import junit.framework.AssertionFailedError;
import org.checkerframework.checker.nullness.qual.Nullable;
@@ -55,7 +52,7 @@
* A test utility that verifies that your methods and constructors throw {@link
* NullPointerException} or {@link UnsupportedOperationException} whenever null is passed to a
* parameter whose declaration or type isn't annotated with an annotation with the simple name
- * {@code Nullable}, {@code CheckForNull}, {@link NullableType}, or {@link NullableDecl}.
+ * {@code Nullable}, {@lcode CheckForNull}, {@link NullableType}, or {@link NullableDecl}.
*
* <p>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
@@ -476,8 +473,7 @@
}
private static final ImmutableSet<String> NULLABLE_ANNOTATION_SIMPLE_NAMES =
- ImmutableSet.of(
- "CheckForNull", "Nullable", "NullableDecl", "NullableType", "ParametricNullness");
+ ImmutableSet.of("CheckForNull", "Nullable", "NullableDecl", "NullableType");
static boolean isNullable(Invokable<?, ?> invokable) {
return isNullable(invokable.getAnnotatedReturnType().getAnnotations())
@@ -486,24 +482,7 @@
static boolean isNullable(Parameter param) {
return isNullable(param.getAnnotatedType().getAnnotations())
- || isNullable(param.getAnnotations())
- || isNullableTypeVariable(param.getAnnotatedType().getType());
- }
-
- private static boolean isNullableTypeVariable(Type type) {
- if (!(type instanceof TypeVariable)) {
- return false;
- }
- TypeVariable<?> var = (TypeVariable<?>) type;
- AnnotatedType[] bounds = GET_ANNOTATED_BOUNDS.apply(var);
- for (AnnotatedType bound : bounds) {
- // Until Java 15, the isNullableTypeVariable case here won't help:
- // https://bugs.openjdk.java.net/browse/JDK-8202469
- if (isNullable(bound.getAnnotations()) || isNullableTypeVariable(bound.getType())) {
- return true;
- }
- }
- return false;
+ || isNullable(param.getAnnotations());
}
private static boolean isNullable(Annotation[] annotations) {
@@ -515,33 +494,12 @@
return false;
}
- // This is currently required because of j2objc restrictions.
- private static final Function<TypeVariable<?>, AnnotatedType[]> GET_ANNOTATED_BOUNDS =
- initGetAnnotatedBounds();
-
- private static Function<TypeVariable<?>, AnnotatedType[]> initGetAnnotatedBounds() {
- AnnotatedType[] noBounds = new AnnotatedType[0];
- Method getAnnotatedBounds;
- try {
- getAnnotatedBounds = TypeVariable.class.getMethod("getAnnotatedBounds");
- } catch (ReflectiveOperationException e) {
- return v -> noBounds;
- }
- return v -> {
- try {
- return (AnnotatedType[]) getAnnotatedBounds.invoke(v);
- } catch (ReflectiveOperationException e) {
- return noBounds;
- }
- };
- }
-
private boolean isIgnored(Member member) {
return member.isSynthetic() || ignoredMembers.contains(member) || isEquals(member);
}
/**
- * Returns true if the given member is a method that overrides {@link Object#equals(Object)}.
+ * Returns true if the the given member is a method that overrides {@link Object#equals(Object)}.
*
* <p>The documentation for {@link Object#equals} says it should accept null, so don't require an
* explicit {@code @Nullable} annotation (see <a
diff --git a/guava-testlib/src/com/google/common/testing/SerializableTester.java b/guava-testlib/src/com/google/common/testing/SerializableTester.java
index 6298076..65445e5 100644
--- a/guava-testlib/src/com/google/common/testing/SerializableTester.java
+++ b/guava-testlib/src/com/google/common/testing/SerializableTester.java
@@ -29,6 +29,7 @@
* serialization tests require more setup. This no-op behavior allows test authors to intersperse
* {@code SerializableTester} calls with other, GWT-compatible tests.
*
+ *
* @author Mike Bostock
* @since 10.0
*/
diff --git a/guava-testlib/test/com/google/common/collect/testing/MapTestSuiteBuilderTests.java b/guava-testlib/test/com/google/common/collect/testing/MapTestSuiteBuilderTests.java
index 5fd0d03..a7a39cd 100644
--- a/guava-testlib/test/com/google/common/collect/testing/MapTestSuiteBuilderTests.java
+++ b/guava-testlib/test/com/google/common/collect/testing/MapTestSuiteBuilderTests.java
@@ -26,11 +26,6 @@
import com.google.common.collect.testing.features.CollectionSize;
import com.google.common.collect.testing.features.Feature;
import com.google.common.collect.testing.features.MapFeature;
-import com.google.common.reflect.Reflection;
-import java.io.Serializable;
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
import java.util.AbstractMap;
import java.util.AbstractSet;
import java.util.Collection;
@@ -41,7 +36,6 @@
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
-import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.Predicate;
import junit.framework.Test;
import junit.framework.TestCase;
@@ -59,7 +53,6 @@
TestSuite suite = new TestSuite(MapTestSuiteBuilderTests.class.getSimpleName());
suite.addTest(testsForHashMapNullKeysForbidden());
suite.addTest(testsForHashMapNullValuesForbidden());
- suite.addTest(testsForSetUpTearDown());
return suite;
}
@@ -270,89 +263,4 @@
"HashMap w/out null values",
ALLOWS_NULL_KEYS);
}
-
- /**
- * Map generator that verifies that {@code setUp()} methods are called in all the test cases. The
- * {@code setUpRan} parameter is set true by the {@code setUp} that every test case is supposed to
- * have registered, and set false by the {@code tearDown}. We use a dynamic proxy to intercept all
- * of the {@code Map} method calls and check that {@code setUpRan} is true.
- */
- private static class CheckSetUpHashMapGenerator extends WrappedHashMapGenerator {
- private final AtomicBoolean setUpRan;
-
- CheckSetUpHashMapGenerator(AtomicBoolean setUpRan) {
- this.setUpRan = setUpRan;
- }
-
- @Override
- Map<String, String> wrap(HashMap<String, String> map) {
- @SuppressWarnings("unchecked")
- Map<String, String> proxy =
- Reflection.newProxy(Map.class, new CheckSetUpInvocationHandler(map, setUpRan));
- return proxy;
- }
- }
-
- /**
- * Intercepts calls to a {@code Map} to check that {@code setUpRan} is true when they happen. Then
- * forwards the calls to the underlying {@code Map}.
- */
- private static class CheckSetUpInvocationHandler implements InvocationHandler, Serializable {
- private final Map<String, String> map;
- private final AtomicBoolean setUpRan;
-
- CheckSetUpInvocationHandler(Map<String, String> map, AtomicBoolean setUpRan) {
- this.map = map;
- this.setUpRan = setUpRan;
- }
-
- @Override
- public Object invoke(Object target, Method method, Object[] args) throws Throwable {
- assertTrue("setUp should have run", setUpRan.get());
- try {
- return method.invoke(map, args);
- } catch (InvocationTargetException e) {
- throw e.getCause();
- } catch (IllegalAccessException e) {
- throw newLinkageError(e);
- }
- }
- }
-
- /** Verifies that {@code setUp} and {@code tearDown} are called in all map test cases. */
- private static Test testsForSetUpTearDown() {
- final AtomicBoolean setUpRan = new AtomicBoolean();
- Runnable setUp =
- new Runnable() {
- @Override
- public void run() {
- assertFalse("previous tearDown should have run before setUp", setUpRan.getAndSet(true));
- }
- };
- Runnable tearDown =
- new Runnable() {
- @Override
- public void run() {
- assertTrue("setUp should have run", setUpRan.getAndSet(false));
- }
- };
- return MapTestSuiteBuilder.using(new CheckSetUpHashMapGenerator(setUpRan))
- .named("setUpTearDown")
- .withFeatures(
- MapFeature.GENERAL_PURPOSE,
- MapFeature.ALLOWS_NULL_KEYS,
- MapFeature.ALLOWS_NULL_VALUES,
- CollectionFeature.SERIALIZABLE,
- CollectionFeature.SUPPORTS_ITERATOR_REMOVE,
- CollectionSize.ANY)
- .withSetUp(setUp)
- .withTearDown(tearDown)
- .createTestSuite();
- }
-
- private static LinkageError newLinkageError(Throwable cause) {
- LinkageError error = new LinkageError(cause.toString());
- error.initCause(cause);
- return error;
- }
}
diff --git a/guava-testlib/test/com/google/common/testing/FakeTickerTest.java b/guava-testlib/test/com/google/common/testing/FakeTickerTest.java
index 1372b45..09e4a31 100644
--- a/guava-testlib/test/com/google/common/testing/FakeTickerTest.java
+++ b/guava-testlib/test/com/google/common/testing/FakeTickerTest.java
@@ -162,7 +162,7 @@
final CountDownLatch startLatch = new CountDownLatch(numberOfThreads);
final CountDownLatch doneLatch = new CountDownLatch(numberOfThreads);
for (int i = numberOfThreads; i > 0; i--) {
- @SuppressWarnings("unused") // https://errorprone.info/bugpattern/FutureReturnValueIgnored
+ @SuppressWarnings("unused") // go/futurereturn-lsc
Future<?> possiblyIgnoredError =
executorService.submit(
new Callable<Void>() {
diff --git a/guava-testlib/test/com/google/common/testing/NullPointerTesterTest.java b/guava-testlib/test/com/google/common/testing/NullPointerTesterTest.java
index a5a20ec..3c7bf31 100644
--- a/guava-testlib/test/com/google/common/testing/NullPointerTesterTest.java
+++ b/guava-testlib/test/com/google/common/testing/NullPointerTesterTest.java
@@ -54,7 +54,6 @@
* @author Kevin Bourrillion
* @author Mick Killianey
*/
-@SuppressWarnings("CheckReturnValue")
public class NullPointerTesterTest extends TestCase {
/** Non-NPE RuntimeException. */
@@ -1484,47 +1483,4 @@
}
fail("Should detect problem in " + FailOnOneOfTwoConstructors.class.getSimpleName());
}
-
- public static class NullBounds<T extends @Nullable Object, U extends T, X> {
- boolean xWasCalled;
-
- @SuppressWarnings("unused") // Called by reflection
- public void x(X x) {
- xWasCalled = true;
- checkNotNull(x);
- }
-
- @SuppressWarnings("unused") // Called by reflection
- public void t(T t) {
- fail("Method with parameter <T extends @Nullable Object> should not be called");
- }
-
- @SuppressWarnings("unused") // Called by reflection
- public void u(U u) {
- fail(
- "Method with parameter <U extends T> where <T extends @Nullable Object> should not be"
- + " called");
- }
-
- @SuppressWarnings("unused") // Called by reflection
- public <A extends @Nullable Object> void a(A a) {
- fail("Method with parameter <A extends @Nullable Object> should not be called");
- }
-
- @SuppressWarnings("unused") // Called by reflection
- public <A extends B, B extends @Nullable Object> void b(A a) {
- fail(
- "Method with parameter <A extends B> where <B extends @Nullable Object> should not be"
- + " called");
- }
- }
-
- public void testNullBounds() {
- // NullBounds has methods whose parameters are type variables that have
- // "extends @Nullable Object" as a bound. This test ensures that NullPointerTester considers
- // those parameters to be @Nullable, so it won't call the methods.
- NullBounds<?, ?, ?> nullBounds = new NullBounds<>();
- new NullPointerTester().testAllPublicInstanceMethods(nullBounds);
- assertThat(nullBounds.xWasCalled).isTrue();
- }
}
diff --git a/guava-testlib/test/com/google/common/testing/PackageSanityTests.java b/guava-testlib/test/com/google/common/testing/PackageSanityTests.java
index d5483d3..cf446d2 100644
--- a/guava-testlib/test/com/google/common/testing/PackageSanityTests.java
+++ b/guava-testlib/test/com/google/common/testing/PackageSanityTests.java
@@ -16,7 +16,6 @@
package com.google.common.testing;
-
/** Test nulls for the entire package. */
public class PackageSanityTests extends AbstractPackageSanityTests {}
diff --git a/guava-tests/benchmark/com/google/common/base/CharMatcherBenchmark.java b/guava-tests/benchmark/com/google/common/base/CharMatcherBenchmark.java
index 9dee99b..e2ba458 100644
--- a/guava-tests/benchmark/com/google/common/base/CharMatcherBenchmark.java
+++ b/guava-tests/benchmark/com/google/common/base/CharMatcherBenchmark.java
@@ -29,6 +29,7 @@
/**
* Benchmark for the {@link CharMatcher} class.
*
+ *
* @author David Beaumont
* @author Kevin Bourrillion
* @author David Richter
diff --git a/guava-tests/benchmark/com/google/common/base/StringsRepeatBenchmark.java b/guava-tests/benchmark/com/google/common/base/StringsRepeatBenchmark.java
index 16e00ef..30261da 100644
--- a/guava-tests/benchmark/com/google/common/base/StringsRepeatBenchmark.java
+++ b/guava-tests/benchmark/com/google/common/base/StringsRepeatBenchmark.java
@@ -40,7 +40,7 @@
}
@Benchmark
- void oldRepeat(long reps) {
+ void oldRepeat(int reps) {
for (int i = 0; i < reps; i++) {
String x = oldRepeat(originalString, count);
if (x.length() != (originalString.length() * count)) {
@@ -62,7 +62,7 @@
}
@Benchmark
- void mikeRepeat(long reps) {
+ void mikeRepeat(int reps) {
for (int i = 0; i < reps; i++) {
String x = mikeRepeat(originalString, count);
if (x.length() != (originalString.length() * count)) {
@@ -95,7 +95,7 @@
}
@Benchmark
- void martinRepeat(long reps) {
+ void martinRepeat(int reps) {
for (int i = 0; i < reps; i++) {
String x = martinRepeat(originalString, count);
if (x.length() != (originalString.length() * count)) {
diff --git a/guava-tests/benchmark/com/google/common/base/ToStringHelperBenchmark.java b/guava-tests/benchmark/com/google/common/base/ToStringHelperBenchmark.java
index a555fc4..6b33599 100644
--- a/guava-tests/benchmark/com/google/common/base/ToStringHelperBenchmark.java
+++ b/guava-tests/benchmark/com/google/common/base/ToStringHelperBenchmark.java
@@ -18,8 +18,6 @@
import com.google.caliper.Benchmark;
import com.google.caliper.Param;
-import java.util.Arrays;
-import java.util.Collections;
/**
* Some microbenchmarks for the {@link MoreObjects.ToStringHelper} class.
@@ -28,114 +26,33 @@
*/
public class ToStringHelperBenchmark {
- @Param({"0", "1", "5"})
+ @Param({"0", "2", "5", "10"})
int dataSize;
- @Param({"false", "true"})
- boolean omitNulls;
+ private static final String NAME = "abcdefgh";
+ private static final String NAME3 = Strings.repeat(NAME, 3);
- enum Dataset {
- SMALL {
- void addEntries(MoreObjects.ToStringHelper helper) {
- helper
- .add(SHORT_NAME, 10)
- .addValue(10L)
- .add(SHORT_NAME, 3.14f)
- .addValue(3.14d)
- .add(LONG_NAME, false)
- .add(LONG_NAME, LONG_NAME);
- }
- },
- CONDITIONAL {
- void addEntries(MoreObjects.ToStringHelper helper) {
- helper
- .add(SHORT_NAME, "x")
- .add(LONG_NAME, "y")
- .add(SHORT_NAME, null)
- .add(LONG_NAME, null)
- .addValue("z")
- .addValue("")
- .addValue(null)
- .add(SHORT_NAME, Arrays.asList("A"))
- .add(LONG_NAME, Arrays.asList("B"))
- .add(SHORT_NAME, Arrays.asList())
- .add(LONG_NAME, Arrays.asList())
- .addValue(Arrays.asList("C"))
- .addValue(Arrays.asList())
- .add(SHORT_NAME, Collections.singletonMap("k1", "v1"))
- .add(LONG_NAME, Collections.singletonMap("k2", "v2"))
- .addValue(Collections.singletonMap("k3", "v3"))
- .addValue(Collections.emptyMap())
- .addValue(null)
- .add(SHORT_NAME, java.util.Optional.of("1"))
- .add(LONG_NAME, java.util.Optional.of("1"))
- .add(SHORT_NAME, java.util.Optional.empty())
- .add(LONG_NAME, java.util.Optional.empty())
- .add(SHORT_NAME, Optional.of("2"))
- .add(SHORT_NAME, Optional.absent())
- .addValue(null)
- .add(SHORT_NAME, new int[] {1})
- .add(LONG_NAME, new int[] {2})
- .addValue(new int[] {3})
- .addValue(new int[] {})
- .addValue(null);
- }
- },
- UNCONDITIONAL {
- void addEntries(MoreObjects.ToStringHelper helper) {
- helper
- .add(SHORT_NAME, false)
- .add(LONG_NAME, false)
- .addValue(true)
- .add(SHORT_NAME, (byte) 1)
- .add(LONG_NAME, (byte) 2)
- .addValue((byte) 3)
- .add(SHORT_NAME, 'A')
- .add(LONG_NAME, 'B')
- .addValue('C')
- .add(SHORT_NAME, (short) 4)
- .add(LONG_NAME, (short) 5)
- .addValue((short) 6)
- .add(SHORT_NAME, 7)
- .add(LONG_NAME, 8)
- .addValue(9)
- .add(SHORT_NAME, 10L)
- .add(LONG_NAME, 11L)
- .addValue(12L)
- .add(SHORT_NAME, 13.0f)
- .add(LONG_NAME, 14.0f)
- .addValue(15.0f);
- }
- };
-
- void addEntries(MoreObjects.ToStringHelper helper) {}
- }
-
- @Param Dataset dataset;
-
- private static final String SHORT_NAME = "userId";
- private static final String LONG_NAME = "fluxCapacitorFailureRate95Percentile";
-
- private MoreObjects.ToStringHelper newHelper() {
- MoreObjects.ToStringHelper helper = MoreObjects.toStringHelper("klass");
- if (omitNulls) {
- helper = helper.omitNullValues();
- }
- return helper;
+ private static void addEntries(MoreObjects.ToStringHelper helper) {
+ helper
+ .add(NAME, 10)
+ .addValue(10L)
+ .add(NAME, 3.14f)
+ .addValue(3.14d)
+ .add(NAME3, false)
+ .add(NAME3, NAME3)
+ .add(NAME3, 'x');
}
@Benchmark
int toString(int reps) {
int dummy = 0;
for (int i = 0; i < reps; i++) {
- MoreObjects.ToStringHelper helper = newHelper();
+ MoreObjects.ToStringHelper helper = MoreObjects.toStringHelper("klass").omitNullValues();
for (int j = 0; j < dataSize; ++j) {
- dataset.addEntries(helper);
+ addEntries(helper);
}
dummy ^= helper.toString().hashCode();
}
return dummy;
}
-
- // When omitEmptyValues() is released, remove this method and add a new @Param "omitEmptyValues".
}
diff --git a/guava-tests/benchmark/com/google/common/collect/ImmutableSetHashFloodingDetectionBenchmark.java b/guava-tests/benchmark/com/google/common/collect/ImmutableSetHashFloodingDetectionBenchmark.java
index 9e43bb7..9e45916 100644
--- a/guava-tests/benchmark/com/google/common/collect/ImmutableSetHashFloodingDetectionBenchmark.java
+++ b/guava-tests/benchmark/com/google/common/collect/ImmutableSetHashFloodingDetectionBenchmark.java
@@ -140,50 +140,6 @@
}
return false;
}
- },
- SKIPPING {
- int maxRunBeforeFallback(int tableSize) {
- return 13 * IntMath.log2(tableSize, RoundingMode.UNNECESSARY);
- }
-
- @Override
- boolean hashFloodingDetected(Object[] hashTable) {
- int maxRunBeforeFallback = maxRunBeforeFallback(hashTable.length);
- int mask = hashTable.length - 1;
-
- // Invariant: all elements at indices in [knownRunStart, knownRunEnd) are nonnull.
- // If knownRunStart == knownRunEnd, this is vacuously true.
- // When knownRunEnd exceeds hashTable.length, it "wraps", detecting runs around the end
- // of the table.
- int knownRunStart = 0;
- int knownRunEnd = 0;
-
- outerLoop:
- while (knownRunStart < hashTable.length) {
- if (knownRunStart == knownRunEnd && hashTable[knownRunStart] == null) {
- if (hashTable[(knownRunStart + maxRunBeforeFallback - 1) & mask] == null) {
- // There are only maxRunBeforeFallback - 1 elements between here and there,
- // so even if they were all nonnull, we wouldn't detect a hash flood. Therefore,
- // we can skip them all.
- knownRunStart += maxRunBeforeFallback;
- } else {
- knownRunStart++; // the only case in which maxRunEnd doesn't increase by mRBF
- // happens about f * (1-f) for f = DESIRED_LOAD_FACTOR, so around 21% of the time
- }
- knownRunEnd = knownRunStart;
- } else {
- for (int j = knownRunStart + maxRunBeforeFallback - 1; j >= knownRunEnd; j--) {
- if (hashTable[j & mask] == null) {
- knownRunEnd = knownRunStart + maxRunBeforeFallback;
- knownRunStart = j + 1;
- continue outerLoop;
- }
- }
- return true;
- }
- }
- return false;
- }
};
abstract boolean hashFloodingDetected(Object[] array);
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 ed27840..02db8fd 100644
--- a/guava-tests/benchmark/com/google/common/util/concurrent/ExecutionListBenchmark.java
+++ b/guava-tests/benchmark/com/google/common/util/concurrent/ExecutionListBenchmark.java
@@ -252,7 +252,7 @@
final AtomicInteger integer = new AtomicInteger();
// Execute a bunch of tasks to ensure that our threads are allocated and hot
for (int i = 0; i < NUM_THREADS * 10; i++) {
- @SuppressWarnings("unused") // https://errorprone.info/bugpattern/FutureReturnValueIgnored
+ @SuppressWarnings("unused") // go/futurereturn-lsc
Future<?> possiblyIgnoredError =
executorService.submit(
new Runnable() {
@@ -334,10 +334,10 @@
list = impl.newExecutionList();
listenerLatch = new CountDownLatch(numListeners * NUM_THREADS);
for (int j = 0; j < NUM_THREADS; j++) {
- @SuppressWarnings("unused") // https://errorprone.info/bugpattern/FutureReturnValueIgnored
+ @SuppressWarnings("unused") // go/futurereturn-lsc
Future<?> possiblyIgnoredError = executorService.submit(addTask);
}
- @SuppressWarnings("unused") // https://errorprone.info/bugpattern/FutureReturnValueIgnored
+ @SuppressWarnings("unused") // go/futurereturn-lsc
Future<?> possiblyIgnoredError = executorService.submit(executeTask);
returnValue += (int) listenerLatch.getCount();
listenerLatch.await();
@@ -360,10 +360,10 @@
for (int i = 0; i < reps; i++) {
list = impl.newExecutionList();
listenerLatch = new CountDownLatch(numListeners * NUM_THREADS);
- @SuppressWarnings("unused") // https://errorprone.info/bugpattern/FutureReturnValueIgnored
+ @SuppressWarnings("unused") // go/futurereturn-lsc
Future<?> possiblyIgnoredError = executorService.submit(executeTask);
for (int j = 0; j < NUM_THREADS; j++) {
- @SuppressWarnings("unused") // https://errorprone.info/bugpattern/FutureReturnValueIgnored
+ @SuppressWarnings("unused") // go/futurereturn-lsc
Future<?> possiblyIgnoredError1 = executorService.submit(addTask);
}
returnValue += (int) listenerLatch.getCount();
diff --git a/guava-tests/benchmark/com/google/common/util/concurrent/FuturesGetCheckedBenchmark.java b/guava-tests/benchmark/com/google/common/util/concurrent/FuturesGetCheckedBenchmark.java
index c25a8ff..dd1883b 100644
--- a/guava-tests/benchmark/com/google/common/util/concurrent/FuturesGetCheckedBenchmark.java
+++ b/guava-tests/benchmark/com/google/common/util/concurrent/FuturesGetCheckedBenchmark.java
@@ -52,8 +52,7 @@
NON_CACHING_WITH_CONSTRUCTOR_CHECK(nonCachingWithConstructorCheckValidator()),
NON_CACHING_WITHOUT_CONSTRUCTOR_CHECK(nonCachingWithoutConstructorCheckValidator()),
WEAK_SET(weakSetValidator()),
- CLASS_VALUE(classValueValidator()),
- ;
+ CLASS_VALUE(classValueValidator());
final GetCheckedTypeValidator validator;
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 dafb39b..c1e5201 100644
--- a/guava-tests/benchmark/com/google/common/util/concurrent/MonitorBasedArrayBlockingQueue.java
+++ b/guava-tests/benchmark/com/google/common/util/concurrent/MonitorBasedArrayBlockingQueue.java
@@ -36,12 +36,12 @@
*
* <p>This is a classic "bounded buffer", in which a fixed-sized array holds elements
* inserted by producers and extracted by consumers. Once created, the capacity cannot be increased.
- * Attempts to {@code put} an element into a full queue will result in the operation blocking;
- * attempts to {@code take} an element from an empty queue will similarly block.
+ * Attempts to <tt>put</tt> an element into a full queue will result in the operation blocking;
+ * attempts to <tt>take</tt> an element from an empty queue will similarly block.
*
* <p>This class supports an optional fairness policy for ordering waiting producer and consumer
* threads. By default, this ordering is not guaranteed. However, a queue constructed with fairness
- * set to {@code true} grants threads access in FIFO order. Fairness generally decreases throughput
+ * set to <tt>true</tt> grants threads access in FIFO order. Fairness generally decreases throughput
* but reduces variability and avoids starvation.
*
* <p>This class and its iterator implement all of the <em>optional</em> methods of the {@link
@@ -139,24 +139,24 @@
}
/**
- * Creates an {@code MonitorBasedArrayBlockingQueue} with the given (fixed) capacity and default
+ * Creates an <tt>MonitorBasedArrayBlockingQueue</tt> with the given (fixed) capacity and default
* access policy.
*
* @param capacity the capacity of this queue
- * @throws IllegalArgumentException if {@code capacity} is less than 1
+ * @throws IllegalArgumentException if <tt>capacity</tt> is less than 1
*/
public MonitorBasedArrayBlockingQueue(int capacity) {
this(capacity, false);
}
/**
- * Creates an {@code MonitorBasedArrayBlockingQueue} with the given (fixed) capacity and the
+ * Creates an <tt>MonitorBasedArrayBlockingQueue</tt> with the given (fixed) capacity and the
* specified access policy.
*
* @param capacity the capacity of this queue
- * @param fair if {@code true} then queue accesses for threads blocked on insertion or removal,
- * are processed in FIFO order; if {@code false} the access order is unspecified.
- * @throws IllegalArgumentException if {@code capacity} is less than 1
+ * @param fair if <tt>true</tt> then queue accesses for threads blocked on insertion or removal,
+ * are processed in FIFO order; if <tt>false</tt> the access order is unspecified.
+ * @throws IllegalArgumentException if <tt>capacity</tt> is less than 1
*/
public MonitorBasedArrayBlockingQueue(int capacity, boolean fair) {
if (capacity <= 0) throw new IllegalArgumentException();
@@ -179,15 +179,15 @@
}
/**
- * Creates an {@code MonitorBasedArrayBlockingQueue} with the given (fixed) capacity, the
+ * Creates an <tt>MonitorBasedArrayBlockingQueue</tt> with the given (fixed) capacity, the
* specified access policy and initially containing the elements of the given collection, added in
* traversal order of the collection's iterator.
*
* @param capacity the capacity of this queue
- * @param fair if {@code true} then queue accesses for threads blocked on insertion or removal,
- * are processed in FIFO order; if {@code false} the access order is unspecified.
+ * @param fair if <tt>true</tt> then queue accesses for threads blocked on insertion or removal,
+ * are processed in FIFO order; if <tt>false</tt> the access order is unspecified.
* @param c the collection of elements to initially contain
- * @throws IllegalArgumentException if {@code capacity} is less than {@code c.size()}, or less
+ * @throws IllegalArgumentException if <tt>capacity</tt> is less than <tt>c.size()</tt>, or less
* than 1.
* @throws NullPointerException if the specified collection or any of its elements are null
*/
@@ -205,11 +205,11 @@
/**
* Inserts the specified element at the tail of this queue if it is possible to do so immediately
- * without exceeding the queue's capacity, returning {@code true} upon success and throwing an
- * {@code IllegalStateException} if this queue is full.
+ * without exceeding the queue's capacity, returning <tt>true</tt> upon success and throwing an
+ * <tt>IllegalStateException</tt> if this queue is full.
*
* @param e the element to add
- * @return {@code true} (as specified by {@link Collection#add})
+ * @return <tt>true</tt> (as specified by {@link Collection#add})
* @throws IllegalStateException if this queue is full
* @throws NullPointerException if the specified element is null
*/
@@ -220,7 +220,7 @@
/**
* Inserts the specified element at the tail of this queue if it is possible to do so immediately
- * without exceeding the queue's capacity, returning {@code true} upon success and {@code false}
+ * without exceeding the queue's capacity, returning <tt>true</tt> upon success and <tt>false</tt>
* if this queue is full. This method is generally preferable to method {@link #add}, which can
* fail to insert an element only by throwing an exception.
*
@@ -361,11 +361,11 @@
/**
* Returns the number of additional elements that this queue can ideally (in the absence of memory
* or resource constraints) accept without blocking. This is always equal to the initial capacity
- * of this queue less the current {@code size} of this queue.
+ * of this queue less the current <tt>size</tt> of this queue.
*
* <p>Note that you <em>cannot</em> always tell if an attempt to insert an element will succeed by
- * inspecting {@code remainingCapacity} because it may be the case that another thread is about to
- * insert or remove an element.
+ * inspecting <tt>remainingCapacity</tt> because it may be the case that another thread is about
+ * to insert or remove an element.
*/
@Override
public int remainingCapacity() {
@@ -380,12 +380,12 @@
/**
* Removes a single instance of the specified element from this queue, if it is present. More
- * formally, removes an element {@code e} such that {@code o.equals(e)}, if this queue contains
- * one or more such elements. Returns {@code true} if this queue contained the specified element
+ * formally, removes an element <tt>e</tt> such that <tt>o.equals(e)</tt>, if this queue contains
+ * one or more such elements. Returns <tt>true</tt> if this queue contained the specified element
* (or equivalently, if this queue changed as a result of the call).
*
* @param o element to be removed from this queue, if present
- * @return {@code true} if this queue changed as a result of the call
+ * @return <tt>true</tt> if this queue changed as a result of the call
*/
@Override
public boolean remove(@Nullable Object o) {
@@ -410,12 +410,12 @@
}
/**
- * Returns {@code true} if this queue contains the specified element. More formally, returns
- * {@code true} if and only if this queue contains at least one element {@code e} such that {@code
- * o.equals(e)}.
+ * Returns <tt>true</tt> if this queue contains the specified element. More formally, returns
+ * <tt>true</tt> if and only if this queue contains at least one element <tt>e</tt> such that
+ * <tt>o.equals(e)</tt>.
*
* @param o object to be checked for containment in this queue
- * @return {@code true} if this queue contains the specified element
+ * @return <tt>true</tt> if this queue contains the specified element
*/
@Override
public boolean contains(@Nullable Object o) {
@@ -474,19 +474,19 @@
*
* <p>If this queue fits in the specified array with room to spare (i.e., the array has more
* elements than this queue), the element in the array immediately following the end of the queue
- * is set to {@code null}.
+ * is set to <tt>null</tt>.
*
* <p>Like the {@link #toArray()} method, this method acts as bridge between array-based and
* collection-based APIs. Further, this method allows precise control over the runtime type of the
* output array, and may, under certain circumstances, be used to save allocation costs.
*
- * <p>Suppose {@code x} is a queue known to contain only strings. The following code can be used
- * to dump the queue into a newly allocated array of {@code String}:
+ * <p>Suppose <tt>x</tt> is a queue known to contain only strings. The following code can be used
+ * to dump the queue into a newly allocated array of <tt>String</tt>:
*
* <pre>
* String[] y = x.toArray(new String[0]);</pre>
*
- * <p>Note that {@code toArray(new Object[0])} is identical in function to {@code toArray()}.
+ * <p>Note that <tt>toArray(new Object[0])</tt> is identical in function to <tt>toArray()</tt>.
*
* @param a the array into which the elements of the queue are to be stored, if it is big enough;
* otherwise, a new array of the same runtime type is allocated for this purpose
@@ -626,8 +626,8 @@
}
/**
- * Returns an iterator over the elements in this queue in proper sequence. The returned {@code
- * Iterator} is a "weakly consistent" iterator that will never throw {@link
+ * Returns an iterator over the elements in this queue in proper sequence. The returned
+ * <tt>Iterator</tt> is a "weakly consistent" iterator that will never throw {@link
* ConcurrentModificationException}, and guarantees to traverse elements as they existed upon
* construction of the iterator, and may (but is not guaranteed to) reflect any modifications
* subsequent to construction.
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 16b648b..6e06346 100644
--- a/guava-tests/benchmark/com/google/common/util/concurrent/MonitorBasedPriorityBlockingQueue.java
+++ b/guava-tests/benchmark/com/google/common/util/concurrent/MonitorBasedPriorityBlockingQueue.java
@@ -35,23 +35,23 @@
/**
* An unbounded {@linkplain BlockingQueue blocking queue} that uses the same ordering rules as class
* {@link PriorityQueue} and supplies blocking retrieval operations. While this queue is logically
- * unbounded, attempted additions may fail due to resource exhaustion (causing {@code
- * OutOfMemoryError}). This class does not permit {@code null} elements. A priority queue relying on
- * {@linkplain Comparable natural ordering} also does not permit insertion of non-comparable objects
- * (doing so results in {@code ClassCastException}).
+ * unbounded, attempted additions may fail due to resource exhaustion (causing
+ * <tt>OutOfMemoryError</tt>). This class does not permit <tt>null</tt> elements. A priority queue
+ * relying on {@linkplain Comparable natural ordering} also does not permit insertion of
+ * non-comparable objects (doing so results in <tt>ClassCastException</tt>).
*
* <p>This class and its iterator implement all of the <em>optional</em> methods of the {@link
* Collection} and {@link Iterator} interfaces. The Iterator provided in method {@link #iterator()}
* is <em>not</em> guaranteed to traverse the elements of the MonitorBasedPriorityBlockingQueue in
- * any particular order. If you need ordered traversal, consider using {@code
- * Arrays.sort(pq.toArray())}. Also, method {@code drainTo} can be used to <em>remove</em> some or
- * all elements in priority order and place them in another collection.
+ * any particular order. If you need ordered traversal, consider using
+ * <tt>Arrays.sort(pq.toArray())</tt>. Also, method <tt>drainTo</tt> can be used to <em>remove</em>
+ * some or all elements in priority order and place them in another collection.
*
* <p>Operations on this class make no guarantees about the ordering of elements with equal
* priority. If you need to enforce an ordering, you can define custom classes or comparators that
* use a secondary key to break ties in primary priority values. For example, here is a class that
* applies first-in-first-out tie-breaking to comparable elements. To use it, you would insert a
- * {@code new FIFOEntry(anEntry)} instead of a plain entry object.
+ * <tt>new FIFOEntry(anEntry)</tt> instead of a plain entry object.
*
* <pre>
* class FIFOEntry<E extends Comparable<? super E>>
@@ -96,32 +96,32 @@
};
/**
- * Creates a {@code MonitorBasedPriorityBlockingQueue} with the default initial capacity (11) that
- * orders its elements according to their {@linkplain Comparable natural ordering}.
+ * Creates a <tt>MonitorBasedPriorityBlockingQueue</tt> with the default initial capacity (11)
+ * that orders its elements according to their {@linkplain Comparable natural ordering}.
*/
public MonitorBasedPriorityBlockingQueue() {
q = new PriorityQueue<E>();
}
/**
- * Creates a {@code MonitorBasedPriorityBlockingQueue} with the specified initial capacity that
+ * Creates a <tt>MonitorBasedPriorityBlockingQueue</tt> with the specified initial capacity that
* orders its elements according to their {@linkplain Comparable natural ordering}.
*
* @param initialCapacity the initial capacity for this priority queue
- * @throws IllegalArgumentException if {@code initialCapacity} is less than 1
+ * @throws IllegalArgumentException if <tt>initialCapacity</tt> is less than 1
*/
public MonitorBasedPriorityBlockingQueue(int initialCapacity) {
q = new PriorityQueue<E>(initialCapacity, null);
}
/**
- * Creates a {@code MonitorBasedPriorityBlockingQueue} with the specified initial capacity that
+ * Creates a <tt>MonitorBasedPriorityBlockingQueue</tt> with the specified initial capacity that
* orders its elements according to the specified comparator.
*
* @param initialCapacity the initial capacity for this priority queue
* @param comparator the comparator that will be used to order this priority queue. If {@code
* null}, the {@linkplain Comparable natural ordering} of the elements will be used.
- * @throws IllegalArgumentException if {@code initialCapacity} is less than 1
+ * @throws IllegalArgumentException if <tt>initialCapacity</tt> is less than 1
*/
public MonitorBasedPriorityBlockingQueue(
int initialCapacity, @Nullable Comparator<? super E> comparator) {
@@ -129,7 +129,7 @@
}
/**
- * Creates a {@code MonitorBasedPriorityBlockingQueue} containing the elements in the specified
+ * Creates a <tt>MonitorBasedPriorityBlockingQueue</tt> containing the elements in the specified
* collection. If the specified collection is a {@link SortedSet} or a {@link PriorityQueue}, this
* priority queue will be ordered according to the same ordering. Otherwise, this priority queue
* will be ordered according to the {@linkplain Comparable natural ordering} of its elements.
@@ -147,7 +147,7 @@
* Inserts the specified element into this priority queue.
*
* @param e the element to add
- * @return {@code true} (as specified by {@link Collection#add})
+ * @return <tt>true</tt> (as specified by {@link Collection#add})
* @throws ClassCastException if the specified element cannot be compared with elements currently
* in the priority queue according to the priority queue's ordering
* @throws NullPointerException if the specified element is null
@@ -161,7 +161,7 @@
* Inserts the specified element into this priority queue.
*
* @param e the element to add
- * @return {@code true} (as specified by {@link Queue#offer})
+ * @return <tt>true</tt> (as specified by {@link Queue#offer})
* @throws ClassCastException if the specified element cannot be compared with elements currently
* in the priority queue according to the priority queue's ordering
* @throws NullPointerException if the specified element is null
@@ -188,7 +188,7 @@
* @param e the element to add
* @param timeout This parameter is ignored as the method never blocks
* @param unit This parameter is ignored as the method never blocks
- * @return {@code true}
+ * @return <tt>true</tt>
* @throws ClassCastException if the specified element cannot be compared with elements currently
* in the priority queue according to the priority queue's ordering
* @throws NullPointerException if the specified element is null
@@ -261,10 +261,10 @@
}
/**
- * Returns the comparator used to order the elements in this queue, or {@code null} if this queue
+ * Returns the comparator used to order the elements in this queue, or <tt>null</tt> if this queue
* uses the {@linkplain Comparable natural ordering} of its elements.
*
- * @return the comparator used to order the elements in this queue, or {@code null} if this queue
+ * @return the comparator used to order the elements in this queue, or <tt>null</tt> if this queue
* uses the natural ordering of its elements
*/
public Comparator<? super E> comparator() {
@@ -283,10 +283,10 @@
}
/**
- * Always returns {@code Integer.MAX_VALUE} because a {@code MonitorBasedPriorityBlockingQueue} is
- * not capacity constrained.
+ * Always returns <tt>Integer.MAX_VALUE</tt> because a <tt>MonitorBasedPriorityBlockingQueue</tt>
+ * is not capacity constrained.
*
- * @return {@code Integer.MAX_VALUE}
+ * @return <tt>Integer.MAX_VALUE</tt>
*/
@Override
public int remainingCapacity() {
@@ -300,7 +300,7 @@
* specified element (or equivalently, if this queue changed as a result of the call).
*
* @param o element to be removed from this queue, if present
- * @return {@code true} if this queue changed as a result of the call
+ * @return <tt>true</tt> if this queue changed as a result of the call
*/
@Override
public boolean remove(@Nullable Object o) {
@@ -319,7 +319,7 @@
* o.equals(e)}.
*
* @param o object to be checked for containment in this queue
- * @return {@code true} if this queue contains the specified element
+ * @return <tt>true</tt> if this queue contains the specified element
*/
@Override
public boolean contains(@Nullable Object o) {
@@ -363,19 +363,19 @@
*
* <p>If this queue fits in the specified array with room to spare (i.e., the array has more
* elements than this queue), the element in the array immediately following the end of the queue
- * is set to {@code null}.
+ * is set to <tt>null</tt>.
*
* <p>Like the {@link #toArray()} method, this method acts as bridge between array-based and
* collection-based APIs. Further, this method allows precise control over the runtime type of the
* output array, and may, under certain circumstances, be used to save allocation costs.
*
- * <p>Suppose {@code x} is a queue known to contain only strings. The following code can be used
- * to dump the queue into a newly allocated array of {@code String}:
+ * <p>Suppose <tt>x</tt> is a queue known to contain only strings. The following code can be used
+ * to dump the queue into a newly allocated array of <tt>String</tt>:
*
* <pre>
* String[] y = x.toArray(new String[0]);</pre>
*
- * <p>Note that {@code toArray(new Object[0])} is identical in function to {@code toArray()}.
+ * <p>Note that <tt>toArray(new Object[0])</tt> is identical in function to <tt>toArray()</tt>.
*
* @param a the array into which the elements of the queue are to be stored, if it is big enough;
* otherwise, a new array of the same runtime type is allocated for this purpose
@@ -474,7 +474,7 @@
/**
* Returns an iterator over the elements in this queue. The iterator does not return the elements
- * in any particular order. The returned {@code Iterator} is a "weakly consistent" iterator that
+ * in any particular order. The returned <tt>Iterator</tt> is a "weakly consistent" iterator that
* will never throw {@link ConcurrentModificationException}, and guarantees to traverse elements
* as they existed upon construction of the iterator, and may (but is not guaranteed to) reflect
* any modifications subsequent to construction.
diff --git a/guava-tests/pom.xml b/guava-tests/pom.xml
index a40b092..bff476b 100644
--- a/guava-tests/pom.xml
+++ b/guava-tests/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>com.google.guava</groupId>
<artifactId>guava-parent</artifactId>
- <version>31.0.1-jre</version>
+ <version>30.0-jre</version>
</parent>
<artifactId>guava-tests</artifactId>
<name>Guava Unit Tests</name>
@@ -106,9 +106,6 @@
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>animal-sniffer-maven-plugin</artifactId>
- <configuration>
- <checkTestClasses>false</checkTestClasses> <!-- TODO(cpovirk): Consider checking them. -->
- </configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
diff --git a/guava-tests/test/com/google/common/base/AbstractIteratorTest.java b/guava-tests/test/com/google/common/base/AbstractIteratorTest.java
index da732bf..e8f8b93 100644
--- a/guava-tests/test/com/google/common/base/AbstractIteratorTest.java
+++ b/guava-tests/test/com/google/common/base/AbstractIteratorTest.java
@@ -171,7 +171,6 @@
}
}
-
@GwtIncompatible // weak references
public void testFreesNextReference() {
Iterator<Object> itr =
diff --git a/guava-tests/test/com/google/common/base/AndroidIncompatible.java b/guava-tests/test/com/google/common/base/AndroidIncompatible.java
index 5e190a3..e3a250d 100644
--- a/guava-tests/test/com/google/common/base/AndroidIncompatible.java
+++ b/guava-tests/test/com/google/common/base/AndroidIncompatible.java
@@ -32,6 +32,7 @@
* Google-internal Android suite generators. Note that those generators also suppress any test
* annotated with MediumTest or LargeTest.
*
+ *
* <p>Why use a custom annotation instead of {@code android.test.suitebuilder.annotation.Suppress}?
* I'm not completely sure that this is the right choice, but it has various advantages:
*
diff --git a/guava-tests/test/com/google/common/base/EnumsTest.java b/guava-tests/test/com/google/common/base/EnumsTest.java
index d8b13af..413f308 100644
--- a/guava-tests/test/com/google/common/base/EnumsTest.java
+++ b/guava-tests/test/com/google/common/base/EnumsTest.java
@@ -79,7 +79,6 @@
assertThat(Enums.getIfPresent(TestEnum.class, "WOMBAT")).isAbsent();
}
-
@GwtIncompatible // weak references
public void testGetIfPresent_doesNotPreventClassUnloading() throws Exception {
WeakReference<?> shadowLoaderReference = doTestClassUnloading();
diff --git a/guava-tests/test/com/google/common/base/FinalizableReferenceQueueClassLoaderUnloadingTest.java b/guava-tests/test/com/google/common/base/FinalizableReferenceQueueClassLoaderUnloadingTest.java
index ae35c16..453b23c 100644
--- a/guava-tests/test/com/google/common/base/FinalizableReferenceQueueClassLoaderUnloadingTest.java
+++ b/guava-tests/test/com/google/common/base/FinalizableReferenceQueueClassLoaderUnloadingTest.java
@@ -47,7 +47,6 @@
* @author Eamonn McManus
*/
-
public class FinalizableReferenceQueueClassLoaderUnloadingTest extends TestCase {
/*
@@ -111,8 +110,7 @@
// Now make a parallel FRQ and an associated FinalizableWeakReference to an object, in order to
// exercise some classes from the parallel ClassLoader.
- AtomicReference<Object> sepFrqA =
- new AtomicReference<Object>(sepFrqC.getDeclaredConstructor().newInstance());
+ AtomicReference<Object> sepFrqA = new AtomicReference<Object>(sepFrqC.newInstance());
Class<?> sepFwrC = sepLoader.loadClass(MyFinalizableWeakReference.class.getName());
Constructor<?> sepFwrCons = sepFwrC.getConstructor(Object.class, sepFrqC);
// The object that we will wrap in FinalizableWeakReference is a Stopwatch.
@@ -242,7 +240,7 @@
assertNotSame(frqUserC, sepFrqUserC);
assertSame(sepLoader, sepFrqUserC.getClassLoader());
- Callable<?> sepFrqUser = (Callable<?>) sepFrqUserC.getDeclaredConstructor().newInstance();
+ Callable<?> sepFrqUser = (Callable<?>) sepFrqUserC.newInstance();
WeakReference<?> finalizableWeakReference = (WeakReference<?>) sepFrqUser.call();
GcFinalization.awaitClear(finalizableWeakReference);
diff --git a/guava-tests/test/com/google/common/base/FinalizableReferenceQueueTest.java b/guava-tests/test/com/google/common/base/FinalizableReferenceQueueTest.java
index 3b5fd1d..b8af398 100644
--- a/guava-tests/test/com/google/common/base/FinalizableReferenceQueueTest.java
+++ b/guava-tests/test/com/google/common/base/FinalizableReferenceQueueTest.java
@@ -40,7 +40,6 @@
frq = null;
}
-
public void testFinalizeReferentCalled() {
final MockReference reference = new MockReference(frq = new FinalizableReferenceQueue());
@@ -73,7 +72,6 @@
*/
private WeakReference<ReferenceQueue<Object>> queueReference;
-
public void testThatFinalizerStops() {
weaklyReferenceQueue();
GcFinalization.awaitClear(queueReference);
diff --git a/guava-tests/test/com/google/common/base/OptionalTest.java b/guava-tests/test/com/google/common/base/OptionalTest.java
index f8d8333..db7a9e3 100644
--- a/guava-tests/test/com/google/common/base/OptionalTest.java
+++ b/guava-tests/test/com/google/common/base/OptionalTest.java
@@ -85,7 +85,6 @@
assertFalse(Optional.absent().isPresent());
}
- @SuppressWarnings("OptionalOfRedundantMethod") // Unit tests for Optional
public void testIsPresent_yes() {
assertTrue(Optional.of("training").isPresent());
}
@@ -103,7 +102,6 @@
assertEquals("training", Optional.of("training").get());
}
- @SuppressWarnings("OptionalOfRedundantMethod") // Unit tests for Optional
public void testOr_T_present() {
assertEquals("a", Optional.of("a").or("default"));
}
@@ -112,7 +110,6 @@
assertEquals("default", Optional.absent().or("default"));
}
- @SuppressWarnings("OptionalOfRedundantMethod") // Unit tests for Optional
public void testOr_supplier_present() {
assertEquals("a", Optional.of("a").or(Suppliers.ofInstance("fallback")));
}
@@ -131,13 +128,11 @@
}
}
- @SuppressWarnings("OptionalOfRedundantMethod") // Unit tests for Optional
public void testOr_nullSupplier_present() {
Supplier<String> nullSupplier = Suppliers.ofInstance(null);
assertEquals("a", Optional.of("a").or(nullSupplier));
}
- @SuppressWarnings("OptionalOfRedundantMethod") // Unit tests for Optional
public void testOr_Optional_present() {
assertEquals(Optional.of("a"), Optional.of("a").or(Optional.of("fallback")));
}
@@ -146,7 +141,6 @@
assertEquals(Optional.of("fallback"), Optional.absent().or(Optional.of("fallback")));
}
- @SuppressWarnings("OptionalOfRedundantMethod") // Unit tests for Optional
public void testOrNull_present() {
assertEquals("a", Optional.of("a").orNull());
}
diff --git a/guava-tests/test/com/google/common/base/PreconditionsTest.java b/guava-tests/test/com/google/common/base/PreconditionsTest.java
index 1add44d..072649f 100644
--- a/guava-tests/test/com/google/common/base/PreconditionsTest.java
+++ b/guava-tests/test/com/google/common/base/PreconditionsTest.java
@@ -24,6 +24,7 @@
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Lists;
import com.google.common.testing.ArbitraryInstances;
+import com.google.common.testing.NullPointerTester;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
@@ -538,22 +539,8 @@
@GwtIncompatible // NullPointerTester
public void testNullPointers() {
- /*
- * Don't bother testing: Preconditions defines a bunch of methods that accept a template (or
- * even entire message) that simultaneously:
- *
- * - _shouldn't_ be null, so we don't annotate it with @Nullable
- *
- * - _can_ be null without causing a runtime failure (because we don't want the interesting
- * details of precondition failure to be hidden by an exception we throw about an unexpectedly
- * null _failure message_)
- *
- * That combination upsets NullPointerTester, which wants any call that passes null for a
- * non-@Nullable parameter to trigger a NullPointerException.
- *
- * (We still define this empty method to keep PackageSanityTests from generating its own
- * automated nullness tests, which would fail.)
- */
+ NullPointerTester tester = new NullPointerTester();
+ tester.testAllPublicStaticMethods(Preconditions.class);
}
private static final Object IGNORE_ME =
diff --git a/guava-tests/test/com/google/common/base/StopwatchJavaTimeTest.java b/guava-tests/test/com/google/common/base/StopwatchJavaTimeTest.java
deleted file mode 100644
index 35fd5b1..0000000
--- a/guava-tests/test/com/google/common/base/StopwatchJavaTimeTest.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (C) 2008 The Guava Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.common.base;
-
-import com.google.common.annotations.GwtIncompatible;
-import com.google.common.testing.FakeTicker;
-import java.time.Duration;
-import junit.framework.TestCase;
-
-/** Unit test for the {@code java.time} support in {@link Stopwatch}. */
-@GwtIncompatible
-public class StopwatchJavaTimeTest extends TestCase {
- private final FakeTicker ticker = new FakeTicker();
- private final Stopwatch stopwatch = new Stopwatch(ticker);
-
- public void testElapsed_duration() {
- stopwatch.start();
- ticker.advance(999999);
- assertEquals(Duration.ofNanos(999999), stopwatch.elapsed());
- ticker.advance(1);
- assertEquals(Duration.ofMillis(1), stopwatch.elapsed());
- }
-}
diff --git a/guava-tests/test/com/google/common/base/StopwatchTest.java b/guava-tests/test/com/google/common/base/StopwatchTest.java
index b85ebb7..25ba527 100644
--- a/guava-tests/test/com/google/common/base/StopwatchTest.java
+++ b/guava-tests/test/com/google/common/base/StopwatchTest.java
@@ -21,7 +21,9 @@
import static java.util.concurrent.TimeUnit.NANOSECONDS;
import com.google.common.annotations.GwtCompatible;
+import com.google.common.annotations.GwtIncompatible;
import com.google.common.testing.FakeTicker;
+import java.time.Duration;
import junit.framework.TestCase;
/**
@@ -166,6 +168,15 @@
assertEquals(1, stopwatch.elapsed(MILLISECONDS));
}
+ @GwtIncompatible
+ public void testElapsed_duration() {
+ stopwatch.start();
+ ticker.advance(999999);
+ assertEquals(Duration.ofNanos(999999), stopwatch.elapsed());
+ ticker.advance(1);
+ assertEquals(Duration.ofMillis(1), stopwatch.elapsed());
+ }
+
public void testToString() {
stopwatch.start();
assertEquals("0.000 ns", stopwatch.toString());
diff --git a/guava-tests/test/com/google/common/base/ToStringHelperTest.java b/guava-tests/test/com/google/common/base/ToStringHelperTest.java
index db15f2e..3f1ef0f 100644
--- a/guava-tests/test/com/google/common/base/ToStringHelperTest.java
+++ b/guava-tests/test/com/google/common/base/ToStringHelperTest.java
@@ -116,15 +116,15 @@
@GwtIncompatible // Class names are obfuscated in GWT
public void testToStringHelper_moreThanNineAnonymousClasses() {
// The nth anonymous class has a name ending like "Outer.$n"
- Object unused1 = new Object() {};
- Object unused2 = new Object() {};
- Object unused3 = new Object() {};
- Object unused4 = new Object() {};
- Object unused5 = new Object() {};
- Object unused6 = new Object() {};
- Object unused7 = new Object() {};
- Object unused8 = new Object() {};
- Object unused9 = new Object() {};
+ Object o1 = new Object() {};
+ Object o2 = new Object() {};
+ Object o3 = new Object() {};
+ Object o4 = new Object() {};
+ Object o5 = new Object() {};
+ Object o6 = new Object() {};
+ Object o7 = new Object() {};
+ Object o8 = new Object() {};
+ Object o9 = new Object() {};
Object o10 = new Object() {};
String toTest = MoreObjects.toStringHelper(o10).toString();
assertEquals("{}", toTest);
@@ -132,15 +132,15 @@
public void testToStringHelperLenient_moreThanNineAnonymousClasses() {
// The nth anonymous class has a name ending like "Outer.$n"
- Object unused1 = new Object() {};
- Object unused2 = new Object() {};
- Object unused3 = new Object() {};
- Object unused4 = new Object() {};
- Object unused5 = new Object() {};
- Object unused6 = new Object() {};
- Object unused7 = new Object() {};
- Object unused8 = new Object() {};
- Object unused9 = new Object() {};
+ Object o1 = new Object() {};
+ Object o2 = new Object() {};
+ Object o3 = new Object() {};
+ Object o4 = new Object() {};
+ Object o5 = new Object() {};
+ Object o6 = new Object() {};
+ Object o7 = new Object() {};
+ Object o8 = new Object() {};
+ Object o9 = new Object() {};
Object o10 = new Object() {};
String toTest = MoreObjects.toStringHelper(o10).toString();
assertTrue(toTest, toTest.matches(".*\\{\\}"));
@@ -357,7 +357,7 @@
}
@GwtIncompatible // Class names are obfuscated in GWT
- public void testToStringOmitEmptyValues_oneValue() {
+ public void testToStringOmitNullValues_oneValue() {
String toTest =
MoreObjects.toStringHelper(new TestClass()).omitNullValues().addValue(null).toString();
assertEquals("TestClass{}", toTest);
diff --git a/guava-tests/test/com/google/common/base/VerifyTest.java b/guava-tests/test/com/google/common/base/VerifyTest.java
index 37c6efc..03d2c2f 100644
--- a/guava-tests/test/com/google/common/base/VerifyTest.java
+++ b/guava-tests/test/com/google/common/base/VerifyTest.java
@@ -19,12 +19,11 @@
import static com.google.common.truth.Truth.assertThat;
import com.google.common.annotations.GwtCompatible;
-import com.google.common.annotations.GwtIncompatible;
import junit.framework.AssertionFailedError;
import junit.framework.TestCase;
/** Unit test for {@link com.google.common.base.Verify}. */
-@GwtCompatible(emulated = true)
+@GwtCompatible
public class VerifyTest extends TestCase {
public void testVerify_simple_success() {
verify(true);
@@ -93,11 +92,6 @@
}
}
- @GwtIncompatible // NullPointerTester
- public void testNullPointers() {
- // Don't bother testing: Verify is like Preconditions. See the discussion on that class.
- }
-
private static final Object IGNORE_ME =
new Object() {
@Override
diff --git a/guava-tests/test/com/google/common/cache/CacheBuilderSpecTest.java b/guava-tests/test/com/google/common/cache/CacheBuilderSpecTest.java
index 09f2eb6..ba2e08e 100644
--- a/guava-tests/test/com/google/common/cache/CacheBuilderSpecTest.java
+++ b/guava-tests/test/com/google/common/cache/CacheBuilderSpecTest.java
@@ -468,13 +468,11 @@
.testEquals();
}
- @SuppressWarnings("ReturnValueIgnored")
public void testMaximumWeight_withWeigher() {
CacheBuilder<Object, Object> builder = CacheBuilder.from(parse("maximumWeight=9000"));
builder.weigher(constantWeigher(42)).build(CacheLoader.from(Suppliers.ofInstance(null)));
}
- @SuppressWarnings("ReturnValueIgnored")
public void testMaximumWeight_withoutWeigher() {
CacheBuilder<Object, Object> builder = CacheBuilder.from(parse("maximumWeight=9000"));
try {
@@ -484,13 +482,11 @@
}
}
- @SuppressWarnings("ReturnValueIgnored")
public void testMaximumSize_withWeigher() {
CacheBuilder<Object, Object> builder = CacheBuilder.from(parse("maximumSize=9000"));
builder.weigher(constantWeigher(42)).build(CacheLoader.from(Suppliers.ofInstance(null)));
}
- @SuppressWarnings("ReturnValueIgnored")
public void testMaximumSize_withoutWeigher() {
CacheBuilder<Object, Object> builder = CacheBuilder.from(parse("maximumSize=9000"));
builder.build(CacheLoader.from(Suppliers.ofInstance(null)));
diff --git a/guava-tests/test/com/google/common/cache/CacheBuilderTest.java b/guava-tests/test/com/google/common/cache/CacheBuilderTest.java
index 16488f3..8042ea7 100644
--- a/guava-tests/test/com/google/common/cache/CacheBuilderTest.java
+++ b/guava-tests/test/com/google/common/cache/CacheBuilderTest.java
@@ -305,7 +305,6 @@
}
}
- @SuppressWarnings("ReturnValueIgnored")
public void testTimeToLive_small() {
CacheBuilder.newBuilder().expireAfterWrite(1, NANOSECONDS).build(identityLoader());
// well, it didn't blow up.
@@ -353,7 +352,6 @@
}
}
- @SuppressWarnings("ReturnValueIgnored")
public void testTimeToIdle_small() {
CacheBuilder.newBuilder().expireAfterAccess(1, NANOSECONDS).build(identityLoader());
// well, it didn't blow up.
@@ -382,7 +380,6 @@
}
}
- @SuppressWarnings("ReturnValueIgnored")
public void testTimeToIdleAndToLive() {
CacheBuilder.newBuilder()
.expireAfterWrite(1, NANOSECONDS)
@@ -579,7 +576,7 @@
final CountDownLatch tasksFinished = new CountDownLatch(nTasks);
for (int i = 0; i < nTasks; i++) {
final String s = "a" + i;
- @SuppressWarnings("unused") // https://errorprone.info/bugpattern/FutureReturnValueIgnored
+ @SuppressWarnings("unused") // go/futurereturn-lsc
Future<?> possiblyIgnoredError =
threadPool.submit(
new Runnable() {
@@ -674,7 +671,7 @@
ExecutorService threadPool = Executors.newFixedThreadPool(nThreads);
for (int i = 0; i < nTasks; i++) {
- @SuppressWarnings("unused") // https://errorprone.info/bugpattern/FutureReturnValueIgnored
+ @SuppressWarnings("unused") // go/futurereturn-lsc
Future<?> possiblyIgnoredError =
threadPool.submit(
new Runnable() {
diff --git a/guava-tests/test/com/google/common/cache/CacheLoaderTest.java b/guava-tests/test/com/google/common/cache/CacheLoaderTest.java
index e078ddd..6147ff2 100644
--- a/guava-tests/test/com/google/common/cache/CacheLoaderTest.java
+++ b/guava-tests/test/com/google/common/cache/CacheLoaderTest.java
@@ -18,10 +18,10 @@
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.Queues;
+import com.google.common.collect.Lists;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
-import java.util.Deque;
+import java.util.LinkedList;
import java.util.Map;
import java.util.concurrent.Executor;
import java.util.concurrent.Future;
@@ -36,7 +36,7 @@
public class CacheLoaderTest extends TestCase {
private static class QueuingExecutor implements Executor {
- private final Deque<Runnable> tasks = Queues.newArrayDeque();
+ private LinkedList<Runnable> tasks = Lists.newLinkedList();
@Override
public void execute(Runnable task) {
@@ -79,7 +79,7 @@
assertEquals(0, loadAllCount.get());
baseLoader.load(new Object());
- @SuppressWarnings("unused") // https://errorprone.info/bugpattern/FutureReturnValueIgnored
+ @SuppressWarnings("unused") // go/futurereturn-lsc
Future<?> possiblyIgnoredError = baseLoader.reload(new Object(), new Object());
baseLoader.loadAll(ImmutableList.of(new Object()));
assertEquals(1, loadCount.get());
@@ -90,7 +90,7 @@
CacheLoader<Object, Object> asyncReloader = CacheLoader.asyncReloading(baseLoader, executor);
asyncReloader.load(new Object());
- @SuppressWarnings("unused") // https://errorprone.info/bugpattern/FutureReturnValueIgnored
+ @SuppressWarnings("unused") // go/futurereturn-lsc
Future<?> possiblyIgnoredError1 = asyncReloader.reload(new Object(), new Object());
asyncReloader.loadAll(ImmutableList.of(new Object()));
assertEquals(2, loadCount.get());
diff --git a/guava-tests/test/com/google/common/cache/CacheLoadingTest.java b/guava-tests/test/com/google/common/cache/CacheLoadingTest.java
index f5ea546..ba3e7e9 100644
--- a/guava-tests/test/com/google/common/cache/CacheLoadingTest.java
+++ b/guava-tests/test/com/google/common/cache/CacheLoadingTest.java
@@ -1766,7 +1766,6 @@
assertEquals(0, removalListener.getCount());
}
-
public void testReloadAfterValueReclamation() throws InterruptedException, ExecutionException {
CountingLoader countingLoader = new CountingLoader();
LoadingCache<Object, Object> cache =
@@ -1941,7 +1940,6 @@
}
}
-
public void testConcurrentLoading() throws InterruptedException {
testConcurrentLoading(CacheBuilder.newBuilder());
}
@@ -1954,7 +1952,6 @@
testConcurrentLoadingCheckedException(builder);
}
-
public void testConcurrentExpirationLoading() throws InterruptedException {
testConcurrentLoading(CacheBuilder.newBuilder().expireAfterWrite(10, TimeUnit.SECONDS));
}
@@ -2184,7 +2181,6 @@
return resultList;
}
-
public void testAsMapDuringLoading() throws InterruptedException, ExecutionException {
final CountDownLatch getStartedSignal = new CountDownLatch(2);
final CountDownLatch letGetFinishSignal = new CountDownLatch(1);
@@ -2243,7 +2239,6 @@
assertEquals(refreshKey + suffix, map.get(refreshKey));
}
-
public void testInvalidateDuringLoading() throws InterruptedException, ExecutionException {
// computation starts; invalidate() is called on the key being computed, computation finishes
final CountDownLatch computationStarted = new CountDownLatch(2);
@@ -2300,7 +2295,6 @@
assertEquals(2, cache.size());
}
-
public void testInvalidateAndReloadDuringLoading()
throws InterruptedException, ExecutionException {
// computation starts; clear() is called, computation finishes
@@ -2373,7 +2367,6 @@
assertEquals(refreshKey + suffix, map.get(refreshKey));
}
-
public void testExpandDuringLoading() throws InterruptedException {
final int count = 3;
final AtomicInteger callCount = new AtomicInteger();
diff --git a/guava-tests/test/com/google/common/cache/EmptyCachesTest.java b/guava-tests/test/com/google/common/cache/EmptyCachesTest.java
index a5e3a59..a56c280 100644
--- a/guava-tests/test/com/google/common/cache/EmptyCachesTest.java
+++ b/guava-tests/test/com/google/common/cache/EmptyCachesTest.java
@@ -47,7 +47,6 @@
}
}
-
public void testInvalidate_empty() {
for (LoadingCache<Object, Object> cache : caches()) {
cache.getUnchecked("a");
@@ -69,7 +68,6 @@
}
}
-
public void testEquals_null() {
for (LoadingCache<Object, Object> cache : caches()) {
assertFalse(cache.equals(null));
@@ -139,7 +137,6 @@
}
}
-
public void testKeySet_clear() {
for (LoadingCache<Object, Object> cache : caches()) {
warmUp(cache, 0, 100);
@@ -214,7 +211,6 @@
}
}
-
public void testValues_clear() {
for (LoadingCache<Object, Object> cache : caches()) {
warmUp(cache, 0, 100);
@@ -289,7 +285,6 @@
}
}
-
public void testEntrySet_clear() {
for (LoadingCache<Object, Object> cache : caches()) {
warmUp(cache, 0, 100);
diff --git a/guava-tests/test/com/google/common/cache/ForwardingLoadingCacheTest.java b/guava-tests/test/com/google/common/cache/ForwardingLoadingCacheTest.java
index d78db2d..c5681d2 100644
--- a/guava-tests/test/com/google/common/cache/ForwardingLoadingCacheTest.java
+++ b/guava-tests/test/com/google/common/cache/ForwardingLoadingCacheTest.java
@@ -90,7 +90,7 @@
public void testSize() {
when(mock.size()).thenReturn(0L);
- long unused = forward.size();
+ forward.size();
}
public void testStats() {
diff --git a/guava-tests/test/com/google/common/cache/LocalCacheMapComputeTest.java b/guava-tests/test/com/google/common/cache/LocalCacheMapComputeTest.java
index 3684a70..2c1e1e8 100644
--- a/guava-tests/test/com/google/common/cache/LocalCacheMapComputeTest.java
+++ b/guava-tests/test/com/google/common/cache/LocalCacheMapComputeTest.java
@@ -18,12 +18,6 @@
import static com.google.common.truth.Truth.assertThat;
-import com.google.common.util.concurrent.UncheckedExecutionException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Queue;
-import java.util.concurrent.ConcurrentLinkedQueue;
-import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.function.IntConsumer;
import java.util.stream.IntStream;
@@ -97,31 +91,6 @@
assertThat(cache.getIfPresent(key).split(delimiter)).hasLength(count + 1);
}
- public void testComputeIfPresentRemove() {
- List<RemovalNotification<Integer, Integer>> notifications = new ArrayList<>();
- Cache<Integer, Integer> cache =
- CacheBuilder.newBuilder()
- .removalListener(
- new RemovalListener<Integer, Integer>() {
- @Override
- public void onRemoval(RemovalNotification<Integer, Integer> notification) {
- notifications.add(notification);
- }
- })
- .build();
- cache.put(1, 2);
-
- // explicitly remove the existing value
- cache.asMap().computeIfPresent(1, (key, value) -> null);
- assertThat(notifications).hasSize(1);
- CacheTesting.checkEmpty(cache);
-
- // ensure no zombie entry remains
- cache.asMap().computeIfPresent(1, (key, value) -> null);
- assertThat(notifications).hasSize(1);
- CacheTesting.checkEmpty(cache);
- }
-
public void testUpdates() {
cache.put(key, "1");
// simultaneous update for same key, some null, some non-null
@@ -144,41 +113,6 @@
assertEquals(0, cache.size());
}
- public void testComputeWithLoad() {
- Queue<RemovalNotification<String, String>> notifications = new ConcurrentLinkedQueue<>();
- cache =
- CacheBuilder.newBuilder()
- .removalListener(
- new RemovalListener<String, String>() {
- @Override
- public void onRemoval(RemovalNotification<String, String> notification) {
- notifications.add(notification);
- }
- })
- .expireAfterAccess(500000, TimeUnit.MILLISECONDS)
- .maximumSize(count)
- .build();
-
- cache.put(key, "1");
- // simultaneous load and deletion
- doParallelCacheOp(
- count,
- n -> {
- try {
- cache.get(key, () -> key);
- cache.asMap().compute(key, (k, v) -> null);
- } catch (ExecutionException e) {
- throw new UncheckedExecutionException(e);
- }
- });
-
- CacheTesting.checkEmpty(cache);
- for (RemovalNotification<String, String> entry : notifications) {
- assertThat(entry.getKey()).isNotNull();
- assertThat(entry.getValue()).isNotNull();
- }
- }
-
public void testComputeExceptionally() {
try {
doParallelCacheOp(
diff --git a/guava-tests/test/com/google/common/cache/LocalCacheTest.java b/guava-tests/test/com/google/common/cache/LocalCacheTest.java
index ceecb5d..f3d3f94 100644
--- a/guava-tests/test/com/google/common/cache/LocalCacheTest.java
+++ b/guava-tests/test/com/google/common/cache/LocalCacheTest.java
@@ -98,7 +98,6 @@
}
}
-
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTestSuite(LocalCacheTest.class);
@@ -714,7 +713,6 @@
assertTrue(notifications.toString(), notifications.isEmpty());
}
-
public void testCopyEntry_computing() {
final CountDownLatch startSignal = new CountDownLatch(1);
final CountDownLatch computingSignal = new CountDownLatch(1);
@@ -816,7 +814,6 @@
checkLogged(e);
}
-
public void testRemovalListener_replaced_computing() {
final CountDownLatch startSignal = new CountDownLatch(1);
final CountDownLatch computingSignal = new CountDownLatch(1);
diff --git a/guava-tests/test/com/google/common/cache/LocalLoadingCacheTest.java b/guava-tests/test/com/google/common/cache/LocalLoadingCacheTest.java
index 8ba9dbc..6b73bdc 100644
--- a/guava-tests/test/com/google/common/cache/LocalLoadingCacheTest.java
+++ b/guava-tests/test/com/google/common/cache/LocalLoadingCacheTest.java
@@ -157,7 +157,7 @@
assertThat(map).containsEntry(three, one);
assertThat(map).containsEntry(one, two);
- // TODO(user): Confirm with fry@ that this is a reasonable substitute.
+ // TODO(cgruber): Confirm with fry@ that this is a reasonable substitute.
// Set<Entry<Object, Object>> entries = map.entrySet();
// assertThat(entries).containsExactly(
// Maps.immutableEntry(three, one), Maps.immutableEntry(one, two));
@@ -293,7 +293,6 @@
assertFalse(segment.recencyQueue.isEmpty());
}
-
public void testRecursiveComputation() throws InterruptedException {
final AtomicReference<LoadingCache<Integer, String>> cacheRef = new AtomicReference<>();
CacheLoader<Integer, String> recursiveLoader =
diff --git a/guava-tests/test/com/google/common/cache/PopulatedCachesTest.java b/guava-tests/test/com/google/common/cache/PopulatedCachesTest.java
index b02b8ac..1e71b63 100644
--- a/guava-tests/test/com/google/common/cache/PopulatedCachesTest.java
+++ b/guava-tests/test/com/google/common/cache/PopulatedCachesTest.java
@@ -187,7 +187,6 @@
}
}
-
public void testKeySet_populated() {
for (LoadingCache<Object, Object> cache : caches()) {
Set<Object> keys = cache.asMap().keySet();
@@ -238,7 +237,6 @@
}
}
-
public void testEntrySet_populated() {
for (LoadingCache<Object, Object> cache : caches()) {
Set<Entry<Object, Object>> entries = cache.asMap().entrySet();
diff --git a/guava-tests/test/com/google/common/collect/AbstractIteratorTest.java b/guava-tests/test/com/google/common/collect/AbstractIteratorTest.java
index 3592210..4cb9d1b 100644
--- a/guava-tests/test/com/google/common/collect/AbstractIteratorTest.java
+++ b/guava-tests/test/com/google/common/collect/AbstractIteratorTest.java
@@ -137,7 +137,6 @@
}
}
-
@GwtIncompatible // weak references
public void testFreesNextReference() {
Iterator<Object> itr =
diff --git a/guava-tests/test/com/google/common/collect/DiscreteDomainTest.java b/guava-tests/test/com/google/common/collect/DiscreteDomainTest.java
index b9e15fd..5de3f8d 100644
--- a/guava-tests/test/com/google/common/collect/DiscreteDomainTest.java
+++ b/guava-tests/test/com/google/common/collect/DiscreteDomainTest.java
@@ -87,48 +87,4 @@
} catch (IllegalArgumentException expected) {
}
}
-
- public void testCustomOffsetExceptions() {
- try {
- new MyIntegerDomain().offset(0, -1);
- fail();
- } catch (IllegalArgumentException expected) {
- }
- try {
- new MyIntegerDomain().offset(Integer.MAX_VALUE, 1);
- fail();
- } catch (IllegalArgumentException expected) {
- }
- }
-
- private static final class MyIntegerDomain extends DiscreteDomain<Integer> {
- static final DiscreteDomain<Integer> DELEGATE = DiscreteDomain.integers();
-
- @Override
- public Integer next(Integer value) {
- return DELEGATE.next(value);
- }
-
- @Override
- public Integer previous(Integer value) {
- return DELEGATE.previous(value);
- }
-
- // Do *not* override offset() to delegate: We want to test the default implementation.
-
- @Override
- public long distance(Integer start, Integer end) {
- return DELEGATE.distance(start, end);
- }
-
- @Override
- public Integer minValue() {
- return DELEGATE.minValue();
- }
-
- @Override
- public Integer maxValue() {
- return DELEGATE.maxValue();
- }
- }
}
diff --git a/guava-tests/test/com/google/common/collect/ImmutableBiMapTest.java b/guava-tests/test/com/google/common/collect/ImmutableBiMapTest.java
index fa0a7c1..0f95428 100644
--- a/guava-tests/test/com/google/common/collect/ImmutableBiMapTest.java
+++ b/guava-tests/test/com/google/common/collect/ImmutableBiMapTest.java
@@ -37,7 +37,6 @@
import com.google.common.testing.CollectorTester;
import com.google.common.testing.SerializableTester;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
-import java.util.AbstractMap;
import java.util.Arrays;
import java.util.Collections;
import java.util.EnumSet;
@@ -427,136 +426,6 @@
"four",
5,
"five");
- assertMapEquals(
- ImmutableBiMap.of(
- "one", 1,
- "two", 2,
- "three", 3,
- "four", 4,
- "five", 5,
- "six", 6),
- "one",
- 1,
- "two",
- 2,
- "three",
- 3,
- "four",
- 4,
- "five",
- 5,
- "six",
- 6);
- assertMapEquals(
- ImmutableBiMap.of(
- "one", 1,
- "two", 2,
- "three", 3,
- "four", 4,
- "five", 5,
- "six", 6,
- "seven", 7),
- "one",
- 1,
- "two",
- 2,
- "three",
- 3,
- "four",
- 4,
- "five",
- 5,
- "six",
- 6,
- "seven",
- 7);
- assertMapEquals(
- ImmutableBiMap.of(
- "one", 1,
- "two", 2,
- "three", 3,
- "four", 4,
- "five", 5,
- "six", 6,
- "seven", 7,
- "eight", 8),
- "one",
- 1,
- "two",
- 2,
- "three",
- 3,
- "four",
- 4,
- "five",
- 5,
- "six",
- 6,
- "seven",
- 7,
- "eight",
- 8);
- assertMapEquals(
- ImmutableBiMap.of(
- "one", 1,
- "two", 2,
- "three", 3,
- "four", 4,
- "five", 5,
- "six", 6,
- "seven", 7,
- "eight", 8,
- "nine", 9),
- "one",
- 1,
- "two",
- 2,
- "three",
- 3,
- "four",
- 4,
- "five",
- 5,
- "six",
- 6,
- "seven",
- 7,
- "eight",
- 8,
- "nine",
- 9);
- assertMapEquals(
- ImmutableBiMap.of(
- "one", 1,
- "two", 2,
- "three", 3,
- "four", 4,
- "five", 5,
- "six", 6,
- "seven", 7,
- "eight", 8,
- "nine", 9,
- "ten", 10),
- "one",
- 1,
- "two",
- 2,
- "three",
- 3,
- "four",
- 4,
- "five",
- 5,
- "six",
- 6,
- "seven",
- 7,
- "eight",
- 8,
- "nine",
- 9,
- "ten",
- 10);
}
public void testOfNullKey() {
@@ -596,30 +465,6 @@
}
}
- public void testOfEntries() {
- assertMapEquals(
- ImmutableBiMap.ofEntries(entry("one", 1), entry("two", 2)), "one", 1, "two", 2);
- }
-
- public void testOfEntriesNull() {
- Entry<Integer, Integer> nullKey = entry(null, 23);
- try {
- ImmutableBiMap.ofEntries(nullKey);
- fail();
- } catch (NullPointerException expected) {
- }
- Entry<Integer, Integer> nullValue = entry(23, null);
- try {
- ImmutableBiMap.ofEntries(nullValue);
- fail();
- } catch (NullPointerException expected) {
- }
- }
-
- private static <T> Entry<T, T> entry(T key, T value) {
- return new AbstractMap.SimpleImmutableEntry<>(key, value);
- }
-
public void testCopyOfEmptyMap() {
ImmutableBiMap<String, Integer> copy =
ImmutableBiMap.copyOf(Collections.<String, Integer>emptyMap());
diff --git a/guava-tests/test/com/google/common/collect/ImmutableListMultimapTest.java b/guava-tests/test/com/google/common/collect/ImmutableListMultimapTest.java
index 4e0bdda..d270610 100644
--- a/guava-tests/test/com/google/common/collect/ImmutableListMultimapTest.java
+++ b/guava-tests/test/com/google/common/collect/ImmutableListMultimapTest.java
@@ -32,7 +32,6 @@
import com.google.common.collect.testing.google.UnmodifiableCollectionTests;
import com.google.common.testing.CollectorTester;
import com.google.common.testing.EqualsTester;
-import com.google.common.testing.NullPointerTester;
import com.google.common.testing.SerializableTester;
import java.util.Arrays;
import java.util.Collection;
@@ -602,13 +601,4 @@
Multimap<String, Integer> multimap = ImmutableListMultimap.of();
assertSame(multimap, SerializableTester.reserialize(multimap));
}
-
- @GwtIncompatible // reflection
- public void testNulls() throws Exception {
- NullPointerTester tester = new NullPointerTester();
- tester.testAllPublicStaticMethods(ImmutableListMultimap.class);
- tester.ignore(ImmutableListMultimap.class.getMethod("get", Object.class));
- tester.testAllPublicInstanceMethods(ImmutableListMultimap.of());
- tester.testAllPublicInstanceMethods(ImmutableListMultimap.of("a", 1));
- }
}
diff --git a/guava-tests/test/com/google/common/collect/ImmutableMapTest.java b/guava-tests/test/com/google/common/collect/ImmutableMapTest.java
index 18a17a0..34d1e21 100644
--- a/guava-tests/test/com/google/common/collect/ImmutableMapTest.java
+++ b/guava-tests/test/com/google/common/collect/ImmutableMapTest.java
@@ -19,7 +19,6 @@
import static com.google.common.collect.testing.Helpers.mapEntry;
import static com.google.common.testing.SerializableTester.reserialize;
import static com.google.common.truth.Truth.assertThat;
-import static com.google.common.truth.Truth.assertWithMessage;
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.GwtIncompatible;
@@ -622,136 +621,6 @@
4,
"five",
5);
- assertMapEquals(
- ImmutableMap.of(
- "one", 1,
- "two", 2,
- "three", 3,
- "four", 4,
- "five", 5,
- "six", 6),
- "one",
- 1,
- "two",
- 2,
- "three",
- 3,
- "four",
- 4,
- "five",
- 5,
- "six",
- 6);
- assertMapEquals(
- ImmutableMap.of(
- "one", 1,
- "two", 2,
- "three", 3,
- "four", 4,
- "five", 5,
- "six", 6,
- "seven", 7),
- "one",
- 1,
- "two",
- 2,
- "three",
- 3,
- "four",
- 4,
- "five",
- 5,
- "six",
- 6,
- "seven",
- 7);
- assertMapEquals(
- ImmutableMap.of(
- "one", 1,
- "two", 2,
- "three", 3,
- "four", 4,
- "five", 5,
- "six", 6,
- "seven", 7,
- "eight", 8),
- "one",
- 1,
- "two",
- 2,
- "three",
- 3,
- "four",
- 4,
- "five",
- 5,
- "six",
- 6,
- "seven",
- 7,
- "eight",
- 8);
- assertMapEquals(
- ImmutableMap.of(
- "one", 1,
- "two", 2,
- "three", 3,
- "four", 4,
- "five", 5,
- "six", 6,
- "seven", 7,
- "eight", 8,
- "nine", 9),
- "one",
- 1,
- "two",
- 2,
- "three",
- 3,
- "four",
- 4,
- "five",
- 5,
- "six",
- 6,
- "seven",
- 7,
- "eight",
- 8,
- "nine",
- 9);
- assertMapEquals(
- ImmutableMap.of(
- "one", 1,
- "two", 2,
- "three", 3,
- "four", 4,
- "five", 5,
- "six", 6,
- "seven", 7,
- "eight", 8,
- "nine", 9,
- "ten", 10),
- "one",
- 1,
- "two",
- 2,
- "three",
- 3,
- "four",
- 4,
- "five",
- 5,
- "six",
- 6,
- "seven",
- 7,
- "eight",
- 8,
- "nine",
- 9,
- "ten",
- 10);
}
public void testOfNullKey() {
@@ -1080,87 +949,18 @@
public void testEquals() {
new EqualsTester()
- .addEqualityGroup(
- ImmutableMap.of(), ImmutableMap.builder().build(), ImmutableMap.ofEntries(), map())
- .addEqualityGroup(
- ImmutableMap.of(1, 1),
- ImmutableMap.builder().put(1, 1).build(),
- ImmutableMap.ofEntries(entry(1, 1)),
- map(1, 1))
- .addEqualityGroup(
- ImmutableMap.of(1, 1, 2, 2),
- ImmutableMap.builder().put(1, 1).put(2, 2).build(),
- ImmutableMap.ofEntries(entry(1, 1), entry(2, 2)),
- map(1, 1, 2, 2))
- .addEqualityGroup(
- ImmutableMap.of(1, 1, 2, 2, 3, 3),
- ImmutableMap.builder().put(1, 1).put(2, 2).put(3, 3).build(),
- ImmutableMap.ofEntries(entry(1, 1), entry(2, 2), entry(3, 3)),
- map(1, 1, 2, 2, 3, 3))
- .addEqualityGroup(
- ImmutableMap.of(1, 4, 2, 2, 3, 3),
- ImmutableMap.builder().put(1, 4).put(2, 2).put(3, 3).build(),
- ImmutableMap.ofEntries(entry(1, 4), entry(2, 2), entry(3, 3)),
- map(1, 4, 2, 2, 3, 3))
- .addEqualityGroup(
- ImmutableMap.of(1, 1, 2, 4, 3, 3),
- ImmutableMap.builder().put(1, 1).put(2, 4).put(3, 3).build(),
- ImmutableMap.ofEntries(entry(1, 1), entry(2, 4), entry(3, 3)),
- map(1, 1, 2, 4, 3, 3))
- .addEqualityGroup(
- ImmutableMap.of(1, 1, 2, 2, 3, 4),
- ImmutableMap.builder().put(1, 1).put(2, 2).put(3, 4).build(),
- ImmutableMap.ofEntries(entry(1, 1), entry(2, 2), entry(3, 4)),
- map(1, 1, 2, 2, 3, 4))
- .addEqualityGroup(
- ImmutableMap.of(1, 2, 2, 3, 3, 1),
- ImmutableMap.builder().put(1, 2).put(2, 3).put(3, 1).build(),
- ImmutableMap.ofEntries(entry(1, 2), entry(2, 3), entry(3, 1)),
- map(1, 2, 2, 3, 3, 1))
- .addEqualityGroup(
- ImmutableMap.of(1, 1, 2, 2, 3, 3, 4, 4),
- ImmutableMap.builder().put(1, 1).put(2, 2).put(3, 3).put(4, 4).build(),
- ImmutableMap.ofEntries(entry(1, 1), entry(2, 2), entry(3, 3), entry(4, 4)),
- map(1, 1, 2, 2, 3, 3, 4, 4))
- .addEqualityGroup(
- ImmutableMap.of(1, 1, 2, 2, 3, 3, 4, 4, 5, 5),
- ImmutableMap.builder().put(1, 1).put(2, 2).put(3, 3).put(4, 4).put(5, 5).build(),
- ImmutableMap.ofEntries(entry(1, 1), entry(2, 2), entry(3, 3), entry(4, 4), entry(5, 5)),
- map(1, 1, 2, 2, 3, 3, 4, 4, 5, 5))
+ .addEqualityGroup(ImmutableMap.of(), ImmutableMap.builder().build())
+ .addEqualityGroup(ImmutableMap.of(1, 1), ImmutableMap.builder().put(1, 1).build())
+ .addEqualityGroup(ImmutableMap.of(1, 1, 2, 2))
+ .addEqualityGroup(ImmutableMap.of(1, 1, 2, 2, 3, 3))
+ .addEqualityGroup(ImmutableMap.of(1, 4, 2, 2, 3, 3))
+ .addEqualityGroup(ImmutableMap.of(1, 1, 2, 4, 3, 3))
+ .addEqualityGroup(ImmutableMap.of(1, 1, 2, 2, 3, 4))
+ .addEqualityGroup(ImmutableMap.of(1, 2, 2, 3, 3, 1))
+ .addEqualityGroup(ImmutableMap.of(1, 1, 2, 2, 3, 3, 4, 4))
.testEquals();
}
- public void testOfEntriesNull() {
- Entry<Integer, Integer> nullKey = entry(null, 23);
- try {
- ImmutableMap.ofEntries(nullKey);
- fail();
- } catch (NullPointerException expected) {
- }
- Entry<Integer, Integer> nullValue = entry(23, null);
- try {
- ImmutableMap.ofEntries(nullValue);
- fail();
- } catch (NullPointerException expected) {
- }
- }
-
- private static <T> Map<T, T> map(T... keysAndValues) {
- assertThat(keysAndValues.length % 2).isEqualTo(0);
- LinkedHashMap<T, T> map = new LinkedHashMap<>();
- for (int i = 0; i < keysAndValues.length; i += 2) {
- T key = keysAndValues[i];
- T value = keysAndValues[i + 1];
- T old = map.put(key, value);
- assertWithMessage("Key %s set to %s and %s", key, value, old).that(old).isNull();
- }
- return map;
- }
-
- private static <T> Entry<T, T> entry(T key, T value) {
- return new AbstractMap.SimpleImmutableEntry<>(key, value);
- }
-
public void testCopyOfMutableEntryList() {
List<Entry<String, String>> entryList =
Arrays.asList(
diff --git a/guava-tests/test/com/google/common/collect/ImmutableMultimapTest.java b/guava-tests/test/com/google/common/collect/ImmutableMultimapTest.java
index ac09593..5263258 100644
--- a/guava-tests/test/com/google/common/collect/ImmutableMultimapTest.java
+++ b/guava-tests/test/com/google/common/collect/ImmutableMultimapTest.java
@@ -17,13 +17,11 @@
package com.google.common.collect;
import com.google.common.annotations.GwtCompatible;
-import com.google.common.annotations.GwtIncompatible;
import com.google.common.collect.ImmutableMultimap.Builder;
import com.google.common.collect.testing.SampleElements;
import com.google.common.collect.testing.SampleElements.Unhashables;
import com.google.common.collect.testing.UnhashableObject;
import com.google.common.testing.EqualsTester;
-import com.google.common.testing.NullPointerTester;
import java.util.Arrays;
import java.util.Map.Entry;
import junit.framework.TestCase;
@@ -126,13 +124,4 @@
ImmutableMultimap.of(1, "a", 2, "b"), ImmutableMultimap.of(2, "b", 1, "a"))
.testEquals();
}
-
- @GwtIncompatible // reflection
- public void testNulls() throws Exception {
- NullPointerTester tester = new NullPointerTester();
- tester.testAllPublicStaticMethods(ImmutableMultimap.class);
- tester.ignore(ImmutableListMultimap.class.getMethod("get", Object.class));
- tester.testAllPublicInstanceMethods(ImmutableMultimap.of());
- tester.testAllPublicInstanceMethods(ImmutableMultimap.of("a", 1));
- }
}
diff --git a/guava-tests/test/com/google/common/collect/ImmutableRangeMapTest.java b/guava-tests/test/com/google/common/collect/ImmutableRangeMapTest.java
index e5caa62..a245e0c 100644
--- a/guava-tests/test/com/google/common/collect/ImmutableRangeMapTest.java
+++ b/guava-tests/test/com/google/common/collect/ImmutableRangeMapTest.java
@@ -208,7 +208,6 @@
}
}
-
public void testSubRangeMap() {
for (Range<Integer> range1 : RANGES) {
for (Range<Integer> range2 : RANGES) {
@@ -257,7 +256,7 @@
SerializableTester.reserializeAndAssert(nonEmptyRangeMap);
}
- public void testToImmutableRangeMap() {
+ public void testToImmutableRangeSet() {
Range<Integer> rangeOne = Range.closedOpen(1, 5);
Range<Integer> rangeTwo = Range.openClosed(6, 7);
ImmutableRangeMap<Integer, Integer> rangeMap =
diff --git a/guava-tests/test/com/google/common/collect/ImmutableSetMultimapTest.java b/guava-tests/test/com/google/common/collect/ImmutableSetMultimapTest.java
index 842ba92..a1b2c0f 100644
--- a/guava-tests/test/com/google/common/collect/ImmutableSetMultimapTest.java
+++ b/guava-tests/test/com/google/common/collect/ImmutableSetMultimapTest.java
@@ -32,7 +32,6 @@
import com.google.common.collect.testing.google.UnmodifiableCollectionTests;
import com.google.common.testing.CollectorTester;
import com.google.common.testing.EqualsTester;
-import com.google.common.testing.NullPointerTester;
import com.google.common.testing.SerializableTester;
import java.util.Arrays;
import java.util.Collection;
@@ -625,13 +624,4 @@
.put("foo", 3)
.build();
}
-
- @GwtIncompatible // reflection
- public void testNulls() throws Exception {
- NullPointerTester tester = new NullPointerTester();
- tester.testAllPublicStaticMethods(ImmutableSetMultimap.class);
- tester.ignore(ImmutableSetMultimap.class.getMethod("get", Object.class));
- tester.testAllPublicInstanceMethods(ImmutableSetMultimap.of());
- tester.testAllPublicInstanceMethods(ImmutableSetMultimap.of("a", 1));
- }
}
diff --git a/guava-tests/test/com/google/common/collect/ImmutableSetTest.java b/guava-tests/test/com/google/common/collect/ImmutableSetTest.java
index 1828517..06d6a8e 100644
--- a/guava-tests/test/com/google/common/collect/ImmutableSetTest.java
+++ b/guava-tests/test/com/google/common/collect/ImmutableSetTest.java
@@ -378,12 +378,6 @@
.testEquals();
}
- /**
- * The maximum allowed probability of falsely detecting a hash flooding attack if the input is
- * randomly generated.
- */
- private static final double HASH_FLOODING_FPP = 0.001;
-
public void testReuseBuilderReducingHashTableSizeWithPowerOfTwoTotalElements() {
ImmutableSet.Builder<Object> builder = ImmutableSet.builderWithExpectedSize(6);
builder.add(0);
diff --git a/guava-tests/test/com/google/common/collect/ImmutableSortedMapTest.java b/guava-tests/test/com/google/common/collect/ImmutableSortedMapTest.java
index 2136f2a..03738c0 100644
--- a/guava-tests/test/com/google/common/collect/ImmutableSortedMapTest.java
+++ b/guava-tests/test/com/google/common/collect/ImmutableSortedMapTest.java
@@ -320,7 +320,6 @@
assertMapEquals(map, "five", 5, "four", 4, "one", 1, "three", 3, "two", 2);
}
- @SuppressWarnings("DoNotCall")
public void testBuilder_orderEntriesByValueFails() {
ImmutableSortedMap.Builder<String, Integer> builder = ImmutableSortedMap.naturalOrder();
try {
@@ -488,136 +487,6 @@
3,
"two",
2);
- assertMapEquals(
- ImmutableSortedMap.of(
- "one", 1,
- "two", 2,
- "three", 3,
- "four", 4,
- "five", 5,
- "six", 6),
- "five",
- 5,
- "four",
- 4,
- "one",
- 1,
- "six",
- 6,
- "three",
- 3,
- "two",
- 2);
- assertMapEquals(
- ImmutableSortedMap.of(
- "one", 1,
- "two", 2,
- "three", 3,
- "four", 4,
- "five", 5,
- "six", 6,
- "seven", 7),
- "five",
- 5,
- "four",
- 4,
- "one",
- 1,
- "seven",
- 7,
- "six",
- 6,
- "three",
- 3,
- "two",
- 2);
- assertMapEquals(
- ImmutableSortedMap.of(
- "one", 1,
- "two", 2,
- "three", 3,
- "four", 4,
- "five", 5,
- "six", 6,
- "seven", 7,
- "eight", 8),
- "eight",
- 8,
- "five",
- 5,
- "four",
- 4,
- "one",
- 1,
- "seven",
- 7,
- "six",
- 6,
- "three",
- 3,
- "two",
- 2);
- assertMapEquals(
- ImmutableSortedMap.of(
- "one", 1,
- "two", 2,
- "three", 3,
- "four", 4,
- "five", 5,
- "six", 6,
- "seven", 7,
- "eight", 8,
- "nine", 9),
- "eight",
- 8,
- "five",
- 5,
- "four",
- 4,
- "nine",
- 9,
- "one",
- 1,
- "seven",
- 7,
- "six",
- 6,
- "three",
- 3,
- "two",
- 2);
- assertMapEquals(
- ImmutableSortedMap.of(
- "one", 1,
- "two", 2,
- "three", 3,
- "four", 4,
- "five", 5,
- "six", 6,
- "seven", 7,
- "eight", 8,
- "nine", 9,
- "ten", 10),
- "eight",
- 8,
- "five",
- 5,
- "four",
- 4,
- "nine",
- 9,
- "one",
- 1,
- "seven",
- 7,
- "six",
- 6,
- "ten",
- 10,
- "three",
- 3,
- "two",
- 2);
}
public void testOfNullKey() {
diff --git a/guava-tests/test/com/google/common/collect/ImmutableSortedSetTest.java b/guava-tests/test/com/google/common/collect/ImmutableSortedSetTest.java
index b4cd891..1f45227 100644
--- a/guava-tests/test/com/google/common/collect/ImmutableSortedSetTest.java
+++ b/guava-tests/test/com/google/common/collect/ImmutableSortedSetTest.java
@@ -965,7 +965,7 @@
assertTrue(Iterables.elementsEqual(LegacyComparable.VALUES_BACKWARD, set));
}
- @SuppressWarnings({"deprecation", "static-access", "DoNotCall"})
+ @SuppressWarnings({"deprecation", "static-access"})
public void testBuilderMethod() {
try {
ImmutableSortedSet.builder();
diff --git a/guava-tests/test/com/google/common/collect/ImmutableTableTest.java b/guava-tests/test/com/google/common/collect/ImmutableTableTest.java
index d48938c..fdc1625 100644
--- a/guava-tests/test/com/google/common/collect/ImmutableTableTest.java
+++ b/guava-tests/test/com/google/common/collect/ImmutableTableTest.java
@@ -20,10 +20,13 @@
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.GwtIncompatible;
+import com.google.common.base.Equivalence;
+import com.google.common.base.MoreObjects;
import com.google.common.collect.Table.Cell;
import com.google.common.testing.CollectorTester;
import com.google.common.testing.SerializableTester;
import java.util.stream.Collector;
+import java.util.stream.Stream;
/**
* Tests common methods in {@link ImmutableTable}
@@ -41,26 +44,153 @@
return builder.build();
}
- // The bulk of the toImmutableTable tests can be found in TableCollectorsTest.
- // This gives minimal coverage to the forwarding functions
- public void testToImmutableTableSanityTest() {
+ public void testToImmutableTable() {
Collector<Cell<String, String, Integer>, ?, ImmutableTable<String, String, Integer>> collector =
- TableCollectors.toImmutableTable(Cell::getRowKey, Cell::getColumnKey, Cell::getValue);
- CollectorTester.of(collector)
- .expectCollects(ImmutableTable.of())
- .expectCollects(ImmutableTable.of("one", "uno", 1), Tables.immutableCell("one", "uno", 1));
+ ImmutableTable.toImmutableTable(Cell::getRowKey, Cell::getColumnKey, Cell::getValue);
+ Equivalence<ImmutableTable<String, String, Integer>> equivalence =
+ Equivalence.equals()
+ .<Cell<String, String, Integer>>pairwise()
+ .onResultOf(ImmutableTable::cellSet);
+ CollectorTester.of(collector, equivalence)
+ .expectCollects(
+ new ImmutableTable.Builder<String, String, Integer>()
+ .put("one", "uno", 1)
+ .put("two", "dos", 2)
+ .put("three", "tres", 3)
+ .build(),
+ Tables.immutableCell("one", "uno", 1),
+ Tables.immutableCell("two", "dos", 2),
+ Tables.immutableCell("three", "tres", 3));
}
- public void testToImmutableTableMergingSanityTest() {
+ public void testToImmutableTableConflict() {
Collector<Cell<String, String, Integer>, ?, ImmutableTable<String, String, Integer>> collector =
- TableCollectors.toImmutableTable(
+ ImmutableTable.toImmutableTable(Cell::getRowKey, Cell::getColumnKey, Cell::getValue);
+ try {
+ Stream.of(Tables.immutableCell("one", "uno", 1), Tables.immutableCell("one", "uno", 2))
+ .collect(collector);
+ fail("Expected IllegalArgumentException");
+ } catch (IllegalArgumentException expected) {
+ }
+ }
+
+ public void testToImmutableTableNullRowKey() {
+ Collector<Cell<String, String, Integer>, ?, ImmutableTable<String, String, Integer>> collector =
+ ImmutableTable.toImmutableTable(t -> null, Cell::getColumnKey, Cell::getValue);
+ try {
+ Stream.of(Tables.immutableCell("one", "uno", 1)).collect(collector);
+ fail("Expected NullPointerException");
+ } catch (NullPointerException expected) {
+ }
+ }
+
+ public void testToImmutableTableNullColumnKey() {
+ Collector<Cell<String, String, Integer>, ?, ImmutableTable<String, String, Integer>> collector =
+ ImmutableTable.toImmutableTable(Cell::getRowKey, t -> null, Cell::getValue);
+ try {
+ Stream.of(Tables.immutableCell("one", "uno", 1)).collect(collector);
+ fail("Expected NullPointerException");
+ } catch (NullPointerException expected) {
+ }
+ }
+
+ public void testToImmutableTableNullValue() {
+ Collector<Cell<String, String, Integer>, ?, ImmutableTable<String, String, Integer>> collector =
+ ImmutableTable.toImmutableTable(Cell::getRowKey, Cell::getColumnKey, t -> null);
+ try {
+ Stream.of(Tables.immutableCell("one", "uno", 1)).collect(collector);
+ fail("Expected NullPointerException");
+ } catch (NullPointerException expected) {
+ }
+ collector =
+ ImmutableTable.toImmutableTable(Cell::getRowKey, Cell::getColumnKey, Cell::getValue);
+ try {
+ Stream.of(
+ Tables.immutableCell("one", "uno", 1),
+ Tables.immutableCell("one", "uno", (Integer) null))
+ .collect(collector);
+ fail("Expected NullPointerException");
+ } catch (NullPointerException expected) {
+ }
+ }
+
+ public void testToImmutableTableMerging() {
+ Collector<Cell<String, String, Integer>, ?, ImmutableTable<String, String, Integer>> collector =
+ ImmutableTable.toImmutableTable(
Cell::getRowKey, Cell::getColumnKey, Cell::getValue, Integer::sum);
- CollectorTester.of(collector)
- .expectCollects(ImmutableTable.of())
+ Equivalence<ImmutableTable<String, String, Integer>> equivalence =
+ Equivalence.equals()
+ .<Cell<String, String, Integer>>pairwise()
+ .onResultOf(ImmutableTable::cellSet);
+ CollectorTester.of(collector, equivalence)
.expectCollects(
- ImmutableTable.of("one", "uno", 3),
+ new ImmutableTable.Builder<String, String, Integer>()
+ .put("one", "uno", 1)
+ .put("two", "dos", 6)
+ .put("three", "tres", 3)
+ .build(),
Tables.immutableCell("one", "uno", 1),
- Tables.immutableCell("one", "uno", 2));
+ Tables.immutableCell("two", "dos", 2),
+ Tables.immutableCell("three", "tres", 3),
+ Tables.immutableCell("two", "dos", 4));
+ }
+
+ public void testToImmutableTableMergingNullRowKey() {
+ Collector<Cell<String, String, Integer>, ?, ImmutableTable<String, String, Integer>> collector =
+ ImmutableTable.toImmutableTable(
+ t -> null, Cell::getColumnKey, Cell::getValue, Integer::sum);
+ try {
+ Stream.of(Tables.immutableCell("one", "uno", 1)).collect(collector);
+ fail("Expected NullPointerException");
+ } catch (NullPointerException expected) {
+ }
+ }
+
+ public void testToImmutableTableMergingNullColumnKey() {
+ Collector<Cell<String, String, Integer>, ?, ImmutableTable<String, String, Integer>> collector =
+ ImmutableTable.toImmutableTable(Cell::getRowKey, t -> null, Cell::getValue, Integer::sum);
+ try {
+ Stream.of(Tables.immutableCell("one", "uno", 1)).collect(collector);
+ fail("Expected NullPointerException");
+ } catch (NullPointerException expected) {
+ }
+ }
+
+ public void testToImmutableTableMergingNullValue() {
+ Collector<Cell<String, String, Integer>, ?, ImmutableTable<String, String, Integer>> collector =
+ ImmutableTable.toImmutableTable(
+ Cell::getRowKey, Cell::getColumnKey, t -> null, Integer::sum);
+ try {
+ Stream.of(Tables.immutableCell("one", "uno", 1)).collect(collector);
+ fail("Expected NullPointerException");
+ } catch (NullPointerException expected) {
+ }
+ collector =
+ ImmutableTable.toImmutableTable(
+ Cell::getRowKey,
+ Cell::getColumnKey,
+ Cell::getValue,
+ (i, j) -> MoreObjects.firstNonNull(i, 0) + MoreObjects.firstNonNull(j, 0));
+ try {
+ Stream.of(
+ Tables.immutableCell("one", "uno", 1),
+ Tables.immutableCell("one", "uno", (Integer) null))
+ .collect(collector);
+ fail("Expected NullPointerException");
+ } catch (NullPointerException expected) {
+ }
+ }
+
+ public void testToImmutableTableMergingNullMerge() {
+ Collector<Cell<String, String, Integer>, ?, ImmutableTable<String, String, Integer>> collector =
+ ImmutableTable.toImmutableTable(
+ Cell::getRowKey, Cell::getColumnKey, Cell::getValue, (v1, v2) -> null);
+ try {
+ Stream.of(Tables.immutableCell("one", "uno", 1), Tables.immutableCell("one", "uno", 2))
+ .collect(collector);
+ fail("Expected NullPointerException");
+ } catch (NullPointerException expected) {
+ }
}
public void testBuilder() {
diff --git a/guava-tests/test/com/google/common/collect/InternersTest.java b/guava-tests/test/com/google/common/collect/InternersTest.java
index cfa14b8..08bdc53 100644
--- a/guava-tests/test/com/google/common/collect/InternersTest.java
+++ b/guava-tests/test/com/google/common/collect/InternersTest.java
@@ -84,7 +84,6 @@
assertEquals(concurrencyLevel, internerImpl.map.concurrencyLevel);
}
-
public void testWeak_afterGC() throws InterruptedException {
Integer canonical = new Integer(5);
Integer not = new Integer(5);
diff --git a/guava-tests/test/com/google/common/collect/MoreCollectorsTest.java b/guava-tests/test/com/google/common/collect/MoreCollectorsTest.java
index 65a8971..f5c5f26 100644
--- a/guava-tests/test/com/google/common/collect/MoreCollectorsTest.java
+++ b/guava-tests/test/com/google/common/collect/MoreCollectorsTest.java
@@ -57,14 +57,6 @@
}
}
- public void testToOptionalMultipleWithNull() {
- try {
- Stream.of(1, null).collect(MoreCollectors.toOptional());
- fail("Expected NullPointerException");
- } catch (NullPointerException expected) {
- }
- }
-
public void testToOptionalMany() {
try {
Stream.of(1, 2, 3, 4, 5, 6).collect(MoreCollectors.toOptional());
diff --git a/guava-tests/test/com/google/common/collect/QueuesTest.java b/guava-tests/test/com/google/common/collect/QueuesTest.java
index ba5f4f0..9b45116 100644
--- a/guava-tests/test/com/google/common/collect/QueuesTest.java
+++ b/guava-tests/test/com/google/common/collect/QueuesTest.java
@@ -101,15 +101,15 @@
private void testMultipleProducers(BlockingQueue<Object> q) throws InterruptedException {
for (boolean interruptibly : new boolean[] {true, false}) {
- @SuppressWarnings("unused") // https://errorprone.info/bugpattern/FutureReturnValueIgnored
+ @SuppressWarnings("unused") // go/futurereturn-lsc
Future<?> possiblyIgnoredError = threadPool.submit(new Producer(q, 20));
- @SuppressWarnings("unused") // https://errorprone.info/bugpattern/FutureReturnValueIgnored
+ @SuppressWarnings("unused") // go/futurereturn-lsc
Future<?> possiblyIgnoredError1 = threadPool.submit(new Producer(q, 20));
- @SuppressWarnings("unused") // https://errorprone.info/bugpattern/FutureReturnValueIgnored
+ @SuppressWarnings("unused") // go/futurereturn-lsc
Future<?> possiblyIgnoredError2 = threadPool.submit(new Producer(q, 20));
- @SuppressWarnings("unused") // https://errorprone.info/bugpattern/FutureReturnValueIgnored
+ @SuppressWarnings("unused") // go/futurereturn-lsc
Future<?> possiblyIgnoredError3 = threadPool.submit(new Producer(q, 20));
- @SuppressWarnings("unused") // https://errorprone.info/bugpattern/FutureReturnValueIgnored
+ @SuppressWarnings("unused") // go/futurereturn-lsc
Future<?> possiblyIgnoredError4 = threadPool.submit(new Producer(q, 20));
List<Object> buf = newArrayList();
@@ -182,7 +182,7 @@
}
private void testNegativeMaxElements(BlockingQueue<Object> q) throws InterruptedException {
- @SuppressWarnings("unused") // https://errorprone.info/bugpattern/FutureReturnValueIgnored
+ @SuppressWarnings("unused") // go/futurereturn-lsc
Future<?> possiblyIgnoredError = threadPool.submit(new Producer(q, 1));
List<Object> buf = newArrayList();
@@ -201,7 +201,7 @@
}
private void testDrain_throws(BlockingQueue<Object> q) {
- @SuppressWarnings("unused") // https://errorprone.info/bugpattern/FutureReturnValueIgnored
+ @SuppressWarnings("unused") // go/futurereturn-lsc
Future<?> possiblyIgnoredError = threadPool.submit(new Interrupter(currentThread()));
try {
Queues.drain(q, ImmutableList.of(), 100, MAX_VALUE, NANOSECONDS);
@@ -218,7 +218,7 @@
private void testDrainUninterruptibly_doesNotThrow(final BlockingQueue<Object> q) {
final Thread mainThread = currentThread();
- @SuppressWarnings("unused") // https://errorprone.info/bugpattern/FutureReturnValueIgnored
+ @SuppressWarnings("unused") // go/futurereturn-lsc
Future<?> possiblyIgnoredError =
threadPool.submit(
new Callable<Void>() {
@@ -276,7 +276,7 @@
}
// but does the wait actually occurs?
- @SuppressWarnings("unused") // https://errorprone.info/bugpattern/FutureReturnValueIgnored
+ @SuppressWarnings("unused") // go/futurereturn-lsc
Future<?> possiblyIgnoredError = threadPool.submit(new Interrupter(currentThread()));
try {
// if waiting works, this should get stuck
@@ -292,7 +292,7 @@
assertEquals(0, Queues.drainUninterruptibly(q, ImmutableList.of(), 0, 10, MILLISECONDS));
// but does the wait actually occurs?
- @SuppressWarnings("unused") // https://errorprone.info/bugpattern/FutureReturnValueIgnored
+ @SuppressWarnings("unused") // go/futurereturn-lsc
Future<?> possiblyIgnoredError = threadPool.submit(new Interrupter(currentThread()));
Stopwatch timer = Stopwatch.createStarted();
diff --git a/guava-tests/test/com/google/common/collect/SynchronizedDequeTest.java b/guava-tests/test/com/google/common/collect/SynchronizedDequeTest.java
index 1df6aa1..0a11b27 100644
--- a/guava-tests/test/com/google/common/collect/SynchronizedDequeTest.java
+++ b/guava-tests/test/com/google/common/collect/SynchronizedDequeTest.java
@@ -254,7 +254,6 @@
private static final long serialVersionUID = 0;
}
- @SuppressWarnings("CheckReturnValue")
public void testHoldsLockOnAllOperations() {
create().element();
create().offer("foo");
@@ -264,8 +263,8 @@
create().add("foo");
create().addAll(ImmutableList.of("foo"));
create().clear();
- create().contains("foo");
- create().containsAll(ImmutableList.of("foo"));
+ boolean unused = create().contains("foo");
+ boolean unused2 = create().containsAll(ImmutableList.of("foo"));
create().equals(new ArrayDeque<>(ImmutableList.of("foo")));
create().hashCode();
create().isEmpty();
diff --git a/guava-tests/test/com/google/common/collect/SynchronizedMapTest.java b/guava-tests/test/com/google/common/collect/SynchronizedMapTest.java
index b07802a..34d1c6f 100644
--- a/guava-tests/test/com/google/common/collect/SynchronizedMapTest.java
+++ b/guava-tests/test/com/google/common/collect/SynchronizedMapTest.java
@@ -159,11 +159,11 @@
*/
public void testSize() {
- int unused = create().size();
+ create().size();
}
public void testIsEmpty() {
- boolean unused = create().isEmpty();
+ create().isEmpty();
}
public void testRemove() {
diff --git a/guava-tests/test/com/google/common/collect/SynchronizedQueueTest.java b/guava-tests/test/com/google/common/collect/SynchronizedQueueTest.java
index 1e2290d..ac48846 100644
--- a/guava-tests/test/com/google/common/collect/SynchronizedQueueTest.java
+++ b/guava-tests/test/com/google/common/collect/SynchronizedQueueTest.java
@@ -153,7 +153,6 @@
private static final long serialVersionUID = 0;
}
- @SuppressWarnings("CheckReturnValue")
public void testHoldsLockOnAllOperations() {
create().element();
create().offer("foo");
@@ -163,8 +162,8 @@
create().add("foo");
create().addAll(ImmutableList.of("foo"));
create().clear();
- create().contains("foo");
- create().containsAll(ImmutableList.of("foo"));
+ boolean unused = create().contains("foo");
+ boolean unused2 = create().containsAll(ImmutableList.of("foo"));
create().equals(new ArrayDeque<>(ImmutableList.of("foo")));
create().hashCode();
create().isEmpty();
diff --git a/guava-tests/test/com/google/common/collect/TableCollectorsTest.java b/guava-tests/test/com/google/common/collect/TableCollectorsTest.java
deleted file mode 100644
index 98b7074..0000000
--- a/guava-tests/test/com/google/common/collect/TableCollectorsTest.java
+++ /dev/null
@@ -1,282 +0,0 @@
-/*
- * Copyright (C) 2009 The Guava Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.common.collect;
-
-import static com.google.common.collect.Tables.immutableCell;
-
-import com.google.common.annotations.GwtCompatible;
-import com.google.common.base.Equivalence;
-import com.google.common.base.Function;
-import com.google.common.base.MoreObjects;
-import com.google.common.collect.Table.Cell;
-import com.google.common.testing.CollectorTester;
-import java.util.function.BiPredicate;
-import java.util.stream.Collector;
-import java.util.stream.Stream;
-import junit.framework.TestCase;
-
-/** Unit tests for {@link TableCollectors}. */
-@GwtCompatible(emulated = true)
-public class TableCollectorsTest {
-
- public static final class ToImmutableTableTest extends TestCase {
- public void testToImmutableTable() {
- Collector<Cell<String, String, Integer>, ?, ImmutableTable<String, String, Integer>>
- collector =
- TableCollectors.toImmutableTable(Cell::getRowKey, Cell::getColumnKey, Cell::getValue);
- BiPredicate<ImmutableTable<String, String, Integer>, ImmutableTable<String, String, Integer>>
- equivalence = pairwiseOnResultOf(ImmutableTable::cellSet);
- CollectorTester.of(collector, equivalence)
- .expectCollects(
- new ImmutableTable.Builder<String, String, Integer>()
- .put("one", "uno", 1)
- .put("two", "dos", 2)
- .put("three", "tres", 3)
- .build(),
- immutableCell("one", "uno", 1),
- immutableCell("two", "dos", 2),
- immutableCell("three", "tres", 3));
- }
-
- public void testToImmutableTableConflict() {
- Collector<Cell<String, String, Integer>, ?, ImmutableTable<String, String, Integer>>
- collector =
- TableCollectors.toImmutableTable(Cell::getRowKey, Cell::getColumnKey, Cell::getValue);
- try {
- Stream.of(immutableCell("one", "uno", 1), immutableCell("one", "uno", 2))
- .collect(collector);
- fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
- }
- }
-
- public void testToImmutableTableNullRowKey() {
- Collector<Cell<String, String, Integer>, ?, ImmutableTable<String, String, Integer>>
- collector =
- TableCollectors.toImmutableTable(t -> null, Cell::getColumnKey, Cell::getValue);
- try {
- Stream.of(immutableCell("one", "uno", 1)).collect(collector);
- fail("Expected NullPointerException");
- } catch (NullPointerException expected) {
- }
- }
-
- public void testToImmutableTableNullColumnKey() {
- Collector<Cell<String, String, Integer>, ?, ImmutableTable<String, String, Integer>>
- collector = TableCollectors.toImmutableTable(Cell::getRowKey, t -> null, Cell::getValue);
- try {
- Stream.of(immutableCell("one", "uno", 1)).collect(collector);
- fail("Expected NullPointerException");
- } catch (NullPointerException expected) {
- }
- }
-
- public void testToImmutableTableNullValue() {
- Collector<Cell<String, String, Integer>, ?, ImmutableTable<String, String, Integer>>
- collector =
- TableCollectors.toImmutableTable(Cell::getRowKey, Cell::getColumnKey, t -> null);
- try {
- Stream.of(immutableCell("one", "uno", 1)).collect(collector);
- fail("Expected NullPointerException");
- } catch (NullPointerException expected) {
- }
- collector =
- TableCollectors.toImmutableTable(Cell::getRowKey, Cell::getColumnKey, Cell::getValue);
- try {
- Stream.of(immutableCell("one", "uno", 1), immutableCell("one", "uno", (Integer) null))
- .collect(collector);
- fail("Expected NullPointerException");
- } catch (NullPointerException expected) {
- }
- }
-
- public void testToImmutableTableMerging() {
- Collector<Cell<String, String, Integer>, ?, ImmutableTable<String, String, Integer>>
- collector =
- TableCollectors.toImmutableTable(
- Cell::getRowKey, Cell::getColumnKey, Cell::getValue, Integer::sum);
- BiPredicate<ImmutableTable<String, String, Integer>, ImmutableTable<String, String, Integer>>
- equivalence = pairwiseOnResultOf(ImmutableTable::cellSet);
- CollectorTester.of(collector, equivalence)
- .expectCollects(
- new ImmutableTable.Builder<String, String, Integer>()
- .put("one", "uno", 1)
- .put("two", "dos", 6)
- .put("three", "tres", 3)
- .build(),
- immutableCell("one", "uno", 1),
- immutableCell("two", "dos", 2),
- immutableCell("three", "tres", 3),
- immutableCell("two", "dos", 4));
- }
-
- public void testToImmutableTableMergingNullRowKey() {
- Collector<Cell<String, String, Integer>, ?, ImmutableTable<String, String, Integer>>
- collector =
- TableCollectors.toImmutableTable(
- t -> null, Cell::getColumnKey, Cell::getValue, Integer::sum);
- try {
- Stream.of(immutableCell("one", "uno", 1)).collect(collector);
- fail("Expected NullPointerException");
- } catch (NullPointerException expected) {
- }
- }
-
- public void testToImmutableTableMergingNullColumnKey() {
- Collector<Cell<String, String, Integer>, ?, ImmutableTable<String, String, Integer>>
- collector =
- TableCollectors.toImmutableTable(
- Cell::getRowKey, t -> null, Cell::getValue, Integer::sum);
- try {
- Stream.of(immutableCell("one", "uno", 1)).collect(collector);
- fail("Expected NullPointerException");
- } catch (NullPointerException expected) {
- }
- }
-
- public void testToImmutableTableMergingNullValue() {
- Collector<Cell<String, String, Integer>, ?, ImmutableTable<String, String, Integer>>
- collector =
- TableCollectors.toImmutableTable(
- Cell::getRowKey, Cell::getColumnKey, t -> null, Integer::sum);
- try {
- Stream.of(immutableCell("one", "uno", 1)).collect(collector);
- fail("Expected NullPointerException");
- } catch (NullPointerException expected) {
- }
- collector =
- TableCollectors.toImmutableTable(
- Cell::getRowKey,
- Cell::getColumnKey,
- Cell::getValue,
- (i, j) -> MoreObjects.firstNonNull(i, 0) + MoreObjects.firstNonNull(j, 0));
- try {
- Stream.of(immutableCell("one", "uno", 1), immutableCell("one", "uno", (Integer) null))
- .collect(collector);
- fail("Expected NullPointerException");
- } catch (NullPointerException expected) {
- }
- }
-
- public void testToImmutableTableMergingNullMerge() {
- Collector<Cell<String, String, Integer>, ?, ImmutableTable<String, String, Integer>>
- collector =
- TableCollectors.toImmutableTable(
- Cell::getRowKey, Cell::getColumnKey, Cell::getValue, (v1, v2) -> null);
- try {
- Stream.of(immutableCell("one", "uno", 1), immutableCell("one", "uno", 2))
- .collect(collector);
- fail("Expected NullPointerException");
- } catch (NullPointerException expected) {
- }
- }
- }
-
- public static final class ToTableTest extends TestCase {
-
- public void testToTable() {
- Collector<Cell<String, String, Integer>, ?, Table<String, String, Integer>> collector =
- TableCollectors.toTable(
- Cell::getRowKey, Cell::getColumnKey, Cell::getValue, HashBasedTable::create);
- BiPredicate<Table<String, String, Integer>, Table<String, String, Integer>> equivalence =
- pairwiseOnResultOf(Table::cellSet);
- CollectorTester.of(collector, equivalence)
- .expectCollects(
- new ImmutableTable.Builder<String, String, Integer>()
- .put("one", "uno", 1)
- .put("two", "dos", 2)
- .put("three", "tres", 3)
- .build(),
- immutableCell("one", "uno", 1),
- immutableCell("two", "dos", 2),
- immutableCell("three", "tres", 3));
- }
-
- public void testToTableNullMerge() {
- Collector<Cell<String, String, Integer>, ?, Table<String, String, Integer>> collector =
- TableCollectors.toTable(
- Cell::getRowKey,
- Cell::getColumnKey,
- Cell::getValue,
- (Integer v1, Integer v2) -> null,
- HashBasedTable::create);
- BiPredicate<Table<String, String, Integer>, Table<String, String, Integer>> equivalence =
- pairwiseOnResultOf(Table::cellSet);
- CollectorTester.of(collector, equivalence)
- .expectCollects(
- ImmutableTable.of(), immutableCell("one", "uno", 1), immutableCell("one", "uno", 2));
- }
-
- public void testToTableNullValues() {
- Collector<Cell<String, String, Integer>, ?, Table<String, String, Integer>> collector =
- TableCollectors.toTable(
- Cell::getRowKey,
- Cell::getColumnKey,
- Cell::getValue,
- () -> ArrayTable.create(ImmutableList.of("one"), ImmutableList.of("uno")));
- try {
- Stream.of(immutableCell("one", "uno", (Integer) null)).collect(collector);
- fail("Expected NullPointerException");
- } catch (NullPointerException expected) {
- }
- }
-
- public void testToTableConflict() {
- Collector<Cell<String, String, Integer>, ?, Table<String, String, Integer>> collector =
- TableCollectors.toTable(
- Cell::getRowKey, Cell::getColumnKey, Cell::getValue, HashBasedTable::create);
- try {
- Stream.of(immutableCell("one", "uno", 1), immutableCell("one", "uno", 2))
- .collect(collector);
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
- }
-
- public void testToTableMerging() {
- Collector<Cell<String, String, Integer>, ?, Table<String, String, Integer>> collector =
- TableCollectors.toTable(
- Cell::getRowKey,
- Cell::getColumnKey,
- Cell::getValue,
- Integer::sum,
- HashBasedTable::create);
- BiPredicate<Table<String, String, Integer>, Table<String, String, Integer>> equivalence =
- pairwiseOnResultOf(Table::cellSet);
- CollectorTester.of(collector, equivalence)
- .expectCollects(
- new ImmutableTable.Builder<String, String, Integer>()
- .put("one", "uno", 1)
- .put("two", "dos", 6)
- .put("three", "tres", 3)
- .build(),
- immutableCell("one", "uno", 1),
- immutableCell("two", "dos", 2),
- immutableCell("three", "tres", 3),
- immutableCell("two", "dos", 4));
- }
- }
-
- // This function specifically returns a BiPredicate, because Guava7’s Equivalence class does not
- // actually implement BiPredicate, and CollectorTests expects a BiPredicate.
- static <C, E, R extends Iterable<E>> BiPredicate<C, C> pairwiseOnResultOf(Function<C, R> arg) {
- Equivalence<C> equivalence = Equivalence.equals().<E>pairwise().onResultOf(arg);
- return equivalence::equivalent;
- }
-
- private TableCollectorsTest() {}
-}
diff --git a/guava-tests/test/com/google/common/collect/TablesTest.java b/guava-tests/test/com/google/common/collect/TablesTest.java
index dd56614..084d391 100644
--- a/guava-tests/test/com/google/common/collect/TablesTest.java
+++ b/guava-tests/test/com/google/common/collect/TablesTest.java
@@ -18,11 +18,13 @@
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.GwtIncompatible;
+import com.google.common.base.Equivalence;
import com.google.common.collect.Table.Cell;
import com.google.common.testing.CollectorTester;
import com.google.common.testing.EqualsTester;
import com.google.common.testing.SerializableTester;
import java.util.stream.Collector;
+import java.util.stream.Stream;
import junit.framework.TestCase;
/**
@@ -33,19 +35,66 @@
@GwtCompatible(emulated = true)
public class TablesTest extends TestCase {
- // The bulk of the toTable tests can be found in TableCollectorsTest.
- // This gives minimal coverage to the forwarding functions
- public void testToTableSanityTest() {
+ public void testToTable() {
Collector<Cell<String, String, Integer>, ?, Table<String, String, Integer>> collector =
Tables.toTable(Cell::getRowKey, Cell::getColumnKey, Cell::getValue, HashBasedTable::create);
- HashBasedTable<String, String, Integer> expected = HashBasedTable.create();
- expected.put("one", "uno", 1);
- CollectorTester.of(collector)
- .expectCollects(HashBasedTable.create())
- .expectCollects(expected, Tables.immutableCell("one", "uno", 1));
+ Equivalence<Table<String, String, Integer>> equivalence =
+ Equivalence.equals().<Cell<String, String, Integer>>pairwise().onResultOf(Table::cellSet);
+ CollectorTester.of(collector, equivalence)
+ .expectCollects(
+ new ImmutableTable.Builder<String, String, Integer>()
+ .put("one", "uno", 1)
+ .put("two", "dos", 2)
+ .put("three", "tres", 3)
+ .build(),
+ Tables.immutableCell("one", "uno", 1),
+ Tables.immutableCell("two", "dos", 2),
+ Tables.immutableCell("three", "tres", 3));
}
- public void testToTableMergingSanityTest() {
+ public void testToTableNullMerge() {
+ Collector<Cell<String, String, Integer>, ?, Table<String, String, Integer>> collector =
+ Tables.toTable(
+ Cell::getRowKey,
+ Cell::getColumnKey,
+ Cell::getValue,
+ (Integer v1, Integer v2) -> null,
+ HashBasedTable::create);
+ Equivalence<Table<String, String, Integer>> equivalence =
+ Equivalence.equals().<Cell<String, String, Integer>>pairwise().onResultOf(Table::cellSet);
+ CollectorTester.of(collector, equivalence)
+ .expectCollects(
+ ImmutableTable.of(),
+ Tables.immutableCell("one", "uno", 1),
+ Tables.immutableCell("one", "uno", 2));
+ }
+
+ public void testToTableNullValues() {
+ Collector<Cell<String, String, Integer>, ?, Table<String, String, Integer>> collector =
+ Tables.toTable(
+ Cell::getRowKey,
+ Cell::getColumnKey,
+ Cell::getValue,
+ () -> ArrayTable.create(ImmutableList.of("one"), ImmutableList.of("uno")));
+ try {
+ Stream.of(Tables.immutableCell("one", "uno", (Integer) null)).collect(collector);
+ fail("Expected NullPointerException");
+ } catch (NullPointerException expected) {
+ }
+ }
+
+ public void testToTableConflict() {
+ Collector<Cell<String, String, Integer>, ?, Table<String, String, Integer>> collector =
+ Tables.toTable(Cell::getRowKey, Cell::getColumnKey, Cell::getValue, HashBasedTable::create);
+ try {
+ Stream.of(Tables.immutableCell("one", "uno", 1), Tables.immutableCell("one", "uno", 2))
+ .collect(collector);
+ fail("Expected IllegalStateException");
+ } catch (IllegalStateException expected) {
+ }
+ }
+
+ public void testToTableMerging() {
Collector<Cell<String, String, Integer>, ?, Table<String, String, Integer>> collector =
Tables.toTable(
Cell::getRowKey,
@@ -53,12 +102,19 @@
Cell::getValue,
Integer::sum,
HashBasedTable::create);
- HashBasedTable<String, String, Integer> expected = HashBasedTable.create();
- expected.put("one", "uno", 3);
- CollectorTester.of(collector)
- .expectCollects(HashBasedTable.create())
+ Equivalence<Table<String, String, Integer>> equivalence =
+ Equivalence.equals().<Cell<String, String, Integer>>pairwise().onResultOf(Table::cellSet);
+ CollectorTester.of(collector, equivalence)
.expectCollects(
- expected, Tables.immutableCell("one", "uno", 1), Tables.immutableCell("one", "uno", 2));
+ new ImmutableTable.Builder<String, String, Integer>()
+ .put("one", "uno", 1)
+ .put("two", "dos", 6)
+ .put("three", "tres", 3)
+ .build(),
+ Tables.immutableCell("one", "uno", 1),
+ Tables.immutableCell("two", "dos", 2),
+ Tables.immutableCell("three", "tres", 3),
+ Tables.immutableCell("two", "dos", 4));
}
@GwtIncompatible // SerializableTester
diff --git a/guava-tests/test/com/google/common/collect/TopKSelectorTest.java b/guava-tests/test/com/google/common/collect/TopKSelectorTest.java
index 2cebdc3..e21f817 100644
--- a/guava-tests/test/com/google/common/collect/TopKSelectorTest.java
+++ b/guava-tests/test/com/google/common/collect/TopKSelectorTest.java
@@ -18,7 +18,6 @@
import static com.google.common.truth.Truth.assertThat;
-import com.google.common.annotations.GwtCompatible;
import com.google.common.math.IntMath;
import com.google.common.primitives.Ints;
import java.math.RoundingMode;
@@ -32,7 +31,6 @@
*
* @author Louis Wasserman
*/
-@GwtCompatible
public class TopKSelectorTest extends TestCase {
public void testNegativeK() {
@@ -121,13 +119,4 @@
assertThat(top.topK()).containsExactlyElementsIn(Collections.nCopies(k, 0));
assertThat(compareCalls[0]).isAtMost(10L * n * IntMath.log2(k, RoundingMode.CEILING));
}
-
- public void testExceedMaxIteration() {
- /*
- * Bug #5692 occurred when TopKSelector called Arrays.sort incorrectly.
- */
- TopKSelector<Integer> top = TopKSelector.least(7);
- top.offerAll(Ints.asList(5, 7, 6, 2, 4, 3, 1, 0, 0, 0, 0, 0, 0, 0));
- assertThat(top.topK()).isEqualTo(Ints.asList(0, 0, 0, 0, 0, 0, 0));
- }
}
diff --git a/guava-tests/test/com/google/common/collect/TreeRangeMapTest.java b/guava-tests/test/com/google/common/collect/TreeRangeMapTest.java
index 9e57bba..d8ff908 100644
--- a/guava-tests/test/com/google/common/collect/TreeRangeMapTest.java
+++ b/guava-tests/test/com/google/common/collect/TreeRangeMapTest.java
@@ -690,7 +690,6 @@
}
}
-
public void testSubRangeMapExhaustive() {
for (Range<Integer> range1 : RANGES) {
for (Range<Integer> range2 : RANGES) {
diff --git a/guava-tests/test/com/google/common/collect/TreeRangeSetTest.java b/guava-tests/test/com/google/common/collect/TreeRangeSetTest.java
index b33ab2d..498a1a1 100644
--- a/guava-tests/test/com/google/common/collect/TreeRangeSetTest.java
+++ b/guava-tests/test/com/google/common/collect/TreeRangeSetTest.java
@@ -271,7 +271,6 @@
return expected;
}
-
public void testSubRangeSet() {
for (Range<Integer> range1 : QUERY_RANGES) {
for (Range<Integer> range2 : QUERY_RANGES) {
@@ -310,7 +309,6 @@
}
}
-
public void testSubRangeSetOfComplement() {
for (Range<Integer> range1 : QUERY_RANGES) {
for (Range<Integer> range2 : QUERY_RANGES) {
@@ -326,7 +324,6 @@
}
}
-
public void testComplementOfSubRangeSet() {
for (Range<Integer> range1 : QUERY_RANGES) {
for (Range<Integer> range2 : QUERY_RANGES) {
diff --git a/guava-tests/test/com/google/common/graph/AbstractNetworkTest.java b/guava-tests/test/com/google/common/graph/AbstractNetworkTest.java
index e5e8e7f..889f0fb 100644
--- a/guava-tests/test/com/google/common/graph/AbstractNetworkTest.java
+++ b/guava-tests/test/com/google/common/graph/AbstractNetworkTest.java
@@ -792,7 +792,6 @@
assertThat(network.edgesConnecting(N1, N2)).containsExactly(E12);
}
-
@Test
public void concurrentIteration() throws Exception {
addEdge(1, 2, "foo");
diff --git a/guava-tests/test/com/google/common/graph/MapCacheTest.java b/guava-tests/test/com/google/common/graph/MapCacheTest.java
index f04f010..f66b19b 100644
--- a/guava-tests/test/com/google/common/graph/MapCacheTest.java
+++ b/guava-tests/test/com/google/common/graph/MapCacheTest.java
@@ -90,4 +90,25 @@
assertThat(mapCache.remove(fooReference2)).isEqualTo("bar");
assertThat(mapCache.get(fooReference1)).isNull();
}
+
+ @Test
+ public void testHandleNulls() {
+ mapCache.put("foo", "bar");
+ mapCache.put("non-null key", null);
+ mapCache.put(null, "non-null value");
+
+ assertThat(mapCache.get("foo")).isEqualTo("bar");
+ assertThat(mapCache.get("non-null key")).isNull();
+ assertThat(mapCache.get(null)).isEqualTo("non-null value");
+
+ assertThat(mapCache.containsKey("foo")).isTrue();
+ assertThat(mapCache.containsKey("bar")).isFalse();
+ assertThat(mapCache.containsKey("non-null key")).isTrue();
+ assertThat(mapCache.containsKey(null)).isTrue();
+
+ // Test again - in reverse order.
+ assertThat(mapCache.get(null)).isEqualTo("non-null value");
+ assertThat(mapCache.get("non-null key")).isNull();
+ assertThat(mapCache.get("foo")).isEqualTo("bar");
+ }
}
diff --git a/guava-tests/test/com/google/common/graph/ValueGraphTest.java b/guava-tests/test/com/google/common/graph/ValueGraphTest.java
index 31d41aa..edc2631 100644
--- a/guava-tests/test/com/google/common/graph/ValueGraphTest.java
+++ b/guava-tests/test/com/google/common/graph/ValueGraphTest.java
@@ -440,7 +440,6 @@
.inOrder();
}
-
@Test
public void concurrentIteration() throws Exception {
graph = ValueGraphBuilder.directed().build();
diff --git a/guava-tests/test/com/google/common/hash/BloomFilterTest.java b/guava-tests/test/com/google/common/hash/BloomFilterTest.java
index 411e097..7c21044 100644
--- a/guava-tests/test/com/google/common/hash/BloomFilterTest.java
+++ b/guava-tests/test/com/google/common/hash/BloomFilterTest.java
@@ -535,7 +535,6 @@
assertEquals(BloomFilterStrategies.MURMUR128_MITZ_64, BloomFilterStrategies.values()[1]);
}
-
public void testNoRaceConditions() throws Exception {
final BloomFilter<Integer> bloomFilter =
BloomFilter.create(Funnels.integerFunnel(), 15_000_000, 0.01);
diff --git a/guava-tests/test/com/google/common/hash/Crc32cHashFunctionTest.java b/guava-tests/test/com/google/common/hash/Crc32cHashFunctionTest.java
index 3bea975..4619cec 100644
--- a/guava-tests/test/com/google/common/hash/Crc32cHashFunctionTest.java
+++ b/guava-tests/test/com/google/common/hash/Crc32cHashFunctionTest.java
@@ -17,7 +17,6 @@
import static com.google.common.base.Charsets.UTF_8;
import java.util.Arrays;
-import java.util.Random;
import junit.framework.TestCase;
/**
@@ -27,22 +26,14 @@
* @author Kurt Alfred Kluever
*/
public class Crc32cHashFunctionTest extends TestCase {
- public void testEmpty() {
- assertCrc(0, new byte[0]);
- }
public void testZeros() {
// Test 32 byte array of 0x00.
byte[] zeros = new byte[32];
+ Arrays.fill(zeros, (byte) 0x00);
assertCrc(0x8a9136aa, zeros);
}
- public void testZeros100() {
- // Test 100 byte array of 0x00.
- byte[] zeros = new byte[100];
- assertCrc(0x07cb9ff6, zeros);
- }
-
public void testFull() {
// Test 32 byte array of 0xFF.
byte[] fulls = new byte[32];
@@ -50,13 +41,6 @@
assertCrc(0x62a8ab43, fulls);
}
- public void testFull100() {
- // Test 100 byte array of 0xFF.
- byte[] fulls = new byte[100];
- Arrays.fill(fulls, (byte) 0xFF);
- assertCrc(0xbc753add, fulls);
- }
-
public void testAscending() {
// Test 32 byte arrays of ascending.
byte[] ascending = new byte[32];
@@ -75,15 +59,6 @@
assertCrc(0x113fdb5c, descending);
}
- public void testDescending100() {
- // Test 100 byte arrays of descending.
- byte[] descending = new byte[100];
- for (int i = 0; i < 100; i++) {
- descending[i] = (byte) (99 - i);
- }
- assertCrc(0xd022db97, descending);
- }
-
public void testScsiReadCommand() {
// Test SCSI read command.
byte[] scsiReadCommand =
@@ -112,23 +87,6 @@
assertCrc(0xBFE92A83, "23456789".getBytes(UTF_8));
}
- public void testAgainstSimplerImplementation() {
- Random r = new Random(1234567);
- for (int length = 0; length < 1000; length++) {
- byte[] bytes = new byte[length];
- r.nextBytes(bytes);
- assertCrc(referenceCrc(bytes), bytes);
- }
- }
-
- private static int referenceCrc(byte[] bytes) {
- int crc = ~0;
- for (byte b : bytes) {
- crc = (crc >>> 8) ^ Crc32cHashFunction.Crc32cHasher.BYTE_TABLE[(crc ^ b) & 0xFF];
- }
- return ~crc;
- }
-
/**
* Verifies that the crc of an array of byte data matches the expected value.
*
@@ -137,15 +95,7 @@
*/
private static void assertCrc(int expectedCrc, byte[] data) {
int actualCrc = Hashing.crc32c().hashBytes(data).asInt();
- assertEquals(
- String.format("expected: %08x, actual: %08x", expectedCrc, actualCrc),
- expectedCrc,
- actualCrc);
- int actualCrcHasher = Hashing.crc32c().newHasher().putBytes(data).hash().asInt();
- assertEquals(
- String.format("expected: %08x, actual: %08x", expectedCrc, actualCrc),
- expectedCrc,
- actualCrcHasher);
+ assertEquals(expectedCrc, actualCrc);
}
// From RFC 3720, Section 12.1, the polynomial generator is 0x11EDC6F41.
@@ -155,7 +105,7 @@
private static final int CRC32C_GENERATOR = 0x1EDC6F41; // 0x11EDC6F41
private static final int CRC32C_GENERATOR_FLIPPED = Integer.reverse(CRC32C_GENERATOR);
- public void testCrc32cByteTable() {
+ public void testCrc32cLookupTable() {
// See Hacker's Delight 2nd Edition, Figure 14-7.
int[] expected = new int[256];
for (int i = 0; i < expected.length; i++) {
@@ -167,47 +117,9 @@
expected[i] = crc;
}
- int[] actual = Crc32cHashFunction.Crc32cHasher.BYTE_TABLE;
+ int[] actual = Crc32cHashFunction.Crc32cHasher.CRC_TABLE;
assertTrue(
"Expected: \n" + Arrays.toString(expected) + "\nActual:\n" + Arrays.toString(actual),
Arrays.equals(expected, actual));
}
-
- static int advanceOneBit(int next) {
- if ((next & 1) != 0) {
- return (next >>> 1) ^ CRC32C_GENERATOR_FLIPPED;
- } else {
- return next >>> 1;
- }
- }
-
- public void testCrc32cStrideTable() {
- int next = CRC32C_GENERATOR_FLIPPED;
- for (int i = 0; i < 12; i++) { // for 3 ints = 12 bytes in between each stride window
- next = (next >>> 8) ^ Crc32cHashFunction.Crc32cHasher.BYTE_TABLE[next & 0xFF];
- }
- int[][] expected = new int[4][256];
- for (int b = 0; b < 4; ++b) {
- for (int bit = 128; bit != 0; bit >>= 1) {
- expected[b][bit] = next;
- next = advanceOneBit(next);
- }
- }
- for (int b = 0; b < 4; ++b) {
- expected[b][0] = 0;
- for (int bit = 2; bit < 256; bit <<= 1) {
- for (int i = bit + 1; i < (bit << 1); i++) {
- expected[b][i] = expected[b][bit] ^ expected[b][i ^ bit];
- }
- }
- }
-
- int[][] actual = Crc32cHashFunction.Crc32cHasher.STRIDE_TABLE;
- assertTrue(
- "Expected: \n"
- + Arrays.deepToString(expected)
- + "\nActual:\n"
- + Arrays.deepToString(actual),
- Arrays.deepEquals(expected, actual));
- }
}
diff --git a/guava-tests/test/com/google/common/hash/HashFunctionEnum.java b/guava-tests/test/com/google/common/hash/HashFunctionEnum.java
index 3471747..c055063 100644
--- a/guava-tests/test/com/google/common/hash/HashFunctionEnum.java
+++ b/guava-tests/test/com/google/common/hash/HashFunctionEnum.java
@@ -16,7 +16,6 @@
package com.google.common.hash;
-
/**
* An enum that contains all of the known hash functions.
*
@@ -32,7 +31,6 @@
MD5(Hashing.md5()),
MURMUR3_128(Hashing.murmur3_128()),
MURMUR3_32(Hashing.murmur3_32()),
- MURMUR3_32_FIXED(Hashing.murmur3_32_fixed()),
SHA1(Hashing.sha1()),
SHA256(Hashing.sha256()),
SHA384(Hashing.sha384()),
diff --git a/guava-tests/test/com/google/common/hash/HashTestUtils.java b/guava-tests/test/com/google/common/hash/HashTestUtils.java
index 9e9944b..8dfbdb0 100644
--- a/guava-tests/test/com/google/common/hash/HashTestUtils.java
+++ b/guava-tests/test/com/google/common/hash/HashTestUtils.java
@@ -195,8 +195,8 @@
int limit = pos + random.nextInt(value.length - pos + 1);
for (PrimitiveSink sink : sinks) {
ByteBuffer buffer = ByteBuffer.wrap(value);
- Java8Compatibility.position(buffer, pos);
- Java8Compatibility.limit(buffer, limit);
+ buffer.position(pos);
+ buffer.limit(limit);
sink.putBytes(buffer);
assertEquals(limit, buffer.limit());
assertEquals(limit, buffer.position());
diff --git a/guava-tests/test/com/google/common/hash/HashingTest.java b/guava-tests/test/com/google/common/hash/HashingTest.java
index bc3db34..dc50299 100644
--- a/guava-tests/test/com/google/common/hash/HashingTest.java
+++ b/guava-tests/test/com/google/common/hash/HashingTest.java
@@ -146,7 +146,7 @@
// goodFastHash(128) uses Murmur3_128. Use the same epsilon bounds.
public void testGoodFastHash128() {
HashTestUtils.check2BitAvalanche(Hashing.goodFastHash(128), 250, 0.20);
- HashTestUtils.checkAvalanche(Hashing.goodFastHash(128), 500, 0.17);
+ HashTestUtils.checkAvalanche(Hashing.goodFastHash(128), 250, 0.17);
HashTestUtils.checkNo2BitCharacteristics(Hashing.goodFastHash(128));
HashTestUtils.checkNoFunnels(Hashing.goodFastHash(128));
HashTestUtils.assertInvariants(Hashing.goodFastHash(128));
@@ -155,7 +155,7 @@
// goodFastHash(256) uses Murmur3_128. Use the same epsilon bounds.
public void testGoodFastHash256() {
HashTestUtils.check2BitAvalanche(Hashing.goodFastHash(256), 250, 0.20);
- HashTestUtils.checkAvalanche(Hashing.goodFastHash(256), 500, 0.17);
+ HashTestUtils.checkAvalanche(Hashing.goodFastHash(256), 250, 0.17);
HashTestUtils.checkNo2BitCharacteristics(Hashing.goodFastHash(256));
HashTestUtils.checkNoFunnels(Hashing.goodFastHash(256));
HashTestUtils.assertInvariants(Hashing.goodFastHash(256));
@@ -432,9 +432,6 @@
.put(Hashing.murmur3_32(), EMPTY_STRING, "00000000")
.put(Hashing.murmur3_32(), TQBFJOTLD, "23f74f2e")
.put(Hashing.murmur3_32(), TQBFJOTLDP, "fc8bc4d5")
- .put(Hashing.murmur3_32_fixed(), EMPTY_STRING, "00000000")
- .put(Hashing.murmur3_32_fixed(), TQBFJOTLD, "23f74f2e")
- .put(Hashing.murmur3_32_fixed(), TQBFJOTLDP, "fc8bc4d5")
.put(Hashing.sha1(), EMPTY_STRING, "da39a3ee5e6b4b0d3255bfef95601890afd80709")
.put(Hashing.sha1(), TQBFJOTLD, "2fd4e1c67a2d28fced849ee1bb76e7391b93eb12")
.put(Hashing.sha1(), TQBFJOTLDP, "408d94384216f890ff7a0c3528e8bed1e0b01621")
diff --git a/guava-tests/test/com/google/common/hash/Murmur3Hash32Test.java b/guava-tests/test/com/google/common/hash/Murmur3Hash32Test.java
index 181b2a7..de86e4b 100644
--- a/guava-tests/test/com/google/common/hash/Murmur3Hash32Test.java
+++ b/guava-tests/test/com/google/common/hash/Murmur3Hash32Test.java
@@ -17,11 +17,9 @@
package com.google.common.hash;
import static com.google.common.hash.Hashing.murmur3_32;
-import static com.google.common.hash.Hashing.murmur3_32_fixed;
import com.google.common.base.Charsets;
import com.google.common.hash.HashTestUtils.HashFn;
-import java.nio.charset.Charset;
import java.util.Random;
import junit.framework.TestCase;
@@ -53,53 +51,16 @@
-528633700, murmur3_32().hashUnencodedChars("The quick brown fox jumps over the lazy dog"));
}
- @SuppressWarnings("deprecation")
- public void testKnownEncodedStringInputs() {
- assertStringHash(0, "", Charsets.UTF_8);
- assertStringHash(0xcfbda5d1, "k", Charsets.UTF_8);
- assertStringHash(0xa167dbf3, "hell", Charsets.UTF_8);
- assertStringHash(0x248bfa47, "hello", Charsets.UTF_8);
- assertStringHash(0x3d41b97c, "http://www.google.com/", Charsets.UTF_8);
- assertStringHash(0x2e4ff723, "The quick brown fox jumps over the lazy dog", Charsets.UTF_8);
- assertStringHash(0xb5a4be05, "ABCDefGHI\u0799", Charsets.UTF_8);
- assertStringHash(0xfc5ba834, "毎月1日,毎週月曜日", Charsets.UTF_8);
- assertStringHash(0x8a5c3699, "surrogate pair: \uD83D\uDCB0", Charsets.UTF_8);
-
- assertStringHash(0, "", Charsets.UTF_16LE);
- assertStringHash(0x288418e4, "k", Charsets.UTF_16LE);
- assertStringHash(0x5a0cb7c3, "hell", Charsets.UTF_16LE);
- assertStringHash(0xd7c31989, "hello", Charsets.UTF_16LE);
- assertStringHash(0x73564d8c, "http://www.google.com/", Charsets.UTF_16LE);
- assertStringHash(0xe07db09c, "The quick brown fox jumps over the lazy dog", Charsets.UTF_16LE);
- assertStringHash(0xfefa3e76, "ABCDefGHI\u0799", Charsets.UTF_16LE);
- assertStringHash(0x6a7be132, "毎月1日,毎週月曜日", Charsets.UTF_16LE);
- assertStringHash(0x5a2d41c7, "surrogate pair: \uD83D\uDCB0", Charsets.UTF_16LE);
- }
-
- @SuppressWarnings("deprecation")
- private void assertStringHash(int expected, String string, Charset charset) {
- if (allBmp(string)) {
- assertHash(expected, murmur3_32().hashString(string, charset));
- }
- assertHash(expected, murmur3_32_fixed().hashString(string, charset));
- assertHash(expected, murmur3_32().newHasher().putString(string, charset).hash());
- assertHash(expected, murmur3_32_fixed().newHasher().putString(string, charset).hash());
- assertHash(expected, murmur3_32().hashBytes(string.getBytes(charset)));
- assertHash(expected, murmur3_32_fixed().hashBytes(string.getBytes(charset)));
- assertHash(expected, murmur3_32().newHasher().putBytes(string.getBytes(charset)).hash());
- assertHash(expected, murmur3_32_fixed().newHasher().putBytes(string.getBytes(charset)).hash());
- }
-
- private boolean allBmp(String string) {
- // Ordinarily we'd use something like i += Character.charCount(string.codePointAt(i)) here. But
- // we can get away with i++ because the whole point of this method is to return false if we find
- // a code point that doesn't fit in a char.
- for (int i = 0; i < string.length(); i++) {
- if (string.codePointAt(i) > 0xffff) {
- return false;
- }
- }
- return true;
+ public void testKnownUtf8StringInputs() {
+ assertHash(0, murmur3_32().hashString("", Charsets.UTF_8));
+ assertHash(0xcfbda5d1, murmur3_32().hashString("k", Charsets.UTF_8));
+ assertHash(0xa167dbf3, murmur3_32().hashString("hell", Charsets.UTF_8));
+ assertHash(0x248bfa47, murmur3_32().hashString("hello", Charsets.UTF_8));
+ assertHash(0x3d41b97c, murmur3_32().hashString("http://www.google.com/", Charsets.UTF_8));
+ assertHash(
+ 0x2e4ff723,
+ murmur3_32().hashString("The quick brown fox jumps over the lazy dog", Charsets.UTF_8));
+ assertHash(0xfc5ba834, murmur3_32().hashString("毎月1日,毎週月曜日", Charsets.UTF_8));
}
@SuppressWarnings("deprecation")
@@ -110,7 +71,7 @@
}
@SuppressWarnings("deprecation")
- public void testEncodedStringInputs() {
+ public void testStringInputsUtf8() {
Random rng = new Random(0);
for (int z = 0; z < 100; z++) {
String str;
@@ -127,16 +88,9 @@
builder.appendCodePoint(codePoints[i]);
}
str = builder.toString();
- HashCode hashUtf8 = murmur3_32().hashBytes(str.getBytes(Charsets.UTF_8));
assertEquals(
- hashUtf8, murmur3_32().newHasher().putBytes(str.getBytes(Charsets.UTF_8)).hash());
- assertEquals(hashUtf8, murmur3_32().hashString(str, Charsets.UTF_8));
- assertEquals(hashUtf8, murmur3_32().newHasher().putString(str, Charsets.UTF_8).hash());
- HashCode hashUtf16 = murmur3_32().hashBytes(str.getBytes(Charsets.UTF_16));
- assertEquals(
- hashUtf16, murmur3_32().newHasher().putBytes(str.getBytes(Charsets.UTF_16)).hash());
- assertEquals(hashUtf16, murmur3_32().hashString(str, Charsets.UTF_16));
- assertEquals(hashUtf16, murmur3_32().newHasher().putString(str, Charsets.UTF_16).hash());
+ murmur3_32().hashBytes(str.getBytes(Charsets.UTF_8)),
+ murmur3_32().hashString(str, Charsets.UTF_8));
}
}
@@ -184,12 +138,8 @@
assertEquals(
murmur3_32().hashBytes(str.getBytes(Charsets.UTF_8)),
murmur3_32().hashString(str, Charsets.UTF_8));
- assertEquals(
- murmur3_32_fixed().hashBytes(str.getBytes(Charsets.UTF_8)),
- murmur3_32().hashString(str, Charsets.UTF_8));
}
- @SuppressWarnings("deprecation")
public void testInvalidUnicodeHasherPutString() {
String str =
new String(
@@ -197,8 +147,5 @@
assertEquals(
murmur3_32().hashBytes(str.getBytes(Charsets.UTF_8)),
murmur3_32().newHasher().putString(str, Charsets.UTF_8).hash());
- assertEquals(
- murmur3_32_fixed().hashBytes(str.getBytes(Charsets.UTF_8)),
- murmur3_32_fixed().newHasher().putString(str, Charsets.UTF_8).hash());
}
}
diff --git a/guava-tests/test/com/google/common/io/ByteSourceTest.java b/guava-tests/test/com/google/common/io/ByteSourceTest.java
index 3cf6cca..f0ba829 100644
--- a/guava-tests/test/com/google/common/io/ByteSourceTest.java
+++ b/guava-tests/test/com/google/common/io/ByteSourceTest.java
@@ -30,7 +30,6 @@
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
import com.google.common.hash.Hashing;
-import com.google.common.io.Closer.LoggingSuppressor;
import com.google.common.primitives.UnsignedBytes;
import com.google.common.testing.TestLogHandler;
import java.io.ByteArrayOutputStream;
@@ -396,7 +395,7 @@
ImmutableSet.of(BROKEN_CLOSE_SINK, BROKEN_OPEN_SINK, BROKEN_WRITE_SINK);
public void testCopyExceptions() {
- if (Closer.create().suppressor instanceof LoggingSuppressor) {
+ if (!Closer.SuppressingSuppressor.isAvailable()) {
// test that exceptions are logged
TestLogHandler logHandler = new TestLogHandler();
diff --git a/guava-tests/test/com/google/common/io/ByteSourceTester.java b/guava-tests/test/com/google/common/io/ByteSourceTester.java
index 7585412..490f1e6 100644
--- a/guava-tests/test/com/google/common/io/ByteSourceTester.java
+++ b/guava-tests/test/com/google/common/io/ByteSourceTester.java
@@ -38,7 +38,7 @@
/**
* A generator of {@code TestSuite} instances for testing {@code ByteSource} implementations.
* Generates tests of a all methods on a {@code ByteSource} given various inputs the source is
- * expected to contain as well as sub-suites for testing the {@code CharSource} view and {@code
+ * expected to contain as well as as sub-suites for testing the {@code CharSource} view and {@code
* slice()} views in the same way.
*
* @author Colin Decker
diff --git a/guava-tests/test/com/google/common/io/ByteStreamsTest.java b/guava-tests/test/com/google/common/io/ByteStreamsTest.java
index 3ae2c25..f715303 100644
--- a/guava-tests/test/com/google/common/io/ByteStreamsTest.java
+++ b/guava-tests/test/com/google/common/io/ByteStreamsTest.java
@@ -51,7 +51,6 @@
assertThat(out.toByteArray()).isEqualTo(expected);
}
-
public void testCopyFileChannel() throws IOException {
final int chunkSize = 14407; // Random prime, unlikely to match any internal chunk size
ByteArrayOutputStream out = new ByteArrayOutputStream();
diff --git a/guava-tests/test/com/google/common/io/CharSequenceReaderTest.java b/guava-tests/test/com/google/common/io/CharSequenceReaderTest.java
index dbe94fc..12bc17e 100644
--- a/guava-tests/test/com/google/common/io/CharSequenceReaderTest.java
+++ b/guava-tests/test/com/google/common/io/CharSequenceReaderTest.java
@@ -211,7 +211,7 @@
reader = new CharSequenceReader(charSequence);
CharBuffer buf2 = CharBuffer.allocate(expected.length());
assertEquals(expected.length() == 0 ? -1 : expected.length(), reader.read(buf2));
- Java8Compatibility.flip(buf2);
+ buf2.flip();
assertEquals(expected, buf2.toString());
assertFullyRead(reader);
@@ -220,9 +220,9 @@
buf2 = CharBuffer.allocate(5);
builder = new StringBuilder();
while (reader.read(buf2) != -1) {
- Java8Compatibility.flip(buf2);
+ buf2.flip();
builder.append(buf2);
- Java8Compatibility.clear(buf2);
+ buf2.clear();
}
assertEquals(expected, builder.toString());
assertFullyRead(reader);
diff --git a/guava-tests/test/com/google/common/io/CharSourceTest.java b/guava-tests/test/com/google/common/io/CharSourceTest.java
index 787d744..c4fbe46 100644
--- a/guava-tests/test/com/google/common/io/CharSourceTest.java
+++ b/guava-tests/test/com/google/common/io/CharSourceTest.java
@@ -26,7 +26,6 @@
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
-import com.google.common.io.Closer.LoggingSuppressor;
import com.google.common.testing.TestLogHandler;
import java.io.BufferedReader;
import java.io.IOException;
@@ -289,7 +288,7 @@
ImmutableSet.of(BROKEN_CLOSE_SINK, BROKEN_OPEN_SINK, BROKEN_WRITE_SINK);
public void testCopyExceptions() {
- if (Closer.create().suppressor instanceof LoggingSuppressor) {
+ if (!Closer.SuppressingSuppressor.isAvailable()) {
// test that exceptions are logged
TestLogHandler logHandler = new TestLogHandler();
diff --git a/guava-tests/test/com/google/common/io/CloserTest.java b/guava-tests/test/com/google/common/io/CloserTest.java
index 3876174..3d16a09 100644
--- a/guava-tests/test/com/google/common/io/CloserTest.java
+++ b/guava-tests/test/com/google/common/io/CloserTest.java
@@ -24,7 +24,6 @@
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Lists;
-import com.google.common.io.Closer.LoggingSuppressor;
import com.google.common.testing.TestLogHandler;
import java.io.Closeable;
import java.io.IOException;
@@ -312,12 +311,13 @@
}
public static void testSuppressingSuppressorIfPossible() throws IOException {
- Closer closer = Closer.create();
// can't test the JDK7 suppressor when not running on JDK7
- if (closer.suppressor instanceof LoggingSuppressor) {
+ if (!Closer.SuppressingSuppressor.isAvailable()) {
return;
}
+ Closer closer = new Closer(new Closer.SuppressingSuppressor());
+
IOException thrownException = new IOException();
IOException c1Exception = new IOException();
RuntimeException c2Exception = new RuntimeException();
diff --git a/guava-tests/test/com/google/common/io/FileBackedOutputStreamTest.java b/guava-tests/test/com/google/common/io/FileBackedOutputStreamTest.java
index 6841a41..66558e9 100644
--- a/guava-tests/test/com/google/common/io/FileBackedOutputStreamTest.java
+++ b/guava-tests/test/com/google/common/io/FileBackedOutputStreamTest.java
@@ -16,7 +16,6 @@
package com.google.common.io;
-
import com.google.common.testing.GcFinalization;
import java.io.File;
import java.io.IOException;
@@ -30,7 +29,6 @@
*/
public class FileBackedOutputStreamTest extends IoTestCase {
-
public void testThreshold() throws Exception {
testThreshold(0, 100, true, false);
testThreshold(10, 100, true, false);
@@ -78,7 +76,6 @@
}
}
-
public void testFinalizeDeletesFile() throws Exception {
byte[] data = newPreFilledByteArray(100);
FileBackedOutputStream out = new FileBackedOutputStream(0, true);
@@ -102,7 +99,6 @@
});
}
-
public void testThreshold_resetOnFinalize() throws Exception {
testThreshold(0, 100, true, true);
testThreshold(10, 100, true, true);
diff --git a/guava-tests/test/com/google/common/io/FilesTest.java b/guava-tests/test/com/google/common/io/FilesTest.java
index 8446da1..e987f60 100644
--- a/guava-tests/test/com/google/common/io/FilesTest.java
+++ b/guava-tests/test/com/google/common/io/FilesTest.java
@@ -16,6 +16,7 @@
package com.google.common.io;
+import static com.google.common.io.Files.touch;
import static com.google.common.truth.Truth.assertThat;
import com.google.common.base.Charsets;
@@ -195,7 +196,7 @@
File temp2 = createTempFile();
Files.write(ASCII, temp2, Charsets.UTF_8);
Files.copy(temp1, temp2);
- assertEquals(ASCII, Files.toString(temp2, Charsets.UTF_8));
+ assertEquals(ASCII, Files.toString(temp1, Charsets.UTF_8));
}
public void testEqual() throws IOException {
diff --git a/guava-tests/test/com/google/common/io/MoreFilesTest.java b/guava-tests/test/com/google/common/io/MoreFilesTest.java
index 005cf53..693c7cc 100644
--- a/guava-tests/test/com/google/common/io/MoreFilesTest.java
+++ b/guava-tests/test/com/google/common/io/MoreFilesTest.java
@@ -34,7 +34,6 @@
import java.nio.file.FileSystems;
import java.nio.file.FileVisitResult;
import java.nio.file.Files;
-import java.nio.file.NoSuchFileException;
import java.nio.file.Path;
import java.nio.file.SimpleFileVisitor;
import java.nio.file.attribute.BasicFileAttributes;
@@ -557,17 +556,6 @@
}
}
- public void testDeleteRecursively_nonexistingFile_throwsNoSuchFileException() throws IOException {
- try (FileSystem fs = newTestFileSystem()) {
- try {
- MoreFiles.deleteRecursively(fs.getPath("/work/nothere"), ALLOW_INSECURE);
- fail();
- } catch (NoSuchFileException expected) {
- assertThat(expected.getFile()).isEqualTo("/work/nothere");
- }
- }
- }
-
public void testDeleteDirectoryContents_symlinkToDir_sdsNotSupported_allowInsecure()
throws IOException {
try (FileSystem fs = newTestFileSystem()) {
@@ -661,7 +649,7 @@
*/
private static void startDirectorySymlinkSwitching(
final Path file, final Path target, ExecutorService executor) {
- @SuppressWarnings("unused") // https://errorprone.info/bugpattern/FutureReturnValueIgnored
+ @SuppressWarnings("unused") // go/futurereturn-lsc
Future<?> possiblyIgnoredError =
executor.submit(
new Runnable() {
diff --git a/guava-tests/test/com/google/common/io/PatternFilenameFilterTest.java b/guava-tests/test/com/google/common/io/PatternFilenameFilterTest.java
index 94ab1f0..77ace52 100644
--- a/guava-tests/test/com/google/common/io/PatternFilenameFilterTest.java
+++ b/guava-tests/test/com/google/common/io/PatternFilenameFilterTest.java
@@ -16,8 +16,6 @@
package com.google.common.io;
-import com.google.common.testing.NullPointerTester;
-import com.google.common.testing.NullPointerTester.Visibility;
import java.io.File;
import java.io.FilenameFilter;
import java.util.regex.PatternSyntaxException;
@@ -48,15 +46,4 @@
// Show that dir is ignored
assertTrue(filter.accept(null, "a"));
}
-
- public void testNulls() throws Exception {
- NullPointerTester tester = new NullPointerTester();
-
- tester.testConstructors(PatternFilenameFilter.class, Visibility.PACKAGE);
- tester.testStaticMethods(PatternFilenameFilter.class, Visibility.PACKAGE); // currently none
-
- // The reason that we skip this method is discussed in a comment on the method.
- tester.ignore(PatternFilenameFilter.class.getMethod("accept", File.class, String.class));
- tester.testInstanceMethods(new PatternFilenameFilter(".*"), Visibility.PACKAGE);
- }
}
diff --git a/guava-tests/test/com/google/common/io/SourceSinkFactories.java b/guava-tests/test/com/google/common/io/SourceSinkFactories.java
index d24622d..9b761d3 100644
--- a/guava-tests/test/com/google/common/io/SourceSinkFactories.java
+++ b/guava-tests/test/com/google/common/io/SourceSinkFactories.java
@@ -442,9 +442,9 @@
StringBuilder builder = new StringBuilder();
CharBuffer buffer = CharBuffer.allocate(100);
while (reader.read(buffer) != -1) {
- Java8Compatibility.flip(buffer);
+ buffer.flip();
builder.append(buffer);
- Java8Compatibility.clear(buffer);
+ buffer.clear();
}
return builder.toString();
}
diff --git a/guava-tests/test/com/google/common/math/BigIntegerMathTest.java b/guava-tests/test/com/google/common/math/BigIntegerMathTest.java
index 170261b..8a9b4fc 100644
--- a/guava-tests/test/com/google/common/math/BigIntegerMathTest.java
+++ b/guava-tests/test/com/google/common/math/BigIntegerMathTest.java
@@ -441,7 +441,7 @@
@GwtIncompatible // TODO
@AndroidIncompatible // slow
public void testDivNonZeroExact() {
- boolean isAndroid = System.getProperty("java.runtime.name").contains("Android");
+ boolean isAndroid = System.getProperties().getProperty("java.runtime.name").contains("Android");
for (BigInteger p : NONZERO_BIGINTEGER_CANDIDATES) {
for (BigInteger q : NONZERO_BIGINTEGER_CANDIDATES) {
if (isAndroid && p.equals(BAD_FOR_ANDROID_P) && q.equals(BAD_FOR_ANDROID_Q)) {
diff --git a/guava-tests/test/com/google/common/math/LongMathTest.java b/guava-tests/test/com/google/common/math/LongMathTest.java
index 40c2ac9..2284668 100644
--- a/guava-tests/test/com/google/common/math/LongMathTest.java
+++ b/guava-tests/test/com/google/common/math/LongMathTest.java
@@ -747,7 +747,6 @@
}
}
-
@GwtIncompatible // Slow
public void testBinomial_exhaustiveNotOverflowing() {
// Tests all of the inputs to LongMath.binomial that won't cause it to overflow, that weren't
@@ -784,7 +783,6 @@
}
}
-
@GwtIncompatible // far too slow
public void testSqrtOfPerfectSquareAsDoubleIsPerfect() {
// This takes just over a minute on my machine.
diff --git a/guava-tests/test/com/google/common/math/MathPreconditionsTest.java b/guava-tests/test/com/google/common/math/MathPreconditionsTest.java
index 5dbe017..69719e0 100644
--- a/guava-tests/test/com/google/common/math/MathPreconditionsTest.java
+++ b/guava-tests/test/com/google/common/math/MathPreconditionsTest.java
@@ -289,15 +289,4 @@
assertThat(expected).hasMessageThat().contains("testCheckNoOverflow_failure(0, 0)");
}
}
-
- public void testNulls() {
- /*
- * Don't bother testing. All non-primitive parameters are used only to construct error messages.
- * We never want to pass null for them, so we haven't annotated them to say that null is
- * allowed. But at the same time, it seems wasteful to bother inserting the checkNotNull calls
- * that NullPointerTester wants.
- *
- * (This empty method disables the automatic null testing provided by PackageSanityTests.)
- */
- }
}
diff --git a/guava-tests/test/com/google/common/math/TestPlatform.java b/guava-tests/test/com/google/common/math/TestPlatform.java
index 03eb2ec..95df331 100644
--- a/guava-tests/test/com/google/common/math/TestPlatform.java
+++ b/guava-tests/test/com/google/common/math/TestPlatform.java
@@ -26,6 +26,6 @@
}
static boolean isAndroid() {
- return System.getProperty("java.runtime.name").contains("Android");
+ return System.getProperties().getProperty("java.runtime.name").contains("Android");
}
}
diff --git a/guava-tests/test/com/google/common/net/HostAndPortTest.java b/guava-tests/test/com/google/common/net/HostAndPortTest.java
index 65e8096..5e7eb2f 100644
--- a/guava-tests/test/com/google/common/net/HostAndPortTest.java
+++ b/guava-tests/test/com/google/common/net/HostAndPortTest.java
@@ -59,13 +59,6 @@
checkFromStringCase("[2001::2]:85", 77, "2001::2", 85, true);
}
- public void testFromStringNonAsciiDigits() {
- // Same as testFromStringUnusedDefaultPort but with Gujarati digits for port numbers.
- checkFromStringCase("gmail.com:૮1", 77, null, -1, false);
- checkFromStringCase("192.0.2.2:૮૩", 77, null, -1, false);
- checkFromStringCase("[2001::2]:૮૫", 77, null, -1, false);
- }
-
public void testFromStringBadPort() {
// Out-of-range ports.
checkFromStringCase("google.com:65536", 1, null, 99, false);
diff --git a/guava-tests/test/com/google/common/net/HttpHeadersTest.java b/guava-tests/test/com/google/common/net/HttpHeadersTest.java
index 5361b3f..9927e6b 100644
--- a/guava-tests/test/com/google/common/net/HttpHeadersTest.java
+++ b/guava-tests/test/com/google/common/net/HttpHeadersTest.java
@@ -50,8 +50,8 @@
.build();
ImmutableSet<String> uppercaseAcronyms =
ImmutableSet.of(
- "CH", "ID", "DNT", "DNS", "ECT", "HTTP2", "IP", "MD5", "P3P", "RTT", "TE", "UA", "UID",
- "URL", "WWW", "XSS");
+ "CH", "ID", "DNT", "DNS", "HTTP2", "IP", "MD5", "P3P", "TE", "UA", "UID", "URL", "WWW",
+ "XSS");
assertConstantNameMatchesString(HttpHeaders.class, specialCases, uppercaseAcronyms);
}
diff --git a/guava-tests/test/com/google/common/net/InetAddressesTest.java b/guava-tests/test/com/google/common/net/InetAddressesTest.java
index be77e7b..ed3aa27 100644
--- a/guava-tests/test/com/google/common/net/InetAddressesTest.java
+++ b/guava-tests/test/com/google/common/net/InetAddressesTest.java
@@ -135,20 +135,6 @@
assertTrue(InetAddresses.isInetAddress(ipStr));
}
- public void testForStringIPv4NonAsciiInput() throws UnknownHostException {
- String ipStr = "૧૯૨.૧૬૮.૦.૧"; // 192.168.0.1 in Gujarati digits
- // Shouldn't hit DNS, because it's an IP string literal.
- InetAddress ipv4Addr;
- try {
- ipv4Addr = InetAddress.getByName(ipStr);
- } catch (UnknownHostException e) {
- // OK: this is probably Android, which is stricter.
- return;
- }
- assertEquals(ipv4Addr, InetAddresses.forString(ipStr));
- assertTrue(InetAddresses.isInetAddress(ipStr));
- }
-
public void testForStringIPv6Input() throws UnknownHostException {
String ipStr = "3ffe::1";
// Shouldn't hit DNS, because it's an IP string literal.
@@ -157,20 +143,6 @@
assertTrue(InetAddresses.isInetAddress(ipStr));
}
- public void testForStringIPv6NonAsciiInput() throws UnknownHostException {
- String ipStr = "૩ffe::૧"; // 3ffe::1 with Gujarati digits for 3 and 1
- // Shouldn't hit DNS, because it's an IP string literal.
- InetAddress ipv6Addr;
- try {
- ipv6Addr = InetAddress.getByName(ipStr);
- } catch (UnknownHostException e) {
- // OK: this is probably Android, which is stricter.
- return;
- }
- assertEquals(ipv6Addr, InetAddresses.forString(ipStr));
- assertTrue(InetAddresses.isInetAddress(ipStr));
- }
-
public void testForStringIPv6EightColons() throws UnknownHostException {
ImmutableSet<String> eightColons =
ImmutableSet.of("::7:6:5:4:3:2:1", "::7:6:5:4:3:2:0", "7:6:5:4:3:2:1::", "0:6:5:4:3:2:1::");
diff --git a/guava-tests/test/com/google/common/net/InternetDomainNameTest.java b/guava-tests/test/com/google/common/net/InternetDomainNameTest.java
index 7113fb4..09602b7 100644
--- a/guava-tests/test/com/google/common/net/InternetDomainNameTest.java
+++ b/guava-tests/test/com/google/common/net/InternetDomainNameTest.java
@@ -16,7 +16,6 @@
package com.google.common.net;
-
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.GwtIncompatible;
import com.google.common.base.Ascii;
diff --git a/guava-tests/test/com/google/common/net/MediaTypeTest.java b/guava-tests/test/com/google/common/net/MediaTypeTest.java
index 574db68..cec3cdd 100644
--- a/guava-tests/test/com/google/common/net/MediaTypeTest.java
+++ b/guava-tests/test/com/google/common/net/MediaTypeTest.java
@@ -46,6 +46,7 @@
import com.google.common.testing.NullPointerTester;
import java.lang.reflect.Field;
import java.nio.charset.Charset;
+import java.nio.charset.IllegalCharsetNameException;
import java.nio.charset.UnsupportedCharsetException;
import java.util.Arrays;
import junit.framework.TestCase;
@@ -536,7 +537,7 @@
try {
mediaType.charset();
fail();
- } catch (IllegalArgumentException expected) {
+ } catch (IllegalCharsetNameException expected) {
}
}
diff --git a/guava-tests/test/com/google/common/primitives/UnsignedLongTest.java b/guava-tests/test/com/google/common/primitives/UnsignedLongTest.java
index cfa2862..dd2a8ab 100644
--- a/guava-tests/test/com/google/common/primitives/UnsignedLongTest.java
+++ b/guava-tests/test/com/google/common/primitives/UnsignedLongTest.java
@@ -36,23 +36,13 @@
static {
ImmutableSet.Builder<Long> testLongsBuilder = ImmutableSet.builder();
ImmutableSet.Builder<BigInteger> testBigIntegersBuilder = ImmutableSet.builder();
-
- // The values here look like 111...11101...010 in binary, where the initial 111...1110 takes
- // up exactly as many bits as can be represented in the significand (24 for float, 53 for
- // double). That final 0 should be rounded up to 1 because the remaining bits make that number
- // slightly nearer.
- long floatConversionTest = 0xfffffe8000000002L;
- long doubleConversionTest = 0xfffffffffffff402L;
-
for (long i = -3; i <= 3; i++) {
testLongsBuilder
.add(i)
.add(Long.MAX_VALUE + i)
.add(Long.MIN_VALUE + i)
.add(Integer.MIN_VALUE + i)
- .add(Integer.MAX_VALUE + i)
- .add(floatConversionTest + i)
- .add(doubleConversionTest + i);
+ .add(Integer.MAX_VALUE + i);
BigInteger bigI = BigInteger.valueOf(i);
testBigIntegersBuilder
.add(bigI)
@@ -140,26 +130,17 @@
}
}
- @AndroidIncompatible // b/28251030, re-enable when the fix is everywhere we run this test
public void testFloatValue() {
for (long value : TEST_LONGS) {
UnsignedLong unsignedValue = UnsignedLong.fromLongBits(value);
- assertEquals(
- "Float value of " + unsignedValue,
- unsignedValue.bigIntegerValue().floatValue(),
- unsignedValue.floatValue(),
- 0.0f);
+ assertEquals(unsignedValue.bigIntegerValue().floatValue(), unsignedValue.floatValue());
}
}
public void testDoubleValue() {
for (long value : TEST_LONGS) {
UnsignedLong unsignedValue = UnsignedLong.fromLongBits(value);
- assertEquals(
- "Double value of " + unsignedValue,
- unsignedValue.bigIntegerValue().doubleValue(),
- unsignedValue.doubleValue(),
- 0.0);
+ assertEquals(unsignedValue.bigIntegerValue().doubleValue(), unsignedValue.doubleValue());
}
}
diff --git a/guava-tests/test/com/google/common/reflect/ClassPathTest.java b/guava-tests/test/com/google/common/reflect/ClassPathTest.java
index 797baeb..1d21002 100644
--- a/guava-tests/test/com/google/common/reflect/ClassPathTest.java
+++ b/guava-tests/test/com/google/common/reflect/ClassPathTest.java
@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
package com.google.common.reflect;
import static com.google.common.base.Charsets.US_ASCII;
@@ -48,7 +49,10 @@
import java.net.URLClassLoader;
import java.security.Permission;
import java.security.PermissionCollection;
+import java.util.HashSet;
+import java.util.Set;
import java.util.jar.Attributes;
+import java.util.jar.JarFile;
import java.util.jar.JarOutputStream;
import java.util.jar.Manifest;
import java.util.logging.Logger;
@@ -74,7 +78,7 @@
@AndroidIncompatible // Android forbids null parent ClassLoader
public void testClassPathEntries_emptyURLClassLoader_noParent() {
- assertThat(ClassPath.getClassPathEntries(new URLClassLoader(new URL[0], null)).keySet())
+ assertThat(ClassPath.Scanner.getClassPathEntries(new URLClassLoader(new URL[0], null)).keySet())
.isEmpty();
}
@@ -83,7 +87,7 @@
URL url1 = new URL("file:/a");
URL url2 = new URL("file:/b");
URLClassLoader classloader = new URLClassLoader(new URL[] {url1, url2}, null);
- assertThat(ClassPath.getClassPathEntries(classloader))
+ assertThat(ClassPath.Scanner.getClassPathEntries(classloader))
.containsExactly(new File("/a"), classloader, new File("/b"), classloader);
}
@@ -93,7 +97,7 @@
URL url2 = new URL("file:/b");
URLClassLoader parent = new URLClassLoader(new URL[] {url1}, null);
URLClassLoader child = new URLClassLoader(new URL[] {url2}, parent) {};
- assertThat(ClassPath.getClassPathEntries(child))
+ assertThat(ClassPath.Scanner.getClassPathEntries(child))
.containsExactly(new File("/a"), parent, new File("/b"), child)
.inOrder();
}
@@ -103,19 +107,20 @@
URL url = new URL("file:/a");
URLClassLoader parent = new URLClassLoader(new URL[] {url}, null);
URLClassLoader child = new URLClassLoader(new URL[] {url}, parent) {};
- assertThat(ClassPath.getClassPathEntries(child)).containsExactly(new File("/a"), parent);
+ assertThat(ClassPath.Scanner.getClassPathEntries(child))
+ .containsExactly(new File("/a"), parent);
}
@AndroidIncompatible // Android forbids null parent ClassLoader
public void testClassPathEntries_notURLClassLoader_noParent() {
- assertThat(ClassPath.getClassPathEntries(new ClassLoader(null) {})).isEmpty();
+ assertThat(ClassPath.Scanner.getClassPathEntries(new ClassLoader(null) {})).isEmpty();
}
@AndroidIncompatible // Android forbids null parent ClassLoader
public void testClassPathEntries_notURLClassLoader_withParent() throws Exception {
URL url = new URL("file:/a");
URLClassLoader parent = new URLClassLoader(new URL[] {url}, null);
- assertThat(ClassPath.getClassPathEntries(new ClassLoader(parent) {}))
+ assertThat(ClassPath.Scanner.getClassPathEntries(new ClassLoader(parent) {}))
.containsExactly(new File("/a"), parent);
}
@@ -125,7 +130,7 @@
URL url2 = new URL("file:/b");
URLClassLoader grandParent = new URLClassLoader(new URL[] {url1}, null);
URLClassLoader parent = new URLClassLoader(new URL[] {url2}, grandParent);
- assertThat(ClassPath.getClassPathEntries(new ClassLoader(parent) {}))
+ assertThat(ClassPath.Scanner.getClassPathEntries(new ClassLoader(parent) {}))
.containsExactly(new File("/a"), grandParent, new File("/b"), parent);
}
@@ -134,7 +139,7 @@
URL url = new URL("file:/a");
URLClassLoader grandParent = new URLClassLoader(new URL[] {url}, null);
ClassLoader parent = new ClassLoader(grandParent) {};
- assertThat(ClassPath.getClassPathEntries(new ClassLoader(parent) {}))
+ assertThat(ClassPath.Scanner.getClassPathEntries(new ClassLoader(parent) {}))
.containsExactly(new File("/a"), grandParent);
}
@@ -143,7 +148,7 @@
public void testClassPathEntries_URLClassLoader_pathWithSpace() throws Exception {
URL url = new URL("file:///c:/Documents and Settings/");
URLClassLoader classloader = new URLClassLoader(new URL[] {url}, null);
- assertThat(ClassPath.getClassPathEntries(classloader))
+ assertThat(ClassPath.Scanner.getClassPathEntries(classloader))
.containsExactly(new File("/c:/Documents and Settings/"), classloader);
}
@@ -152,7 +157,7 @@
public void testClassPathEntries_URLClassLoader_pathWithEscapedSpace() throws Exception {
URL url = new URL("file:///c:/Documents%20and%20Settings/");
URLClassLoader classloader = new URLClassLoader(new URL[] {url}, null);
- assertThat(ClassPath.getClassPathEntries(classloader))
+ assertThat(ClassPath.Scanner.getClassPathEntries(classloader))
.containsExactly(new File("/c:/Documents and Settings/"), classloader);
}
@@ -175,7 +180,6 @@
.isEqualTo(new File("/C:\\\u20320 \u22909"));
}
-
@AndroidIncompatible // Android forbids null parent ClassLoader
// https://github.com/google/guava/issues/2152
public void testJarFileWithSpaces() throws Exception {
@@ -184,15 +188,13 @@
assertThat(ClassPath.from(classloader).getTopLevelClasses()).isNotEmpty();
}
-
public void testScan_classPathCycle() throws IOException {
File jarFile = File.createTempFile("with_circular_class_path", ".jar");
try {
writeSelfReferencingJarFile(jarFile, "test.txt");
- assertThat(
- new ClassPath.LocationInfo(jarFile, ClassPathTest.class.getClassLoader())
- .scanResources())
- .hasSize(1);
+ ClassPath.DefaultScanner scanner = new ClassPath.DefaultScanner();
+ scanner.scan(jarFile, ClassPathTest.class.getClassLoader());
+ assertThat(scanner.getResources()).hasSize(1);
} finally {
jarFile.delete();
}
@@ -218,13 +220,17 @@
createSymbolicLink(left.resolve("sibling"), right);
createSymbolicLink(right.resolve("sibling"), left);
+
+ ClassPath.DefaultScanner scanner = new ClassPath.DefaultScanner();
+ scanner.scan(root.toFile(), loader);
+
assertEquals(
ImmutableSet.of(
new ResourceInfo(FILE, "left/some.txt", loader),
new ResourceInfo(FILE, "left/sibling/another.txt", loader),
new ResourceInfo(FILE, "right/another.txt", loader),
new ResourceInfo(FILE, "right/sibling/some.txt", loader)),
- new ClassPath.LocationInfo(root.toFile(), loader).scanResources());
+ scanner.getResources());
} finally {
deleteRecursivelyOrLog(root);
}
@@ -243,77 +249,83 @@
createFile(root.resolve("some.txt"));
java.nio.file.Path child = createDirectory(root.resolve("child"));
createSymbolicLink(child.resolve("grandchild"), root);
+
+ ClassPath.DefaultScanner scanner = new ClassPath.DefaultScanner();
+ scanner.scan(root.toFile(), loader);
+
assertEquals(
- ImmutableSet.of(new ResourceInfo(FILE, "some.txt", loader)),
- new ClassPath.LocationInfo(root.toFile(), loader).scanResources());
+ ImmutableSet.of(new ResourceInfo(FILE, "some.txt", loader)), scanner.getResources());
} finally {
deleteRecursivelyOrLog(root);
}
}
-
public void testScanFromFile_fileNotExists() throws IOException {
ClassLoader classLoader = ClassPathTest.class.getClassLoader();
- assertThat(
- new ClassPath.LocationInfo(new File("no/such/file/anywhere"), classLoader)
- .scanResources())
- .isEmpty();
+ ClassPath.DefaultScanner scanner = new ClassPath.DefaultScanner();
+ scanner.scan(new File("no/such/file/anywhere"), classLoader);
+ assertThat(scanner.getResources()).isEmpty();
}
-
public void testScanFromFile_notJarFile() throws IOException {
ClassLoader classLoader = ClassPathTest.class.getClassLoader();
File notJar = File.createTempFile("not_a_jar", "txt");
+ ClassPath.DefaultScanner scanner = new ClassPath.DefaultScanner();
try {
- assertThat(new ClassPath.LocationInfo(notJar, classLoader).scanResources()).isEmpty();
+ scanner.scan(notJar, classLoader);
} finally {
notJar.delete();
}
+ assertThat(scanner.getResources()).isEmpty();
}
public void testGetClassPathEntry() throws MalformedURLException, URISyntaxException {
assertEquals(
new File("/usr/test/dep.jar").toURI(),
- ClassPath.getClassPathEntry(new File("/home/build/outer.jar"), "file:/usr/test/dep.jar")
+ ClassPath.Scanner.getClassPathEntry(
+ new File("/home/build/outer.jar"), "file:/usr/test/dep.jar")
.toURI());
assertEquals(
new File("/home/build/a.jar").toURI(),
- ClassPath.getClassPathEntry(new File("/home/build/outer.jar"), "a.jar").toURI());
+ ClassPath.Scanner.getClassPathEntry(new File("/home/build/outer.jar"), "a.jar").toURI());
assertEquals(
new File("/home/build/x/y/z").toURI(),
- ClassPath.getClassPathEntry(new File("/home/build/outer.jar"), "x/y/z").toURI());
+ ClassPath.Scanner.getClassPathEntry(new File("/home/build/outer.jar"), "x/y/z").toURI());
assertEquals(
new File("/home/build/x/y/z.jar").toURI(),
- ClassPath.getClassPathEntry(new File("/home/build/outer.jar"), "x/y/z.jar").toURI());
+ ClassPath.Scanner.getClassPathEntry(new File("/home/build/outer.jar"), "x/y/z.jar")
+ .toURI());
assertEquals(
"/home/build/x y.jar",
- ClassPath.getClassPathEntry(new File("/home/build/outer.jar"), "x y.jar").getFile());
+ ClassPath.Scanner.getClassPathEntry(new File("/home/build/outer.jar"), "x y.jar")
+ .getFile());
}
public void testGetClassPathFromManifest_nullManifest() {
- assertThat(ClassPath.getClassPathFromManifest(new File("some.jar"), null)).isEmpty();
+ assertThat(ClassPath.Scanner.getClassPathFromManifest(new File("some.jar"), null)).isEmpty();
}
public void testGetClassPathFromManifest_noClassPath() throws IOException {
File jarFile = new File("base.jar");
- assertThat(ClassPath.getClassPathFromManifest(jarFile, manifest(""))).isEmpty();
+ assertThat(ClassPath.Scanner.getClassPathFromManifest(jarFile, manifest(""))).isEmpty();
}
public void testGetClassPathFromManifest_emptyClassPath() throws IOException {
File jarFile = new File("base.jar");
- assertThat(ClassPath.getClassPathFromManifest(jarFile, manifestClasspath(""))).isEmpty();
+ assertThat(ClassPath.Scanner.getClassPathFromManifest(jarFile, manifestClasspath("")))
+ .isEmpty();
}
public void testGetClassPathFromManifest_badClassPath() throws IOException {
File jarFile = new File("base.jar");
Manifest manifest = manifestClasspath("nosuchscheme:an_invalid^path");
- assertThat(ClassPath.getClassPathFromManifest(jarFile, manifest)).isEmpty();
+ assertThat(ClassPath.Scanner.getClassPathFromManifest(jarFile, manifest)).isEmpty();
}
public void testGetClassPathFromManifest_pathWithStrangeCharacter() throws IOException {
File jarFile = new File("base/some.jar");
Manifest manifest = manifestClasspath("file:the^file.jar");
- assertThat(ClassPath.getClassPathFromManifest(jarFile, manifest))
+ assertThat(ClassPath.Scanner.getClassPathFromManifest(jarFile, manifest))
.containsExactly(fullpath("base/the^file.jar"));
}
@@ -321,7 +333,7 @@
File jarFile = new File("base/some.jar");
// with/relative/directory is the Class-Path value in the mf file.
Manifest manifest = manifestClasspath("with/relative/dir");
- assertThat(ClassPath.getClassPathFromManifest(jarFile, manifest))
+ assertThat(ClassPath.Scanner.getClassPathFromManifest(jarFile, manifest))
.containsExactly(fullpath("base/with/relative/dir"));
}
@@ -329,7 +341,7 @@
File jarFile = new File("base/some.jar");
// with/relative/directory is the Class-Path value in the mf file.
Manifest manifest = manifestClasspath("with/relative.jar");
- assertThat(ClassPath.getClassPathFromManifest(jarFile, manifest))
+ assertThat(ClassPath.Scanner.getClassPathFromManifest(jarFile, manifest))
.containsExactly(fullpath("base/with/relative.jar"));
}
@@ -337,28 +349,28 @@
File jarFile = new File("base/some.jar");
// with/relative/directory is the Class-Path value in the mf file.
Manifest manifest = manifestClasspath("current.jar");
- assertThat(ClassPath.getClassPathFromManifest(jarFile, manifest))
+ assertThat(ClassPath.Scanner.getClassPathFromManifest(jarFile, manifest))
.containsExactly(fullpath("base/current.jar"));
}
public void testGetClassPathFromManifest_absoluteDirectory() throws IOException {
File jarFile = new File("base/some.jar");
Manifest manifest = manifestClasspath("file:/with/absolute/dir");
- assertThat(ClassPath.getClassPathFromManifest(jarFile, manifest))
+ assertThat(ClassPath.Scanner.getClassPathFromManifest(jarFile, manifest))
.containsExactly(fullpath("/with/absolute/dir"));
}
public void testGetClassPathFromManifest_absoluteJar() throws IOException {
File jarFile = new File("base/some.jar");
Manifest manifest = manifestClasspath("file:/with/absolute.jar");
- assertThat(ClassPath.getClassPathFromManifest(jarFile, manifest))
+ assertThat(ClassPath.Scanner.getClassPathFromManifest(jarFile, manifest))
.containsExactly(fullpath("/with/absolute.jar"));
}
public void testGetClassPathFromManifest_multiplePaths() throws IOException {
File jarFile = new File("base/some.jar");
Manifest manifest = manifestClasspath("file:/with/absolute.jar relative.jar relative/dir");
- assertThat(ClassPath.getClassPathFromManifest(jarFile, manifest))
+ assertThat(ClassPath.Scanner.getClassPathFromManifest(jarFile, manifest))
.containsExactly(
fullpath("/with/absolute.jar"),
fullpath("base/relative.jar"),
@@ -369,14 +381,14 @@
public void testGetClassPathFromManifest_leadingBlanks() throws IOException {
File jarFile = new File("base/some.jar");
Manifest manifest = manifestClasspath(" relative.jar");
- assertThat(ClassPath.getClassPathFromManifest(jarFile, manifest))
+ assertThat(ClassPath.Scanner.getClassPathFromManifest(jarFile, manifest))
.containsExactly(fullpath("base/relative.jar"));
}
public void testGetClassPathFromManifest_trailingBlanks() throws IOException {
File jarFile = new File("base/some.jar");
Manifest manifest = manifestClasspath("relative.jar ");
- assertThat(ClassPath.getClassPathFromManifest(jarFile, manifest))
+ assertThat(ClassPath.Scanner.getClassPathFromManifest(jarFile, manifest))
.containsExactly(fullpath("base/relative.jar"));
}
@@ -410,7 +422,6 @@
// Test that ResourceInfo.urls() returns identical content to ClassLoader.getResources()
-
public void testGetClassPathUrls() throws Exception {
String oldPathSeparator = PATH_SEPARATOR.value();
String oldClassPath = JAVA_CLASS_PATH.value();
@@ -424,7 +435,7 @@
"relative/path/to/class/root",
"/absolute/path/to/class/root"));
try {
- ImmutableList<URL> urls = ClassPath.parseJavaClassPath();
+ ImmutableList<URL> urls = ClassPath.Scanner.parseJavaClassPath();
assertThat(urls.get(0).getProtocol()).isEqualTo("file");
assertThat(urls.get(0).getAuthority()).isNull();
@@ -451,50 +462,18 @@
private static class Nested {}
-
public void testNulls() throws IOException {
new NullPointerTester().testAllPublicStaticMethods(ClassPath.class);
new NullPointerTester()
.testAllPublicInstanceMethods(ClassPath.from(getClass().getClassLoader()));
}
-
- public void testLocationsFrom_idempotentScan() throws IOException {
- ImmutableSet<ClassPath.LocationInfo> locations =
- ClassPath.locationsFrom(getClass().getClassLoader());
- assertThat(locations).isNotEmpty();
- for (ClassPath.LocationInfo location : locations) {
- ImmutableSet<ResourceInfo> resources = location.scanResources();
- assertThat(location.scanResources()).containsExactlyElementsIn(resources);
- }
+ public void testResourceScanner() throws IOException {
+ ResourceScanner scanner = new ResourceScanner();
+ scanner.scan(ClassLoader.getSystemClassLoader());
+ assertThat(scanner.resources).contains("com/google/common/reflect/ClassPathTest.class");
}
- public void testLocationsFrom_idempotentLocations() {
- ImmutableSet<ClassPath.LocationInfo> locations =
- ClassPath.locationsFrom(getClass().getClassLoader());
- assertThat(ClassPath.locationsFrom(getClass().getClassLoader()))
- .containsExactlyElementsIn(locations);
- }
-
- public void testLocationEquals() {
- ClassLoader child = getClass().getClassLoader();
- ClassLoader parent = child.getParent();
- new EqualsTester()
- .addEqualityGroup(
- new ClassPath.LocationInfo(new File("foo.jar"), child),
- new ClassPath.LocationInfo(new File("foo.jar"), child))
- .addEqualityGroup(new ClassPath.LocationInfo(new File("foo.jar"), parent))
- .addEqualityGroup(new ClassPath.LocationInfo(new File("foo"), child))
- .testEquals();
- }
-
-
- public void testScanAllResources() throws IOException {
- assertThat(scanResourceNames(ClassLoader.getSystemClassLoader()))
- .contains("com/google/common/reflect/ClassPathTest.class");
- }
-
-
public void testExistsThrowsSecurityException() throws IOException, URISyntaxException {
SecurityManager oldSecurityManager = System.getSecurityManager();
try {
@@ -509,7 +488,7 @@
// In Java 9, Logger may read the TZ database. Only disallow reading the class path URLs.
final PermissionCollection readClassPathFiles =
new FilePermission("", "read").newPermissionCollection();
- for (URL url : ClassPath.parseJavaClassPath()) {
+ for (URL url : ClassPath.Scanner.parseJavaClassPath()) {
if (url.getProtocol().equalsIgnoreCase("file")) {
file = new File(url.toURI());
readClassPathFiles.add(new FilePermission(file.getAbsolutePath(), "read"));
@@ -601,21 +580,47 @@
return new File(new File(path).toURI());
}
+ private static class ResourceScanner extends ClassPath.Scanner {
+ final Set<String> resources = new HashSet<>();
+
+ @Override
+ protected void scanResource(ResourceInfo resource) throws IOException {
+ resources.add(resource.getResourceName());
+ }
+ }
+
private static URL makeJarUrlWithName(String name) throws IOException {
File fullPath = new File(Files.createTempDir(), name);
- File jarFile = pickAnyJarFile();
+ File jarFile = JarFileFinder.pickAnyJarFile();
Files.copy(jarFile, fullPath);
return fullPath.toURI().toURL();
}
- private static File pickAnyJarFile() throws IOException {
- for (ClassPath.LocationInfo location :
- ClassPath.locationsFrom(ClassPathTest.class.getClassLoader())) {
- if (!location.file().isDirectory() && location.file().exists()) {
- return location.file();
+ private static final class JarFileFinder extends ClassPath.Scanner {
+
+ private File found;
+
+ static File pickAnyJarFile() throws IOException {
+ JarFileFinder finder = new JarFileFinder();
+ try {
+ finder.scan(JarFileFinder.class.getClassLoader());
+ throw new IllegalStateException("No jar file found!");
+ } catch (StopScanningException expected) {
+ return finder.found;
}
}
- throw new AssertionError("Failed to find a jar file");
+
+ @Override
+ void scanJarFile(ClassLoader classloader, JarFile file) throws IOException {
+ this.found = new File(file.getName());
+ throw new StopScanningException();
+ }
+
+ @Override
+ protected void scanResource(ResourceInfo resource) {}
+
+ // Special exception just to terminate the scanning when we get any jar file to use.
+ private static final class StopScanningException extends RuntimeException {}
}
@AndroidIncompatible // Path (for symlink creation)
@@ -626,14 +631,4 @@
log.log(WARNING, "Failure cleaning up test directory", e);
}
}
-
- private static ImmutableSet<String> scanResourceNames(ClassLoader loader) throws IOException {
- ImmutableSet.Builder<String> builder = ImmutableSet.builder();
- for (ClassPath.LocationInfo location : ClassPath.locationsFrom(loader)) {
- for (ResourceInfo resource : location.scanResources()) {
- builder.add(resource.getResourceName());
- }
- }
- return builder.build();
- }
}
diff --git a/guava-tests/test/com/google/common/reflect/ElementTest.java b/guava-tests/test/com/google/common/reflect/ElementTest.java
new file mode 100644
index 0000000..abe63ba
--- /dev/null
+++ b/guava-tests/test/com/google/common/reflect/ElementTest.java
@@ -0,0 +1,247 @@
+/*
+ * Copyright (C) 2012 The Guava Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.google.common.reflect;
+
+import com.google.common.testing.EqualsTester;
+import com.google.common.testing.NullPointerTester;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.reflect.Constructor;
+import junit.framework.TestCase;
+
+/**
+ * Unit tests of {@link Element}.
+ *
+ * @author Ben Yu
+ */
+public class ElementTest extends TestCase {
+
+ public void testPrivateField() throws Exception {
+ Element element = A.field("privateField");
+ assertTrue(element.isPrivate());
+ assertFalse(element.isAbstract());
+ assertFalse(element.isPackagePrivate());
+ assertFalse(element.isProtected());
+ assertFalse(element.isPublic());
+ assertFalse(element.isFinal());
+ assertFalse(element.isStatic());
+ assertTrue(element.isAnnotationPresent(Tested.class));
+ }
+
+ public void testPackagePrivateField() throws Exception {
+ Element element = A.field("packagePrivateField");
+ assertFalse(element.isPrivate());
+ assertTrue(element.isPackagePrivate());
+ assertFalse(element.isProtected());
+ assertFalse(element.isPublic());
+ assertFalse(element.isFinal());
+ assertFalse(element.isStatic());
+ assertTrue(element.isAnnotationPresent(Tested.class));
+ }
+
+ public void testProtectedField() throws Exception {
+ Element element = A.field("protectedField");
+ assertFalse(element.isPrivate());
+ assertFalse(element.isPackagePrivate());
+ assertTrue(element.isProtected());
+ assertFalse(element.isPublic());
+ assertFalse(element.isFinal());
+ assertFalse(element.isStatic());
+ assertTrue(element.isAnnotationPresent(Tested.class));
+ }
+
+ public void testPublicField() throws Exception {
+ Element element = A.field("publicField");
+ assertFalse(element.isPrivate());
+ assertFalse(element.isPackagePrivate());
+ assertFalse(element.isProtected());
+ assertTrue(element.isPublic());
+ assertFalse(element.isFinal());
+ assertFalse(element.isStatic());
+ assertTrue(element.isAnnotationPresent(Tested.class));
+ }
+
+ public void testFinalField() throws Exception {
+ Element element = A.field("finalField");
+ assertTrue(element.isFinal());
+ assertFalse(element.isStatic());
+ assertTrue(element.isAnnotationPresent(Tested.class));
+ }
+
+ public void testStaticField() throws Exception {
+ Element element = A.field("staticField");
+ assertTrue(element.isStatic());
+ assertTrue(element.isAnnotationPresent(Tested.class));
+ }
+
+ public void testVolatileField() throws Exception {
+ Element element = A.field("volatileField");
+ assertTrue(element.isVolatile());
+ }
+
+ public void testTransientField() throws Exception {
+ Element element = A.field("transientField");
+ assertTrue(element.isTransient());
+ }
+
+ public void testConstructor() throws Exception {
+ Element element = A.constructor();
+ assertTrue(element.isPublic());
+ assertFalse(element.isPackagePrivate());
+ assertFalse(element.isAbstract());
+ assertFalse(element.isStatic());
+ assertTrue(element.isAnnotationPresent(Tested.class));
+ }
+
+ public void testAbstractMethod() throws Exception {
+ Element element = A.method("abstractMethod");
+ assertTrue(element.isPackagePrivate());
+ assertTrue(element.isAbstract());
+ assertFalse(element.isFinal());
+ assertTrue(element.isAnnotationPresent(Tested.class));
+ }
+
+ public void testOverridableMethod() throws Exception {
+ Element element = A.method("overridableMethod");
+ assertTrue(element.isPackagePrivate());
+ assertFalse(element.isAbstract());
+ assertFalse(element.isFinal());
+ assertTrue(element.isAnnotationPresent(Tested.class));
+ }
+
+ public void testPrivateMethod() throws Exception {
+ Element element = A.method("privateMethod");
+ assertFalse(element.isAbstract());
+ assertTrue(element.isPrivate());
+ assertFalse(element.isPackagePrivate());
+ assertFalse(element.isPublic());
+ assertFalse(element.isProtected());
+ assertTrue(element.isAnnotationPresent(Tested.class));
+ }
+
+ public void testProtectedMethod() throws Exception {
+ Element element = A.method("protectedMethod");
+ assertFalse(element.isAbstract());
+ assertFalse(element.isPrivate());
+ assertFalse(element.isPackagePrivate());
+ assertFalse(element.isFinal());
+ assertFalse(element.isPublic());
+ assertTrue(element.isProtected());
+ assertTrue(element.isAnnotationPresent(Tested.class));
+ }
+
+ public void testFinalMethod() throws Exception {
+ Element element = A.method("publicFinalMethod");
+ assertFalse(element.isAbstract());
+ assertFalse(element.isPrivate());
+ assertTrue(element.isFinal());
+ assertTrue(element.isPublic());
+ assertTrue(element.isAnnotationPresent(Tested.class));
+ }
+
+ public void testNativeMethod() throws Exception {
+ Element element = A.method("nativeMethod");
+ assertTrue(element.isNative());
+ assertTrue(element.isPackagePrivate());
+ }
+
+ public void testSynchronizedMethod() throws Exception {
+ Element element = A.method("synchronizedMethod");
+ assertTrue(element.isSynchronized());
+ }
+
+ public void testUnannotatedMethod() throws Exception {
+ Element element = A.method("notAnnotatedMethod");
+ assertFalse(element.isAnnotationPresent(Tested.class));
+ }
+
+ public void testEquals() throws Exception {
+ new EqualsTester()
+ .addEqualityGroup(A.field("privateField"), A.field("privateField"))
+ .addEqualityGroup(A.field("publicField"))
+ .addEqualityGroup(A.constructor(), A.constructor())
+ .addEqualityGroup(A.method("privateMethod"), A.method("privateMethod"))
+ .addEqualityGroup(A.method("publicFinalMethod"))
+ .testEquals();
+ }
+
+ public void testNulls() {
+ new NullPointerTester().testAllPublicStaticMethods(Element.class);
+ }
+
+ @Retention(RetentionPolicy.RUNTIME)
+ private @interface Tested {}
+
+ private abstract static class A {
+ @Tested private boolean privateField;
+ @Tested int packagePrivateField;
+ @Tested protected int protectedField;
+ @Tested public String publicField;
+ @Tested private static Iterable<String> staticField;
+ @Tested private final Object finalField;
+ private volatile char volatileField;
+ private transient long transientField;
+
+ @Tested
+ public A(Object finalField) {
+ this.finalField = finalField;
+ }
+
+ @Tested
+ abstract void abstractMethod();
+
+ @Tested
+ void overridableMethod() {}
+
+ @Tested
+ protected void protectedMethod() {}
+
+ @Tested
+ private void privateMethod() {}
+
+ @Tested
+ public final void publicFinalMethod() {}
+
+ void notAnnotatedMethod() {}
+
+ static Element field(String name) throws Exception {
+ Element element = new Element(A.class.getDeclaredField(name));
+ assertEquals(name, element.getName());
+ assertEquals(A.class, element.getDeclaringClass());
+ return element;
+ }
+
+ static Element constructor() throws Exception {
+ Constructor<?> constructor = A.class.getDeclaredConstructor(Object.class);
+ Element element = new Element(constructor);
+ assertEquals(constructor.getName(), element.getName());
+ assertEquals(A.class, element.getDeclaringClass());
+ return element;
+ }
+
+ static Element method(String name, Class<?>... parameterTypes) throws Exception {
+ Element element = new Element(A.class.getDeclaredMethod(name, parameterTypes));
+ assertEquals(name, element.getName());
+ assertEquals(A.class, element.getDeclaringClass());
+ return element;
+ }
+
+ native void nativeMethod();
+
+ synchronized void synchronizedMethod() {}
+ }
+}
diff --git a/guava-tests/test/com/google/common/reflect/InvokableTest.java b/guava-tests/test/com/google/common/reflect/InvokableTest.java
index 3e51c82..1b48ba6 100644
--- a/guava-tests/test/com/google/common/reflect/InvokableTest.java
+++ b/guava-tests/test/com/google/common/reflect/InvokableTest.java
@@ -19,16 +19,13 @@
import static com.google.common.truth.Truth.assertThat;
import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
import com.google.common.testing.EqualsTester;
import com.google.common.testing.NullPointerTester;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
-import java.lang.reflect.AccessibleObject;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.TypeVariable;
import java.util.Collections;
@@ -42,180 +39,6 @@
*/
@AndroidIncompatible // lots of failures, possibly some related to bad equals() implementations?
public class InvokableTest extends TestCase {
- // Historically Invokable inherited from java.lang.reflect.AccessibleObject. That's no longer the
- // case, but we do check that its API still has the same public methods. We exclude some methods
- // that were added in Java 9 and that people probably weren't calling via Invokable, namely
- // `boolean canAccess(Object)` and `boolean trySetAccessible()`.
- public void testApiCompatibleWithAccessibleObject() {
- ImmutableSet<String> invokableMethods =
- publicMethodSignatures(Invokable.class, ImmutableSet.<String>of());
- ImmutableSet<String> accesibleObjectMethods =
- publicMethodSignatures(AccessibleObject.class, ImmutableSet.of("canAccess"));
- assertThat(invokableMethods).containsAtLeastElementsIn(accesibleObjectMethods);
- Class<?> genericDeclaration;
- try {
- genericDeclaration = Class.forName("java.lang.reflect.GenericDeclaration");
- ImmutableSet<String> genericDeclarationMethods =
- publicMethodSignatures(genericDeclaration, ImmutableSet.<String>of());
- assertThat(invokableMethods).containsAtLeastElementsIn(genericDeclarationMethods);
- } catch (ClassNotFoundException e) {
- // OK: we're on Java 7, which doesn't have this class
- }
- }
-
- private static ImmutableSet<String> publicMethodSignatures(
- Class<?> c, ImmutableSet<String> ignore) {
- ImmutableSet.Builder<String> methods = ImmutableSet.builder();
- for (Method method : c.getMethods()) {
- if (Modifier.isStatic(method.getModifiers()) || ignore.contains(method.getName())) {
- continue;
- }
- StringBuilder signature =
- new StringBuilder()
- .append(typeName(method.getReturnType()))
- .append(" ")
- .append(method.getName())
- .append("(");
- String sep = "";
- for (Class<?> param : method.getParameterTypes()) {
- signature.append(sep).append(typeName(param));
- sep = ", ";
- }
- methods.add(signature.append(")").toString());
- }
- return methods.build();
- }
-
- private static String typeName(Class<?> type) {
- return type.isArray() ? typeName(type.getComponentType()) + "[]" : type.getName();
- }
-
- public void testConstructor() throws Exception {
- Invokable<A, A> invokable = A.constructor();
- assertTrue(invokable.isPublic());
- assertFalse(invokable.isPackagePrivate());
- assertFalse(invokable.isAbstract());
- assertFalse(invokable.isStatic());
- assertTrue(invokable.isAnnotationPresent(Tested.class));
- }
-
- public void testAbstractMethod() throws Exception {
- Invokable<?, Object> invokable = A.method("abstractMethod");
- assertTrue(invokable.isPackagePrivate());
- assertTrue(invokable.isAbstract());
- assertFalse(invokable.isFinal());
- assertTrue(invokable.isAnnotationPresent(Tested.class));
- }
-
- public void testOverridableMethod() throws Exception {
- Invokable<?, Object> invokable = A.method("overridableMethod");
- assertTrue(invokable.isPackagePrivate());
- assertFalse(invokable.isAbstract());
- assertFalse(invokable.isFinal());
- assertTrue(invokable.isAnnotationPresent(Tested.class));
- }
-
- public void testPrivateMethod() throws Exception {
- Invokable<?, Object> invokable = A.method("privateMethod");
- assertFalse(invokable.isAbstract());
- assertTrue(invokable.isPrivate());
- assertFalse(invokable.isPackagePrivate());
- assertFalse(invokable.isPublic());
- assertFalse(invokable.isProtected());
- assertTrue(invokable.isAnnotationPresent(Tested.class));
- }
-
- public void testProtectedMethod() throws Exception {
- Invokable<?, Object> invokable = A.method("protectedMethod");
- assertFalse(invokable.isAbstract());
- assertFalse(invokable.isPrivate());
- assertFalse(invokable.isPackagePrivate());
- assertFalse(invokable.isFinal());
- assertFalse(invokable.isPublic());
- assertTrue(invokable.isProtected());
- assertTrue(invokable.isAnnotationPresent(Tested.class));
- }
-
- public void testFinalMethod() throws Exception {
- Invokable<?, Object> invokable = A.method("publicFinalMethod");
- assertFalse(invokable.isAbstract());
- assertFalse(invokable.isPrivate());
- assertTrue(invokable.isFinal());
- assertTrue(invokable.isPublic());
- assertTrue(invokable.isAnnotationPresent(Tested.class));
- }
-
- public void testNativeMethod() throws Exception {
- Invokable<?, Object> invokable = A.method("nativeMethod");
- assertTrue(invokable.isNative());
- assertTrue(invokable.isPackagePrivate());
- }
-
- public void testSynchronizedMethod() throws Exception {
- Invokable<?, Object> invokable = A.method("synchronizedMethod");
- assertTrue(invokable.isSynchronized());
- }
-
- public void testUnannotatedMethod() throws Exception {
- Invokable<?, Object> invokable = A.method("notAnnotatedMethod");
- assertFalse(invokable.isAnnotationPresent(Tested.class));
- }
-
- @Retention(RetentionPolicy.RUNTIME)
- private @interface Tested {}
-
- private abstract static class A {
- @Tested private boolean privateField;
- @Tested int packagePrivateField;
- @Tested protected int protectedField;
- @Tested public String publicField;
- @Tested private static Iterable<String> staticField;
- @Tested private final Object finalField;
- private volatile char volatileField;
- private transient long transientField;
-
- @Tested
- public A(Object finalField) {
- this.finalField = finalField;
- }
-
- @Tested
- abstract void abstractMethod();
-
- @Tested
- void overridableMethod() {}
-
- @Tested
- protected void protectedMethod() {}
-
- @Tested
- private void privateMethod() {}
-
- @Tested
- public final void publicFinalMethod() {}
-
- void notAnnotatedMethod() {}
-
- static Invokable<A, A> constructor() throws Exception {
- Constructor<A> constructor = A.class.getDeclaredConstructor(Object.class);
- Invokable<A, A> invokable = Invokable.from(constructor);
- assertEquals(constructor.getName(), invokable.getName());
- assertEquals(A.class, invokable.getDeclaringClass());
- return invokable;
- }
-
- static Invokable<?, Object> method(String name, Class<?>... parameterTypes) throws Exception {
- Invokable<?, Object> invokable =
- Invokable.from(A.class.getDeclaredMethod(name, parameterTypes));
- assertEquals(name, invokable.getName());
- assertEquals(A.class, invokable.getDeclaringClass());
- return invokable;
- }
-
- native void nativeMethod();
-
- synchronized void synchronizedMethod() {}
- }
public void testConstructor_returnType() throws Exception {
assertEquals(Prepender.class, Prepender.constructor().getReturnType().getType());
@@ -251,7 +74,7 @@
public void testConstructor_typeParameters() throws Exception {
TypeVariable<?>[] variables = Prepender.constructor().getTypeParameters();
assertThat(variables).hasLength(1);
- assertEquals("T", variables[0].getName());
+ assertEquals("A", variables[0].getName());
}
public void testConstructor_parameters() throws Exception {
@@ -707,9 +530,6 @@
public void testEquals() throws Exception {
new EqualsTester()
- .addEqualityGroup(A.constructor(), A.constructor())
- .addEqualityGroup(A.method("privateMethod"), A.method("privateMethod"))
- .addEqualityGroup(A.method("publicFinalMethod"))
.addEqualityGroup(Prepender.constructor(), Prepender.constructor())
.addEqualityGroup(Prepender.constructor(String.class, int.class))
.addEqualityGroup(Prepender.method("privateMethod"), Prepender.method("privateMethod"))
@@ -742,7 +562,7 @@
}
// just for testing
- private <T> Prepender() {
+ private <A> Prepender() {
this(null, 0);
}
diff --git a/guava-tests/test/com/google/common/util/concurrent/AbstractExecutionThreadServiceTest.java b/guava-tests/test/com/google/common/util/concurrent/AbstractExecutionThreadServiceTest.java
index 557fc0b..9b3f0f8 100644
--- a/guava-tests/test/com/google/common/util/concurrent/AbstractExecutionThreadServiceTest.java
+++ b/guava-tests/test/com/google/common/util/concurrent/AbstractExecutionThreadServiceTest.java
@@ -68,7 +68,6 @@
thrownByExecutionThread);
}
-
public void testServiceStartStop() throws Exception {
WaitOnRunService service = new WaitOnRunService();
assertFalse(service.startUpCalled);
@@ -85,7 +84,6 @@
executionThread.join();
}
-
public void testServiceStopIdempotence() throws Exception {
WaitOnRunService service = new WaitOnRunService();
@@ -102,7 +100,6 @@
executionThread.join();
}
-
public void testServiceExitingOnItsOwn() throws Exception {
WaitOnRunService service = new WaitOnRunService();
service.expectedShutdownState = Service.State.RUNNING;
@@ -173,7 +170,6 @@
}
}
-
public void testServiceThrowOnStartUp() throws Exception {
ThrowOnStartUpService service = new ThrowOnStartUpService();
assertFalse(service.startUpCalled);
@@ -212,7 +208,6 @@
}
}
-
public void testServiceThrowOnRun() throws Exception {
ThrowOnRunService service = new ThrowOnRunService();
@@ -229,7 +224,6 @@
assertEquals(Service.State.FAILED, service.state());
}
-
public void testServiceThrowOnRunAndThenAgainOnShutDown() throws Exception {
ThrowOnRunService service = new ThrowOnRunService();
service.throwOnShutDown = true;
@@ -271,7 +265,6 @@
}
}
-
public void testServiceThrowOnShutDown() throws Exception {
ThrowOnShutDown service = new ThrowOnShutDown();
@@ -331,7 +324,6 @@
protected void run() throws Exception {}
}
-
public void testStopWhileStarting_runNotCalled() throws Exception {
final CountDownLatch started = new CountDownLatch(1);
FakeService service =
@@ -361,7 +353,6 @@
assertEquals(0, service.shutdownCalled);
}
-
public void testDefaultService() throws InterruptedException {
WaitOnRunService service = new WaitOnRunService();
service.startAsync().awaitRunning();
diff --git a/guava-tests/test/com/google/common/util/concurrent/AbstractFutureFallbackAtomicHelperTest.java b/guava-tests/test/com/google/common/util/concurrent/AbstractFutureFallbackAtomicHelperTest.java
index 208cf24..77d04ff 100644
--- a/guava-tests/test/com/google/common/util/concurrent/AbstractFutureFallbackAtomicHelperTest.java
+++ b/guava-tests/test/com/google/common/util/concurrent/AbstractFutureFallbackAtomicHelperTest.java
@@ -107,7 +107,7 @@
private void runTestMethod(ClassLoader classLoader) throws Exception {
Class<?> test = classLoader.loadClass(AbstractFutureTest.class.getName());
- test.getMethod(getName()).invoke(test.getDeclaredConstructor().newInstance());
+ test.getMethod(getName()).invoke(test.newInstance());
}
private void checkHelperVersion(ClassLoader classLoader, String expectedHelperClassName)
diff --git a/guava-tests/test/com/google/common/util/concurrent/AbstractFutureInnocuousThreadTest.java b/guava-tests/test/com/google/common/util/concurrent/AbstractFutureInnocuousThreadTest.java
index e49af23..e88e7e8 100644
--- a/guava-tests/test/com/google/common/util/concurrent/AbstractFutureInnocuousThreadTest.java
+++ b/guava-tests/test/com/google/common/util/concurrent/AbstractFutureInnocuousThreadTest.java
@@ -16,7 +16,6 @@
package com.google.common.util.concurrent;
-
import java.net.URLClassLoader;
import java.security.Permission;
import java.util.HashMap;
diff --git a/guava-tests/test/com/google/common/util/concurrent/AbstractFutureTest.java b/guava-tests/test/com/google/common/util/concurrent/AbstractFutureTest.java
index e55a31e..3c210ce 100644
--- a/guava-tests/test/com/google/common/util/concurrent/AbstractFutureTest.java
+++ b/guava-tests/test/com/google/common/util/concurrent/AbstractFutureTest.java
@@ -579,7 +579,7 @@
final AbstractFuture<String> future = new AbstractFuture<String>() {};
currentFuture.set(future);
for (Callable<?> task : allTasks) {
- @SuppressWarnings("unused") // https://errorprone.info/bugpattern/FutureReturnValueIgnored
+ @SuppressWarnings("unused") // go/futurereturn-lsc
Future<?> possiblyIgnoredError = executor.submit(task);
}
awaitUnchecked(barrier);
@@ -798,7 +798,7 @@
final AbstractFuture<String> future = new AbstractFuture<String>() {};
currentFuture.set(future);
for (Callable<?> task : allTasks) {
- @SuppressWarnings("unused") // https://errorprone.info/bugpattern/FutureReturnValueIgnored
+ @SuppressWarnings("unused") // go/futurereturn-lsc
Future<?> possiblyIgnoredError = executor.submit(task);
}
awaitUnchecked(barrier);
diff --git a/guava-tests/test/com/google/common/util/concurrent/AbstractScheduledServiceTest.java b/guava-tests/test/com/google/common/util/concurrent/AbstractScheduledServiceTest.java
index a2411ad..16a4cd0 100644
--- a/guava-tests/test/com/google/common/util/concurrent/AbstractScheduledServiceTest.java
+++ b/guava-tests/test/com/google/common/util/concurrent/AbstractScheduledServiceTest.java
@@ -21,7 +21,6 @@
import static com.google.common.util.concurrent.MoreExecutors.directExecutor;
import static java.util.concurrent.TimeUnit.SECONDS;
-import com.google.common.util.concurrent.AbstractScheduledService.Cancellable;
import com.google.common.util.concurrent.AbstractScheduledService.Scheduler;
import com.google.common.util.concurrent.Service.State;
import com.google.common.util.concurrent.testing.TestingExecutors;
@@ -29,7 +28,6 @@
import java.util.concurrent.CancellationException;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.CyclicBarrier;
-import java.util.concurrent.Delayed;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.ScheduledExecutorService;
@@ -390,7 +388,7 @@
public void testFixedRateSchedule() {
Scheduler schedule = Scheduler.newFixedRateSchedule(initialDelay, delay, unit);
- Cancellable unused =
+ Future<?> unused =
schedule.schedule(
null,
new ScheduledThreadPoolExecutor(1) {
@@ -398,7 +396,7 @@
public ScheduledFuture<?> scheduleAtFixedRate(
Runnable command, long initialDelay, long period, TimeUnit unit) {
assertSingleCallWithCorrectParameters(command, initialDelay, delay, unit);
- return new ThrowingScheduledFuture<>();
+ return null;
}
},
testRunnable);
@@ -407,7 +405,7 @@
public void testFixedDelaySchedule() {
Scheduler schedule = newFixedDelaySchedule(initialDelay, delay, unit);
- Cancellable unused =
+ Future<?> unused =
schedule.schedule(
null,
new ScheduledThreadPoolExecutor(10) {
@@ -415,32 +413,13 @@
public ScheduledFuture<?> scheduleWithFixedDelay(
Runnable command, long initialDelay, long delay, TimeUnit unit) {
assertSingleCallWithCorrectParameters(command, initialDelay, delay, unit);
- return new ThrowingScheduledFuture<>();
+ return null;
}
},
testRunnable);
assertTrue(called);
}
- private static final class ThrowingScheduledFuture<V> extends ForwardingFuture<V>
- implements ScheduledFuture<V> {
- @Override
- protected Future<V> delegate() {
- throw new UnsupportedOperationException("test should not care about this");
- }
-
- @Override
- public long getDelay(TimeUnit unit) {
- throw new UnsupportedOperationException("test should not care about this");
- }
-
- @Override
- public int compareTo(Delayed other) {
- throw new UnsupportedOperationException("test should not care about this");
- }
- }
-
-
public void testFixedDelayScheduleFarFuturePotentiallyOverflowingScheduleIsNeverReached()
throws Exception {
TestAbstractScheduledCustomService service =
@@ -461,7 +440,6 @@
service.awaitTerminated();
}
-
public void testCustomSchedulerFarFuturePotentiallyOverflowingScheduleIsNeverReached()
throws Exception {
TestAbstractScheduledCustomService service =
@@ -497,7 +475,6 @@
}
}
-
public void testCustomSchedule_startStop() throws Exception {
final CyclicBarrier firstBarrier = new CyclicBarrier(2);
final CyclicBarrier secondBarrier = new CyclicBarrier(2);
@@ -517,7 +494,7 @@
}
};
TestCustomScheduler scheduler = new TestCustomScheduler();
- Cancellable future = scheduler.schedule(null, Executors.newScheduledThreadPool(10), task);
+ Future<?> future = scheduler.schedule(null, Executors.newScheduledThreadPool(10), task);
firstBarrier.await();
assertEquals(1, scheduler.scheduleCounter.get());
secondBarrier.await();
@@ -528,7 +505,6 @@
future.cancel(false);
}
-
public void testCustomSchedulerServiceStop() throws Exception {
TestAbstractScheduledCustomService service = new TestAbstractScheduledCustomService();
service.startAsync().awaitRunning();
@@ -542,7 +518,6 @@
assertEquals(1, service.numIterations.get());
}
-
public void testCustomScheduler_deadlock() throws InterruptedException, BrokenBarrierException {
final CyclicBarrier inGetNextSchedule = new CyclicBarrier(2);
// This will flakily deadlock, so run it multiple times to increase the flake likelihood
@@ -573,7 +548,6 @@
}
}
-
public void testBig() throws Exception {
TestAbstractScheduledCustomService service =
new TestAbstractScheduledCustomService() {
@@ -633,7 +607,6 @@
}
}
-
public void testCustomSchedulerFailure() throws Exception {
TestFailingCustomScheduledService service = new TestFailingCustomScheduledService();
service.startAsync().awaitRunning();
diff --git a/guava-tests/test/com/google/common/util/concurrent/AbstractServiceTest.java b/guava-tests/test/com/google/common/util/concurrent/AbstractServiceTest.java
index e3c22a8..5f42106 100644
--- a/guava-tests/test/com/google/common/util/concurrent/AbstractServiceTest.java
+++ b/guava-tests/test/com/google/common/util/concurrent/AbstractServiceTest.java
@@ -330,7 +330,6 @@
}
}
-
public void testAwaitTerminated() throws Exception {
final NoOpService service = new NoOpService();
Thread waiter =
@@ -348,7 +347,6 @@
assertFalse(waiter.isAlive());
}
-
public void testAwaitTerminated_FailedService() throws Exception {
final ManualSwitchedService service = new ManualSwitchedService();
final AtomicReference<Throwable> exception = Atomics.newReference();
@@ -376,7 +374,6 @@
assertThat(exception.get()).hasCauseThat().isEqualTo(EXCEPTION);
}
-
public void testThreadedServiceStartAndWaitStopAndWait() throws Throwable {
ThreadedService service = new ThreadedService();
RecordingListener listener = RecordingListener.record(service);
@@ -394,7 +391,6 @@
listener.getStateHistory());
}
-
public void testThreadedServiceStopIdempotence() throws Throwable {
ThreadedService service = new ThreadedService();
@@ -410,7 +406,6 @@
throwIfSet(thrownByExecutionThread);
}
-
public void testThreadedServiceStopIdempotenceAfterWait() throws Throwable {
ThreadedService service = new ThreadedService();
@@ -428,7 +423,6 @@
throwIfSet(thrownByExecutionThread);
}
-
public void testThreadedServiceStopIdempotenceDoubleWait() throws Throwable {
ThreadedService service = new ThreadedService();
@@ -661,7 +655,6 @@
}
}
-
public void testAddListenerAfterFailureDoesntCauseDeadlock() throws InterruptedException {
final StartFailingService service = new StartFailingService();
service.startAsync();
@@ -681,7 +674,6 @@
assertFalse(thread + " is deadlocked", thread.isAlive());
}
-
public void testListenerDoesntDeadlockOnStartAndWaitFromRunning() throws Exception {
final NoOpThreadedService service = new NoOpThreadedService();
service.addListener(
@@ -696,7 +688,6 @@
service.stopAsync();
}
-
public void testListenerDoesntDeadlockOnStopAndWaitFromTerminated() throws Exception {
final NoOpThreadedService service = new NoOpThreadedService();
service.addListener(
diff --git a/guava-tests/test/com/google/common/util/concurrent/AggregateFutureStateFallbackAtomicHelperTest.java b/guava-tests/test/com/google/common/util/concurrent/AggregateFutureStateFallbackAtomicHelperTest.java
index fec9394..761f7d7 100644
--- a/guava-tests/test/com/google/common/util/concurrent/AggregateFutureStateFallbackAtomicHelperTest.java
+++ b/guava-tests/test/com/google/common/util/concurrent/AggregateFutureStateFallbackAtomicHelperTest.java
@@ -95,7 +95,7 @@
private void runTestMethod(ClassLoader classLoader) throws Exception {
Class<?> test = classLoader.loadClass(FuturesTest.class.getName());
- Object testInstance = test.getDeclaredConstructor().newInstance();
+ Object testInstance = test.newInstance();
test.getMethod("setUp").invoke(testInstance);
test.getMethod(getName()).invoke(testInstance);
test.getMethod("tearDown").invoke(testInstance);
diff --git a/guava-tests/test/com/google/common/util/concurrent/AtomicDoubleTest.java b/guava-tests/test/com/google/common/util/concurrent/AtomicDoubleTest.java
index df9bd8b..c892842 100644
--- a/guava-tests/test/com/google/common/util/concurrent/AtomicDoubleTest.java
+++ b/guava-tests/test/com/google/common/util/concurrent/AtomicDoubleTest.java
@@ -13,7 +13,6 @@
package com.google.common.util.concurrent;
-
/** Unit test for {@link AtomicDouble}. */
public class AtomicDoubleTest extends JSR166TestCase {
diff --git a/guava-tests/test/com/google/common/util/concurrent/AtomicLongMapBasherTest.java b/guava-tests/test/com/google/common/util/concurrent/AtomicLongMapBasherTest.java
index 4765825..d905dcd 100644
--- a/guava-tests/test/com/google/common/util/concurrent/AtomicLongMapBasherTest.java
+++ b/guava-tests/test/com/google/common/util/concurrent/AtomicLongMapBasherTest.java
@@ -47,7 +47,7 @@
ExecutorService threadPool = Executors.newFixedThreadPool(nThreads);
for (int i = 0; i < nTasks; i++) {
- @SuppressWarnings("unused") // https://errorprone.info/bugpattern/FutureReturnValueIgnored
+ @SuppressWarnings("unused") // go/futurereturn-lsc
Future<?> possiblyIgnoredError =
threadPool.submit(
new Runnable() {
diff --git a/guava-tests/test/com/google/common/util/concurrent/ClosingFutureTest.java b/guava-tests/test/com/google/common/util/concurrent/ClosingFutureTest.java
index ab0e5f8..58cf5bb 100644
--- a/guava-tests/test/com/google/common/util/concurrent/ClosingFutureTest.java
+++ b/guava-tests/test/com/google/common/util/concurrent/ClosingFutureTest.java
@@ -38,7 +38,6 @@
import com.google.common.reflect.Reflection;
import com.google.common.truth.FailureStrategy;
import com.google.common.truth.StandardSubjectBuilder;
-import com.google.common.util.concurrent.ClosingFuture.AsyncClosingCallable;
import com.google.common.util.concurrent.ClosingFuture.AsyncClosingFunction;
import com.google.common.util.concurrent.ClosingFuture.ClosingCallable;
import com.google.common.util.concurrent.ClosingFuture.ClosingFunction;
@@ -268,76 +267,6 @@
assertClosed(closeable1, closeable2);
}
- public void testSubmitAsync() throws Exception {
- ClosingFuture<TestCloseable> closingFuture =
- ClosingFuture.submitAsync(
- new AsyncClosingCallable<TestCloseable>() {
- @Override
- public ClosingFuture<TestCloseable> call(DeferredCloser closer) {
- closer.eventuallyClose(closeable1, closingExecutor);
- return ClosingFuture.submit(
- new ClosingCallable<TestCloseable>() {
- @Override
- public TestCloseable call(DeferredCloser deferredCloser) throws Exception {
- return closeable2;
- }
- },
- directExecutor());
- }
- },
- executor);
- assertThat(getFinalValue(closingFuture)).isSameInstanceAs(closeable2);
- waitUntilClosed(closingFuture);
- assertClosed(closeable1);
- assertStillOpen(closeable2);
- }
-
- public void testSubmitAsync_cancelledPipeline() throws Exception {
- ClosingFuture<TestCloseable> closingFuture =
- ClosingFuture.submitAsync(
- waiter.waitFor(
- new AsyncClosingCallable<TestCloseable>() {
- @Override
- public ClosingFuture<TestCloseable> call(DeferredCloser closer) throws Exception {
- awaitUninterruptibly(futureCancelled);
- closer.eventuallyClose(closeable1, closingExecutor);
- closer.eventuallyClose(closeable2, closingExecutor);
- return ClosingFuture.submit(
- new ClosingCallable<TestCloseable>() {
- @Override
- public TestCloseable call(DeferredCloser deferredCloser)
- throws Exception {
- deferredCloser.eventuallyClose(closeable3, closingExecutor);
- return closeable3;
- }
- },
- directExecutor());
- }
- }),
- executor);
- waiter.awaitStarted();
- cancelFinalStepAndWait(closingFuture);
- waiter.awaitReturned();
- assertClosed(closeable1, closeable2, closeable3);
- }
-
- public void testSubmitAsync_throws() throws Exception {
- ClosingFuture<Object> closingFuture =
- ClosingFuture.submitAsync(
- new AsyncClosingCallable<Object>() {
- @Override
- public ClosingFuture<Object> call(DeferredCloser closer) throws Exception {
- closer.eventuallyClose(closeable1, closingExecutor);
- closer.eventuallyClose(closeable2, closingExecutor);
- throw exception;
- }
- },
- executor);
- assertFinallyFailsWithException(closingFuture);
- waitUntilClosed(closingFuture);
- assertClosed(closeable1, closeable2);
- }
-
public void testAutoCloseable() throws Exception {
AutoCloseable autoCloseable = closeable1::close;
ClosingFuture<String> closingFuture =
@@ -1925,10 +1854,6 @@
return waitFor(closingCallable, ClosingCallable.class);
}
- <V> AsyncClosingCallable<V> waitFor(AsyncClosingCallable<V> asyncClosingCallable) {
- return waitFor(asyncClosingCallable, AsyncClosingCallable.class);
- }
-
<T, U> ClosingFunction<T, U> waitFor(ClosingFunction<T, U> closingFunction) {
return waitFor(closingFunction, ClosingFunction.class);
}
diff --git a/guava-tests/test/com/google/common/util/concurrent/CycleDetectingLockFactoryTest.java b/guava-tests/test/com/google/common/util/concurrent/CycleDetectingLockFactoryTest.java
index 18e69b1..5abe6ce 100644
--- a/guava-tests/test/com/google/common/util/concurrent/CycleDetectingLockFactoryTest.java
+++ b/guava-tests/test/com/google/common/util/concurrent/CycleDetectingLockFactoryTest.java
@@ -16,7 +16,6 @@
package com.google.common.util.concurrent;
-
import com.google.common.base.Joiner;
import com.google.common.util.concurrent.CycleDetectingLockFactory.Policies;
import com.google.common.util.concurrent.CycleDetectingLockFactory.Policy;
@@ -442,7 +441,6 @@
lockD.lock();
}
-
public void testReentrantLock_tryLock() throws Exception {
LockingThread thread = new LockingThread(lockA);
thread.start();
@@ -454,7 +452,6 @@
assertTrue(lockA.tryLock());
}
-
public void testReentrantWriteLock_tryLock() throws Exception {
LockingThread thread = new LockingThread(writeLockA);
thread.start();
@@ -468,7 +465,6 @@
assertTrue(readLockA.tryLock());
}
-
public void testReentrantReadLock_tryLock() throws Exception {
LockingThread thread = new LockingThread(readLockA);
thread.start();
diff --git a/guava-tests/test/com/google/common/util/concurrent/ExecutionListTest.java b/guava-tests/test/com/google/common/util/concurrent/ExecutionListTest.java
index 5bd3cf7..34678ed 100644
--- a/guava-tests/test/com/google/common/util/concurrent/ExecutionListTest.java
+++ b/guava-tests/test/com/google/common/util/concurrent/ExecutionListTest.java
@@ -36,7 +36,6 @@
private final ExecutionList list = new ExecutionList();
-
public void testRunOnPopulatedList() throws Exception {
Executor exec = Executors.newCachedThreadPool();
CountDownLatch countDownLatch = new CountDownLatch(3);
@@ -67,7 +66,6 @@
assertEquals(1, runCalled.get());
}
-
public void testExecute_idempotentConcurrently() throws InterruptedException {
final CountDownLatch okayToRun = new CountDownLatch(1);
final AtomicInteger runCalled = new AtomicInteger();
@@ -103,7 +101,6 @@
assertEquals(1, runCalled.get());
}
-
public void testAddAfterRun() throws Exception {
// Run the previous test
testRunOnPopulatedList();
diff --git a/guava-tests/test/com/google/common/util/concurrent/ExecutionSequencerTest.java b/guava-tests/test/com/google/common/util/concurrent/ExecutionSequencerTest.java
index 1c03f5a..687f226 100644
--- a/guava-tests/test/com/google/common/util/concurrent/ExecutionSequencerTest.java
+++ b/guava-tests/test/com/google/common/util/concurrent/ExecutionSequencerTest.java
@@ -88,7 +88,6 @@
assertThat(thirdCallable.called).isTrue();
}
-
public void testCancellationMultipleThreads() throws Exception {
final BlockingCallable blockingCallable = new BlockingCallable();
ListenableFuture<Void> unused = serializer.submit(blockingCallable, executor);
@@ -116,7 +115,6 @@
assertThat(getDone(future2)).isFalse();
}
-
public void testSecondTaskWaitsForFirstEvenIfCancelled() throws Exception {
final BlockingCallable blockingCallable = new BlockingCallable();
ListenableFuture<Void> future1 = serializer.submit(blockingCallable, executor);
diff --git a/guava-tests/test/com/google/common/util/concurrent/FluentFutureTest.java b/guava-tests/test/com/google/common/util/concurrent/FluentFutureTest.java
index cc4751d..ab53f53 100644
--- a/guava-tests/test/com/google/common/util/concurrent/FluentFutureTest.java
+++ b/guava-tests/test/com/google/common/util/concurrent/FluentFutureTest.java
@@ -132,7 +132,6 @@
assertThat(f.get()).isEqualTo(2);
}
-
@GwtIncompatible // withTimeout
public void testWithTimeout() throws Exception {
ScheduledExecutorService executor = newScheduledThreadPool(1);
diff --git a/guava-tests/test/com/google/common/util/concurrent/ForwardingObjectTester.java b/guava-tests/test/com/google/common/util/concurrent/ForwardingObjectTester.java
index 84b0426..021d96d 100644
--- a/guava-tests/test/com/google/common/util/concurrent/ForwardingObjectTester.java
+++ b/guava-tests/test/com/google/common/util/concurrent/ForwardingObjectTester.java
@@ -61,7 +61,7 @@
new Function<Object, T>() {
@Override
public T apply(Object delegate) {
- T mock = mock(forwarderClass, CALLS_REAL_METHODS);
+ T mock = mock(forwarderClass, CALLS_REAL_METHODS.get());
try {
T stubber = doReturn(delegate).when(mock);
DELEGATE_METHOD.invoke(stubber);
diff --git a/guava-tests/test/com/google/common/util/concurrent/FuturesGetCheckedTest.java b/guava-tests/test/com/google/common/util/concurrent/FuturesGetCheckedTest.java
index 3bc69bd..2ec1736 100644
--- a/guava-tests/test/com/google/common/util/concurrent/FuturesGetCheckedTest.java
+++ b/guava-tests/test/com/google/common/util/concurrent/FuturesGetCheckedTest.java
@@ -353,7 +353,6 @@
public static final class WillBeUnloadedException extends Exception {}
-
public void testGetChecked_classUnloading() throws Exception {
WeakReference<?> classUsedByGetChecked = doTestClassUnloading();
GcFinalization.awaitClear(classUsedByGetChecked);
@@ -381,8 +380,5 @@
* environment that forces Futures.getChecked to its fallback WeakSetValidator. One awful way of
* doing so would be to derive a separate test library by using remove_from_jar to strip out
* ClassValueValidator.
- *
- * Fortunately, we get pretty good coverage "by accident": We run all these tests against the
- * *backport*, where ClassValueValidator is not present.
*/
}
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 0c3a9ae..9586a65 100644
--- a/guava-tests/test/com/google/common/util/concurrent/FuturesTest.java
+++ b/guava-tests/test/com/google/common/util/concurrent/FuturesTest.java
@@ -3375,13 +3375,11 @@
: pseudoTimedGetUninterruptibly(future, 2500, MILLISECONDS);
}
-
@GwtIncompatible // threads
public void testAllAsList_extensive() throws InterruptedException {
runExtensiveMergerTest(Merger.allMerger);
}
-
@GwtIncompatible // threads
public void testSuccessfulAsList_extensive() throws InterruptedException {
runExtensiveMergerTest(Merger.successMerger);
diff --git a/guava-tests/test/com/google/common/util/concurrent/FuturesTransformAsyncTest.java b/guava-tests/test/com/google/common/util/concurrent/FuturesTransformAsyncTest.java
index d0fcee2..2499020 100644
--- a/guava-tests/test/com/google/common/util/concurrent/FuturesTransformAsyncTest.java
+++ b/guava-tests/test/com/google/common/util/concurrent/FuturesTransformAsyncTest.java
@@ -131,7 +131,6 @@
}
}
-
public void testFutureCancellableBeforeFunctionCompletion() throws Exception {
// Set the result in a separate thread since this test runs the function
// (which will block) in the same thread.
diff --git a/guava-tests/test/com/google/common/util/concurrent/InterruptibleMonitorTest.java b/guava-tests/test/com/google/common/util/concurrent/InterruptibleMonitorTest.java
index 4d7a45f..f0727da 100644
--- a/guava-tests/test/com/google/common/util/concurrent/InterruptibleMonitorTest.java
+++ b/guava-tests/test/com/google/common/util/concurrent/InterruptibleMonitorTest.java
@@ -16,7 +16,6 @@
package com.google.common.util.concurrent;
-
/**
* Tests for {@link Monitor}'s interruptible methods.
*
diff --git a/guava-tests/test/com/google/common/util/concurrent/InterruptibleTaskTest.java b/guava-tests/test/com/google/common/util/concurrent/InterruptibleTaskTest.java
index afa7eae..8f91bcc 100644
--- a/guava-tests/test/com/google/common/util/concurrent/InterruptibleTaskTest.java
+++ b/guava-tests/test/com/google/common/util/concurrent/InterruptibleTaskTest.java
@@ -17,15 +17,12 @@
import static com.google.common.truth.Truth.assertThat;
-import java.lang.reflect.Method;
import java.nio.channels.spi.AbstractInterruptibleChannel;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
-import java.util.concurrent.locks.AbstractOwnableSynchronizer;
import java.util.concurrent.locks.LockSupport;
import junit.framework.TestCase;
-
public final class InterruptibleTaskTest extends TestCase {
// Regression test for a deadlock where a task could be stuck busy waiting for the task to
@@ -54,10 +51,7 @@
}
@Override
- void afterRanInterruptiblySuccess(Void result) {}
-
- @Override
- void afterRanInterruptiblyFailure(Throwable error) {}
+ void afterRanInterruptibly(Void result, Throwable error) {}
};
Thread runner = new Thread(task);
runner.start();
@@ -120,38 +114,25 @@
}
@Override
- void afterRanInterruptiblySuccess(Void result) {}
-
- @Override
- void afterRanInterruptiblyFailure(Throwable error) {}
+ void afterRanInterruptibly(Void result, Throwable error) {}
};
Thread runner = new Thread(task, "runner");
runner.start();
isInterruptibleRegistered.await();
// trigger the interrupt on another thread since it will block
- Thread interrupter =
- new Thread("Interrupter") {
- @Override
- public void run() {
- task.interruptTask();
- }
- };
- interrupter.start();
+ new Thread("Interrupter") {
+ @Override
+ public void run() {
+ task.interruptTask();
+ }
+ }.start();
// this will happen once the interrupt has been set which means that
// 1. the runner has been woken up
// 2. the interrupter is stuck in the call the Thread.interrupt()
// after some period of time the runner thread should become blocked on the task because it is
// waiting for the slow interrupting thread to complete Thread.interrupt
- awaitBlockedOnInstanceOf(runner, InterruptibleTask.Blocker.class);
-
- Object blocker = LockSupport.getBlocker(runner);
- assertThat(blocker).isInstanceOf(AbstractOwnableSynchronizer.class);
- Method getExclusiveOwnerThread =
- AbstractOwnableSynchronizer.class.getDeclaredMethod("getExclusiveOwnerThread");
- getExclusiveOwnerThread.setAccessible(true);
- Thread owner = (Thread) getExclusiveOwnerThread.invoke(blocker);
- assertThat(owner).isSameInstanceAs(interrupter);
+ awaitBlockedOn(runner, task);
slowChannel.exitClose.countDown(); // release the interrupter
@@ -161,9 +142,8 @@
}
// waits for the given thread to be blocked on the given object
- private static void awaitBlockedOnInstanceOf(Thread t, Class<?> blocker)
- throws InterruptedException {
- while (!isThreadBlockedOnInstanceOf(t, blocker)) {
+ private static void awaitBlockedOn(Thread t, Object blocker) throws InterruptedException {
+ while (!isThreadBlockedOn(t, blocker)) {
if (t.getState() == Thread.State.TERMINATED) {
throw new RuntimeException("Thread " + t + " exited unexpectedly");
}
@@ -171,8 +151,8 @@
}
}
- private static boolean isThreadBlockedOnInstanceOf(Thread t, Class<?> blocker) {
- return t.getState() == Thread.State.WAITING && blocker.isInstance(LockSupport.getBlocker(t));
+ private static boolean isThreadBlockedOn(Thread t, Object blocker) {
+ return t.getState() == Thread.State.WAITING && LockSupport.getBlocker(t) == blocker;
}
static final class SlowChannel extends AbstractInterruptibleChannel {
diff --git a/guava-tests/test/com/google/common/util/concurrent/JSR166TestCase.java b/guava-tests/test/com/google/common/util/concurrent/JSR166TestCase.java
index 1825c08..8df7ce9 100644
--- a/guava-tests/test/com/google/common/util/concurrent/JSR166TestCase.java
+++ b/guava-tests/test/com/google/common/util/concurrent/JSR166TestCase.java
@@ -682,7 +682,7 @@
/**
* Returns the number of milliseconds since time given by startNanoTime, which must have been
- * previously returned from a call to {@link System#nanoTime()}.
+ * previously returned from a call to {@link System.nanoTime()}.
*/
long millisElapsedSince(long startNanoTime) {
return NANOSECONDS.toMillis(System.nanoTime() - startNanoTime);
diff --git a/guava-tests/test/com/google/common/util/concurrent/JdkFutureAdaptersTest.java b/guava-tests/test/com/google/common/util/concurrent/JdkFutureAdaptersTest.java
index 3bb819a..741ff45 100644
--- a/guava-tests/test/com/google/common/util/concurrent/JdkFutureAdaptersTest.java
+++ b/guava-tests/test/com/google/common/util/concurrent/JdkFutureAdaptersTest.java
@@ -100,7 +100,6 @@
assertTrue(listenableFuture.isDone());
}
-
public void testListenInPoolThreadUsesGivenExecutor() throws Exception {
ExecutorService executorService =
newCachedThreadPool(new ThreadFactoryBuilder().setDaemon(true).build());
@@ -125,7 +124,6 @@
assertTrue(listenableFuture.isDone());
}
-
public void testListenInPoolThreadCustomExecutorInterrupted() throws Exception {
final CountDownLatch submitSuccessful = new CountDownLatch(1);
ExecutorService executorService =
@@ -235,7 +233,6 @@
}
}
-
@SuppressWarnings("IsInstanceIncompatibleType") // intentional.
public void testListenInPoolThreadRunsListenerAfterRuntimeException() throws Exception {
RuntimeExceptionThrowingFuture<String> input = new RuntimeExceptionThrowingFuture<>();
diff --git a/guava-tests/test/com/google/common/util/concurrent/ListenableFutureTaskTest.java b/guava-tests/test/com/google/common/util/concurrent/ListenableFutureTaskTest.java
index 8969a75..fd51a73 100644
--- a/guava-tests/test/com/google/common/util/concurrent/ListenableFutureTaskTest.java
+++ b/guava-tests/test/com/google/common/util/concurrent/ListenableFutureTaskTest.java
@@ -80,7 +80,6 @@
super.tearDown();
}
-
public void testListenerDoesNotRunUntilTaskCompletes() throws Exception {
// Test default state of not started.
@@ -106,7 +105,6 @@
assertFalse(task.isCancelled());
}
-
public void testListenerCalledOnException() throws Exception {
throwException = true;
@@ -142,7 +140,6 @@
assertEquals(1, runLatch.getCount());
}
-
public void testListenerCalledOnCancelFromRunning() throws Exception {
exec.execute(task);
runLatch.await();
diff --git a/guava-tests/test/com/google/common/util/concurrent/ListenerCallQueueTest.java b/guava-tests/test/com/google/common/util/concurrent/ListenerCallQueueTest.java
index 5fd9b95..e0eb32e 100644
--- a/guava-tests/test/com/google/common/util/concurrent/ListenerCallQueueTest.java
+++ b/guava-tests/test/com/google/common/util/concurrent/ListenerCallQueueTest.java
@@ -129,7 +129,6 @@
logHandler.getStoredLogRecords().get(0).getMessage());
}
-
public void testEnqueueAndDispatch_multithreaded() throws InterruptedException {
Object listener = new Object();
ExecutorService service = Executors.newFixedThreadPool(4);
@@ -153,7 +152,6 @@
}
}
-
public void testEnqueueAndDispatch_multithreaded_withThrowingRunnable()
throws InterruptedException {
Object listener = new Object();
diff --git a/guava-tests/test/com/google/common/util/concurrent/MoreExecutorsTest.java b/guava-tests/test/com/google/common/util/concurrent/MoreExecutorsTest.java
index fe4e7f5..08c8f19 100644
--- a/guava-tests/test/com/google/common/util/concurrent/MoreExecutorsTest.java
+++ b/guava-tests/test/com/google/common/util/concurrent/MoreExecutorsTest.java
@@ -88,7 +88,6 @@
public void run() {}
};
-
public void testDirectExecutorServiceServiceInThreadExecution() throws Exception {
final ListeningExecutorService executor = newDirectExecutorService();
final ThreadLocal<Integer> threadLocalCount =
@@ -168,7 +167,6 @@
assertEquals(10, threadLocalCount.get().intValue());
}
-
public void testDirectExecutorServiceServiceTermination() throws Exception {
final ExecutorService executor = newDirectExecutorService();
final CyclicBarrier barrier = new CyclicBarrier(2);
@@ -354,7 +352,6 @@
verify(delegate).execute(task);
}
-
public void testListeningDecorator_scheduleSuccess() throws Exception {
final CountDownLatch completed = new CountDownLatch(1);
ScheduledThreadPoolExecutor delegate =
@@ -380,7 +377,6 @@
assertEquals(0, delegate.getQueue().size());
}
-
public void testListeningDecorator_scheduleFailure() throws Exception {
ScheduledThreadPoolExecutor delegate = new ScheduledThreadPoolExecutor(1);
ListeningScheduledExecutorService service = listeningDecorator(delegate);
@@ -391,7 +387,6 @@
assertEquals(0, delegate.getQueue().size());
}
-
public void testListeningDecorator_schedulePeriodic() throws Exception {
ScheduledThreadPoolExecutor delegate = new ScheduledThreadPoolExecutor(1);
ListeningScheduledExecutorService service = listeningDecorator(delegate);
@@ -412,7 +407,6 @@
assertEquals(0, delegate.getQueue().size());
}
-
public void testListeningDecorator_cancelled() throws Exception {
ScheduledThreadPoolExecutor delegate = new ScheduledThreadPoolExecutor(1);
BlockingQueue<?> delegateQueue = delegate.getQueue();
@@ -566,7 +560,6 @@
}
}
-
public void testAddDelayedShutdownHook_success() throws InterruptedException {
TestApplication application = new TestApplication();
ExecutorService service = mock(ExecutorService.class);
@@ -578,7 +571,6 @@
shutdownFirst.verify(service).awaitTermination(2, TimeUnit.SECONDS);
}
-
public void testAddDelayedShutdownHook_interrupted() throws InterruptedException {
TestApplication application = new TestApplication();
ExecutorService service = mock(ExecutorService.class);
@@ -588,7 +580,6 @@
verify(service).shutdown();
}
-
public void testGetExitingExecutorService_executorSetToUseDaemonThreads() {
TestApplication application = new TestApplication();
ThreadPoolExecutor executor =
@@ -597,7 +588,6 @@
assertTrue(executor.getThreadFactory().newThread(EMPTY_RUNNABLE).isDaemon());
}
-
public void testGetExitingExecutorService_executorDelegatesToOriginal() {
TestApplication application = new TestApplication();
ThreadPoolExecutor executor = mock(ThreadPoolExecutor.class);
@@ -607,7 +597,6 @@
verify(executor).execute(EMPTY_RUNNABLE);
}
-
public void testGetExitingExecutorService_shutdownHookRegistered() throws InterruptedException {
TestApplication application = new TestApplication();
ThreadPoolExecutor executor = mock(ThreadPoolExecutor.class);
@@ -618,7 +607,6 @@
verify(executor).shutdown();
}
-
public void testGetExitingScheduledExecutorService_executorSetToUseDaemonThreads() {
TestApplication application = new TestApplication();
ScheduledThreadPoolExecutor executor = new ScheduledThreadPoolExecutor(1);
@@ -626,7 +614,6 @@
assertTrue(executor.getThreadFactory().newThread(EMPTY_RUNNABLE).isDaemon());
}
-
public void testGetExitingScheduledExecutorService_executorDelegatesToOriginal() {
TestApplication application = new TestApplication();
ScheduledThreadPoolExecutor executor = mock(ScheduledThreadPoolExecutor.class);
@@ -636,7 +623,6 @@
verify(executor).execute(EMPTY_RUNNABLE);
}
-
public void testGetScheduledExitingExecutorService_shutdownHookRegistered()
throws InterruptedException {
TestApplication application = new TestApplication();
@@ -669,7 +655,6 @@
assertEquals(oldName, Thread.currentThread().getName());
}
-
public void testExecutors_nullCheck() throws Exception {
new ClassSanityTester()
.setDefault(RateLimiter.class, RateLimiter.create(1.0))
@@ -699,14 +684,12 @@
/* Half of a 1-second timeout in nanoseconds */
private static final long HALF_SECOND_NANOS = NANOSECONDS.convert(1L, SECONDS) / 2;
-
public void testShutdownAndAwaitTermination_immediateShutdown() throws Exception {
ExecutorService service = Executors.newSingleThreadExecutor();
assertTrue(shutdownAndAwaitTermination(service, 1L, SECONDS));
assertTrue(service.isTerminated());
}
-
public void testShutdownAndAwaitTermination_immediateShutdownInternal() throws Exception {
ExecutorService service = mock(ExecutorService.class);
when(service.awaitTermination(HALF_SECOND_NANOS, NANOSECONDS)).thenReturn(true);
@@ -716,7 +699,6 @@
verify(service).awaitTermination(HALF_SECOND_NANOS, NANOSECONDS);
}
-
public void testShutdownAndAwaitTermination_forcedShutDownInternal() throws Exception {
ExecutorService service = mock(ExecutorService.class);
when(service.awaitTermination(HALF_SECOND_NANOS, NANOSECONDS))
@@ -729,7 +711,6 @@
verify(service).shutdownNow();
}
-
public void testShutdownAndAwaitTermination_nonTerminationInternal() throws Exception {
ExecutorService service = mock(ExecutorService.class);
when(service.awaitTermination(HALF_SECOND_NANOS, NANOSECONDS))
@@ -741,7 +722,6 @@
verify(service).shutdownNow();
}
-
public void testShutdownAndAwaitTermination_interruptedInternal() throws Exception {
final ExecutorService service = mock(ExecutorService.class);
when(service.awaitTermination(HALF_SECOND_NANOS, NANOSECONDS))
diff --git a/guava-tests/test/com/google/common/util/concurrent/SequentialExecutorTest.java b/guava-tests/test/com/google/common/util/concurrent/SequentialExecutorTest.java
index 20209e8..ff9e311 100644
--- a/guava-tests/test/com/google/common/util/concurrent/SequentialExecutorTest.java
+++ b/guava-tests/test/com/google/common/util/concurrent/SequentialExecutorTest.java
@@ -274,7 +274,6 @@
assertEquals(1, numCalls.get());
}
-
public void testTaskThrowsError() throws Exception {
class MyError extends Error {}
final CyclicBarrier barrier = new CyclicBarrier(2);
@@ -313,7 +312,6 @@
}
}
-
public void testRejectedExecutionThrownWithMultipleCalls() throws Exception {
final CountDownLatch latch = new CountDownLatch(1);
final SettableFuture<?> future = SettableFuture.create();
diff --git a/guava-tests/test/com/google/common/util/concurrent/ServiceManagerTest.java b/guava-tests/test/com/google/common/util/concurrent/ServiceManagerTest.java
index e8552ed..fbc238e 100644
--- a/guava-tests/test/com/google/common/util/concurrent/ServiceManagerTest.java
+++ b/guava-tests/test/com/google/common/util/concurrent/ServiceManagerTest.java
@@ -29,7 +29,6 @@
import com.google.common.testing.TestLogHandler;
import com.google.common.util.concurrent.Service.State;
import com.google.common.util.concurrent.ServiceManager.Listener;
-import java.time.Duration;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
@@ -120,31 +119,19 @@
}
}
-
public void testServiceStartupTimes() {
Service a = new NoOpDelayedService(150);
Service b = new NoOpDelayedService(353);
ServiceManager serviceManager = new ServiceManager(asList(a, b));
serviceManager.startAsync().awaitHealthy();
ImmutableMap<Service, Long> startupTimes = serviceManager.startupTimes();
- assertThat(startupTimes).hasSize(2);
- assertThat(startupTimes.get(a)).isAtLeast(150);
- assertThat(startupTimes.get(b)).isAtLeast(353);
+ assertEquals(2, startupTimes.size());
+ // TODO(kak): Use assertThat(startupTimes.get(a)).isAtLeast(150);
+ assertTrue(startupTimes.get(a) >= 150);
+ // TODO(kak): Use assertThat(startupTimes.get(b)).isAtLeast(353);
+ assertTrue(startupTimes.get(b) >= 353);
}
-
- public void testServiceStartupDurations() {
- Service a = new NoOpDelayedService(150);
- Service b = new NoOpDelayedService(353);
- ServiceManager serviceManager = new ServiceManager(asList(a, b));
- serviceManager.startAsync().awaitHealthy();
- ImmutableMap<Service, Duration> startupTimes = serviceManager.startupDurations();
- assertThat(startupTimes).hasSize(2);
- assertThat(startupTimes.get(a)).isAtLeast(Duration.ofMillis(150));
- assertThat(startupTimes.get(b)).isAtLeast(Duration.ofMillis(353));
- }
-
-
public void testServiceStartupTimes_selfStartingServices() {
// This tests to ensure that:
// 1. service times are accurate when the service is started by the manager
@@ -170,8 +157,9 @@
ServiceManager serviceManager = new ServiceManager(asList(a, b));
serviceManager.startAsync().awaitHealthy();
ImmutableMap<Service, Long> startupTimes = serviceManager.startupTimes();
- assertThat(startupTimes).hasSize(2);
- assertThat(startupTimes.get(a)).isAtLeast(150);
+ assertEquals(2, startupTimes.size());
+ // TODO(kak): Use assertThat(startupTimes.get(a)).isAtLeast(150);
+ assertTrue(startupTimes.get(a) >= 150);
// Service b startup takes at least 353 millis, but starting the timer is delayed by at least
// 150 milliseconds. so in a perfect world the timing would be 353-150=203ms, but since either
// of our sleep calls can be arbitrarily delayed we should just assert that there is a time
@@ -179,7 +167,6 @@
assertThat(startupTimes.get(b)).isNotNull();
}
-
public void testServiceStartStop() {
Service a = new NoOpService();
Service b = new NoOpService();
@@ -201,7 +188,6 @@
assertTrue(listener.failedServices.isEmpty());
}
-
public void testFailStart() throws Exception {
Service a = new NoOpService();
Service b = new FailStartService();
@@ -229,7 +215,6 @@
assertTrue(listener.stoppedCalled);
}
-
public void testFailRun() throws Exception {
Service a = new NoOpService();
Service b = new FailRunService();
@@ -252,7 +237,6 @@
assertTrue(listener.stoppedCalled);
}
-
public void testFailStop() throws Exception {
Service a = new NoOpService();
Service b = new FailStopService();
@@ -281,7 +265,6 @@
assertThat(toString).contains("FailStartService");
}
-
public void testTimeouts() throws Exception {
Service a = new NoOpDelayedService(50);
ServiceManager manager = new ServiceManager(asList(a));
diff --git a/guava-tests/test/com/google/common/util/concurrent/SettableFutureTest.java b/guava-tests/test/com/google/common/util/concurrent/SettableFutureTest.java
index 9b8b88f..105e8de 100644
--- a/guava-tests/test/com/google/common/util/concurrent/SettableFutureTest.java
+++ b/guava-tests/test/com/google/common/util/concurrent/SettableFutureTest.java
@@ -51,19 +51,16 @@
}
}
-
public void testSetValue() throws Exception {
assertTrue(future.set("value"));
tester.testCompletedFuture("value");
}
-
public void testSetFailure() throws Exception {
assertTrue(future.setException(new Exception("failure")));
tester.testFailedFuture("failure");
}
-
public void testSetFailureNull() throws Exception {
try {
future.setException(null);
@@ -75,7 +72,6 @@
tester.testFailedFuture("failure");
}
-
public void testCancel() throws Exception {
assertTrue(future.cancel(true));
tester.testCancelledFuture();
diff --git a/guava-tests/test/com/google/common/util/concurrent/StripedTest.java b/guava-tests/test/com/google/common/util/concurrent/StripedTest.java
index fa9d87f..9832c30 100644
--- a/guava-tests/test/com/google/common/util/concurrent/StripedTest.java
+++ b/guava-tests/test/com/google/common/util/concurrent/StripedTest.java
@@ -129,7 +129,6 @@
assertTrue(Striped.lazyWeakLock(256).size() == 256);
}
-
public void testWeakImplementations() {
for (Striped<?> striped : weakImplementations()) {
WeakReference<Object> weakRef = new WeakReference<>(striped.get(new Object()));
@@ -137,7 +136,6 @@
}
}
-
public void testWeakReadWrite() {
Striped<ReadWriteLock> striped = Striped.lazyWeakReadWriteLock(1000);
Object key = new Object();
@@ -150,7 +148,6 @@
readLock.unlock();
}
-
public void testStrongImplementations() {
for (Striped<?> striped : strongImplementations()) {
WeakReference<Object> weakRef = new WeakReference<>(striped.get(new Object()));
diff --git a/guava-tests/test/com/google/common/util/concurrent/ThreadFactoryBuilderTest.java b/guava-tests/test/com/google/common/util/concurrent/ThreadFactoryBuilderTest.java
index 7684b96..a3a7b8e 100644
--- a/guava-tests/test/com/google/common/util/concurrent/ThreadFactoryBuilderTest.java
+++ b/guava-tests/test/com/google/common/util/concurrent/ThreadFactoryBuilderTest.java
@@ -56,7 +56,6 @@
builder = new ThreadFactoryBuilder();
}
-
public void testThreadFactoryBuilder_defaults() throws InterruptedException {
ThreadFactory threadFactory = builder.build();
Thread thread = threadFactory.newThread(monitoredRunnable);
@@ -93,7 +92,6 @@
assertThat(thread.getName()).matches("^pool-\\d+-thread-" + threadId + "$");
}
-
public void testNameFormatWithPercentS_custom() {
String format = "super-duper-thread-%s";
ThreadFactory factory = builder.setNameFormat(format).build();
@@ -102,7 +100,6 @@
}
}
-
public void testNameFormatWithPercentD_custom() {
String format = "super-duper-thread-%d";
ThreadFactory factory = builder.setNameFormat(format).build();
@@ -111,21 +108,18 @@
}
}
-
public void testDaemon_false() {
ThreadFactory factory = builder.setDaemon(false).build();
Thread thread = factory.newThread(monitoredRunnable);
assertFalse(thread.isDaemon());
}
-
public void testDaemon_true() {
ThreadFactory factory = builder.setDaemon(true).build();
Thread thread = factory.newThread(monitoredRunnable);
assertTrue(thread.isDaemon());
}
-
public void testPriority_custom() {
for (int i = Thread.MIN_PRIORITY; i <= Thread.MAX_PRIORITY; i++) {
ThreadFactory factory = builder.setPriority(i).build();
@@ -150,7 +144,6 @@
}
}
-
public void testUncaughtExceptionHandler_custom() {
assertEquals(
UNCAUGHT_EXCEPTION_HANDLER,
@@ -161,7 +154,6 @@
.getUncaughtExceptionHandler());
}
-
public void testBuildMutateBuild() {
ThreadFactory factory1 = builder.setPriority(1).build();
assertEquals(1, factory1.newThread(monitoredRunnable).getPriority());
@@ -177,7 +169,6 @@
unused = builder.build(); // this is *also* allowed
}
-
public void testBuildMutate() {
ThreadFactory factory1 = builder.setPriority(1).build();
assertEquals(1, factory1.newThread(monitoredRunnable).getPriority());
@@ -186,7 +177,6 @@
assertEquals(1, factory1.newThread(monitoredRunnable).getPriority());
}
-
public void testThreadFactory() throws InterruptedException {
final String THREAD_NAME = "ludicrous speed";
final int THREAD_PRIORITY = 1;
diff --git a/guava-tests/test/com/google/common/util/concurrent/TrustedInputFutureTest.java b/guava-tests/test/com/google/common/util/concurrent/TrustedInputFutureTest.java
index 1f2ecca..d452f96 100644
--- a/guava-tests/test/com/google/common/util/concurrent/TrustedInputFutureTest.java
+++ b/guava-tests/test/com/google/common/util/concurrent/TrustedInputFutureTest.java
@@ -16,7 +16,6 @@
package com.google.common.util.concurrent;
-
import com.google.common.annotations.GwtCompatible;
import com.google.common.util.concurrent.AbstractFuture.TrustedFuture;
diff --git a/guava-tests/test/com/google/common/util/concurrent/UninterruptibleFutureTest.java b/guava-tests/test/com/google/common/util/concurrent/UninterruptibleFutureTest.java
index 0d24266..47507cd 100644
--- a/guava-tests/test/com/google/common/util/concurrent/UninterruptibleFutureTest.java
+++ b/guava-tests/test/com/google/common/util/concurrent/UninterruptibleFutureTest.java
@@ -116,7 +116,6 @@
assertTrue(sleeper.completed);
}
-
public void testMakeUninterruptible_timeoutPreservedThroughInterruption()
throws ExecutionException {
@@ -155,32 +154,26 @@
}
}
-
public void testMakeUninterruptible_untimed_uninterrupted() throws Exception {
runUntimedInterruptsTest(0);
}
-
public void testMakeUninterruptible_untimed_interrupted() throws Exception {
runUntimedInterruptsTest(1);
}
-
public void testMakeUninterruptible_untimed_multiplyInterrupted() throws Exception {
runUntimedInterruptsTest(38);
}
-
public void testMakeUninterruptible_timed_uninterrupted() throws Exception {
runTimedInterruptsTest(0);
}
-
public void testMakeUninterruptible_timed_interrupted() throws Exception {
runTimedInterruptsTest(1);
}
-
public void testMakeUninterruptible_timed_multiplyInterrupted() throws Exception {
runTimedInterruptsTest(38);
}
@@ -235,7 +228,6 @@
}
}
-
public void testMakeUninterruptible_timedGetZeroTimeoutAttempted()
throws TimeoutException, ExecutionException {
SettableFuture<String> future = SettableFuture.create();
@@ -248,7 +240,6 @@
assertEquals(RESULT, getUninterruptibly(future, 0, SECONDS));
}
-
public void testMakeUninterruptible_timedGetNegativeTimeoutAttempted()
throws TimeoutException, ExecutionException {
SettableFuture<String> future = SettableFuture.create();
diff --git a/guava-tests/test/com/google/common/util/concurrent/UninterruptibleMonitorTest.java b/guava-tests/test/com/google/common/util/concurrent/UninterruptibleMonitorTest.java
index 59bf808..30ce22d 100644
--- a/guava-tests/test/com/google/common/util/concurrent/UninterruptibleMonitorTest.java
+++ b/guava-tests/test/com/google/common/util/concurrent/UninterruptibleMonitorTest.java
@@ -16,7 +16,6 @@
package com.google.common.util.concurrent;
-
/**
* Tests for {@link Monitor}'s uninterruptible methods.
*
diff --git a/guava-tests/test/com/google/common/util/concurrent/UntrustedInputFutureTest.java b/guava-tests/test/com/google/common/util/concurrent/UntrustedInputFutureTest.java
index a6241d2..2d071b5 100644
--- a/guava-tests/test/com/google/common/util/concurrent/UntrustedInputFutureTest.java
+++ b/guava-tests/test/com/google/common/util/concurrent/UntrustedInputFutureTest.java
@@ -16,7 +16,6 @@
package com.google.common.util.concurrent;
-
import com.google.common.annotations.GwtCompatible;
import com.google.common.util.concurrent.AbstractFuture.TrustedFuture;
diff --git a/guava-tests/test/com/google/common/util/concurrent/WrappingScheduledExecutorServiceTest.java b/guava-tests/test/com/google/common/util/concurrent/WrappingScheduledExecutorServiceTest.java
index 8d0183e..6a8adfe 100644
--- a/guava-tests/test/com/google/common/util/concurrent/WrappingScheduledExecutorServiceTest.java
+++ b/guava-tests/test/com/google/common/util/concurrent/WrappingScheduledExecutorServiceTest.java
@@ -46,11 +46,11 @@
MockExecutor mock = new MockExecutor();
TestExecutor testExecutor = new TestExecutor(mock);
- @SuppressWarnings("unused") // https://errorprone.info/bugpattern/FutureReturnValueIgnored
+ @SuppressWarnings("unused") // go/futurereturn-lsc
Future<?> possiblyIgnoredError = testExecutor.schedule(DO_NOTHING, 10, TimeUnit.MINUTES);
mock.assertLastMethodCalled("scheduleRunnable", 10, TimeUnit.MINUTES);
- @SuppressWarnings("unused") // https://errorprone.info/bugpattern/FutureReturnValueIgnored
+ @SuppressWarnings("unused") // go/futurereturn-lsc
Future<?> possiblyIgnoredError1 =
testExecutor.schedule(Executors.callable(DO_NOTHING), 5, TimeUnit.SECONDS);
mock.assertLastMethodCalled("scheduleCallable", 5, TimeUnit.SECONDS);
@@ -59,12 +59,12 @@
public void testSchedule_repeating() {
MockExecutor mock = new MockExecutor();
TestExecutor testExecutor = new TestExecutor(mock);
- @SuppressWarnings("unused") // https://errorprone.info/bugpattern/FutureReturnValueIgnored
+ @SuppressWarnings("unused") // go/futurereturn-lsc
Future<?> possiblyIgnoredError =
testExecutor.scheduleWithFixedDelay(DO_NOTHING, 100, 10, TimeUnit.MINUTES);
mock.assertLastMethodCalled("scheduleWithFixedDelay", 100, 10, TimeUnit.MINUTES);
- @SuppressWarnings("unused") // https://errorprone.info/bugpattern/FutureReturnValueIgnored
+ @SuppressWarnings("unused") // go/futurereturn-lsc
Future<?> possiblyIgnoredError1 =
testExecutor.scheduleAtFixedRate(DO_NOTHING, 3, 7, TimeUnit.SECONDS);
mock.assertLastMethodCalled("scheduleAtFixedRate", 3, 7, TimeUnit.SECONDS);
diff --git a/guava/pom.xml b/guava/pom.xml
index 4a4f9eb..20e9af8 100644
--- a/guava/pom.xml
+++ b/guava/pom.xml
@@ -5,15 +5,14 @@
<parent>
<groupId>com.google.guava</groupId>
<artifactId>guava-parent</artifactId>
- <version>31.0.1-jre</version>
+ <version>30.0-jre</version>
</parent>
<artifactId>guava</artifactId>
<packaging>bundle</packaging>
<name>Guava: Google Core Libraries for Java</name>
- <url>https://github.com/google/guava</url>
<description>
Guava is a suite of core and expanded libraries that include
- utility classes, Google's collections, I/O classes, and
+ utility classes, google's collections, io classes, and much
much more.
</description>
<dependencies>
diff --git a/guava/src/com/google/common/annotations/Beta.java b/guava/src/com/google/common/annotations/Beta.java
index f71dc94..47dafe8 100644
--- a/guava/src/com/google/common/annotations/Beta.java
+++ b/guava/src/com/google/common/annotations/Beta.java
@@ -31,6 +31,7 @@
* work during upgrades. However it is generally inadvisable for <i>libraries</i> (which get
* included on users' CLASSPATHs, outside the library developers' control) to do so.
*
+ *
* @author Kevin Bourrillion
*/
@Retention(RetentionPolicy.CLASS)
diff --git a/guava/src/com/google/common/annotations/GwtCompatible.java b/guava/src/com/google/common/annotations/GwtCompatible.java
index 4bf6efb..1391728 100644
--- a/guava/src/com/google/common/annotations/GwtCompatible.java
+++ b/guava/src/com/google/common/annotations/GwtCompatible.java
@@ -54,6 +54,7 @@
*
* <p>Note that a {@code GwtCompatible} type may have some {@link GwtIncompatible} methods.
*
+ *
* @author Charles Fry
* @author Hayward Chan
*/
diff --git a/guava/src/com/google/common/base/Absent.java b/guava/src/com/google/common/base/Absent.java
index f96136b..4223b39 100644
--- a/guava/src/com/google/common/base/Absent.java
+++ b/guava/src/com/google/common/base/Absent.java
@@ -19,11 +19,10 @@
import com.google.common.annotations.GwtCompatible;
import java.util.Collections;
import java.util.Set;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/** Implementation of an {@link Optional} not containing a reference. */
@GwtCompatible
-@ElementTypesAreNonnullByDefault
final class Absent<T> extends Optional<T> {
static final Absent<Object> INSTANCE = new Absent<>();
@@ -62,8 +61,7 @@
}
@Override
- @CheckForNull
- public T orNull() {
+ public @Nullable T orNull() {
return null;
}
@@ -79,7 +77,7 @@
}
@Override
- public boolean equals(@CheckForNull 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 bb0a1d3..57d8167 100644
--- a/guava/src/com/google/common/base/AbstractIterator.java
+++ b/guava/src/com/google/common/base/AbstractIterator.java
@@ -14,14 +14,12 @@
package com.google.common.base;
-import static com.google.common.base.NullnessCasts.uncheckedCastNullableTToT;
import static com.google.common.base.Preconditions.checkState;
import com.google.common.annotations.GwtCompatible;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import java.util.Iterator;
import java.util.NoSuchElementException;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -29,8 +27,7 @@
* reasons).
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-abstract class AbstractIterator<T extends @Nullable Object> implements Iterator<T> {
+abstract class AbstractIterator<T> implements Iterator<T> {
private State state = State.NOT_READY;
protected AbstractIterator() {}
@@ -42,14 +39,12 @@
FAILED,
}
- @CheckForNull private T next;
+ private @Nullable T next;
- @CheckForNull
protected abstract T computeNext();
@CanIgnoreReturnValue
- @CheckForNull
- protected final T endOfData() {
+ protected final @Nullable T endOfData() {
state = State.DONE;
return null;
}
@@ -78,14 +73,12 @@
}
@Override
- @ParametricNullness
public final T next() {
if (!hasNext()) {
throw new NoSuchElementException();
}
state = State.NOT_READY;
- // Safe because hasNext() ensures that tryToComputeNext() has put a T into `next`.
- T result = uncheckedCastNullableTToT(next);
+ T result = next;
next = null;
return result;
}
diff --git a/guava/src/com/google/common/base/Ascii.java b/guava/src/com/google/common/base/Ascii.java
index 0c651bb..0a8ec50 100644
--- a/guava/src/com/google/common/base/Ascii.java
+++ b/guava/src/com/google/common/base/Ascii.java
@@ -37,7 +37,6 @@
* @since 7.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
public final class Ascii {
private Ascii() {}
@@ -440,7 +439,7 @@
}
/**
- * If the argument is an {@linkplain #isUpperCase(char) uppercase ASCII character}, returns the
+ * If the argument is an {@linkplain #isUpperCase(char) uppercase ASCII character} returns the
* lowercase equivalent. Otherwise returns the argument.
*/
public static char toLowerCase(char c) {
@@ -488,7 +487,7 @@
}
/**
- * If the argument is a {@linkplain #isLowerCase(char) lowercase ASCII character}, returns the
+ * If the argument is a {@linkplain #isLowerCase(char) lowercase ASCII character} returns the
* uppercase equivalent. Otherwise returns the argument.
*/
public static char toUpperCase(char c) {
@@ -543,6 +542,7 @@
* <li>it is safe to use non-ASCII characters in the truncation indicator
* </ul>
*
+ *
* @throws IllegalArgumentException if {@code maxLength} is less than the length of {@code
* truncationIndicator}
* @since 16.0
diff --git a/guava/src/com/google/common/base/CaseFormat.java b/guava/src/com/google/common/base/CaseFormat.java
index 7b393eb..188d0d0 100644
--- a/guava/src/com/google/common/base/CaseFormat.java
+++ b/guava/src/com/google/common/base/CaseFormat.java
@@ -15,11 +15,10 @@
package com.google.common.base;
import static com.google.common.base.Preconditions.checkNotNull;
-import static java.util.Objects.requireNonNull;
import com.google.common.annotations.GwtCompatible;
import java.io.Serializable;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Utility class for converting between various ASCII case formats. Behavior is undefined for
@@ -29,7 +28,6 @@
* @since 1.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
public enum CaseFormat {
/** Hyphenated variable naming convention, e.g., "lower-hyphen". */
LOWER_HYPHEN(CharMatcher.is('-'), "-") {
@@ -140,14 +138,14 @@
out = new StringBuilder(s.length() + 4 * format.wordSeparator.length());
out.append(format.normalizeFirstWord(s.substring(i, j)));
} else {
- requireNonNull(out).append(format.normalizeWord(s.substring(i, j)));
+ out.append(format.normalizeWord(s.substring(i, j)));
}
out.append(format.wordSeparator);
i = j + wordSeparator.length();
}
return (i == 0)
? format.normalizeFirstWord(s)
- : requireNonNull(out).append(format.normalizeWord(s.substring(i))).toString();
+ : out.append(format.normalizeWord(s.substring(i))).toString();
}
/**
@@ -181,7 +179,7 @@
}
@Override
- public boolean equals(@CheckForNull 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/CharMatcher.java b/guava/src/com/google/common/base/CharMatcher.java
index e052f80..0291086 100644
--- a/guava/src/com/google/common/base/CharMatcher.java
+++ b/guava/src/com/google/common/base/CharMatcher.java
@@ -61,7 +61,6 @@
* @since 1.0
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
public abstract class CharMatcher implements Predicate<Character> {
/*
* N777777777NO
diff --git a/guava/src/com/google/common/base/Charsets.java b/guava/src/com/google/common/base/Charsets.java
index 7aebea8..2c9563d 100644
--- a/guava/src/com/google/common/base/Charsets.java
+++ b/guava/src/com/google/common/base/Charsets.java
@@ -31,7 +31,6 @@
* @since 1.0
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
public final class Charsets {
private Charsets() {}
diff --git a/guava/src/com/google/common/base/CommonMatcher.java b/guava/src/com/google/common/base/CommonMatcher.java
index d63b46b..6d14c6b 100644
--- a/guava/src/com/google/common/base/CommonMatcher.java
+++ b/guava/src/com/google/common/base/CommonMatcher.java
@@ -22,7 +22,6 @@
* javadoc for details.
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
abstract class CommonMatcher {
public abstract boolean matches();
diff --git a/guava/src/com/google/common/base/CommonPattern.java b/guava/src/com/google/common/base/CommonPattern.java
index c425d52..6be5b01 100644
--- a/guava/src/com/google/common/base/CommonPattern.java
+++ b/guava/src/com/google/common/base/CommonPattern.java
@@ -22,7 +22,6 @@
* javadoc for details.
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
abstract class CommonPattern {
public abstract CommonMatcher matcher(CharSequence t);
diff --git a/guava/src/com/google/common/base/Converter.java b/guava/src/com/google/common/base/Converter.java
index 208a032..a9107bf 100644
--- a/guava/src/com/google/common/base/Converter.java
+++ b/guava/src/com/google/common/base/Converter.java
@@ -14,7 +14,6 @@
package com.google.common.base;
-import static com.google.common.base.NullnessCasts.uncheckedCastNullableTToT;
import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.annotations.GwtCompatible;
@@ -24,7 +23,7 @@
import com.google.j2objc.annotations.RetainedWith;
import java.io.Serializable;
import java.util.Iterator;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* A function from {@code A} to {@code B} with an associated <i>reverse</i> function from {@code B}
@@ -56,6 +55,7 @@
* behavior for all converters; implementations of {@link #doForward} and {@link #doBackward} are
* guaranteed to never be passed {@code null}, and must never return {@code null}.
*
+ *
* <h3>Common ways to use</h3>
*
* <p>Getting a converter:
@@ -114,36 +114,11 @@
* @since 16.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-/*
- * 1. The type parameter is <T> rather than <T extends @Nullable> so that we can use T in the
- * doForward and doBackward methods to indicate that the parameter cannot be null. (We also take
- * advantage of that for convertAll, as discussed on that method.)
- *
- * 2. The supertype of this class could be `Function<@Nullable A, @Nullable B>`, since
- * Converter.apply (like Converter.convert) is capable of accepting null inputs. However, a
- * supertype of `Function<A, B>` turns out to be massively more useful to callers in practice: They
- * want their output to be non-null in operations like `stream.map(myConverter)`, and we can
- * guarantee that as long as we also require the input type to be non-null[*] (which is a
- * requirement that existing callers already fulfill).
- *
- * Disclaimer: Part of the reason that callers are so well adapted to `Function<A, B>` may be that
- * that is how the signature looked even prior to this comment! So naturally any change can break
- * existing users, but it can't *fix* existing users because any users who needed
- * `Function<@Nullable A, @Nullable B>` already had to find a workaround. Still, there is a *ton* of
- * fallout from trying to switch. I would be shocked if the switch would offer benefits to anywhere
- * near enough users to justify the costs.
- *
- * Fortunately, if anyone does want to use a Converter as a `Function<@Nullable A, @Nullable B>`,
- * it's easy to get one: `converter::convert`.
- *
- * [*] In annotating this class, we're ignoring LegacyConverter.
- */
public abstract class Converter<A, B> implements Function<A, B> {
private final boolean handleNullAutomatically;
// We lazily cache the reverse view to avoid allocating on every call to reverse().
- @LazyInit @RetainedWith @CheckForNull private transient Converter<B, A> reverse;
+ @LazyInit @RetainedWith private transient @Nullable Converter<B, A> reverse;
/** Constructor for use by subclasses. */
protected Converter() {
@@ -190,67 +165,30 @@
* @return the converted value; is null <i>if and only if</i> {@code a} is null
*/
@CanIgnoreReturnValue
- @CheckForNull
- public final B convert(@CheckForNull A a) {
+ public final @Nullable B convert(@Nullable A a) {
return correctedDoForward(a);
}
- @CheckForNull
- B correctedDoForward(@CheckForNull 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));
} else {
- return unsafeDoForward(a);
+ return doForward(a);
}
}
- @CheckForNull
- A correctedDoBackward(@CheckForNull 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));
} else {
- return unsafeDoBackward(b);
+ return doBackward(b);
}
}
- /*
- * LegacyConverter violates the contract of Converter by allowing its doForward and doBackward
- * methods to accept null. We could avoid having unchecked casts in Converter.java itself if we
- * could perform a cast to LegacyConverter, but we can't because it's an internal-only class.
- *
- * TODO(cpovirk): So make it part of the open-source build, albeit package-private there?
- *
- * So we use uncheckedCastNullableTToT here. This is a weird usage of that method: The method is
- * documented as being for use with type parameters that have parametric nullness. But Converter's
- * type parameters do not. Still, we use it here so that we can suppress a warning at a smaller
- * level than the whole method but without performing a runtime null check. That way, we can still
- * pass null inputs to LegacyConverter, and it can violate the contract of Converter.
- *
- * TODO(cpovirk): Could this be simplified if we modified implementations of LegacyConverter to
- * override methods (probably called "unsafeDoForward" and "unsafeDoBackward") with the same
- * signatures as the methods below, rather than overriding the same doForward and doBackward
- * methods as implementations of normal converters do?
- *
- * But no matter what we do, it's worth remembering that the resulting code is going to be unsound
- * in the presence of LegacyConverter, at least in the case of users who view the converter as a
- * Function<A, B> or who call convertAll (and for any checkers that apply @PolyNull-like semantics
- * to Converter.convert). So maybe we don't want to think too hard about how to prevent our
- * checkers from issuing errors related to LegacyConverter, since it turns out that
- * LegacyConverter does violate the assumptions we make elsewhere.
- */
-
- @CheckForNull
- private B unsafeDoForward(@CheckForNull A a) {
- return doForward(uncheckedCastNullableTToT(a));
- }
-
- @CheckForNull
- private A unsafeDoBackward(@CheckForNull B b) {
- return doBackward(uncheckedCastNullableTToT(b));
- }
-
/**
* Returns an iterable that applies {@code convert} to each element of {@code fromIterable}. The
* conversion is done lazily.
@@ -260,16 +198,6 @@
* element.
*/
@CanIgnoreReturnValue
- /*
- * Just as Converter could implement `Function<@Nullable A, @Nullable B>` instead of `Function<A,
- * B>`, convertAll could accept and return iterables with nullable element types. In both cases,
- * we've chosen to instead use a signature that benefits existing users -- and is still safe.
- *
- * For convertAll, I haven't looked as closely at *how* much existing users benefit, so we should
- * keep an eye out for problems that new users encounter. Note also that convertAll could support
- * both use cases by using @PolyNull. (By contrast, we can't use @PolyNull for our superinterface
- * (`implements Function<@PolyNull A, @PolyNull B>`), at least as far as I know.)
- */
public Iterable<B> convertAll(final Iterable<? extends A> fromIterable) {
checkNotNull(fromIterable, "fromIterable");
return new Iterable<B>() {
@@ -284,8 +212,6 @@
}
@Override
- @SuppressWarnings("nullness") // See code comments on convertAll and Converter.apply.
- @CheckForNull
public B next() {
return convert(fromIterator.next());
}
@@ -339,14 +265,14 @@
}
@Override
- @CheckForNull
- A correctedDoForward(@CheckForNull B b) {
+ @Nullable
+ A correctedDoForward(@Nullable B b) {
return original.correctedDoBackward(b);
}
@Override
- @CheckForNull
- B correctedDoBackward(@CheckForNull A a) {
+ @Nullable
+ B correctedDoBackward(@Nullable A a) {
return original.correctedDoForward(a);
}
@@ -356,7 +282,7 @@
}
@Override
- public boolean equals(@CheckForNull Object object) {
+ public boolean equals(@Nullable Object object) {
if (object instanceof ReverseConverter) {
ReverseConverter<?, ?> that = (ReverseConverter<?, ?>) object;
return this.original.equals(that.original);
@@ -421,19 +347,19 @@
}
@Override
- @CheckForNull
- C correctedDoForward(@CheckForNull A a) {
+ @Nullable
+ C correctedDoForward(@Nullable A a) {
return second.correctedDoForward(first.correctedDoForward(a));
}
@Override
- @CheckForNull
- A correctedDoBackward(@CheckForNull C c) {
+ @Nullable
+ A correctedDoBackward(@Nullable C c) {
return first.correctedDoBackward(second.correctedDoBackward(c));
}
@Override
- public boolean equals(@CheckForNull 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);
@@ -460,39 +386,7 @@
@Deprecated
@Override
@CanIgnoreReturnValue
- /*
- * Even though we implement `Function<A, B>` instead of `Function<@Nullable A, @Nullable B>` (as
- * discussed in a code comment at the top of the class), we declare our override of Function.apply
- * to accept and return null. This requires a suppression, but it's safe:
- *
- * - Callers who use Converter as a Function<A, B> will neither pass null nor have it returned to
- * them. (Or, if they're not using nullness checking, they might be able to pass null and thus
- * have null returned to them. But our signature isn't making their existing nullness type error
- * any worse.)
- * - In the relatively unlikely event that anyone calls Converter.apply directly, that caller is
- * allowed to pass null but is also forced to deal with a potentially null return.
- * - Perhaps more important than actual *callers* of this method are various tools that look at
- * bytecode. Notably, NullPointerTester expects a method to throw NPE when passed null unless it
- * is annotated in a way that identifies its parameter type as potentially including null. (And
- * this method does not throw NPE -- nor do we want to enact a dangerous change to make it begin
- * doing so.) We can even imagine tools that rewrite bytecode to insert null checks before and
- * after calling methods with allegedly non-nullable parameters[*]. If we didn't annotate the
- * parameter and return type here, then anyone who used such a tool (and managed to pass null to
- * this method, presumably because that user doesn't run a normal nullness checker) could see
- * NullPointerException.
- *
- * [*] Granted, such tools could conceivably be smart enough to recognize that the apply() method
- * on a a Function<Foo, Bar> should never allow null inputs and never produce null outputs even if
- * this specific subclass claims otherwise. Such tools might still produce NPE for calls to this
- * method. And that is one reason that we should be nervous about "lying" by extending Function<A,
- * B> in the first place. But for now, we're giving it a try, since extending Function<@Nullable
- * A, @Nullable B> will cause issues *today*, whereas extending Function<A, B> causes problems in
- * various hypothetical futures. (Plus, a tool that were that smart would likely already introduce
- * problems with LegacyConverter.)
- */
- @SuppressWarnings("nullness")
- @CheckForNull
- public final B apply(@CheckForNull A a) {
+ public final @Nullable B apply(@Nullable A a) {
return convert(a);
}
@@ -508,7 +402,7 @@
* interchangeable.
*/
@Override
- public boolean equals(@CheckForNull Object object) {
+ public boolean equals(@Nullable Object object) {
return super.equals(object);
}
@@ -557,7 +451,7 @@
}
@Override
- public boolean equals(@CheckForNull 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 5d12343..92958c1 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 javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* This class provides default values for all Java types, as defined by the JLS.
@@ -26,12 +26,11 @@
* @since 1.0
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public final class Defaults {
private Defaults() {}
- private static final Double DOUBLE_DEFAULT = 0d;
- private static final Float FLOAT_DEFAULT = 0f;
+ private static final Double DOUBLE_DEFAULT = Double.valueOf(0d);
+ private static final Float FLOAT_DEFAULT = Float.valueOf(0f);
/**
* Returns the default value of {@code type} as defined by JLS --- {@code 0} for numbers, {@code
@@ -39,28 +38,26 @@
* {@code void}, {@code null} is returned.
*/
@SuppressWarnings("unchecked")
- @CheckForNull
- public static <T> T defaultValue(Class<T> type) {
+ public static <T> @Nullable T defaultValue(Class<T> type) {
checkNotNull(type);
- if (type.isPrimitive()) {
- if (type == boolean.class) {
- return (T) Boolean.FALSE;
- } else if (type == char.class) {
- return (T) Character.valueOf('\0');
- } else if (type == byte.class) {
- return (T) Byte.valueOf((byte) 0);
- } else if (type == short.class) {
- return (T) Short.valueOf((short) 0);
- } else if (type == int.class) {
- return (T) Integer.valueOf(0);
- } else if (type == long.class) {
- return (T) Long.valueOf(0L);
- } else if (type == float.class) {
- return (T) FLOAT_DEFAULT;
- } else if (type == double.class) {
- return (T) DOUBLE_DEFAULT;
- }
+ if (type == boolean.class) {
+ return (T) Boolean.FALSE;
+ } else if (type == char.class) {
+ return (T) Character.valueOf('\0');
+ } else if (type == byte.class) {
+ return (T) Byte.valueOf((byte) 0);
+ } else if (type == short.class) {
+ return (T) Short.valueOf((short) 0);
+ } else if (type == int.class) {
+ return (T) Integer.valueOf(0);
+ } else if (type == long.class) {
+ return (T) Long.valueOf(0L);
+ } else if (type == float.class) {
+ return (T) FLOAT_DEFAULT;
+ } else if (type == double.class) {
+ return (T) DOUBLE_DEFAULT;
+ } else {
+ return null;
}
- return null;
}
}
diff --git a/guava/src/com/google/common/base/ElementTypesAreNonnullByDefault.java b/guava/src/com/google/common/base/ElementTypesAreNonnullByDefault.java
deleted file mode 100644
index 890e3a3..0000000
--- a/guava/src/com/google/common/base/ElementTypesAreNonnullByDefault.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) 2021 The Guava Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.common.base;
-
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.PARAMETER;
-import static java.lang.annotation.ElementType.TYPE;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-import com.google.common.annotations.GwtCompatible;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-import javax.annotation.Nonnull;
-import javax.annotation.meta.TypeQualifierDefault;
-
-/**
- * Marks all "top-level" types as non-null in a way that is recognized by Kotlin. Note that this
- * unfortunately includes type-variable usages, so we also provide {@link ParametricNullness} to
- * "undo" it as best we can.
- */
-@GwtCompatible
-@Retention(RUNTIME)
-@Target(TYPE)
-@TypeQualifierDefault({FIELD, METHOD, PARAMETER})
-@Nonnull
-@interface ElementTypesAreNonnullByDefault {}
diff --git a/guava/src/com/google/common/base/Enums.java b/guava/src/com/google/common/base/Enums.java
index 449b7e3..2a1b429 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 javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Utility methods for working with {@link Enum} instances.
@@ -34,7 +34,6 @@
* @since 9.0
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
public final class Enums {
private Enums() {}
@@ -129,7 +128,7 @@
}
@Override
- public boolean equals(@CheckForNull 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 fbcd212..b4ac005 100644
--- a/guava/src/com/google/common/base/Equivalence.java
+++ b/guava/src/com/google/common/base/Equivalence.java
@@ -20,7 +20,6 @@
import com.google.errorprone.annotations.ForOverride;
import java.io.Serializable;
import java.util.function.BiPredicate;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -35,12 +34,7 @@
* source-compatible</a> since 4.0)
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-/*
- * The type parameter is <T> rather than <T extends @Nullable> so that we can use T in the
- * doEquivalent and doHash methods to indicate that the parameter cannot be null.
- */
-public abstract class Equivalence<T> implements BiPredicate<@Nullable T, @Nullable T> {
+public abstract class Equivalence<T> implements BiPredicate<T, T> {
/** Constructor for use by subclasses. */
protected Equivalence() {}
@@ -61,7 +55,7 @@
* <p>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(@CheckForNull T a, @CheckForNull T b) {
+ public final boolean equivalent(@Nullable T a, @Nullable T b) {
if (a == b) {
return true;
}
@@ -78,7 +72,7 @@
*/
@Deprecated
@Override
- public final boolean test(@CheckForNull T t, @CheckForNull T u) {
+ public final boolean test(@Nullable T t, @Nullable T u) {
return equivalent(t, u);
}
@@ -111,7 +105,7 @@
* <li>{@code hash(null)} is {@code 0}.
* </ul>
*/
- public final int hash(@CheckForNull T t) {
+ public final int hash(@Nullable T t) {
if (t == null) {
return 0;
}
@@ -153,7 +147,7 @@
*
* @since 10.0
*/
- public final <F> Equivalence<F> onResultOf(Function<? super F, ? extends @Nullable T> function) {
+ public final <F> Equivalence<F> onResultOf(Function<F, ? extends T> function) {
return new FunctionalEquivalence<>(function, this);
}
@@ -164,7 +158,7 @@
*
* @since 10.0
*/
- public final <S extends @Nullable T> Wrapper<S> wrap(@ParametricNullness S reference) {
+ public final <S extends T> Wrapper<S> wrap(@Nullable S reference) {
return new Wrapper<S>(this, reference);
}
@@ -188,18 +182,17 @@
*
* @since 10.0
*/
- public static final class Wrapper<T extends @Nullable Object> implements Serializable {
+ public static final class Wrapper<T> implements Serializable {
private final Equivalence<? super T> equivalence;
- @ParametricNullness private final T reference;
+ private final @Nullable T reference;
- private Wrapper(Equivalence<? super T> equivalence, @ParametricNullness T reference) {
+ private Wrapper(Equivalence<? super T> equivalence, @Nullable T reference) {
this.equivalence = checkNotNull(equivalence);
this.reference = reference;
}
/** Returns the (possibly null) reference wrapped by this instance. */
- @ParametricNullness
- public T get() {
+ public @Nullable T get() {
return reference;
}
@@ -209,7 +202,7 @@
* equivalence.
*/
@Override
- public boolean equals(@CheckForNull Object obj) {
+ public boolean equals(@Nullable Object obj) {
if (obj == this) {
return true;
}
@@ -259,10 +252,10 @@
* @since 10.0
*/
@GwtCompatible(serializable = true)
- public final <S extends @Nullable T> Equivalence<Iterable<S>> pairwise() {
+ public final <S extends T> Equivalence<Iterable<S>> pairwise() {
// Ideally, the returned equivalence would support Iterable<? extends T>. However,
// the need for this is so rare that it's not worth making callers deal with the ugly wildcard.
- return new PairwiseEquivalence<>(this);
+ return new PairwiseEquivalence<S>(this);
}
/**
@@ -271,28 +264,27 @@
*
* @since 10.0
*/
- public final Predicate<@Nullable T> equivalentTo(@CheckForNull T target) {
+ public final Predicate<T> equivalentTo(@Nullable T target) {
return new EquivalentToPredicate<T>(this, target);
}
- private static final class EquivalentToPredicate<T>
- implements Predicate<@Nullable T>, Serializable {
+ private static final class EquivalentToPredicate<T> implements Predicate<T>, Serializable {
private final Equivalence<T> equivalence;
- @CheckForNull private final T target;
+ private final @Nullable T target;
- EquivalentToPredicate(Equivalence<T> equivalence, @CheckForNull T target) {
+ EquivalentToPredicate(Equivalence<T> equivalence, @Nullable T target) {
this.equivalence = checkNotNull(equivalence);
this.target = target;
}
@Override
- public boolean apply(@CheckForNull T input) {
+ public boolean apply(@Nullable T input) {
return equivalence.equivalent(input, target);
}
@Override
- public boolean equals(@CheckForNull Object obj) {
+ public boolean equals(@Nullable Object obj) {
if (this == obj) {
return true;
}
diff --git a/guava/src/com/google/common/base/ExtraObjectsMethodsForWeb.java b/guava/src/com/google/common/base/ExtraObjectsMethodsForWeb.java
index 6770755..21cca2c 100644
--- a/guava/src/com/google/common/base/ExtraObjectsMethodsForWeb.java
+++ b/guava/src/com/google/common/base/ExtraObjectsMethodsForWeb.java
@@ -21,5 +21,4 @@
* version.
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
abstract class ExtraObjectsMethodsForWeb {}
diff --git a/guava/src/com/google/common/base/FinalizablePhantomReference.java b/guava/src/com/google/common/base/FinalizablePhantomReference.java
index 4f93996..f920575 100644
--- a/guava/src/com/google/common/base/FinalizablePhantomReference.java
+++ b/guava/src/com/google/common/base/FinalizablePhantomReference.java
@@ -17,7 +17,6 @@
import com.google.common.annotations.GwtIncompatible;
import java.lang.ref.PhantomReference;
import java.lang.ref.ReferenceQueue;
-import javax.annotation.CheckForNull;
/**
* Phantom reference with a {@code finalizeReferent()} method which a background thread invokes
@@ -30,7 +29,6 @@
* @since 2.0
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public abstract class FinalizablePhantomReference<T> extends PhantomReference<T>
implements FinalizableReference {
/**
@@ -39,7 +37,7 @@
* @param referent to phantom reference
* @param queue that should finalize the referent
*/
- protected FinalizablePhantomReference(@CheckForNull T referent, FinalizableReferenceQueue queue) {
+ protected FinalizablePhantomReference(T referent, FinalizableReferenceQueue queue) {
super(referent, queue.queue);
queue.cleanUp();
}
diff --git a/guava/src/com/google/common/base/FinalizableReference.java b/guava/src/com/google/common/base/FinalizableReference.java
index 73753c9..848e7ee 100644
--- a/guava/src/com/google/common/base/FinalizableReference.java
+++ b/guava/src/com/google/common/base/FinalizableReference.java
@@ -26,7 +26,6 @@
*/
@DoNotMock("Use an instance of one of the Finalizable*Reference classes")
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public interface FinalizableReference {
/**
* Invoked on a background thread after the referent has been garbage collected unless security
diff --git a/guava/src/com/google/common/base/FinalizableReferenceQueue.java b/guava/src/com/google/common/base/FinalizableReferenceQueue.java
index 5ce1d31..3fe706f 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 javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* A reference queue with an associated background thread that dequeues references and invokes
@@ -37,7 +37,7 @@
* finalized. If this object is garbage collected earlier, the backing thread will not invoke {@code
* finalizeReferent()} on the remaining references.
*
- * <p>As an example of how this is used, imagine you have a class {@code MyServer} that creates a
+ * <p>As an example of how this is used, imagine you have a class {@code MyServer} that creates a a
* {@link java.net.ServerSocket ServerSocket}, and you would like to ensure that the {@code
* ServerSocket} is closed even if the {@code MyServer} object is garbage-collected without calling
* its {@code close} method. You <em>could</em> use a finalizer to accomplish this, but that has a
@@ -89,7 +89,6 @@
* @since 2.0
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public class FinalizableReferenceQueue implements Closeable {
/*
* The Finalizer thread keeps a phantom reference to this object. When the client (for example, a
@@ -229,7 +228,7 @@
*
* @throws SecurityException if we don't have the appropriate privileges
*/
- @CheckForNull
+ @Nullable
Class<?> loadFinalizer();
}
@@ -243,8 +242,7 @@
@VisibleForTesting static boolean disabled;
@Override
- @CheckForNull
- public Class<?> loadFinalizer() {
+ public @Nullable Class<?> loadFinalizer() {
if (disabled) {
return null;
}
@@ -281,8 +279,7 @@
+ "issue, or move Guava to your system class path.";
@Override
- @CheckForNull
- public Class<?> loadFinalizer() {
+ public @Nullable Class<?> loadFinalizer() {
try {
/*
* We use URLClassLoader because it's the only concrete class loader implementation in the
diff --git a/guava/src/com/google/common/base/FinalizableSoftReference.java b/guava/src/com/google/common/base/FinalizableSoftReference.java
index c0e9b6b..45ecc65 100644
--- a/guava/src/com/google/common/base/FinalizableSoftReference.java
+++ b/guava/src/com/google/common/base/FinalizableSoftReference.java
@@ -17,7 +17,6 @@
import com.google.common.annotations.GwtIncompatible;
import java.lang.ref.ReferenceQueue;
import java.lang.ref.SoftReference;
-import javax.annotation.CheckForNull;
/**
* Soft reference with a {@code finalizeReferent()} method which a background thread invokes after
@@ -28,7 +27,6 @@
* @since 2.0
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public abstract class FinalizableSoftReference<T> extends SoftReference<T>
implements FinalizableReference {
/**
@@ -37,7 +35,7 @@
* @param referent to softly reference
* @param queue that should finalize the referent
*/
- protected FinalizableSoftReference(@CheckForNull T referent, FinalizableReferenceQueue queue) {
+ protected FinalizableSoftReference(T referent, FinalizableReferenceQueue queue) {
super(referent, queue.queue);
queue.cleanUp();
}
diff --git a/guava/src/com/google/common/base/FinalizableWeakReference.java b/guava/src/com/google/common/base/FinalizableWeakReference.java
index 9cca92e..fb3b09b 100644
--- a/guava/src/com/google/common/base/FinalizableWeakReference.java
+++ b/guava/src/com/google/common/base/FinalizableWeakReference.java
@@ -17,7 +17,6 @@
import com.google.common.annotations.GwtIncompatible;
import java.lang.ref.ReferenceQueue;
import java.lang.ref.WeakReference;
-import javax.annotation.CheckForNull;
/**
* Weak reference with a {@code finalizeReferent()} method which a background thread invokes after
@@ -28,7 +27,6 @@
* @since 2.0
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public abstract class FinalizableWeakReference<T> extends WeakReference<T>
implements FinalizableReference {
/**
@@ -37,7 +35,7 @@
* @param referent to weakly reference
* @param queue that should finalize the referent
*/
- protected FinalizableWeakReference(@CheckForNull T referent, FinalizableReferenceQueue queue) {
+ protected FinalizableWeakReference(T referent, FinalizableReferenceQueue queue) {
super(referent, queue.queue);
queue.cleanUp();
}
diff --git a/guava/src/com/google/common/base/Function.java b/guava/src/com/google/common/base/Function.java
index 45287b7..29b46c0 100644
--- a/guava/src/com/google/common/base/Function.java
+++ b/guava/src/com/google/common/base/Function.java
@@ -16,7 +16,6 @@
import com.google.common.annotations.GwtCompatible;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -42,13 +41,11 @@
*/
@GwtCompatible
@FunctionalInterface
-@ElementTypesAreNonnullByDefault
-public interface Function<F extends @Nullable Object, T extends @Nullable Object>
- extends java.util.function.Function<F, T> {
+public interface Function<F, T> extends java.util.function.Function<F, T> {
@Override
@CanIgnoreReturnValue // TODO(kevinb): remove this
- @ParametricNullness
- T apply(@ParametricNullness F input);
+ @Nullable
+ T apply(@Nullable F input);
/**
* <i>May</i> return {@code true} if {@code object} is a {@code Function} that behaves identically
@@ -62,5 +59,5 @@
* disappear. It is best not to depend on it.
*/
@Override
- boolean equals(@CheckForNull 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 8bb67be..05b6271 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 javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Equivalence applied on functional result.
@@ -29,16 +29,14 @@
*/
@Beta
@GwtCompatible
-@ElementTypesAreNonnullByDefault
final class FunctionalEquivalence<F, T> extends Equivalence<F> implements Serializable {
private static final long serialVersionUID = 0;
- private final Function<? super F, ? extends T> function;
+ private final Function<F, ? extends T> function;
private final Equivalence<T> resultEquivalence;
- FunctionalEquivalence(
- Function<? super F, ? extends T> function, Equivalence<T> resultEquivalence) {
+ FunctionalEquivalence(Function<F, ? extends T> function, Equivalence<T> resultEquivalence) {
this.function = checkNotNull(function);
this.resultEquivalence = checkNotNull(resultEquivalence);
}
@@ -54,7 +52,7 @@
}
@Override
- public boolean equals(@CheckForNull 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 5337d0e..be845c6 100644
--- a/guava/src/com/google/common/base/Functions.java
+++ b/guava/src/com/google/common/base/Functions.java
@@ -14,14 +14,12 @@
package com.google.common.base;
-import static com.google.common.base.NullnessCasts.uncheckedCastNullableTToT;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.annotations.GwtCompatible;
import java.io.Serializable;
import java.util.Map;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -38,7 +36,6 @@
* @since 2.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
public final class Functions {
private Functions() {}
@@ -82,17 +79,16 @@
/** Returns the identity function. */
// implementation is "fully variant"; E has become a "pass-through" type
@SuppressWarnings("unchecked")
- public static <E extends @Nullable Object> Function<E, E> identity() {
+ public static <E> Function<E, E> identity() {
return (Function<E, E>) IdentityFunction.INSTANCE;
}
// enum singleton pattern
- private enum IdentityFunction implements Function<@Nullable Object, @Nullable Object> {
+ private enum IdentityFunction implements Function<Object, Object> {
INSTANCE;
@Override
- @CheckForNull
- public Object apply(@CheckForNull Object o) {
+ public @Nullable Object apply(@Nullable Object o) {
return o;
}
@@ -115,8 +111,7 @@
* key (instead of an exception being thrown), you can use the method reference {@code map::get}
* instead.
*/
- public static <K extends @Nullable Object, V extends @Nullable Object> Function<K, V> forMap(
- Map<K, V> map) {
+ public static <K, V> Function<K, V> forMap(Map<K, V> map) {
return new FunctionForMapNoDefault<>(map);
}
@@ -133,14 +128,11 @@
* @return function that returns {@code map.get(a)} when {@code a} is a key, or {@code
* defaultValue} otherwise
*/
- public static <K extends @Nullable Object, V extends @Nullable Object> Function<K, V> forMap(
- Map<K, ? extends V> map, @ParametricNullness V defaultValue) {
+ public static <K, V> Function<K, V> forMap(Map<K, ? extends V> map, @Nullable V defaultValue) {
return new ForMapWithDefault<>(map, defaultValue);
}
- private static class FunctionForMapNoDefault<
- K extends @Nullable Object, V extends @Nullable Object>
- implements Function<K, V>, Serializable {
+ private static class FunctionForMapNoDefault<K, V> implements Function<K, V>, Serializable {
final Map<K, V> map;
FunctionForMapNoDefault(Map<K, V> map) {
@@ -148,16 +140,14 @@
}
@Override
- @ParametricNullness
- public V apply(@ParametricNullness 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);
- // The unchecked cast is safe because of the containsKey check.
- return uncheckedCastNullableTToT(result);
+ return result;
}
@Override
- public boolean equals(@CheckForNull Object o) {
+ public boolean equals(@Nullable Object o) {
if (o instanceof FunctionForMapNoDefault) {
FunctionForMapNoDefault<?, ?> that = (FunctionForMapNoDefault<?, ?>) o;
return map.equals(that.map);
@@ -178,28 +168,23 @@
private static final long serialVersionUID = 0;
}
- private static class ForMapWithDefault<K extends @Nullable Object, V extends @Nullable Object>
- implements Function<K, V>, Serializable {
+ private static class ForMapWithDefault<K, V> implements Function<K, V>, Serializable {
final Map<K, ? extends V> map;
- @ParametricNullness final V defaultValue;
+ final @Nullable V defaultValue;
- ForMapWithDefault(Map<K, ? extends V> map, @ParametricNullness V defaultValue) {
+ ForMapWithDefault(Map<K, ? extends V> map, @Nullable V defaultValue) {
this.map = checkNotNull(map);
this.defaultValue = defaultValue;
}
@Override
- @ParametricNullness
- public V apply(@ParametricNullness K key) {
+ public V apply(@Nullable K key) {
V result = map.get(key);
- // The unchecked cast is safe because of the containsKey check.
- return (result != null || map.containsKey(key))
- ? uncheckedCastNullableTToT(result)
- : defaultValue;
+ return (result != null || map.containsKey(key)) ? result : defaultValue;
}
@Override
- public boolean equals(@CheckForNull 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);
@@ -233,14 +218,11 @@
* @return the composition of {@code f} and {@code g}
* @see <a href="//en.wikipedia.org/wiki/Function_composition">function composition</a>
*/
- public static <A extends @Nullable Object, B extends @Nullable Object, C extends @Nullable Object>
- Function<A, C> compose(Function<B, C> g, Function<A, ? extends B> f) {
+ public static <A, B, C> Function<A, C> compose(Function<B, C> g, Function<A, ? extends B> f) {
return new FunctionComposition<>(g, f);
}
- private static class FunctionComposition<
- A extends @Nullable Object, B extends @Nullable Object, C extends @Nullable Object>
- implements Function<A, C>, Serializable {
+ private static class FunctionComposition<A, B, C> implements Function<A, C>, Serializable {
private final Function<B, C> g;
private final Function<A, ? extends B> f;
@@ -250,13 +232,12 @@
}
@Override
- @ParametricNullness
- public C apply(@ParametricNullness A a) {
+ public C apply(@Nullable A a) {
return g.apply(f.apply(a));
}
@Override
- public boolean equals(@CheckForNull 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);
@@ -286,14 +267,12 @@
*
* <p><b>Java 8 users:</b> use the method reference {@code predicate::test} instead.
*/
- public static <T extends @Nullable Object> Function<T, Boolean> forPredicate(
- Predicate<T> predicate) {
+ public static <T> Function<T, Boolean> forPredicate(Predicate<T> predicate) {
return new PredicateFunction<T>(predicate);
}
/** @see Functions#forPredicate */
- private static class PredicateFunction<T extends @Nullable Object>
- implements Function<T, Boolean>, Serializable {
+ private static class PredicateFunction<T> implements Function<T, Boolean>, Serializable {
private final Predicate<T> predicate;
private PredicateFunction(Predicate<T> predicate) {
@@ -301,12 +280,12 @@
}
@Override
- public Boolean apply(@ParametricNullness T t) {
+ public Boolean apply(@Nullable T t) {
return predicate.apply(t);
}
@Override
- public boolean equals(@CheckForNull Object obj) {
+ public boolean equals(@Nullable Object obj) {
if (obj instanceof PredicateFunction) {
PredicateFunction<?> that = (PredicateFunction<?>) obj;
return predicate.equals(that.predicate);
@@ -335,27 +314,24 @@
* @param value the constant value for the function to return
* @return a function that always returns {@code value}
*/
- public static <E extends @Nullable Object> Function<@Nullable Object, E> constant(
- @ParametricNullness E value) {
- return new ConstantFunction<>(value);
+ public static <E> Function<Object, E> constant(@Nullable E value) {
+ return new ConstantFunction<E>(value);
}
- private static class ConstantFunction<E extends @Nullable Object>
- implements Function<@Nullable Object, E>, Serializable {
- @ParametricNullness private final E value;
+ private static class ConstantFunction<E> implements Function<Object, E>, Serializable {
+ private final @Nullable E value;
- public ConstantFunction(@ParametricNullness E value) {
+ public ConstantFunction(@Nullable E value) {
this.value = value;
}
@Override
- @ParametricNullness
- public E apply(@CheckForNull Object from) {
+ public E apply(@Nullable Object from) {
return value;
}
@Override
- public boolean equals(@CheckForNull Object obj) {
+ public boolean equals(@Nullable Object obj) {
if (obj instanceof ConstantFunction) {
ConstantFunction<?> that = (ConstantFunction<?>) obj;
return Objects.equal(value, that.value);
@@ -383,14 +359,12 @@
*
* @since 10.0
*/
- public static <F extends @Nullable Object, T extends @Nullable Object> Function<F, T> forSupplier(
- Supplier<T> supplier) {
- return new SupplierFunction<>(supplier);
+ public static <T> Function<Object, T> forSupplier(Supplier<T> supplier) {
+ return new SupplierFunction<T>(supplier);
}
/** @see Functions#forSupplier */
- private static class SupplierFunction<F extends @Nullable Object, T extends @Nullable Object>
- implements Function<F, T>, Serializable {
+ private static class SupplierFunction<T> implements Function<Object, T>, Serializable {
private final Supplier<T> supplier;
@@ -399,15 +373,14 @@
}
@Override
- @ParametricNullness
- public T apply(@ParametricNullness F input) {
+ public T apply(@Nullable Object input) {
return supplier.get();
}
@Override
- public boolean equals(@CheckForNull Object obj) {
+ public boolean equals(@Nullable Object obj) {
if (obj instanceof SupplierFunction) {
- SupplierFunction<?, ?> that = (SupplierFunction<?, ?>) obj;
+ SupplierFunction<?> that = (SupplierFunction<?>) obj;
return this.supplier.equals(that.supplier);
}
return false;
diff --git a/guava/src/com/google/common/base/Java8Compatibility.java b/guava/src/com/google/common/base/Java8Compatibility.java
deleted file mode 100644
index edc8b73..0000000
--- a/guava/src/com/google/common/base/Java8Compatibility.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (C) 2020 The Guava Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
- * or implied. See the License for the specific language governing permissions and limitations under
- * the License.
- */
-
-package com.google.common.base;
-
-import com.google.common.annotations.GwtIncompatible;
-import java.nio.Buffer;
-
-/**
- * Wrappers around {@link Buffer} methods that are covariantly overridden in Java 9+. See
- * https://github.com/google/guava/issues/3990
- */
-@GwtIncompatible
-@ElementTypesAreNonnullByDefault
-final class Java8Compatibility {
- static void clear(Buffer b) {
- b.clear();
- }
-
- static void flip(Buffer b) {
- b.flip();
- }
-
- static void limit(Buffer b, int limit) {
- b.limit(limit);
- }
-
- static void position(Buffer b, int position) {
- b.position(position);
- }
-
- private Java8Compatibility() {}
-}
diff --git a/guava/src/com/google/common/base/JdkPattern.java b/guava/src/com/google/common/base/JdkPattern.java
index 4788398..f7791db 100644
--- a/guava/src/com/google/common/base/JdkPattern.java
+++ b/guava/src/com/google/common/base/JdkPattern.java
@@ -20,7 +20,6 @@
import java.util.regex.Pattern;
/** A regex pattern implementation which is backed by the {@link Pattern}. */
-@ElementTypesAreNonnullByDefault
@GwtIncompatible
final class JdkPattern extends CommonPattern implements Serializable {
private final Pattern pattern;
diff --git a/guava/src/com/google/common/base/Joiner.java b/guava/src/com/google/common/base/Joiner.java
index 0f3d6e4..922c1eb 100644
--- a/guava/src/com/google/common/base/Joiner.java
+++ b/guava/src/com/google/common/base/Joiner.java
@@ -15,7 +15,6 @@
package com.google.common.base;
import static com.google.common.base.Preconditions.checkNotNull;
-import static java.util.Objects.requireNonNull;
import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtCompatible;
@@ -26,7 +25,6 @@
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -65,7 +63,6 @@
* @since 2.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
public class Joiner {
/** Returns a joiner which automatically places {@code separator} between consecutive elements. */
public static Joiner on(String separator) {
@@ -87,19 +84,12 @@
this.separator = prototype.separator;
}
- /*
- * In this file, we use <? extends @Nullable Object> instead of <?> to work around a Kotlin bug
- * (see b/189937072 until we file a bug against Kotlin itself). (The two should be equivalent, so
- * we normally prefer the shorter one.)
- */
-
/**
* Appends the string representation of each of {@code parts}, using the previously configured
* separator between each, to {@code appendable}.
*/
@CanIgnoreReturnValue
- public <A extends Appendable> A appendTo(A appendable, Iterable<? extends @Nullable Object> parts)
- throws IOException {
+ public <A extends Appendable> A appendTo(A appendable, Iterable<?> parts) throws IOException {
return appendTo(appendable, parts.iterator());
}
@@ -110,8 +100,7 @@
* @since 11.0
*/
@CanIgnoreReturnValue
- public <A extends Appendable> A appendTo(A appendable, Iterator<? extends @Nullable Object> parts)
- throws IOException {
+ public <A extends Appendable> A appendTo(A appendable, Iterator<?> parts) throws IOException {
checkNotNull(appendable);
if (parts.hasNext()) {
appendable.append(toString(parts.next()));
@@ -128,18 +117,14 @@
* separator between each, to {@code appendable}.
*/
@CanIgnoreReturnValue
- public final <A extends Appendable> A appendTo(A appendable, @Nullable Object[] parts)
- throws IOException {
+ public final <A extends Appendable> A appendTo(A appendable, Object[] parts) throws IOException {
return appendTo(appendable, Arrays.asList(parts));
}
/** Appends to {@code appendable} the string representation of each of the remaining arguments. */
@CanIgnoreReturnValue
public final <A extends Appendable> A appendTo(
- A appendable,
- @CheckForNull Object first,
- @CheckForNull Object second,
- @Nullable Object... rest)
+ A appendable, @Nullable Object first, @Nullable Object second, Object... rest)
throws IOException {
return appendTo(appendable, iterable(first, second, rest));
}
@@ -150,8 +135,7 @@
* Iterable)}, except that it does not throw {@link IOException}.
*/
@CanIgnoreReturnValue
- public final StringBuilder appendTo(
- StringBuilder builder, Iterable<? extends @Nullable Object> parts) {
+ public final StringBuilder appendTo(StringBuilder builder, Iterable<?> parts) {
return appendTo(builder, parts.iterator());
}
@@ -163,8 +147,7 @@
* @since 11.0
*/
@CanIgnoreReturnValue
- public final StringBuilder appendTo(
- StringBuilder builder, Iterator<? extends @Nullable Object> parts) {
+ public final StringBuilder appendTo(StringBuilder builder, Iterator<?> parts) {
try {
appendTo((Appendable) builder, parts);
} catch (IOException impossible) {
@@ -179,7 +162,7 @@
* Iterable)}, except that it does not throw {@link IOException}.
*/
@CanIgnoreReturnValue
- public final StringBuilder appendTo(StringBuilder builder, @Nullable Object[] parts) {
+ public final StringBuilder appendTo(StringBuilder builder, Object[] parts) {
return appendTo(builder, Arrays.asList(parts));
}
@@ -190,10 +173,7 @@
*/
@CanIgnoreReturnValue
public final StringBuilder appendTo(
- StringBuilder builder,
- @CheckForNull Object first,
- @CheckForNull Object second,
- @Nullable Object... rest) {
+ StringBuilder builder, @Nullable Object first, @Nullable Object second, Object... rest) {
return appendTo(builder, iterable(first, second, rest));
}
@@ -201,7 +181,7 @@
* Returns a string containing the string representation of each of {@code parts}, using the
* previously configured separator between each.
*/
- public final String join(Iterable<? extends @Nullable Object> parts) {
+ public final String join(Iterable<?> parts) {
return join(parts.iterator());
}
@@ -211,7 +191,7 @@
*
* @since 11.0
*/
- public final String join(Iterator<? extends @Nullable Object> parts) {
+ public final String join(Iterator<?> parts) {
return appendTo(new StringBuilder(), parts).toString();
}
@@ -219,7 +199,7 @@
* Returns a string containing the string representation of each of {@code parts}, using the
* previously configured separator between each.
*/
- public final String join(@Nullable Object[] parts) {
+ public final String join(Object[] parts) {
return join(Arrays.asList(parts));
}
@@ -227,8 +207,7 @@
* Returns a string containing the string representation of each argument, using the previously
* configured separator between each.
*/
- public final String join(
- @CheckForNull Object first, @CheckForNull Object second, @Nullable Object... rest) {
+ public final String join(@Nullable Object first, @Nullable Object second, Object... rest) {
return join(iterable(first, second, rest));
}
@@ -240,7 +219,7 @@
checkNotNull(nullText);
return new Joiner(this) {
@Override
- CharSequence toString(@CheckForNull Object part) {
+ CharSequence toString(@Nullable Object part) {
return (part == null) ? nullText : Joiner.this.toString(part);
}
@@ -263,8 +242,7 @@
public Joiner skipNulls() {
return new Joiner(this) {
@Override
- public <A extends Appendable> A appendTo(
- A appendable, Iterator<? extends @Nullable Object> parts) throws IOException {
+ public <A extends Appendable> A appendTo(A appendable, Iterator<?> parts) throws IOException {
checkNotNull(appendable, "appendable");
checkNotNull(parts, "parts");
while (parts.hasNext()) {
@@ -470,41 +448,21 @@
}
}
- CharSequence toString(@CheckForNull Object part) {
- /*
- * requireNonNull is not safe: Joiner.on(...).join(somethingThatContainsNull) will indeed throw.
- * However, Joiner.on(...).useForNull(...).join(somethingThatContainsNull) *is* safe -- because
- * it returns a subclass of Joiner that overrides this method to tolerate null inputs.
- *
- * Unfortunately, we don't distinguish between these two cases in our public API: Joiner.on(...)
- * and Joiner.on(...).useForNull(...) both declare the same return type: plain Joiner. To ensure
- * that users *can* pass null arguments to Joiner, we annotate it as if it always tolerates null
- * inputs, rather than as if it never tolerates them.
- *
- * We rely on checkers to implement special cases to catch dangerous calls to join(), etc. based
- * on what they know about the particular Joiner instances the calls are performed on.
- *
- * (In addition to useForNull, we also offer skipNulls. It, too, tolerates null inputs, but its
- * tolerance is implemented differently: Its implementation avoids calling this toString(Object)
- * method in the first place.)
- */
- requireNonNull(part);
+ CharSequence toString(Object part) {
+ checkNotNull(part); // checkNotNull for GWT (do not optimize).
return (part instanceof CharSequence) ? (CharSequence) part : part.toString();
}
- private static Iterable<@Nullable Object> iterable(
- @CheckForNull final Object first,
- @CheckForNull final Object second,
- final @Nullable Object[] rest) {
+ private static Iterable<Object> iterable(
+ final Object first, final Object second, final Object[] rest) {
checkNotNull(rest);
- return new AbstractList<@Nullable Object>() {
+ return new AbstractList<Object>() {
@Override
public int size() {
return rest.length + 2;
}
@Override
- @CheckForNull
public Object get(int index) {
switch (index) {
case 0:
diff --git a/guava/src/com/google/common/base/MoreObjects.java b/guava/src/com/google/common/base/MoreObjects.java
index 16e12bb..cf901b5 100644
--- a/guava/src/com/google/common/base/MoreObjects.java
+++ b/guava/src/com/google/common/base/MoreObjects.java
@@ -18,14 +18,8 @@
import com.google.common.annotations.GwtCompatible;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
-import java.lang.reflect.Array;
import java.util.Arrays;
-import java.util.Collection;
-import java.util.Map;
-import java.util.OptionalDouble;
-import java.util.OptionalInt;
-import java.util.OptionalLong;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Helper functions that operate on any {@code Object}, and are not already provided in {@link
@@ -39,7 +33,6 @@
* @since 18.0 (since 2.0 as {@code Objects})
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
public final class MoreObjects {
/**
* Returns the first of two given parameters that is not {@code null}, if either is, or otherwise
@@ -61,24 +54,7 @@
* @throws NullPointerException if both {@code first} and {@code second} are null
* @since 18.0 (since 3.0 as {@code Objects.firstNonNull()}).
*/
- /*
- * We annotate firstNonNull in a way that protects against NullPointerException at the cost of
- * forbidding some reasonable calls.
- *
- * The more permissive signature would be to accept (@CheckForNull T first, @CheckForNull T
- * second), since it's OK for `second` to be null as long as `first` is not also null. But we
- * expect for that flexibility to be useful relatively rarely: The more common use case is to
- * supply a clearly non-null default, like `firstNonNull(someString, "")`. And users who really
- * know that `first` is guaranteed non-null when `second` is null can write the logic out
- * longhand, including a requireNonNull call, which calls attention to the fact that the static
- * analyzer can't prove that the operation is safe.
- *
- * This matches the signature we currently have for requireNonNullElse in our own checker. (And
- * that in turn matches that method's signature under the Checker Framework.) As always, we could
- * consider the more flexible signature if we judge it worth the risks. If we do, we would likely
- * update both methods so that they continue to match.
- */
- public static <T> T firstNonNull(@CheckForNull T first, T second) {
+ public static <T> T firstNonNull(@Nullable T first, @Nullable T second) {
if (first != null) {
return first;
}
@@ -169,7 +145,6 @@
private final ValueHolder holderHead = new ValueHolder();
private ValueHolder holderTail = holderHead;
private boolean omitNullValues = false;
- private boolean omitEmptyValues = false;
/** Use {@link MoreObjects#toStringHelper(Object)} to create an instance. */
private ToStringHelper(String className) {
@@ -195,7 +170,7 @@
* called, in which case this name/value pair will not be added.
*/
@CanIgnoreReturnValue
- public ToStringHelper add(String name, @CheckForNull Object value) {
+ public ToStringHelper add(String name, @Nullable Object value) {
return addHolder(name, value);
}
@@ -206,7 +181,7 @@
*/
@CanIgnoreReturnValue
public ToStringHelper add(String name, boolean value) {
- return addUnconditionalHolder(name, String.valueOf(value));
+ return addHolder(name, String.valueOf(value));
}
/**
@@ -216,7 +191,7 @@
*/
@CanIgnoreReturnValue
public ToStringHelper add(String name, char value) {
- return addUnconditionalHolder(name, String.valueOf(value));
+ return addHolder(name, String.valueOf(value));
}
/**
@@ -226,7 +201,7 @@
*/
@CanIgnoreReturnValue
public ToStringHelper add(String name, double value) {
- return addUnconditionalHolder(name, String.valueOf(value));
+ return addHolder(name, String.valueOf(value));
}
/**
@@ -236,7 +211,7 @@
*/
@CanIgnoreReturnValue
public ToStringHelper add(String name, float value) {
- return addUnconditionalHolder(name, String.valueOf(value));
+ return addHolder(name, String.valueOf(value));
}
/**
@@ -246,7 +221,7 @@
*/
@CanIgnoreReturnValue
public ToStringHelper add(String name, int value) {
- return addUnconditionalHolder(name, String.valueOf(value));
+ return addHolder(name, String.valueOf(value));
}
/**
@@ -256,7 +231,7 @@
*/
@CanIgnoreReturnValue
public ToStringHelper add(String name, long value) {
- return addUnconditionalHolder(name, String.valueOf(value));
+ return addHolder(name, String.valueOf(value));
}
/**
@@ -266,7 +241,7 @@
* readable name.
*/
@CanIgnoreReturnValue
- public ToStringHelper addValue(@CheckForNull Object value) {
+ public ToStringHelper addValue(@Nullable Object value) {
return addHolder(value);
}
@@ -280,7 +255,7 @@
*/
@CanIgnoreReturnValue
public ToStringHelper addValue(boolean value) {
- return addUnconditionalHolder(String.valueOf(value));
+ return addHolder(String.valueOf(value));
}
/**
@@ -293,7 +268,7 @@
*/
@CanIgnoreReturnValue
public ToStringHelper addValue(char value) {
- return addUnconditionalHolder(String.valueOf(value));
+ return addHolder(String.valueOf(value));
}
/**
@@ -306,7 +281,7 @@
*/
@CanIgnoreReturnValue
public ToStringHelper addValue(double value) {
- return addUnconditionalHolder(String.valueOf(value));
+ return addHolder(String.valueOf(value));
}
/**
@@ -319,7 +294,7 @@
*/
@CanIgnoreReturnValue
public ToStringHelper addValue(float value) {
- return addUnconditionalHolder(String.valueOf(value));
+ return addHolder(String.valueOf(value));
}
/**
@@ -332,7 +307,7 @@
*/
@CanIgnoreReturnValue
public ToStringHelper addValue(int value) {
- return addUnconditionalHolder(String.valueOf(value));
+ return addHolder(String.valueOf(value));
}
/**
@@ -345,31 +320,7 @@
*/
@CanIgnoreReturnValue
public ToStringHelper addValue(long value) {
- return addUnconditionalHolder(String.valueOf(value));
- }
-
- private static boolean isEmpty(Object value) {
- // Put types estimated to be most frequent first.
- if (value instanceof CharSequence) {
- return ((CharSequence) value).length() == 0;
- } else if (value instanceof Collection) {
- return ((Collection<?>) value).isEmpty();
- } else if (value instanceof Map) {
- return ((Map<?, ?>) value).isEmpty();
- } else if (value instanceof java.util.Optional) {
- return !((java.util.Optional<?>) value).isPresent();
- } else if (value instanceof OptionalInt) {
- return !((OptionalInt) value).isPresent();
- } else if (value instanceof OptionalLong) {
- return !((OptionalLong) value).isPresent();
- } else if (value instanceof OptionalDouble) {
- return !((OptionalDouble) value).isPresent();
- } else if (value instanceof Optional) {
- return !((Optional) value).isPresent();
- } else if (value.getClass().isArray()) {
- return Array.getLength(value) == 0;
- }
- return false;
+ return addHolder(String.valueOf(value));
}
/**
@@ -384,17 +335,13 @@
public String toString() {
// create a copy to keep it consistent in case value changes
boolean omitNullValuesSnapshot = omitNullValues;
- boolean omitEmptyValuesSnapshot = omitEmptyValues;
String nextSeparator = "";
StringBuilder builder = new StringBuilder(32).append(className).append('{');
for (ValueHolder valueHolder = holderHead.next;
valueHolder != null;
valueHolder = valueHolder.next) {
Object value = valueHolder.value;
- if (valueHolder instanceof UnconditionalValueHolder
- || (value == null
- ? !omitNullValuesSnapshot
- : (!omitEmptyValuesSnapshot || !isEmpty(value)))) {
+ if (!omitNullValuesSnapshot || value != null) {
builder.append(nextSeparator);
nextSeparator = ", ";
@@ -419,51 +366,24 @@
return valueHolder;
}
- private ToStringHelper addHolder(@CheckForNull Object value) {
+ private ToStringHelper addHolder(@Nullable Object value) {
ValueHolder valueHolder = addHolder();
valueHolder.value = value;
return this;
}
- private ToStringHelper addHolder(String name, @CheckForNull Object value) {
+ private ToStringHelper addHolder(String name, @Nullable Object value) {
ValueHolder valueHolder = addHolder();
valueHolder.value = value;
valueHolder.name = checkNotNull(name);
return this;
}
- private UnconditionalValueHolder addUnconditionalHolder() {
- UnconditionalValueHolder valueHolder = new UnconditionalValueHolder();
- holderTail = holderTail.next = valueHolder;
- return valueHolder;
+ private static final class ValueHolder {
+ @Nullable String name;
+ @Nullable Object value;
+ @Nullable ValueHolder next;
}
-
- private ToStringHelper addUnconditionalHolder(Object value) {
- UnconditionalValueHolder valueHolder = addUnconditionalHolder();
- valueHolder.value = value;
- return this;
- }
-
- private ToStringHelper addUnconditionalHolder(String name, Object value) {
- UnconditionalValueHolder valueHolder = addUnconditionalHolder();
- valueHolder.value = value;
- valueHolder.name = checkNotNull(name);
- return this;
- }
-
- // Holder object for values that might be null and/or empty.
- private static class ValueHolder {
- @CheckForNull String name;
- @CheckForNull Object value;
- @CheckForNull ValueHolder next;
- }
-
- /**
- * Holder object for values that cannot be null or empty (will be printed unconditionally). This
- * helps to shortcut most calls to isEmpty(), which is important because the check for emptiness
- * is relatively expensive. Use a subtype so this also doesn't need any extra storage.
- */
- private static final class UnconditionalValueHolder extends ValueHolder {}
}
private MoreObjects() {}
diff --git a/guava/src/com/google/common/base/NullnessCasts.java b/guava/src/com/google/common/base/NullnessCasts.java
deleted file mode 100644
index 1ada6bf..0000000
--- a/guava/src/com/google/common/base/NullnessCasts.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright (C) 2021 The Guava Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
- * or implied. See the License for the specific language governing permissions and limitations under
- * the License.
- */
-
-package com.google.common.base;
-
-import com.google.common.annotations.GwtCompatible;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
-
-/** A utility method to perform unchecked casts to suppress errors produced by nullness analyses. */
-@GwtCompatible
-@ElementTypesAreNonnullByDefault
-final class NullnessCasts {
- /**
- * Accepts a {@code @Nullable T} and returns a plain {@code T}, without performing any check that
- * that conversion is safe.
- *
- * <p>This method is intended to help with usages of type parameters that have {@linkplain
- * ParametricNullness parametric nullness}. If a type parameter instead ranges over only non-null
- * types (or if the type is a non-variable type, like {@code String}), then code should almost
- * never use this method, preferring instead to call {@code requireNonNull} so as to benefit from
- * its runtime check.
- *
- * <p>An example use case for this method is in implementing an {@code Iterator<T>} whose {@code
- * next} field is lazily initialized. The type of that field would be {@code @Nullable T}, and the
- * code would be responsible for populating a "real" {@code T} (which might still be the value
- * {@code null}!) before returning it to callers. Depending on how the code is structured, a
- * nullness analysis might not understand that the field has been populated. To avoid that problem
- * without having to add {@code @SuppressWarnings}, the code can call this method.
- *
- * <p>Why <i>not</i> just add {@code SuppressWarnings}? The problem is that this method is
- * typically useful for {@code return} statements. That leaves the code with two options: Either
- * add the suppression to the whole method (which turns off checking for a large section of code),
- * or extract a variable, and put the suppression on that. However, a local variable typically
- * doesn't work: Because nullness analyses typically infer the nullness of local variables,
- * there's no way to assign a {@code @Nullable T} to a field {@code T foo;} and instruct the
- * analysis that that means "plain {@code T}" rather than the inferred type {@code @Nullable T}.
- * (Even if supported added {@code @NonNull}, that would not help, since the problem case
- * addressed by this method is the case in which {@code T} has parametric nullness -- and thus its
- * value may be legitimately {@code null}.)
- */
- @ParametricNullness
- @SuppressWarnings("nullness")
- static <T extends @Nullable Object> T uncheckedCastNullableTToT(@CheckForNull T t) {
- return t;
- }
-
- private NullnessCasts() {}
-}
diff --git a/guava/src/com/google/common/base/Objects.java b/guava/src/com/google/common/base/Objects.java
index bd6b0d9..ed513d2 100644
--- a/guava/src/com/google/common/base/Objects.java
+++ b/guava/src/com/google/common/base/Objects.java
@@ -16,7 +16,6 @@
import com.google.common.annotations.GwtCompatible;
import java.util.Arrays;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -30,7 +29,6 @@
* @since 2.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
public final class Objects extends ExtraObjectsMethodsForWeb {
private Objects() {}
@@ -50,7 +48,7 @@
* <p><b>Note for Java 7 and later:</b> This method should be treated as deprecated; use {@link
* java.util.Objects#equals} instead.
*/
- public static boolean equal(@CheckForNull Object a, @CheckForNull Object b) {
+ public static boolean equal(@Nullable Object a, @Nullable Object b) {
return a == b || (a != null && a.equals(b));
}
@@ -75,7 +73,7 @@
* <p><b>Note for Java 7 and later:</b> This method should be treated as deprecated; use {@link
* java.util.Objects#hash} instead.
*/
- public static int hashCode(@CheckForNull @Nullable Object... objects) {
+ public static int hashCode(@Nullable 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 b47705e..51966f6 100644
--- a/guava/src/com/google/common/base/Optional.java
+++ b/guava/src/com/google/common/base/Optional.java
@@ -15,14 +15,14 @@
package com.google.common.base;
import static com.google.common.base.Preconditions.checkNotNull;
+import com.google.errorprone.annotations.DoNotMock;
import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtCompatible;
-import com.google.errorprone.annotations.DoNotMock;
import java.io.Serializable;
import java.util.Iterator;
import java.util.Set;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* An immutable object that may contain a non-null reference to another object. Each instance of
@@ -82,7 +82,6 @@
*/
@DoNotMock("Use Optional.of(value) or Optional.absent()")
@GwtCompatible(serializable = true)
-@ElementTypesAreNonnullByDefault
public abstract class Optional<T> implements Serializable {
/**
* Returns an {@code Optional} instance with no contained reference.
@@ -113,7 +112,7 @@
* <p><b>Comparison to {@code java.util.Optional}:</b> this method is equivalent to Java 8's
* {@code Optional.ofNullable}.
*/
- public static <T> Optional<T> fromNullable(@CheckForNull T nullableReference) {
+ public static <T> Optional<T> fromNullable(@Nullable T nullableReference) {
return (nullableReference == null) ? Optional.<T>absent() : new Present<T>(nullableReference);
}
@@ -123,8 +122,8 @@
*
* @since 21.0
*/
- @CheckForNull
- public static <T> Optional<T> fromJavaUtil(@CheckForNull java.util.Optional<T> javaUtilOptional) {
+ public static <T> @Nullable Optional<T> fromJavaUtil(
+ java.util.@Nullable Optional<T> javaUtilOptional) {
return (javaUtilOptional == null) ? null : fromNullable(javaUtilOptional.orElse(null));
}
@@ -141,8 +140,8 @@
*
* @since 21.0
*/
- @CheckForNull
- public static <T> java.util.Optional<T> toJavaUtil(@CheckForNull Optional<T> googleOptional) {
+ public static <T> java.util.@Nullable Optional<T> toJavaUtil(
+ @Nullable Optional<T> googleOptional) {
return googleOptional == null ? null : googleOptional.toJavaUtil();
}
@@ -249,8 +248,7 @@
* <p><b>Comparison to {@code java.util.Optional}:</b> this method is equivalent to Java 8's
* {@code Optional.orElse(null)}.
*/
- @CheckForNull
- public abstract T orNull();
+ public abstract @Nullable T orNull();
/**
* Returns an immutable singleton {@link Set} whose only element is the contained instance if it
@@ -298,7 +296,7 @@
* <p><b>Comparison to {@code java.util.Optional}:</b> no differences.
*/
@Override
- public abstract boolean equals(@CheckForNull Object object);
+ public abstract boolean equals(@Nullable Object object);
/**
* Returns a hash code for this instance.
@@ -343,7 +341,6 @@
checkNotNull(optionals.iterator());
@Override
- @CheckForNull
protected T computeNext() {
while (iterator.hasNext()) {
Optional<? extends T> optional = iterator.next();
diff --git a/guava/src/com/google/common/base/PairwiseEquivalence.java b/guava/src/com/google/common/base/PairwiseEquivalence.java
index 74be27f..89cb562 100644
--- a/guava/src/com/google/common/base/PairwiseEquivalence.java
+++ b/guava/src/com/google/common/base/PairwiseEquivalence.java
@@ -17,16 +17,14 @@
import com.google.common.annotations.GwtCompatible;
import java.io.Serializable;
import java.util.Iterator;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
@GwtCompatible(serializable = true)
-@ElementTypesAreNonnullByDefault
-final class PairwiseEquivalence<E, T extends @Nullable E> extends Equivalence<Iterable<T>>
- implements Serializable {
- final Equivalence<E> elementEquivalence;
+final class PairwiseEquivalence<T> extends Equivalence<Iterable<T>> implements Serializable {
- PairwiseEquivalence(Equivalence<E> elementEquivalence) {
+ final Equivalence<? super T> elementEquivalence;
+
+ PairwiseEquivalence(Equivalence<? super T> elementEquivalence) {
this.elementEquivalence = Preconditions.checkNotNull(elementEquivalence);
}
@@ -54,9 +52,9 @@
}
@Override
- public boolean equals(@CheckForNull Object object) {
+ public boolean equals(@Nullable Object object) {
if (object instanceof PairwiseEquivalence) {
- PairwiseEquivalence<?, ?> that = (PairwiseEquivalence<?, ?>) object;
+ PairwiseEquivalence<?> that = (PairwiseEquivalence<?>) object;
return this.elementEquivalence.equals(that.elementEquivalence);
}
diff --git a/guava/src/com/google/common/base/ParametricNullness.java b/guava/src/com/google/common/base/ParametricNullness.java
deleted file mode 100644
index c736055..0000000
--- a/guava/src/com/google/common/base/ParametricNullness.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2021 The Guava Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.common.base;
-
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.PARAMETER;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-import static javax.annotation.meta.When.UNKNOWN;
-
-import com.google.common.annotations.GwtCompatible;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-import javax.annotation.Nonnull;
-import javax.annotation.meta.TypeQualifierNickname;
-
-/**
- * Marks a "top-level" type-variable usage as (a) a Kotlin platform type when the type argument is
- * non-nullable and (b) nullable when the type argument is nullable. This is the closest we can get
- * to "non-nullable when non-nullable; nullable when nullable" (like the Android <a
- * href="https://android.googlesource.com/platform/libcore/+/master/luni/src/main/java/libcore/util/NullFromTypeParam.java">{@code
- * NullFromTypeParam}</a>). We use this to "undo" {@link ElementTypesAreNonnullByDefault}.
- */
-@GwtCompatible
-@Retention(RUNTIME)
-@Target({FIELD, METHOD, PARAMETER})
-@TypeQualifierNickname
-@Nonnull(when = UNKNOWN)
-@interface ParametricNullness {}
diff --git a/guava/src/com/google/common/base/PatternCompiler.java b/guava/src/com/google/common/base/PatternCompiler.java
index 72a45fa..813a25f 100644
--- a/guava/src/com/google/common/base/PatternCompiler.java
+++ b/guava/src/com/google/common/base/PatternCompiler.java
@@ -22,7 +22,6 @@
* java.util.ServiceLoader} mechanism.
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
interface PatternCompiler {
/**
* Compiles the given pattern.
diff --git a/guava/src/com/google/common/base/Platform.java b/guava/src/com/google/common/base/Platform.java
index 644e89c..54b2dfc 100644
--- a/guava/src/com/google/common/base/Platform.java
+++ b/guava/src/com/google/common/base/Platform.java
@@ -21,7 +21,7 @@
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.regex.Pattern;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Methods factored out so that they can be emulated differently in GWT.
@@ -29,7 +29,6 @@
* @author Jesse Wilson
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
final class Platform {
private static final Logger logger = Logger.getLogger(Platform.class.getName());
private static final PatternCompiler patternCompiler = loadPatternCompiler();
@@ -55,28 +54,15 @@
return String.format(Locale.ROOT, "%.4g", value);
}
- static boolean stringIsNullOrEmpty(@CheckForNull String string) {
+ static boolean stringIsNullOrEmpty(@Nullable String string) {
return string == null || string.isEmpty();
}
- /**
- * Returns the string if it is not null, or an empty string otherwise.
- *
- * @param string the string to test and possibly return
- * @return {@code string} if it is not null; {@code ""} otherwise
- */
- static String nullToEmpty(@CheckForNull String string) {
+ static String nullToEmpty(@Nullable String string) {
return (string == null) ? "" : string;
}
- /**
- * Returns the string if it is not empty, or a null string otherwise.
- *
- * @param string the string to test and possibly return
- * @return {@code string} if it is not empty; {@code null} otherwise
- */
- @CheckForNull
- static String emptyToNull(@CheckForNull String string) {
+ static String emptyToNull(@Nullable String string) {
return stringIsNullOrEmpty(string) ? null : string;
}
@@ -128,5 +114,6 @@
+ " warning because you are sending a Guava type over GWT-RPC, which will break. You"
+ " can identify which type by looking at the class name in the attached stack trace.",
new Throwable());
+
}
}
diff --git a/guava/src/com/google/common/base/Preconditions.java b/guava/src/com/google/common/base/Preconditions.java
index 13ff77b..30cc374 100644
--- a/guava/src/com/google/common/base/Preconditions.java
+++ b/guava/src/com/google/common/base/Preconditions.java
@@ -18,7 +18,7 @@
import com.google.common.annotations.GwtCompatible;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -114,12 +114,9 @@
* @since 2.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
public final class Preconditions {
private Preconditions() {}
- // TODO(cpovirk): Standardize parameter names (expression vs. b, reference vs. obj).
-
/**
* Ensures the truth of an expression involving one or more parameters to the calling method.
*
@@ -140,7 +137,7 @@
* string using {@link String#valueOf(Object)}
* @throws IllegalArgumentException if {@code expression} is false
*/
- public static void checkArgument(boolean expression, @CheckForNull Object errorMessage) {
+ public static void checkArgument(boolean expression, @Nullable Object errorMessage) {
if (!expression) {
throw new IllegalArgumentException(String.valueOf(errorMessage));
}
@@ -161,8 +158,8 @@
*/
public static void checkArgument(
boolean expression,
- String errorMessageTemplate,
- @CheckForNull @Nullable Object... errorMessageArgs) {
+ @Nullable String errorMessageTemplate,
+ @Nullable Object @Nullable ... errorMessageArgs) {
if (!expression) {
throw new IllegalArgumentException(lenientFormat(errorMessageTemplate, errorMessageArgs));
}
@@ -175,7 +172,7 @@
*
* @since 20.0 (varargs overload since 2.0)
*/
- public static void checkArgument(boolean b, String errorMessageTemplate, char p1) {
+ public static void checkArgument(boolean b, @Nullable String errorMessageTemplate, char p1) {
if (!b) {
throw new IllegalArgumentException(lenientFormat(errorMessageTemplate, p1));
}
@@ -188,7 +185,7 @@
*
* @since 20.0 (varargs overload since 2.0)
*/
- public static void checkArgument(boolean b, String errorMessageTemplate, int p1) {
+ public static void checkArgument(boolean b, @Nullable String errorMessageTemplate, int p1) {
if (!b) {
throw new IllegalArgumentException(lenientFormat(errorMessageTemplate, p1));
}
@@ -201,7 +198,7 @@
*
* @since 20.0 (varargs overload since 2.0)
*/
- public static void checkArgument(boolean b, String errorMessageTemplate, long p1) {
+ public static void checkArgument(boolean b, @Nullable String errorMessageTemplate, long p1) {
if (!b) {
throw new IllegalArgumentException(lenientFormat(errorMessageTemplate, p1));
}
@@ -215,7 +212,7 @@
* @since 20.0 (varargs overload since 2.0)
*/
public static void checkArgument(
- boolean b, String errorMessageTemplate, @CheckForNull Object p1) {
+ boolean b, @Nullable String errorMessageTemplate, @Nullable Object p1) {
if (!b) {
throw new IllegalArgumentException(lenientFormat(errorMessageTemplate, p1));
}
@@ -228,33 +225,8 @@
*
* @since 20.0 (varargs overload since 2.0)
*/
- public static void checkArgument(boolean b, String errorMessageTemplate, char p1, char p2) {
- if (!b) {
- throw new IllegalArgumentException(lenientFormat(errorMessageTemplate, p1, p2));
- }
- }
-
- /**
- * Ensures the truth of an expression involving one or more parameters to the calling method.
- *
- * <p>See {@link #checkArgument(boolean, String, Object...)} for details.
- *
- * @since 20.0 (varargs overload since 2.0)
- */
- public static void checkArgument(boolean b, String errorMessageTemplate, char p1, int p2) {
- if (!b) {
- throw new IllegalArgumentException(lenientFormat(errorMessageTemplate, p1, p2));
- }
- }
-
- /**
- * Ensures the truth of an expression involving one or more parameters to the calling method.
- *
- * <p>See {@link #checkArgument(boolean, String, Object...)} for details.
- *
- * @since 20.0 (varargs overload since 2.0)
- */
- public static void checkArgument(boolean b, String errorMessageTemplate, char p1, long p2) {
+ public static void checkArgument(
+ boolean b, @Nullable String errorMessageTemplate, char p1, char p2) {
if (!b) {
throw new IllegalArgumentException(lenientFormat(errorMessageTemplate, p1, p2));
}
@@ -268,46 +240,7 @@
* @since 20.0 (varargs overload since 2.0)
*/
public static void checkArgument(
- boolean b, String errorMessageTemplate, char p1, @CheckForNull Object p2) {
- if (!b) {
- throw new IllegalArgumentException(lenientFormat(errorMessageTemplate, p1, p2));
- }
- }
-
- /**
- * Ensures the truth of an expression involving one or more parameters to the calling method.
- *
- * <p>See {@link #checkArgument(boolean, String, Object...)} for details.
- *
- * @since 20.0 (varargs overload since 2.0)
- */
- public static void checkArgument(boolean b, String errorMessageTemplate, int p1, char p2) {
- if (!b) {
- throw new IllegalArgumentException(lenientFormat(errorMessageTemplate, p1, p2));
- }
- }
-
- /**
- * Ensures the truth of an expression involving one or more parameters to the calling method.
- *
- * <p>See {@link #checkArgument(boolean, String, Object...)} for details.
- *
- * @since 20.0 (varargs overload since 2.0)
- */
- public static void checkArgument(boolean b, String errorMessageTemplate, int p1, int p2) {
- if (!b) {
- throw new IllegalArgumentException(lenientFormat(errorMessageTemplate, p1, p2));
- }
- }
-
- /**
- * Ensures the truth of an expression involving one or more parameters to the calling method.
- *
- * <p>See {@link #checkArgument(boolean, String, Object...)} for details.
- *
- * @since 20.0 (varargs overload since 2.0)
- */
- public static void checkArgument(boolean b, String errorMessageTemplate, int p1, long p2) {
+ boolean b, @Nullable String errorMessageTemplate, char p1, int p2) {
if (!b) {
throw new IllegalArgumentException(lenientFormat(errorMessageTemplate, p1, p2));
}
@@ -321,46 +254,7 @@
* @since 20.0 (varargs overload since 2.0)
*/
public static void checkArgument(
- boolean b, String errorMessageTemplate, int p1, @CheckForNull Object p2) {
- if (!b) {
- throw new IllegalArgumentException(lenientFormat(errorMessageTemplate, p1, p2));
- }
- }
-
- /**
- * Ensures the truth of an expression involving one or more parameters to the calling method.
- *
- * <p>See {@link #checkArgument(boolean, String, Object...)} for details.
- *
- * @since 20.0 (varargs overload since 2.0)
- */
- public static void checkArgument(boolean b, String errorMessageTemplate, long p1, char p2) {
- if (!b) {
- throw new IllegalArgumentException(lenientFormat(errorMessageTemplate, p1, p2));
- }
- }
-
- /**
- * Ensures the truth of an expression involving one or more parameters to the calling method.
- *
- * <p>See {@link #checkArgument(boolean, String, Object...)} for details.
- *
- * @since 20.0 (varargs overload since 2.0)
- */
- public static void checkArgument(boolean b, String errorMessageTemplate, long p1, int p2) {
- if (!b) {
- throw new IllegalArgumentException(lenientFormat(errorMessageTemplate, p1, p2));
- }
- }
-
- /**
- * Ensures the truth of an expression involving one or more parameters to the calling method.
- *
- * <p>See {@link #checkArgument(boolean, String, Object...)} for details.
- *
- * @since 20.0 (varargs overload since 2.0)
- */
- public static void checkArgument(boolean b, String errorMessageTemplate, long p1, long p2) {
+ boolean b, @Nullable String errorMessageTemplate, char p1, long p2) {
if (!b) {
throw new IllegalArgumentException(lenientFormat(errorMessageTemplate, p1, p2));
}
@@ -374,7 +268,7 @@
* @since 20.0 (varargs overload since 2.0)
*/
public static void checkArgument(
- boolean b, String errorMessageTemplate, long p1, @CheckForNull Object p2) {
+ boolean b, @Nullable String errorMessageTemplate, char p1, @Nullable Object p2) {
if (!b) {
throw new IllegalArgumentException(lenientFormat(errorMessageTemplate, p1, p2));
}
@@ -388,7 +282,7 @@
* @since 20.0 (varargs overload since 2.0)
*/
public static void checkArgument(
- boolean b, String errorMessageTemplate, @CheckForNull Object p1, char p2) {
+ boolean b, @Nullable String errorMessageTemplate, int p1, char p2) {
if (!b) {
throw new IllegalArgumentException(lenientFormat(errorMessageTemplate, p1, p2));
}
@@ -402,7 +296,7 @@
* @since 20.0 (varargs overload since 2.0)
*/
public static void checkArgument(
- boolean b, String errorMessageTemplate, @CheckForNull Object p1, int p2) {
+ boolean b, @Nullable String errorMessageTemplate, int p1, int p2) {
if (!b) {
throw new IllegalArgumentException(lenientFormat(errorMessageTemplate, p1, p2));
}
@@ -416,7 +310,7 @@
* @since 20.0 (varargs overload since 2.0)
*/
public static void checkArgument(
- boolean b, String errorMessageTemplate, @CheckForNull Object p1, long p2) {
+ boolean b, @Nullable String errorMessageTemplate, int p1, long p2) {
if (!b) {
throw new IllegalArgumentException(lenientFormat(errorMessageTemplate, p1, p2));
}
@@ -430,7 +324,119 @@
* @since 20.0 (varargs overload since 2.0)
*/
public static void checkArgument(
- boolean b, String errorMessageTemplate, @CheckForNull Object p1, @CheckForNull Object p2) {
+ boolean b, @Nullable String errorMessageTemplate, int p1, @Nullable Object p2) {
+ if (!b) {
+ throw new IllegalArgumentException(lenientFormat(errorMessageTemplate, p1, p2));
+ }
+ }
+
+ /**
+ * Ensures the truth of an expression involving one or more parameters to the calling method.
+ *
+ * <p>See {@link #checkArgument(boolean, String, Object...)} for details.
+ *
+ * @since 20.0 (varargs overload since 2.0)
+ */
+ public static void checkArgument(
+ boolean b, @Nullable String errorMessageTemplate, long p1, char p2) {
+ if (!b) {
+ throw new IllegalArgumentException(lenientFormat(errorMessageTemplate, p1, p2));
+ }
+ }
+
+ /**
+ * Ensures the truth of an expression involving one or more parameters to the calling method.
+ *
+ * <p>See {@link #checkArgument(boolean, String, Object...)} for details.
+ *
+ * @since 20.0 (varargs overload since 2.0)
+ */
+ public static void checkArgument(
+ boolean b, @Nullable String errorMessageTemplate, long p1, int p2) {
+ if (!b) {
+ throw new IllegalArgumentException(lenientFormat(errorMessageTemplate, p1, p2));
+ }
+ }
+
+ /**
+ * Ensures the truth of an expression involving one or more parameters to the calling method.
+ *
+ * <p>See {@link #checkArgument(boolean, String, Object...)} for details.
+ *
+ * @since 20.0 (varargs overload since 2.0)
+ */
+ public static void checkArgument(
+ boolean b, @Nullable String errorMessageTemplate, long p1, long p2) {
+ if (!b) {
+ throw new IllegalArgumentException(lenientFormat(errorMessageTemplate, p1, p2));
+ }
+ }
+
+ /**
+ * Ensures the truth of an expression involving one or more parameters to the calling method.
+ *
+ * <p>See {@link #checkArgument(boolean, String, Object...)} for details.
+ *
+ * @since 20.0 (varargs overload since 2.0)
+ */
+ public static void checkArgument(
+ boolean b, @Nullable String errorMessageTemplate, long p1, @Nullable Object p2) {
+ if (!b) {
+ throw new IllegalArgumentException(lenientFormat(errorMessageTemplate, p1, p2));
+ }
+ }
+
+ /**
+ * Ensures the truth of an expression involving one or more parameters to the calling method.
+ *
+ * <p>See {@link #checkArgument(boolean, String, Object...)} for details.
+ *
+ * @since 20.0 (varargs overload since 2.0)
+ */
+ public static void checkArgument(
+ boolean b, @Nullable String errorMessageTemplate, @Nullable Object p1, char p2) {
+ if (!b) {
+ throw new IllegalArgumentException(lenientFormat(errorMessageTemplate, p1, p2));
+ }
+ }
+
+ /**
+ * Ensures the truth of an expression involving one or more parameters to the calling method.
+ *
+ * <p>See {@link #checkArgument(boolean, String, Object...)} for details.
+ *
+ * @since 20.0 (varargs overload since 2.0)
+ */
+ public static void checkArgument(
+ boolean b, @Nullable String errorMessageTemplate, @Nullable Object p1, int p2) {
+ if (!b) {
+ throw new IllegalArgumentException(lenientFormat(errorMessageTemplate, p1, p2));
+ }
+ }
+
+ /**
+ * Ensures the truth of an expression involving one or more parameters to the calling method.
+ *
+ * <p>See {@link #checkArgument(boolean, String, Object...)} for details.
+ *
+ * @since 20.0 (varargs overload since 2.0)
+ */
+ public static void checkArgument(
+ boolean b, @Nullable String errorMessageTemplate, @Nullable Object p1, long p2) {
+ if (!b) {
+ throw new IllegalArgumentException(lenientFormat(errorMessageTemplate, p1, p2));
+ }
+ }
+
+ /**
+ * Ensures the truth of an expression involving one or more parameters to the calling method.
+ *
+ * <p>See {@link #checkArgument(boolean, String, Object...)} for details.
+ *
+ * @since 20.0 (varargs overload since 2.0)
+ */
+ public static void checkArgument(
+ boolean b, @Nullable String errorMessageTemplate, @Nullable Object p1, @Nullable Object p2) {
if (!b) {
throw new IllegalArgumentException(lenientFormat(errorMessageTemplate, p1, p2));
}
@@ -445,10 +451,10 @@
*/
public static void checkArgument(
boolean b,
- String errorMessageTemplate,
- @CheckForNull Object p1,
- @CheckForNull Object p2,
- @CheckForNull Object p3) {
+ @Nullable String errorMessageTemplate,
+ @Nullable Object p1,
+ @Nullable Object p2,
+ @Nullable Object p3) {
if (!b) {
throw new IllegalArgumentException(lenientFormat(errorMessageTemplate, p1, p2, p3));
}
@@ -463,11 +469,11 @@
*/
public static void checkArgument(
boolean b,
- String errorMessageTemplate,
- @CheckForNull Object p1,
- @CheckForNull Object p2,
- @CheckForNull Object p3,
- @CheckForNull Object p4) {
+ @Nullable String errorMessageTemplate,
+ @Nullable Object p1,
+ @Nullable Object p2,
+ @Nullable Object p3,
+ @Nullable Object p4) {
if (!b) {
throw new IllegalArgumentException(lenientFormat(errorMessageTemplate, p1, p2, p3, p4));
}
@@ -497,7 +503,7 @@
* @throws IllegalStateException if {@code expression} is false
* @see Verify#verify Verify.verify()
*/
- public static void checkState(boolean expression, @CheckForNull Object errorMessage) {
+ public static void checkState(boolean expression, @Nullable Object errorMessage) {
if (!expression) {
throw new IllegalStateException(String.valueOf(errorMessage));
}
@@ -520,16 +526,8 @@
*/
public static void checkState(
boolean expression,
- /*
- * TODO(cpovirk): Consider removing @CheckForNull here, as we've done with the other methods'
- * errorMessageTemplate parameters: It it unlikely that callers intend for their string
- * template to be null (though we do handle that case gracefully at runtime). I've left this
- * one as it is because one of our users has defined a wrapper API around Preconditions,
- * declaring a checkState method that accepts a possibly null template. So we'd need to update
- * that user first.
- */
- @CheckForNull String errorMessageTemplate,
- @CheckForNull @Nullable Object... errorMessageArgs) {
+ @Nullable String errorMessageTemplate,
+ @Nullable Object @Nullable ... errorMessageArgs) {
if (!expression) {
throw new IllegalStateException(lenientFormat(errorMessageTemplate, errorMessageArgs));
}
@@ -543,7 +541,7 @@
*
* @since 20.0 (varargs overload since 2.0)
*/
- public static void checkState(boolean b, String errorMessageTemplate, char p1) {
+ public static void checkState(boolean b, @Nullable String errorMessageTemplate, char p1) {
if (!b) {
throw new IllegalStateException(lenientFormat(errorMessageTemplate, p1));
}
@@ -557,7 +555,7 @@
*
* @since 20.0 (varargs overload since 2.0)
*/
- public static void checkState(boolean b, String errorMessageTemplate, int p1) {
+ public static void checkState(boolean b, @Nullable String errorMessageTemplate, int p1) {
if (!b) {
throw new IllegalStateException(lenientFormat(errorMessageTemplate, p1));
}
@@ -571,7 +569,7 @@
*
* @since 20.0 (varargs overload since 2.0)
*/
- public static void checkState(boolean b, String errorMessageTemplate, long p1) {
+ public static void checkState(boolean b, @Nullable String errorMessageTemplate, long p1) {
if (!b) {
throw new IllegalStateException(lenientFormat(errorMessageTemplate, p1));
}
@@ -585,7 +583,8 @@
*
* @since 20.0 (varargs overload since 2.0)
*/
- public static void checkState(boolean b, String errorMessageTemplate, @CheckForNull Object p1) {
+ public static void checkState(
+ boolean b, @Nullable String errorMessageTemplate, @Nullable Object p1) {
if (!b) {
throw new IllegalStateException(lenientFormat(errorMessageTemplate, p1));
}
@@ -599,7 +598,8 @@
*
* @since 20.0 (varargs overload since 2.0)
*/
- public static void checkState(boolean b, String errorMessageTemplate, char p1, char p2) {
+ public static void checkState(
+ boolean b, @Nullable String errorMessageTemplate, char p1, char p2) {
if (!b) {
throw new IllegalStateException(lenientFormat(errorMessageTemplate, p1, p2));
}
@@ -613,21 +613,7 @@
*
* @since 20.0 (varargs overload since 2.0)
*/
- public static void checkState(boolean b, String errorMessageTemplate, char p1, int p2) {
- if (!b) {
- throw new IllegalStateException(lenientFormat(errorMessageTemplate, p1, p2));
- }
- }
-
- /**
- * Ensures the truth of an expression involving the state of the calling instance, but not
- * involving any parameters to the calling method.
- *
- * <p>See {@link #checkState(boolean, String, Object...)} for details.
- *
- * @since 20.0 (varargs overload since 2.0)
- */
- public static void checkState(boolean b, String errorMessageTemplate, char p1, long p2) {
+ public static void checkState(boolean b, @Nullable String errorMessageTemplate, char p1, int p2) {
if (!b) {
throw new IllegalStateException(lenientFormat(errorMessageTemplate, p1, p2));
}
@@ -642,49 +628,7 @@
* @since 20.0 (varargs overload since 2.0)
*/
public static void checkState(
- boolean b, String errorMessageTemplate, char p1, @CheckForNull Object p2) {
- if (!b) {
- throw new IllegalStateException(lenientFormat(errorMessageTemplate, p1, p2));
- }
- }
-
- /**
- * Ensures the truth of an expression involving the state of the calling instance, but not
- * involving any parameters to the calling method.
- *
- * <p>See {@link #checkState(boolean, String, Object...)} for details.
- *
- * @since 20.0 (varargs overload since 2.0)
- */
- public static void checkState(boolean b, String errorMessageTemplate, int p1, char p2) {
- if (!b) {
- throw new IllegalStateException(lenientFormat(errorMessageTemplate, p1, p2));
- }
- }
-
- /**
- * Ensures the truth of an expression involving the state of the calling instance, but not
- * involving any parameters to the calling method.
- *
- * <p>See {@link #checkState(boolean, String, Object...)} for details.
- *
- * @since 20.0 (varargs overload since 2.0)
- */
- public static void checkState(boolean b, String errorMessageTemplate, int p1, int p2) {
- if (!b) {
- throw new IllegalStateException(lenientFormat(errorMessageTemplate, p1, p2));
- }
- }
-
- /**
- * Ensures the truth of an expression involving the state of the calling instance, but not
- * involving any parameters to the calling method.
- *
- * <p>See {@link #checkState(boolean, String, Object...)} for details.
- *
- * @since 20.0 (varargs overload since 2.0)
- */
- public static void checkState(boolean b, String errorMessageTemplate, int p1, long p2) {
+ boolean b, @Nullable String errorMessageTemplate, char p1, long p2) {
if (!b) {
throw new IllegalStateException(lenientFormat(errorMessageTemplate, p1, p2));
}
@@ -699,7 +643,7 @@
* @since 20.0 (varargs overload since 2.0)
*/
public static void checkState(
- boolean b, String errorMessageTemplate, int p1, @CheckForNull Object p2) {
+ boolean b, @Nullable String errorMessageTemplate, char p1, @Nullable Object p2) {
if (!b) {
throw new IllegalStateException(lenientFormat(errorMessageTemplate, p1, p2));
}
@@ -713,7 +657,7 @@
*
* @since 20.0 (varargs overload since 2.0)
*/
- public static void checkState(boolean b, String errorMessageTemplate, long p1, char p2) {
+ public static void checkState(boolean b, @Nullable String errorMessageTemplate, int p1, char p2) {
if (!b) {
throw new IllegalStateException(lenientFormat(errorMessageTemplate, p1, p2));
}
@@ -727,7 +671,7 @@
*
* @since 20.0 (varargs overload since 2.0)
*/
- public static void checkState(boolean b, String errorMessageTemplate, long p1, int p2) {
+ public static void checkState(boolean b, @Nullable String errorMessageTemplate, int p1, int p2) {
if (!b) {
throw new IllegalStateException(lenientFormat(errorMessageTemplate, p1, p2));
}
@@ -741,7 +685,7 @@
*
* @since 20.0 (varargs overload since 2.0)
*/
- public static void checkState(boolean b, String errorMessageTemplate, long p1, long p2) {
+ public static void checkState(boolean b, @Nullable String errorMessageTemplate, int p1, long p2) {
if (!b) {
throw new IllegalStateException(lenientFormat(errorMessageTemplate, p1, p2));
}
@@ -756,7 +700,7 @@
* @since 20.0 (varargs overload since 2.0)
*/
public static void checkState(
- boolean b, String errorMessageTemplate, long p1, @CheckForNull Object p2) {
+ boolean b, @Nullable String errorMessageTemplate, int p1, @Nullable Object p2) {
if (!b) {
throw new IllegalStateException(lenientFormat(errorMessageTemplate, p1, p2));
}
@@ -771,7 +715,21 @@
* @since 20.0 (varargs overload since 2.0)
*/
public static void checkState(
- boolean b, String errorMessageTemplate, @CheckForNull Object p1, char p2) {
+ boolean b, @Nullable String errorMessageTemplate, long p1, char p2) {
+ if (!b) {
+ throw new IllegalStateException(lenientFormat(errorMessageTemplate, p1, p2));
+ }
+ }
+
+ /**
+ * Ensures the truth of an expression involving the state of the calling instance, but not
+ * involving any parameters to the calling method.
+ *
+ * <p>See {@link #checkState(boolean, String, Object...)} for details.
+ *
+ * @since 20.0 (varargs overload since 2.0)
+ */
+ public static void checkState(boolean b, @Nullable String errorMessageTemplate, long p1, int p2) {
if (!b) {
throw new IllegalStateException(lenientFormat(errorMessageTemplate, p1, p2));
}
@@ -786,7 +744,7 @@
* @since 20.0 (varargs overload since 2.0)
*/
public static void checkState(
- boolean b, String errorMessageTemplate, @CheckForNull Object p1, int p2) {
+ boolean b, @Nullable String errorMessageTemplate, long p1, long p2) {
if (!b) {
throw new IllegalStateException(lenientFormat(errorMessageTemplate, p1, p2));
}
@@ -801,7 +759,7 @@
* @since 20.0 (varargs overload since 2.0)
*/
public static void checkState(
- boolean b, String errorMessageTemplate, @CheckForNull Object p1, long p2) {
+ boolean b, @Nullable String errorMessageTemplate, long p1, @Nullable Object p2) {
if (!b) {
throw new IllegalStateException(lenientFormat(errorMessageTemplate, p1, p2));
}
@@ -816,7 +774,52 @@
* @since 20.0 (varargs overload since 2.0)
*/
public static void checkState(
- boolean b, String errorMessageTemplate, @CheckForNull Object p1, @CheckForNull Object p2) {
+ boolean b, @Nullable String errorMessageTemplate, @Nullable Object p1, char p2) {
+ if (!b) {
+ throw new IllegalStateException(lenientFormat(errorMessageTemplate, p1, p2));
+ }
+ }
+
+ /**
+ * Ensures the truth of an expression involving the state of the calling instance, but not
+ * involving any parameters to the calling method.
+ *
+ * <p>See {@link #checkState(boolean, String, Object...)} for details.
+ *
+ * @since 20.0 (varargs overload since 2.0)
+ */
+ public static void checkState(
+ boolean b, @Nullable String errorMessageTemplate, @Nullable Object p1, int p2) {
+ if (!b) {
+ throw new IllegalStateException(lenientFormat(errorMessageTemplate, p1, p2));
+ }
+ }
+
+ /**
+ * Ensures the truth of an expression involving the state of the calling instance, but not
+ * involving any parameters to the calling method.
+ *
+ * <p>See {@link #checkState(boolean, String, Object...)} for details.
+ *
+ * @since 20.0 (varargs overload since 2.0)
+ */
+ public static void checkState(
+ boolean b, @Nullable String errorMessageTemplate, @Nullable Object p1, long p2) {
+ if (!b) {
+ throw new IllegalStateException(lenientFormat(errorMessageTemplate, p1, p2));
+ }
+ }
+
+ /**
+ * Ensures the truth of an expression involving the state of the calling instance, but not
+ * involving any parameters to the calling method.
+ *
+ * <p>See {@link #checkState(boolean, String, Object...)} for details.
+ *
+ * @since 20.0 (varargs overload since 2.0)
+ */
+ public static void checkState(
+ boolean b, @Nullable String errorMessageTemplate, @Nullable Object p1, @Nullable Object p2) {
if (!b) {
throw new IllegalStateException(lenientFormat(errorMessageTemplate, p1, p2));
}
@@ -832,10 +835,10 @@
*/
public static void checkState(
boolean b,
- String errorMessageTemplate,
- @CheckForNull Object p1,
- @CheckForNull Object p2,
- @CheckForNull Object p3) {
+ @Nullable String errorMessageTemplate,
+ @Nullable Object p1,
+ @Nullable Object p2,
+ @Nullable Object p3) {
if (!b) {
throw new IllegalStateException(lenientFormat(errorMessageTemplate, p1, p2, p3));
}
@@ -851,30 +854,16 @@
*/
public static void checkState(
boolean b,
- String errorMessageTemplate,
- @CheckForNull Object p1,
- @CheckForNull Object p2,
- @CheckForNull Object p3,
- @CheckForNull Object p4) {
+ @Nullable String errorMessageTemplate,
+ @Nullable Object p1,
+ @Nullable Object p2,
+ @Nullable Object p3,
+ @Nullable Object p4) {
if (!b) {
throw new IllegalStateException(lenientFormat(errorMessageTemplate, p1, p2, p3, p4));
}
}
- /*
- * Preconditions.checkNotNull is *intended* for performing eager null checks on parameters that a
- * nullness checker can already "prove" are non-null. That means that the first parameter to
- * checkNotNull *should* be annotated to require it to be non-null.
- *
- * However, for a variety of reasons, Google developers have written a ton of code over the past
- * decade that assumes that they can use checkNotNull for non-precondition checks. I had hoped to
- * take a principled stand on this, but the amount of such code is simply overwhelming. To avoid
- * creating a lot of compile errors that users would not find to be informative, we're giving in
- * and allowing callers to pass arguments that a nullness checker believes could be null.
- *
- * We still encourage people to use requireNonNull over checkNotNull for non-precondition checks.
- */
-
/**
* Ensures that an object reference passed as a parameter to the calling method is not null.
*
@@ -884,7 +873,7 @@
* @see Verify#verifyNotNull Verify.verifyNotNull()
*/
@CanIgnoreReturnValue
- public static <T> T checkNotNull(@CheckForNull T reference) {
+ public static <T extends @NonNull Object> T checkNotNull(T reference) {
if (reference == null) {
throw new NullPointerException();
}
@@ -902,7 +891,8 @@
* @see Verify#verifyNotNull Verify.verifyNotNull()
*/
@CanIgnoreReturnValue
- public static <T> T checkNotNull(@CheckForNull T reference, @CheckForNull Object errorMessage) {
+ public static <T extends @NonNull Object> T checkNotNull(
+ T reference, @Nullable Object errorMessage) {
if (reference == null) {
throw new NullPointerException(String.valueOf(errorMessage));
}
@@ -925,10 +915,10 @@
* @see Verify#verifyNotNull Verify.verifyNotNull()
*/
@CanIgnoreReturnValue
- public static <T> T checkNotNull(
- @CheckForNull T reference,
- String errorMessageTemplate,
- @CheckForNull @Nullable Object... errorMessageArgs) {
+ public static <T extends @NonNull Object> T checkNotNull(
+ T reference,
+ @Nullable String errorMessageTemplate,
+ @Nullable Object @Nullable ... errorMessageArgs) {
if (reference == null) {
throw new NullPointerException(lenientFormat(errorMessageTemplate, errorMessageArgs));
}
@@ -943,7 +933,8 @@
* @since 20.0 (varargs overload since 2.0)
*/
@CanIgnoreReturnValue
- public static <T> T checkNotNull(@CheckForNull T obj, String errorMessageTemplate, char p1) {
+ public static <T extends @NonNull Object> T checkNotNull(
+ T obj, @Nullable String errorMessageTemplate, char p1) {
if (obj == null) {
throw new NullPointerException(lenientFormat(errorMessageTemplate, p1));
}
@@ -958,7 +949,8 @@
* @since 20.0 (varargs overload since 2.0)
*/
@CanIgnoreReturnValue
- public static <T> T checkNotNull(@CheckForNull T obj, String errorMessageTemplate, int p1) {
+ public static <T extends @NonNull Object> T checkNotNull(
+ T obj, @Nullable String errorMessageTemplate, int p1) {
if (obj == null) {
throw new NullPointerException(lenientFormat(errorMessageTemplate, p1));
}
@@ -973,7 +965,8 @@
* @since 20.0 (varargs overload since 2.0)
*/
@CanIgnoreReturnValue
- public static <T> T checkNotNull(@CheckForNull T obj, String errorMessageTemplate, long p1) {
+ public static <T extends @NonNull Object> T checkNotNull(
+ T obj, @Nullable String errorMessageTemplate, long p1) {
if (obj == null) {
throw new NullPointerException(lenientFormat(errorMessageTemplate, p1));
}
@@ -988,8 +981,8 @@
* @since 20.0 (varargs overload since 2.0)
*/
@CanIgnoreReturnValue
- public static <T> T checkNotNull(
- @CheckForNull T obj, String errorMessageTemplate, @CheckForNull Object p1) {
+ public static <T extends @NonNull Object> T checkNotNull(
+ T obj, @Nullable String errorMessageTemplate, @Nullable Object p1) {
if (obj == null) {
throw new NullPointerException(lenientFormat(errorMessageTemplate, p1));
}
@@ -1004,8 +997,8 @@
* @since 20.0 (varargs overload since 2.0)
*/
@CanIgnoreReturnValue
- public static <T> T checkNotNull(
- @CheckForNull T obj, String errorMessageTemplate, char p1, char p2) {
+ public static <T extends @NonNull Object> T checkNotNull(
+ T obj, @Nullable String errorMessageTemplate, char p1, char p2) {
if (obj == null) {
throw new NullPointerException(lenientFormat(errorMessageTemplate, p1, p2));
}
@@ -1020,8 +1013,8 @@
* @since 20.0 (varargs overload since 2.0)
*/
@CanIgnoreReturnValue
- public static <T> T checkNotNull(
- @CheckForNull T obj, String errorMessageTemplate, char p1, int p2) {
+ public static <T extends @NonNull Object> T checkNotNull(
+ T obj, @Nullable String errorMessageTemplate, char p1, int p2) {
if (obj == null) {
throw new NullPointerException(lenientFormat(errorMessageTemplate, p1, p2));
}
@@ -1036,8 +1029,8 @@
* @since 20.0 (varargs overload since 2.0)
*/
@CanIgnoreReturnValue
- public static <T> T checkNotNull(
- @CheckForNull T obj, String errorMessageTemplate, char p1, long p2) {
+ public static <T extends @NonNull Object> T checkNotNull(
+ T obj, @Nullable String errorMessageTemplate, char p1, long p2) {
if (obj == null) {
throw new NullPointerException(lenientFormat(errorMessageTemplate, p1, p2));
}
@@ -1052,8 +1045,8 @@
* @since 20.0 (varargs overload since 2.0)
*/
@CanIgnoreReturnValue
- public static <T> T checkNotNull(
- @CheckForNull T obj, String errorMessageTemplate, char p1, @CheckForNull Object p2) {
+ public static <T extends @NonNull Object> T checkNotNull(
+ T obj, @Nullable String errorMessageTemplate, char p1, @Nullable Object p2) {
if (obj == null) {
throw new NullPointerException(lenientFormat(errorMessageTemplate, p1, p2));
}
@@ -1068,8 +1061,8 @@
* @since 20.0 (varargs overload since 2.0)
*/
@CanIgnoreReturnValue
- public static <T> T checkNotNull(
- @CheckForNull T obj, String errorMessageTemplate, int p1, char p2) {
+ public static <T extends @NonNull Object> T checkNotNull(
+ T obj, @Nullable String errorMessageTemplate, int p1, char p2) {
if (obj == null) {
throw new NullPointerException(lenientFormat(errorMessageTemplate, p1, p2));
}
@@ -1084,8 +1077,8 @@
* @since 20.0 (varargs overload since 2.0)
*/
@CanIgnoreReturnValue
- public static <T> T checkNotNull(
- @CheckForNull T obj, String errorMessageTemplate, int p1, int p2) {
+ public static <T extends @NonNull Object> T checkNotNull(
+ T obj, @Nullable String errorMessageTemplate, int p1, int p2) {
if (obj == null) {
throw new NullPointerException(lenientFormat(errorMessageTemplate, p1, p2));
}
@@ -1100,8 +1093,8 @@
* @since 20.0 (varargs overload since 2.0)
*/
@CanIgnoreReturnValue
- public static <T> T checkNotNull(
- @CheckForNull T obj, String errorMessageTemplate, int p1, long p2) {
+ public static <T extends @NonNull Object> T checkNotNull(
+ T obj, @Nullable String errorMessageTemplate, int p1, long p2) {
if (obj == null) {
throw new NullPointerException(lenientFormat(errorMessageTemplate, p1, p2));
}
@@ -1116,8 +1109,8 @@
* @since 20.0 (varargs overload since 2.0)
*/
@CanIgnoreReturnValue
- public static <T> T checkNotNull(
- @CheckForNull T obj, String errorMessageTemplate, int p1, @CheckForNull Object p2) {
+ public static <T extends @NonNull Object> T checkNotNull(
+ T obj, @Nullable String errorMessageTemplate, int p1, @Nullable Object p2) {
if (obj == null) {
throw new NullPointerException(lenientFormat(errorMessageTemplate, p1, p2));
}
@@ -1132,8 +1125,8 @@
* @since 20.0 (varargs overload since 2.0)
*/
@CanIgnoreReturnValue
- public static <T> T checkNotNull(
- @CheckForNull T obj, String errorMessageTemplate, long p1, char p2) {
+ public static <T extends @NonNull Object> T checkNotNull(
+ T obj, @Nullable String errorMessageTemplate, long p1, char p2) {
if (obj == null) {
throw new NullPointerException(lenientFormat(errorMessageTemplate, p1, p2));
}
@@ -1148,8 +1141,8 @@
* @since 20.0 (varargs overload since 2.0)
*/
@CanIgnoreReturnValue
- public static <T> T checkNotNull(
- @CheckForNull T obj, String errorMessageTemplate, long p1, int p2) {
+ public static <T extends @NonNull Object> T checkNotNull(
+ T obj, @Nullable String errorMessageTemplate, long p1, int p2) {
if (obj == null) {
throw new NullPointerException(lenientFormat(errorMessageTemplate, p1, p2));
}
@@ -1164,8 +1157,8 @@
* @since 20.0 (varargs overload since 2.0)
*/
@CanIgnoreReturnValue
- public static <T> T checkNotNull(
- @CheckForNull T obj, String errorMessageTemplate, long p1, long p2) {
+ public static <T extends @NonNull Object> T checkNotNull(
+ T obj, @Nullable String errorMessageTemplate, long p1, long p2) {
if (obj == null) {
throw new NullPointerException(lenientFormat(errorMessageTemplate, p1, p2));
}
@@ -1180,8 +1173,8 @@
* @since 20.0 (varargs overload since 2.0)
*/
@CanIgnoreReturnValue
- public static <T> T checkNotNull(
- @CheckForNull T obj, String errorMessageTemplate, long p1, @CheckForNull Object p2) {
+ public static <T extends @NonNull Object> T checkNotNull(
+ T obj, @Nullable String errorMessageTemplate, long p1, @Nullable Object p2) {
if (obj == null) {
throw new NullPointerException(lenientFormat(errorMessageTemplate, p1, p2));
}
@@ -1196,8 +1189,8 @@
* @since 20.0 (varargs overload since 2.0)
*/
@CanIgnoreReturnValue
- public static <T> T checkNotNull(
- @CheckForNull T obj, String errorMessageTemplate, @CheckForNull Object p1, char p2) {
+ public static <T extends @NonNull Object> T checkNotNull(
+ T obj, @Nullable String errorMessageTemplate, @Nullable Object p1, char p2) {
if (obj == null) {
throw new NullPointerException(lenientFormat(errorMessageTemplate, p1, p2));
}
@@ -1212,8 +1205,8 @@
* @since 20.0 (varargs overload since 2.0)
*/
@CanIgnoreReturnValue
- public static <T> T checkNotNull(
- @CheckForNull T obj, String errorMessageTemplate, @CheckForNull Object p1, int p2) {
+ public static <T extends @NonNull Object> T checkNotNull(
+ T obj, @Nullable String errorMessageTemplate, @Nullable Object p1, int p2) {
if (obj == null) {
throw new NullPointerException(lenientFormat(errorMessageTemplate, p1, p2));
}
@@ -1228,8 +1221,8 @@
* @since 20.0 (varargs overload since 2.0)
*/
@CanIgnoreReturnValue
- public static <T> T checkNotNull(
- @CheckForNull T obj, String errorMessageTemplate, @CheckForNull Object p1, long p2) {
+ public static <T extends @NonNull Object> T checkNotNull(
+ T obj, @Nullable String errorMessageTemplate, @Nullable Object p1, long p2) {
if (obj == null) {
throw new NullPointerException(lenientFormat(errorMessageTemplate, p1, p2));
}
@@ -1244,11 +1237,8 @@
* @since 20.0 (varargs overload since 2.0)
*/
@CanIgnoreReturnValue
- public static <T> T checkNotNull(
- @CheckForNull T obj,
- String errorMessageTemplate,
- @CheckForNull Object p1,
- @CheckForNull Object p2) {
+ public static <T extends @NonNull Object> T checkNotNull(
+ T obj, @Nullable String errorMessageTemplate, @Nullable Object p1, @Nullable Object p2) {
if (obj == null) {
throw new NullPointerException(lenientFormat(errorMessageTemplate, p1, p2));
}
@@ -1263,12 +1253,12 @@
* @since 20.0 (varargs overload since 2.0)
*/
@CanIgnoreReturnValue
- public static <T> T checkNotNull(
- @CheckForNull T obj,
- String errorMessageTemplate,
- @CheckForNull Object p1,
- @CheckForNull Object p2,
- @CheckForNull Object p3) {
+ public static <T extends @NonNull Object> T checkNotNull(
+ T obj,
+ @Nullable String errorMessageTemplate,
+ @Nullable Object p1,
+ @Nullable Object p2,
+ @Nullable Object p3) {
if (obj == null) {
throw new NullPointerException(lenientFormat(errorMessageTemplate, p1, p2, p3));
}
@@ -1283,13 +1273,13 @@
* @since 20.0 (varargs overload since 2.0)
*/
@CanIgnoreReturnValue
- public static <T> T checkNotNull(
- @CheckForNull T obj,
- String errorMessageTemplate,
- @CheckForNull Object p1,
- @CheckForNull Object p2,
- @CheckForNull Object p3,
- @CheckForNull Object p4) {
+ public static <T extends @NonNull Object> T checkNotNull(
+ T obj,
+ @Nullable String errorMessageTemplate,
+ @Nullable Object p1,
+ @Nullable Object p2,
+ @Nullable Object p3,
+ @Nullable Object p4) {
if (obj == null) {
throw new NullPointerException(lenientFormat(errorMessageTemplate, p1, p2, p3, p4));
}
@@ -1349,7 +1339,7 @@
* @throws IllegalArgumentException if {@code size} is negative
*/
@CanIgnoreReturnValue
- public static int checkElementIndex(int index, int size, 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));
@@ -1357,7 +1347,7 @@
return index;
}
- private static String badElementIndex(int index, int size, String desc) {
+ private static String badElementIndex(int index, int size, @Nullable String desc) {
if (index < 0) {
return lenientFormat("%s (%s) must not be negative", desc, index);
} else if (size < 0) {
@@ -1394,7 +1384,7 @@
* @throws IllegalArgumentException if {@code size} is negative
*/
@CanIgnoreReturnValue
- public static int checkPositionIndex(int index, int size, 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));
@@ -1402,7 +1392,7 @@
return index;
}
- private static String badPositionIndex(int index, int size, String desc) {
+ private static String badPositionIndex(int index, int size, @Nullable String desc) {
if (index < 0) {
return lenientFormat("%s (%s) must not be negative", desc, index);
} else if (size < 0) {
diff --git a/guava/src/com/google/common/base/Predicate.java b/guava/src/com/google/common/base/Predicate.java
index 4384ed0..a116cec 100644
--- a/guava/src/com/google/common/base/Predicate.java
+++ b/guava/src/com/google/common/base/Predicate.java
@@ -16,7 +16,6 @@
import com.google.common.annotations.GwtCompatible;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -43,8 +42,7 @@
*/
@FunctionalInterface
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-public interface Predicate<T extends @Nullable Object> extends java.util.function.Predicate<T> {
+public interface Predicate<T> extends java.util.function.Predicate<T> {
/**
* Returns the result of applying this predicate to {@code input} (Java 8 users, see notes in the
* class documentation above). This method is <i>generally expected</i>, but not absolutely
@@ -61,7 +59,7 @@
* arguments
*/
@CanIgnoreReturnValue
- boolean apply(@ParametricNullness T input);
+ boolean apply(@Nullable T input);
/**
* Indicates whether another object is equal to this predicate.
@@ -74,10 +72,10 @@
* predicates are known <i>not</i> to be interchangeable.
*/
@Override
- boolean equals(@CheckForNull Object object);
+ boolean equals(@Nullable Object object);
@Override
- default boolean test(@ParametricNullness 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 c3b5562..033ab6c 100644
--- a/guava/src/com/google/common/base/Predicates.java
+++ b/guava/src/com/google/common/base/Predicates.java
@@ -25,7 +25,6 @@
import java.util.Collection;
import java.util.List;
import java.util.regex.Pattern;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -40,7 +39,6 @@
* @since 2.0
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
public final class Predicates {
private Predicates() {}
@@ -49,13 +47,13 @@
/** Returns a predicate that always evaluates to {@code true}. */
@GwtCompatible(serializable = true)
- public static <T extends @Nullable Object> Predicate<T> alwaysTrue() {
+ public static <T> Predicate<T> alwaysTrue() {
return ObjectPredicate.ALWAYS_TRUE.withNarrowedType();
}
/** Returns a predicate that always evaluates to {@code false}. */
@GwtCompatible(serializable = true)
- public static <T extends @Nullable Object> Predicate<T> alwaysFalse() {
+ public static <T> Predicate<T> alwaysFalse() {
return ObjectPredicate.ALWAYS_FALSE.withNarrowedType();
}
@@ -64,7 +62,7 @@
* null.
*/
@GwtCompatible(serializable = true)
- public static <T extends @Nullable Object> Predicate<T> isNull() {
+ public static <T> Predicate<T> isNull() {
return ObjectPredicate.IS_NULL.withNarrowedType();
}
@@ -73,7 +71,7 @@
* null.
*/
@GwtCompatible(serializable = true)
- public static <T extends @Nullable Object> Predicate<T> notNull() {
+ public static <T> Predicate<T> notNull() {
return ObjectPredicate.NOT_NULL.withNarrowedType();
}
@@ -81,7 +79,7 @@
* Returns a predicate that evaluates to {@code true} if the given predicate evaluates to {@code
* false}.
*/
- public static <T extends @Nullable Object> Predicate<T> not(Predicate<T> predicate) {
+ public static <T> Predicate<T> not(Predicate<T> predicate) {
return new NotPredicate<T>(predicate);
}
@@ -92,8 +90,7 @@
* changes to it won't alter the behavior of this predicate. If {@code components} is empty, the
* returned predicate will always evaluate to {@code true}.
*/
- public static <T extends @Nullable Object> Predicate<T> and(
- Iterable<? extends Predicate<? super T>> components) {
+ public static <T> Predicate<T> and(Iterable<? extends Predicate<? super T>> components) {
return new AndPredicate<T>(defensiveCopy(components));
}
@@ -105,7 +102,7 @@
* returned predicate will always evaluate to {@code true}.
*/
@SafeVarargs
- public static <T extends @Nullable Object> Predicate<T> and(Predicate<? super T>... components) {
+ public static <T> Predicate<T> and(Predicate<? super T>... components) {
return new AndPredicate<T>(defensiveCopy(components));
}
@@ -114,8 +111,7 @@
* true}. The components are evaluated in order, and evaluation will be "short-circuited" as soon
* as a false predicate is found.
*/
- public static <T extends @Nullable Object> Predicate<T> and(
- Predicate<? super T> first, Predicate<? super T> second) {
+ public static <T> Predicate<T> and(Predicate<? super T> first, Predicate<? super T> second) {
return new AndPredicate<T>(Predicates.<T>asList(checkNotNull(first), checkNotNull(second)));
}
@@ -126,8 +122,7 @@
* changes to it won't alter the behavior of this predicate. If {@code components} is empty, the
* returned predicate will always evaluate to {@code false}.
*/
- public static <T extends @Nullable Object> Predicate<T> or(
- Iterable<? extends Predicate<? super T>> components) {
+ public static <T> Predicate<T> or(Iterable<? extends Predicate<? super T>> components) {
return new OrPredicate<T>(defensiveCopy(components));
}
@@ -139,7 +134,7 @@
* returned predicate will always evaluate to {@code false}.
*/
@SafeVarargs
- public static <T extends @Nullable Object> Predicate<T> or(Predicate<? super T>... components) {
+ public static <T> Predicate<T> or(Predicate<? super T>... components) {
return new OrPredicate<T>(defensiveCopy(components));
}
@@ -148,8 +143,7 @@
* {@code true}. The components are evaluated in order, and evaluation will be "short-circuited"
* as soon as a true predicate is found.
*/
- public static <T extends @Nullable Object> Predicate<T> or(
- Predicate<? super T> first, Predicate<? super T> second) {
+ public static <T> Predicate<T> or(Predicate<? super T> first, Predicate<? super T> second) {
return new OrPredicate<T>(Predicates.<T>asList(checkNotNull(first), checkNotNull(second)));
}
@@ -157,10 +151,8 @@
* Returns a predicate that evaluates to {@code true} if the object being tested {@code equals()}
* the given target or both are null.
*/
- public static <T extends @Nullable Object> Predicate<T> equalTo(@ParametricNullness T target) {
- return (target == null)
- ? Predicates.<T>isNull()
- : new IsEqualToPredicate(target).withNarrowedType();
+ public static <T> Predicate<T> equalTo(@Nullable T target) {
+ return (target == null) ? Predicates.<T>isNull() : new IsEqualToPredicate<T>(target);
}
/**
@@ -177,8 +169,8 @@
* instances {@code Lists.newArrayList(1)} and {@code Arrays.asList(1)}.
*/
@GwtIncompatible // Class.isInstance
- public static <T extends @Nullable Object> Predicate<T> instanceOf(Class<?> clazz) {
- return new InstanceOfPredicate<>(clazz);
+ public static Predicate<Object> instanceOf(Class<?> clazz) {
+ return new InstanceOfPredicate(clazz);
}
/**
@@ -212,7 +204,7 @@
*
* @param target the collection that may contain the function input
*/
- public static <T extends @Nullable Object> Predicate<T> in(Collection<? extends T> target) {
+ public static <T> Predicate<T> in(Collection<? extends T> target) {
return new InPredicate<T>(target);
}
@@ -222,7 +214,7 @@
*
* @return the composition of the provided function and predicate
*/
- public static <A extends @Nullable Object, B extends @Nullable Object> Predicate<A> compose(
+ public static <A, B> Predicate<A> compose(
Predicate<B> predicate, Function<A, ? extends B> function) {
return new CompositionPredicate<>(predicate, function);
}
@@ -255,11 +247,11 @@
// End public API, begin private implementation classes.
// Package private for GWT serialization.
- enum ObjectPredicate implements Predicate<@Nullable Object> {
+ enum ObjectPredicate implements Predicate<Object> {
/** @see Predicates#alwaysTrue() */
ALWAYS_TRUE {
@Override
- public boolean apply(@CheckForNull Object o) {
+ public boolean apply(@Nullable Object o) {
return true;
}
@@ -271,7 +263,7 @@
/** @see Predicates#alwaysFalse() */
ALWAYS_FALSE {
@Override
- public boolean apply(@CheckForNull Object o) {
+ public boolean apply(@Nullable Object o) {
return false;
}
@@ -283,7 +275,7 @@
/** @see Predicates#isNull() */
IS_NULL {
@Override
- public boolean apply(@CheckForNull Object o) {
+ public boolean apply(@Nullable Object o) {
return o == null;
}
@@ -295,7 +287,7 @@
/** @see Predicates#notNull() */
NOT_NULL {
@Override
- public boolean apply(@CheckForNull Object o) {
+ public boolean apply(@Nullable Object o) {
return o != null;
}
@@ -306,14 +298,13 @@
};
@SuppressWarnings("unchecked") // safe contravariant cast
- <T extends @Nullable Object> Predicate<T> withNarrowedType() {
+ <T> Predicate<T> withNarrowedType() {
return (Predicate<T>) this;
}
}
/** @see Predicates#not(Predicate) */
- private static class NotPredicate<T extends @Nullable Object>
- implements Predicate<T>, Serializable {
+ private static class NotPredicate<T> implements Predicate<T>, Serializable {
final Predicate<T> predicate;
NotPredicate(Predicate<T> predicate) {
@@ -321,7 +312,7 @@
}
@Override
- public boolean apply(@ParametricNullness T t) {
+ public boolean apply(@Nullable T t) {
return !predicate.apply(t);
}
@@ -331,7 +322,7 @@
}
@Override
- public boolean equals(@CheckForNull Object obj) {
+ public boolean equals(@Nullable Object obj) {
if (obj instanceof NotPredicate) {
NotPredicate<?> that = (NotPredicate<?>) obj;
return predicate.equals(that.predicate);
@@ -348,8 +339,7 @@
}
/** @see Predicates#and(Iterable) */
- private static class AndPredicate<T extends @Nullable Object>
- implements Predicate<T>, Serializable {
+ private static class AndPredicate<T> implements Predicate<T>, Serializable {
private final List<? extends Predicate<? super T>> components;
private AndPredicate(List<? extends Predicate<? super T>> components) {
@@ -357,7 +347,7 @@
}
@Override
- public boolean apply(@ParametricNullness 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)) {
@@ -374,7 +364,7 @@
}
@Override
- public boolean equals(@CheckForNull Object obj) {
+ public boolean equals(@Nullable Object obj) {
if (obj instanceof AndPredicate) {
AndPredicate<?> that = (AndPredicate<?>) obj;
return components.equals(that.components);
@@ -391,8 +381,7 @@
}
/** @see Predicates#or(Iterable) */
- private static class OrPredicate<T extends @Nullable Object>
- implements Predicate<T>, Serializable {
+ private static class OrPredicate<T> implements Predicate<T>, Serializable {
private final List<? extends Predicate<? super T>> components;
private OrPredicate(List<? extends Predicate<? super T>> components) {
@@ -400,7 +389,7 @@
}
@Override
- public boolean apply(@ParametricNullness 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)) {
@@ -417,7 +406,7 @@
}
@Override
- public boolean equals(@CheckForNull Object obj) {
+ public boolean equals(@Nullable Object obj) {
if (obj instanceof OrPredicate) {
OrPredicate<?> that = (OrPredicate<?>) obj;
return components.equals(that.components);
@@ -447,16 +436,16 @@
}
/** @see Predicates#equalTo(Object) */
- private static class IsEqualToPredicate implements Predicate<@Nullable Object>, Serializable {
- private final Object target;
+ private static class IsEqualToPredicate<T> implements Predicate<T>, Serializable {
+ private final T target;
- private IsEqualToPredicate(Object target) {
+ private IsEqualToPredicate(T target) {
this.target = target;
}
@Override
- public boolean apply(@CheckForNull Object o) {
- return target.equals(o);
+ public boolean apply(T t) {
+ return target.equals(t);
}
@Override
@@ -465,9 +454,9 @@
}
@Override
- public boolean equals(@CheckForNull Object obj) {
+ public boolean equals(@Nullable Object obj) {
if (obj instanceof IsEqualToPredicate) {
- IsEqualToPredicate that = (IsEqualToPredicate) obj;
+ IsEqualToPredicate<?> that = (IsEqualToPredicate<?>) obj;
return target.equals(that.target);
}
return false;
@@ -479,17 +468,11 @@
}
private static final long serialVersionUID = 0;
-
- @SuppressWarnings("unchecked") // safe contravariant cast
- <T extends @Nullable Object> Predicate<T> withNarrowedType() {
- return (Predicate<T>) this;
- }
}
/** @see Predicates#instanceOf(Class) */
@GwtIncompatible // Class.isInstance
- private static class InstanceOfPredicate<T extends @Nullable Object>
- implements Predicate<T>, Serializable {
+ private static class InstanceOfPredicate implements Predicate<Object>, Serializable {
private final Class<?> clazz;
private InstanceOfPredicate(Class<?> clazz) {
@@ -497,7 +480,7 @@
}
@Override
- public boolean apply(@ParametricNullness T o) {
+ public boolean apply(@Nullable Object o) {
return clazz.isInstance(o);
}
@@ -507,9 +490,9 @@
}
@Override
- public boolean equals(@CheckForNull Object obj) {
+ public boolean equals(@Nullable Object obj) {
if (obj instanceof InstanceOfPredicate) {
- InstanceOfPredicate<?> that = (InstanceOfPredicate<?>) obj;
+ InstanceOfPredicate that = (InstanceOfPredicate) obj;
return clazz == that.clazz;
}
return false;
@@ -543,7 +526,7 @@
}
@Override
- public boolean equals(@CheckForNull Object obj) {
+ public boolean equals(@Nullable Object obj) {
if (obj instanceof SubtypeOfPredicate) {
SubtypeOfPredicate that = (SubtypeOfPredicate) obj;
return clazz == that.clazz;
@@ -560,8 +543,7 @@
}
/** @see Predicates#in(Collection) */
- private static class InPredicate<T extends @Nullable Object>
- implements Predicate<T>, Serializable {
+ private static class InPredicate<T> implements Predicate<T>, Serializable {
private final Collection<?> target;
private InPredicate(Collection<?> target) {
@@ -569,7 +551,7 @@
}
@Override
- public boolean apply(@ParametricNullness T t) {
+ public boolean apply(@Nullable T t) {
try {
return target.contains(t);
} catch (NullPointerException | ClassCastException e) {
@@ -578,7 +560,7 @@
}
@Override
- public boolean equals(@CheckForNull Object obj) {
+ public boolean equals(@Nullable Object obj) {
if (obj instanceof InPredicate) {
InPredicate<?> that = (InPredicate<?>) obj;
return target.equals(that.target);
@@ -600,8 +582,7 @@
}
/** @see Predicates#compose(Predicate, Function) */
- private static class CompositionPredicate<A extends @Nullable Object, B extends @Nullable Object>
- implements Predicate<A>, Serializable {
+ private static class CompositionPredicate<A, B> implements Predicate<A>, Serializable {
final Predicate<B> p;
final Function<A, ? extends B> f;
@@ -611,12 +592,12 @@
}
@Override
- public boolean apply(@ParametricNullness A a) {
+ public boolean apply(@Nullable A a) {
return p.apply(f.apply(a));
}
@Override
- public boolean equals(@CheckForNull 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);
@@ -661,7 +642,7 @@
}
@Override
- public boolean equals(@CheckForNull Object obj) {
+ public boolean equals(@Nullable Object obj) {
if (obj instanceof ContainsPatternPredicate) {
ContainsPatternPredicate that = (ContainsPatternPredicate) obj;
@@ -702,7 +683,7 @@
private static final long serialVersionUID = 0;
}
- private static <T extends @Nullable Object> List<Predicate<? super T>> asList(
+ private static <T> List<Predicate<? super T>> asList(
Predicate<? super T> first, Predicate<? super T> second) {
// TODO(kevinb): understand why we still get a warning despite @SafeVarargs!
return Arrays.<Predicate<? super T>>asList(first, second);
diff --git a/guava/src/com/google/common/base/Present.java b/guava/src/com/google/common/base/Present.java
index 59efebc..a25de82 100644
--- a/guava/src/com/google/common/base/Present.java
+++ b/guava/src/com/google/common/base/Present.java
@@ -19,11 +19,10 @@
import com.google.common.annotations.GwtCompatible;
import java.util.Collections;
import java.util.Set;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/** Implementation of an {@link Optional} containing a reference. */
@GwtCompatible
-@ElementTypesAreNonnullByDefault
final class Present<T> extends Optional<T> {
private final T reference;
@@ -78,7 +77,7 @@
}
@Override
- public boolean equals(@CheckForNull 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/SmallCharMatcher.java b/guava/src/com/google/common/base/SmallCharMatcher.java
index f0e801b..1e565c8 100644
--- a/guava/src/com/google/common/base/SmallCharMatcher.java
+++ b/guava/src/com/google/common/base/SmallCharMatcher.java
@@ -26,7 +26,6 @@
* @author Christopher Swenson
*/
@GwtIncompatible // no precomputation is done in GWT
-@ElementTypesAreNonnullByDefault
final class SmallCharMatcher extends NamedFastMatcher {
static final int MAX_SIZE = 1023;
private final char[] table;
diff --git a/guava/src/com/google/common/base/Splitter.java b/guava/src/com/google/common/base/Splitter.java
index e60e988..e0b498e 100644
--- a/guava/src/com/google/common/base/Splitter.java
+++ b/guava/src/com/google/common/base/Splitter.java
@@ -29,7 +29,6 @@
import java.util.regex.Pattern;
import java.util.stream.Stream;
import java.util.stream.StreamSupport;
-import javax.annotation.CheckForNull;
/**
* Extracts non-overlapping substrings from an input string, typically by recognizing appearances of
@@ -100,7 +99,6 @@
* @since 1.0
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
public final class Splitter {
private final CharMatcher trimmer;
private final boolean omitEmptyStrings;
@@ -566,7 +564,6 @@
this.toSplit = toSplit;
}
- @CheckForNull
@Override
protected String computeNext() {
/*
diff --git a/guava/src/com/google/common/base/StandardSystemProperty.java b/guava/src/com/google/common/base/StandardSystemProperty.java
index dc29792..7a7b115 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 javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Represents a {@linkplain System#getProperties() standard system property}.
@@ -24,7 +24,6 @@
* @since 15.0
*/
@GwtIncompatible // java.lang.System#getProperty
-@ElementTypesAreNonnullByDefault
public enum StandardSystemProperty {
/** Java Runtime Environment version. */
@@ -81,15 +80,7 @@
/** Name of JIT compiler to use. */
JAVA_COMPILER("java.compiler"),
- /**
- * Path of extension directory or directories.
- *
- * @deprecated This property was <a
- * href="https://openjdk.java.net/jeps/220#Removed:-The-extension-mechanism">deprecated</a> in
- * Java 8 and removed in Java 9. We do not plan to remove this API from Guava, but if you are
- * using it, it is probably not doing what you want.
- */
- @Deprecated
+ /** Path of extension directory or directories. */
JAVA_EXT_DIRS("java.ext.dirs"),
/** Operating system name. */
@@ -133,28 +124,8 @@
/**
* Returns the current value for this system property by delegating to {@link
* System#getProperty(String)}.
- *
- * <p>The value returned by this method is non-null except in rare circumstances:
- *
- * <ul>
- * <li>{@link #JAVA_EXT_DIRS} was deprecated in Java 8 and removed in Java 9. We have not
- * confirmed whether it is available under older versions.
- * <li>{@link #JAVA_COMPILER}, while still listed as required as of Java 15, is typically not
- * available even under older version.
- * <li>Any property may be cleared through APIs like {@link System#clearProperty}.
- * <li>Unusual environments like GWT may have their own special handling of system properties.
- * </ul>
- *
- * <p>Note that {@code StandardSystemProperty} does not provide constants for more recently added
- * properties, including:
- *
- * <ul>
- * <li>{@code java.vendor.version} (added in Java 11, listed as optional as of Java 13)
- * <li>{@code jdk.module.*} (added in Java 9, optional)
- * </ul>
*/
- @CheckForNull
- public String value() {
+ public @Nullable String value() {
return System.getProperty(key);
}
diff --git a/guava/src/com/google/common/base/Stopwatch.java b/guava/src/com/google/common/base/Stopwatch.java
index 9d5282d..e4cca1f 100644
--- a/guava/src/com/google/common/base/Stopwatch.java
+++ b/guava/src/com/google/common/base/Stopwatch.java
@@ -79,7 +79,7 @@
* Stopwatch.createStarted(
* new Ticker() {
* public long read() {
- * return android.os.SystemClock.elapsedRealtimeNanos(); // requires API Level 17
+ * return android.os.SystemClock.elapsedRealtimeNanos();
* }
* });
* }</pre>
@@ -89,7 +89,6 @@
*/
@GwtCompatible(emulated = true)
@SuppressWarnings("GoodTime") // lots of violations
-@ElementTypesAreNonnullByDefault
public final class Stopwatch {
private final Ticker ticker;
private boolean isRunning;
diff --git a/guava/src/com/google/common/base/Strings.java b/guava/src/com/google/common/base/Strings.java
index e56bf1c..f02b64e 100644
--- a/guava/src/com/google/common/base/Strings.java
+++ b/guava/src/com/google/common/base/Strings.java
@@ -20,10 +20,7 @@
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.VisibleForTesting;
-import com.google.errorprone.annotations.InlineMe;
-import com.google.errorprone.annotations.InlineMeValidationDisabled;
import java.util.logging.Logger;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -33,7 +30,6 @@
* @since 3.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
public final class Strings {
private Strings() {}
@@ -43,7 +39,7 @@
* @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(@CheckForNull String string) {
+ public static String nullToEmpty(@Nullable String string) {
return Platform.nullToEmpty(string);
}
@@ -53,8 +49,7 @@
* @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
*/
- @CheckForNull
- public static String emptyToNull(@CheckForNull String string) {
+ public static @Nullable String emptyToNull(@Nullable String string) {
return Platform.emptyToNull(string);
}
@@ -69,7 +64,7 @@
* @param string a string reference to check
* @return {@code true} if the string is null or is the empty string
*/
- public static boolean isNullOrEmpty(@CheckForNull String string) {
+ public static boolean isNullOrEmpty(@Nullable String string) {
return Platform.stringIsNullOrEmpty(string);
}
@@ -139,16 +134,12 @@
* Returns a string consisting of a specific number of concatenated copies of an input string. For
* example, {@code repeat("hey", 3)} returns the string {@code "heyheyhey"}.
*
- * <p><b>Java 11+ users:</b> use {@code string.repeat(count)} instead.
- *
* @param string any non-null string
* @param count the number of times to repeat it; a nonnegative integer
* @return a string containing {@code string} repeated {@code count} times (the empty string if
* {@code count} is zero)
* @throws IllegalArgumentException if {@code count} is negative
*/
- @InlineMe(replacement = "string.repeat(count)")
- @InlineMeValidationDisabled("Java 11+ API only")
public static String repeat(String string, int count) {
checkNotNull(string); // eager for GWT.
@@ -266,7 +257,7 @@
*/
// TODO(diamondm) consider using Arrays.toString() for array parameters
public static String lenientFormat(
- @CheckForNull String template, @CheckForNull @Nullable Object... args) {
+ @Nullable String template, @Nullable Object @Nullable ... args) {
template = String.valueOf(template); // null -> "null"
if (args == null) {
@@ -306,7 +297,7 @@
return builder.toString();
}
- private static String lenientToString(@CheckForNull Object o) {
+ private static String lenientToString(@Nullable Object o) {
if (o == null) {
return "null";
}
diff --git a/guava/src/com/google/common/base/Supplier.java b/guava/src/com/google/common/base/Supplier.java
index 08f96be..0226d1d 100644
--- a/guava/src/com/google/common/base/Supplier.java
+++ b/guava/src/com/google/common/base/Supplier.java
@@ -16,7 +16,6 @@
import com.google.common.annotations.GwtCompatible;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Legacy version of {@link java.util.function.Supplier java.util.function.Supplier}. Semantically,
@@ -38,8 +37,7 @@
*/
@GwtCompatible
@FunctionalInterface
-@ElementTypesAreNonnullByDefault
-public interface Supplier<T extends @Nullable Object> extends java.util.function.Supplier<T> {
+public interface Supplier<T> extends java.util.function.Supplier<T> {
/**
* Retrieves an instance of the appropriate type. The returned object may or may not be a new
* instance, depending on the implementation.
@@ -48,6 +46,5 @@
*/
@CanIgnoreReturnValue
@Override
- @ParametricNullness
T get();
}
diff --git a/guava/src/com/google/common/base/Suppliers.java b/guava/src/com/google/common/base/Suppliers.java
index 57d3486..b02b32e 100644
--- a/guava/src/com/google/common/base/Suppliers.java
+++ b/guava/src/com/google/common/base/Suppliers.java
@@ -14,16 +14,13 @@
package com.google.common.base;
-import static com.google.common.base.NullnessCasts.uncheckedCastNullableTToT;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
-import static java.util.Objects.requireNonNull;
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.VisibleForTesting;
import java.io.Serializable;
import java.util.concurrent.TimeUnit;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -36,7 +33,6 @@
* @since 2.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
public final class Suppliers {
private Suppliers() {}
@@ -46,13 +42,11 @@
* and then applying {@code function} to that value. Note that the resulting supplier will not
* call {@code supplier} or invoke {@code function} until it is called.
*/
- public static <F extends @Nullable Object, T extends @Nullable Object> Supplier<T> compose(
- Function<? super F, T> function, Supplier<F> supplier) {
+ public static <F, T> Supplier<T> compose(Function<? super F, T> function, Supplier<F> supplier) {
return new SupplierComposition<>(function, supplier);
}
- private static class SupplierComposition<F extends @Nullable Object, T extends @Nullable Object>
- implements Supplier<T>, Serializable {
+ private static class SupplierComposition<F, T> implements Supplier<T>, Serializable {
final Function<? super F, T> function;
final Supplier<F> supplier;
@@ -62,13 +56,12 @@
}
@Override
- @ParametricNullness
public T get() {
return function.apply(supplier.get());
}
@Override
- public boolean equals(@CheckForNull 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);
@@ -105,7 +98,7 @@
* <p>If {@code delegate} is an instance created by an earlier call to {@code memoize}, it is
* returned directly.
*/
- public static <T extends @Nullable Object> Supplier<T> memoize(Supplier<T> delegate) {
+ public static <T> Supplier<T> memoize(Supplier<T> delegate) {
if (delegate instanceof NonSerializableMemoizingSupplier
|| delegate instanceof MemoizingSupplier) {
return delegate;
@@ -116,19 +109,18 @@
}
@VisibleForTesting
- static class MemoizingSupplier<T extends @Nullable Object> implements Supplier<T>, Serializable {
+ static class MemoizingSupplier<T> implements Supplier<T>, Serializable {
final Supplier<T> delegate;
transient volatile boolean initialized;
// "value" does not need to be volatile; visibility piggy-backs
// on volatile read of "initialized".
- @CheckForNull transient T value;
+ transient @Nullable T value;
MemoizingSupplier(Supplier<T> delegate) {
this.delegate = checkNotNull(delegate);
}
@Override
- @ParametricNullness
public T get() {
// A 2-field variant of Double Checked Locking.
if (!initialized) {
@@ -141,8 +133,7 @@
}
}
}
- // This is safe because we checked `initialized.`
- return uncheckedCastNullableTToT(value);
+ return value;
}
@Override
@@ -156,31 +147,24 @@
}
@VisibleForTesting
- static class NonSerializableMemoizingSupplier<T extends @Nullable Object> implements Supplier<T> {
- @CheckForNull volatile Supplier<T> delegate;
+ static class NonSerializableMemoizingSupplier<T> implements Supplier<T> {
+ volatile Supplier<T> delegate;
volatile boolean initialized;
// "value" does not need to be volatile; visibility piggy-backs
// on volatile read of "initialized".
- @CheckForNull T value;
+ @Nullable T value;
NonSerializableMemoizingSupplier(Supplier<T> delegate) {
this.delegate = checkNotNull(delegate);
}
@Override
- @ParametricNullness
public T get() {
// A 2-field variant of Double Checked Locking.
if (!initialized) {
synchronized (this) {
if (!initialized) {
- /*
- * requireNonNull is safe because we read and write `delegate` under synchronization.
- *
- * TODO(cpovirk): To avoid having to check for null, replace `delegate` with a singleton
- * `Supplier` that always throws an exception.
- */
- T t = requireNonNull(delegate).get();
+ T t = delegate.get();
value = t;
initialized = true;
// Release the delegate to GC.
@@ -189,8 +173,7 @@
}
}
}
- // This is safe because we checked `initialized.`
- return uncheckedCastNullableTToT(value);
+ return value;
}
@Override
@@ -224,18 +207,17 @@
* @since 2.0
*/
@SuppressWarnings("GoodTime") // should accept a java.time.Duration
- public static <T extends @Nullable Object> Supplier<T> memoizeWithExpiration(
+ public static <T> Supplier<T> memoizeWithExpiration(
Supplier<T> delegate, long duration, TimeUnit unit) {
return new ExpiringMemoizingSupplier<T>(delegate, duration, unit);
}
@VisibleForTesting
@SuppressWarnings("GoodTime") // lots of violations
- static class ExpiringMemoizingSupplier<T extends @Nullable Object>
- implements Supplier<T>, Serializable {
+ static class ExpiringMemoizingSupplier<T> implements Supplier<T>, Serializable {
final Supplier<T> delegate;
final long durationNanos;
- @CheckForNull transient volatile T value;
+ transient volatile @Nullable T value;
// The special value 0 means "not yet initialized".
transient volatile long expirationNanos;
@@ -246,7 +228,6 @@
}
@Override
- @ParametricNullness
public T get() {
// Another variant of Double Checked Locking.
//
@@ -269,8 +250,7 @@
}
}
}
- // This is safe because we checked `expirationNanos.`
- return uncheckedCastNullableTToT(value);
+ return value;
}
@Override
@@ -284,27 +264,24 @@
}
/** Returns a supplier that always supplies {@code instance}. */
- public static <T extends @Nullable Object> Supplier<T> ofInstance(
- @ParametricNullness T instance) {
+ public static <T> Supplier<T> ofInstance(@Nullable T instance) {
return new SupplierOfInstance<T>(instance);
}
- private static class SupplierOfInstance<T extends @Nullable Object>
- implements Supplier<T>, Serializable {
- @ParametricNullness final T instance;
+ private static class SupplierOfInstance<T> implements Supplier<T>, Serializable {
+ final @Nullable T instance;
- SupplierOfInstance(@ParametricNullness T instance) {
+ SupplierOfInstance(@Nullable T instance) {
this.instance = instance;
}
@Override
- @ParametricNullness
public T get() {
return instance;
}
@Override
- public boolean equals(@CheckForNull Object obj) {
+ public boolean equals(@Nullable Object obj) {
if (obj instanceof SupplierOfInstance) {
SupplierOfInstance<?> that = (SupplierOfInstance<?>) obj;
return Objects.equal(instance, that.instance);
@@ -329,13 +306,11 @@
* Returns a supplier whose {@code get()} method synchronizes on {@code delegate} before calling
* it, making it thread-safe.
*/
- public static <T extends @Nullable Object> Supplier<T> synchronizedSupplier(
- Supplier<T> delegate) {
+ public static <T> Supplier<T> synchronizedSupplier(Supplier<T> delegate) {
return new ThreadSafeSupplier<T>(delegate);
}
- private static class ThreadSafeSupplier<T extends @Nullable Object>
- implements Supplier<T>, Serializable {
+ private static class ThreadSafeSupplier<T> implements Supplier<T>, Serializable {
final Supplier<T> delegate;
ThreadSafeSupplier(Supplier<T> delegate) {
@@ -343,7 +318,6 @@
}
@Override
- @ParametricNullness
public T get() {
synchronized (delegate) {
return delegate.get();
@@ -366,21 +340,20 @@
*
* @since 8.0
*/
- public static <T extends @Nullable Object> Function<Supplier<T>, T> supplierFunction() {
+ public static <T> Function<Supplier<T>, T> supplierFunction() {
@SuppressWarnings("unchecked") // implementation is "fully variant"
SupplierFunction<T> sf = (SupplierFunction<T>) SupplierFunctionImpl.INSTANCE;
return sf;
}
- private interface SupplierFunction<T extends @Nullable Object> extends Function<Supplier<T>, T> {}
+ private interface SupplierFunction<T> extends Function<Supplier<T>, T> {}
- private enum SupplierFunctionImpl implements SupplierFunction<@Nullable Object> {
+ private enum SupplierFunctionImpl implements SupplierFunction<Object> {
INSTANCE;
// Note: This makes T a "pass-through type"
@Override
- @CheckForNull
- public Object apply(Supplier<@Nullable Object> input) {
+ public Object apply(Supplier<Object> input) {
return input.get();
}
diff --git a/guava/src/com/google/common/base/Throwables.java b/guava/src/com/google/common/base/Throwables.java
index 7832d18..e50a416 100644
--- a/guava/src/com/google/common/base/Throwables.java
+++ b/guava/src/com/google/common/base/Throwables.java
@@ -17,7 +17,6 @@
import static com.google.common.base.Preconditions.checkNotNull;
import static java.util.Arrays.asList;
import static java.util.Collections.unmodifiableList;
-import static java.util.Objects.requireNonNull;
import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtCompatible;
@@ -33,7 +32,7 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Static utility methods pertaining to instances of {@link Throwable}.
@@ -46,7 +45,6 @@
* @since 1.0
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
public final class Throwables {
private Throwables() {}
@@ -101,7 +99,7 @@
@Deprecated
@GwtIncompatible // throwIfInstanceOf
public static <X extends Throwable> void propagateIfInstanceOf(
- @CheckForNull Throwable throwable, Class<X> declaredType) throws X {
+ @Nullable Throwable throwable, Class<X> declaredType) throws X {
if (throwable != null) {
throwIfInstanceOf(throwable, declaredType);
}
@@ -156,7 +154,7 @@
*/
@Deprecated
@GwtIncompatible
- public static void propagateIfPossible(@CheckForNull Throwable throwable) {
+ public static void propagateIfPossible(@Nullable Throwable throwable) {
if (throwable != null) {
throwIfUnchecked(throwable);
}
@@ -182,7 +180,7 @@
*/
@GwtIncompatible // propagateIfInstanceOf
public static <X extends Throwable> void propagateIfPossible(
- @CheckForNull Throwable throwable, Class<X> declaredType) throws X {
+ @Nullable Throwable throwable, Class<X> declaredType) throws X {
propagateIfInstanceOf(throwable, declaredType);
propagateIfPossible(throwable);
}
@@ -200,7 +198,7 @@
*/
@GwtIncompatible // propagateIfInstanceOf
public static <X1 extends Throwable, X2 extends Throwable> void propagateIfPossible(
- @CheckForNull Throwable throwable, Class<X1> declaredType1, Class<X2> declaredType2)
+ @Nullable Throwable throwable, Class<X1> declaredType1, Class<X2> declaredType2)
throws X1, X2 {
checkNotNull(declaredType2);
propagateIfInstanceOf(throwable, declaredType1);
@@ -332,7 +330,6 @@
*/
@Beta
@GwtIncompatible // Class.cast(Object)
- @CheckForNull
public static <X extends Throwable> X getCauseAs(
Throwable throwable, Class<X> expectedCauseType) {
try {
@@ -415,22 +412,15 @@
* AOSP grief.
*/
return new AbstractList<StackTraceElement>() {
- /*
- * The following requireNonNull calls are safe because we use jlaStackTrace() only if
- * lazyStackTraceIsLazy() returns true.
- */
@Override
public StackTraceElement get(int n) {
return (StackTraceElement)
- invokeAccessibleNonThrowingMethod(
- requireNonNull(getStackTraceElementMethod), requireNonNull(jla), t, n);
+ invokeAccessibleNonThrowingMethod(getStackTraceElementMethod, jla, t, n);
}
@Override
public int size() {
- return (Integer)
- invokeAccessibleNonThrowingMethod(
- requireNonNull(getStackTraceDepthMethod), requireNonNull(jla), t);
+ return (Integer) invokeAccessibleNonThrowingMethod(getStackTraceDepthMethod, jla, t);
}
};
}
@@ -458,32 +448,30 @@
/** Access to some fancy internal JVM internals. */
@GwtIncompatible // java.lang.reflect
- @CheckForNull
- private static final Object jla = getJLA();
+ private static final @Nullable Object jla = getJLA();
/**
* The "getStackTraceElementMethod" method, only available on some JDKs so we use reflection to
* find it when available. When this is null, use the slow way.
*/
@GwtIncompatible // java.lang.reflect
- @CheckForNull
- private static final Method getStackTraceElementMethod = (jla == null) ? null : getGetMethod();
+ private static final @Nullable Method getStackTraceElementMethod =
+ (jla == null) ? null : getGetMethod();
/**
* The "getStackTraceDepth" method, only available on some JDKs so we use reflection to find it
* when available. When this is null, use the slow way.
*/
@GwtIncompatible // java.lang.reflect
- @CheckForNull
- private static final Method getStackTraceDepthMethod = (jla == null) ? null : getSizeMethod(jla);
+ private static final @Nullable Method getStackTraceDepthMethod =
+ (jla == null) ? null : getSizeMethod();
/**
* Returns the JavaLangAccess class that is present in all Sun JDKs. It is not allowed in
* AppEngine, and not present in non-Sun JDKs.
*/
@GwtIncompatible // java.lang.reflect
- @CheckForNull
- private static Object getJLA() {
+ private static @Nullable Object getJLA() {
try {
/*
* We load sun.misc.* classes using reflection since Android doesn't support these classes and
@@ -508,8 +496,7 @@
* method cannot be found (it is only to be found in fairly recent JDKs).
*/
@GwtIncompatible // java.lang.reflect
- @CheckForNull
- private static Method getGetMethod() {
+ private static @Nullable Method getGetMethod() {
return getJlaMethod("getStackTraceElement", Throwable.class, int.class);
}
@@ -523,14 +510,13 @@
* UnsupportedOperationException</a>.
*/
@GwtIncompatible // java.lang.reflect
- @CheckForNull
- private static Method getSizeMethod(Object jla) {
+ private static @Nullable Method getSizeMethod() {
try {
Method getStackTraceDepth = getJlaMethod("getStackTraceDepth", Throwable.class);
if (getStackTraceDepth == null) {
return null;
}
- getStackTraceDepth.invoke(jla, new Throwable());
+ getStackTraceDepth.invoke(getJLA(), new Throwable());
return getStackTraceDepth;
} catch (UnsupportedOperationException | IllegalAccessException | InvocationTargetException e) {
return null;
@@ -538,8 +524,8 @@
}
@GwtIncompatible // java.lang.reflect
- @CheckForNull
- private static Method getJlaMethod(String name, Class<?>... parameterTypes) throws ThreadDeath {
+ private static @Nullable Method getJlaMethod(String name, Class<?>... parameterTypes)
+ throws ThreadDeath {
try {
return Class.forName(JAVA_LANG_ACCESS_CLASSNAME, false, null).getMethod(name, parameterTypes);
} catch (ThreadDeath death) {
diff --git a/guava/src/com/google/common/base/Ticker.java b/guava/src/com/google/common/base/Ticker.java
index d898735..a53883b 100644
--- a/guava/src/com/google/common/base/Ticker.java
+++ b/guava/src/com/google/common/base/Ticker.java
@@ -28,7 +28,6 @@
* source-compatible</a> since 9.0)
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
public abstract class Ticker {
/** Constructor for use by subclasses. */
protected Ticker() {}
diff --git a/guava/src/com/google/common/base/Utf8.java b/guava/src/com/google/common/base/Utf8.java
index bb945a3..8a2fbb7 100644
--- a/guava/src/com/google/common/base/Utf8.java
+++ b/guava/src/com/google/common/base/Utf8.java
@@ -38,7 +38,6 @@
*/
@Beta
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
public final class Utf8 {
/**
* Returns the number of bytes in the UTF-8-encoded form of {@code sequence}. For a string, this
diff --git a/guava/src/com/google/common/base/Verify.java b/guava/src/com/google/common/base/Verify.java
index b2e9f5f..c2846de 100644
--- a/guava/src/com/google/common/base/Verify.java
+++ b/guava/src/com/google/common/base/Verify.java
@@ -18,7 +18,6 @@
import com.google.common.annotations.GwtCompatible;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -88,7 +87,6 @@
* @since 17.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
public final class Verify {
/**
* Ensures that {@code expression} is {@code true}, throwing a {@code VerifyException} with no
@@ -120,8 +118,8 @@
*/
public static void verify(
boolean expression,
- String errorMessageTemplate,
- @CheckForNull @Nullable Object... errorMessageArgs) {
+ @Nullable String errorMessageTemplate,
+ @Nullable Object @Nullable ... errorMessageArgs) {
if (!expression) {
throw new VerifyException(lenientFormat(errorMessageTemplate, errorMessageArgs));
}
@@ -135,7 +133,7 @@
*
* @since 23.1 (varargs overload since 17.0)
*/
- public static void verify(boolean expression, String errorMessageTemplate, char p1) {
+ public static void verify(boolean expression, @Nullable String errorMessageTemplate, char p1) {
if (!expression) {
throw new VerifyException(lenientFormat(errorMessageTemplate, p1));
}
@@ -149,7 +147,7 @@
*
* @since 23.1 (varargs overload since 17.0)
*/
- public static void verify(boolean expression, String errorMessageTemplate, int p1) {
+ public static void verify(boolean expression, @Nullable String errorMessageTemplate, int p1) {
if (!expression) {
throw new VerifyException(lenientFormat(errorMessageTemplate, p1));
}
@@ -163,7 +161,7 @@
*
* @since 23.1 (varargs overload since 17.0)
*/
- public static void verify(boolean expression, String errorMessageTemplate, long p1) {
+ public static void verify(boolean expression, @Nullable String errorMessageTemplate, long p1) {
if (!expression) {
throw new VerifyException(lenientFormat(errorMessageTemplate, p1));
}
@@ -178,7 +176,7 @@
* @since 23.1 (varargs overload since 17.0)
*/
public static void verify(
- boolean expression, String errorMessageTemplate, @CheckForNull Object p1) {
+ boolean expression, @Nullable String errorMessageTemplate, @Nullable Object p1) {
if (!expression) {
throw new VerifyException(lenientFormat(errorMessageTemplate, p1));
}
@@ -192,35 +190,8 @@
*
* @since 23.1 (varargs overload since 17.0)
*/
- public static void verify(boolean expression, String errorMessageTemplate, char p1, char p2) {
- if (!expression) {
- throw new VerifyException(lenientFormat(errorMessageTemplate, p1, p2));
- }
- }
-
- /**
- * Ensures that {@code expression} is {@code true}, throwing a {@code VerifyException} with a
- * custom message otherwise.
- *
- * <p>See {@link #verify(boolean, String, Object...)} for details.
- *
- * @since 23.1 (varargs overload since 17.0)
- */
- public static void verify(boolean expression, String errorMessageTemplate, int p1, char p2) {
- if (!expression) {
- throw new VerifyException(lenientFormat(errorMessageTemplate, p1, p2));
- }
- }
-
- /**
- * Ensures that {@code expression} is {@code true}, throwing a {@code VerifyException} with a
- * custom message otherwise.
- *
- * <p>See {@link #verify(boolean, String, Object...)} for details.
- *
- * @since 23.1 (varargs overload since 17.0)
- */
- public static void verify(boolean expression, String errorMessageTemplate, long p1, char p2) {
+ public static void verify(
+ boolean expression, @Nullable String errorMessageTemplate, char p1, char p2) {
if (!expression) {
throw new VerifyException(lenientFormat(errorMessageTemplate, p1, p2));
}
@@ -235,49 +206,7 @@
* @since 23.1 (varargs overload since 17.0)
*/
public static void verify(
- boolean expression, String errorMessageTemplate, @CheckForNull Object p1, char p2) {
- if (!expression) {
- throw new VerifyException(lenientFormat(errorMessageTemplate, p1, p2));
- }
- }
-
- /**
- * Ensures that {@code expression} is {@code true}, throwing a {@code VerifyException} with a
- * custom message otherwise.
- *
- * <p>See {@link #verify(boolean, String, Object...)} for details.
- *
- * @since 23.1 (varargs overload since 17.0)
- */
- public static void verify(boolean expression, String errorMessageTemplate, char p1, int p2) {
- if (!expression) {
- throw new VerifyException(lenientFormat(errorMessageTemplate, p1, p2));
- }
- }
-
- /**
- * Ensures that {@code expression} is {@code true}, throwing a {@code VerifyException} with a
- * custom message otherwise.
- *
- * <p>See {@link #verify(boolean, String, Object...)} for details.
- *
- * @since 23.1 (varargs overload since 17.0)
- */
- public static void verify(boolean expression, String errorMessageTemplate, int p1, int p2) {
- if (!expression) {
- throw new VerifyException(lenientFormat(errorMessageTemplate, p1, p2));
- }
- }
-
- /**
- * Ensures that {@code expression} is {@code true}, throwing a {@code VerifyException} with a
- * custom message otherwise.
- *
- * <p>See {@link #verify(boolean, String, Object...)} for details.
- *
- * @since 23.1 (varargs overload since 17.0)
- */
- public static void verify(boolean expression, String errorMessageTemplate, long p1, int p2) {
+ boolean expression, @Nullable String errorMessageTemplate, int p1, char p2) {
if (!expression) {
throw new VerifyException(lenientFormat(errorMessageTemplate, p1, p2));
}
@@ -292,49 +221,7 @@
* @since 23.1 (varargs overload since 17.0)
*/
public static void verify(
- boolean expression, String errorMessageTemplate, @CheckForNull Object p1, int p2) {
- if (!expression) {
- throw new VerifyException(lenientFormat(errorMessageTemplate, p1, p2));
- }
- }
-
- /**
- * Ensures that {@code expression} is {@code true}, throwing a {@code VerifyException} with a
- * custom message otherwise.
- *
- * <p>See {@link #verify(boolean, String, Object...)} for details.
- *
- * @since 23.1 (varargs overload since 17.0)
- */
- public static void verify(boolean expression, String errorMessageTemplate, char p1, long p2) {
- if (!expression) {
- throw new VerifyException(lenientFormat(errorMessageTemplate, p1, p2));
- }
- }
-
- /**
- * Ensures that {@code expression} is {@code true}, throwing a {@code VerifyException} with a
- * custom message otherwise.
- *
- * <p>See {@link #verify(boolean, String, Object...)} for details.
- *
- * @since 23.1 (varargs overload since 17.0)
- */
- public static void verify(boolean expression, String errorMessageTemplate, int p1, long p2) {
- if (!expression) {
- throw new VerifyException(lenientFormat(errorMessageTemplate, p1, p2));
- }
- }
-
- /**
- * Ensures that {@code expression} is {@code true}, throwing a {@code VerifyException} with a
- * custom message otherwise.
- *
- * <p>See {@link #verify(boolean, String, Object...)} for details.
- *
- * @since 23.1 (varargs overload since 17.0)
- */
- public static void verify(boolean expression, String errorMessageTemplate, long p1, long p2) {
+ boolean expression, @Nullable String errorMessageTemplate, long p1, char p2) {
if (!expression) {
throw new VerifyException(lenientFormat(errorMessageTemplate, p1, p2));
}
@@ -349,7 +236,7 @@
* @since 23.1 (varargs overload since 17.0)
*/
public static void verify(
- boolean expression, String errorMessageTemplate, @CheckForNull Object p1, long p2) {
+ boolean expression, @Nullable String errorMessageTemplate, @Nullable Object p1, char p2) {
if (!expression) {
throw new VerifyException(lenientFormat(errorMessageTemplate, p1, p2));
}
@@ -364,7 +251,7 @@
* @since 23.1 (varargs overload since 17.0)
*/
public static void verify(
- boolean expression, String errorMessageTemplate, char p1, @CheckForNull Object p2) {
+ boolean expression, @Nullable String errorMessageTemplate, char p1, int p2) {
if (!expression) {
throw new VerifyException(lenientFormat(errorMessageTemplate, p1, p2));
}
@@ -379,7 +266,7 @@
* @since 23.1 (varargs overload since 17.0)
*/
public static void verify(
- boolean expression, String errorMessageTemplate, int p1, @CheckForNull Object p2) {
+ boolean expression, @Nullable String errorMessageTemplate, int p1, int p2) {
if (!expression) {
throw new VerifyException(lenientFormat(errorMessageTemplate, p1, p2));
}
@@ -394,7 +281,127 @@
* @since 23.1 (varargs overload since 17.0)
*/
public static void verify(
- boolean expression, String errorMessageTemplate, long p1, @CheckForNull Object p2) {
+ boolean expression, @Nullable String errorMessageTemplate, long p1, int p2) {
+ if (!expression) {
+ throw new VerifyException(lenientFormat(errorMessageTemplate, p1, p2));
+ }
+ }
+
+ /**
+ * Ensures that {@code expression} is {@code true}, throwing a {@code VerifyException} with a
+ * custom message otherwise.
+ *
+ * <p>See {@link #verify(boolean, String, Object...)} for details.
+ *
+ * @since 23.1 (varargs overload since 17.0)
+ */
+ public static void verify(
+ boolean expression, @Nullable String errorMessageTemplate, @Nullable Object p1, int p2) {
+ if (!expression) {
+ throw new VerifyException(lenientFormat(errorMessageTemplate, p1, p2));
+ }
+ }
+
+ /**
+ * Ensures that {@code expression} is {@code true}, throwing a {@code VerifyException} with a
+ * custom message otherwise.
+ *
+ * <p>See {@link #verify(boolean, String, Object...)} for details.
+ *
+ * @since 23.1 (varargs overload since 17.0)
+ */
+ public static void verify(
+ boolean expression, @Nullable String errorMessageTemplate, char p1, long p2) {
+ if (!expression) {
+ throw new VerifyException(lenientFormat(errorMessageTemplate, p1, p2));
+ }
+ }
+
+ /**
+ * Ensures that {@code expression} is {@code true}, throwing a {@code VerifyException} with a
+ * custom message otherwise.
+ *
+ * <p>See {@link #verify(boolean, String, Object...)} for details.
+ *
+ * @since 23.1 (varargs overload since 17.0)
+ */
+ public static void verify(
+ boolean expression, @Nullable String errorMessageTemplate, int p1, long p2) {
+ if (!expression) {
+ throw new VerifyException(lenientFormat(errorMessageTemplate, p1, p2));
+ }
+ }
+
+ /**
+ * Ensures that {@code expression} is {@code true}, throwing a {@code VerifyException} with a
+ * custom message otherwise.
+ *
+ * <p>See {@link #verify(boolean, String, Object...)} for details.
+ *
+ * @since 23.1 (varargs overload since 17.0)
+ */
+ public static void verify(
+ boolean expression, @Nullable String errorMessageTemplate, long p1, long p2) {
+ if (!expression) {
+ throw new VerifyException(lenientFormat(errorMessageTemplate, p1, p2));
+ }
+ }
+
+ /**
+ * Ensures that {@code expression} is {@code true}, throwing a {@code VerifyException} with a
+ * custom message otherwise.
+ *
+ * <p>See {@link #verify(boolean, String, Object...)} for details.
+ *
+ * @since 23.1 (varargs overload since 17.0)
+ */
+ public static void verify(
+ boolean expression, @Nullable String errorMessageTemplate, @Nullable Object p1, long p2) {
+ if (!expression) {
+ throw new VerifyException(lenientFormat(errorMessageTemplate, p1, p2));
+ }
+ }
+
+ /**
+ * Ensures that {@code expression} is {@code true}, throwing a {@code VerifyException} with a
+ * custom message otherwise.
+ *
+ * <p>See {@link #verify(boolean, String, Object...)} for details.
+ *
+ * @since 23.1 (varargs overload since 17.0)
+ */
+ public static void verify(
+ boolean expression, @Nullable String errorMessageTemplate, char p1, @Nullable Object p2) {
+ if (!expression) {
+ throw new VerifyException(lenientFormat(errorMessageTemplate, p1, p2));
+ }
+ }
+
+ /**
+ * Ensures that {@code expression} is {@code true}, throwing a {@code VerifyException} with a
+ * custom message otherwise.
+ *
+ * <p>See {@link #verify(boolean, String, Object...)} for details.
+ *
+ * @since 23.1 (varargs overload since 17.0)
+ */
+ public static void verify(
+ boolean expression, @Nullable String errorMessageTemplate, int p1, @Nullable Object p2) {
+ if (!expression) {
+ throw new VerifyException(lenientFormat(errorMessageTemplate, p1, p2));
+ }
+ }
+
+ /**
+ * Ensures that {@code expression} is {@code true}, throwing a {@code VerifyException} with a
+ * custom message otherwise.
+ *
+ * <p>See {@link #verify(boolean, String, Object...)} for details.
+ *
+ * @since 23.1 (varargs overload since 17.0)
+ */
+ public static void verify(
+ boolean expression, @Nullable String errorMessageTemplate, long p1, @Nullable Object p2) {
if (!expression) {
throw new VerifyException(lenientFormat(errorMessageTemplate, p1, p2));
}
@@ -410,9 +417,9 @@
*/
public static void verify(
boolean expression,
- String errorMessageTemplate,
- @CheckForNull Object p1,
- @CheckForNull Object p2) {
+ @Nullable String errorMessageTemplate,
+ @Nullable Object p1,
+ @Nullable Object p2) {
if (!expression) {
throw new VerifyException(lenientFormat(errorMessageTemplate, p1, p2));
}
@@ -428,10 +435,10 @@
*/
public static void verify(
boolean expression,
- String errorMessageTemplate,
- @CheckForNull Object p1,
- @CheckForNull Object p2,
- @CheckForNull Object p3) {
+ @Nullable String errorMessageTemplate,
+ @Nullable Object p1,
+ @Nullable Object p2,
+ @Nullable Object p3) {
if (!expression) {
throw new VerifyException(lenientFormat(errorMessageTemplate, p1, p2, p3));
}
@@ -447,25 +454,16 @@
*/
public static void verify(
boolean expression,
- String errorMessageTemplate,
- @CheckForNull Object p1,
- @CheckForNull Object p2,
- @CheckForNull Object p3,
- @CheckForNull Object p4) {
+ @Nullable String errorMessageTemplate,
+ @Nullable Object p1,
+ @Nullable Object p2,
+ @Nullable Object p3,
+ @Nullable Object p4) {
if (!expression) {
throw new VerifyException(lenientFormat(errorMessageTemplate, p1, p2, p3, p4));
}
}
- /*
- * For a discussion of the signature of verifyNotNull, see the discussion above
- * Preconditions.checkNotNull.
- *
- * (verifyNotNull has many fewer "problem" callers, so we could try to be stricter. On the other
- * hand, verifyNotNull arguably has more reason to accept nullable arguments in the first
- * place....)
- */
-
/**
* Ensures that {@code reference} is non-null, throwing a {@code VerifyException} with a default
* message otherwise.
@@ -475,7 +473,7 @@
* @see Preconditions#checkNotNull Preconditions.checkNotNull()
*/
@CanIgnoreReturnValue
- public static <T> T verifyNotNull(@CheckForNull T reference) {
+ public static <T> T verifyNotNull(@Nullable T reference) {
return verifyNotNull(reference, "expected a non-null reference");
}
@@ -496,12 +494,10 @@
*/
@CanIgnoreReturnValue
public static <T> T verifyNotNull(
- @CheckForNull T reference,
- String errorMessageTemplate,
- @CheckForNull @Nullable Object... errorMessageArgs) {
- if (reference == null) {
- throw new VerifyException(lenientFormat(errorMessageTemplate, 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 10b99de..1b6781b 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 javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Exception thrown upon the failure of a <a
@@ -25,13 +25,12 @@
* @since 17.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
public class VerifyException extends RuntimeException {
/** Constructs a {@code VerifyException} with no message. */
public VerifyException() {}
/** Constructs a {@code VerifyException} with the message {@code message}. */
- public VerifyException(@CheckForNull String message) {
+ public VerifyException(@Nullable String message) {
super(message);
}
@@ -41,7 +40,7 @@
*
* @since 19.0
*/
- public VerifyException(@CheckForNull Throwable cause) {
+ public VerifyException(@Nullable Throwable cause) {
super(cause);
}
@@ -51,7 +50,7 @@
*
* @since 19.0
*/
- public VerifyException(@CheckForNull String message, @CheckForNull Throwable cause) {
+ public VerifyException(@Nullable String message, @Nullable Throwable cause) {
super(message, cause);
}
}
diff --git a/guava/src/com/google/common/cache/AbstractCache.java b/guava/src/com/google/common/cache/AbstractCache.java
index eec5fdc..d8ef032 100644
--- a/guava/src/com/google/common/cache/AbstractCache.java
+++ b/guava/src/com/google/common/cache/AbstractCache.java
@@ -38,7 +38,6 @@
* @since 10.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
public abstract class AbstractCache<K, V> implements Cache<K, V> {
/** Constructor for use by subclasses. */
@@ -59,12 +58,8 @@
*
* @since 11.0
*/
- /*
- * <? extends Object> is mostly the same as <?> to plain Java. But to nullness checkers, they
- * differ: <? extends Object> means "non-null types," while <?> means "all types."
- */
@Override
- public ImmutableMap<K, V> getAllPresent(Iterable<? extends Object> keys) {
+ public ImmutableMap<K, V> getAllPresent(Iterable<?> keys) {
Map<K, V> result = Maps.newLinkedHashMap();
for (Object key : keys) {
if (!result.containsKey(key)) {
@@ -108,8 +103,7 @@
/** @since 11.0 */
@Override
- // For discussion of <? extends Object>, see getAllPresent.
- public void invalidateAll(Iterable<? extends Object> keys) {
+ public void invalidateAll(Iterable<?> keys) {
for (Object key : keys) {
invalidate(key);
}
diff --git a/guava/src/com/google/common/cache/AbstractLoadingCache.java b/guava/src/com/google/common/cache/AbstractLoadingCache.java
index 489597c..38b9774 100644
--- a/guava/src/com/google/common/cache/AbstractLoadingCache.java
+++ b/guava/src/com/google/common/cache/AbstractLoadingCache.java
@@ -38,7 +38,6 @@
* @since 11.0
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public abstract class AbstractLoadingCache<K, V> extends AbstractCache<K, V>
implements LoadingCache<K, V> {
diff --git a/guava/src/com/google/common/cache/Cache.java b/guava/src/com/google/common/cache/Cache.java
index 8755595..4bcb308 100644
--- a/guava/src/com/google/common/cache/Cache.java
+++ b/guava/src/com/google/common/cache/Cache.java
@@ -18,14 +18,13 @@
import com.google.common.collect.ImmutableMap;
import com.google.common.util.concurrent.ExecutionError;
import com.google.common.util.concurrent.UncheckedExecutionException;
-import com.google.errorprone.annotations.CheckReturnValue;
import com.google.errorprone.annotations.CompatibleWith;
import com.google.errorprone.annotations.DoNotMock;
import java.util.Map;
import java.util.concurrent.Callable;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.ExecutionException;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* A semi-persistent mapping from keys to values. Cache entries are manually added using {@link
@@ -35,14 +34,11 @@
* <p>Implementations of this interface are expected to be thread-safe, and can be safely accessed
* by multiple concurrent threads.
*
- * @param <K> the type of the cache's keys, which are not permitted to be null
- * @param <V> the type of the cache's values, which are not permitted to be null
* @author Charles Fry
* @since 10.0
*/
@DoNotMock("Use CacheBuilder.newBuilder().build()")
@GwtCompatible
-@ElementTypesAreNonnullByDefault
public interface Cache<K, V> {
/**
@@ -51,7 +47,7 @@
*
* @since 11.0
*/
- @CheckForNull
+ @Nullable
V getIfPresent(@CompatibleWith("K") Object key);
/**
@@ -108,11 +104,7 @@
*
* @since 11.0
*/
- /*
- * <? extends Object> is mostly the same as <?> to plain Java. But to nullness checkers, they
- * differ: <? extends Object> means "non-null types," while <?> means "all types."
- */
- ImmutableMap<K, V> getAllPresent(Iterable<? extends Object> keys);
+ ImmutableMap<K, V> getAllPresent(Iterable<?> keys);
/**
* Associates {@code value} with {@code key} in this cache. If the cache previously contained a
@@ -143,14 +135,12 @@
*
* @since 11.0
*/
- // For discussion of <? extends Object>, see getAllPresent.
- void invalidateAll(Iterable<? extends Object> keys);
+ void invalidateAll(Iterable<?> keys);
/** Discards all entries in the cache. */
void invalidateAll();
/** Returns the approximate number of entries in this cache. */
- @CheckReturnValue
long size();
/**
@@ -164,7 +154,6 @@
* all values is returned.
*
*/
- @CheckReturnValue
CacheStats stats();
/**
@@ -175,7 +164,6 @@
* concurrent use, but if the cache is modified (including by eviction) after the iterator is
* created, it is undefined which of the changes (if any) will be reflected in that iterator.
*/
- @CheckReturnValue
ConcurrentMap<K, V> asMap();
/**
diff --git a/guava/src/com/google/common/cache/CacheBuilder.java b/guava/src/com/google/common/cache/CacheBuilder.java
index 3537bab..944e291 100644
--- a/guava/src/com/google/common/cache/CacheBuilder.java
+++ b/guava/src/com/google/common/cache/CacheBuilder.java
@@ -41,52 +41,12 @@
import org.checkerframework.checker.nullness.qual.Nullable;
/**
- * A builder of {@link LoadingCache} and {@link Cache} instances.
- *
- * <h2>Prefer <a href="https://github.com/ben-manes/caffeine/wiki">Caffeine</a> over Guava's caching
- * API</h2>
- *
- * <p>The successor to Guava's caching API is <a
- * href="https://github.com/ben-manes/caffeine/wiki">Caffeine</a>. Its API is designed to make it a
- * nearly drop-in replacement -- though it requires Java 8 APIs and is not available for Android or
- * GWT/j2cl. Its equivalent to {@code CacheBuilder} is its <a
- * href="https://www.javadoc.io/doc/com.github.ben-manes.caffeine/caffeine/latest/com.github.benmanes.caffeine/com/github/benmanes/caffeine/cache/Caffeine.html">{@code
- * Caffeine}</a> class. Caffeine offers better performance, more features (including asynchronous
- * loading), and fewer <a
- * href="https://github.com/google/guava/issues?q=is%3Aopen+is%3Aissue+label%3Apackage%3Dcache+label%3Atype%3Ddefect">bugs</a>.
- *
- * <p>Caffeine defines its own interfaces (<a
- * href="https://www.javadoc.io/doc/com.github.ben-manes.caffeine/caffeine/latest/com.github.benmanes.caffeine/com/github/benmanes/caffeine/cache/Cache.html">{@code
- * Cache}</a>, <a
- * href="https://www.javadoc.io/doc/com.github.ben-manes.caffeine/caffeine/latest/com.github.benmanes.caffeine/com/github/benmanes/caffeine/cache/LoadingCache.html">{@code
- * LoadingCache}</a>, <a
- * href="https://www.javadoc.io/doc/com.github.ben-manes.caffeine/caffeine/latest/com.github.benmanes.caffeine/com/github/benmanes/caffeine/cache/CacheLoader.html">{@code
- * CacheLoader}</a>, etc.), so you can use Caffeine without needing to use any Guava types.
- * Caffeine's types are better than Guava's, especially for <a
- * href="https://www.javadoc.io/doc/com.github.ben-manes.caffeine/caffeine/latest/com.github.benmanes.caffeine/com/github/benmanes/caffeine/cache/AsyncLoadingCache.html">their
- * deep support for asynchronous operations</a>. But if you want to migrate to Caffeine with minimal
- * code changes, you can use <a
- * href="https://www.javadoc.io/doc/com.github.ben-manes.caffeine/guava/latest/com.github.benmanes.caffeine.guava/com/github/benmanes/caffeine/guava/CaffeinatedGuava.html">its
- * {@code CaffeinatedGuava} adapter class</a>, which lets you build a Guava {@code Cache} or a Guava
- * {@code LoadingCache} backed by a Guava {@code CacheLoader}.
- *
- * <p>Caffeine's API for asynchronous operations uses {@code CompletableFuture}: <a
- * href="https://www.javadoc.io/doc/com.github.ben-manes.caffeine/caffeine/latest/com.github.benmanes.caffeine/com/github/benmanes/caffeine/cache/AsyncLoadingCache.html#get(K)">{@code
- * AsyncLoadingCache.get}</a> returns a {@code CompletableFuture}, and implementations of <a
- * href="https://www.javadoc.io/doc/com.github.ben-manes.caffeine/caffeine/latest/com.github.benmanes.caffeine/com/github/benmanes/caffeine/cache/AsyncCacheLoader.html#asyncLoad(K,java.util.concurrent.Executor)">{@code
- * AsyncCacheLoader.asyncLoad}</a> must return a {@code CompletableFuture}. Users of Guava's {@link
- * com.google.common.util.concurrent.ListenableFuture} can adapt between the two {@code Future}
- * types by using <a href="https://github.com/lukas-krecan/future-converter#java8-guava">{@code
- * net.javacrumbs.futureconverter.java8guava.FutureConverter}</a>.
- *
- * <h2>More on {@code CacheBuilder}</h2>
- *
- * {@code CacheBuilder} builds caches with any combination of the following features:
+ * A builder of {@link LoadingCache} and {@link Cache} instances having any combination of the
+ * following features:
*
* <ul>
* <li>automatic loading of entries into the cache
- * <li>least-recently-used eviction when a maximum size is exceeded (note that the cache is
- * divided into segments, each of which does LRU internally)
+ * <li>least-recently-used eviction when a maximum size is exceeded
* <li>time-based expiration of entries, measured since last access or last write
* <li>keys automatically wrapped in {@code WeakReference}
* <li>values automatically wrapped in {@code WeakReference} or {@code SoftReference}
@@ -94,6 +54,7 @@
* <li>accumulation of cache access statistics
* </ul>
*
+ *
* <p>These features are all optional; caches can be created using all or none of them. By default
* cache instances created by {@code CacheBuilder} will not perform any type of eviction.
*
@@ -181,16 +142,15 @@
*
* @param <K> the most general key type this builder will be able to create caches for. This is
* normally {@code Object} unless it is constrained by using a method like {@code
- * #removalListener}. Cache keys may not be null.
+ * #removalListener}
* @param <V> the most general value type this builder will be able to create caches for. This is
* normally {@code Object} unless it is constrained by using a method like {@code
- * #removalListener}. Cache values may not be null.
+ * #removalListener}
* @author Charles Fry
* @author Kevin Bourrillion
* @since 10.0
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
public final class CacheBuilder<K, V> {
private static final int DEFAULT_INITIAL_CAPACITY = 16;
private static final int DEFAULT_CONCURRENCY_LEVEL = 4;
@@ -301,7 +261,6 @@
* <p>Note that while this return type is {@code CacheBuilder<Object, Object>}, type parameters on
* the {@link #build} methods allow you to create a cache of any key and value type desired.
*/
- @CheckReturnValue
public static CacheBuilder<Object, Object> newBuilder() {
return new CacheBuilder<>();
}
@@ -312,7 +271,6 @@
* @since 12.0
*/
@GwtIncompatible // To be supported
- @CheckReturnValue
public static CacheBuilder<Object, Object> from(CacheBuilderSpec spec) {
return spec.toCacheBuilder().lenientParsing();
}
@@ -325,7 +283,6 @@
* @since 12.0
*/
@GwtIncompatible // To be supported
- @CheckReturnValue
public static CacheBuilder<Object, Object> from(String spec) {
return from(CacheBuilderSpec.parse(spec));
}
@@ -520,8 +477,8 @@
this.maximumWeight);
checkState(
this.maximumSize == UNSET_INT, "maximum size was already set to %s", this.maximumSize);
- checkArgument(maximumWeight >= 0, "maximum weight must not be negative");
this.maximumWeight = maximumWeight;
+ checkArgument(maximumWeight >= 0, "maximum weight must not be negative");
return this;
}
@@ -689,7 +646,7 @@
* removed
* @return this {@code CacheBuilder} instance (for chaining)
* @throws IllegalArgumentException if {@code duration} is negative
- * @throws IllegalStateException if {@link #expireAfterWrite} was already set
+ * @throws IllegalStateException if the time to live or time to idle was already set
* @throws ArithmeticException for durations greater than +/- approximately 292 years
* @since 25.0
*/
@@ -720,7 +677,7 @@
* @param unit the unit that {@code duration} is expressed in
* @return this {@code CacheBuilder} instance (for chaining)
* @throws IllegalArgumentException if {@code duration} is negative
- * @throws IllegalStateException if {@link #expireAfterWrite} was already set
+ * @throws IllegalStateException if the time to live or time to idle was already set
*/
@SuppressWarnings("GoodTime") // should accept a java.time.Duration
public CacheBuilder<K, V> expireAfterWrite(long duration, TimeUnit unit) {
@@ -759,7 +716,7 @@
* automatically removed
* @return this {@code CacheBuilder} instance (for chaining)
* @throws IllegalArgumentException if {@code duration} is negative
- * @throws IllegalStateException if {@link #expireAfterAccess} was already set
+ * @throws IllegalStateException if the time to idle or time to live was already set
* @throws ArithmeticException for durations greater than +/- approximately 292 years
* @since 25.0
*/
@@ -795,7 +752,7 @@
* @param unit the unit that {@code duration} is expressed in
* @return this {@code CacheBuilder} instance (for chaining)
* @throws IllegalArgumentException if {@code duration} is negative
- * @throws IllegalStateException if {@link #expireAfterAccess} was already set
+ * @throws IllegalStateException if the time to idle or time to live was already set
*/
@SuppressWarnings("GoodTime") // should accept a java.time.Duration
public CacheBuilder<K, V> expireAfterAccess(long duration, TimeUnit unit) {
@@ -827,10 +784,9 @@
* operations.
*
* <p>Currently automatic refreshes are performed when the first stale request for an entry
- * occurs. The request triggering refresh will make a synchronous call to {@link
- * CacheLoader#reload}
- * to obtain a future of the new value. If the returned future is already complete, it is returned
- * immediately. Otherwise, the old value is returned.
+ * occurs. The request triggering refresh will make a blocking call to {@link CacheLoader#reload}
+ * and immediately return the new value if the returned future is complete, and the old value
+ * otherwise.
*
* <p><b>Note:</b> <i>all exceptions thrown during refresh will be logged and then swallowed</i>.
*
@@ -838,7 +794,7 @@
* stale, and thus eligible for refresh
* @return this {@code CacheBuilder} instance (for chaining)
* @throws IllegalArgumentException if {@code duration} is negative
- * @throws IllegalStateException if {@link #refreshAfterWrite} was already set
+ * @throws IllegalStateException if the refresh interval was already set
* @throws ArithmeticException for durations greater than +/- approximately 292 years
* @since 25.0
*/
@@ -861,8 +817,7 @@
* operations.
*
* <p>Currently automatic refreshes are performed when the first stale request for an entry
- * occurs. The request triggering refresh will make a synchronous call to {@link
- * CacheLoader#reload}
+ * occurs. The request triggering refresh will make a blocking call to {@link CacheLoader#reload}
* and immediately return the new value if the returned future is complete, and the old value
* otherwise.
*
@@ -876,7 +831,7 @@
* @param unit the unit that {@code duration} is expressed in
* @return this {@code CacheBuilder} instance (for chaining)
* @throws IllegalArgumentException if {@code duration} is negative
- * @throws IllegalStateException if {@link #refreshAfterWrite} was already set
+ * @throws IllegalStateException if the refresh interval was already set
* @since 11.0
*/
@GwtIncompatible // To be supported (synchronously).
@@ -991,7 +946,6 @@
* @param loader the cache loader used to obtain new values
* @return a cache having the requested features
*/
- @CheckReturnValue
public <K1 extends K, V1 extends V> LoadingCache<K1, V1> build(
CacheLoader<? super K1, V1> loader) {
checkWeightWithWeigher();
@@ -1010,7 +964,6 @@
* @return a cache having the requested features
* @since 11.0
*/
- @CheckReturnValue
public <K1 extends K, V1 extends V> Cache<K1, V1> build() {
checkWeightWithWeigher();
checkNonLoadingCache();
diff --git a/guava/src/com/google/common/cache/CacheBuilderSpec.java b/guava/src/com/google/common/cache/CacheBuilderSpec.java
index 64b5ad2..cba6721 100644
--- a/guava/src/com/google/common/cache/CacheBuilderSpec.java
+++ b/guava/src/com/google/common/cache/CacheBuilderSpec.java
@@ -15,7 +15,6 @@
package com.google.common.cache;
import static com.google.common.base.Preconditions.checkArgument;
-import static com.google.common.base.Strings.isNullOrEmpty;
import com.google.common.annotations.GwtIncompatible;
import com.google.common.annotations.VisibleForTesting;
@@ -28,7 +27,6 @@
import java.util.List;
import java.util.Locale;
import java.util.concurrent.TimeUnit;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -80,11 +78,10 @@
*/
@SuppressWarnings("GoodTime") // lots of violations (nanosecond math)
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public final class CacheBuilderSpec {
/** Parses a single value. */
private interface ValueParser {
- void parse(CacheBuilderSpec spec, String key, @CheckForNull String value);
+ void parse(CacheBuilderSpec spec, String key, @Nullable String value);
}
/** Splits each key-value pair. */
@@ -110,19 +107,19 @@
.put("refreshInterval", new RefreshDurationParser())
.build();
- @VisibleForTesting @CheckForNull Integer initialCapacity;
- @VisibleForTesting @CheckForNull Long maximumSize;
- @VisibleForTesting @CheckForNull Long maximumWeight;
- @VisibleForTesting @CheckForNull Integer concurrencyLevel;
- @VisibleForTesting @CheckForNull Strength keyStrength;
- @VisibleForTesting @CheckForNull Strength valueStrength;
- @VisibleForTesting @CheckForNull Boolean recordStats;
+ @VisibleForTesting @Nullable Integer initialCapacity;
+ @VisibleForTesting @Nullable Long maximumSize;
+ @VisibleForTesting @Nullable Long maximumWeight;
+ @VisibleForTesting @Nullable Integer concurrencyLevel;
+ @VisibleForTesting @Nullable Strength keyStrength;
+ @VisibleForTesting @Nullable Strength valueStrength;
+ @VisibleForTesting @Nullable Boolean recordStats;
@VisibleForTesting long writeExpirationDuration;
- @VisibleForTesting @CheckForNull TimeUnit writeExpirationTimeUnit;
+ @VisibleForTesting @Nullable TimeUnit writeExpirationTimeUnit;
@VisibleForTesting long accessExpirationDuration;
- @VisibleForTesting @CheckForNull TimeUnit accessExpirationTimeUnit;
+ @VisibleForTesting @Nullable TimeUnit accessExpirationTimeUnit;
@VisibleForTesting long refreshDuration;
- @VisibleForTesting @CheckForNull TimeUnit refreshTimeUnit;
+ @VisibleForTesting @Nullable TimeUnit refreshTimeUnit;
/** Specification; used for toParseableString(). */
private final String specification;
@@ -251,7 +248,7 @@
}
@Override
- public boolean equals(@CheckForNull Object obj) {
+ public boolean equals(@Nullable Object obj) {
if (this == obj) {
return true;
}
@@ -281,8 +278,7 @@
* Converts an expiration duration/unit pair into a single Long for hashing and equality. Uses
* nanos to match CacheBuilder implementation.
*/
- @CheckForNull
- private static Long durationInNanos(long duration, @CheckForNull TimeUnit unit) {
+ private static @Nullable Long durationInNanos(long duration, @Nullable TimeUnit unit) {
return (unit == null) ? null : unit.toNanos(duration);
}
@@ -291,10 +287,8 @@
protected abstract void parseInteger(CacheBuilderSpec spec, int value);
@Override
- public void parse(CacheBuilderSpec spec, String key, @Nullable String value) {
- if (isNullOrEmpty(value)) {
- throw new IllegalArgumentException("value of key " + key + " omitted");
- }
+ public void parse(CacheBuilderSpec spec, String key, String value) {
+ checkArgument(value != null && !value.isEmpty(), "value of key %s omitted", key);
try {
parseInteger(spec, Integer.parseInt(value));
} catch (NumberFormatException e) {
@@ -309,10 +303,8 @@
protected abstract void parseLong(CacheBuilderSpec spec, long value);
@Override
- public void parse(CacheBuilderSpec spec, String key, @Nullable String value) {
- if (isNullOrEmpty(value)) {
- throw new IllegalArgumentException("value of key " + key + " omitted");
- }
+ public void parse(CacheBuilderSpec spec, String key, String value) {
+ checkArgument(value != null && !value.isEmpty(), "value of key %s omitted", key);
try {
parseLong(spec, Long.parseLong(value));
} catch (NumberFormatException e) {
@@ -377,7 +369,7 @@
}
@Override
- public void parse(CacheBuilderSpec spec, String key, @CheckForNull 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;
@@ -393,7 +385,7 @@
}
@Override
- public void parse(CacheBuilderSpec spec, String key, @CheckForNull 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);
@@ -406,7 +398,7 @@
static class RecordStatsParser implements ValueParser {
@Override
- public void parse(CacheBuilderSpec spec, String key, @CheckForNull 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;
@@ -418,10 +410,8 @@
protected abstract void parseDuration(CacheBuilderSpec spec, long duration, TimeUnit unit);
@Override
- public void parse(CacheBuilderSpec spec, String key, @CheckForNull String value) {
- if (isNullOrEmpty(value)) {
- throw new IllegalArgumentException("value of key " + key + " omitted");
- }
+ public void parse(CacheBuilderSpec spec, String key, String value) {
+ checkArgument(value != null && !value.isEmpty(), "value of key %s omitted", key);
try {
char lastChar = value.charAt(value.length() - 1);
TimeUnit timeUnit;
@@ -440,7 +430,8 @@
break;
default:
throw new IllegalArgumentException(
- format("key %s invalid unit: was %s, must end with one of [dhms]", key, value));
+ format(
+ "key %s invalid format. was %s, must end with one of [dDhHmMsS]", key, value));
}
long duration = Long.parseLong(value.substring(0, value.length() - 1));
diff --git a/guava/src/com/google/common/cache/CacheLoader.java b/guava/src/com/google/common/cache/CacheLoader.java
index 7a5e017..36639fd 100644
--- a/guava/src/com/google/common/cache/CacheLoader.java
+++ b/guava/src/com/google/common/cache/CacheLoader.java
@@ -23,7 +23,6 @@
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.ListenableFutureTask;
-import com.google.errorprone.annotations.CheckReturnValue;
import java.io.Serializable;
import java.util.Map;
import java.util.concurrent.Callable;
@@ -57,7 +56,6 @@
* @since 10.0
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
public abstract class CacheLoader<K, V> {
/** Constructor for use by subclasses. */
protected CacheLoader() {}
@@ -137,7 +135,6 @@
* @param function the function to be used for loading values; must never return {@code null}
* @return a cache loader that loads values by passing each key to {@code function}
*/
- @CheckReturnValue
public static <K, V> CacheLoader<K, V> from(Function<K, V> function) {
return new FunctionToCacheLoader<>(function);
}
@@ -151,7 +148,6 @@
* @return a cache loader that loads values by calling {@link Supplier#get}, irrespective of the
* key
*/
- @CheckReturnValue
public static <V> CacheLoader<Object, V> from(Supplier<V> supplier) {
return new SupplierToCacheLoader<V>(supplier);
}
@@ -181,7 +177,6 @@
*
* @since 17.0
*/
- @CheckReturnValue
@GwtIncompatible // Executor + Futures
public static <K, V> CacheLoader<K, V> asyncReloading(
final CacheLoader<K, V> loader, final Executor executor) {
diff --git a/guava/src/com/google/common/cache/CacheStats.java b/guava/src/com/google/common/cache/CacheStats.java
index 8307e94..777d53f 100644
--- a/guava/src/com/google/common/cache/CacheStats.java
+++ b/guava/src/com/google/common/cache/CacheStats.java
@@ -22,7 +22,7 @@
import com.google.common.base.MoreObjects;
import com.google.common.base.Objects;
import java.util.concurrent.Callable;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Statistics about the performance of a {@link Cache}. Instances of this class are immutable.
@@ -57,7 +57,6 @@
* @since 10.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
public final class CacheStats {
private final long hitCount;
private final long missCount;
@@ -277,7 +276,7 @@
}
@Override
- public boolean equals(@CheckForNull 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/ElementTypesAreNonnullByDefault.java b/guava/src/com/google/common/cache/ElementTypesAreNonnullByDefault.java
deleted file mode 100644
index bcf0fce..0000000
--- a/guava/src/com/google/common/cache/ElementTypesAreNonnullByDefault.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) 2021 The Guava Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.common.cache;
-
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.PARAMETER;
-import static java.lang.annotation.ElementType.TYPE;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-import com.google.common.annotations.GwtCompatible;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-import javax.annotation.Nonnull;
-import javax.annotation.meta.TypeQualifierDefault;
-
-/**
- * Marks all "top-level" types as non-null in a way that is recognized by Kotlin. Note that this
- * unfortunately includes type-variable usages, so we also provide {@link ParametricNullness} to
- * "undo" it as best we can.
- */
-@GwtCompatible
-@Retention(RUNTIME)
-@Target(TYPE)
-@TypeQualifierDefault({FIELD, METHOD, PARAMETER})
-@Nonnull
-@interface ElementTypesAreNonnullByDefault {}
diff --git a/guava/src/com/google/common/cache/ForwardingCache.java b/guava/src/com/google/common/cache/ForwardingCache.java
index f118977..81dbf7a 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 javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* A cache which forwards all its method calls to another cache. Subclasses should override one or
@@ -33,7 +33,6 @@
* @since 10.0
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public abstract class ForwardingCache<K, V> extends ForwardingObject implements Cache<K, V> {
/** Constructor for use by subclasses. */
@@ -44,8 +43,7 @@
/** @since 11.0 */
@Override
- @CheckForNull
- public V getIfPresent(Object key) {
+ public @Nullable V getIfPresent(Object key) {
return delegate().getIfPresent(key);
}
@@ -57,11 +55,7 @@
/** @since 11.0 */
@Override
- /*
- * <? extends Object> is mostly the same as <?> to plain Java. But to nullness checkers, they
- * differ: <? extends Object> means "non-null types," while <?> means "all types."
- */
- public ImmutableMap<K, V> getAllPresent(Iterable<? extends Object> keys) {
+ public ImmutableMap<K, V> getAllPresent(Iterable<?> keys) {
return delegate().getAllPresent(keys);
}
@@ -84,8 +78,7 @@
/** @since 11.0 */
@Override
- // For discussion of <? extends Object>, see getAllPresent.
- public void invalidateAll(Iterable<? extends Object> keys) {
+ public void invalidateAll(Iterable<?> keys) {
delegate().invalidateAll(keys);
}
diff --git a/guava/src/com/google/common/cache/ForwardingLoadingCache.java b/guava/src/com/google/common/cache/ForwardingLoadingCache.java
index ecd44ca..ba88ded 100644
--- a/guava/src/com/google/common/cache/ForwardingLoadingCache.java
+++ b/guava/src/com/google/common/cache/ForwardingLoadingCache.java
@@ -31,7 +31,6 @@
* @since 11.0
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public abstract class ForwardingLoadingCache<K, V> extends ForwardingCache<K, V>
implements LoadingCache<K, V> {
diff --git a/guava/src/com/google/common/cache/LoadingCache.java b/guava/src/com/google/common/cache/LoadingCache.java
index e338ac4..6af1d3a 100644
--- a/guava/src/com/google/common/cache/LoadingCache.java
+++ b/guava/src/com/google/common/cache/LoadingCache.java
@@ -33,13 +33,10 @@
* <p>When evaluated as a {@link Function}, a cache yields the same result as invoking {@link
* #getUnchecked}.
*
- * @param <K> the type of the cache's keys, which are not permitted to be null
- * @param <V> the type of the cache's values, which are not permitted to be null
* @author Charles Fry
* @since 11.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
public interface LoadingCache<K, V> extends Cache<K, V>, Function<K, V> {
/**
@@ -133,11 +130,11 @@
V apply(K key);
/**
- * Loads a new value for {@code key}, possibly asynchronously. While the new value is loading the
- * previous value (if any) will continue to be returned by {@code get(key)} unless it is evicted.
- * If the new value is loaded successfully it will replace the previous value in the cache; if an
- * exception is thrown while refreshing the previous value will remain, <i>and the exception will
- * be logged (using {@link java.util.logging.Logger}) and swallowed</i>.
+ * Loads a new value for key {@code key}, possibly asynchronously. While the new value is loading
+ * the previous value (if any) will continue to be returned by {@code get(key)} unless it is
+ * evicted. If the new value is loaded successfully it will replace the previous value in the
+ * cache; if an exception is thrown while refreshing the previous value will remain, <i>and the
+ * exception will be logged (using {@link java.util.logging.Logger}) and swallowed</i>.
*
* <p>Caches loaded by a {@link CacheLoader} will call {@link CacheLoader#reload} if the cache
* currently contains a value for {@code key}, and {@link CacheLoader#load} otherwise. Loading is
diff --git a/guava/src/com/google/common/cache/LocalCache.java b/guava/src/com/google/common/cache/LocalCache.java
index f421781..a485ad5 100644
--- a/guava/src/com/google/common/cache/LocalCache.java
+++ b/guava/src/com/google/common/cache/LocalCache.java
@@ -97,12 +97,8 @@
* @author Bob Lee ({@code com.google.common.collect.MapMaker})
* @author Doug Lea ({@code ConcurrentHashMap})
*/
-@SuppressWarnings({
- "GoodTime", // lots of violations (nanosecond math)
- "nullness", // too much trouble for the payoff
-})
+@SuppressWarnings("GoodTime") // lots of violations (nanosecond math)
@GwtCompatible(emulated = true)
-// TODO(cpovirk): Annotate for nullness.
class LocalCache<K, V> extends AbstractMap<K, V> implements ConcurrentMap<K, V> {
/*
@@ -2192,7 +2188,7 @@
V compute(K key, int hash, BiFunction<? super K, ? super V, ? extends V> function) {
ReferenceEntry<K, V> e;
ValueReference<K, V> valueReference = null;
- ComputingValueReference<K, V> computingValueReference = null;
+ LoadingValueReference<K, V> loadingValueReference = null;
boolean createNewEntry = true;
V newValue;
@@ -2233,33 +2229,33 @@
// note valueReference can be an existing value or even itself another loading value if
// the value for the key is already being computed.
- computingValueReference = new ComputingValueReference<>(valueReference);
+ loadingValueReference = new LoadingValueReference<>(valueReference);
if (e == null) {
createNewEntry = true;
e = newEntry(key, hash, first);
- e.setValueReference(computingValueReference);
+ e.setValueReference(loadingValueReference);
table.set(index, e);
} else {
- e.setValueReference(computingValueReference);
+ e.setValueReference(loadingValueReference);
}
- newValue = computingValueReference.compute(key, function);
+ newValue = loadingValueReference.compute(key, function);
if (newValue != null) {
if (valueReference != null && newValue == valueReference.get()) {
- computingValueReference.set(newValue);
+ loadingValueReference.set(newValue);
e.setValueReference(valueReference);
recordWrite(e, 0, now); // no change in weight
return newValue;
}
try {
return getAndRecordStats(
- key, hash, computingValueReference, Futures.immediateFuture(newValue));
+ key, hash, loadingValueReference, Futures.immediateFuture(newValue));
} catch (ExecutionException exception) {
throw new AssertionError("impossible; Futures.immediateFuture can't throw");
}
- } else if (createNewEntry || valueReference.isLoading()) {
- removeLoadingValue(key, hash, computingValueReference);
+ } else if (createNewEntry) {
+ removeLoadingValue(key, hash, loadingValueReference);
return null;
} else {
removeEntry(e, hash, RemovalCause.EXPLICIT);
@@ -3607,17 +3603,6 @@
}
}
- static class ComputingValueReference<K, V> extends LoadingValueReference<K, V> {
- ComputingValueReference(ValueReference<K, V> oldValue) {
- super(oldValue);
- }
-
- @Override
- public boolean isLoading() {
- return false;
- }
- }
-
// Queues
/**
@@ -3942,7 +3927,7 @@
Segment<K, V>[] segments = this.segments;
long sum = 0;
for (int i = 0; i < segments.length; ++i) {
- sum += segments[i].count;
+ sum += Math.max(0, segments[i].count); // see https://github.com/google/guava/issues/2108
}
return sum;
}
diff --git a/guava/src/com/google/common/cache/LongAddable.java b/guava/src/com/google/common/cache/LongAddable.java
index 9851052..eaa6414 100644
--- a/guava/src/com/google/common/cache/LongAddable.java
+++ b/guava/src/com/google/common/cache/LongAddable.java
@@ -22,7 +22,6 @@
* @author Louis Wasserman
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
interface LongAddable {
void increment();
diff --git a/guava/src/com/google/common/cache/LongAddables.java b/guava/src/com/google/common/cache/LongAddables.java
index b0f9e2b..203d2ef 100644
--- a/guava/src/com/google/common/cache/LongAddables.java
+++ b/guava/src/com/google/common/cache/LongAddables.java
@@ -24,7 +24,6 @@
* @author Louis Wasserman
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
final class LongAddables {
private static final Supplier<LongAddable> SUPPLIER;
diff --git a/guava/src/com/google/common/cache/LongAdder.java b/guava/src/com/google/common/cache/LongAdder.java
index 7ead7e8..f0c44ff 100644
--- a/guava/src/com/google/common/cache/LongAdder.java
+++ b/guava/src/com/google/common/cache/LongAdder.java
@@ -40,7 +40,6 @@
* @author Doug Lea
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
final class LongAdder extends Striped64 implements Serializable, LongAddable {
private static final long serialVersionUID = 7249069246863182397L;
diff --git a/guava/src/com/google/common/cache/ParametricNullness.java b/guava/src/com/google/common/cache/ParametricNullness.java
deleted file mode 100644
index 19305a6..0000000
--- a/guava/src/com/google/common/cache/ParametricNullness.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2021 The Guava Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.common.cache;
-
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.PARAMETER;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-import static javax.annotation.meta.When.UNKNOWN;
-
-import com.google.common.annotations.GwtCompatible;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-import javax.annotation.Nonnull;
-import javax.annotation.meta.TypeQualifierNickname;
-
-/**
- * Marks a "top-level" type-variable usage as (a) a Kotlin platform type when the type argument is
- * non-nullable and (b) nullable when the type argument is nullable. This is the closest we can get
- * to "non-nullable when non-nullable; nullable when nullable" (like the Android <a
- * href="https://android.googlesource.com/platform/libcore/+/master/luni/src/main/java/libcore/util/NullFromTypeParam.java">{@code
- * NullFromTypeParam}</a>). We use this to "undo" {@link ElementTypesAreNonnullByDefault}.
- */
-@GwtCompatible
-@Retention(RUNTIME)
-@Target({FIELD, METHOD, PARAMETER})
-@TypeQualifierNickname
-@Nonnull(when = UNKNOWN)
-@interface ParametricNullness {}
diff --git a/guava/src/com/google/common/cache/ReferenceEntry.java b/guava/src/com/google/common/cache/ReferenceEntry.java
index 8ff2e6c..63bf2fe 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 javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* An entry in a reference map.
@@ -39,24 +39,22 @@
* </ul>
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
interface ReferenceEntry<K, V> {
/** Returns the value reference from this entry. */
- @CheckForNull
ValueReference<K, V> getValueReference();
/** Sets the value reference for this entry. */
void setValueReference(ValueReference<K, V> valueReference);
/** Returns the next entry in the chain. */
- @CheckForNull
+ @Nullable
ReferenceEntry<K, V> getNext();
/** Returns the entry's hash. */
int getHash();
/** Returns the key for this entry. */
- @CheckForNull
+ @Nullable
K getKey();
/*
diff --git a/guava/src/com/google/common/cache/RemovalCause.java b/guava/src/com/google/common/cache/RemovalCause.java
index 2e68e68..8ecc1d6 100644
--- a/guava/src/com/google/common/cache/RemovalCause.java
+++ b/guava/src/com/google/common/cache/RemovalCause.java
@@ -26,7 +26,6 @@
* @since 10.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
public enum RemovalCause {
/**
* The entry was manually removed by the user. This can result from the user invoking {@link
diff --git a/guava/src/com/google/common/cache/RemovalListener.java b/guava/src/com/google/common/cache/RemovalListener.java
index 4713be5..c9a343c 100644
--- a/guava/src/com/google/common/cache/RemovalListener.java
+++ b/guava/src/com/google/common/cache/RemovalListener.java
@@ -34,7 +34,6 @@
*/
@GwtCompatible
@FunctionalInterface
-@ElementTypesAreNonnullByDefault
public interface RemovalListener<K, V> {
/**
* Notifies the listener that a removal occurred at some point in the past.
diff --git a/guava/src/com/google/common/cache/RemovalListeners.java b/guava/src/com/google/common/cache/RemovalListeners.java
index d0623e7..c82b094 100644
--- a/guava/src/com/google/common/cache/RemovalListeners.java
+++ b/guava/src/com/google/common/cache/RemovalListeners.java
@@ -26,7 +26,6 @@
* @since 10.0
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public final class RemovalListeners {
private RemovalListeners() {}
diff --git a/guava/src/com/google/common/cache/RemovalNotification.java b/guava/src/com/google/common/cache/RemovalNotification.java
index dab7fe5..641d18f 100644
--- a/guava/src/com/google/common/cache/RemovalNotification.java
+++ b/guava/src/com/google/common/cache/RemovalNotification.java
@@ -18,7 +18,6 @@
import com.google.common.annotations.GwtCompatible;
import java.util.AbstractMap.SimpleImmutableEntry;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -33,9 +32,7 @@
* @since 10.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-public final class RemovalNotification<K, V>
- extends SimpleImmutableEntry<@Nullable K, @Nullable V> {
+public final class RemovalNotification<K, V> extends SimpleImmutableEntry<K, V> {
private final RemovalCause cause;
/**
@@ -46,11 +43,11 @@
* @since 19.0
*/
public static <K, V> RemovalNotification<K, V> create(
- @CheckForNull K key, @CheckForNull V value, RemovalCause cause) {
+ @Nullable K key, @Nullable V value, RemovalCause cause) {
return new RemovalNotification(key, value, cause);
}
- private RemovalNotification(@CheckForNull K key, @CheckForNull 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 0d2d75b..8c53158 100644
--- a/guava/src/com/google/common/cache/Striped64.java
+++ b/guava/src/com/google/common/cache/Striped64.java
@@ -13,7 +13,6 @@
import com.google.common.annotations.GwtIncompatible;
import java.util.Random;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -22,7 +21,6 @@
* so.
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
abstract class Striped64 extends Number {
/*
* This class maintains a lazily-initialized table of atomically
@@ -127,7 +125,7 @@
* class, we use a suboptimal int[] representation to avoid introducing a new type that can impede
* class-unloading when ThreadLocals are not removed.
*/
- static final ThreadLocal<int @Nullable []> threadHashCode = new ThreadLocal<>();
+ static final ThreadLocal<int[]> threadHashCode = new ThreadLocal<>();
/** Generator of new random hash codes */
static final Random rng = new Random();
@@ -136,7 +134,7 @@
static final int NCPU = Runtime.getRuntime().availableProcessors();
/** Table of cells. When non-null, size is a power of 2. */
- @CheckForNull 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
@@ -179,7 +177,7 @@
* @param hc the hash code holder
* @param wasUncontended false if CAS failed before call
*/
- final void retryUpdate(long x, @CheckForNull int[] hc, boolean wasUncontended) {
+ final void retryUpdate(long x, int[] hc, boolean wasUncontended) {
int h;
if (hc == null) {
threadHashCode.set(hc = new int[1]); // Initialize randomly
diff --git a/guava/src/com/google/common/cache/Weigher.java b/guava/src/com/google/common/cache/Weigher.java
index bbee3f5..7372a46 100644
--- a/guava/src/com/google/common/cache/Weigher.java
+++ b/guava/src/com/google/common/cache/Weigher.java
@@ -24,7 +24,6 @@
*/
@GwtCompatible
@FunctionalInterface
-@ElementTypesAreNonnullByDefault
public interface Weigher<K, V> {
/**
diff --git a/guava/src/com/google/common/collect/AbstractBiMap.java b/guava/src/com/google/common/collect/AbstractBiMap.java
index 9b2ad2a..68744c1 100644
--- a/guava/src/com/google/common/collect/AbstractBiMap.java
+++ b/guava/src/com/google/common/collect/AbstractBiMap.java
@@ -18,7 +18,7 @@
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkState;
-import static com.google.common.collect.NullnessCasts.uncheckedCastNullableTToT;
+import static com.google.common.collect.CollectPreconditions.checkRemove;
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.GwtIncompatible;
@@ -35,7 +35,6 @@
import java.util.Map;
import java.util.Set;
import java.util.function.BiFunction;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -48,12 +47,11 @@
* @author Mike Bostock
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
-abstract class AbstractBiMap<K extends @Nullable Object, V extends @Nullable Object>
- extends ForwardingMap<K, V> implements BiMap<K, V>, Serializable {
+abstract class AbstractBiMap<K, V> extends ForwardingMap<K, V>
+ implements BiMap<K, V>, Serializable {
- private transient Map<K, V> delegate;
- @RetainedWith transient AbstractBiMap<V, K> inverse;
+ private transient @Nullable Map<K, V> delegate;
+ @RetainedWith transient @Nullable AbstractBiMap<V, K> inverse;
/** Package-private constructor for creating a map-backed bimap. */
AbstractBiMap(Map<K, V> forward, Map<V, K> backward) {
@@ -73,15 +71,13 @@
/** Returns its input, or throws an exception if this is not a valid key. */
@CanIgnoreReturnValue
- @ParametricNullness
- K checkKey(@ParametricNullness K key) {
+ K checkKey(@Nullable K key) {
return key;
}
/** Returns its input, or throws an exception if this is not a valid value. */
@CanIgnoreReturnValue
- @ParametricNullness
- V checkValue(@ParametricNullness V value) {
+ V checkValue(@Nullable V value) {
return value;
}
@@ -110,7 +106,7 @@
// Query Operations (optimizations)
@Override
- public boolean containsValue(@CheckForNull Object value) {
+ public boolean containsValue(@Nullable Object value) {
return inverse.containsKey(value);
}
@@ -118,20 +114,17 @@
@CanIgnoreReturnValue
@Override
- @CheckForNull
- public V put(@ParametricNullness K key, @ParametricNullness V value) {
+ public V put(@Nullable K key, @Nullable V value) {
return putInBothMaps(key, value, false);
}
@CanIgnoreReturnValue
@Override
- @CheckForNull
- public V forcePut(@ParametricNullness K key, @ParametricNullness V value) {
+ public V forcePut(@Nullable K key, @Nullable V value) {
return putInBothMaps(key, value, true);
}
- @CheckForNull
- private V putInBothMaps(@ParametricNullness K key, @ParametricNullness V value, boolean force) {
+ private V putInBothMaps(@Nullable K key, @Nullable V value, boolean force) {
checkKey(key);
checkValue(value);
boolean containedKey = containsKey(key);
@@ -148,35 +141,27 @@
return oldValue;
}
- private void updateInverseMap(
- @ParametricNullness K key,
- boolean containedKey,
- @CheckForNull V oldValue,
- @ParametricNullness V newValue) {
+ private void updateInverseMap(K key, boolean containedKey, V oldValue, V newValue) {
if (containedKey) {
- // The cast is safe because of the containedKey check.
- removeFromInverseMap(uncheckedCastNullableTToT(oldValue));
+ removeFromInverseMap(oldValue);
}
inverse.delegate.put(newValue, key);
}
@CanIgnoreReturnValue
@Override
- @CheckForNull
- public V remove(@CheckForNull Object key) {
+ public V remove(@Nullable Object key) {
return containsKey(key) ? removeFromBothMaps(key) : null;
}
@CanIgnoreReturnValue
- @ParametricNullness
- private V removeFromBothMaps(@CheckForNull Object key) {
- // The cast is safe because the callers of this method first check that the key is present.
- V oldValue = uncheckedCastNullableTToT(delegate.remove(key));
+ private V removeFromBothMaps(Object key) {
+ V oldValue = delegate.remove(key);
removeFromInverseMap(oldValue);
return oldValue;
}
- private void removeFromInverseMap(@ParametricNullness V oldValue) {
+ private void removeFromInverseMap(V oldValue) {
inverse.delegate.remove(oldValue);
}
@@ -225,7 +210,7 @@
return inverse;
}
- @CheckForNull private transient Set<K> keySet;
+ private transient @Nullable Set<K> keySet;
@Override
public Set<K> keySet() {
@@ -246,7 +231,7 @@
}
@Override
- public boolean remove(@CheckForNull Object key) {
+ public boolean remove(Object key) {
if (!contains(key)) {
return false;
}
@@ -270,7 +255,7 @@
}
}
- @CheckForNull private transient Set<V> valueSet;
+ private transient @Nullable Set<V> valueSet;
@Override
public Set<V> values() {
@@ -297,13 +282,12 @@
}
@Override
- public @Nullable Object[] toArray() {
+ public Object[] toArray() {
return standardToArray();
}
@Override
- @SuppressWarnings("nullness") // bug in our checker's handling of toArray signatures
- public <T extends @Nullable Object> T[] toArray(T[] array) {
+ public <T> T[] toArray(T[] array) {
return standardToArray(array);
}
@@ -313,7 +297,7 @@
}
}
- @CheckForNull private transient Set<Entry<K, V>> entrySet;
+ private transient @Nullable Set<Entry<K, V>> entrySet;
@Override
public Set<Entry<K, V>> entrySet() {
@@ -353,7 +337,7 @@
Iterator<Entry<K, V>> entrySetIterator() {
final Iterator<Entry<K, V>> iterator = delegate.entrySet().iterator();
return new Iterator<Entry<K, V>>() {
- @CheckForNull Entry<K, V> entry;
+ @Nullable Entry<K, V> entry;
@Override
public boolean hasNext() {
@@ -368,9 +352,7 @@
@Override
public void remove() {
- if (entry == null) {
- throw new IllegalStateException("no calls to next() since the last call to remove()");
- }
+ checkRemove(entry != null);
V value = entry.getValue();
iterator.remove();
removeFromInverseMap(value);
@@ -394,15 +376,12 @@
}
@Override
- public boolean remove(@CheckForNull Object object) {
- /*
- * `o instanceof Entry` is guaranteed by `contains`, but we check it here to satisfy our
- * nullness checker.
- */
- if (!esDelegate.contains(object) || !(object instanceof Entry)) {
+ public boolean remove(Object object) {
+ if (!esDelegate.contains(object)) {
return false;
}
+ // safe because esDelegate.contains(object).
Entry<?, ?> entry = (Entry<?, ?>) object;
inverse.delegate.remove(entry.getValue());
/*
@@ -423,24 +402,16 @@
@Override
public Object[] toArray() {
- /*
- * standardToArray returns `@Nullable Object[]` rather than `Object[]` but only because it can
- * be used with collections that may contain null. This collection never contains nulls, so we
- * can treat it as a plain `Object[]`.
- */
- @SuppressWarnings("nullness")
- Object[] result = standardToArray();
- return result;
+ return standardToArray();
}
@Override
- @SuppressWarnings("nullness") // bug in our checker's handling of toArray signatures
- public <T extends @Nullable Object> T[] toArray(T[] array) {
+ public <T> T[] toArray(T[] array) {
return standardToArray(array);
}
@Override
- public boolean contains(@CheckForNull Object o) {
+ public boolean contains(Object o) {
return Maps.containsEntryImpl(delegate(), o);
}
@@ -461,8 +432,7 @@
}
/** The inverse of any other {@code AbstractBiMap} subclass. */
- static class Inverse<K extends @Nullable Object, V extends @Nullable Object>
- extends AbstractBiMap<K, V> {
+ static class Inverse<K, V> extends AbstractBiMap<K, V> {
Inverse(Map<K, V> backward, AbstractBiMap<V, K> forward) {
super(backward, forward);
}
@@ -477,14 +447,12 @@
*/
@Override
- @ParametricNullness
- K checkKey(@ParametricNullness K key) {
+ K checkKey(K key) {
return inverse.checkValue(key);
}
@Override
- @ParametricNullness
- V checkValue(@ParametricNullness V value) {
+ V checkValue(V value) {
return inverse.checkKey(value);
}
diff --git a/guava/src/com/google/common/collect/AbstractIndexedListIterator.java b/guava/src/com/google/common/collect/AbstractIndexedListIterator.java
index abb3960..855fb1c 100644
--- a/guava/src/com/google/common/collect/AbstractIndexedListIterator.java
+++ b/guava/src/com/google/common/collect/AbstractIndexedListIterator.java
@@ -21,7 +21,6 @@
import com.google.common.annotations.GwtCompatible;
import java.util.ListIterator;
import java.util.NoSuchElementException;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* This class provides a skeletal implementation of the {@link ListIterator} interface across a
@@ -31,14 +30,11 @@
* @author Jared Levy
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-abstract class AbstractIndexedListIterator<E extends @Nullable Object>
- extends UnmodifiableListIterator<E> {
+abstract class AbstractIndexedListIterator<E> extends UnmodifiableListIterator<E> {
private final int size;
private int position;
/** Returns the element with the specified index. This method is called by {@link #next()}. */
- @ParametricNullness
protected abstract E get(int index);
/**
@@ -74,7 +70,6 @@
}
@Override
- @ParametricNullness
public final E next() {
if (!hasNext()) {
throw new NoSuchElementException();
@@ -93,7 +88,6 @@
}
@Override
- @ParametricNullness
public final E previous() {
if (!hasPrevious()) {
throw new NoSuchElementException();
diff --git a/guava/src/com/google/common/collect/AbstractIterator.java b/guava/src/com/google/common/collect/AbstractIterator.java
index 66273f4..ff009c5 100644
--- a/guava/src/com/google/common/collect/AbstractIterator.java
+++ b/guava/src/com/google/common/collect/AbstractIterator.java
@@ -17,12 +17,10 @@
package com.google.common.collect;
import static com.google.common.base.Preconditions.checkState;
-import static com.google.common.collect.NullnessCasts.uncheckedCastNullableTToT;
import com.google.common.annotations.GwtCompatible;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import java.util.NoSuchElementException;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -63,8 +61,7 @@
// When making changes to this class, please also update the copy at
// com.google.common.base.AbstractIterator
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-public abstract class AbstractIterator<T extends @Nullable Object> extends UnmodifiableIterator<T> {
+public abstract class AbstractIterator<T> extends UnmodifiableIterator<T> {
private State state = State.NOT_READY;
/** Constructor for use by subclasses. */
@@ -84,7 +81,7 @@
FAILED,
}
- @CheckForNull private T next;
+ private @Nullable T next;
/**
* Returns the next element. <b>Note:</b> the implementation must call {@link #endOfData()} when
@@ -110,7 +107,6 @@
* this method. Any further attempts to use the iterator will result in an {@link
* IllegalStateException}.
*/
- @CheckForNull
protected abstract T computeNext();
/**
@@ -121,7 +117,6 @@
* simple statement {@code return endOfData();}
*/
@CanIgnoreReturnValue
- @CheckForNull
protected final T endOfData() {
state = State.DONE;
return null;
@@ -153,14 +148,12 @@
@CanIgnoreReturnValue // TODO(kak): Should we remove this?
@Override
- @ParametricNullness
public final T next() {
if (!hasNext()) {
throw new NoSuchElementException();
}
state = State.NOT_READY;
- // Safe because hasNext() ensures that tryToComputeNext() has put a T into `next`.
- T result = uncheckedCastNullableTToT(next);
+ T result = next;
next = null;
return result;
}
@@ -172,12 +165,10 @@
* <p>Implementations of {@code AbstractIterator} that wish to expose this functionality should
* implement {@code PeekingIterator}.
*/
- @ParametricNullness
public final T peek() {
if (!hasNext()) {
throw new NoSuchElementException();
}
- // Safe because hasNext() ensures that tryToComputeNext() has put a T into `next`.
- return uncheckedCastNullableTToT(next);
+ return next;
}
}
diff --git a/guava/src/com/google/common/collect/AbstractListMultimap.java b/guava/src/com/google/common/collect/AbstractListMultimap.java
index 46c4ee2..d1c87c9 100644
--- a/guava/src/com/google/common/collect/AbstractListMultimap.java
+++ b/guava/src/com/google/common/collect/AbstractListMultimap.java
@@ -22,7 +22,6 @@
import java.util.Collections;
import java.util.List;
import java.util.Map;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -34,9 +33,8 @@
* @since 2.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-abstract class AbstractListMultimap<K extends @Nullable Object, V extends @Nullable Object>
- extends AbstractMapBasedMultimap<K, V> implements ListMultimap<K, V> {
+abstract class AbstractListMultimap<K, V> extends AbstractMapBasedMultimap<K, V>
+ implements ListMultimap<K, V> {
/**
* Creates a new multimap that uses the provided map.
*
@@ -55,13 +53,12 @@
}
@Override
- <E extends @Nullable Object> Collection<E> unmodifiableCollectionSubclass(
- Collection<E> collection) {
+ <E> Collection<E> unmodifiableCollectionSubclass(Collection<E> collection) {
return Collections.unmodifiableList((List<E>) collection);
}
@Override
- Collection<V> wrapCollection(@ParametricNullness K key, Collection<V> collection) {
+ Collection<V> wrapCollection(K key, Collection<V> collection) {
return wrapList(key, (List<V>) collection, null);
}
@@ -75,7 +72,7 @@
* Multimap} interface.
*/
@Override
- public List<V> get(@ParametricNullness K key) {
+ public List<V> get(@Nullable K key) {
return (List<V>) super.get(key);
}
@@ -88,7 +85,7 @@
*/
@CanIgnoreReturnValue
@Override
- public List<V> removeAll(@CheckForNull Object key) {
+ public List<V> removeAll(@Nullable Object key) {
return (List<V>) super.removeAll(key);
}
@@ -101,7 +98,7 @@
*/
@CanIgnoreReturnValue
@Override
- public List<V> replaceValues(@ParametricNullness K key, Iterable<? extends V> values) {
+ public List<V> replaceValues(@Nullable K key, Iterable<? extends V> values) {
return (List<V>) super.replaceValues(key, values);
}
@@ -114,7 +111,7 @@
*/
@CanIgnoreReturnValue
@Override
- public boolean put(@ParametricNullness K key, @ParametricNullness V value) {
+ public boolean put(@Nullable K key, @Nullable V value) {
return super.put(key, value);
}
@@ -136,7 +133,7 @@
* in the same order. If the value orderings disagree, the multimaps will not be considered equal.
*/
@Override
- public boolean equals(@CheckForNull 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 4c5a0f0..b9f46ed 100644
--- a/guava/src/com/google/common/collect/AbstractMapBasedMultimap.java
+++ b/guava/src/com/google/common/collect/AbstractMapBasedMultimap.java
@@ -18,9 +18,7 @@
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.base.Preconditions.checkState;
-import static com.google.common.collect.NullnessCasts.uncheckedCastNullableTToT;
-import static java.util.Objects.requireNonNull;
+import static com.google.common.collect.CollectPreconditions.checkRemove;
import com.google.common.annotations.GwtCompatible;
import com.google.common.collect.Maps.ViewCachingAbstractMap;
@@ -44,7 +42,6 @@
import java.util.SortedSet;
import java.util.Spliterator;
import java.util.function.BiConsumer;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -86,9 +83,8 @@
* @author Louis Wasserman
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-abstract class AbstractMapBasedMultimap<K extends @Nullable Object, V extends @Nullable Object>
- extends AbstractMultimap<K, V> implements Serializable {
+abstract class AbstractMapBasedMultimap<K, V> extends AbstractMultimap<K, V>
+ implements Serializable {
/*
* Here's an outline of the overall design.
*
@@ -161,7 +157,7 @@
* @param key key to associate with values in the collection
* @return an empty collection of values
*/
- Collection<V> createCollection(@ParametricNullness K key) {
+ Collection<V> createCollection(@Nullable K key) {
return createCollection();
}
@@ -177,14 +173,14 @@
}
@Override
- public boolean containsKey(@CheckForNull Object key) {
+ public boolean containsKey(@Nullable Object key) {
return map.containsKey(key);
}
// Modification Operations
@Override
- public boolean put(@ParametricNullness K key, @ParametricNullness V value) {
+ public boolean put(@Nullable K key, @Nullable V value) {
Collection<V> collection = map.get(key);
if (collection == null) {
collection = createCollection(key);
@@ -203,7 +199,7 @@
}
}
- private Collection<V> getOrCreateCollection(@ParametricNullness K key) {
+ private Collection<V> getOrCreateCollection(@Nullable K key) {
Collection<V> collection = map.get(key);
if (collection == null) {
collection = createCollection(key);
@@ -220,7 +216,7 @@
* <p>The returned collection is immutable.
*/
@Override
- public Collection<V> replaceValues(@ParametricNullness K key, Iterable<? extends V> values) {
+ public Collection<V> replaceValues(@Nullable K key, Iterable<? extends V> values) {
Iterator<? extends V> iterator = values.iterator();
if (!iterator.hasNext()) {
return removeAll(key);
@@ -249,7 +245,7 @@
* <p>The returned collection is immutable.
*/
@Override
- public Collection<V> removeAll(@CheckForNull Object key) {
+ public Collection<V> removeAll(@Nullable Object key) {
Collection<V> collection = map.remove(key);
if (collection == null) {
@@ -264,8 +260,7 @@
return unmodifiableCollectionSubclass(output);
}
- <E extends @Nullable Object> Collection<E> unmodifiableCollectionSubclass(
- Collection<E> collection) {
+ <E> Collection<E> unmodifiableCollectionSubclass(Collection<E> collection) {
return Collections.unmodifiableCollection(collection);
}
@@ -287,7 +282,7 @@
* <p>The returned collection is not serializable.
*/
@Override
- public Collection<V> get(@ParametricNullness K key) {
+ public Collection<V> get(@Nullable K key) {
Collection<V> collection = map.get(key);
if (collection == null) {
collection = createCollection(key);
@@ -299,12 +294,11 @@
* 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<V> wrapCollection(@ParametricNullness K key, Collection<V> collection) {
+ Collection<V> wrapCollection(@Nullable K key, Collection<V> collection) {
return new WrappedCollection(key, collection, null);
}
- final List<V> wrapList(
- @ParametricNullness K key, List<V> list, @CheckForNull WrappedCollection ancestor) {
+ final List<V> wrapList(@Nullable K key, List<V> list, @Nullable WrappedCollection ancestor) {
return (list instanceof RandomAccess)
? new RandomAccessWrappedList(key, list, ancestor)
: new WrappedList(key, list, ancestor);
@@ -327,15 +321,13 @@
*/
@WeakOuter
class WrappedCollection extends AbstractCollection<V> {
- @ParametricNullness final K key;
+ final @Nullable K key;
Collection<V> delegate;
- @CheckForNull final WrappedCollection ancestor;
- @CheckForNull final Collection<V> ancestorDelegate;
+ final @Nullable WrappedCollection ancestor;
+ final @Nullable Collection<V> ancestorDelegate;
WrappedCollection(
- @ParametricNullness K key,
- Collection<V> delegate,
- @CheckForNull WrappedCollection ancestor) {
+ @Nullable K key, Collection<V> delegate, @Nullable WrappedCollection ancestor) {
this.key = key;
this.delegate = delegate;
this.ancestor = ancestor;
@@ -375,7 +367,6 @@
}
}
- @ParametricNullness
K getKey() {
return key;
}
@@ -401,7 +392,7 @@
}
@Override
- public boolean equals(@CheckForNull Object object) {
+ public boolean equals(@Nullable Object object) {
if (object == this) {
return true;
}
@@ -467,7 +458,6 @@
}
@Override
- @ParametricNullness
public V next() {
validateIterator();
return delegateIterator.next();
@@ -487,7 +477,7 @@
}
@Override
- public boolean add(@ParametricNullness V value) {
+ public boolean add(V value) {
refreshIfEmpty();
boolean wasEmpty = delegate.isEmpty();
boolean changed = delegate.add(value);
@@ -500,7 +490,6 @@
return changed;
}
- @CheckForNull
WrappedCollection getAncestor() {
return ancestor;
}
@@ -525,7 +514,7 @@
}
@Override
- public boolean contains(@CheckForNull Object o) {
+ public boolean contains(Object o) {
refreshIfEmpty();
return delegate.contains(o);
}
@@ -548,7 +537,7 @@
}
@Override
- public boolean remove(@CheckForNull Object o) {
+ public boolean remove(Object o) {
refreshIfEmpty();
boolean changed = delegate.remove(o);
if (changed) {
@@ -587,8 +576,7 @@
}
}
- private static <E extends @Nullable Object> Iterator<E> iteratorOrListIterator(
- Collection<E> collection) {
+ private static <E> Iterator<E> iteratorOrListIterator(Collection<E> collection) {
return (collection instanceof List)
? ((List<E>) collection).listIterator()
: collection.iterator();
@@ -597,7 +585,7 @@
/** Set decorator that stays in sync with the multimap values for a key. */
@WeakOuter
class WrappedSet extends WrappedCollection implements Set<V> {
- WrappedSet(@ParametricNullness K key, Set<V> delegate) {
+ WrappedSet(@Nullable K key, Set<V> delegate) {
super(key, delegate, null);
}
@@ -624,10 +612,7 @@
/** SortedSet decorator that stays in sync with the multimap values for a key. */
@WeakOuter
class WrappedSortedSet extends WrappedCollection implements SortedSet<V> {
- WrappedSortedSet(
- @ParametricNullness K key,
- SortedSet<V> delegate,
- @CheckForNull WrappedCollection ancestor) {
+ WrappedSortedSet(@Nullable K key, SortedSet<V> delegate, @Nullable WrappedCollection ancestor) {
super(key, delegate, ancestor);
}
@@ -636,27 +621,24 @@
}
@Override
- @CheckForNull
public Comparator<? super V> comparator() {
return getSortedSetDelegate().comparator();
}
@Override
- @ParametricNullness
public V first() {
refreshIfEmpty();
return getSortedSetDelegate().first();
}
@Override
- @ParametricNullness
public V last() {
refreshIfEmpty();
return getSortedSetDelegate().last();
}
@Override
- public SortedSet<V> headSet(@ParametricNullness V toElement) {
+ public SortedSet<V> headSet(V toElement) {
refreshIfEmpty();
return new WrappedSortedSet(
getKey(),
@@ -665,7 +647,7 @@
}
@Override
- public SortedSet<V> subSet(@ParametricNullness V fromElement, @ParametricNullness V toElement) {
+ public SortedSet<V> subSet(V fromElement, V toElement) {
refreshIfEmpty();
return new WrappedSortedSet(
getKey(),
@@ -674,7 +656,7 @@
}
@Override
- public SortedSet<V> tailSet(@ParametricNullness V fromElement) {
+ public SortedSet<V> tailSet(V fromElement) {
refreshIfEmpty();
return new WrappedSortedSet(
getKey(),
@@ -686,9 +668,7 @@
@WeakOuter
class WrappedNavigableSet extends WrappedSortedSet implements NavigableSet<V> {
WrappedNavigableSet(
- @ParametricNullness K key,
- NavigableSet<V> delegate,
- @CheckForNull WrappedCollection ancestor) {
+ @Nullable K key, NavigableSet<V> delegate, @Nullable WrappedCollection ancestor) {
super(key, delegate, ancestor);
}
@@ -698,37 +678,31 @@
}
@Override
- @CheckForNull
- public V lower(@ParametricNullness V v) {
+ public V lower(V v) {
return getSortedSetDelegate().lower(v);
}
@Override
- @CheckForNull
- public V floor(@ParametricNullness V v) {
+ public V floor(V v) {
return getSortedSetDelegate().floor(v);
}
@Override
- @CheckForNull
- public V ceiling(@ParametricNullness V v) {
+ public V ceiling(V v) {
return getSortedSetDelegate().ceiling(v);
}
@Override
- @CheckForNull
- public V higher(@ParametricNullness V v) {
+ public V higher(V v) {
return getSortedSetDelegate().higher(v);
}
@Override
- @CheckForNull
public V pollFirst() {
return Iterators.pollNext(iterator());
}
@Override
- @CheckForNull
public V pollLast() {
return Iterators.pollNext(descendingIterator());
}
@@ -749,21 +723,18 @@
@Override
public NavigableSet<V> subSet(
- @ParametricNullness V fromElement,
- boolean fromInclusive,
- @ParametricNullness V toElement,
- boolean toInclusive) {
+ V fromElement, boolean fromInclusive, V toElement, boolean toInclusive) {
return wrap(
getSortedSetDelegate().subSet(fromElement, fromInclusive, toElement, toInclusive));
}
@Override
- public NavigableSet<V> headSet(@ParametricNullness V toElement, boolean inclusive) {
+ public NavigableSet<V> headSet(V toElement, boolean inclusive) {
return wrap(getSortedSetDelegate().headSet(toElement, inclusive));
}
@Override
- public NavigableSet<V> tailSet(@ParametricNullness V fromElement, boolean inclusive) {
+ public NavigableSet<V> tailSet(V fromElement, boolean inclusive) {
return wrap(getSortedSetDelegate().tailSet(fromElement, inclusive));
}
}
@@ -771,8 +742,7 @@
/** List decorator that stays in sync with the multimap values for a key. */
@WeakOuter
class WrappedList extends WrappedCollection implements List<V> {
- WrappedList(
- @ParametricNullness K key, List<V> delegate, @CheckForNull WrappedCollection ancestor) {
+ WrappedList(@Nullable K key, List<V> delegate, @Nullable WrappedCollection ancestor) {
super(key, delegate, ancestor);
}
@@ -798,21 +768,19 @@
}
@Override
- @ParametricNullness
public V get(int index) {
refreshIfEmpty();
return getListDelegate().get(index);
}
@Override
- @ParametricNullness
- public V set(int index, @ParametricNullness V element) {
+ public V set(int index, V element) {
refreshIfEmpty();
return getListDelegate().set(index, element);
}
@Override
- public void add(int index, @ParametricNullness V element) {
+ public void add(int index, V element) {
refreshIfEmpty();
boolean wasEmpty = getDelegate().isEmpty();
getListDelegate().add(index, element);
@@ -823,7 +791,6 @@
}
@Override
- @ParametricNullness
public V remove(int index) {
refreshIfEmpty();
V value = getListDelegate().remove(index);
@@ -833,13 +800,13 @@
}
@Override
- public int indexOf(@CheckForNull Object o) {
+ public int indexOf(Object o) {
refreshIfEmpty();
return getListDelegate().indexOf(o);
}
@Override
- public int lastIndexOf(@CheckForNull Object o) {
+ public int lastIndexOf(Object o) {
refreshIfEmpty();
return getListDelegate().lastIndexOf(o);
}
@@ -883,7 +850,6 @@
}
@Override
- @ParametricNullness
public V previous() {
return getDelegateListIterator().previous();
}
@@ -899,12 +865,12 @@
}
@Override
- public void set(@ParametricNullness V value) {
+ public void set(V value) {
getDelegateListIterator().set(value);
}
@Override
- public void add(@ParametricNullness V value) {
+ public void add(V value) {
boolean wasEmpty = isEmpty();
getDelegateListIterator().add(value);
totalSize++;
@@ -921,7 +887,7 @@
*/
private class RandomAccessWrappedList extends WrappedList implements RandomAccess {
RandomAccessWrappedList(
- @ParametricNullness K key, List<V> delegate, @CheckForNull WrappedCollection ancestor) {
+ @Nullable K key, List<V> delegate, @Nullable WrappedCollection ancestor) {
super(key, delegate, ancestor);
}
}
@@ -951,7 +917,7 @@
public Iterator<K> iterator() {
final Iterator<Entry<K, Collection<V>>> entryIterator = map().entrySet().iterator();
return new Iterator<K>() {
- @CheckForNull Entry<K, Collection<V>> entry;
+ @Nullable Entry<K, Collection<V>> entry;
@Override
public boolean hasNext() {
@@ -959,7 +925,6 @@
}
@Override
- @ParametricNullness
public K next() {
entry = entryIterator.next();
return entry.getKey();
@@ -967,7 +932,7 @@
@Override
public void remove() {
- checkState(entry != null, "no calls to next() since the last call to remove()");
+ checkRemove(entry != null);
Collection<V> collection = entry.getValue();
entryIterator.remove();
totalSize -= collection.size();
@@ -985,7 +950,7 @@
}
@Override
- public boolean remove(@CheckForNull Object key) {
+ public boolean remove(Object key) {
int count = 0;
Collection<V> collection = map().remove(key);
if (collection != null) {
@@ -1007,7 +972,7 @@
}
@Override
- public boolean equals(@CheckForNull Object object) {
+ public boolean equals(@Nullable Object object) {
return this == object || this.map().keySet().equals(object);
}
@@ -1029,35 +994,32 @@
}
@Override
- @CheckForNull
public Comparator<? super K> comparator() {
return sortedMap().comparator();
}
@Override
- @ParametricNullness
public K first() {
return sortedMap().firstKey();
}
@Override
- public SortedSet<K> headSet(@ParametricNullness K toElement) {
+ public SortedSet<K> headSet(K toElement) {
return new SortedKeySet(sortedMap().headMap(toElement));
}
@Override
- @ParametricNullness
public K last() {
return sortedMap().lastKey();
}
@Override
- public SortedSet<K> subSet(@ParametricNullness K fromElement, @ParametricNullness K toElement) {
+ public SortedSet<K> subSet(K fromElement, K toElement) {
return new SortedKeySet(sortedMap().subMap(fromElement, toElement));
}
@Override
- public SortedSet<K> tailSet(@ParametricNullness K fromElement) {
+ public SortedSet<K> tailSet(K fromElement) {
return new SortedKeySet(sortedMap().tailMap(fromElement));
}
}
@@ -1074,37 +1036,31 @@
}
@Override
- @CheckForNull
- public K lower(@ParametricNullness K k) {
+ public K lower(K k) {
return sortedMap().lowerKey(k);
}
@Override
- @CheckForNull
- public K floor(@ParametricNullness K k) {
+ public K floor(K k) {
return sortedMap().floorKey(k);
}
@Override
- @CheckForNull
- public K ceiling(@ParametricNullness K k) {
+ public K ceiling(K k) {
return sortedMap().ceilingKey(k);
}
@Override
- @CheckForNull
- public K higher(@ParametricNullness K k) {
+ public K higher(K k) {
return sortedMap().higherKey(k);
}
@Override
- @CheckForNull
public K pollFirst() {
return Iterators.pollNext(iterator());
}
@Override
- @CheckForNull
public K pollLast() {
return Iterators.pollNext(descendingIterator());
}
@@ -1120,44 +1076,40 @@
}
@Override
- public NavigableSet<K> headSet(@ParametricNullness K toElement) {
+ public NavigableSet<K> headSet(K toElement) {
return headSet(toElement, false);
}
@Override
- public NavigableSet<K> headSet(@ParametricNullness K toElement, boolean inclusive) {
+ public NavigableSet<K> headSet(K toElement, boolean inclusive) {
return new NavigableKeySet(sortedMap().headMap(toElement, inclusive));
}
@Override
- public NavigableSet<K> subSet(
- @ParametricNullness K fromElement, @ParametricNullness K toElement) {
+ public NavigableSet<K> subSet(K fromElement, K toElement) {
return subSet(fromElement, true, toElement, false);
}
@Override
public NavigableSet<K> subSet(
- @ParametricNullness K fromElement,
- boolean fromInclusive,
- @ParametricNullness K toElement,
- boolean toInclusive) {
+ K fromElement, boolean fromInclusive, K toElement, boolean toInclusive) {
return new NavigableKeySet(
sortedMap().subMap(fromElement, fromInclusive, toElement, toInclusive));
}
@Override
- public NavigableSet<K> tailSet(@ParametricNullness K fromElement) {
+ public NavigableSet<K> tailSet(K fromElement) {
return tailSet(fromElement, true);
}
@Override
- public NavigableSet<K> tailSet(@ParametricNullness K fromElement, boolean inclusive) {
+ public NavigableSet<K> tailSet(K fromElement, boolean inclusive) {
return new NavigableKeySet(sortedMap().tailMap(fromElement, inclusive));
}
}
/** Removes all values for the provided key. */
- private void removeValuesForKey(@CheckForNull Object key) {
+ private void removeValuesForKey(Object key) {
Collection<V> collection = Maps.safeRemove(map, key);
if (collection != null) {
@@ -1167,10 +1119,10 @@
}
}
- private abstract class Itr<T extends @Nullable Object> implements Iterator<T> {
+ private abstract class Itr<T> implements Iterator<T> {
final Iterator<Entry<K, Collection<V>>> keyIterator;
- @CheckForNull K key;
- @CheckForNull Collection<V> collection;
+ @Nullable K key;
+ @Nullable Collection<V> collection;
Iterator<V> valueIterator;
Itr() {
@@ -1180,7 +1132,7 @@
valueIterator = Iterators.emptyModifiableIterator();
}
- abstract T output(@ParametricNullness K key, @ParametricNullness V value);
+ abstract T output(K key, V value);
@Override
public boolean hasNext() {
@@ -1195,21 +1147,13 @@
collection = mapEntry.getValue();
valueIterator = collection.iterator();
}
- /*
- * uncheckedCastNullableTToT is safe: The first call to this method always enters the !hasNext() case and
- * populates key, after which it's never cleared.
- */
- return output(uncheckedCastNullableTToT(key), valueIterator.next());
+ return output(key, valueIterator.next());
}
@Override
public void remove() {
valueIterator.remove();
- /*
- * requireNonNull is safe because we've already initialized `collection`. If we hadn't, then
- * valueIterator.remove() would have failed.
- */
- if (requireNonNull(collection).isEmpty()) {
+ if (collection.isEmpty()) {
keyIterator.remove();
}
totalSize--;
@@ -1236,8 +1180,7 @@
Iterator<V> valueIterator() {
return new Itr<V>() {
@Override
- @ParametricNullness
- V output(@ParametricNullness K key, @ParametricNullness V value) {
+ V output(K key, V value) {
return value;
}
};
@@ -1295,7 +1238,7 @@
Iterator<Entry<K, V>> entryIterator() {
return new Itr<Entry<K, V>>() {
@Override
- Entry<K, V> output(@ParametricNullness K key, @ParametricNullness V value) {
+ Entry<K, V> output(K key, V value) {
return Maps.immutableEntry(key, value);
}
};
@@ -1357,13 +1300,12 @@
// The following methods are included for performance.
@Override
- public boolean containsKey(@CheckForNull Object key) {
+ public boolean containsKey(Object key) {
return Maps.safeContainsKey(submap, key);
}
@Override
- @CheckForNull
- public Collection<V> get(@CheckForNull Object key) {
+ public Collection<V> get(Object key) {
Collection<V> collection = Maps.safeGet(submap, key);
if (collection == null) {
return null;
@@ -1384,8 +1326,7 @@
}
@Override
- @CheckForNull
- public Collection<V> remove(@CheckForNull Object key) {
+ public Collection<V> remove(Object key) {
Collection<V> collection = submap.remove(key);
if (collection == null) {
return null;
@@ -1399,7 +1340,7 @@
}
@Override
- public boolean equals(@CheckForNull Object object) {
+ public boolean equals(@Nullable Object object) {
return this == object || submap.equals(object);
}
@@ -1447,17 +1388,16 @@
// The following methods are included for performance.
@Override
- public boolean contains(@CheckForNull Object o) {
+ public boolean contains(Object o) {
return Collections2.safeContains(submap.entrySet(), o);
}
@Override
- public boolean remove(@CheckForNull Object o) {
+ public boolean remove(Object o) {
if (!contains(o)) {
return false;
}
- // requireNonNull is safe because of the contains check.
- Entry<?, ?> entry = requireNonNull((Entry<?, ?>) o);
+ Entry<?, ?> entry = (Entry<?, ?>) o;
removeValuesForKey(entry.getKey());
return true;
}
@@ -1466,7 +1406,7 @@
/** Iterator across all keys and value collections. */
class AsMapIterator implements Iterator<Entry<K, Collection<V>>> {
final Iterator<Entry<K, Collection<V>>> delegateIterator = submap.entrySet().iterator();
- @CheckForNull Collection<V> collection;
+ @Nullable Collection<V> collection;
@Override
public boolean hasNext() {
@@ -1482,7 +1422,7 @@
@Override
public void remove() {
- checkState(collection != null, "no calls to next() since the last call to remove()");
+ checkRemove(collection != null);
delegateIterator.remove();
totalSize -= collection.size();
collection.clear();
@@ -1502,40 +1442,36 @@
}
@Override
- @CheckForNull
public Comparator<? super K> comparator() {
return sortedMap().comparator();
}
@Override
- @ParametricNullness
public K firstKey() {
return sortedMap().firstKey();
}
@Override
- @ParametricNullness
public K lastKey() {
return sortedMap().lastKey();
}
@Override
- public SortedMap<K, Collection<V>> headMap(@ParametricNullness K toKey) {
+ public SortedMap<K, Collection<V>> headMap(K toKey) {
return new SortedAsMap(sortedMap().headMap(toKey));
}
@Override
- public SortedMap<K, Collection<V>> subMap(
- @ParametricNullness K fromKey, @ParametricNullness K toKey) {
+ public SortedMap<K, Collection<V>> subMap(K fromKey, K toKey) {
return new SortedAsMap(sortedMap().subMap(fromKey, toKey));
}
@Override
- public SortedMap<K, Collection<V>> tailMap(@ParametricNullness K fromKey) {
+ public SortedMap<K, Collection<V>> tailMap(K fromKey) {
return new SortedAsMap(sortedMap().tailMap(fromKey));
}
- @CheckForNull SortedSet<K> sortedKeySet;
+ @Nullable SortedSet<K> sortedKeySet;
// returns a SortedSet, even though returning a Set would be sufficient to
// satisfy the SortedMap.keySet() interface
@@ -1563,84 +1499,71 @@
}
@Override
- @CheckForNull
- public Entry<K, Collection<V>> lowerEntry(@ParametricNullness K key) {
+ public Entry<K, Collection<V>> lowerEntry(K key) {
Entry<K, Collection<V>> entry = sortedMap().lowerEntry(key);
return (entry == null) ? null : wrapEntry(entry);
}
@Override
- @CheckForNull
- public K lowerKey(@ParametricNullness K key) {
+ public K lowerKey(K key) {
return sortedMap().lowerKey(key);
}
@Override
- @CheckForNull
- public Entry<K, Collection<V>> floorEntry(@ParametricNullness K key) {
+ public Entry<K, Collection<V>> floorEntry(K key) {
Entry<K, Collection<V>> entry = sortedMap().floorEntry(key);
return (entry == null) ? null : wrapEntry(entry);
}
@Override
- @CheckForNull
- public K floorKey(@ParametricNullness K key) {
+ public K floorKey(K key) {
return sortedMap().floorKey(key);
}
@Override
- @CheckForNull
- public Entry<K, Collection<V>> ceilingEntry(@ParametricNullness K key) {
+ public Entry<K, Collection<V>> ceilingEntry(K key) {
Entry<K, Collection<V>> entry = sortedMap().ceilingEntry(key);
return (entry == null) ? null : wrapEntry(entry);
}
@Override
- @CheckForNull
- public K ceilingKey(@ParametricNullness K key) {
+ public K ceilingKey(K key) {
return sortedMap().ceilingKey(key);
}
@Override
- @CheckForNull
- public Entry<K, Collection<V>> higherEntry(@ParametricNullness K key) {
+ public Entry<K, Collection<V>> higherEntry(K key) {
Entry<K, Collection<V>> entry = sortedMap().higherEntry(key);
return (entry == null) ? null : wrapEntry(entry);
}
@Override
- @CheckForNull
- public K higherKey(@ParametricNullness K key) {
+ public K higherKey(K key) {
return sortedMap().higherKey(key);
}
@Override
- @CheckForNull
public Entry<K, Collection<V>> firstEntry() {
Entry<K, Collection<V>> entry = sortedMap().firstEntry();
return (entry == null) ? null : wrapEntry(entry);
}
@Override
- @CheckForNull
public Entry<K, Collection<V>> lastEntry() {
Entry<K, Collection<V>> entry = sortedMap().lastEntry();
return (entry == null) ? null : wrapEntry(entry);
}
@Override
- @CheckForNull
public Entry<K, Collection<V>> pollFirstEntry() {
return pollAsMapEntry(entrySet().iterator());
}
@Override
- @CheckForNull
public Entry<K, Collection<V>> pollLastEntry() {
return pollAsMapEntry(descendingMap().entrySet().iterator());
}
- @CheckForNull
Entry<K, Collection<V>> pollAsMapEntry(Iterator<Entry<K, Collection<V>>> entryIterator) {
if (!entryIterator.hasNext()) {
return null;
@@ -1678,38 +1601,33 @@
}
@Override
- public NavigableMap<K, Collection<V>> subMap(
- @ParametricNullness K fromKey, @ParametricNullness K toKey) {
+ public NavigableMap<K, Collection<V>> subMap(K fromKey, K toKey) {
return subMap(fromKey, true, toKey, false);
}
@Override
public NavigableMap<K, Collection<V>> subMap(
- @ParametricNullness K fromKey,
- boolean fromInclusive,
- @ParametricNullness K toKey,
- boolean toInclusive) {
+ K fromKey, boolean fromInclusive, K toKey, boolean toInclusive) {
return new NavigableAsMap(sortedMap().subMap(fromKey, fromInclusive, toKey, toInclusive));
}
@Override
- public NavigableMap<K, Collection<V>> headMap(@ParametricNullness K toKey) {
+ public NavigableMap<K, Collection<V>> headMap(K toKey) {
return headMap(toKey, false);
}
@Override
- public NavigableMap<K, Collection<V>> headMap(@ParametricNullness K toKey, boolean inclusive) {
+ public NavigableMap<K, Collection<V>> headMap(K toKey, boolean inclusive) {
return new NavigableAsMap(sortedMap().headMap(toKey, inclusive));
}
@Override
- public NavigableMap<K, Collection<V>> tailMap(@ParametricNullness K fromKey) {
+ public NavigableMap<K, Collection<V>> tailMap(K fromKey) {
return tailMap(fromKey, true);
}
@Override
- public NavigableMap<K, Collection<V>> tailMap(
- @ParametricNullness K fromKey, boolean inclusive) {
+ public NavigableMap<K, Collection<V>> tailMap(K fromKey, boolean inclusive) {
return new NavigableAsMap(sortedMap().tailMap(fromKey, inclusive));
}
}
diff --git a/guava/src/com/google/common/collect/AbstractMapBasedMultiset.java b/guava/src/com/google/common/collect/AbstractMapBasedMultiset.java
index b37214e..2d28c1d 100644
--- a/guava/src/com/google/common/collect/AbstractMapBasedMultiset.java
+++ b/guava/src/com/google/common/collect/AbstractMapBasedMultiset.java
@@ -18,10 +18,8 @@
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.base.Preconditions.checkState;
import static com.google.common.collect.CollectPreconditions.checkNonnegative;
import static com.google.common.collect.CollectPreconditions.checkRemove;
-import static java.util.Objects.requireNonNull;
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.GwtIncompatible;
@@ -35,7 +33,6 @@
import java.util.Map;
import java.util.Set;
import java.util.function.ObjIntConsumer;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -47,9 +44,7 @@
* @author Kevin Bourrillion
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
-abstract class AbstractMapBasedMultiset<E extends @Nullable Object> extends AbstractMultiset<E>
- implements Serializable {
+abstract class AbstractMapBasedMultiset<E> extends AbstractMultiset<E> implements Serializable {
// TODO(lowasser): consider overhauling this back to Map<E, Integer>
private transient Map<E, Count> backingMap;
@@ -89,7 +84,7 @@
Iterator<E> elementIterator() {
final Iterator<Map.Entry<E, Count>> backingEntries = backingMap.entrySet().iterator();
return new Iterator<E>() {
- @CheckForNull Map.Entry<E, Count> toRemove;
+ Map.@Nullable Entry<E, Count> toRemove;
@Override
public boolean hasNext() {
@@ -97,7 +92,6 @@
}
@Override
- @ParametricNullness
public E next() {
final Map.Entry<E, Count> mapEntry = backingEntries.next();
toRemove = mapEntry;
@@ -106,7 +100,7 @@
@Override
public void remove() {
- checkState(toRemove != null, "no calls to next() since the last call to remove()");
+ checkRemove(toRemove != null);
size -= toRemove.getValue().getAndSet(0);
backingEntries.remove();
toRemove = null;
@@ -118,7 +112,7 @@
Iterator<Entry<E>> entryIterator() {
final Iterator<Map.Entry<E, Count>> backingEntries = backingMap.entrySet().iterator();
return new Iterator<Multiset.Entry<E>>() {
- @CheckForNull Map.Entry<E, Count> toRemove;
+ Map.@Nullable Entry<E, Count> toRemove;
@Override
public boolean hasNext() {
@@ -131,7 +125,6 @@
toRemove = mapEntry;
return new Multisets.AbstractEntry<E>() {
@Override
- @ParametricNullness
public E getElement() {
return mapEntry.getKey();
}
@@ -152,7 +145,7 @@
@Override
public void remove() {
- checkState(toRemove != null, "no calls to next() since the last call to remove()");
+ checkRemove(toRemove != null);
size -= toRemove.getValue().getAndSet(0);
backingEntries.remove();
toRemove = null;
@@ -199,7 +192,7 @@
*/
private class MapBasedMultisetIterator implements Iterator<E> {
final Iterator<Map.Entry<E, Count>> entryIterator;
- @CheckForNull Map.Entry<E, Count> currentEntry;
+ Map.@Nullable Entry<E, Count> currentEntry;
int occurrencesLeft;
boolean canRemove;
@@ -213,7 +206,6 @@
}
@Override
- @ParametricNullness
public E next() {
if (occurrencesLeft == 0) {
currentEntry = entryIterator.next();
@@ -221,21 +213,13 @@
}
occurrencesLeft--;
canRemove = true;
- /*
- * requireNonNull is safe because occurrencesLeft starts at 0, forcing us to initialize
- * currentEntry above. After that, we never clear it.
- */
- return requireNonNull(currentEntry).getKey();
+ return currentEntry.getKey();
}
@Override
public void remove() {
checkRemove(canRemove);
- /*
- * requireNonNull is safe because canRemove is set to true only after we initialize
- * currentEntry (which we never subsequently clear).
- */
- int frequency = requireNonNull(currentEntry).getValue().get();
+ int frequency = currentEntry.getValue().get();
if (frequency <= 0) {
throw new ConcurrentModificationException();
}
@@ -248,7 +232,7 @@
}
@Override
- public int count(@CheckForNull Object element) {
+ public int count(@Nullable Object element) {
Count frequency = Maps.safeGet(backingMap, element);
return (frequency == null) ? 0 : frequency.get();
}
@@ -263,7 +247,7 @@
*/
@CanIgnoreReturnValue
@Override
- public int add(@ParametricNullness E element, int occurrences) {
+ public int add(@Nullable E element, int occurrences) {
if (occurrences == 0) {
return count(element);
}
@@ -285,7 +269,7 @@
@CanIgnoreReturnValue
@Override
- public int remove(@CheckForNull Object element, int occurrences) {
+ public int remove(@Nullable Object element, int occurrences) {
if (occurrences == 0) {
return count(element);
}
@@ -313,7 +297,7 @@
// Roughly a 33% performance improvement over AbstractMultiset.setCount().
@CanIgnoreReturnValue
@Override
- public int setCount(@ParametricNullness E element, int count) {
+ public int setCount(@Nullable E element, int count) {
checkNonnegative(count, "count");
Count existingCounter;
@@ -334,7 +318,7 @@
return oldCount;
}
- private static int getAndSet(@CheckForNull 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 e9accf0..267897d 100644
--- a/guava/src/com/google/common/collect/AbstractMapEntry.java
+++ b/guava/src/com/google/common/collect/AbstractMapEntry.java
@@ -19,7 +19,6 @@
import com.google.common.annotations.GwtCompatible;
import com.google.common.base.Objects;
import java.util.Map.Entry;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -29,26 +28,21 @@
* @author Jared Levy
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-abstract class AbstractMapEntry<K extends @Nullable Object, V extends @Nullable Object>
- implements Entry<K, V> {
+abstract class AbstractMapEntry<K, V> implements Entry<K, V> {
@Override
- @ParametricNullness
public abstract K getKey();
@Override
- @ParametricNullness
public abstract V getValue();
@Override
- @ParametricNullness
- public V setValue(@ParametricNullness V value) {
+ public V setValue(V value) {
throw new UnsupportedOperationException();
}
@Override
- public boolean equals(@CheckForNull 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 299decb..fedafd2 100644
--- a/guava/src/com/google/common/collect/AbstractMultimap.java
+++ b/guava/src/com/google/common/collect/AbstractMultimap.java
@@ -20,7 +20,6 @@
import com.google.common.annotations.GwtCompatible;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
-import com.google.errorprone.annotations.concurrent.LazyInit;
import com.google.j2objc.annotations.WeakOuter;
import java.util.AbstractCollection;
import java.util.Collection;
@@ -30,7 +29,6 @@
import java.util.Set;
import java.util.Spliterator;
import java.util.Spliterators;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -39,16 +37,14 @@
* @author Louis Wasserman
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-abstract class AbstractMultimap<K extends @Nullable Object, V extends @Nullable Object>
- implements Multimap<K, V> {
+abstract class AbstractMultimap<K, V> implements Multimap<K, V> {
@Override
public boolean isEmpty() {
return size() == 0;
}
@Override
- public boolean containsValue(@CheckForNull Object value) {
+ public boolean containsValue(@Nullable Object value) {
for (Collection<V> collection : asMap().values()) {
if (collection.contains(value)) {
return true;
@@ -59,27 +55,27 @@
}
@Override
- public boolean containsEntry(@CheckForNull Object key, @CheckForNull Object value) {
+ public boolean containsEntry(@Nullable Object key, @Nullable Object value) {
Collection<V> collection = asMap().get(key);
return collection != null && collection.contains(value);
}
@CanIgnoreReturnValue
@Override
- public boolean remove(@CheckForNull Object key, @CheckForNull Object value) {
+ public boolean remove(@Nullable Object key, @Nullable Object value) {
Collection<V> collection = asMap().get(key);
return collection != null && collection.remove(value);
}
@CanIgnoreReturnValue
@Override
- public boolean put(@ParametricNullness K key, @ParametricNullness V value) {
+ public boolean put(@Nullable K key, @Nullable V value) {
return get(key).add(value);
}
@CanIgnoreReturnValue
@Override
- public boolean putAll(@ParametricNullness K key, Iterable<? extends V> values) {
+ public boolean putAll(@Nullable K key, Iterable<? extends V> values) {
checkNotNull(values);
// make sure we only call values.iterator() once
// and we only call get(key) if values is nonempty
@@ -104,14 +100,14 @@
@CanIgnoreReturnValue
@Override
- public Collection<V> replaceValues(@ParametricNullness K key, Iterable<? extends V> values) {
+ public Collection<V> replaceValues(@Nullable K key, Iterable<? extends V> values) {
checkNotNull(values);
Collection<V> result = removeAll(key);
putAll(key, values);
return result;
}
- @LazyInit @CheckForNull private transient Collection<Entry<K, V>> entries;
+ private transient @Nullable Collection<Entry<K, V>> entries;
@Override
public Collection<Entry<K, V>> entries() {
@@ -147,7 +143,7 @@
}
@Override
- public boolean equals(@CheckForNull Object obj) {
+ public boolean equals(@Nullable Object obj) {
return Sets.equalsImpl(this, obj);
}
}
@@ -159,7 +155,7 @@
entryIterator(), size(), (this instanceof SetMultimap) ? Spliterator.DISTINCT : 0);
}
- @LazyInit @CheckForNull private transient Set<K> keySet;
+ private transient @Nullable Set<K> keySet;
@Override
public Set<K> keySet() {
@@ -169,7 +165,7 @@
abstract Set<K> createKeySet();
- @LazyInit @CheckForNull private transient Multiset<K> keys;
+ private transient @Nullable Multiset<K> keys;
@Override
public Multiset<K> keys() {
@@ -179,7 +175,7 @@
abstract Multiset<K> createKeys();
- @LazyInit @CheckForNull private transient Collection<V> values;
+ private transient @Nullable Collection<V> values;
@Override
public Collection<V> values() {
@@ -207,7 +203,7 @@
}
@Override
- public boolean contains(@CheckForNull Object o) {
+ public boolean contains(@Nullable Object o) {
return AbstractMultimap.this.containsValue(o);
}
@@ -225,7 +221,7 @@
return Spliterators.spliterator(valueIterator(), size(), 0);
}
- @LazyInit @CheckForNull private transient Map<K, Collection<V>> asMap;
+ private transient @Nullable Map<K, Collection<V>> asMap;
@Override
public Map<K, Collection<V>> asMap() {
@@ -238,7 +234,7 @@
// Comparison and hashing
@Override
- public boolean equals(@CheckForNull 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 8203e44..1bf3721 100644
--- a/guava/src/com/google/common/collect/AbstractMultiset.java
+++ b/guava/src/com/google/common/collect/AbstractMultiset.java
@@ -26,7 +26,6 @@
import java.util.Collection;
import java.util.Iterator;
import java.util.Set;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -43,9 +42,7 @@
* @author Louis Wasserman
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-abstract class AbstractMultiset<E extends @Nullable Object> extends AbstractCollection<E>
- implements Multiset<E> {
+abstract class AbstractMultiset<E> extends AbstractCollection<E> implements Multiset<E> {
// Query Operations
@Override
@@ -54,45 +51,45 @@
}
@Override
- public boolean contains(@CheckForNull Object element) {
+ public boolean contains(@Nullable Object element) {
return count(element) > 0;
}
// Modification Operations
@CanIgnoreReturnValue
@Override
- public final boolean add(@ParametricNullness E element) {
+ public final boolean add(@Nullable E element) {
add(element, 1);
return true;
}
@CanIgnoreReturnValue
@Override
- public int add(@ParametricNullness E element, int occurrences) {
+ public int add(@Nullable E element, int occurrences) {
throw new UnsupportedOperationException();
}
@CanIgnoreReturnValue
@Override
- public final boolean remove(@CheckForNull Object element) {
+ public final boolean remove(@Nullable Object element) {
return remove(element, 1) > 0;
}
@CanIgnoreReturnValue
@Override
- public int remove(@CheckForNull Object element, int occurrences) {
+ public int remove(@Nullable Object element, int occurrences) {
throw new UnsupportedOperationException();
}
@CanIgnoreReturnValue
@Override
- public int setCount(@ParametricNullness E element, int count) {
+ public int setCount(@Nullable E element, int count) {
return setCountImpl(this, element, count);
}
@CanIgnoreReturnValue
@Override
- public boolean setCount(@ParametricNullness E element, int oldCount, int newCount) {
+ public boolean setCount(@Nullable E element, int oldCount, int newCount) {
return setCountImpl(this, element, oldCount, newCount);
}
@@ -127,7 +124,7 @@
// Views
- @LazyInit @CheckForNull private transient Set<E> elementSet;
+ @LazyInit private transient @Nullable Set<E> elementSet;
@Override
public Set<E> elementSet() {
@@ -161,7 +158,7 @@
abstract Iterator<E> elementIterator();
- @LazyInit @CheckForNull private transient Set<Entry<E>> entrySet;
+ @LazyInit private transient @Nullable Set<Entry<E>> entrySet;
@Override
public Set<Entry<E>> entrySet() {
@@ -207,7 +204,7 @@
* and if, for each element, the two multisets have the same count.
*/
@Override
- public final boolean equals(@CheckForNull 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 47048d0..b0200d7 100644
--- a/guava/src/com/google/common/collect/AbstractNavigableMap.java
+++ b/guava/src/com/google/common/collect/AbstractNavigableMap.java
@@ -24,7 +24,6 @@
import java.util.NoSuchElementException;
import java.util.Set;
import java.util.SortedMap;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -33,40 +32,33 @@
* @author Louis Wasserman
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
-abstract class AbstractNavigableMap<K extends @Nullable Object, V extends @Nullable Object>
- extends IteratorBasedAbstractMap<K, V> implements NavigableMap<K, V> {
+abstract class AbstractNavigableMap<K, V> extends IteratorBasedAbstractMap<K, V>
+ implements NavigableMap<K, V> {
@Override
- @CheckForNull
- public abstract V get(@CheckForNull Object key);
+ public abstract @Nullable V get(@Nullable Object key);
@Override
- @CheckForNull
- public Entry<K, V> firstEntry() {
+ public @Nullable Entry<K, V> firstEntry() {
return Iterators.getNext(entryIterator(), null);
}
@Override
- @CheckForNull
- public Entry<K, V> lastEntry() {
+ public @Nullable Entry<K, V> lastEntry() {
return Iterators.getNext(descendingEntryIterator(), null);
}
@Override
- @CheckForNull
- public Entry<K, V> pollFirstEntry() {
+ public @Nullable Entry<K, V> pollFirstEntry() {
return Iterators.pollNext(entryIterator());
}
@Override
- @CheckForNull
- public Entry<K, V> pollLastEntry() {
+ public @Nullable Entry<K, V> pollLastEntry() {
return Iterators.pollNext(descendingEntryIterator());
}
@Override
- @ParametricNullness
public K firstKey() {
Entry<K, V> entry = firstEntry();
if (entry == null) {
@@ -77,7 +69,6 @@
}
@Override
- @ParametricNullness
public K lastKey() {
Entry<K, V> entry = lastEntry();
if (entry == null) {
@@ -88,67 +79,59 @@
}
@Override
- @CheckForNull
- public Entry<K, V> lowerEntry(@ParametricNullness K key) {
+ public @Nullable Entry<K, V> lowerEntry(K key) {
return headMap(key, false).lastEntry();
}
@Override
- @CheckForNull
- public Entry<K, V> floorEntry(@ParametricNullness K key) {
+ public @Nullable Entry<K, V> floorEntry(K key) {
return headMap(key, true).lastEntry();
}
@Override
- @CheckForNull
- public Entry<K, V> ceilingEntry(@ParametricNullness K key) {
+ public @Nullable Entry<K, V> ceilingEntry(K key) {
return tailMap(key, true).firstEntry();
}
@Override
- @CheckForNull
- public Entry<K, V> higherEntry(@ParametricNullness K key) {
+ public @Nullable Entry<K, V> higherEntry(K key) {
return tailMap(key, false).firstEntry();
}
@Override
- @CheckForNull
- public K lowerKey(@ParametricNullness K key) {
+ public K lowerKey(K key) {
return Maps.keyOrNull(lowerEntry(key));
}
@Override
- @CheckForNull
- public K floorKey(@ParametricNullness K key) {
+ public K floorKey(K key) {
return Maps.keyOrNull(floorEntry(key));
}
@Override
- @CheckForNull
- public K ceilingKey(@ParametricNullness K key) {
+ public K ceilingKey(K key) {
return Maps.keyOrNull(ceilingEntry(key));
}
@Override
- @CheckForNull
- public K higherKey(@ParametricNullness K key) {
+ public K higherKey(K key) {
return Maps.keyOrNull(higherEntry(key));
}
abstract Iterator<Entry<K, V>> descendingEntryIterator();
@Override
- public SortedMap<K, V> subMap(@ParametricNullness K fromKey, @ParametricNullness K toKey) {
+ public SortedMap<K, V> subMap(K fromKey, K toKey) {
return subMap(fromKey, true, toKey, false);
}
@Override
- public SortedMap<K, V> headMap(@ParametricNullness K toKey) {
+ public SortedMap<K, V> headMap(K toKey) {
return headMap(toKey, false);
}
@Override
- public SortedMap<K, V> tailMap(@ParametricNullness K fromKey) {
+ public SortedMap<K, V> tailMap(K fromKey) {
return tailMap(fromKey, true);
}
diff --git a/guava/src/com/google/common/collect/AbstractRangeSet.java b/guava/src/com/google/common/collect/AbstractRangeSet.java
index d112a11..1c454cd 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 javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* A skeletal implementation of {@code RangeSet}.
@@ -23,7 +23,6 @@
* @author Louis Wasserman
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
abstract class AbstractRangeSet<C extends Comparable> implements RangeSet<C> {
AbstractRangeSet() {}
@@ -33,7 +32,6 @@
}
@Override
- @CheckForNull
public abstract Range<C> rangeContaining(C value);
@Override
@@ -80,7 +78,7 @@
public abstract boolean encloses(Range<C> otherRange);
@Override
- public boolean equals(@CheckForNull 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 172fe35..37540c2 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 javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* This class provides a skeletal implementation of the {@code Iterator} interface for sequences
@@ -40,15 +40,14 @@
* @since 12.0 (in Guava as {@code AbstractLinkedIterator} since 8.0)
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
public abstract class AbstractSequentialIterator<T> extends UnmodifiableIterator<T> {
- @CheckForNull private T nextOrNull;
+ private @Nullable T nextOrNull;
/**
* Creates a new iterator with the given first element, or, if {@code firstOrNull} is null,
* creates a new empty iterator.
*/
- protected AbstractSequentialIterator(@CheckForNull T firstOrNull) {
+ protected AbstractSequentialIterator(@Nullable T firstOrNull) {
this.nextOrNull = firstOrNull;
}
@@ -57,8 +56,7 @@
* remain. This method is invoked during each call to {@link #next()} in order to compute the
* result of a <i>future</i> call to {@code next()}.
*/
- @CheckForNull
- protected abstract T computeNext(T previous);
+ protected abstract @Nullable T computeNext(T previous);
@Override
public final boolean hasNext() {
@@ -67,11 +65,13 @@
@Override
public final T next() {
- if (nextOrNull == null) {
+ if (!hasNext()) {
throw new NoSuchElementException();
}
- T oldNext = nextOrNull;
- nextOrNull = computeNext(oldNext);
- return oldNext;
+ try {
+ return nextOrNull;
+ } finally {
+ nextOrNull = computeNext(nextOrNull);
+ }
}
}
diff --git a/guava/src/com/google/common/collect/AbstractSetMultimap.java b/guava/src/com/google/common/collect/AbstractSetMultimap.java
index 90aa9dc..326f998 100644
--- a/guava/src/com/google/common/collect/AbstractSetMultimap.java
+++ b/guava/src/com/google/common/collect/AbstractSetMultimap.java
@@ -23,7 +23,6 @@
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -34,9 +33,8 @@
* @author Jared Levy
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-abstract class AbstractSetMultimap<K extends @Nullable Object, V extends @Nullable Object>
- extends AbstractMapBasedMultimap<K, V> implements SetMultimap<K, V> {
+abstract class AbstractSetMultimap<K, V> extends AbstractMapBasedMultimap<K, V>
+ implements SetMultimap<K, V> {
/**
* Creates a new multimap that uses the provided map.
*
@@ -55,13 +53,12 @@
}
@Override
- <E extends @Nullable Object> Collection<E> unmodifiableCollectionSubclass(
- Collection<E> collection) {
+ <E> Collection<E> unmodifiableCollectionSubclass(Collection<E> collection) {
return Collections.unmodifiableSet((Set<E>) collection);
}
@Override
- Collection<V> wrapCollection(@ParametricNullness K key, Collection<V> collection) {
+ Collection<V> wrapCollection(K key, Collection<V> collection) {
return new WrappedSet(key, (Set<V>) collection);
}
@@ -74,7 +71,7 @@
* {@link Set}, instead of the {@link Collection} specified in the {@link Multimap} interface.
*/
@Override
- public Set<V> get(@ParametricNullness K key) {
+ public Set<V> get(@Nullable K key) {
return (Set<V>) super.get(key);
}
@@ -97,7 +94,7 @@
*/
@CanIgnoreReturnValue
@Override
- public Set<V> removeAll(@CheckForNull Object key) {
+ public Set<V> removeAll(@Nullable Object key) {
return (Set<V>) super.removeAll(key);
}
@@ -111,7 +108,7 @@
*/
@CanIgnoreReturnValue
@Override
- public Set<V> replaceValues(@ParametricNullness K key, Iterable<? extends V> values) {
+ public Set<V> replaceValues(@Nullable K key, Iterable<? extends V> values) {
return (Set<V>) super.replaceValues(key, values);
}
@@ -136,7 +133,7 @@
*/
@CanIgnoreReturnValue
@Override
- public boolean put(@ParametricNullness K key, @ParametricNullness V value) {
+ public boolean put(@Nullable K key, @Nullable V value) {
return super.put(key, value);
}
@@ -147,7 +144,7 @@
* Equality does not depend on the ordering of keys or values.
*/
@Override
- public boolean equals(@CheckForNull Object object) {
+ public boolean equals(@Nullable Object object) {
return super.equals(object);
}
diff --git a/guava/src/com/google/common/collect/AbstractSortedKeySortedSetMultimap.java b/guava/src/com/google/common/collect/AbstractSortedKeySortedSetMultimap.java
index 676936f..0ee6edb 100644
--- a/guava/src/com/google/common/collect/AbstractSortedKeySortedSetMultimap.java
+++ b/guava/src/com/google/common/collect/AbstractSortedKeySortedSetMultimap.java
@@ -21,7 +21,6 @@
import java.util.Set;
import java.util.SortedMap;
import java.util.SortedSet;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Basic implementation of a {@link SortedSetMultimap} with a sorted key set.
@@ -32,10 +31,7 @@
* @author Louis Wasserman
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-abstract class AbstractSortedKeySortedSetMultimap<
- K extends @Nullable Object, V extends @Nullable Object>
- extends AbstractSortedSetMultimap<K, V> {
+abstract class AbstractSortedKeySortedSetMultimap<K, V> extends AbstractSortedSetMultimap<K, V> {
AbstractSortedKeySortedSetMultimap(SortedMap<K, Collection<V>> map) {
super(map);
diff --git a/guava/src/com/google/common/collect/AbstractSortedMultiset.java b/guava/src/com/google/common/collect/AbstractSortedMultiset.java
index fd4fce2..67d629a 100644
--- a/guava/src/com/google/common/collect/AbstractSortedMultiset.java
+++ b/guava/src/com/google/common/collect/AbstractSortedMultiset.java
@@ -21,7 +21,6 @@
import java.util.Comparator;
import java.util.Iterator;
import java.util.NavigableSet;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -34,9 +33,7 @@
* @author Louis Wasserman
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
-abstract class AbstractSortedMultiset<E extends @Nullable Object> extends AbstractMultiset<E>
- implements SortedMultiset<E> {
+abstract class AbstractSortedMultiset<E> extends AbstractMultiset<E> implements SortedMultiset<E> {
@GwtTransient final Comparator<? super E> comparator;
// needed for serialization
@@ -65,21 +62,18 @@
}
@Override
- @CheckForNull
public Entry<E> firstEntry() {
Iterator<Entry<E>> entryIterator = entryIterator();
return entryIterator.hasNext() ? entryIterator.next() : null;
}
@Override
- @CheckForNull
public Entry<E> lastEntry() {
Iterator<Entry<E>> entryIterator = descendingEntryIterator();
return entryIterator.hasNext() ? entryIterator.next() : null;
}
@Override
- @CheckForNull
public Entry<E> pollFirstEntry() {
Iterator<Entry<E>> entryIterator = entryIterator();
if (entryIterator.hasNext()) {
@@ -92,7 +86,6 @@
}
@Override
- @CheckForNull
public Entry<E> pollLastEntry() {
Iterator<Entry<E>> entryIterator = descendingEntryIterator();
if (entryIterator.hasNext()) {
@@ -106,9 +99,9 @@
@Override
public SortedMultiset<E> subMultiset(
- @ParametricNullness E fromElement,
+ @Nullable E fromElement,
BoundType fromBoundType,
- @ParametricNullness E toElement,
+ @Nullable E toElement,
BoundType toBoundType) {
// These are checked elsewhere, but NullPointerTester wants them checked eagerly.
checkNotNull(fromBoundType);
@@ -122,7 +115,7 @@
return Multisets.iteratorImpl(descendingMultiset());
}
- @CheckForNull private transient SortedMultiset<E> descendingMultiset;
+ private transient @Nullable SortedMultiset<E> descendingMultiset;
@Override
public SortedMultiset<E> descendingMultiset() {
diff --git a/guava/src/com/google/common/collect/AbstractSortedSetMultimap.java b/guava/src/com/google/common/collect/AbstractSortedSetMultimap.java
index 3231613..2e4de2e 100644
--- a/guava/src/com/google/common/collect/AbstractSortedSetMultimap.java
+++ b/guava/src/com/google/common/collect/AbstractSortedSetMultimap.java
@@ -23,7 +23,6 @@
import java.util.Map;
import java.util.NavigableSet;
import java.util.SortedSet;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -34,9 +33,8 @@
* @author Jared Levy
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-abstract class AbstractSortedSetMultimap<K extends @Nullable Object, V extends @Nullable Object>
- extends AbstractSetMultimap<K, V> implements SortedSetMultimap<K, V> {
+abstract class AbstractSortedSetMultimap<K, V> extends AbstractSetMultimap<K, V>
+ implements SortedSetMultimap<K, V> {
/**
* Creates a new multimap that uses the provided map.
*
@@ -55,8 +53,7 @@
}
@Override
- <E extends @Nullable Object> SortedSet<E> unmodifiableCollectionSubclass(
- Collection<E> collection) {
+ <E> SortedSet<E> unmodifiableCollectionSubclass(Collection<E> collection) {
if (collection instanceof NavigableSet) {
return Sets.unmodifiableNavigableSet((NavigableSet<E>) collection);
} else {
@@ -65,7 +62,7 @@
}
@Override
- Collection<V> wrapCollection(@ParametricNullness K key, Collection<V> collection) {
+ Collection<V> wrapCollection(K key, Collection<V> collection) {
if (collection instanceof NavigableSet) {
return new WrappedNavigableSet(key, (NavigableSet<V>) collection, null);
} else {
@@ -86,7 +83,7 @@
* Multimap} interface.
*/
@Override
- public SortedSet<V> get(@ParametricNullness K key) {
+ public SortedSet<V> get(@Nullable K key) {
return (SortedSet<V>) super.get(key);
}
@@ -99,7 +96,7 @@
*/
@CanIgnoreReturnValue
@Override
- public SortedSet<V> removeAll(@CheckForNull Object key) {
+ public SortedSet<V> removeAll(@Nullable Object key) {
return (SortedSet<V>) super.removeAll(key);
}
@@ -115,7 +112,7 @@
*/
@CanIgnoreReturnValue
@Override
- public SortedSet<V> replaceValues(@ParametricNullness K key, Iterable<? extends V> values) {
+ public SortedSet<V> replaceValues(@Nullable K key, Iterable<? extends V> values) {
return (SortedSet<V>) 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 99a1215..823570d 100644
--- a/guava/src/com/google/common/collect/AbstractTable.java
+++ b/guava/src/com/google/common/collect/AbstractTable.java
@@ -25,7 +25,6 @@
import java.util.Map;
import java.util.Set;
import java.util.Spliterator;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -34,18 +33,15 @@
* @author Louis Wasserman
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-abstract class AbstractTable<
- R extends @Nullable Object, C extends @Nullable Object, V extends @Nullable Object>
- implements Table<R, C, V> {
+abstract class AbstractTable<R, C, V> implements Table<R, C, V> {
@Override
- public boolean containsRow(@CheckForNull Object rowKey) {
+ public boolean containsRow(@Nullable Object rowKey) {
return Maps.safeContainsKey(rowMap(), rowKey);
}
@Override
- public boolean containsColumn(@CheckForNull Object columnKey) {
+ public boolean containsColumn(@Nullable Object columnKey) {
return Maps.safeContainsKey(columnMap(), columnKey);
}
@@ -60,7 +56,7 @@
}
@Override
- public boolean containsValue(@CheckForNull Object value) {
+ public boolean containsValue(@Nullable Object value) {
for (Map<C, V> row : rowMap().values()) {
if (row.containsValue(value)) {
return true;
@@ -70,14 +66,13 @@
}
@Override
- public boolean contains(@CheckForNull Object rowKey, @CheckForNull Object columnKey) {
+ public boolean contains(@Nullable Object rowKey, @Nullable Object columnKey) {
Map<C, V> row = Maps.safeGet(rowMap(), rowKey);
return row != null && Maps.safeContainsKey(row, columnKey);
}
@Override
- @CheckForNull
- public V get(@CheckForNull Object rowKey, @CheckForNull Object columnKey) {
+ public V get(@Nullable Object rowKey, @Nullable Object columnKey) {
Map<C, V> row = Maps.safeGet(rowMap(), rowKey);
return (row == null) ? null : Maps.safeGet(row, columnKey);
}
@@ -94,17 +89,14 @@
@CanIgnoreReturnValue
@Override
- @CheckForNull
- public V remove(@CheckForNull Object rowKey, @CheckForNull Object columnKey) {
+ public V remove(@Nullable Object rowKey, @Nullable Object columnKey) {
Map<C, V> row = Maps.safeGet(rowMap(), rowKey);
return (row == null) ? null : Maps.safeRemove(row, columnKey);
}
@CanIgnoreReturnValue
@Override
- @CheckForNull
- public V put(
- @ParametricNullness R rowKey, @ParametricNullness C columnKey, @ParametricNullness V value) {
+ public V put(R rowKey, C columnKey, V value) {
return row(rowKey).put(columnKey, value);
}
@@ -115,7 +107,7 @@
}
}
- @LazyInit @CheckForNull private transient Set<Cell<R, C, V>> cellSet;
+ @LazyInit private transient @Nullable Set<Cell<R, C, V>> cellSet;
@Override
public Set<Cell<R, C, V>> cellSet() {
@@ -134,7 +126,7 @@
@WeakOuter
class CellSet extends AbstractSet<Cell<R, C, V>> {
@Override
- public boolean contains(@CheckForNull Object o) {
+ public boolean contains(Object o) {
if (o instanceof Cell) {
Cell<?, ?, ?> cell = (Cell<?, ?, ?>) o;
Map<C, V> row = Maps.safeGet(rowMap(), cell.getRowKey());
@@ -146,7 +138,7 @@
}
@Override
- public boolean remove(@CheckForNull Object o) {
+ public boolean remove(@Nullable Object o) {
if (o instanceof Cell) {
Cell<?, ?, ?> cell = (Cell<?, ?, ?>) o;
Map<C, V> row = Maps.safeGet(rowMap(), cell.getRowKey());
@@ -178,7 +170,7 @@
}
}
- @LazyInit @CheckForNull private transient Collection<V> values;
+ @LazyInit private transient @Nullable Collection<V> values;
@Override
public Collection<V> values() {
@@ -193,7 +185,6 @@
Iterator<V> valuesIterator() {
return new TransformedIterator<Cell<R, C, V>, V>(cellSet().iterator()) {
@Override
- @ParametricNullness
V transform(Cell<R, C, V> cell) {
return cell.getValue();
}
@@ -217,7 +208,7 @@
}
@Override
- public boolean contains(@CheckForNull Object o) {
+ public boolean contains(Object o) {
return containsValue(o);
}
@@ -233,7 +224,7 @@
}
@Override
- public boolean equals(@CheckForNull 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 f6ca6fa..357b1fc 100644
--- a/guava/src/com/google/common/collect/AllEqualOrdering.java
+++ b/guava/src/com/google/common/collect/AllEqualOrdering.java
@@ -19,7 +19,6 @@
import com.google.common.annotations.GwtCompatible;
import java.io.Serializable;
import java.util.List;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -28,29 +27,27 @@
* @author Emily Soldal
*/
@GwtCompatible(serializable = true)
-@ElementTypesAreNonnullByDefault
-final class AllEqualOrdering extends Ordering<@Nullable Object> implements Serializable {
+final class AllEqualOrdering extends Ordering<Object> implements Serializable {
static final AllEqualOrdering INSTANCE = new AllEqualOrdering();
@Override
- public int compare(@CheckForNull Object left, @CheckForNull Object right) {
+ public int compare(@Nullable Object left, @Nullable Object right) {
return 0;
}
@Override
- public <E extends @Nullable Object> List<E> sortedCopy(Iterable<E> iterable) {
+ public <E> List<E> sortedCopy(Iterable<E> iterable) {
return Lists.newArrayList(iterable);
}
@Override
- @SuppressWarnings("nullness") // unsafe: see supertype
- public <E extends @Nullable Object> ImmutableList<E> immutableSortedCopy(Iterable<E> iterable) {
+ public <E> ImmutableList<E> immutableSortedCopy(Iterable<E> iterable) {
return ImmutableList.copyOf(iterable);
}
@SuppressWarnings("unchecked")
@Override
- public <S extends @Nullable Object> Ordering<S> reverse() {
+ public <S> Ordering<S> reverse() {
return (Ordering<S>) this;
}
diff --git a/guava/src/com/google/common/collect/ArrayListMultimap.java b/guava/src/com/google/common/collect/ArrayListMultimap.java
index c8f7106..bebdae6 100644
--- a/guava/src/com/google/common/collect/ArrayListMultimap.java
+++ b/guava/src/com/google/common/collect/ArrayListMultimap.java
@@ -29,7 +29,6 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Implementation of {@code Multimap} that uses an {@code ArrayList} to store the values for a given
@@ -60,8 +59,7 @@
* @since 2.0
*/
@GwtCompatible(serializable = true, emulated = true)
-@ElementTypesAreNonnullByDefault
-public final class ArrayListMultimap<K extends @Nullable Object, V extends @Nullable Object>
+public final class ArrayListMultimap<K, V>
extends ArrayListMultimapGwtSerializationDependencies<K, V> {
// Default from ArrayList
private static final int DEFAULT_VALUES_PER_KEY = 3;
@@ -74,8 +72,7 @@
* <p>This method will soon be deprecated in favor of {@code
* MultimapBuilder.hashKeys().arrayListValues().build()}.
*/
- public static <K extends @Nullable Object, V extends @Nullable Object>
- ArrayListMultimap<K, V> create() {
+ public static <K, V> ArrayListMultimap<K, V> create() {
return new ArrayListMultimap<>();
}
@@ -91,8 +88,7 @@
* @throws IllegalArgumentException if {@code expectedKeys} or {@code expectedValuesPerKey} is
* negative
*/
- public static <K extends @Nullable Object, V extends @Nullable Object>
- ArrayListMultimap<K, V> create(int expectedKeys, int expectedValuesPerKey) {
+ public static <K, V> ArrayListMultimap<K, V> create(int expectedKeys, int expectedValuesPerKey) {
return new ArrayListMultimap<>(expectedKeys, expectedValuesPerKey);
}
@@ -104,8 +100,7 @@
*
* @param multimap the multimap whose contents are copied to this multimap
*/
- public static <K extends @Nullable Object, V extends @Nullable Object>
- ArrayListMultimap<K, V> create(Multimap<? extends K, ? extends V> multimap) {
+ public static <K, V> ArrayListMultimap<K, V> create(Multimap<? extends K, ? extends V> multimap) {
return new ArrayListMultimap<>(multimap);
}
diff --git a/guava/src/com/google/common/collect/ArrayTable.java b/guava/src/com/google/common/collect/ArrayTable.java
index 01652c5..f500a89 100644
--- a/guava/src/com/google/common/collect/ArrayTable.java
+++ b/guava/src/com/google/common/collect/ArrayTable.java
@@ -19,7 +19,6 @@
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkElementIndex;
import static com.google.common.base.Preconditions.checkNotNull;
-import static java.util.Collections.emptyMap;
import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtCompatible;
@@ -27,7 +26,6 @@
import com.google.common.base.Objects;
import com.google.common.collect.Maps.IteratorBasedAbstractMap;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
-import com.google.errorprone.annotations.DoNotCall;
import com.google.j2objc.annotations.WeakOuter;
import java.io.Serializable;
import java.lang.reflect.Array;
@@ -37,22 +35,11 @@
import java.util.Map;
import java.util.Set;
import java.util.Spliterator;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Fixed-size {@link Table} implementation backed by a two-dimensional array.
*
- * <p><b>Warning:</b> {@code ArrayTable} is rarely the {@link Table} implementation you want. First,
- * it requires that the complete universe of rows and columns be specified at construction time.
- * Second, it is always backed by an array large enough to hold a value for every possible
- * combination of row and column keys. (This is rarely optimal unless the table is extremely dense.)
- * Finally, every possible combination of row and column keys is always considered to have a value
- * associated with it: It is not possible to "remove" a value, only to replace it with {@code null},
- * which will still appear when iterating over the table's contents in a foreach loop or a call to a
- * null-hostile method like {@link ImmutableTable#copyOf}. For alternatives, please see <a
- * href="https://github.com/google/guava/wiki/NewCollectionTypesExplained#table">the wiki</a>.
- *
* <p>The allowed row and column keys must be supplied when the table is created. The table always
* contains a mapping for every row key / column pair. The value corresponding to a given row and
* column is null unless another value is provided.
@@ -91,9 +78,7 @@
*/
@Beta
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
-public final class ArrayTable<R, C, V> extends AbstractTable<R, C, @Nullable V>
- implements Serializable {
+public final class ArrayTable<R, C, V> extends AbstractTable<R, C, V> implements Serializable {
/**
* Creates an {@code ArrayTable} filled with {@code null}.
@@ -133,8 +118,8 @@
*
* @throws NullPointerException if {@code table} has a null key
*/
- public static <R, C, V> ArrayTable<R, C, V> create(Table<R, C, ? extends @Nullable V> table) {
- return (table instanceof ArrayTable)
+ public static <R, C, V> ArrayTable<R, C, V> create(Table<R, C, V> table) {
+ return (table instanceof ArrayTable<?, ?, ?>)
? new ArrayTable<R, C, V>((ArrayTable<R, C, V>) table)
: new ArrayTable<R, C, V>(table);
}
@@ -145,7 +130,7 @@
// TODO(jlevy): Add getters returning rowKeyToIndex and columnKeyToIndex?
private final ImmutableMap<R, Integer> rowKeyToIndex;
private final ImmutableMap<C, Integer> columnKeyToIndex;
- private final @Nullable V[][] array;
+ private final V[][] array;
private ArrayTable(Iterable<? extends R> rowKeys, Iterable<? extends C> columnKeys) {
this.rowList = ImmutableList.copyOf(rowKeys);
@@ -162,14 +147,13 @@
columnKeyToIndex = Maps.indexMap(columnList);
@SuppressWarnings("unchecked")
- @Nullable
- V[][] tmpArray = (@Nullable V[][]) new Object[rowList.size()][columnList.size()];
+ V[][] tmpArray = (V[][]) new Object[rowList.size()][columnList.size()];
array = tmpArray;
// Necessary because in GWT the arrays are initialized with "undefined" instead of null.
eraseAll();
}
- private ArrayTable(Table<R, C, ? extends @Nullable V> table) {
+ private ArrayTable(Table<R, C, V> table) {
this(table.rowKeySet(), table.columnKeySet());
putAll(table);
}
@@ -180,16 +164,14 @@
rowKeyToIndex = table.rowKeyToIndex;
columnKeyToIndex = table.columnKeyToIndex;
@SuppressWarnings("unchecked")
- @Nullable
- V[][] copy = (@Nullable V[][]) new Object[rowList.size()][columnList.size()];
+ V[][] copy = (V[][]) new Object[rowList.size()][columnList.size()];
array = copy;
for (int i = 0; i < rowList.size(); i++) {
System.arraycopy(table.array[i], 0, copy[i], 0, table.array[i].length);
}
}
- private abstract static class ArrayMap<K, V extends @Nullable Object>
- extends IteratorBasedAbstractMap<K, V> {
+ private abstract static class ArrayMap<K, V> extends IteratorBasedAbstractMap<K, V> {
private final ImmutableMap<K, Integer> keyIndex;
private ArrayMap(ImmutableMap<K, Integer> keyIndex) {
@@ -207,11 +189,9 @@
abstract String getKeyRole();
- @ParametricNullness
- abstract V getValue(int index);
+ abstract @Nullable V getValue(int index);
- @ParametricNullness
- abstract V setValue(int index, @ParametricNullness V newValue);
+ abstract @Nullable V setValue(int index, V newValue);
@Override
public int size() {
@@ -232,14 +212,12 @@
}
@Override
- @ParametricNullness
public V getValue() {
return ArrayMap.this.getValue(index);
}
@Override
- @ParametricNullness
- public V setValue(@ParametricNullness V value) {
+ public V setValue(V value) {
return ArrayMap.this.setValue(index, value);
}
};
@@ -263,13 +241,12 @@
// TODO(lowasser): consider an optimized values() implementation
@Override
- public boolean containsKey(@CheckForNull Object key) {
+ public boolean containsKey(@Nullable Object key) {
return keyIndex.containsKey(key);
}
- @CheckForNull
@Override
- public V get(@CheckForNull Object key) {
+ public V get(@Nullable Object key) {
Integer index = keyIndex.get(key);
if (index == null) {
return null;
@@ -279,8 +256,7 @@
}
@Override
- @CheckForNull
- public V put(K key, @ParametricNullness V value) {
+ public V put(K key, V value) {
Integer index = keyIndex.get(key);
if (index == null) {
throw new IllegalArgumentException(
@@ -290,8 +266,7 @@
}
@Override
- @CheckForNull
- public V remove(@CheckForNull Object key) {
+ public V remove(Object key) {
throw new UnsupportedOperationException();
}
@@ -329,7 +304,6 @@
* or equal to the number of allowed row keys, or {@code columnIndex} is greater than or equal
* to the number of allowed column keys
*/
- @CheckForNull
public V at(int rowIndex, int columnIndex) {
// In GWT array access never throws IndexOutOfBoundsException.
checkElementIndex(rowIndex, rowList.size());
@@ -351,8 +325,7 @@
* to the number of allowed column keys
*/
@CanIgnoreReturnValue
- @CheckForNull
- public V set(int rowIndex, int columnIndex, @CheckForNull 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());
@@ -371,10 +344,9 @@
* @param valueClass class of values stored in the returned array
*/
@GwtIncompatible // reflection
- public @Nullable V[][] toArray(Class<V> valueClass) {
+ public V[][] toArray(Class<V> valueClass) {
@SuppressWarnings("unchecked") // TODO: safe?
- @Nullable
- V[][] copy = (@Nullable V[][]) Array.newInstance(valueClass, rowList.size(), columnList.size());
+ V[][] copy = (V[][]) Array.newInstance(valueClass, rowList.size(), columnList.size());
for (int i = 0; i < rowList.size(); i++) {
System.arraycopy(array[i], 0, copy[i], 0, array[i].length);
}
@@ -387,7 +359,6 @@
* @throws UnsupportedOperationException always
* @deprecated Use {@link #eraseAll}
*/
- @DoNotCall("Always throws UnsupportedOperationException")
@Override
@Deprecated
public void clear() {
@@ -396,7 +367,7 @@
/** Associates the value {@code null} with every pair of allowed row and column keys. */
public void eraseAll() {
- for (@Nullable V[] row : array) {
+ for (V[] row : array) {
Arrays.fill(row, null);
}
}
@@ -406,7 +377,7 @@
* constructed.
*/
@Override
- public boolean contains(@CheckForNull Object rowKey, @CheckForNull Object columnKey) {
+ public boolean contains(@Nullable Object rowKey, @Nullable Object columnKey) {
return containsRow(rowKey) && containsColumn(columnKey);
}
@@ -415,7 +386,7 @@
* table was constructed.
*/
@Override
- public boolean containsColumn(@CheckForNull Object columnKey) {
+ public boolean containsColumn(@Nullable Object columnKey) {
return columnKeyToIndex.containsKey(columnKey);
}
@@ -424,13 +395,13 @@
* constructed.
*/
@Override
- public boolean containsRow(@CheckForNull Object rowKey) {
+ public boolean containsRow(@Nullable Object rowKey) {
return rowKeyToIndex.containsKey(rowKey);
}
@Override
- public boolean containsValue(@CheckForNull Object value) {
- for (@Nullable V[] row : array) {
+ public boolean containsValue(@Nullable Object value) {
+ for (V[] row : array) {
for (V element : row) {
if (Objects.equal(value, element)) {
return true;
@@ -441,8 +412,7 @@
}
@Override
- @CheckForNull
- public V get(@CheckForNull Object rowKey, @CheckForNull 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);
@@ -464,8 +434,7 @@
*/
@CanIgnoreReturnValue
@Override
- @CheckForNull
- public V put(R rowKey, C columnKey, @CheckForNull V value) {
+ public V put(R rowKey, C columnKey, @Nullable V value) {
checkNotNull(rowKey);
checkNotNull(columnKey);
Integer rowIndex = rowKeyToIndex.get(rowKey);
@@ -491,7 +460,7 @@
* in {@link #rowKeySet()} or {@link #columnKeySet()}
*/
@Override
- public void putAll(Table<? extends R, ? extends C, ? extends @Nullable V> table) {
+ public void putAll(Table<? extends R, ? extends C, ? extends V> table) {
super.putAll(table);
}
@@ -501,12 +470,10 @@
* @throws UnsupportedOperationException always
* @deprecated Use {@link #erase}
*/
- @DoNotCall("Always throws UnsupportedOperationException")
@CanIgnoreReturnValue
@Override
@Deprecated
- @CheckForNull
- public V remove(@CheckForNull Object rowKey, @CheckForNull Object columnKey) {
+ public V remove(Object rowKey, Object columnKey) {
throw new UnsupportedOperationException();
}
@@ -524,8 +491,7 @@
* for the keys
*/
@CanIgnoreReturnValue
- @CheckForNull
- public V erase(@CheckForNull Object rowKey, @CheckForNull 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) {
@@ -553,28 +519,28 @@
* @return set of table cells consisting of row key / column key / value triplets
*/
@Override
- public Set<Cell<R, C, @Nullable V>> cellSet() {
+ public Set<Cell<R, C, V>> cellSet() {
return super.cellSet();
}
@Override
- Iterator<Cell<R, C, @Nullable V>> cellIterator() {
- return new AbstractIndexedListIterator<Cell<R, C, @Nullable V>>(size()) {
+ Iterator<Cell<R, C, V>> cellIterator() {
+ return new AbstractIndexedListIterator<Cell<R, C, V>>(size()) {
@Override
- protected Cell<R, C, @Nullable V> get(final int index) {
+ protected Cell<R, C, V> get(final int index) {
return getCell(index);
}
};
}
@Override
- Spliterator<Cell<R, C, @Nullable V>> cellSpliterator() {
- return CollectSpliterators.<Cell<R, C, @Nullable V>>indexed(
+ Spliterator<Cell<R, C, V>> cellSpliterator() {
+ return CollectSpliterators.indexed(
size(), Spliterator.ORDERED | Spliterator.NONNULL | Spliterator.DISTINCT, this::getCell);
}
- private Cell<R, C, @Nullable V> getCell(final int index) {
- return new Tables.AbstractCell<R, C, @Nullable V>() {
+ private Cell<R, C, V> getCell(final int index) {
+ return new Tables.AbstractCell<R, C, V>() {
final int rowIndex = index / columnList.size();
final int columnIndex = index % columnList.size();
@@ -589,14 +555,12 @@
}
@Override
- @CheckForNull
public V getValue() {
return at(rowIndex, columnIndex);
}
};
}
- @CheckForNull
private V getValue(int index) {
int rowIndex = index / columnList.size();
int columnIndex = index % columnList.size();
@@ -615,17 +579,13 @@
* @return the corresponding map from row keys to values
*/
@Override
- public Map<R, @Nullable V> column(C columnKey) {
+ public Map<R, V> column(C columnKey) {
checkNotNull(columnKey);
Integer columnIndex = columnKeyToIndex.get(columnKey);
- if (columnIndex == null) {
- return emptyMap();
- } else {
- return new Column(columnIndex);
- }
+ return (columnIndex == null) ? ImmutableMap.<R, V>of() : new Column(columnIndex);
}
- private class Column extends ArrayMap<R, @Nullable V> {
+ private class Column extends ArrayMap<R, V> {
final int columnIndex;
Column(int columnIndex) {
@@ -639,14 +599,12 @@
}
@Override
- @CheckForNull
V getValue(int index) {
return at(index, columnIndex);
}
@Override
- @CheckForNull
- V setValue(int index, @CheckForNull V newValue) {
+ V setValue(int index, V newValue) {
return set(index, columnIndex, newValue);
}
}
@@ -662,16 +620,16 @@
return columnKeyToIndex.keySet();
}
- @CheckForNull private transient ColumnMap columnMap;
+ private transient @Nullable ColumnMap columnMap;
@Override
- public Map<C, Map<R, @Nullable V>> columnMap() {
+ public Map<C, Map<R, V>> columnMap() {
ColumnMap map = columnMap;
return (map == null) ? columnMap = new ColumnMap() : map;
}
@WeakOuter
- private class ColumnMap extends ArrayMap<C, Map<R, @Nullable V>> {
+ private class ColumnMap extends ArrayMap<C, Map<R, V>> {
private ColumnMap() {
super(columnKeyToIndex);
}
@@ -682,18 +640,17 @@
}
@Override
- Map<R, @Nullable V> getValue(int index) {
+ Map<R, V> getValue(int index) {
return new Column(index);
}
@Override
- Map<R, @Nullable V> setValue(int index, Map<R, @Nullable V> newValue) {
+ Map<R, V> setValue(int index, Map<R, V> newValue) {
throw new UnsupportedOperationException();
}
@Override
- @CheckForNull
- public Map<R, @Nullable V> put(C key, Map<R, @Nullable V> value) {
+ public Map<R, V> put(C key, Map<R, V> value) {
throw new UnsupportedOperationException();
}
}
@@ -710,17 +667,13 @@
* @return the corresponding map from column keys to values
*/
@Override
- public Map<C, @Nullable V> row(R rowKey) {
+ public Map<C, V> row(R rowKey) {
checkNotNull(rowKey);
Integer rowIndex = rowKeyToIndex.get(rowKey);
- if (rowIndex == null) {
- return emptyMap();
- } else {
- return new Row(rowIndex);
- }
+ return (rowIndex == null) ? ImmutableMap.<C, V>of() : new Row(rowIndex);
}
- private class Row extends ArrayMap<C, @Nullable V> {
+ private class Row extends ArrayMap<C, V> {
final int rowIndex;
Row(int rowIndex) {
@@ -734,14 +687,12 @@
}
@Override
- @CheckForNull
V getValue(int index) {
return at(rowIndex, index);
}
@Override
- @CheckForNull
- V setValue(int index, @CheckForNull V newValue) {
+ V setValue(int index, V newValue) {
return set(rowIndex, index, newValue);
}
}
@@ -757,16 +708,16 @@
return rowKeyToIndex.keySet();
}
- @CheckForNull private transient RowMap rowMap;
+ private transient @Nullable RowMap rowMap;
@Override
- public Map<R, Map<C, @Nullable V>> rowMap() {
+ public Map<R, Map<C, V>> rowMap() {
RowMap map = rowMap;
return (map == null) ? rowMap = new RowMap() : map;
}
@WeakOuter
- private class RowMap extends ArrayMap<R, Map<C, @Nullable V>> {
+ private class RowMap extends ArrayMap<R, Map<C, V>> {
private RowMap() {
super(rowKeyToIndex);
}
@@ -777,18 +728,17 @@
}
@Override
- Map<C, @Nullable V> getValue(int index) {
+ Map<C, V> getValue(int index) {
return new Row(index);
}
@Override
- Map<C, @Nullable V> setValue(int index, Map<C, @Nullable V> newValue) {
+ Map<C, V> setValue(int index, Map<C, V> newValue) {
throw new UnsupportedOperationException();
}
@Override
- @CheckForNull
- public Map<C, @Nullable V> put(R key, Map<C, @Nullable V> value) {
+ public Map<C, V> put(R key, Map<C, V> value) {
throw new UnsupportedOperationException();
}
}
@@ -803,15 +753,14 @@
* @return collection of values
*/
@Override
- public Collection<@Nullable V> values() {
+ public Collection<V> values() {
return super.values();
}
@Override
- Iterator<@Nullable V> valuesIterator() {
- return new AbstractIndexedListIterator<@Nullable V>(size()) {
+ Iterator<V> valuesIterator() {
+ return new AbstractIndexedListIterator<V>(size()) {
@Override
- @CheckForNull
protected V get(int index) {
return getValue(index);
}
@@ -819,8 +768,8 @@
}
@Override
- Spliterator<@Nullable V> valuesSpliterator() {
- return CollectSpliterators.<@Nullable V>indexed(size(), Spliterator.ORDERED, this::getValue);
+ Spliterator<V> valuesSpliterator() {
+ return CollectSpliterators.indexed(size(), Spliterator.ORDERED, this::getValue);
}
private static final long serialVersionUID = 0;
diff --git a/guava/src/com/google/common/collect/BaseImmutableMultimap.java b/guava/src/com/google/common/collect/BaseImmutableMultimap.java
index 2e69c2a..6ebdf14 100644
--- a/guava/src/com/google/common/collect/BaseImmutableMultimap.java
+++ b/guava/src/com/google/common/collect/BaseImmutableMultimap.java
@@ -22,5 +22,4 @@
* retaining additional implementation details of {@link ImmutableMultimap}.
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
abstract class BaseImmutableMultimap<K, V> extends AbstractMultimap<K, V> {}
diff --git a/guava/src/com/google/common/collect/BiMap.java b/guava/src/com/google/common/collect/BiMap.java
index 12eb4e3..e4a755e 100644
--- a/guava/src/com/google/common/collect/BiMap.java
+++ b/guava/src/com/google/common/collect/BiMap.java
@@ -20,7 +20,6 @@
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import java.util.Map;
import java.util.Set;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -29,14 +28,13 @@
* bimap containing the same entries as this bimap but with reversed keys and values.
*
* <p>See the Guava User Guide article on <a href=
- * "https://github.com/google/guava/wiki/NewCollectionTypesExplained#bimap">{@code BiMap}</a>.
+ * "https://github.com/google/guava/wiki/NewCollectionTypesExplained#bimap"> {@code BiMap}</a>.
*
* @author Kevin Bourrillion
* @since 2.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-public interface BiMap<K extends @Nullable Object, V extends @Nullable Object> extends Map<K, V> {
+public interface BiMap<K, V> extends Map<K, V> {
// Modification Operations
/**
@@ -48,8 +46,8 @@
*/
@CanIgnoreReturnValue
@Override
- @CheckForNull
- V put(@ParametricNullness K key, @ParametricNullness 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
@@ -64,14 +62,12 @@
*
* @param key the key with which the specified value is to be associated
* @param value the value to be associated with the specified key
- * @return the value that was previously associated with the key, or {@code null} if there was no
- * previous entry. (If the bimap contains null values, then {@code forcePut}, like {@code
- * put}, returns {@code null} both if the key is absent and if it is present with a null
- * value.)
+ * @return the value which was previously associated with the key, which may be {@code null}, or
+ * {@code null} if there was no previous entry
*/
@CanIgnoreReturnValue
- @CheckForNull
- V forcePut(@ParametricNullness K key, @ParametricNullness V value);
+ @Nullable
+ V forcePut(@Nullable K key, @Nullable V value);
// Bulk Operations
diff --git a/guava/src/com/google/common/collect/BoundType.java b/guava/src/com/google/common/collect/BoundType.java
index 00ac08c..ce03802 100644
--- a/guava/src/com/google/common/collect/BoundType.java
+++ b/guava/src/com/google/common/collect/BoundType.java
@@ -24,7 +24,6 @@
* @since 10.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
public enum BoundType {
/** The endpoint value <i>is not</i> considered part of the set ("exclusive"). */
OPEN(false),
@@ -40,4 +39,8 @@
static BoundType forBoolean(boolean inclusive) {
return inclusive ? CLOSED : OPEN;
}
+
+ BoundType flip() {
+ return forBoolean(!inclusive);
+ }
}
diff --git a/guava/src/com/google/common/collect/ByFunctionOrdering.java b/guava/src/com/google/common/collect/ByFunctionOrdering.java
index 43ebddd..f05bf01 100644
--- a/guava/src/com/google/common/collect/ByFunctionOrdering.java
+++ b/guava/src/com/google/common/collect/ByFunctionOrdering.java
@@ -22,7 +22,6 @@
import com.google.common.base.Function;
import com.google.common.base.Objects;
import java.io.Serializable;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -30,9 +29,7 @@
* elements.
*/
@GwtCompatible(serializable = true)
-@ElementTypesAreNonnullByDefault
-final class ByFunctionOrdering<F extends @Nullable Object, T extends @Nullable Object>
- extends Ordering<F> implements Serializable {
+final class ByFunctionOrdering<F, T> extends Ordering<F> implements Serializable {
final Function<F, ? extends T> function;
final Ordering<T> ordering;
@@ -42,12 +39,12 @@
}
@Override
- public int compare(@ParametricNullness F left, @ParametricNullness F right) {
+ public int compare(F left, F right) {
return ordering.compare(function.apply(left), function.apply(right));
}
@Override
- public boolean equals(@CheckForNull 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 475b3f2..ebff724 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 javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Implementation of {@link Lists#cartesianProduct(List)}.
@@ -30,7 +30,6 @@
* @author Louis Wasserman
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
final class CartesianList<E> extends AbstractList<List<E>> implements RandomAccess {
private final transient ImmutableList<List<E>> axes;
@@ -68,7 +67,7 @@
}
@Override
- public int indexOf(@CheckForNull Object o) {
+ public int indexOf(Object o) {
if (!(o instanceof List)) {
return -1;
}
@@ -90,7 +89,7 @@
}
@Override
- public int lastIndexOf(@CheckForNull Object o) {
+ public int lastIndexOf(Object o) {
if (!(o instanceof List)) {
return -1;
}
@@ -141,7 +140,7 @@
}
@Override
- public boolean contains(@CheckForNull Object object) {
+ public boolean contains(@Nullable Object object) {
if (!(object 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 9bd826f..a173556 100644
--- a/guava/src/com/google/common/collect/ClassToInstanceMap.java
+++ b/guava/src/com/google/common/collect/ClassToInstanceMap.java
@@ -20,7 +20,7 @@
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import com.google.errorprone.annotations.DoNotMock;
import java.util.Map;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* A map, each entry of which maps a Java <a href="http://tinyurl.com/2cmwkz">raw type</a> to an
@@ -30,19 +30,8 @@
* <p>Like any other {@code Map<Class, Object>}, this map may contain entries for primitive types,
* and a primitive type and its corresponding wrapper type may map to different values.
*
- * <p>This class's support for {@code null} requires some explanation: From release 31.0 onward,
- * Guava specifies the nullness of its types through annotations. In the case of {@code
- * ClassToInstanceMap}, it specifies that both the key and value types are restricted to
- * non-nullable types. This specification is reasonable for <i>keys</i>, which must be non-null
- * classes. This is in contrast to the specification for <i>values</i>: Null values <i>are</i>
- * supported by the implementation {@link MutableClassToInstanceMap}, even though that
- * implementation and this interface specify otherwise. Thus, if you use a nullness checker, you can
- * safely suppress any warnings it produces when you write null values into a {@code
- * MutableClassToInstanceMap}. Just be sure to be prepared for null values when reading from it,
- * since nullness checkers will assume that vaules are non-null then, too.
- *
* <p>See the Guava User Guide article on <a href=
- * "https://github.com/google/guava/wiki/NewCollectionTypesExplained#classtoinstancemap">{@code
+ * "https://github.com/google/guava/wiki/NewCollectionTypesExplained#classtoinstancemap"> {@code
* ClassToInstanceMap}</a>.
*
* <p>To map a generic type to an instance of that type, use {@link
@@ -54,18 +43,12 @@
*/
@DoNotMock("Use ImmutableClassToInstanceMap or MutableClassToInstanceMap")
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-// If we ever support non-null projections (https://github.com/jspecify/jspecify/issues/86), we
-// we might annotate this as...
-// ClassToInstanceMap<B extends @Nullable Object> extends Map<Class<? extends @Nonnull B>, B>
-// ...and change its methods similarly (<T extends @Nonnull B> or Class<@Nonnull T>).
public interface ClassToInstanceMap<B> extends Map<Class<? extends B>, B> {
/**
* Returns the value the specified class is mapped to, or {@code null} if no entry for this class
* is present. This will only return a value that was bound to this specific class, not a value
* that may have been bound to a subtype.
*/
- @CheckForNull
<T extends B> T getInstance(Class<T> type);
/**
@@ -76,6 +59,5 @@
* null} if there was no previous entry.
*/
@CanIgnoreReturnValue
- @CheckForNull
- <T extends B> T putInstance(Class<T> type, T value);
+ <T extends B> T putInstance(Class<T> type, @Nullable T value);
}
diff --git a/guava/src/com/google/common/collect/CollectCollectors.java b/guava/src/com/google/common/collect/CollectCollectors.java
index 63eec12..8e038c8 100644
--- a/guava/src/com/google/common/collect/CollectCollectors.java
+++ b/guava/src/com/google/common/collect/CollectCollectors.java
@@ -20,222 +20,14 @@
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.GwtIncompatible;
-import com.google.common.base.Preconditions;
-import java.util.Collection;
import java.util.Comparator;
-import java.util.EnumMap;
-import java.util.EnumSet;
-import java.util.LinkedHashMap;
-import java.util.TreeMap;
-import java.util.function.BinaryOperator;
import java.util.function.Function;
-import java.util.function.Supplier;
-import java.util.function.ToIntFunction;
import java.util.stream.Collector;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
/** Collectors utilities for {@code common.collect} internals. */
@GwtCompatible
-@ElementTypesAreNonnullByDefault
final class CollectCollectors {
-
- private static final Collector<Object, ?, ImmutableList<Object>> TO_IMMUTABLE_LIST =
- Collector.of(
- ImmutableList::builder,
- ImmutableList.Builder::add,
- ImmutableList.Builder::combine,
- ImmutableList.Builder::build);
-
- private static final Collector<Object, ?, ImmutableSet<Object>> TO_IMMUTABLE_SET =
- Collector.of(
- ImmutableSet::builder,
- ImmutableSet.Builder::add,
- ImmutableSet.Builder::combine,
- ImmutableSet.Builder::build);
-
- @GwtIncompatible
- private static final Collector<Range<Comparable<?>>, ?, ImmutableRangeSet<Comparable<?>>>
- TO_IMMUTABLE_RANGE_SET =
- Collector.of(
- ImmutableRangeSet::builder,
- ImmutableRangeSet.Builder::add,
- ImmutableRangeSet.Builder::combine,
- ImmutableRangeSet.Builder::build);
-
- // Lists
-
- @SuppressWarnings({"rawtypes", "unchecked"})
- static <E> Collector<E, ?, ImmutableList<E>> toImmutableList() {
- return (Collector) TO_IMMUTABLE_LIST;
- }
-
- // Sets
-
- @SuppressWarnings({"rawtypes", "unchecked"})
- static <E> Collector<E, ?, ImmutableSet<E>> toImmutableSet() {
- return (Collector) TO_IMMUTABLE_SET;
- }
-
- static <E> Collector<E, ?, ImmutableSortedSet<E>> toImmutableSortedSet(
- Comparator<? super E> comparator) {
- checkNotNull(comparator);
- return Collector.of(
- () -> new ImmutableSortedSet.Builder<E>(comparator),
- ImmutableSortedSet.Builder::add,
- ImmutableSortedSet.Builder::combine,
- ImmutableSortedSet.Builder::build);
- }
-
- @SuppressWarnings({"rawtypes", "unchecked"})
- static <E extends Enum<E>> Collector<E, ?, ImmutableSet<E>> toImmutableEnumSet() {
- return (Collector) EnumSetAccumulator.TO_IMMUTABLE_ENUM_SET;
- }
-
- private static final class EnumSetAccumulator<E extends Enum<E>> {
- @SuppressWarnings({"rawtypes", "unchecked"})
- static final Collector<Enum<?>, ?, ImmutableSet<? extends Enum<?>>> TO_IMMUTABLE_ENUM_SET =
- (Collector)
- Collector.<Enum, EnumSetAccumulator, ImmutableSet<?>>of(
- EnumSetAccumulator::new,
- EnumSetAccumulator::add,
- EnumSetAccumulator::combine,
- EnumSetAccumulator::toImmutableSet,
- Collector.Characteristics.UNORDERED);
-
- @CheckForNull private EnumSet<E> set;
-
- void add(E e) {
- if (set == null) {
- set = EnumSet.of(e);
- } else {
- set.add(e);
- }
- }
-
- EnumSetAccumulator<E> combine(EnumSetAccumulator<E> other) {
- if (this.set == null) {
- return other;
- } else if (other.set == null) {
- return this;
- } else {
- this.set.addAll(other.set);
- return this;
- }
- }
-
- ImmutableSet<E> toImmutableSet() {
- return (set == null) ? ImmutableSet.<E>of() : ImmutableEnumSet.asImmutable(set);
- }
- }
-
- @GwtIncompatible
- @SuppressWarnings({"rawtypes", "unchecked"})
- static <E extends Comparable<? super E>>
- Collector<Range<E>, ?, ImmutableRangeSet<E>> toImmutableRangeSet() {
- return (Collector) TO_IMMUTABLE_RANGE_SET;
- }
-
- // Multisets
-
- static <T extends @Nullable Object, E> Collector<T, ?, ImmutableMultiset<E>> toImmutableMultiset(
- Function<? super T, ? extends E> elementFunction, ToIntFunction<? super T> countFunction) {
- checkNotNull(elementFunction);
- checkNotNull(countFunction);
- return Collector.of(
- LinkedHashMultiset::create,
- (multiset, t) ->
- multiset.add(checkNotNull(elementFunction.apply(t)), countFunction.applyAsInt(t)),
- (multiset1, multiset2) -> {
- multiset1.addAll(multiset2);
- return multiset1;
- },
- (Multiset<E> multiset) -> ImmutableMultiset.copyFromEntries(multiset.entrySet()));
- }
-
- static <T extends @Nullable Object, E extends @Nullable Object, M extends Multiset<E>>
- Collector<T, ?, M> toMultiset(
- Function<? super T, E> elementFunction,
- ToIntFunction<? super T> countFunction,
- Supplier<M> multisetSupplier) {
- checkNotNull(elementFunction);
- checkNotNull(countFunction);
- checkNotNull(multisetSupplier);
- return Collector.of(
- multisetSupplier,
- (ms, t) -> ms.add(elementFunction.apply(t), countFunction.applyAsInt(t)),
- (ms1, ms2) -> {
- ms1.addAll(ms2);
- return ms1;
- });
- }
-
- // Maps
-
- static <T extends @Nullable Object, K, V> Collector<T, ?, ImmutableMap<K, V>> toImmutableMap(
- Function<? super T, ? extends K> keyFunction,
- Function<? super T, ? extends V> valueFunction) {
- checkNotNull(keyFunction);
- checkNotNull(valueFunction);
- return Collector.of(
- ImmutableMap.Builder<K, V>::new,
- (builder, input) -> builder.put(keyFunction.apply(input), valueFunction.apply(input)),
- ImmutableMap.Builder::combine,
- ImmutableMap.Builder::build);
- }
-
- public static <T extends @Nullable Object, K, V>
- Collector<T, ?, ImmutableMap<K, V>> toImmutableMap(
- Function<? super T, ? extends K> keyFunction,
- Function<? super T, ? extends V> valueFunction,
- BinaryOperator<V> mergeFunction) {
- checkNotNull(keyFunction);
- checkNotNull(valueFunction);
- checkNotNull(mergeFunction);
- return Collectors.collectingAndThen(
- Collectors.toMap(keyFunction, valueFunction, mergeFunction, LinkedHashMap::new),
- ImmutableMap::copyOf);
- }
-
- static <T extends @Nullable Object, K, V>
- Collector<T, ?, ImmutableSortedMap<K, V>> toImmutableSortedMap(
- Comparator<? super K> comparator,
- Function<? super T, ? extends K> keyFunction,
- Function<? super T, ? extends V> valueFunction) {
- checkNotNull(comparator);
- checkNotNull(keyFunction);
- checkNotNull(valueFunction);
- /*
- * We will always fail if there are duplicate keys, and the keys are always sorted by
- * the Comparator, so the entries can come in an arbitrary order -- so we report UNORDERED.
- */
- return Collector.of(
- () -> new ImmutableSortedMap.Builder<K, V>(comparator),
- (builder, input) -> builder.put(keyFunction.apply(input), valueFunction.apply(input)),
- ImmutableSortedMap.Builder::combine,
- ImmutableSortedMap.Builder::build,
- Collector.Characteristics.UNORDERED);
- }
-
- static <T extends @Nullable Object, K, V>
- Collector<T, ?, ImmutableSortedMap<K, V>> toImmutableSortedMap(
- Comparator<? super K> comparator,
- Function<? super T, ? extends K> keyFunction,
- Function<? super T, ? extends V> valueFunction,
- BinaryOperator<V> mergeFunction) {
- checkNotNull(comparator);
- checkNotNull(keyFunction);
- checkNotNull(valueFunction);
- checkNotNull(mergeFunction);
- return Collectors.collectingAndThen(
- Collectors.toMap(
- keyFunction, valueFunction, mergeFunction, () -> new TreeMap<K, V>(comparator)),
- ImmutableSortedMap::copyOfSorted);
- }
-
- static <T extends @Nullable Object, K, V> Collector<T, ?, ImmutableBiMap<K, V>> toImmutableBiMap(
+ static <T, K, V> Collector<T, ?, ImmutableBiMap<K, V>> toImmutableBiMap(
Function<? super T, ? extends K> keyFunction,
Function<? super T, ? extends V> valueFunction) {
checkNotNull(keyFunction);
@@ -248,93 +40,86 @@
new Collector.Characteristics[0]);
}
- static <T extends @Nullable Object, K extends Enum<K>, V>
- Collector<T, ?, ImmutableMap<K, V>> toImmutableEnumMap(
- Function<? super T, ? extends K> keyFunction,
- Function<? super T, ? extends V> valueFunction) {
+ private static final Collector<Object, ?, ImmutableList<Object>> TO_IMMUTABLE_LIST =
+ Collector.of(
+ ImmutableList::<Object>builder,
+ ImmutableList.Builder::add,
+ ImmutableList.Builder::combine,
+ ImmutableList.Builder::build);
+
+ static <E> Collector<E, ?, ImmutableList<E>> toImmutableList() {
+ return (Collector) TO_IMMUTABLE_LIST;
+ }
+
+ static <T, K, V> Collector<T, ?, ImmutableMap<K, V>> toImmutableMap(
+ Function<? super T, ? extends K> keyFunction,
+ Function<? super T, ? extends V> valueFunction) {
checkNotNull(keyFunction);
checkNotNull(valueFunction);
return Collector.of(
- () ->
- new EnumMapAccumulator<K, V>(
- (v1, v2) -> {
- throw new IllegalArgumentException("Multiple values for key: " + v1 + ", " + v2);
- }),
- (accum, t) -> {
- /*
- * We assign these to variables before calling checkNotNull to work around a bug in our
- * nullness checker.
- */
- K key = keyFunction.apply(t);
- V newValue = valueFunction.apply(t);
- accum.put(
- checkNotNull(key, "Null key for input %s", t),
- checkNotNull(newValue, "Null value for input %s", t));
- },
- EnumMapAccumulator::combine,
- EnumMapAccumulator::toImmutableMap,
+ ImmutableMap.Builder<K, V>::new,
+ (builder, input) -> builder.put(keyFunction.apply(input), valueFunction.apply(input)),
+ ImmutableMap.Builder::combine,
+ ImmutableMap.Builder::build);
+ }
+
+ private static final Collector<Object, ?, ImmutableSet<Object>> TO_IMMUTABLE_SET =
+ Collector.of(
+ ImmutableSet::<Object>builder,
+ ImmutableSet.Builder::add,
+ ImmutableSet.Builder::combine,
+ ImmutableSet.Builder::build);
+
+ static <E> Collector<E, ?, ImmutableSet<E>> toImmutableSet() {
+ return (Collector) TO_IMMUTABLE_SET;
+ }
+
+ static <T, K, V> Collector<T, ?, ImmutableSortedMap<K, V>> toImmutableSortedMap(
+ Comparator<? super K> comparator,
+ Function<? super T, ? extends K> keyFunction,
+ Function<? super T, ? extends V> valueFunction) {
+ checkNotNull(comparator);
+ checkNotNull(keyFunction);
+ checkNotNull(valueFunction);
+ /*
+ * We will always fail if there are duplicate keys, and the keys are always sorted by
+ * the Comparator, so the entries can come in in arbitrary order -- so we report UNORDERED.
+ */
+ return Collector.of(
+ () -> new ImmutableSortedMap.Builder<K, V>(comparator),
+ (builder, input) -> builder.put(keyFunction.apply(input), valueFunction.apply(input)),
+ ImmutableSortedMap.Builder::combine,
+ ImmutableSortedMap.Builder::build,
Collector.Characteristics.UNORDERED);
}
- static <T extends @Nullable Object, K extends Enum<K>, V>
- Collector<T, ?, ImmutableMap<K, V>> toImmutableEnumMap(
- Function<? super T, ? extends K> keyFunction,
- Function<? super T, ? extends V> valueFunction,
- BinaryOperator<V> mergeFunction) {
- checkNotNull(keyFunction);
- checkNotNull(valueFunction);
- checkNotNull(mergeFunction);
- // not UNORDERED because we don't know if mergeFunction is commutative
+ static <E> Collector<E, ?, ImmutableSortedSet<E>> toImmutableSortedSet(
+ Comparator<? super E> comparator) {
+ checkNotNull(comparator);
return Collector.of(
- () -> new EnumMapAccumulator<K, V>(mergeFunction),
- (accum, t) -> {
- /*
- * We assign these to variables before calling checkNotNull to work around a bug in our
- * nullness checker.
- */
- K key = keyFunction.apply(t);
- V newValue = valueFunction.apply(t);
- accum.put(
- checkNotNull(key, "Null key for input %s", t),
- checkNotNull(newValue, "Null value for input %s", t));
- },
- EnumMapAccumulator::combine,
- EnumMapAccumulator::toImmutableMap);
- }
-
- private static class EnumMapAccumulator<K extends Enum<K>, V> {
- private final BinaryOperator<V> mergeFunction;
- @CheckForNull private EnumMap<K, V> map = null;
-
- EnumMapAccumulator(BinaryOperator<V> mergeFunction) {
- this.mergeFunction = mergeFunction;
- }
-
- void put(K key, V value) {
- if (map == null) {
- map = new EnumMap<>(key.getDeclaringClass());
- }
- map.merge(key, value, mergeFunction);
- }
-
- EnumMapAccumulator<K, V> combine(EnumMapAccumulator<K, V> other) {
- if (this.map == null) {
- return other;
- } else if (other.map == null) {
- return this;
- } else {
- other.map.forEach(this::put);
- return this;
- }
- }
-
- ImmutableMap<K, V> toImmutableMap() {
- return (map == null) ? ImmutableMap.<K, V>of() : ImmutableEnumMap.asImmutable(map);
- }
+ () -> new ImmutableSortedSet.Builder<E>(comparator),
+ ImmutableSortedSet.Builder::add,
+ ImmutableSortedSet.Builder::combine,
+ ImmutableSortedSet.Builder::build);
}
@GwtIncompatible
- static <T extends @Nullable Object, K extends Comparable<? super K>, V>
+ private static final Collector<Range<Comparable>, ?, ImmutableRangeSet<Comparable>>
+ TO_IMMUTABLE_RANGE_SET =
+ Collector.of(
+ ImmutableRangeSet::<Comparable>builder,
+ ImmutableRangeSet.Builder::add,
+ ImmutableRangeSet.Builder::combine,
+ ImmutableRangeSet.Builder::build);
+
+ @GwtIncompatible
+ static <E extends Comparable<? super E>>
+ Collector<Range<E>, ?, ImmutableRangeSet<E>> toImmutableRangeSet() {
+ return (Collector) TO_IMMUTABLE_RANGE_SET;
+ }
+
+ @GwtIncompatible
+ static <T, K extends Comparable<? super K>, V>
Collector<T, ?, ImmutableRangeMap<K, V>> toImmutableRangeMap(
Function<? super T, Range<K>> keyFunction,
Function<? super T, ? extends V> valueFunction) {
@@ -346,106 +131,4 @@
ImmutableRangeMap.Builder::combine,
ImmutableRangeMap.Builder::build);
}
-
- // Multimaps
-
- static <T extends @Nullable Object, K, V>
- Collector<T, ?, ImmutableListMultimap<K, V>> toImmutableListMultimap(
- Function<? super T, ? extends K> keyFunction,
- Function<? super T, ? extends V> valueFunction) {
- checkNotNull(keyFunction, "keyFunction");
- checkNotNull(valueFunction, "valueFunction");
- return Collector.of(
- ImmutableListMultimap::<K, V>builder,
- (builder, t) -> builder.put(keyFunction.apply(t), valueFunction.apply(t)),
- ImmutableListMultimap.Builder::combine,
- ImmutableListMultimap.Builder::build);
- }
-
- static <T extends @Nullable Object, K, V>
- Collector<T, ?, ImmutableListMultimap<K, V>> flatteningToImmutableListMultimap(
- Function<? super T, ? extends K> keyFunction,
- Function<? super T, ? extends Stream<? extends V>> valuesFunction) {
- checkNotNull(keyFunction);
- checkNotNull(valuesFunction);
- return Collectors.collectingAndThen(
- flatteningToMultimap(
- input -> checkNotNull(keyFunction.apply(input)),
- input -> valuesFunction.apply(input).peek(Preconditions::checkNotNull),
- MultimapBuilder.linkedHashKeys().arrayListValues()::<K, V>build),
- ImmutableListMultimap::copyOf);
- }
-
- static <T extends @Nullable Object, K, V>
- Collector<T, ?, ImmutableSetMultimap<K, V>> toImmutableSetMultimap(
- Function<? super T, ? extends K> keyFunction,
- Function<? super T, ? extends V> valueFunction) {
- checkNotNull(keyFunction, "keyFunction");
- checkNotNull(valueFunction, "valueFunction");
- return Collector.of(
- ImmutableSetMultimap::<K, V>builder,
- (builder, t) -> builder.put(keyFunction.apply(t), valueFunction.apply(t)),
- ImmutableSetMultimap.Builder::combine,
- ImmutableSetMultimap.Builder::build);
- }
-
- static <T extends @Nullable Object, K, V>
- Collector<T, ?, ImmutableSetMultimap<K, V>> flatteningToImmutableSetMultimap(
- Function<? super T, ? extends K> keyFunction,
- Function<? super T, ? extends Stream<? extends V>> valuesFunction) {
- checkNotNull(keyFunction);
- checkNotNull(valuesFunction);
- return Collectors.collectingAndThen(
- flatteningToMultimap(
- input -> checkNotNull(keyFunction.apply(input)),
- input -> valuesFunction.apply(input).peek(Preconditions::checkNotNull),
- MultimapBuilder.linkedHashKeys().linkedHashSetValues()::<K, V>build),
- ImmutableSetMultimap::copyOf);
- }
-
- static <
- T extends @Nullable Object,
- K extends @Nullable Object,
- V extends @Nullable Object,
- M extends Multimap<K, V>>
- Collector<T, ?, M> toMultimap(
- Function<? super T, ? extends K> keyFunction,
- Function<? super T, ? extends V> valueFunction,
- Supplier<M> multimapSupplier) {
- checkNotNull(keyFunction);
- checkNotNull(valueFunction);
- checkNotNull(multimapSupplier);
- return Collector.of(
- multimapSupplier,
- (multimap, input) -> multimap.put(keyFunction.apply(input), valueFunction.apply(input)),
- (multimap1, multimap2) -> {
- multimap1.putAll(multimap2);
- return multimap1;
- });
- }
-
- static <
- T extends @Nullable Object,
- K extends @Nullable Object,
- V extends @Nullable Object,
- M extends Multimap<K, V>>
- Collector<T, ?, M> flatteningToMultimap(
- Function<? super T, ? extends K> keyFunction,
- Function<? super T, ? extends Stream<? extends V>> valueFunction,
- Supplier<M> multimapSupplier) {
- checkNotNull(keyFunction);
- checkNotNull(valueFunction);
- checkNotNull(multimapSupplier);
- return Collector.of(
- multimapSupplier,
- (multimap, input) -> {
- K key = keyFunction.apply(input);
- Collection<V> valuesForKey = multimap.get(key);
- valueFunction.apply(input).forEachOrdered(valuesForKey::add);
- },
- (multimap1, multimap2) -> {
- multimap1.putAll(multimap2);
- return multimap1;
- });
- }
}
diff --git a/guava/src/com/google/common/collect/CollectPreconditions.java b/guava/src/com/google/common/collect/CollectPreconditions.java
index c649b03..98b30c6 100644
--- a/guava/src/com/google/common/collect/CollectPreconditions.java
+++ b/guava/src/com/google/common/collect/CollectPreconditions.java
@@ -23,7 +23,6 @@
/** Precondition checks useful in collection implementations. */
@GwtCompatible
-@ElementTypesAreNonnullByDefault
final class CollectPreconditions {
static void checkEntryNotNull(Object key, Object value) {
diff --git a/guava/src/com/google/common/collect/CollectSpliterators.java b/guava/src/com/google/common/collect/CollectSpliterators.java
index 91f563d..974f77f 100644
--- a/guava/src/com/google/common/collect/CollectSpliterators.java
+++ b/guava/src/com/google/common/collect/CollectSpliterators.java
@@ -18,7 +18,6 @@
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.collect.NullnessCasts.uncheckedCastNullableTToT;
import com.google.common.annotations.GwtCompatible;
import com.google.j2objc.annotations.Weak;
@@ -32,25 +31,22 @@
import java.util.function.LongConsumer;
import java.util.function.Predicate;
import java.util.stream.IntStream;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/** Spliterator utilities for {@code common.collect} internals. */
@GwtCompatible
-@ElementTypesAreNonnullByDefault
final class CollectSpliterators {
private CollectSpliterators() {}
- static <T extends @Nullable Object> Spliterator<T> indexed(
- int size, int extraCharacteristics, IntFunction<T> function) {
+ static <T> Spliterator<T> indexed(int size, int extraCharacteristics, IntFunction<T> function) {
return indexed(size, extraCharacteristics, function, null);
}
- static <T extends @Nullable Object> Spliterator<T> indexed(
+ static <T> Spliterator<T> indexed(
int size,
int extraCharacteristics,
IntFunction<T> function,
- @CheckForNull Comparator<? super T> comparator) {
+ Comparator<? super T> comparator) {
if (comparator != null) {
checkArgument((extraCharacteristics & Spliterator.SORTED) != 0);
}
@@ -72,8 +68,7 @@
}
@Override
- @CheckForNull
- public Spliterator<T> trySplit() {
+ public @Nullable Spliterator<T> trySplit() {
Spliterator.OfInt split = delegate.trySplit();
return (split == null) ? null : new WithCharacteristics(split);
}
@@ -92,7 +87,6 @@
}
@Override
- @CheckForNull
public Comparator<? super T> getComparator() {
if (hasCharacteristics(Spliterator.SORTED)) {
return comparator;
@@ -108,10 +102,9 @@
* Returns a {@code Spliterator} over the elements of {@code fromSpliterator} mapped by {@code
* function}.
*/
- static <InElementT extends @Nullable Object, OutElementT extends @Nullable Object>
- Spliterator<OutElementT> map(
- Spliterator<InElementT> fromSpliterator,
- Function<? super InElementT, ? extends OutElementT> function) {
+ static <InElementT, OutElementT> Spliterator<OutElementT> map(
+ Spliterator<InElementT> fromSpliterator,
+ Function<? super InElementT, ? extends OutElementT> function) {
checkNotNull(fromSpliterator);
checkNotNull(function);
return new Spliterator<OutElementT>() {
@@ -128,7 +121,6 @@
}
@Override
- @CheckForNull
public Spliterator<OutElementT> trySplit() {
Spliterator<InElementT> fromSplit = fromSpliterator.trySplit();
return (fromSplit != null) ? map(fromSplit, function) : null;
@@ -148,15 +140,14 @@
}
/** Returns a {@code Spliterator} filtered by the specified predicate. */
- static <T extends @Nullable Object> Spliterator<T> filter(
- Spliterator<T> fromSpliterator, Predicate<? super T> predicate) {
+ static <T> Spliterator<T> filter(Spliterator<T> fromSpliterator, Predicate<? super T> predicate) {
checkNotNull(fromSpliterator);
checkNotNull(predicate);
class Splitr implements Spliterator<T>, Consumer<T> {
- @CheckForNull T holder = null;
+ T holder = null;
@Override
- public void accept(@ParametricNullness T t) {
+ public void accept(T t) {
this.holder = t;
}
@@ -164,10 +155,8 @@
public boolean tryAdvance(Consumer<? super T> action) {
while (fromSpliterator.tryAdvance(this)) {
try {
- // The cast is safe because tryAdvance puts a T into `holder`.
- T next = uncheckedCastNullableTToT(holder);
- if (predicate.test(next)) {
- action.accept(next);
+ if (predicate.test(holder)) {
+ action.accept(holder);
return true;
}
} finally {
@@ -178,7 +167,6 @@
}
@Override
- @CheckForNull
public Spliterator<T> trySplit() {
Spliterator<T> fromSplit = fromSpliterator.trySplit();
return (fromSplit == null) ? null : filter(fromSplit, predicate);
@@ -190,7 +178,6 @@
}
@Override
- @CheckForNull
public Comparator<? super T> getComparator() {
return fromSpliterator.getComparator();
}
@@ -211,12 +198,11 @@
* Returns a {@code Spliterator} that iterates over the elements of the spliterators generated by
* applying {@code function} to the elements of {@code fromSpliterator}.
*/
- static <InElementT extends @Nullable Object, OutElementT extends @Nullable Object>
- Spliterator<OutElementT> flatMap(
- Spliterator<InElementT> fromSpliterator,
- Function<? super InElementT, Spliterator<OutElementT>> function,
- int topCharacteristics,
- long topSize) {
+ static <InElementT, OutElementT> Spliterator<OutElementT> flatMap(
+ Spliterator<InElementT> fromSpliterator,
+ Function<? super InElementT, Spliterator<OutElementT>> function,
+ int topCharacteristics,
+ long topSize) {
checkArgument(
(topCharacteristics & Spliterator.SUBSIZED) == 0,
"flatMap does not support SUBSIZED characteristic");
@@ -234,7 +220,7 @@
* generated by applying {@code function} to the elements of {@code fromSpliterator}. (If {@code
* function} returns {@code null} for an input, it is replaced with an empty stream.)
*/
- static <InElementT extends @Nullable Object> Spliterator.OfInt flatMapToInt(
+ static <InElementT> Spliterator.OfInt flatMapToInt(
Spliterator<InElementT> fromSpliterator,
Function<? super InElementT, Spliterator.OfInt> function,
int topCharacteristics,
@@ -256,7 +242,7 @@
* generated by applying {@code function} to the elements of {@code fromSpliterator}. (If {@code
* function} returns {@code null} for an input, it is replaced with an empty stream.)
*/
- static <InElementT extends @Nullable Object> Spliterator.OfLong flatMapToLong(
+ static <InElementT> Spliterator.OfLong flatMapToLong(
Spliterator<InElementT> fromSpliterator,
Function<? super InElementT, Spliterator.OfLong> function,
int topCharacteristics,
@@ -278,7 +264,7 @@
* generated by applying {@code function} to the elements of {@code fromSpliterator}. (If {@code
* function} returns {@code null} for an input, it is replaced with an empty stream.)
*/
- static <InElementT extends @Nullable Object> Spliterator.OfDouble flatMapToDouble(
+ static <InElementT> Spliterator.OfDouble flatMapToDouble(
Spliterator<InElementT> fromSpliterator,
Function<? super InElementT, Spliterator.OfDouble> function,
int topCharacteristics,
@@ -303,22 +289,20 @@
* @param <OutSpliteratorT> the type of the output spliterators
*/
abstract static class FlatMapSpliterator<
- InElementT extends @Nullable Object,
- OutElementT extends @Nullable Object,
- OutSpliteratorT extends Spliterator<OutElementT>>
+ InElementT, OutElementT, OutSpliteratorT extends Spliterator<OutElementT>>
implements Spliterator<OutElementT> {
/** Factory for constructing {@link FlatMapSpliterator} instances. */
@FunctionalInterface
- interface Factory<InElementT extends @Nullable Object, OutSpliteratorT extends Spliterator<?>> {
+ interface Factory<InElementT, OutSpliteratorT extends Spliterator<?>> {
OutSpliteratorT newFlatMapSpliterator(
- @CheckForNull OutSpliteratorT prefix,
+ OutSpliteratorT prefix,
Spliterator<InElementT> fromSplit,
Function<? super InElementT, OutSpliteratorT> function,
int splitCharacteristics,
long estSplitSize);
}
- @Weak @CheckForNull OutSpliteratorT prefix;
+ @Nullable @Weak OutSpliteratorT prefix;
final Spliterator<InElementT> from;
final Function<? super InElementT, OutSpliteratorT> function;
final Factory<InElementT, OutSpliteratorT> factory;
@@ -326,7 +310,7 @@
long estimatedSize;
FlatMapSpliterator(
- @CheckForNull OutSpliteratorT prefix,
+ OutSpliteratorT prefix,
Spliterator<InElementT> from,
Function<? super InElementT, OutSpliteratorT> function,
Factory<InElementT, OutSpliteratorT> factory,
@@ -381,7 +365,6 @@
}
@Override
- @CheckForNull
public final OutSpliteratorT trySplit() {
Spliterator<InElementT> fromSplit = from.trySplit();
if (fromSplit != null) {
@@ -431,11 +414,10 @@
* @param <InElementT> the element type of the input spliterator
* @param <OutElementT> the element type of the output spliterators
*/
- static final class FlatMapSpliteratorOfObject<
- InElementT extends @Nullable Object, OutElementT extends @Nullable Object>
+ static final class FlatMapSpliteratorOfObject<InElementT, OutElementT>
extends FlatMapSpliterator<InElementT, OutElementT, Spliterator<OutElementT>> {
FlatMapSpliteratorOfObject(
- @CheckForNull Spliterator<OutElementT> prefix,
+ Spliterator<OutElementT> prefix,
Spliterator<InElementT> from,
Function<? super InElementT, Spliterator<OutElementT>> function,
int characteristics,
@@ -454,8 +436,8 @@
* @param <OutSpliteratorT> the primitive spliterator type associated with {@code OutElementT}
*/
abstract static class FlatMapSpliteratorOfPrimitive<
- InElementT extends @Nullable Object,
- OutElementT extends @Nullable Object,
+ InElementT,
+ OutElementT,
OutConsumerT,
OutSpliteratorT extends
Spliterator.OfPrimitive<OutElementT, OutConsumerT, OutSpliteratorT>>
@@ -463,7 +445,7 @@
implements Spliterator.OfPrimitive<OutElementT, OutConsumerT, OutSpliteratorT> {
FlatMapSpliteratorOfPrimitive(
- @CheckForNull OutSpliteratorT prefix,
+ OutSpliteratorT prefix,
Spliterator<InElementT> from,
Function<? super InElementT, OutSpliteratorT> function,
Factory<InElementT, OutSpliteratorT> factory,
@@ -507,11 +489,11 @@
}
/** Implementation of {@link #flatMapToInt}. */
- static final class FlatMapSpliteratorOfInt<InElementT extends @Nullable Object>
+ static final class FlatMapSpliteratorOfInt<InElementT>
extends FlatMapSpliteratorOfPrimitive<InElementT, Integer, IntConsumer, Spliterator.OfInt>
implements Spliterator.OfInt {
FlatMapSpliteratorOfInt(
- @CheckForNull Spliterator.OfInt prefix,
+ Spliterator.OfInt prefix,
Spliterator<InElementT> from,
Function<? super InElementT, Spliterator.OfInt> function,
int characteristics,
@@ -521,11 +503,11 @@
}
/** Implementation of {@link #flatMapToLong}. */
- static final class FlatMapSpliteratorOfLong<InElementT extends @Nullable Object>
+ static final class FlatMapSpliteratorOfLong<InElementT>
extends FlatMapSpliteratorOfPrimitive<InElementT, Long, LongConsumer, Spliterator.OfLong>
implements Spliterator.OfLong {
FlatMapSpliteratorOfLong(
- @CheckForNull Spliterator.OfLong prefix,
+ Spliterator.OfLong prefix,
Spliterator<InElementT> from,
Function<? super InElementT, Spliterator.OfLong> function,
int characteristics,
@@ -535,12 +517,12 @@
}
/** Implementation of {@link #flatMapToDouble}. */
- static final class FlatMapSpliteratorOfDouble<InElementT extends @Nullable Object>
+ static final class FlatMapSpliteratorOfDouble<InElementT>
extends FlatMapSpliteratorOfPrimitive<
InElementT, Double, DoubleConsumer, Spliterator.OfDouble>
implements Spliterator.OfDouble {
FlatMapSpliteratorOfDouble(
- @CheckForNull Spliterator.OfDouble prefix,
+ Spliterator.OfDouble prefix,
Spliterator<InElementT> from,
Function<? super InElementT, Spliterator.OfDouble> function,
int characteristics,
diff --git a/guava/src/com/google/common/collect/Collections2.java b/guava/src/com/google/common/collect/Collections2.java
index eb92859..009f10e 100644
--- a/guava/src/com/google/common/collect/Collections2.java
+++ b/guava/src/com/google/common/collect/Collections2.java
@@ -19,7 +19,6 @@
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.collect.CollectPreconditions.checkNonnegative;
-import static java.util.Objects.requireNonNull;
import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtCompatible;
@@ -38,7 +37,6 @@
import java.util.List;
import java.util.Spliterator;
import java.util.function.Consumer;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -55,7 +53,6 @@
* @since 2.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
public final class Collections2 {
private Collections2() {}
@@ -86,8 +83,7 @@
*/
// TODO(kevinb): how can we omit that Iterables link when building gwt
// javadoc?
- public static <E extends @Nullable Object> Collection<E> filter(
- Collection<E> unfiltered, Predicate<? super E> predicate) {
+ public static <E> Collection<E> filter(Collection<E> unfiltered, Predicate<? super E> predicate) {
if (unfiltered instanceof FilteredCollection) {
// Support clear(), removeAll(), and retainAll() when filtering a filtered
// collection.
@@ -101,7 +97,7 @@
* Delegates to {@link Collection#contains}. Returns {@code false} if the {@code contains} method
* throws a {@code ClassCastException} or {@code NullPointerException}.
*/
- static boolean safeContains(Collection<?> collection, @CheckForNull Object object) {
+ static boolean safeContains(Collection<?> collection, @Nullable Object object) {
checkNotNull(collection);
try {
return collection.contains(object);
@@ -114,7 +110,7 @@
* 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, @CheckForNull Object object) {
+ static boolean safeRemove(Collection<?> collection, @Nullable Object object) {
checkNotNull(collection);
try {
return collection.remove(object);
@@ -123,7 +119,7 @@
}
}
- static class FilteredCollection<E extends @Nullable Object> extends AbstractCollection<E> {
+ static class FilteredCollection<E> extends AbstractCollection<E> {
final Collection<E> unfiltered;
final Predicate<? super E> predicate;
@@ -138,7 +134,7 @@
}
@Override
- public boolean add(@ParametricNullness E element) {
+ public boolean add(E element) {
checkArgument(predicate.apply(element));
return unfiltered.add(element);
}
@@ -157,7 +153,7 @@
}
@Override
- public boolean contains(@CheckForNull 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;
@@ -198,7 +194,7 @@
}
@Override
- public boolean remove(@CheckForNull Object element) {
+ public boolean remove(Object element) {
return contains(element) && unfiltered.remove(element);
}
@@ -230,14 +226,13 @@
}
@Override
- public @Nullable Object[] toArray() {
+ public Object[] toArray() {
// creating an ArrayList so filtering happens once
return Lists.newArrayList(iterator()).toArray();
}
@Override
- @SuppressWarnings("nullness") // b/192354773 in our checker affects toArray declarations
- public <T extends @Nullable Object> T[] toArray(T[] array) {
+ public <T> T[] toArray(T[] array) {
return Lists.newArrayList(iterator()).toArray(array);
}
}
@@ -261,13 +256,12 @@
*
* <p><b>{@code Stream} equivalent:</b> {@link java.util.stream.Stream#map Stream.map}.
*/
- public static <F extends @Nullable Object, T extends @Nullable Object> Collection<T> transform(
+ public static <F, T> Collection<T> transform(
Collection<F> fromCollection, Function<? super F, T> function) {
return new TransformedCollection<>(fromCollection, function);
}
- static class TransformedCollection<F extends @Nullable Object, T extends @Nullable Object>
- extends AbstractCollection<T> {
+ static class TransformedCollection<F, T> extends AbstractCollection<T> {
final Collection<F> fromCollection;
final Function<? super F, ? extends T> function;
@@ -495,7 +489,7 @@
}
@Override
- public boolean contains(@CheckForNull Object obj) {
+ public boolean contains(@Nullable Object obj) {
if (obj instanceof List) {
List<?> list = (List<?>) obj;
return isPermutation(inputList, list);
@@ -510,7 +504,7 @@
}
private static final class OrderedPermutationIterator<E> extends AbstractIterator<List<E>> {
- @CheckForNull List<E> nextPermutation;
+ @Nullable List<E> nextPermutation;
final Comparator<? super E> comparator;
OrderedPermutationIterator(List<E> list, Comparator<? super E> comparator) {
@@ -519,7 +513,6 @@
}
@Override
- @CheckForNull
protected List<E> computeNext() {
if (nextPermutation == null) {
return endOfData();
@@ -535,11 +528,6 @@
nextPermutation = null;
return;
}
- /*
- * requireNonNull is safe because we don't clear nextPermutation until we're done calling this
- * method.
- */
- requireNonNull(nextPermutation);
int l = findNextL(j);
Collections.swap(nextPermutation, j, l);
@@ -548,11 +536,6 @@
}
int findNextJ() {
- /*
- * requireNonNull is safe because we don't clear nextPermutation until we're done calling this
- * method.
- */
- requireNonNull(nextPermutation);
for (int k = nextPermutation.size() - 2; k >= 0; k--) {
if (comparator.compare(nextPermutation.get(k), nextPermutation.get(k + 1)) < 0) {
return k;
@@ -562,11 +545,6 @@
}
int findNextL(int j) {
- /*
- * requireNonNull is safe because we don't clear nextPermutation until we're done calling this
- * method.
- */
- requireNonNull(nextPermutation);
E ak = nextPermutation.get(j);
for (int l = nextPermutation.size() - 1; l > j; l--) {
if (comparator.compare(ak, nextPermutation.get(l)) < 0) {
@@ -622,7 +600,7 @@
}
@Override
- public boolean contains(@CheckForNull Object obj) {
+ public boolean contains(@Nullable Object obj) {
if (obj instanceof List) {
List<?> list = (List<?>) obj;
return isPermutation(inputList, list);
@@ -653,7 +631,6 @@
}
@Override
- @CheckForNull
protected List<E> computeNext() {
if (j <= 0) {
return endOfData();
diff --git a/guava/src/com/google/common/collect/CompactHashMap.java b/guava/src/com/google/common/collect/CompactHashMap.java
index e40b05e..a68890e 100644
--- a/guava/src/com/google/common/collect/CompactHashMap.java
+++ b/guava/src/com/google/common/collect/CompactHashMap.java
@@ -20,9 +20,6 @@
import static com.google.common.collect.CollectPreconditions.checkRemove;
import static com.google.common.collect.CompactHashing.UNSET;
import static com.google.common.collect.Hashing.smearedHash;
-import static com.google.common.collect.NullnessCasts.uncheckedCastNullableTToT;
-import static com.google.common.collect.NullnessCasts.unsafeNull;
-import static java.util.Objects.requireNonNull;
import com.google.common.annotations.GwtIncompatible;
import com.google.common.annotations.VisibleForTesting;
@@ -50,7 +47,6 @@
import java.util.function.BiConsumer;
import java.util.function.BiFunction;
import java.util.function.Consumer;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -80,9 +76,7 @@
* @author Jon Noack
*/
@GwtIncompatible // not worth using in GWT for now
-@ElementTypesAreNonnullByDefault
-class CompactHashMap<K extends @Nullable Object, V extends @Nullable Object>
- extends AbstractMap<K, V> implements Serializable {
+class CompactHashMap<K, V> extends AbstractMap<K, V> implements Serializable {
/*
* TODO: Make this a drop-in replacement for j.u. versions, actually drop them in, and test the
* world. Figure out what sort of space-time tradeoff we're actually going to get here with the
@@ -92,8 +86,7 @@
*/
/** Creates an empty {@code CompactHashMap} instance. */
- public static <K extends @Nullable Object, V extends @Nullable Object>
- CompactHashMap<K, V> create() {
+ public static <K, V> CompactHashMap<K, V> create() {
return new CompactHashMap<>();
}
@@ -106,8 +99,7 @@
* elements without resizing
* @throws IllegalArgumentException if {@code expectedSize} is negative
*/
- public static <K extends @Nullable Object, V extends @Nullable Object>
- CompactHashMap<K, V> createWithExpectedSize(int expectedSize) {
+ public static <K, V> CompactHashMap<K, V> createWithExpectedSize(int expectedSize) {
return new CompactHashMap<>(expectedSize);
}
@@ -127,46 +119,6 @@
*/
private static final int MAX_HASH_BUCKET_LENGTH = 9;
- // The way the `table`, `entries`, `keys`, and `values` arrays work together is as follows.
- //
- // The `table` array always has a size that is a power of 2. The hashcode of a key in the map
- // is masked in order to correspond to the current table size. For example, if the table size
- // is 128 then the mask is 127 == 0x7f, keeping the bottom 7 bits of the hash value.
- // If a key hashes to 0x89abcdef the mask reduces it to 0x89abcdef & 0x7f == 0x6f. We'll call this
- // the "short hash".
- //
- // The `keys`, `values`, and `entries` arrays always have the same size as each other. They can be
- // seen as fields of an imaginary `Entry` object like this:
- //
- // class Entry {
- // int hash;
- // Entry next;
- // K key;
- // V value;
- // }
- //
- // The imaginary `hash` and `next` values are combined into a single `int` value in the `entries`
- // array. The top bits of this value are the remaining bits of the hash value that were not used
- // in the short hash. We saw that a mask of 0x7f would keep the 7-bit value 0x6f from a full
- // hashcode of 0x89abcdef. The imaginary `hash` value would then be the remaining top 25 bits,
- // 0x89abcd80. To this is added (or'd) the `next` value, which is an index within `entries`
- // (and therefore within `keys` and `values`) of another entry that has the same short hash
- // value. In our example, it would be another entry for a key whose short hash is also 0x6f.
- //
- // Essentially, then, `table[h]` gives us the start of a linked list in `entries`, where every
- // element of the list has the short hash value h.
- //
- // A wrinkle here is that the value 0 (called UNSET in the code) is used as the equivalent of a
- // null pointer. If `table[h] == 0` that means there are no keys in the map whose short hash is h.
- // If the `next` bits in `entries[i]` are 0 that means there are no further entries for the given
- // short hash. But 0 is also a valid index in `entries`, so we add 1 to these indices before
- // putting them in `table` or in `next` bits, and subtract 1 again when we need an index value.
- //
- // The elements of `keys`, `values`, and `entries` are added sequentially, so that elements 0 to
- // `size() - 1` are used and remaining elements are not. This makes iteration straightforward.
- // Removing an entry generally involves moving the last element of each array to where the removed
- // entry was, and adjusting index links accordingly.
-
/**
* The hashtable object. This can be either:
*
@@ -186,7 +138,7 @@
* <li>null, if no entries have yet been added to the map
* </ul>
*/
- @CheckForNull private transient Object table;
+ @Nullable private transient Object table;
/**
* Contains the logical entries, in the range of [0, size()). The high bits of each int are the
@@ -196,38 +148,32 @@
*
* <pre>
* hash = aaaaaaaa
- * mask = 00000fff
- * next = 00000bbb
- * entry = aaaaabbb
+ * mask = 0000ffff
+ * next = 0000bbbb
+ * entry = aaaabbbb
* </pre>
*
* <p>The pointers in [size(), entries.length) are all "null" (UNSET).
*/
- @VisibleForTesting @CheckForNull transient int[] entries;
+ @VisibleForTesting transient int @Nullable [] entries;
/**
* The keys of the entries in the map, in the range of [0, size()). The keys in [size(),
* keys.length) are all {@code null}.
*/
- @VisibleForTesting @CheckForNull transient @Nullable Object[] keys;
+ @VisibleForTesting transient Object @Nullable [] keys;
/**
* The values of the entries in the map, in the range of [0, size()). The values in [size(),
* values.length) are all {@code null}.
*/
- @VisibleForTesting @CheckForNull transient @Nullable Object[] values;
+ @VisibleForTesting transient Object @Nullable [] values;
/**
* Keeps track of metadata like the number of hash table bits and modifications of this data
* structure (to make it possible to throw ConcurrentModificationException in the iterator). Note
* that we choose not to make this volatile, so we do less of a "best effort" to track such
* errors, for better performance.
- *
- * <p>For a new instance, where the arrays above have not yet been allocated, the value of {@code
- * metadata} is the size that the arrays should be allocated with. Once the arrays have been
- * allocated, the value of {@code metadata} combines the number of bits in the "short hash", in
- * its bottom {@value CompactHashing#HASH_TABLE_BITS_MAX_BITS} bits, with a modification count in
- * the remaining bits that is used to detect concurrent modification during iteration.
*/
private transient int metadata;
@@ -281,7 +227,7 @@
@SuppressWarnings("unchecked")
@VisibleForTesting
- @CheckForNull
+ @Nullable
Map<K, V> delegateOrNull() {
if (table instanceof Map) {
return (Map<K, V>) table;
@@ -293,12 +239,13 @@
return new LinkedHashMap<>(tableSize, 1.0f);
}
+ @SuppressWarnings("unchecked")
@VisibleForTesting
@CanIgnoreReturnValue
Map<K, V> convertToHashFloodingResistantImplementation() {
Map<K, V> newDelegate = createHashFloodingResistantDelegate(hashTableMask() + 1);
for (int i = firstEntryIndex(); i >= 0; i = getSuccessor(i)) {
- newDelegate.put(key(i), value(i));
+ newDelegate.put((K) keys[i], (V) values[i]);
}
this.table = newDelegate;
this.entries = null;
@@ -334,31 +281,30 @@
@CanIgnoreReturnValue
@Override
- @CheckForNull
- public V put(@ParametricNullness K key, @ParametricNullness V value) {
+ public @Nullable V put(@Nullable K key, @Nullable V value) {
if (needsAllocArrays()) {
allocArrays();
}
- Map<K, V> delegate = delegateOrNull();
+ @Nullable Map<K, V> delegate = delegateOrNull();
if (delegate != null) {
return delegate.put(key, value);
}
- int[] entries = requireEntries();
- @Nullable Object[] keys = requireKeys();
- @Nullable Object[] values = requireValues();
+ int[] entries = this.entries;
+ Object[] keys = this.keys;
+ Object[] values = this.values;
int newEntryIndex = this.size; // current size, and pointer to the entry to be appended
int newSize = newEntryIndex + 1;
int hash = smearedHash(key);
int mask = hashTableMask();
int tableIndex = hash & mask;
- int next = CompactHashing.tableGet(requireTable(), tableIndex);
+ int next = CompactHashing.tableGet(table, tableIndex);
if (next == UNSET) { // uninitialized bucket
if (newSize > mask) {
// Resize and add new entry
mask = resizeTable(mask, CompactHashing.newCapacity(mask), hash, newEntryIndex);
} else {
- CompactHashing.tableSet(requireTable(), tableIndex, newEntryIndex + 1);
+ CompactHashing.tableSet(table, tableIndex, newEntryIndex + 1);
}
} else {
int entryIndex;
@@ -371,6 +317,7 @@
if (CompactHashing.getHashPrefix(entry, mask) == hashPrefix
&& Objects.equal(key, keys[entryIndex])) {
@SuppressWarnings("unchecked") // known to be a V
+ @Nullable
V oldValue = (V) values[entryIndex];
values[entryIndex] = value;
@@ -402,16 +349,15 @@
/**
* Creates a fresh entry with the specified object at the specified position in the entry arrays.
*/
- void insertEntry(
- int entryIndex, @ParametricNullness K key, @ParametricNullness V value, int hash, int mask) {
- this.setEntry(entryIndex, CompactHashing.maskCombine(hash, UNSET, mask));
- this.setKey(entryIndex, key);
- this.setValue(entryIndex, value);
+ void insertEntry(int entryIndex, @Nullable K key, @Nullable V value, int hash, int mask) {
+ this.entries[entryIndex] = CompactHashing.maskCombine(hash, UNSET, mask);
+ this.keys[entryIndex] = key;
+ this.values[entryIndex] = value;
}
/** Resizes the entries storage if necessary. */
private void resizeMeMaybe(int newSize) {
- int entriesSize = requireEntries().length;
+ int entriesSize = entries.length;
if (newSize > entriesSize) {
// 1.5x but round up to nearest odd (this is optimal for memory consumption on Android)
int newCapacity =
@@ -427,13 +373,13 @@
* the current capacity.
*/
void resizeEntries(int newCapacity) {
- this.entries = Arrays.copyOf(requireEntries(), newCapacity);
- this.keys = Arrays.copyOf(requireKeys(), newCapacity);
- this.values = Arrays.copyOf(requireValues(), newCapacity);
+ this.entries = Arrays.copyOf(entries, newCapacity);
+ this.keys = Arrays.copyOf(keys, newCapacity);
+ this.values = Arrays.copyOf(values, newCapacity);
}
@CanIgnoreReturnValue
- private int resizeTable(int oldMask, int newCapacity, int targetHash, int targetEntryIndex) {
+ private int resizeTable(int mask, int newCapacity, int targetHash, int targetEntryIndex) {
Object newTable = CompactHashing.createTable(newCapacity);
int newMask = newCapacity - 1;
@@ -442,35 +388,25 @@
CompactHashing.tableSet(newTable, targetHash & newMask, targetEntryIndex + 1);
}
- Object oldTable = requireTable();
- int[] entries = requireEntries();
+ Object table = this.table;
+ int[] entries = this.entries;
- // Loop over `oldTable` to construct its replacement, ``newTable`. The entries do not move, so
- // the `keys` and `values` arrays do not need to change. But because the "short hash" now has a
- // different number of bits, we must rewrite each element of `entries` so that its contribution
- // to the full hashcode reflects the change, and so that its `next` link corresponds to the new
- // linked list of entries with the new short hash.
- for (int oldTableIndex = 0; oldTableIndex <= oldMask; oldTableIndex++) {
- int oldNext = CompactHashing.tableGet(oldTable, oldTableIndex);
- // Each element of `oldTable` is the head of a (possibly empty) linked list of elements in
- // `entries`. The `oldNext` loop is going to traverse that linked list.
- // We need to rewrite the `next` link of each of the elements so that it is in the appropriate
- // linked list starting from `newTable`. In general, each element from the old linked list
- // belongs to a different linked list from `newTable`. We insert each element in turn at the
- // head of its appropriate `newTable` linked list.
- while (oldNext != UNSET) {
- int entryIndex = oldNext - 1;
- int oldEntry = entries[entryIndex];
+ // Loop over current hashtable
+ for (int tableIndex = 0; tableIndex <= mask; tableIndex++) {
+ int next = CompactHashing.tableGet(table, tableIndex);
+ while (next != UNSET) {
+ int entryIndex = next - 1;
+ int entry = entries[entryIndex];
- // Rebuild the full 32-bit hash using entry hashPrefix and oldTableIndex ("hashSuffix").
- int hash = CompactHashing.getHashPrefix(oldEntry, oldMask) | oldTableIndex;
+ // Rebuild hash using entry hashPrefix and tableIndex ("hashSuffix")
+ int hash = CompactHashing.getHashPrefix(entry, mask) | tableIndex;
int newTableIndex = hash & newMask;
int newNext = CompactHashing.tableGet(newTable, newTableIndex);
- CompactHashing.tableSet(newTable, newTableIndex, oldNext);
+ CompactHashing.tableSet(newTable, newTableIndex, next);
entries[entryIndex] = CompactHashing.maskCombine(hash, newNext, newMask);
- oldNext = CompactHashing.getNext(oldEntry, oldMask);
+ next = CompactHashing.getNext(entry, mask);
}
}
@@ -479,22 +415,22 @@
return newMask;
}
- private int indexOf(@CheckForNull Object key) {
+ private int indexOf(@Nullable Object key) {
if (needsAllocArrays()) {
return -1;
}
int hash = smearedHash(key);
int mask = hashTableMask();
- int next = CompactHashing.tableGet(requireTable(), hash & mask);
+ int next = CompactHashing.tableGet(table, hash & mask);
if (next == UNSET) {
return -1;
}
int hashPrefix = CompactHashing.getHashPrefix(hash, mask);
do {
int entryIndex = next - 1;
- int entry = entry(entryIndex);
+ int entry = entries[entryIndex];
if (CompactHashing.getHashPrefix(entry, mask) == hashPrefix
- && Objects.equal(key, key(entryIndex))) {
+ && Objects.equal(key, keys[entryIndex])) {
return entryIndex;
}
next = CompactHashing.getNext(entry, mask);
@@ -503,15 +439,15 @@
}
@Override
- public boolean containsKey(@CheckForNull Object key) {
- Map<K, V> delegate = delegateOrNull();
+ public boolean containsKey(@Nullable Object key) {
+ @Nullable Map<K, V> delegate = delegateOrNull();
return (delegate != null) ? delegate.containsKey(key) : indexOf(key) != -1;
}
+ @SuppressWarnings("unchecked") // known to be a V
@Override
- @CheckForNull
- public V get(@CheckForNull Object key) {
- Map<K, V> delegate = delegateOrNull();
+ public V get(@Nullable Object key) {
+ @Nullable Map<K, V> delegate = delegateOrNull();
if (delegate != null) {
return delegate.get(key);
}
@@ -520,15 +456,14 @@
return null;
}
accessEntry(index);
- return value(index);
+ return (V) values[index];
}
@CanIgnoreReturnValue
@SuppressWarnings("unchecked") // known to be a V
@Override
- @CheckForNull
- public V remove(@CheckForNull Object key) {
- Map<K, V> delegate = delegateOrNull();
+ public @Nullable V remove(@Nullable Object key) {
+ @Nullable Map<K, V> delegate = delegateOrNull();
if (delegate != null) {
return delegate.remove(key);
}
@@ -536,25 +471,19 @@
return (oldValue == NOT_FOUND) ? null : (V) oldValue;
}
- private @Nullable Object removeHelper(@CheckForNull Object key) {
+ private @Nullable Object removeHelper(@Nullable Object key) {
if (needsAllocArrays()) {
return NOT_FOUND;
}
int mask = hashTableMask();
int index =
CompactHashing.remove(
- key,
- /* value= */ null,
- mask,
- requireTable(),
- requireEntries(),
- requireKeys(),
- /* values= */ null);
+ key, /* value= */ null, mask, table, entries, keys, /* values= */ null);
if (index == -1) {
return NOT_FOUND;
}
- Object oldValue = value(index);
+ @Nullable Object oldValue = values[index];
moveLastEntry(index, mask);
size--;
@@ -567,14 +496,10 @@
* Moves the last entry in the entry array into {@code dstIndex}, and nulls out its old position.
*/
void moveLastEntry(int dstIndex, int mask) {
- Object table = requireTable();
- int[] entries = requireEntries();
- @Nullable Object[] keys = requireKeys();
- @Nullable Object[] values = requireValues();
int srcIndex = size() - 1;
if (dstIndex < srcIndex) {
// move last entry to deleted spot
- Object key = keys[srcIndex];
+ @Nullable Object key = keys[srcIndex];
keys[dstIndex] = key;
values[dstIndex] = values[srcIndex];
keys[srcIndex] = null;
@@ -627,7 +552,7 @@
return indexBeforeRemove - 1;
}
- private abstract class Itr<T extends @Nullable Object> implements Iterator<T> {
+ private abstract class Itr<T> implements Iterator<T> {
int expectedMetadata = metadata;
int currentIndex = firstEntryIndex();
int indexToRemove = -1;
@@ -637,11 +562,9 @@
return currentIndex >= 0;
}
- @ParametricNullness
abstract T getOutput(int entry);
@Override
- @ParametricNullness
public T next() {
checkForConcurrentModification();
if (!hasNext()) {
@@ -658,7 +581,7 @@
checkForConcurrentModification();
checkRemove(indexToRemove >= 0);
incrementExpectedModCount();
- CompactHashMap.this.remove(key(indexToRemove));
+ CompactHashMap.this.remove(keys[indexToRemove]);
currentIndex = adjustAfterRemove(currentIndex, indexToRemove);
indexToRemove = -1;
}
@@ -674,20 +597,21 @@
}
}
+ @SuppressWarnings("unchecked") // known to be Ks and Vs
@Override
public void replaceAll(BiFunction<? super K, ? super V, ? extends V> function) {
checkNotNull(function);
- Map<K, V> delegate = delegateOrNull();
+ @Nullable Map<K, V> delegate = delegateOrNull();
if (delegate != null) {
delegate.replaceAll(function);
} else {
for (int i = 0; i < size; i++) {
- setValue(i, function.apply(key(i), value(i)));
+ values[i] = function.apply((K) keys[i], (V) values[i]);
}
}
}
- @CheckForNull private transient Set<K> keySetView;
+ private transient @Nullable Set<K> keySetView;
@Override
public Set<K> keySet() {
@@ -705,35 +629,33 @@
}
@Override
- public @Nullable Object[] toArray() {
+ public Object[] toArray() {
if (needsAllocArrays()) {
return new Object[0];
}
- Map<K, V> delegate = delegateOrNull();
+ @Nullable Map<K, V> delegate = delegateOrNull();
return (delegate != null)
? delegate.keySet().toArray()
- : ObjectArrays.copyAsObjectArray(requireKeys(), 0, size);
+ : ObjectArrays.copyAsObjectArray(keys, 0, size);
}
@Override
- @SuppressWarnings("nullness") // b/192354773 in our checker affects toArray declarations
- public <T extends @Nullable Object> T[] toArray(T[] a) {
+ public <T> T[] toArray(T[] a) {
if (needsAllocArrays()) {
if (a.length > 0) {
- @Nullable Object[] unsoundlyCovariantArray = a;
- unsoundlyCovariantArray[0] = null;
+ a[0] = null;
}
return a;
}
- Map<K, V> delegate = delegateOrNull();
+ @Nullable Map<K, V> delegate = delegateOrNull();
return (delegate != null)
? delegate.keySet().toArray(a)
- : ObjectArrays.toArrayImpl(requireKeys(), 0, size, a);
+ : ObjectArrays.toArrayImpl(keys, 0, size, a);
}
@Override
- public boolean remove(@CheckForNull Object o) {
- Map<K, V> delegate = delegateOrNull();
+ public boolean remove(@Nullable Object o) {
+ @Nullable Map<K, V> delegate = delegateOrNull();
return (delegate != null)
? delegate.keySet().remove(o)
: CompactHashMap.this.removeHelper(o) != NOT_FOUND;
@@ -749,55 +671,56 @@
if (needsAllocArrays()) {
return Spliterators.spliterator(new Object[0], Spliterator.DISTINCT | Spliterator.ORDERED);
}
- Map<K, V> delegate = delegateOrNull();
+ @Nullable Map<K, V> delegate = delegateOrNull();
return (delegate != null)
? delegate.keySet().spliterator()
- : Spliterators.spliterator(
- requireKeys(), 0, size, Spliterator.DISTINCT | Spliterator.ORDERED);
+ : Spliterators.spliterator(keys, 0, size, Spliterator.DISTINCT | Spliterator.ORDERED);
}
+ @SuppressWarnings("unchecked") // known to be Ks
@Override
public void forEach(Consumer<? super K> action) {
checkNotNull(action);
- Map<K, V> delegate = delegateOrNull();
+ @Nullable Map<K, V> delegate = delegateOrNull();
if (delegate != null) {
delegate.keySet().forEach(action);
} else {
for (int i = firstEntryIndex(); i >= 0; i = getSuccessor(i)) {
- action.accept(key(i));
+ action.accept((K) keys[i]);
}
}
}
}
Iterator<K> keySetIterator() {
- Map<K, V> delegate = delegateOrNull();
+ @Nullable Map<K, V> delegate = delegateOrNull();
if (delegate != null) {
return delegate.keySet().iterator();
}
return new Itr<K>() {
+ @SuppressWarnings("unchecked") // known to be a K
@Override
- @ParametricNullness
K getOutput(int entry) {
- return key(entry);
+ return (K) keys[entry];
}
};
}
+ @SuppressWarnings("unchecked") // known to be Ks and Vs
@Override
public void forEach(BiConsumer<? super K, ? super V> action) {
checkNotNull(action);
- Map<K, V> delegate = delegateOrNull();
+ @Nullable Map<K, V> delegate = delegateOrNull();
if (delegate != null) {
delegate.forEach(action);
} else {
for (int i = firstEntryIndex(); i >= 0; i = getSuccessor(i)) {
- action.accept(key(i), value(i));
+ action.accept((K) keys[i], (V) values[i]);
}
}
}
- @CheckForNull private transient Set<Entry<K, V>> entrySetView;
+ private transient @Nullable Set<Entry<K, V>> entrySetView;
@Override
public Set<Entry<K, V>> entrySet() {
@@ -822,7 +745,7 @@
@Override
public Spliterator<Entry<K, V>> spliterator() {
- Map<K, V> delegate = delegateOrNull();
+ @Nullable Map<K, V> delegate = delegateOrNull();
return (delegate != null)
? delegate.entrySet().spliterator()
: CollectSpliterators.indexed(
@@ -830,21 +753,21 @@
}
@Override
- public boolean contains(@CheckForNull Object o) {
- Map<K, V> delegate = delegateOrNull();
+ public boolean contains(@Nullable Object o) {
+ @Nullable Map<K, V> delegate = delegateOrNull();
if (delegate != null) {
return delegate.entrySet().contains(o);
} else if (o instanceof Entry) {
Entry<?, ?> entry = (Entry<?, ?>) o;
int index = indexOf(entry.getKey());
- return index != -1 && Objects.equal(value(index), entry.getValue());
+ return index != -1 && Objects.equal(values[index], entry.getValue());
}
return false;
}
@Override
- public boolean remove(@CheckForNull Object o) {
- Map<K, V> delegate = delegateOrNull();
+ public boolean remove(@Nullable Object o) {
+ @Nullable Map<K, V> delegate = delegateOrNull();
if (delegate != null) {
return delegate.entrySet().remove(o);
} else if (o instanceof Entry) {
@@ -855,13 +778,7 @@
int mask = hashTableMask();
int index =
CompactHashing.remove(
- entry.getKey(),
- entry.getValue(),
- mask,
- requireTable(),
- requireEntries(),
- requireKeys(),
- requireValues());
+ entry.getKey(), entry.getValue(), mask, table, entries, keys, values);
if (index == -1) {
return false;
}
@@ -877,7 +794,7 @@
}
Iterator<Entry<K, V>> entrySetIterator() {
- Map<K, V> delegate = delegateOrNull();
+ @Nullable Map<K, V> delegate = delegateOrNull();
if (delegate != null) {
return delegate.entrySet().iterator();
}
@@ -890,17 +807,18 @@
}
final class MapEntry extends AbstractMapEntry<K, V> {
- @ParametricNullness private final K key;
+ private final @Nullable K key;
private int lastKnownIndex;
+ @SuppressWarnings("unchecked") // known to be a K
MapEntry(int index) {
- this.key = key(index);
+ this.key = (K) keys[index];
this.lastKnownIndex = index;
}
+ @Nullable
@Override
- @ParametricNullness
public K getKey() {
return key;
}
@@ -908,48 +826,36 @@
private void updateLastKnownIndex() {
if (lastKnownIndex == -1
|| lastKnownIndex >= size()
- || !Objects.equal(key, key(lastKnownIndex))) {
+ || !Objects.equal(key, keys[lastKnownIndex])) {
lastKnownIndex = indexOf(key);
}
}
+ @SuppressWarnings("unchecked") // known to be a V
@Override
- @ParametricNullness
- public V getValue() {
- Map<K, V> delegate = delegateOrNull();
+ public @Nullable V getValue() {
+ @Nullable Map<K, V> delegate = delegateOrNull();
if (delegate != null) {
- /*
- * The cast is safe because the entry is present in the map. Or, if it has been removed by a
- * concurrent modification, behavior is undefined.
- */
- return uncheckedCastNullableTToT(delegate.get(key));
+ return delegate.get(key);
}
updateLastKnownIndex();
- /*
- * If the entry has been removed from the map, we return null, even though that might not be a
- * valid value. That's the best we can do, short of holding a reference to the most recently
- * seen value. And while we *could* do that, we aren't required to: Map.Entry explicitly says
- * that behavior is undefined when the backing map is modified through another API. (It even
- * permits us to throw IllegalStateException. Maybe we should have done that, but we probably
- * shouldn't change now for fear of breaking people.)
- */
- return (lastKnownIndex == -1) ? unsafeNull() : value(lastKnownIndex);
+ return (lastKnownIndex == -1) ? null : (V) values[lastKnownIndex];
}
+ @SuppressWarnings("unchecked") // known to be a V
@Override
- @ParametricNullness
- public V setValue(@ParametricNullness V value) {
- Map<K, V> delegate = delegateOrNull();
+ public V setValue(V value) {
+ @Nullable Map<K, V> delegate = delegateOrNull();
if (delegate != null) {
- return uncheckedCastNullableTToT(delegate.put(key, value)); // See discussion in getValue().
+ return delegate.put(key, value);
}
updateLastKnownIndex();
if (lastKnownIndex == -1) {
put(key, value);
- return unsafeNull(); // See discussion in getValue().
+ return null;
} else {
- V old = value(lastKnownIndex);
- CompactHashMap.this.setValue(lastKnownIndex, value);
+ V old = (V) values[lastKnownIndex];
+ values[lastKnownIndex] = value;
return old;
}
}
@@ -957,7 +863,7 @@
@Override
public int size() {
- Map<K, V> delegate = delegateOrNull();
+ @Nullable Map<K, V> delegate = delegateOrNull();
return (delegate != null) ? delegate.size() : size;
}
@@ -967,20 +873,20 @@
}
@Override
- public boolean containsValue(@CheckForNull Object value) {
- Map<K, V> delegate = delegateOrNull();
+ public boolean containsValue(@Nullable Object value) {
+ @Nullable Map<K, V> delegate = delegateOrNull();
if (delegate != null) {
return delegate.containsValue(value);
}
for (int i = 0; i < size; i++) {
- if (Objects.equal(value, value(i))) {
+ if (Objects.equal(value, values[i])) {
return true;
}
}
return false;
}
- @CheckForNull private transient Collection<V> valuesView;
+ private transient @Nullable Collection<V> valuesView;
@Override
public Collection<V> values() {
@@ -1002,15 +908,16 @@
return valuesIterator();
}
+ @SuppressWarnings("unchecked") // known to be Vs
@Override
public void forEach(Consumer<? super V> action) {
checkNotNull(action);
- Map<K, V> delegate = delegateOrNull();
+ @Nullable Map<K, V> delegate = delegateOrNull();
if (delegate != null) {
delegate.values().forEach(action);
} else {
for (int i = firstEntryIndex(); i >= 0; i = getSuccessor(i)) {
- action.accept(value(i));
+ action.accept((V) values[i]);
}
}
}
@@ -1020,50 +927,48 @@
if (needsAllocArrays()) {
return Spliterators.spliterator(new Object[0], Spliterator.ORDERED);
}
- Map<K, V> delegate = delegateOrNull();
+ @Nullable Map<K, V> delegate = delegateOrNull();
return (delegate != null)
? delegate.values().spliterator()
- : Spliterators.spliterator(requireValues(), 0, size, Spliterator.ORDERED);
+ : Spliterators.spliterator(values, 0, size, Spliterator.ORDERED);
}
@Override
- public @Nullable Object[] toArray() {
+ public Object[] toArray() {
if (needsAllocArrays()) {
return new Object[0];
}
- Map<K, V> delegate = delegateOrNull();
+ @Nullable Map<K, V> delegate = delegateOrNull();
return (delegate != null)
? delegate.values().toArray()
- : ObjectArrays.copyAsObjectArray(requireValues(), 0, size);
+ : ObjectArrays.copyAsObjectArray(values, 0, size);
}
@Override
- @SuppressWarnings("nullness") // b/192354773 in our checker affects toArray declarations
- public <T extends @Nullable Object> T[] toArray(T[] a) {
+ public <T> T[] toArray(T[] a) {
if (needsAllocArrays()) {
if (a.length > 0) {
- @Nullable Object[] unsoundlyCovariantArray = a;
- unsoundlyCovariantArray[0] = null;
+ a[0] = null;
}
return a;
}
- Map<K, V> delegate = delegateOrNull();
+ @Nullable Map<K, V> delegate = delegateOrNull();
return (delegate != null)
? delegate.values().toArray(a)
- : ObjectArrays.toArrayImpl(requireValues(), 0, size, a);
+ : ObjectArrays.toArrayImpl(values, 0, size, a);
}
}
Iterator<V> valuesIterator() {
- Map<K, V> delegate = delegateOrNull();
+ @Nullable Map<K, V> delegate = delegateOrNull();
if (delegate != null) {
return delegate.values().iterator();
}
return new Itr<V>() {
+ @SuppressWarnings("unchecked") // known to be a V
@Override
- @ParametricNullness
V getOutput(int entry) {
- return value(entry);
+ return (V) values[entry];
}
};
}
@@ -1076,7 +981,7 @@
if (needsAllocArrays()) {
return;
}
- Map<K, V> delegate = delegateOrNull();
+ @Nullable Map<K, V> delegate = delegateOrNull();
if (delegate != null) {
Map<K, V> newDelegate = createHashFloodingResistantDelegate(size());
newDelegate.putAll(delegate);
@@ -1084,7 +989,7 @@
return;
}
int size = this.size;
- if (size < requireEntries().length) {
+ if (size < entries.length) {
resizeEntries(size);
}
int minimumTableSize = CompactHashing.tableSize(size);
@@ -1100,7 +1005,7 @@
return;
}
incrementModCount();
- Map<K, V> delegate = delegateOrNull();
+ @Nullable Map<K, V> delegate = delegateOrNull();
if (delegate != null) {
metadata =
Ints.constrainToRange(size(), CompactHashing.DEFAULT_SIZE, CompactHashing.MAX_SIZE);
@@ -1108,10 +1013,10 @@
table = null;
size = 0;
} else {
- Arrays.fill(requireKeys(), 0, size, null);
- Arrays.fill(requireValues(), 0, size, null);
- CompactHashing.tableClear(requireTable());
- Arrays.fill(requireEntries(), 0, size, 0);
+ Arrays.fill(keys, 0, size, null);
+ Arrays.fill(values, 0, size, null);
+ CompactHashing.tableClear(table);
+ Arrays.fill(entries, 0, size, 0);
this.size = 0;
}
}
@@ -1141,66 +1046,4 @@
put(key, value);
}
}
-
- /*
- * The following methods are safe to call as long as both of the following hold:
- *
- * - allocArrays() has been called. Callers can confirm this by checking needsAllocArrays().
- *
- * - The map has not switched to delegating to a java.util implementation to mitigate hash
- * flooding. Callers can confirm this by null-checking delegateOrNull().
- *
- * In an ideal world, we would document why we know those things are true every time we call these
- * methods. But that is a bit too painful....
- */
-
- private Object requireTable() {
- return requireNonNull(table);
- }
-
- private int[] requireEntries() {
- return requireNonNull(entries);
- }
-
- private @Nullable Object[] requireKeys() {
- return requireNonNull(keys);
- }
-
- private @Nullable Object[] requireValues() {
- return requireNonNull(values);
- }
-
- /*
- * The following methods are safe to call as long as the conditions in the *previous* comment are
- * met *and* the index is less than size().
- *
- * (The above explains when these methods are safe from a `nullness` perspective. From an
- * `unchecked` perspective, they're safe because we put only K/V elements into each array.)
- */
-
- @SuppressWarnings("unchecked")
- private K key(int i) {
- return (K) requireKeys()[i];
- }
-
- @SuppressWarnings("unchecked")
- private V value(int i) {
- return (V) requireValues()[i];
- }
-
- private int entry(int i) {
- return requireEntries()[i];
- }
-
- private void setKey(int i, K key) {
- requireKeys()[i] = key;
- }
-
- private void setValue(int i, V value) {
- requireValues()[i] = value;
- }
-
- private void setEntry(int i, int value) {
- requireEntries()[i] = value;
- }
}
diff --git a/guava/src/com/google/common/collect/CompactHashSet.java b/guava/src/com/google/common/collect/CompactHashSet.java
index 2cfcf0a..d54e166 100644
--- a/guava/src/com/google/common/collect/CompactHashSet.java
+++ b/guava/src/com/google/common/collect/CompactHashSet.java
@@ -20,7 +20,6 @@
import static com.google.common.collect.CollectPreconditions.checkRemove;
import static com.google.common.collect.CompactHashing.UNSET;
import static com.google.common.collect.Hashing.smearedHash;
-import static java.util.Objects.requireNonNull;
import com.google.common.annotations.GwtIncompatible;
import com.google.common.annotations.VisibleForTesting;
@@ -45,7 +44,6 @@
import java.util.Spliterator;
import java.util.Spliterators;
import java.util.function.Consumer;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -76,12 +74,11 @@
* @author Jon Noack
*/
@GwtIncompatible // not worth using in GWT for now
-@ElementTypesAreNonnullByDefault
-class CompactHashSet<E extends @Nullable Object> extends AbstractSet<E> implements Serializable {
+class CompactHashSet<E> extends AbstractSet<E> implements Serializable {
// TODO(user): cache all field accesses in local vars
/** Creates an empty {@code CompactHashSet} instance. */
- public static <E extends @Nullable Object> CompactHashSet<E> create() {
+ public static <E> CompactHashSet<E> create() {
return new CompactHashSet<>();
}
@@ -92,8 +89,7 @@
* @param collection the elements that the set should contain
* @return a new {@code CompactHashSet} containing those elements (minus duplicates)
*/
- public static <E extends @Nullable Object> CompactHashSet<E> create(
- Collection<? extends E> collection) {
+ public static <E> CompactHashSet<E> create(Collection<? extends E> collection) {
CompactHashSet<E> set = createWithExpectedSize(collection.size());
set.addAll(collection);
return set;
@@ -107,7 +103,7 @@
* @return a new {@code CompactHashSet} containing those elements (minus duplicates)
*/
@SafeVarargs
- public static <E extends @Nullable Object> CompactHashSet<E> create(E... elements) {
+ public static <E> CompactHashSet<E> create(E... elements) {
CompactHashSet<E> set = createWithExpectedSize(elements.length);
Collections.addAll(set, elements);
return set;
@@ -122,8 +118,7 @@
* elements without resizing
* @throws IllegalArgumentException if {@code expectedSize} is negative
*/
- public static <E extends @Nullable Object> CompactHashSet<E> createWithExpectedSize(
- int expectedSize) {
+ public static <E> CompactHashSet<E> createWithExpectedSize(int expectedSize) {
return new CompactHashSet<>(expectedSize);
}
@@ -141,10 +136,6 @@
*/
private static final int MAX_HASH_BUCKET_LENGTH = 9;
- // See CompactHashMap for a detailed description of how the following fields work. That
- // description talks about `keys`, `values`, and `entries`; here the `keys` and `values` arrays
- // are replaced by a single `elements` array but everything else works similarly.
-
/**
* The hashtable object. This can be either:
*
@@ -164,7 +155,7 @@
* <li>null, if no entries have yet been added to the map
* </ul>
*/
- @CheckForNull private transient Object table;
+ @Nullable private transient Object table;
/**
* Contains the logical entries, in the range of [0, size()). The high bits of each int are the
@@ -174,20 +165,20 @@
*
* <pre>
* hash = aaaaaaaa
- * mask = 00000fff
- * next = 00000bbb
- * entry = aaaaabbb
+ * mask = 0000ffff
+ * next = 0000bbbb
+ * entry = aaaabbbb
* </pre>
*
* <p>The pointers in [size(), entries.length) are all "null" (UNSET).
*/
- @CheckForNull private transient int[] entries;
+ private transient int @Nullable [] entries;
/**
* The elements contained in the set, in the range of [0, size()). The elements in [size(),
* elements.length) are all {@code null}.
*/
- @VisibleForTesting @CheckForNull transient @Nullable Object[] elements;
+ @VisibleForTesting transient Object @Nullable [] elements;
/**
* Keeps track of metadata like the number of hash table bits and modifications of this data
@@ -246,7 +237,7 @@
@SuppressWarnings("unchecked")
@VisibleForTesting
- @CheckForNull
+ @Nullable
Set<E> delegateOrNull() {
if (table instanceof Set) {
return (Set<E>) table;
@@ -258,12 +249,13 @@
return new LinkedHashSet<>(tableSize, 1.0f);
}
+ @SuppressWarnings("unchecked")
@VisibleForTesting
@CanIgnoreReturnValue
Set<E> convertToHashFloodingResistantImplementation() {
Set<E> newDelegate = createHashFloodingResistantDelegate(hashTableMask() + 1);
for (int i = firstEntryIndex(); i >= 0; i = getSuccessor(i)) {
- newDelegate.add(element(i));
+ newDelegate.add((E) elements[i]);
}
this.table = newDelegate;
this.entries = null;
@@ -295,29 +287,29 @@
@CanIgnoreReturnValue
@Override
- public boolean add(@ParametricNullness E object) {
+ public boolean add(@Nullable E object) {
if (needsAllocArrays()) {
allocArrays();
}
- Set<E> delegate = delegateOrNull();
+ @Nullable Set<E> delegate = delegateOrNull();
if (delegate != null) {
return delegate.add(object);
}
- int[] entries = requireEntries();
- @Nullable Object[] elements = requireElements();
+ int[] entries = this.entries;
+ Object[] elements = this.elements;
int newEntryIndex = this.size; // current size, and pointer to the entry to be appended
int newSize = newEntryIndex + 1;
int hash = smearedHash(object);
int mask = hashTableMask();
int tableIndex = hash & mask;
- int next = CompactHashing.tableGet(requireTable(), tableIndex);
+ int next = CompactHashing.tableGet(table, tableIndex);
if (next == UNSET) { // uninitialized bucket
if (newSize > mask) {
// Resize and add new entry
mask = resizeTable(mask, CompactHashing.newCapacity(mask), hash, newEntryIndex);
} else {
- CompactHashing.tableSet(requireTable(), tableIndex, newEntryIndex + 1);
+ CompactHashing.tableSet(table, tableIndex, newEntryIndex + 1);
}
} else {
int entryIndex;
@@ -356,14 +348,14 @@
/**
* Creates a fresh entry with the specified object at the specified position in the entry arrays.
*/
- void insertEntry(int entryIndex, @ParametricNullness E object, int hash, int mask) {
- setEntry(entryIndex, CompactHashing.maskCombine(hash, UNSET, mask));
- setElement(entryIndex, object);
+ void insertEntry(int entryIndex, @Nullable E object, int hash, int mask) {
+ this.entries[entryIndex] = CompactHashing.maskCombine(hash, UNSET, mask);
+ this.elements[entryIndex] = object;
}
/** Resizes the entries storage if necessary. */
private void resizeMeMaybe(int newSize) {
- int entriesSize = requireEntries().length;
+ int entriesSize = entries.length;
if (newSize > entriesSize) {
// 1.5x but round up to nearest odd (this is optimal for memory consumption on Android)
int newCapacity =
@@ -379,12 +371,12 @@
* the current capacity.
*/
void resizeEntries(int newCapacity) {
- this.entries = Arrays.copyOf(requireEntries(), newCapacity);
- this.elements = Arrays.copyOf(requireElements(), newCapacity);
+ this.entries = Arrays.copyOf(entries, newCapacity);
+ this.elements = Arrays.copyOf(elements, newCapacity);
}
@CanIgnoreReturnValue
- private int resizeTable(int oldMask, int newCapacity, int targetHash, int targetEntryIndex) {
+ private int resizeTable(int mask, int newCapacity, int targetHash, int targetEntryIndex) {
Object newTable = CompactHashing.createTable(newCapacity);
int newMask = newCapacity - 1;
@@ -393,25 +385,25 @@
CompactHashing.tableSet(newTable, targetHash & newMask, targetEntryIndex + 1);
}
- Object oldTable = requireTable();
- int[] entries = requireEntries();
+ Object table = this.table;
+ int[] entries = this.entries;
// Loop over current hashtable
- for (int oldTableIndex = 0; oldTableIndex <= oldMask; oldTableIndex++) {
- int oldNext = CompactHashing.tableGet(oldTable, oldTableIndex);
- while (oldNext != UNSET) {
- int entryIndex = oldNext - 1;
- int oldEntry = entries[entryIndex];
+ for (int tableIndex = 0; tableIndex <= mask; tableIndex++) {
+ int next = CompactHashing.tableGet(table, tableIndex);
+ while (next != UNSET) {
+ int entryIndex = next - 1;
+ int entry = entries[entryIndex];
// Rebuild hash using entry hashPrefix and tableIndex ("hashSuffix")
- int hash = CompactHashing.getHashPrefix(oldEntry, oldMask) | oldTableIndex;
+ int hash = CompactHashing.getHashPrefix(entry, mask) | tableIndex;
int newTableIndex = hash & newMask;
int newNext = CompactHashing.tableGet(newTable, newTableIndex);
- CompactHashing.tableSet(newTable, newTableIndex, oldNext);
+ CompactHashing.tableSet(newTable, newTableIndex, next);
entries[entryIndex] = CompactHashing.maskCombine(hash, newNext, newMask);
- oldNext = CompactHashing.getNext(oldEntry, oldMask);
+ next = CompactHashing.getNext(entry, mask);
}
}
@@ -421,26 +413,26 @@
}
@Override
- public boolean contains(@CheckForNull Object object) {
+ public boolean contains(@Nullable Object object) {
if (needsAllocArrays()) {
return false;
}
- Set<E> delegate = delegateOrNull();
+ @Nullable Set<E> delegate = delegateOrNull();
if (delegate != null) {
return delegate.contains(object);
}
int hash = smearedHash(object);
int mask = hashTableMask();
- int next = CompactHashing.tableGet(requireTable(), hash & mask);
+ int next = CompactHashing.tableGet(table, hash & mask);
if (next == UNSET) {
return false;
}
int hashPrefix = CompactHashing.getHashPrefix(hash, mask);
do {
int entryIndex = next - 1;
- int entry = entry(entryIndex);
+ int entry = entries[entryIndex];
if (CompactHashing.getHashPrefix(entry, mask) == hashPrefix
- && Objects.equal(object, element(entryIndex))) {
+ && Objects.equal(object, elements[entryIndex])) {
return true;
}
next = CompactHashing.getNext(entry, mask);
@@ -450,24 +442,18 @@
@CanIgnoreReturnValue
@Override
- public boolean remove(@CheckForNull Object object) {
+ public boolean remove(@Nullable Object object) {
if (needsAllocArrays()) {
return false;
}
- Set<E> delegate = delegateOrNull();
+ @Nullable Set<E> delegate = delegateOrNull();
if (delegate != null) {
return delegate.remove(object);
}
int mask = hashTableMask();
int index =
CompactHashing.remove(
- object,
- /* value= */ null,
- mask,
- requireTable(),
- requireEntries(),
- requireElements(),
- /* values= */ null);
+ object, /* value= */ null, mask, table, entries, elements, /* values= */ null);
if (index == -1) {
return false;
}
@@ -483,13 +469,10 @@
* Moves the last entry in the entry array into {@code dstIndex}, and nulls out its old position.
*/
void moveLastEntry(int dstIndex, int mask) {
- Object table = requireTable();
- int[] entries = requireEntries();
- @Nullable Object[] elements = requireElements();
int srcIndex = size() - 1;
if (dstIndex < srcIndex) {
// move last entry to deleted spot
- Object object = elements[srcIndex];
+ @Nullable Object object = elements[srcIndex];
elements[dstIndex] = object;
elements[srcIndex] = null;
@@ -541,7 +524,7 @@
@Override
public Iterator<E> iterator() {
- Set<E> delegate = delegateOrNull();
+ @Nullable Set<E> delegate = delegateOrNull();
if (delegate != null) {
return delegate.iterator();
}
@@ -555,15 +538,15 @@
return currentIndex >= 0;
}
+ @SuppressWarnings("unchecked") // known to be Es
@Override
- @ParametricNullness
public E next() {
checkForConcurrentModification();
if (!hasNext()) {
throw new NoSuchElementException();
}
indexToRemove = currentIndex;
- E result = element(currentIndex);
+ E result = (E) elements[currentIndex];
currentIndex = getSuccessor(currentIndex);
return result;
}
@@ -573,7 +556,7 @@
checkForConcurrentModification();
checkRemove(indexToRemove >= 0);
incrementExpectedModCount();
- CompactHashSet.this.remove(element(indexToRemove));
+ CompactHashSet.this.remove(elements[indexToRemove]);
currentIndex = adjustAfterRemove(currentIndex, indexToRemove);
indexToRemove = -1;
}
@@ -595,29 +578,29 @@
if (needsAllocArrays()) {
return Spliterators.spliterator(new Object[0], Spliterator.DISTINCT | Spliterator.ORDERED);
}
- Set<E> delegate = delegateOrNull();
+ @Nullable Set<E> delegate = delegateOrNull();
return (delegate != null)
? delegate.spliterator()
- : Spliterators.spliterator(
- requireElements(), 0, size, Spliterator.DISTINCT | Spliterator.ORDERED);
+ : Spliterators.spliterator(elements, 0, size, Spliterator.DISTINCT | Spliterator.ORDERED);
}
+ @SuppressWarnings("unchecked") // known to be Es
@Override
public void forEach(Consumer<? super E> action) {
checkNotNull(action);
- Set<E> delegate = delegateOrNull();
+ @Nullable Set<E> delegate = delegateOrNull();
if (delegate != null) {
delegate.forEach(action);
} else {
for (int i = firstEntryIndex(); i >= 0; i = getSuccessor(i)) {
- action.accept(element(i));
+ action.accept((E) elements[i]);
}
}
}
@Override
public int size() {
- Set<E> delegate = delegateOrNull();
+ @Nullable Set<E> delegate = delegateOrNull();
return (delegate != null) ? delegate.size() : size;
}
@@ -627,28 +610,27 @@
}
@Override
- public @Nullable Object[] toArray() {
+ public Object[] toArray() {
if (needsAllocArrays()) {
return new Object[0];
}
- Set<E> delegate = delegateOrNull();
- return (delegate != null) ? delegate.toArray() : Arrays.copyOf(requireElements(), size);
+ @Nullable Set<E> delegate = delegateOrNull();
+ return (delegate != null) ? delegate.toArray() : Arrays.copyOf(elements, size);
}
@CanIgnoreReturnValue
@Override
- @SuppressWarnings("nullness") // b/192354773 in our checker affects toArray declarations
- public <T extends @Nullable Object> T[] toArray(T[] a) {
+ public <T> T[] toArray(T[] a) {
if (needsAllocArrays()) {
if (a.length > 0) {
a[0] = null;
}
return a;
}
- Set<E> delegate = delegateOrNull();
+ @Nullable Set<E> delegate = delegateOrNull();
return (delegate != null)
? delegate.toArray(a)
- : ObjectArrays.toArrayImpl(requireElements(), 0, size, a);
+ : ObjectArrays.toArrayImpl(elements, 0, size, a);
}
/**
@@ -659,7 +641,7 @@
if (needsAllocArrays()) {
return;
}
- Set<E> delegate = delegateOrNull();
+ @Nullable Set<E> delegate = delegateOrNull();
if (delegate != null) {
Set<E> newDelegate = createHashFloodingResistantDelegate(size());
newDelegate.addAll(delegate);
@@ -667,7 +649,7 @@
return;
}
int size = this.size;
- if (size < requireEntries().length) {
+ if (size < entries.length) {
resizeEntries(size);
}
int minimumTableSize = CompactHashing.tableSize(size);
@@ -683,7 +665,7 @@
return;
}
incrementModCount();
- Set<E> delegate = delegateOrNull();
+ @Nullable Set<E> delegate = delegateOrNull();
if (delegate != null) {
metadata =
Ints.constrainToRange(size(), CompactHashing.DEFAULT_SIZE, CompactHashing.MAX_SIZE);
@@ -691,9 +673,9 @@
table = null;
size = 0;
} else {
- Arrays.fill(requireElements(), 0, size, null);
- CompactHashing.tableClear(requireTable());
- Arrays.fill(requireEntries(), 0, size, 0);
+ Arrays.fill(elements, 0, size, null);
+ CompactHashing.tableClear(table);
+ Arrays.fill(entries, 0, size, 0);
this.size = 0;
}
}
@@ -719,38 +701,4 @@
add(element);
}
}
-
- /*
- * For discussion of the safety of the following methods, see the comments near the end of
- * CompactHashMap.
- */
-
- private Object requireTable() {
- return requireNonNull(table);
- }
-
- private int[] requireEntries() {
- return requireNonNull(entries);
- }
-
- private @Nullable Object[] requireElements() {
- return requireNonNull(elements);
- }
-
- @SuppressWarnings("unchecked")
- private E element(int i) {
- return (E) requireElements()[i];
- }
-
- private int entry(int i) {
- return requireEntries()[i];
- }
-
- private void setElement(int i, E value) {
- requireElements()[i] = value;
- }
-
- private void setEntry(int i, int value) {
- requireEntries()[i] = value;
- }
}
diff --git a/guava/src/com/google/common/collect/CompactHashing.java b/guava/src/com/google/common/collect/CompactHashing.java
index a8fe902..3444aeb 100644
--- a/guava/src/com/google/common/collect/CompactHashing.java
+++ b/guava/src/com/google/common/collect/CompactHashing.java
@@ -20,7 +20,6 @@
import com.google.common.base.Objects;
import com.google.common.primitives.Ints;
import java.util.Arrays;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -29,7 +28,6 @@
* @author Jon Noack
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
final class CompactHashing {
private CompactHashing() {}
@@ -98,11 +96,6 @@
}
}
- /**
- * Returns {@code table[index]}, where {@code table} is actually a {@code byte[]}, {@code
- * short[]}, or {@code int[]}. When it is a {@code byte[]} or {@code short[]}, the returned value
- * is unsigned, so the range of possible returned values is 0–255 or 0–65535, respectively.
- */
static int tableGet(Object table, int index) {
if (table instanceof byte[]) {
return ((byte[]) table)[index] & BYTE_MASK; // unsigned read
@@ -113,13 +106,6 @@
}
}
- /**
- * Sets {@code table[index]} to {@code entry}, where {@code table} is actually a {@code byte[]},
- * {@code short[]}, or {@code int[]}. The value of {@code entry} should fit in the size of the
- * assigned array element, when seen as an unsigned value. So if {@code table} is a {@code byte[]}
- * then we should have {@code 0 ≤ entry ≤ 255}, and if {@code table} is a {@code short[]} then we
- * should have {@code 0 ≤ entry ≤ 65535}. It is the caller's responsibility to ensure this.
- */
static void tableSet(Object table, int index, int entry) {
if (table instanceof byte[]) {
((byte[]) table)[index] = (byte) entry; // unsigned write
@@ -157,13 +143,13 @@
}
static int remove(
- @CheckForNull Object key,
- @CheckForNull Object value,
+ @Nullable Object key,
+ @Nullable Object value,
int mask,
Object table,
int[] entries,
- @Nullable Object[] keys,
- @CheckForNull @Nullable Object[] values) {
+ Object[] keys,
+ Object @Nullable [] values) {
int hash = Hashing.smearedHash(key);
int tableIndex = hash & mask;
int next = tableGet(table, tableIndex);
diff --git a/guava/src/com/google/common/collect/CompactLinkedHashMap.java b/guava/src/com/google/common/collect/CompactLinkedHashMap.java
index 97b3a4b..be878c8 100644
--- a/guava/src/com/google/common/collect/CompactLinkedHashMap.java
+++ b/guava/src/com/google/common/collect/CompactLinkedHashMap.java
@@ -16,8 +16,6 @@
package com.google.common.collect;
-import static java.util.Objects.requireNonNull;
-
import com.google.common.annotations.GwtIncompatible;
import com.google.common.annotations.VisibleForTesting;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
@@ -29,7 +27,6 @@
import java.util.Set;
import java.util.Spliterator;
import java.util.Spliterators;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -53,14 +50,11 @@
* @author Louis Wasserman
*/
@GwtIncompatible // not worth using in GWT for now
-@ElementTypesAreNonnullByDefault
-class CompactLinkedHashMap<K extends @Nullable Object, V extends @Nullable Object>
- extends CompactHashMap<K, V> {
+class CompactLinkedHashMap<K, V> extends CompactHashMap<K, V> {
// TODO(lowasser): implement removeEldestEntry so this can be used as a drop-in replacement
/** Creates an empty {@code CompactLinkedHashMap} instance. */
- public static <K extends @Nullable Object, V extends @Nullable Object>
- CompactLinkedHashMap<K, V> create() {
+ public static <K, V> CompactLinkedHashMap<K, V> create() {
return new CompactLinkedHashMap<>();
}
@@ -73,8 +67,7 @@
* expectedSize} elements without resizing
* @throws IllegalArgumentException if {@code expectedSize} is negative
*/
- public static <K extends @Nullable Object, V extends @Nullable Object>
- CompactLinkedHashMap<K, V> createWithExpectedSize(int expectedSize) {
+ public static <K, V> CompactLinkedHashMap<K, V> createWithExpectedSize(int expectedSize) {
return new CompactLinkedHashMap<>(expectedSize);
}
@@ -89,7 +82,7 @@
* <p>A node with "prev" pointer equal to {@code ENDPOINT} is the first node in the linked list,
* and a node with "next" pointer equal to {@code ENDPOINT} is the last node.
*/
- @CheckForNull @VisibleForTesting transient long[] links;
+ @VisibleForTesting transient long @Nullable [] links;
/** Pointer to the first node in the linked list, or {@code ENDPOINT} if there are no entries. */
private transient int firstEntry;
@@ -139,29 +132,23 @@
return result;
}
- /*
- * For discussion of the safety of the following methods for operating on predecessors and
- * successors, see the comments near the end of CompactHashMap, noting that the methods here call
- * link(), which is defined at the end of this file.
- */
-
private int getPredecessor(int entry) {
- return ((int) (link(entry) >>> 32)) - 1;
+ return ((int) (links[entry] >>> 32)) - 1;
}
@Override
int getSuccessor(int entry) {
- return ((int) link(entry)) - 1;
+ return ((int) links[entry]) - 1;
}
private void setSuccessor(int entry, int succ) {
long succMask = (~0L) >>> 32;
- setLink(entry, (link(entry) & ~succMask) | ((succ + 1) & succMask));
+ links[entry] = (links[entry] & ~succMask) | ((succ + 1) & succMask);
}
private void setPredecessor(int entry, int pred) {
long predMask = ~0L << 32;
- setLink(entry, (link(entry) & ~predMask) | ((long) (pred + 1) << 32));
+ links[entry] = (links[entry] & ~predMask) | ((long) (pred + 1) << 32);
}
private void setSucceeds(int pred, int succ) {
@@ -179,8 +166,7 @@
}
@Override
- void insertEntry(
- int entryIndex, @ParametricNullness K key, @ParametricNullness V value, int hash, int mask) {
+ void insertEntry(int entryIndex, @Nullable K key, @Nullable V value, int hash, int mask) {
super.insertEntry(entryIndex, key, value, hash, mask);
setSucceeds(lastEntry, entryIndex);
setSucceeds(entryIndex, ENDPOINT);
@@ -208,13 +194,13 @@
setSucceeds(getPredecessor(srcIndex), dstIndex);
setSucceeds(dstIndex, getSuccessor(srcIndex));
}
- setLink(srcIndex, 0);
+ links[srcIndex] = 0;
}
@Override
void resizeEntries(int newCapacity) {
super.resizeEntries(newCapacity);
- links = Arrays.copyOf(requireLinks(), newCapacity);
+ links = Arrays.copyOf(links, newCapacity);
}
@Override
@@ -244,13 +230,12 @@
@WeakOuter
class KeySetImpl extends KeySetView {
@Override
- public @Nullable Object[] toArray() {
+ public Object[] toArray() {
return ObjectArrays.toArrayImpl(this);
}
@Override
- @SuppressWarnings("nullness") // b/192354773 in our checker affects toArray declarations
- public <T extends @Nullable Object> T[] toArray(T[] a) {
+ public <T> T[] toArray(T[] a) {
return ObjectArrays.toArrayImpl(this, a);
}
@@ -267,13 +252,12 @@
@WeakOuter
class ValuesImpl extends ValuesView {
@Override
- public @Nullable Object[] toArray() {
+ public Object[] toArray() {
return ObjectArrays.toArrayImpl(this);
}
@Override
- @SuppressWarnings("nullness") // b/192354773 in our checker affects toArray declarations
- public <T extends @Nullable Object> T[] toArray(T[] a) {
+ public <T> T[] toArray(T[] a) {
return ObjectArrays.toArrayImpl(this, a);
}
@@ -297,27 +281,4 @@
}
super.clear();
}
-
- /*
- * For discussion of the safety of the following methods, see the comments near the end of
- * CompactHashMap.
- */
-
- private long[] requireLinks() {
- return requireNonNull(links);
- }
-
- private long link(int i) {
- return requireLinks()[i];
- }
-
- private void setLink(int i, long value) {
- requireLinks()[i] = value;
- }
-
- /*
- * We don't define getPredecessor+getSuccessor and setPredecessor+setSuccessor here because
- * they're defined above -- including logic to add and subtract 1 to map between the values stored
- * in the predecessor/successor arrays and the indexes in the elements array that they identify.
- */
}
diff --git a/guava/src/com/google/common/collect/CompactLinkedHashSet.java b/guava/src/com/google/common/collect/CompactLinkedHashSet.java
index c1d813c..74caf47 100644
--- a/guava/src/com/google/common/collect/CompactLinkedHashSet.java
+++ b/guava/src/com/google/common/collect/CompactLinkedHashSet.java
@@ -16,8 +16,6 @@
package com.google.common.collect;
-import static java.util.Objects.requireNonNull;
-
import com.google.common.annotations.GwtIncompatible;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import java.util.Arrays;
@@ -26,7 +24,6 @@
import java.util.Set;
import java.util.Spliterator;
import java.util.Spliterators;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -51,11 +48,10 @@
* @author Louis Wasserman
*/
@GwtIncompatible // not worth using in GWT for now
-@ElementTypesAreNonnullByDefault
-class CompactLinkedHashSet<E extends @Nullable Object> extends CompactHashSet<E> {
+class CompactLinkedHashSet<E> extends CompactHashSet<E> {
/** Creates an empty {@code CompactLinkedHashSet} instance. */
- public static <E extends @Nullable Object> CompactLinkedHashSet<E> create() {
+ public static <E> CompactLinkedHashSet<E> create() {
return new CompactLinkedHashSet<>();
}
@@ -66,8 +62,7 @@
* @param collection the elements that the set should contain
* @return a new {@code CompactLinkedHashSet} containing those elements (minus duplicates)
*/
- public static <E extends @Nullable Object> CompactLinkedHashSet<E> create(
- Collection<? extends E> collection) {
+ public static <E> CompactLinkedHashSet<E> create(Collection<? extends E> collection) {
CompactLinkedHashSet<E> set = createWithExpectedSize(collection.size());
set.addAll(collection);
return set;
@@ -81,7 +76,7 @@
* @return a new {@code CompactLinkedHashSet} containing those elements (minus duplicates)
*/
@SafeVarargs
- public static <E extends @Nullable Object> CompactLinkedHashSet<E> create(E... elements) {
+ public static <E> CompactLinkedHashSet<E> create(E... elements) {
CompactLinkedHashSet<E> set = createWithExpectedSize(elements.length);
Collections.addAll(set, elements);
return set;
@@ -96,8 +91,7 @@
* expectedSize} elements without resizing
* @throws IllegalArgumentException if {@code expectedSize} is negative
*/
- public static <E extends @Nullable Object> CompactLinkedHashSet<E> createWithExpectedSize(
- int expectedSize) {
+ public static <E> CompactLinkedHashSet<E> createWithExpectedSize(int expectedSize) {
return new CompactLinkedHashSet<>(expectedSize);
}
@@ -111,13 +105,13 @@
* Pointer to the predecessor of an entry in insertion order. ENDPOINT indicates a node is the
* first node in insertion order; all values at indices ≥ {@link #size()} are UNSET.
*/
- @CheckForNull private transient int[] predecessor;
+ private transient int @Nullable [] predecessor;
/**
* Pointer to the successor of an entry in insertion order. ENDPOINT indicates a node is the last
* node in insertion order; all values at indices ≥ {@link #size()} are UNSET.
*/
- @CheckForNull private transient int[] successor;
+ private transient int @Nullable [] successor;
/** Pointer to the first node in the linked list, or {@code ENDPOINT} if there are no entries. */
private transient int firstEntry;
@@ -157,27 +151,21 @@
return result;
}
- /*
- * For discussion of the safety of the following methods for operating on predecessors and
- * successors, see the comments near the end of CompactHashMap, noting that the methods here call
- * requirePredecessors() and requireSuccessors(), which are defined at the end of this file.
- */
-
private int getPredecessor(int entry) {
- return requirePredecessors()[entry] - 1;
+ return predecessor[entry] - 1;
}
@Override
int getSuccessor(int entry) {
- return requireSuccessors()[entry] - 1;
+ return successor[entry] - 1;
}
private void setSuccessor(int entry, int succ) {
- requireSuccessors()[entry] = succ + 1;
+ successor[entry] = succ + 1;
}
private void setPredecessor(int entry, int pred) {
- requirePredecessors()[entry] = pred + 1;
+ predecessor[entry] = pred + 1;
}
private void setSucceeds(int pred, int succ) {
@@ -195,7 +183,7 @@
}
@Override
- void insertEntry(int entryIndex, @ParametricNullness E object, int hash, int mask) {
+ void insertEntry(int entryIndex, @Nullable E object, int hash, int mask) {
super.insertEntry(entryIndex, object, hash, mask);
setSucceeds(lastEntry, entryIndex);
setSucceeds(entryIndex, ENDPOINT);
@@ -211,15 +199,15 @@
setSucceeds(getPredecessor(srcIndex), dstIndex);
setSucceeds(dstIndex, getSuccessor(srcIndex));
}
- requirePredecessors()[srcIndex] = 0;
- requireSuccessors()[srcIndex] = 0;
+ predecessor[srcIndex] = 0;
+ successor[srcIndex] = 0;
}
@Override
void resizeEntries(int newCapacity) {
super.resizeEntries(newCapacity);
- predecessor = Arrays.copyOf(requirePredecessors(), newCapacity);
- successor = Arrays.copyOf(requireSuccessors(), newCapacity);
+ predecessor = Arrays.copyOf(predecessor, newCapacity);
+ successor = Arrays.copyOf(successor, newCapacity);
}
@Override
@@ -233,13 +221,12 @@
}
@Override
- public @Nullable Object[] toArray() {
+ public Object[] toArray() {
return ObjectArrays.toArrayImpl(this);
}
@Override
- @SuppressWarnings("nullness") // b/192354773 in our checker affects toArray declarations
- public <T extends @Nullable Object> T[] toArray(T[] a) {
+ public <T> T[] toArray(T[] a) {
return ObjectArrays.toArrayImpl(this, a);
}
@@ -255,30 +242,10 @@
}
this.firstEntry = ENDPOINT;
this.lastEntry = ENDPOINT;
- // Either both arrays are null or neither is, but we check both to satisfy the nullness checker.
- if (predecessor != null && successor != null) {
+ if (predecessor != null) {
Arrays.fill(predecessor, 0, size(), 0);
Arrays.fill(successor, 0, size(), 0);
}
super.clear();
}
-
- /*
- * For discussion of the safety of the following methods, see the comments near the end of
- * CompactHashMap.
- */
-
- private int[] requirePredecessors() {
- return requireNonNull(predecessor);
- }
-
- private int[] requireSuccessors() {
- return requireNonNull(successor);
- }
-
- /*
- * We don't define getPredecessor+getSuccessor and setPredecessor+setSuccessor here because
- * they're defined above -- including logic to add and subtract 1 to map between the values stored
- * in the predecessor/successor arrays and the indexes in the elements array that they identify.
- */
}
diff --git a/guava/src/com/google/common/collect/ComparatorOrdering.java b/guava/src/com/google/common/collect/ComparatorOrdering.java
index 8b34070..52cbf2a 100644
--- a/guava/src/com/google/common/collect/ComparatorOrdering.java
+++ b/guava/src/com/google/common/collect/ComparatorOrdering.java
@@ -21,14 +21,11 @@
import com.google.common.annotations.GwtCompatible;
import java.io.Serializable;
import java.util.Comparator;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/** An ordering for a pre-existing comparator. */
@GwtCompatible(serializable = true)
-@ElementTypesAreNonnullByDefault
-final class ComparatorOrdering<T extends @Nullable Object> extends Ordering<T>
- implements Serializable {
+final class ComparatorOrdering<T> extends Ordering<T> implements Serializable {
final Comparator<T> comparator;
ComparatorOrdering(Comparator<T> comparator) {
@@ -36,12 +33,12 @@
}
@Override
- public int compare(@ParametricNullness T a, @ParametricNullness T b) {
+ public int compare(T a, T b) {
return comparator.compare(a, b);
}
@Override
- public boolean equals(@CheckForNull Object object) {
+ public boolean equals(@Nullable Object object) {
if (object == this) {
return true;
}
diff --git a/guava/src/com/google/common/collect/Comparators.java b/guava/src/com/google/common/collect/Comparators.java
index 1b90fb8..a541de9 100644
--- a/guava/src/com/google/common/collect/Comparators.java
+++ b/guava/src/com/google/common/collect/Comparators.java
@@ -44,7 +44,6 @@
* @author Louis Wasserman
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
public final class Comparators {
private Comparators() {}
@@ -63,8 +62,7 @@
// desired return type. However, *nested* generics introduce a special class of problems that we
// think tip it over into being worthwhile.
@Beta
- public static <T extends @Nullable Object, S extends T> Comparator<Iterable<S>> lexicographical(
- Comparator<T> comparator) {
+ public static <T, S extends T> Comparator<Iterable<S>> lexicographical(Comparator<T> comparator) {
return new LexicographicalOrdering<S>(checkNotNull(comparator));
}
@@ -74,8 +72,7 @@
* always true when the iterable has fewer than two elements.
*/
@Beta
- public static <T extends @Nullable Object> boolean isInOrder(
- Iterable<? extends T> iterable, Comparator<T> comparator) {
+ public static <T> boolean isInOrder(Iterable<? extends T> iterable, Comparator<T> comparator) {
checkNotNull(comparator);
Iterator<? extends T> it = iterable.iterator();
if (it.hasNext()) {
@@ -97,7 +94,7 @@
* this is always true when the iterable has fewer than two elements.
*/
@Beta
- public static <T extends @Nullable Object> boolean isInStrictOrder(
+ public static <T> boolean isInStrictOrder(
Iterable<? extends T> iterable, Comparator<T> comparator) {
checkNotNull(comparator);
Iterator<? extends T> it = iterable.iterator();
@@ -134,8 +131,7 @@
* @throws IllegalArgumentException if {@code k < 0}
* @since 22.0
*/
- public static <T extends @Nullable Object> Collector<T, ?, List<T>> least(
- int k, Comparator<? super T> comparator) {
+ public static <T> Collector<T, ?, List<T>> least(int k, Comparator<? super T> comparator) {
checkNonnegative(k, "k");
checkNotNull(comparator);
return Collector.of(
@@ -166,8 +162,7 @@
* @throws IllegalArgumentException if {@code k < 0}
* @since 22.0
*/
- public static <T extends @Nullable Object> Collector<T, ?, List<T>> greatest(
- int k, Comparator<? super T> comparator) {
+ public static <T> Collector<T, ?, List<T>> greatest(int k, Comparator<? super T> comparator) {
return least(k, comparator.reversed());
}
@@ -181,8 +176,7 @@
@Beta
public static <T> Comparator<Optional<T>> emptiesFirst(Comparator<? super T> valueComparator) {
checkNotNull(valueComparator);
- return Comparator.<Optional<T>, @Nullable T>comparing(
- o -> o.orElse(null), Comparator.nullsFirst(valueComparator));
+ return Comparator.comparing(o -> o.orElse(null), Comparator.nullsFirst(valueComparator));
}
/**
@@ -195,8 +189,7 @@
@Beta
public static <T> Comparator<Optional<T>> emptiesLast(Comparator<? super T> valueComparator) {
checkNotNull(valueComparator);
- return Comparator.<Optional<T>, @Nullable T>comparing(
- o -> o.orElse(null), Comparator.nullsLast(valueComparator));
+ return Comparator.comparing(o -> o.orElse(null), Comparator.nullsLast(valueComparator));
}
/**
@@ -233,9 +226,7 @@
* @since 30.0
*/
@Beta
- @ParametricNullness
- public static <T extends @Nullable Object> T min(
- @ParametricNullness T a, @ParametricNullness T b, Comparator<T> comparator) {
+ public static <T> T min(@Nullable T a, @Nullable T b, Comparator<T> comparator) {
return (comparator.compare(a, b) <= 0) ? a : b;
}
@@ -273,9 +264,7 @@
* @since 30.0
*/
@Beta
- @ParametricNullness
- public static <T extends @Nullable Object> T max(
- @ParametricNullness T a, @ParametricNullness T b, Comparator<T> comparator) {
+ public static <T> T max(@Nullable T a, @Nullable T b, Comparator<T> comparator) {
return (comparator.compare(a, b) >= 0) ? a : b;
}
}
diff --git a/guava/src/com/google/common/collect/ComparisonChain.java b/guava/src/com/google/common/collect/ComparisonChain.java
index 32aeb4d..578166d 100644
--- a/guava/src/com/google/common/collect/ComparisonChain.java
+++ b/guava/src/com/google/common/collect/ComparisonChain.java
@@ -57,7 +57,6 @@
* @since 2.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
public abstract class ComparisonChain {
private ComparisonChain() {}
@@ -68,15 +67,15 @@
private static final ComparisonChain ACTIVE =
new ComparisonChain() {
- @SuppressWarnings("unchecked") // unsafe; see discussion on supertype
+ @SuppressWarnings("unchecked")
@Override
- public ComparisonChain compare(Comparable<?> left, Comparable<?> right) {
- return classify(((Comparable<Object>) left).compareTo(right));
+ public ComparisonChain compare(Comparable left, Comparable right) {
+ return classify(left.compareTo(right));
}
@Override
- public <T extends @Nullable Object> ComparisonChain compare(
- @ParametricNullness T left, @ParametricNullness T right, Comparator<T> comparator) {
+ public <T> ComparisonChain compare(
+ @Nullable T left, @Nullable T right, Comparator<T> comparator) {
return classify(comparator.compare(left, right));
}
@@ -132,13 +131,13 @@
}
@Override
- public ComparisonChain compare(Comparable<?> left, Comparable<?> right) {
+ public ComparisonChain compare(@Nullable Comparable left, @Nullable Comparable right) {
return this;
}
@Override
- public <T extends @Nullable Object> ComparisonChain compare(
- @ParametricNullness T left, @ParametricNullness T right, Comparator<T> comparator) {
+ public <T> ComparisonChain compare(
+ @Nullable T left, @Nullable T right, @Nullable Comparator<T> comparator) {
return this;
}
@@ -181,18 +180,6 @@
/**
* Compares two comparable objects as specified by {@link Comparable#compareTo}, <i>if</i> the
* result of this comparison chain has not already been determined.
- *
- * <p>This method is declared to accept any 2 {@code Comparable} objects, even if they are not <a
- * href="https://docs.oracle.com/javase/tutorial/collections/interfaces/order.html">mutually
- * comparable</a>. If you pass objects that are not mutually comparable, this method may throw an
- * exception. (The reason for this decision is lost to time, but the reason <i>might</i> be that
- * we wanted to support legacy classes that implement the raw type {@code Comparable} (instead of
- * implementing {@code Comparable<Foo>}) without producing warnings. If so, we would prefer today
- * to produce warnings in that case, and we may change this method to do so in the future. Support
- * for raw {@code Comparable} types in Guava in general is tracked as <a
- * href="https://github.com/google/guava/issues/989">#989</a>.)
- *
- * @throws ClassCastException if the parameters are not mutually comparable
*/
public abstract ComparisonChain compare(Comparable<?> left, Comparable<?> right);
@@ -200,8 +187,8 @@
* Compares two objects using a comparator, <i>if</i> the result of this comparison chain has not
* already been determined.
*/
- public abstract <T extends @Nullable Object> ComparisonChain compare(
- @ParametricNullness T left, @ParametricNullness T right, Comparator<T> comparator);
+ public abstract <T> ComparisonChain compare(
+ @Nullable T left, @Nullable T right, Comparator<T> comparator);
/**
* Compares two {@code int} values as specified by {@link Ints#compare}, <i>if</i> the result of
diff --git a/guava/src/com/google/common/collect/CompoundOrdering.java b/guava/src/com/google/common/collect/CompoundOrdering.java
index 42feed3..e803acb 100644
--- a/guava/src/com/google/common/collect/CompoundOrdering.java
+++ b/guava/src/com/google/common/collect/CompoundOrdering.java
@@ -20,14 +20,10 @@
import java.io.Serializable;
import java.util.Arrays;
import java.util.Comparator;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
/** An ordering that tries several comparators in order. */
@GwtCompatible(serializable = true)
-@ElementTypesAreNonnullByDefault
-final class CompoundOrdering<T extends @Nullable Object> extends Ordering<T>
- implements Serializable {
+final class CompoundOrdering<T> extends Ordering<T> implements Serializable {
final Comparator<? super T>[] comparators;
CompoundOrdering(Comparator<? super T> primary, Comparator<? super T> secondary) {
@@ -39,7 +35,7 @@
}
@Override
- public int compare(@ParametricNullness T left, @ParametricNullness T right) {
+ public int compare(T left, T right) {
for (int i = 0; i < comparators.length; i++) {
int result = comparators[i].compare(left, right);
if (result != 0) {
@@ -50,7 +46,7 @@
}
@Override
- public boolean equals(@CheckForNull Object object) {
+ public boolean equals(Object object) {
if (object == this) {
return true;
}
diff --git a/guava/src/com/google/common/collect/ComputationException.java b/guava/src/com/google/common/collect/ComputationException.java
index b05577c..df8d377 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 javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Wraps an exception that occurred during a computation.
@@ -34,10 +34,9 @@
*/
@Deprecated
@GwtCompatible
-@ElementTypesAreNonnullByDefault
public class ComputationException extends RuntimeException {
/** Creates a new instance with the given cause. */
- public ComputationException(@CheckForNull 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 ab03ead..3aaa76e 100644
--- a/guava/src/com/google/common/collect/ConcurrentHashMultiset.java
+++ b/guava/src/com/google/common/collect/ConcurrentHashMultiset.java
@@ -18,8 +18,8 @@
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.base.Preconditions.checkState;
import static com.google.common.collect.CollectPreconditions.checkNonnegative;
+import static com.google.common.collect.CollectPreconditions.checkRemove;
import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtIncompatible;
@@ -41,7 +41,6 @@
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.atomic.AtomicInteger;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -57,7 +56,6 @@
* @since 2.0
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public final class ConcurrentHashMultiset<E> extends AbstractMultiset<E> implements Serializable {
/*
@@ -139,7 +137,7 @@
* @return the nonnegative number of occurrences of the element
*/
@Override
- public int count(@CheckForNull Object element) {
+ public int count(@Nullable Object element) {
AtomicInteger existingCounter = Maps.safeGet(countMap, element);
return (existingCounter == null) ? 0 : existingCounter.get();
}
@@ -170,8 +168,7 @@
}
@Override
- @SuppressWarnings("nullness") // b/192354773 in our checker affects toArray declarations
- public <T extends @Nullable Object> T[] toArray(T[] array) {
+ public <T> T[] toArray(T[] array) {
return snapshot().toArray(array);
}
@@ -208,7 +205,7 @@
if (occurrences == 0) {
return count(element);
}
- CollectPreconditions.checkPositive(occurrences, "occurrences");
+ CollectPreconditions.checkPositive(occurrences, "occurences");
while (true) {
AtomicInteger existingCounter = Maps.safeGet(countMap, element);
@@ -270,11 +267,11 @@
*/
@CanIgnoreReturnValue
@Override
- public int remove(@CheckForNull Object element, int occurrences) {
+ public int remove(@Nullable Object element, int occurrences) {
if (occurrences == 0) {
return count(element);
}
- CollectPreconditions.checkPositive(occurrences, "occurrences");
+ CollectPreconditions.checkPositive(occurrences, "occurences");
AtomicInteger existingCounter = Maps.safeGet(countMap, element);
if (existingCounter == null) {
@@ -311,11 +308,11 @@
* @throws IllegalArgumentException if {@code occurrences} is negative
*/
@CanIgnoreReturnValue
- public boolean removeExactly(@CheckForNull Object element, int occurrences) {
+ public boolean removeExactly(@Nullable Object element, int occurrences) {
if (occurrences == 0) {
return true;
}
- CollectPreconditions.checkPositive(occurrences, "occurrences");
+ CollectPreconditions.checkPositive(occurrences, "occurences");
AtomicInteger existingCounter = Maps.safeGet(countMap, element);
if (existingCounter == null) {
@@ -457,7 +454,7 @@
}
@Override
- public boolean contains(@CheckForNull Object object) {
+ public boolean contains(@Nullable Object object) {
return object != null && Collections2.safeContains(delegate, object);
}
@@ -467,7 +464,7 @@
}
@Override
- public boolean remove(@CheckForNull Object object) {
+ public boolean remove(Object object) {
return object != null && Collections2.safeRemove(delegate, object);
}
@@ -510,7 +507,6 @@
countMap.entrySet().iterator();
@Override
- @CheckForNull
protected Entry<E> computeNext() {
while (true) {
if (!mapEntries.hasNext()) {
@@ -526,7 +522,7 @@
};
return new ForwardingIterator<Entry<E>>() {
- @CheckForNull private Entry<E> last;
+ private @Nullable Entry<E> last;
@Override
protected Iterator<Entry<E>> delegate() {
@@ -541,7 +537,7 @@
@Override
public void remove() {
- checkState(last != null, "no calls to next() since the last call to remove()");
+ checkRemove(last != null);
ConcurrentHashMultiset.this.setCount(last.getElement(), 0);
last = null;
}
@@ -576,8 +572,7 @@
}
@Override
- @SuppressWarnings("nullness") // b/192354773 in our checker affects toArray declarations
- public <T extends @Nullable Object> T[] toArray(T[] array) {
+ public <T> T[] toArray(T[] array) {
return snapshot().toArray(array);
}
diff --git a/guava/src/com/google/common/collect/ConsumingQueueIterator.java b/guava/src/com/google/common/collect/ConsumingQueueIterator.java
index 7721e12..2f288f0 100644
--- a/guava/src/com/google/common/collect/ConsumingQueueIterator.java
+++ b/guava/src/com/google/common/collect/ConsumingQueueIterator.java
@@ -17,30 +17,29 @@
import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.annotations.GwtCompatible;
+import java.util.ArrayDeque;
+import java.util.Collections;
import java.util.Queue;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* An Iterator implementation which draws elements from a queue, removing them from the queue as it
* iterates.
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-final class ConsumingQueueIterator<T extends @Nullable Object> extends AbstractIterator<T> {
+class ConsumingQueueIterator<T> extends AbstractIterator<T> {
private final Queue<T> queue;
+ ConsumingQueueIterator(T... elements) {
+ this.queue = new ArrayDeque<T>(elements.length);
+ Collections.addAll(queue, elements);
+ }
+
ConsumingQueueIterator(Queue<T> queue) {
this.queue = checkNotNull(queue);
}
@Override
- @CheckForNull
public T computeNext() {
- // TODO(b/192579700): Use a ternary once it no longer confuses our nullness checker.
- if (queue.isEmpty()) {
- return endOfData();
- }
- return queue.remove();
+ return queue.isEmpty() ? endOfData() : queue.remove();
}
}
diff --git a/guava/src/com/google/common/collect/ContiguousSet.java b/guava/src/com/google/common/collect/ContiguousSet.java
index cd77042..6755be6 100644
--- a/guava/src/com/google/common/collect/ContiguousSet.java
+++ b/guava/src/com/google/common/collect/ContiguousSet.java
@@ -16,12 +16,10 @@
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
-import static java.util.Objects.requireNonNull;
import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.GwtIncompatible;
-import com.google.errorprone.annotations.DoNotCall;
import java.util.Collections;
import java.util.NoSuchElementException;
import java.util.Set;
@@ -50,7 +48,6 @@
*/
@GwtCompatible(emulated = true)
@SuppressWarnings("rawtypes") // allow ungenerified Comparable types
-@ElementTypesAreNonnullByDefault
public abstract class ContiguousSet<C extends Comparable> extends ImmutableSortedSet<C> {
/**
* Returns a {@code ContiguousSet} containing the same values in the given domain {@linkplain
@@ -76,19 +73,13 @@
throw new IllegalArgumentException(e);
}
- boolean empty;
- if (effectiveRange.isEmpty()) {
- empty = true;
- } else {
- /*
- * requireNonNull is safe because the effectiveRange operations above would have thrown or
- * effectiveRange.isEmpty() would have returned true.
- */
- C afterLower = requireNonNull(range.lowerBound.leastValueAbove(domain));
- C beforeUpper = requireNonNull(range.upperBound.greatestValueBelow(domain));
- // Per class spec, we are allowed to throw CCE if necessary
- empty = Range.compareOrThrow(afterLower, beforeUpper) > 0;
- }
+ // Per class spec, we are allowed to throw CCE if necessary
+ boolean empty =
+ effectiveRange.isEmpty()
+ || Range.compareOrThrow(
+ range.lowerBound.leastValueAbove(domain),
+ range.upperBound.greatestValueBelow(domain))
+ > 0;
return empty
? new EmptyContiguousSet<C>(domain)
@@ -200,14 +191,15 @@
/*
* These methods perform most headSet, subSet, and tailSet logic, besides parameter validation.
*/
- @SuppressWarnings("MissingOverride") // Supermethod does not exist under GWT.
+ // TODO(kevinb): we can probably make these real @Overrides now
+ /* @Override */
abstract ContiguousSet<C> headSetImpl(C toElement, boolean inclusive);
- @SuppressWarnings("MissingOverride") // Supermethod does not exist under GWT.
+ /* @Override */
abstract ContiguousSet<C> subSetImpl(
C fromElement, boolean fromInclusive, C toElement, boolean toInclusive);
- @SuppressWarnings("MissingOverride") // Supermethod does not exist under GWT.
+ /* @Override */
abstract ContiguousSet<C> tailSetImpl(C fromElement, boolean inclusive);
/**
@@ -260,7 +252,6 @@
* @deprecated Use {@link #create}.
*/
@Deprecated
- @DoNotCall("Always throws UnsupportedOperationException")
public static <E> ImmutableSortedSet.Builder<E> builder() {
throw new UnsupportedOperationException();
}
diff --git a/guava/src/com/google/common/collect/Count.java b/guava/src/com/google/common/collect/Count.java
index 7aa5550..e2da82a 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 javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* A mutable value of type {@code int}, for multisets to use in tracking counts of values.
@@ -24,7 +24,6 @@
* @author Louis Wasserman
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
final class Count implements Serializable {
private int value;
@@ -60,7 +59,7 @@
}
@Override
- public boolean equals(@CheckForNull 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 4a8d4c7..8f6cd81 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 javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Implementation detail for the internal structure of {@link Range} instances. Represents a unique
@@ -32,11 +32,10 @@
* @author Kevin Bourrillion
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
abstract class Cut<C extends Comparable> implements Comparable<Cut<C>>, Serializable {
- final C endpoint;
+ final @Nullable C endpoint;
- Cut(C endpoint) {
+ Cut(@Nullable C endpoint) {
this.endpoint = endpoint;
}
@@ -54,10 +53,8 @@
abstract void describeAsUpperBound(StringBuilder sb);
- @CheckForNull
abstract C leastValueAbove(DiscreteDomain<C> domain);
- @CheckForNull
abstract C greatestValueBelow(DiscreteDomain<C> domain);
/*
@@ -91,15 +88,14 @@
@SuppressWarnings("unchecked") // catching CCE
@Override
- public boolean equals(@CheckForNull Object obj) {
+ public boolean equals(Object obj) {
if (obj instanceof Cut) {
// It might not really be a Cut<C>, but we'll catch a CCE if it's not
Cut<C> that = (Cut<C>) obj;
try {
int compareResult = compareTo(that);
return compareResult == 0;
- } catch (ClassCastException wastNotComparableToOurType) {
- return false;
+ } catch (ClassCastException ignored) {
}
}
return false;
@@ -124,13 +120,7 @@
private static final BelowAll INSTANCE = new BelowAll();
private BelowAll() {
- /*
- * No code ever sees this bogus value for `endpoint`: This class overrides both methods that
- * use the `endpoint` field, compareTo() and endpoint(). Additionally, the main implementation
- * of Cut.compareTo checks for belowAll before reading accessing `endpoint` on another Cut
- * instance.
- */
- super("");
+ super(null);
}
@Override
@@ -229,8 +219,7 @@
private static final AboveAll INSTANCE = new AboveAll();
private AboveAll() {
- // For discussion of "", see BelowAll.
- super("");
+ super(null);
}
@Override
@@ -337,7 +326,7 @@
case CLOSED:
return this;
case OPEN:
- C previous = domain.previous(endpoint);
+ @Nullable C previous = domain.previous(endpoint);
return (previous == null) ? Cut.<C>belowAll() : new AboveValue<C>(previous);
default:
throw new AssertionError();
@@ -348,7 +337,7 @@
Cut<C> withUpperBoundType(BoundType boundType, DiscreteDomain<C> domain) {
switch (boundType) {
case CLOSED:
- C previous = domain.previous(endpoint);
+ @Nullable C previous = domain.previous(endpoint);
return (previous == null) ? Cut.<C>aboveAll() : new AboveValue<C>(previous);
case OPEN:
return this;
@@ -373,7 +362,6 @@
}
@Override
- @CheckForNull
C greatestValueBelow(DiscreteDomain<C> domain) {
return domain.previous(endpoint);
}
@@ -421,7 +409,7 @@
case OPEN:
return this;
case CLOSED:
- C next = domain.next(endpoint);
+ @Nullable C next = domain.next(endpoint);
return (next == null) ? Cut.<C>belowAll() : belowValue(next);
default:
throw new AssertionError();
@@ -432,7 +420,7 @@
Cut<C> withUpperBoundType(BoundType boundType, DiscreteDomain<C> domain) {
switch (boundType) {
case OPEN:
- C next = domain.next(endpoint);
+ @Nullable C next = domain.next(endpoint);
return (next == null) ? Cut.<C>aboveAll() : belowValue(next);
case CLOSED:
return this;
@@ -452,7 +440,6 @@
}
@Override
- @CheckForNull
C leastValueAbove(DiscreteDomain<C> domain) {
return domain.next(endpoint);
}
diff --git a/guava/src/com/google/common/collect/DenseImmutableTable.java b/guava/src/com/google/common/collect/DenseImmutableTable.java
index 9de77c5..91c2d48 100644
--- a/guava/src/com/google/common/collect/DenseImmutableTable.java
+++ b/guava/src/com/google/common/collect/DenseImmutableTable.java
@@ -14,20 +14,16 @@
package com.google.common.collect;
-import static java.util.Objects.requireNonNull;
-
import com.google.common.annotations.GwtCompatible;
import com.google.common.collect.ImmutableMap.IteratorBasedImmutableMap;
import com.google.errorprone.annotations.Immutable;
import com.google.j2objc.annotations.WeakOuter;
import java.util.Map;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/** A {@code RegularImmutableTable} optimized for dense data. */
@GwtCompatible
@Immutable(containerOf = {"R", "C", "V"})
-@ElementTypesAreNonnullByDefault
final class DenseImmutableTable<R, C, V> extends RegularImmutableTable<R, C, V> {
private final ImmutableMap<R, Integer> rowKeyToIndex;
private final ImmutableMap<C, Integer> columnKeyToIndex;
@@ -41,7 +37,7 @@
private final int[] columnCounts;
@SuppressWarnings("Immutable") // We don't modify this after construction.
- private final @Nullable V[][] values;
+ private final V[][] values;
// For each cell in iteration order, the index of that cell's row key in the row key list.
@SuppressWarnings("Immutable") // We don't modify this after construction.
@@ -56,8 +52,7 @@
ImmutableSet<R> rowSpace,
ImmutableSet<C> columnSpace) {
@SuppressWarnings("unchecked")
- @Nullable
- V[][] array = (@Nullable V[][]) new Object[rowSpace.size()][columnSpace.size()];
+ V[][] array = (V[][]) new Object[rowSpace.size()][columnSpace.size()];
this.values = array;
this.rowKeyToIndex = Maps.indexMap(rowSpace);
this.columnKeyToIndex = Maps.indexMap(columnSpace);
@@ -69,9 +64,8 @@
Cell<R, C, V> cell = cellList.get(i);
R rowKey = cell.getRowKey();
C columnKey = cell.getColumnKey();
- // The requireNonNull calls are safe because we construct the indexes with indexMap.
- int rowIndex = requireNonNull(rowKeyToIndex.get(rowKey));
- int columnIndex = requireNonNull(columnKeyToIndex.get(columnKey));
+ int rowIndex = rowKeyToIndex.get(rowKey);
+ int columnIndex = columnKeyToIndex.get(columnKey);
V existingValue = values[rowIndex][columnIndex];
checkNoDuplicate(rowKey, columnKey, existingValue, cell.getValue());
values[rowIndex][columnIndex] = cell.getValue();
@@ -105,8 +99,7 @@
return keyToIndex().keySet().asList().get(index);
}
- @CheckForNull
- abstract V getValue(int keyIndex);
+ abstract @Nullable V getValue(int keyIndex);
@Override
ImmutableSet<K> createKeySet() {
@@ -119,8 +112,7 @@
}
@Override
- @CheckForNull
- public V get(@CheckForNull Object key) {
+ public V get(@Nullable Object key) {
Integer keyIndex = keyToIndex().get(key);
return (keyIndex == null) ? null : getValue(keyIndex);
}
@@ -132,7 +124,6 @@
private final int maxIndex = keyToIndex().size();
@Override
- @CheckForNull
protected Entry<K, V> computeNext() {
for (index++; index < maxIndex; index++) {
V value = getValue(index);
@@ -160,7 +151,6 @@
}
@Override
- @CheckForNull
V getValue(int keyIndex) {
return values[rowIndex][keyIndex];
}
@@ -185,7 +175,6 @@
}
@Override
- @CheckForNull
V getValue(int keyIndex) {
return values[keyIndex][columnIndex];
}
@@ -255,8 +244,7 @@
}
@Override
- @CheckForNull
- public V get(@CheckForNull Object rowKey, @CheckForNull 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];
@@ -273,15 +261,13 @@
int columnIndex = cellColumnIndices[index];
R rowKey = rowKeySet().asList().get(rowIndex);
C columnKey = columnKeySet().asList().get(columnIndex);
- // requireNonNull is safe because we use indexes that were populated by the constructor.
- V value = requireNonNull(values[rowIndex][columnIndex]);
+ V value = values[rowIndex][columnIndex];
return cellOf(rowKey, columnKey, value);
}
@Override
V getValue(int index) {
- // requireNonNull is safe because we use indexes that were populated by the constructor.
- return requireNonNull(values[cellRowIndices[index]][cellColumnIndices[index]]);
+ return values[cellRowIndices[index]][cellColumnIndices[index]];
}
@Override
diff --git a/guava/src/com/google/common/collect/DescendingImmutableSortedMultiset.java b/guava/src/com/google/common/collect/DescendingImmutableSortedMultiset.java
index 181731c..346bafb 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 javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* A descending wrapper around an {@code ImmutableSortedMultiset}
@@ -24,7 +24,6 @@
*/
@SuppressWarnings("serial") // uses writeReplace, not default serialization
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
final class DescendingImmutableSortedMultiset<E> extends ImmutableSortedMultiset<E> {
private final transient ImmutableSortedMultiset<E> forward;
@@ -33,18 +32,16 @@
}
@Override
- public int count(@CheckForNull Object element) {
+ public int count(@Nullable Object element) {
return forward.count(element);
}
@Override
- @CheckForNull
public Entry<E> firstEntry() {
return forward.lastEntry();
}
@Override
- @CheckForNull
public Entry<E> lastEntry() {
return forward.firstEntry();
}
diff --git a/guava/src/com/google/common/collect/DescendingImmutableSortedSet.java b/guava/src/com/google/common/collect/DescendingImmutableSortedSet.java
index 88c7d6b..6354378 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 javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Skeletal implementation of {@link ImmutableSortedSet#descendingSet()}.
@@ -25,7 +25,6 @@
* @author Louis Wasserman
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
final class DescendingImmutableSortedSet<E> extends ImmutableSortedSet<E> {
private final ImmutableSortedSet<E> forward;
@@ -35,7 +34,7 @@
}
@Override
- public boolean contains(@CheckForNull Object object) {
+ public boolean contains(@Nullable Object object) {
return forward.contains(object);
}
@@ -84,31 +83,27 @@
}
@Override
- @CheckForNull
public E lower(E element) {
return forward.higher(element);
}
@Override
- @CheckForNull
public E floor(E element) {
return forward.ceiling(element);
}
@Override
- @CheckForNull
public E ceiling(E element) {
return forward.floor(element);
}
@Override
- @CheckForNull
public E higher(E element) {
return forward.lower(element);
}
@Override
- int indexOf(@CheckForNull 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/DescendingMultiset.java b/guava/src/com/google/common/collect/DescendingMultiset.java
index ec5a1d0..74590ac 100644
--- a/guava/src/com/google/common/collect/DescendingMultiset.java
+++ b/guava/src/com/google/common/collect/DescendingMultiset.java
@@ -22,7 +22,6 @@
import java.util.Iterator;
import java.util.NavigableSet;
import java.util.Set;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -32,12 +31,10 @@
* @author Louis Wasserman
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
-abstract class DescendingMultiset<E extends @Nullable Object> extends ForwardingMultiset<E>
- implements SortedMultiset<E> {
+abstract class DescendingMultiset<E> extends ForwardingMultiset<E> implements SortedMultiset<E> {
abstract SortedMultiset<E> forwardMultiset();
- @CheckForNull private transient Comparator<? super E> comparator;
+ private transient @Nullable Comparator<? super E> comparator;
@Override
public Comparator<? super E> comparator() {
@@ -48,7 +45,7 @@
return result;
}
- @CheckForNull private transient NavigableSet<E> elementSet;
+ private transient @Nullable NavigableSet<E> elementSet;
@Override
public NavigableSet<E> elementSet() {
@@ -60,35 +57,30 @@
}
@Override
- @CheckForNull
public Entry<E> pollFirstEntry() {
return forwardMultiset().pollLastEntry();
}
@Override
- @CheckForNull
public Entry<E> pollLastEntry() {
return forwardMultiset().pollFirstEntry();
}
@Override
- public SortedMultiset<E> headMultiset(@ParametricNullness E toElement, BoundType boundType) {
+ public SortedMultiset<E> headMultiset(E toElement, BoundType boundType) {
return forwardMultiset().tailMultiset(toElement, boundType).descendingMultiset();
}
@Override
public SortedMultiset<E> subMultiset(
- @ParametricNullness E fromElement,
- BoundType fromBoundType,
- @ParametricNullness E toElement,
- BoundType toBoundType) {
+ E fromElement, BoundType fromBoundType, E toElement, BoundType toBoundType) {
return forwardMultiset()
.subMultiset(toElement, toBoundType, fromElement, fromBoundType)
.descendingMultiset();
}
@Override
- public SortedMultiset<E> tailMultiset(@ParametricNullness E fromElement, BoundType boundType) {
+ public SortedMultiset<E> tailMultiset(E fromElement, BoundType boundType) {
return forwardMultiset().headMultiset(fromElement, boundType).descendingMultiset();
}
@@ -103,20 +95,18 @@
}
@Override
- @CheckForNull
public Entry<E> firstEntry() {
return forwardMultiset().lastEntry();
}
@Override
- @CheckForNull
public Entry<E> lastEntry() {
return forwardMultiset().firstEntry();
}
abstract Iterator<Entry<E>> entryIterator();
- @CheckForNull private transient Set<Entry<E>> entrySet;
+ private transient @Nullable Set<Entry<E>> entrySet;
@Override
public Set<Entry<E>> entrySet() {
@@ -151,13 +141,12 @@
}
@Override
- public @Nullable Object[] toArray() {
+ public Object[] toArray() {
return standardToArray();
}
@Override
- @SuppressWarnings("nullness") // b/192354773 in our checker affects toArray declarations
- public <T extends @Nullable Object> T[] toArray(T[] array) {
+ public <T> T[] toArray(T[] array) {
return standardToArray(array);
}
diff --git a/guava/src/com/google/common/collect/DiscreteDomain.java b/guava/src/com/google/common/collect/DiscreteDomain.java
index bce7062..3777a6d 100644
--- a/guava/src/com/google/common/collect/DiscreteDomain.java
+++ b/guava/src/com/google/common/collect/DiscreteDomain.java
@@ -25,7 +25,6 @@
import java.io.Serializable;
import java.math.BigInteger;
import java.util.NoSuchElementException;
-import javax.annotation.CheckForNull;
/**
* A descriptor for a <i>discrete</i> {@code Comparable} domain such as all {@link Integer}
@@ -44,7 +43,6 @@
* @since 10.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
public abstract class DiscreteDomain<C extends Comparable> {
/**
@@ -64,14 +62,12 @@
}
@Override
- @CheckForNull
public Integer next(Integer value) {
int i = value;
return (i == Integer.MAX_VALUE) ? null : i + 1;
}
@Override
- @CheckForNull
public Integer previous(Integer value) {
int i = value;
return (i == Integer.MIN_VALUE) ? null : i - 1;
@@ -127,14 +123,12 @@
}
@Override
- @CheckForNull
public Long next(Long value) {
long l = value;
return (l == Long.MAX_VALUE) ? null : l + 1;
}
@Override
- @CheckForNull
public Long previous(Long value) {
long l = value;
return (l == Long.MIN_VALUE) ? null : l - 1;
@@ -254,16 +248,11 @@
* #next} on {@code origin} {@code distance} times.
*/
C offset(C origin, long distance) {
- C current = origin;
checkNonnegative(distance, "distance");
for (long i = 0; i < distance; i++) {
- current = next(current);
- if (current == null) {
- throw new IllegalArgumentException(
- "overflowed computing offset(" + origin + ", " + distance + ")");
- }
+ origin = next(origin);
}
- return current;
+ return origin;
}
/**
@@ -274,7 +263,6 @@
* @return the least value greater than {@code value}, or {@code null} if {@code value} is {@code
* maxValue()}
*/
- @CheckForNull
public abstract C next(C value);
/**
@@ -285,7 +273,6 @@
* @return the greatest value less than {@code value}, or {@code null} if {@code value} is {@code
* minValue()}
*/
- @CheckForNull
public abstract C previous(C value);
/**
diff --git a/guava/src/com/google/common/collect/ElementTypesAreNonnullByDefault.java b/guava/src/com/google/common/collect/ElementTypesAreNonnullByDefault.java
deleted file mode 100644
index e1c640f..0000000
--- a/guava/src/com/google/common/collect/ElementTypesAreNonnullByDefault.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) 2021 The Guava Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.common.collect;
-
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.PARAMETER;
-import static java.lang.annotation.ElementType.TYPE;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-import com.google.common.annotations.GwtCompatible;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-import javax.annotation.Nonnull;
-import javax.annotation.meta.TypeQualifierDefault;
-
-/**
- * Marks all "top-level" types as non-null in a way that is recognized by Kotlin. Note that this
- * unfortunately includes type-variable usages, so we also provide {@link ParametricNullness} to
- * "undo" it as best we can.
- */
-@GwtCompatible
-@Retention(RUNTIME)
-@Target(TYPE)
-@TypeQualifierDefault({FIELD, METHOD, PARAMETER})
-@Nonnull
-@interface ElementTypesAreNonnullByDefault {}
diff --git a/guava/src/com/google/common/collect/EmptyContiguousSet.java b/guava/src/com/google/common/collect/EmptyContiguousSet.java
index f4fe33c..fd90124 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 javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* An empty contiguous set.
@@ -27,7 +27,6 @@
*/
@GwtCompatible(emulated = true)
@SuppressWarnings("rawtypes") // allow ungenerified Comparable types
-@ElementTypesAreNonnullByDefault
final class EmptyContiguousSet<C extends Comparable> extends ContiguousSet<C> {
EmptyContiguousSet(DiscreteDomain<C> domain) {
super(domain);
@@ -80,13 +79,13 @@
}
@Override
- public boolean contains(@CheckForNull Object object) {
+ public boolean contains(Object object) {
return false;
}
@GwtIncompatible // not used by GWT emulation
@Override
- int indexOf(@CheckForNull Object target) {
+ int indexOf(Object target) {
return -1;
}
@@ -122,7 +121,7 @@
}
@Override
- public boolean equals(@CheckForNull 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/EmptyImmutableListMultimap.java b/guava/src/com/google/common/collect/EmptyImmutableListMultimap.java
index 10d030f..9b167fb 100644
--- a/guava/src/com/google/common/collect/EmptyImmutableListMultimap.java
+++ b/guava/src/com/google/common/collect/EmptyImmutableListMultimap.java
@@ -24,7 +24,6 @@
* @author Jared Levy
*/
@GwtCompatible(serializable = true)
-@ElementTypesAreNonnullByDefault
class EmptyImmutableListMultimap extends ImmutableListMultimap<Object, Object> {
static final EmptyImmutableListMultimap INSTANCE = new EmptyImmutableListMultimap();
diff --git a/guava/src/com/google/common/collect/EmptyImmutableSetMultimap.java b/guava/src/com/google/common/collect/EmptyImmutableSetMultimap.java
index bd0a67a..ec2ce2e 100644
--- a/guava/src/com/google/common/collect/EmptyImmutableSetMultimap.java
+++ b/guava/src/com/google/common/collect/EmptyImmutableSetMultimap.java
@@ -24,7 +24,6 @@
* @author Mike Ward
*/
@GwtCompatible(serializable = true)
-@ElementTypesAreNonnullByDefault
class EmptyImmutableSetMultimap extends ImmutableSetMultimap<Object, Object> {
static final EmptyImmutableSetMultimap INSTANCE = new EmptyImmutableSetMultimap();
diff --git a/guava/src/com/google/common/collect/EnumBiMap.java b/guava/src/com/google/common/collect/EnumBiMap.java
index 82aa052..f72b8b9 100644
--- a/guava/src/com/google/common/collect/EnumBiMap.java
+++ b/guava/src/com/google/common/collect/EnumBiMap.java
@@ -38,7 +38,6 @@
* @since 2.0
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
public final class EnumBiMap<K extends Enum<K>, V extends Enum<V>> extends AbstractBiMap<K, V> {
private transient Class<K> keyType;
private transient Class<V> valueType;
diff --git a/guava/src/com/google/common/collect/EnumHashBiMap.java b/guava/src/com/google/common/collect/EnumHashBiMap.java
index f68bc4c..47094ae 100644
--- a/guava/src/com/google/common/collect/EnumHashBiMap.java
+++ b/guava/src/com/google/common/collect/EnumHashBiMap.java
@@ -27,7 +27,6 @@
import java.util.EnumMap;
import java.util.HashMap;
import java.util.Map;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -42,9 +41,7 @@
* @since 2.0
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
-public final class EnumHashBiMap<K extends Enum<K>, V extends @Nullable Object>
- extends AbstractBiMap<K, V> {
+public final class EnumHashBiMap<K extends Enum<K>, V> extends AbstractBiMap<K, V> {
private transient Class<K> keyType;
/**
@@ -52,8 +49,7 @@
*
* @param keyType the key type
*/
- public static <K extends Enum<K>, V extends @Nullable Object> EnumHashBiMap<K, V> create(
- Class<K> keyType) {
+ public static <K extends Enum<K>, V> EnumHashBiMap<K, V> create(Class<K> keyType) {
return new EnumHashBiMap<>(keyType);
}
@@ -67,8 +63,7 @@
* @throws IllegalArgumentException if map is not an {@code EnumBiMap} or an {@code EnumHashBiMap}
* instance and contains no mappings
*/
- public static <K extends Enum<K>, V extends @Nullable Object> EnumHashBiMap<K, V> create(
- Map<K, ? extends V> map) {
+ public static <K extends Enum<K>, V> EnumHashBiMap<K, V> create(Map<K, ? extends V> map) {
EnumHashBiMap<K, V> bimap = create(EnumBiMap.inferKeyType(map));
bimap.putAll(map);
return bimap;
@@ -90,19 +85,13 @@
@CanIgnoreReturnValue
@Override
- @SuppressWarnings("RedundantOverride") // b/192446478: RedundantOverride ignores some annotations.
- // TODO(b/192446998): Remove this override after tools understand nullness better.
- @CheckForNull
- public V put(K key, @ParametricNullness V value) {
+ public V put(K key, @Nullable V value) {
return super.put(key, value);
}
@CanIgnoreReturnValue
@Override
- @SuppressWarnings("RedundantOverride") // b/192446478: RedundantOverride ignores some annotations.
- // TODO(b/192446998): Remove this override after tools understand nullness better.
- @CheckForNull
- public V forcePut(K key, @ParametricNullness 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 09dde1b..c6b9b5b 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 javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Multiset implementation specialized for enum elements, supporting all single-element operations
@@ -45,7 +45,6 @@
* @since 2.0
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
public final class EnumMultiset<E extends Enum<E>> extends AbstractMultiset<E>
implements Serializable {
/** Creates an empty {@code EnumMultiset}. */
@@ -95,7 +94,7 @@
this.counts = new int[enumConstants.length];
}
- private boolean isActuallyE(@CheckForNull Object o) {
+ private boolean isActuallyE(@Nullable Object o) {
if (o instanceof Enum) {
Enum<?> e = (Enum<?>) o;
int index = e.ordinal();
@@ -108,7 +107,7 @@
* Returns {@code element} cast to {@code E}, if it actually is a nonnull E. Otherwise, throws
* either a NullPointerException or a ClassCastException as appropriate.
*/
- private void checkIsE(Object element) {
+ void checkIsE(@Nullable Object element) {
checkNotNull(element);
if (!isActuallyE(element)) {
throw new ClassCastException("Expected an " + type + " but got " + element);
@@ -126,9 +125,8 @@
}
@Override
- public int count(@CheckForNull Object element) {
- // isActuallyE checks for null, but we check explicitly to help nullness checkers.
- if (element == null || !isActuallyE(element)) {
+ public int count(@Nullable Object element) {
+ if (!isActuallyE(element)) {
return 0;
}
Enum<?> e = (Enum<?>) element;
@@ -159,9 +157,8 @@
// Modification Operations
@CanIgnoreReturnValue
@Override
- public int remove(@CheckForNull Object element, int occurrences) {
- // isActuallyE checks for null, but we check explicitly to help nullness checkers.
- if (element == null || !isActuallyE(element)) {
+ public int remove(@Nullable Object element, int occurrences) {
+ if (!isActuallyE(element)) {
return 0;
}
Enum<?> e = (Enum<?>) element;
diff --git a/guava/src/com/google/common/collect/EvictingQueue.java b/guava/src/com/google/common/collect/EvictingQueue.java
index 45f59f3..37a65f3 100644
--- a/guava/src/com/google/common/collect/EvictingQueue.java
+++ b/guava/src/com/google/common/collect/EvictingQueue.java
@@ -45,7 +45,6 @@
*/
@Beta
@GwtCompatible
-@ElementTypesAreNonnullByDefault
public final class EvictingQueue<E> extends ForwardingQueue<E> implements Serializable {
private final Queue<E> delegate;
@@ -127,19 +126,17 @@
}
@Override
- public Object[] toArray() {
- /*
- * If we could, we'd declare the no-arg `Collection.toArray()` to return "Object[] but elements
- * have the same nullness as E." Since we can't, we declare it to return nullable elements, and
- * we can override it in our non-null-guaranteeing subtypes to present a better signature to
- * their users.
- *
- * However, the checker *we* use has this special knowledge about `Collection.toArray()` anyway,
- * so in our implementation code, we can rely on that. That's why the expression below
- * type-checks.
- */
- return super.toArray();
+ public boolean contains(Object object) {
+ return delegate().contains(checkNotNull(object));
}
+ @Override
+ @CanIgnoreReturnValue
+ public boolean remove(Object object) {
+ return delegate().remove(checkNotNull(object));
+ }
+
+ // TODO(kak): Do we want to checkNotNull each element in containsAll, removeAll, and retainAll?
+
private static final long serialVersionUID = 0L;
}
diff --git a/guava/src/com/google/common/collect/ExplicitOrdering.java b/guava/src/com/google/common/collect/ExplicitOrdering.java
index 383318a..526e6e3 100644
--- a/guava/src/com/google/common/collect/ExplicitOrdering.java
+++ b/guava/src/com/google/common/collect/ExplicitOrdering.java
@@ -19,11 +19,10 @@
import com.google.common.annotations.GwtCompatible;
import java.io.Serializable;
import java.util.List;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/** An ordering that compares objects according to a given order. */
@GwtCompatible(serializable = true)
-@ElementTypesAreNonnullByDefault
final class ExplicitOrdering<T> extends Ordering<T> implements Serializable {
final ImmutableMap<T, Integer> rankMap;
@@ -49,7 +48,7 @@
}
@Override
- public boolean equals(@CheckForNull 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 3ff00b7..ced909a 100644
--- a/guava/src/com/google/common/collect/FilteredEntryMultimap.java
+++ b/guava/src/com/google/common/collect/FilteredEntryMultimap.java
@@ -33,7 +33,6 @@
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -43,9 +42,7 @@
* @author Louis Wasserman
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-class FilteredEntryMultimap<K extends @Nullable Object, V extends @Nullable Object>
- extends AbstractMultimap<K, V> implements FilteredMultimap<K, V> {
+class FilteredEntryMultimap<K, V> extends AbstractMultimap<K, V> implements FilteredMultimap<K, V> {
final Multimap<K, V> unfiltered;
final Predicate<? super Entry<K, V>> predicate;
@@ -69,24 +66,24 @@
return entries().size();
}
- private boolean satisfies(@ParametricNullness K key, @ParametricNullness V value) {
+ private boolean satisfies(K key, V value) {
return predicate.apply(Maps.immutableEntry(key, value));
}
final class ValuePredicate implements Predicate<V> {
- @ParametricNullness private final K key;
+ private final K key;
- ValuePredicate(@ParametricNullness K key) {
+ ValuePredicate(K key) {
this.key = key;
}
@Override
- public boolean apply(@ParametricNullness V value) {
+ public boolean apply(@Nullable V value) {
return satisfies(key, value);
}
}
- static <E extends @Nullable Object> Collection<E> filterCollection(
+ static <E> Collection<E> filterCollection(
Collection<E> collection, Predicate<? super E> predicate) {
if (collection instanceof Set) {
return Sets.filter((Set<E>) collection, predicate);
@@ -96,12 +93,12 @@
}
@Override
- public boolean containsKey(@CheckForNull Object key) {
+ public boolean containsKey(@Nullable Object key) {
return asMap().get(key) != null;
}
@Override
- public Collection<V> removeAll(@CheckForNull Object key) {
+ public Collection<V> removeAll(@Nullable Object key) {
return MoreObjects.firstNonNull(asMap().remove(key), unmodifiableEmptyCollection());
}
@@ -118,7 +115,7 @@
}
@Override
- public Collection<V> get(@ParametricNullness final K key) {
+ public Collection<V> get(final K key) {
return filterCollection(unfiltered.get(key), new ValuePredicate(key));
}
@@ -169,7 +166,7 @@
@WeakOuter
class AsMap extends ViewCachingAbstractMap<K, Collection<V>> {
@Override
- public boolean containsKey(@CheckForNull Object key) {
+ public boolean containsKey(@Nullable Object key) {
return get(key) != null;
}
@@ -179,8 +176,7 @@
}
@Override
- @CheckForNull
- public Collection<V> get(@CheckForNull Object key) {
+ public Collection<V> get(@Nullable Object key) {
Collection<V> result = unfiltered.asMap().get(key);
if (result == null) {
return null;
@@ -192,8 +188,7 @@
}
@Override
- @CheckForNull
- public Collection<V> remove(@CheckForNull Object key) {
+ public Collection<V> remove(@Nullable Object key) {
Collection<V> collection = unfiltered.asMap().get(key);
if (collection == null) {
return null;
@@ -237,7 +232,7 @@
}
@Override
- public boolean remove(@CheckForNull Object o) {
+ public boolean remove(@Nullable Object o) {
return AsMap.this.remove(o) != null;
}
}
@@ -260,7 +255,6 @@
unfiltered.asMap().entrySet().iterator();
@Override
- @CheckForNull
protected Entry<K, Collection<V>> computeNext() {
while (backingIterator.hasNext()) {
Entry<K, Collection<V>> entry = backingIterator.next();
@@ -303,7 +297,7 @@
}
@Override
- public boolean remove(@CheckForNull Object o) {
+ public boolean remove(@Nullable Object o) {
if (o instanceof Collection) {
Collection<?> c = (Collection<?>) o;
Iterator<Entry<K, Collection<V>>> entryIterator =
@@ -352,7 +346,7 @@
}
@Override
- public int remove(@CheckForNull 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/FilteredEntrySetMultimap.java b/guava/src/com/google/common/collect/FilteredEntrySetMultimap.java
index 20413f8..94740a4 100644
--- a/guava/src/com/google/common/collect/FilteredEntrySetMultimap.java
+++ b/guava/src/com/google/common/collect/FilteredEntrySetMultimap.java
@@ -20,8 +20,6 @@
import com.google.common.base.Predicate;
import java.util.Map.Entry;
import java.util.Set;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Implementation of {@link Multimaps#filterEntries(SetMultimap, Predicate)}.
@@ -29,9 +27,8 @@
* @author Louis Wasserman
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-final class FilteredEntrySetMultimap<K extends @Nullable Object, V extends @Nullable Object>
- extends FilteredEntryMultimap<K, V> implements FilteredSetMultimap<K, V> {
+final class FilteredEntrySetMultimap<K, V> extends FilteredEntryMultimap<K, V>
+ implements FilteredSetMultimap<K, V> {
FilteredEntrySetMultimap(SetMultimap<K, V> unfiltered, Predicate<? super Entry<K, V>> predicate) {
super(unfiltered, predicate);
@@ -43,17 +40,17 @@
}
@Override
- public Set<V> get(@ParametricNullness K key) {
+ public Set<V> get(K key) {
return (Set<V>) super.get(key);
}
@Override
- public Set<V> removeAll(@CheckForNull Object key) {
+ public Set<V> removeAll(Object key) {
return (Set<V>) super.removeAll(key);
}
@Override
- public Set<V> replaceValues(@ParametricNullness K key, Iterable<? extends V> values) {
+ public Set<V> replaceValues(K key, Iterable<? extends V> values) {
return (Set<V>) super.replaceValues(key, values);
}
diff --git a/guava/src/com/google/common/collect/FilteredKeyListMultimap.java b/guava/src/com/google/common/collect/FilteredKeyListMultimap.java
index c82c8da..8de9ed4 100644
--- a/guava/src/com/google/common/collect/FilteredKeyListMultimap.java
+++ b/guava/src/com/google/common/collect/FilteredKeyListMultimap.java
@@ -19,7 +19,6 @@
import com.google.common.annotations.GwtCompatible;
import com.google.common.base.Predicate;
import java.util.List;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -28,9 +27,8 @@
* @author Louis Wasserman
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-final class FilteredKeyListMultimap<K extends @Nullable Object, V extends @Nullable Object>
- extends FilteredKeyMultimap<K, V> implements ListMultimap<K, V> {
+final class FilteredKeyListMultimap<K, V> extends FilteredKeyMultimap<K, V>
+ implements ListMultimap<K, V> {
FilteredKeyListMultimap(ListMultimap<K, V> unfiltered, Predicate<? super K> keyPredicate) {
super(unfiltered, keyPredicate);
}
@@ -41,17 +39,17 @@
}
@Override
- public List<V> get(@ParametricNullness K key) {
+ public List<V> get(K key) {
return (List<V>) super.get(key);
}
@Override
- public List<V> removeAll(@CheckForNull Object key) {
+ public List<V> removeAll(@Nullable Object key) {
return (List<V>) super.removeAll(key);
}
@Override
- public List<V> replaceValues(@ParametricNullness K key, Iterable<? extends V> values) {
+ public List<V> replaceValues(K key, Iterable<? extends V> values) {
return (List<V>) super.replaceValues(key, values);
}
}
diff --git a/guava/src/com/google/common/collect/FilteredKeyMultimap.java b/guava/src/com/google/common/collect/FilteredKeyMultimap.java
index 68fad75..12456b3 100644
--- a/guava/src/com/google/common/collect/FilteredKeyMultimap.java
+++ b/guava/src/com/google/common/collect/FilteredKeyMultimap.java
@@ -16,8 +16,6 @@
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkPositionIndex;
-import static java.util.Collections.emptyList;
-import static java.util.Collections.emptySet;
import com.google.common.annotations.GwtCompatible;
import com.google.common.base.Predicate;
@@ -30,7 +28,6 @@
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -39,9 +36,7 @@
* @author Louis Wasserman
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-class FilteredKeyMultimap<K extends @Nullable Object, V extends @Nullable Object>
- extends AbstractMultimap<K, V> implements FilteredMultimap<K, V> {
+class FilteredKeyMultimap<K, V> extends AbstractMultimap<K, V> implements FilteredMultimap<K, V> {
final Multimap<K, V> unfiltered;
final Predicate<? super K> keyPredicate;
@@ -70,7 +65,7 @@
}
@Override
- public boolean containsKey(@CheckForNull 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;
@@ -80,15 +75,15 @@
}
@Override
- public Collection<V> removeAll(@CheckForNull Object key) {
+ public Collection<V> removeAll(Object key) {
return containsKey(key) ? unfiltered.removeAll(key) : unmodifiableEmptyCollection();
}
Collection<V> unmodifiableEmptyCollection() {
if (unfiltered instanceof SetMultimap) {
- return emptySet();
+ return ImmutableSet.of();
} else {
- return emptyList();
+ return ImmutableList.of();
}
}
@@ -103,7 +98,7 @@
}
@Override
- public Collection<V> get(@ParametricNullness K key) {
+ public Collection<V> get(K key) {
if (keyPredicate.apply(key)) {
return unfiltered.get(key);
} else if (unfiltered instanceof SetMultimap) {
@@ -113,16 +108,15 @@
}
}
- static class AddRejectingSet<K extends @Nullable Object, V extends @Nullable Object>
- extends ForwardingSet<V> {
- @ParametricNullness final K key;
+ static class AddRejectingSet<K, V> extends ForwardingSet<V> {
+ final K key;
- AddRejectingSet(@ParametricNullness K key) {
+ AddRejectingSet(K key) {
this.key = key;
}
@Override
- public boolean add(@ParametricNullness V element) {
+ public boolean add(V element) {
throw new IllegalArgumentException("Key does not satisfy predicate: " + key);
}
@@ -138,22 +132,21 @@
}
}
- static class AddRejectingList<K extends @Nullable Object, V extends @Nullable Object>
- extends ForwardingList<V> {
- @ParametricNullness final K key;
+ static class AddRejectingList<K, V> extends ForwardingList<V> {
+ final K key;
- AddRejectingList(@ParametricNullness K key) {
+ AddRejectingList(K key) {
this.key = key;
}
@Override
- public boolean add(@ParametricNullness V v) {
+ public boolean add(V v) {
add(0, v);
return true;
}
@Override
- public void add(int index, @ParametricNullness V element) {
+ public void add(int index, V element) {
checkPositionIndex(index, 0);
throw new IllegalArgumentException("Key does not satisfy predicate: " + key);
}
@@ -197,7 +190,7 @@
@Override
@SuppressWarnings("unchecked")
- public boolean remove(@CheckForNull 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 e492a5c..f6fb61d 100644
--- a/guava/src/com/google/common/collect/FilteredKeySetMultimap.java
+++ b/guava/src/com/google/common/collect/FilteredKeySetMultimap.java
@@ -20,7 +20,6 @@
import com.google.common.base.Predicate;
import java.util.Map.Entry;
import java.util.Set;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -29,9 +28,8 @@
* @author Louis Wasserman
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-final class FilteredKeySetMultimap<K extends @Nullable Object, V extends @Nullable Object>
- extends FilteredKeyMultimap<K, V> implements FilteredSetMultimap<K, V> {
+final class FilteredKeySetMultimap<K, V> extends FilteredKeyMultimap<K, V>
+ implements FilteredSetMultimap<K, V> {
FilteredKeySetMultimap(SetMultimap<K, V> unfiltered, Predicate<? super K> keyPredicate) {
super(unfiltered, keyPredicate);
@@ -43,17 +41,17 @@
}
@Override
- public Set<V> get(@ParametricNullness K key) {
+ public Set<V> get(K key) {
return (Set<V>) super.get(key);
}
@Override
- public Set<V> removeAll(@CheckForNull Object key) {
+ public Set<V> removeAll(Object key) {
return (Set<V>) super.removeAll(key);
}
@Override
- public Set<V> replaceValues(@ParametricNullness K key, Iterable<? extends V> values) {
+ public Set<V> replaceValues(K key, Iterable<? extends V> values) {
return (Set<V>) super.replaceValues(key, values);
}
@@ -74,7 +72,7 @@
}
@Override
- public boolean equals(@CheckForNull Object o) {
+ public boolean equals(@Nullable Object o) {
return Sets.equalsImpl(this, o);
}
}
diff --git a/guava/src/com/google/common/collect/FilteredMultimap.java b/guava/src/com/google/common/collect/FilteredMultimap.java
index 4e1fa06..ef5ed4a 100644
--- a/guava/src/com/google/common/collect/FilteredMultimap.java
+++ b/guava/src/com/google/common/collect/FilteredMultimap.java
@@ -19,7 +19,6 @@
import com.google.common.annotations.GwtCompatible;
import com.google.common.base.Predicate;
import java.util.Map.Entry;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* An interface for all filtered multimap types.
@@ -27,9 +26,7 @@
* @author Louis Wasserman
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-interface FilteredMultimap<K extends @Nullable Object, V extends @Nullable Object>
- extends Multimap<K, V> {
+interface FilteredMultimap<K, V> extends Multimap<K, V> {
Multimap<K, V> unfiltered();
Predicate<? super Entry<K, V>> entryPredicate();
diff --git a/guava/src/com/google/common/collect/FilteredMultimapValues.java b/guava/src/com/google/common/collect/FilteredMultimapValues.java
index ecbfab2..7e3d257 100644
--- a/guava/src/com/google/common/collect/FilteredMultimapValues.java
+++ b/guava/src/com/google/common/collect/FilteredMultimapValues.java
@@ -25,7 +25,6 @@
import java.util.Collection;
import java.util.Iterator;
import java.util.Map.Entry;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -34,9 +33,7 @@
* @author Louis Wasserman
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-final class FilteredMultimapValues<K extends @Nullable Object, V extends @Nullable Object>
- extends AbstractCollection<V> {
+final class FilteredMultimapValues<K, V> extends AbstractCollection<V> {
@Weak private final FilteredMultimap<K, V> multimap;
FilteredMultimapValues(FilteredMultimap<K, V> multimap) {
@@ -49,7 +46,7 @@
}
@Override
- public boolean contains(@CheckForNull Object o) {
+ public boolean contains(@Nullable Object o) {
return multimap.containsValue(o);
}
@@ -59,7 +56,7 @@
}
@Override
- public boolean remove(@CheckForNull Object o) {
+ public boolean remove(@Nullable Object o) {
Predicate<? super Entry<K, V>> entryPredicate = multimap.entryPredicate();
for (Iterator<Entry<K, V>> unfilteredItr = multimap.unfiltered().entries().iterator();
unfilteredItr.hasNext(); ) {
diff --git a/guava/src/com/google/common/collect/FilteredSetMultimap.java b/guava/src/com/google/common/collect/FilteredSetMultimap.java
index 8e2ff7c..a0a149f 100644
--- a/guava/src/com/google/common/collect/FilteredSetMultimap.java
+++ b/guava/src/com/google/common/collect/FilteredSetMultimap.java
@@ -17,7 +17,6 @@
package com.google.common.collect;
import com.google.common.annotations.GwtCompatible;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* A supertype for filtered {@link SetMultimap} implementations.
@@ -25,9 +24,7 @@
* @author Louis Wasserman
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-interface FilteredSetMultimap<K extends @Nullable Object, V extends @Nullable Object>
- extends FilteredMultimap<K, V>, SetMultimap<K, V> {
+interface FilteredSetMultimap<K, V> extends FilteredMultimap<K, V>, SetMultimap<K, V> {
@Override
SetMultimap<K, V> unfiltered();
}
diff --git a/guava/src/com/google/common/collect/FluentIterable.java b/guava/src/com/google/common/collect/FluentIterable.java
index 11bda3b..a15bcdd 100644
--- a/guava/src/com/google/common/collect/FluentIterable.java
+++ b/guava/src/com/google/common/collect/FluentIterable.java
@@ -24,16 +24,13 @@
import com.google.common.base.Optional;
import com.google.common.base.Predicate;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
-import com.google.errorprone.annotations.InlineMe;
import java.util.Arrays;
import java.util.Collection;
-import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
import java.util.SortedSet;
import java.util.stream.Stream;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -109,12 +106,11 @@
* @since 12.0
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
-public abstract class FluentIterable<E extends @Nullable Object> implements Iterable<E> {
+public abstract class FluentIterable<E> implements Iterable<E> {
// We store 'iterable' and use it instead of 'this' to allow Iterables to perform instanceof
// checks on the _original_ iterable when FluentIterable.from is used.
// To avoid a self retain cycle under j2objc, we store Optional.absent() instead of
- // Optional.of(this). To access the delegate iterable, call #getDelegate(), which converts to
+ // Optional.of(this). To access the iterator delegate, call #getDelegate(), which converts to
// absent() back to 'this'.
private final Optional<Iterable<E>> iterableDelegate;
@@ -124,7 +120,8 @@
}
FluentIterable(Iterable<E> iterable) {
- this.iterableDelegate = Optional.of(iterable);
+ checkNotNull(iterable);
+ this.iterableDelegate = Optional.fromNullable(this != iterable ? iterable : null);
}
private Iterable<E> getDelegate() {
@@ -138,7 +135,7 @@
* <p><b>{@code Stream} equivalent:</b> {@link Collection#stream} if {@code iterable} is a {@link
* Collection}; {@link Streams#stream(Iterable)} otherwise.
*/
- public static <E extends @Nullable Object> FluentIterable<E> from(final Iterable<E> iterable) {
+ public static <E> FluentIterable<E> from(final Iterable<E> iterable) {
return (iterable instanceof FluentIterable)
? (FluentIterable<E>) iterable
: new FluentIterable<E>(iterable) {
@@ -160,7 +157,7 @@
* @since 20.0 (since 18.0 as an overload of {@code of})
*/
@Beta
- public static <E extends @Nullable Object> FluentIterable<E> from(E[] elements) {
+ public static <E> FluentIterable<E> from(E[] elements) {
return from(Arrays.asList(elements));
}
@@ -173,10 +170,7 @@
* FluentIterable}
*/
@Deprecated
- @InlineMe(
- replacement = "checkNotNull(iterable)",
- staticImports = {"com.google.common.base.Preconditions.checkNotNull"})
- public static <E extends @Nullable Object> FluentIterable<E> from(FluentIterable<E> iterable) {
+ public static <E> FluentIterable<E> from(FluentIterable<E> iterable) {
return checkNotNull(iterable);
}
@@ -193,8 +187,7 @@
* @since 20.0
*/
@Beta
- public static <T extends @Nullable Object> FluentIterable<T> concat(
- Iterable<? extends T> a, Iterable<? extends T> b) {
+ public static <T> FluentIterable<T> concat(Iterable<? extends T> a, Iterable<? extends T> b) {
return concatNoDefensiveCopy(a, b);
}
@@ -212,7 +205,7 @@
* @since 20.0
*/
@Beta
- public static <T extends @Nullable Object> FluentIterable<T> concat(
+ public static <T> FluentIterable<T> concat(
Iterable<? extends T> a, Iterable<? extends T> b, Iterable<? extends T> c) {
return concatNoDefensiveCopy(a, b, c);
}
@@ -232,7 +225,7 @@
* @since 20.0
*/
@Beta
- public static <T extends @Nullable Object> FluentIterable<T> concat(
+ public static <T> FluentIterable<T> concat(
Iterable<? extends T> a,
Iterable<? extends T> b,
Iterable<? extends T> c,
@@ -256,8 +249,7 @@
* @since 20.0
*/
@Beta
- public static <T extends @Nullable Object> FluentIterable<T> concat(
- Iterable<? extends T>... inputs) {
+ public static <T> FluentIterable<T> concat(Iterable<? extends T>... inputs) {
return concatNoDefensiveCopy(Arrays.copyOf(inputs, inputs.length));
}
@@ -276,7 +268,7 @@
* @since 20.0
*/
@Beta
- public static <T extends @Nullable Object> FluentIterable<T> concat(
+ public static <T> FluentIterable<T> concat(
final Iterable<? extends Iterable<? extends T>> inputs) {
checkNotNull(inputs);
return new FluentIterable<T>() {
@@ -288,7 +280,7 @@
}
/** Concatenates a varargs array of iterables without making a defensive copy of the array. */
- private static <T extends @Nullable Object> FluentIterable<T> concatNoDefensiveCopy(
+ private static <T> FluentIterable<T> concatNoDefensiveCopy(
final Iterable<? extends T>... inputs) {
for (Iterable<? extends T> input : inputs) {
checkNotNull(input);
@@ -316,8 +308,8 @@
* @since 20.0
*/
@Beta
- public static <E extends @Nullable Object> FluentIterable<E> of() {
- return FluentIterable.from(Collections.<E>emptyList());
+ public static <E> FluentIterable<E> of() {
+ return FluentIterable.from(ImmutableList.<E>of());
}
/**
@@ -329,8 +321,7 @@
* @since 20.0
*/
@Beta
- public static <E extends @Nullable Object> FluentIterable<E> of(
- @ParametricNullness E element, E... elements) {
+ public static <E> FluentIterable<E> of(@Nullable E element, E... elements) {
return from(Lists.asList(element, elements));
}
@@ -361,7 +352,7 @@
*
* <p><b>{@code Stream} equivalent:</b> {@code stream.anyMatch(Predicate.isEqual(target))}.
*/
- public final boolean contains(@CheckForNull Object target) {
+ public final boolean contains(@Nullable Object target) {
return Iterables.contains(getDelegate(), target);
}
@@ -471,7 +462,6 @@
*
* <p><b>{@code Stream} equivalent:</b> {@code stream.filter(predicate).findFirst()}.
*/
- @SuppressWarnings("nullness") // Unsafe, but we can't do much about it now.
public final Optional<E> firstMatch(Predicate<? super E> predicate) {
return Iterables.tryFind(getDelegate(), predicate);
}
@@ -486,8 +476,7 @@
*
* <p><b>{@code Stream} equivalent:</b> {@link Stream#map}.
*/
- public final <T extends @Nullable Object> FluentIterable<T> transform(
- Function<? super E, T> function) {
+ public final <T> FluentIterable<T> transform(Function<? super E, T> function) {
return from(Iterables.transform(getDelegate(), function));
}
@@ -504,7 +493,7 @@
*
* @since 13.0 (required {@code Function<E, Iterable<T>>} until 14.0)
*/
- public <T extends @Nullable Object> FluentIterable<T> transformAndConcat(
+ public <T> FluentIterable<T> transformAndConcat(
Function<? super E, ? extends Iterable<? extends T>> function) {
return FluentIterable.concat(transform(function));
}
@@ -519,7 +508,6 @@
* @throws NullPointerException if the first element is null; if this is a possibility, use {@code
* iterator().next()} or {@link Iterables#getFirst} instead.
*/
- @SuppressWarnings("nullness") // Unsafe, but we can't do much about it now.
public final Optional<E> first() {
Iterator<E> iterator = getDelegate().iterator();
return iterator.hasNext() ? Optional.of(iterator.next()) : Optional.<E>absent();
@@ -536,7 +524,6 @@
* @throws NullPointerException if the last element is null; if this is a possibility, use {@link
* Iterables#getLast} instead.
*/
- @SuppressWarnings("nullness") // Unsafe, but we can't do much about it now.
public final Optional<E> last() {
// Iterables#getLast was inlined here so we don't have to throw/catch a NSEE
@@ -626,7 +613,6 @@
* @throws NullPointerException if any element is {@code null}
* @since 14.0 (since 12.0 as {@code toImmutableList()}).
*/
- @SuppressWarnings("nullness") // Unsafe, but we can't do much about it now.
public final ImmutableList<E> toList() {
return ImmutableList.copyOf(getDelegate());
}
@@ -643,7 +629,6 @@
* @throws NullPointerException if any element of this iterable is {@code null}
* @since 14.0 (since 13.0 as {@code toSortedImmutableList()}).
*/
- @SuppressWarnings("nullness") // Unsafe, but we can't do much about it now.
public final ImmutableList<E> toSortedList(Comparator<? super E> comparator) {
return Ordering.from(comparator).immutableSortedCopy(getDelegate());
}
@@ -658,7 +643,6 @@
* @throws NullPointerException if any element is {@code null}
* @since 14.0 (since 12.0 as {@code toImmutableSet()}).
*/
- @SuppressWarnings("nullness") // Unsafe, but we can't do much about it now.
public final ImmutableSet<E> toSet() {
return ImmutableSet.copyOf(getDelegate());
}
@@ -676,7 +660,6 @@
* @throws NullPointerException if any element of this iterable is {@code null}
* @since 14.0 (since 12.0 as {@code toImmutableSortedSet()}).
*/
- @SuppressWarnings("nullness") // Unsafe, but we can't do much about it now.
public final ImmutableSortedSet<E> toSortedSet(Comparator<? super E> comparator) {
return ImmutableSortedSet.copyOf(comparator, getDelegate());
}
@@ -690,7 +673,6 @@
* @throws NullPointerException if any element is null
* @since 19.0
*/
- @SuppressWarnings("nullness") // Unsafe, but we can't do much about it now.
public final ImmutableMultiset<E> toMultiset() {
return ImmutableMultiset.copyOf(getDelegate());
}
@@ -711,7 +693,6 @@
* valueFunction} produces {@code null} for any key
* @since 14.0
*/
- @SuppressWarnings("nullness") // Unsafe, but we can't do much about it now.
public final <V> ImmutableMap<E, V> toMap(Function<? super E, V> valueFunction) {
return Maps.toMap(getDelegate(), valueFunction);
}
@@ -734,7 +715,6 @@
* keyFunction} produces {@code null} for any key
* @since 14.0
*/
- @SuppressWarnings("nullness") // Unsafe, but we can't do much about it now.
public final <K> ImmutableListMultimap<K, E> index(Function<? super E, K> keyFunction) {
return Multimaps.index(getDelegate(), keyFunction);
}
@@ -769,7 +749,6 @@
* keyFunction} produces {@code null} for any key
* @since 14.0
*/
- @SuppressWarnings("nullness") // Unsafe, but we can't do much about it now.
public final <K> ImmutableMap<K, E> uniqueIndex(Function<? super E, K> keyFunction) {
return Maps.uniqueIndex(getDelegate(), keyFunction);
}
@@ -787,15 +766,7 @@
* copied
*/
@GwtIncompatible // Array.newArray(Class, int)
- /*
- * Both the declaration of our Class<E> parameter and its usage in a call to Iterables.toArray
- * produce a nullness error: E may be a nullable type, and our nullness checker has Class's type
- * parameter bounded to non-null types. To avoid that, we'd use Class<@Nonnull E> if we could.
- * (Granted, this is only one of many nullness-checking problems that arise from letting
- * FluentIterable support null elements, and most of the other produce outright unsoundness.)
- */
- @SuppressWarnings("nullness")
- public final @Nullable E[] toArray(Class<E> type) {
+ public final E[] toArray(Class<E> type) {
return Iterables.toArray(getDelegate(), type);
}
@@ -851,7 +822,7 @@
* @throws IndexOutOfBoundsException if {@code position} is negative or greater than or equal to
* the size of this fluent iterable
*/
- @ParametricNullness
+ // TODO(kevinb): add @Nullable?
public final E get(int position) {
return Iterables.get(getDelegate(), position);
}
@@ -871,8 +842,7 @@
}
/** Function that transforms {@code Iterable<E>} into a fluent iterable. */
- private static class FromIterableFunction<E extends @Nullable Object>
- implements Function<Iterable<E>, FluentIterable<E>> {
+ private static class FromIterableFunction<E> implements Function<Iterable<E>, FluentIterable<E>> {
@Override
public FluentIterable<E> apply(Iterable<E> fromObject) {
return FluentIterable.from(fromObject);
diff --git a/guava/src/com/google/common/collect/ForwardingBlockingDeque.java b/guava/src/com/google/common/collect/ForwardingBlockingDeque.java
index 49d4bcf..7d3895d 100644
--- a/guava/src/com/google/common/collect/ForwardingBlockingDeque.java
+++ b/guava/src/com/google/common/collect/ForwardingBlockingDeque.java
@@ -20,7 +20,6 @@
import java.util.Collection;
import java.util.concurrent.BlockingDeque;
import java.util.concurrent.TimeUnit;
-import javax.annotation.CheckForNull;
/**
* A {@link BlockingDeque} which forwards all its method calls to another {@code BlockingDeque}.
@@ -47,7 +46,6 @@
*/
@Deprecated
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public abstract class ForwardingBlockingDeque<E> extends ForwardingDeque<E>
implements BlockingDeque<E> {
@@ -93,13 +91,11 @@
}
@Override
- @CheckForNull
public E pollFirst(long timeout, TimeUnit unit) throws InterruptedException {
return delegate().pollFirst(timeout, unit);
}
@Override
- @CheckForNull
public E pollLast(long timeout, TimeUnit unit) throws InterruptedException {
return delegate().pollLast(timeout, unit);
}
@@ -120,7 +116,6 @@
}
@Override
- @CheckForNull
public E poll(long timeout, TimeUnit unit) throws InterruptedException {
return delegate().poll(timeout, unit);
}
diff --git a/guava/src/com/google/common/collect/ForwardingCollection.java b/guava/src/com/google/common/collect/ForwardingCollection.java
index ca1edc1..66219c8 100644
--- a/guava/src/com/google/common/collect/ForwardingCollection.java
+++ b/guava/src/com/google/common/collect/ForwardingCollection.java
@@ -21,7 +21,6 @@
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import java.util.Collection;
import java.util.Iterator;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -47,9 +46,7 @@
* @since 2.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-public abstract class ForwardingCollection<E extends @Nullable Object> extends ForwardingObject
- implements Collection<E> {
+public abstract class ForwardingCollection<E> extends ForwardingObject implements Collection<E> {
// TODO(lowasser): identify places where thread safety is actually lost
/** Constructor for use by subclasses. */
@@ -80,19 +77,19 @@
}
@Override
- public boolean contains(@CheckForNull Object object) {
+ public boolean contains(Object object) {
return delegate().contains(object);
}
@CanIgnoreReturnValue
@Override
- public boolean add(@ParametricNullness E element) {
+ public boolean add(E element) {
return delegate().add(element);
}
@CanIgnoreReturnValue
@Override
- public boolean remove(@CheckForNull Object object) {
+ public boolean remove(Object object) {
return delegate().remove(object);
}
@@ -119,14 +116,13 @@
}
@Override
- public @Nullable Object[] toArray() {
+ public Object[] toArray() {
return delegate().toArray();
}
@CanIgnoreReturnValue
@Override
- @SuppressWarnings("nullness") // b/192354773 in our checker affects toArray declarations
- public <T extends @Nullable Object> T[] toArray(T[] array) {
+ public <T> T[] toArray(T[] array) {
return delegate().toArray(array);
}
@@ -137,7 +133,7 @@
*
* @since 7.0
*/
- protected boolean standardContains(@CheckForNull Object object) {
+ protected boolean standardContains(@Nullable Object object) {
return Iterators.contains(iterator(), object);
}
@@ -169,7 +165,7 @@
*
* @since 7.0
*/
- protected boolean standardRemove(@CheckForNull Object object) {
+ protected boolean standardRemove(@Nullable Object object) {
Iterator<E> iterator = iterator();
while (iterator.hasNext()) {
if (Objects.equal(iterator.next(), object)) {
@@ -242,8 +238,8 @@
*
* @since 7.0
*/
- protected @Nullable Object[] standardToArray() {
- @Nullable Object[] newArray = new @Nullable Object[size()];
+ protected Object[] standardToArray() {
+ Object[] newArray = new Object[size()];
return toArray(newArray);
}
@@ -254,7 +250,7 @@
*
* @since 7.0
*/
- protected <T extends @Nullable Object> T[] standardToArray(T[] array) {
+ protected <T> T[] standardToArray(T[] array) {
return ObjectArrays.toArrayImpl(this, array);
}
}
diff --git a/guava/src/com/google/common/collect/ForwardingConcurrentMap.java b/guava/src/com/google/common/collect/ForwardingConcurrentMap.java
index b662b07..0910424 100644
--- a/guava/src/com/google/common/collect/ForwardingConcurrentMap.java
+++ b/guava/src/com/google/common/collect/ForwardingConcurrentMap.java
@@ -19,7 +19,6 @@
import com.google.common.annotations.GwtCompatible;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import java.util.concurrent.ConcurrentMap;
-import javax.annotation.CheckForNull;
/**
* A concurrent map which forwards all its method calls to another concurrent map. Subclasses should
@@ -37,7 +36,6 @@
* @since 2.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
public abstract class ForwardingConcurrentMap<K, V> extends ForwardingMap<K, V>
implements ConcurrentMap<K, V> {
@@ -49,20 +47,18 @@
@CanIgnoreReturnValue
@Override
- @CheckForNull
public V putIfAbsent(K key, V value) {
return delegate().putIfAbsent(key, value);
}
@CanIgnoreReturnValue
@Override
- public boolean remove(@CheckForNull Object key, @CheckForNull Object value) {
+ public boolean remove(Object key, Object value) {
return delegate().remove(key, value);
}
@CanIgnoreReturnValue
@Override
- @CheckForNull
public V replace(K key, V value) {
return delegate().replace(key, value);
}
diff --git a/guava/src/com/google/common/collect/ForwardingDeque.java b/guava/src/com/google/common/collect/ForwardingDeque.java
index 571535c..87ac71b 100644
--- a/guava/src/com/google/common/collect/ForwardingDeque.java
+++ b/guava/src/com/google/common/collect/ForwardingDeque.java
@@ -20,8 +20,6 @@
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import java.util.Deque;
import java.util.Iterator;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* A deque which forwards all its method calls to another deque. Subclasses should override one or
@@ -41,9 +39,7 @@
* @since 12.0
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
-public abstract class ForwardingDeque<E extends @Nullable Object> extends ForwardingQueue<E>
- implements Deque<E> {
+public abstract class ForwardingDeque<E> extends ForwardingQueue<E> implements Deque<E> {
/** Constructor for use by subclasses. */
protected ForwardingDeque() {}
@@ -52,12 +48,12 @@
protected abstract Deque<E> delegate();
@Override
- public void addFirst(@ParametricNullness E e) {
+ public void addFirst(E e) {
delegate().addFirst(e);
}
@Override
- public void addLast(@ParametricNullness E e) {
+ public void addLast(E e) {
delegate().addLast(e);
}
@@ -67,90 +63,81 @@
}
@Override
- @ParametricNullness
public E getFirst() {
return delegate().getFirst();
}
@Override
- @ParametricNullness
public E getLast() {
return delegate().getLast();
}
@CanIgnoreReturnValue // TODO(cpovirk): Consider removing this?
@Override
- public boolean offerFirst(@ParametricNullness E e) {
+ public boolean offerFirst(E e) {
return delegate().offerFirst(e);
}
@CanIgnoreReturnValue // TODO(cpovirk): Consider removing this?
@Override
- public boolean offerLast(@ParametricNullness E e) {
+ public boolean offerLast(E e) {
return delegate().offerLast(e);
}
@Override
- @CheckForNull
public E peekFirst() {
return delegate().peekFirst();
}
@Override
- @CheckForNull
public E peekLast() {
return delegate().peekLast();
}
@CanIgnoreReturnValue // TODO(cpovirk): Consider removing this?
@Override
- @CheckForNull
public E pollFirst() {
return delegate().pollFirst();
}
@CanIgnoreReturnValue // TODO(cpovirk): Consider removing this?
@Override
- @CheckForNull
public E pollLast() {
return delegate().pollLast();
}
@CanIgnoreReturnValue
@Override
- @ParametricNullness
public E pop() {
return delegate().pop();
}
@Override
- public void push(@ParametricNullness E e) {
+ public void push(E e) {
delegate().push(e);
}
@CanIgnoreReturnValue
@Override
- @ParametricNullness
public E removeFirst() {
return delegate().removeFirst();
}
@CanIgnoreReturnValue
@Override
- @ParametricNullness
public E removeLast() {
return delegate().removeLast();
}
@CanIgnoreReturnValue
@Override
- public boolean removeFirstOccurrence(@CheckForNull Object o) {
+ public boolean removeFirstOccurrence(Object o) {
return delegate().removeFirstOccurrence(o);
}
@CanIgnoreReturnValue
@Override
- public boolean removeLastOccurrence(@CheckForNull Object o) {
+ public boolean removeLastOccurrence(Object o) {
return delegate().removeLastOccurrence(o);
}
}
diff --git a/guava/src/com/google/common/collect/ForwardingImmutableCollection.java b/guava/src/com/google/common/collect/ForwardingImmutableCollection.java
index 043fe58..c0b9c5e 100644
--- a/guava/src/com/google/common/collect/ForwardingImmutableCollection.java
+++ b/guava/src/com/google/common/collect/ForwardingImmutableCollection.java
@@ -24,7 +24,6 @@
* @author Hayward Chan
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
class ForwardingImmutableCollection {
private ForwardingImmutableCollection() {}
}
diff --git a/guava/src/com/google/common/collect/ForwardingImmutableList.java b/guava/src/com/google/common/collect/ForwardingImmutableList.java
index bd5480d..2b9092e 100644
--- a/guava/src/com/google/common/collect/ForwardingImmutableList.java
+++ b/guava/src/com/google/common/collect/ForwardingImmutableList.java
@@ -24,7 +24,6 @@
* @author Chris Povirk
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
abstract class ForwardingImmutableList<E> {
private ForwardingImmutableList() {}
}
diff --git a/guava/src/com/google/common/collect/ForwardingImmutableMap.java b/guava/src/com/google/common/collect/ForwardingImmutableMap.java
index 22cc9ff..a367157 100644
--- a/guava/src/com/google/common/collect/ForwardingImmutableMap.java
+++ b/guava/src/com/google/common/collect/ForwardingImmutableMap.java
@@ -24,7 +24,6 @@
* @author Chris Povirk
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
abstract class ForwardingImmutableMap<K, V> {
private ForwardingImmutableMap() {}
}
diff --git a/guava/src/com/google/common/collect/ForwardingImmutableSet.java b/guava/src/com/google/common/collect/ForwardingImmutableSet.java
index 047d5fd..c7d7bf6 100644
--- a/guava/src/com/google/common/collect/ForwardingImmutableSet.java
+++ b/guava/src/com/google/common/collect/ForwardingImmutableSet.java
@@ -24,7 +24,6 @@
* @author Chris Povirk
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
abstract class ForwardingImmutableSet<E> {
private ForwardingImmutableSet() {}
}
diff --git a/guava/src/com/google/common/collect/ForwardingIterator.java b/guava/src/com/google/common/collect/ForwardingIterator.java
index 1f5a8f1..5ecd3d2 100644
--- a/guava/src/com/google/common/collect/ForwardingIterator.java
+++ b/guava/src/com/google/common/collect/ForwardingIterator.java
@@ -19,7 +19,6 @@
import com.google.common.annotations.GwtCompatible;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import java.util.Iterator;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* An iterator which forwards all its method calls to another iterator. Subclasses should override
@@ -37,9 +36,7 @@
* @since 2.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-public abstract class ForwardingIterator<T extends @Nullable Object> extends ForwardingObject
- implements Iterator<T> {
+public abstract class ForwardingIterator<T> extends ForwardingObject implements Iterator<T> {
/** Constructor for use by subclasses. */
protected ForwardingIterator() {}
@@ -54,7 +51,6 @@
@CanIgnoreReturnValue
@Override
- @ParametricNullness
public T next() {
return delegate().next();
}
diff --git a/guava/src/com/google/common/collect/ForwardingList.java b/guava/src/com/google/common/collect/ForwardingList.java
index 4b4551e..d2ba154 100644
--- a/guava/src/com/google/common/collect/ForwardingList.java
+++ b/guava/src/com/google/common/collect/ForwardingList.java
@@ -23,7 +23,6 @@
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -52,9 +51,7 @@
* @since 2.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-public abstract class ForwardingList<E extends @Nullable Object> extends ForwardingCollection<E>
- implements List<E> {
+public abstract class ForwardingList<E> extends ForwardingCollection<E> implements List<E> {
// TODO(lowasser): identify places where thread safety is actually lost
/** Constructor for use by subclasses. */
@@ -64,7 +61,7 @@
protected abstract List<E> delegate();
@Override
- public void add(int index, @ParametricNullness E element) {
+ public void add(int index, E element) {
delegate().add(index, element);
}
@@ -75,18 +72,17 @@
}
@Override
- @ParametricNullness
public E get(int index) {
return delegate().get(index);
}
@Override
- public int indexOf(@CheckForNull Object element) {
+ public int indexOf(Object element) {
return delegate().indexOf(element);
}
@Override
- public int lastIndexOf(@CheckForNull Object element) {
+ public int lastIndexOf(Object element) {
return delegate().lastIndexOf(element);
}
@@ -102,15 +98,13 @@
@CanIgnoreReturnValue
@Override
- @ParametricNullness
public E remove(int index) {
return delegate().remove(index);
}
@CanIgnoreReturnValue
@Override
- @ParametricNullness
- public E set(int index, @ParametricNullness E element) {
+ public E set(int index, E element) {
return delegate().set(index, element);
}
@@ -120,7 +114,7 @@
}
@Override
- public boolean equals(@CheckForNull Object object) {
+ public boolean equals(@Nullable Object object) {
return object == this || delegate().equals(object);
}
@@ -136,7 +130,7 @@
*
* @since 7.0
*/
- protected boolean standardAdd(@ParametricNullness E element) {
+ protected boolean standardAdd(E element) {
add(size(), element);
return true;
}
@@ -159,7 +153,7 @@
*
* @since 7.0
*/
- protected int standardIndexOf(@CheckForNull Object element) {
+ protected int standardIndexOf(@Nullable Object element) {
return Lists.indexOfImpl(this, element);
}
@@ -170,7 +164,7 @@
*
* @since 7.0
*/
- protected int standardLastIndexOf(@CheckForNull Object element) {
+ protected int standardLastIndexOf(@Nullable Object element) {
return Lists.lastIndexOfImpl(this, element);
}
@@ -228,7 +222,7 @@
* @since 7.0
*/
@Beta
- protected boolean standardEquals(@CheckForNull Object object) {
+ protected boolean standardEquals(@Nullable Object object) {
return Lists.equalsImpl(this, object);
}
diff --git a/guava/src/com/google/common/collect/ForwardingListIterator.java b/guava/src/com/google/common/collect/ForwardingListIterator.java
index a2ac32b..bc2a5ad 100644
--- a/guava/src/com/google/common/collect/ForwardingListIterator.java
+++ b/guava/src/com/google/common/collect/ForwardingListIterator.java
@@ -19,7 +19,6 @@
import com.google.common.annotations.GwtCompatible;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import java.util.ListIterator;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* A list iterator which forwards all its method calls to another list iterator. Subclasses should
@@ -37,9 +36,8 @@
* @since 2.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-public abstract class ForwardingListIterator<E extends @Nullable Object>
- extends ForwardingIterator<E> implements ListIterator<E> {
+public abstract class ForwardingListIterator<E> extends ForwardingIterator<E>
+ implements ListIterator<E> {
/** Constructor for use by subclasses. */
protected ForwardingListIterator() {}
@@ -48,7 +46,7 @@
protected abstract ListIterator<E> delegate();
@Override
- public void add(@ParametricNullness E element) {
+ public void add(E element) {
delegate().add(element);
}
@@ -64,7 +62,6 @@
@CanIgnoreReturnValue
@Override
- @ParametricNullness
public E previous() {
return delegate().previous();
}
@@ -75,7 +72,7 @@
}
@Override
- public void set(@ParametricNullness E element) {
+ public void set(E element) {
delegate().set(element);
}
}
diff --git a/guava/src/com/google/common/collect/ForwardingListMultimap.java b/guava/src/com/google/common/collect/ForwardingListMultimap.java
index 11779c0..c67d56c 100644
--- a/guava/src/com/google/common/collect/ForwardingListMultimap.java
+++ b/guava/src/com/google/common/collect/ForwardingListMultimap.java
@@ -19,7 +19,6 @@
import com.google.common.annotations.GwtCompatible;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import java.util.List;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -35,9 +34,8 @@
* @since 3.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-public abstract class ForwardingListMultimap<K extends @Nullable Object, V extends @Nullable Object>
- extends ForwardingMultimap<K, V> implements ListMultimap<K, V> {
+public abstract class ForwardingListMultimap<K, V> extends ForwardingMultimap<K, V>
+ implements ListMultimap<K, V> {
/** Constructor for use by subclasses. */
protected ForwardingListMultimap() {}
@@ -46,19 +44,19 @@
protected abstract ListMultimap<K, V> delegate();
@Override
- public List<V> get(@ParametricNullness K key) {
+ public List<V> get(@Nullable K key) {
return delegate().get(key);
}
@CanIgnoreReturnValue
@Override
- public List<V> removeAll(@CheckForNull Object key) {
+ public List<V> removeAll(@Nullable Object key) {
return delegate().removeAll(key);
}
@CanIgnoreReturnValue
@Override
- public List<V> replaceValues(@ParametricNullness K key, Iterable<? extends V> values) {
+ public List<V> replaceValues(K key, Iterable<? extends V> values) {
return delegate().replaceValues(key, values);
}
}
diff --git a/guava/src/com/google/common/collect/ForwardingMap.java b/guava/src/com/google/common/collect/ForwardingMap.java
index 315a4fa..3a6aa52 100644
--- a/guava/src/com/google/common/collect/ForwardingMap.java
+++ b/guava/src/com/google/common/collect/ForwardingMap.java
@@ -24,7 +24,6 @@
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -56,9 +55,7 @@
* @since 2.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-public abstract class ForwardingMap<K extends @Nullable Object, V extends @Nullable Object>
- extends ForwardingObject implements Map<K, V> {
+public abstract class ForwardingMap<K, V> extends ForwardingObject implements Map<K, V> {
// TODO(lowasser): identify places where thread safety is actually lost
/** Constructor for use by subclasses. */
@@ -79,8 +76,7 @@
@CanIgnoreReturnValue
@Override
- @CheckForNull
- public V remove(@CheckForNull Object key) {
+ public V remove(Object key) {
return delegate().remove(key);
}
@@ -90,25 +86,23 @@
}
@Override
- public boolean containsKey(@CheckForNull Object key) {
+ public boolean containsKey(@Nullable Object key) {
return delegate().containsKey(key);
}
@Override
- public boolean containsValue(@CheckForNull Object value) {
+ public boolean containsValue(@Nullable Object value) {
return delegate().containsValue(value);
}
@Override
- @CheckForNull
- public V get(@CheckForNull Object key) {
+ public V get(@Nullable Object key) {
return delegate().get(key);
}
@CanIgnoreReturnValue
@Override
- @CheckForNull
- public V put(@ParametricNullness K key, @ParametricNullness V value) {
+ public V put(K key, V value) {
return delegate().put(key, value);
}
@@ -133,7 +127,7 @@
}
@Override
- public boolean equals(@CheckForNull Object object) {
+ public boolean equals(@Nullable Object object) {
return object == this || delegate().equals(object);
}
@@ -164,8 +158,7 @@
* @since 7.0
*/
@Beta
- @CheckForNull
- protected V standardRemove(@CheckForNull Object key) {
+ protected V standardRemove(@Nullable Object key) {
Iterator<Entry<K, V>> entryIterator = entrySet().iterator();
while (entryIterator.hasNext()) {
Entry<K, V> entry = entryIterator.next();
@@ -214,7 +207,7 @@
* @since 7.0
*/
@Beta
- protected boolean standardContainsKey(@CheckForNull Object key) {
+ protected boolean standardContainsKey(@Nullable Object key) {
return Maps.containsKeyImpl(this, key);
}
@@ -242,7 +235,7 @@
*
* @since 7.0
*/
- protected boolean standardContainsValue(@CheckForNull Object value) {
+ protected boolean standardContainsValue(@Nullable Object value) {
return Maps.containsValueImpl(this, value);
}
@@ -284,7 +277,7 @@
*
* @since 7.0
*/
- protected boolean standardEquals(@CheckForNull 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 6816ccb..c775986 100644
--- a/guava/src/com/google/common/collect/ForwardingMapEntry.java
+++ b/guava/src/com/google/common/collect/ForwardingMapEntry.java
@@ -21,7 +21,6 @@
import com.google.common.base.Objects;
import java.util.Map;
import java.util.Map.Entry;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -48,9 +47,7 @@
* @since 2.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-public abstract class ForwardingMapEntry<K extends @Nullable Object, V extends @Nullable Object>
- extends ForwardingObject implements Map.Entry<K, V> {
+public abstract class ForwardingMapEntry<K, V> extends ForwardingObject implements Map.Entry<K, V> {
// TODO(lowasser): identify places where thread safety is actually lost
/** Constructor for use by subclasses. */
@@ -60,25 +57,22 @@
protected abstract Entry<K, V> delegate();
@Override
- @ParametricNullness
public K getKey() {
return delegate().getKey();
}
@Override
- @ParametricNullness
public V getValue() {
return delegate().getValue();
}
@Override
- @ParametricNullness
- public V setValue(@ParametricNullness V value) {
+ public V setValue(V value) {
return delegate().setValue(value);
}
@Override
- public boolean equals(@CheckForNull Object object) {
+ public boolean equals(@Nullable Object object) {
return delegate().equals(object);
}
@@ -94,7 +88,7 @@
*
* @since 7.0
*/
- protected boolean standardEquals(@CheckForNull 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 a3db061..bc6d902 100644
--- a/guava/src/com/google/common/collect/ForwardingMultimap.java
+++ b/guava/src/com/google/common/collect/ForwardingMultimap.java
@@ -22,7 +22,6 @@
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -38,9 +37,7 @@
* @since 2.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-public abstract class ForwardingMultimap<K extends @Nullable Object, V extends @Nullable Object>
- extends ForwardingObject implements Multimap<K, V> {
+public abstract class ForwardingMultimap<K, V> extends ForwardingObject implements Multimap<K, V> {
/** Constructor for use by subclasses. */
protected ForwardingMultimap() {}
@@ -59,17 +56,17 @@
}
@Override
- public boolean containsEntry(@CheckForNull Object key, @CheckForNull Object value) {
+ public boolean containsEntry(@Nullable Object key, @Nullable Object value) {
return delegate().containsEntry(key, value);
}
@Override
- public boolean containsKey(@CheckForNull Object key) {
+ public boolean containsKey(@Nullable Object key) {
return delegate().containsKey(key);
}
@Override
- public boolean containsValue(@CheckForNull Object value) {
+ public boolean containsValue(@Nullable Object value) {
return delegate().containsValue(value);
}
@@ -79,7 +76,7 @@
}
@Override
- public Collection<V> get(@ParametricNullness K key) {
+ public Collection<V> get(@Nullable K key) {
return delegate().get(key);
}
@@ -100,13 +97,13 @@
@CanIgnoreReturnValue
@Override
- public boolean put(@ParametricNullness K key, @ParametricNullness V value) {
+ public boolean put(K key, V value) {
return delegate().put(key, value);
}
@CanIgnoreReturnValue
@Override
- public boolean putAll(@ParametricNullness K key, Iterable<? extends V> values) {
+ public boolean putAll(K key, Iterable<? extends V> values) {
return delegate().putAll(key, values);
}
@@ -118,19 +115,19 @@
@CanIgnoreReturnValue
@Override
- public boolean remove(@CheckForNull Object key, @CheckForNull Object value) {
+ public boolean remove(@Nullable Object key, @Nullable Object value) {
return delegate().remove(key, value);
}
@CanIgnoreReturnValue
@Override
- public Collection<V> removeAll(@CheckForNull Object key) {
+ public Collection<V> removeAll(@Nullable Object key) {
return delegate().removeAll(key);
}
@CanIgnoreReturnValue
@Override
- public Collection<V> replaceValues(@ParametricNullness K key, Iterable<? extends V> values) {
+ public Collection<V> replaceValues(K key, Iterable<? extends V> values) {
return delegate().replaceValues(key, values);
}
@@ -145,7 +142,7 @@
}
@Override
- public boolean equals(@CheckForNull 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 857b9ae..6bf5c33 100644
--- a/guava/src/com/google/common/collect/ForwardingMultiset.java
+++ b/guava/src/com/google/common/collect/ForwardingMultiset.java
@@ -23,7 +23,6 @@
import java.util.Collection;
import java.util.Iterator;
import java.util.Set;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -49,9 +48,7 @@
* @since 2.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-public abstract class ForwardingMultiset<E extends @Nullable Object> extends ForwardingCollection<E>
- implements Multiset<E> {
+public abstract class ForwardingMultiset<E> extends ForwardingCollection<E> implements Multiset<E> {
/** Constructor for use by subclasses. */
protected ForwardingMultiset() {}
@@ -60,19 +57,19 @@
protected abstract Multiset<E> delegate();
@Override
- public int count(@CheckForNull Object element) {
+ public int count(Object element) {
return delegate().count(element);
}
@CanIgnoreReturnValue
@Override
- public int add(@ParametricNullness E element, int occurrences) {
+ public int add(E element, int occurrences) {
return delegate().add(element, occurrences);
}
@CanIgnoreReturnValue
@Override
- public int remove(@CheckForNull Object element, int occurrences) {
+ public int remove(Object element, int occurrences) {
return delegate().remove(element, occurrences);
}
@@ -87,7 +84,7 @@
}
@Override
- public boolean equals(@CheckForNull Object object) {
+ public boolean equals(@Nullable Object object) {
return object == this || delegate().equals(object);
}
@@ -98,13 +95,13 @@
@CanIgnoreReturnValue
@Override
- public int setCount(@ParametricNullness E element, int count) {
+ public int setCount(E element, int count) {
return delegate().setCount(element, count);
}
@CanIgnoreReturnValue
@Override
- public boolean setCount(@ParametricNullness E element, int oldCount, int newCount) {
+ public boolean setCount(E element, int oldCount, int newCount) {
return delegate().setCount(element, oldCount, newCount);
}
@@ -115,7 +112,7 @@
* @since 7.0
*/
@Override
- protected boolean standardContains(@CheckForNull Object object) {
+ protected boolean standardContains(@Nullable Object object) {
return count(object) > 0;
}
@@ -139,7 +136,7 @@
* @since 7.0
*/
@Beta
- protected int standardCount(@CheckForNull Object object) {
+ protected int standardCount(@Nullable Object object) {
for (Entry<?> entry : this.entrySet()) {
if (Objects.equal(entry.getElement(), object)) {
return entry.getCount();
@@ -155,7 +152,7 @@
*
* @since 7.0
*/
- protected boolean standardAdd(@ParametricNullness E element) {
+ protected boolean standardAdd(E element) {
add(element, 1);
return true;
}
@@ -181,7 +178,7 @@
* @since 7.0
*/
@Override
- protected boolean standardRemove(@CheckForNull Object element) {
+ protected boolean standardRemove(Object element) {
return remove(element, 1) > 0;
}
@@ -217,7 +214,7 @@
*
* @since 7.0
*/
- protected int standardSetCount(@ParametricNullness E element, int count) {
+ protected int standardSetCount(E element, int count) {
return Multisets.setCountImpl(this, element, count);
}
@@ -228,7 +225,7 @@
*
* @since 7.0
*/
- protected boolean standardSetCount(@ParametricNullness E element, int oldCount, int newCount) {
+ protected boolean standardSetCount(E element, int oldCount, int newCount) {
return Multisets.setCountImpl(this, element, oldCount, newCount);
}
@@ -288,7 +285,7 @@
*
* @since 7.0
*/
- protected boolean standardEquals(@CheckForNull Object object) {
+ protected boolean standardEquals(@Nullable Object object) {
return Multisets.equalsImpl(this, object);
}
diff --git a/guava/src/com/google/common/collect/ForwardingNavigableMap.java b/guava/src/com/google/common/collect/ForwardingNavigableMap.java
index c32468d..5f23d05 100644
--- a/guava/src/com/google/common/collect/ForwardingNavigableMap.java
+++ b/guava/src/com/google/common/collect/ForwardingNavigableMap.java
@@ -16,6 +16,7 @@
package com.google.common.collect;
+import static com.google.common.collect.CollectPreconditions.checkRemove;
import static com.google.common.collect.Maps.keyOrNull;
import com.google.common.annotations.Beta;
@@ -26,8 +27,6 @@
import java.util.NoSuchElementException;
import java.util.SortedMap;
import java.util.function.BiFunction;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* A navigable map which forwards all its method calls to another navigable map. Subclasses should
@@ -56,9 +55,8 @@
* @since 12.0
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
-public abstract class ForwardingNavigableMap<K extends @Nullable Object, V extends @Nullable Object>
- extends ForwardingSortedMap<K, V> implements NavigableMap<K, V> {
+public abstract class ForwardingNavigableMap<K, V> extends ForwardingSortedMap<K, V>
+ implements NavigableMap<K, V> {
/** Constructor for use by subclasses. */
protected ForwardingNavigableMap() {}
@@ -67,8 +65,7 @@
protected abstract NavigableMap<K, V> delegate();
@Override
- @CheckForNull
- public Entry<K, V> lowerEntry(@ParametricNullness K key) {
+ public Entry<K, V> lowerEntry(K key) {
return delegate().lowerEntry(key);
}
@@ -77,14 +74,12 @@
* #headMap(Object, boolean)}. If you override {@code headMap}, you may wish to override {@code
* lowerEntry} to forward to this implementation.
*/
- @CheckForNull
- protected Entry<K, V> standardLowerEntry(@ParametricNullness K key) {
+ protected Entry<K, V> standardLowerEntry(K key) {
return headMap(key, false).lastEntry();
}
@Override
- @CheckForNull
- public K lowerKey(@ParametricNullness K key) {
+ public K lowerKey(K key) {
return delegate().lowerKey(key);
}
@@ -93,14 +88,12 @@
* {@link #lowerEntry}, you may wish to override {@code lowerKey} to forward to this
* implementation.
*/
- @CheckForNull
- protected K standardLowerKey(@ParametricNullness K key) {
+ protected K standardLowerKey(K key) {
return keyOrNull(lowerEntry(key));
}
@Override
- @CheckForNull
- public Entry<K, V> floorEntry(@ParametricNullness K key) {
+ public Entry<K, V> floorEntry(K key) {
return delegate().floorEntry(key);
}
@@ -109,14 +102,12 @@
* #headMap(Object, boolean)}. If you override {@code headMap}, you may wish to override {@code
* floorEntry} to forward to this implementation.
*/
- @CheckForNull
- protected Entry<K, V> standardFloorEntry(@ParametricNullness K key) {
+ protected Entry<K, V> standardFloorEntry(K key) {
return headMap(key, true).lastEntry();
}
@Override
- @CheckForNull
- public K floorKey(@ParametricNullness K key) {
+ public K floorKey(K key) {
return delegate().floorKey(key);
}
@@ -125,14 +116,12 @@
* {@code floorEntry}, you may wish to override {@code floorKey} to forward to this
* implementation.
*/
- @CheckForNull
- protected K standardFloorKey(@ParametricNullness K key) {
+ protected K standardFloorKey(K key) {
return keyOrNull(floorEntry(key));
}
@Override
- @CheckForNull
- public Entry<K, V> ceilingEntry(@ParametricNullness K key) {
+ public Entry<K, V> ceilingEntry(K key) {
return delegate().ceilingEntry(key);
}
@@ -141,14 +130,12 @@
* #tailMap(Object, boolean)}. If you override {@code tailMap}, you may wish to override {@code
* ceilingEntry} to forward to this implementation.
*/
- @CheckForNull
- protected Entry<K, V> standardCeilingEntry(@ParametricNullness K key) {
+ protected Entry<K, V> standardCeilingEntry(K key) {
return tailMap(key, true).firstEntry();
}
@Override
- @CheckForNull
- public K ceilingKey(@ParametricNullness K key) {
+ public K ceilingKey(K key) {
return delegate().ceilingKey(key);
}
@@ -157,14 +144,12 @@
* {@code ceilingEntry}, you may wish to override {@code ceilingKey} to forward to this
* implementation.
*/
- @CheckForNull
- protected K standardCeilingKey(@ParametricNullness K key) {
+ protected K standardCeilingKey(K key) {
return keyOrNull(ceilingEntry(key));
}
@Override
- @CheckForNull
- public Entry<K, V> higherEntry(@ParametricNullness K key) {
+ public Entry<K, V> higherEntry(K key) {
return delegate().higherEntry(key);
}
@@ -173,14 +158,12 @@
* #tailMap(Object, boolean)}. If you override {@code tailMap}, you may wish to override {@code
* higherEntry} to forward to this implementation.
*/
- @CheckForNull
- protected Entry<K, V> standardHigherEntry(@ParametricNullness K key) {
+ protected Entry<K, V> standardHigherEntry(K key) {
return tailMap(key, false).firstEntry();
}
@Override
- @CheckForNull
- public K higherKey(@ParametricNullness K key) {
+ public K higherKey(K key) {
return delegate().higherKey(key);
}
@@ -189,13 +172,11 @@
* {@code higherEntry}, you may wish to override {@code higherKey} to forward to this
* implementation.
*/
- @CheckForNull
- protected K standardHigherKey(@ParametricNullness K key) {
+ protected K standardHigherKey(K key) {
return keyOrNull(higherEntry(key));
}
@Override
- @CheckForNull
public Entry<K, V> firstEntry() {
return delegate().firstEntry();
}
@@ -205,7 +186,6 @@
* #entrySet}. If you override {@code entrySet}, you may wish to override {@code firstEntry} to
* forward to this implementation.
*/
- @CheckForNull
protected Entry<K, V> standardFirstEntry() {
return Iterables.getFirst(entrySet(), null);
}
@@ -225,7 +205,6 @@
}
@Override
- @CheckForNull
public Entry<K, V> lastEntry() {
return delegate().lastEntry();
}
@@ -235,7 +214,6 @@
* #entrySet} of {@link #descendingMap}. If you override {@code descendingMap}, you may wish to
* override {@code lastEntry} to forward to this implementation.
*/
- @CheckForNull
protected Entry<K, V> standardLastEntry() {
return Iterables.getFirst(descendingMap().entrySet(), null);
}
@@ -254,7 +232,6 @@
}
@Override
- @CheckForNull
public Entry<K, V> pollFirstEntry() {
return delegate().pollFirstEntry();
}
@@ -264,13 +241,11 @@
* entrySet}. If you override {@code entrySet}, you may wish to override {@code pollFirstEntry} to
* forward to this implementation.
*/
- @CheckForNull
protected Entry<K, V> standardPollFirstEntry() {
return Iterators.pollNext(entrySet().iterator());
}
@Override
- @CheckForNull
public Entry<K, V> pollLastEntry() {
return delegate().pollLastEntry();
}
@@ -280,7 +255,6 @@
* entrySet} of {@code descendingMap}. If you override {@code descendingMap}, you may wish to
* override {@code pollFirstEntry} to forward to this implementation.
*/
- @CheckForNull
protected Entry<K, V> standardPollLastEntry() {
return Iterators.pollNext(descendingMap().entrySet().iterator());
}
@@ -319,8 +293,8 @@
@Override
protected Iterator<Entry<K, V>> entryIterator() {
return new Iterator<Entry<K, V>>() {
- @CheckForNull private Entry<K, V> toRemove = null;
- @CheckForNull private Entry<K, V> nextOrNull = forward().lastEntry();
+ private Entry<K, V> toRemove = null;
+ private Entry<K, V> nextOrNull = forward().lastEntry();
@Override
public boolean hasNext() {
@@ -329,7 +303,7 @@
@Override
public java.util.Map.Entry<K, V> next() {
- if (nextOrNull == null) {
+ if (!hasNext()) {
throw new NoSuchElementException();
}
try {
@@ -342,9 +316,7 @@
@Override
public void remove() {
- if (toRemove == null) {
- throw new IllegalStateException("no calls to next() since the last call to remove()");
- }
+ checkRemove(toRemove != null);
forward().remove(toRemove.getKey());
toRemove = null;
}
@@ -396,27 +368,22 @@
* wish to override {@code subMap} to forward to this implementation.
*/
@Override
- protected SortedMap<K, V> standardSubMap(
- @ParametricNullness K fromKey, @ParametricNullness K toKey) {
+ protected SortedMap<K, V> standardSubMap(K fromKey, K toKey) {
return subMap(fromKey, true, toKey, false);
}
@Override
- public NavigableMap<K, V> subMap(
- @ParametricNullness K fromKey,
- boolean fromInclusive,
- @ParametricNullness K toKey,
- boolean toInclusive) {
+ public NavigableMap<K, V> subMap(K fromKey, boolean fromInclusive, K toKey, boolean toInclusive) {
return delegate().subMap(fromKey, fromInclusive, toKey, toInclusive);
}
@Override
- public NavigableMap<K, V> headMap(@ParametricNullness K toKey, boolean inclusive) {
+ public NavigableMap<K, V> headMap(K toKey, boolean inclusive) {
return delegate().headMap(toKey, inclusive);
}
@Override
- public NavigableMap<K, V> tailMap(@ParametricNullness K fromKey, boolean inclusive) {
+ public NavigableMap<K, V> tailMap(K fromKey, boolean inclusive) {
return delegate().tailMap(fromKey, inclusive);
}
@@ -425,7 +392,7 @@
* boolean)}. If you override {@code headMap(K, boolean)}, you may wish to override {@code
* headMap} to forward to this implementation.
*/
- protected SortedMap<K, V> standardHeadMap(@ParametricNullness K toKey) {
+ protected SortedMap<K, V> standardHeadMap(K toKey) {
return headMap(toKey, false);
}
@@ -434,7 +401,7 @@
* boolean)}. If you override {@code tailMap(K, boolean)}, you may wish to override {@code
* tailMap} to forward to this implementation.
*/
- protected SortedMap<K, V> standardTailMap(@ParametricNullness K fromKey) {
+ protected SortedMap<K, V> standardTailMap(K fromKey) {
return tailMap(fromKey, true);
}
}
diff --git a/guava/src/com/google/common/collect/ForwardingNavigableSet.java b/guava/src/com/google/common/collect/ForwardingNavigableSet.java
index 6822aa8..827698e 100644
--- a/guava/src/com/google/common/collect/ForwardingNavigableSet.java
+++ b/guava/src/com/google/common/collect/ForwardingNavigableSet.java
@@ -21,8 +21,6 @@
import java.util.Iterator;
import java.util.NavigableSet;
import java.util.SortedSet;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* A navigable set which forwards all its method calls to another navigable set. Subclasses should
@@ -51,9 +49,8 @@
* @since 12.0
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
-public abstract class ForwardingNavigableSet<E extends @Nullable Object>
- extends ForwardingSortedSet<E> implements NavigableSet<E> {
+public abstract class ForwardingNavigableSet<E> extends ForwardingSortedSet<E>
+ implements NavigableSet<E> {
/** Constructor for use by subclasses. */
protected ForwardingNavigableSet() {}
@@ -62,8 +59,7 @@
protected abstract NavigableSet<E> delegate();
@Override
- @CheckForNull
- public E lower(@ParametricNullness E e) {
+ public E lower(E e) {
return delegate().lower(e);
}
@@ -72,14 +68,12 @@
* {@link #headSet(Object, boolean)}. If you override {@link #headSet(Object, boolean)}, you may
* wish to override {@link #lower} to forward to this implementation.
*/
- @CheckForNull
- protected E standardLower(@ParametricNullness E e) {
+ protected E standardLower(E e) {
return Iterators.getNext(headSet(e, false).descendingIterator(), null);
}
@Override
- @CheckForNull
- public E floor(@ParametricNullness E e) {
+ public E floor(E e) {
return delegate().floor(e);
}
@@ -88,14 +82,12 @@
* {@link #headSet(Object, boolean)}. If you override {@link #headSet(Object, boolean)}, you may
* wish to override {@link #floor} to forward to this implementation.
*/
- @CheckForNull
- protected E standardFloor(@ParametricNullness E e) {
+ protected E standardFloor(E e) {
return Iterators.getNext(headSet(e, true).descendingIterator(), null);
}
@Override
- @CheckForNull
- public E ceiling(@ParametricNullness E e) {
+ public E ceiling(E e) {
return delegate().ceiling(e);
}
@@ -104,14 +96,12 @@
* #tailSet(Object, boolean)}. If you override {@link #tailSet(Object, boolean)}, you may wish to
* override {@link #ceiling} to forward to this implementation.
*/
- @CheckForNull
- protected E standardCeiling(@ParametricNullness E e) {
+ protected E standardCeiling(E e) {
return Iterators.getNext(tailSet(e, true).iterator(), null);
}
@Override
- @CheckForNull
- public E higher(@ParametricNullness E e) {
+ public E higher(E e) {
return delegate().higher(e);
}
@@ -120,13 +110,11 @@
* #tailSet(Object, boolean)}. If you override {@link #tailSet(Object, boolean)}, you may wish to
* override {@link #higher} to forward to this implementation.
*/
- @CheckForNull
- protected E standardHigher(@ParametricNullness E e) {
+ protected E standardHigher(E e) {
return Iterators.getNext(tailSet(e, false).iterator(), null);
}
@Override
- @CheckForNull
public E pollFirst() {
return delegate().pollFirst();
}
@@ -136,13 +124,11 @@
* override {@link #iterator} you may wish to override {@link #pollFirst} to forward to this
* implementation.
*/
- @CheckForNull
protected E standardPollFirst() {
return Iterators.pollNext(iterator());
}
@Override
- @CheckForNull
public E pollLast() {
return delegate().pollLast();
}
@@ -152,17 +138,14 @@
* If you override {@link #descendingIterator} you may wish to override {@link #pollLast} to
* forward to this implementation.
*/
- @CheckForNull
protected E standardPollLast() {
return Iterators.pollNext(descendingIterator());
}
- @ParametricNullness
protected E standardFirst() {
return iterator().next();
}
- @ParametricNullness
protected E standardLast() {
return descendingIterator().next();
}
@@ -196,10 +179,7 @@
@Override
public NavigableSet<E> subSet(
- @ParametricNullness E fromElement,
- boolean fromInclusive,
- @ParametricNullness E toElement,
- boolean toInclusive) {
+ E fromElement, boolean fromInclusive, E toElement, boolean toInclusive) {
return delegate().subSet(fromElement, fromInclusive, toElement, toInclusive);
}
@@ -210,10 +190,7 @@
*/
@Beta
protected NavigableSet<E> standardSubSet(
- @ParametricNullness E fromElement,
- boolean fromInclusive,
- @ParametricNullness E toElement,
- boolean toInclusive) {
+ E fromElement, boolean fromInclusive, E toElement, boolean toInclusive) {
return tailSet(fromElement, fromInclusive).headSet(toElement, toInclusive);
}
@@ -224,13 +201,12 @@
* implementation.
*/
@Override
- protected SortedSet<E> standardSubSet(
- @ParametricNullness E fromElement, @ParametricNullness E toElement) {
+ protected SortedSet<E> standardSubSet(E fromElement, E toElement) {
return subSet(fromElement, true, toElement, false);
}
@Override
- public NavigableSet<E> headSet(@ParametricNullness E toElement, boolean inclusive) {
+ public NavigableSet<E> headSet(E toElement, boolean inclusive) {
return delegate().headSet(toElement, inclusive);
}
@@ -239,12 +215,12 @@
* boolean)} method. If you override {@link #headSet(Object, boolean)}, you may wish to override
* {@link #headSet(Object)} to forward to this implementation.
*/
- protected SortedSet<E> standardHeadSet(@ParametricNullness E toElement) {
+ protected SortedSet<E> standardHeadSet(E toElement) {
return headSet(toElement, false);
}
@Override
- public NavigableSet<E> tailSet(@ParametricNullness E fromElement, boolean inclusive) {
+ public NavigableSet<E> tailSet(E fromElement, boolean inclusive) {
return delegate().tailSet(fromElement, inclusive);
}
@@ -253,7 +229,7 @@
* boolean)} method. If you override {@link #tailSet(Object, boolean)}, you may wish to override
* {@link #tailSet(Object)} to forward to this implementation.
*/
- protected SortedSet<E> standardTailSet(@ParametricNullness E fromElement) {
+ protected SortedSet<E> standardTailSet(E fromElement) {
return tailSet(fromElement, true);
}
}
diff --git a/guava/src/com/google/common/collect/ForwardingObject.java b/guava/src/com/google/common/collect/ForwardingObject.java
index 64af908..712b14f 100644
--- a/guava/src/com/google/common/collect/ForwardingObject.java
+++ b/guava/src/com/google/common/collect/ForwardingObject.java
@@ -44,7 +44,6 @@
* @since 2.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
public abstract class ForwardingObject {
/** Constructor for use by subclasses. */
diff --git a/guava/src/com/google/common/collect/ForwardingQueue.java b/guava/src/com/google/common/collect/ForwardingQueue.java
index 43c2eaa..f77e560 100644
--- a/guava/src/com/google/common/collect/ForwardingQueue.java
+++ b/guava/src/com/google/common/collect/ForwardingQueue.java
@@ -20,8 +20,6 @@
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import java.util.NoSuchElementException;
import java.util.Queue;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* A queue which forwards all its method calls to another queue. Subclasses should override one or
@@ -46,9 +44,7 @@
* @since 2.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-public abstract class ForwardingQueue<E extends @Nullable Object> extends ForwardingCollection<E>
- implements Queue<E> {
+public abstract class ForwardingQueue<E> extends ForwardingCollection<E> implements Queue<E> {
/** Constructor for use by subclasses. */
protected ForwardingQueue() {}
@@ -58,32 +54,28 @@
@CanIgnoreReturnValue // TODO(cpovirk): Consider removing this?
@Override
- public boolean offer(@ParametricNullness E o) {
+ public boolean offer(E o) {
return delegate().offer(o);
}
@CanIgnoreReturnValue // TODO(cpovirk): Consider removing this?
@Override
- @CheckForNull
public E poll() {
return delegate().poll();
}
@CanIgnoreReturnValue
@Override
- @ParametricNullness
public E remove() {
return delegate().remove();
}
@Override
- @CheckForNull
public E peek() {
return delegate().peek();
}
@Override
- @ParametricNullness
public E element() {
return delegate().element();
}
@@ -94,7 +86,7 @@
*
* @since 7.0
*/
- protected boolean standardOffer(@ParametricNullness E e) {
+ protected boolean standardOffer(E e) {
try {
return add(e);
} catch (IllegalStateException caught) {
@@ -108,7 +100,6 @@
*
* @since 7.0
*/
- @CheckForNull
protected E standardPeek() {
try {
return element();
@@ -123,7 +114,6 @@
*
* @since 7.0
*/
- @CheckForNull
protected E standardPoll() {
try {
return remove();
diff --git a/guava/src/com/google/common/collect/ForwardingSet.java b/guava/src/com/google/common/collect/ForwardingSet.java
index bc27272..ff21924 100644
--- a/guava/src/com/google/common/collect/ForwardingSet.java
+++ b/guava/src/com/google/common/collect/ForwardingSet.java
@@ -21,7 +21,6 @@
import com.google.common.annotations.GwtCompatible;
import java.util.Collection;
import java.util.Set;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -47,9 +46,7 @@
* @since 2.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-public abstract class ForwardingSet<E extends @Nullable Object> extends ForwardingCollection<E>
- implements Set<E> {
+public abstract class ForwardingSet<E> extends ForwardingCollection<E> implements Set<E> {
// TODO(lowasser): identify places where thread safety is actually lost
/** Constructor for use by subclasses. */
@@ -59,7 +56,7 @@
protected abstract Set<E> delegate();
@Override
- public boolean equals(@CheckForNull Object object) {
+ public boolean equals(@Nullable Object object) {
return object == this || delegate().equals(object);
}
@@ -87,7 +84,7 @@
*
* @since 7.0
*/
- protected boolean standardEquals(@CheckForNull 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 5077c68..a4d6c76 100644
--- a/guava/src/com/google/common/collect/ForwardingSetMultimap.java
+++ b/guava/src/com/google/common/collect/ForwardingSetMultimap.java
@@ -20,7 +20,6 @@
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import java.util.Map.Entry;
import java.util.Set;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -36,9 +35,8 @@
* @since 3.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-public abstract class ForwardingSetMultimap<K extends @Nullable Object, V extends @Nullable Object>
- extends ForwardingMultimap<K, V> implements SetMultimap<K, V> {
+public abstract class ForwardingSetMultimap<K, V> extends ForwardingMultimap<K, V>
+ implements SetMultimap<K, V> {
@Override
protected abstract SetMultimap<K, V> delegate();
@@ -49,19 +47,19 @@
}
@Override
- public Set<V> get(@ParametricNullness K key) {
+ public Set<V> get(@Nullable K key) {
return delegate().get(key);
}
@CanIgnoreReturnValue
@Override
- public Set<V> removeAll(@CheckForNull Object key) {
+ public Set<V> removeAll(@Nullable Object key) {
return delegate().removeAll(key);
}
@CanIgnoreReturnValue
@Override
- public Set<V> replaceValues(@ParametricNullness K key, Iterable<? extends V> values) {
+ public Set<V> replaceValues(K key, Iterable<? extends V> values) {
return delegate().replaceValues(key, values);
}
}
diff --git a/guava/src/com/google/common/collect/ForwardingSortedMap.java b/guava/src/com/google/common/collect/ForwardingSortedMap.java
index e0882ab..8539adf 100644
--- a/guava/src/com/google/common/collect/ForwardingSortedMap.java
+++ b/guava/src/com/google/common/collect/ForwardingSortedMap.java
@@ -23,7 +23,6 @@
import java.util.Comparator;
import java.util.NoSuchElementException;
import java.util.SortedMap;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -52,9 +51,8 @@
* @since 2.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-public abstract class ForwardingSortedMap<K extends @Nullable Object, V extends @Nullable Object>
- extends ForwardingMap<K, V> implements SortedMap<K, V> {
+public abstract class ForwardingSortedMap<K, V> extends ForwardingMap<K, V>
+ implements SortedMap<K, V> {
// TODO(lowasser): identify places where thread safety is actually lost
/** Constructor for use by subclasses. */
@@ -64,35 +62,32 @@
protected abstract SortedMap<K, V> delegate();
@Override
- @CheckForNull
public Comparator<? super K> comparator() {
return delegate().comparator();
}
@Override
- @ParametricNullness
public K firstKey() {
return delegate().firstKey();
}
@Override
- public SortedMap<K, V> headMap(@ParametricNullness K toKey) {
+ public SortedMap<K, V> headMap(K toKey) {
return delegate().headMap(toKey);
}
@Override
- @ParametricNullness
public K lastKey() {
return delegate().lastKey();
}
@Override
- public SortedMap<K, V> subMap(@ParametricNullness K fromKey, @ParametricNullness K toKey) {
+ public SortedMap<K, V> subMap(K fromKey, K toKey) {
return delegate().subMap(fromKey, toKey);
}
@Override
- public SortedMap<K, V> tailMap(@ParametricNullness K fromKey) {
+ public SortedMap<K, V> tailMap(K fromKey) {
return delegate().tailMap(fromKey);
}
@@ -111,14 +106,14 @@
}
}
- // unsafe, but worst case is a CCE or NPE is thrown, which callers will be expecting
- @SuppressWarnings({"unchecked", "nullness"})
- static int unsafeCompare(
- @CheckForNull Comparator<?> comparator, @CheckForNull Object o1, @CheckForNull Object o2) {
+ // unsafe, but worst case is a CCE is thrown, which callers will be expecting
+ @SuppressWarnings("unchecked")
+ private int unsafeCompare(Object k1, Object k2) {
+ Comparator<? super K> comparator = comparator();
if (comparator == null) {
- return ((Comparable<@Nullable Object>) o1).compareTo(o2);
+ return ((Comparable<Object>) k1).compareTo(k2);
} else {
- return ((Comparator<@Nullable Object>) comparator).compare(o1, o2);
+ return ((Comparator<Object>) comparator).compare(k1, k2);
}
}
@@ -131,13 +126,13 @@
*/
@Override
@Beta
- protected boolean standardContainsKey(@CheckForNull Object key) {
+ protected boolean standardContainsKey(@Nullable Object key) {
try {
- // any CCE or NPE will be caught
- @SuppressWarnings({"unchecked", "nullness"})
- SortedMap<@Nullable Object, V> self = (SortedMap<@Nullable Object, V>) this;
+ // any CCE will be caught
+ @SuppressWarnings("unchecked")
+ SortedMap<Object, V> self = (SortedMap<Object, V>) this;
Object ceilingKey = self.tailMap(key).firstKey();
- return unsafeCompare(comparator(), ceilingKey, key) == 0;
+ return unsafeCompare(ceilingKey, key) == 0;
} catch (ClassCastException | NoSuchElementException | NullPointerException e) {
return false;
}
@@ -152,7 +147,7 @@
*/
@Beta
protected SortedMap<K, V> standardSubMap(K fromKey, K toKey) {
- checkArgument(unsafeCompare(comparator(), fromKey, toKey) <= 0, "fromKey must be <= toKey");
+ checkArgument(unsafeCompare(fromKey, toKey) <= 0, "fromKey must be <= toKey");
return tailMap(fromKey).headMap(toKey);
}
}
diff --git a/guava/src/com/google/common/collect/ForwardingSortedMultiset.java b/guava/src/com/google/common/collect/ForwardingSortedMultiset.java
index 4626d31..1d34fb3 100644
--- a/guava/src/com/google/common/collect/ForwardingSortedMultiset.java
+++ b/guava/src/com/google/common/collect/ForwardingSortedMultiset.java
@@ -19,8 +19,6 @@
import java.util.Comparator;
import java.util.Iterator;
import java.util.NavigableSet;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* A sorted multiset which forwards all its method calls to another sorted multiset. Subclasses
@@ -46,9 +44,8 @@
*/
@Beta
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
-public abstract class ForwardingSortedMultiset<E extends @Nullable Object>
- extends ForwardingMultiset<E> implements SortedMultiset<E> {
+public abstract class ForwardingSortedMultiset<E> extends ForwardingMultiset<E>
+ implements SortedMultiset<E> {
/** Constructor for use by subclasses. */
protected ForwardingSortedMultiset() {}
@@ -113,7 +110,6 @@
}
@Override
- @CheckForNull
public Entry<E> firstEntry() {
return delegate().firstEntry();
}
@@ -124,7 +120,6 @@
* <p>If you override {@link #entrySet()}, you may wish to override {@link #firstEntry()} to
* forward to this implementation.
*/
- @CheckForNull
protected Entry<E> standardFirstEntry() {
Iterator<Entry<E>> entryIterator = entrySet().iterator();
if (!entryIterator.hasNext()) {
@@ -135,7 +130,6 @@
}
@Override
- @CheckForNull
public Entry<E> lastEntry() {
return delegate().lastEntry();
}
@@ -147,7 +141,6 @@
* <p>If you override {@link #descendingMultiset} or {@link #entrySet()}, you may wish to override
* {@link #firstEntry()} to forward to this implementation.
*/
- @CheckForNull
protected Entry<E> standardLastEntry() {
Iterator<Entry<E>> entryIterator = descendingMultiset().entrySet().iterator();
if (!entryIterator.hasNext()) {
@@ -158,7 +151,6 @@
}
@Override
- @CheckForNull
public Entry<E> pollFirstEntry() {
return delegate().pollFirstEntry();
}
@@ -169,7 +161,6 @@
* <p>If you override {@link #entrySet()}, you may wish to override {@link #pollFirstEntry()} to
* forward to this implementation.
*/
- @CheckForNull
protected Entry<E> standardPollFirstEntry() {
Iterator<Entry<E>> entryIterator = entrySet().iterator();
if (!entryIterator.hasNext()) {
@@ -182,7 +173,6 @@
}
@Override
- @CheckForNull
public Entry<E> pollLastEntry() {
return delegate().pollLastEntry();
}
@@ -194,7 +184,6 @@
* <p>If you override {@link #descendingMultiset()} or {@link #entrySet()}, you may wish to
* override {@link #pollLastEntry()} to forward to this implementation.
*/
- @CheckForNull
protected Entry<E> standardPollLastEntry() {
Iterator<Entry<E>> entryIterator = descendingMultiset().entrySet().iterator();
if (!entryIterator.hasNext()) {
@@ -207,16 +196,13 @@
}
@Override
- public SortedMultiset<E> headMultiset(@ParametricNullness E upperBound, BoundType boundType) {
+ public SortedMultiset<E> headMultiset(E upperBound, BoundType boundType) {
return delegate().headMultiset(upperBound, boundType);
}
@Override
public SortedMultiset<E> subMultiset(
- @ParametricNullness E lowerBound,
- BoundType lowerBoundType,
- @ParametricNullness E upperBound,
- BoundType upperBoundType) {
+ E lowerBound, BoundType lowerBoundType, E upperBound, BoundType upperBoundType) {
return delegate().subMultiset(lowerBound, lowerBoundType, upperBound, upperBoundType);
}
@@ -229,15 +215,12 @@
* #subMultiset(Object, BoundType, Object, BoundType)} to forward to this implementation.
*/
protected SortedMultiset<E> standardSubMultiset(
- @ParametricNullness E lowerBound,
- BoundType lowerBoundType,
- @ParametricNullness E upperBound,
- BoundType upperBoundType) {
+ E lowerBound, BoundType lowerBoundType, E upperBound, BoundType upperBoundType) {
return tailMultiset(lowerBound, lowerBoundType).headMultiset(upperBound, upperBoundType);
}
@Override
- public SortedMultiset<E> tailMultiset(@ParametricNullness E lowerBound, BoundType boundType) {
+ public SortedMultiset<E> tailMultiset(E lowerBound, BoundType boundType) {
return delegate().tailMultiset(lowerBound, boundType);
}
}
diff --git a/guava/src/com/google/common/collect/ForwardingSortedSet.java b/guava/src/com/google/common/collect/ForwardingSortedSet.java
index 32625af..4c4ddf4 100644
--- a/guava/src/com/google/common/collect/ForwardingSortedSet.java
+++ b/guava/src/com/google/common/collect/ForwardingSortedSet.java
@@ -16,15 +16,12 @@
package com.google.common.collect;
-import static com.google.common.collect.ForwardingSortedMap.unsafeCompare;
-
import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtCompatible;
import java.util.Comparator;
import java.util.Iterator;
import java.util.NoSuchElementException;
import java.util.SortedSet;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -55,9 +52,7 @@
* @since 2.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-public abstract class ForwardingSortedSet<E extends @Nullable Object> extends ForwardingSet<E>
- implements SortedSet<E> {
+public abstract class ForwardingSortedSet<E> extends ForwardingSet<E> implements SortedSet<E> {
/** Constructor for use by subclasses. */
protected ForwardingSortedSet() {}
@@ -66,38 +61,44 @@
protected abstract SortedSet<E> delegate();
@Override
- @CheckForNull
public Comparator<? super E> comparator() {
return delegate().comparator();
}
@Override
- @ParametricNullness
public E first() {
return delegate().first();
}
@Override
- public SortedSet<E> headSet(@ParametricNullness E toElement) {
+ public SortedSet<E> headSet(E toElement) {
return delegate().headSet(toElement);
}
@Override
- @ParametricNullness
public E last() {
return delegate().last();
}
@Override
- public SortedSet<E> subSet(@ParametricNullness E fromElement, @ParametricNullness E toElement) {
+ public SortedSet<E> subSet(E fromElement, E toElement) {
return delegate().subSet(fromElement, toElement);
}
@Override
- public SortedSet<E> tailSet(@ParametricNullness E fromElement) {
+ public SortedSet<E> tailSet(E fromElement) {
return delegate().tailSet(fromElement);
}
+ // unsafe, but worst case is a CCE is thrown, which callers will be expecting
+ @SuppressWarnings("unchecked")
+ private int unsafeCompare(@Nullable Object o1, @Nullable Object o2) {
+ Comparator<? super E> comparator = comparator();
+ return (comparator == null)
+ ? ((Comparable<Object>) o1).compareTo(o2)
+ : ((Comparator<Object>) comparator).compare(o1, o2);
+ }
+
/**
* A sensible definition of {@link #contains} in terms of the {@code first()} method of {@link
* #tailSet}. If you override {@link #tailSet}, you may wish to override {@link #contains} to
@@ -107,13 +108,13 @@
*/
@Override
@Beta
- protected boolean standardContains(@CheckForNull Object object) {
+ protected boolean standardContains(@Nullable Object object) {
try {
- // any ClassCastExceptions and NullPointerExceptions are caught
- @SuppressWarnings({"unchecked", "nullness"})
- SortedSet<@Nullable Object> self = (SortedSet<@Nullable Object>) this;
+ // any ClassCastExceptions are caught
+ @SuppressWarnings("unchecked")
+ SortedSet<Object> self = (SortedSet<Object>) this;
Object ceiling = self.tailSet(object).first();
- return unsafeCompare(comparator(), ceiling, object) == 0;
+ return unsafeCompare(ceiling, object) == 0;
} catch (ClassCastException | NoSuchElementException | NullPointerException e) {
return false;
}
@@ -128,15 +129,15 @@
*/
@Override
@Beta
- protected boolean standardRemove(@CheckForNull Object object) {
+ protected boolean standardRemove(@Nullable Object object) {
try {
- // any ClassCastExceptions and NullPointerExceptions are caught
- @SuppressWarnings({"unchecked", "nullness"})
- SortedSet<@Nullable Object> self = (SortedSet<@Nullable Object>) this;
- Iterator<?> iterator = self.tailSet(object).iterator();
+ // any ClassCastExceptions are caught
+ @SuppressWarnings("unchecked")
+ SortedSet<Object> self = (SortedSet<Object>) this;
+ Iterator<Object> iterator = self.tailSet(object).iterator();
if (iterator.hasNext()) {
Object ceiling = iterator.next();
- if (unsafeCompare(comparator(), ceiling, object) == 0) {
+ if (unsafeCompare(ceiling, object) == 0) {
iterator.remove();
return true;
}
@@ -155,8 +156,7 @@
* @since 7.0
*/
@Beta
- protected SortedSet<E> standardSubSet(
- @ParametricNullness E fromElement, @ParametricNullness E toElement) {
+ protected SortedSet<E> standardSubSet(E fromElement, E toElement) {
return tailSet(fromElement).headSet(toElement);
}
}
diff --git a/guava/src/com/google/common/collect/ForwardingSortedSetMultimap.java b/guava/src/com/google/common/collect/ForwardingSortedSetMultimap.java
index b91a68b..546eb47 100644
--- a/guava/src/com/google/common/collect/ForwardingSortedSetMultimap.java
+++ b/guava/src/com/google/common/collect/ForwardingSortedSetMultimap.java
@@ -19,7 +19,6 @@
import com.google.common.annotations.GwtCompatible;
import java.util.Comparator;
import java.util.SortedSet;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -35,10 +34,8 @@
* @since 3.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-public abstract class ForwardingSortedSetMultimap<
- K extends @Nullable Object, V extends @Nullable Object>
- extends ForwardingSetMultimap<K, V> implements SortedSetMultimap<K, V> {
+public abstract class ForwardingSortedSetMultimap<K, V> extends ForwardingSetMultimap<K, V>
+ implements SortedSetMultimap<K, V> {
/** Constructor for use by subclasses. */
protected ForwardingSortedSetMultimap() {}
@@ -47,22 +44,21 @@
protected abstract SortedSetMultimap<K, V> delegate();
@Override
- public SortedSet<V> get(@ParametricNullness K key) {
+ public SortedSet<V> get(@Nullable K key) {
return delegate().get(key);
}
@Override
- public SortedSet<V> removeAll(@CheckForNull Object key) {
+ public SortedSet<V> removeAll(@Nullable Object key) {
return delegate().removeAll(key);
}
@Override
- public SortedSet<V> replaceValues(@ParametricNullness K key, Iterable<? extends V> values) {
+ public SortedSet<V> replaceValues(K key, Iterable<? extends V> values) {
return delegate().replaceValues(key, values);
}
@Override
- @CheckForNull
public Comparator<? super V> valueComparator() {
return delegate().valueComparator();
}
diff --git a/guava/src/com/google/common/collect/ForwardingTable.java b/guava/src/com/google/common/collect/ForwardingTable.java
index 4fcb858..71a54cf 100644
--- a/guava/src/com/google/common/collect/ForwardingTable.java
+++ b/guava/src/com/google/common/collect/ForwardingTable.java
@@ -21,8 +21,6 @@
import java.util.Collection;
import java.util.Map;
import java.util.Set;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* A table which forwards all its method calls to another table. Subclasses should override one or
@@ -33,10 +31,7 @@
* @since 7.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-public abstract class ForwardingTable<
- R extends @Nullable Object, C extends @Nullable Object, V extends @Nullable Object>
- extends ForwardingObject implements Table<R, C, V> {
+public abstract class ForwardingTable<R, C, V> extends ForwardingObject implements Table<R, C, V> {
/** Constructor for use by subclasses. */
protected ForwardingTable() {}
@@ -54,7 +49,7 @@
}
@Override
- public Map<R, V> column(@ParametricNullness C columnKey) {
+ public Map<R, V> column(C columnKey) {
return delegate().column(columnKey);
}
@@ -69,28 +64,27 @@
}
@Override
- public boolean contains(@CheckForNull Object rowKey, @CheckForNull Object columnKey) {
+ public boolean contains(Object rowKey, Object columnKey) {
return delegate().contains(rowKey, columnKey);
}
@Override
- public boolean containsColumn(@CheckForNull Object columnKey) {
+ public boolean containsColumn(Object columnKey) {
return delegate().containsColumn(columnKey);
}
@Override
- public boolean containsRow(@CheckForNull Object rowKey) {
+ public boolean containsRow(Object rowKey) {
return delegate().containsRow(rowKey);
}
@Override
- public boolean containsValue(@CheckForNull Object value) {
+ public boolean containsValue(Object value) {
return delegate().containsValue(value);
}
@Override
- @CheckForNull
- public V get(@CheckForNull Object rowKey, @CheckForNull Object columnKey) {
+ public V get(Object rowKey, Object columnKey) {
return delegate().get(rowKey, columnKey);
}
@@ -101,9 +95,7 @@
@CanIgnoreReturnValue
@Override
- @CheckForNull
- public V put(
- @ParametricNullness R rowKey, @ParametricNullness C columnKey, @ParametricNullness V value) {
+ public V put(R rowKey, C columnKey, V value) {
return delegate().put(rowKey, columnKey, value);
}
@@ -114,13 +106,12 @@
@CanIgnoreReturnValue
@Override
- @CheckForNull
- public V remove(@CheckForNull Object rowKey, @CheckForNull Object columnKey) {
+ public V remove(Object rowKey, Object columnKey) {
return delegate().remove(rowKey, columnKey);
}
@Override
- public Map<C, V> row(@ParametricNullness R rowKey) {
+ public Map<C, V> row(R rowKey) {
return delegate().row(rowKey);
}
@@ -145,7 +136,7 @@
}
@Override
- public boolean equals(@CheckForNull Object obj) {
+ public boolean equals(Object obj) {
return (obj == this) || delegate().equals(obj);
}
diff --git a/guava/src/com/google/common/collect/GeneralRange.java b/guava/src/com/google/common/collect/GeneralRange.java
index 20cf4fb..1ce5659 100644
--- a/guava/src/com/google/common/collect/GeneralRange.java
+++ b/guava/src/com/google/common/collect/GeneralRange.java
@@ -18,13 +18,11 @@
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.collect.BoundType.CLOSED;
import static com.google.common.collect.BoundType.OPEN;
-import static com.google.common.collect.NullnessCasts.uncheckedCastNullableTToT;
import com.google.common.annotations.GwtCompatible;
import com.google.common.base.Objects;
import java.io.Serializable;
import java.util.Comparator;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -37,14 +35,13 @@
* @author Louis Wasserman
*/
@GwtCompatible(serializable = true)
-@ElementTypesAreNonnullByDefault
-final class GeneralRange<T extends @Nullable Object> implements Serializable {
+final class GeneralRange<T> implements Serializable {
/** Converts a Range to a GeneralRange. */
static <T extends Comparable> GeneralRange<T> from(Range<T> range) {
- T lowerEndpoint = range.hasLowerBound() ? range.lowerEndpoint() : null;
+ @Nullable T lowerEndpoint = range.hasLowerBound() ? range.lowerEndpoint() : null;
BoundType lowerBoundType = range.hasLowerBound() ? range.lowerBoundType() : OPEN;
- 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<T>(
Ordering.natural(),
@@ -57,7 +54,7 @@
}
/** Returns the whole range relative to the specified comparator. */
- static <T extends @Nullable Object> GeneralRange<T> all(Comparator<? super T> comparator) {
+ static <T> GeneralRange<T> all(Comparator<? super T> comparator) {
return new GeneralRange<T>(comparator, false, null, OPEN, false, null, OPEN);
}
@@ -65,8 +62,8 @@
* Returns everything above the endpoint relative to the specified comparator, with the specified
* endpoint behavior.
*/
- static <T extends @Nullable Object> GeneralRange<T> downTo(
- Comparator<? super T> comparator, @ParametricNullness T endpoint, BoundType boundType) {
+ static <T> GeneralRange<T> downTo(
+ Comparator<? super T> comparator, @Nullable T endpoint, BoundType boundType) {
return new GeneralRange<T>(comparator, true, endpoint, boundType, false, null, OPEN);
}
@@ -74,8 +71,8 @@
* Returns everything below the endpoint relative to the specified comparator, with the specified
* endpoint behavior.
*/
- static <T extends @Nullable Object> GeneralRange<T> upTo(
- Comparator<? super T> comparator, @ParametricNullness T endpoint, BoundType boundType) {
+ static <T> GeneralRange<T> upTo(
+ Comparator<? super T> comparator, @Nullable T endpoint, BoundType boundType) {
return new GeneralRange<T>(comparator, false, null, OPEN, true, endpoint, boundType);
}
@@ -83,30 +80,30 @@
* Returns everything between the endpoints relative to the specified comparator, with the
* specified endpoint behavior.
*/
- static <T extends @Nullable Object> GeneralRange<T> range(
+ static <T> GeneralRange<T> range(
Comparator<? super T> comparator,
- @ParametricNullness T lower,
+ @Nullable T lower,
BoundType lowerType,
- @ParametricNullness T upper,
+ @Nullable T upper,
BoundType upperType) {
return new GeneralRange<T>(comparator, true, lower, lowerType, true, upper, upperType);
}
private final Comparator<? super T> comparator;
private final boolean hasLowerBound;
- @CheckForNull private final T lowerEndpoint;
+ private final @Nullable T lowerEndpoint;
private final BoundType lowerBoundType;
private final boolean hasUpperBound;
- @CheckForNull private final T upperEndpoint;
+ private final @Nullable T upperEndpoint;
private final BoundType upperBoundType;
private GeneralRange(
Comparator<? super T> comparator,
boolean hasLowerBound,
- @CheckForNull T lowerEndpoint,
+ @Nullable T lowerEndpoint,
BoundType lowerBoundType,
boolean hasUpperBound,
- @CheckForNull T upperEndpoint,
+ @Nullable T upperEndpoint,
BoundType upperBoundType) {
this.comparator = checkNotNull(comparator);
this.hasLowerBound = hasLowerBound;
@@ -116,24 +113,14 @@
this.upperEndpoint = upperEndpoint;
this.upperBoundType = checkNotNull(upperBoundType);
- // Trigger any exception that the comparator would throw for the endpoints.
- /*
- * uncheckedCastNullableTToT is safe as long as the callers are careful to pass a "real" T
- * whenever they pass `true` for the matching `has*Bound` parameter.
- */
if (hasLowerBound) {
- comparator.compare(
- uncheckedCastNullableTToT(lowerEndpoint), uncheckedCastNullableTToT(lowerEndpoint));
+ comparator.compare(lowerEndpoint, lowerEndpoint);
}
if (hasUpperBound) {
- comparator.compare(
- uncheckedCastNullableTToT(upperEndpoint), uncheckedCastNullableTToT(upperEndpoint));
+ comparator.compare(upperEndpoint, upperEndpoint);
}
-
if (hasLowerBound && hasUpperBound) {
- int cmp =
- comparator.compare(
- uncheckedCastNullableTToT(lowerEndpoint), uncheckedCastNullableTToT(upperEndpoint));
+ int cmp = comparator.compare(lowerEndpoint, upperEndpoint);
// be consistent with Range
checkArgument(
cmp <= 0, "lowerEndpoint (%s) > upperEndpoint (%s)", lowerEndpoint, upperEndpoint);
@@ -156,45 +143,41 @@
}
boolean isEmpty() {
- // The casts are safe because of the has*Bound() checks.
- return (hasUpperBound() && tooLow(uncheckedCastNullableTToT(getUpperEndpoint())))
- || (hasLowerBound() && tooHigh(uncheckedCastNullableTToT(getLowerEndpoint())));
+ return (hasUpperBound() && tooLow(getUpperEndpoint()))
+ || (hasLowerBound() && tooHigh(getLowerEndpoint()));
}
- boolean tooLow(@ParametricNullness T t) {
+ boolean tooLow(@Nullable T t) {
if (!hasLowerBound()) {
return false;
}
- // The cast is safe because of the hasLowerBound() check.
- T lbound = uncheckedCastNullableTToT(getLowerEndpoint());
+ T lbound = getLowerEndpoint();
int cmp = comparator.compare(t, lbound);
return cmp < 0 | (cmp == 0 & getLowerBoundType() == OPEN);
}
- boolean tooHigh(@ParametricNullness T t) {
+ boolean tooHigh(@Nullable T t) {
if (!hasUpperBound()) {
return false;
}
- // The cast is safe because of the hasUpperBound() check.
- T ubound = uncheckedCastNullableTToT(getUpperEndpoint());
+ T ubound = getUpperEndpoint();
int cmp = comparator.compare(t, ubound);
return cmp > 0 | (cmp == 0 & getUpperBoundType() == OPEN);
}
- boolean contains(@ParametricNullness T t) {
+ boolean contains(@Nullable T t) {
return !tooLow(t) && !tooHigh(t);
}
/**
* Returns the intersection of the two ranges, or an empty range if their intersection is empty.
*/
- @SuppressWarnings("nullness") // TODO(cpovirk): Add casts as needed. Will be noisy and annoying...
GeneralRange<T> intersect(GeneralRange<T> other) {
checkNotNull(other);
checkArgument(comparator.equals(other.comparator));
boolean hasLowBound = this.hasLowerBound;
- T lowEnd = getLowerEndpoint();
+ @Nullable T lowEnd = getLowerEndpoint();
BoundType lowType = getLowerBoundType();
if (!hasLowerBound()) {
hasLowBound = other.hasLowerBound;
@@ -209,7 +192,7 @@
}
boolean hasUpBound = this.hasUpperBound;
- T upEnd = getUpperEndpoint();
+ @Nullable T upEnd = getUpperEndpoint();
BoundType upType = getUpperBoundType();
if (!hasUpperBound()) {
hasUpBound = other.hasUpperBound;
@@ -237,7 +220,7 @@
}
@Override
- public boolean equals(@CheckForNull Object obj) {
+ public boolean equals(@Nullable Object obj) {
if (obj instanceof GeneralRange) {
GeneralRange<?> r = (GeneralRange<?>) obj;
return comparator.equals(r.comparator)
@@ -261,7 +244,7 @@
getUpperBoundType());
}
- @CheckForNull private transient GeneralRange<T> reverse;
+ private transient @Nullable GeneralRange<T> reverse;
/** Returns the same range relative to the reversed comparator. */
GeneralRange<T> reverse() {
@@ -293,7 +276,6 @@
+ (upperBoundType == CLOSED ? ']' : ')');
}
- @CheckForNull
T getLowerEndpoint() {
return lowerEndpoint;
}
@@ -302,7 +284,6 @@
return lowerBoundType;
}
- @CheckForNull
T getUpperEndpoint() {
return upperEndpoint;
}
diff --git a/guava/src/com/google/common/collect/GwtTransient.java b/guava/src/com/google/common/collect/GwtTransient.java
index ce5ea48..9c09c53 100644
--- a/guava/src/com/google/common/collect/GwtTransient.java
+++ b/guava/src/com/google/common/collect/GwtTransient.java
@@ -33,5 +33,4 @@
@GwtCompatible
@Retention(RUNTIME)
@Target(FIELD)
-@ElementTypesAreNonnullByDefault
@interface GwtTransient {}
diff --git a/guava/src/com/google/common/collect/HashBasedTable.java b/guava/src/com/google/common/collect/HashBasedTable.java
index c8ba50f..8f6df57 100644
--- a/guava/src/com/google/common/collect/HashBasedTable.java
+++ b/guava/src/com/google/common/collect/HashBasedTable.java
@@ -20,9 +20,11 @@
import com.google.common.annotations.GwtCompatible;
import com.google.common.base.Supplier;
+import com.google.errorprone.annotations.CanIgnoreReturnValue;
import java.io.Serializable;
import java.util.LinkedHashMap;
import java.util.Map;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Implementation of {@link Table} using linked hash tables. This guarantees predictable iteration
@@ -47,7 +49,6 @@
* @since 7.0
*/
@GwtCompatible(serializable = true)
-@ElementTypesAreNonnullByDefault
public class HashBasedTable<R, C, V> extends StandardTable<R, C, V> {
private static class Factory<C, V> implements Supplier<Map<C, V>>, Serializable {
final int expectedSize;
@@ -102,5 +103,43 @@
super(backingMap, factory);
}
+ // Overriding so NullPointerTester test passes.
+
+ @Override
+ public boolean contains(@Nullable Object rowKey, @Nullable Object columnKey) {
+ return super.contains(rowKey, columnKey);
+ }
+
+ @Override
+ public boolean containsColumn(@Nullable Object columnKey) {
+ return super.containsColumn(columnKey);
+ }
+
+ @Override
+ public boolean containsRow(@Nullable Object rowKey) {
+ return super.containsRow(rowKey);
+ }
+
+ @Override
+ public boolean containsValue(@Nullable Object value) {
+ return super.containsValue(value);
+ }
+
+ @Override
+ public V get(@Nullable Object rowKey, @Nullable Object columnKey) {
+ return super.get(rowKey, columnKey);
+ }
+
+ @Override
+ public boolean equals(@Nullable Object obj) {
+ return super.equals(obj);
+ }
+
+ @CanIgnoreReturnValue
+ @Override
+ public V remove(@Nullable Object rowKey, @Nullable Object columnKey) {
+ return super.remove(rowKey, columnKey);
+ }
+
private static final long serialVersionUID = 0;
}
diff --git a/guava/src/com/google/common/collect/HashBiMap.java b/guava/src/com/google/common/collect/HashBiMap.java
index b6e2042..33365ec 100644
--- a/guava/src/com/google/common/collect/HashBiMap.java
+++ b/guava/src/com/google/common/collect/HashBiMap.java
@@ -17,8 +17,8 @@
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.collect.CollectPreconditions.checkNonnegative;
+import static com.google.common.collect.CollectPreconditions.checkRemove;
import static com.google.common.collect.Hashing.smearedHash;
-import static java.util.Objects.requireNonNull;
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.GwtIncompatible;
@@ -27,7 +27,7 @@
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import com.google.errorprone.annotations.concurrent.LazyInit;
import com.google.j2objc.annotations.RetainedWith;
-import com.google.j2objc.annotations.Weak;
+import com.google.j2objc.annotations.WeakOuter;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
@@ -40,7 +40,6 @@
import java.util.Set;
import java.util.function.BiConsumer;
import java.util.function.BiFunction;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -57,12 +56,11 @@
* @since 2.0
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
-public final class HashBiMap<K extends @Nullable Object, V extends @Nullable Object>
- extends IteratorBasedAbstractMap<K, V> implements BiMap<K, V>, Serializable {
+public final class HashBiMap<K, V> extends IteratorBasedAbstractMap<K, V>
+ implements BiMap<K, V>, Serializable {
/** Returns a new, empty {@code HashBiMap} with the default initial capacity (16). */
- public static <K extends @Nullable Object, V extends @Nullable Object> HashBiMap<K, V> create() {
+ public static <K, V> HashBiMap<K, V> create() {
return create(16);
}
@@ -72,8 +70,7 @@
* @param expectedSize the expected number of entries
* @throws IllegalArgumentException if the specified expected size is negative
*/
- public static <K extends @Nullable Object, V extends @Nullable Object> HashBiMap<K, V> create(
- int expectedSize) {
+ public static <K, V> HashBiMap<K, V> create(int expectedSize) {
return new HashBiMap<>(expectedSize);
}
@@ -81,31 +78,23 @@
* Constructs a new bimap containing initial values from {@code map}. The bimap is created with an
* initial capacity sufficient to hold the mappings in the specified map.
*/
- public static <K extends @Nullable Object, V extends @Nullable Object> HashBiMap<K, V> create(
- Map<? extends K, ? extends V> map) {
+ public static <K, V> HashBiMap<K, V> create(Map<? extends K, ? extends V> map) {
HashBiMap<K, V> bimap = create(map.size());
bimap.putAll(map);
return bimap;
}
- private static final class BiEntry<K extends @Nullable Object, V extends @Nullable Object>
- extends ImmutableEntry<K, V> {
+ private static final class BiEntry<K, V> extends ImmutableEntry<K, V> {
final int keyHash;
final int valueHash;
- // All BiEntry instances are strongly reachable from owning HashBiMap through
- // "HashBiMap.hashTableKToV" and "BiEntry.nextInKToVBucket" references.
- // Under that assumption, the remaining references can be safely marked as @Weak.
- // Using @Weak is necessary to avoid retain-cycles between BiEntry instances on iOS,
- // which would cause memory leaks when non-empty HashBiMap with cyclic BiEntry
- // instances is deallocated.
- @CheckForNull BiEntry<K, V> nextInKToVBucket;
- @Weak @CheckForNull BiEntry<K, V> nextInVToKBucket;
+ @Nullable BiEntry<K, V> nextInKToVBucket;
+ @Nullable BiEntry<K, V> nextInVToKBucket;
- @Weak @CheckForNull BiEntry<K, V> nextInKeyInsertionOrder;
- @Weak @CheckForNull BiEntry<K, V> prevInKeyInsertionOrder;
+ @Nullable BiEntry<K, V> nextInKeyInsertionOrder;
+ @Nullable BiEntry<K, V> prevInKeyInsertionOrder;
- BiEntry(@ParametricNullness K key, int keyHash, @ParametricNullness V value, int valueHash) {
+ BiEntry(K key, int keyHash, V value, int valueHash) {
super(key, value);
this.keyHash = keyHash;
this.valueHash = valueHash;
@@ -114,15 +103,10 @@
private static final double LOAD_FACTOR = 1.0;
- /*
- * The following two arrays may *contain* nulls, but they are never *themselves* null: Even though
- * they are not initialized inline in the constructor, they are initialized from init(), which the
- * constructor calls (as does readObject()).
- */
- private transient @Nullable BiEntry<K, V>[] hashTableKToV;
- private transient @Nullable BiEntry<K, V>[] hashTableVToK;
- @Weak @CheckForNull private transient BiEntry<K, V> firstInKeyInsertionOrder;
- @Weak @CheckForNull private transient BiEntry<K, V> lastInKeyInsertionOrder;
+ private transient BiEntry<K, V>[] hashTableKToV;
+ private transient BiEntry<K, V>[] hashTableVToK;
+ private transient @Nullable BiEntry<K, V> firstInKeyInsertionOrder;
+ private transient @Nullable BiEntry<K, V> lastInKeyInsertionOrder;
private transient int size;
private transient int mask;
private transient int modCount;
@@ -196,7 +180,7 @@
modCount++;
}
- private void insert(BiEntry<K, V> entry, @CheckForNull BiEntry<K, V> oldEntryForKey) {
+ private void insert(BiEntry<K, V> entry, @Nullable BiEntry<K, V> oldEntryForKey) {
int keyBucket = entry.keyHash & mask;
entry.nextInKToVBucket = hashTableKToV[keyBucket];
hashTableKToV[keyBucket] = entry;
@@ -233,8 +217,7 @@
modCount++;
}
- @CheckForNull
- private BiEntry<K, V> seekByKey(@CheckForNull Object key, int keyHash) {
+ private BiEntry<K, V> seekByKey(@Nullable Object key, int keyHash) {
for (BiEntry<K, V> entry = hashTableKToV[keyHash & mask];
entry != null;
entry = entry.nextInKToVBucket) {
@@ -245,8 +228,7 @@
return null;
}
- @CheckForNull
- private BiEntry<K, V> seekByValue(@CheckForNull Object value, int valueHash) {
+ private BiEntry<K, V> seekByValue(@Nullable Object value, int valueHash) {
for (BiEntry<K, V> entry = hashTableVToK[valueHash & mask];
entry != null;
entry = entry.nextInVToKBucket) {
@@ -258,7 +240,7 @@
}
@Override
- public boolean containsKey(@CheckForNull Object key) {
+ public boolean containsKey(@Nullable Object key) {
return seekByKey(key, smearedHash(key)) != null;
}
@@ -273,25 +255,22 @@
* @return true if a mapping exists from a key to the specified value
*/
@Override
- public boolean containsValue(@CheckForNull Object value) {
+ public boolean containsValue(@Nullable Object value) {
return seekByValue(value, smearedHash(value)) != null;
}
@Override
- @CheckForNull
- public V get(@CheckForNull Object key) {
+ public @Nullable V get(@Nullable Object key) {
return Maps.valueOrNull(seekByKey(key, smearedHash(key)));
}
@CanIgnoreReturnValue
@Override
- @CheckForNull
- public V put(@ParametricNullness K key, @ParametricNullness V value) {
+ public V put(@Nullable K key, @Nullable V value) {
return put(key, value, false);
}
- @CheckForNull
- private V put(@ParametricNullness K key, @ParametricNullness V value, boolean force) {
+ private V put(@Nullable K key, @Nullable V value, boolean force) {
int keyHash = smearedHash(key);
int valueHash = smearedHash(value);
@@ -327,13 +306,11 @@
@CanIgnoreReturnValue
@Override
- @CheckForNull
- public V forcePut(@ParametricNullness K key, @ParametricNullness V value) {
+ public @Nullable V forcePut(@Nullable K key, @Nullable V value) {
return put(key, value, true);
}
- @CheckForNull
- private K putInverse(@ParametricNullness V value, @ParametricNullness K key, boolean force) {
+ private @Nullable K putInverse(@Nullable V value, @Nullable K key, boolean force) {
int valueHash = smearedHash(value);
int keyHash = smearedHash(key);
@@ -378,7 +355,7 @@
}
private void rehashIfNecessary() {
- @Nullable BiEntry<K, V>[] oldKToV = hashTableKToV;
+ BiEntry<K, V>[] oldKToV = hashTableKToV;
if (Hashing.needsResizing(size, oldKToV.length, LOAD_FACTOR)) {
int newTableSize = oldKToV.length * 2;
@@ -396,15 +373,14 @@
}
}
- @SuppressWarnings({"unchecked", "rawtypes"})
- private @Nullable BiEntry<K, V>[] createTable(int length) {
- return new @Nullable BiEntry[length];
+ @SuppressWarnings("unchecked")
+ private BiEntry<K, V>[] createTable(int length) {
+ return new BiEntry[length];
}
@CanIgnoreReturnValue
@Override
- @CheckForNull
- public V remove(@CheckForNull Object key) {
+ public @Nullable V remove(@Nullable Object key) {
BiEntry<K, V> entry = seekByKey(key, smearedHash(key));
if (entry == null) {
return null;
@@ -431,9 +407,9 @@
return size;
}
- abstract class Itr<T extends @Nullable Object> implements Iterator<T> {
- @CheckForNull BiEntry<K, V> next = firstInKeyInsertionOrder;
- @CheckForNull BiEntry<K, V> toRemove = null;
+ abstract class Itr<T> implements Iterator<T> {
+ BiEntry<K, V> next = firstInKeyInsertionOrder;
+ BiEntry<K, V> toRemove = null;
int expectedModCount = modCount;
int remaining = size();
@@ -451,8 +427,7 @@
throw new NoSuchElementException();
}
- // requireNonNull is safe because of the hasNext check.
- BiEntry<K, V> entry = requireNonNull(next);
+ BiEntry<K, V> entry = next;
next = entry.nextInKeyInsertionOrder;
toRemove = entry;
remaining--;
@@ -464,9 +439,7 @@
if (modCount != expectedModCount) {
throw new ConcurrentModificationException();
}
- if (toRemove == null) {
- throw new IllegalStateException("no calls to next() since the last call to remove()");
- }
+ checkRemove(toRemove != null);
delete(toRemove);
expectedModCount = modCount;
toRemove = null;
@@ -480,6 +453,7 @@
return new KeySet();
}
+ @WeakOuter
private final class KeySet extends Maps.KeySet<K, V> {
KeySet() {
super(HashBiMap.this);
@@ -496,7 +470,7 @@
}
@Override
- public boolean remove(@CheckForNull Object o) {
+ public boolean remove(@Nullable Object o) {
BiEntry<K, V> entry = seekByKey(o, smearedHash(o));
if (entry == null) {
return false;
@@ -583,7 +557,7 @@
}
}
- @LazyInit @RetainedWith @CheckForNull private transient BiMap<V, K> inverse;
+ @LazyInit @RetainedWith private transient @Nullable BiMap<V, K> inverse;
@Override
public BiMap<V, K> inverse() {
@@ -608,32 +582,28 @@
}
@Override
- public boolean containsKey(@CheckForNull Object value) {
+ public boolean containsKey(@Nullable Object value) {
return forward().containsValue(value);
}
@Override
- @CheckForNull
- public K get(@CheckForNull Object value) {
+ public K get(@Nullable Object value) {
return Maps.keyOrNull(seekByValue(value, smearedHash(value)));
}
@CanIgnoreReturnValue
@Override
- @CheckForNull
- public K put(@ParametricNullness V value, @ParametricNullness K key) {
+ public @Nullable K put(@Nullable V value, @Nullable K key) {
return putInverse(value, key, false);
}
@Override
- @CheckForNull
- public K forcePut(@ParametricNullness V value, @ParametricNullness K key) {
+ public @Nullable K forcePut(@Nullable V value, @Nullable K key) {
return putInverse(value, key, true);
}
@Override
- @CheckForNull
- public K remove(@CheckForNull Object value) {
+ public @Nullable K remove(@Nullable Object value) {
BiEntry<K, V> entry = seekByValue(value, smearedHash(value));
if (entry == null) {
return null;
@@ -655,13 +625,14 @@
return new InverseKeySet();
}
+ @WeakOuter
private final class InverseKeySet extends Maps.KeySet<V, K> {
InverseKeySet() {
super(Inverse.this);
}
@Override
- public boolean remove(@CheckForNull Object o) {
+ public boolean remove(@Nullable Object o) {
BiEntry<K, V> entry = seekByValue(o, smearedHash(o));
if (entry == null) {
return false;
@@ -753,9 +724,7 @@
}
}
- private static final class InverseSerializedForm<
- K extends @Nullable Object, V extends @Nullable Object>
- implements Serializable {
+ private static final class InverseSerializedForm<K, V> implements Serializable {
private final HashBiMap<K, V> bimap;
InverseSerializedForm(HashBiMap<K, V> bimap) {
diff --git a/guava/src/com/google/common/collect/HashMultimap.java b/guava/src/com/google/common/collect/HashMultimap.java
index 9e4c1c2..9297260 100644
--- a/guava/src/com/google/common/collect/HashMultimap.java
+++ b/guava/src/com/google/common/collect/HashMultimap.java
@@ -26,7 +26,6 @@
import java.util.Collection;
import java.util.Map;
import java.util.Set;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Implementation of {@link Multimap} using hash tables.
@@ -42,16 +41,11 @@
* concurrent update operations, wrap your multimap with a call to {@link
* Multimaps#synchronizedSetMultimap}.
*
- * <p><b>Warning:</b> Do not modify either a key <i>or a value</i> of a {@code HashMultimap} in a
- * way that affects its {@link Object#equals} behavior. Undefined behavior and bugs will result.
- *
* @author Jared Levy
* @since 2.0
*/
@GwtCompatible(serializable = true, emulated = true)
-@ElementTypesAreNonnullByDefault
-public final class HashMultimap<K extends @Nullable Object, V extends @Nullable Object>
- extends HashMultimapGwtSerializationDependencies<K, V> {
+public final class HashMultimap<K, V> extends HashMultimapGwtSerializationDependencies<K, V> {
private static final int DEFAULT_VALUES_PER_KEY = 2;
@VisibleForTesting transient int expectedValuesPerKey = DEFAULT_VALUES_PER_KEY;
@@ -62,8 +56,7 @@
* <p>This method will soon be deprecated in favor of {@code
* MultimapBuilder.hashKeys().hashSetValues().build()}.
*/
- public static <K extends @Nullable Object, V extends @Nullable Object>
- HashMultimap<K, V> create() {
+ public static <K, V> HashMultimap<K, V> create() {
return new HashMultimap<>();
}
@@ -79,8 +72,7 @@
* @throws IllegalArgumentException if {@code expectedKeys} or {@code expectedValuesPerKey} is
* negative
*/
- public static <K extends @Nullable Object, V extends @Nullable Object> HashMultimap<K, V> create(
- int expectedKeys, int expectedValuesPerKey) {
+ public static <K, V> HashMultimap<K, V> create(int expectedKeys, int expectedValuesPerKey) {
return new HashMultimap<>(expectedKeys, expectedValuesPerKey);
}
@@ -94,8 +86,7 @@
*
* @param multimap the multimap whose contents are copied to this multimap
*/
- public static <K extends @Nullable Object, V extends @Nullable Object> HashMultimap<K, V> create(
- Multimap<? extends K, ? extends V> multimap) {
+ public static <K, V> HashMultimap<K, V> create(Multimap<? extends K, ? extends V> multimap) {
return new HashMultimap<>(multimap);
}
diff --git a/guava/src/com/google/common/collect/HashMultiset.java b/guava/src/com/google/common/collect/HashMultiset.java
index b916457..d820434 100644
--- a/guava/src/com/google/common/collect/HashMultiset.java
+++ b/guava/src/com/google/common/collect/HashMultiset.java
@@ -22,7 +22,6 @@
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.HashMap;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Multiset implementation backed by a {@link HashMap}.
@@ -32,11 +31,10 @@
* @since 2.0
*/
@GwtCompatible(serializable = true, emulated = true)
-@ElementTypesAreNonnullByDefault
-public final class HashMultiset<E extends @Nullable Object> extends AbstractMapBasedMultiset<E> {
+public final class HashMultiset<E> extends AbstractMapBasedMultiset<E> {
/** Creates a new, empty {@code HashMultiset} using the default initial capacity. */
- public static <E extends @Nullable Object> HashMultiset<E> create() {
+ public static <E> HashMultiset<E> create() {
return new HashMultiset<E>();
}
@@ -47,7 +45,7 @@
* @param distinctElements the expected number of distinct elements
* @throws IllegalArgumentException if {@code distinctElements} is negative
*/
- public static <E extends @Nullable Object> HashMultiset<E> create(int distinctElements) {
+ public static <E> HashMultiset<E> create(int distinctElements) {
return new HashMultiset<E>(distinctElements);
}
@@ -58,8 +56,7 @@
*
* @param elements the elements that the multiset should contain
*/
- public static <E extends @Nullable Object> HashMultiset<E> create(
- Iterable<? extends E> elements) {
+ public static <E> HashMultiset<E> create(Iterable<? extends E> elements) {
HashMultiset<E> multiset = create(Multisets.inferDistinctElements(elements));
Iterables.addAll(multiset, elements);
return multiset;
diff --git a/guava/src/com/google/common/collect/Hashing.java b/guava/src/com/google/common/collect/Hashing.java
index 81ef67e..8d7c874 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 javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Static methods for implementing hash-based collections.
@@ -28,7 +28,6 @@
* @author Austin Appleby
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
final class Hashing {
private Hashing() {}
@@ -51,7 +50,7 @@
return (int) (C2 * Integer.rotateLeft((int) (hashCode * C1), 15));
}
- static int smearedHash(@CheckForNull Object o) {
+ static int smearedHash(@Nullable Object o) {
return smear((o == null) ? 0 : o.hashCode());
}
diff --git a/guava/src/com/google/common/collect/ImmutableAsList.java b/guava/src/com/google/common/collect/ImmutableAsList.java
index c397479..528a8dc 100644
--- a/guava/src/com/google/common/collect/ImmutableAsList.java
+++ b/guava/src/com/google/common/collect/ImmutableAsList.java
@@ -21,7 +21,6 @@
import java.io.InvalidObjectException;
import java.io.ObjectInputStream;
import java.io.Serializable;
-import javax.annotation.CheckForNull;
/**
* List returned by {@link ImmutableCollection#asList} that delegates {@code contains} checks to the
@@ -32,12 +31,11 @@
*/
@GwtCompatible(serializable = true, emulated = true)
@SuppressWarnings("serial")
-@ElementTypesAreNonnullByDefault
abstract class ImmutableAsList<E> extends ImmutableList<E> {
abstract ImmutableCollection<E> delegateCollection();
@Override
- public boolean contains(@CheckForNull Object target) {
+ public boolean contains(Object target) {
// The collection's contains() is at least as fast as ImmutableList's
// and is often faster.
return delegateCollection().contains(target);
diff --git a/guava/src/com/google/common/collect/ImmutableBiMap.java b/guava/src/com/google/common/collect/ImmutableBiMap.java
index 2f2e9ab..d7855c3 100644
--- a/guava/src/com/google/common/collect/ImmutableBiMap.java
+++ b/guava/src/com/google/common/collect/ImmutableBiMap.java
@@ -18,21 +18,17 @@
import static com.google.common.base.Preconditions.checkState;
import static com.google.common.collect.CollectPreconditions.checkNonnegative;
-import static java.util.Objects.requireNonNull;
import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.VisibleForTesting;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
-import com.google.errorprone.annotations.DoNotCall;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collector;
import java.util.stream.Collectors;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* A {@link BiMap} whose contents will never change, with many other important properties detailed
@@ -42,7 +38,6 @@
* @since 2.0
*/
@GwtCompatible(serializable = true, emulated = true)
-@ElementTypesAreNonnullByDefault
public abstract class ImmutableBiMap<K, V> extends ImmutableBiMapFauxverideShim<K, V>
implements BiMap<K, V> {
@@ -58,18 +53,13 @@
*
* @since 21.0
*/
- public static <T extends @Nullable Object, K, V>
- Collector<T, ?, ImmutableBiMap<K, V>> toImmutableBiMap(
- Function<? super T, ? extends K> keyFunction,
- Function<? super T, ? extends V> valueFunction) {
+ public static <T, K, V> Collector<T, ?, ImmutableBiMap<K, V>> toImmutableBiMap(
+ Function<? super T, ? extends K> keyFunction,
+ Function<? super T, ? extends V> valueFunction) {
return CollectCollectors.toImmutableBiMap(keyFunction, valueFunction);
}
- /**
- * Returns the empty bimap.
- *
- * <p><b>Performance note:</b> the instance returned is a singleton.
- */
+ /** Returns the empty bimap. */
// Casting to any type is safe because the set will never hold any elements.
@SuppressWarnings("unchecked")
public static <K, V> ImmutableBiMap<K, V> of() {
@@ -120,165 +110,7 @@
entryOf(k1, v1), entryOf(k2, v2), entryOf(k3, v3), entryOf(k4, v4), entryOf(k5, v5));
}
- /**
- * Returns an immutable map containing the given entries, in order.
- *
- * @throws IllegalArgumentException if duplicate keys or values are added
- * @since 31.0
- */
- public static <K, V> ImmutableBiMap<K, V> of(
- K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6) {
- return RegularImmutableBiMap.fromEntries(
- entryOf(k1, v1),
- entryOf(k2, v2),
- entryOf(k3, v3),
- entryOf(k4, v4),
- entryOf(k5, v5),
- entryOf(k6, v6));
- }
-
- /**
- * Returns an immutable map containing the given entries, in order.
- *
- * @throws IllegalArgumentException if duplicate keys or values are added
- * @since 31.0
- */
- public static <K, V> ImmutableBiMap<K, V> of(
- K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6, K k7, V v7) {
- return RegularImmutableBiMap.fromEntries(
- entryOf(k1, v1),
- entryOf(k2, v2),
- entryOf(k3, v3),
- entryOf(k4, v4),
- entryOf(k5, v5),
- entryOf(k6, v6),
- entryOf(k7, v7));
- }
-
- /**
- * Returns an immutable map containing the given entries, in order.
- *
- * @throws IllegalArgumentException if duplicate keys or values are added
- * @since 31.0
- */
- public static <K, V> ImmutableBiMap<K, V> of(
- K k1,
- V v1,
- K k2,
- V v2,
- K k3,
- V v3,
- K k4,
- V v4,
- K k5,
- V v5,
- K k6,
- V v6,
- K k7,
- V v7,
- K k8,
- V v8) {
- return RegularImmutableBiMap.fromEntries(
- entryOf(k1, v1),
- entryOf(k2, v2),
- entryOf(k3, v3),
- entryOf(k4, v4),
- entryOf(k5, v5),
- entryOf(k6, v6),
- entryOf(k7, v7),
- entryOf(k8, v8));
- }
-
- /**
- * Returns an immutable map containing the given entries, in order.
- *
- * @throws IllegalArgumentException if duplicate keys or values are added
- * @since 31.0
- */
- public static <K, V> ImmutableBiMap<K, V> of(
- K k1,
- V v1,
- K k2,
- V v2,
- K k3,
- V v3,
- K k4,
- V v4,
- K k5,
- V v5,
- K k6,
- V v6,
- K k7,
- V v7,
- K k8,
- V v8,
- K k9,
- V v9) {
- return RegularImmutableBiMap.fromEntries(
- entryOf(k1, v1),
- entryOf(k2, v2),
- entryOf(k3, v3),
- entryOf(k4, v4),
- entryOf(k5, v5),
- entryOf(k6, v6),
- entryOf(k7, v7),
- entryOf(k8, v8),
- entryOf(k9, v9));
- }
- /**
- * Returns an immutable map containing the given entries, in order.
- *
- * @throws IllegalArgumentException if duplicate keys or values are added
- * @since 31.0
- */
- public static <K, V> ImmutableBiMap<K, V> of(
- K k1,
- V v1,
- K k2,
- V v2,
- K k3,
- V v3,
- K k4,
- V v4,
- K k5,
- V v5,
- K k6,
- V v6,
- K k7,
- V v7,
- K k8,
- V v8,
- K k9,
- V v9,
- K k10,
- V v10) {
- return RegularImmutableBiMap.fromEntries(
- entryOf(k1, v1),
- entryOf(k2, v2),
- entryOf(k3, v3),
- entryOf(k4, v4),
- entryOf(k5, v5),
- entryOf(k6, v6),
- entryOf(k7, v7),
- entryOf(k8, v8),
- entryOf(k9, v9),
- entryOf(k10, v10));
- }
-
- // looking for of() with > 10 entries? Use the builder or ofEntries instead.
-
- /**
- * Returns an immutable map containing the given entries, in order.
- *
- * @throws IllegalArgumentException if duplicate keys or values are provided
- * @since 31.0
- */
- @SafeVarargs
- public static <K, V> ImmutableBiMap<K, V> ofEntries(Entry<? extends K, ? extends V>... entries) {
- @SuppressWarnings("unchecked") // we will only ever read these
- Entry<K, V>[] entries2 = (Entry<K, V>[]) entries;
- return RegularImmutableBiMap.fromEntries(entries2);
- }
+ // looking for of() with > 5 entries? Use the builder instead.
/**
* Returns a new builder. The generated builder is equivalent to the builder created by the {@link
@@ -316,7 +148,7 @@
* .put("one", 1)
* .put("two", 2)
* .put("three", 3)
- * .buildOrThrow();
+ * .build();
* }</pre>
*
* <p>For <i>small</i> immutable bimaps, the {@code ImmutableBiMap.of()} methods are even more
@@ -329,8 +161,8 @@
* want a different order, consider using {@link #orderEntriesByValue(Comparator)}, which changes
* this builder to sort entries by value.
*
- * <p>Builder instances can be reused - it is safe to call {@link #buildOrThrow} multiple times to
- * build multiple bimaps in series. Each bimap is a superset of the bimaps created before it.
+ * <p>Builder instances can be reused - it is safe to call {@link #build} multiple times to build
+ * multiple bimaps in series. Each bimap is a superset of the bimaps created before it.
*
* @since 2.0
*/
@@ -428,35 +260,15 @@
* order in which entries were inserted into the builder, unless {@link #orderEntriesByValue}
* was called, in which case entries are sorted by value.
*
- * <p>Prefer the equivalent method {@link #buildOrThrow()} to make it explicit that the method
- * will throw an exception if there are duplicate keys or values. The {@code build()} method
- * will soon be deprecated.
- *
* @throws IllegalArgumentException if duplicate keys or values were added
*/
@Override
public ImmutableBiMap<K, V> build() {
- return buildOrThrow();
- }
-
- /**
- * Returns a newly-created immutable bimap, or throws an exception if any key or value was added
- * more than once. The iteration order of the returned bimap is the order in which entries were
- * inserted into the builder, unless {@link #orderEntriesByValue} was called, in which case
- * entries are sorted by value.
- *
- * @throws IllegalArgumentException if duplicate keys or values were added
- * @since 31.0
- */
- @Override
- public ImmutableBiMap<K, V> buildOrThrow() {
switch (size) {
case 0:
return of();
case 1:
- // requireNonNull is safe because the first `size` elements have been filled in.
- Entry<K, V> onlyEntry = requireNonNull(entries[0]);
- return of(onlyEntry.getKey(), onlyEntry.getValue());
+ return of(entries[0].getKey(), entries[0].getValue());
default:
/*
* If entries is full, or if hash flooding is detected, then this implementation may end
@@ -490,9 +302,7 @@
case 0:
return of();
case 1:
- // requireNonNull is safe because the first `size` elements have been filled in.
- Entry<K, V> onlyEntry = requireNonNull(entries[0]);
- return of(onlyEntry.getKey(), onlyEntry.getValue());
+ return of(entries[0].getKey(), entries[0].getValue());
default:
entriesUsed = true;
return RegularImmutableBiMap.fromEntryArray(size, entries);
@@ -591,9 +401,7 @@
@CanIgnoreReturnValue
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
- @CheckForNull
- public final V forcePut(K key, V value) {
+ public V forcePut(K key, V value) {
throw new UnsupportedOperationException();
}
diff --git a/guava/src/com/google/common/collect/ImmutableBiMapFauxverideShim.java b/guava/src/com/google/common/collect/ImmutableBiMapFauxverideShim.java
index 2f1f25c..dd787d5 100644
--- a/guava/src/com/google/common/collect/ImmutableBiMapFauxverideShim.java
+++ b/guava/src/com/google/common/collect/ImmutableBiMapFauxverideShim.java
@@ -17,11 +17,9 @@
package com.google.common.collect;
import com.google.common.annotations.GwtIncompatible;
-import com.google.errorprone.annotations.DoNotCall;
import java.util.function.BinaryOperator;
import java.util.function.Function;
import java.util.stream.Collector;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* "Overrides" the {@link ImmutableMap} static methods that lack {@link ImmutableBiMap} equivalents
@@ -31,7 +29,6 @@
* @author Louis Wasserman
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
abstract class ImmutableBiMapFauxverideShim<K, V> extends ImmutableMap<K, V> {
/**
* Not supported. Use {@link ImmutableBiMap#toImmutableBiMap} instead. This method exists only to
@@ -42,11 +39,9 @@
* @deprecated Use {@link ImmutableBiMap#toImmutableBiMap}.
*/
@Deprecated
- @DoNotCall("Use toImmutableBiMap")
- public static <T extends @Nullable Object, K, V>
- Collector<T, ?, ImmutableMap<K, V>> toImmutableMap(
- Function<? super T, ? extends K> keyFunction,
- Function<? super T, ? extends V> valueFunction) {
+ public static <T, K, V> Collector<T, ?, ImmutableMap<K, V>> toImmutableMap(
+ Function<? super T, ? extends K> keyFunction,
+ Function<? super T, ? extends V> valueFunction) {
throw new UnsupportedOperationException();
}
@@ -59,12 +54,10 @@
* @deprecated
*/
@Deprecated
- @DoNotCall("Use toImmutableBiMap")
- public static <T extends @Nullable Object, K, V>
- Collector<T, ?, ImmutableMap<K, V>> toImmutableMap(
- Function<? super T, ? extends K> keyFunction,
- Function<? super T, ? extends V> valueFunction,
- BinaryOperator<V> mergeFunction) {
+ public static <T, K, V> Collector<T, ?, ImmutableMap<K, V>> toImmutableMap(
+ Function<? super T, ? extends K> keyFunction,
+ Function<? super T, ? extends V> valueFunction,
+ BinaryOperator<V> mergeFunction) {
throw new UnsupportedOperationException();
}
}
diff --git a/guava/src/com/google/common/collect/ImmutableClassToInstanceMap.java b/guava/src/com/google/common/collect/ImmutableClassToInstanceMap.java
index aeabe5d..8370f0a 100644
--- a/guava/src/com/google/common/collect/ImmutableClassToInstanceMap.java
+++ b/guava/src/com/google/common/collect/ImmutableClassToInstanceMap.java
@@ -21,11 +21,10 @@
import com.google.common.annotations.GwtIncompatible;
import com.google.common.primitives.Primitives;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
-import com.google.errorprone.annotations.DoNotCall;
import com.google.errorprone.annotations.Immutable;
import java.io.Serializable;
import java.util.Map;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* A {@link ClassToInstanceMap} whose contents will never change, with many other important
@@ -36,7 +35,6 @@
*/
@Immutable(containerOf = "B")
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public final class ImmutableClassToInstanceMap<B> extends ForwardingMap<Class<? extends B>, B>
implements ClassToInstanceMap<B>, Serializable {
@@ -46,8 +44,6 @@
/**
* Returns an empty {@code ImmutableClassToInstanceMap}.
*
- * <p><b>Performance note:</b> the instance returned is a singleton.
- *
* @since 19.0
*/
@SuppressWarnings("unchecked")
@@ -174,8 +170,7 @@
@Override
@SuppressWarnings("unchecked") // value could not get in if not a T
- @CheckForNull
- public <T extends B> T getInstance(Class<T> type) {
+ public <T extends B> @Nullable T getInstance(Class<T> type) {
return (T) delegate.get(checkNotNull(type));
}
@@ -188,8 +183,6 @@
@CanIgnoreReturnValue
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
- @CheckForNull
public <T extends B> T putInstance(Class<T> type, T value) {
throw new UnsupportedOperationException();
}
diff --git a/guava/src/com/google/common/collect/ImmutableCollection.java b/guava/src/com/google/common/collect/ImmutableCollection.java
index 80fefb6..5a76efa 100644
--- a/guava/src/com/google/common/collect/ImmutableCollection.java
+++ b/guava/src/com/google/common/collect/ImmutableCollection.java
@@ -20,7 +20,6 @@
import com.google.common.annotations.GwtCompatible;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
-import com.google.errorprone.annotations.DoNotCall;
import com.google.errorprone.annotations.DoNotMock;
import java.io.Serializable;
import java.util.AbstractCollection;
@@ -32,7 +31,6 @@
import java.util.Spliterator;
import java.util.Spliterators;
import java.util.function.Predicate;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -163,7 +161,6 @@
@DoNotMock("Use ImmutableList.of or another implementation")
@GwtCompatible(emulated = true)
@SuppressWarnings("serial") // we're overriding default serialization
-@ElementTypesAreNonnullByDefault
// TODO(kevinb): I think we should push everything down to "BaseImmutableCollection" or something,
// just to do everything we can to emphasize the "practically an interface" nature of this class.
public abstract class ImmutableCollection<E> extends AbstractCollection<E> implements Serializable {
@@ -195,20 +192,7 @@
@CanIgnoreReturnValue
@Override
- /*
- * This suppression is here for two reasons:
- *
- * 1. b/192354773 in our checker affects toArray declarations.
- *
- * 2. `other[size] = null` is unsound. We could "fix" this by requiring callers to pass in an
- * array with a nullable element type. But probably they usually want an array with a non-nullable
- * type. That said, we could *accept* a `@Nullable T[]` (which, given that we treat arrays as
- * covariant, would still permit a plain `T[]`) and return a plain `T[]`. But of course that would
- * require its own suppression, since it is also unsound. toArray(T[]) is just a mess from a
- * nullness perspective. The signature below at least has the virtue of being relatively simple.
- */
- @SuppressWarnings("nullness")
- public final <T extends @Nullable Object> T[] toArray(T[] other) {
+ public final <T> T[] toArray(T[] other) {
checkNotNull(other);
int size = size();
@@ -226,8 +210,7 @@
}
/** If this collection is backed by an array of its elements in insertion order, returns it. */
- @CheckForNull
- Object[] internalArray() {
+ Object @Nullable [] internalArray() {
return null;
}
@@ -248,7 +231,7 @@
}
@Override
- public abstract boolean contains(@CheckForNull Object object);
+ public abstract boolean contains(@Nullable Object object);
/**
* Guaranteed to throw an exception and leave the collection unmodified.
@@ -259,7 +242,6 @@
@CanIgnoreReturnValue
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
public final boolean add(E e) {
throw new UnsupportedOperationException();
}
@@ -273,8 +255,7 @@
@CanIgnoreReturnValue
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
- public final boolean remove(@CheckForNull Object object) {
+ public final boolean remove(Object object) {
throw new UnsupportedOperationException();
}
@@ -287,7 +268,6 @@
@CanIgnoreReturnValue
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
public final boolean addAll(Collection<? extends E> newElements) {
throw new UnsupportedOperationException();
}
@@ -301,7 +281,6 @@
@CanIgnoreReturnValue
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
public final boolean removeAll(Collection<?> oldElements) {
throw new UnsupportedOperationException();
}
@@ -315,7 +294,6 @@
@CanIgnoreReturnValue
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
public final boolean removeIf(Predicate<? super E> filter) {
throw new UnsupportedOperationException();
}
@@ -328,7 +306,6 @@
*/
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
public final boolean retainAll(Collection<?> elementsToKeep) {
throw new UnsupportedOperationException();
}
@@ -341,7 +318,6 @@
*/
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
public final void clear() {
throw new UnsupportedOperationException();
}
@@ -380,7 +356,7 @@
* offset. Returns {@code offset + size()}.
*/
@CanIgnoreReturnValue
- int copyIntoArray(@Nullable Object[] dst, int offset) {
+ int copyIntoArray(Object[] dst, int offset) {
for (E e : this) {
dst[offset++] = e;
}
diff --git a/guava/src/com/google/common/collect/ImmutableEntry.java b/guava/src/com/google/common/collect/ImmutableEntry.java
index edc25f4..0f435e9 100644
--- a/guava/src/com/google/common/collect/ImmutableEntry.java
+++ b/guava/src/com/google/common/collect/ImmutableEntry.java
@@ -22,32 +22,27 @@
/** @see com.google.common.collect.Maps#immutableEntry(Object, Object) */
@GwtCompatible(serializable = true)
-@ElementTypesAreNonnullByDefault
-class ImmutableEntry<K extends @Nullable Object, V extends @Nullable Object>
- extends AbstractMapEntry<K, V> implements Serializable {
- @ParametricNullness final K key;
- @ParametricNullness final V value;
+class ImmutableEntry<K, V> extends AbstractMapEntry<K, V> implements Serializable {
+ final @Nullable K key;
+ final @Nullable V value;
- ImmutableEntry(@ParametricNullness K key, @ParametricNullness V value) {
+ ImmutableEntry(@Nullable K key, @Nullable V value) {
this.key = key;
this.value = value;
}
@Override
- @ParametricNullness
- public final K getKey() {
+ public final @Nullable K getKey() {
return key;
}
@Override
- @ParametricNullness
- public final V getValue() {
+ public final @Nullable V getValue() {
return value;
}
@Override
- @ParametricNullness
- public final V setValue(@ParametricNullness V value) {
+ public final V setValue(V value) {
throw new UnsupportedOperationException();
}
diff --git a/guava/src/com/google/common/collect/ImmutableEnumMap.java b/guava/src/com/google/common/collect/ImmutableEnumMap.java
index d1e10f9..f12e1a9 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 javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Implementation of {@link ImmutableMap} backed by a non-empty {@link java.util.EnumMap}.
@@ -33,7 +33,6 @@
*/
@GwtCompatible(serializable = true, emulated = true)
@SuppressWarnings("serial") // we're overriding default serialization
-@ElementTypesAreNonnullByDefault
final class ImmutableEnumMap<K extends Enum<K>, V> extends IteratorBasedImmutableMap<K, V> {
static <K extends Enum<K>, V> ImmutableMap<K, V> asImmutable(EnumMap<K, V> map) {
switch (map.size()) {
@@ -70,18 +69,17 @@
}
@Override
- public boolean containsKey(@CheckForNull Object key) {
+ public boolean containsKey(@Nullable Object key) {
return delegate.containsKey(key);
}
@Override
- @CheckForNull
- public V get(@CheckForNull Object key) {
+ public V get(Object key) {
return delegate.get(key);
}
@Override
- public boolean equals(@CheckForNull Object object) {
+ public boolean equals(Object object) {
if (object == this) {
return true;
}
diff --git a/guava/src/com/google/common/collect/ImmutableEnumSet.java b/guava/src/com/google/common/collect/ImmutableEnumSet.java
index 32287bd..5677cbe 100644
--- a/guava/src/com/google/common/collect/ImmutableEnumSet.java
+++ b/guava/src/com/google/common/collect/ImmutableEnumSet.java
@@ -23,7 +23,6 @@
import java.util.EnumSet;
import java.util.Spliterator;
import java.util.function.Consumer;
-import javax.annotation.CheckForNull;
/**
* Implementation of {@link ImmutableSet} backed by a non-empty {@link java.util.EnumSet}.
@@ -32,7 +31,6 @@
*/
@GwtCompatible(serializable = true, emulated = true)
@SuppressWarnings("serial") // we're overriding default serialization
-@ElementTypesAreNonnullByDefault
final class ImmutableEnumSet<E extends Enum<E>> extends ImmutableSet<E> {
@SuppressWarnings("rawtypes") // necessary to compile against Java 8
static ImmutableSet asImmutable(EnumSet set) {
@@ -86,7 +84,7 @@
}
@Override
- public boolean contains(@CheckForNull Object object) {
+ public boolean contains(Object object) {
return delegate.contains(object);
}
@@ -104,7 +102,7 @@
}
@Override
- public boolean equals(@CheckForNull Object object) {
+ public boolean equals(Object object) {
if (object == this) {
return true;
}
diff --git a/guava/src/com/google/common/collect/ImmutableList.java b/guava/src/com/google/common/collect/ImmutableList.java
index 115c022..05e7088 100644
--- a/guava/src/com/google/common/collect/ImmutableList.java
+++ b/guava/src/com/google/common/collect/ImmutableList.java
@@ -23,14 +23,11 @@
import static com.google.common.collect.CollectPreconditions.checkNonnegative;
import static com.google.common.collect.ObjectArrays.checkElementsNotNull;
import static com.google.common.collect.RegularImmutableList.EMPTY;
-import static java.util.Objects.requireNonNull;
import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.VisibleForTesting;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
-import com.google.errorprone.annotations.DoNotCall;
-import com.google.errorprone.annotations.InlineMe;
import java.io.InvalidObjectException;
import java.io.ObjectInputStream;
import java.io.Serializable;
@@ -45,7 +42,6 @@
import java.util.function.Consumer;
import java.util.function.UnaryOperator;
import java.util.stream.Collector;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -62,7 +58,6 @@
*/
@GwtCompatible(serializable = true, emulated = true)
@SuppressWarnings("serial") // we're overriding default serialization
-@ElementTypesAreNonnullByDefault
public abstract class ImmutableList<E> extends ImmutableCollection<E>
implements List<E>, RandomAccess {
@@ -80,8 +75,6 @@
* Returns the empty immutable list. This list behaves and performs comparably to {@link
* Collections#emptyList}, and is preferable mainly for consistency and maintainability of your
* code.
- *
- * <p><b>Performance note:</b> the instance returned is a singleton.
*/
// Casting to any type is safe because the list will never hold any elements.
@SuppressWarnings("unchecked")
@@ -366,27 +359,17 @@
* Views the array as an immutable list. Copies if the specified range does not cover the complete
* array. Does not check for nulls.
*/
- static <E> ImmutableList<E> asImmutableList(@Nullable Object[] elements, int length) {
+ static <E> ImmutableList<E> asImmutableList(Object[] elements, int length) {
switch (length) {
case 0:
return of();
case 1:
- /*
- * requireNonNull is safe because the callers promise to put non-null objects in the first
- * `length` array elements.
- */
- @SuppressWarnings("unchecked") // our callers put only E instances into the array
- E onlyElement = (E) requireNonNull(elements[0]);
- return of(onlyElement);
+ return of((E) elements[0]);
default:
- /*
- * The suppression is safe because the callers promise to put non-null objects in the first
- * `length` array elements.
- */
- @SuppressWarnings("nullness")
- Object[] elementsWithoutTrailingNulls =
- length < elements.length ? Arrays.copyOf(elements, length) : elements;
- return new RegularImmutableList<E>(elementsWithoutTrailingNulls);
+ if (length < elements.length) {
+ elements = Arrays.copyOf(elements, length);
+ }
+ return new RegularImmutableList<E>(elements);
}
}
@@ -424,17 +407,17 @@
}
@Override
- public int indexOf(@CheckForNull Object object) {
+ public int indexOf(@Nullable Object object) {
return (object == null) ? -1 : Lists.indexOfImpl(this, object);
}
@Override
- public int lastIndexOf(@CheckForNull Object object) {
+ public int lastIndexOf(@Nullable Object object) {
return (object == null) ? -1 : Lists.lastIndexOfImpl(this, object);
}
@Override
- public boolean contains(@CheckForNull Object object) {
+ public boolean contains(@Nullable Object object) {
return indexOf(object) >= 0;
}
@@ -509,7 +492,6 @@
@CanIgnoreReturnValue
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
public final boolean addAll(int index, Collection<? extends E> newElements) {
throw new UnsupportedOperationException();
}
@@ -523,7 +505,6 @@
@CanIgnoreReturnValue
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
public final E set(int index, E element) {
throw new UnsupportedOperationException();
}
@@ -536,7 +517,6 @@
*/
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
public final void add(int index, E element) {
throw new UnsupportedOperationException();
}
@@ -550,7 +530,6 @@
@CanIgnoreReturnValue
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
public final E remove(int index) {
throw new UnsupportedOperationException();
}
@@ -563,7 +542,6 @@
*/
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
public final void replaceAll(UnaryOperator<E> operator) {
throw new UnsupportedOperationException();
}
@@ -576,7 +554,6 @@
*/
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
public final void sort(Comparator<? super E> c) {
throw new UnsupportedOperationException();
}
@@ -585,10 +562,7 @@
* Returns this list instance.
*
* @since 2.0
- * @deprecated There is no reason to use this; it always returns {@code this}.
*/
- @InlineMe(replacement = "this")
- @Deprecated
@Override
public final ImmutableList<E> asList() {
return this;
@@ -600,7 +574,7 @@
}
@Override
- int copyIntoArray(@Nullable Object[] dst, int offset) {
+ int copyIntoArray(Object[] dst, int offset) {
// this loop is faster for RandomAccess instances, which ImmutableLists are
int size = size();
for (int i = 0; i < size; i++) {
@@ -641,18 +615,18 @@
}
@Override
- public boolean contains(@CheckForNull Object object) {
+ public boolean contains(@Nullable Object object) {
return forwardList.contains(object);
}
@Override
- public int indexOf(@CheckForNull Object object) {
+ public int indexOf(@Nullable Object object) {
int index = forwardList.lastIndexOf(object);
return (index >= 0) ? reverseIndex(index) : -1;
}
@Override
- public int lastIndexOf(@CheckForNull Object object) {
+ public int lastIndexOf(@Nullable Object object) {
int index = forwardList.indexOf(object);
return (index >= 0) ? reverseIndex(index) : -1;
}
@@ -681,7 +655,7 @@
}
@Override
- public boolean equals(@CheckForNull Object obj) {
+ public boolean equals(@Nullable Object obj) {
return Lists.equalsImpl(this, obj);
}
@@ -772,8 +746,7 @@
* @since 2.0
*/
public static final class Builder<E> extends ImmutableCollection.Builder<E> {
- // The first `size` elements are non-null.
- @VisibleForTesting @Nullable Object[] contents;
+ @VisibleForTesting Object[] contents;
private int size;
private boolean forceCopy;
@@ -786,7 +759,7 @@
}
Builder(int capacity) {
- this.contents = new @Nullable Object[capacity];
+ this.contents = new Object[capacity];
this.size = 0;
}
@@ -831,16 +804,8 @@
return this;
}
- private void add(@Nullable Object[] elements, int n) {
+ private void add(Object[] elements, int n) {
getReadyToExpandTo(size + n);
- /*
- * The following call is not statically checked, since arraycopy accepts plain Object for its
- * parameters. If it were statically checked, the checker would still be OK with it, since
- * we're copying into a `contents` array whose type allows it to contain nulls. Still, it's
- * worth noting that we promise not to put nulls into the array in the first `size` elements.
- * We uphold that promise here because our callers promise that `elements` will not contain
- * nulls in its first `n` elements.
- */
System.arraycopy(elements, 0, contents, size, n);
size += n;
}
diff --git a/guava/src/com/google/common/collect/ImmutableListMultimap.java b/guava/src/com/google/common/collect/ImmutableListMultimap.java
index f847016..879c71e 100644
--- a/guava/src/com/google/common/collect/ImmutableListMultimap.java
+++ b/guava/src/com/google/common/collect/ImmutableListMultimap.java
@@ -16,12 +16,13 @@
package com.google.common.collect;
+import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.GwtIncompatible;
+import com.google.common.base.Preconditions;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
-import com.google.errorprone.annotations.DoNotCall;
import com.google.errorprone.annotations.concurrent.LazyInit;
import com.google.j2objc.annotations.RetainedWith;
import java.io.IOException;
@@ -34,8 +35,8 @@
import java.util.Map.Entry;
import java.util.function.Function;
import java.util.stream.Collector;
+import java.util.stream.Collectors;
import java.util.stream.Stream;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -49,7 +50,6 @@
* @since 2.0
*/
@GwtCompatible(serializable = true, emulated = true)
-@ElementTypesAreNonnullByDefault
public class ImmutableListMultimap<K, V> extends ImmutableMultimap<K, V>
implements ListMultimap<K, V> {
/**
@@ -80,11 +80,16 @@
*
* @since 21.0
*/
- public static <T extends @Nullable Object, K, V>
- Collector<T, ?, ImmutableListMultimap<K, V>> toImmutableListMultimap(
- Function<? super T, ? extends K> keyFunction,
- Function<? super T, ? extends V> valueFunction) {
- return CollectCollectors.toImmutableListMultimap(keyFunction, valueFunction);
+ public static <T, K, V> Collector<T, ?, ImmutableListMultimap<K, V>> toImmutableListMultimap(
+ Function<? super T, ? extends K> keyFunction,
+ Function<? super T, ? extends V> valueFunction) {
+ checkNotNull(keyFunction, "keyFunction");
+ checkNotNull(valueFunction, "valueFunction");
+ return Collector.of(
+ ImmutableListMultimap::<K, V>builder,
+ (builder, t) -> builder.put(keyFunction.apply(t), valueFunction.apply(t)),
+ ImmutableListMultimap.Builder::combine,
+ ImmutableListMultimap.Builder::build);
}
/**
@@ -118,18 +123,21 @@
*
* @since 21.0
*/
- public static <T extends @Nullable Object, K, V>
+ public static <T, K, V>
Collector<T, ?, ImmutableListMultimap<K, V>> flatteningToImmutableListMultimap(
Function<? super T, ? extends K> keyFunction,
Function<? super T, ? extends Stream<? extends V>> valuesFunction) {
- return CollectCollectors.flatteningToImmutableListMultimap(keyFunction, valuesFunction);
+ checkNotNull(keyFunction);
+ checkNotNull(valuesFunction);
+ return Collectors.collectingAndThen(
+ Multimaps.flatteningToMultimap(
+ input -> checkNotNull(keyFunction.apply(input)),
+ input -> valuesFunction.apply(input).peek(Preconditions::checkNotNull),
+ MultimapBuilder.linkedHashKeys().arrayListValues()::<K, V>build),
+ ImmutableListMultimap::copyOf);
}
- /**
- * Returns the empty multimap.
- *
- * <p><b>Performance note:</b> the instance returned is a singleton.
- */
+ /** Returns the empty multimap. */
// Casting is safe because the multimap will never hold any elements.
@SuppressWarnings("unchecked")
public static <K, V> ImmutableListMultimap<K, V> of() {
@@ -392,13 +400,13 @@
* parameters used to build this multimap.
*/
@Override
- public ImmutableList<V> get(K key) {
+ public ImmutableList<V> get(@Nullable K key) {
// This cast is safe as its type is known in constructor.
ImmutableList<V> list = (ImmutableList<V>) map.get(key);
return (list == null) ? ImmutableList.<V>of() : list;
}
- @LazyInit @RetainedWith @CheckForNull private transient ImmutableListMultimap<V, K> inverse;
+ @LazyInit @RetainedWith private transient ImmutableListMultimap<V, K> inverse;
/**
* {@inheritDoc}
@@ -434,8 +442,7 @@
@CanIgnoreReturnValue
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
- public final ImmutableList<V> removeAll(@CheckForNull Object key) {
+ public ImmutableList<V> removeAll(Object key) {
throw new UnsupportedOperationException();
}
@@ -448,8 +455,7 @@
@CanIgnoreReturnValue
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
- public final ImmutableList<V> replaceValues(K key, Iterable<? extends V> values) {
+ public ImmutableList<V> replaceValues(K key, Iterable<? extends V> values) {
throw new UnsupportedOperationException();
}
diff --git a/guava/src/com/google/common/collect/ImmutableMap.java b/guava/src/com/google/common/collect/ImmutableMap.java
index 23335b2..5c24df2 100644
--- a/guava/src/com/google/common/collect/ImmutableMap.java
+++ b/guava/src/com/google/common/collect/ImmutableMap.java
@@ -20,13 +20,11 @@
import static com.google.common.base.Preconditions.checkState;
import static com.google.common.collect.CollectPreconditions.checkEntryNotNull;
import static com.google.common.collect.CollectPreconditions.checkNonnegative;
-import static java.util.Objects.requireNonNull;
import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.VisibleForTesting;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
-import com.google.errorprone.annotations.DoNotCall;
import com.google.errorprone.annotations.DoNotMock;
import com.google.errorprone.annotations.concurrent.LazyInit;
import com.google.j2objc.annotations.RetainedWith;
@@ -39,6 +37,7 @@
import java.util.Comparator;
import java.util.EnumMap;
import java.util.Iterator;
+import java.util.LinkedHashMap;
import java.util.Map;
import java.util.SortedMap;
import java.util.Spliterator;
@@ -48,7 +47,6 @@
import java.util.function.Function;
import java.util.stream.Collector;
import java.util.stream.Collectors;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -65,7 +63,6 @@
@DoNotMock("Use ImmutableMap.of or another implementation")
@GwtCompatible(serializable = true, emulated = true)
@SuppressWarnings("serial") // we're overriding default serialization
-@ElementTypesAreNonnullByDefault
public abstract class ImmutableMap<K, V> implements Map<K, V>, Serializable {
/**
@@ -80,10 +77,9 @@
*
* @since 21.0
*/
- public static <T extends @Nullable Object, K, V>
- Collector<T, ?, ImmutableMap<K, V>> toImmutableMap(
- Function<? super T, ? extends K> keyFunction,
- Function<? super T, ? extends V> valueFunction) {
+ public static <T, K, V> Collector<T, ?, ImmutableMap<K, V>> toImmutableMap(
+ Function<? super T, ? extends K> keyFunction,
+ Function<? super T, ? extends V> valueFunction) {
return CollectCollectors.toImmutableMap(keyFunction, valueFunction);
}
@@ -97,20 +93,22 @@
*
* @since 21.0
*/
- public static <T extends @Nullable Object, K, V>
- Collector<T, ?, ImmutableMap<K, V>> toImmutableMap(
- Function<? super T, ? extends K> keyFunction,
- Function<? super T, ? extends V> valueFunction,
- BinaryOperator<V> mergeFunction) {
- return CollectCollectors.toImmutableMap(keyFunction, valueFunction, mergeFunction);
+ public static <T, K, V> Collector<T, ?, ImmutableMap<K, V>> toImmutableMap(
+ Function<? super T, ? extends K> keyFunction,
+ Function<? super T, ? extends V> valueFunction,
+ BinaryOperator<V> mergeFunction) {
+ checkNotNull(keyFunction);
+ checkNotNull(valueFunction);
+ checkNotNull(mergeFunction);
+ return Collectors.collectingAndThen(
+ Collectors.toMap(keyFunction, valueFunction, mergeFunction, LinkedHashMap::new),
+ ImmutableMap::copyOf);
}
/**
* Returns the empty map. This map behaves and performs comparably to {@link
* Collections#emptyMap}, and is preferable mainly for consistency and maintainability of your
* code.
- *
- * <p><b>Performance note:</b> the instance returned is a singleton.
*/
@SuppressWarnings("unchecked")
public static <K, V> ImmutableMap<K, V> of() {
@@ -165,166 +163,7 @@
entryOf(k1, v1), entryOf(k2, v2), entryOf(k3, v3), entryOf(k4, v4), entryOf(k5, v5));
}
- /**
- * Returns an immutable map containing the given entries, in order.
- *
- * @throws IllegalArgumentException if duplicate keys are provided
- * @since 31.0
- */
- public static <K, V> ImmutableMap<K, V> of(
- K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6) {
- return RegularImmutableMap.fromEntries(
- entryOf(k1, v1),
- entryOf(k2, v2),
- entryOf(k3, v3),
- entryOf(k4, v4),
- entryOf(k5, v5),
- entryOf(k6, v6));
- }
-
- /**
- * Returns an immutable map containing the given entries, in order.
- *
- * @throws IllegalArgumentException if duplicate keys are provided
- * @since 31.0
- */
- public static <K, V> ImmutableMap<K, V> of(
- K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6, K k7, V v7) {
- return RegularImmutableMap.fromEntries(
- entryOf(k1, v1),
- entryOf(k2, v2),
- entryOf(k3, v3),
- entryOf(k4, v4),
- entryOf(k5, v5),
- entryOf(k6, v6),
- entryOf(k7, v7));
- }
-
- /**
- * Returns an immutable map containing the given entries, in order.
- *
- * @throws IllegalArgumentException if duplicate keys are provided
- * @since 31.0
- */
- public static <K, V> ImmutableMap<K, V> of(
- K k1,
- V v1,
- K k2,
- V v2,
- K k3,
- V v3,
- K k4,
- V v4,
- K k5,
- V v5,
- K k6,
- V v6,
- K k7,
- V v7,
- K k8,
- V v8) {
- return RegularImmutableMap.fromEntries(
- entryOf(k1, v1),
- entryOf(k2, v2),
- entryOf(k3, v3),
- entryOf(k4, v4),
- entryOf(k5, v5),
- entryOf(k6, v6),
- entryOf(k7, v7),
- entryOf(k8, v8));
- }
-
- /**
- * Returns an immutable map containing the given entries, in order.
- *
- * @throws IllegalArgumentException if duplicate keys are provided
- * @since 31.0
- */
- public static <K, V> ImmutableMap<K, V> of(
- K k1,
- V v1,
- K k2,
- V v2,
- K k3,
- V v3,
- K k4,
- V v4,
- K k5,
- V v5,
- K k6,
- V v6,
- K k7,
- V v7,
- K k8,
- V v8,
- K k9,
- V v9) {
- return RegularImmutableMap.fromEntries(
- entryOf(k1, v1),
- entryOf(k2, v2),
- entryOf(k3, v3),
- entryOf(k4, v4),
- entryOf(k5, v5),
- entryOf(k6, v6),
- entryOf(k7, v7),
- entryOf(k8, v8),
- entryOf(k9, v9));
- }
-
- /**
- * Returns an immutable map containing the given entries, in order.
- *
- * @throws IllegalArgumentException if duplicate keys are provided
- * @since 31.0
- */
- public static <K, V> ImmutableMap<K, V> of(
- K k1,
- V v1,
- K k2,
- V v2,
- K k3,
- V v3,
- K k4,
- V v4,
- K k5,
- V v5,
- K k6,
- V v6,
- K k7,
- V v7,
- K k8,
- V v8,
- K k9,
- V v9,
- K k10,
- V v10) {
- return RegularImmutableMap.fromEntries(
- entryOf(k1, v1),
- entryOf(k2, v2),
- entryOf(k3, v3),
- entryOf(k4, v4),
- entryOf(k5, v5),
- entryOf(k6, v6),
- entryOf(k7, v7),
- entryOf(k8, v8),
- entryOf(k9, v9),
- entryOf(k10, v10));
- }
-
- // looking for of() with > 10 entries? Use the builder or ofEntries instead.
-
- /**
- * Returns an immutable map containing the given entries, in order.
- *
- * @throws IllegalArgumentException if duplicate keys are provided
- * @since 31.0
- */
- @SafeVarargs
- public static <K, V> ImmutableMap<K, V> ofEntries(Entry<? extends K, ? extends V>... entries) {
- @SuppressWarnings("unchecked") // we will only ever read these
- Entry<K, V>[] entries2 = (Entry<K, V>[]) entries;
- return RegularImmutableMap.fromEntries(entries2);
- }
+ // looking for of() with > 5 entries? Use the builder instead.
/**
* Verifies that {@code key} and {@code value} are non-null, and returns a new immutable entry
@@ -387,7 +226,7 @@
* .put("one", 1)
* .put("two", 2)
* .put("three", 3)
- * .buildOrThrow();
+ * .build();
* }</pre>
*
* <p>For <i>small</i> immutable maps, the {@code ImmutableMap.of()} methods are even more
@@ -401,15 +240,15 @@
* sort by keys, or call {@link #orderEntriesByValue(Comparator)}, which changes this builder to
* sort entries by value.
*
- * <p>Builder instances can be reused - it is safe to call {@link #buildOrThrow} multiple times to
- * build multiple maps in series. Each map is a superset of the maps created before it.
+ * <p>Builder instances can be reused - it is safe to call {@link #build} multiple times to build
+ * multiple maps in series. Each map is a superset of the maps created before it.
*
* @since 2.0
*/
@DoNotMock
public static class Builder<K, V> {
- @CheckForNull Comparator<? super V> valueComparator;
- @Nullable Entry<K, V>[] entries;
+ @Nullable Comparator<? super V> valueComparator;
+ Entry<K, V>[] entries;
int size;
boolean entriesUsed;
@@ -421,9 +260,9 @@
this(ImmutableCollection.Builder.DEFAULT_INITIAL_CAPACITY);
}
- @SuppressWarnings({"unchecked", "rawtypes"})
+ @SuppressWarnings("unchecked")
Builder(int initialCapacity) {
- this.entries = new @Nullable Entry[initialCapacity];
+ this.entries = new Entry[initialCapacity];
this.size = 0;
this.entriesUsed = false;
}
@@ -528,26 +367,9 @@
* in which entries were inserted into the builder, unless {@link #orderEntriesByValue} was
* called, in which case entries are sorted by value.
*
- * <p>Prefer the equivalent method {@link #buildOrThrow()} to make it explicit that the method
- * will throw an exception if there are duplicate keys. The {@code build()} method will soon be
- * deprecated.
- *
* @throws IllegalArgumentException if duplicate keys were added
*/
public ImmutableMap<K, V> build() {
- return buildOrThrow();
- }
-
- /**
- * Returns a newly-created immutable map, or throws an exception if any key was added more than
- * once. The iteration order of the returned map is the order in which entries were inserted
- * into the builder, unless {@link #orderEntriesByValue} was called, in which case entries are
- * sorted by value.
- *
- * @throws IllegalArgumentException if duplicate keys were added
- * @since 31.0
- */
- public ImmutableMap<K, V> buildOrThrow() {
/*
* If entries is full, or if hash flooding is detected, then this implementation may end up
* using the entries array directly and writing over the entry objects with non-terminal
@@ -566,9 +388,7 @@
case 0:
return of();
case 1:
- // requireNonNull is safe because the first `size` elements have been filled in.
- Entry<K, V> onlyEntry = requireNonNull(entries[0]);
- return of(onlyEntry.getKey(), onlyEntry.getValue());
+ return of(entries[0].getKey(), entries[0].getValue());
default:
entriesUsed = true;
return RegularImmutableMap.fromEntryArray(size, entries);
@@ -583,9 +403,7 @@
case 0:
return of();
case 1:
- // requireNonNull is safe because the first `size` elements have been filled in.
- Entry<K, V> onlyEntry = requireNonNull(entries[0]);
- return of(onlyEntry.getKey(), onlyEntry.getValue());
+ return of(entries[0].getKey(), entries[0].getValue());
default:
entriesUsed = true;
return JdkBackedImmutableMap.create(size, entries);
@@ -637,8 +455,7 @@
case 0:
return of();
case 1:
- // requireNonNull is safe because the first `size` elements have been filled in.
- Entry<K, V> onlyEntry = requireNonNull(entryArray[0]);
+ Entry<K, V> onlyEntry = entryArray[0];
return of(onlyEntry.getKey(), onlyEntry.getValue());
default:
/*
@@ -652,7 +469,7 @@
private static <K extends Enum<K>, V> ImmutableMap<K, V> copyOfEnumMap(
EnumMap<K, ? extends V> original) {
EnumMap<K, V> copy = new EnumMap<>(original);
- for (Entry<K, V> entry : copy.entrySet()) {
+ for (Entry<?, ?> entry : copy.entrySet()) {
checkEntryNotNull(entry.getKey(), entry.getValue());
}
return ImmutableEnumMap.asImmutable(copy);
@@ -708,8 +525,6 @@
@CanIgnoreReturnValue
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
- @CheckForNull
public final V put(K k, V v) {
throw new UnsupportedOperationException();
}
@@ -723,8 +538,6 @@
@CanIgnoreReturnValue
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
- @CheckForNull
public final V putIfAbsent(K key, V value) {
throw new UnsupportedOperationException();
}
@@ -737,7 +550,6 @@
*/
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
public final boolean replace(K key, V oldValue, V newValue) {
throw new UnsupportedOperationException();
}
@@ -750,8 +562,6 @@
*/
@Deprecated
@Override
- @CheckForNull
- @DoNotCall("Always throws UnsupportedOperationException")
public final V replace(K key, V value) {
throw new UnsupportedOperationException();
}
@@ -764,7 +574,6 @@
*/
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
public final V computeIfAbsent(K key, Function<? super K, ? extends V> mappingFunction) {
throw new UnsupportedOperationException();
}
@@ -777,7 +586,6 @@
*/
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
public final V computeIfPresent(
K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction) {
throw new UnsupportedOperationException();
@@ -791,9 +599,7 @@
*/
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
- public final V compute(
- K key, BiFunction<? super K, ? super @Nullable V, ? extends V> remappingFunction) {
+ public final V compute(K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction) {
throw new UnsupportedOperationException();
}
@@ -805,7 +611,6 @@
*/
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
public final V merge(
K key, V value, BiFunction<? super V, ? super V, ? extends V> remappingFunction) {
throw new UnsupportedOperationException();
@@ -819,7 +624,6 @@
*/
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
public final void putAll(Map<? extends K, ? extends V> map) {
throw new UnsupportedOperationException();
}
@@ -832,7 +636,6 @@
*/
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
public final void replaceAll(BiFunction<? super K, ? super V, ? extends V> function) {
throw new UnsupportedOperationException();
}
@@ -845,9 +648,7 @@
*/
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
- @CheckForNull
- public final V remove(@CheckForNull Object o) {
+ public final V remove(Object o) {
throw new UnsupportedOperationException();
}
@@ -859,8 +660,7 @@
*/
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
- public final boolean remove(@CheckForNull Object key, @CheckForNull Object value) {
+ public final boolean remove(Object key, Object value) {
throw new UnsupportedOperationException();
}
@@ -872,7 +672,6 @@
*/
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
public final void clear() {
throw new UnsupportedOperationException();
}
@@ -883,19 +682,18 @@
}
@Override
- public boolean containsKey(@CheckForNull Object key) {
+ public boolean containsKey(@Nullable Object key) {
return get(key) != null;
}
@Override
- public boolean containsValue(@CheckForNull Object value) {
+ public boolean containsValue(@Nullable Object value) {
return values().contains(value);
}
// Overriding to mark it Nullable
@Override
- @CheckForNull
- public abstract V get(@CheckForNull Object key);
+ public abstract V get(@Nullable Object key);
/**
* @since 21.0 (but only since 23.5 in the Android <a
@@ -903,18 +701,12 @@
* Note, however, that Java 8 users can call this method with any version and flavor of Guava.
*/
@Override
- @CheckForNull
- public final V getOrDefault(@CheckForNull Object key, @CheckForNull V defaultValue) {
+ public final V getOrDefault(@Nullable Object key, @Nullable V defaultValue) {
V result = get(key);
- // TODO(b/192579700): Use a ternary once it no longer confuses our nullness checker.
- if (result != null) {
- return result;
- } else {
- return defaultValue;
- }
+ return (result != null) ? result : defaultValue;
}
- @LazyInit @RetainedWith @CheckForNull private transient ImmutableSet<Entry<K, V>> entrySet;
+ @LazyInit @RetainedWith private transient ImmutableSet<Entry<K, V>> entrySet;
/**
* Returns an immutable set of the mappings in this map. The iteration order is specified by the
@@ -928,7 +720,7 @@
abstract ImmutableSet<Entry<K, V>> createEntrySet();
- @LazyInit @RetainedWith @CheckForNull private transient ImmutableSet<K> keySet;
+ @LazyInit @RetainedWith private transient ImmutableSet<K> keySet;
/**
* Returns an immutable set of the keys in this map, in the same order that they appear in {@link
@@ -966,7 +758,7 @@
return CollectSpliterators.map(entrySet().spliterator(), Entry::getKey);
}
- @LazyInit @RetainedWith @CheckForNull private transient ImmutableCollection<V> values;
+ @LazyInit @RetainedWith private transient ImmutableCollection<V> values;
/**
* Returns an immutable collection of the values in this map, in the same order that they appear
@@ -986,7 +778,7 @@
abstract ImmutableCollection<V> createValues();
// cached so that this.multimapView().inverse() only computes inverse once
- @LazyInit @CheckForNull private transient ImmutableSetMultimap<K, V> multimapView;
+ @LazyInit private transient ImmutableSetMultimap<K, V> multimapView;
/**
* Returns a multimap view of the map.
@@ -1019,13 +811,12 @@
}
@Override
- public boolean containsKey(@CheckForNull Object key) {
+ public boolean containsKey(@Nullable Object key) {
return ImmutableMap.this.containsKey(key);
}
@Override
- @CheckForNull
- public ImmutableSet<V> get(@CheckForNull Object key) {
+ public ImmutableSet<V> get(@Nullable Object key) {
V outerValue = ImmutableMap.this.get(key);
return (outerValue == null) ? null : ImmutableSet.of(outerValue);
}
@@ -1075,7 +866,7 @@
}
@Override
- public boolean equals(@CheckForNull Object object) {
+ public boolean equals(@Nullable Object object) {
return Maps.equalsImpl(this, object);
}
@@ -1116,8 +907,7 @@
Object[] keys = new Object[map.size()];
Object[] values = new Object[map.size()];
int i = 0;
- // "extends Object" works around https://github.com/typetools/checker-framework/issues/3013
- for (Entry<? extends Object, ? extends Object> entry : map.entrySet()) {
+ for (Entry<?, ?> entry : map.entrySet()) {
keys[i] = entry.getKey();
values[i] = entry.getValue();
i++;
diff --git a/guava/src/com/google/common/collect/ImmutableMapEntry.java b/guava/src/com/google/common/collect/ImmutableMapEntry.java
index ac483d8..d03d4fa 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 javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Implementation of {@code Entry} for {@link ImmutableMap} that adds extra methods to traverse hash
@@ -33,16 +33,10 @@
* @author Louis Wasserman
*/
@GwtIncompatible // unnecessary
-@ElementTypesAreNonnullByDefault
class ImmutableMapEntry<K, V> extends ImmutableEntry<K, V> {
/**
* Creates an {@code ImmutableMapEntry} array to hold parameterized entries. The result must never
* be upcast back to ImmutableMapEntry[] (or Object[], etc.), or allowed to escape the class.
- *
- * <p>The returned array has all its elements set to their initial null values. However, we don't
- * declare it as {@code @Nullable ImmutableMapEntry[]} because our checker doesn't require newly
- * created arrays to have a {@code @Nullable} element type even when they're created directly with
- * {@code new ImmutableMapEntry[...]}, so it seems silly to insist on that only here.
*/
@SuppressWarnings("unchecked") // Safe as long as the javadocs are followed
static <K, V> ImmutableMapEntry<K, V>[] createEntryArray(int size) {
@@ -59,12 +53,12 @@
// null check would be redundant
}
- @CheckForNull
+ @Nullable
ImmutableMapEntry<K, V> getNextInKeyBucket() {
return null;
}
- @CheckForNull
+ @Nullable
ImmutableMapEntry<K, V> getNextInValueBucket() {
return null;
}
@@ -78,23 +72,15 @@
}
static class NonTerminalImmutableMapEntry<K, V> extends ImmutableMapEntry<K, V> {
- /*
- * Yes, we sometimes set nextInKeyBucket to null, even for this "non-terminal" entry. We don't
- * do that with a plain NonTerminalImmutableMapEntry, but we do do it with the BiMap-specific
- * subclass below. That's because the Entry might be non-terminal in the key bucket but terminal
- * in the value bucket (or vice versa).
- */
- @CheckForNull private final transient ImmutableMapEntry<K, V> nextInKeyBucket;
+ private final transient ImmutableMapEntry<K, V> nextInKeyBucket;
- NonTerminalImmutableMapEntry(
- K key, V value, @CheckForNull ImmutableMapEntry<K, V> nextInKeyBucket) {
+ NonTerminalImmutableMapEntry(K key, V value, ImmutableMapEntry<K, V> nextInKeyBucket) {
super(key, value);
this.nextInKeyBucket = nextInKeyBucket;
}
@Override
- @CheckForNull
- final ImmutableMapEntry<K, V> getNextInKeyBucket() {
+ final @Nullable ImmutableMapEntry<K, V> getNextInKeyBucket() {
return nextInKeyBucket;
}
@@ -106,19 +92,19 @@
static final class NonTerminalImmutableBiMapEntry<K, V>
extends NonTerminalImmutableMapEntry<K, V> {
- @CheckForNull private final transient ImmutableMapEntry<K, V> nextInValueBucket;
+ private final transient ImmutableMapEntry<K, V> nextInValueBucket;
NonTerminalImmutableBiMapEntry(
K key,
V value,
- @CheckForNull ImmutableMapEntry<K, V> nextInKeyBucket,
- @CheckForNull ImmutableMapEntry<K, V> nextInValueBucket) {
+ ImmutableMapEntry<K, V> nextInKeyBucket,
+ ImmutableMapEntry<K, V> nextInValueBucket) {
super(key, value, nextInKeyBucket);
this.nextInValueBucket = nextInValueBucket;
}
@Override
- @CheckForNull
+ @Nullable
ImmutableMapEntry<K, V> getNextInValueBucket() {
return nextInValueBucket;
}
diff --git a/guava/src/com/google/common/collect/ImmutableMapEntrySet.java b/guava/src/com/google/common/collect/ImmutableMapEntrySet.java
index 6f5503a..8305283 100644
--- a/guava/src/com/google/common/collect/ImmutableMapEntrySet.java
+++ b/guava/src/com/google/common/collect/ImmutableMapEntrySet.java
@@ -22,7 +22,6 @@
import java.util.Map.Entry;
import java.util.Spliterator;
import java.util.function.Consumer;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -32,8 +31,7 @@
* @author Kevin Bourrillion
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
-abstract class ImmutableMapEntrySet<K, V> extends ImmutableSet.CachingAsList<Entry<K, V>> {
+abstract class ImmutableMapEntrySet<K, V> extends ImmutableSet<Entry<K, V>> {
static final class RegularEntrySet<K, V> extends ImmutableMapEntrySet<K, V> {
private final transient ImmutableMap<K, V> map;
private final transient ImmutableList<Entry<K, V>> entries;
@@ -54,7 +52,7 @@
@Override
@GwtIncompatible("not used in GWT")
- int copyIntoArray(@Nullable Object[] dst, int offset) {
+ int copyIntoArray(Object[] dst, int offset) {
return entries.copyIntoArray(dst, offset);
}
@@ -89,7 +87,7 @@
}
@Override
- public boolean contains(@CheckForNull 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 d10ee10..0b28cc2 100644
--- a/guava/src/com/google/common/collect/ImmutableMapKeySet.java
+++ b/guava/src/com/google/common/collect/ImmutableMapKeySet.java
@@ -23,7 +23,7 @@
import java.io.Serializable;
import java.util.Spliterator;
import java.util.function.Consumer;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* {@code keySet()} implementation for {@link ImmutableMap}.
@@ -32,7 +32,6 @@
* @author Kevin Bourrillion
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
final class ImmutableMapKeySet<K, V> extends IndexedImmutableSet<K> {
private final ImmutableMap<K, V> map;
@@ -56,7 +55,7 @@
}
@Override
- public boolean contains(@CheckForNull 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 702191c..2950f90 100644
--- a/guava/src/com/google/common/collect/ImmutableMapValues.java
+++ b/guava/src/com/google/common/collect/ImmutableMapValues.java
@@ -24,7 +24,7 @@
import java.util.Map.Entry;
import java.util.Spliterator;
import java.util.function.Consumer;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* {@code values()} implementation for {@link ImmutableMap}.
@@ -33,7 +33,6 @@
* @author Kevin Bourrillion
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
final class ImmutableMapValues<K, V> extends ImmutableCollection<V> {
private final ImmutableMap<K, V> map;
@@ -69,7 +68,7 @@
}
@Override
- public boolean contains(@CheckForNull 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 5dfbb9b..cf785ef 100644
--- a/guava/src/com/google/common/collect/ImmutableMultimap.java
+++ b/guava/src/com/google/common/collect/ImmutableMultimap.java
@@ -18,14 +18,11 @@
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.collect.CollectPreconditions.checkEntryNotNull;
-import static com.google.common.collect.Maps.immutableEntry;
-import static java.util.Objects.requireNonNull;
import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.GwtIncompatible;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
-import com.google.errorprone.annotations.DoNotCall;
import com.google.errorprone.annotations.DoNotMock;
import com.google.j2objc.annotations.Weak;
import com.google.j2objc.annotations.WeakOuter;
@@ -40,7 +37,6 @@
import java.util.Set;
import java.util.Spliterator;
import java.util.function.BiConsumer;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -70,15 +66,10 @@
* @since 2.0
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
public abstract class ImmutableMultimap<K, V> extends BaseImmutableMultimap<K, V>
implements Serializable {
- /**
- * Returns an empty multimap.
- *
- * <p><b>Performance note:</b> the instance returned is a singleton.
- */
+ /** Returns an empty multimap. */
public static <K, V> ImmutableMultimap<K, V> of() {
return ImmutableListMultimap.of();
}
@@ -149,9 +140,9 @@
*/
@DoNotMock
public static class Builder<K, V> {
- final Map<K, Collection<V>> builderMap;
- @CheckForNull Comparator<? super K> keyComparator;
- @CheckForNull Comparator<? super V> valueComparator;
+ Map<K, Collection<V>> builderMap;
+ @Nullable Comparator<? super K> keyComparator;
+ @Nullable Comparator<? super V> valueComparator;
/**
* Creates a new builder. The returned builder is equivalent to the builder generated by {@link
@@ -367,11 +358,7 @@
@CanIgnoreReturnValue
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
- // DoNotCall wants this to be final, but we want to override it to return more specific types.
- // Inheritance is closed, and all subtypes are @DoNotCall, so this is safe to suppress.
- @SuppressWarnings("DoNotCall")
- public ImmutableCollection<V> removeAll(@CheckForNull Object key) {
+ public ImmutableCollection<V> removeAll(Object key) {
throw new UnsupportedOperationException();
}
@@ -384,10 +371,6 @@
@CanIgnoreReturnValue
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
- // DoNotCall wants this to be final, but we want to override it to return more specific types.
- // Inheritance is closed, and all subtypes are @DoNotCall, so this is safe to suppress.
- @SuppressWarnings("DoNotCall")
public ImmutableCollection<V> replaceValues(K key, Iterable<? extends V> values) {
throw new UnsupportedOperationException();
}
@@ -400,8 +383,7 @@
*/
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
- public final void clear() {
+ public void clear() {
throw new UnsupportedOperationException();
}
@@ -430,8 +412,7 @@
@CanIgnoreReturnValue
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
- public final boolean put(K key, V value) {
+ public boolean put(K key, V value) {
throw new UnsupportedOperationException();
}
@@ -444,8 +425,7 @@
@CanIgnoreReturnValue
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
- public final boolean putAll(K key, Iterable<? extends V> values) {
+ public boolean putAll(K key, Iterable<? extends V> values) {
throw new UnsupportedOperationException();
}
@@ -458,8 +438,7 @@
@CanIgnoreReturnValue
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
- public final boolean putAll(Multimap<? extends K, ? extends V> multimap) {
+ public boolean putAll(Multimap<? extends K, ? extends V> multimap) {
throw new UnsupportedOperationException();
}
@@ -472,8 +451,7 @@
@CanIgnoreReturnValue
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
- public final boolean remove(@CheckForNull Object key, @CheckForNull Object value) {
+ public boolean remove(Object key, Object value) {
throw new UnsupportedOperationException();
}
@@ -490,12 +468,12 @@
// accessors
@Override
- public boolean containsKey(@CheckForNull Object key) {
+ public boolean containsKey(@Nullable Object key) {
return map.containsKey(key);
}
@Override
- public boolean containsValue(@CheckForNull Object value) {
+ public boolean containsValue(@Nullable Object value) {
return value != null && super.containsValue(value);
}
@@ -569,7 +547,7 @@
}
@Override
- public boolean contains(@CheckForNull Object object) {
+ public boolean contains(Object object) {
if (object instanceof Entry) {
Entry<?, ?> entry = (Entry<?, ?>) object;
return multimap.containsEntry(entry.getKey(), entry.getValue());
@@ -585,7 +563,7 @@
return new UnmodifiableIterator<Entry<K, V>>() {
final Iterator<? extends Entry<K, ? extends ImmutableCollection<V>>> asMapItr =
map.entrySet().iterator();
- @CheckForNull K currentKey = null;
+ K currentKey = null;
Iterator<V> valueItr = Iterators.emptyIterator();
@Override
@@ -600,11 +578,7 @@
currentKey = entry.getKey();
valueItr = entry.getValue().iterator();
}
- /*
- * requireNonNull is safe: The first call to this method always enters the !hasNext() case
- * and populates currentKey, after which it's never cleared.
- */
- return immutableEntry(requireNonNull(currentKey), valueItr.next());
+ return Maps.immutableEntry(currentKey, valueItr.next());
}
};
}
@@ -650,12 +624,12 @@
@WeakOuter
class Keys extends ImmutableMultiset<K> {
@Override
- public boolean contains(@CheckForNull Object object) {
+ public boolean contains(@Nullable Object object) {
return containsKey(object);
}
@Override
- public int count(@CheckForNull Object element) {
+ public int count(@Nullable Object element) {
Collection<V> values = map.get(element);
return (values == null) ? 0 : values.size();
}
@@ -744,7 +718,7 @@
}
@Override
- public boolean contains(@CheckForNull Object object) {
+ public boolean contains(@Nullable Object object) {
return multimap.containsValue(object);
}
@@ -755,7 +729,7 @@
@GwtIncompatible // not present in emulated superclass
@Override
- int copyIntoArray(@Nullable Object[] dst, int offset) {
+ int copyIntoArray(Object[] dst, int offset) {
for (ImmutableCollection<V> valueCollection : multimap.map.values()) {
offset = valueCollection.copyIntoArray(dst, offset);
}
diff --git a/guava/src/com/google/common/collect/ImmutableMultiset.java b/guava/src/com/google/common/collect/ImmutableMultiset.java
index f397a49..77d6cc5 100644
--- a/guava/src/com/google/common/collect/ImmutableMultiset.java
+++ b/guava/src/com/google/common/collect/ImmutableMultiset.java
@@ -17,13 +17,11 @@
package com.google.common.collect;
import static com.google.common.base.Preconditions.checkNotNull;
-import static java.util.Objects.requireNonNull;
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.GwtIncompatible;
import com.google.common.annotations.VisibleForTesting;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
-import com.google.errorprone.annotations.DoNotCall;
import com.google.errorprone.annotations.concurrent.LazyInit;
import com.google.j2objc.annotations.WeakOuter;
import java.io.Serializable;
@@ -35,7 +33,6 @@
import java.util.function.Function;
import java.util.function.ToIntFunction;
import java.util.stream.Collector;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -55,7 +52,6 @@
*/
@GwtCompatible(serializable = true, emulated = true)
@SuppressWarnings("serial") // we're overriding default serialization
-@ElementTypesAreNonnullByDefault
public abstract class ImmutableMultiset<E> extends ImmutableMultisetGwtSerializationDependencies<E>
implements Multiset<E> {
@@ -67,7 +63,7 @@
* @since 21.0
*/
public static <E> Collector<E, ?, ImmutableMultiset<E>> toImmutableMultiset() {
- return CollectCollectors.toImmutableMultiset(Function.identity(), e -> 1);
+ return toImmutableMultiset(Function.identity(), e -> 1);
}
/**
@@ -81,18 +77,22 @@
*
* @since 22.0
*/
- public static <T extends @Nullable Object, E>
- Collector<T, ?, ImmutableMultiset<E>> toImmutableMultiset(
- Function<? super T, ? extends E> elementFunction,
- ToIntFunction<? super T> countFunction) {
- return CollectCollectors.toImmutableMultiset(elementFunction, countFunction);
+ public static <T, E> Collector<T, ?, ImmutableMultiset<E>> toImmutableMultiset(
+ Function<? super T, ? extends E> elementFunction, ToIntFunction<? super T> countFunction) {
+ checkNotNull(elementFunction);
+ checkNotNull(countFunction);
+ return Collector.of(
+ LinkedHashMultiset::create,
+ (multiset, t) ->
+ multiset.add(checkNotNull(elementFunction.apply(t)), countFunction.applyAsInt(t)),
+ (multiset1, multiset2) -> {
+ multiset1.addAll(multiset2);
+ return multiset1;
+ },
+ (Multiset<E> multiset) -> copyFromEntries(multiset.entrySet()));
}
- /**
- * Returns the empty immutable multiset.
- *
- * <p><b>Performance note:</b> the instance returned is a singleton.
- */
+ /** Returns the empty immutable multiset. */
@SuppressWarnings("unchecked") // all supported methods are covariant
public static <E> ImmutableMultiset<E> of() {
return (ImmutableMultiset<E>) RegularImmutableMultiset.EMPTY;
@@ -104,6 +104,7 @@
* @throws NullPointerException if {@code element} is null
* @since 6.0 (source-compatible since 2.0)
*/
+ @SuppressWarnings("unchecked") // generic array created but never written
public static <E> ImmutableMultiset<E> of(E element) {
return copyFromElements(element);
}
@@ -114,6 +115,7 @@
* @throws NullPointerException if any element is null
* @since 6.0 (source-compatible since 2.0)
*/
+ @SuppressWarnings("unchecked") //
public static <E> ImmutableMultiset<E> of(E e1, E e2) {
return copyFromElements(e1, e2);
}
@@ -125,6 +127,7 @@
* @throws NullPointerException if any element is null
* @since 6.0 (source-compatible since 2.0)
*/
+ @SuppressWarnings("unchecked") //
public static <E> ImmutableMultiset<E> of(E e1, E e2, E e3) {
return copyFromElements(e1, e2, e3);
}
@@ -136,6 +139,7 @@
* @throws NullPointerException if any element is null
* @since 6.0 (source-compatible since 2.0)
*/
+ @SuppressWarnings("unchecked") //
public static <E> ImmutableMultiset<E> of(E e1, E e2, E e3, E e4) {
return copyFromElements(e1, e2, e3, e4);
}
@@ -147,6 +151,7 @@
* @throws NullPointerException if any element is null
* @since 6.0 (source-compatible since 2.0)
*/
+ @SuppressWarnings("unchecked") //
public static <E> ImmutableMultiset<E> of(E e1, E e2, E e3, E e4, E e5) {
return copyFromElements(e1, e2, e3, e4, e5);
}
@@ -158,6 +163,7 @@
* @throws NullPointerException if any element is null
* @since 6.0 (source-compatible since 2.0)
*/
+ @SuppressWarnings("unchecked") //
public static <E> ImmutableMultiset<E> of(E e1, E e2, E e3, E e4, E e5, E e6, E... others) {
return new Builder<E>().add(e1).add(e2).add(e3).add(e4).add(e5).add(e6).add(others).build();
}
@@ -230,7 +236,7 @@
final Iterator<Entry<E>> entryIterator = entrySet().iterator();
return new UnmodifiableIterator<E>() {
int remaining;
- @CheckForNull E element;
+ @Nullable E element;
@Override
public boolean hasNext() {
@@ -245,16 +251,12 @@
remaining = entry.getCount();
}
remaining--;
- /*
- * requireNonNull is safe because `remaining` starts at 0, forcing us to initialize
- * `element` above. After that, we never clear it.
- */
- return requireNonNull(element);
+ return element;
}
};
}
- @LazyInit @CheckForNull private transient ImmutableList<E> asList;
+ @LazyInit private transient ImmutableList<E> asList;
@Override
public ImmutableList<E> asList() {
@@ -263,7 +265,7 @@
}
@Override
- public boolean contains(@CheckForNull Object object) {
+ public boolean contains(@Nullable Object object) {
return count(object) > 0;
}
@@ -276,7 +278,6 @@
@CanIgnoreReturnValue
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
public final int add(E element, int occurrences) {
throw new UnsupportedOperationException();
}
@@ -290,8 +291,7 @@
@CanIgnoreReturnValue
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
- public final int remove(@CheckForNull Object element, int occurrences) {
+ public final int remove(Object element, int occurrences) {
throw new UnsupportedOperationException();
}
@@ -304,7 +304,6 @@
@CanIgnoreReturnValue
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
public final int setCount(E element, int count) {
throw new UnsupportedOperationException();
}
@@ -318,7 +317,6 @@
@CanIgnoreReturnValue
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
public final boolean setCount(E element, int oldCount, int newCount) {
throw new UnsupportedOperationException();
}
@@ -334,7 +332,7 @@
}
@Override
- public boolean equals(@CheckForNull Object object) {
+ public boolean equals(@Nullable Object object) {
return Multisets.equalsImpl(this, object);
}
@@ -352,7 +350,7 @@
@Override
public abstract ImmutableSet<E> elementSet();
- @LazyInit @CheckForNull private transient ImmutableSet<Entry<E>> entrySet;
+ @LazyInit private transient ImmutableSet<Entry<E>> entrySet;
@Override
public ImmutableSet<Entry<E>> entrySet() {
@@ -384,7 +382,7 @@
}
@Override
- public boolean contains(@CheckForNull Object o) {
+ public boolean contains(Object o) {
if (o instanceof Entry) {
Entry<?> entry = (Entry<?>) o;
if (entry.getCount() <= 0) {
@@ -599,7 +597,7 @@
}
@Override
- public boolean contains(@CheckForNull Object object) {
+ public boolean contains(@Nullable Object object) {
return delegate.contains(object);
}
@@ -618,13 +616,12 @@
final Object[] elements;
final int[] counts;
- // "extends Object" works around https://github.com/typetools/checker-framework/issues/3013
- SerializedForm(Multiset<? extends Object> multiset) {
+ SerializedForm(Multiset<?> multiset) {
int distinct = multiset.entrySet().size();
elements = new Object[distinct];
counts = new int[distinct];
int i = 0;
- for (Entry<? extends Object> entry : multiset.entrySet()) {
+ for (Entry<?> entry : multiset.entrySet()) {
elements[i] = entry.getElement();
counts[i] = entry.getCount();
i++;
diff --git a/guava/src/com/google/common/collect/ImmutableMultisetGwtSerializationDependencies.java b/guava/src/com/google/common/collect/ImmutableMultisetGwtSerializationDependencies.java
index 2469a18..a8b1899 100644
--- a/guava/src/com/google/common/collect/ImmutableMultisetGwtSerializationDependencies.java
+++ b/guava/src/com/google/common/collect/ImmutableMultisetGwtSerializationDependencies.java
@@ -37,5 +37,4 @@
* and make types non-final.
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
abstract class ImmutableMultisetGwtSerializationDependencies<E> extends ImmutableCollection<E> {}
diff --git a/guava/src/com/google/common/collect/ImmutableRangeMap.java b/guava/src/com/google/common/collect/ImmutableRangeMap.java
index e1979ab..f164701 100644
--- a/guava/src/com/google/common/collect/ImmutableRangeMap.java
+++ b/guava/src/com/google/common/collect/ImmutableRangeMap.java
@@ -23,7 +23,6 @@
import com.google.common.collect.SortedLists.KeyAbsentBehavior;
import com.google.common.collect.SortedLists.KeyPresentBehavior;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
-import com.google.errorprone.annotations.DoNotCall;
import com.google.errorprone.annotations.DoNotMock;
import java.io.Serializable;
import java.util.Collections;
@@ -34,7 +33,6 @@
import java.util.function.BiFunction;
import java.util.function.Function;
import java.util.stream.Collector;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -46,7 +44,6 @@
*/
@Beta
@GwtIncompatible // NavigableMap
-@ElementTypesAreNonnullByDefault
public class ImmutableRangeMap<K extends Comparable<?>, V> implements RangeMap<K, V>, Serializable {
private static final ImmutableRangeMap<Comparable<?>, Object> EMPTY =
@@ -58,18 +55,14 @@
*
* @since 23.1
*/
- public static <T extends @Nullable Object, K extends Comparable<? super K>, V>
+ public static <T, K extends Comparable<? super K>, V>
Collector<T, ?, ImmutableRangeMap<K, V>> toImmutableRangeMap(
Function<? super T, Range<K>> keyFunction,
Function<? super T, ? extends V> valueFunction) {
return CollectCollectors.toImmutableRangeMap(keyFunction, valueFunction);
}
- /**
- * Returns an empty immutable range map.
- *
- * <p><b>Performance note:</b> the instance returned is a singleton.
- */
+ /** Returns an empty immutable range map. */
@SuppressWarnings("unchecked")
public static <K extends Comparable<?>, V> ImmutableRangeMap<K, V> of() {
return (ImmutableRangeMap<K, V>) EMPTY;
@@ -178,8 +171,7 @@
}
@Override
- @CheckForNull
- public V get(K key) {
+ public @Nullable V get(K key) {
int index =
SortedLists.binarySearch(
ranges,
@@ -196,8 +188,7 @@
}
@Override
- @CheckForNull
- public Entry<Range<K>, V> getEntry(K key) {
+ public @Nullable Entry<Range<K>, V> getEntry(K key) {
int index =
SortedLists.binarySearch(
ranges,
@@ -231,8 +222,7 @@
*/
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
- public final void put(Range<K> range, V value) {
+ public void put(Range<K> range, V value) {
throw new UnsupportedOperationException();
}
@@ -244,8 +234,7 @@
*/
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
- public final void putCoalescing(Range<K> range, V value) {
+ public void putCoalescing(Range<K> range, V value) {
throw new UnsupportedOperationException();
}
@@ -257,8 +246,7 @@
*/
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
- public final void putAll(RangeMap<K, V> rangeMap) {
+ public void putAll(RangeMap<K, V> rangeMap) {
throw new UnsupportedOperationException();
}
@@ -270,8 +258,7 @@
*/
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
- public final void clear() {
+ public void clear() {
throw new UnsupportedOperationException();
}
@@ -283,8 +270,7 @@
*/
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
- public final void remove(Range<K> range) {
+ public void remove(Range<K> range) {
throw new UnsupportedOperationException();
}
@@ -296,11 +282,10 @@
*/
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
- public final void merge(
+ public void merge(
Range<K> range,
- @CheckForNull V value,
- BiFunction<? super V, ? super @Nullable V, ? extends @Nullable V> remappingFunction) {
+ @Nullable V value,
+ BiFunction<? super V, ? super V, ? extends V> remappingFunction) {
throw new UnsupportedOperationException();
}
@@ -391,7 +376,7 @@
}
@Override
- public boolean equals(@CheckForNull 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 f279aae..df063a8 100644
--- a/guava/src/com/google/common/collect/ImmutableRangeSet.java
+++ b/guava/src/com/google/common/collect/ImmutableRangeSet.java
@@ -20,7 +20,6 @@
import static com.google.common.collect.SortedLists.KeyAbsentBehavior.NEXT_HIGHER;
import static com.google.common.collect.SortedLists.KeyAbsentBehavior.NEXT_LOWER;
import static com.google.common.collect.SortedLists.KeyPresentBehavior.ANY_PRESENT;
-import static java.util.Objects.requireNonNull;
import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtIncompatible;
@@ -28,7 +27,6 @@
import com.google.common.collect.SortedLists.KeyPresentBehavior;
import com.google.common.primitives.Ints;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
-import com.google.errorprone.annotations.DoNotCall;
import com.google.errorprone.annotations.concurrent.LazyInit;
import java.io.Serializable;
import java.util.Collections;
@@ -37,7 +35,7 @@
import java.util.NoSuchElementException;
import java.util.Set;
import java.util.stream.Collector;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* A {@link RangeSet} whose contents will never change, with many other important properties
@@ -48,7 +46,6 @@
*/
@Beta
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public final class ImmutableRangeSet<C extends Comparable> extends AbstractRangeSet<C>
implements Serializable {
@@ -70,11 +67,7 @@
return CollectCollectors.toImmutableRangeSet();
}
- /**
- * Returns an empty immutable range set.
- *
- * <p><b>Performance note:</b> the instance returned is a singleton.
- */
+ /** Returns an empty immutable range set. */
@SuppressWarnings("unchecked")
public static <C extends Comparable> ImmutableRangeSet<C> of() {
return (ImmutableRangeSet<C>) EMPTY;
@@ -188,7 +181,6 @@
}
@Override
- @CheckForNull
public Range<C> rangeContaining(C value) {
int index =
SortedLists.binarySearch(
@@ -226,7 +218,6 @@
*/
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
public void add(Range<C> range) {
throw new UnsupportedOperationException();
}
@@ -239,7 +230,6 @@
*/
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
public void addAll(RangeSet<C> other) {
throw new UnsupportedOperationException();
}
@@ -252,7 +242,6 @@
*/
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
public void addAll(Iterable<Range<C>> other) {
throw new UnsupportedOperationException();
}
@@ -265,7 +254,6 @@
*/
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
public void remove(Range<C> range) {
throw new UnsupportedOperationException();
}
@@ -278,7 +266,6 @@
*/
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
public void removeAll(RangeSet<C> other) {
throw new UnsupportedOperationException();
}
@@ -291,7 +278,6 @@
*/
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
public void removeAll(Iterable<Range<C>> other) {
throw new UnsupportedOperationException();
}
@@ -312,7 +298,7 @@
return new RegularImmutableSortedSet<>(ranges.reverse(), Range.<C>rangeLexOrdering().reverse());
}
- @LazyInit @CheckForNull private transient ImmutableRangeSet<C> complement;
+ @LazyInit private transient ImmutableRangeSet<C> complement;
private final class ComplementRanges extends ImmutableList<Range<C>> {
// True if the "positive" range set is empty or bounded below.
@@ -554,7 +540,7 @@
this.domain = domain;
}
- @CheckForNull private transient Integer size;
+ private transient @Nullable Integer size;
@Override
public int size() {
@@ -580,7 +566,6 @@
Iterator<C> elemItr = Iterators.emptyIterator();
@Override
- @CheckForNull
protected C computeNext() {
while (!elemItr.hasNext()) {
if (rangeItr.hasNext()) {
@@ -602,7 +587,6 @@
Iterator<C> elemItr = Iterators.emptyIterator();
@Override
- @CheckForNull
protected C computeNext() {
while (!elemItr.hasNext()) {
if (rangeItr.hasNext()) {
@@ -643,7 +627,7 @@
}
@Override
- public boolean contains(@CheckForNull Object o) {
+ public boolean contains(@Nullable Object o) {
if (o == null) {
return false;
}
@@ -657,10 +641,10 @@
}
@Override
- int indexOf(@CheckForNull Object target) {
+ int indexOf(Object target) {
if (contains(target)) {
@SuppressWarnings("unchecked") // if it's contained, it's definitely a C
- C c = (C) requireNonNull(target);
+ C c = (C) target;
long total = 0;
for (Range<C> range : ranges) {
if (range.contains(c)) {
diff --git a/guava/src/com/google/common/collect/ImmutableSet.java b/guava/src/com/google/common/collect/ImmutableSet.java
index 73d5b09..097b877 100644
--- a/guava/src/com/google/common/collect/ImmutableSet.java
+++ b/guava/src/com/google/common/collect/ImmutableSet.java
@@ -19,7 +19,6 @@
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.collect.CollectPreconditions.checkNonnegative;
-import static java.util.Objects.requireNonNull;
import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtCompatible;
@@ -41,7 +40,6 @@
import java.util.Spliterator;
import java.util.function.Consumer;
import java.util.stream.Collector;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -52,7 +50,6 @@
*/
@GwtCompatible(serializable = true, emulated = true)
@SuppressWarnings("serial") // we're overriding default serialization
-@ElementTypesAreNonnullByDefault
public abstract class ImmutableSet<E> extends ImmutableCollection<E> implements Set<E> {
static final int SPLITERATOR_CHARACTERISTICS =
ImmutableCollection.SPLITERATOR_CHARACTERISTICS | Spliterator.DISTINCT;
@@ -72,8 +69,6 @@
/**
* Returns the empty immutable set. Preferred over {@link Collections#emptySet} for code
* consistency, and because the return type conveys the immutability guarantee.
- *
- * <p><b>Performance note:</b> the instance returned is a singleton.
*/
@SuppressWarnings({"unchecked"}) // fully variant implementation (never actually produces any Es)
public static <E> ImmutableSet<E> of() {
@@ -312,11 +307,10 @@
}
@Override
- public boolean equals(@CheckForNull Object object) {
+ public boolean equals(@Nullable Object object) {
if (object == this) {
return true;
- }
- if (object instanceof ImmutableSet
+ } else if (object instanceof ImmutableSet
&& isHashCodeFast()
&& ((ImmutableSet<?>) object).isHashCodeFast()
&& hashCode() != object.hashCode()) {
@@ -335,26 +329,19 @@
@Override
public abstract UnmodifiableIterator<E> iterator();
- @GwtCompatible
- abstract static class CachingAsList<E> extends ImmutableSet<E> {
- @LazyInit @RetainedWith @CheckForNull private transient ImmutableList<E> asList;
+ @LazyInit @RetainedWith private transient @Nullable ImmutableList<E> asList;
- @Override
- public ImmutableList<E> asList() {
- ImmutableList<E> result = asList;
- if (result == null) {
- return asList = createAsList();
- } else {
- return result;
- }
- }
-
- ImmutableList<E> createAsList() {
- return new RegularImmutableAsList<E>(this, toArray());
- }
+ @Override
+ public ImmutableList<E> asList() {
+ ImmutableList<E> result = asList;
+ return (result == null) ? asList = createAsList() : result;
}
- abstract static class Indexed<E> extends CachingAsList<E> {
+ ImmutableList<E> createAsList() {
+ return new RegularImmutableAsList<E>(this, toArray());
+ }
+
+ abstract static class Indexed<E> extends ImmutableSet<E> {
abstract E get(int index);
@Override
@@ -377,7 +364,7 @@
}
@Override
- int copyIntoArray(@Nullable Object[] dst, int offset) {
+ int copyIntoArray(Object[] dst, int offset) {
return asList().copyIntoArray(dst, offset);
}
@@ -449,6 +436,24 @@
return new Builder<E>(expectedSize);
}
+ /** Builds a new open-addressed hash table from the first n objects in elements. */
+ static Object[] rebuildHashTable(int newTableSize, Object[] elements, int n) {
+ Object[] hashTable = new Object[newTableSize];
+ int mask = hashTable.length - 1;
+ for (int i = 0; i < n; i++) {
+ Object e = elements[i];
+ int j0 = Hashing.smear(e.hashCode());
+ for (int j = j0; ; j++) {
+ int index = j & mask;
+ if (hashTable[index] == null) {
+ hashTable[index] = e;
+ break;
+ }
+ }
+ }
+ return hashTable;
+ }
+
/**
* A builder for creating {@code ImmutableSet} instances. Example:
*
@@ -468,24 +473,15 @@
* @since 2.0
*/
public static class Builder<E> extends ImmutableCollection.Builder<E> {
- /*
- * `impl` is null only for instances of the subclass, ImmutableSortedSet.Builder. That subclass
- * overrides all the methods that access it here. Thus, all the methods here can safely assume
- * that this field is non-null.
- */
- @CheckForNull private SetBuilderImpl<E> impl;
+ private SetBuilderImpl<E> impl;
boolean forceCopy;
public Builder() {
- this(0);
+ this(DEFAULT_INITIAL_CAPACITY);
}
Builder(int capacity) {
- if (capacity > 0) {
- impl = new RegularSetBuilderImpl<E>(capacity);
- } else {
- impl = EmptySetBuilderImpl.instance();
- }
+ impl = new RegularSetBuilderImpl<E>(capacity);
}
Builder(@SuppressWarnings("unused") boolean subclass) {
@@ -494,7 +490,6 @@
@VisibleForTesting
void forceJdk() {
- requireNonNull(impl); // see the comment on the field
this.impl = new JdkBackedSetBuilderImpl<E>(impl);
}
@@ -506,14 +501,12 @@
}
void copy() {
- requireNonNull(impl); // see the comment on the field
impl = impl.copy();
}
@Override
@CanIgnoreReturnValue
public Builder<E> add(E element) {
- requireNonNull(impl); // see the comment on the field
checkNotNull(element);
copyIfNecessary();
impl = impl.add(element);
@@ -550,16 +543,6 @@
}
Builder<E> combine(Builder<E> other) {
- requireNonNull(impl);
- requireNonNull(other.impl);
- /*
- * For discussion of requireNonNull, see the comment on the field.
- *
- * (And I don't believe there's any situation in which we call x.combine(y) when x is a plain
- * ImmutableSet.Builder but y is an ImmutableSortedSet.Builder (or vice versa). Certainly
- * ImmutableSortedSet.Builder.combine() is written as if its argument will never be a plain
- * ImmutableSet.Builder: It casts immediately to ImmutableSortedSet.Builder.)
- */
copyIfNecessary();
this.impl = this.impl.combine(other.impl);
return this;
@@ -567,7 +550,6 @@
@Override
public ImmutableSet<E> build() {
- requireNonNull(impl); // see the comment on the field
forceCopy = true;
impl = impl.review();
return impl.build();
@@ -576,8 +558,6 @@
/** Swappable internal implementation of an ImmutableSet.Builder. */
private abstract static class SetBuilderImpl<E> {
- // The first `distinct` elements are non-null.
- // Since we can never access null elements, we don't mark this nullable.
E[] dedupedElements;
int distinct;
@@ -621,11 +601,7 @@
final SetBuilderImpl<E> combine(SetBuilderImpl<E> other) {
SetBuilderImpl<E> result = this;
for (int i = 0; i < other.distinct; i++) {
- /*
- * requireNonNull is safe because we ensure that the first `distinct` elements have been
- * populated.
- */
- result = result.add(requireNonNull(other.dedupedElements[i]));
+ result = result.add(other.dedupedElements[i]);
}
return result;
}
@@ -647,34 +623,6 @@
abstract ImmutableSet<E> build();
}
- private static final class EmptySetBuilderImpl<E> extends SetBuilderImpl<E> {
- private static final EmptySetBuilderImpl<Object> INSTANCE = new EmptySetBuilderImpl<>();
-
- @SuppressWarnings("unchecked")
- static <E> SetBuilderImpl<E> instance() {
- return (SetBuilderImpl<E>) INSTANCE;
- }
-
- private EmptySetBuilderImpl() {
- super(0);
- }
-
- @Override
- SetBuilderImpl<E> add(E e) {
- return new RegularSetBuilderImpl<E>(Builder.DEFAULT_INITIAL_CAPACITY).add(e);
- }
-
- @Override
- SetBuilderImpl<E> copy() {
- return this;
- }
-
- @Override
- ImmutableSet<E> build() {
- return ImmutableSet.of();
- }
- }
-
// We use power-of-2 tables, and this is the highest int that's a power of 2
static final int MAX_TABLE_SIZE = Ints.MAX_POWER_OF_TWO;
@@ -689,7 +637,7 @@
* with linear probing in its implementation. The returned size is the smallest power of two that
* can hold setSize elements with the desired load factor. Always returns at least setSize + 2.
*/
- // TODO(cpovirk): Move to Hashing or something, since it's used elsewhere in the Android version.
+ @VisibleForTesting
static int chooseTableSize(int setSize) {
setSize = Math.max(setSize, 2);
// Correct the size for open addressing to match desired load factor.
@@ -708,6 +656,92 @@
}
/**
+ * We attempt to detect deliberate hash flooding attempts, and if one is detected, fall back to a
+ * wrapper around j.u.HashSet, which has built in flooding protection. HASH_FLOODING_FPP is the
+ * maximum allowed probability of falsely detecting a hash flooding attack if the input is
+ * randomly generated.
+ *
+ * <p>MAX_RUN_MULTIPLIER was determined experimentally to match this FPP.
+ */
+ static final double HASH_FLOODING_FPP = 0.001;
+
+ // NB: yes, this is surprisingly high, but that's what the experiments said was necessary
+ // The higher it is, the worse constant factors we are willing to accept.
+ static final int MAX_RUN_MULTIPLIER = 13;
+
+ /**
+ * Checks the whole hash table for poor hash distribution. Takes O(n) in the worst case, O(n / log
+ * n) on average.
+ *
+ * <p>The online hash flooding detecting in RegularSetBuilderImpl.add can detect e.g. many exactly
+ * matching hash codes, which would cause construction to take O(n^2), but can't detect e.g. hash
+ * codes adversarially designed to go into ascending table locations, which keeps construction
+ * O(n) (as desired) but then can have O(n) queries later.
+ *
+ * <p>If this returns false, then no query can take more than O(log n).
+ *
+ * <p>Note that for a RegularImmutableSet with elements with truly random hash codes, contains
+ * operations take expected O(1) time but with high probability take O(log n) for at least some
+ * element. (https://en.wikipedia.org/wiki/Linear_probing#Analysis)
+ *
+ * <p>This method may return {@code true} up to {@link #HASH_FLOODING_FPP} of the time even on
+ * truly random input.
+ *
+ * <p>If this method returns false, there are definitely no runs of length at least {@code
+ * maxRunBeforeFallback(hashTable.length)} nonnull elements. If there are no runs of length at
+ * least {@code maxRunBeforeFallback(hashTable.length) / 2} nonnull elements, this method
+ * definitely returns false. In between those constraints, the result of this method is undefined,
+ * subject to the above {@link #HASH_FLOODING_FPP} constraint.
+ */
+ static boolean hashFloodingDetected(Object[] hashTable) {
+ int maxRunBeforeFallback = maxRunBeforeFallback(hashTable.length);
+
+ // Test for a run wrapping around the end of the table of length at least maxRunBeforeFallback.
+ int endOfStartRun;
+ for (endOfStartRun = 0; endOfStartRun < hashTable.length; ) {
+ if (hashTable[endOfStartRun] == null) {
+ break;
+ }
+ endOfStartRun++;
+ if (endOfStartRun > maxRunBeforeFallback) {
+ return true;
+ }
+ }
+ int startOfEndRun;
+ for (startOfEndRun = hashTable.length - 1; startOfEndRun > endOfStartRun; startOfEndRun--) {
+ if (hashTable[startOfEndRun] == null) {
+ break;
+ }
+ if (endOfStartRun + (hashTable.length - 1 - startOfEndRun) > maxRunBeforeFallback) {
+ return true;
+ }
+ }
+
+ // Now, break the remainder of the table into blocks of maxRunBeforeFallback/2 elements and
+ // check that each has at least one null.
+ int testBlockSize = maxRunBeforeFallback / 2;
+ blockLoop:
+ for (int i = endOfStartRun + 1; i + testBlockSize <= startOfEndRun; i += testBlockSize) {
+ for (int j = 0; j < testBlockSize; j++) {
+ if (hashTable[i + j] == null) {
+ continue blockLoop;
+ }
+ }
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * If more than this many consecutive positions are filled in a table of the specified size,
+ * report probable hash flooding. ({@link #hashFloodingDetected} may also report hash flooding if
+ * fewer consecutive positions are filled; see that method for details.)
+ */
+ private static int maxRunBeforeFallback(int tableSize) {
+ return MAX_RUN_MULTIPLIER * IntMath.log2(tableSize, RoundingMode.UNNECESSARY);
+ }
+
+ /**
* Default implementation of the guts of ImmutableSet.Builder, creating an open-addressed hash
* table and deduplicating elements as they come, so it only allocates O(max(distinct,
* expectedCapacity)) rather than O(calls to add).
@@ -716,46 +750,39 @@
* JdkBackedSetBuilderImpl.
*/
private static final class RegularSetBuilderImpl<E> extends SetBuilderImpl<E> {
- // null until at least two elements are present
- private @Nullable Object @Nullable [] hashTable;
+ private Object[] hashTable;
private int maxRunBeforeFallback;
private int expandTableThreshold;
private int hashCode;
RegularSetBuilderImpl(int expectedCapacity) {
super(expectedCapacity);
- this.hashTable = null;
- this.maxRunBeforeFallback = 0;
- this.expandTableThreshold = 0;
+ int tableSize = chooseTableSize(expectedCapacity);
+ this.hashTable = new Object[tableSize];
+ this.maxRunBeforeFallback = maxRunBeforeFallback(tableSize);
+ this.expandTableThreshold = (int) (DESIRED_LOAD_FACTOR * tableSize);
}
RegularSetBuilderImpl(RegularSetBuilderImpl<E> toCopy) {
super(toCopy);
- this.hashTable = (toCopy.hashTable == null) ? null : toCopy.hashTable.clone();
+ this.hashTable = Arrays.copyOf(toCopy.hashTable, toCopy.hashTable.length);
this.maxRunBeforeFallback = toCopy.maxRunBeforeFallback;
this.expandTableThreshold = toCopy.expandTableThreshold;
this.hashCode = toCopy.hashCode;
}
+ void ensureTableCapacity(int minCapacity) {
+ if (minCapacity > expandTableThreshold && hashTable.length < MAX_TABLE_SIZE) {
+ int newTableSize = hashTable.length * 2;
+ hashTable = rebuildHashTable(newTableSize, dedupedElements, distinct);
+ maxRunBeforeFallback = maxRunBeforeFallback(newTableSize);
+ expandTableThreshold = (int) (DESIRED_LOAD_FACTOR * newTableSize);
+ }
+ }
+
@Override
SetBuilderImpl<E> add(E e) {
checkNotNull(e);
- if (hashTable == null) {
- if (distinct == 0) {
- addDedupedElement(e);
- return this;
- } else {
- ensureTableCapacity(dedupedElements.length);
- E elem = dedupedElements[0];
- distinct--;
- return insertInHashTable(elem).add(e);
- }
- }
- return insertInHashTable(e);
- }
-
- private SetBuilderImpl<E> insertInHashTable(E e) {
- requireNonNull(hashTable);
int eHash = e.hashCode();
int i0 = Hashing.smear(eHash);
int mask = hashTable.length - 1;
@@ -783,9 +810,6 @@
@Override
SetBuilderImpl<E> review() {
- if (hashTable == null) {
- return this;
- }
int targetTableSize = chooseTableSize(distinct);
if (targetTableSize * 2 < hashTable.length) {
hashTable = rebuildHashTable(targetTableSize, dedupedElements, distinct);
@@ -801,134 +825,15 @@
case 0:
return of();
case 1:
- /*
- * requireNonNull is safe because we ensure that the first `distinct` elements have been
- * populated.
- */
- return of(requireNonNull(dedupedElements[0]));
+ return of(dedupedElements[0]);
default:
- /*
- * The suppression is safe because we ensure that the first `distinct` elements have been
- * populated.
- */
- @SuppressWarnings("nullness")
Object[] elements =
(distinct == dedupedElements.length)
? dedupedElements
: Arrays.copyOf(dedupedElements, distinct);
- return new RegularImmutableSet<E>(
- elements, hashCode, requireNonNull(hashTable), hashTable.length - 1);
+ return new RegularImmutableSet<E>(elements, hashCode, hashTable, hashTable.length - 1);
}
}
-
- /** Builds a new open-addressed hash table from the first n objects in elements. */
- static @Nullable Object[] rebuildHashTable(int newTableSize, Object[] elements, int n) {
- @Nullable Object[] hashTable = new @Nullable Object[newTableSize];
- int mask = hashTable.length - 1;
- for (int i = 0; i < n; i++) {
- // requireNonNull is safe because we ensure that the first n elements have been populated.
- Object e = requireNonNull(elements[i]);
- int j0 = Hashing.smear(e.hashCode());
- for (int j = j0; ; j++) {
- int index = j & mask;
- if (hashTable[index] == null) {
- hashTable[index] = e;
- break;
- }
- }
- }
- return hashTable;
- }
-
- void ensureTableCapacity(int minCapacity) {
- int newTableSize;
- if (hashTable == null) {
- newTableSize = chooseTableSize(minCapacity);
- hashTable = new Object[newTableSize];
- } else if (minCapacity > expandTableThreshold && hashTable.length < MAX_TABLE_SIZE) {
- newTableSize = hashTable.length * 2;
- hashTable = rebuildHashTable(newTableSize, dedupedElements, distinct);
- } else {
- return;
- }
- maxRunBeforeFallback = maxRunBeforeFallback(newTableSize);
- expandTableThreshold = (int) (DESIRED_LOAD_FACTOR * newTableSize);
- }
-
- /**
- * We attempt to detect deliberate hash flooding attempts. If one is detected, we fall back to a
- * wrapper around j.u.HashSet, which has built in flooding protection. MAX_RUN_MULTIPLIER was
- * determined experimentally to match our desired probability of false positives.
- */
- // NB: yes, this is surprisingly high, but that's what the experiments said was necessary
- // Raising this number slows the worst-case contains behavior, speeds up hashFloodingDetected,
- // and reduces the false-positive probability.
- static final int MAX_RUN_MULTIPLIER = 13;
-
- /**
- * Checks the whole hash table for poor hash distribution. Takes O(n) in the worst case, O(n /
- * log n) on average.
- *
- * <p>The online hash flooding detecting in RegularSetBuilderImpl.add can detect e.g. many
- * exactly matching hash codes, which would cause construction to take O(n^2), but can't detect
- * e.g. hash codes adversarially designed to go into ascending table locations, which keeps
- * construction O(n) (as desired) but then can have O(n) queries later.
- *
- * <p>If this returns false, then no query can take more than O(log n).
- *
- * <p>Note that for a RegularImmutableSet with elements with truly random hash codes, contains
- * operations take expected O(1) time but with high probability take O(log n) for at least some
- * element. (https://en.wikipedia.org/wiki/Linear_probing#Analysis)
- *
- * <p>This method may return {@code true} even on truly random input, but {@code
- * ImmutableSetTest} tests that the probability of that is low.
- */
- static boolean hashFloodingDetected(@Nullable Object[] hashTable) {
- int maxRunBeforeFallback = maxRunBeforeFallback(hashTable.length);
- int mask = hashTable.length - 1;
-
- // Invariant: all elements at indices in [knownRunStart, knownRunEnd) are nonnull.
- // If knownRunStart == knownRunEnd, this is vacuously true.
- // When knownRunEnd exceeds hashTable.length, it "wraps", detecting runs around the end
- // of the table.
- int knownRunStart = 0;
- int knownRunEnd = 0;
-
- outerLoop:
- while (knownRunStart < hashTable.length) {
- if (knownRunStart == knownRunEnd && hashTable[knownRunStart] == null) {
- if (hashTable[(knownRunStart + maxRunBeforeFallback - 1) & mask] == null) {
- // There are only maxRunBeforeFallback - 1 elements between here and there,
- // so even if they were all nonnull, we wouldn't detect a hash flood. Therefore,
- // we can skip them all.
- knownRunStart += maxRunBeforeFallback;
- } else {
- knownRunStart++; // the only case in which maxRunEnd doesn't increase by mRBF
- // happens about f * (1-f) for f = DESIRED_LOAD_FACTOR, so around 21% of the time
- }
- knownRunEnd = knownRunStart;
- } else {
- for (int j = knownRunStart + maxRunBeforeFallback - 1; j >= knownRunEnd; j--) {
- if (hashTable[j & mask] == null) {
- knownRunEnd = knownRunStart + maxRunBeforeFallback;
- knownRunStart = j + 1;
- continue outerLoop;
- }
- }
- return true;
- }
- }
- return false;
- }
-
- /**
- * If more than this many consecutive positions are filled in a table of the specified size,
- * report probable hash flooding. ({@link #hashFloodingDetected} may also report hash flooding
- * if fewer consecutive positions are filled; see that method for details.)
- */
- static int maxRunBeforeFallback(int tableSize) {
- return MAX_RUN_MULTIPLIER * IntMath.log2(tableSize, RoundingMode.UNNECESSARY);
- }
}
/**
@@ -941,11 +846,7 @@
super(toCopy); // initializes dedupedElements and distinct
delegate = Sets.newHashSetWithExpectedSize(distinct);
for (int i = 0; i < distinct; i++) {
- /*
- * requireNonNull is safe because we ensure that the first `distinct` elements have been
- * populated.
- */
- delegate.add(requireNonNull(dedupedElements[i]));
+ delegate.add(dedupedElements[i]);
}
}
@@ -969,11 +870,7 @@
case 0:
return of();
case 1:
- /*
- * requireNonNull is safe because we ensure that the first `distinct` elements have been
- * populated.
- */
- return of(requireNonNull(dedupedElements[0]));
+ return of(dedupedElements[0]);
default:
return new JdkBackedImmutableSet<E>(
delegate, ImmutableList.asImmutableList(dedupedElements, distinct));
diff --git a/guava/src/com/google/common/collect/ImmutableSetMultimap.java b/guava/src/com/google/common/collect/ImmutableSetMultimap.java
index 007c16b..9691ef5 100644
--- a/guava/src/com/google/common/collect/ImmutableSetMultimap.java
+++ b/guava/src/com/google/common/collect/ImmutableSetMultimap.java
@@ -22,8 +22,8 @@
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.GwtIncompatible;
import com.google.common.base.MoreObjects;
+import com.google.common.base.Preconditions;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
-import com.google.errorprone.annotations.DoNotCall;
import com.google.errorprone.annotations.concurrent.LazyInit;
import com.google.j2objc.annotations.RetainedWith;
import com.google.j2objc.annotations.Weak;
@@ -38,18 +38,14 @@
import java.util.Map.Entry;
import java.util.function.Function;
import java.util.stream.Collector;
+import java.util.stream.Collectors;
import java.util.stream.Stream;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
* A {@link SetMultimap} whose contents will never change, with many other important properties
* detailed at {@link ImmutableCollection}.
*
- * <p><b>Warning:</b> As in all {@link SetMultimap}s, do not modify either a key <i>or a value</i>
- * of a {@code ImmutableSetMultimap} in a way that affects its {@link Object#equals} behavior.
- * Undefined behavior and bugs will result.
- *
* <p>See the Guava User Guide article on <a href=
* "https://github.com/google/guava/wiki/ImmutableCollectionsExplained"> immutable collections</a>.
*
@@ -57,7 +53,6 @@
* @since 2.0
*/
@GwtCompatible(serializable = true, emulated = true)
-@ElementTypesAreNonnullByDefault
public class ImmutableSetMultimap<K, V> extends ImmutableMultimap<K, V>
implements SetMultimap<K, V> {
/**
@@ -88,11 +83,16 @@
*
* @since 21.0
*/
- public static <T extends @Nullable Object, K, V>
- Collector<T, ?, ImmutableSetMultimap<K, V>> toImmutableSetMultimap(
- Function<? super T, ? extends K> keyFunction,
- Function<? super T, ? extends V> valueFunction) {
- return CollectCollectors.toImmutableSetMultimap(keyFunction, valueFunction);
+ public static <T, K, V> Collector<T, ?, ImmutableSetMultimap<K, V>> toImmutableSetMultimap(
+ Function<? super T, ? extends K> keyFunction,
+ Function<? super T, ? extends V> valueFunction) {
+ checkNotNull(keyFunction, "keyFunction");
+ checkNotNull(valueFunction, "valueFunction");
+ return Collector.of(
+ ImmutableSetMultimap::<K, V>builder,
+ (builder, t) -> builder.put(keyFunction.apply(t), valueFunction.apply(t)),
+ ImmutableSetMultimap.Builder::combine,
+ ImmutableSetMultimap.Builder::build);
}
/**
@@ -135,18 +135,21 @@
*
* @since 21.0
*/
- public static <T extends @Nullable Object, K, V>
+ public static <T, K, V>
Collector<T, ?, ImmutableSetMultimap<K, V>> flatteningToImmutableSetMultimap(
Function<? super T, ? extends K> keyFunction,
Function<? super T, ? extends Stream<? extends V>> valuesFunction) {
- return CollectCollectors.flatteningToImmutableSetMultimap(keyFunction, valuesFunction);
+ checkNotNull(keyFunction);
+ checkNotNull(valuesFunction);
+ return Collectors.collectingAndThen(
+ Multimaps.flatteningToMultimap(
+ input -> checkNotNull(keyFunction.apply(input)),
+ input -> valuesFunction.apply(input).peek(Preconditions::checkNotNull),
+ MultimapBuilder.linkedHashKeys().linkedHashSetValues()::<K, V>build),
+ ImmutableSetMultimap::copyOf);
}
- /**
- * Returns the empty multimap.
- *
- * <p><b>Performance note:</b> the instance returned is a singleton.
- */
+ /** Returns the empty multimap. */
// Casting is safe because the multimap will never hold any elements.
@SuppressWarnings("unchecked")
public static <K, V> ImmutableSetMultimap<K, V> of() {
@@ -374,8 +377,7 @@
}
private static <K, V> ImmutableSetMultimap<K, V> copyOf(
- Multimap<? extends K, ? extends V> multimap,
- @CheckForNull Comparator<? super V> valueComparator) {
+ Multimap<? extends K, ? extends V> multimap, Comparator<? super V> valueComparator) {
checkNotNull(multimap); // eager for GWT
if (multimap.isEmpty() && valueComparator == null) {
return of();
@@ -410,7 +412,7 @@
/** Creates an ImmutableSetMultimap from an asMap.entrySet. */
static <K, V> ImmutableSetMultimap<K, V> fromMapEntries(
Collection<? extends Map.Entry<? extends K, ? extends Collection<? extends V>>> mapEntries,
- @CheckForNull Comparator<? super V> valueComparator) {
+ @Nullable Comparator<? super V> valueComparator) {
if (mapEntries.isEmpty()) {
return of();
}
@@ -440,7 +442,7 @@
ImmutableSetMultimap(
ImmutableMap<K, ImmutableSet<V>> map,
int size,
- @CheckForNull Comparator<? super V> valueComparator) {
+ @Nullable Comparator<? super V> valueComparator) {
super(map, size);
this.emptySet = emptySet(valueComparator);
}
@@ -453,13 +455,13 @@
* parameters used to build this multimap.
*/
@Override
- public ImmutableSet<V> get(K key) {
+ public ImmutableSet<V> get(@Nullable K key) {
// This cast is safe as its type is known in constructor.
ImmutableSet<V> set = (ImmutableSet<V>) map.get(key);
return MoreObjects.firstNonNull(set, emptySet);
}
- @LazyInit @RetainedWith @CheckForNull private transient ImmutableSetMultimap<V, K> inverse;
+ @LazyInit @RetainedWith private transient @Nullable ImmutableSetMultimap<V, K> inverse;
/**
* {@inheritDoc}
@@ -493,8 +495,7 @@
@CanIgnoreReturnValue
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
- public final ImmutableSet<V> removeAll(@CheckForNull Object key) {
+ public ImmutableSet<V> removeAll(Object key) {
throw new UnsupportedOperationException();
}
@@ -507,12 +508,11 @@
@CanIgnoreReturnValue
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
- public final ImmutableSet<V> replaceValues(K key, Iterable<? extends V> values) {
+ public ImmutableSet<V> replaceValues(K key, Iterable<? extends V> values) {
throw new UnsupportedOperationException();
}
- @LazyInit @RetainedWith @CheckForNull private transient ImmutableSet<Entry<K, V>> entries;
+ @LazyInit @RetainedWith private transient @Nullable ImmutableSet<Entry<K, V>> entries;
/**
* Returns an immutable collection of all key-value pairs in the multimap. Its iterator traverses
@@ -532,7 +532,7 @@
}
@Override
- public boolean contains(@CheckForNull Object object) {
+ public boolean contains(@Nullable Object object) {
if (object instanceof Entry) {
Entry<?, ?> entry = (Entry<?, ?>) object;
return multimap.containsEntry(entry.getKey(), entry.getValue());
@@ -557,20 +557,20 @@
}
private static <V> ImmutableSet<V> valueSet(
- @CheckForNull Comparator<? super V> valueComparator, Collection<? extends V> values) {
+ @Nullable Comparator<? super V> valueComparator, Collection<? extends V> values) {
return (valueComparator == null)
? ImmutableSet.copyOf(values)
: ImmutableSortedSet.copyOf(valueComparator, values);
}
- private static <V> ImmutableSet<V> emptySet(@CheckForNull Comparator<? super V> valueComparator) {
+ private static <V> ImmutableSet<V> emptySet(@Nullable Comparator<? super V> valueComparator) {
return (valueComparator == null)
? ImmutableSet.<V>of()
: ImmutableSortedSet.<V>emptySet(valueComparator);
}
private static <V> ImmutableSet.Builder<V> valuesBuilder(
- @CheckForNull Comparator<? super V> valueComparator) {
+ @Nullable Comparator<? super V> valueComparator) {
return (valueComparator == null)
? new ImmutableSet.Builder<V>()
: new ImmutableSortedSet.Builder<V>(valueComparator);
@@ -587,7 +587,7 @@
Serialization.writeMultimap(this, stream);
}
- @CheckForNull
+ @Nullable
Comparator<? super V> valueComparator() {
return emptySet instanceof ImmutableSortedSet
? ((ImmutableSortedSet<V>) emptySet).comparator()
diff --git a/guava/src/com/google/common/collect/ImmutableSortedAsList.java b/guava/src/com/google/common/collect/ImmutableSortedAsList.java
index 30f19a0..91f700e 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 javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* List returned by {@code ImmutableSortedSet.asList()} when the set isn't empty.
@@ -28,7 +28,6 @@
*/
@GwtCompatible(emulated = true)
@SuppressWarnings("serial")
-@ElementTypesAreNonnullByDefault
final class ImmutableSortedAsList<E> extends RegularImmutableAsList<E>
implements SortedIterable<E> {
ImmutableSortedAsList(ImmutableSortedSet<E> backingSet, ImmutableList<E> backingList) {
@@ -50,7 +49,7 @@
@GwtIncompatible // ImmutableSortedSet.indexOf
// TODO(cpovirk): consider manual binary search under GWT to preserve O(log N) lookup
@Override
- public int indexOf(@CheckForNull 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
@@ -63,12 +62,12 @@
@GwtIncompatible // ImmutableSortedSet.indexOf
@Override
- public int lastIndexOf(@CheckForNull Object target) {
+ public int lastIndexOf(@Nullable Object target) {
return indexOf(target);
}
@Override
- public boolean contains(@CheckForNull Object target) {
+ public boolean contains(Object target) {
// Necessary for ISS's with comparators inconsistent with equals.
return indexOf(target) >= 0;
}
diff --git a/guava/src/com/google/common/collect/ImmutableSortedMap.java b/guava/src/com/google/common/collect/ImmutableSortedMap.java
index c4b59c8..dcda1f4 100644
--- a/guava/src/com/google/common/collect/ImmutableSortedMap.java
+++ b/guava/src/com/google/common/collect/ImmutableSortedMap.java
@@ -20,12 +20,10 @@
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.collect.CollectPreconditions.checkEntryNotNull;
import static com.google.common.collect.Maps.keyOrNull;
-import static java.util.Objects.requireNonNull;
import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtCompatible;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
-import com.google.errorprone.annotations.DoNotCall;
import java.util.AbstractMap;
import java.util.Arrays;
import java.util.Comparator;
@@ -40,7 +38,6 @@
import java.util.function.Function;
import java.util.stream.Collector;
import java.util.stream.Collectors;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -61,7 +58,6 @@
* @since 2.0 (implements {@code NavigableMap} since 12.0)
*/
@GwtCompatible(serializable = true, emulated = true)
-@ElementTypesAreNonnullByDefault
public final class ImmutableSortedMap<K, V> extends ImmutableSortedMapFauxverideShim<K, V>
implements NavigableMap<K, V> {
/**
@@ -76,11 +72,10 @@
*
* @since 21.0
*/
- public static <T extends @Nullable Object, K, V>
- Collector<T, ?, ImmutableSortedMap<K, V>> toImmutableSortedMap(
- Comparator<? super K> comparator,
- Function<? super T, ? extends K> keyFunction,
- Function<? super T, ? extends V> valueFunction) {
+ public static <T, K, V> Collector<T, ?, ImmutableSortedMap<K, V>> toImmutableSortedMap(
+ Comparator<? super K> comparator,
+ Function<? super T, ? extends K> keyFunction,
+ Function<? super T, ? extends V> valueFunction) {
return CollectCollectors.toImmutableSortedMap(comparator, keyFunction, valueFunction);
}
@@ -95,14 +90,19 @@
*
* @since 21.0
*/
- public static <T extends @Nullable Object, K, V>
- Collector<T, ?, ImmutableSortedMap<K, V>> toImmutableSortedMap(
- Comparator<? super K> comparator,
- Function<? super T, ? extends K> keyFunction,
- Function<? super T, ? extends V> valueFunction,
- BinaryOperator<V> mergeFunction) {
- return CollectCollectors.toImmutableSortedMap(
- comparator, keyFunction, valueFunction, mergeFunction);
+ public static <T, K, V> Collector<T, ?, ImmutableSortedMap<K, V>> toImmutableSortedMap(
+ Comparator<? super K> comparator,
+ Function<? super T, ? extends K> keyFunction,
+ Function<? super T, ? extends V> valueFunction,
+ BinaryOperator<V> mergeFunction) {
+ checkNotNull(comparator);
+ checkNotNull(keyFunction);
+ checkNotNull(valueFunction);
+ checkNotNull(mergeFunction);
+ return Collectors.collectingAndThen(
+ Collectors.toMap(
+ keyFunction, valueFunction, mergeFunction, () -> new TreeMap<K, V>(comparator)),
+ ImmutableSortedMap::copyOfSorted);
}
/*
@@ -124,11 +124,7 @@
}
}
- /**
- * Returns the empty sorted map.
- *
- * <p><b>Performance note:</b> the instance returned is a singleton.
- */
+ /** Returns the empty sorted map. */
@SuppressWarnings("unchecked")
// unsafe, comparator() returns a comparator on the specified type
// TODO(kevinb): evaluate whether or not of().comparator() should return null
@@ -157,7 +153,7 @@
@SuppressWarnings("unchecked")
public static <K extends Comparable<? super K>, V> ImmutableSortedMap<K, V> of(
K k1, V v1, K k2, V v2) {
- return fromEntries(entryOf(k1, v1), entryOf(k2, v2));
+ return ofEntries(entryOf(k1, v1), entryOf(k2, v2));
}
/**
@@ -169,7 +165,7 @@
@SuppressWarnings("unchecked")
public static <K extends Comparable<? super K>, V> ImmutableSortedMap<K, V> of(
K k1, V v1, K k2, V v2, K k3, V v3) {
- return fromEntries(entryOf(k1, v1), entryOf(k2, v2), entryOf(k3, v3));
+ return ofEntries(entryOf(k1, v1), entryOf(k2, v2), entryOf(k3, v3));
}
/**
@@ -181,7 +177,7 @@
@SuppressWarnings("unchecked")
public static <K extends Comparable<? super K>, V> ImmutableSortedMap<K, V> of(
K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4) {
- return fromEntries(entryOf(k1, v1), entryOf(k2, v2), entryOf(k3, v3), entryOf(k4, v4));
+ return ofEntries(entryOf(k1, v1), entryOf(k2, v2), entryOf(k3, v3), entryOf(k4, v4));
}
/**
@@ -193,164 +189,13 @@
@SuppressWarnings("unchecked")
public static <K extends Comparable<? super K>, V> ImmutableSortedMap<K, V> of(
K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5) {
- return fromEntries(
+ return ofEntries(
entryOf(k1, v1), entryOf(k2, v2), entryOf(k3, v3), entryOf(k4, v4), entryOf(k5, v5));
}
- /**
- * Returns an immutable sorted map containing the given entries, sorted by the natural ordering of
- * their keys.
- *
- * @throws IllegalArgumentException if any two keys are equal according to their natural ordering
- * @since 31.0
- */
- @SuppressWarnings("unchecked")
- public static <K extends Comparable<? super K>, V> ImmutableSortedMap<K, V> of(
- K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6) {
- return fromEntries(
- entryOf(k1, v1),
- entryOf(k2, v2),
- entryOf(k3, v3),
- entryOf(k4, v4),
- entryOf(k5, v5),
- entryOf(k6, v6));
- }
-
- /**
- * Returns an immutable sorted map containing the given entries, sorted by the natural ordering of
- * their keys.
- *
- * @throws IllegalArgumentException if any two keys are equal according to their natural ordering
- * @since 31.0
- */
- @SuppressWarnings("unchecked")
- public static <K extends Comparable<? super K>, V> ImmutableSortedMap<K, V> of(
- K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6, K k7, V v7) {
- return fromEntries(
- entryOf(k1, v1),
- entryOf(k2, v2),
- entryOf(k3, v3),
- entryOf(k4, v4),
- entryOf(k5, v5),
- entryOf(k6, v6),
- entryOf(k7, v7));
- }
-
- /**
- * Returns an immutable sorted map containing the given entries, sorted by the natural ordering of
- * their keys.
- *
- * @throws IllegalArgumentException if any two keys are equal according to their natural ordering
- * @since 31.0
- */
- @SuppressWarnings("unchecked")
- public static <K extends Comparable<? super K>, V> ImmutableSortedMap<K, V> of(
- K k1,
- V v1,
- K k2,
- V v2,
- K k3,
- V v3,
- K k4,
- V v4,
- K k5,
- V v5,
- K k6,
- V v6,
- K k7,
- V v7,
- K k8,
- V v8) {
- return fromEntries(
- entryOf(k1, v1),
- entryOf(k2, v2),
- entryOf(k3, v3),
- entryOf(k4, v4),
- entryOf(k5, v5),
- entryOf(k6, v6),
- entryOf(k7, v7),
- entryOf(k8, v8));
- }
-
- /**
- * Returns an immutable sorted map containing the given entries, sorted by the natural ordering of
- * their keys.
- *
- * @throws IllegalArgumentException if any two keys are equal according to their natural ordering
- * @since 31.0
- */
- @SuppressWarnings("unchecked")
- public static <K extends Comparable<? super K>, V> ImmutableSortedMap<K, V> of(
- K k1,
- V v1,
- K k2,
- V v2,
- K k3,
- V v3,
- K k4,
- V v4,
- K k5,
- V v5,
- K k6,
- V v6,
- K k7,
- V v7,
- K k8,
- V v8,
- K k9,
- V v9) {
- return fromEntries(
- entryOf(k1, v1),
- entryOf(k2, v2),
- entryOf(k3, v3),
- entryOf(k4, v4),
- entryOf(k5, v5),
- entryOf(k6, v6),
- entryOf(k7, v7),
- entryOf(k8, v8),
- entryOf(k9, v9));
- }
-
- /**
- * Returns an immutable sorted map containing the given entries, sorted by the natural ordering of
- * their keys.
- *
- * @throws IllegalArgumentException if any two keys are equal according to their natural ordering
- * @since 31.0
- */
- @SuppressWarnings("unchecked")
- public static <K extends Comparable<? super K>, V> ImmutableSortedMap<K, V> of(
- K k1,
- V v1,
- K k2,
- V v2,
- K k3,
- V v3,
- K k4,
- V v4,
- K k5,
- V v5,
- K k6,
- V v6,
- K k7,
- V v7,
- K k8,
- V v8,
- K k9,
- V v9,
- K k10,
- V v10) {
- return fromEntries(
- entryOf(k1, v1),
- entryOf(k2, v2),
- entryOf(k3, v3),
- entryOf(k4, v4),
- entryOf(k5, v5),
- entryOf(k6, v6),
- entryOf(k7, v7),
- entryOf(k8, v8),
- entryOf(k9, v9),
- entryOf(k10, v10));
+ private static <K extends Comparable<? super K>, V> ImmutableSortedMap<K, V> ofEntries(
+ Entry<K, V>... entries) {
+ return fromEntries(Ordering.natural(), false, entries, entries.length);
}
/**
@@ -393,8 +238,8 @@
}
/**
- * Returns an immutable map containing the given entries, with keys sorted by their natural
- * ordering.
+ * Returns an immutable map containing the given entries, with keys sorted by the provided
+ * comparator.
*
* <p>This method is not type-safe, as it may be called on a map with keys that are not mutually
* comparable.
@@ -480,11 +325,6 @@
return fromEntries(comparator, sameComparator, map.entrySet());
}
- private static <K extends Comparable<? super K>, V> ImmutableSortedMap<K, V> fromEntries(
- Entry<K, V>... entries) {
- return fromEntries(Ordering.natural(), false, entries, entries.length);
- }
-
/**
* Accepts a collection of possibly-null entries. If {@code sameComparator}, then it is assumed
* that they do not need to be sorted or checked for dupes.
@@ -504,25 +344,22 @@
private static <K, V> ImmutableSortedMap<K, V> fromEntries(
final Comparator<? super K> comparator,
boolean sameComparator,
- @Nullable Entry<K, V>[] entryArray,
+ Entry<K, V>[] entryArray,
int size) {
switch (size) {
case 0:
return emptyMap(comparator);
case 1:
- // requireNonNull is safe because the first `size` elements have been filled in.
- Entry<K, V> onlyEntry = requireNonNull(entryArray[0]);
- return of(comparator, onlyEntry.getKey(), onlyEntry.getValue());
+ return ImmutableSortedMap.<K, V>of(
+ comparator, entryArray[0].getKey(), entryArray[0].getValue());
default:
Object[] keys = new Object[size];
Object[] values = new Object[size];
if (sameComparator) {
// Need to check for nulls, but don't need to sort or validate.
for (int i = 0; i < size; i++) {
- // requireNonNull is safe because the first `size` elements have been filled in.
- Entry<K, V> entry = requireNonNull(entryArray[i]);
- Object key = entry.getKey();
- Object value = entry.getValue();
+ Object key = entryArray[i].getKey();
+ Object value = entryArray[i].getValue();
checkEntryNotNull(key, value);
keys[i] = key;
values[i] = value;
@@ -535,31 +372,24 @@
entryArray,
0,
size,
- new Comparator<@Nullable Entry<K, V>>() {
+ new Comparator<Entry<K, V>>() {
@Override
- public int compare(@CheckForNull Entry<K, V> e1, @CheckForNull Entry<K, V> e2) {
- // requireNonNull is safe because the first `size` elements have been filled in.
- requireNonNull(e1);
- requireNonNull(e2);
+ public int compare(Entry<K, V> e1, Entry<K, V> e2) {
return comparator.compare(e1.getKey(), e2.getKey());
}
});
- // requireNonNull is safe because the first `size` elements have been filled in.
- Entry<K, V> firstEntry = requireNonNull(entryArray[0]);
- K prevKey = firstEntry.getKey();
+ K prevKey = entryArray[0].getKey();
keys[0] = prevKey;
- values[0] = firstEntry.getValue();
+ values[0] = entryArray[0].getValue();
checkEntryNotNull(keys[0], values[0]);
for (int i = 1; i < size; i++) {
- // requireNonNull is safe because the first `size` elements have been filled in.
- Entry<K, V> prevEntry = requireNonNull(entryArray[i - 1]);
- Entry<K, V> entry = requireNonNull(entryArray[i]);
- K key = entry.getKey();
- V value = entry.getValue();
+ K key = entryArray[i].getKey();
+ V value = entryArray[i].getValue();
checkEntryNotNull(key, value);
keys[i] = key;
values[i] = value;
- checkNoConflict(comparator.compare(prevKey, key) != 0, "key", prevEntry, entry);
+ checkNoConflict(
+ comparator.compare(prevKey, key) != 0, "key", entryArray[i - 1], entryArray[i]);
prevKey = key;
}
}
@@ -607,14 +437,14 @@
* .put(1, "one")
* .put(2, "two")
* .put(3, "three")
- * .buildOrThrow();
+ * .build();
* }</pre>
*
* <p>For <i>small</i> immutable sorted maps, the {@code ImmutableSortedMap.of()} methods are even
* more convenient.
*
- * <p>Builder instances can be reused - it is safe to call {@link #buildOrThrow} multiple times to
- * build multiple maps in series. Each map is a superset of the maps created before it.
+ * <p>Builder instances can be reused - it is safe to call {@link #build} multiple times to build
+ * multiple maps in series. Each map is a superset of the maps created before it.
*
* @since 2.0
*/
@@ -696,8 +526,7 @@
@Beta
@Override
@Deprecated
- @DoNotCall("Always throws UnsupportedOperationException")
- public final Builder<K, V> orderEntriesByValue(Comparator<? super V> valueComparator) {
+ public Builder<K, V> orderEntriesByValue(Comparator<? super V> valueComparator) {
throw new UnsupportedOperationException("Not available on ImmutableSortedMap.Builder");
}
@@ -710,35 +539,16 @@
/**
* Returns a newly-created immutable sorted map.
*
- * <p>Prefer the equivalent method {@link #buildOrThrow()} to make it explicit that the method
- * will throw an exception if there are duplicate keys. The {@code build()} method will soon be
- * deprecated.
- *
* @throws IllegalArgumentException if any two keys are equal according to the comparator (which
* might be the keys' natural order)
*/
@Override
public ImmutableSortedMap<K, V> build() {
- return buildOrThrow();
- }
-
- /**
- * Returns a newly-created immutable sorted map, or throws an exception if any two keys are
- * equal.
- *
- * @throws IllegalArgumentException if any two keys are equal according to the comparator (which
- * might be the keys' natural order)
- * @since 31.0
- */
- @Override
- public ImmutableSortedMap<K, V> buildOrThrow() {
switch (size) {
case 0:
return emptyMap(comparator);
case 1:
- // requireNonNull is safe because the first `size` elements have been filled in.
- Entry<K, V> onlyEntry = requireNonNull(entries[0]);
- return of(comparator, onlyEntry.getKey(), onlyEntry.getValue());
+ return of(comparator, entries[0].getKey(), entries[0].getValue());
default:
return fromEntries(comparator, false, entries, size);
}
@@ -747,7 +557,7 @@
private final transient RegularImmutableSortedSet<K> keySet;
private final transient ImmutableList<V> valueList;
- @CheckForNull private transient ImmutableSortedMap<K, V> descendingMap;
+ private transient ImmutableSortedMap<K, V> descendingMap;
ImmutableSortedMap(RegularImmutableSortedSet<K> keySet, ImmutableList<V> valueList) {
this(keySet, valueList, null);
@@ -756,7 +566,7 @@
ImmutableSortedMap(
RegularImmutableSortedSet<K> keySet,
ImmutableList<V> valueList,
- @CheckForNull ImmutableSortedMap<K, V> descendingMap) {
+ ImmutableSortedMap<K, V> descendingMap) {
this.keySet = keySet;
this.valueList = valueList;
this.descendingMap = descendingMap;
@@ -777,8 +587,7 @@
}
@Override
- @CheckForNull
- public V get(@CheckForNull Object key) {
+ public V get(@Nullable Object key) {
int index = keySet.indexOf(key);
return (index == -1) ? null : valueList.get(index);
}
@@ -1000,61 +809,51 @@
}
@Override
- @CheckForNull
public Entry<K, V> lowerEntry(K key) {
return headMap(key, false).lastEntry();
}
@Override
- @CheckForNull
public K lowerKey(K key) {
return keyOrNull(lowerEntry(key));
}
@Override
- @CheckForNull
public Entry<K, V> floorEntry(K key) {
return headMap(key, true).lastEntry();
}
@Override
- @CheckForNull
public K floorKey(K key) {
return keyOrNull(floorEntry(key));
}
@Override
- @CheckForNull
public Entry<K, V> ceilingEntry(K key) {
return tailMap(key, true).firstEntry();
}
@Override
- @CheckForNull
public K ceilingKey(K key) {
return keyOrNull(ceilingEntry(key));
}
@Override
- @CheckForNull
public Entry<K, V> higherEntry(K key) {
return tailMap(key, false).firstEntry();
}
@Override
- @CheckForNull
public K higherKey(K key) {
return keyOrNull(higherEntry(key));
}
@Override
- @CheckForNull
public Entry<K, V> firstEntry() {
return isEmpty() ? null : entrySet().asList().get(0);
}
@Override
- @CheckForNull
public Entry<K, V> lastEntry() {
return isEmpty() ? null : entrySet().asList().get(size() - 1);
}
@@ -1068,8 +867,6 @@
@CanIgnoreReturnValue
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
- @CheckForNull
public final Entry<K, V> pollFirstEntry() {
throw new UnsupportedOperationException();
}
@@ -1083,8 +880,6 @@
@CanIgnoreReturnValue
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
- @CheckForNull
public final Entry<K, V> pollLastEntry() {
throw new UnsupportedOperationException();
}
diff --git a/guava/src/com/google/common/collect/ImmutableSortedMapFauxverideShim.java b/guava/src/com/google/common/collect/ImmutableSortedMapFauxverideShim.java
index 7b2e4d7..87b8351 100644
--- a/guava/src/com/google/common/collect/ImmutableSortedMapFauxverideShim.java
+++ b/guava/src/com/google/common/collect/ImmutableSortedMapFauxverideShim.java
@@ -17,11 +17,9 @@
package com.google.common.collect;
import com.google.common.annotations.GwtIncompatible;
-import com.google.errorprone.annotations.DoNotCall;
import java.util.function.BinaryOperator;
import java.util.function.Function;
import java.util.stream.Collector;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* "Overrides" the {@link ImmutableMap} static methods that lack {@link ImmutableSortedMap}
@@ -31,7 +29,6 @@
* @author Chris Povirk
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
abstract class ImmutableSortedMapFauxverideShim<K, V> extends ImmutableMap<K, V> {
/**
* Not supported. Use {@link ImmutableSortedMap#toImmutableSortedMap}, which offers better
@@ -41,12 +38,10 @@
* @throws UnsupportedOperationException always
* @deprecated Use {@link ImmutableSortedMap#toImmutableSortedMap}.
*/
- @DoNotCall("Use toImmutableSortedMap")
@Deprecated
- public static <T extends @Nullable Object, K, V>
- Collector<T, ?, ImmutableMap<K, V>> toImmutableMap(
- Function<? super T, ? extends K> keyFunction,
- Function<? super T, ? extends V> valueFunction) {
+ public static <T, K, V> Collector<T, ?, ImmutableMap<K, V>> toImmutableMap(
+ Function<? super T, ? extends K> keyFunction,
+ Function<? super T, ? extends V> valueFunction) {
throw new UnsupportedOperationException();
}
@@ -58,13 +53,11 @@
* @throws UnsupportedOperationException always
* @deprecated Use {@link ImmutableSortedMap#toImmutableSortedMap}.
*/
- @DoNotCall("Use toImmutableSortedMap")
@Deprecated
- public static <T extends @Nullable Object, K, V>
- Collector<T, ?, ImmutableMap<K, V>> toImmutableMap(
- Function<? super T, ? extends K> keyFunction,
- Function<? super T, ? extends V> valueFunction,
- BinaryOperator<V> mergeFunction) {
+ public static <T, K, V> Collector<T, ?, ImmutableMap<K, V>> toImmutableMap(
+ Function<? super T, ? extends K> keyFunction,
+ Function<? super T, ? extends V> valueFunction,
+ BinaryOperator<V> mergeFunction) {
throw new UnsupportedOperationException();
}
@@ -76,7 +69,6 @@
* @throws UnsupportedOperationException always
* @deprecated Use {@link ImmutableSortedMap#naturalOrder}, which offers better type-safety.
*/
- @DoNotCall("Use naturalOrder")
@Deprecated
public static <K, V> ImmutableSortedMap.Builder<K, V> builder() {
throw new UnsupportedOperationException();
@@ -88,7 +80,6 @@
* @throws UnsupportedOperationException always
* @deprecated Not supported for ImmutableSortedMap.
*/
- @DoNotCall("Use naturalOrder (which does not accept an expected size)")
@Deprecated
public static <K, V> ImmutableSortedMap.Builder<K, V> builderWithExpectedSize(int expectedSize) {
throw new UnsupportedOperationException();
@@ -103,7 +94,6 @@
* @deprecated <b>Pass a key of type {@code Comparable} to use {@link
* ImmutableSortedMap#of(Comparable, Object)}.</b>
*/
- @DoNotCall("Pass a key of type Comparable")
@Deprecated
public static <K, V> ImmutableSortedMap<K, V> of(K k1, V v1) {
throw new UnsupportedOperationException();
@@ -118,7 +108,6 @@
* @deprecated <b>Pass keys of type {@code Comparable} to use {@link
* ImmutableSortedMap#of(Comparable, Object, Comparable, Object)}.</b>
*/
- @DoNotCall("Pass keys of type Comparable")
@Deprecated
public static <K, V> ImmutableSortedMap<K, V> of(K k1, V v1, K k2, V v2) {
throw new UnsupportedOperationException();
@@ -133,7 +122,6 @@
* @deprecated <b>Pass keys of type {@code Comparable} to use {@link
* ImmutableSortedMap#of(Comparable, Object, Comparable, Object, Comparable, Object)}.</b>
*/
- @DoNotCall("Pass keys of type Comparable")
@Deprecated
public static <K, V> ImmutableSortedMap<K, V> of(K k1, V v1, K k2, V v2, K k3, V v3) {
throw new UnsupportedOperationException();
@@ -149,7 +137,6 @@
* ImmutableSortedMap#of(Comparable, Object, Comparable, Object, Comparable, Object,
* Comparable, Object)}.</b>
*/
- @DoNotCall("Pass keys of type Comparable")
@Deprecated
public static <K, V> ImmutableSortedMap<K, V> of(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4) {
throw new UnsupportedOperationException();
@@ -165,160 +152,11 @@
* ImmutableSortedMap#of(Comparable, Object, Comparable, Object, Comparable, Object,
* Comparable, Object, Comparable, Object)}.</b>
*/
- @DoNotCall("Pass keys of type Comparable")
@Deprecated
public static <K, V> ImmutableSortedMap<K, V> of(
K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5) {
throw new UnsupportedOperationException();
}
- /**
- * Not supported. <b>You are attempting to create a map that may contain non-{@code Comparable}
- * keys.</b> Proper calls will resolve to the version in {@code ImmutableSortedMap}, not this
- * dummy version.
- *
- * @throws UnsupportedOperationException always
- * @deprecated <b>Pass keys of type {@code Comparable} to use {@link
- * ImmutableSortedMap#of(Comparable, Object, Comparable, Object, Comparable, Object,
- * Comparable, Object, Comparable, Object)}.</b>
- */
- @DoNotCall("Pass keys of type Comparable")
- @Deprecated
- public static <K, V> ImmutableSortedMap<K, V> of(
- K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Not supported. <b>You are attempting to create a map that may contain non-{@code Comparable}
- * keys.</b> Proper calls will resolve to the version in {@code ImmutableSortedMap}, not this
- * dummy version.
- *
- * @throws UnsupportedOperationException always
- * @deprecated <b>Pass keys of type {@code Comparable} to use {@link
- * ImmutableSortedMap#of(Comparable, Object, Comparable, Object, Comparable, Object,
- * Comparable, Object, Comparable, Object)}.</b>
- */
- @DoNotCall("Pass keys of type Comparable")
- @Deprecated
- public static <K, V> ImmutableSortedMap<K, V> of(
- K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6, K k7, V v7) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Not supported. <b>You are attempting to create a map that may contain non-{@code Comparable}
- * keys.</b> Proper calls will resolve to the version in {@code ImmutableSortedMap}, not this
- * dummy version.
- *
- * @throws UnsupportedOperationException always
- * @deprecated <b>Pass keys of type {@code Comparable} to use {@link
- * ImmutableSortedMap#of(Comparable, Object, Comparable, Object, Comparable, Object,
- * Comparable, Object, Comparable, Object)}.</b>
- */
- @DoNotCall("Pass keys of type Comparable")
- @Deprecated
- public static <K, V> ImmutableSortedMap<K, V> of(
- K k1,
- V v1,
- K k2,
- V v2,
- K k3,
- V v3,
- K k4,
- V v4,
- K k5,
- V v5,
- K k6,
- V v6,
- K k7,
- V v7,
- K k8,
- V v8) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Not supported. <b>You are attempting to create a map that may contain non-{@code Comparable}
- * keys.</b> Proper calls will resolve to the version in {@code ImmutableSortedMap}, not this
- * dummy version.
- *
- * @throws UnsupportedOperationException always
- * @deprecated <b>Pass keys of type {@code Comparable} to use {@link
- * ImmutableSortedMap#of(Comparable, Object, Comparable, Object, Comparable, Object,
- * Comparable, Object, Comparable, Object)}.</b>
- */
- @DoNotCall("Pass keys of type Comparable")
- @Deprecated
- public static <K, V> ImmutableSortedMap<K, V> of(
- K k1,
- V v1,
- K k2,
- V v2,
- K k3,
- V v3,
- K k4,
- V v4,
- K k5,
- V v5,
- K k6,
- V v6,
- K k7,
- V v7,
- K k8,
- V v8,
- K k9,
- V v9) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Not supported. <b>You are attempting to create a map that may contain non-{@code Comparable}
- * keys.</b> Proper calls will resolve to the version in {@code ImmutableSortedMap}, not this
- * dummy version.
- *
- * @throws UnsupportedOperationException always
- * @deprecated <b>Pass keys of type {@code Comparable} to use {@link
- * ImmutableSortedMap#of(Comparable, Object, Comparable, Object, Comparable, Object,
- * Comparable, Object, Comparable, Object)}.</b>
- */
- @DoNotCall("Pass keys of type Comparable")
- @Deprecated
- public static <K, V> ImmutableSortedMap<K, V> of(
- K k1,
- V v1,
- K k2,
- V v2,
- K k3,
- V v3,
- K k4,
- V v4,
- K k5,
- V v5,
- K k6,
- V v6,
- K k7,
- V v7,
- K k8,
- V v8,
- K k9,
- V v9,
- K k10,
- V v10) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Not supported. Use {@code ImmutableSortedMap.copyOf(ImmutableMap.ofEntries(...))}.
- *
- * @deprecated Use {@code ImmutableSortedMap.copyOf(ImmutableMap.ofEntries(...))}.
- */
- @DoNotCall("ImmutableSortedMap.ofEntries not currently available; use ImmutableSortedMap.copyOf")
- @Deprecated
- public static <K, V> ImmutableSortedMap<K, V> ofEntries(
- Entry<? extends K, ? extends V>... entries) {
- throw new UnsupportedOperationException();
- }
-
// No copyOf() fauxveride; see ImmutableSortedSetFauxverideShim.
}
diff --git a/guava/src/com/google/common/collect/ImmutableSortedMultiset.java b/guava/src/com/google/common/collect/ImmutableSortedMultiset.java
index bf5a2f4..ec02063 100644
--- a/guava/src/com/google/common/collect/ImmutableSortedMultiset.java
+++ b/guava/src/com/google/common/collect/ImmutableSortedMultiset.java
@@ -19,7 +19,6 @@
import com.google.common.annotations.GwtIncompatible;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
-import com.google.errorprone.annotations.DoNotCall;
import com.google.errorprone.annotations.concurrent.LazyInit;
import java.io.Serializable;
import java.util.Arrays;
@@ -31,8 +30,6 @@
import java.util.function.Function;
import java.util.function.ToIntFunction;
import java.util.stream.Collector;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* A {@link SortedMultiset} whose contents will never change, with many other important properties
@@ -51,7 +48,6 @@
* @since 12.0
*/
@GwtIncompatible // hasn't been tested yet
-@ElementTypesAreNonnullByDefault
public abstract class ImmutableSortedMultiset<E> extends ImmutableSortedMultisetFauxverideShim<E>
implements SortedMultiset<E> {
// TODO(lowasser): GWT compatibility
@@ -81,11 +77,10 @@
*
* @since 22.0
*/
- public static <T extends @Nullable Object, E>
- Collector<T, ?, ImmutableSortedMultiset<E>> toImmutableSortedMultiset(
- Comparator<? super E> comparator,
- Function<? super T, ? extends E> elementFunction,
- ToIntFunction<? super T> countFunction) {
+ public static <T, E> Collector<T, ?, ImmutableSortedMultiset<E>> toImmutableSortedMultiset(
+ Comparator<? super E> comparator,
+ Function<? super T, ? extends E> elementFunction,
+ ToIntFunction<? super T> countFunction) {
checkNotNull(comparator);
checkNotNull(elementFunction);
checkNotNull(countFunction);
@@ -100,11 +95,7 @@
(Multiset<E> multiset) -> copyOfSortedEntries(comparator, multiset.entrySet()));
}
- /**
- * Returns the empty immutable sorted multiset.
- *
- * <p><b>Performance note:</b> the instance returned is a singleton.
- */
+ /** Returns the empty immutable sorted multiset. */
@SuppressWarnings("unchecked")
public static <E> ImmutableSortedMultiset<E> of() {
return (ImmutableSortedMultiset) RegularImmutableSortedMultiset.NATURAL_EMPTY_MULTISET;
@@ -124,6 +115,7 @@
*
* @throws NullPointerException if any element is null
*/
+ @SuppressWarnings("unchecked")
public static <E extends Comparable<? super E>> ImmutableSortedMultiset<E> of(E e1, E e2) {
return copyOf(Ordering.natural(), Arrays.asList(e1, e2));
}
@@ -134,6 +126,7 @@
*
* @throws NullPointerException if any element is null
*/
+ @SuppressWarnings("unchecked")
public static <E extends Comparable<? super E>> ImmutableSortedMultiset<E> of(E e1, E e2, E e3) {
return copyOf(Ordering.natural(), Arrays.asList(e1, e2, e3));
}
@@ -144,6 +137,7 @@
*
* @throws NullPointerException if any element is null
*/
+ @SuppressWarnings("unchecked")
public static <E extends Comparable<? super E>> ImmutableSortedMultiset<E> of(
E e1, E e2, E e3, E e4) {
return copyOf(Ordering.natural(), Arrays.asList(e1, e2, e3, e4));
@@ -155,6 +149,7 @@
*
* @throws NullPointerException if any element is null
*/
+ @SuppressWarnings("unchecked")
public static <E extends Comparable<? super E>> ImmutableSortedMultiset<E> of(
E e1, E e2, E e3, E e4, E e5) {
return copyOf(Ordering.natural(), Arrays.asList(e1, e2, e3, e4, e5));
@@ -166,6 +161,7 @@
*
* @throws NullPointerException if any element is null
*/
+ @SuppressWarnings("unchecked")
public static <E extends Comparable<? super E>> ImmutableSortedMultiset<E> of(
E e1, E e2, E e3, E e4, E e5, E e6, E... remaining) {
int size = remaining.length + 6;
@@ -331,7 +327,7 @@
@Override
public abstract ImmutableSortedSet<E> elementSet();
- @LazyInit @CheckForNull transient ImmutableSortedMultiset<E> descendingMultiset;
+ @LazyInit transient ImmutableSortedMultiset<E> descendingMultiset;
@Override
public ImmutableSortedMultiset<E> descendingMultiset() {
@@ -356,8 +352,6 @@
@CanIgnoreReturnValue
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
- @CheckForNull
public final Entry<E> pollFirstEntry() {
throw new UnsupportedOperationException();
}
@@ -373,8 +367,6 @@
@CanIgnoreReturnValue
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
- @CheckForNull
public final Entry<E> pollLastEntry() {
throw new UnsupportedOperationException();
}
diff --git a/guava/src/com/google/common/collect/ImmutableSortedMultisetFauxverideShim.java b/guava/src/com/google/common/collect/ImmutableSortedMultisetFauxverideShim.java
index 94a2f56..e3f45f7 100644
--- a/guava/src/com/google/common/collect/ImmutableSortedMultisetFauxverideShim.java
+++ b/guava/src/com/google/common/collect/ImmutableSortedMultisetFauxverideShim.java
@@ -15,11 +15,9 @@
package com.google.common.collect;
import com.google.common.annotations.GwtIncompatible;
-import com.google.errorprone.annotations.DoNotCall;
import java.util.function.Function;
import java.util.function.ToIntFunction;
import java.util.stream.Collector;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* "Overrides" the {@link ImmutableMultiset} static methods that lack {@link
@@ -39,7 +37,6 @@
* @author Louis Wasserman
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
abstract class ImmutableSortedMultisetFauxverideShim<E> extends ImmutableMultiset<E> {
/**
* Not supported. Use {@link ImmutableSortedMultiset#toImmutableSortedMultiset} instead. This
@@ -50,7 +47,6 @@
* @deprecated Use {@link ImmutableSortedMultiset#toImmutableSortedMultiset}.
* @since 21.0
*/
- @DoNotCall("Use toImmutableSortedMultiset.")
@Deprecated
public static <E> Collector<E, ?, ImmutableMultiset<E>> toImmutableMultiset() {
throw new UnsupportedOperationException();
@@ -65,12 +61,9 @@
* @deprecated Use {@link ImmutableSortedMultiset#toImmutableSortedMultiset}.
* @since 22.0
*/
- @DoNotCall("Use toImmutableSortedMultiset.")
@Deprecated
- public static <T extends @Nullable Object, E>
- Collector<T, ?, ImmutableMultiset<E>> toImmutableMultiset(
- Function<? super T, ? extends E> elementFunction,
- ToIntFunction<? super T> countFunction) {
+ public static <T, E> Collector<T, ?, ImmutableMultiset<E>> toImmutableMultiset(
+ Function<? super T, ? extends E> elementFunction, ToIntFunction<? super T> countFunction) {
throw new UnsupportedOperationException();
}
@@ -82,7 +75,6 @@
* @throws UnsupportedOperationException always
* @deprecated Use {@link ImmutableSortedMultiset#naturalOrder}, which offers better type-safety.
*/
- @DoNotCall("Use naturalOrder.")
@Deprecated
public static <E> ImmutableSortedMultiset.Builder<E> builder() {
throw new UnsupportedOperationException();
@@ -97,7 +89,6 @@
* @deprecated <b>Pass a parameter of type {@code Comparable} to use {@link
* ImmutableSortedMultiset#of(Comparable)}.</b>
*/
- @DoNotCall("Elements must be Comparable. (Or, pass a Comparator to orderedBy or copyOf.)")
@Deprecated
public static <E> ImmutableSortedMultiset<E> of(E element) {
throw new UnsupportedOperationException();
@@ -112,7 +103,6 @@
* @deprecated <b>Pass the parameters of type {@code Comparable} to use {@link
* ImmutableSortedMultiset#of(Comparable, Comparable)}.</b>
*/
- @DoNotCall("Elements must be Comparable. (Or, pass a Comparator to orderedBy or copyOf.)")
@Deprecated
public static <E> ImmutableSortedMultiset<E> of(E e1, E e2) {
throw new UnsupportedOperationException();
@@ -127,7 +117,6 @@
* @deprecated <b>Pass the parameters of type {@code Comparable} to use {@link
* ImmutableSortedMultiset#of(Comparable, Comparable, Comparable)}.</b>
*/
- @DoNotCall("Elements must be Comparable. (Or, pass a Comparator to orderedBy or copyOf.)")
@Deprecated
public static <E> ImmutableSortedMultiset<E> of(E e1, E e2, E e3) {
throw new UnsupportedOperationException();
@@ -142,7 +131,6 @@
* @deprecated <b>Pass the parameters of type {@code Comparable} to use {@link
* ImmutableSortedMultiset#of(Comparable, Comparable, Comparable, Comparable)}. </b>
*/
- @DoNotCall("Elements must be Comparable. (Or, pass a Comparator to orderedBy or copyOf.)")
@Deprecated
public static <E> ImmutableSortedMultiset<E> of(E e1, E e2, E e3, E e4) {
throw new UnsupportedOperationException();
@@ -158,7 +146,6 @@
* ImmutableSortedMultiset#of(Comparable, Comparable, Comparable, Comparable, Comparable)} .
* </b>
*/
- @DoNotCall("Elements must be Comparable. (Or, pass a Comparator to orderedBy or copyOf.)")
@Deprecated
public static <E> ImmutableSortedMultiset<E> of(E e1, E e2, E e3, E e4, E e5) {
throw new UnsupportedOperationException();
@@ -174,7 +161,6 @@
* ImmutableSortedMultiset#of(Comparable, Comparable, Comparable, Comparable, Comparable,
* Comparable, Comparable...)} . </b>
*/
- @DoNotCall("Elements must be Comparable. (Or, pass a Comparator to orderedBy or copyOf.)")
@Deprecated
public static <E> ImmutableSortedMultiset<E> of(
E e1, E e2, E e3, E e4, E e5, E e6, E... remaining) {
@@ -190,7 +176,6 @@
* @deprecated <b>Pass parameters of type {@code Comparable} to use {@link
* ImmutableSortedMultiset#copyOf(Comparable[])}.</b>
*/
- @DoNotCall("Elements must be Comparable. (Or, pass a Comparator to orderedBy or copyOf.)")
@Deprecated
public static <E> ImmutableSortedMultiset<E> copyOf(E[] elements) {
throw new UnsupportedOperationException();
diff --git a/guava/src/com/google/common/collect/ImmutableSortedSet.java b/guava/src/com/google/common/collect/ImmutableSortedSet.java
index 8a7aec1..9a3409c 100644
--- a/guava/src/com/google/common/collect/ImmutableSortedSet.java
+++ b/guava/src/com/google/common/collect/ImmutableSortedSet.java
@@ -23,7 +23,6 @@
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.GwtIncompatible;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
-import com.google.errorprone.annotations.DoNotCall;
import com.google.errorprone.annotations.concurrent.LazyInit;
import java.io.InvalidObjectException;
import java.io.ObjectInputStream;
@@ -39,7 +38,6 @@
import java.util.Spliterators;
import java.util.function.Consumer;
import java.util.stream.Collector;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -62,7 +60,6 @@
// TODO(benyu): benchmark and optimize all creation paths, which are a mess now
@GwtCompatible(serializable = true, emulated = true)
@SuppressWarnings("serial") // we're overriding default serialization
-@ElementTypesAreNonnullByDefault
public abstract class ImmutableSortedSet<E> extends ImmutableSortedSetFauxverideShim<E>
implements NavigableSet<E>, SortedIterable<E> {
static final int SPLITERATOR_CHARACTERISTICS =
@@ -90,11 +87,7 @@
}
}
- /**
- * Returns the empty immutable sorted set.
- *
- * <p><b>Performance note:</b> the instance returned is a singleton.
- */
+ /** Returns the empty immutable sorted set. */
public static <E> ImmutableSortedSet<E> of() {
return (ImmutableSortedSet<E>) RegularImmutableSortedSet.NATURAL_EMPTY_SET;
}
@@ -577,16 +570,16 @@
}
}
- int unsafeCompare(Object a, @CheckForNull Object b) {
+ int unsafeCompare(Object a, Object b) {
return unsafeCompare(comparator, a, b);
}
- static int unsafeCompare(Comparator<?> comparator, Object a, @CheckForNull Object b) {
+ static int unsafeCompare(Comparator<?> comparator, Object a, Object b) {
// Pretend the comparator can compare anything. If it turns out it can't
- // compare a and b, we should get a CCE or NPE on the subsequent line. Only methods
- // that are spec'd to throw CCE and NPE should call this.
- @SuppressWarnings({"unchecked", "nullness"})
- Comparator<@Nullable Object> unsafeComparator = (Comparator<@Nullable Object>) comparator;
+ // compare a and b, we should get a CCE on the subsequent line. Only methods
+ // that are spec'd to throw CCE should call this.
+ @SuppressWarnings("unchecked")
+ Comparator<Object> unsafeComparator = (Comparator<Object>) comparator;
return unsafeComparator.compare(a, b);
}
@@ -693,21 +686,18 @@
/** @since 12.0 */
@GwtIncompatible // NavigableSet
@Override
- @CheckForNull
public E lower(E e) {
return Iterators.getNext(headSet(e, false).descendingIterator(), null);
}
/** @since 12.0 */
@Override
- @CheckForNull
public E floor(E e) {
return Iterators.getNext(headSet(e, true).descendingIterator(), null);
}
/** @since 12.0 */
@Override
- @CheckForNull
public E ceiling(E e) {
return Iterables.getFirst(tailSet(e, true), null);
}
@@ -715,7 +705,6 @@
/** @since 12.0 */
@GwtIncompatible // NavigableSet
@Override
- @CheckForNull
public E higher(E e) {
return Iterables.getFirst(tailSet(e, false), null);
}
@@ -741,8 +730,6 @@
@Deprecated
@GwtIncompatible // NavigableSet
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
- @CheckForNull
public final E pollFirst() {
throw new UnsupportedOperationException();
}
@@ -758,15 +745,12 @@
@Deprecated
@GwtIncompatible // NavigableSet
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
- @CheckForNull
public final E pollLast() {
throw new UnsupportedOperationException();
}
@GwtIncompatible // NavigableSet
@LazyInit
- @CheckForNull
transient ImmutableSortedSet<E> descendingSet;
/** @since 12.0 */
@@ -817,7 +801,7 @@
public abstract UnmodifiableIterator<E> descendingIterator();
/** Returns the position of an element within the set, or -1 if not present. */
- abstract int indexOf(@CheckForNull 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/ImmutableSortedSetFauxverideShim.java b/guava/src/com/google/common/collect/ImmutableSortedSetFauxverideShim.java
index ff3ac12..9a49fcb 100644
--- a/guava/src/com/google/common/collect/ImmutableSortedSetFauxverideShim.java
+++ b/guava/src/com/google/common/collect/ImmutableSortedSetFauxverideShim.java
@@ -17,7 +17,6 @@
package com.google.common.collect;
import com.google.common.annotations.GwtIncompatible;
-import com.google.errorprone.annotations.DoNotCall;
import java.util.stream.Collector;
/**
@@ -38,8 +37,7 @@
* @author Chris Povirk
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
-abstract class ImmutableSortedSetFauxverideShim<E> extends ImmutableSet.CachingAsList<E> {
+abstract class ImmutableSortedSetFauxverideShim<E> extends ImmutableSet<E> {
/**
* Not supported. Use {@link ImmutableSortedSet#toImmutableSortedSet} instead. This method exists
* only to hide {@link ImmutableSet#toImmutableSet} from consumers of {@code ImmutableSortedSet}.
@@ -48,7 +46,6 @@
* @deprecated Use {@link ImmutableSortedSet#toImmutableSortedSet}.
* @since 21.0
*/
- @DoNotCall("Use toImmutableSortedSet")
@Deprecated
public static <E> Collector<E, ?, ImmutableSet<E>> toImmutableSet() {
throw new UnsupportedOperationException();
@@ -62,7 +59,6 @@
* @throws UnsupportedOperationException always
* @deprecated Use {@link ImmutableSortedSet#naturalOrder}, which offers better type-safety.
*/
- @DoNotCall("Use naturalOrder")
@Deprecated
public static <E> ImmutableSortedSet.Builder<E> builder() {
throw new UnsupportedOperationException();
@@ -75,7 +71,6 @@
* @throws UnsupportedOperationException always
* @deprecated Not supported by ImmutableSortedSet.
*/
- @DoNotCall("Use naturalOrder (which does not accept an expected size)")
@Deprecated
public static <E> ImmutableSortedSet.Builder<E> builderWithExpectedSize(int expectedSize) {
throw new UnsupportedOperationException();
@@ -90,7 +85,6 @@
* @deprecated <b>Pass a parameter of type {@code Comparable} to use {@link
* ImmutableSortedSet#of(Comparable)}.</b>
*/
- @DoNotCall("Pass a parameter of type Comparable")
@Deprecated
public static <E> ImmutableSortedSet<E> of(E element) {
throw new UnsupportedOperationException();
@@ -105,7 +99,6 @@
* @deprecated <b>Pass the parameters of type {@code Comparable} to use {@link
* ImmutableSortedSet#of(Comparable, Comparable)}.</b>
*/
- @DoNotCall("Pass parameters of type Comparable")
@Deprecated
public static <E> ImmutableSortedSet<E> of(E e1, E e2) {
throw new UnsupportedOperationException();
@@ -120,7 +113,6 @@
* @deprecated <b>Pass the parameters of type {@code Comparable} to use {@link
* ImmutableSortedSet#of(Comparable, Comparable, Comparable)}.</b>
*/
- @DoNotCall("Pass parameters of type Comparable")
@Deprecated
public static <E> ImmutableSortedSet<E> of(E e1, E e2, E e3) {
throw new UnsupportedOperationException();
@@ -135,7 +127,6 @@
* @deprecated <b>Pass the parameters of type {@code Comparable} to use {@link
* ImmutableSortedSet#of(Comparable, Comparable, Comparable, Comparable)}. </b>
*/
- @DoNotCall("Pass parameters of type Comparable")
@Deprecated
public static <E> ImmutableSortedSet<E> of(E e1, E e2, E e3, E e4) {
throw new UnsupportedOperationException();
@@ -150,7 +141,6 @@
* @deprecated <b>Pass the parameters of type {@code Comparable} to use {@link
* ImmutableSortedSet#of( Comparable, Comparable, Comparable, Comparable, Comparable)}. </b>
*/
- @DoNotCall("Pass parameters of type Comparable")
@Deprecated
public static <E> ImmutableSortedSet<E> of(E e1, E e2, E e3, E e4, E e5) {
throw new UnsupportedOperationException();
@@ -166,7 +156,6 @@
* ImmutableSortedSet#of(Comparable, Comparable, Comparable, Comparable, Comparable,
* Comparable, Comparable...)}. </b>
*/
- @DoNotCall("Pass parameters of type Comparable")
@Deprecated
public static <E> ImmutableSortedSet<E> of(E e1, E e2, E e3, E e4, E e5, E e6, E... remaining) {
throw new UnsupportedOperationException();
@@ -181,7 +170,6 @@
* @deprecated <b>Pass parameters of type {@code Comparable} to use {@link
* ImmutableSortedSet#copyOf(Comparable[])}.</b>
*/
- @DoNotCall("Pass parameters of type Comparable")
@Deprecated
public static <E> ImmutableSortedSet<E> copyOf(E[] elements) {
throw new UnsupportedOperationException();
diff --git a/guava/src/com/google/common/collect/ImmutableTable.java b/guava/src/com/google/common/collect/ImmutableTable.java
index 6d15938..bdaddc3 100644
--- a/guava/src/com/google/common/collect/ImmutableTable.java
+++ b/guava/src/com/google/common/collect/ImmutableTable.java
@@ -20,10 +20,11 @@
import com.google.common.annotations.GwtCompatible;
import com.google.common.base.MoreObjects;
+import com.google.common.collect.Tables.AbstractCell;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
-import com.google.errorprone.annotations.DoNotCall;
import com.google.errorprone.annotations.DoNotMock;
import java.io.Serializable;
+import java.util.ArrayList;
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
@@ -31,8 +32,8 @@
import java.util.Spliterator;
import java.util.function.BinaryOperator;
import java.util.function.Function;
+import java.util.function.Supplier;
import java.util.stream.Collector;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -46,7 +47,6 @@
* @since 11.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
public abstract class ImmutableTable<R, C, V> extends AbstractTable<R, C, V>
implements Serializable {
@@ -60,12 +60,19 @@
*
* @since 21.0
*/
- public static <T extends @Nullable Object, R, C, V>
- Collector<T, ?, ImmutableTable<R, C, V>> toImmutableTable(
- Function<? super T, ? extends R> rowFunction,
- Function<? super T, ? extends C> columnFunction,
- Function<? super T, ? extends V> valueFunction) {
- return TableCollectors.toImmutableTable(rowFunction, columnFunction, valueFunction);
+ public static <T, R, C, V> Collector<T, ?, ImmutableTable<R, C, V>> toImmutableTable(
+ Function<? super T, ? extends R> rowFunction,
+ Function<? super T, ? extends C> columnFunction,
+ Function<? super T, ? extends V> valueFunction) {
+ checkNotNull(rowFunction, "rowFunction");
+ checkNotNull(columnFunction, "columnFunction");
+ checkNotNull(valueFunction, "valueFunction");
+ return Collector.of(
+ (Supplier<Builder<R, C, V>>) Builder::new,
+ (builder, t) ->
+ builder.put(rowFunction.apply(t), columnFunction.apply(t), valueFunction.apply(t)),
+ Builder::combine,
+ Builder::build);
}
/**
@@ -79,21 +86,96 @@
*
* @since 21.0
*/
- public static <T extends @Nullable Object, R, C, V>
- Collector<T, ?, ImmutableTable<R, C, V>> toImmutableTable(
- Function<? super T, ? extends R> rowFunction,
- Function<? super T, ? extends C> columnFunction,
- Function<? super T, ? extends V> valueFunction,
- BinaryOperator<V> mergeFunction) {
- return TableCollectors.toImmutableTable(
- rowFunction, columnFunction, valueFunction, mergeFunction);
+ public static <T, R, C, V> Collector<T, ?, ImmutableTable<R, C, V>> toImmutableTable(
+ Function<? super T, ? extends R> rowFunction,
+ Function<? super T, ? extends C> columnFunction,
+ Function<? super T, ? extends V> valueFunction,
+ BinaryOperator<V> mergeFunction) {
+
+ checkNotNull(rowFunction, "rowFunction");
+ checkNotNull(columnFunction, "columnFunction");
+ checkNotNull(valueFunction, "valueFunction");
+ checkNotNull(mergeFunction, "mergeFunction");
+
+ /*
+ * No mutable Table exactly matches the insertion order behavior of ImmutableTable.Builder, but
+ * the Builder can't efficiently support merging of duplicate values. Getting around this
+ * requires some work.
+ */
+
+ return Collector.of(
+ () -> new CollectorState<R, C, V>()
+ /* GWT isn't currently playing nicely with constructor references? */ ,
+ (state, input) ->
+ state.put(
+ rowFunction.apply(input),
+ columnFunction.apply(input),
+ valueFunction.apply(input),
+ mergeFunction),
+ (s1, s2) -> s1.combine(s2, mergeFunction),
+ state -> state.toTable());
}
- /**
- * Returns an empty immutable table.
- *
- * <p><b>Performance note:</b> the instance returned is a singleton.
- */
+ private static final class CollectorState<R, C, V> {
+ final List<MutableCell<R, C, V>> insertionOrder = new ArrayList<>();
+ final Table<R, C, MutableCell<R, C, V>> table = HashBasedTable.create();
+
+ void put(R row, C column, V value, BinaryOperator<V> merger) {
+ MutableCell<R, C, V> oldCell = table.get(row, column);
+ if (oldCell == null) {
+ MutableCell<R, C, V> cell = new MutableCell<>(row, column, value);
+ insertionOrder.add(cell);
+ table.put(row, column, cell);
+ } else {
+ oldCell.merge(value, merger);
+ }
+ }
+
+ CollectorState<R, C, V> combine(CollectorState<R, C, V> other, BinaryOperator<V> merger) {
+ for (MutableCell<R, C, V> cell : other.insertionOrder) {
+ put(cell.getRowKey(), cell.getColumnKey(), cell.getValue(), merger);
+ }
+ return this;
+ }
+
+ ImmutableTable<R, C, V> toTable() {
+ return copyOf(insertionOrder);
+ }
+ }
+
+ private static final class MutableCell<R, C, V> extends AbstractCell<R, C, V> {
+ private final R row;
+ private final C column;
+ private V value;
+
+ MutableCell(R row, C column, V value) {
+ this.row = checkNotNull(row, "row");
+ this.column = checkNotNull(column, "column");
+ this.value = checkNotNull(value, "value");
+ }
+
+ @Override
+ public R getRowKey() {
+ return row;
+ }
+
+ @Override
+ public C getColumnKey() {
+ return column;
+ }
+
+ @Override
+ public V getValue() {
+ return value;
+ }
+
+ void merge(V value, BinaryOperator<V> mergeFunction) {
+ checkNotNull(value, "value");
+ this.value = checkNotNull(mergeFunction.apply(this.value, value), "mergeFunction.apply");
+ }
+ }
+
+ /** Returns an empty immutable table. */
@SuppressWarnings("unchecked")
public static <R, C, V> ImmutableTable<R, C, V> of() {
return (ImmutableTable<R, C, V>) SparseImmutableTable.EMPTY;
@@ -128,7 +210,7 @@
}
}
- static <R, C, V> ImmutableTable<R, C, V> copyOf(
+ private static <R, C, V> ImmutableTable<R, C, V> copyOf(
Iterable<? extends Cell<? extends R, ? extends C, ? extends V>> cells) {
ImmutableTable.Builder<R, C, V> builder = ImmutableTable.builder();
for (Cell<? extends R, ? extends C, ? extends V> cell : cells) {
@@ -166,7 +248,7 @@
* .put(1, 'A', "foo")
* .put(1, 'B', "bar")
* .put(2, 'A', "baz")
- * .buildOrThrow();
+ * .build();
* }</pre>
*
* <p>By default, the order in which cells are added to the builder determines the iteration
@@ -177,16 +259,16 @@
* <p>For empty or single-cell immutable tables, {@link #of()} and {@link #of(Object, Object,
* Object)} are even more convenient.
*
- * <p>Builder instances can be reused - it is safe to call {@link #buildOrThrow} multiple times to
- * build multiple tables in series. Each table is a superset of the tables created before it.
+ * <p>Builder instances can be reused - it is safe to call {@link #build} multiple times to build
+ * multiple tables in series. Each table is a superset of the tables created before it.
*
* @since 11.0
*/
@DoNotMock
public static final class Builder<R, C, V> {
private final List<Cell<R, C, V>> cells = Lists.newArrayList();
- @CheckForNull private Comparator<? super R> rowComparator;
- @CheckForNull private Comparator<? super C> columnComparator;
+ private @Nullable Comparator<? super R> rowComparator;
+ private @Nullable Comparator<? super C> columnComparator;
/**
* Creates a new builder. The returned builder is equivalent to the builder generated by {@link
@@ -251,7 +333,6 @@
return this;
}
- @CanIgnoreReturnValue
Builder<R, C, V> combine(Builder<R, C, V> other) {
this.cells.addAll(other.cells);
return this;
@@ -260,24 +341,9 @@
/**
* Returns a newly-created immutable table.
*
- * <p>Prefer the equivalent method {@link #buildOrThrow()} to make it explicit that the method
- * will throw an exception if there are duplicate key pairs. The {@code build()} method will
- * soon be deprecated.
- *
* @throws IllegalArgumentException if duplicate key pairs were added
*/
public ImmutableTable<R, C, V> build() {
- return buildOrThrow();
- }
-
- /**
- * Returns a newly-created immutable table, or throws an exception if duplicate key pairs were
- * added.
- *
- * @throws IllegalArgumentException if duplicate key pairs were added
- * @since 31.0
- */
- public ImmutableTable<R, C, V> buildOrThrow() {
int size = cells.size();
switch (size) {
case 0:
@@ -376,12 +442,12 @@
public abstract ImmutableMap<R, Map<C, V>> rowMap();
@Override
- public boolean contains(@CheckForNull Object rowKey, @CheckForNull Object columnKey) {
+ public boolean contains(@Nullable Object rowKey, @Nullable Object columnKey) {
return get(rowKey, columnKey) != null;
}
@Override
- public boolean containsValue(@CheckForNull Object value) {
+ public boolean containsValue(@Nullable Object value) {
return values().contains(value);
}
@@ -393,7 +459,6 @@
*/
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
public final void clear() {
throw new UnsupportedOperationException();
}
@@ -407,8 +472,6 @@
@CanIgnoreReturnValue
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
- @CheckForNull
public final V put(R rowKey, C columnKey, V value) {
throw new UnsupportedOperationException();
}
@@ -421,7 +484,6 @@
*/
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
public final void putAll(Table<? extends R, ? extends C, ? extends V> table) {
throw new UnsupportedOperationException();
}
@@ -435,9 +497,7 @@
@CanIgnoreReturnValue
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
- @CheckForNull
- public final V remove(@CheckForNull Object rowKey, @CheckForNull Object columnKey) {
+ public final V remove(Object rowKey, Object columnKey) {
throw new UnsupportedOperationException();
}
diff --git a/guava/src/com/google/common/collect/IndexedImmutableSet.java b/guava/src/com/google/common/collect/IndexedImmutableSet.java
index 20dfacb..0168913 100644
--- a/guava/src/com/google/common/collect/IndexedImmutableSet.java
+++ b/guava/src/com/google/common/collect/IndexedImmutableSet.java
@@ -22,11 +22,9 @@
import com.google.common.annotations.GwtIncompatible;
import java.util.Spliterator;
import java.util.function.Consumer;
-import org.checkerframework.checker.nullness.qual.Nullable;
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
-abstract class IndexedImmutableSet<E> extends ImmutableSet.CachingAsList<E> {
+abstract class IndexedImmutableSet<E> extends ImmutableSet<E> {
abstract E get(int index);
@Override
@@ -50,7 +48,7 @@
@Override
@GwtIncompatible
- int copyIntoArray(@Nullable Object[] dst, int offset) {
+ int copyIntoArray(Object[] dst, int offset) {
return asList().copyIntoArray(dst, offset);
}
diff --git a/guava/src/com/google/common/collect/Interner.java b/guava/src/com/google/common/collect/Interner.java
index bfc2035..310bfca 100644
--- a/guava/src/com/google/common/collect/Interner.java
+++ b/guava/src/com/google/common/collect/Interner.java
@@ -16,6 +16,7 @@
package com.google.common.collect;
+import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtIncompatible;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import com.google.errorprone.annotations.DoNotMock;
@@ -31,9 +32,9 @@
* @author Kevin Bourrillion
* @since 3.0
*/
+@Beta
@DoNotMock("Use Interners.new*Interner")
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public interface Interner<E> {
/**
* Chooses and returns the representative instance for any of a collection of instances that are
diff --git a/guava/src/com/google/common/collect/Interners.java b/guava/src/com/google/common/collect/Interners.java
index a3ae374..061a1cf 100644
--- a/guava/src/com/google/common/collect/Interners.java
+++ b/guava/src/com/google/common/collect/Interners.java
@@ -16,13 +16,13 @@
import static com.google.common.base.Preconditions.checkNotNull;
+import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtIncompatible;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Equivalence;
import com.google.common.base.Function;
import com.google.common.collect.MapMaker.Dummy;
import com.google.common.collect.MapMakerInternalMap.InternalEntry;
-import javax.annotation.CheckForNull;
/**
* Contains static methods pertaining to instances of {@link Interner}.
@@ -30,8 +30,8 @@
* @author Kevin Bourrillion
* @since 3.0
*/
+@Beta
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public final class Interners {
private Interners() {}
@@ -124,15 +124,11 @@
public E intern(E sample) {
while (true) {
// trying to read the canonical...
- @SuppressWarnings("rawtypes") // using raw types to avoid a bug in our nullness checker :(
- InternalEntry entry = map.getEntry(sample);
+ InternalEntry<E, Dummy, ?> entry = map.getEntry(sample);
if (entry != null) {
- Object canonical = entry.getKey();
+ E canonical = entry.getKey();
if (canonical != null) { // only matters if weak/soft keys are used
- // The compiler would know this is safe if not for our use of raw types (see above).
- @SuppressWarnings("unchecked")
- E result = (E) canonical;
- return result;
+ return canonical;
}
}
@@ -180,7 +176,7 @@
}
@Override
- public boolean equals(@CheckForNull Object other) {
+ public boolean equals(Object other) {
if (other instanceof InternerFunction) {
InternerFunction<?> that = (InternerFunction<?>) other;
return interner.equals(that.interner);
diff --git a/guava/src/com/google/common/collect/Iterables.java b/guava/src/com/google/common/collect/Iterables.java
index fb2b543..4aa02e1 100644
--- a/guava/src/com/google/common/collect/Iterables.java
+++ b/guava/src/com/google/common/collect/Iterables.java
@@ -39,7 +39,6 @@
import java.util.Spliterator;
import java.util.function.Consumer;
import java.util.stream.Stream;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -65,13 +64,11 @@
* @since 2.0
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
public final class Iterables {
private Iterables() {}
/** Returns an unmodifiable view of {@code iterable}. */
- public static <T extends @Nullable Object> Iterable<T> unmodifiableIterable(
- final Iterable<? extends T> iterable) {
+ public static <T> Iterable<T> unmodifiableIterable(final Iterable<? extends T> iterable) {
checkNotNull(iterable);
if (iterable instanceof UnmodifiableIterable || iterable instanceof ImmutableCollection) {
@SuppressWarnings("unchecked") // Since it's unmodifiable, the covariant cast is safe
@@ -92,8 +89,7 @@
return checkNotNull(iterable);
}
- private static final class UnmodifiableIterable<T extends @Nullable Object>
- extends FluentIterable<T> {
+ private static final class UnmodifiableIterable<T> extends FluentIterable<T> {
private final Iterable<? extends T> iterable;
private UnmodifiableIterable(Iterable<? extends T> iterable) {
@@ -136,9 +132,7 @@
* cases where {@link Collection#contains} might throw {@link NullPointerException} or {@link
* ClassCastException}.
*/
- // <? extends @Nullable Object> instead of <?> because of Kotlin b/189937072, discussed in Joiner.
- public static boolean contains(
- Iterable<? extends @Nullable Object> iterable, @CheckForNull Object element) {
+ public static boolean contains(Iterable<?> iterable, @Nullable Object element) {
if (iterable instanceof Collection) {
Collection<?> collection = (Collection<?>) iterable;
return Collections2.safeContains(collection, element);
@@ -197,8 +191,7 @@
* @since 2.0
*/
@CanIgnoreReturnValue
- public static <T extends @Nullable Object> boolean removeIf(
- Iterable<T> removeFrom, Predicate<? super T> predicate) {
+ public static <T> boolean removeIf(Iterable<T> removeFrom, Predicate<? super T> predicate) {
if (removeFrom instanceof Collection) {
return ((Collection<T>) removeFrom).removeIf(predicate);
}
@@ -206,8 +199,7 @@
}
/** Removes and returns the first matching element, or returns {@code null} if there is none. */
- @CheckForNull
- static <T extends @Nullable Object> T removeFirstMatching(
+ static <T> @Nullable T removeFirstMatching(
Iterable<T> removeFrom, Predicate<? super T> predicate) {
checkNotNull(predicate);
Iterator<T> iterator = removeFrom.iterator();
@@ -258,8 +250,7 @@
* @throws NoSuchElementException if the iterable is empty
* @throws IllegalArgumentException if the iterable contains multiple elements
*/
- @ParametricNullness
- public static <T extends @Nullable Object> T getOnlyElement(Iterable<T> iterable) {
+ public static <T> T getOnlyElement(Iterable<T> iterable) {
return Iterators.getOnlyElement(iterable.iterator());
}
@@ -272,9 +263,8 @@
*
* @throws IllegalArgumentException if the iterator contains multiple elements
*/
- @ParametricNullness
- public static <T extends @Nullable Object> T getOnlyElement(
- Iterable<? extends T> iterable, @ParametricNullness T defaultValue) {
+ public static <T> @Nullable T getOnlyElement(
+ Iterable<? extends T> iterable, @Nullable T defaultValue) {
return Iterators.getOnlyElement(iterable.iterator(), defaultValue);
}
@@ -286,16 +276,11 @@
* @return a newly-allocated array into which all the elements of the iterable have been copied
*/
@GwtIncompatible // Array.newInstance(Class, int)
- /*
- * If we could express Class<@Nonnull T>, we could generalize the type parameter to <T extends
- * @Nullable Object>, and then we could accept an Iterable<? extends T> and return a plain T[]
- * instead of a @Nullable T[].
- */
- public static <T> @Nullable T[] toArray(Iterable<? extends @Nullable T> iterable, Class<T> type) {
+ public static <T> T[] toArray(Iterable<? extends T> iterable, Class<T> type) {
return toArray(iterable, ObjectArrays.newArray(type, 0));
}
- static <T extends @Nullable Object> T[] toArray(Iterable<? extends T> iterable, T[] array) {
+ static <T> T[] toArray(Iterable<? extends T> iterable, T[] array) {
Collection<? extends T> collection = castOrCopyToCollection(iterable);
return collection.toArray(array);
}
@@ -306,7 +291,7 @@
* @param iterable the iterable to copy
* @return a newly-allocated array into which all the elements of the iterable have been copied
*/
- static @Nullable Object[] toArray(Iterable<?> iterable) {
+ static Object[] toArray(Iterable<?> iterable) {
return castOrCopyToCollection(iterable).toArray();
}
@@ -315,8 +300,7 @@
* returned. Otherwise, an {@link java.util.ArrayList} is created with the contents of the
* iterable in the same iteration order.
*/
- private static <E extends @Nullable Object> Collection<E> castOrCopyToCollection(
- Iterable<E> iterable) {
+ private static <E> Collection<E> castOrCopyToCollection(Iterable<E> iterable) {
return (iterable instanceof Collection)
? (Collection<E>) iterable
: Lists.newArrayList(iterable.iterator());
@@ -328,8 +312,7 @@
* @return {@code true} if {@code collection} was modified as a result of this operation.
*/
@CanIgnoreReturnValue
- public static <T extends @Nullable Object> boolean addAll(
- Collection<T> addTo, Iterable<? extends T> elementsToAdd) {
+ public static <T> boolean addAll(Collection<T> addTo, Iterable<? extends T> elementsToAdd) {
if (elementsToAdd instanceof Collection) {
Collection<? extends T> c = (Collection<? extends T>) elementsToAdd;
return addTo.addAll(c);
@@ -348,7 +331,7 @@
* @see java.util.Collections#frequency(Collection, Object) Collections.frequency(Collection,
* Object)
*/
- public static int frequency(Iterable<?> iterable, @CheckForNull 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)) {
@@ -375,7 +358,7 @@
* <p><b>Java 8 users:</b> The {@code Stream} equivalent of this method is {@code
* Stream.generate(() -> iterable).flatMap(Streams::stream)}.
*/
- public static <T extends @Nullable Object> Iterable<T> cycle(final Iterable<T> iterable) {
+ public static <T> Iterable<T> cycle(final Iterable<T> iterable) {
checkNotNull(iterable);
return new FluentIterable<T>() {
@Override
@@ -385,7 +368,7 @@
@Override
public Spliterator<T> spliterator() {
- return Stream.generate(() -> iterable).<T>flatMap(Streams::stream).spliterator();
+ return Stream.generate(() -> iterable).flatMap(Streams::stream).spliterator();
}
@Override
@@ -416,7 +399,7 @@
* and use {@code Stream.generate(() -> collection).flatMap(Collection::stream)}.
*/
@SafeVarargs
- public static <T extends @Nullable Object> Iterable<T> cycle(T... elements) {
+ public static <T> Iterable<T> cycle(T... elements) {
return cycle(Lists.newArrayList(elements));
}
@@ -431,8 +414,7 @@
* <p><b>Java 8 users:</b> The {@code Stream} equivalent of this method is {@code Stream.concat(a,
* b)}.
*/
- public static <T extends @Nullable Object> Iterable<T> concat(
- Iterable<? extends T> a, Iterable<? extends T> b) {
+ public static <T> Iterable<T> concat(Iterable<? extends T> a, Iterable<? extends T> b) {
return FluentIterable.concat(a, b);
}
@@ -447,7 +429,7 @@
* <p><b>Java 8 users:</b> The {@code Stream} equivalent of this method is {@code
* Streams.concat(a, b, c)}.
*/
- public static <T extends @Nullable Object> Iterable<T> concat(
+ public static <T> Iterable<T> concat(
Iterable<? extends T> a, Iterable<? extends T> b, Iterable<? extends T> c) {
return FluentIterable.concat(a, b, c);
}
@@ -464,7 +446,7 @@
* <p><b>Java 8 users:</b> The {@code Stream} equivalent of this method is {@code
* Streams.concat(a, b, c, d)}.
*/
- public static <T extends @Nullable Object> Iterable<T> concat(
+ public static <T> Iterable<T> concat(
Iterable<? extends T> a,
Iterable<? extends T> b,
Iterable<? extends T> c,
@@ -486,7 +468,7 @@
* @throws NullPointerException if any of the provided iterables is null
*/
@SafeVarargs
- public static <T extends @Nullable Object> Iterable<T> concat(Iterable<? extends T>... inputs) {
+ public static <T> Iterable<T> concat(Iterable<? extends T>... inputs) {
return FluentIterable.concat(inputs);
}
@@ -502,8 +484,7 @@
* <p><b>Java 8 users:</b> The {@code Stream} equivalent of this method is {@code
* streamOfStreams.flatMap(s -> s)}.
*/
- public static <T extends @Nullable Object> Iterable<T> concat(
- Iterable<? extends Iterable<? extends T>> inputs) {
+ public static <T> Iterable<T> concat(Iterable<? extends Iterable<? extends T>> inputs) {
return FluentIterable.concat(inputs);
}
@@ -525,8 +506,7 @@
* into partitions
* @throws IllegalArgumentException if {@code size} is nonpositive
*/
- public static <T extends @Nullable Object> Iterable<List<T>> partition(
- final Iterable<T> iterable, final int size) {
+ public static <T> Iterable<List<T>> partition(final Iterable<T> iterable, final int size) {
checkNotNull(iterable);
checkArgument(size > 0);
return new FluentIterable<List<T>>() {
@@ -552,13 +532,12 @@
* into partitions (the final iterable may have trailing null elements)
* @throws IllegalArgumentException if {@code size} is nonpositive
*/
- public static <T extends @Nullable Object> Iterable<List<@Nullable T>> paddedPartition(
- final Iterable<T> iterable, final int size) {
+ public static <T> Iterable<List<T>> paddedPartition(final Iterable<T> iterable, final int size) {
checkNotNull(iterable);
checkArgument(size > 0);
- return new FluentIterable<List<@Nullable T>>() {
+ return new FluentIterable<List<T>>() {
@Override
- public Iterator<List<@Nullable T>> iterator() {
+ public Iterator<List<T>> iterator() {
return Iterators.paddedPartition(iterable.iterator(), size);
}
};
@@ -570,7 +549,7 @@
*
* <p><b>{@code Stream} equivalent:</b> {@link Stream#filter}.
*/
- public static <T extends @Nullable Object> Iterable<T> filter(
+ public static <T> Iterable<T> filter(
final Iterable<T> unfiltered, final Predicate<? super T> retainIfTrue) {
checkNotNull(unfiltered);
checkNotNull(retainIfTrue);
@@ -584,7 +563,7 @@
public void forEach(Consumer<? super T> action) {
checkNotNull(action);
unfiltered.forEach(
- (@ParametricNullness T a) -> {
+ (T a) -> {
if (retainIfTrue.test(a)) {
action.accept(a);
}
@@ -625,8 +604,7 @@
*
* <p><b>{@code Stream} equivalent:</b> {@link Stream#anyMatch}.
*/
- public static <T extends @Nullable Object> boolean any(
- Iterable<T> iterable, Predicate<? super T> predicate) {
+ public static <T> boolean any(Iterable<T> iterable, Predicate<? super T> predicate) {
return Iterators.any(iterable.iterator(), predicate);
}
@@ -636,8 +614,7 @@
*
* <p><b>{@code Stream} equivalent:</b> {@link Stream#allMatch}.
*/
- public static <T extends @Nullable Object> boolean all(
- Iterable<T> iterable, Predicate<? super T> predicate) {
+ public static <T> boolean all(Iterable<T> iterable, Predicate<? super T> predicate) {
return Iterators.all(iterable.iterator(), predicate);
}
@@ -650,9 +627,7 @@
*
* @throws NoSuchElementException if no element in {@code iterable} matches the given predicate
*/
- @ParametricNullness
- public static <T extends @Nullable Object> T find(
- Iterable<T> iterable, Predicate<? super T> predicate) {
+ public static <T> T find(Iterable<T> iterable, Predicate<? super T> predicate) {
return Iterators.find(iterable.iterator(), predicate);
}
@@ -666,26 +641,8 @@
*
* @since 7.0
*/
- // The signature we really want here is...
- //
- // <T extends @Nullable Object> @JointlyNullable T find(
- // Iterable<? extends T> iterable,
- // Predicate<? super T> predicate,
- // @JointlyNullable T defaultValue);
- //
- // ...where "@JointlyNullable" is similar to @PolyNull but slightly different:
- //
- // - @PolyNull means "@Nullable or @Nonnull"
- // (That would be unsound for an input Iterable<@Nullable Foo>. So, if we wanted to use
- // @PolyNull, we would have to restrict this method to non-null <T>. But it has users who pass
- // iterables with null elements.)
- //
- // - @JointlyNullable means "@Nullable or no annotation"
- @CheckForNull
- public static <T extends @Nullable Object> T find(
- Iterable<? extends T> iterable,
- Predicate<? super T> predicate,
- @CheckForNull T defaultValue) {
+ public static <T> @Nullable T find(
+ Iterable<? extends T> iterable, Predicate<? super T> predicate, @Nullable T defaultValue) {
return Iterators.find(iterable.iterator(), predicate, defaultValue);
}
@@ -714,8 +671,7 @@
*
* @since 2.0
*/
- public static <T extends @Nullable Object> int indexOf(
- Iterable<T> iterable, Predicate<? super T> predicate) {
+ public static <T> int indexOf(Iterable<T> iterable, Predicate<? super T> predicate) {
return Iterators.indexOf(iterable.iterator(), predicate);
}
@@ -732,7 +688,7 @@
*
* <p><b>{@code Stream} equivalent:</b> {@link Stream#map}
*/
- public static <F extends @Nullable Object, T extends @Nullable Object> Iterable<T> transform(
+ public static <F, T> Iterable<T> transform(
final Iterable<F> fromIterable, final Function<? super F, ? extends T> function) {
checkNotNull(fromIterable);
checkNotNull(function);
@@ -766,8 +722,7 @@
* @throws IndexOutOfBoundsException if {@code position} is negative or greater than or equal to
* the size of {@code iterable}
*/
- @ParametricNullness
- public static <T extends @Nullable Object> T get(Iterable<T> iterable, int position) {
+ public static <T> T get(Iterable<T> iterable, int position) {
checkNotNull(iterable);
return (iterable instanceof List)
? ((List<T>) iterable).get(position)
@@ -789,9 +744,8 @@
* @throws IndexOutOfBoundsException if {@code position} is negative
* @since 4.0
*/
- @ParametricNullness
- public static <T extends @Nullable Object> T get(
- Iterable<? extends T> iterable, int position, @ParametricNullness T defaultValue) {
+ public static <T> @Nullable T get(
+ Iterable<? extends T> iterable, int position, @Nullable T defaultValue) {
checkNotNull(iterable);
Iterators.checkNonnegative(position);
if (iterable instanceof List) {
@@ -821,9 +775,7 @@
* @return the first element of {@code iterable} or the default value
* @since 7.0
*/
- @ParametricNullness
- public static <T extends @Nullable Object> T getFirst(
- Iterable<? extends T> iterable, @ParametricNullness T defaultValue) {
+ public static <T> @Nullable T getFirst(Iterable<? extends T> iterable, @Nullable T defaultValue) {
return Iterators.getNext(iterable.iterator(), defaultValue);
}
@@ -836,8 +788,7 @@
* @return the last element of {@code iterable}
* @throws NoSuchElementException if the iterable is empty
*/
- @ParametricNullness
- public static <T extends @Nullable Object> T getLast(Iterable<T> iterable) {
+ public static <T> T getLast(Iterable<T> iterable) {
// TODO(kevinb): Support a concurrently modified collection?
if (iterable instanceof List) {
List<T> list = (List<T>) iterable;
@@ -861,9 +812,7 @@
* @return the last element of {@code iterable} or the default value
* @since 3.0
*/
- @ParametricNullness
- public static <T extends @Nullable Object> T getLast(
- Iterable<? extends T> iterable, @ParametricNullness T defaultValue) {
+ public static <T> @Nullable T getLast(Iterable<? extends T> iterable, @Nullable T defaultValue) {
if (iterable instanceof Collection) {
Collection<? extends T> c = (Collection<? extends T>) iterable;
if (c.isEmpty()) {
@@ -876,8 +825,7 @@
return Iterators.getLast(iterable.iterator(), defaultValue);
}
- @ParametricNullness
- private static <T extends @Nullable Object> T getLastInNonemptyList(List<T> list) {
+ private static <T> T getLastInNonemptyList(List<T> list) {
return list.get(list.size() - 1);
}
@@ -900,8 +848,7 @@
*
* @since 3.0
*/
- public static <T extends @Nullable Object> Iterable<T> skip(
- final Iterable<T> iterable, final int numberToSkip) {
+ public static <T> Iterable<T> skip(final Iterable<T> iterable, final int numberToSkip) {
checkNotNull(iterable);
checkArgument(numberToSkip >= 0, "number to skip cannot be negative");
@@ -931,7 +878,6 @@
}
@Override
- @ParametricNullness
public T next() {
T result = iterator.next();
atStart = false; // not called if next() fails
@@ -972,8 +918,7 @@
* @throws IllegalArgumentException if {@code limitSize} is negative
* @since 3.0
*/
- public static <T extends @Nullable Object> Iterable<T> limit(
- final Iterable<T> iterable, final int limitSize) {
+ public static <T> Iterable<T> limit(final Iterable<T> iterable, final int limitSize) {
checkNotNull(iterable);
checkArgument(limitSize >= 0, "limit is negative");
return new FluentIterable<T>() {
@@ -1005,8 +950,7 @@
* @see Iterators#consumingIterator(Iterator)
* @since 2.0
*/
- public static <T extends @Nullable Object> Iterable<T> consumingIterable(
- final Iterable<T> iterable) {
+ public static <T> Iterable<T> consumingIterable(final Iterable<T> iterable) {
checkNotNull(iterable);
return new FluentIterable<T>() {
@@ -1057,7 +1001,7 @@
* @since 11.0
*/
@Beta
- public static <T extends @Nullable Object> Iterable<T> mergeSorted(
+ public static <T> Iterable<T> mergeSorted(
final Iterable<? extends Iterable<? extends T>> iterables,
final Comparator<? super T> comparator) {
checkNotNull(iterables, "iterables");
@@ -1075,8 +1019,7 @@
// TODO(user): Is this the best place for this? Move to fluent functions?
// Useful as a public method?
- static <T extends @Nullable Object>
- Function<Iterable<? extends T>, Iterator<? extends T>> toIterator() {
+ static <T> Function<Iterable<? extends T>, Iterator<? extends T>> toIterator() {
return new Function<Iterable<? extends T>, Iterator<? extends T>>() {
@Override
public Iterator<? extends T> apply(Iterable<? extends T> iterable) {
diff --git a/guava/src/com/google/common/collect/Iterators.java b/guava/src/com/google/common/collect/Iterators.java
index 5ea2da9..f655c27 100644
--- a/guava/src/com/google/common/collect/Iterators.java
+++ b/guava/src/com/google/common/collect/Iterators.java
@@ -21,8 +21,6 @@
import static com.google.common.base.Preconditions.checkState;
import static com.google.common.base.Predicates.instanceOf;
import static com.google.common.collect.CollectPreconditions.checkRemove;
-import static com.google.common.collect.NullnessCasts.uncheckedCastNullableTToT;
-import static java.util.Objects.requireNonNull;
import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtCompatible;
@@ -47,7 +45,6 @@
import java.util.NoSuchElementException;
import java.util.PriorityQueue;
import java.util.Queue;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -68,7 +65,6 @@
* @since 2.0
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
public final class Iterators {
private Iterators() {}
@@ -77,7 +73,7 @@
*
* <p>The {@link Iterable} equivalent of this method is {@link ImmutableSet#of()}.
*/
- static <T extends @Nullable Object> UnmodifiableIterator<T> emptyIterator() {
+ static <T> UnmodifiableIterator<T> emptyIterator() {
return emptyListIterator();
}
@@ -88,7 +84,7 @@
*/
// Casting to any type is safe since there are no actual elements.
@SuppressWarnings("unchecked")
- static <T extends @Nullable Object> UnmodifiableListIterator<T> emptyListIterator() {
+ static <T> UnmodifiableListIterator<T> emptyListIterator() {
return (UnmodifiableListIterator<T>) ArrayItr.EMPTY;
}
@@ -121,12 +117,12 @@
*/
// Casting to any type is safe since there are no actual elements.
@SuppressWarnings("unchecked")
- static <T extends @Nullable Object> Iterator<T> emptyModifiableIterator() {
+ static <T> Iterator<T> emptyModifiableIterator() {
return (Iterator<T>) EmptyModifiableIterator.INSTANCE;
}
/** Returns an unmodifiable view of {@code iterator}. */
- public static <T extends @Nullable Object> UnmodifiableIterator<T> unmodifiableIterator(
+ public static <T> UnmodifiableIterator<T> unmodifiableIterator(
final Iterator<? extends T> iterator) {
checkNotNull(iterator);
if (iterator instanceof UnmodifiableIterator) {
@@ -141,7 +137,6 @@
}
@Override
- @ParametricNullness
public T next() {
return iterator.next();
}
@@ -155,8 +150,7 @@
* @since 10.0
*/
@Deprecated
- public static <T extends @Nullable Object> UnmodifiableIterator<T> unmodifiableIterator(
- UnmodifiableIterator<T> iterator) {
+ public static <T> UnmodifiableIterator<T> unmodifiableIterator(UnmodifiableIterator<T> iterator) {
return checkNotNull(iterator);
}
@@ -174,7 +168,7 @@
}
/** Returns {@code true} if {@code iterator} contains {@code element}. */
- public static boolean contains(Iterator<?> iterator, @CheckForNull Object element) {
+ public static boolean contains(Iterator<?> iterator, @Nullable Object element) {
if (element == null) {
while (iterator.hasNext()) {
if (iterator.next() == null) {
@@ -222,8 +216,7 @@
* @since 2.0
*/
@CanIgnoreReturnValue
- public static <T extends @Nullable Object> boolean removeIf(
- Iterator<T> removeFrom, Predicate<? super T> predicate) {
+ public static <T> boolean removeIf(Iterator<T> removeFrom, Predicate<? super T> predicate) {
checkNotNull(predicate);
boolean modified = false;
while (removeFrom.hasNext()) {
@@ -304,8 +297,7 @@
* @throws IllegalArgumentException if the iterator contains multiple elements. The state of the
* iterator is unspecified.
*/
- @ParametricNullness
- public static <T extends @Nullable Object> T getOnlyElement(Iterator<T> iterator) {
+ public static <T> T getOnlyElement(Iterator<T> iterator) {
T first = iterator.next();
if (!iterator.hasNext()) {
return first;
@@ -330,9 +322,8 @@
* @throws IllegalArgumentException if the iterator contains multiple elements. The state of the
* iterator is unspecified.
*/
- @ParametricNullness
- public static <T extends @Nullable Object> T getOnlyElement(
- Iterator<? extends T> iterator, @ParametricNullness T defaultValue) {
+ public static <T> @Nullable T getOnlyElement(
+ Iterator<? extends T> iterator, @Nullable T defaultValue) {
return iterator.hasNext() ? getOnlyElement(iterator) : defaultValue;
}
@@ -345,9 +336,8 @@
* @return a newly-allocated array into which all the elements of the iterator have been copied
*/
@GwtIncompatible // Array.newInstance(Class, int)
- // For discussion of this signature, see the corresponding overload of *Iterables*.toArray.
- public static <T> @Nullable T[] toArray(Iterator<? extends @Nullable T> iterator, Class<T> type) {
- List<@Nullable T> list = Lists.newArrayList(iterator);
+ public static <T> T[] toArray(Iterator<? extends T> iterator, Class<T> type) {
+ List<T> list = Lists.newArrayList(iterator);
return Iterables.toArray(list, type);
}
@@ -358,8 +348,7 @@
* @return {@code true} if {@code collection} was modified as a result of this operation
*/
@CanIgnoreReturnValue
- public static <T extends @Nullable Object> boolean addAll(
- Collection<T> addTo, Iterator<? extends T> iterator) {
+ public static <T> boolean addAll(Collection<T> addTo, Iterator<? extends T> iterator) {
checkNotNull(addTo);
checkNotNull(iterator);
boolean wasModified = false;
@@ -375,7 +364,7 @@
*
* @see Collections#frequency
*/
- public static int frequency(Iterator<?> iterator, @CheckForNull 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,
@@ -397,7 +386,7 @@
* should use an explicit {@code break} or be certain that you will eventually remove all the
* elements.
*/
- public static <T extends @Nullable Object> Iterator<T> cycle(final Iterable<T> iterable) {
+ public static <T> Iterator<T> cycle(final Iterable<T> iterable) {
checkNotNull(iterable);
return new Iterator<T>() {
Iterator<T> iterator = emptyModifiableIterator();
@@ -417,7 +406,6 @@
}
@Override
- @ParametricNullness
public T next() {
if (!iterator.hasNext()) {
iterator = iterable.iterator();
@@ -448,7 +436,7 @@
* elements.
*/
@SafeVarargs
- public static <T extends @Nullable Object> Iterator<T> cycle(T... elements) {
+ public static <T> Iterator<T> cycle(T... elements) {
return cycle(Lists.newArrayList(elements));
}
@@ -456,15 +444,10 @@
* Returns an Iterator that walks the specified array, nulling out elements behind it. This can
* avoid memory leaks when an element is no longer necessary.
*
- * <p>This method accepts an array with element type {@code @Nullable T}, but callers must pass an
- * array whose contents are initially non-null. The {@code @Nullable} annotation indicates that
- * this method will write nulls into the array during iteration.
- *
* <p>This is mainly just to avoid the intermediate ArrayDeque in ConsumingQueueIterator.
*/
- private static <I extends Iterator<?>> Iterator<I> consumingForArray(
- final @Nullable I... elements) {
- return new UnmodifiableIterator<I>() {
+ private static <T> Iterator<T> consumingForArray(final T... elements) {
+ return new UnmodifiableIterator<T>() {
int index = 0;
@Override
@@ -473,15 +456,11 @@
}
@Override
- public I next() {
+ public T next() {
if (!hasNext()) {
throw new NoSuchElementException();
}
- /*
- * requireNonNull is safe because our callers always pass non-null arguments. Each element
- * of the array becomes null only when we iterate past it and then clear it.
- */
- I result = requireNonNull(elements[index]);
+ T result = elements[index];
elements[index] = null;
index++;
return result;
@@ -497,8 +476,7 @@
* <p>The returned iterator supports {@code remove()} when the corresponding input iterator
* supports it.
*/
- public static <T extends @Nullable Object> Iterator<T> concat(
- Iterator<? extends T> a, Iterator<? extends T> b) {
+ public static <T> Iterator<T> concat(Iterator<? extends T> a, Iterator<? extends T> b) {
checkNotNull(a);
checkNotNull(b);
return concat(consumingForArray(a, b));
@@ -512,7 +490,7 @@
* <p>The returned iterator supports {@code remove()} when the corresponding input iterator
* supports it.
*/
- public static <T extends @Nullable Object> Iterator<T> concat(
+ public static <T> Iterator<T> concat(
Iterator<? extends T> a, Iterator<? extends T> b, Iterator<? extends T> c) {
checkNotNull(a);
checkNotNull(b);
@@ -529,7 +507,7 @@
* <p>The returned iterator supports {@code remove()} when the corresponding input iterator
* supports it.
*/
- public static <T extends @Nullable Object> Iterator<T> concat(
+ public static <T> Iterator<T> concat(
Iterator<? extends T> a,
Iterator<? extends T> b,
Iterator<? extends T> c,
@@ -551,7 +529,7 @@
*
* @throws NullPointerException if any of the provided iterators is null
*/
- public static <T extends @Nullable Object> Iterator<T> concat(Iterator<? extends T>... inputs) {
+ public static <T> Iterator<T> concat(Iterator<? extends T>... inputs) {
return concatNoDefensiveCopy(Arrays.copyOf(inputs, inputs.length));
}
@@ -564,14 +542,12 @@
* supports it. The methods of the returned iterator may throw {@code NullPointerException} if any
* of the input iterators is null.
*/
- public static <T extends @Nullable Object> Iterator<T> concat(
- Iterator<? extends Iterator<? extends T>> inputs) {
+ public static <T> Iterator<T> concat(Iterator<? extends Iterator<? extends T>> inputs) {
return new ConcatenatedIterator<T>(inputs);
}
/** Concats a varargs array of iterators without making a defensive copy of the array. */
- static <T extends @Nullable Object> Iterator<T> concatNoDefensiveCopy(
- Iterator<? extends T>... inputs) {
+ static <T> Iterator<T> concatNoDefensiveCopy(Iterator<? extends T>... inputs) {
for (Iterator<? extends T> input : checkNotNull(inputs)) {
checkNotNull(input);
}
@@ -592,8 +568,7 @@
* partitions
* @throws IllegalArgumentException if {@code size} is nonpositive
*/
- public static <T extends @Nullable Object> UnmodifiableIterator<List<T>> partition(
- Iterator<T> iterator, int size) {
+ public static <T> UnmodifiableIterator<List<T>> partition(Iterator<T> iterator, int size) {
return partitionImpl(iterator, size, false);
}
@@ -611,29 +586,26 @@
* partitions (the final iterable may have trailing null elements)
* @throws IllegalArgumentException if {@code size} is nonpositive
*/
- public static <T extends @Nullable Object>
- UnmodifiableIterator<List<@Nullable T>> paddedPartition(Iterator<T> iterator, int size) {
+ public static <T> UnmodifiableIterator<List<T>> paddedPartition(Iterator<T> iterator, int size) {
return partitionImpl(iterator, size, true);
}
- private static <T extends @Nullable Object> UnmodifiableIterator<List<@Nullable T>> partitionImpl(
+ private static <T> UnmodifiableIterator<List<T>> partitionImpl(
final Iterator<T> iterator, final int size, final boolean pad) {
checkNotNull(iterator);
checkArgument(size > 0);
- return new UnmodifiableIterator<List<@Nullable T>>() {
+ return new UnmodifiableIterator<List<T>>() {
@Override
public boolean hasNext() {
return iterator.hasNext();
}
@Override
- public List<@Nullable T> next() {
+ public List<T> next() {
if (!hasNext()) {
throw new NoSuchElementException();
}
- @SuppressWarnings("unchecked") // we only put Ts in it
- @Nullable
- T[] array = (@Nullable T[]) new Object[size];
+ Object[] array = new Object[size];
int count = 0;
for (; count < size && iterator.hasNext(); count++) {
array[count] = iterator.next();
@@ -642,13 +614,9 @@
array[i] = null; // for GWT
}
- List<@Nullable T> list = Collections.unmodifiableList(Arrays.asList(array));
- // TODO(b/192579700): Use a ternary once it no longer confuses our nullness checker.
- if (pad || count == size) {
- return list;
- } else {
- return list.subList(0, count);
- }
+ @SuppressWarnings("unchecked") // we only put Ts in it
+ List<T> list = Collections.unmodifiableList((List<T>) Arrays.asList(array));
+ return (pad || count == size) ? list : list.subList(0, count);
}
};
}
@@ -657,13 +625,12 @@
* Returns a view of {@code unfiltered} containing all elements that satisfy the input predicate
* {@code retainIfTrue}.
*/
- public static <T extends @Nullable Object> UnmodifiableIterator<T> filter(
+ public static <T> UnmodifiableIterator<T> filter(
final Iterator<T> unfiltered, final Predicate<? super T> retainIfTrue) {
checkNotNull(unfiltered);
checkNotNull(retainIfTrue);
return new AbstractIterator<T>() {
@Override
- @CheckForNull
protected T computeNext() {
while (unfiltered.hasNext()) {
T element = unfiltered.next();
@@ -690,8 +657,7 @@
* Returns {@code true} if one or more elements returned by {@code iterator} satisfy the given
* predicate.
*/
- public static <T extends @Nullable Object> boolean any(
- Iterator<T> iterator, Predicate<? super T> predicate) {
+ public static <T> boolean any(Iterator<T> iterator, Predicate<? super T> predicate) {
return indexOf(iterator, predicate) != -1;
}
@@ -699,8 +665,7 @@
* Returns {@code true} if every element returned by {@code iterator} satisfies the given
* predicate. If {@code iterator} is empty, {@code true} is returned.
*/
- public static <T extends @Nullable Object> boolean all(
- Iterator<T> iterator, Predicate<? super T> predicate) {
+ public static <T> boolean all(Iterator<T> iterator, Predicate<? super T> predicate) {
checkNotNull(predicate);
while (iterator.hasNext()) {
T element = iterator.next();
@@ -720,9 +685,7 @@
*
* @throws NoSuchElementException if no element in {@code iterator} matches the given predicate
*/
- @ParametricNullness
- public static <T extends @Nullable Object> T find(
- Iterator<T> iterator, Predicate<? super T> predicate) {
+ public static <T> T find(Iterator<T> iterator, Predicate<? super T> predicate) {
checkNotNull(iterator);
checkNotNull(predicate);
while (iterator.hasNext()) {
@@ -742,12 +705,8 @@
*
* @since 7.0
*/
- // For discussion of this signature, see the corresponding overload of *Iterables*.find.
- @CheckForNull
- public static <T extends @Nullable Object> T find(
- Iterator<? extends T> iterator,
- Predicate<? super T> predicate,
- @CheckForNull T defaultValue) {
+ public static <T> @Nullable T find(
+ Iterator<? extends T> iterator, Predicate<? super T> predicate, @Nullable T defaultValue) {
checkNotNull(iterator);
checkNotNull(predicate);
while (iterator.hasNext()) {
@@ -796,8 +755,7 @@
*
* @since 2.0
*/
- public static <T extends @Nullable Object> int indexOf(
- Iterator<T> iterator, Predicate<? super T> predicate) {
+ public static <T> int indexOf(Iterator<T> iterator, Predicate<? super T> predicate) {
checkNotNull(predicate, "predicate");
for (int i = 0; iterator.hasNext(); i++) {
T current = iterator.next();
@@ -816,13 +774,12 @@
* successful {@code remove()} call, {@code fromIterator} no longer contains the corresponding
* element.
*/
- public static <F extends @Nullable Object, T extends @Nullable Object> Iterator<T> transform(
+ public static <F, T> Iterator<T> transform(
final Iterator<F> fromIterator, final Function<? super F, ? extends T> function) {
checkNotNull(function);
return new TransformedIterator<F, T>(fromIterator) {
- @ParametricNullness
@Override
- T transform(@ParametricNullness F from) {
+ T transform(F from) {
return function.apply(from);
}
};
@@ -837,8 +794,7 @@
* @throws IndexOutOfBoundsException if {@code position} is negative or greater than or equal to
* the number of elements remaining in {@code iterator}
*/
- @ParametricNullness
- public static <T extends @Nullable Object> T get(Iterator<T> iterator, int position) {
+ public static <T> T get(Iterator<T> iterator, int position) {
checkNonnegative(position);
int skipped = advance(iterator, position);
if (!iterator.hasNext()) {
@@ -864,9 +820,8 @@
* @throws IndexOutOfBoundsException if {@code position} is negative
* @since 4.0
*/
- @ParametricNullness
- public static <T extends @Nullable Object> T get(
- Iterator<? extends T> iterator, int position, @ParametricNullness T defaultValue) {
+ public static <T> @Nullable T get(
+ Iterator<? extends T> iterator, int position, @Nullable T defaultValue) {
checkNonnegative(position);
advance(iterator, position);
return getNext(iterator, defaultValue);
@@ -886,9 +841,7 @@
* @return the next element of {@code iterator} or the default value
* @since 7.0
*/
- @ParametricNullness
- public static <T extends @Nullable Object> T getNext(
- Iterator<? extends T> iterator, @ParametricNullness T defaultValue) {
+ public static <T> @Nullable T getNext(Iterator<? extends T> iterator, @Nullable T defaultValue) {
return iterator.hasNext() ? iterator.next() : defaultValue;
}
@@ -898,8 +851,7 @@
* @return the last element of {@code iterator}
* @throws NoSuchElementException if the iterator is empty
*/
- @ParametricNullness
- public static <T extends @Nullable Object> T getLast(Iterator<T> iterator) {
+ public static <T> T getLast(Iterator<T> iterator) {
while (true) {
T current = iterator.next();
if (!iterator.hasNext()) {
@@ -916,9 +868,7 @@
* @return the last element of {@code iterator}
* @since 3.0
*/
- @ParametricNullness
- public static <T extends @Nullable Object> T getLast(
- Iterator<? extends T> iterator, @ParametricNullness T defaultValue) {
+ public static <T> @Nullable T getLast(Iterator<? extends T> iterator, @Nullable T defaultValue) {
return iterator.hasNext() ? getLast(iterator) : defaultValue;
}
@@ -951,8 +901,7 @@
* @throws IllegalArgumentException if {@code limitSize} is negative
* @since 3.0
*/
- public static <T extends @Nullable Object> Iterator<T> limit(
- final Iterator<T> iterator, final int limitSize) {
+ public static <T> Iterator<T> limit(final Iterator<T> iterator, final int limitSize) {
checkNotNull(iterator);
checkArgument(limitSize >= 0, "limit is negative");
return new Iterator<T>() {
@@ -964,7 +913,6 @@
}
@Override
- @ParametricNullness
public T next() {
if (!hasNext()) {
throw new NoSuchElementException();
@@ -991,8 +939,7 @@
* @return an iterator that removes and returns elements from the supplied iterator
* @since 2.0
*/
- public static <T extends @Nullable Object> Iterator<T> consumingIterator(
- final Iterator<T> iterator) {
+ public static <T> Iterator<T> consumingIterator(final Iterator<T> iterator) {
checkNotNull(iterator);
return new UnmodifiableIterator<T>() {
@Override
@@ -1001,7 +948,6 @@
}
@Override
- @ParametricNullness
public T next() {
T next = iterator.next();
iterator.remove();
@@ -1019,8 +965,7 @@
* Deletes and returns the next value from the iterator, or returns {@code null} if there is no
* such value.
*/
- @CheckForNull
- static <T extends @Nullable Object> T pollNext(Iterator<T> iterator) {
+ static <T> @Nullable T pollNext(Iterator<T> iterator) {
if (iterator.hasNext()) {
T result = iterator.next();
iterator.remove();
@@ -1052,7 +997,7 @@
* {@link ImmutableList#copyOf(Object[])}}, or {@link ImmutableList#of}.
*/
@SafeVarargs
- public static <T extends @Nullable Object> UnmodifiableIterator<T> forArray(final T... array) {
+ public static <T> UnmodifiableIterator<T> forArray(final T... array) {
return forArray(array, 0, array.length, 0);
}
@@ -1063,7 +1008,7 @@
* <p>The {@code Iterable} equivalent of this method is {@code
* Arrays.asList(array).subList(offset, offset + length).listIterator(index)}.
*/
- static <T extends @Nullable Object> UnmodifiableListIterator<T> forArray(
+ static <T> UnmodifiableListIterator<T> forArray(
final T[] array, final int offset, int length, int index) {
checkArgument(length >= 0);
int end = offset + length;
@@ -1077,8 +1022,7 @@
return new ArrayItr<T>(array, offset, length, index);
}
- private static final class ArrayItr<T extends @Nullable Object>
- extends AbstractIndexedListIterator<T> {
+ private static final class ArrayItr<T> extends AbstractIndexedListIterator<T> {
static final UnmodifiableListIterator<Object> EMPTY = new ArrayItr<>(new Object[0], 0, 0, 0);
private final T[] array;
@@ -1091,7 +1035,6 @@
}
@Override
- @ParametricNullness
protected T get(int index) {
return array[offset + index];
}
@@ -1102,8 +1045,7 @@
*
* <p>The {@link Iterable} equivalent of this method is {@link Collections#singleton}.
*/
- public static <T extends @Nullable Object> UnmodifiableIterator<T> singletonIterator(
- @ParametricNullness final T value) {
+ public static <T> UnmodifiableIterator<T> singletonIterator(final @Nullable T value) {
return new UnmodifiableIterator<T>() {
boolean done;
@@ -1113,7 +1055,6 @@
}
@Override
- @ParametricNullness
public T next() {
if (done) {
throw new NoSuchElementException();
@@ -1134,8 +1075,7 @@
* <p><b>Java 9 users:</b> use {@code enumeration.asIterator()} instead, unless it is important to
* return an {@code UnmodifiableIterator} instead of a plain {@code Iterator}.
*/
- public static <T extends @Nullable Object> UnmodifiableIterator<T> forEnumeration(
- final Enumeration<T> enumeration) {
+ public static <T> UnmodifiableIterator<T> forEnumeration(final Enumeration<T> enumeration) {
checkNotNull(enumeration);
return new UnmodifiableIterator<T>() {
@Override
@@ -1144,7 +1084,6 @@
}
@Override
- @ParametricNullness
public T next() {
return enumeration.nextElement();
}
@@ -1157,8 +1096,7 @@
* <p>The {@code Iterable} equivalent of this method is either {@link Collections#enumeration} (if
* you have a {@link Collection}), or {@code Iterators.asEnumeration(collection.iterator())}.
*/
- public static <T extends @Nullable Object> Enumeration<T> asEnumeration(
- final Iterator<T> iterator) {
+ public static <T> Enumeration<T> asEnumeration(final Iterator<T> iterator) {
checkNotNull(iterator);
return new Enumeration<T>() {
@Override
@@ -1167,7 +1105,6 @@
}
@Override
- @ParametricNullness
public T nextElement() {
return iterator.next();
}
@@ -1175,11 +1112,11 @@
}
/** Implementation of PeekingIterator that avoids peeking unless necessary. */
- private static class PeekingImpl<E extends @Nullable Object> implements PeekingIterator<E> {
+ private static class PeekingImpl<E> implements PeekingIterator<E> {
private final Iterator<? extends E> iterator;
private boolean hasPeeked;
- @CheckForNull private E peekedElement;
+ private @Nullable E peekedElement;
public PeekingImpl(Iterator<? extends E> iterator) {
this.iterator = checkNotNull(iterator);
@@ -1191,13 +1128,11 @@
}
@Override
- @ParametricNullness
public E next() {
if (!hasPeeked) {
return iterator.next();
}
- // The cast is safe because of the hasPeeked check.
- E result = uncheckedCastNullableTToT(peekedElement);
+ E result = peekedElement;
hasPeeked = false;
peekedElement = null;
return result;
@@ -1210,14 +1145,12 @@
}
@Override
- @ParametricNullness
public E peek() {
if (!hasPeeked) {
peekedElement = iterator.next();
hasPeeked = true;
}
- // The cast is safe because of the hasPeeked check.
- return uncheckedCastNullableTToT(peekedElement);
+ return peekedElement;
}
}
@@ -1257,8 +1190,7 @@
* @return a peeking iterator backed by that iterator. Apart from the additional {@link
* PeekingIterator#peek()} method, this iterator behaves exactly the same as {@code iterator}.
*/
- public static <T extends @Nullable Object> PeekingIterator<T> peekingIterator(
- Iterator<? extends T> iterator) {
+ public static <T> PeekingIterator<T> peekingIterator(Iterator<? extends T> iterator) {
if (iterator instanceof PeekingImpl) {
// Safe to cast <? extends T> to <T> because PeekingImpl only uses T
// covariantly (and cannot be subclassed to add non-covariant uses).
@@ -1276,8 +1208,7 @@
* @since 10.0
*/
@Deprecated
- public static <T extends @Nullable Object> PeekingIterator<T> peekingIterator(
- PeekingIterator<T> iterator) {
+ public static <T> PeekingIterator<T> peekingIterator(PeekingIterator<T> iterator) {
return checkNotNull(iterator);
}
@@ -1294,7 +1225,7 @@
* @since 11.0
*/
@Beta
- public static <T extends @Nullable Object> UnmodifiableIterator<T> mergeSorted(
+ public static <T> UnmodifiableIterator<T> mergeSorted(
Iterable<? extends Iterator<? extends T>> iterators, Comparator<? super T> comparator) {
checkNotNull(iterators, "iterators");
checkNotNull(comparator, "comparator");
@@ -1311,7 +1242,7 @@
* iterators. (Retrieving all elements takes approximately O(N*log(M)) time, where N is the total
* number of elements.)
*/
- private static class MergingIterator<T extends @Nullable Object> extends UnmodifiableIterator<T> {
+ private static class MergingIterator<T> extends UnmodifiableIterator<T> {
final Queue<PeekingIterator<T>> queue;
public MergingIterator(
@@ -1342,7 +1273,6 @@
}
@Override
- @ParametricNullness
public T next() {
PeekingIterator<T> nextIter = queue.remove();
T next = nextIter.next();
@@ -1353,9 +1283,9 @@
}
}
- private static class ConcatenatedIterator<T extends @Nullable Object> implements Iterator<T> {
+ private static class ConcatenatedIterator<T> implements Iterator<T> {
/* The last iterator to return an element. Calls to remove() go to this iterator. */
- @CheckForNull private Iterator<? extends T> toRemove;
+ private @Nullable Iterator<? extends T> toRemove;
/* The iterator currently returning elements. */
private Iterator<? extends T> iterator;
@@ -1367,10 +1297,10 @@
* operation O(1).
*/
- @CheckForNull private Iterator<? extends Iterator<? extends T>> topMetaIterator;
+ private Iterator<? extends Iterator<? extends T>> topMetaIterator;
// Only becomes nonnull if we encounter nested concatenations.
- @CheckForNull private Deque<Iterator<? extends Iterator<? extends T>>> metaIterators;
+ private @Nullable Deque<Iterator<? extends Iterator<? extends T>>> metaIterators;
ConcatenatedIterator(Iterator<? extends Iterator<? extends T>> metaIterator) {
iterator = emptyIterator();
@@ -1378,8 +1308,7 @@
}
// Returns a nonempty meta-iterator or, if all meta-iterators are empty, null.
- @CheckForNull
- private Iterator<? extends Iterator<? extends T>> getTopMetaIterator() {
+ private @Nullable Iterator<? extends Iterator<? extends T>> getTopMetaIterator() {
while (topMetaIterator == null || !topMetaIterator.hasNext()) {
if (metaIterators != null && !metaIterators.isEmpty()) {
topMetaIterator = metaIterators.removeFirst();
@@ -1429,7 +1358,6 @@
}
@Override
- @ParametricNullness
public T next() {
if (hasNext()) {
toRemove = iterator;
@@ -1441,16 +1369,14 @@
@Override
public void remove() {
- if (toRemove == null) {
- throw new IllegalStateException("no calls to next() since the last call to remove()");
- }
+ CollectPreconditions.checkRemove(toRemove != null);
toRemove.remove();
toRemove = null;
}
}
/** Used to avoid http://bugs.sun.com/view_bug.do?bug_id=6558557 */
- static <T extends @Nullable Object> ListIterator<T> cast(Iterator<T> iterator) {
+ static <T> ListIterator<T> cast(Iterator<T> iterator) {
return (ListIterator<T>) iterator;
}
}
diff --git a/guava/src/com/google/common/collect/JdkBackedImmutableBiMap.java b/guava/src/com/google/common/collect/JdkBackedImmutableBiMap.java
index 09f3135..6fceaa9 100644
--- a/guava/src/com/google/common/collect/JdkBackedImmutableBiMap.java
+++ b/guava/src/com/google/common/collect/JdkBackedImmutableBiMap.java
@@ -15,15 +15,12 @@
*/
package com.google.common.collect;
-import static java.util.Objects.requireNonNull;
-
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.VisibleForTesting;
import com.google.errorprone.annotations.concurrent.LazyInit;
import com.google.j2objc.annotations.RetainedWith;
import com.google.j2objc.annotations.WeakOuter;
import java.util.Map;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -31,15 +28,13 @@
* protecting against hash flooding.
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
final class JdkBackedImmutableBiMap<K, V> extends ImmutableBiMap<K, V> {
@VisibleForTesting
- static <K, V> ImmutableBiMap<K, V> create(int n, @Nullable Entry<K, V>[] entryArray) {
+ static <K, V> ImmutableBiMap<K, V> create(int n, Entry<K, V>[] entryArray) {
Map<K, V> forwardDelegate = Maps.newHashMapWithExpectedSize(n);
Map<V, K> backwardDelegate = Maps.newHashMapWithExpectedSize(n);
for (int i = 0; i < n; i++) {
- // requireNonNull is safe because the first `n` elements have been filled in.
- Entry<K, V> e = RegularImmutableMap.makeImmutable(requireNonNull(entryArray[i]));
+ Entry<K, V> e = RegularImmutableMap.makeImmutable(entryArray[i]);
entryArray[i] = e;
V oldValue = forwardDelegate.putIfAbsent(e.getKey(), e.getValue());
if (oldValue != null) {
@@ -70,7 +65,7 @@
return entries.size();
}
- @LazyInit @RetainedWith @CheckForNull private transient JdkBackedImmutableBiMap<V, K> inverse;
+ @LazyInit @RetainedWith private transient JdkBackedImmutableBiMap<V, K> inverse;
@Override
public ImmutableBiMap<V, K> inverse() {
@@ -105,8 +100,7 @@
}
@Override
- @CheckForNull
- public V get(@CheckForNull 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 5b323b9..ffbd189 100644
--- a/guava/src/com/google/common/collect/JdkBackedImmutableMap.java
+++ b/guava/src/com/google/common/collect/JdkBackedImmutableMap.java
@@ -18,12 +18,10 @@
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.collect.RegularImmutableMap.makeImmutable;
-import static java.util.Objects.requireNonNull;
import com.google.common.annotations.GwtCompatible;
import java.util.Map;
import java.util.function.BiConsumer;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -31,18 +29,16 @@
* hash flooding.
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
final class JdkBackedImmutableMap<K, V> extends ImmutableMap<K, V> {
/**
* Creates an {@code ImmutableMap} backed by a JDK HashMap. Used when probable hash flooding is
* detected. This implementation may replace the entries in entryArray with its own entry objects
* (though they will have the same key/value contents), and will take ownership of entryArray.
*/
- static <K, V> ImmutableMap<K, V> create(int n, @Nullable Entry<K, V>[] entryArray) {
+ static <K, V> ImmutableMap<K, V> create(int n, Entry<K, V>[] entryArray) {
Map<K, V> delegateMap = Maps.newHashMapWithExpectedSize(n);
for (int i = 0; i < n; i++) {
- // requireNonNull is safe because the first `n` elements have been filled in.
- entryArray[i] = makeImmutable(requireNonNull(entryArray[i]));
+ entryArray[i] = makeImmutable(entryArray[i]);
V oldValue = delegateMap.putIfAbsent(entryArray[i].getKey(), entryArray[i].getValue());
if (oldValue != null) {
throw conflictException("key", entryArray[i], entryArray[i].getKey() + "=" + oldValue);
@@ -65,8 +61,7 @@
}
@Override
- @CheckForNull
- public V get(@CheckForNull 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 7bdd9e8..f2f196b 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 javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* An implementation of ImmutableMultiset backed by a JDK Map and a list of entries. Used to protect
@@ -29,7 +29,6 @@
* @author Louis Wasserman
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
final class JdkBackedImmutableMultiset<E> extends ImmutableMultiset<E> {
private final Map<E, Integer> delegateMap;
private final ImmutableList<Entry<E>> entries;
@@ -62,11 +61,11 @@
}
@Override
- public int count(@CheckForNull Object element) {
+ public int count(@Nullable Object element) {
return delegateMap.getOrDefault(element, 0);
}
- @CheckForNull private transient ImmutableSet<E> elementSet;
+ private transient ImmutableSet<E> elementSet;
@Override
public ImmutableSet<E> elementSet() {
diff --git a/guava/src/com/google/common/collect/JdkBackedImmutableSet.java b/guava/src/com/google/common/collect/JdkBackedImmutableSet.java
index c001677..fa2c615 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 javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* ImmutableSet implementation backed by a JDK HashSet, used to defend against apparent hash
@@ -26,7 +26,6 @@
* @author Louis Wasserman
*/
@GwtCompatible(serializable = true)
-@ElementTypesAreNonnullByDefault
final class JdkBackedImmutableSet<E> extends IndexedImmutableSet<E> {
private final Set<?> delegate;
private final ImmutableList<E> delegateList;
@@ -42,7 +41,7 @@
}
@Override
- public boolean contains(@CheckForNull 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 91fc7bf..5e00eb4 100644
--- a/guava/src/com/google/common/collect/LexicographicalOrdering.java
+++ b/guava/src/com/google/common/collect/LexicographicalOrdering.java
@@ -20,14 +20,11 @@
import java.io.Serializable;
import java.util.Comparator;
import java.util.Iterator;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/** An ordering which sorts iterables by comparing corresponding elements pairwise. */
@GwtCompatible(serializable = true)
-@ElementTypesAreNonnullByDefault
-final class LexicographicalOrdering<T extends @Nullable Object> extends Ordering<Iterable<T>>
- implements Serializable {
+final class LexicographicalOrdering<T> extends Ordering<Iterable<T>> implements Serializable {
final Comparator<? super T> elementOrder;
LexicographicalOrdering(Comparator<? super T> elementOrder) {
@@ -54,7 +51,7 @@
}
@Override
- public boolean equals(@CheckForNull 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 b4d2ab9..f4a1c65 100644
--- a/guava/src/com/google/common/collect/LinkedHashMultimap.java
+++ b/guava/src/com/google/common/collect/LinkedHashMultimap.java
@@ -17,9 +17,8 @@
package com.google.common.collect;
import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.base.Preconditions.checkState;
import static com.google.common.collect.CollectPreconditions.checkNonnegative;
-import static java.util.Objects.requireNonNull;
+import static com.google.common.collect.CollectPreconditions.checkRemove;
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.GwtIncompatible;
@@ -41,7 +40,6 @@
import java.util.Spliterator;
import java.util.Spliterators;
import java.util.function.Consumer;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -71,10 +69,6 @@
* read operations will work correctly. To allow concurrent update operations, wrap your multimap
* with a call to {@link Multimaps#synchronizedSetMultimap}.
*
- * <p><b>Warning:</b> Do not modify either a key <i>or a value</i> of a {@code LinkedHashMultimap}
- * in a way that affects its {@link Object#equals} behavior. Undefined behavior and bugs will
- * result.
- *
* <p>See the Guava User Guide article on <a href=
* "https://github.com/google/guava/wiki/NewCollectionTypesExplained#multimap"> {@code
* Multimap}</a>.
@@ -84,13 +78,11 @@
* @since 2.0
*/
@GwtCompatible(serializable = true, emulated = true)
-@ElementTypesAreNonnullByDefault
-public final class LinkedHashMultimap<K extends @Nullable Object, V extends @Nullable Object>
+public final class LinkedHashMultimap<K, V>
extends LinkedHashMultimapGwtSerializationDependencies<K, V> {
/** Creates a new, empty {@code LinkedHashMultimap} with the default initial capacities. */
- public static <K extends @Nullable Object, V extends @Nullable Object>
- LinkedHashMultimap<K, V> create() {
+ public static <K, V> LinkedHashMultimap<K, V> create() {
return new LinkedHashMultimap<>(DEFAULT_KEY_CAPACITY, DEFAULT_VALUE_SET_CAPACITY);
}
@@ -103,8 +95,7 @@
* @throws IllegalArgumentException if {@code expectedKeys} or {@code expectedValuesPerKey} is
* negative
*/
- public static <K extends @Nullable Object, V extends @Nullable Object>
- LinkedHashMultimap<K, V> create(int expectedKeys, int expectedValuesPerKey) {
+ public static <K, V> LinkedHashMultimap<K, V> create(int expectedKeys, int expectedValuesPerKey) {
return new LinkedHashMultimap<>(
Maps.capacity(expectedKeys), Maps.capacity(expectedValuesPerKey));
}
@@ -117,14 +108,14 @@
*
* @param multimap the multimap whose contents are copied to this multimap
*/
- public static <K extends @Nullable Object, V extends @Nullable Object>
- LinkedHashMultimap<K, V> create(Multimap<? extends K, ? extends V> multimap) {
+ public static <K, V> LinkedHashMultimap<K, V> create(
+ Multimap<? extends K, ? extends V> multimap) {
LinkedHashMultimap<K, V> result = create(multimap.keySet().size(), DEFAULT_VALUE_SET_CAPACITY);
result.putAll(multimap);
return result;
}
- private interface ValueSetLink<K extends @Nullable Object, V extends @Nullable Object> {
+ private interface ValueSetLink<K, V> {
ValueSetLink<K, V> getPredecessorInValueSet();
ValueSetLink<K, V> getSuccessorInValueSet();
@@ -134,25 +125,21 @@
void setSuccessorInValueSet(ValueSetLink<K, V> entry);
}
- private static <K extends @Nullable Object, V extends @Nullable Object> void succeedsInValueSet(
- ValueSetLink<K, V> pred, ValueSetLink<K, V> succ) {
+ private static <K, V> void succeedsInValueSet(ValueSetLink<K, V> pred, ValueSetLink<K, V> succ) {
pred.setSuccessorInValueSet(succ);
succ.setPredecessorInValueSet(pred);
}
- private static <K extends @Nullable Object, V extends @Nullable Object> void succeedsInMultimap(
- ValueEntry<K, V> pred, ValueEntry<K, V> succ) {
+ private static <K, V> void succeedsInMultimap(ValueEntry<K, V> pred, ValueEntry<K, V> succ) {
pred.setSuccessorInMultimap(succ);
succ.setPredecessorInMultimap(pred);
}
- private static <K extends @Nullable Object, V extends @Nullable Object> void deleteFromValueSet(
- ValueSetLink<K, V> entry) {
+ private static <K, V> void deleteFromValueSet(ValueSetLink<K, V> entry) {
succeedsInValueSet(entry.getPredecessorInValueSet(), entry.getSuccessorInValueSet());
}
- private static <K extends @Nullable Object, V extends @Nullable Object> void deleteFromMultimap(
- ValueEntry<K, V> entry) {
+ private static <K, V> void deleteFromMultimap(ValueEntry<K, V> entry) {
succeedsInMultimap(entry.getPredecessorInMultimap(), entry.getSuccessorInMultimap());
}
@@ -163,69 +150,39 @@
* whole.
*/
@VisibleForTesting
- static final class ValueEntry<K extends @Nullable Object, V extends @Nullable Object>
- extends ImmutableEntry<K, V> implements ValueSetLink<K, V> {
+ static final class ValueEntry<K, V> extends ImmutableEntry<K, V> implements ValueSetLink<K, V> {
final int smearedValueHash;
- @CheckForNull ValueEntry<K, V> nextInValueBucket;
- /*
- * The *InValueSet and *InMultimap fields below are null after construction, but we almost
- * always call succeedsIn*() to initialize them immediately thereafter.
- *
- * The exception is the *InValueSet fields of multimapHeaderEntry, which are never set. (That
- * works out fine as long as we continue to be careful not to try delete them or iterate past
- * them.)
- *
- * We could consider "lying" and omitting @CheckNotNull from all these fields. Normally, I'm not
- * a fan of that: What if we someday implement (presumably to be enabled during tests only)
- * bytecode rewriting that checks for any null value that passes through an API with a
- * known-non-null type? But that particular problem might not arise here, since we're not
- * actually reading from the fields in any case in which they might be null (as proven by the
- * requireNonNull checks below). Plus, we're *already* lying here, since newHeader passes a null
- * key and value, which we pass to the superconstructor, even though the key and value type for
- * a given entry might not include null. The right fix for the header problems is probably to
- * define a separate MultimapLink interface with a separate "header" implementation, which
- * hopefully could avoid implementing Entry or ValueSetLink at all. (But note that that approach
- * requires us to define extra classes -- unfortunate under Android.) *Then* we could consider
- * lying about the fields below on the grounds that we always initialize them just after the
- * constructor -- an example of the kind of lying that our hypotheticaly bytecode rewriter would
- * already have to deal with, thanks to DI frameworks that perform field and method injection,
- * frameworks like Android that define post-construct hooks like Activity.onCreate, etc.
- */
+ @Nullable ValueEntry<K, V> nextInValueBucket;
- @CheckForNull ValueSetLink<K, V> predecessorInValueSet;
- @CheckForNull ValueSetLink<K, V> successorInValueSet;
+ @Nullable ValueSetLink<K, V> predecessorInValueSet;
+ @Nullable ValueSetLink<K, V> successorInValueSet;
- @CheckForNull ValueEntry<K, V> predecessorInMultimap;
- @CheckForNull ValueEntry<K, V> successorInMultimap;
+ @Nullable ValueEntry<K, V> predecessorInMultimap;
+ @Nullable ValueEntry<K, V> successorInMultimap;
ValueEntry(
- @ParametricNullness K key,
- @ParametricNullness V value,
+ @Nullable K key,
+ @Nullable V value,
int smearedValueHash,
- @CheckForNull ValueEntry<K, V> nextInValueBucket) {
+ @Nullable ValueEntry<K, V> nextInValueBucket) {
super(key, value);
this.smearedValueHash = smearedValueHash;
this.nextInValueBucket = nextInValueBucket;
}
- @SuppressWarnings("nullness") // see the comment on the class fields, especially about newHeader
- static <K extends @Nullable Object, V extends @Nullable Object> ValueEntry<K, V> newHeader() {
- return new ValueEntry<>(null, null, 0, null);
- }
-
- boolean matchesValue(@CheckForNull Object v, int smearedVHash) {
+ boolean matchesValue(@Nullable Object v, int smearedVHash) {
return smearedValueHash == smearedVHash && Objects.equal(getValue(), v);
}
@Override
public ValueSetLink<K, V> getPredecessorInValueSet() {
- return requireNonNull(predecessorInValueSet); // see the comment on the class fields
+ return predecessorInValueSet;
}
@Override
public ValueSetLink<K, V> getSuccessorInValueSet() {
- return requireNonNull(successorInValueSet); // see the comment on the class fields
+ return successorInValueSet;
}
@Override
@@ -239,11 +196,11 @@
}
public ValueEntry<K, V> getPredecessorInMultimap() {
- return requireNonNull(predecessorInMultimap); // see the comment on the class fields
+ return predecessorInMultimap;
}
public ValueEntry<K, V> getSuccessorInMultimap() {
- return requireNonNull(successorInMultimap); // see the comment on the class fields
+ return successorInMultimap;
}
public void setSuccessorInMultimap(ValueEntry<K, V> multimapSuccessor) {
@@ -267,7 +224,7 @@
checkNonnegative(valueSetCapacity, "expectedValuesPerKey");
this.valueSetCapacity = valueSetCapacity;
- this.multimapHeaderEntry = ValueEntry.newHeader();
+ this.multimapHeaderEntry = new ValueEntry<>(null, null, 0, null);
succeedsInMultimap(multimapHeaderEntry, multimapHeaderEntry);
}
@@ -293,7 +250,7 @@
* @return a new decorated set containing a collection of values for one key
*/
@Override
- Collection<V> createCollection(@ParametricNullness K key) {
+ Collection<V> createCollection(K key) {
return new ValueSet(key, valueSetCapacity);
}
@@ -306,7 +263,7 @@
*/
@CanIgnoreReturnValue
@Override
- public Set<V> replaceValues(@ParametricNullness K key, Iterable<? extends V> values) {
+ public Set<V> replaceValues(@Nullable K key, Iterable<? extends V> values) {
return super.replaceValues(key, values);
}
@@ -361,8 +318,8 @@
* consumption.
*/
- @ParametricNullness private final K key;
- @VisibleForTesting @Nullable ValueEntry<K, V>[] hashTable;
+ private final K key;
+ @VisibleForTesting ValueEntry<K, V>[] hashTable;
private int size = 0;
private int modCount = 0;
@@ -371,16 +328,15 @@
private ValueSetLink<K, V> firstEntry;
private ValueSetLink<K, V> lastEntry;
- ValueSet(@ParametricNullness K key, int expectedValues) {
+ ValueSet(K key, int expectedValues) {
this.key = key;
this.firstEntry = this;
this.lastEntry = this;
// Round expected values up to a power of 2 to get the table size.
int tableSize = Hashing.closedTableSize(expectedValues, VALUE_SET_LOAD_FACTOR);
- @SuppressWarnings({"rawtypes", "unchecked"})
- @Nullable
- ValueEntry<K, V>[] hashTable = new @Nullable ValueEntry[tableSize];
+ @SuppressWarnings("unchecked")
+ ValueEntry<K, V>[] hashTable = new ValueEntry[tableSize];
this.hashTable = hashTable;
}
@@ -412,7 +368,7 @@
public Iterator<V> iterator() {
return new Iterator<V>() {
ValueSetLink<K, V> nextEntry = firstEntry;
- @CheckForNull ValueEntry<K, V> toRemove;
+ @Nullable ValueEntry<K, V> toRemove;
int expectedModCount = modCount;
private void checkForComodification() {
@@ -428,7 +384,6 @@
}
@Override
- @ParametricNullness
public V next() {
if (!hasNext()) {
throw new NoSuchElementException();
@@ -443,7 +398,7 @@
@Override
public void remove() {
checkForComodification();
- checkState(toRemove != null, "no calls to next() since the last call to remove()");
+ checkRemove(toRemove != null);
ValueSet.this.remove(toRemove.getValue());
expectedModCount = modCount;
toRemove = null;
@@ -467,7 +422,7 @@
}
@Override
- public boolean contains(@CheckForNull Object o) {
+ public boolean contains(@Nullable Object o) {
int smearedHash = Hashing.smearedHash(o);
for (ValueEntry<K, V> entry = hashTable[smearedHash & mask()];
entry != null;
@@ -480,7 +435,7 @@
}
@Override
- public boolean add(@ParametricNullness V value) {
+ public boolean add(@Nullable V value) {
int smearedHash = Hashing.smearedHash(value);
int bucket = smearedHash & mask();
ValueEntry<K, V> rowHead = hashTable[bucket];
@@ -521,7 +476,7 @@
@CanIgnoreReturnValue
@Override
- public boolean remove(@CheckForNull Object o) {
+ public boolean remove(@Nullable Object o) {
int smearedHash = Hashing.smearedHash(o);
int bucket = smearedHash & mask();
ValueEntry<K, V> prev = null;
@@ -563,8 +518,8 @@
@Override
Iterator<Entry<K, V>> entryIterator() {
return new Iterator<Entry<K, V>>() {
- ValueEntry<K, V> nextEntry = multimapHeaderEntry.getSuccessorInMultimap();
- @CheckForNull ValueEntry<K, V> toRemove;
+ ValueEntry<K, V> nextEntry = multimapHeaderEntry.successorInMultimap;
+ @Nullable ValueEntry<K, V> toRemove;
@Override
public boolean hasNext() {
@@ -578,13 +533,13 @@
}
ValueEntry<K, V> result = nextEntry;
toRemove = result;
- nextEntry = nextEntry.getSuccessorInMultimap();
+ nextEntry = nextEntry.successorInMultimap;
return result;
}
@Override
public void remove() {
- checkState(toRemove != null, "no calls to next() since the last call to remove()");
+ checkRemove(toRemove != null);
LinkedHashMultimap.this.remove(toRemove.getKey(), toRemove.getValue());
toRemove = null;
}
@@ -633,7 +588,7 @@
@GwtIncompatible // java.io.ObjectInputStream
private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {
stream.defaultReadObject();
- multimapHeaderEntry = ValueEntry.newHeader();
+ multimapHeaderEntry = new ValueEntry<>(null, null, 0, null);
succeedsInMultimap(multimapHeaderEntry, multimapHeaderEntry);
valueSetCapacity = DEFAULT_VALUE_SET_CAPACITY;
int distinctKeys = stream.readInt();
@@ -649,11 +604,7 @@
K key = (K) stream.readObject();
@SuppressWarnings("unchecked")
V value = (V) stream.readObject();
- /*
- * requireNonNull is safe for a properly serialized multimap: We've already inserted a
- * collection for each key that we expect.
- */
- requireNonNull(map.get(key)).add(value);
+ map.get(key).add(value);
}
setMap(map);
}
diff --git a/guava/src/com/google/common/collect/LinkedHashMultiset.java b/guava/src/com/google/common/collect/LinkedHashMultiset.java
index 13f70a7..87c2ad2 100644
--- a/guava/src/com/google/common/collect/LinkedHashMultiset.java
+++ b/guava/src/com/google/common/collect/LinkedHashMultiset.java
@@ -22,7 +22,6 @@
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.LinkedHashMap;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* A {@code Multiset} implementation with predictable iteration order. Its iterator orders elements
@@ -40,12 +39,10 @@
* @since 2.0
*/
@GwtCompatible(serializable = true, emulated = true)
-@ElementTypesAreNonnullByDefault
-public final class LinkedHashMultiset<E extends @Nullable Object>
- extends AbstractMapBasedMultiset<E> {
+public final class LinkedHashMultiset<E> extends AbstractMapBasedMultiset<E> {
/** Creates a new, empty {@code LinkedHashMultiset} using the default initial capacity. */
- public static <E extends @Nullable Object> LinkedHashMultiset<E> create() {
+ public static <E> LinkedHashMultiset<E> create() {
return new LinkedHashMultiset<E>();
}
@@ -56,7 +53,7 @@
* @param distinctElements the expected number of distinct elements
* @throws IllegalArgumentException if {@code distinctElements} is negative
*/
- public static <E extends @Nullable Object> LinkedHashMultiset<E> create(int distinctElements) {
+ public static <E> LinkedHashMultiset<E> create(int distinctElements) {
return new LinkedHashMultiset<E>(distinctElements);
}
@@ -67,8 +64,7 @@
*
* @param elements the elements that the multiset should contain
*/
- public static <E extends @Nullable Object> LinkedHashMultiset<E> create(
- Iterable<? extends E> elements) {
+ public static <E> LinkedHashMultiset<E> create(Iterable<? extends E> elements) {
LinkedHashMultiset<E> multiset = create(Multisets.inferDistinctElements(elements));
Iterables.addAll(multiset, elements);
return multiset;
diff --git a/guava/src/com/google/common/collect/LinkedListMultimap.java b/guava/src/com/google/common/collect/LinkedListMultimap.java
index a557870..b93a9a3 100644
--- a/guava/src/com/google/common/collect/LinkedListMultimap.java
+++ b/guava/src/com/google/common/collect/LinkedListMultimap.java
@@ -19,8 +19,8 @@
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkPositionIndex;
import static com.google.common.base.Preconditions.checkState;
+import static com.google.common.collect.CollectPreconditions.checkRemove;
import static java.util.Collections.unmodifiableList;
-import static java.util.Objects.requireNonNull;
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.GwtIncompatible;
@@ -41,7 +41,6 @@
import java.util.NoSuchElementException;
import java.util.Set;
import java.util.function.Consumer;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -97,9 +96,8 @@
* @since 2.0
*/
@GwtCompatible(serializable = true, emulated = true)
-@ElementTypesAreNonnullByDefault
-public class LinkedListMultimap<K extends @Nullable Object, V extends @Nullable Object>
- extends AbstractMultimap<K, V> implements ListMultimap<K, V>, Serializable {
+public class LinkedListMultimap<K, V> extends AbstractMultimap<K, V>
+ implements ListMultimap<K, V>, Serializable {
/*
* Order is maintained using a linked list containing all key-value pairs. In
* addition, a series of disjoint linked lists of "siblings", each containing
@@ -107,42 +105,38 @@
* ValueForKeyIterator} in constant time.
*/
- private static final class Node<K extends @Nullable Object, V extends @Nullable Object>
- extends AbstractMapEntry<K, V> {
- @ParametricNullness final K key;
- @ParametricNullness V value;
- @CheckForNull Node<K, V> next; // the next node (with any key)
- @CheckForNull Node<K, V> previous; // the previous node (with any key)
- @CheckForNull Node<K, V> nextSibling; // the next node with the same key
- @CheckForNull Node<K, V> previousSibling; // the previous node with the same key
+ private static final class Node<K, V> extends AbstractMapEntry<K, V> {
+ final @Nullable K key;
+ @Nullable V value;
+ @Nullable Node<K, V> next; // the next node (with any key)
+ @Nullable Node<K, V> previous; // the previous node (with any key)
+ @Nullable Node<K, V> nextSibling; // the next node with the same key
+ @Nullable Node<K, V> previousSibling; // the previous node with the same key
- Node(@ParametricNullness K key, @ParametricNullness V value) {
+ Node(@Nullable K key, @Nullable V value) {
this.key = key;
this.value = value;
}
@Override
- @ParametricNullness
public K getKey() {
return key;
}
@Override
- @ParametricNullness
public V getValue() {
return value;
}
@Override
- @ParametricNullness
- public V setValue(@ParametricNullness V newValue) {
+ public V setValue(@Nullable V newValue) {
V result = value;
this.value = newValue;
return result;
}
}
- private static class KeyList<K extends @Nullable Object, V extends @Nullable Object> {
+ private static class KeyList<K, V> {
Node<K, V> head;
Node<K, V> tail;
int count;
@@ -156,8 +150,8 @@
}
}
- @CheckForNull private transient Node<K, V> head; // the head for all keys
- @CheckForNull private transient Node<K, V> tail; // the tail for all keys
+ private transient @Nullable Node<K, V> head; // the head for all keys
+ private transient @Nullable Node<K, V> tail; // the tail for all keys
private transient Map<K, KeyList<K, V>> keyToKeyList;
private transient int size;
@@ -169,8 +163,7 @@
private transient int modCount;
/** Creates a new, empty {@code LinkedListMultimap} with the default initial capacity. */
- public static <K extends @Nullable Object, V extends @Nullable Object>
- LinkedListMultimap<K, V> create() {
+ public static <K, V> LinkedListMultimap<K, V> create() {
return new LinkedListMultimap<>();
}
@@ -181,8 +174,7 @@
* @param expectedKeys the expected number of distinct keys
* @throws IllegalArgumentException if {@code expectedKeys} is negative
*/
- public static <K extends @Nullable Object, V extends @Nullable Object>
- LinkedListMultimap<K, V> create(int expectedKeys) {
+ public static <K, V> LinkedListMultimap<K, V> create(int expectedKeys) {
return new LinkedListMultimap<>(expectedKeys);
}
@@ -193,8 +185,8 @@
*
* @param multimap the multimap whose contents are copied to this multimap
*/
- public static <K extends @Nullable Object, V extends @Nullable Object>
- LinkedListMultimap<K, V> create(Multimap<? extends K, ? extends V> multimap) {
+ public static <K, V> LinkedListMultimap<K, V> create(
+ Multimap<? extends K, ? extends V> multimap) {
return new LinkedListMultimap<>(multimap);
}
@@ -217,18 +209,14 @@
* is specified, it MUST be for an node for the same {@code key}!
*/
@CanIgnoreReturnValue
- private Node<K, V> addNode(
- @ParametricNullness K key,
- @ParametricNullness V value,
- @CheckForNull Node<K, V> nextSibling) {
+ private Node<K, V> addNode(@Nullable K key, @Nullable V value, @Nullable Node<K, V> nextSibling) {
Node<K, V> node = new Node<>(key, value);
if (head == null) { // empty list
head = tail = node;
keyToKeyList.put(key, new KeyList<K, V>(node));
modCount++;
} else if (nextSibling == null) { // non-empty list, add to tail
- // requireNonNull is safe because the list is non-empty.
- requireNonNull(tail).next = node;
+ tail.next = node;
node.previous = tail;
tail = node;
KeyList<K, V> keyList = keyToKeyList.get(key);
@@ -243,19 +231,14 @@
keyList.tail = node;
}
} else { // non-empty list, insert before nextSibling
- /*
- * requireNonNull is safe as long as callers pass a nextSibling that (a) has the same key and
- * (b) is present in the multimap. (And they do, except maybe in case of concurrent
- * modification, in which case all bets are off.)
- */
- KeyList<K, V> keyList = requireNonNull(keyToKeyList.get(key));
+ KeyList<K, V> keyList = keyToKeyList.get(key);
keyList.count++;
node.previous = nextSibling.previous;
node.previousSibling = nextSibling.previousSibling;
node.next = nextSibling;
node.nextSibling = nextSibling;
if (nextSibling.previousSibling == null) { // nextSibling was key head
- keyList.head = node;
+ keyToKeyList.get(key).head = node;
} else {
nextSibling.previousSibling.nextSibling = node;
}
@@ -287,29 +270,21 @@
tail = node.previous;
}
if (node.previousSibling == null && node.nextSibling == null) {
- /*
- * requireNonNull is safe as long as we call removeNode only for nodes that are still in the
- * Multimap. This should be the case (except in case of concurrent modification, when all bets
- * are off).
- */
- KeyList<K, V> keyList = requireNonNull(keyToKeyList.remove(node.key));
+ KeyList<K, V> keyList = keyToKeyList.remove(node.key);
keyList.count = 0;
modCount++;
} else {
- // requireNonNull is safe (under the conditions listed in the comment in the branch above).
- KeyList<K, V> keyList = requireNonNull(keyToKeyList.get(node.key));
+ KeyList<K, V> keyList = keyToKeyList.get(node.key);
keyList.count--;
if (node.previousSibling == null) {
- // requireNonNull is safe because we checked that not *both* siblings were null.
- keyList.head = requireNonNull(node.nextSibling);
+ keyList.head = node.nextSibling;
} else {
node.previousSibling.nextSibling = node.nextSibling;
}
if (node.nextSibling == null) {
- // requireNonNull is safe because we checked that not *both* siblings were null.
- keyList.tail = requireNonNull(node.previousSibling);
+ keyList.tail = node.previousSibling;
} else {
node.nextSibling.previousSibling = node.previousSibling;
}
@@ -318,16 +293,23 @@
}
/** Removes all nodes for the specified key. */
- private void removeAllNodes(@ParametricNullness K 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(@Nullable Object node) {
+ if (node == null) {
+ throw new NoSuchElementException();
+ }
+ }
+
/** An {@code Iterator} over all nodes. */
private class NodeIterator implements ListIterator<Entry<K, V>> {
int nextIndex;
- @CheckForNull Node<K, V> next;
- @CheckForNull Node<K, V> current;
- @CheckForNull Node<K, V> previous;
+ @Nullable Node<K, V> next;
+ @Nullable Node<K, V> current;
+ @Nullable Node<K, V> previous;
int expectedModCount = modCount;
NodeIterator(int index) {
@@ -364,9 +346,7 @@
@Override
public Node<K, V> next() {
checkForConcurrentModification();
- if (next == null) {
- throw new NoSuchElementException();
- }
+ checkElement(next);
previous = current = next;
next = next.next;
nextIndex++;
@@ -376,7 +356,7 @@
@Override
public void remove() {
checkForConcurrentModification();
- checkState(current != null, "no calls to next() since the last call to remove()");
+ checkRemove(current != null);
if (current != next) { // after call to next()
previous = current.previous;
nextIndex--;
@@ -398,9 +378,7 @@
@Override
public Node<K, V> previous() {
checkForConcurrentModification();
- if (previous == null) {
- throw new NoSuchElementException();
- }
+ checkElement(previous);
next = current = previous;
previous = previous.previous;
nextIndex--;
@@ -427,7 +405,7 @@
throw new UnsupportedOperationException();
}
- void setValue(@ParametricNullness V value) {
+ void setValue(V value) {
checkState(current != null);
current.value = value;
}
@@ -436,8 +414,8 @@
/** An {@code Iterator} over distinct keys in key head order. */
private class DistinctKeyIterator implements Iterator<K> {
final Set<K> seenKeys = Sets.<K>newHashSetWithExpectedSize(keySet().size());
- @CheckForNull Node<K, V> next = head;
- @CheckForNull Node<K, V> current;
+ Node<K, V> next = head;
+ @Nullable Node<K, V> current;
int expectedModCount = modCount;
private void checkForConcurrentModification() {
@@ -453,12 +431,9 @@
}
@Override
- @ParametricNullness
public K next() {
checkForConcurrentModification();
- if (next == null) {
- throw new NoSuchElementException();
- }
+ checkElement(next);
current = next;
seenKeys.add(current.key);
do { // skip ahead to next unseen key
@@ -470,7 +445,7 @@
@Override
public void remove() {
checkForConcurrentModification();
- checkState(current != null, "no calls to next() since the last call to remove()");
+ checkRemove(current != null);
removeAllNodes(current.key);
current = null;
expectedModCount = modCount;
@@ -479,14 +454,14 @@
/** A {@code ListIterator} over values for a specified key. */
private class ValueForKeyIterator implements ListIterator<V> {
- @ParametricNullness final K key;
+ final @Nullable Object key;
int nextIndex;
- @CheckForNull Node<K, V> next;
- @CheckForNull Node<K, V> current;
- @CheckForNull Node<K, V> previous;
+ @Nullable Node<K, V> next;
+ @Nullable Node<K, V> current;
+ @Nullable Node<K, V> previous;
/** Constructs a new iterator over all values for the specified key. */
- ValueForKeyIterator(@ParametricNullness K key) {
+ ValueForKeyIterator(@Nullable Object key) {
this.key = key;
KeyList<K, V> keyList = keyToKeyList.get(key);
next = (keyList == null) ? null : keyList.head;
@@ -500,7 +475,7 @@
*
* @throws IndexOutOfBoundsException if index is invalid
*/
- public ValueForKeyIterator(@ParametricNullness K key, int index) {
+ public ValueForKeyIterator(@Nullable Object key, int index) {
KeyList<K, V> keyList = keyToKeyList.get(key);
int size = (keyList == null) ? 0 : keyList.count;
checkPositionIndex(index, size);
@@ -527,11 +502,8 @@
@CanIgnoreReturnValue
@Override
- @ParametricNullness
public V next() {
- if (next == null) {
- throw new NoSuchElementException();
- }
+ checkElement(next);
previous = current = next;
next = next.nextSibling;
nextIndex++;
@@ -545,11 +517,8 @@
@CanIgnoreReturnValue
@Override
- @ParametricNullness
public V previous() {
- if (previous == null) {
- throw new NoSuchElementException();
- }
+ checkElement(previous);
next = current = previous;
previous = previous.previousSibling;
nextIndex--;
@@ -568,7 +537,7 @@
@Override
public void remove() {
- checkState(current != null, "no calls to next() since the last call to remove()");
+ checkRemove(current != null);
if (current != next) { // after call to next()
previous = current.previousSibling;
nextIndex--;
@@ -580,14 +549,15 @@
}
@Override
- public void set(@ParametricNullness V value) {
+ public void set(V value) {
checkState(current != null);
current.value = value;
}
@Override
- public void add(@ParametricNullness V value) {
- previous = addNode(key, value, next);
+ @SuppressWarnings("unchecked")
+ public void add(V value) {
+ previous = addNode((K) key, value, next);
nextIndex++;
current = null;
}
@@ -606,12 +576,12 @@
}
@Override
- public boolean containsKey(@CheckForNull Object key) {
+ public boolean containsKey(@Nullable Object key) {
return keyToKeyList.containsKey(key);
}
@Override
- public boolean containsValue(@CheckForNull Object value) {
+ public boolean containsValue(@Nullable Object value) {
return values().contains(value);
}
@@ -626,7 +596,7 @@
*/
@CanIgnoreReturnValue
@Override
- public boolean put(@ParametricNullness K key, @ParametricNullness V value) {
+ public boolean put(@Nullable K key, @Nullable V value) {
addNode(key, value, null);
return true;
}
@@ -643,7 +613,7 @@
*/
@CanIgnoreReturnValue
@Override
- public List<V> replaceValues(@ParametricNullness K key, Iterable<? extends V> values) {
+ public List<V> replaceValues(@Nullable K key, Iterable<? extends V> values) {
List<V> oldValues = getCopy(key);
ListIterator<V> keyValues = new ValueForKeyIterator(key);
Iterator<? extends V> newValues = values.iterator();
@@ -668,7 +638,7 @@
return oldValues;
}
- private List<V> getCopy(@ParametricNullness K key) {
+ private List<V> getCopy(@Nullable Object key) {
return unmodifiableList(Lists.newArrayList(new ValueForKeyIterator(key)));
}
@@ -680,15 +650,8 @@
@CanIgnoreReturnValue
@Override
public List<V> removeAll(@Nullable Object key) {
- /*
- * Safe because all we do is remove values for the key, not add them. (If we wanted to make sure
- * to call getCopy and removeAllNodes only with a true K, then we could check containsKey first.
- * But that check wouldn't eliminate the warnings.)
- */
- @SuppressWarnings({"unchecked", "nullness"})
- K castKey = (K) key;
- List<V> oldValues = getCopy(castKey);
- removeAllNodes(castKey);
+ List<V> oldValues = getCopy(key);
+ removeAllNodes(key);
return oldValues;
}
@@ -713,7 +676,7 @@
* <p>The returned list is not serializable and does not have random access.
*/
@Override
- public List<V> get(@ParametricNullness final K key) {
+ public List<V> get(final @Nullable K key) {
return new AbstractSequentialList<V>() {
@Override
public int size() {
@@ -743,12 +706,12 @@
}
@Override
- public boolean contains(@CheckForNull Object key) { // for performance
+ public boolean contains(Object key) { // for performance
return containsKey(key);
}
@Override
- public boolean remove(@CheckForNull Object o) { // for performance
+ public boolean remove(Object o) { // for performance
return !LinkedListMultimap.this.removeAll(o).isEmpty();
}
}
@@ -787,13 +750,12 @@
final NodeIterator nodeItr = new NodeIterator(index);
return new TransformedListIterator<Entry<K, V>, V>(nodeItr) {
@Override
- @ParametricNullness
V transform(Entry<K, V> entry) {
return entry.getValue();
}
@Override
- public void set(@ParametricNullness V value) {
+ public void set(V value) {
nodeItr.setValue(value);
}
};
diff --git a/guava/src/com/google/common/collect/ListMultimap.java b/guava/src/com/google/common/collect/ListMultimap.java
index 1686068..967c9a0 100644
--- a/guava/src/com/google/common/collect/ListMultimap.java
+++ b/guava/src/com/google/common/collect/ListMultimap.java
@@ -21,7 +21,6 @@
import java.util.Collection;
import java.util.List;
import java.util.Map;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -41,9 +40,7 @@
* @since 2.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-public interface ListMultimap<K extends @Nullable Object, V extends @Nullable Object>
- extends Multimap<K, V> {
+public interface ListMultimap<K, V> extends Multimap<K, V> {
/**
* {@inheritDoc}
*
@@ -52,7 +49,7 @@
* the {@link Multimap} interface.
*/
@Override
- List<V> get(@ParametricNullness K key);
+ List<V> get(@Nullable K key);
/**
* {@inheritDoc}
@@ -63,7 +60,7 @@
*/
@CanIgnoreReturnValue
@Override
- List<V> removeAll(@CheckForNull Object key);
+ List<V> removeAll(@Nullable Object key);
/**
* {@inheritDoc}
@@ -74,7 +71,7 @@
*/
@CanIgnoreReturnValue
@Override
- List<V> replaceValues(@ParametricNullness K key, Iterable<? extends V> values);
+ List<V> replaceValues(K key, Iterable<? extends V> values);
/**
* {@inheritDoc}
@@ -96,5 +93,5 @@
* empty {@code SetMultimap}.
*/
@Override
- boolean equals(@CheckForNull 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 31d6e2a..3882493 100644
--- a/guava/src/com/google/common/collect/Lists.java
+++ b/guava/src/com/google/common/collect/Lists.java
@@ -49,7 +49,6 @@
import java.util.RandomAccess;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.function.Predicate;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -65,7 +64,6 @@
* @since 2.0
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
public final class Lists {
private Lists() {}
@@ -81,7 +79,7 @@
* directly, taking advantage of the new <a href="http://goo.gl/iz2Wi">"diamond" syntax</a>.
*/
@GwtCompatible(serializable = true)
- public static <E extends @Nullable Object> ArrayList<E> newArrayList() {
+ public static <E> ArrayList<E> newArrayList() {
return new ArrayList<>();
}
@@ -101,7 +99,7 @@
*/
@SafeVarargs
@GwtCompatible(serializable = true)
- public static <E extends @Nullable Object> ArrayList<E> newArrayList(E... elements) {
+ public static <E> ArrayList<E> newArrayList(E... elements) {
checkNotNull(elements); // for GWT
// Avoid integer overflow when a large array is passed in
int capacity = computeArrayListCapacity(elements.length);
@@ -124,8 +122,7 @@
* syntax</a>.
*/
@GwtCompatible(serializable = true)
- public static <E extends @Nullable Object> ArrayList<E> newArrayList(
- Iterable<? extends E> elements) {
+ public static <E> ArrayList<E> newArrayList(Iterable<? extends E> elements) {
checkNotNull(elements); // for GWT
// Let ArrayList's sizing logic work, if possible
return (elements instanceof Collection)
@@ -141,8 +138,7 @@
* ImmutableList#copyOf(Iterator)} instead.
*/
@GwtCompatible(serializable = true)
- public static <E extends @Nullable Object> ArrayList<E> newArrayList(
- Iterator<? extends E> elements) {
+ public static <E> ArrayList<E> newArrayList(Iterator<? extends E> elements) {
ArrayList<E> list = newArrayList();
Iterators.addAll(list, elements);
return list;
@@ -173,8 +169,7 @@
* @throws IllegalArgumentException if {@code initialArraySize} is negative
*/
@GwtCompatible(serializable = true)
- public static <E extends @Nullable Object> ArrayList<E> newArrayListWithCapacity(
- int initialArraySize) {
+ public static <E> ArrayList<E> newArrayListWithCapacity(int initialArraySize) {
checkNonnegative(initialArraySize, "initialArraySize"); // for GWT.
return new ArrayList<>(initialArraySize);
}
@@ -193,8 +188,7 @@
* @throws IllegalArgumentException if {@code estimatedSize} is negative
*/
@GwtCompatible(serializable = true)
- public static <E extends @Nullable Object> ArrayList<E> newArrayListWithExpectedSize(
- int estimatedSize) {
+ public static <E> ArrayList<E> newArrayListWithExpectedSize(int estimatedSize) {
return new ArrayList<>(computeArrayListCapacity(estimatedSize));
}
@@ -216,7 +210,7 @@
* syntax</a>.
*/
@GwtCompatible(serializable = true)
- public static <E extends @Nullable Object> LinkedList<E> newLinkedList() {
+ public static <E> LinkedList<E> newLinkedList() {
return new LinkedList<>();
}
@@ -238,8 +232,7 @@
* syntax</a>.
*/
@GwtCompatible(serializable = true)
- public static <E extends @Nullable Object> LinkedList<E> newLinkedList(
- Iterable<? extends E> elements) {
+ public static <E> LinkedList<E> newLinkedList(Iterable<? extends E> elements) {
LinkedList<E> list = newLinkedList();
Iterables.addAll(list, elements);
return list;
@@ -255,7 +248,7 @@
* @since 12.0
*/
@GwtIncompatible // CopyOnWriteArrayList
- public static <E extends @Nullable Object> CopyOnWriteArrayList<E> newCopyOnWriteArrayList() {
+ public static <E> CopyOnWriteArrayList<E> newCopyOnWriteArrayList() {
return new CopyOnWriteArrayList<>();
}
@@ -267,7 +260,7 @@
* @since 12.0
*/
@GwtIncompatible // CopyOnWriteArrayList
- public static <E extends @Nullable Object> CopyOnWriteArrayList<E> newCopyOnWriteArrayList(
+ public static <E> CopyOnWriteArrayList<E> newCopyOnWriteArrayList(
Iterable<? extends E> elements) {
// We copy elements to an ArrayList first, rather than incurring the
// quadratic cost of adding them to the COWAL directly.
@@ -292,7 +285,7 @@
* @param rest an array of additional elements, possibly empty
* @return an unmodifiable list containing the specified elements
*/
- public static <E extends @Nullable Object> List<E> asList(@ParametricNullness E first, E[] rest) {
+ public static <E> List<E> asList(@Nullable E first, E[] rest) {
return new OnePlusArrayList<>(first, rest);
}
@@ -312,18 +305,17 @@
* @param rest an array of additional elements, possibly empty
* @return an unmodifiable list containing the specified elements
*/
- public static <E extends @Nullable Object> List<E> asList(
- @ParametricNullness E first, @ParametricNullness E second, E[] rest) {
+ public static <E> List<E> asList(@Nullable E first, @Nullable E second, E[] rest) {
return new TwoPlusArrayList<>(first, second, rest);
}
/** @see Lists#asList(Object, Object[]) */
- private static class OnePlusArrayList<E extends @Nullable Object> extends AbstractList<E>
+ private static class OnePlusArrayList<E> extends AbstractList<E>
implements Serializable, RandomAccess {
- @ParametricNullness final E first;
+ final @Nullable E first;
final E[] rest;
- OnePlusArrayList(@ParametricNullness E first, E[] rest) {
+ OnePlusArrayList(@Nullable E first, E[] rest) {
this.first = first;
this.rest = checkNotNull(rest);
}
@@ -334,7 +326,6 @@
}
@Override
- @ParametricNullness
public E get(int index) {
// check explicitly so the IOOBE will have the right message
checkElementIndex(index, size());
@@ -345,13 +336,13 @@
}
/** @see Lists#asList(Object, Object, Object[]) */
- private static class TwoPlusArrayList<E extends @Nullable Object> extends AbstractList<E>
+ private static class TwoPlusArrayList<E> extends AbstractList<E>
implements Serializable, RandomAccess {
- @ParametricNullness final E first;
- @ParametricNullness final E second;
+ final @Nullable E first;
+ final @Nullable E second;
final E[] rest;
- TwoPlusArrayList(@ParametricNullness E first, @ParametricNullness E second, E[] rest) {
+ TwoPlusArrayList(@Nullable E first, @Nullable E second, E[] rest) {
this.first = first;
this.second = second;
this.rest = checkNotNull(rest);
@@ -363,7 +354,6 @@
}
@Override
- @ParametricNullness
public E get(int index) {
switch (index) {
case 0:
@@ -529,7 +519,7 @@
* java.util.stream.Stream#map}. This method is not being deprecated, but we gently encourage you
* to migrate to streams.
*/
- public static <F extends @Nullable Object, T extends @Nullable Object> List<T> transform(
+ public static <F, T> List<T> transform(
List<F> fromList, Function<? super F, ? extends T> function) {
return (fromList instanceof RandomAccess)
? new TransformingRandomAccessList<>(fromList, function)
@@ -541,9 +531,8 @@
*
* @see Lists#transform
*/
- private static class TransformingSequentialList<
- F extends @Nullable Object, T extends @Nullable Object>
- extends AbstractSequentialList<T> implements Serializable {
+ private static class TransformingSequentialList<F, T> extends AbstractSequentialList<T>
+ implements Serializable {
final List<F> fromList;
final Function<? super F, ? extends T> function;
@@ -570,8 +559,7 @@
public ListIterator<T> listIterator(final int index) {
return new TransformedListIterator<F, T>(fromList.listIterator(index)) {
@Override
- @ParametricNullness
- T transform(@ParametricNullness F from) {
+ T transform(F from) {
return function.apply(from);
}
};
@@ -593,9 +581,8 @@
*
* @see Lists#transform
*/
- private static class TransformingRandomAccessList<
- F extends @Nullable Object, T extends @Nullable Object>
- extends AbstractList<T> implements RandomAccess, Serializable {
+ private static class TransformingRandomAccessList<F, T> extends AbstractList<T>
+ implements RandomAccess, Serializable {
final List<F> fromList;
final Function<? super F, ? extends T> function;
@@ -610,7 +597,6 @@
}
@Override
- @ParametricNullness
public T get(int index) {
return function.apply(fromList.get(index));
}
@@ -642,7 +628,6 @@
}
@Override
- @ParametricNullness
public T remove(int index) {
return function.apply(fromList.remove(index));
}
@@ -670,7 +655,7 @@
* @return a list of consecutive sublists
* @throws IllegalArgumentException if {@code partitionSize} is nonpositive
*/
- public static <T extends @Nullable Object> List<List<T>> partition(List<T> list, int size) {
+ public static <T> List<List<T>> partition(List<T> list, int size) {
checkNotNull(list);
checkArgument(size > 0);
return (list instanceof RandomAccess)
@@ -678,7 +663,7 @@
: new Partition<>(list, size);
}
- private static class Partition<T extends @Nullable Object> extends AbstractList<List<T>> {
+ private static class Partition<T> extends AbstractList<List<T>> {
final List<T> list;
final int size;
@@ -706,8 +691,7 @@
}
}
- private static class RandomAccessPartition<T extends @Nullable Object> extends Partition<T>
- implements RandomAccess {
+ private static class RandomAccessPartition<T> extends Partition<T> implements RandomAccess {
RandomAccessPartition(List<T> list, int size) {
super(list, size);
}
@@ -746,12 +730,12 @@
}
@Override
- public int indexOf(@CheckForNull Object object) {
+ public int indexOf(@Nullable Object object) {
return (object instanceof Character) ? string.indexOf((Character) object) : -1;
}
@Override
- public int lastIndexOf(@CheckForNull Object object) {
+ public int lastIndexOf(@Nullable Object object) {
return (object instanceof Character) ? string.lastIndexOf((Character) object) : -1;
}
@@ -808,13 +792,9 @@
*
* @since 7.0
*/
- public static <T extends @Nullable Object> List<T> reverse(List<T> list) {
+ public static <T> List<T> reverse(List<T> list) {
if (list instanceof ImmutableList) {
- // Avoid nullness warnings.
- List<?> reversed = ((ImmutableList<?>) list).reverse();
- @SuppressWarnings("unchecked")
- List<T> result = (List<T>) reversed;
- return result;
+ return ((ImmutableList<T>) list).reverse();
} else if (list instanceof ReverseList) {
return ((ReverseList<T>) list).getForwardList();
} else if (list instanceof RandomAccess) {
@@ -824,7 +804,7 @@
}
}
- private static class ReverseList<T extends @Nullable Object> extends AbstractList<T> {
+ private static class ReverseList<T> extends AbstractList<T> {
private final List<T> forwardList;
ReverseList(List<T> forwardList) {
@@ -848,7 +828,7 @@
}
@Override
- public void add(int index, @ParametricNullness T element) {
+ public void add(int index, @Nullable T element) {
forwardList.add(reversePosition(index), element);
}
@@ -858,7 +838,6 @@
}
@Override
- @ParametricNullness
public T remove(int index) {
return forwardList.remove(reverseIndex(index));
}
@@ -869,13 +848,11 @@
}
@Override
- @ParametricNullness
- public T set(int index, @ParametricNullness T element) {
+ public T set(int index, @Nullable T element) {
return forwardList.set(reverseIndex(index), element);
}
@Override
- @ParametricNullness
public T get(int index) {
return forwardList.get(reverseIndex(index));
}
@@ -905,7 +882,7 @@
boolean canRemoveOrSet;
@Override
- public void add(@ParametricNullness T e) {
+ public void add(T e) {
forwardIterator.add(e);
forwardIterator.previous();
canRemoveOrSet = false;
@@ -922,7 +899,6 @@
}
@Override
- @ParametricNullness
public T next() {
if (!hasNext()) {
throw new NoSuchElementException();
@@ -937,7 +913,6 @@
}
@Override
- @ParametricNullness
public T previous() {
if (!hasPrevious()) {
throw new NoSuchElementException();
@@ -959,7 +934,7 @@
}
@Override
- public void set(@ParametricNullness T e) {
+ public void set(T e) {
checkState(canRemoveOrSet);
forwardIterator.set(e);
}
@@ -967,8 +942,7 @@
}
}
- private static class RandomAccessReverseList<T extends @Nullable Object> extends ReverseList<T>
- implements RandomAccess {
+ private static class RandomAccessReverseList<T> extends ReverseList<T> implements RandomAccess {
RandomAccessReverseList(List<T> forwardList) {
super(forwardList);
}
@@ -988,7 +962,7 @@
}
/** An implementation of {@link List#equals(Object)}. */
- static boolean equalsImpl(List<?> thisList, @CheckForNull Object other) {
+ static boolean equalsImpl(List<?> thisList, @Nullable Object other) {
if (other == checkNotNull(thisList)) {
return true;
}
@@ -1014,8 +988,7 @@
}
/** An implementation of {@link List#addAll(int, Collection)}. */
- static <E extends @Nullable Object> boolean addAllImpl(
- List<E> list, int index, Iterable<? extends E> elements) {
+ static <E> boolean addAllImpl(List<E> list, int index, Iterable<? extends E> elements) {
boolean changed = false;
ListIterator<E> listIterator = list.listIterator(index);
for (E e : elements) {
@@ -1026,7 +999,7 @@
}
/** An implementation of {@link List#indexOf(Object)}. */
- static int indexOfImpl(List<?> list, @CheckForNull Object element) {
+ static int indexOfImpl(List<?> list, @Nullable Object element) {
if (list instanceof RandomAccess) {
return indexOfRandomAccess(list, element);
} else {
@@ -1040,7 +1013,7 @@
}
}
- private static int indexOfRandomAccess(List<?> list, @CheckForNull 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++) {
@@ -1059,7 +1032,7 @@
}
/** An implementation of {@link List#lastIndexOf(Object)}. */
- static int lastIndexOfImpl(List<?> list, @CheckForNull Object element) {
+ static int lastIndexOfImpl(List<?> list, @Nullable Object element) {
if (list instanceof RandomAccess) {
return lastIndexOfRandomAccess(list, element);
} else {
@@ -1073,7 +1046,7 @@
}
}
- private static int lastIndexOfRandomAccess(List<?> list, @CheckForNull 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) {
@@ -1091,13 +1064,12 @@
}
/** Returns an implementation of {@link List#listIterator(int)}. */
- static <E extends @Nullable Object> ListIterator<E> listIteratorImpl(List<E> list, int index) {
+ static <E> ListIterator<E> listIteratorImpl(List<E> list, int index) {
return new AbstractListWrapper<>(list).listIterator(index);
}
/** An implementation of {@link List#subList(int, int)}. */
- static <E extends @Nullable Object> List<E> subListImpl(
- final List<E> list, int fromIndex, int toIndex) {
+ static <E> List<E> subListImpl(final List<E> list, int fromIndex, int toIndex) {
List<E> wrapper;
if (list instanceof RandomAccess) {
wrapper =
@@ -1123,7 +1095,7 @@
return wrapper.subList(fromIndex, toIndex);
}
- private static class AbstractListWrapper<E extends @Nullable Object> extends AbstractList<E> {
+ private static class AbstractListWrapper<E> extends AbstractList<E> {
final List<E> backingList;
AbstractListWrapper(List<E> backingList) {
@@ -1131,7 +1103,7 @@
}
@Override
- public void add(int index, @ParametricNullness E element) {
+ public void add(int index, E element) {
backingList.add(index, element);
}
@@ -1141,25 +1113,22 @@
}
@Override
- @ParametricNullness
public E get(int index) {
return backingList.get(index);
}
@Override
- @ParametricNullness
public E remove(int index) {
return backingList.remove(index);
}
@Override
- @ParametricNullness
- public E set(int index, @ParametricNullness E element) {
+ public E set(int index, E element) {
return backingList.set(index, element);
}
@Override
- public boolean contains(@CheckForNull Object o) {
+ public boolean contains(Object o) {
return backingList.contains(o);
}
@@ -1169,15 +1138,15 @@
}
}
- private static class RandomAccessListWrapper<E extends @Nullable Object>
- extends AbstractListWrapper<E> implements RandomAccess {
+ private static class RandomAccessListWrapper<E> extends AbstractListWrapper<E>
+ implements RandomAccess {
RandomAccessListWrapper(List<E> backingList) {
super(backingList);
}
}
/** Used to avoid http://bugs.sun.com/view_bug.do?bug_id=6558557 */
- static <T extends @Nullable Object> List<T> cast(Iterable<T> iterable) {
+ static <T> List<T> cast(Iterable<T> iterable) {
return (List<T>) iterable;
}
}
diff --git a/guava/src/com/google/common/collect/MapDifference.java b/guava/src/com/google/common/collect/MapDifference.java
index 5000e4b..066aebf 100644
--- a/guava/src/com/google/common/collect/MapDifference.java
+++ b/guava/src/com/google/common/collect/MapDifference.java
@@ -19,7 +19,6 @@
import com.google.common.annotations.GwtCompatible;
import com.google.errorprone.annotations.DoNotMock;
import java.util.Map;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -30,8 +29,7 @@
*/
@DoNotMock("Use Maps.difference")
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-public interface MapDifference<K extends @Nullable Object, V extends @Nullable Object> {
+public interface MapDifference<K, V> {
/**
* Returns {@code true} if there are no differences between the two maps; that is, if the maps are
* equal.
@@ -69,7 +67,7 @@
* #entriesDiffering()} of the two instances are equal.
*/
@Override
- boolean equals(@CheckForNull Object object);
+ boolean equals(@Nullable Object object);
/**
* Returns the hash code for this instance. This is defined as the hash code of
@@ -89,13 +87,11 @@
* @since 2.0
*/
@DoNotMock("Use Maps.difference")
- interface ValueDifference<V extends @Nullable Object> {
+ interface ValueDifference<V> {
/** Returns the value from the left map (possibly null). */
- @ParametricNullness
V leftValue();
/** Returns the value from the right map (possibly null). */
- @ParametricNullness
V rightValue();
/**
@@ -103,7 +99,7 @@
* {@link #rightValue()} values are also equal.
*/
@Override
- boolean equals(@CheckForNull 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/MapMaker.java b/guava/src/com/google/common/collect/MapMaker.java
index a2612c1..1cbe4a4 100644
--- a/guava/src/com/google/common/collect/MapMaker.java
+++ b/guava/src/com/google/common/collect/MapMaker.java
@@ -30,7 +30,7 @@
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* A builder of {@link ConcurrentMap} instances that can have keys or values automatically wrapped
@@ -86,7 +86,6 @@
* @since 2.0
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
public final class MapMaker {
private static final int DEFAULT_INITIAL_CAPACITY = 16;
private static final int DEFAULT_CONCURRENCY_LEVEL = 4;
@@ -99,10 +98,10 @@
int initialCapacity = UNSET_INT;
int concurrencyLevel = UNSET_INT;
- @CheckForNull Strength keyStrength;
- @CheckForNull Strength valueStrength;
+ @Nullable Strength keyStrength;
+ @Nullable Strength valueStrength;
- @CheckForNull Equivalence<Object> keyEquivalence;
+ @Nullable Equivalence<Object> keyEquivalence;
/**
* Constructs a new {@code MapMaker} instance with default settings, including strong keys, strong
diff --git a/guava/src/com/google/common/collect/MapMakerInternalMap.java b/guava/src/com/google/common/collect/MapMakerInternalMap.java
index 3725d97..b647f76 100644
--- a/guava/src/com/google/common/collect/MapMakerInternalMap.java
+++ b/guava/src/com/google/common/collect/MapMakerInternalMap.java
@@ -65,11 +65,7 @@
*/
// TODO(kak): Consider removing @CanIgnoreReturnValue from this class.
@GwtIncompatible
-@SuppressWarnings({
- "GuardedBy", // TODO(b/35466881): Fix or suppress.
- "nullness", // too much trouble for the payoff
-})
-// TODO(cpovirk): Annotate for nullness.
+@SuppressWarnings("GuardedBy") // TODO(b/35466881): Fix or suppress.
class MapMakerInternalMap<
K,
V,
diff --git a/guava/src/com/google/common/collect/Maps.java b/guava/src/com/google/common/collect/Maps.java
index c892557..3dad657 100644
--- a/guava/src/com/google/common/collect/Maps.java
+++ b/guava/src/com/google/common/collect/Maps.java
@@ -21,8 +21,6 @@
import static com.google.common.base.Predicates.compose;
import static com.google.common.collect.CollectPreconditions.checkEntryNotNull;
import static com.google.common.collect.CollectPreconditions.checkNonnegative;
-import static com.google.common.collect.NullnessCasts.uncheckedCastNullableTToT;
-import static java.util.Objects.requireNonNull;
import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtCompatible;
@@ -70,7 +68,6 @@
import java.util.function.BinaryOperator;
import java.util.function.Consumer;
import java.util.stream.Collector;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -88,53 +85,46 @@
* @since 2.0
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
public final class Maps {
private Maps() {}
- private enum EntryFunction implements Function<Entry<?, ?>, @Nullable Object> {
+ private enum EntryFunction implements Function<Entry<?, ?>, Object> {
KEY {
@Override
- @CheckForNull
- public Object apply(Entry<?, ?> entry) {
+ public @Nullable Object apply(Entry<?, ?> entry) {
return entry.getKey();
}
},
VALUE {
@Override
- @CheckForNull
- public Object apply(Entry<?, ?> entry) {
+ public @Nullable Object apply(Entry<?, ?> entry) {
return entry.getValue();
}
};
}
@SuppressWarnings("unchecked")
- static <K extends @Nullable Object> Function<Entry<K, ?>, K> keyFunction() {
+ static <K> Function<Entry<K, ?>, K> keyFunction() {
return (Function) EntryFunction.KEY;
}
@SuppressWarnings("unchecked")
- static <V extends @Nullable Object> Function<Entry<?, V>, V> valueFunction() {
+ static <V> Function<Entry<?, V>, V> valueFunction() {
return (Function) EntryFunction.VALUE;
}
- static <K extends @Nullable Object, V extends @Nullable Object> Iterator<K> keyIterator(
- Iterator<Entry<K, V>> entryIterator) {
+ static <K, V> Iterator<K> keyIterator(Iterator<Entry<K, V>> entryIterator) {
return new TransformedIterator<Entry<K, V>, K>(entryIterator) {
@Override
- @ParametricNullness
K transform(Entry<K, V> entry) {
return entry.getKey();
}
};
}
- static <K extends @Nullable Object, V extends @Nullable Object> Iterator<V> valueIterator(
- Iterator<Entry<K, V>> entryIterator) {
+ static <K, V> Iterator<V> valueIterator(Iterator<Entry<K, V>> entryIterator) {
return new TransformedIterator<Entry<K, V>, V>(entryIterator) {
@Override
- @ParametricNullness
V transform(Entry<K, V> entry) {
return entry.getValue();
}
@@ -181,6 +171,37 @@
return ImmutableEnumMap.asImmutable(enumMap);
}
+ private static class Accumulator<K extends Enum<K>, V> {
+ private final BinaryOperator<V> mergeFunction;
+ private EnumMap<K, V> map = null;
+
+ Accumulator(BinaryOperator<V> mergeFunction) {
+ this.mergeFunction = mergeFunction;
+ }
+
+ void put(K key, V value) {
+ if (map == null) {
+ map = new EnumMap<>(key.getDeclaringClass());
+ }
+ map.merge(key, value, mergeFunction);
+ }
+
+ Accumulator<K, V> combine(Accumulator<K, V> other) {
+ if (this.map == null) {
+ return other;
+ } else if (other.map == null) {
+ return this;
+ } else {
+ other.map.forEach(this::put);
+ return this;
+ }
+ }
+
+ ImmutableMap<K, V> toImmutableMap() {
+ return (map == null) ? ImmutableMap.<K, V>of() : ImmutableEnumMap.asImmutable(map);
+ }
+ }
+
/**
* Returns a {@link Collector} that accumulates elements into an {@code ImmutableMap} whose keys
* and values are the result of applying the provided mapping functions to the input elements. The
@@ -195,11 +216,25 @@
*
* @since 21.0
*/
- public static <T extends @Nullable Object, K extends Enum<K>, V>
- Collector<T, ?, ImmutableMap<K, V>> toImmutableEnumMap(
- java.util.function.Function<? super T, ? extends K> keyFunction,
- java.util.function.Function<? super T, ? extends V> valueFunction) {
- return CollectCollectors.toImmutableEnumMap(keyFunction, valueFunction);
+ public static <T, K extends Enum<K>, V> Collector<T, ?, ImmutableMap<K, V>> toImmutableEnumMap(
+ java.util.function.Function<? super T, ? extends K> keyFunction,
+ java.util.function.Function<? super T, ? extends V> valueFunction) {
+ checkNotNull(keyFunction);
+ checkNotNull(valueFunction);
+ return Collector.of(
+ () ->
+ new Accumulator<K, V>(
+ (v1, v2) -> {
+ throw new IllegalArgumentException("Multiple values for key: " + v1 + ", " + v2);
+ }),
+ (accum, t) -> {
+ K key = checkNotNull(keyFunction.apply(t), "Null key for input %s", t);
+ V newValue = checkNotNull(valueFunction.apply(t), "Null value for input %s", t);
+ accum.put(key, newValue);
+ },
+ Accumulator::combine,
+ Accumulator::toImmutableMap,
+ Collector.Characteristics.UNORDERED);
}
/**
@@ -213,12 +248,23 @@
*
* @since 21.0
*/
- public static <T extends @Nullable Object, K extends Enum<K>, V>
- Collector<T, ?, ImmutableMap<K, V>> toImmutableEnumMap(
- java.util.function.Function<? super T, ? extends K> keyFunction,
- java.util.function.Function<? super T, ? extends V> valueFunction,
- BinaryOperator<V> mergeFunction) {
- return CollectCollectors.toImmutableEnumMap(keyFunction, valueFunction, mergeFunction);
+ public static <T, K extends Enum<K>, V> Collector<T, ?, ImmutableMap<K, V>> toImmutableEnumMap(
+ java.util.function.Function<? super T, ? extends K> keyFunction,
+ java.util.function.Function<? super T, ? extends V> valueFunction,
+ BinaryOperator<V> mergeFunction) {
+ checkNotNull(keyFunction);
+ checkNotNull(valueFunction);
+ checkNotNull(mergeFunction);
+ // not UNORDERED because we don't know if mergeFunction is commutative
+ return Collector.of(
+ () -> new Accumulator<K, V>(mergeFunction),
+ (accum, t) -> {
+ K key = checkNotNull(keyFunction.apply(t), "Null key for input %s", t);
+ V newValue = checkNotNull(valueFunction.apply(t), "Null value for input %s", t);
+ accum.put(key, newValue);
+ },
+ Accumulator::combine,
+ Accumulator::toImmutableMap);
}
/**
@@ -234,8 +280,7 @@
*
* @return a new, empty {@code HashMap}
*/
- public static <K extends @Nullable Object, V extends @Nullable Object>
- HashMap<K, V> newHashMap() {
+ public static <K, V> HashMap<K, V> newHashMap() {
return new HashMap<>();
}
@@ -253,8 +298,7 @@
* @param map the mappings to be placed in the new map
* @return a new {@code HashMap} initialized with the mappings from {@code map}
*/
- public static <K extends @Nullable Object, V extends @Nullable Object> HashMap<K, V> newHashMap(
- Map<? extends K, ? extends V> map) {
+ public static <K, V> HashMap<K, V> newHashMap(Map<? extends K, ? extends V> map) {
return new HashMap<>(map);
}
@@ -269,8 +313,7 @@
* without resizing
* @throws IllegalArgumentException if {@code expectedSize} is negative
*/
- public static <K extends @Nullable Object, V extends @Nullable Object>
- HashMap<K, V> newHashMapWithExpectedSize(int expectedSize) {
+ public static <K, V> HashMap<K, V> newHashMapWithExpectedSize(int expectedSize) {
return new HashMap<>(capacity(expectedSize));
}
@@ -303,8 +346,7 @@
*
* @return a new, empty {@code LinkedHashMap}
*/
- public static <K extends @Nullable Object, V extends @Nullable Object>
- LinkedHashMap<K, V> newLinkedHashMap() {
+ public static <K, V> LinkedHashMap<K, V> newLinkedHashMap() {
return new LinkedHashMap<>();
}
@@ -321,8 +363,7 @@
* @param map the mappings to be placed in the new map
* @return a new, {@code LinkedHashMap} initialized with the mappings from {@code map}
*/
- public static <K extends @Nullable Object, V extends @Nullable Object>
- LinkedHashMap<K, V> newLinkedHashMap(Map<? extends K, ? extends V> map) {
+ public static <K, V> LinkedHashMap<K, V> newLinkedHashMap(Map<? extends K, ? extends V> map) {
return new LinkedHashMap<>(map);
}
@@ -338,8 +379,7 @@
* @throws IllegalArgumentException if {@code expectedSize} is negative
* @since 19.0
*/
- public static <K extends @Nullable Object, V extends @Nullable Object>
- LinkedHashMap<K, V> newLinkedHashMapWithExpectedSize(int expectedSize) {
+ public static <K, V> LinkedHashMap<K, V> newLinkedHashMapWithExpectedSize(int expectedSize) {
return new LinkedHashMap<>(capacity(expectedSize));
}
@@ -364,7 +404,7 @@
*
* @return a new, empty {@code TreeMap}
*/
- public static <K extends Comparable, V extends @Nullable Object> TreeMap<K, V> newTreeMap() {
+ public static <K extends Comparable, V> TreeMap<K, V> newTreeMap() {
return new TreeMap<>();
}
@@ -384,8 +424,7 @@
* @return a new {@code TreeMap} initialized with the mappings from {@code map} and using the
* comparator of {@code map}
*/
- public static <K extends @Nullable Object, V extends @Nullable Object> TreeMap<K, V> newTreeMap(
- SortedMap<K, ? extends V> map) {
+ public static <K, V> TreeMap<K, V> newTreeMap(SortedMap<K, ? extends V> map) {
return new TreeMap<>(map);
}
@@ -402,8 +441,7 @@
* @param comparator the comparator to sort the keys with
* @return a new, empty {@code TreeMap}
*/
- public static <C extends @Nullable Object, K extends C, V extends @Nullable Object>
- TreeMap<K, V> newTreeMap(@CheckForNull Comparator<C> comparator) {
+ public static <C, K extends C, V> TreeMap<K, V> newTreeMap(@Nullable Comparator<C> 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:
@@ -418,8 +456,7 @@
* @param type the key type for this map
* @return a new, empty {@code EnumMap}
*/
- public static <K extends Enum<K>, V extends @Nullable Object> EnumMap<K, V> newEnumMap(
- Class<K> type) {
+ public static <K extends Enum<K>, V> EnumMap<K, V> newEnumMap(Class<K> type) {
return new EnumMap<>(checkNotNull(type));
}
@@ -435,8 +472,7 @@
* @throws IllegalArgumentException if {@code m} is not an {@code EnumMap} instance and contains
* no mappings
*/
- public static <K extends Enum<K>, V extends @Nullable Object> EnumMap<K, V> newEnumMap(
- Map<K, ? extends V> map) {
+ public static <K extends Enum<K>, V> EnumMap<K, V> newEnumMap(Map<K, ? extends V> map) {
return new EnumMap<>(map);
}
@@ -449,8 +485,7 @@
*
* @return a new, empty {@code IdentityHashMap}
*/
- public static <K extends @Nullable Object, V extends @Nullable Object>
- IdentityHashMap<K, V> newIdentityHashMap() {
+ public static <K, V> IdentityHashMap<K, V> newIdentityHashMap() {
return new IdentityHashMap<>();
}
@@ -470,27 +505,13 @@
* @return the difference between the two maps
*/
@SuppressWarnings("unchecked")
- public static <K extends @Nullable Object, V extends @Nullable Object>
- MapDifference<K, V> difference(
- Map<? extends K, ? extends V> left, Map<? extends K, ? extends V> right) {
+ public static <K, V> MapDifference<K, V> difference(
+ Map<? extends K, ? extends V> left, Map<? extends K, ? extends V> right) {
if (left instanceof SortedMap) {
SortedMap<K, ? extends V> sortedLeft = (SortedMap<K, ? extends V>) left;
return difference(sortedLeft, right);
}
- /*
- * This cast is safe: The Equivalence-accepting overload of difference() (which we call below)
- * has a weird signature because Equivalence is itself a little weird. Still, we know that
- * Equivalence.equals() can handle all inputs, and we know that the resulting MapDifference will
- * contain only Ks and Vs (as opposed to possibly containing @Nullable objects even when K and V
- * are *not* @Nullable).
- *
- * An alternative to suppressing the warning would be to inline the body of the other
- * difference() method into this one.
- */
- @SuppressWarnings("nullness")
- MapDifference<K, V> result =
- (MapDifference<K, V>) difference(left, right, Equivalence.equals());
- return result;
+ return difference(left, right, Equivalence.equals());
}
/**
@@ -507,33 +528,7 @@
* @return the difference between the two maps
* @since 10.0
*/
- /*
- * This method should really be annotated to accept maps with @Nullable value types. Fortunately,
- * no existing Google callers appear to pass null values (much less pass null values *and* run a
- * nullness checker).
- *
- * Still, if we decide that we want to make that work, we'd need to introduce a new type parameter
- * for the Equivalence input type:
- *
- * <E, K extends @Nullable Object, V extends @Nullable E> ... difference(..., Equivalence<E> ...)
- *
- * Maybe we should, even though it will break source compatibility.
- *
- * Alternatively, this is a case in which it would be useful to be able to express Equivalence<?
- * super @Nonnull T>).
- *
- * As things stand now, though, we have to either:
- *
- * - require non-null inputs so that we can guarantee non-null outputs
- *
- * - accept nullable inputs but force users to cope with nullable outputs
- *
- * And the non-null option is far more useful to existing users.
- *
- * (Vaguely related: Another thing we could consider is an overload that accepts a BiPredicate:
- * https://github.com/google/guava/issues/3913)
- */
- public static <K extends @Nullable Object, V> MapDifference<K, V> difference(
+ public static <K, V> MapDifference<K, V> difference(
Map<? extends K, ? extends V> left,
Map<? extends K, ? extends V> right,
Equivalence<? super V> valueEquivalence) {
@@ -564,9 +559,8 @@
* @return the difference between the two maps
* @since 11.0
*/
- public static <K extends @Nullable Object, V extends @Nullable Object>
- SortedMapDifference<K, V> difference(
- SortedMap<K, ? extends V> left, Map<? extends K, ? extends V> right) {
+ public static <K, V> SortedMapDifference<K, V> difference(
+ SortedMap<K, ? extends V> left, Map<? extends K, ? extends V> right) {
checkNotNull(left);
checkNotNull(right);
Comparator<? super K> comparator = orNaturalOrder(left.comparator());
@@ -579,7 +573,7 @@
return new SortedMapDifferenceImpl<>(onlyOnLeft, onlyOnRight, onBoth, differences);
}
- private static <K extends @Nullable Object, V extends @Nullable Object> void doDifference(
+ private static <K, V> void doDifference(
Map<? extends K, ? extends V> left,
Map<? extends K, ? extends V> right,
Equivalence<? super V> valueEquivalence,
@@ -591,17 +585,7 @@
K leftKey = entry.getKey();
V leftValue = entry.getValue();
if (right.containsKey(leftKey)) {
- /*
- * The cast is safe because onlyOnRight contains all the keys of right.
- *
- * TODO(cpovirk): Consider checking onlyOnRight.containsKey instead of right.containsKey.
- * That could change behavior if the input maps use different equivalence relations (and so
- * a key that appears once in `right` might appear multiple times in `left`). We don't
- * guarantee behavior in that case, anyway, and the current behavior is likely undesirable.
- * So that's either a reason to feel free to change it or a reason to not bother thinking
- * further about this.
- */
- V rightValue = uncheckedCastNullableTToT(onlyOnRight.remove(leftKey));
+ V rightValue = onlyOnRight.remove(leftKey);
if (valueEquivalence.equivalent(leftValue, rightValue)) {
onBoth.put(leftKey, leftValue);
} else {
@@ -613,8 +597,7 @@
}
}
- private static <K extends @Nullable Object, V extends @Nullable Object> Map<K, V> unmodifiableMap(
- Map<K, ? extends V> map) {
+ private static <K, V> Map<K, V> unmodifiableMap(Map<K, ? extends V> map) {
if (map instanceof SortedMap) {
return Collections.unmodifiableSortedMap((SortedMap<K, ? extends V>) map);
} else {
@@ -622,8 +605,7 @@
}
}
- static class MapDifferenceImpl<K extends @Nullable Object, V extends @Nullable Object>
- implements MapDifference<K, V> {
+ static class MapDifferenceImpl<K, V> implements MapDifference<K, V> {
final Map<K, V> onlyOnLeft;
final Map<K, V> onlyOnRight;
final Map<K, V> onBoth;
@@ -666,7 +648,7 @@
}
@Override
- public boolean equals(@CheckForNull Object object) {
+ public boolean equals(Object object) {
if (object == this) {
return true;
}
@@ -706,35 +688,31 @@
}
}
- static class ValueDifferenceImpl<V extends @Nullable Object>
- implements MapDifference.ValueDifference<V> {
- @ParametricNullness private final V left;
- @ParametricNullness private final V right;
+ static class ValueDifferenceImpl<V> implements MapDifference.ValueDifference<V> {
+ private final @Nullable V left;
+ private final @Nullable V right;
- static <V extends @Nullable Object> ValueDifference<V> create(
- @ParametricNullness V left, @ParametricNullness V right) {
+ static <V> ValueDifference<V> create(@Nullable V left, @Nullable V right) {
return new ValueDifferenceImpl<V>(left, right);
}
- private ValueDifferenceImpl(@ParametricNullness V left, @ParametricNullness V right) {
+ private ValueDifferenceImpl(@Nullable V left, @Nullable V right) {
this.left = left;
this.right = right;
}
@Override
- @ParametricNullness
public V leftValue() {
return left;
}
@Override
- @ParametricNullness
public V rightValue() {
return right;
}
@Override
- public boolean equals(@CheckForNull 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())
@@ -754,8 +732,8 @@
}
}
- static class SortedMapDifferenceImpl<K extends @Nullable Object, V extends @Nullable Object>
- extends MapDifferenceImpl<K, V> implements SortedMapDifference<K, V> {
+ static class SortedMapDifferenceImpl<K, V> extends MapDifferenceImpl<K, V>
+ implements SortedMapDifference<K, V> {
SortedMapDifferenceImpl(
SortedMap<K, V> onlyOnLeft,
SortedMap<K, V> onlyOnRight,
@@ -791,8 +769,7 @@
* ugly type-casting in one place.
*/
@SuppressWarnings("unchecked")
- static <E extends @Nullable Object> Comparator<? super E> orNaturalOrder(
- @CheckForNull Comparator<? super E> comparator) {
+ static <E> Comparator<? super E> orNaturalOrder(@Nullable Comparator<? super E> comparator) {
if (comparator != null) { // can't use ? : because of javac bug 5080917
return comparator;
}
@@ -823,8 +800,7 @@
*
* @since 14.0
*/
- public static <K extends @Nullable Object, V extends @Nullable Object> Map<K, V> asMap(
- Set<K> set, Function<? super K, V> function) {
+ public static <K, V> Map<K, V> asMap(Set<K> set, Function<? super K, V> function) {
return new AsMapView<>(set, function);
}
@@ -851,8 +827,7 @@
*
* @since 14.0
*/
- public static <K extends @Nullable Object, V extends @Nullable Object> SortedMap<K, V> asMap(
- SortedSet<K> set, Function<? super K, V> function) {
+ public static <K, V> SortedMap<K, V> asMap(SortedSet<K> set, Function<? super K, V> function) {
return new SortedAsMapView<>(set, function);
}
@@ -880,13 +855,12 @@
* @since 14.0
*/
@GwtIncompatible // NavigableMap
- public static <K extends @Nullable Object, V extends @Nullable Object> NavigableMap<K, V> asMap(
+ public static <K, V> NavigableMap<K, V> asMap(
NavigableSet<K> set, Function<? super K, V> function) {
return new NavigableAsMapView<>(set, function);
}
- private static class AsMapView<K extends @Nullable Object, V extends @Nullable Object>
- extends ViewCachingAbstractMap<K, V> {
+ private static class AsMapView<K, V> extends ViewCachingAbstractMap<K, V> {
private final Set<K> set;
final Function<? super K, V> function;
@@ -916,19 +890,17 @@
}
@Override
- public boolean containsKey(@CheckForNull Object key) {
+ public boolean containsKey(@Nullable Object key) {
return backingSet().contains(key);
}
@Override
- @CheckForNull
- public V get(@CheckForNull Object key) {
+ public V get(@Nullable Object key) {
return getOrDefault(key, null);
}
@Override
- @CheckForNull
- public V getOrDefault(@CheckForNull Object key, @CheckForNull 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;
@@ -939,8 +911,7 @@
}
@Override
- @CheckForNull
- public V remove(@CheckForNull Object key) {
+ public V remove(@Nullable Object key) {
if (backingSet().remove(key)) {
@SuppressWarnings("unchecked") // unsafe, but Javadoc warns about it
K k = (K) key;
@@ -980,18 +951,17 @@
}
}
- static <K extends @Nullable Object, V extends @Nullable Object>
- Iterator<Entry<K, V>> asMapEntryIterator(Set<K> set, final Function<? super K, V> function) {
+ static <K, V> Iterator<Entry<K, V>> asMapEntryIterator(
+ Set<K> set, final Function<? super K, V> function) {
return new TransformedIterator<K, Entry<K, V>>(set.iterator()) {
@Override
- Entry<K, V> transform(@ParametricNullness final K key) {
+ Entry<K, V> transform(final K key) {
return immutableEntry(key, function.apply(key));
}
};
}
- private static class SortedAsMapView<K extends @Nullable Object, V extends @Nullable Object>
- extends AsMapView<K, V> implements SortedMap<K, V> {
+ private static class SortedAsMapView<K, V> extends AsMapView<K, V> implements SortedMap<K, V> {
SortedAsMapView(SortedSet<K> set, Function<? super K, V> function) {
super(set, function);
@@ -1003,7 +973,6 @@
}
@Override
- @CheckForNull
public Comparator<? super K> comparator() {
return backingSet().comparator();
}
@@ -1014,37 +983,33 @@
}
@Override
- public SortedMap<K, V> subMap(@ParametricNullness K fromKey, @ParametricNullness K toKey) {
+ public SortedMap<K, V> subMap(K fromKey, K toKey) {
return asMap(backingSet().subSet(fromKey, toKey), function);
}
@Override
- public SortedMap<K, V> headMap(@ParametricNullness K toKey) {
+ public SortedMap<K, V> headMap(K toKey) {
return asMap(backingSet().headSet(toKey), function);
}
@Override
- public SortedMap<K, V> tailMap(@ParametricNullness K fromKey) {
+ public SortedMap<K, V> tailMap(K fromKey) {
return asMap(backingSet().tailSet(fromKey), function);
}
@Override
- @ParametricNullness
public K firstKey() {
return backingSet().first();
}
@Override
- @ParametricNullness
public K lastKey() {
return backingSet().last();
}
}
@GwtIncompatible // NavigableMap
- private static final class NavigableAsMapView<
- K extends @Nullable Object, V extends @Nullable Object>
- extends AbstractNavigableMap<K, V> {
+ private static final class NavigableAsMapView<K, V> extends AbstractNavigableMap<K, V> {
/*
* Using AbstractNavigableMap is simpler than extending SortedAsMapView and rewriting all the
* NavigableMap methods.
@@ -1060,38 +1025,32 @@
@Override
public NavigableMap<K, V> subMap(
- @ParametricNullness K fromKey,
- boolean fromInclusive,
- @ParametricNullness K toKey,
- boolean toInclusive) {
+ K fromKey, boolean fromInclusive, K toKey, boolean toInclusive) {
return asMap(set.subSet(fromKey, fromInclusive, toKey, toInclusive), function);
}
@Override
- public NavigableMap<K, V> headMap(@ParametricNullness K toKey, boolean inclusive) {
+ public NavigableMap<K, V> headMap(K toKey, boolean inclusive) {
return asMap(set.headSet(toKey, inclusive), function);
}
@Override
- public NavigableMap<K, V> tailMap(@ParametricNullness K fromKey, boolean inclusive) {
+ public NavigableMap<K, V> tailMap(K fromKey, boolean inclusive) {
return asMap(set.tailSet(fromKey, inclusive), function);
}
@Override
- @CheckForNull
public Comparator<? super K> comparator() {
return set.comparator();
}
@Override
- @CheckForNull
- public V get(@CheckForNull Object key) {
+ public @Nullable V get(@Nullable Object key) {
return getOrDefault(key, null);
}
@Override
- @CheckForNull
- public V getOrDefault(@CheckForNull Object key, @CheckForNull V defaultValue) {
+ public @Nullable 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;
@@ -1142,7 +1101,7 @@
}
}
- private static <E extends @Nullable Object> Set<E> removeOnlySet(final Set<E> set) {
+ private static <E> Set<E> removeOnlySet(final Set<E> set) {
return new ForwardingSet<E>() {
@Override
protected Set<E> delegate() {
@@ -1150,7 +1109,7 @@
}
@Override
- public boolean add(@ParametricNullness E element) {
+ public boolean add(E element) {
throw new UnsupportedOperationException();
}
@@ -1161,8 +1120,7 @@
};
}
- private static <E extends @Nullable Object> SortedSet<E> removeOnlySortedSet(
- final SortedSet<E> set) {
+ private static <E> SortedSet<E> removeOnlySortedSet(final SortedSet<E> set) {
return new ForwardingSortedSet<E>() {
@Override
protected SortedSet<E> delegate() {
@@ -1170,7 +1128,7 @@
}
@Override
- public boolean add(@ParametricNullness E element) {
+ public boolean add(E element) {
throw new UnsupportedOperationException();
}
@@ -1180,26 +1138,24 @@
}
@Override
- public SortedSet<E> headSet(@ParametricNullness E toElement) {
+ public SortedSet<E> headSet(E toElement) {
return removeOnlySortedSet(super.headSet(toElement));
}
@Override
- public SortedSet<E> subSet(
- @ParametricNullness E fromElement, @ParametricNullness E toElement) {
+ public SortedSet<E> subSet(E fromElement, E toElement) {
return removeOnlySortedSet(super.subSet(fromElement, toElement));
}
@Override
- public SortedSet<E> tailSet(@ParametricNullness E fromElement) {
+ public SortedSet<E> tailSet(E fromElement) {
return removeOnlySortedSet(super.tailSet(fromElement));
}
};
}
@GwtIncompatible // NavigableSet
- private static <E extends @Nullable Object> NavigableSet<E> removeOnlyNavigableSet(
- final NavigableSet<E> set) {
+ private static <E> NavigableSet<E> removeOnlyNavigableSet(final NavigableSet<E> set) {
return new ForwardingNavigableSet<E>() {
@Override
protected NavigableSet<E> delegate() {
@@ -1207,7 +1163,7 @@
}
@Override
- public boolean add(@ParametricNullness E element) {
+ public boolean add(E element) {
throw new UnsupportedOperationException();
}
@@ -1217,38 +1173,34 @@
}
@Override
- public SortedSet<E> headSet(@ParametricNullness E toElement) {
+ public SortedSet<E> headSet(E toElement) {
return removeOnlySortedSet(super.headSet(toElement));
}
@Override
- public NavigableSet<E> headSet(@ParametricNullness E toElement, boolean inclusive) {
+ public NavigableSet<E> headSet(E toElement, boolean inclusive) {
return removeOnlyNavigableSet(super.headSet(toElement, inclusive));
}
@Override
- public SortedSet<E> subSet(
- @ParametricNullness E fromElement, @ParametricNullness E toElement) {
+ public SortedSet<E> subSet(E fromElement, E toElement) {
return removeOnlySortedSet(super.subSet(fromElement, toElement));
}
@Override
public NavigableSet<E> subSet(
- @ParametricNullness E fromElement,
- boolean fromInclusive,
- @ParametricNullness E toElement,
- boolean toInclusive) {
+ E fromElement, boolean fromInclusive, E toElement, boolean toInclusive) {
return removeOnlyNavigableSet(
super.subSet(fromElement, fromInclusive, toElement, toInclusive));
}
@Override
- public SortedSet<E> tailSet(@ParametricNullness E fromElement) {
+ public SortedSet<E> tailSet(E fromElement) {
return removeOnlySortedSet(super.tailSet(fromElement));
}
@Override
- public NavigableSet<E> tailSet(@ParametricNullness E fromElement, boolean inclusive) {
+ public NavigableSet<E> tailSet(E fromElement, boolean inclusive) {
return removeOnlyNavigableSet(super.tailSet(fromElement, inclusive));
}
@@ -1394,42 +1346,16 @@
*
* @param properties a {@code Properties} object to be converted
* @return an immutable map containing all the entries in {@code properties}
- * @throws ClassCastException if any key in {@code properties} is not a {@code String}
- * @throws NullPointerException if any key or value in {@code properties} is null
+ * @throws ClassCastException if any key in {@code Properties} is not a {@code String}
+ * @throws NullPointerException if any key or value in {@code Properties} is null
*/
@GwtIncompatible // java.util.Properties
public static ImmutableMap<String, String> fromProperties(Properties properties) {
ImmutableMap.Builder<String, String> builder = ImmutableMap.builder();
for (Enumeration<?> e = properties.propertyNames(); e.hasMoreElements(); ) {
- /*
- * requireNonNull is safe because propertyNames contains only non-null elements.
- *
- * Accordingly, we have it annotated as returning `Enumeration<? extends Object>` in our
- * prototype checker's JDK. However, the checker still sees the return type as plain
- * `Enumeration<?>`, probably because of one of the following two bugs (and maybe those two
- * bugs are themselves just symptoms of the same underlying problem):
- *
- * https://github.com/typetools/checker-framework/issues/3030
- *
- * https://github.com/typetools/checker-framework/issues/3236
- */
- String key = (String) requireNonNull(e.nextElement());
- /*
- * requireNonNull is safe because the key came from propertyNames...
- *
- * ...except that it's possible for users to insert a string key with a non-string value, and
- * in that case, getProperty *will* return null.
- *
- * TODO(b/192002623): Handle that case: Either:
- *
- * - Skip non-string keys and values entirely, as proposed in the linked bug.
- *
- * - Throw ClassCastException instead of NullPointerException, as documented in the current
- * Javadoc. (Note that we can't necessarily "just" change our call to `getProperty` to `get`
- * because `get` does not consult the default properties.)
- */
- builder.put(key, requireNonNull(properties.getProperty(key)));
+ String key = (String) e.nextElement();
+ builder.put(key, properties.getProperty(key));
}
return builder.build();
@@ -1448,8 +1374,7 @@
* @param value the value to be associated with the returned entry
*/
@GwtCompatible(serializable = true)
- public static <K extends @Nullable Object, V extends @Nullable Object> Entry<K, V> immutableEntry(
- @ParametricNullness K key, @ParametricNullness V value) {
+ public static <K, V> Entry<K, V> immutableEntry(@Nullable K key, @Nullable V value) {
return new ImmutableEntry<>(key, value);
}
@@ -1461,8 +1386,7 @@
* @param entrySet the entries for which to return an unmodifiable view
* @return an unmodifiable view of the entries
*/
- static <K extends @Nullable Object, V extends @Nullable Object>
- Set<Entry<K, V>> unmodifiableEntrySet(Set<Entry<K, V>> entrySet) {
+ static <K, V> Set<Entry<K, V>> unmodifiableEntrySet(Set<Entry<K, V>> entrySet) {
return new UnmodifiableEntrySet<>(Collections.unmodifiableSet(entrySet));
}
@@ -1475,27 +1399,23 @@
* @param entry the entry for which to return an unmodifiable view
* @return an unmodifiable view of the entry
*/
- static <K extends @Nullable Object, V extends @Nullable Object> Entry<K, V> unmodifiableEntry(
- final Entry<? extends K, ? extends V> entry) {
+ static <K, V> Entry<K, V> unmodifiableEntry(final Entry<? extends K, ? extends V> entry) {
checkNotNull(entry);
return new AbstractMapEntry<K, V>() {
@Override
- @ParametricNullness
public K getKey() {
return entry.getKey();
}
@Override
- @ParametricNullness
public V getValue() {
return entry.getValue();
}
};
}
- static <K extends @Nullable Object, V extends @Nullable Object>
- UnmodifiableIterator<Entry<K, V>> unmodifiableEntryIterator(
- final Iterator<Entry<K, V>> entryIterator) {
+ static <K, V> UnmodifiableIterator<Entry<K, V>> unmodifiableEntryIterator(
+ final Iterator<Entry<K, V>> entryIterator) {
return new UnmodifiableIterator<Entry<K, V>>() {
@Override
public boolean hasNext() {
@@ -1510,8 +1430,7 @@
}
/** @see Multimaps#unmodifiableEntries */
- static class UnmodifiableEntries<K extends @Nullable Object, V extends @Nullable Object>
- extends ForwardingCollection<Entry<K, V>> {
+ static class UnmodifiableEntries<K, V> extends ForwardingCollection<Entry<K, V>> {
private final Collection<Entry<K, V>> entries;
UnmodifiableEntries(Collection<Entry<K, V>> entries) {
@@ -1532,26 +1451,18 @@
@Override
public Object[] toArray() {
- /*
- * standardToArray returns `@Nullable Object[]` rather than `Object[]` but only because it can
- * be used with collections that may contain null. This collection never contains nulls, so we
- * can treat it as a plain `Object[]`.
- */
- @SuppressWarnings("nullness")
- Object[] result = standardToArray();
- return result;
+ return standardToArray();
}
@Override
- @SuppressWarnings("nullness") // b/192354773 in our checker affects toArray declarations
- public <T extends @Nullable Object> T[] toArray(T[] array) {
+ public <T> T[] toArray(T[] array) {
return standardToArray(array);
}
}
/** @see Maps#unmodifiableEntrySet(Set) */
- static class UnmodifiableEntrySet<K extends @Nullable Object, V extends @Nullable Object>
- extends UnmodifiableEntries<K, V> implements Set<Entry<K, V>> {
+ static class UnmodifiableEntrySet<K, V> extends UnmodifiableEntries<K, V>
+ implements Set<Entry<K, V>> {
UnmodifiableEntrySet(Set<Entry<K, V>> entries) {
super(entries);
}
@@ -1559,7 +1470,7 @@
// See java.util.Collections.UnmodifiableEntrySet for details on attacks.
@Override
- public boolean equals(@CheckForNull Object object) {
+ public boolean equals(@Nullable Object object) {
return Sets.equalsImpl(this, object);
}
@@ -1607,7 +1518,7 @@
}
@Override
- public boolean equals(@CheckForNull Object object) {
+ public boolean equals(@Nullable Object object) {
if (object instanceof BiMapConverter) {
BiMapConverter<?, ?> that = (BiMapConverter<?, ?>) object;
return this.bimap.equals(that.bimap);
@@ -1658,8 +1569,7 @@
* @param bimap the bimap to be wrapped in a synchronized view
* @return a synchronized view of the specified bimap
*/
- public static <K extends @Nullable Object, V extends @Nullable Object>
- BiMap<K, V> synchronizedBiMap(BiMap<K, V> bimap) {
+ public static <K, V> BiMap<K, V> synchronizedBiMap(BiMap<K, V> bimap) {
return Synchronized.biMap(bimap, null);
}
@@ -1674,20 +1584,19 @@
* @param bimap the bimap for which an unmodifiable view is to be returned
* @return an unmodifiable view of the specified bimap
*/
- public static <K extends @Nullable Object, V extends @Nullable Object>
- BiMap<K, V> unmodifiableBiMap(BiMap<? extends K, ? extends V> bimap) {
+ public static <K, V> BiMap<K, V> unmodifiableBiMap(BiMap<? extends K, ? extends V> bimap) {
return new UnmodifiableBiMap<>(bimap, null);
}
/** @see Maps#unmodifiableBiMap(BiMap) */
- private static class UnmodifiableBiMap<K extends @Nullable Object, V extends @Nullable Object>
- extends ForwardingMap<K, V> implements BiMap<K, V>, Serializable {
+ private static class UnmodifiableBiMap<K, V> extends ForwardingMap<K, V>
+ implements BiMap<K, V>, Serializable {
final Map<K, V> unmodifiableMap;
final BiMap<? extends K, ? extends V> delegate;
- @RetainedWith @CheckForNull BiMap<V, K> inverse;
- @CheckForNull transient Set<V> values;
+ @RetainedWith @Nullable BiMap<V, K> inverse;
+ transient @Nullable Set<V> values;
- UnmodifiableBiMap(BiMap<? extends K, ? extends V> delegate, @CheckForNull BiMap<V, K> inverse) {
+ UnmodifiableBiMap(BiMap<? extends K, ? extends V> delegate, @Nullable BiMap<V, K> inverse) {
unmodifiableMap = Collections.unmodifiableMap(delegate);
this.delegate = delegate;
this.inverse = inverse;
@@ -1699,8 +1608,7 @@
}
@Override
- @CheckForNull
- public V forcePut(@ParametricNullness K key, @ParametricNullness V value) {
+ public V forcePut(K key, V value) {
throw new UnsupportedOperationException();
}
@@ -1754,9 +1662,8 @@
* function} should be fast. To avoid lazy evaluation when the returned map doesn't need to be a
* view, copy the returned map into a new map of your choosing.
*/
- public static <
- K extends @Nullable Object, V1 extends @Nullable Object, V2 extends @Nullable Object>
- Map<K, V2> transformValues(Map<K, V1> fromMap, Function<? super V1, V2> function) {
+ public static <K, V1, V2> Map<K, V2> transformValues(
+ Map<K, V1> fromMap, Function<? super V1, V2> function) {
return transformEntries(fromMap, asEntryTransformer(function));
}
@@ -1796,10 +1703,8 @@
*
* @since 11.0
*/
- public static <
- K extends @Nullable Object, V1 extends @Nullable Object, V2 extends @Nullable Object>
- SortedMap<K, V2> transformValues(
- SortedMap<K, V1> fromMap, Function<? super V1, V2> function) {
+ public static <K, V1, V2> SortedMap<K, V2> transformValues(
+ SortedMap<K, V1> fromMap, Function<? super V1, V2> function) {
return transformEntries(fromMap, asEntryTransformer(function));
}
@@ -1842,10 +1747,8 @@
* @since 13.0
*/
@GwtIncompatible // NavigableMap
- public static <
- K extends @Nullable Object, V1 extends @Nullable Object, V2 extends @Nullable Object>
- NavigableMap<K, V2> transformValues(
- NavigableMap<K, V1> fromMap, Function<? super V1, V2> function) {
+ public static <K, V1, V2> NavigableMap<K, V2> transformValues(
+ NavigableMap<K, V1> fromMap, Function<? super V1, V2> function) {
return transformEntries(fromMap, asEntryTransformer(function));
}
@@ -1896,10 +1799,8 @@
*
* @since 7.0
*/
- public static <
- K extends @Nullable Object, V1 extends @Nullable Object, V2 extends @Nullable Object>
- Map<K, V2> transformEntries(
- Map<K, V1> fromMap, EntryTransformer<? super K, ? super V1, V2> transformer) {
+ public static <K, V1, V2> Map<K, V2> transformEntries(
+ Map<K, V1> fromMap, EntryTransformer<? super K, ? super V1, V2> transformer) {
return new TransformedEntriesMap<>(fromMap, transformer);
}
@@ -1950,10 +1851,8 @@
*
* @since 11.0
*/
- public static <
- K extends @Nullable Object, V1 extends @Nullable Object, V2 extends @Nullable Object>
- SortedMap<K, V2> transformEntries(
- SortedMap<K, V1> fromMap, EntryTransformer<? super K, ? super V1, V2> transformer) {
+ public static <K, V1, V2> SortedMap<K, V2> transformEntries(
+ SortedMap<K, V1> fromMap, EntryTransformer<? super K, ? super V1, V2> transformer) {
return new TransformedEntriesSortedMap<>(fromMap, transformer);
}
@@ -2006,10 +1905,8 @@
* @since 13.0
*/
@GwtIncompatible // NavigableMap
- public static <
- K extends @Nullable Object, V1 extends @Nullable Object, V2 extends @Nullable Object>
- NavigableMap<K, V2> transformEntries(
- NavigableMap<K, V1> fromMap, EntryTransformer<? super K, ? super V1, V2> transformer) {
+ public static <K, V1, V2> NavigableMap<K, V2> transformEntries(
+ final NavigableMap<K, V1> fromMap, EntryTransformer<? super K, ? super V1, V2> transformer) {
return new TransformedEntriesNavigableMap<>(fromMap, transformer);
}
@@ -2023,8 +1920,7 @@
* @since 7.0
*/
@FunctionalInterface
- public interface EntryTransformer<
- K extends @Nullable Object, V1 extends @Nullable Object, V2 extends @Nullable Object> {
+ public interface EntryTransformer<K, V1, V2> {
/**
* Determines an output value based on a key-value pair. This method is <i>generally
* expected</i>, but not absolutely required, to have the following properties:
@@ -2039,43 +1935,38 @@
* @throws NullPointerException if the key or value is null and this transformer does not accept
* null arguments
*/
- V2 transformEntry(@ParametricNullness K key, @ParametricNullness V1 value);
+ V2 transformEntry(@Nullable K key, @Nullable V1 value);
}
/** Views a function as an entry transformer that ignores the entry key. */
- static <K extends @Nullable Object, V1 extends @Nullable Object, V2 extends @Nullable Object>
- EntryTransformer<K, V1, V2> asEntryTransformer(final Function<? super V1, V2> function) {
+ static <K, V1, V2> EntryTransformer<K, V1, V2> asEntryTransformer(
+ final Function<? super V1, V2> function) {
checkNotNull(function);
return new EntryTransformer<K, V1, V2>() {
@Override
- @ParametricNullness
- public V2 transformEntry(@ParametricNullness K key, @ParametricNullness V1 value) {
+ public V2 transformEntry(K key, V1 value) {
return function.apply(value);
}
};
}
- static <K extends @Nullable Object, V1 extends @Nullable Object, V2 extends @Nullable Object>
- Function<V1, V2> asValueToValueFunction(
- final EntryTransformer<? super K, V1, V2> transformer, @ParametricNullness final K key) {
+ static <K, V1, V2> Function<V1, V2> asValueToValueFunction(
+ final EntryTransformer<? super K, V1, V2> transformer, final K key) {
checkNotNull(transformer);
return new Function<V1, V2>() {
@Override
- @ParametricNullness
- public V2 apply(@ParametricNullness V1 v1) {
+ public V2 apply(@Nullable V1 v1) {
return transformer.transformEntry(key, v1);
}
};
}
/** Views an entry transformer as a function from {@code Entry} to values. */
- static <K extends @Nullable Object, V1 extends @Nullable Object, V2 extends @Nullable Object>
- Function<Entry<K, V1>, V2> asEntryToValueFunction(
- final EntryTransformer<? super K, ? super V1, V2> transformer) {
+ static <K, V1, V2> Function<Entry<K, V1>, V2> asEntryToValueFunction(
+ final EntryTransformer<? super K, ? super V1, V2> transformer) {
checkNotNull(transformer);
return new Function<Entry<K, V1>, V2>() {
@Override
- @ParametricNullness
public V2 apply(Entry<K, V1> entry) {
return transformer.transformEntry(entry.getKey(), entry.getValue());
}
@@ -2083,20 +1974,17 @@
}
/** Returns a view of an entry transformed by the specified transformer. */
- static <V2 extends @Nullable Object, K extends @Nullable Object, V1 extends @Nullable Object>
- Entry<K, V2> transformEntry(
- final EntryTransformer<? super K, ? super V1, V2> transformer, final Entry<K, V1> entry) {
+ static <V2, K, V1> Entry<K, V2> transformEntry(
+ final EntryTransformer<? super K, ? super V1, V2> transformer, final Entry<K, V1> entry) {
checkNotNull(transformer);
checkNotNull(entry);
return new AbstractMapEntry<K, V2>() {
@Override
- @ParametricNullness
public K getKey() {
return entry.getKey();
}
@Override
- @ParametricNullness
public V2 getValue() {
return transformer.transformEntry(entry.getKey(), entry.getValue());
}
@@ -2104,9 +1992,8 @@
}
/** Views an entry transformer as a function from entries to entries. */
- static <K extends @Nullable Object, V1 extends @Nullable Object, V2 extends @Nullable Object>
- Function<Entry<K, V1>, Entry<K, V2>> asEntryToEntryFunction(
- final EntryTransformer<? super K, ? super V1, V2> transformer) {
+ static <K, V1, V2> Function<Entry<K, V1>, Entry<K, V2>> asEntryToEntryFunction(
+ final EntryTransformer<? super K, ? super V1, V2> transformer) {
checkNotNull(transformer);
return new Function<Entry<K, V1>, Entry<K, V2>>() {
@Override
@@ -2116,9 +2003,7 @@
};
}
- static class TransformedEntriesMap<
- K extends @Nullable Object, V1 extends @Nullable Object, V2 extends @Nullable Object>
- extends IteratorBasedAbstractMap<K, V2> {
+ static class TransformedEntriesMap<K, V1, V2> extends IteratorBasedAbstractMap<K, V2> {
final Map<K, V1> fromMap;
final EntryTransformer<? super K, ? super V1, V2> transformer;
@@ -2134,37 +2019,31 @@
}
@Override
- public boolean containsKey(@CheckForNull Object key) {
+ public boolean containsKey(Object key) {
return fromMap.containsKey(key);
}
@Override
- @CheckForNull
- public V2 get(@CheckForNull Object key) {
+ public @Nullable V2 get(@Nullable Object key) {
return getOrDefault(key, null);
}
// safe as long as the user followed the <b>Warning</b> in the javadoc
@SuppressWarnings("unchecked")
@Override
- @CheckForNull
- public V2 getOrDefault(@CheckForNull Object key, @CheckForNull V2 defaultValue) {
+ public @Nullable V2 getOrDefault(@Nullable Object key, @Nullable V2 defaultValue) {
V1 value = fromMap.get(key);
- if (value != null || fromMap.containsKey(key)) {
- // The cast is safe because of the containsKey check.
- return transformer.transformEntry((K) key, uncheckedCastNullableTToT(value));
- }
- return defaultValue;
+ return (value != null || fromMap.containsKey(key))
+ ? transformer.transformEntry((K) key, value)
+ : defaultValue;
}
// safe as long as the user followed the <b>Warning</b> in the javadoc
@SuppressWarnings("unchecked")
@Override
- @CheckForNull
- public V2 remove(@CheckForNull Object key) {
+ public V2 remove(Object key) {
return fromMap.containsKey(key)
- // The cast is safe because of the containsKey check.
- ? transformer.transformEntry((K) key, uncheckedCastNullableTToT(fromMap.remove(key)))
+ ? transformer.transformEntry((K) key, fromMap.remove(key))
: null;
}
@@ -2203,9 +2082,8 @@
}
}
- static class TransformedEntriesSortedMap<
- K extends @Nullable Object, V1 extends @Nullable Object, V2 extends @Nullable Object>
- extends TransformedEntriesMap<K, V1, V2> implements SortedMap<K, V2> {
+ static class TransformedEntriesSortedMap<K, V1, V2> extends TransformedEntriesMap<K, V1, V2>
+ implements SortedMap<K, V2> {
protected SortedMap<K, V1> fromMap() {
return (SortedMap<K, V1>) fromMap;
@@ -2217,42 +2095,38 @@
}
@Override
- @CheckForNull
public Comparator<? super K> comparator() {
return fromMap().comparator();
}
@Override
- @ParametricNullness
public K firstKey() {
return fromMap().firstKey();
}
@Override
- public SortedMap<K, V2> headMap(@ParametricNullness K toKey) {
+ public SortedMap<K, V2> headMap(K toKey) {
return transformEntries(fromMap().headMap(toKey), transformer);
}
@Override
- @ParametricNullness
public K lastKey() {
return fromMap().lastKey();
}
@Override
- public SortedMap<K, V2> subMap(@ParametricNullness K fromKey, @ParametricNullness K toKey) {
+ public SortedMap<K, V2> subMap(K fromKey, K toKey) {
return transformEntries(fromMap().subMap(fromKey, toKey), transformer);
}
@Override
- public SortedMap<K, V2> tailMap(@ParametricNullness K fromKey) {
+ public SortedMap<K, V2> tailMap(K fromKey) {
return transformEntries(fromMap().tailMap(fromKey), transformer);
}
}
@GwtIncompatible // NavigableMap
- private static class TransformedEntriesNavigableMap<
- K extends @Nullable Object, V1 extends @Nullable Object, V2 extends @Nullable Object>
+ private static class TransformedEntriesNavigableMap<K, V1, V2>
extends TransformedEntriesSortedMap<K, V1, V2> implements NavigableMap<K, V2> {
TransformedEntriesNavigableMap(
@@ -2261,14 +2135,12 @@
}
@Override
- @CheckForNull
- public Entry<K, V2> ceilingEntry(@ParametricNullness K key) {
+ public Entry<K, V2> ceilingEntry(K key) {
return transformEntry(fromMap().ceilingEntry(key));
}
@Override
- @CheckForNull
- public K ceilingKey(@ParametricNullness K key) {
+ public K ceilingKey(K key) {
return fromMap().ceilingKey(key);
}
@@ -2283,60 +2155,52 @@
}
@Override
- @CheckForNull
public Entry<K, V2> firstEntry() {
return transformEntry(fromMap().firstEntry());
}
@Override
- @CheckForNull
- public Entry<K, V2> floorEntry(@ParametricNullness K key) {
+ public Entry<K, V2> floorEntry(K key) {
return transformEntry(fromMap().floorEntry(key));
}
@Override
- @CheckForNull
- public K floorKey(@ParametricNullness K key) {
+ public K floorKey(K key) {
return fromMap().floorKey(key);
}
@Override
- public NavigableMap<K, V2> headMap(@ParametricNullness K toKey) {
+ public NavigableMap<K, V2> headMap(K toKey) {
return headMap(toKey, false);
}
@Override
- public NavigableMap<K, V2> headMap(@ParametricNullness K toKey, boolean inclusive) {
+ public NavigableMap<K, V2> headMap(K toKey, boolean inclusive) {
return transformEntries(fromMap().headMap(toKey, inclusive), transformer);
}
@Override
- @CheckForNull
- public Entry<K, V2> higherEntry(@ParametricNullness K key) {
+ public Entry<K, V2> higherEntry(K key) {
return transformEntry(fromMap().higherEntry(key));
}
@Override
- @CheckForNull
- public K higherKey(@ParametricNullness K key) {
+ public K higherKey(K key) {
return fromMap().higherKey(key);
}
@Override
- @CheckForNull
public Entry<K, V2> lastEntry() {
return transformEntry(fromMap().lastEntry());
}
@Override
- @CheckForNull
- public Entry<K, V2> lowerEntry(@ParametricNullness K key) {
+ public Entry<K, V2> lowerEntry(K key) {
return transformEntry(fromMap().lowerEntry(key));
}
@Override
- @CheckForNull
- public K lowerKey(@ParametricNullness K key) {
+ public K lowerKey(K key) {
return fromMap().lowerKey(key);
}
@@ -2346,44 +2210,38 @@
}
@Override
- @CheckForNull
public Entry<K, V2> pollFirstEntry() {
return transformEntry(fromMap().pollFirstEntry());
}
@Override
- @CheckForNull
public Entry<K, V2> pollLastEntry() {
return transformEntry(fromMap().pollLastEntry());
}
@Override
public NavigableMap<K, V2> subMap(
- @ParametricNullness K fromKey,
- boolean fromInclusive,
- @ParametricNullness K toKey,
- boolean toInclusive) {
+ K fromKey, boolean fromInclusive, K toKey, boolean toInclusive) {
return transformEntries(
fromMap().subMap(fromKey, fromInclusive, toKey, toInclusive), transformer);
}
@Override
- public NavigableMap<K, V2> subMap(@ParametricNullness K fromKey, @ParametricNullness K toKey) {
+ public NavigableMap<K, V2> subMap(K fromKey, K toKey) {
return subMap(fromKey, true, toKey, false);
}
@Override
- public NavigableMap<K, V2> tailMap(@ParametricNullness K fromKey) {
+ public NavigableMap<K, V2> tailMap(K fromKey) {
return tailMap(fromKey, true);
}
@Override
- public NavigableMap<K, V2> tailMap(@ParametricNullness K fromKey, boolean inclusive) {
+ public NavigableMap<K, V2> tailMap(K fromKey, boolean inclusive) {
return transformEntries(fromMap().tailMap(fromKey, inclusive), transformer);
}
- @CheckForNull
- private Entry<K, V2> transformEntry(@CheckForNull Entry<K, V1> entry) {
+ private @Nullable Entry<K, V2> transformEntry(@Nullable Entry<K, V1> entry) {
return (entry == null) ? null : Maps.transformEntry(transformer, entry);
}
@@ -2393,13 +2251,11 @@
}
}
- static <K extends @Nullable Object> Predicate<Entry<K, ?>> keyPredicateOnEntries(
- Predicate<? super K> keyPredicate) {
+ static <K> Predicate<Entry<K, ?>> keyPredicateOnEntries(Predicate<? super K> keyPredicate) {
return compose(keyPredicate, Maps.<K>keyFunction());
}
- static <V extends @Nullable Object> Predicate<Entry<?, V>> valuePredicateOnEntries(
- Predicate<? super V> valuePredicate) {
+ static <V> Predicate<Entry<?, V>> valuePredicateOnEntries(Predicate<? super V> valuePredicate) {
return compose(valuePredicate, Maps.<V>valueFunction());
}
@@ -2426,7 +2282,7 @@
* {@link Predicate#apply}. Do not provide a predicate such as {@code
* Predicates.instanceOf(ArrayList.class)}, which is inconsistent with equals.
*/
- public static <K extends @Nullable Object, V extends @Nullable Object> Map<K, V> filterKeys(
+ public static <K, V> Map<K, V> filterKeys(
Map<K, V> unfiltered, final Predicate<? super K> keyPredicate) {
checkNotNull(keyPredicate);
Predicate<Entry<K, ?>> entryPredicate = keyPredicateOnEntries(keyPredicate);
@@ -2461,7 +2317,7 @@
*
* @since 11.0
*/
- public static <K extends @Nullable Object, V extends @Nullable Object> SortedMap<K, V> filterKeys(
+ public static <K, V> SortedMap<K, V> filterKeys(
SortedMap<K, V> unfiltered, final Predicate<? super K> keyPredicate) {
// TODO(lowasser): Return a subclass of Maps.FilteredKeyMap for slightly better
// performance.
@@ -2495,9 +2351,8 @@
* @since 14.0
*/
@GwtIncompatible // NavigableMap
- public static <K extends @Nullable Object, V extends @Nullable Object>
- NavigableMap<K, V> filterKeys(
- NavigableMap<K, V> unfiltered, final Predicate<? super K> keyPredicate) {
+ public static <K, V> NavigableMap<K, V> filterKeys(
+ NavigableMap<K, V> unfiltered, final Predicate<? super K> keyPredicate) {
// TODO(lowasser): Return a subclass of Maps.FilteredKeyMap for slightly better
// performance.
return filterEntries(unfiltered, Maps.<K>keyPredicateOnEntries(keyPredicate));
@@ -2527,7 +2382,7 @@
*
* @since 14.0
*/
- public static <K extends @Nullable Object, V extends @Nullable Object> BiMap<K, V> filterKeys(
+ public static <K, V> BiMap<K, V> filterKeys(
BiMap<K, V> unfiltered, final Predicate<? super K> keyPredicate) {
checkNotNull(keyPredicate);
return filterEntries(unfiltered, Maps.<K>keyPredicateOnEntries(keyPredicate));
@@ -2556,7 +2411,7 @@
* at {@link Predicate#apply}. Do not provide a predicate such as {@code
* Predicates.instanceOf(ArrayList.class)}, which is inconsistent with equals.
*/
- public static <K extends @Nullable Object, V extends @Nullable Object> Map<K, V> filterValues(
+ public static <K, V> Map<K, V> filterValues(
Map<K, V> unfiltered, final Predicate<? super V> valuePredicate) {
return filterEntries(unfiltered, Maps.<V>valuePredicateOnEntries(valuePredicate));
}
@@ -2587,9 +2442,8 @@
*
* @since 11.0
*/
- public static <K extends @Nullable Object, V extends @Nullable Object>
- SortedMap<K, V> filterValues(
- SortedMap<K, V> unfiltered, final Predicate<? super V> valuePredicate) {
+ public static <K, V> SortedMap<K, V> filterValues(
+ SortedMap<K, V> unfiltered, final Predicate<? super V> valuePredicate) {
return filterEntries(unfiltered, Maps.<V>valuePredicateOnEntries(valuePredicate));
}
@@ -2620,9 +2474,8 @@
* @since 14.0
*/
@GwtIncompatible // NavigableMap
- public static <K extends @Nullable Object, V extends @Nullable Object>
- NavigableMap<K, V> filterValues(
- NavigableMap<K, V> unfiltered, final Predicate<? super V> valuePredicate) {
+ public static <K, V> NavigableMap<K, V> filterValues(
+ NavigableMap<K, V> unfiltered, final Predicate<? super V> valuePredicate) {
return filterEntries(unfiltered, Maps.<V>valuePredicateOnEntries(valuePredicate));
}
@@ -2653,7 +2506,7 @@
*
* @since 14.0
*/
- public static <K extends @Nullable Object, V extends @Nullable Object> BiMap<K, V> filterValues(
+ public static <K, V> BiMap<K, V> filterValues(
BiMap<K, V> unfiltered, final Predicate<? super V> valuePredicate) {
return filterEntries(unfiltered, Maps.<V>valuePredicateOnEntries(valuePredicate));
}
@@ -2682,7 +2535,7 @@
* <p><b>Warning:</b> {@code entryPredicate} must be <i>consistent with equals</i>, as documented
* at {@link Predicate#apply}.
*/
- public static <K extends @Nullable Object, V extends @Nullable Object> Map<K, V> filterEntries(
+ public static <K, V> Map<K, V> filterEntries(
Map<K, V> unfiltered, Predicate<? super Entry<K, V>> entryPredicate) {
checkNotNull(entryPredicate);
return (unfiltered instanceof AbstractFilteredMap)
@@ -2716,9 +2569,8 @@
*
* @since 11.0
*/
- public static <K extends @Nullable Object, V extends @Nullable Object>
- SortedMap<K, V> filterEntries(
- SortedMap<K, V> unfiltered, Predicate<? super Entry<K, V>> entryPredicate) {
+ public static <K, V> SortedMap<K, V> filterEntries(
+ SortedMap<K, V> unfiltered, Predicate<? super Entry<K, V>> entryPredicate) {
checkNotNull(entryPredicate);
return (unfiltered instanceof FilteredEntrySortedMap)
? filterFiltered((FilteredEntrySortedMap<K, V>) unfiltered, entryPredicate)
@@ -2752,9 +2604,8 @@
* @since 14.0
*/
@GwtIncompatible // NavigableMap
- public static <K extends @Nullable Object, V extends @Nullable Object>
- NavigableMap<K, V> filterEntries(
- NavigableMap<K, V> unfiltered, Predicate<? super Entry<K, V>> entryPredicate) {
+ public static <K, V> NavigableMap<K, V> filterEntries(
+ NavigableMap<K, V> unfiltered, Predicate<? super Entry<K, V>> entryPredicate) {
checkNotNull(entryPredicate);
return (unfiltered instanceof FilteredEntryNavigableMap)
? filterFiltered((FilteredEntryNavigableMap<K, V>) unfiltered, entryPredicate)
@@ -2788,7 +2639,7 @@
*
* @since 14.0
*/
- public static <K extends @Nullable Object, V extends @Nullable Object> BiMap<K, V> filterEntries(
+ public static <K, V> BiMap<K, V> filterEntries(
BiMap<K, V> unfiltered, Predicate<? super Entry<K, V>> entryPredicate) {
checkNotNull(unfiltered);
checkNotNull(entryPredicate);
@@ -2801,7 +2652,7 @@
* Support {@code clear()}, {@code removeAll()}, and {@code retainAll()} when filtering a filtered
* map.
*/
- private static <K extends @Nullable Object, V extends @Nullable Object> Map<K, V> filterFiltered(
+ private static <K, V> Map<K, V> filterFiltered(
AbstractFilteredMap<K, V> map, Predicate<? super Entry<K, V>> entryPredicate) {
return new FilteredEntryMap<>(
map.unfiltered, Predicates.<Entry<K, V>>and(map.predicate, entryPredicate));
@@ -2811,9 +2662,8 @@
* Support {@code clear()}, {@code removeAll()}, and {@code retainAll()} when filtering a filtered
* sorted map.
*/
- private static <K extends @Nullable Object, V extends @Nullable Object>
- SortedMap<K, V> filterFiltered(
- FilteredEntrySortedMap<K, V> map, Predicate<? super Entry<K, V>> entryPredicate) {
+ private static <K, V> SortedMap<K, V> filterFiltered(
+ FilteredEntrySortedMap<K, V> map, Predicate<? super Entry<K, V>> entryPredicate) {
Predicate<Entry<K, V>> predicate = Predicates.<Entry<K, V>>and(map.predicate, entryPredicate);
return new FilteredEntrySortedMap<>(map.sortedMap(), predicate);
}
@@ -2823,9 +2673,8 @@
* navigable map.
*/
@GwtIncompatible // NavigableMap
- private static <K extends @Nullable Object, V extends @Nullable Object>
- NavigableMap<K, V> filterFiltered(
- FilteredEntryNavigableMap<K, V> map, Predicate<? super Entry<K, V>> entryPredicate) {
+ private static <K, V> NavigableMap<K, V> filterFiltered(
+ FilteredEntryNavigableMap<K, V> map, Predicate<? super Entry<K, V>> entryPredicate) {
Predicate<Entry<K, V>> predicate =
Predicates.<Entry<K, V>>and(map.entryPredicate, entryPredicate);
return new FilteredEntryNavigableMap<>(map.unfiltered, predicate);
@@ -2835,16 +2684,13 @@
* Support {@code clear()}, {@code removeAll()}, and {@code retainAll()} when filtering a filtered
* map.
*/
- private static <K extends @Nullable Object, V extends @Nullable Object>
- BiMap<K, V> filterFiltered(
- FilteredEntryBiMap<K, V> map, Predicate<? super Entry<K, V>> entryPredicate) {
+ private static <K, V> BiMap<K, V> filterFiltered(
+ FilteredEntryBiMap<K, V> map, Predicate<? super Entry<K, V>> entryPredicate) {
Predicate<Entry<K, V>> predicate = Predicates.<Entry<K, V>>and(map.predicate, entryPredicate);
return new FilteredEntryBiMap<>(map.unfiltered(), predicate);
}
- private abstract static class AbstractFilteredMap<
- K extends @Nullable Object, V extends @Nullable Object>
- extends ViewCachingAbstractMap<K, V> {
+ private abstract static class AbstractFilteredMap<K, V> extends ViewCachingAbstractMap<K, V> {
final Map<K, V> unfiltered;
final Predicate<? super Entry<K, V>> predicate;
@@ -2853,17 +2699,16 @@
this.predicate = predicate;
}
- boolean apply(@CheckForNull Object key, @ParametricNullness V value) {
- // This method is called only when the key is in the map (or about to be added to the map),
- // implying that key is a K.
- @SuppressWarnings({"unchecked", "nullness"})
+ 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")
K k = (K) key;
return predicate.apply(Maps.immutableEntry(k, value));
}
@Override
- @CheckForNull
- public V put(@ParametricNullness K key, @ParametricNullness V value) {
+ public V put(K key, V value) {
checkArgument(apply(key, value));
return unfiltered.put(key, value);
}
@@ -2877,13 +2722,12 @@
}
@Override
- public boolean containsKey(@CheckForNull Object key) {
+ public boolean containsKey(Object key) {
return unfiltered.containsKey(key) && apply(key, unfiltered.get(key));
}
@Override
- @CheckForNull
- public V get(@CheckForNull Object key) {
+ public V get(Object key) {
V value = unfiltered.get(key);
return ((value != null) && apply(key, value)) ? value : null;
}
@@ -2894,8 +2738,7 @@
}
@Override
- @CheckForNull
- public V remove(@CheckForNull Object key) {
+ public V remove(Object key) {
return containsKey(key) ? unfiltered.remove(key) : null;
}
@@ -2905,9 +2748,7 @@
}
}
- private static final class FilteredMapValues<
- K extends @Nullable Object, V extends @Nullable Object>
- extends Maps.Values<K, V> {
+ private static final class FilteredMapValues<K, V> extends Maps.Values<K, V> {
final Map<K, V> unfiltered;
final Predicate<? super Entry<K, V>> predicate;
@@ -2919,7 +2760,7 @@
}
@Override
- public boolean remove(@CheckForNull Object o) {
+ public boolean remove(Object o) {
Iterator<Entry<K, V>> entryItr = unfiltered.entrySet().iterator();
while (entryItr.hasNext()) {
Entry<K, V> entry = entryItr.next();
@@ -2960,20 +2801,18 @@
}
@Override
- public @Nullable Object[] toArray() {
+ public Object[] toArray() {
// creating an ArrayList so filtering happens once
return Lists.newArrayList(iterator()).toArray();
}
@Override
- @SuppressWarnings("nullness") // b/192354773 in our checker affects toArray declarations
- public <T extends @Nullable Object> T[] toArray(T[] array) {
+ public <T> T[] toArray(T[] array) {
return Lists.newArrayList(iterator()).toArray(array);
}
}
- private static class FilteredKeyMap<K extends @Nullable Object, V extends @Nullable Object>
- extends AbstractFilteredMap<K, V> {
+ private static class FilteredKeyMap<K, V> extends AbstractFilteredMap<K, V> {
final Predicate<? super K> keyPredicate;
FilteredKeyMap(
@@ -2998,13 +2837,12 @@
// that key is a K.
@Override
@SuppressWarnings("unchecked")
- public boolean containsKey(@CheckForNull Object key) {
+ public boolean containsKey(Object key) {
return unfiltered.containsKey(key) && keyPredicate.apply((K) key);
}
}
- static class FilteredEntryMap<K extends @Nullable Object, V extends @Nullable Object>
- extends AbstractFilteredMap<K, V> {
+ static class FilteredEntryMap<K, V> extends AbstractFilteredMap<K, V> {
/**
* Entries in this set satisfy the predicate, but they don't validate the input to {@code
* Entry.setValue()}.
@@ -3040,8 +2878,7 @@
}
@Override
- @ParametricNullness
- public V setValue(@ParametricNullness V newValue) {
+ public V setValue(V newValue) {
checkArgument(apply(getKey(), newValue));
return super.setValue(newValue);
}
@@ -3056,7 +2893,7 @@
return new KeySet();
}
- static <K extends @Nullable Object, V extends @Nullable Object> boolean removeAllKeys(
+ static <K, V> boolean removeAllKeys(
Map<K, V> map, Predicate<? super Entry<K, V>> entryPredicate, Collection<?> keyCollection) {
Iterator<Entry<K, V>> entryItr = map.entrySet().iterator();
boolean result = false;
@@ -3070,7 +2907,7 @@
return result;
}
- static <K extends @Nullable Object, V extends @Nullable Object> boolean retainAllKeys(
+ static <K, V> boolean retainAllKeys(
Map<K, V> map, Predicate<? super Entry<K, V>> entryPredicate, Collection<?> keyCollection) {
Iterator<Entry<K, V>> entryItr = map.entrySet().iterator();
boolean result = false;
@@ -3091,7 +2928,7 @@
}
@Override
- public boolean remove(@CheckForNull Object o) {
+ public boolean remove(Object o) {
if (containsKey(o)) {
unfiltered.remove(o);
return true;
@@ -3110,22 +2947,20 @@
}
@Override
- public @Nullable Object[] toArray() {
+ public Object[] toArray() {
// creating an ArrayList so filtering happens once
return Lists.newArrayList(iterator()).toArray();
}
@Override
- @SuppressWarnings("nullness") // b/192354773 in our checker affects toArray declarations
- public <T extends @Nullable Object> T[] toArray(T[] array) {
+ public <T> T[] toArray(T[] array) {
return Lists.newArrayList(iterator()).toArray(array);
}
}
}
- private static class FilteredEntrySortedMap<
- K extends @Nullable Object, V extends @Nullable Object>
- extends FilteredEntryMap<K, V> implements SortedMap<K, V> {
+ private static class FilteredEntrySortedMap<K, V> extends FilteredEntryMap<K, V>
+ implements SortedMap<K, V> {
FilteredEntrySortedMap(
SortedMap<K, V> unfiltered, Predicate<? super Entry<K, V>> entryPredicate) {
@@ -3149,62 +2984,54 @@
@WeakOuter
class SortedKeySet extends KeySet implements SortedSet<K> {
@Override
- @CheckForNull
public Comparator<? super K> comparator() {
return sortedMap().comparator();
}
@Override
- public SortedSet<K> subSet(
- @ParametricNullness K fromElement, @ParametricNullness K toElement) {
+ public SortedSet<K> subSet(K fromElement, K toElement) {
return (SortedSet<K>) subMap(fromElement, toElement).keySet();
}
@Override
- public SortedSet<K> headSet(@ParametricNullness K toElement) {
+ public SortedSet<K> headSet(K toElement) {
return (SortedSet<K>) headMap(toElement).keySet();
}
@Override
- public SortedSet<K> tailSet(@ParametricNullness K fromElement) {
+ public SortedSet<K> tailSet(K fromElement) {
return (SortedSet<K>) tailMap(fromElement).keySet();
}
@Override
- @ParametricNullness
public K first() {
return firstKey();
}
@Override
- @ParametricNullness
public K last() {
return lastKey();
}
}
@Override
- @CheckForNull
public Comparator<? super K> comparator() {
return sortedMap().comparator();
}
@Override
- @ParametricNullness
public K firstKey() {
// correctly throws NoSuchElementException when filtered map is empty.
return keySet().iterator().next();
}
@Override
- @ParametricNullness
public K lastKey() {
SortedMap<K, V> headMap = sortedMap();
while (true) {
// correctly throws NoSuchElementException when filtered map is empty.
K key = headMap.lastKey();
- // The cast is safe because the key is taken from the map.
- if (apply(key, uncheckedCastNullableTToT(unfiltered.get(key)))) {
+ if (apply(key, unfiltered.get(key))) {
return key;
}
headMap = sortedMap().headMap(key);
@@ -3212,25 +3039,23 @@
}
@Override
- public SortedMap<K, V> headMap(@ParametricNullness K toKey) {
+ public SortedMap<K, V> headMap(K toKey) {
return new FilteredEntrySortedMap<>(sortedMap().headMap(toKey), predicate);
}
@Override
- public SortedMap<K, V> subMap(@ParametricNullness K fromKey, @ParametricNullness K toKey) {
+ public SortedMap<K, V> subMap(K fromKey, K toKey) {
return new FilteredEntrySortedMap<>(sortedMap().subMap(fromKey, toKey), predicate);
}
@Override
- public SortedMap<K, V> tailMap(@ParametricNullness K fromKey) {
+ public SortedMap<K, V> tailMap(K fromKey) {
return new FilteredEntrySortedMap<>(sortedMap().tailMap(fromKey), predicate);
}
}
@GwtIncompatible // NavigableMap
- private static class FilteredEntryNavigableMap<
- K extends @Nullable Object, V extends @Nullable Object>
- extends AbstractNavigableMap<K, V> {
+ private static class FilteredEntryNavigableMap<K, V> extends AbstractNavigableMap<K, V> {
/*
* It's less code to extend AbstractNavigableMap and forward the filtering logic to
* FilteredEntryMap than to extend FilteredEntrySortedMap and reimplement all the NavigableMap
@@ -3249,7 +3074,6 @@
}
@Override
- @CheckForNull
public Comparator<? super K> comparator() {
return unfiltered.comparator();
}
@@ -3295,25 +3119,22 @@
}
@Override
- @CheckForNull
- public V get(@CheckForNull Object key) {
+ public @Nullable V get(@Nullable Object key) {
return filteredDelegate.get(key);
}
@Override
- public boolean containsKey(@CheckForNull Object key) {
+ public boolean containsKey(@Nullable Object key) {
return filteredDelegate.containsKey(key);
}
@Override
- @CheckForNull
- public V put(@ParametricNullness K key, @ParametricNullness V value) {
+ public V put(K key, V value) {
return filteredDelegate.put(key, value);
}
@Override
- @CheckForNull
- public V remove(@CheckForNull Object key) {
+ public V remove(@Nullable Object key) {
return filteredDelegate.remove(key);
}
@@ -3333,13 +3154,11 @@
}
@Override
- @CheckForNull
public Entry<K, V> pollFirstEntry() {
return Iterables.removeFirstMatching(unfiltered.entrySet(), entryPredicate);
}
@Override
- @CheckForNull
public Entry<K, V> pollLastEntry() {
return Iterables.removeFirstMatching(unfiltered.descendingMap().entrySet(), entryPredicate);
}
@@ -3351,32 +3170,28 @@
@Override
public NavigableMap<K, V> subMap(
- @ParametricNullness K fromKey,
- boolean fromInclusive,
- @ParametricNullness K toKey,
- boolean toInclusive) {
+ K fromKey, boolean fromInclusive, K toKey, boolean toInclusive) {
return filterEntries(
unfiltered.subMap(fromKey, fromInclusive, toKey, toInclusive), entryPredicate);
}
@Override
- public NavigableMap<K, V> headMap(@ParametricNullness K toKey, boolean inclusive) {
+ public NavigableMap<K, V> headMap(K toKey, boolean inclusive) {
return filterEntries(unfiltered.headMap(toKey, inclusive), entryPredicate);
}
@Override
- public NavigableMap<K, V> tailMap(@ParametricNullness K fromKey, boolean inclusive) {
+ public NavigableMap<K, V> tailMap(K fromKey, boolean inclusive) {
return filterEntries(unfiltered.tailMap(fromKey, inclusive), entryPredicate);
}
}
- static final class FilteredEntryBiMap<K extends @Nullable Object, V extends @Nullable Object>
- extends FilteredEntryMap<K, V> implements BiMap<K, V> {
+ static final class FilteredEntryBiMap<K, V> extends FilteredEntryMap<K, V>
+ implements BiMap<K, V> {
@RetainedWith private final BiMap<V, K> inverse;
- private static <K extends @Nullable Object, V extends @Nullable Object>
- Predicate<Entry<V, K>> inversePredicate(
- final Predicate<? super Entry<K, V>> forwardPredicate) {
+ private static <K, V> Predicate<Entry<V, K>> inversePredicate(
+ final Predicate<? super Entry<K, V>> forwardPredicate) {
return new Predicate<Entry<V, K>>() {
@Override
public boolean apply(Entry<V, K> input) {
@@ -3402,8 +3217,7 @@
}
@Override
- @CheckForNull
- public V forcePut(@ParametricNullness K key, @ParametricNullness V value) {
+ public V forcePut(@Nullable K key, @Nullable V value) {
checkArgument(apply(key, value));
return unfiltered().forcePut(key, value);
}
@@ -3448,8 +3262,8 @@
* @since 12.0
*/
@GwtIncompatible // NavigableMap
- public static <K extends @Nullable Object, V extends @Nullable Object>
- NavigableMap<K, V> unmodifiableNavigableMap(NavigableMap<K, ? extends V> map) {
+ public static <K, V> NavigableMap<K, V> unmodifiableNavigableMap(
+ NavigableMap<K, ? extends V> map) {
checkNotNull(map);
if (map instanceof UnmodifiableNavigableMap) {
@SuppressWarnings("unchecked") // covariant
@@ -3460,15 +3274,14 @@
}
}
- @CheckForNull
- private static <K extends @Nullable Object, V extends @Nullable Object>
- Entry<K, V> unmodifiableOrNull(@CheckForNull Entry<K, ? extends V> entry) {
+ private static <K, V> @Nullable Entry<K, V> unmodifiableOrNull(
+ @Nullable Entry<K, ? extends V> entry) {
return (entry == null) ? null : Maps.unmodifiableEntry(entry);
}
@GwtIncompatible // NavigableMap
- static class UnmodifiableNavigableMap<K extends @Nullable Object, V extends @Nullable Object>
- extends ForwardingSortedMap<K, V> implements NavigableMap<K, V>, Serializable {
+ static class UnmodifiableNavigableMap<K, V> extends ForwardingSortedMap<K, V>
+ implements NavigableMap<K, V>, Serializable {
private final NavigableMap<K, ? extends V> delegate;
UnmodifiableNavigableMap(NavigableMap<K, ? extends V> delegate) {
@@ -3487,78 +3300,66 @@
}
@Override
- @CheckForNull
- public Entry<K, V> lowerEntry(@ParametricNullness K key) {
+ public Entry<K, V> lowerEntry(K key) {
return unmodifiableOrNull(delegate.lowerEntry(key));
}
@Override
- @CheckForNull
- public K lowerKey(@ParametricNullness K key) {
+ public K lowerKey(K key) {
return delegate.lowerKey(key);
}
@Override
- @CheckForNull
- public Entry<K, V> floorEntry(@ParametricNullness K key) {
+ public Entry<K, V> floorEntry(K key) {
return unmodifiableOrNull(delegate.floorEntry(key));
}
@Override
- @CheckForNull
- public K floorKey(@ParametricNullness K key) {
+ public K floorKey(K key) {
return delegate.floorKey(key);
}
@Override
- @CheckForNull
- public Entry<K, V> ceilingEntry(@ParametricNullness K key) {
+ public Entry<K, V> ceilingEntry(K key) {
return unmodifiableOrNull(delegate.ceilingEntry(key));
}
@Override
- @CheckForNull
- public K ceilingKey(@ParametricNullness K key) {
+ public K ceilingKey(K key) {
return delegate.ceilingKey(key);
}
@Override
- @CheckForNull
- public Entry<K, V> higherEntry(@ParametricNullness K key) {
+ public Entry<K, V> higherEntry(K key) {
return unmodifiableOrNull(delegate.higherEntry(key));
}
@Override
- @CheckForNull
- public K higherKey(@ParametricNullness K key) {
+ public K higherKey(K key) {
return delegate.higherKey(key);
}
@Override
- @CheckForNull
public Entry<K, V> firstEntry() {
return unmodifiableOrNull(delegate.firstEntry());
}
@Override
- @CheckForNull
public Entry<K, V> lastEntry() {
return unmodifiableOrNull(delegate.lastEntry());
}
@Override
- @CheckForNull
public final Entry<K, V> pollFirstEntry() {
throw new UnsupportedOperationException();
}
@Override
- @CheckForNull
public final Entry<K, V> pollLastEntry() {
throw new UnsupportedOperationException();
}
- @CheckForNull private transient UnmodifiableNavigableMap<K, V> descendingMap;
+ private transient @Nullable UnmodifiableNavigableMap<K, V> descendingMap;
@Override
public NavigableMap<K, V> descendingMap() {
@@ -3584,37 +3385,34 @@
}
@Override
- public SortedMap<K, V> subMap(@ParametricNullness K fromKey, @ParametricNullness K toKey) {
+ public SortedMap<K, V> subMap(K fromKey, K toKey) {
return subMap(fromKey, true, toKey, false);
}
@Override
public NavigableMap<K, V> subMap(
- @ParametricNullness K fromKey,
- boolean fromInclusive,
- @ParametricNullness K toKey,
- boolean toInclusive) {
+ K fromKey, boolean fromInclusive, K toKey, boolean toInclusive) {
return Maps.unmodifiableNavigableMap(
delegate.subMap(fromKey, fromInclusive, toKey, toInclusive));
}
@Override
- public SortedMap<K, V> headMap(@ParametricNullness K toKey) {
+ public SortedMap<K, V> headMap(K toKey) {
return headMap(toKey, false);
}
@Override
- public NavigableMap<K, V> headMap(@ParametricNullness K toKey, boolean inclusive) {
+ public NavigableMap<K, V> headMap(K toKey, boolean inclusive) {
return Maps.unmodifiableNavigableMap(delegate.headMap(toKey, inclusive));
}
@Override
- public SortedMap<K, V> tailMap(@ParametricNullness K fromKey) {
+ public SortedMap<K, V> tailMap(K fromKey) {
return tailMap(fromKey, true);
}
@Override
- public NavigableMap<K, V> tailMap(@ParametricNullness K fromKey, boolean inclusive) {
+ public NavigableMap<K, V> tailMap(K fromKey, boolean inclusive) {
return Maps.unmodifiableNavigableMap(delegate.tailMap(fromKey, inclusive));
}
}
@@ -3669,8 +3467,8 @@
* @since 13.0
*/
@GwtIncompatible // NavigableMap
- public static <K extends @Nullable Object, V extends @Nullable Object>
- NavigableMap<K, V> synchronizedNavigableMap(NavigableMap<K, V> navigableMap) {
+ public static <K, V> NavigableMap<K, V> synchronizedNavigableMap(
+ NavigableMap<K, V> navigableMap) {
return Synchronized.navigableMap(navigableMap);
}
@@ -3679,16 +3477,14 @@
* entrySet views.
*/
@GwtCompatible
- abstract static class ViewCachingAbstractMap<
- K extends @Nullable Object, V extends @Nullable Object>
- extends AbstractMap<K, V> {
+ abstract static class ViewCachingAbstractMap<K, V> extends AbstractMap<K, V> {
/**
* Creates the entry set to be returned by {@link #entrySet()}. This method is invoked at most
* once on a given map, at the time when {@code entrySet} is first called.
*/
abstract Set<Entry<K, V>> createEntrySet();
- @CheckForNull private transient Set<Entry<K, V>> entrySet;
+ private transient @Nullable Set<Entry<K, V>> entrySet;
@Override
public Set<Entry<K, V>> entrySet() {
@@ -3696,7 +3492,7 @@
return (result == null) ? entrySet = createEntrySet() : result;
}
- @CheckForNull private transient Set<K> keySet;
+ private transient @Nullable Set<K> keySet;
@Override
public Set<K> keySet() {
@@ -3708,7 +3504,7 @@
return new KeySet<>(this);
}
- @CheckForNull private transient Collection<V> values;
+ private transient @Nullable Collection<V> values;
@Override
public Collection<V> values() {
@@ -3721,9 +3517,7 @@
}
}
- abstract static class IteratorBasedAbstractMap<
- K extends @Nullable Object, V extends @Nullable Object>
- extends AbstractMap<K, V> {
+ abstract static class IteratorBasedAbstractMap<K, V> extends AbstractMap<K, V> {
@Override
public abstract int size();
@@ -3773,8 +3567,7 @@
* Delegates to {@link Map#get}. Returns {@code null} on {@code ClassCastException} and {@code
* NullPointerException}.
*/
- @CheckForNull
- static <V extends @Nullable Object> V safeGet(Map<?, V> map, @CheckForNull Object key) {
+ static <V> V safeGet(Map<?, V> map, @Nullable Object key) {
checkNotNull(map);
try {
return map.get(key);
@@ -3787,7 +3580,7 @@
* Delegates to {@link Map#containsKey}. Returns {@code false} on {@code ClassCastException} and
* {@code NullPointerException}.
*/
- static boolean safeContainsKey(Map<?, ?> map, @CheckForNull Object key) {
+ static boolean safeContainsKey(Map<?, ?> map, Object key) {
checkNotNull(map);
try {
return map.containsKey(key);
@@ -3800,8 +3593,7 @@
* Delegates to {@link Map#remove}. Returns {@code null} on {@code ClassCastException} and {@code
* NullPointerException}.
*/
- @CheckForNull
- static <V extends @Nullable Object> V safeRemove(Map<?, V> map, @CheckForNull Object key) {
+ static <V> V safeRemove(Map<?, V> map, Object key) {
checkNotNull(map);
try {
return map.remove(key);
@@ -3811,12 +3603,12 @@
}
/** An admittedly inefficient implementation of {@link Map#containsKey}. */
- static boolean containsKeyImpl(Map<?, ?> map, @CheckForNull 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, @CheckForNull Object value) {
+ static boolean containsValueImpl(Map<?, ?> map, @Nullable Object value) {
return Iterators.contains(valueIterator(map.entrySet().iterator()), value);
}
@@ -3832,8 +3624,7 @@
* @param o the object that might be contained in {@code c}
* @return {@code true} if {@code c} contains {@code o}
*/
- static <K extends @Nullable Object, V extends @Nullable Object> boolean containsEntryImpl(
- Collection<Entry<K, V>> c, @CheckForNull Object o) {
+ static <K, V> boolean containsEntryImpl(Collection<Entry<K, V>> c, Object o) {
if (!(o instanceof Entry)) {
return false;
}
@@ -3851,8 +3642,7 @@
* @param o the object to remove from {@code c}
* @return {@code true} if {@code c} was changed
*/
- static <K extends @Nullable Object, V extends @Nullable Object> boolean removeEntryImpl(
- Collection<Entry<K, V>> c, @CheckForNull Object o) {
+ static <K, V> boolean removeEntryImpl(Collection<Entry<K, V>> c, Object o) {
if (!(o instanceof Entry)) {
return false;
}
@@ -3860,7 +3650,7 @@
}
/** An implementation of {@link Map#equals}. */
- static boolean equalsImpl(Map<?, ?> map, @CheckForNull Object object) {
+ static boolean equalsImpl(Map<?, ?> map, Object object) {
if (map == object) {
return true;
} else if (object instanceof Map) {
@@ -3885,15 +3675,13 @@
}
/** An implementation of {@link Map#putAll}. */
- static <K extends @Nullable Object, V extends @Nullable Object> void putAllImpl(
- Map<K, V> self, Map<? extends K, ? extends V> map) {
+ static <K, V> void putAllImpl(Map<K, V> self, Map<? extends K, ? extends V> map) {
for (Entry<? extends K, ? extends V> entry : map.entrySet()) {
self.put(entry.getKey(), entry.getValue());
}
}
- static class KeySet<K extends @Nullable Object, V extends @Nullable Object>
- extends Sets.ImprovedAbstractSet<K> {
+ static class KeySet<K, V> extends Sets.ImprovedAbstractSet<K> {
@Weak final Map<K, V> map;
KeySet(Map<K, V> map) {
@@ -3927,12 +3715,12 @@
}
@Override
- public boolean contains(@CheckForNull Object o) {
+ public boolean contains(Object o) {
return map().containsKey(o);
}
@Override
- public boolean remove(@CheckForNull Object o) {
+ public boolean remove(Object o) {
if (contains(o)) {
map().remove(o);
return true;
@@ -3946,18 +3734,15 @@
}
}
- @CheckForNull
- static <K extends @Nullable Object> K keyOrNull(@CheckForNull Entry<K, ?> entry) {
+ static <K> @Nullable K keyOrNull(@Nullable Entry<K, ?> entry) {
return (entry == null) ? null : entry.getKey();
}
- @CheckForNull
- static <V extends @Nullable Object> V valueOrNull(@CheckForNull Entry<?, V> entry) {
+ static <V> @Nullable V valueOrNull(@Nullable Entry<?, V> entry) {
return (entry == null) ? null : entry.getValue();
}
- static class SortedKeySet<K extends @Nullable Object, V extends @Nullable Object>
- extends KeySet<K, V> implements SortedSet<K> {
+ static class SortedKeySet<K, V> extends KeySet<K, V> implements SortedSet<K> {
SortedKeySet(SortedMap<K, V> map) {
super(map);
}
@@ -3968,42 +3753,38 @@
}
@Override
- @CheckForNull
public Comparator<? super K> comparator() {
return map().comparator();
}
@Override
- public SortedSet<K> subSet(@ParametricNullness K fromElement, @ParametricNullness K toElement) {
+ public SortedSet<K> subSet(K fromElement, K toElement) {
return new SortedKeySet<>(map().subMap(fromElement, toElement));
}
@Override
- public SortedSet<K> headSet(@ParametricNullness K toElement) {
+ public SortedSet<K> headSet(K toElement) {
return new SortedKeySet<>(map().headMap(toElement));
}
@Override
- public SortedSet<K> tailSet(@ParametricNullness K fromElement) {
+ public SortedSet<K> tailSet(K fromElement) {
return new SortedKeySet<>(map().tailMap(fromElement));
}
@Override
- @ParametricNullness
public K first() {
return map().firstKey();
}
@Override
- @ParametricNullness
public K last() {
return map().lastKey();
}
}
@GwtIncompatible // NavigableMap
- static class NavigableKeySet<K extends @Nullable Object, V extends @Nullable Object>
- extends SortedKeySet<K, V> implements NavigableSet<K> {
+ static class NavigableKeySet<K, V> extends SortedKeySet<K, V> implements NavigableSet<K> {
NavigableKeySet(NavigableMap<K, V> map) {
super(map);
}
@@ -4014,37 +3795,31 @@
}
@Override
- @CheckForNull
- public K lower(@ParametricNullness K e) {
+ public K lower(K e) {
return map().lowerKey(e);
}
@Override
- @CheckForNull
- public K floor(@ParametricNullness K e) {
+ public K floor(K e) {
return map().floorKey(e);
}
@Override
- @CheckForNull
- public K ceiling(@ParametricNullness K e) {
+ public K ceiling(K e) {
return map().ceilingKey(e);
}
@Override
- @CheckForNull
- public K higher(@ParametricNullness K e) {
+ public K higher(K e) {
return map().higherKey(e);
}
@Override
- @CheckForNull
public K pollFirst() {
return keyOrNull(map().pollFirstEntry());
}
@Override
- @CheckForNull
public K pollLast() {
return keyOrNull(map().pollLastEntry());
}
@@ -4061,41 +3836,37 @@
@Override
public NavigableSet<K> subSet(
- @ParametricNullness K fromElement,
- boolean fromInclusive,
- @ParametricNullness K toElement,
- boolean toInclusive) {
+ K fromElement, boolean fromInclusive, K toElement, boolean toInclusive) {
return map().subMap(fromElement, fromInclusive, toElement, toInclusive).navigableKeySet();
}
@Override
- public SortedSet<K> subSet(@ParametricNullness K fromElement, @ParametricNullness K toElement) {
+ public SortedSet<K> subSet(K fromElement, K toElement) {
return subSet(fromElement, true, toElement, false);
}
@Override
- public NavigableSet<K> headSet(@ParametricNullness K toElement, boolean inclusive) {
+ public NavigableSet<K> headSet(K toElement, boolean inclusive) {
return map().headMap(toElement, inclusive).navigableKeySet();
}
@Override
- public SortedSet<K> headSet(@ParametricNullness K toElement) {
+ public SortedSet<K> headSet(K toElement) {
return headSet(toElement, false);
}
@Override
- public NavigableSet<K> tailSet(@ParametricNullness K fromElement, boolean inclusive) {
+ public NavigableSet<K> tailSet(K fromElement, boolean inclusive) {
return map().tailMap(fromElement, inclusive).navigableKeySet();
}
@Override
- public SortedSet<K> tailSet(@ParametricNullness K fromElement) {
+ public SortedSet<K> tailSet(K fromElement) {
return tailSet(fromElement, true);
}
}
- static class Values<K extends @Nullable Object, V extends @Nullable Object>
- extends AbstractCollection<V> {
+ static class Values<K, V> extends AbstractCollection<V> {
@Weak final Map<K, V> map;
Values(Map<K, V> map) {
@@ -4119,7 +3890,7 @@
}
@Override
- public boolean remove(@CheckForNull Object o) {
+ public boolean remove(Object o) {
try {
return super.remove(o);
} catch (UnsupportedOperationException e) {
@@ -4174,7 +3945,7 @@
}
@Override
- public boolean contains(@CheckForNull Object o) {
+ public boolean contains(@Nullable Object o) {
return map().containsValue(o);
}
@@ -4184,8 +3955,7 @@
}
}
- abstract static class EntrySet<K extends @Nullable Object, V extends @Nullable Object>
- extends Sets.ImprovedAbstractSet<Entry<K, V>> {
+ abstract static class EntrySet<K, V> extends Sets.ImprovedAbstractSet<Entry<K, V>> {
abstract Map<K, V> map();
@Override
@@ -4199,7 +3969,7 @@
}
@Override
- public boolean contains(@CheckForNull Object o) {
+ public boolean contains(Object o) {
if (o instanceof Entry) {
Entry<?, ?> entry = (Entry<?, ?>) o;
Object key = entry.getKey();
@@ -4215,12 +3985,8 @@
}
@Override
- public boolean remove(@CheckForNull Object o) {
- /*
- * `o instanceof Entry` is guaranteed by `contains`, but we check it here to satisfy our
- * nullness checker.
- */
- if (contains(o) && o instanceof Entry) {
+ public boolean remove(Object o) {
+ if (contains(o)) {
Entry<?, ?> entry = (Entry<?, ?>) o;
return map().keySet().remove(entry.getKey());
}
@@ -4243,13 +4009,9 @@
return super.retainAll(checkNotNull(c));
} catch (UnsupportedOperationException e) {
// if the iterators don't support remove
- Set<@Nullable Object> keys = Sets.newHashSetWithExpectedSize(c.size());
+ Set<Object> keys = Sets.newHashSetWithExpectedSize(c.size());
for (Object o : c) {
- /*
- * `o instanceof Entry` is guaranteed by `contains`, but we check it here to satisfy our
- * nullness checker.
- */
- if (contains(o) && o instanceof Entry) {
+ if (contains(o)) {
Entry<?, ?> entry = (Entry<?, ?>) o;
keys.add(entry.getKey());
}
@@ -4260,8 +4022,8 @@
}
@GwtIncompatible // NavigableMap
- abstract static class DescendingMap<K extends @Nullable Object, V extends @Nullable Object>
- extends ForwardingMap<K, V> implements NavigableMap<K, V> {
+ abstract static class DescendingMap<K, V> extends ForwardingMap<K, V>
+ implements NavigableMap<K, V> {
abstract NavigableMap<K, V> forward();
@@ -4270,7 +4032,7 @@
return forward();
}
- @CheckForNull private transient Comparator<? super K> comparator;
+ private transient @Nullable Comparator<? super K> comparator;
@SuppressWarnings("unchecked")
@Override
@@ -4287,90 +4049,76 @@
}
// If we inline this, we get a javac error.
- private static <T extends @Nullable Object> Ordering<T> reverse(Comparator<T> forward) {
+ private static <T> Ordering<T> reverse(Comparator<T> forward) {
return Ordering.from(forward).reverse();
}
@Override
- @ParametricNullness
public K firstKey() {
return forward().lastKey();
}
@Override
- @ParametricNullness
public K lastKey() {
return forward().firstKey();
}
@Override
- @CheckForNull
- public Entry<K, V> lowerEntry(@ParametricNullness K key) {
+ public Entry<K, V> lowerEntry(K key) {
return forward().higherEntry(key);
}
@Override
- @CheckForNull
- public K lowerKey(@ParametricNullness K key) {
+ public K lowerKey(K key) {
return forward().higherKey(key);
}
@Override
- @CheckForNull
- public Entry<K, V> floorEntry(@ParametricNullness K key) {
+ public Entry<K, V> floorEntry(K key) {
return forward().ceilingEntry(key);
}
@Override
- @CheckForNull
- public K floorKey(@ParametricNullness K key) {
+ public K floorKey(K key) {
return forward().ceilingKey(key);
}
@Override
- @CheckForNull
- public Entry<K, V> ceilingEntry(@ParametricNullness K key) {
+ public Entry<K, V> ceilingEntry(K key) {
return forward().floorEntry(key);
}
@Override
- @CheckForNull
- public K ceilingKey(@ParametricNullness K key) {
+ public K ceilingKey(K key) {
return forward().floorKey(key);
}
@Override
- @CheckForNull
- public Entry<K, V> higherEntry(@ParametricNullness K key) {
+ public Entry<K, V> higherEntry(K key) {
return forward().lowerEntry(key);
}
@Override
- @CheckForNull
- public K higherKey(@ParametricNullness K key) {
+ public K higherKey(K key) {
return forward().lowerKey(key);
}
@Override
- @CheckForNull
public Entry<K, V> firstEntry() {
return forward().lastEntry();
}
@Override
- @CheckForNull
public Entry<K, V> lastEntry() {
return forward().firstEntry();
}
@Override
- @CheckForNull
public Entry<K, V> pollFirstEntry() {
return forward().pollLastEntry();
}
@Override
- @CheckForNull
public Entry<K, V> pollLastEntry() {
return forward().pollFirstEntry();
}
@@ -4380,7 +4128,7 @@
return forward();
}
- @CheckForNull private transient Set<Entry<K, V>> entrySet;
+ private transient @Nullable Set<Entry<K, V>> entrySet;
@Override
public Set<Entry<K, V>> entrySet() {
@@ -4411,7 +4159,7 @@
return navigableKeySet();
}
- @CheckForNull private transient NavigableSet<K> navigableKeySet;
+ private transient @Nullable NavigableSet<K> navigableKeySet;
@Override
public NavigableSet<K> navigableKeySet() {
@@ -4426,35 +4174,32 @@
@Override
public NavigableMap<K, V> subMap(
- @ParametricNullness K fromKey,
- boolean fromInclusive,
- @ParametricNullness K toKey,
- boolean toInclusive) {
+ K fromKey, boolean fromInclusive, K toKey, boolean toInclusive) {
return forward().subMap(toKey, toInclusive, fromKey, fromInclusive).descendingMap();
}
@Override
- public SortedMap<K, V> subMap(@ParametricNullness K fromKey, @ParametricNullness K toKey) {
+ public SortedMap<K, V> subMap(K fromKey, K toKey) {
return subMap(fromKey, true, toKey, false);
}
@Override
- public NavigableMap<K, V> headMap(@ParametricNullness K toKey, boolean inclusive) {
+ public NavigableMap<K, V> headMap(K toKey, boolean inclusive) {
return forward().tailMap(toKey, inclusive).descendingMap();
}
@Override
- public SortedMap<K, V> headMap(@ParametricNullness K toKey) {
+ public SortedMap<K, V> headMap(K toKey) {
return headMap(toKey, false);
}
@Override
- public NavigableMap<K, V> tailMap(@ParametricNullness K fromKey, boolean inclusive) {
+ public NavigableMap<K, V> tailMap(K fromKey, boolean inclusive) {
return forward().headMap(fromKey, inclusive).descendingMap();
}
@Override
- public SortedMap<K, V> tailMap(@ParametricNullness K fromKey) {
+ public SortedMap<K, V> tailMap(K fromKey) {
return tailMap(fromKey, true);
}
@@ -4497,8 +4242,8 @@
*/
@Beta
@GwtIncompatible // NavigableMap
- public static <K extends Comparable<? super K>, V extends @Nullable Object>
- NavigableMap<K, V> subMap(NavigableMap<K, V> map, Range<K> range) {
+ public static <K extends Comparable<? super K>, V> NavigableMap<K, V> subMap(
+ NavigableMap<K, V> map, Range<K> range) {
if (map.comparator() != null
&& map.comparator() != Ordering.natural()
&& range.hasLowerBound()
diff --git a/guava/src/com/google/common/collect/MinMaxPriorityQueue.java b/guava/src/com/google/common/collect/MinMaxPriorityQueue.java
index cd01279..32cebef 100644
--- a/guava/src/com/google/common/collect/MinMaxPriorityQueue.java
+++ b/guava/src/com/google/common/collect/MinMaxPriorityQueue.java
@@ -21,7 +21,6 @@
import static com.google.common.base.Preconditions.checkPositionIndex;
import static com.google.common.base.Preconditions.checkState;
import static com.google.common.collect.CollectPreconditions.checkRemove;
-import static java.util.Objects.requireNonNull;
import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtCompatible;
@@ -42,7 +41,6 @@
import java.util.NoSuchElementException;
import java.util.PriorityQueue;
import java.util.Queue;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -100,7 +98,6 @@
*/
@Beta
@GwtCompatible
-@ElementTypesAreNonnullByDefault
public final class MinMaxPriorityQueue<E> extends AbstractQueue<E> {
/**
@@ -124,12 +121,6 @@
* Creates and returns a new builder, configured to build {@code MinMaxPriorityQueue} instances
* that use {@code comparator} to determine the least and greatest elements.
*/
- /*
- * TODO(cpovirk): Change to Comparator<? super B> to permit Comparator<@Nullable ...> and
- * Comparator<SupertypeOfB>? What we have here matches the immutable collections, but those also
- * expose a public Builder constructor that accepts "? super." So maybe we should do *that*
- * instead.
- */
public static <B> Builder<B> orderedBy(Comparator<B> comparator) {
return new Builder<B>(comparator);
}
@@ -233,7 +224,7 @@
private final Heap minHeap;
private final Heap maxHeap;
@VisibleForTesting final int maximumSize;
- private @Nullable Object[] queue;
+ private Object[] queue;
private int size;
private int modCount;
@@ -301,22 +292,16 @@
@CanIgnoreReturnValue
@Override
- @CheckForNull
public E poll() {
return isEmpty() ? null : removeAndGet(0);
}
@SuppressWarnings("unchecked") // we must carefully only allow Es to get in
E elementData(int index) {
- /*
- * requireNonNull is safe as long as we're careful to call this method only with populated
- * indexes.
- */
- return (E) requireNonNull(queue[index]);
+ return (E) queue[index];
}
@Override
- @CheckForNull
public E peek() {
return isEmpty() ? null : elementData(0);
}
@@ -340,7 +325,6 @@
* empty.
*/
@CanIgnoreReturnValue
- @CheckForNull
public E pollFirst() {
return poll();
}
@@ -359,7 +343,6 @@
* Retrieves, but does not remove, the least element of this queue, or returns {@code null} if the
* queue is empty.
*/
- @CheckForNull
public E peekFirst() {
return peek();
}
@@ -369,7 +352,6 @@
* empty.
*/
@CanIgnoreReturnValue
- @CheckForNull
public E pollLast() {
return isEmpty() ? null : removeAndGet(getMaxElementIndex());
}
@@ -391,7 +373,6 @@
* Retrieves, but does not remove, the greatest element of this queue, or returns {@code null} if
* the queue is empty.
*/
- @CheckForNull
public E peekLast() {
return isEmpty() ? null : elementData(getMaxElementIndex());
}
@@ -411,7 +392,6 @@
*/
@VisibleForTesting
@CanIgnoreReturnValue
- @CheckForNull
MoveDesc<E> removeAt(int index) {
checkPositionIndex(index, size);
modCount++;
@@ -447,7 +427,6 @@
return changes;
}
- @CheckForNull
private MoveDesc<E> fillHole(int index, E toTrickle) {
Heap heap = heapForIndex(index);
// We consider elementData(index) a "hole", and we want to fill it
@@ -525,7 +504,7 @@
@WeakOuter
private class Heap {
final Ordering<E> ordering;
- @Weak Heap otherHeap; // always initialized immediately after construction
+ @Weak @Nullable Heap otherHeap;
Heap(Ordering<E> ordering) {
this.ordering = ordering;
@@ -539,7 +518,6 @@
* Tries to move {@code toTrickle} from a min to a max level and bubble up there. If it moved
* before {@code removeIndex} this method returns a pair as described in {@link #removeAt}.
*/
- @CheckForNull
MoveDesc<E> tryCrossOverAndBubbleUp(int removeIndex, int vacated, E toTrickle) {
int crossOver = crossOver(vacated, toTrickle);
if (crossOver == vacated) {
@@ -773,9 +751,9 @@
private int expectedModCount = modCount;
// The same element is not allowed in both forgetMeNot and skipMe, but duplicates are allowed in
// either of them, up to the same multiplicity as the queue.
- @CheckForNull private Queue<E> forgetMeNot;
- @CheckForNull private List<E> skipMe;
- @CheckForNull private E lastFromForgetMeNot;
+ private @Nullable Queue<E> forgetMeNot;
+ private @Nullable List<E> skipMe;
+ private @Nullable E lastFromForgetMeNot;
private boolean canRemove;
@Override
@@ -813,8 +791,7 @@
if (cursor < size()) {
MoveDesc<E> moved = removeAt(cursor);
if (moved != null) {
- // Either both are null or neither is, but we check both to satisfy the nullness checker.
- if (forgetMeNot == null || skipMe == null) {
+ if (forgetMeNot == null) {
forgetMeNot = new ArrayDeque<E>();
skipMe = new ArrayList<E>(3);
}
@@ -828,7 +805,7 @@
cursor--;
nextCursor--;
} else { // we must have set lastFromForgetMeNot in next()
- checkState(removeExact(requireNonNull(lastFromForgetMeNot)));
+ checkState(removeExact(lastFromForgetMeNot));
lastFromForgetMeNot = null;
}
}
diff --git a/guava/src/com/google/common/collect/MoreCollectors.java b/guava/src/com/google/common/collect/MoreCollectors.java
index 5a84a46..f447ebe 100644
--- a/guava/src/com/google/common/collect/MoreCollectors.java
+++ b/guava/src/com/google/common/collect/MoreCollectors.java
@@ -17,7 +17,6 @@
package com.google.common.collect;
import static com.google.common.base.Preconditions.checkNotNull;
-import static java.util.Collections.emptyList;
import com.google.common.annotations.GwtCompatible;
import java.util.ArrayList;
@@ -35,7 +34,6 @@
* @since 21.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
public final class MoreCollectors {
/*
@@ -51,12 +49,10 @@
Collector.Characteristics.UNORDERED);
/**
- * A collector that converts a stream of zero or one elements to an {@code Optional}.
- *
- * @throws IllegalArgumentException if the stream consists of two or more elements.
- * @throws NullPointerException if any element in the stream is {@code null}.
- * @return {@code Optional.of(onlyElement)} if the stream has exactly one element (must not be
- * {@code null}) and returns {@code Optional.empty()} if it has none.
+ * A collector that converts a stream of zero or one elements to an {@code Optional}. The returned
+ * collector throws an {@code IllegalArgumentException} if the stream consists of two or more
+ * elements, and a {@code NullPointerException} if the stream consists of exactly one element,
+ * which is null.
*/
@SuppressWarnings("unchecked")
public static <T> Collector<T, ?, Optional<T>> toOptional() {
@@ -65,8 +61,8 @@
private static final Object NULL_PLACEHOLDER = new Object();
- private static final Collector<@Nullable Object, ?, @Nullable Object> ONLY_ELEMENT =
- Collector.<@Nullable Object, ToOptionalState, @Nullable Object>of(
+ private static final Collector<Object, ?, Object> ONLY_ELEMENT =
+ Collector.of(
ToOptionalState::new,
(state, o) -> state.add((o == null) ? NULL_PLACEHOLDER : o),
ToOptionalState::combine,
@@ -82,7 +78,7 @@
* more elements, and a {@code NoSuchElementException} if the stream is empty.
*/
@SuppressWarnings("unchecked")
- public static <T extends @Nullable Object> Collector<T, ?, T> onlyElement() {
+ public static <T> Collector<T, ?, T> onlyElement() {
return (Collector) ONLY_ELEMENT;
}
@@ -94,11 +90,11 @@
static final int MAX_EXTRAS = 4;
@Nullable Object element;
- List<Object> extras;
+ @Nullable List<Object> extras;
ToOptionalState() {
element = null;
- extras = emptyList();
+ extras = null;
}
IllegalArgumentException multiples(boolean overflow) {
@@ -118,8 +114,7 @@
checkNotNull(o);
if (element == null) {
this.element = o;
- } else if (extras.isEmpty()) {
- // Replace immutable empty list with mutable list.
+ } else if (extras == null) {
extras = new ArrayList<>(MAX_EXTRAS);
extras.add(o);
} else if (extras.size() < MAX_EXTRAS) {
@@ -135,12 +130,13 @@
} else if (other.element == null) {
return this;
} else {
- if (extras.isEmpty()) {
- // Replace immutable empty list with mutable list.
+ if (extras == null) {
extras = new ArrayList<>();
}
extras.add(other.element);
- extras.addAll(other.extras);
+ if (other.extras != null) {
+ this.extras.addAll(other.extras);
+ }
if (extras.size() > MAX_EXTRAS) {
extras.subList(MAX_EXTRAS, extras.size()).clear();
throw multiples(true);
@@ -150,7 +146,7 @@
}
Optional<Object> getOptional() {
- if (extras.isEmpty()) {
+ if (extras == null) {
return Optional.ofNullable(element);
} else {
throw multiples(false);
@@ -160,7 +156,7 @@
Object getElement() {
if (element == null) {
throw new NoSuchElementException();
- } else if (extras.isEmpty()) {
+ } else if (extras == null) {
return element;
} else {
throw multiples(false);
diff --git a/guava/src/com/google/common/collect/Multimap.java b/guava/src/com/google/common/collect/Multimap.java
index e1a0a8e..ec2b9ef 100644
--- a/guava/src/com/google/common/collect/Multimap.java
+++ b/guava/src/com/google/common/collect/Multimap.java
@@ -28,7 +28,6 @@
import java.util.Map.Entry;
import java.util.Set;
import java.util.function.BiConsumer;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -162,8 +161,7 @@
*/
@DoNotMock("Use ImmutableMultimap, HashMultimap, or another implementation")
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-public interface Multimap<K extends @Nullable Object, V extends @Nullable Object> {
+public interface Multimap<K, V> {
// Query Operations
/**
@@ -185,21 +183,20 @@
* Returns {@code true} if this multimap contains at least one key-value pair with the key {@code
* key}.
*/
- boolean containsKey(@CompatibleWith("K") @CheckForNull 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") @CheckForNull 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") @CheckForNull Object key,
- @CompatibleWith("V") @CheckForNull Object value);
+ @CompatibleWith("K") @Nullable Object key, @CompatibleWith("V") @Nullable Object value);
// Modification Operations
@@ -214,7 +211,7 @@
* multimap already contained the key-value pair and doesn't allow duplicates
*/
@CanIgnoreReturnValue
- boolean put(@ParametricNullness K key, @ParametricNullness 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
@@ -225,8 +222,7 @@
*/
@CanIgnoreReturnValue
boolean remove(
- @CompatibleWith("K") @CheckForNull Object key,
- @CompatibleWith("V") @CheckForNull Object value);
+ @CompatibleWith("K") @Nullable Object key, @CompatibleWith("V") @Nullable Object value);
// Bulk Operations
@@ -245,7 +241,7 @@
* @return {@code true} if the multimap changed
*/
@CanIgnoreReturnValue
- boolean putAll(@ParametricNullness K key, Iterable<? extends V> values);
+ boolean putAll(@Nullable K key, Iterable<? extends V> values);
/**
* Stores all key-value pairs of {@code multimap} in this multimap, in the order returned by
@@ -266,7 +262,7 @@
* no effect on the multimap.
*/
@CanIgnoreReturnValue
- Collection<V> replaceValues(@ParametricNullness K key, Iterable<? extends V> values);
+ Collection<V> replaceValues(@Nullable K key, Iterable<? extends V> values);
/**
* Removes all values associated with the key {@code key}.
@@ -278,7 +274,7 @@
* modifiable, but updating it will have no effect on the multimap.
*/
@CanIgnoreReturnValue
- Collection<V> removeAll(@CompatibleWith("K") @CheckForNull Object key);
+ Collection<V> removeAll(@CompatibleWith("K") @Nullable Object key);
/** Removes all key-value pairs from the multimap, leaving it {@linkplain #isEmpty empty}. */
void clear();
@@ -292,7 +288,7 @@
*
* <p>Changes to the returned collection will update the underlying multimap, and vice versa.
*/
- Collection<V> get(@ParametricNullness K key);
+ Collection<V> get(@Nullable K key);
/**
* Returns a view collection of all <i>distinct</i> keys contained in this multimap. Note that the
@@ -374,7 +370,7 @@
* multimaps are equal, because they both have empty {@link #asMap} views.
*/
@Override
- boolean equals(@CheckForNull Object obj);
+ boolean equals(@Nullable Object obj);
/**
* Returns the hash code for this multimap.
diff --git a/guava/src/com/google/common/collect/MultimapBuilder.java b/guava/src/com/google/common/collect/MultimapBuilder.java
index dddae28..161c29d 100644
--- a/guava/src/com/google/common/collect/MultimapBuilder.java
+++ b/guava/src/com/google/common/collect/MultimapBuilder.java
@@ -34,7 +34,6 @@
import java.util.SortedSet;
import java.util.TreeMap;
import java.util.TreeSet;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* A builder for a multimap implementation that allows customization of the backing map and value
@@ -62,8 +61,7 @@
* @since 16.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-public abstract class MultimapBuilder<K0 extends @Nullable Object, V0 extends @Nullable Object> {
+public abstract class MultimapBuilder<K0, V0> {
/*
* Leaving K and V as upper bounds rather than the actual key and value types allows type
* parameters to be left implicit more often. CacheBuilder uses the same technique.
@@ -74,7 +72,7 @@
private static final int DEFAULT_EXPECTED_KEYS = 8;
/** Uses a hash table to map keys to value collections. */
- public static MultimapBuilderWithKeys<@Nullable Object> hashKeys() {
+ public static MultimapBuilderWithKeys<Object> hashKeys() {
return hashKeys(DEFAULT_EXPECTED_KEYS);
}
@@ -84,11 +82,11 @@
*
* @throws IllegalArgumentException if {@code expectedKeys < 0}
*/
- public static MultimapBuilderWithKeys<@Nullable Object> hashKeys(final int expectedKeys) {
+ public static MultimapBuilderWithKeys<Object> hashKeys(final int expectedKeys) {
checkNonnegative(expectedKeys, "expectedKeys");
- return new MultimapBuilderWithKeys<@Nullable Object>() {
+ return new MultimapBuilderWithKeys<Object>() {
@Override
- <K extends @Nullable Object, V extends @Nullable Object> Map<K, Collection<V>> createMap() {
+ <K, V> Map<K, Collection<V>> createMap() {
return Platform.newHashMapWithExpectedSize(expectedKeys);
}
};
@@ -102,7 +100,7 @@
* multimap, save that if all values associated with a key are removed and then the key is added
* back into the multimap, that key will come last in the key iteration order.
*/
- public static MultimapBuilderWithKeys<@Nullable Object> linkedHashKeys() {
+ public static MultimapBuilderWithKeys<Object> linkedHashKeys() {
return linkedHashKeys(DEFAULT_EXPECTED_KEYS);
}
@@ -115,11 +113,11 @@
* multimap, save that if all values associated with a key are removed and then the key is added
* back into the multimap, that key will come last in the key iteration order.
*/
- public static MultimapBuilderWithKeys<@Nullable Object> linkedHashKeys(final int expectedKeys) {
+ public static MultimapBuilderWithKeys<Object> linkedHashKeys(final int expectedKeys) {
checkNonnegative(expectedKeys, "expectedKeys");
- return new MultimapBuilderWithKeys<@Nullable Object>() {
+ return new MultimapBuilderWithKeys<Object>() {
@Override
- <K extends @Nullable Object, V extends @Nullable Object> Map<K, Collection<V>> createMap() {
+ <K, V> Map<K, Collection<V>> createMap() {
return Platform.newLinkedHashMapWithExpectedSize(expectedKeys);
}
};
@@ -153,12 +151,11 @@
* <p>Multimaps generated by the resulting builder will not be serializable if {@code comparator}
* is not serializable.
*/
- public static <K0 extends @Nullable Object> MultimapBuilderWithKeys<K0> treeKeys(
- final Comparator<K0> comparator) {
+ public static <K0> MultimapBuilderWithKeys<K0> treeKeys(final Comparator<K0> comparator) {
checkNotNull(comparator);
return new MultimapBuilderWithKeys<K0>() {
@Override
- <K extends K0, V extends @Nullable Object> Map<K, Collection<V>> createMap() {
+ <K extends K0, V> Map<K, Collection<V>> createMap() {
return new TreeMap<>(comparator);
}
};
@@ -175,7 +172,7 @@
return new MultimapBuilderWithKeys<K0>() {
@SuppressWarnings("unchecked")
@Override
- <K extends K0, V extends @Nullable Object> Map<K, Collection<V>> createMap() {
+ <K extends K0, V> Map<K, Collection<V>> createMap() {
// K must actually be K0, since enums are effectively final
// (their subclasses are inaccessible)
return (Map<K, Collection<V>>) new EnumMap<K0, Collection<V>>(keyClass);
@@ -183,8 +180,7 @@
};
}
- private static final class ArrayListSupplier<V extends @Nullable Object>
- implements Supplier<List<V>>, Serializable {
+ private static final class ArrayListSupplier<V> implements Supplier<List<V>>, Serializable {
private final int expectedValuesPerKey;
ArrayListSupplier(int expectedValuesPerKey) {
@@ -197,10 +193,10 @@
}
}
- private enum LinkedListSupplier implements Supplier<List<?>> {
+ private enum LinkedListSupplier implements Supplier<List<Object>> {
INSTANCE;
- public static <V extends @Nullable Object> Supplier<List<V>> instance() {
+ public static <V> Supplier<List<V>> instance() {
// Each call generates a fresh LinkedList, which can serve as a List<V> for any V.
@SuppressWarnings({"rawtypes", "unchecked"})
Supplier<List<V>> result = (Supplier) INSTANCE;
@@ -208,13 +204,12 @@
}
@Override
- public List<?> get() {
+ public List<Object> get() {
return new LinkedList<>();
}
}
- private static final class HashSetSupplier<V extends @Nullable Object>
- implements Supplier<Set<V>>, Serializable {
+ private static final class HashSetSupplier<V> implements Supplier<Set<V>>, Serializable {
private final int expectedValuesPerKey;
HashSetSupplier(int expectedValuesPerKey) {
@@ -227,8 +222,7 @@
}
}
- private static final class LinkedHashSetSupplier<V extends @Nullable Object>
- implements Supplier<Set<V>>, Serializable {
+ private static final class LinkedHashSetSupplier<V> implements Supplier<Set<V>>, Serializable {
private final int expectedValuesPerKey;
LinkedHashSetSupplier(int expectedValuesPerKey) {
@@ -241,8 +235,7 @@
}
}
- private static final class TreeSetSupplier<V extends @Nullable Object>
- implements Supplier<SortedSet<V>>, Serializable {
+ private static final class TreeSetSupplier<V> implements Supplier<SortedSet<V>>, Serializable {
private final Comparator<? super V> comparator;
TreeSetSupplier(Comparator<? super V> comparator) {
@@ -276,16 +269,16 @@
* @param <K0> The upper bound on the key type of the generated multimap.
* @since 16.0
*/
- public abstract static class MultimapBuilderWithKeys<K0 extends @Nullable Object> {
+ public abstract static class MultimapBuilderWithKeys<K0> {
private static final int DEFAULT_EXPECTED_VALUES_PER_KEY = 2;
MultimapBuilderWithKeys() {}
- abstract <K extends K0, V extends @Nullable Object> Map<K, Collection<V>> createMap();
+ abstract <K extends K0, V> Map<K, Collection<V>> createMap();
/** Uses an {@link ArrayList} to store value collections. */
- public ListMultimapBuilder<K0, @Nullable Object> arrayListValues() {
+ public ListMultimapBuilder<K0, Object> arrayListValues() {
return arrayListValues(DEFAULT_EXPECTED_VALUES_PER_KEY);
}
@@ -295,12 +288,11 @@
*
* @throws IllegalArgumentException if {@code expectedValuesPerKey < 0}
*/
- public ListMultimapBuilder<K0, @Nullable Object> arrayListValues(
- final int expectedValuesPerKey) {
+ public ListMultimapBuilder<K0, Object> arrayListValues(final int expectedValuesPerKey) {
checkNonnegative(expectedValuesPerKey, "expectedValuesPerKey");
- return new ListMultimapBuilder<K0, @Nullable Object>() {
+ return new ListMultimapBuilder<K0, Object>() {
@Override
- public <K extends K0, V extends @Nullable Object> ListMultimap<K, V> build() {
+ public <K extends K0, V> ListMultimap<K, V> build() {
return Multimaps.newListMultimap(
MultimapBuilderWithKeys.this.<K, V>createMap(),
new ArrayListSupplier<V>(expectedValuesPerKey));
@@ -309,10 +301,10 @@
}
/** Uses a {@link LinkedList} to store value collections. */
- public ListMultimapBuilder<K0, @Nullable Object> linkedListValues() {
- return new ListMultimapBuilder<K0, @Nullable Object>() {
+ public ListMultimapBuilder<K0, Object> linkedListValues() {
+ return new ListMultimapBuilder<K0, Object>() {
@Override
- public <K extends K0, V extends @Nullable Object> ListMultimap<K, V> build() {
+ public <K extends K0, V> ListMultimap<K, V> build() {
return Multimaps.newListMultimap(
MultimapBuilderWithKeys.this.<K, V>createMap(), LinkedListSupplier.<V>instance());
}
@@ -320,7 +312,7 @@
}
/** Uses a hash-based {@code Set} to store value collections. */
- public SetMultimapBuilder<K0, @Nullable Object> hashSetValues() {
+ public SetMultimapBuilder<K0, Object> hashSetValues() {
return hashSetValues(DEFAULT_EXPECTED_VALUES_PER_KEY);
}
@@ -330,11 +322,11 @@
*
* @throws IllegalArgumentException if {@code expectedValuesPerKey < 0}
*/
- public SetMultimapBuilder<K0, @Nullable Object> hashSetValues(final int expectedValuesPerKey) {
+ public SetMultimapBuilder<K0, Object> hashSetValues(final int expectedValuesPerKey) {
checkNonnegative(expectedValuesPerKey, "expectedValuesPerKey");
- return new SetMultimapBuilder<K0, @Nullable Object>() {
+ return new SetMultimapBuilder<K0, Object>() {
@Override
- public <K extends K0, V extends @Nullable Object> SetMultimap<K, V> build() {
+ public <K extends K0, V> SetMultimap<K, V> build() {
return Multimaps.newSetMultimap(
MultimapBuilderWithKeys.this.<K, V>createMap(),
new HashSetSupplier<V>(expectedValuesPerKey));
@@ -343,7 +335,7 @@
}
/** Uses an insertion-ordered hash-based {@code Set} to store value collections. */
- public SetMultimapBuilder<K0, @Nullable Object> linkedHashSetValues() {
+ public SetMultimapBuilder<K0, Object> linkedHashSetValues() {
return linkedHashSetValues(DEFAULT_EXPECTED_VALUES_PER_KEY);
}
@@ -353,12 +345,11 @@
*
* @throws IllegalArgumentException if {@code expectedValuesPerKey < 0}
*/
- public SetMultimapBuilder<K0, @Nullable Object> linkedHashSetValues(
- final int expectedValuesPerKey) {
+ public SetMultimapBuilder<K0, Object> linkedHashSetValues(final int expectedValuesPerKey) {
checkNonnegative(expectedValuesPerKey, "expectedValuesPerKey");
- return new SetMultimapBuilder<K0, @Nullable Object>() {
+ return new SetMultimapBuilder<K0, Object>() {
@Override
- public <K extends K0, V extends @Nullable Object> SetMultimap<K, V> build() {
+ public <K extends K0, V> SetMultimap<K, V> build() {
return Multimaps.newSetMultimap(
MultimapBuilderWithKeys.this.<K, V>createMap(),
new LinkedHashSetSupplier<V>(expectedValuesPerKey));
@@ -378,8 +369,7 @@
* <p>Multimaps generated by the resulting builder will not be serializable if {@code
* comparator} is not serializable.
*/
- public <V0 extends @Nullable Object> SortedSetMultimapBuilder<K0, V0> treeSetValues(
- final Comparator<V0> comparator) {
+ public <V0> SortedSetMultimapBuilder<K0, V0> treeSetValues(final Comparator<V0> comparator) {
checkNotNull(comparator, "comparator");
return new SortedSetMultimapBuilder<K0, V0>() {
@Override
@@ -426,9 +416,7 @@
*
* @since 16.0
*/
- public abstract static class ListMultimapBuilder<
- K0 extends @Nullable Object, V0 extends @Nullable Object>
- extends MultimapBuilder<K0, V0> {
+ public abstract static class ListMultimapBuilder<K0, V0> extends MultimapBuilder<K0, V0> {
ListMultimapBuilder() {}
@Override
@@ -446,9 +434,7 @@
*
* @since 16.0
*/
- public abstract static class SetMultimapBuilder<
- K0 extends @Nullable Object, V0 extends @Nullable Object>
- extends MultimapBuilder<K0, V0> {
+ public abstract static class SetMultimapBuilder<K0, V0> extends MultimapBuilder<K0, V0> {
SetMultimapBuilder() {}
@Override
@@ -466,9 +452,7 @@
*
* @since 16.0
*/
- public abstract static class SortedSetMultimapBuilder<
- K0 extends @Nullable Object, V0 extends @Nullable Object>
- extends SetMultimapBuilder<K0, V0> {
+ public abstract static class SortedSetMultimapBuilder<K0, V0> extends SetMultimapBuilder<K0, V0> {
SortedSetMultimapBuilder() {}
@Override
diff --git a/guava/src/com/google/common/collect/Multimaps.java b/guava/src/com/google/common/collect/Multimaps.java
index 9bc9e98..f97191d 100644
--- a/guava/src/com/google/common/collect/Multimaps.java
+++ b/guava/src/com/google/common/collect/Multimaps.java
@@ -19,8 +19,6 @@
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.collect.CollectPreconditions.checkNonnegative;
import static com.google.common.collect.CollectPreconditions.checkRemove;
-import static com.google.common.collect.NullnessCasts.uncheckedCastNullableTToT;
-import static java.util.Objects.requireNonNull;
import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtCompatible;
@@ -31,7 +29,6 @@
import com.google.common.base.Supplier;
import com.google.common.collect.Maps.EntryTransformer;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
-import com.google.errorprone.annotations.concurrent.LazyInit;
import com.google.j2objc.annotations.Weak;
import com.google.j2objc.annotations.WeakOuter;
import java.io.IOException;
@@ -56,7 +53,6 @@
import java.util.function.Consumer;
import java.util.stream.Collector;
import java.util.stream.Stream;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -73,7 +69,6 @@
* @since 2.0
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
public final class Multimaps {
private Multimaps() {}
@@ -107,22 +102,22 @@
* }
* }</pre>
*
- * <p>To collect to an {@link ImmutableMultimap}, use either {@link
- * ImmutableSetMultimap#toImmutableSetMultimap} or {@link
- * ImmutableListMultimap#toImmutableListMultimap}.
- *
* @since 21.0
*/
- public static <
- T extends @Nullable Object,
- K extends @Nullable Object,
- V extends @Nullable Object,
- M extends Multimap<K, V>>
- Collector<T, ?, M> toMultimap(
- java.util.function.Function<? super T, ? extends K> keyFunction,
- java.util.function.Function<? super T, ? extends V> valueFunction,
- java.util.function.Supplier<M> multimapSupplier) {
- return CollectCollectors.toMultimap(keyFunction, valueFunction, multimapSupplier);
+ public static <T, K, V, M extends Multimap<K, V>> Collector<T, ?, M> toMultimap(
+ java.util.function.Function<? super T, ? extends K> keyFunction,
+ java.util.function.Function<? super T, ? extends V> valueFunction,
+ java.util.function.Supplier<M> multimapSupplier) {
+ checkNotNull(keyFunction);
+ checkNotNull(valueFunction);
+ checkNotNull(multimapSupplier);
+ return Collector.of(
+ multimapSupplier,
+ (multimap, input) -> multimap.put(keyFunction.apply(input), valueFunction.apply(input)),
+ (multimap1, multimap2) -> {
+ multimap1.putAll(multimap2);
+ return multimap1;
+ });
}
/**
@@ -159,16 +154,24 @@
* @since 21.0
*/
@Beta
- public static <
- T extends @Nullable Object,
- K extends @Nullable Object,
- V extends @Nullable Object,
- M extends Multimap<K, V>>
- Collector<T, ?, M> flatteningToMultimap(
- java.util.function.Function<? super T, ? extends K> keyFunction,
- java.util.function.Function<? super T, ? extends Stream<? extends V>> valueFunction,
- java.util.function.Supplier<M> multimapSupplier) {
- return CollectCollectors.flatteningToMultimap(keyFunction, valueFunction, multimapSupplier);
+ public static <T, K, V, M extends Multimap<K, V>> Collector<T, ?, M> flatteningToMultimap(
+ java.util.function.Function<? super T, ? extends K> keyFunction,
+ java.util.function.Function<? super T, ? extends Stream<? extends V>> valueFunction,
+ java.util.function.Supplier<M> multimapSupplier) {
+ checkNotNull(keyFunction);
+ checkNotNull(valueFunction);
+ checkNotNull(multimapSupplier);
+ return Collector.of(
+ multimapSupplier,
+ (multimap, input) -> {
+ K key = keyFunction.apply(input);
+ Collection<V> valuesForKey = multimap.get(key);
+ valueFunction.apply(input).forEachOrdered(valuesForKey::add);
+ },
+ (multimap1, multimap2) -> {
+ multimap1.putAll(multimap2);
+ return multimap1;
+ });
}
/**
@@ -207,13 +210,12 @@
* key
* @throws IllegalArgumentException if {@code map} is not empty
*/
- public static <K extends @Nullable Object, V extends @Nullable Object> Multimap<K, V> newMultimap(
+ public static <K, V> Multimap<K, V> newMultimap(
Map<K, Collection<V>> map, final Supplier<? extends Collection<V>> factory) {
return new CustomMultimap<>(map, factory);
}
- private static class CustomMultimap<K extends @Nullable Object, V extends @Nullable Object>
- extends AbstractMapBasedMultimap<K, V> {
+ private static class CustomMultimap<K, V> extends AbstractMapBasedMultimap<K, V> {
transient Supplier<? extends Collection<V>> factory;
CustomMultimap(Map<K, Collection<V>> map, Supplier<? extends Collection<V>> factory) {
@@ -237,8 +239,7 @@
}
@Override
- <E extends @Nullable Object> Collection<E> unmodifiableCollectionSubclass(
- Collection<E> collection) {
+ <E> Collection<E> unmodifiableCollectionSubclass(Collection<E> collection) {
if (collection instanceof NavigableSet) {
return Sets.unmodifiableNavigableSet((NavigableSet<E>) collection);
} else if (collection instanceof SortedSet) {
@@ -253,7 +254,7 @@
}
@Override
- Collection<V> wrapCollection(@ParametricNullness K key, Collection<V> collection) {
+ Collection<V> wrapCollection(K key, Collection<V> collection) {
if (collection instanceof List) {
return wrapList(key, (List<V>) collection, null);
} else if (collection instanceof NavigableSet) {
@@ -321,14 +322,12 @@
* @param factory supplier of new, empty lists that will each hold all values for a given key
* @throws IllegalArgumentException if {@code map} is not empty
*/
- public static <K extends @Nullable Object, V extends @Nullable Object>
- ListMultimap<K, V> newListMultimap(
- Map<K, Collection<V>> map, final Supplier<? extends List<V>> factory) {
+ public static <K, V> ListMultimap<K, V> newListMultimap(
+ Map<K, Collection<V>> map, final Supplier<? extends List<V>> factory) {
return new CustomListMultimap<>(map, factory);
}
- private static class CustomListMultimap<K extends @Nullable Object, V extends @Nullable Object>
- extends AbstractListMultimap<K, V> {
+ private static class CustomListMultimap<K, V> extends AbstractListMultimap<K, V> {
transient Supplier<? extends List<V>> factory;
CustomListMultimap(Map<K, Collection<V>> map, Supplier<? extends List<V>> factory) {
@@ -401,14 +400,12 @@
* @param factory supplier of new, empty sets that will each hold all values for a given key
* @throws IllegalArgumentException if {@code map} is not empty
*/
- public static <K extends @Nullable Object, V extends @Nullable Object>
- SetMultimap<K, V> newSetMultimap(
- Map<K, Collection<V>> map, final Supplier<? extends Set<V>> factory) {
+ public static <K, V> SetMultimap<K, V> newSetMultimap(
+ Map<K, Collection<V>> map, final Supplier<? extends Set<V>> factory) {
return new CustomSetMultimap<>(map, factory);
}
- private static class CustomSetMultimap<K extends @Nullable Object, V extends @Nullable Object>
- extends AbstractSetMultimap<K, V> {
+ private static class CustomSetMultimap<K, V> extends AbstractSetMultimap<K, V> {
transient Supplier<? extends Set<V>> factory;
CustomSetMultimap(Map<K, Collection<V>> map, Supplier<? extends Set<V>> factory) {
@@ -432,8 +429,7 @@
}
@Override
- <E extends @Nullable Object> Collection<E> unmodifiableCollectionSubclass(
- Collection<E> collection) {
+ <E> Collection<E> unmodifiableCollectionSubclass(Collection<E> collection) {
if (collection instanceof NavigableSet) {
return Sets.unmodifiableNavigableSet((NavigableSet<E>) collection);
} else if (collection instanceof SortedSet) {
@@ -444,7 +440,7 @@
}
@Override
- Collection<V> wrapCollection(@ParametricNullness K key, Collection<V> collection) {
+ Collection<V> wrapCollection(K key, Collection<V> collection) {
if (collection instanceof NavigableSet) {
return new WrappedNavigableSet(key, (NavigableSet<V>) collection, null);
} else if (collection instanceof SortedSet) {
@@ -504,17 +500,14 @@
* key
* @throws IllegalArgumentException if {@code map} is not empty
*/
- public static <K extends @Nullable Object, V extends @Nullable Object>
- SortedSetMultimap<K, V> newSortedSetMultimap(
- Map<K, Collection<V>> map, final Supplier<? extends SortedSet<V>> factory) {
+ public static <K, V> SortedSetMultimap<K, V> newSortedSetMultimap(
+ Map<K, Collection<V>> map, final Supplier<? extends SortedSet<V>> factory) {
return new CustomSortedSetMultimap<>(map, factory);
}
- private static class CustomSortedSetMultimap<
- K extends @Nullable Object, V extends @Nullable Object>
- extends AbstractSortedSetMultimap<K, V> {
+ private static class CustomSortedSetMultimap<K, V> extends AbstractSortedSetMultimap<K, V> {
transient Supplier<? extends SortedSet<V>> factory;
- @CheckForNull transient Comparator<? super V> valueComparator;
+ transient Comparator<? super V> valueComparator;
CustomSortedSetMultimap(Map<K, Collection<V>> map, Supplier<? extends SortedSet<V>> factory) {
super(map);
@@ -538,7 +531,6 @@
}
@Override
- @CheckForNull
public Comparator<? super V> valueComparator() {
return valueComparator;
}
@@ -577,8 +569,8 @@
* @return {@code dest}
*/
@CanIgnoreReturnValue
- public static <K extends @Nullable Object, V extends @Nullable Object, M extends Multimap<K, V>>
- M invertFrom(Multimap<? extends V, ? extends K> source, M dest) {
+ public static <K, V, M extends Multimap<K, V>> M invertFrom(
+ Multimap<? extends V, ? extends K> source, M dest) {
checkNotNull(dest);
for (Map.Entry<? extends V, ? extends K> entry : source.entries()) {
dest.put(entry.getValue(), entry.getKey());
@@ -618,8 +610,7 @@
* @param multimap the multimap to be wrapped in a synchronized view
* @return a synchronized view of the specified multimap
*/
- public static <K extends @Nullable Object, V extends @Nullable Object>
- Multimap<K, V> synchronizedMultimap(Multimap<K, V> multimap) {
+ public static <K, V> Multimap<K, V> synchronizedMultimap(Multimap<K, V> multimap) {
return Synchronized.multimap(multimap, null);
}
@@ -634,8 +625,7 @@
* @param delegate the multimap for which an unmodifiable view is to be returned
* @return an unmodifiable view of the specified multimap
*/
- public static <K extends @Nullable Object, V extends @Nullable Object>
- Multimap<K, V> unmodifiableMultimap(Multimap<K, V> delegate) {
+ public static <K, V> Multimap<K, V> unmodifiableMultimap(Multimap<K, V> delegate) {
if (delegate instanceof UnmodifiableMultimap || delegate instanceof ImmutableMultimap) {
return delegate;
}
@@ -653,14 +643,14 @@
return checkNotNull(delegate);
}
- private static class UnmodifiableMultimap<K extends @Nullable Object, V extends @Nullable Object>
- extends ForwardingMultimap<K, V> implements Serializable {
+ private static class UnmodifiableMultimap<K, V> extends ForwardingMultimap<K, V>
+ implements Serializable {
final Multimap<K, V> delegate;
- @LazyInit @CheckForNull transient Collection<Entry<K, V>> entries;
- @LazyInit @CheckForNull transient Multiset<K> keys;
- @LazyInit @CheckForNull transient Set<K> keySet;
- @LazyInit @CheckForNull transient Collection<V> values;
- @LazyInit @CheckForNull transient Map<K, Collection<V>> map;
+ transient @Nullable Collection<Entry<K, V>> entries;
+ transient @Nullable Multiset<K> keys;
+ transient @Nullable Set<K> keySet;
+ transient @Nullable Collection<V> values;
+ transient @Nullable Map<K, Collection<V>> map;
UnmodifiableMultimap(final Multimap<K, V> delegate) {
this.delegate = checkNotNull(delegate);
@@ -710,7 +700,7 @@
}
@Override
- public Collection<V> get(@ParametricNullness K key) {
+ public Collection<V> get(K key) {
return unmodifiableValueCollection(delegate.get(key));
}
@@ -733,12 +723,12 @@
}
@Override
- public boolean put(@ParametricNullness K key, @ParametricNullness V value) {
+ public boolean put(K key, V value) {
throw new UnsupportedOperationException();
}
@Override
- public boolean putAll(@ParametricNullness K key, Iterable<? extends V> values) {
+ public boolean putAll(K key, Iterable<? extends V> values) {
throw new UnsupportedOperationException();
}
@@ -748,17 +738,17 @@
}
@Override
- public boolean remove(@CheckForNull Object key, @CheckForNull Object value) {
+ public boolean remove(Object key, Object value) {
throw new UnsupportedOperationException();
}
@Override
- public Collection<V> removeAll(@CheckForNull Object key) {
+ public Collection<V> removeAll(Object key) {
throw new UnsupportedOperationException();
}
@Override
- public Collection<V> replaceValues(@ParametricNullness K key, Iterable<? extends V> values) {
+ public Collection<V> replaceValues(K key, Iterable<? extends V> values) {
throw new UnsupportedOperationException();
}
@@ -774,9 +764,8 @@
private static final long serialVersionUID = 0;
}
- private static class UnmodifiableListMultimap<
- K extends @Nullable Object, V extends @Nullable Object>
- extends UnmodifiableMultimap<K, V> implements ListMultimap<K, V> {
+ private static class UnmodifiableListMultimap<K, V> extends UnmodifiableMultimap<K, V>
+ implements ListMultimap<K, V> {
UnmodifiableListMultimap(ListMultimap<K, V> delegate) {
super(delegate);
}
@@ -787,26 +776,25 @@
}
@Override
- public List<V> get(@ParametricNullness K key) {
+ public List<V> get(K key) {
return Collections.unmodifiableList(delegate().get(key));
}
@Override
- public List<V> removeAll(@CheckForNull Object key) {
+ public List<V> removeAll(Object key) {
throw new UnsupportedOperationException();
}
@Override
- public List<V> replaceValues(@ParametricNullness K key, Iterable<? extends V> values) {
+ public List<V> replaceValues(K key, Iterable<? extends V> values) {
throw new UnsupportedOperationException();
}
private static final long serialVersionUID = 0;
}
- private static class UnmodifiableSetMultimap<
- K extends @Nullable Object, V extends @Nullable Object>
- extends UnmodifiableMultimap<K, V> implements SetMultimap<K, V> {
+ private static class UnmodifiableSetMultimap<K, V> extends UnmodifiableMultimap<K, V>
+ implements SetMultimap<K, V> {
UnmodifiableSetMultimap(SetMultimap<K, V> delegate) {
super(delegate);
}
@@ -817,7 +805,7 @@
}
@Override
- public Set<V> get(@ParametricNullness K key) {
+ public Set<V> get(K key) {
/*
* Note that this doesn't return a SortedSet when delegate is a
* SortedSetMultiset, unlike (SortedSet<V>) super.get().
@@ -831,21 +819,20 @@
}
@Override
- public Set<V> removeAll(@CheckForNull Object key) {
+ public Set<V> removeAll(Object key) {
throw new UnsupportedOperationException();
}
@Override
- public Set<V> replaceValues(@ParametricNullness K key, Iterable<? extends V> values) {
+ public Set<V> replaceValues(K key, Iterable<? extends V> values) {
throw new UnsupportedOperationException();
}
private static final long serialVersionUID = 0;
}
- private static class UnmodifiableSortedSetMultimap<
- K extends @Nullable Object, V extends @Nullable Object>
- extends UnmodifiableSetMultimap<K, V> implements SortedSetMultimap<K, V> {
+ private static class UnmodifiableSortedSetMultimap<K, V> extends UnmodifiableSetMultimap<K, V>
+ implements SortedSetMultimap<K, V> {
UnmodifiableSortedSetMultimap(SortedSetMultimap<K, V> delegate) {
super(delegate);
}
@@ -856,22 +843,21 @@
}
@Override
- public SortedSet<V> get(@ParametricNullness K key) {
+ public SortedSet<V> get(K key) {
return Collections.unmodifiableSortedSet(delegate().get(key));
}
@Override
- public SortedSet<V> removeAll(@CheckForNull Object key) {
+ public SortedSet<V> removeAll(Object key) {
throw new UnsupportedOperationException();
}
@Override
- public SortedSet<V> replaceValues(@ParametricNullness K key, Iterable<? extends V> values) {
+ public SortedSet<V> replaceValues(K key, Iterable<? extends V> values) {
throw new UnsupportedOperationException();
}
@Override
- @CheckForNull
public Comparator<? super V> valueComparator() {
return delegate().valueComparator();
}
@@ -889,8 +875,7 @@
* @param multimap the multimap to be wrapped
* @return a synchronized view of the specified multimap
*/
- public static <K extends @Nullable Object, V extends @Nullable Object>
- SetMultimap<K, V> synchronizedSetMultimap(SetMultimap<K, V> multimap) {
+ public static <K, V> SetMultimap<K, V> synchronizedSetMultimap(SetMultimap<K, V> multimap) {
return Synchronized.setMultimap(multimap, null);
}
@@ -905,8 +890,7 @@
* @param delegate the multimap for which an unmodifiable view is to be returned
* @return an unmodifiable view of the specified multimap
*/
- public static <K extends @Nullable Object, V extends @Nullable Object>
- SetMultimap<K, V> unmodifiableSetMultimap(SetMultimap<K, V> delegate) {
+ public static <K, V> SetMultimap<K, V> unmodifiableSetMultimap(SetMultimap<K, V> delegate) {
if (delegate instanceof UnmodifiableSetMultimap || delegate instanceof ImmutableSetMultimap) {
return delegate;
}
@@ -936,8 +920,8 @@
* @param multimap the multimap to be wrapped
* @return a synchronized view of the specified multimap
*/
- public static <K extends @Nullable Object, V extends @Nullable Object>
- SortedSetMultimap<K, V> synchronizedSortedSetMultimap(SortedSetMultimap<K, V> multimap) {
+ public static <K, V> SortedSetMultimap<K, V> synchronizedSortedSetMultimap(
+ SortedSetMultimap<K, V> multimap) {
return Synchronized.sortedSetMultimap(multimap, null);
}
@@ -952,8 +936,8 @@
* @param delegate the multimap for which an unmodifiable view is to be returned
* @return an unmodifiable view of the specified multimap
*/
- public static <K extends @Nullable Object, V extends @Nullable Object>
- SortedSetMultimap<K, V> unmodifiableSortedSetMultimap(SortedSetMultimap<K, V> delegate) {
+ public static <K, V> SortedSetMultimap<K, V> unmodifiableSortedSetMultimap(
+ SortedSetMultimap<K, V> delegate) {
if (delegate instanceof UnmodifiableSortedSetMultimap) {
return delegate;
}
@@ -968,8 +952,7 @@
* @param multimap the multimap to be wrapped
* @return a synchronized view of the specified multimap
*/
- public static <K extends @Nullable Object, V extends @Nullable Object>
- ListMultimap<K, V> synchronizedListMultimap(ListMultimap<K, V> multimap) {
+ public static <K, V> ListMultimap<K, V> synchronizedListMultimap(ListMultimap<K, V> multimap) {
return Synchronized.listMultimap(multimap, null);
}
@@ -984,8 +967,7 @@
* @param delegate the multimap for which an unmodifiable view is to be returned
* @return an unmodifiable view of the specified multimap
*/
- public static <K extends @Nullable Object, V extends @Nullable Object>
- ListMultimap<K, V> unmodifiableListMultimap(ListMultimap<K, V> delegate) {
+ public static <K, V> ListMultimap<K, V> unmodifiableListMultimap(ListMultimap<K, V> delegate) {
if (delegate instanceof UnmodifiableListMultimap || delegate instanceof ImmutableListMultimap) {
return delegate;
}
@@ -1012,8 +994,7 @@
* @param collection the collection for which to return an unmodifiable view
* @return an unmodifiable view of the collection
*/
- private static <V extends @Nullable Object> Collection<V> unmodifiableValueCollection(
- Collection<V> collection) {
+ private static <V> Collection<V> unmodifiableValueCollection(Collection<V> collection) {
if (collection instanceof SortedSet) {
return Collections.unmodifiableSortedSet((SortedSet<V>) collection);
} else if (collection instanceof Set) {
@@ -1032,8 +1013,8 @@
* @param entries the entries for which to return an unmodifiable view
* @return an unmodifiable view of the entries
*/
- private static <K extends @Nullable Object, V extends @Nullable Object>
- Collection<Entry<K, V>> unmodifiableEntries(Collection<Entry<K, V>> entries) {
+ private static <K, V> Collection<Entry<K, V>> unmodifiableEntries(
+ Collection<Entry<K, V>> entries) {
if (entries instanceof Set) {
return Maps.unmodifiableEntrySet((Set<Entry<K, V>>) entries);
}
@@ -1049,8 +1030,7 @@
@Beta
@SuppressWarnings("unchecked")
// safe by specification of ListMultimap.asMap()
- public static <K extends @Nullable Object, V extends @Nullable Object> Map<K, List<V>> asMap(
- ListMultimap<K, V> multimap) {
+ public static <K, V> Map<K, List<V>> asMap(ListMultimap<K, V> multimap) {
return (Map<K, List<V>>) (Map<K, ?>) multimap.asMap();
}
@@ -1063,8 +1043,7 @@
@Beta
@SuppressWarnings("unchecked")
// safe by specification of SetMultimap.asMap()
- public static <K extends @Nullable Object, V extends @Nullable Object> Map<K, Set<V>> asMap(
- SetMultimap<K, V> multimap) {
+ public static <K, V> Map<K, Set<V>> asMap(SetMultimap<K, V> multimap) {
return (Map<K, Set<V>>) (Map<K, ?>) multimap.asMap();
}
@@ -1077,8 +1056,7 @@
@Beta
@SuppressWarnings("unchecked")
// safe by specification of SortedSetMultimap.asMap()
- public static <K extends @Nullable Object, V extends @Nullable Object> Map<K, SortedSet<V>> asMap(
- SortedSetMultimap<K, V> multimap) {
+ public static <K, V> Map<K, SortedSet<V>> asMap(SortedSetMultimap<K, V> multimap) {
return (Map<K, SortedSet<V>>) (Map<K, ?>) multimap.asMap();
}
@@ -1089,8 +1067,7 @@
* @since 15.0
*/
@Beta
- public static <K extends @Nullable Object, V extends @Nullable Object>
- Map<K, Collection<V>> asMap(Multimap<K, V> multimap) {
+ public static <K, V> Map<K, Collection<V>> asMap(Multimap<K, V> multimap) {
return multimap.asMap();
}
@@ -1109,14 +1086,13 @@
*
* @param map the backing map for the returned multimap view
*/
- public static <K extends @Nullable Object, V extends @Nullable Object> SetMultimap<K, V> forMap(
- Map<K, V> map) {
+ public static <K, V> SetMultimap<K, V> forMap(Map<K, V> map) {
return new MapMultimap<>(map);
}
/** @see Multimaps#forMap */
- private static class MapMultimap<K extends @Nullable Object, V extends @Nullable Object>
- extends AbstractMultimap<K, V> implements SetMultimap<K, V>, Serializable {
+ private static class MapMultimap<K, V> extends AbstractMultimap<K, V>
+ implements SetMultimap<K, V>, Serializable {
final Map<K, V> map;
MapMultimap(Map<K, V> map) {
@@ -1129,22 +1105,22 @@
}
@Override
- public boolean containsKey(@CheckForNull Object key) {
+ public boolean containsKey(Object key) {
return map.containsKey(key);
}
@Override
- public boolean containsValue(@CheckForNull Object value) {
+ public boolean containsValue(Object value) {
return map.containsValue(value);
}
@Override
- public boolean containsEntry(@CheckForNull Object key, @CheckForNull Object value) {
+ public boolean containsEntry(Object key, Object value) {
return map.entrySet().contains(Maps.immutableEntry(key, value));
}
@Override
- public Set<V> get(@ParametricNullness final K key) {
+ public Set<V> get(final K key) {
return new Sets.ImprovedAbstractSet<V>() {
@Override
public Iterator<V> iterator() {
@@ -1157,17 +1133,12 @@
}
@Override
- @ParametricNullness
public V next() {
if (!hasNext()) {
throw new NoSuchElementException();
}
i++;
- /*
- * The cast is safe because of the containsKey check in hasNext(). (That means it's
- * unsafe under concurrent modification, but all bets are off then, anyway.)
- */
- return uncheckedCastNullableTToT(map.get(key));
+ return map.get(key);
}
@Override
@@ -1187,12 +1158,12 @@
}
@Override
- public boolean put(@ParametricNullness K key, @ParametricNullness V value) {
+ public boolean put(K key, V value) {
throw new UnsupportedOperationException();
}
@Override
- public boolean putAll(@ParametricNullness K key, Iterable<? extends V> values) {
+ public boolean putAll(K key, Iterable<? extends V> values) {
throw new UnsupportedOperationException();
}
@@ -1202,17 +1173,17 @@
}
@Override
- public Set<V> replaceValues(@ParametricNullness K key, Iterable<? extends V> values) {
+ public Set<V> replaceValues(K key, Iterable<? extends V> values) {
throw new UnsupportedOperationException();
}
@Override
- public boolean remove(@CheckForNull Object key, @CheckForNull Object value) {
+ public boolean remove(Object key, Object value) {
return map.entrySet().remove(Maps.immutableEntry(key, value));
}
@Override
- public Set<V> removeAll(@CheckForNull Object key) {
+ public Set<V> removeAll(Object key) {
Set<V> values = new HashSet<V>(2);
if (!map.containsKey(key)) {
return values;
@@ -1310,10 +1281,8 @@
*
* @since 7.0
*/
- public static <
- K extends @Nullable Object, V1 extends @Nullable Object, V2 extends @Nullable Object>
- Multimap<K, V2> transformValues(
- Multimap<K, V1> fromMultimap, final Function<? super V1, V2> function) {
+ public static <K, V1, V2> Multimap<K, V2> transformValues(
+ Multimap<K, V1> fromMultimap, final Function<? super V1, V2> function) {
checkNotNull(function);
EntryTransformer<K, V1, V2> transformer = Maps.asEntryTransformer(function);
return transformEntries(fromMultimap, transformer);
@@ -1359,10 +1328,8 @@
*
* @since 7.0
*/
- public static <
- K extends @Nullable Object, V1 extends @Nullable Object, V2 extends @Nullable Object>
- ListMultimap<K, V2> transformValues(
- ListMultimap<K, V1> fromMultimap, final Function<? super V1, V2> function) {
+ public static <K, V1, V2> ListMultimap<K, V2> transformValues(
+ ListMultimap<K, V1> fromMultimap, final Function<? super V1, V2> function) {
checkNotNull(function);
EntryTransformer<K, V1, V2> transformer = Maps.asEntryTransformer(function);
return transformEntries(fromMultimap, transformer);
@@ -1419,10 +1386,8 @@
*
* @since 7.0
*/
- public static <
- K extends @Nullable Object, V1 extends @Nullable Object, V2 extends @Nullable Object>
- Multimap<K, V2> transformEntries(
- Multimap<K, V1> fromMap, EntryTransformer<? super K, ? super V1, V2> transformer) {
+ public static <K, V1, V2> Multimap<K, V2> transformEntries(
+ Multimap<K, V1> fromMap, EntryTransformer<? super K, ? super V1, V2> transformer) {
return new TransformedEntriesMultimap<>(fromMap, transformer);
}
@@ -1474,16 +1439,12 @@
*
* @since 7.0
*/
- public static <
- K extends @Nullable Object, V1 extends @Nullable Object, V2 extends @Nullable Object>
- ListMultimap<K, V2> transformEntries(
- ListMultimap<K, V1> fromMap, EntryTransformer<? super K, ? super V1, V2> transformer) {
+ public static <K, V1, V2> ListMultimap<K, V2> transformEntries(
+ ListMultimap<K, V1> fromMap, EntryTransformer<? super K, ? super V1, V2> transformer) {
return new TransformedEntriesListMultimap<>(fromMap, transformer);
}
- private static class TransformedEntriesMultimap<
- K extends @Nullable Object, V1 extends @Nullable Object, V2 extends @Nullable Object>
- extends AbstractMultimap<K, V2> {
+ private static class TransformedEntriesMultimap<K, V1, V2> extends AbstractMultimap<K, V2> {
final Multimap<K, V1> fromMultimap;
final EntryTransformer<? super K, ? super V1, V2> transformer;
@@ -1494,7 +1455,7 @@
this.transformer = checkNotNull(transformer);
}
- Collection<V2> transform(@ParametricNullness K key, Collection<V1> values) {
+ Collection<V2> transform(K key, Collection<V1> values) {
Function<? super V1, V2> function = Maps.asValueToValueFunction(transformer, key);
if (values instanceof List) {
return Lists.transform((List<V1>) values, function);
@@ -1509,7 +1470,7 @@
fromMultimap.asMap(),
new EntryTransformer<K, Collection<V1>, Collection<V2>>() {
@Override
- public Collection<V2> transformEntry(@ParametricNullness K key, Collection<V1> value) {
+ public Collection<V2> transformEntry(K key, Collection<V1> value) {
return transform(key, value);
}
});
@@ -1521,7 +1482,7 @@
}
@Override
- public boolean containsKey(@CheckForNull Object key) {
+ public boolean containsKey(Object key) {
return fromMultimap.containsKey(key);
}
@@ -1537,7 +1498,7 @@
}
@Override
- public Collection<V2> get(@ParametricNullness final K key) {
+ public Collection<V2> get(final K key) {
return transform(key, fromMultimap.get(key));
}
@@ -1557,12 +1518,12 @@
}
@Override
- public boolean put(@ParametricNullness K key, @ParametricNullness V2 value) {
+ public boolean put(K key, V2 value) {
throw new UnsupportedOperationException();
}
@Override
- public boolean putAll(@ParametricNullness K key, Iterable<? extends V2> values) {
+ public boolean putAll(K key, Iterable<? extends V2> values) {
throw new UnsupportedOperationException();
}
@@ -1573,18 +1534,18 @@
@SuppressWarnings("unchecked")
@Override
- public boolean remove(@CheckForNull Object key, @CheckForNull Object value) {
+ public boolean remove(Object key, Object value) {
return get((K) key).remove(value);
}
@SuppressWarnings("unchecked")
@Override
- public Collection<V2> removeAll(@CheckForNull Object key) {
+ public Collection<V2> removeAll(Object key) {
return transform((K) key, fromMultimap.removeAll(key));
}
@Override
- public Collection<V2> replaceValues(@ParametricNullness K key, Iterable<? extends V2> values) {
+ public Collection<V2> replaceValues(K key, Iterable<? extends V2> values) {
throw new UnsupportedOperationException();
}
@@ -1600,8 +1561,7 @@
}
}
- private static final class TransformedEntriesListMultimap<
- K extends @Nullable Object, V1 extends @Nullable Object, V2 extends @Nullable Object>
+ private static final class TransformedEntriesListMultimap<K, V1, V2>
extends TransformedEntriesMultimap<K, V1, V2> implements ListMultimap<K, V2> {
TransformedEntriesListMultimap(
@@ -1610,23 +1570,23 @@
}
@Override
- List<V2> transform(@ParametricNullness K key, Collection<V1> values) {
+ List<V2> transform(K key, Collection<V1> values) {
return Lists.transform((List<V1>) values, Maps.asValueToValueFunction(transformer, key));
}
@Override
- public List<V2> get(@ParametricNullness K key) {
+ public List<V2> get(K key) {
return transform(key, fromMultimap.get(key));
}
@SuppressWarnings("unchecked")
@Override
- public List<V2> removeAll(@CheckForNull Object key) {
+ public List<V2> removeAll(Object key) {
return transform((K) key, fromMultimap.removeAll(key));
}
@Override
- public List<V2> replaceValues(@ParametricNullness K key, Iterable<? extends V2> values) {
+ public List<V2> replaceValues(K key, Iterable<? extends V2> values) {
throw new UnsupportedOperationException();
}
}
@@ -1719,8 +1679,7 @@
return builder.build();
}
- static class Keys<K extends @Nullable Object, V extends @Nullable Object>
- extends AbstractMultiset<K> {
+ static class Keys<K, V> extends AbstractMultiset<K> {
@Weak final Multimap<K, V> multimap;
Keys(Multimap<K, V> multimap) {
@@ -1735,7 +1694,6 @@
Multiset.Entry<K> transform(final Map.Entry<K, Collection<V>> backingEntry) {
return new Multisets.AbstractEntry<K>() {
@Override
- @ParametricNullness
public K getElement() {
return backingEntry.getKey();
}
@@ -1771,7 +1729,7 @@
}
@Override
- public boolean contains(@CheckForNull Object element) {
+ public boolean contains(@Nullable Object element) {
return multimap.containsKey(element);
}
@@ -1781,13 +1739,13 @@
}
@Override
- public int count(@CheckForNull Object element) {
+ public int count(@Nullable Object element) {
Collection<V> values = Maps.safeGet(multimap.asMap(), element);
return (values == null) ? 0 : values.size();
}
@Override
- public int remove(@CheckForNull Object element, int occurrences) {
+ public int remove(@Nullable Object element, int occurrences) {
checkNonnegative(occurrences, "occurrences");
if (occurrences == 0) {
return count(element);
@@ -1829,8 +1787,7 @@
}
/** A skeleton implementation of {@link Multimap#entries()}. */
- abstract static class Entries<K extends @Nullable Object, V extends @Nullable Object>
- extends AbstractCollection<Map.Entry<K, V>> {
+ abstract static class Entries<K, V> extends AbstractCollection<Map.Entry<K, V>> {
abstract Multimap<K, V> multimap();
@Override
@@ -1839,7 +1796,7 @@
}
@Override
- public boolean contains(@CheckForNull 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());
@@ -1848,7 +1805,7 @@
}
@Override
- public boolean remove(@CheckForNull 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());
@@ -1863,8 +1820,7 @@
}
/** A skeleton implementation of {@link Multimap#asMap()}. */
- static final class AsMap<K extends @Nullable Object, V extends @Nullable Object>
- extends Maps.ViewCachingAbstractMap<K, Collection<V>> {
+ static final class AsMap<K, V> extends Maps.ViewCachingAbstractMap<K, Collection<V>> {
@Weak private final Multimap<K, V> multimap;
AsMap(Multimap<K, V> multimap) {
@@ -1881,7 +1837,7 @@
return new EntrySet();
}
- void removeValuesForKey(@CheckForNull Object key) {
+ void removeValuesForKey(Object key) {
multimap.keySet().remove(key);
}
@@ -1898,19 +1854,18 @@
multimap.keySet(),
new Function<K, Collection<V>>() {
@Override
- public Collection<V> apply(@ParametricNullness K key) {
+ public Collection<V> apply(K key) {
return multimap.get(key);
}
});
}
@Override
- public boolean remove(@CheckForNull Object o) {
+ public boolean remove(Object o) {
if (!contains(o)) {
return false;
}
- // requireNonNull is safe because of the contains check.
- Map.Entry<?, ?> entry = requireNonNull((Map.Entry<?, ?>) o);
+ Map.Entry<?, ?> entry = (Map.Entry<?, ?>) o;
removeValuesForKey(entry.getKey());
return true;
}
@@ -1918,14 +1873,12 @@
@SuppressWarnings("unchecked")
@Override
- @CheckForNull
- public Collection<V> get(@CheckForNull Object key) {
+ public Collection<V> get(Object key) {
return containsKey(key) ? multimap.get((K) key) : null;
}
@Override
- @CheckForNull
- public Collection<V> remove(@CheckForNull Object key) {
+ public Collection<V> remove(Object key) {
return containsKey(key) ? multimap.removeAll(key) : null;
}
@@ -1940,7 +1893,7 @@
}
@Override
- public boolean containsKey(@CheckForNull Object key) {
+ public boolean containsKey(Object key) {
return multimap.containsKey(key);
}
@@ -1977,7 +1930,7 @@
*
* @since 11.0
*/
- public static <K extends @Nullable Object, V extends @Nullable Object> Multimap<K, V> filterKeys(
+ public static <K, V> Multimap<K, V> filterKeys(
Multimap<K, V> unfiltered, final Predicate<? super K> keyPredicate) {
if (unfiltered instanceof SetMultimap) {
return filterKeys((SetMultimap<K, V>) unfiltered, keyPredicate);
@@ -2022,9 +1975,8 @@
*
* @since 14.0
*/
- public static <K extends @Nullable Object, V extends @Nullable Object>
- SetMultimap<K, V> filterKeys(
- SetMultimap<K, V> unfiltered, final Predicate<? super K> keyPredicate) {
+ public static <K, V> SetMultimap<K, V> filterKeys(
+ SetMultimap<K, V> unfiltered, final Predicate<? super K> keyPredicate) {
if (unfiltered instanceof FilteredKeySetMultimap) {
FilteredKeySetMultimap<K, V> prev = (FilteredKeySetMultimap<K, V>) unfiltered;
return new FilteredKeySetMultimap<>(
@@ -2064,9 +2016,8 @@
*
* @since 14.0
*/
- public static <K extends @Nullable Object, V extends @Nullable Object>
- ListMultimap<K, V> filterKeys(
- ListMultimap<K, V> unfiltered, final Predicate<? super K> keyPredicate) {
+ public static <K, V> ListMultimap<K, V> filterKeys(
+ ListMultimap<K, V> unfiltered, final Predicate<? super K> keyPredicate) {
if (unfiltered instanceof FilteredKeyListMultimap) {
FilteredKeyListMultimap<K, V> prev = (FilteredKeyListMultimap<K, V>) unfiltered;
return new FilteredKeyListMultimap<>(
@@ -2103,9 +2054,8 @@
*
* @since 11.0
*/
- public static <K extends @Nullable Object, V extends @Nullable Object>
- Multimap<K, V> filterValues(
- Multimap<K, V> unfiltered, final Predicate<? super V> valuePredicate) {
+ public static <K, V> Multimap<K, V> filterValues(
+ Multimap<K, V> unfiltered, final Predicate<? super V> valuePredicate) {
return filterEntries(unfiltered, Maps.<V>valuePredicateOnEntries(valuePredicate));
}
@@ -2136,9 +2086,8 @@
*
* @since 14.0
*/
- public static <K extends @Nullable Object, V extends @Nullable Object>
- SetMultimap<K, V> filterValues(
- SetMultimap<K, V> unfiltered, final Predicate<? super V> valuePredicate) {
+ public static <K, V> SetMultimap<K, V> filterValues(
+ SetMultimap<K, V> unfiltered, final Predicate<? super V> valuePredicate) {
return filterEntries(unfiltered, Maps.<V>valuePredicateOnEntries(valuePredicate));
}
@@ -2167,9 +2116,8 @@
*
* @since 11.0
*/
- public static <K extends @Nullable Object, V extends @Nullable Object>
- Multimap<K, V> filterEntries(
- Multimap<K, V> unfiltered, Predicate<? super Entry<K, V>> entryPredicate) {
+ public static <K, V> Multimap<K, V> filterEntries(
+ Multimap<K, V> unfiltered, Predicate<? super Entry<K, V>> entryPredicate) {
checkNotNull(entryPredicate);
if (unfiltered instanceof SetMultimap) {
return filterEntries((SetMultimap<K, V>) unfiltered, entryPredicate);
@@ -2204,9 +2152,8 @@
*
* @since 14.0
*/
- public static <K extends @Nullable Object, V extends @Nullable Object>
- SetMultimap<K, V> filterEntries(
- SetMultimap<K, V> unfiltered, Predicate<? super Entry<K, V>> entryPredicate) {
+ public static <K, V> SetMultimap<K, V> filterEntries(
+ SetMultimap<K, V> unfiltered, Predicate<? super Entry<K, V>> entryPredicate) {
checkNotNull(entryPredicate);
return (unfiltered instanceof FilteredSetMultimap)
? filterFiltered((FilteredSetMultimap<K, V>) unfiltered, entryPredicate)
@@ -2219,9 +2166,8 @@
* lead to a multimap whose removal operations would fail. This method combines the predicates to
* avoid that problem.
*/
- private static <K extends @Nullable Object, V extends @Nullable Object>
- Multimap<K, V> filterFiltered(
- FilteredMultimap<K, V> multimap, Predicate<? super Entry<K, V>> entryPredicate) {
+ private static <K, V> Multimap<K, V> filterFiltered(
+ FilteredMultimap<K, V> multimap, Predicate<? super Entry<K, V>> entryPredicate) {
Predicate<Entry<K, V>> predicate =
Predicates.<Entry<K, V>>and(multimap.entryPredicate(), entryPredicate);
return new FilteredEntryMultimap<>(multimap.unfiltered(), predicate);
@@ -2233,15 +2179,14 @@
* lead to a multimap whose removal operations would fail. This method combines the predicates to
* avoid that problem.
*/
- private static <K extends @Nullable Object, V extends @Nullable Object>
- SetMultimap<K, V> filterFiltered(
- FilteredSetMultimap<K, V> multimap, Predicate<? super Entry<K, V>> entryPredicate) {
+ private static <K, V> SetMultimap<K, V> filterFiltered(
+ FilteredSetMultimap<K, V> multimap, Predicate<? super Entry<K, V>> entryPredicate) {
Predicate<Entry<K, V>> predicate =
Predicates.<Entry<K, V>>and(multimap.entryPredicate(), entryPredicate);
return new FilteredEntrySetMultimap<>(multimap.unfiltered(), predicate);
}
- static boolean equalsImpl(Multimap<?, ?> multimap, @CheckForNull 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 e7c7d62..7fe885b 100644
--- a/guava/src/com/google/common/collect/Multiset.java
+++ b/guava/src/com/google/common/collect/Multiset.java
@@ -30,7 +30,6 @@
import java.util.Spliterator;
import java.util.function.Consumer;
import java.util.function.ObjIntConsumer;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -68,10 +67,6 @@
* <p>A multiset uses {@link Object#equals} to determine whether two instances should be considered
* "the same," <i>unless specified otherwise</i> by the implementation.
*
- * <p><b>Warning:</b> as with normal {@link Set}s, it is almost always a bad idea to modify an
- * element (in a way that affects its {@link Object#equals} behavior) while it is contained in a
- * multiset. Undefined behavior and bugs will result.
- *
* <p>Common implementations include {@link ImmutableMultiset}, {@link HashMultiset}, and {@link
* ConcurrentHashMultiset}.
*
@@ -87,8 +82,7 @@
* @since 2.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-public interface Multiset<E extends @Nullable Object> extends Collection<E> {
+public interface Multiset<E> extends Collection<E> {
// Query Operations
/**
@@ -113,7 +107,7 @@
* @return the number of occurrences of the element in this multiset; possibly zero but never
* negative
*/
- int count(@CompatibleWith("E") @CheckForNull Object element);
+ int count(@Nullable @CompatibleWith("E") Object element);
// Bulk Operations
@@ -136,7 +130,7 @@
* return normally.
*/
@CanIgnoreReturnValue
- int add(@ParametricNullness E element, int occurrences);
+ int add(@Nullable E element, int occurrences);
/**
* Adds a single occurrence of the specified element to this multiset.
@@ -159,7 +153,7 @@
*/
@CanIgnoreReturnValue
@Override
- boolean add(@ParametricNullness E element);
+ boolean add(E element);
/**
* Removes a number of occurrences of the specified element from this multiset. If the multiset
@@ -174,7 +168,7 @@
* @throws IllegalArgumentException if {@code occurrences} is negative
*/
@CanIgnoreReturnValue
- int remove(@CompatibleWith("E") @CheckForNull Object element, int occurrences);
+ int remove(@Nullable @CompatibleWith("E") Object element, int occurrences);
/**
* Removes a <i>single</i> occurrence of the specified element from this multiset, if present.
@@ -190,7 +184,7 @@
*/
@CanIgnoreReturnValue
@Override
- boolean remove(@CheckForNull Object element);
+ boolean remove(@Nullable Object element);
/**
* Adds or removes the necessary occurrences of an element such that the element attains the
@@ -206,7 +200,7 @@
* zero instead.
*/
@CanIgnoreReturnValue
- int setCount(@ParametricNullness E element, int count);
+ int setCount(E element, int count);
/**
* Conditionally sets the count of an element to a new value, as described in {@link
@@ -225,7 +219,7 @@
* implementor may optionally return {@code true} instead.
*/
@CanIgnoreReturnValue
- boolean setCount(@ParametricNullness E element, int oldCount, int newCount);
+ boolean setCount(E element, int oldCount, int newCount);
// Views
@@ -271,7 +265,7 @@
*
* @since 2.0
*/
- interface Entry<E extends @Nullable Object> {
+ interface Entry<E> {
/**
* Returns the multiset element corresponding to this entry. Multiple calls to this method
@@ -279,7 +273,6 @@
*
* @return the element corresponding to this entry
*/
- @ParametricNullness
E getElement();
/**
@@ -307,7 +300,7 @@
*/
@Override
// TODO(kevinb): check this wrt TreeMultiset?
- boolean equals(@CheckForNull Object o);
+ boolean equals(Object o);
/**
* {@inheritDoc}
@@ -355,7 +348,7 @@
*/
@Override
// TODO(kevinb): caveats about equivalence-relation?
- boolean equals(@CheckForNull Object object);
+ boolean equals(@Nullable Object object);
/**
* Returns the hash code for this multiset. This is defined as the sum of
@@ -401,7 +394,7 @@
* @return {@code true} if this multiset contains at least one occurrence of the element
*/
@Override
- boolean contains(@CheckForNull 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 e3203d2..36d146e 100644
--- a/guava/src/com/google/common/collect/Multisets.java
+++ b/guava/src/com/google/common/collect/Multisets.java
@@ -20,7 +20,6 @@
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.collect.CollectPreconditions.checkNonnegative;
import static com.google.common.collect.CollectPreconditions.checkRemove;
-import static java.util.Objects.requireNonNull;
import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtCompatible;
@@ -40,11 +39,7 @@
import java.util.NoSuchElementException;
import java.util.Set;
import java.util.Spliterator;
-import java.util.function.Function;
-import java.util.function.Supplier;
-import java.util.function.ToIntFunction;
import java.util.stream.Collector;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -60,7 +55,6 @@
* @since 2.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
public final class Multisets {
private Multisets() {}
@@ -76,17 +70,22 @@
* <p>Note that {@code stream.collect(toMultiset(function, e -> 1, supplier))} is equivalent to
* {@code stream.map(function).collect(Collectors.toCollection(supplier))}.
*
- * <p>To collect to an {@link ImmutableMultiset}, use {@link
- * ImmutableMultiset#toImmutableMultiset}.
- *
* @since 22.0
*/
- public static <T extends @Nullable Object, E extends @Nullable Object, M extends Multiset<E>>
- Collector<T, ?, M> toMultiset(
- Function<? super T, E> elementFunction,
- ToIntFunction<? super T> countFunction,
- Supplier<M> multisetSupplier) {
- return CollectCollectors.toMultiset(elementFunction, countFunction, multisetSupplier);
+ public static <T, E, M extends Multiset<E>> Collector<T, ?, M> toMultiset(
+ java.util.function.Function<? super T, E> elementFunction,
+ java.util.function.ToIntFunction<? super T> countFunction,
+ java.util.function.Supplier<M> multisetSupplier) {
+ checkNotNull(elementFunction);
+ checkNotNull(countFunction);
+ checkNotNull(multisetSupplier);
+ return Collector.of(
+ multisetSupplier,
+ (ms, t) -> ms.add(elementFunction.apply(t), countFunction.applyAsInt(t)),
+ (ms1, ms2) -> {
+ ms1.addAll(ms2);
+ return ms1;
+ });
}
/**
@@ -99,8 +98,7 @@
* @param multiset the multiset for which an unmodifiable view is to be generated
* @return an unmodifiable view of the multiset
*/
- public static <E extends @Nullable Object> Multiset<E> unmodifiableMultiset(
- Multiset<? extends E> multiset) {
+ public static <E> Multiset<E> unmodifiableMultiset(Multiset<? extends E> multiset) {
if (multiset instanceof UnmodifiableMultiset || multiset instanceof ImmutableMultiset) {
@SuppressWarnings("unchecked") // Since it's unmodifiable, the covariant cast is safe
Multiset<E> result = (Multiset<E>) multiset;
@@ -120,8 +118,7 @@
return checkNotNull(multiset);
}
- static class UnmodifiableMultiset<E extends @Nullable Object> extends ForwardingMultiset<E>
- implements Serializable {
+ static class UnmodifiableMultiset<E> extends ForwardingMultiset<E> implements Serializable {
final Multiset<? extends E> delegate;
UnmodifiableMultiset(Multiset<? extends E> delegate) {
@@ -135,7 +132,7 @@
return (Multiset<E>) delegate;
}
- @CheckForNull transient Set<E> elementSet;
+ transient @Nullable Set<E> elementSet;
Set<E> createElementSet() {
return Collections.<E>unmodifiableSet(delegate.elementSet());
@@ -147,7 +144,7 @@
return (es == null) ? elementSet = createElementSet() : es;
}
- @CheckForNull transient Set<Multiset.Entry<E>> entrySet;
+ transient @Nullable Set<Multiset.Entry<E>> entrySet;
@SuppressWarnings("unchecked")
@Override
@@ -166,12 +163,12 @@
}
@Override
- public boolean add(@ParametricNullness E element) {
+ public boolean add(E element) {
throw new UnsupportedOperationException();
}
@Override
- public int add(@ParametricNullness E element, int occurrences) {
+ public int add(E element, int occurences) {
throw new UnsupportedOperationException();
}
@@ -181,12 +178,12 @@
}
@Override
- public boolean remove(@CheckForNull Object element) {
+ public boolean remove(Object element) {
throw new UnsupportedOperationException();
}
@Override
- public int remove(@CheckForNull Object element, int occurrences) {
+ public int remove(Object element, int occurrences) {
throw new UnsupportedOperationException();
}
@@ -206,12 +203,12 @@
}
@Override
- public int setCount(@ParametricNullness E element, int count) {
+ public int setCount(E element, int count) {
throw new UnsupportedOperationException();
}
@Override
- public boolean setCount(@ParametricNullness E element, int oldCount, int newCount) {
+ public boolean setCount(E element, int oldCount, int newCount) {
throw new UnsupportedOperationException();
}
@@ -230,8 +227,7 @@
* @since 11.0
*/
@Beta
- public static <E extends @Nullable Object> SortedMultiset<E> unmodifiableSortedMultiset(
- SortedMultiset<E> sortedMultiset) {
+ public static <E> SortedMultiset<E> unmodifiableSortedMultiset(SortedMultiset<E> sortedMultiset) {
// it's in its own file so it can be emulated for GWT
return new UnmodifiableSortedMultiset<E>(checkNotNull(sortedMultiset));
}
@@ -244,25 +240,22 @@
* @param n the count to be associated with the returned entry
* @throws IllegalArgumentException if {@code n} is negative
*/
- public static <E extends @Nullable Object> Multiset.Entry<E> immutableEntry(
- @ParametricNullness E e, int n) {
+ public static <E> Multiset.Entry<E> immutableEntry(@Nullable E e, int n) {
return new ImmutableEntry<E>(e, n);
}
- static class ImmutableEntry<E extends @Nullable Object> extends AbstractEntry<E>
- implements Serializable {
- @ParametricNullness private final E element;
+ static class ImmutableEntry<E> extends AbstractEntry<E> implements Serializable {
+ private final @Nullable E element;
private final int count;
- ImmutableEntry(@ParametricNullness E element, int count) {
+ ImmutableEntry(@Nullable E element, int count) {
this.element = element;
this.count = count;
checkNonnegative(count, "count");
}
@Override
- @ParametricNullness
- public final E getElement() {
+ public final @Nullable E getElement() {
return element;
}
@@ -271,7 +264,6 @@
return count;
}
- @CheckForNull
public ImmutableEntry<E> nextInBucket() {
return null;
}
@@ -305,8 +297,7 @@
* @since 14.0
*/
@Beta
- public static <E extends @Nullable Object> Multiset<E> filter(
- Multiset<E> unfiltered, Predicate<? super E> predicate) {
+ public static <E> Multiset<E> filter(Multiset<E> unfiltered, Predicate<? super E> predicate) {
if (unfiltered instanceof FilteredMultiset) {
// Support clear(), removeAll(), and retainAll() when filtering a filtered
// collection.
@@ -317,7 +308,7 @@
return new FilteredMultiset<E>(unfiltered, predicate);
}
- private static final class FilteredMultiset<E extends @Nullable Object> extends ViewMultiset<E> {
+ private static final class FilteredMultiset<E> extends ViewMultiset<E> {
final Multiset<E> unfiltered;
final Predicate<? super E> predicate;
@@ -359,7 +350,7 @@
}
@Override
- public int count(@CheckForNull Object element) {
+ public int count(@Nullable Object element) {
int count = unfiltered.count(element);
if (count > 0) {
@SuppressWarnings("unchecked") // element is equal to an E
@@ -370,14 +361,14 @@
}
@Override
- public int add(@ParametricNullness 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(@CheckForNull Object element, int occurrences) {
+ public int remove(@Nullable Object element, int occurrences) {
checkNonnegative(occurrences, "occurrences");
if (occurrences == 0) {
return count(element);
@@ -412,14 +403,14 @@
* @since 14.0
*/
@Beta
- public static <E extends @Nullable Object> Multiset<E> union(
+ public static <E> Multiset<E> union(
final Multiset<? extends E> multiset1, final Multiset<? extends E> multiset2) {
checkNotNull(multiset1);
checkNotNull(multiset2);
return new ViewMultiset<E>() {
@Override
- public boolean contains(@CheckForNull Object element) {
+ public boolean contains(@Nullable Object element) {
return multiset1.contains(element) || multiset2.contains(element);
}
@@ -429,7 +420,7 @@
}
@Override
- public int count(@CheckForNull Object element) {
+ public int count(Object element) {
return Math.max(multiset1.count(element), multiset2.count(element));
}
@@ -450,7 +441,6 @@
// TODO(lowasser): consider making the entries live views
return new AbstractIterator<Entry<E>>() {
@Override
- @CheckForNull
protected Entry<E> computeNext() {
if (iterator1.hasNext()) {
Entry<? extends E> entry1 = iterator1.next();
@@ -484,14 +474,14 @@
*
* @since 2.0
*/
- public static <E extends @Nullable Object> Multiset<E> intersection(
+ public static <E> Multiset<E> intersection(
final Multiset<E> multiset1, final Multiset<?> multiset2) {
checkNotNull(multiset1);
checkNotNull(multiset2);
return new ViewMultiset<E>() {
@Override
- public int count(@CheckForNull Object element) {
+ public int count(Object element) {
int count1 = multiset1.count(element);
return (count1 == 0) ? 0 : Math.min(count1, multiset2.count(element));
}
@@ -512,7 +502,6 @@
// TODO(lowasser): consider making the entries live views
return new AbstractIterator<Entry<E>>() {
@Override
- @CheckForNull
protected Entry<E> computeNext() {
while (iterator1.hasNext()) {
Entry<E> entry1 = iterator1.next();
@@ -542,7 +531,7 @@
* @since 14.0
*/
@Beta
- public static <E extends @Nullable Object> Multiset<E> sum(
+ public static <E> Multiset<E> sum(
final Multiset<? extends E> multiset1, final Multiset<? extends E> multiset2) {
checkNotNull(multiset1);
checkNotNull(multiset2);
@@ -550,7 +539,7 @@
// TODO(lowasser): consider making the entries live views
return new ViewMultiset<E>() {
@Override
- public boolean contains(@CheckForNull Object element) {
+ public boolean contains(@Nullable Object element) {
return multiset1.contains(element) || multiset2.contains(element);
}
@@ -565,7 +554,7 @@
}
@Override
- public int count(@CheckForNull Object element) {
+ public int count(Object element) {
return multiset1.count(element) + multiset2.count(element);
}
@@ -585,7 +574,6 @@
final Iterator<? extends Entry<? extends E>> iterator2 = multiset2.entrySet().iterator();
return new AbstractIterator<Entry<E>>() {
@Override
- @CheckForNull
protected Entry<E> computeNext() {
if (iterator1.hasNext()) {
Entry<? extends E> entry1 = iterator1.next();
@@ -620,7 +608,7 @@
* @since 14.0
*/
@Beta
- public static <E extends @Nullable Object> Multiset<E> difference(
+ public static <E> Multiset<E> difference(
final Multiset<E> multiset1, final Multiset<?> multiset2) {
checkNotNull(multiset1);
checkNotNull(multiset2);
@@ -628,7 +616,7 @@
// TODO(lowasser): consider making the entries live views
return new ViewMultiset<E>() {
@Override
- public int count(@CheckForNull Object element) {
+ public int count(@Nullable Object element) {
int count1 = multiset1.count(element);
return (count1 == 0) ? 0 : Math.max(0, count1 - multiset2.count(element));
}
@@ -643,7 +631,6 @@
final Iterator<Entry<E>> iterator1 = multiset1.entrySet().iterator();
return new AbstractIterator<E>() {
@Override
- @CheckForNull
protected E computeNext() {
while (iterator1.hasNext()) {
Entry<E> entry1 = iterator1.next();
@@ -662,7 +649,6 @@
final Iterator<Entry<E>> iterator1 = multiset1.entrySet().iterator();
return new AbstractIterator<Entry<E>>() {
@Override
- @CheckForNull
protected Entry<E> computeNext() {
while (iterator1.hasNext()) {
Entry<E> entry1 = iterator1.next();
@@ -726,7 +712,7 @@
}
/** Delegate implementation which cares about the element type. */
- private static <E extends @Nullable Object> boolean retainOccurrencesImpl(
+ private static <E> boolean retainOccurrencesImpl(
Multiset<E> multisetToModify, Multiset<?> occurrencesToRetain) {
checkNotNull(multisetToModify);
checkNotNull(occurrencesToRetain);
@@ -834,13 +820,13 @@
* Implementation of the {@code equals}, {@code hashCode}, and {@code toString} methods of {@link
* Multiset.Entry}.
*/
- abstract static class AbstractEntry<E extends @Nullable Object> implements Multiset.Entry<E> {
+ abstract static class AbstractEntry<E> implements Multiset.Entry<E> {
/**
* Indicates whether an object equals this entry, following the behavior specified in {@link
* Multiset.Entry#equals}.
*/
@Override
- public boolean equals(@CheckForNull Object object) {
+ public boolean equals(@Nullable Object object) {
if (object instanceof Multiset.Entry) {
Multiset.Entry<?> that = (Multiset.Entry<?>) object;
return this.getCount() == that.getCount()
@@ -874,7 +860,7 @@
}
/** An implementation of {@link Multiset#equals}. */
- static boolean equalsImpl(Multiset<?> multiset, @CheckForNull Object object) {
+ static boolean equalsImpl(Multiset<?> multiset, @Nullable Object object) {
if (object == multiset) {
return true;
}
@@ -900,8 +886,7 @@
}
/** An implementation of {@link Multiset#addAll}. */
- static <E extends @Nullable Object> boolean addAllImpl(
- Multiset<E> self, Collection<? extends E> elements) {
+ static <E> boolean addAllImpl(Multiset<E> self, Collection<? extends E> elements) {
checkNotNull(self);
checkNotNull(elements);
if (elements instanceof Multiset) {
@@ -914,8 +899,7 @@
}
/** A specialization of {@code addAllImpl} for when {@code elements} is itself a Multiset. */
- private static <E extends @Nullable Object> boolean addAllImpl(
- Multiset<E> self, Multiset<? extends E> elements) {
+ private static <E> boolean addAllImpl(Multiset<E> self, Multiset<? extends E> elements) {
if (elements.isEmpty()) {
return false;
}
@@ -945,8 +929,7 @@
}
/** An implementation of {@link Multiset#setCount(Object, int)}. */
- static <E extends @Nullable Object> int setCountImpl(
- Multiset<E> self, @ParametricNullness E element, int count) {
+ static <E> int setCountImpl(Multiset<E> self, E element, int count) {
checkNonnegative(count, "count");
int oldCount = self.count(element);
@@ -962,8 +945,7 @@
}
/** An implementation of {@link Multiset#setCount(Object, int, int)}. */
- static <E extends @Nullable Object> boolean setCountImpl(
- Multiset<E> self, @ParametricNullness E element, int oldCount, int newCount) {
+ static <E> boolean setCountImpl(Multiset<E> self, E element, int oldCount, int newCount) {
checkNonnegative(oldCount, "oldCount");
checkNonnegative(newCount, "newCount");
@@ -975,18 +957,16 @@
}
}
- static <E extends @Nullable Object> Iterator<E> elementIterator(
- Iterator<Entry<E>> entryIterator) {
+ static <E> Iterator<E> elementIterator(Iterator<Entry<E>> entryIterator) {
return new TransformedIterator<Entry<E>, E>(entryIterator) {
@Override
- @ParametricNullness
E transform(Entry<E> entry) {
return entry.getElement();
}
};
}
- abstract static class ElementSet<E extends @Nullable Object> extends Sets.ImprovedAbstractSet<E> {
+ abstract static class ElementSet<E> extends Sets.ImprovedAbstractSet<E> {
abstract Multiset<E> multiset();
@Override
@@ -995,7 +975,7 @@
}
@Override
- public boolean contains(@CheckForNull Object o) {
+ public boolean contains(Object o) {
return multiset().contains(o);
}
@@ -1013,7 +993,7 @@
public abstract Iterator<E> iterator();
@Override
- public boolean remove(@CheckForNull Object o) {
+ public boolean remove(Object o) {
return multiset().remove(o, Integer.MAX_VALUE) > 0;
}
@@ -1023,12 +1003,11 @@
}
}
- abstract static class EntrySet<E extends @Nullable Object>
- extends Sets.ImprovedAbstractSet<Entry<E>> {
+ abstract static class EntrySet<E> extends Sets.ImprovedAbstractSet<Entry<E>> {
abstract Multiset<E> multiset();
@Override
- public boolean contains(@CheckForNull Object o) {
+ public boolean contains(@Nullable Object o) {
if (o instanceof Entry) {
/*
* The GWT compiler wrongly issues a warning here.
@@ -1047,16 +1026,15 @@
// GWT compiler warning; see contains().
@SuppressWarnings("cast")
@Override
- public boolean remove(@CheckForNull Object object) {
+ public boolean remove(Object object) {
if (object instanceof Multiset.Entry) {
Entry<?> entry = (Entry<?>) object;
Object element = entry.getElement();
int entryCount = entry.getCount();
if (entryCount != 0) {
// Safe as long as we never add a new entry, which we won't.
- // (Presumably it can still throw CCE/NPE but only if the underlying Multiset does.)
- @SuppressWarnings({"unchecked", "nullness"})
- Multiset<@Nullable Object> multiset = (Multiset<@Nullable Object>) multiset();
+ @SuppressWarnings("unchecked")
+ Multiset<Object> multiset = (Multiset<Object>) multiset();
return multiset.setCount(element, entryCount, 0);
}
}
@@ -1070,14 +1048,14 @@
}
/** An implementation of {@link Multiset#iterator}. */
- static <E extends @Nullable Object> Iterator<E> iteratorImpl(Multiset<E> multiset) {
+ static <E> Iterator<E> iteratorImpl(Multiset<E> multiset) {
return new MultisetIteratorImpl<E>(multiset, multiset.entrySet().iterator());
}
- static final class MultisetIteratorImpl<E extends @Nullable Object> implements Iterator<E> {
+ static final class MultisetIteratorImpl<E> implements Iterator<E> {
private final Multiset<E> multiset;
private final Iterator<Entry<E>> entryIterator;
- @CheckForNull private Entry<E> currentEntry;
+ private @Nullable Entry<E> currentEntry;
/** Count of subsequent elements equal to current element */
private int laterCount;
@@ -1098,7 +1076,6 @@
}
@Override
- @ParametricNullness
public E next() {
if (!hasNext()) {
throw new NoSuchElementException();
@@ -1109,11 +1086,7 @@
}
laterCount--;
canRemove = true;
- /*
- * requireNonNull is safe because laterCount starts at 0, forcing us to initialize
- * currentEntry above. After that, we never clear it.
- */
- return requireNonNull(currentEntry).getElement();
+ return currentEntry.getElement();
}
@Override
@@ -1122,18 +1095,14 @@
if (totalCount == 1) {
entryIterator.remove();
} else {
- /*
- * requireNonNull is safe because canRemove is set to true only after we initialize
- * currentEntry (which we never subsequently clear).
- */
- multiset.remove(requireNonNull(currentEntry).getElement());
+ multiset.remove(currentEntry.getElement());
}
totalCount--;
canRemove = false;
}
}
- static <E extends @Nullable Object> Spliterator<E> spliteratorImpl(Multiset<E> multiset) {
+ static <E> Spliterator<E> spliteratorImpl(Multiset<E> multiset) {
Spliterator<Entry<E>> entrySpliterator = multiset.entrySet().spliterator();
return CollectSpliterators.flatMap(
entrySpliterator,
@@ -1154,7 +1123,7 @@
}
/** Used to avoid http://bugs.sun.com/view_bug.do?bug_id=6558557 */
- static <T extends @Nullable Object> Multiset<T> cast(Iterable<T> iterable) {
+ static <T> Multiset<T> cast(Iterable<T> iterable) {
return (Multiset<T>) iterable;
}
@@ -1184,8 +1153,7 @@
* An {@link AbstractMultiset} with additional default implementations, some of them linear-time
* implementations in terms of {@code elementSet} and {@code entrySet}.
*/
- private abstract static class ViewMultiset<E extends @Nullable Object>
- extends AbstractMultiset<E> {
+ private abstract static class ViewMultiset<E> extends AbstractMultiset<E> {
@Override
public int size() {
return linearTimeSizeImpl(this);
diff --git a/guava/src/com/google/common/collect/MutableClassToInstanceMap.java b/guava/src/com/google/common/collect/MutableClassToInstanceMap.java
index 83fbe94..c3ad908 100644
--- a/guava/src/com/google/common/collect/MutableClassToInstanceMap.java
+++ b/guava/src/com/google/common/collect/MutableClassToInstanceMap.java
@@ -28,26 +28,20 @@
import java.util.Map;
import java.util.Set;
import java.util.Spliterator;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* A mutable class-to-instance map backed by an arbitrary user-provided map. See also {@link
* ImmutableClassToInstanceMap}.
*
* <p>See the Guava User Guide article on <a href=
- * "https://github.com/google/guava/wiki/NewCollectionTypesExplained#classtoinstancemap">{@code
+ * "https://github.com/google/guava/wiki/NewCollectionTypesExplained#classtoinstancemap"> {@code
* ClassToInstanceMap}</a>.
*
- * <p>This implementation <i>does</i> support null values, despite how it is annotated; see
- * discussion at {@link ClassToInstanceMap}.
- *
* @author Kevin Bourrillion
* @since 2.0
*/
@GwtIncompatible
@SuppressWarnings("serial") // using writeReplace instead of standard serialization
-@ElementTypesAreNonnullByDefault
public final class MutableClassToInstanceMap<B> extends ForwardingMap<Class<? extends B>, B>
implements ClassToInstanceMap<B>, Serializable {
@@ -125,20 +119,11 @@
@Override
public Object[] toArray() {
- /*
- * standardToArray returns `@Nullable Object[]` rather than `Object[]` but only because it
- * can be used with collections that may contain null. This collection is a collection of
- * non-null Entry objects (Entry objects that might contain null values but are not
- * themselves null), so we can treat it as a plain `Object[]`.
- */
- @SuppressWarnings("nullness")
- Object[] result = standardToArray();
- return result;
+ return standardToArray();
}
@Override
- @SuppressWarnings("nullness") // b/192354773 in our checker affects toArray declarations
- public <T extends @Nullable Object> T[] toArray(T[] array) {
+ public <T> T[] toArray(T[] array) {
return standardToArray(array);
}
};
@@ -146,7 +131,6 @@
@Override
@CanIgnoreReturnValue
- @CheckForNull
public B put(Class<? extends B> key, B value) {
return super.put(key, cast(key, value));
}
@@ -162,20 +146,17 @@
@CanIgnoreReturnValue
@Override
- @CheckForNull
public <T extends B> T putInstance(Class<T> type, T value) {
return cast(type, put(type, value));
}
@Override
- @CheckForNull
public <T extends B> T getInstance(Class<T> type) {
return cast(type, get(type));
}
@CanIgnoreReturnValue
- @CheckForNull
- private static <B, T extends B> T cast(Class<T> type, @CheckForNull B value) {
+ private static <B, T extends B> T cast(Class<T> type, B value) {
return Primitives.wrap(type).cast(value);
}
diff --git a/guava/src/com/google/common/collect/NaturalOrdering.java b/guava/src/com/google/common/collect/NaturalOrdering.java
index 8cb8aef..c4b98e3 100644
--- a/guava/src/com/google/common/collect/NaturalOrdering.java
+++ b/guava/src/com/google/common/collect/NaturalOrdering.java
@@ -20,46 +20,44 @@
import com.google.common.annotations.GwtCompatible;
import java.io.Serializable;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/** An ordering that uses the natural order of the values. */
@GwtCompatible(serializable = true)
@SuppressWarnings({"unchecked", "rawtypes"}) // TODO(kevinb): the right way to explain this??
-@ElementTypesAreNonnullByDefault
-final class NaturalOrdering extends Ordering<Comparable<?>> implements Serializable {
+final class NaturalOrdering extends Ordering<Comparable> implements Serializable {
static final NaturalOrdering INSTANCE = new NaturalOrdering();
- @CheckForNull private transient Ordering<@Nullable Comparable<?>> nullsFirst;
- @CheckForNull private transient Ordering<@Nullable Comparable<?>> nullsLast;
+ private transient @Nullable Ordering<Comparable> nullsFirst;
+ private transient @Nullable Ordering<Comparable> nullsLast;
@Override
- public int compare(Comparable<?> left, Comparable<?> right) {
+ public int compare(Comparable left, Comparable right) {
checkNotNull(left); // for GWT
checkNotNull(right);
- return ((Comparable<Object>) left).compareTo(right);
+ return left.compareTo(right);
}
@Override
- public <S extends Comparable<?>> Ordering<@Nullable S> nullsFirst() {
- Ordering<@Nullable Comparable<?>> result = nullsFirst;
+ public <S extends Comparable> Ordering<S> nullsFirst() {
+ Ordering<Comparable> result = nullsFirst;
if (result == null) {
- result = nullsFirst = super.<Comparable<?>>nullsFirst();
+ result = nullsFirst = super.nullsFirst();
}
- return (Ordering<@Nullable S>) result;
+ return (Ordering<S>) result;
}
@Override
- public <S extends Comparable<?>> Ordering<@Nullable S> nullsLast() {
- Ordering<@Nullable Comparable<?>> result = nullsLast;
+ public <S extends Comparable> Ordering<S> nullsLast() {
+ Ordering<Comparable> result = nullsLast;
if (result == null) {
- result = nullsLast = super.<Comparable<?>>nullsLast();
+ result = nullsLast = super.nullsLast();
}
- return (Ordering<@Nullable S>) result;
+ return (Ordering<S>) result;
}
@Override
- public <S extends Comparable<?>> Ordering<S> reverse() {
+ public <S extends Comparable> Ordering<S> reverse() {
return (Ordering<S>) ReverseNaturalOrdering.INSTANCE;
}
diff --git a/guava/src/com/google/common/collect/NullnessCasts.java b/guava/src/com/google/common/collect/NullnessCasts.java
deleted file mode 100644
index 6ceeda7..0000000
--- a/guava/src/com/google/common/collect/NullnessCasts.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright (C) 2021 The Guava Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
- * or implied. See the License for the specific language governing permissions and limitations under
- * the License.
- */
-
-package com.google.common.collect;
-
-import com.google.common.annotations.GwtCompatible;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
-
-/** A utility method to perform unchecked casts to suppress errors produced by nullness analyses. */
-@GwtCompatible
-@ElementTypesAreNonnullByDefault
-final class NullnessCasts {
- /**
- * Accepts a {@code @Nullable T} and returns a plain {@code T}, without performing any check that
- * that conversion is safe.
- *
- * <p>This method is intended to help with usages of type parameters that have {@linkplain
- * ParametricNullness parametric nullness}. If a type parameter instead ranges over only non-null
- * types (or if the type is a non-variable type, like {@code String}), then code should almost
- * never use this method, preferring instead to call {@code requireNonNull} so as to benefit from
- * its runtime check.
- *
- * <p>An example use case for this method is in implementing an {@code Iterator<T>} whose {@code
- * next} field is lazily initialized. The type of that field would be {@code @Nullable T}, and the
- * code would be responsible for populating a "real" {@code T} (which might still be the value
- * {@code null}!) before returning it to callers. Depending on how the code is structured, a
- * nullness analysis might not understand that the field has been populated. To avoid that problem
- * without having to add {@code @SuppressWarnings}, the code can call this method.
- *
- * <p>Why <i>not</i> just add {@code SuppressWarnings}? The problem is that this method is
- * typically useful for {@code return} statements. That leaves the code with two options: Either
- * add the suppression to the whole method (which turns off checking for a large section of code),
- * or extract a variable, and put the suppression on that. However, a local variable typically
- * doesn't work: Because nullness analyses typically infer the nullness of local variables,
- * there's no way to assign a {@code @Nullable T} to a field {@code T foo;} and instruct the
- * analysis that that means "plain {@code T}" rather than the inferred type {@code @Nullable T}.
- * (Even if supported added {@code @NonNull}, that would not help, since the problem case
- * addressed by this method is the case in which {@code T} has parametric nullness -- and thus its
- * value may be legitimately {@code null}.)
- */
- @ParametricNullness
- @SuppressWarnings("nullness")
- static <T extends @Nullable Object> T uncheckedCastNullableTToT(@CheckForNull T t) {
- return t;
- }
-
- /** Returns {@code null} as any type, even one that does not include {@code null}. */
- @SuppressWarnings({"nullness", "TypeParameterUnusedInFormals"})
- // The warnings are legitimate. Each time we use this method, we document why.
- @ParametricNullness
- static <T extends @Nullable Object> T unsafeNull() {
- return null;
- }
-
- private NullnessCasts() {}
-}
diff --git a/guava/src/com/google/common/collect/NullsFirstOrdering.java b/guava/src/com/google/common/collect/NullsFirstOrdering.java
index ce8be2f..5e1dfe9 100644
--- a/guava/src/com/google/common/collect/NullsFirstOrdering.java
+++ b/guava/src/com/google/common/collect/NullsFirstOrdering.java
@@ -18,14 +18,11 @@
import com.google.common.annotations.GwtCompatible;
import java.io.Serializable;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/** An ordering that treats {@code null} as less than all other values. */
@GwtCompatible(serializable = true)
-@ElementTypesAreNonnullByDefault
-final class NullsFirstOrdering<T extends @Nullable Object> extends Ordering<@Nullable T>
- implements Serializable {
+final class NullsFirstOrdering<T> extends Ordering<T> implements Serializable {
final Ordering<? super T> ordering;
NullsFirstOrdering(Ordering<? super T> ordering) {
@@ -33,7 +30,7 @@
}
@Override
- public int compare(@CheckForNull T left, @CheckForNull T right) {
+ public int compare(@Nullable T left, @Nullable T right) {
if (left == right) {
return 0;
}
@@ -47,25 +44,24 @@
}
@Override
- @SuppressWarnings("nullness") // should be safe, but not sure if we can avoid the warning
- public <S extends @Nullable T> Ordering<S> reverse() {
+ public <S extends T> Ordering<S> reverse() {
// ordering.reverse() might be optimized, so let it do its thing
return ordering.reverse().nullsLast();
}
@SuppressWarnings("unchecked") // still need the right way to explain this
@Override
- public <S extends T> Ordering<@Nullable S> nullsFirst() {
- return (Ordering<@Nullable S>) this;
+ public <S extends T> Ordering<S> nullsFirst() {
+ return (Ordering<S>) this;
}
@Override
- public <S extends T> Ordering<@Nullable S> nullsLast() {
- return ordering.<S>nullsLast();
+ public <S extends T> Ordering<S> nullsLast() {
+ return ordering.nullsLast();
}
@Override
- public boolean equals(@CheckForNull 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 6f8f74c..a62e219 100644
--- a/guava/src/com/google/common/collect/NullsLastOrdering.java
+++ b/guava/src/com/google/common/collect/NullsLastOrdering.java
@@ -18,14 +18,11 @@
import com.google.common.annotations.GwtCompatible;
import java.io.Serializable;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/** An ordering that treats {@code null} as greater than all other values. */
@GwtCompatible(serializable = true)
-@ElementTypesAreNonnullByDefault
-final class NullsLastOrdering<T extends @Nullable Object> extends Ordering<@Nullable T>
- implements Serializable {
+final class NullsLastOrdering<T> extends Ordering<T> implements Serializable {
final Ordering<? super T> ordering;
NullsLastOrdering(Ordering<? super T> ordering) {
@@ -33,7 +30,7 @@
}
@Override
- public int compare(@CheckForNull T left, @CheckForNull T right) {
+ public int compare(@Nullable T left, @Nullable T right) {
if (left == right) {
return 0;
}
@@ -47,25 +44,24 @@
}
@Override
- @SuppressWarnings("nullness") // should be safe, but not sure if we can avoid the warning
- public <S extends @Nullable T> Ordering<S> reverse() {
+ public <S extends T> Ordering<S> reverse() {
// ordering.reverse() might be optimized, so let it do its thing
return ordering.reverse().nullsFirst();
}
@Override
- public <S extends T> Ordering<@Nullable S> nullsFirst() {
- return ordering.<S>nullsFirst();
+ public <S extends T> Ordering<S> nullsFirst() {
+ return ordering.nullsFirst();
}
@SuppressWarnings("unchecked") // still need the right way to explain this
@Override
- public <S extends T> Ordering<@Nullable S> nullsLast() {
- return (Ordering<@Nullable S>) this;
+ public <S extends T> Ordering<S> nullsLast() {
+ return (Ordering<S>) this;
}
@Override
- public boolean equals(@CheckForNull 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 d3b048d..cfc9a59 100644
--- a/guava/src/com/google/common/collect/ObjectArrays.java
+++ b/guava/src/com/google/common/collect/ObjectArrays.java
@@ -33,7 +33,6 @@
* @since 2.0
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
public final class ObjectArrays {
private ObjectArrays() {}
@@ -56,7 +55,7 @@
* @param reference any array of the desired type
* @param length the length of the new array
*/
- public static <T extends @Nullable Object> T[] newArray(T[] reference, int length) {
+ public static <T> T[] newArray(T[] reference, int length) {
return Platform.newArray(reference, length);
}
@@ -83,7 +82,7 @@
* @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 extends @Nullable Object> T[] concat(@ParametricNullness T element, T[] array) {
+ public static <T> 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);
@@ -98,7 +97,7 @@
* @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 extends @Nullable Object> T[] concat(T[] array, @ParametricNullness T element) {
+ public static <T> T[] concat(T[] array, @Nullable T element) {
T[] result = Arrays.copyOf(array, array.length + 1);
result[array.length] = element;
return result;
@@ -125,15 +124,14 @@
* @throws ArrayStoreException if the runtime type of the specified array is not a supertype of
* the runtime type of every element in the specified collection
*/
- static <T extends @Nullable Object> T[] toArrayImpl(Collection<?> c, T[] array) {
+ static <T> T[] toArrayImpl(Collection<?> c, T[] array) {
int size = c.size();
if (array.length < size) {
array = newArray(array, size);
}
fillArray(c, array);
if (array.length > size) {
- @Nullable Object[] unsoundlyCovariantArray = array;
- unsoundlyCovariantArray[size] = null;
+ array[size] = null;
}
return array;
}
@@ -149,14 +147,12 @@
* collection is set to {@code null}. This is useful in determining the length of the collection
* <i>only</i> if the caller knows that the collection does not contain any null elements.
*/
- static <T extends @Nullable Object> T[] toArrayImpl(
- @Nullable Object[] src, int offset, int len, T[] dst) {
+ static <T> T[] toArrayImpl(Object[] src, int offset, int len, T[] dst) {
checkPositionIndexes(offset, offset + len, src.length);
if (dst.length < len) {
dst = newArray(dst, len);
} else if (dst.length > len) {
- @Nullable Object[] unsoundlyCovariantArray = dst;
- unsoundlyCovariantArray[len] = null;
+ dst[len] = null;
}
System.arraycopy(src, offset, dst, 0, len);
return dst;
@@ -174,7 +170,7 @@
*
* @param c the collection for which to return an array of elements
*/
- static @Nullable Object[] toArrayImpl(Collection<?> c) {
+ static Object[] toArrayImpl(Collection<?> c) {
return fillArray(c, new Object[c.size()]);
}
@@ -182,18 +178,18 @@
* Returns a copy of the specified subrange of the specified array that is literally an Object[],
* and not e.g. a {@code String[]}.
*/
- static @Nullable Object[] copyAsObjectArray(@Nullable Object[] elements, int offset, int length) {
+ static Object[] copyAsObjectArray(Object[] elements, int offset, int length) {
checkPositionIndexes(offset, offset + length, elements.length);
if (length == 0) {
return new Object[0];
}
- @Nullable Object[] result = new Object[length];
+ Object[] result = new Object[length];
System.arraycopy(elements, offset, result, 0, length);
return result;
}
@CanIgnoreReturnValue
- private static @Nullable Object[] fillArray(Iterable<?> elements, @Nullable Object[] array) {
+ private static Object[] fillArray(Iterable<?> elements, Object[] array) {
int i = 0;
for (Object element : elements) {
array[i++] = element;
diff --git a/guava/src/com/google/common/collect/Ordering.java b/guava/src/com/google/common/collect/Ordering.java
index 9bf180f..aa51fb6 100644
--- a/guava/src/com/google/common/collect/Ordering.java
+++ b/guava/src/com/google/common/collect/Ordering.java
@@ -38,7 +38,6 @@
import java.util.TreeSet;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.atomic.AtomicInteger;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -145,8 +144,7 @@
* @since 2.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-public abstract class Ordering<T extends @Nullable Object> implements Comparator<T> {
+public abstract class Ordering<T> implements Comparator<T> {
// Natural order
/**
@@ -180,7 +178,7 @@
* wraps that comparator
*/
@GwtCompatible(serializable = true)
- public static <T extends @Nullable Object> Ordering<T> from(Comparator<T> comparator) {
+ public static <T> Ordering<T> from(Comparator<T> comparator) {
return (comparator instanceof Ordering)
? (Ordering<T>) comparator
: new ComparatorOrdering<T>(comparator);
@@ -193,7 +191,7 @@
*/
@GwtCompatible(serializable = true)
@Deprecated
- public static <T extends @Nullable Object> Ordering<T> from(Ordering<T> ordering) {
+ public static <T> Ordering<T> from(Ordering<T> ordering) {
return checkNotNull(ordering);
}
@@ -280,7 +278,7 @@
*/
@GwtCompatible(serializable = true)
@SuppressWarnings("unchecked")
- public static Ordering<@Nullable Object> allEqual() {
+ public static Ordering<Object> allEqual() {
return AllEqualOrdering.INSTANCE;
}
@@ -313,16 +311,16 @@
* @since 2.0
*/
// TODO(kevinb): copy to Comparators, etc.
- public static Ordering<@Nullable Object> arbitrary() {
+ public static Ordering<Object> arbitrary() {
return ArbitraryOrderingHolder.ARBITRARY_ORDERING;
}
private static class ArbitraryOrderingHolder {
- static final Ordering<@Nullable Object> ARBITRARY_ORDERING = new ArbitraryOrdering();
+ static final Ordering<Object> ARBITRARY_ORDERING = new ArbitraryOrdering();
}
@VisibleForTesting
- static class ArbitraryOrdering extends Ordering<@Nullable Object> {
+ static class ArbitraryOrdering extends Ordering<Object> {
private final AtomicInteger counter = new AtomicInteger(0);
private final ConcurrentMap<Object, Integer> uids =
@@ -344,7 +342,7 @@
}
@Override
- public int compare(@CheckForNull Object left, @CheckForNull Object right) {
+ public int compare(Object left, Object right) {
if (left == right) {
return 0;
} else if (left == null) {
@@ -416,7 +414,7 @@
// type parameter <S> lets us avoid the extra <String> in statements like:
// Ordering<String> o = Ordering.<String>natural().nullsFirst();
@GwtCompatible(serializable = true)
- public <S extends T> Ordering<@Nullable S> nullsFirst() {
+ public <S extends T> Ordering<S> nullsFirst() {
return new NullsFirstOrdering<S>(this);
}
@@ -429,7 +427,7 @@
// type parameter <S> lets us avoid the extra <String> in statements like:
// Ordering<String> o = Ordering.<String>natural().nullsLast();
@GwtCompatible(serializable = true)
- public <S extends T> Ordering<@Nullable S> nullsLast() {
+ public <S extends T> Ordering<S> nullsLast() {
return new NullsLastOrdering<S>(this);
}
@@ -447,7 +445,7 @@
* can omit the comparator if it is the natural order).
*/
@GwtCompatible(serializable = true)
- public <F extends @Nullable Object> Ordering<F> onResultOf(Function<F, ? extends T> function) {
+ public <F> Ordering<F> onResultOf(Function<F, ? extends T> function) {
return new ByFunctionOrdering<>(function, this);
}
@@ -493,8 +491,7 @@
* @param comparators the comparators to try in order
*/
@GwtCompatible(serializable = true)
- public static <T extends @Nullable Object> Ordering<T> compound(
- Iterable<? extends Comparator<? super T>> comparators) {
+ public static <T> Ordering<T> compound(Iterable<? extends Comparator<? super T>> comparators) {
return new CompoundOrdering<T>(comparators);
}
@@ -530,9 +527,10 @@
// Regular instance methods
+ // Override to add @Nullable
@CanIgnoreReturnValue // TODO(kak): Consider removing this
@Override
- public abstract int compare(@ParametricNullness T left, @ParametricNullness 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
@@ -548,7 +546,6 @@
* ordering.
* @since 11.0
*/
- @ParametricNullness
public <E extends T> E min(Iterator<E> iterator) {
// let this throw NoSuchElementException as necessary
E minSoFar = iterator.next();
@@ -574,7 +571,6 @@
* @throws ClassCastException if the parameters are not <i>mutually comparable</i> under this
* ordering.
*/
- @ParametricNullness
public <E extends T> E min(Iterable<E> iterable) {
return min(iterable.iterator());
}
@@ -594,8 +590,7 @@
* @throws ClassCastException if the parameters are not <i>mutually comparable</i> under this
* ordering.
*/
- @ParametricNullness
- public <E extends T> E min(@ParametricNullness E a, @ParametricNullness E b) {
+ public <E extends T> E min(@Nullable E a, @Nullable E b) {
return (compare(a, b) <= 0) ? a : b;
}
@@ -613,9 +608,7 @@
* @throws ClassCastException if the parameters are not <i>mutually comparable</i> under this
* ordering.
*/
- @ParametricNullness
- public <E extends T> E min(
- @ParametricNullness E a, @ParametricNullness E b, @ParametricNullness E c, E... rest) {
+ public <E extends T> E min(@Nullable E a, @Nullable E b, @Nullable E c, E... rest) {
E minSoFar = min(min(a, b), c);
for (E r : rest) {
@@ -639,7 +632,6 @@
* ordering.
* @since 11.0
*/
- @ParametricNullness
public <E extends T> E max(Iterator<E> iterator) {
// let this throw NoSuchElementException as necessary
E maxSoFar = iterator.next();
@@ -665,7 +657,6 @@
* @throws ClassCastException if the parameters are not <i>mutually comparable</i> under this
* ordering.
*/
- @ParametricNullness
public <E extends T> E max(Iterable<E> iterable) {
return max(iterable.iterator());
}
@@ -685,8 +676,7 @@
* @throws ClassCastException if the parameters are not <i>mutually comparable</i> under this
* ordering.
*/
- @ParametricNullness
- public <E extends T> E max(@ParametricNullness E a, @ParametricNullness E b) {
+ public <E extends T> E max(@Nullable E a, @Nullable E b) {
return (compare(a, b) >= 0) ? a : b;
}
@@ -704,9 +694,7 @@
* @throws ClassCastException if the parameters are not <i>mutually comparable</i> under this
* ordering.
*/
- @ParametricNullness
- public <E extends T> E max(
- @ParametricNullness E a, @ParametricNullness E b, @ParametricNullness E c, E... rest) {
+ public <E extends T> E max(@Nullable E a, @Nullable E b, @Nullable E c, E... rest) {
E maxSoFar = max(max(a, b), c);
for (E r : rest) {
@@ -871,7 +859,6 @@
* @since 3.0
*/
// TODO(kevinb): rerun benchmarks including new options
- @SuppressWarnings("nullness") // unsafe, but there's not much we can do about it now
public <E extends T> ImmutableList<E> immutableSortedCopy(Iterable<E> elements) {
return ImmutableList.sortedCopyOf(this, elements);
}
@@ -933,8 +920,7 @@
* @deprecated Use {@link Collections#binarySearch(List, Object, Comparator)} directly.
*/
@Deprecated
- public int binarySearch(
- List<? extends T> sortedList, @ParametricNullness T key) {
+ public int binarySearch(List<? extends T> sortedList, @Nullable T key) {
return Collections.binarySearch(sortedList, key, this);
}
diff --git a/guava/src/com/google/common/collect/ParametricNullness.java b/guava/src/com/google/common/collect/ParametricNullness.java
deleted file mode 100644
index b1cda48..0000000
--- a/guava/src/com/google/common/collect/ParametricNullness.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2021 The Guava Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.common.collect;
-
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.PARAMETER;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-import static javax.annotation.meta.When.UNKNOWN;
-
-import com.google.common.annotations.GwtCompatible;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-import javax.annotation.Nonnull;
-import javax.annotation.meta.TypeQualifierNickname;
-
-/**
- * Marks a "top-level" type-variable usage as (a) a Kotlin platform type when the type argument is
- * non-nullable and (b) nullable when the type argument is nullable. This is the closest we can get
- * to "non-nullable when non-nullable; nullable when nullable" (like the Android <a
- * href="https://android.googlesource.com/platform/libcore/+/master/luni/src/main/java/libcore/util/NullFromTypeParam.java">{@code
- * NullFromTypeParam}</a>). We use this to "undo" {@link ElementTypesAreNonnullByDefault}.
- */
-@GwtCompatible
-@Retention(RUNTIME)
-@Target({FIELD, METHOD, PARAMETER})
-@TypeQualifierNickname
-@Nonnull(when = UNKNOWN)
-@interface ParametricNullness {}
diff --git a/guava/src/com/google/common/collect/PeekingIterator.java b/guava/src/com/google/common/collect/PeekingIterator.java
index a274fe4..5a6c60b 100644
--- a/guava/src/com/google/common/collect/PeekingIterator.java
+++ b/guava/src/com/google/common/collect/PeekingIterator.java
@@ -21,7 +21,6 @@
import com.google.errorprone.annotations.DoNotMock;
import java.util.Iterator;
import java.util.NoSuchElementException;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* An iterator that supports a one-element lookahead while iterating.
@@ -35,8 +34,7 @@
*/
@DoNotMock("Use Iterators.peekingIterator")
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-public interface PeekingIterator<E extends @Nullable Object> extends Iterator<E> {
+public interface PeekingIterator<E> extends Iterator<E> {
/**
* Returns the next element in the iteration, without advancing the iteration.
*
@@ -46,7 +44,6 @@
* @throws NoSuchElementException if the iteration has no more elements according to {@link
* #hasNext()}
*/
- @ParametricNullness
E peek();
/**
@@ -57,7 +54,6 @@
*/
@CanIgnoreReturnValue
@Override
- @ParametricNullness
E next();
/**
diff --git a/guava/src/com/google/common/collect/Platform.java b/guava/src/com/google/common/collect/Platform.java
index b1d6b2f..d4afd32 100644
--- a/guava/src/com/google/common/collect/Platform.java
+++ b/guava/src/com/google/common/collect/Platform.java
@@ -21,8 +21,6 @@
import java.util.Arrays;
import java.util.Map;
import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Methods factored out so that they can be emulated differently in GWT.
@@ -30,14 +28,12 @@
* @author Hayward Chan
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
final class Platform {
private static final java.util.logging.Logger logger =
java.util.logging.Logger.getLogger(Platform.class.getName());
/** Returns the platform preferred implementation of a map based on a hash table. */
- static <K extends @Nullable Object, V extends @Nullable Object>
- Map<K, V> newHashMapWithExpectedSize(int expectedSize) {
+ static <K, V> Map<K, V> newHashMapWithExpectedSize(int expectedSize) {
return Maps.newHashMapWithExpectedSize(expectedSize);
}
@@ -45,26 +41,20 @@
* Returns the platform preferred implementation of an insertion ordered map based on a hash
* table.
*/
- static <K extends @Nullable Object, V extends @Nullable Object>
- Map<K, V> newLinkedHashMapWithExpectedSize(int expectedSize) {
+ static <K, V> Map<K, V> newLinkedHashMapWithExpectedSize(int expectedSize) {
return Maps.newLinkedHashMapWithExpectedSize(expectedSize);
}
/** Returns the platform preferred implementation of a set based on a hash table. */
- static <E extends @Nullable Object> Set<E> newHashSetWithExpectedSize(int expectedSize) {
+ static <E> Set<E> newHashSetWithExpectedSize(int expectedSize) {
return Sets.newHashSetWithExpectedSize(expectedSize);
}
- /** Returns the platform preferred implementation of a thread-safe hash set. */
- static <E> Set<E> newConcurrentHashSet() {
- return ConcurrentHashMap.newKeySet();
- }
-
/**
* Returns the platform preferred implementation of an insertion ordered set based on a hash
* table.
*/
- static <E extends @Nullable Object> Set<E> newLinkedHashSetWithExpectedSize(int expectedSize) {
+ static <E> Set<E> newLinkedHashSetWithExpectedSize(int expectedSize) {
return Sets.newLinkedHashSetWithExpectedSize(expectedSize);
}
@@ -72,8 +62,7 @@
* Returns the platform preferred map implementation that preserves insertion order when used only
* for insertions.
*/
- static <K extends @Nullable Object, V extends @Nullable Object>
- Map<K, V> preservesInsertionOrderOnPutsMap() {
+ static <K, V> Map<K, V> preservesInsertionOrderOnPutsMap() {
return Maps.newLinkedHashMap();
}
@@ -81,7 +70,7 @@
* Returns the platform preferred set implementation that preserves insertion order when used only
* for insertions.
*/
- static <E extends @Nullable Object> Set<E> preservesInsertionOrderOnAddsSet() {
+ static <E> Set<E> preservesInsertionOrderOnAddsSet() {
return Sets.newLinkedHashSet();
}
@@ -91,13 +80,7 @@
* @param reference any array of the desired type
* @param length the length of the new array
*/
- /*
- * The new array contains nulls, even if the old array did not. If we wanted to be accurate, we
- * would declare a return type of `@Nullable T[]`. However, we've decided not to think too hard
- * about arrays for now, as they're a mess. (We previously discussed this in the review of
- * ObjectArrays, which is the main caller of this method.)
- */
- static <T extends @Nullable Object> T[] newArray(T[] reference, int length) {
+ static <T> T[] newArray(T[] reference, int length) {
Class<?> type = reference.getClass().getComponentType();
// the cast is safe because
@@ -108,16 +91,7 @@
}
/** Equivalent to Arrays.copyOfRange(source, from, to, arrayOfType.getClass()). */
- /*
- * Arrays are a mess from a nullness perspective, and Class instances for object-array types are
- * even worse. For now, we just suppress and move on with our lives.
- *
- * - https://github.com/jspecify/jspecify/issues/65
- *
- * - https://github.com/jspecify/jdk/commit/71d826792b8c7ef95d492c50a274deab938f2552
- */
- @SuppressWarnings("nullness")
- static <T extends @Nullable Object> T[] copy(Object[] source, int from, int to, T[] arrayOfType) {
+ static <T> T[] copy(Object[] source, int from, int to, T[] arrayOfType) {
return Arrays.copyOfRange(source, from, to, (Class<? extends T[]>) arrayOfType.getClass());
}
@@ -157,6 +131,7 @@
+ " warning because you are sending a Guava type over GWT-RPC, which will break. You"
+ " can identify which type by looking at the class name in the attached stack trace.",
new Throwable());
+
}
private Platform() {}
diff --git a/guava/src/com/google/common/collect/Queues.java b/guava/src/com/google/common/collect/Queues.java
index a140102..8a69326 100644
--- a/guava/src/com/google/common/collect/Queues.java
+++ b/guava/src/com/google/common/collect/Queues.java
@@ -32,7 +32,6 @@
import java.util.concurrent.PriorityBlockingQueue;
import java.util.concurrent.SynchronousQueue;
import java.util.concurrent.TimeUnit;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Static utility methods pertaining to {@link Queue} and {@link Deque} instances. Also see this
@@ -42,7 +41,6 @@
* @since 11.0
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
public final class Queues {
private Queues() {}
@@ -190,8 +188,7 @@
* Creates an empty {@code PriorityBlockingQueue} with the ordering given by its elements' natural
* ordering.
*
- * @since 11.0 (but the bound of {@code E} was changed from {@code Object} to {@code Comparable}
- * in 15.0)
+ * @since 11.0 (requires that {@code E} be {@code Comparable} since 15.0).
*/
@GwtIncompatible // PriorityBlockingQueue
public static <E extends Comparable> PriorityBlockingQueue<E> newPriorityBlockingQueue() {
@@ -204,8 +201,7 @@
* <p><b>Note:</b> If the specified iterable is a {@code SortedSet} or a {@code PriorityQueue},
* this priority queue will be ordered according to the same ordering.
*
- * @since 11.0 (but the bound of {@code E} was changed from {@code Object} to {@code Comparable}
- * in 15.0)
+ * @since 11.0 (requires that {@code E} be {@code Comparable} since 15.0).
*/
@GwtIncompatible // PriorityBlockingQueue
public static <E extends Comparable> PriorityBlockingQueue<E> newPriorityBlockingQueue(
@@ -224,8 +220,7 @@
* Creates an empty {@code PriorityQueue} with the ordering given by its elements' natural
* ordering.
*
- * @since 11.0 (but the bound of {@code E} was changed from {@code Object} to {@code Comparable}
- * in 15.0)
+ * @since 11.0 (requires that {@code E} be {@code Comparable} since 15.0).
*/
public static <E extends Comparable> PriorityQueue<E> newPriorityQueue() {
return new PriorityQueue<E>();
@@ -237,8 +232,7 @@
* <p><b>Note:</b> If the specified iterable is a {@code SortedSet} or a {@code PriorityQueue},
* this priority queue will be ordered according to the same ordering.
*
- * @since 11.0 (but the bound of {@code E} was changed from {@code Object} to {@code Comparable}
- * in 15.0)
+ * @since 11.0 (requires that {@code E} be {@code Comparable} since 15.0).
*/
public static <E extends Comparable> PriorityQueue<E> newPriorityQueue(
Iterable<? extends E> elements) {
@@ -438,7 +432,7 @@
* @return a synchronized view of the specified queue
* @since 14.0
*/
- public static <E extends @Nullable Object> Queue<E> synchronizedQueue(Queue<E> queue) {
+ public static <E> Queue<E> synchronizedQueue(Queue<E> queue) {
return Synchronized.queue(queue, null);
}
@@ -471,7 +465,7 @@
* @return a synchronized view of the specified deque
* @since 15.0
*/
- public static <E extends @Nullable Object> Deque<E> synchronizedDeque(Deque<E> deque) {
+ public static <E> Deque<E> synchronizedDeque(Deque<E> deque) {
return Synchronized.deque(deque, null);
}
}
diff --git a/guava/src/com/google/common/collect/Range.java b/guava/src/com/google/common/collect/Range.java
index ab5c077..1c6002e 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 javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* A range (or "interval") defines the <i>boundaries</i> around a contiguous span of values of some
@@ -117,7 +117,6 @@
*/
@GwtCompatible
@SuppressWarnings("rawtypes")
-@ElementTypesAreNonnullByDefault
public final class Range<C extends Comparable> extends RangeGwtSerializationDependencies
implements Predicate<C>, Serializable {
@@ -330,7 +329,7 @@
public static <C extends Comparable<?>> Range<C> encloseAll(Iterable<C> values) {
checkNotNull(values);
if (values instanceof SortedSet) {
- SortedSet<C> set = (SortedSet<C>) values;
+ SortedSet<? extends C> set = cast(values);
Comparator<?> comparator = set.comparator();
if (Ordering.natural().equals(comparator) || comparator == null) {
return closed(set.first(), set.last());
@@ -457,7 +456,7 @@
// this optimizes testing equality of two range-backed sets
if (values instanceof SortedSet) {
- SortedSet<? extends C> set = (SortedSet<? extends C>) values;
+ SortedSet<? extends C> set = cast(values);
Comparator<?> comparator = set.comparator();
if (Ordering.natural().equals(comparator) || comparator == null) {
return contains(set.first()) && contains(set.last());
@@ -664,7 +663,7 @@
* {@code [3..3)}, {@code (3..3]}, {@code (4..4]} are all unequal.
*/
@Override
- public boolean equals(@CheckForNull 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);
@@ -695,6 +694,11 @@
return sb.toString();
}
+ /** Used to avoid http://bugs.sun.com/view_bug.do?bug_id=6558557 */
+ private static <T> SortedSet<T> cast(Iterable<T> iterable) {
+ return (SortedSet<T>) iterable;
+ }
+
Object readResolve() {
if (this.equals(ALL)) {
return all();
diff --git a/guava/src/com/google/common/collect/RangeMap.java b/guava/src/com/google/common/collect/RangeMap.java
index 99e7b97..0b319bd 100644
--- a/guava/src/com/google/common/collect/RangeMap.java
+++ b/guava/src/com/google/common/collect/RangeMap.java
@@ -24,7 +24,6 @@
import java.util.Map.Entry;
import java.util.NoSuchElementException;
import java.util.function.BiFunction;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -40,27 +39,21 @@
@Beta
@DoNotMock("Use ImmutableRangeMap or TreeRangeMap")
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public interface RangeMap<K extends Comparable, V> {
- /*
- * TODO(cpovirk): These docs sometimes say "map" and sometimes say "range map." Pick one, or at
- * least decide on a policy for when to use which.
- */
-
/**
* Returns the value associated with the specified key, or {@code null} if there is no such value.
*
* <p>Specifically, if any range in this range map contains the specified key, the value
* associated with that range is returned.
*/
- @CheckForNull
+ @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.
*/
- @CheckForNull
+ @Nullable
Entry<Range<K>, V> getEntry(K key);
/**
@@ -118,27 +111,25 @@
void remove(Range<K> range);
/**
- * Merges a value into a part of the map by applying a remapping function.
+ * Merges a value into the map over a range by applying a remapping function.
*
- * <p>If any parts of the range are already present in this map, those parts are mapped to new
- * values by applying the remapping function. The remapping function accepts the map's existing
- * value for that part of the range and the given value. It returns the value to be associated
- * with that part of the map, or it returns {@code null} to clear that part of the map.
+ * <p>If any parts of the range are already present in this range map, those parts are mapped to
+ * new values by applying the remapping function. Any parts of the range not already present in
+ * this range map are mapped to the specified value, unless the value is {@code null}.
*
- * <p>Any parts of the range not already present in this map are mapped to the specified value,
- * unless the value is {@code null}.
+ * <p>Any existing map entry spanning either range boundary may be split at the boundary, even if
+ * the merge does not affect its value.
*
- * <p>Any existing entry spanning either range boundary may be split at the boundary, even if the
- * merge does not affect its value. For example, if {@code rangeMap} had one entry {@code [1, 5]
- * => 3} then {@code rangeMap.merge(Range.closed(0,2), 3, Math::max)} could yield a map with the
- * entries {@code [0, 1) => 3, [1, 2] => 3, (2, 5] => 3}.
+ * <p>For example, if {@code rangeMap} had one entry {@code [1, 5] => 3} then {@code
+ * rangeMap.merge(Range.closed(0,2), 3, Math::max)} could yield a range map with the entries
+ * {@code [0, 1) => 3, [1, 2] => 3, (2, 5] => 3}.
*
* @since 28.1
*/
void merge(
Range<K> range,
- @CheckForNull V value,
- BiFunction<? super V, ? super @Nullable V, ? extends @Nullable V> remappingFunction);
+ @Nullable V value,
+ BiFunction<? super V, ? super V, ? extends V> remappingFunction);
/**
* Returns a view of this range map as an unmodifiable {@code Map<Range<K>, V>}. Modifications to
@@ -177,7 +168,6 @@
* <p>The returned range map will throw an {@link IllegalArgumentException} on an attempt to
* insert a range not {@linkplain Range#encloses(Range) enclosed} by {@code range}.
*/
- // TODO(cpovirk): Consider documenting that IAE on the various methods that can throw it.
RangeMap<K, V> subRangeMap(Range<K> range);
/**
@@ -185,7 +175,7 @@
* #asMapOfRanges()}.
*/
@Override
- boolean equals(@CheckForNull 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 1fb7b10..4805108 100644
--- a/guava/src/com/google/common/collect/RangeSet.java
+++ b/guava/src/com/google/common/collect/RangeSet.java
@@ -15,11 +15,11 @@
package com.google.common.collect;
import com.google.common.annotations.Beta;
-import com.google.common.annotations.GwtIncompatible;
import com.google.errorprone.annotations.DoNotMock;
+import com.google.common.annotations.GwtIncompatible;
import java.util.NoSuchElementException;
import java.util.Set;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* A set comprising zero or more {@linkplain Range#isEmpty nonempty}, {@linkplain
@@ -52,7 +52,6 @@
@Beta
@DoNotMock("Use ImmutableRangeSet or TreeRangeSet")
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public interface RangeSet<C extends Comparable> {
// TODO(lowasser): consider adding default implementations of some of these methods
@@ -65,7 +64,6 @@
* Returns the unique range from this range set that {@linkplain Range#contains contains} {@code
* value}, or {@code null} if this range set does not contain {@code value}.
*/
- @CheckForNull
Range<C> rangeContaining(C value);
/**
@@ -264,7 +262,7 @@
* according to {@link Range#equals(Object)}.
*/
@Override
- boolean equals(@CheckForNull 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 913e2d7..8497585 100644
--- a/guava/src/com/google/common/collect/RegularContiguousSet.java
+++ b/guava/src/com/google/common/collect/RegularContiguousSet.java
@@ -18,13 +18,12 @@
import static com.google.common.base.Preconditions.checkElementIndex;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.collect.BoundType.CLOSED;
-import static java.util.Objects.requireNonNull;
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.GwtIncompatible;
import java.io.Serializable;
import java.util.Collection;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* An implementation of {@link ContiguousSet} that contains one or more elements.
@@ -33,7 +32,6 @@
*/
@GwtCompatible(emulated = true)
@SuppressWarnings("unchecked") // allow ungenerified Comparable types
-@ElementTypesAreNonnullByDefault
final class RegularContiguousSet<C extends Comparable> extends ContiguousSet<C> {
private final Range<C> range;
@@ -73,9 +71,8 @@
@GwtIncompatible // not used by GWT emulation
@Override
- int indexOf(@CheckForNull Object target) {
- // requireNonNull is safe because of the contains check.
- return contains(target) ? (int) domain.distance(first(), (C) requireNonNull(target)) : -1;
+ int indexOf(Object target) {
+ return contains(target) ? (int) domain.distance(first(), (C) target) : -1;
}
@Override
@@ -84,7 +81,6 @@
final C last = last();
@Override
- @CheckForNull
protected C computeNext(C previous) {
return equalsOrThrow(previous, last) ? null : domain.next(previous);
}
@@ -98,14 +94,13 @@
final C first = first();
@Override
- @CheckForNull
protected C computeNext(C previous) {
return equalsOrThrow(previous, first) ? null : domain.previous(previous);
}
};
}
- private static boolean equalsOrThrow(Comparable<?> left, @CheckForNull Comparable<?> right) {
+ private static boolean equalsOrThrow(Comparable<?> left, @Nullable Comparable<?> right) {
return right != null && Range.compareOrThrow(left, right) == 0;
}
@@ -116,14 +111,12 @@
@Override
public C first() {
- // requireNonNull is safe because we checked the range is not empty in ContiguousSet.create.
- return requireNonNull(range.lowerBound.leastValueAbove(domain));
+ return range.lowerBound.leastValueAbove(domain);
}
@Override
public C last() {
- // requireNonNull is safe because we checked the range is not empty in ContiguousSet.create.
- return requireNonNull(range.upperBound.greatestValueBelow(domain));
+ return range.upperBound.greatestValueBelow(domain);
}
@Override
@@ -153,7 +146,7 @@
}
@Override
- public boolean contains(@CheckForNull Object object) {
+ public boolean contains(@Nullable Object object) {
if (object == null) {
return false;
}
@@ -202,7 +195,7 @@
}
@Override
- public boolean equals(@CheckForNull 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/RegularImmutableAsList.java b/guava/src/com/google/common/collect/RegularImmutableAsList.java
index 0e3fe4e..df17b6e 100644
--- a/guava/src/com/google/common/collect/RegularImmutableAsList.java
+++ b/guava/src/com/google/common/collect/RegularImmutableAsList.java
@@ -19,8 +19,6 @@
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.GwtIncompatible;
import java.util.function.Consumer;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* An {@link ImmutableAsList} implementation specialized for when the delegate collection is already
@@ -30,7 +28,6 @@
*/
@GwtCompatible(emulated = true)
@SuppressWarnings("serial") // uses writeReplace, not default serialization
-@ElementTypesAreNonnullByDefault
class RegularImmutableAsList<E> extends ImmutableAsList<E> {
private final ImmutableCollection<E> delegate;
private final ImmutableList<? extends E> delegateList;
@@ -67,12 +64,11 @@
@GwtIncompatible // not present in emulated superclass
@Override
- int copyIntoArray(@Nullable Object[] dst, int offset) {
+ int copyIntoArray(Object[] dst, int offset) {
return delegateList.copyIntoArray(dst, offset);
}
@Override
- @CheckForNull
Object[] internalArray() {
return delegateList.internalArray();
}
diff --git a/guava/src/com/google/common/collect/RegularImmutableBiMap.java b/guava/src/com/google/common/collect/RegularImmutableBiMap.java
index 60d22e2..f5b8988 100644
--- a/guava/src/com/google/common/collect/RegularImmutableBiMap.java
+++ b/guava/src/com/google/common/collect/RegularImmutableBiMap.java
@@ -21,7 +21,6 @@
import static com.google.common.collect.CollectPreconditions.checkEntryNotNull;
import static com.google.common.collect.ImmutableMapEntry.createEntryArray;
import static com.google.common.collect.RegularImmutableMap.checkNoConflictInKeyBucket;
-import static java.util.Objects.requireNonNull;
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.VisibleForTesting;
@@ -32,7 +31,6 @@
import java.io.Serializable;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -42,7 +40,6 @@
*/
@GwtCompatible(serializable = true, emulated = true)
@SuppressWarnings("serial") // uses writeReplace(), not default serialization
-@ElementTypesAreNonnullByDefault
class RegularImmutableBiMap<K, V> extends ImmutableBiMap<K, V> {
static final RegularImmutableBiMap<Object, Object> EMPTY =
new RegularImmutableBiMap<>(
@@ -50,8 +47,8 @@
static final double MAX_LOAD_FACTOR = 1.2;
- @CheckForNull private final transient @Nullable ImmutableMapEntry<K, V>[] keyTable;
- @CheckForNull private final transient @Nullable ImmutableMapEntry<K, V>[] valueTable;
+ private final transient ImmutableMapEntry<K, V>[] keyTable;
+ private final transient ImmutableMapEntry<K, V>[] valueTable;
@VisibleForTesting final transient Entry<K, V>[] entries;
private final transient int mask;
private final transient int hashCode;
@@ -60,25 +57,23 @@
return fromEntryArray(entries.length, entries);
}
- static <K, V> ImmutableBiMap<K, V> fromEntryArray(int n, @Nullable Entry<K, V>[] entryArray) {
+ static <K, V> ImmutableBiMap<K, V> fromEntryArray(int n, Entry<K, V>[] entryArray) {
checkPositionIndex(n, entryArray.length);
int tableSize = Hashing.closedTableSize(n, MAX_LOAD_FACTOR);
int mask = tableSize - 1;
- @Nullable ImmutableMapEntry<K, V>[] keyTable = createEntryArray(tableSize);
- @Nullable ImmutableMapEntry<K, V>[] valueTable = createEntryArray(tableSize);
- /*
- * The cast is safe: n==entryArray.length means that we have filled the whole array with Entry
- * instances, in which case it is safe to cast it from an array of nullable entries to an array
- * of non-null entries.
- */
- @SuppressWarnings("nullness")
- Entry<K, V>[] entries =
- (n == entryArray.length) ? (Entry<K, V>[]) entryArray : createEntryArray(n);
+ ImmutableMapEntry<K, V>[] keyTable = createEntryArray(tableSize);
+ ImmutableMapEntry<K, V>[] valueTable = createEntryArray(tableSize);
+ Entry<K, V>[] entries;
+ if (n == entryArray.length) {
+ entries = entryArray;
+ } else {
+ entries = createEntryArray(n);
+ }
int hashCode = 0;
for (int i = 0; i < n; i++) {
- // requireNonNull is safe because the first `n` elements have been filled in.
- Entry<K, V> entry = requireNonNull(entryArray[i]);
+ @SuppressWarnings("unchecked")
+ Entry<K, V> entry = entryArray[i];
K key = entry.getKey();
V value = entry.getValue();
checkEntryNotNull(key, value);
@@ -109,8 +104,8 @@
}
private RegularImmutableBiMap(
- @CheckForNull @Nullable ImmutableMapEntry<K, V>[] keyTable,
- @CheckForNull @Nullable ImmutableMapEntry<K, V>[] valueTable,
+ ImmutableMapEntry<K, V>[] keyTable,
+ ImmutableMapEntry<K, V>[] valueTable,
Entry<K, V>[] entries,
int mask,
int hashCode) {
@@ -129,7 +124,7 @@
*/
@CanIgnoreReturnValue
private static int checkNoConflictInValueBucket(
- Object value, Entry<?, ?> entry, @CheckForNull 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);
@@ -139,9 +134,8 @@
}
@Override
- @CheckForNull
- public V get(@CheckForNull Object key) {
- return RegularImmutableMap.get(key, keyTable, mask);
+ public @Nullable V get(@Nullable Object key) {
+ return (keyTable == null) ? null : RegularImmutableMap.get(key, keyTable, mask);
}
@Override
@@ -184,7 +178,7 @@
return entries.length;
}
- @LazyInit @RetainedWith @CheckForNull private transient ImmutableBiMap<V, K> inverse;
+ @LazyInit @RetainedWith private transient ImmutableBiMap<V, K> inverse;
@Override
public ImmutableBiMap<V, K> inverse() {
@@ -214,8 +208,7 @@
}
@Override
- @CheckForNull
- public K get(@CheckForNull Object value) {
+ public K get(@Nullable Object value) {
if (value == null || valueTable == null) {
return null;
}
diff --git a/guava/src/com/google/common/collect/RegularImmutableList.java b/guava/src/com/google/common/collect/RegularImmutableList.java
index 397147d..47f42d5 100644
--- a/guava/src/com/google/common/collect/RegularImmutableList.java
+++ b/guava/src/com/google/common/collect/RegularImmutableList.java
@@ -20,7 +20,6 @@
import com.google.common.annotations.VisibleForTesting;
import java.util.Spliterator;
import java.util.Spliterators;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Implementation of {@link ImmutableList} backed by a simple array.
@@ -29,7 +28,6 @@
*/
@GwtCompatible(serializable = true, emulated = true)
@SuppressWarnings("serial") // uses writeReplace(), not default serialization
-@ElementTypesAreNonnullByDefault
class RegularImmutableList<E> extends ImmutableList<E> {
static final ImmutableList<Object> EMPTY = new RegularImmutableList<>(new Object[0]);
@@ -65,7 +63,7 @@
}
@Override
- int copyIntoArray(@Nullable Object[] dst, int dstOff) {
+ int copyIntoArray(Object[] dst, int dstOff) {
System.arraycopy(array, 0, dst, dstOff, array.length);
return dstOff + array.length;
}
diff --git a/guava/src/com/google/common/collect/RegularImmutableMap.java b/guava/src/com/google/common/collect/RegularImmutableMap.java
index 43425b2..9efda84 100644
--- a/guava/src/com/google/common/collect/RegularImmutableMap.java
+++ b/guava/src/com/google/common/collect/RegularImmutableMap.java
@@ -20,7 +20,6 @@
import static com.google.common.base.Preconditions.checkPositionIndex;
import static com.google.common.collect.CollectPreconditions.checkEntryNotNull;
import static com.google.common.collect.ImmutableMapEntry.createEntryArray;
-import static java.util.Objects.requireNonNull;
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.GwtIncompatible;
@@ -29,7 +28,6 @@
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import java.io.Serializable;
import java.util.function.BiConsumer;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -40,7 +38,6 @@
* @author Gregory Kick
*/
@GwtCompatible(serializable = true, emulated = true)
-@ElementTypesAreNonnullByDefault
final class RegularImmutableMap<K, V> extends ImmutableMap<K, V> {
@SuppressWarnings("unchecked")
static final ImmutableMap<Object, Object> EMPTY =
@@ -68,7 +65,7 @@
// entries in insertion order
@VisibleForTesting final transient Entry<K, V>[] entries;
// array of linked lists of entries
- @CheckForNull private final transient @Nullable ImmutableMapEntry<K, V>[] table;
+ private final transient ImmutableMapEntry<K, V>[] table;
// 'and' with an int to get a table index
private final transient int mask;
@@ -81,30 +78,27 @@
* the entries in entryArray with its own entry objects (though they will have the same key/value
* contents), and may take ownership of entryArray.
*/
- static <K, V> ImmutableMap<K, V> fromEntryArray(int n, @Nullable Entry<K, V>[] entryArray) {
+ static <K, V> ImmutableMap<K, V> fromEntryArray(int n, Entry<K, V>[] entryArray) {
checkPositionIndex(n, entryArray.length);
if (n == 0) {
return (RegularImmutableMap<K, V>) EMPTY;
}
- /*
- * The cast is safe: n==entryArray.length means that we have filled the whole array with Entry
- * instances, in which case it is safe to cast it from an array of nullable entries to an array
- * of non-null entries.
- */
- @SuppressWarnings("nullness")
- Entry<K, V>[] entries =
- (n == entryArray.length) ? (Entry<K, V>[]) entryArray : createEntryArray(n);
+ Entry<K, V>[] entries;
+ if (n == entryArray.length) {
+ entries = entryArray;
+ } else {
+ entries = createEntryArray(n);
+ }
int tableSize = Hashing.closedTableSize(n, MAX_LOAD_FACTOR);
- @Nullable ImmutableMapEntry<K, V>[] table = createEntryArray(tableSize);
+ ImmutableMapEntry<K, V>[] table = createEntryArray(tableSize);
int mask = tableSize - 1;
for (int entryIndex = 0; entryIndex < n; entryIndex++) {
- // requireNonNull is safe because the first `n` elements have been filled in.
- Entry<K, V> entry = requireNonNull(entryArray[entryIndex]);
+ Entry<K, V> entry = entryArray[entryIndex];
K key = entry.getKey();
V value = entry.getValue();
checkEntryNotNull(key, value);
int tableIndex = Hashing.smear(key.hashCode()) & mask;
- ImmutableMapEntry<K, V> existing = table[tableIndex];
+ @Nullable ImmutableMapEntry<K, V> existing = table[tableIndex];
// prepend, not append, so the entries can be immutable
ImmutableMapEntry<K, V> newEntry =
(existing == null)
@@ -134,8 +128,7 @@
return makeImmutable(entry, entry.getKey(), entry.getValue());
}
- private RegularImmutableMap(
- Entry<K, V>[] entries, @CheckForNull @Nullable ImmutableMapEntry<K, V>[] table, int mask) {
+ private RegularImmutableMap(Entry<K, V>[] entries, ImmutableMapEntry<K, V>[] table, int mask) {
this.entries = entries;
this.table = table;
this.mask = mask;
@@ -147,7 +140,7 @@
*/
@CanIgnoreReturnValue
static int checkNoConflictInKeyBucket(
- Object key, Entry<?, ?> entry, @CheckForNull 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);
@@ -157,16 +150,12 @@
}
@Override
- @CheckForNull
- public V get(@CheckForNull Object key) {
+ public V get(@Nullable Object key) {
return get(key, table, mask);
}
- @CheckForNull
- static <V> V get(
- @CheckForNull Object key,
- @CheckForNull @Nullable ImmutableMapEntry<?, V>[] keyTable,
- int mask) {
+ static <V> @Nullable V get(
+ @Nullable Object key, ImmutableMapEntry<?, V> @Nullable [] keyTable, int mask) {
if (key == null || keyTable == null) {
return null;
}
@@ -231,7 +220,7 @@
}
@Override
- public boolean contains(@CheckForNull Object object) {
+ public boolean contains(Object object) {
return map.containsKey(object);
}
diff --git a/guava/src/com/google/common/collect/RegularImmutableMultiset.java b/guava/src/com/google/common/collect/RegularImmutableMultiset.java
index 026919e..93843da 100644
--- a/guava/src/com/google/common/collect/RegularImmutableMultiset.java
+++ b/guava/src/com/google/common/collect/RegularImmutableMultiset.java
@@ -24,7 +24,6 @@
import com.google.errorprone.annotations.concurrent.LazyInit;
import java.util.Arrays;
import java.util.Collection;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -35,41 +34,38 @@
*/
@GwtCompatible(emulated = true, serializable = true)
@SuppressWarnings("serial") // uses writeReplace(), not default serialization
-@ElementTypesAreNonnullByDefault
class RegularImmutableMultiset<E> extends ImmutableMultiset<E> {
- private static final ImmutableEntry<?>[] EMPTY_ARRAY = new ImmutableEntry<?>[0];
static final ImmutableMultiset<Object> EMPTY = create(ImmutableList.<Entry<Object>>of());
static <E> ImmutableMultiset<E> create(Collection<? extends Entry<? extends E>> entries) {
int distinct = entries.size();
- @SuppressWarnings({"unchecked", "rawtypes"})
- ImmutableEntry<E>[] entryArray = new ImmutableEntry[distinct];
+ @SuppressWarnings("unchecked")
+ Multisets.ImmutableEntry<E>[] entryArray = new Multisets.ImmutableEntry[distinct];
if (distinct == 0) {
- return new RegularImmutableMultiset<>(entryArray, EMPTY_ARRAY, 0, 0, ImmutableSet.of());
+ return new RegularImmutableMultiset<>(entryArray, null, 0, 0, ImmutableSet.of());
}
int tableSize = Hashing.closedTableSize(distinct, MAX_LOAD_FACTOR);
int mask = tableSize - 1;
- @SuppressWarnings({"unchecked", "rawtypes"})
- @Nullable
- ImmutableEntry<E>[] hashTable = new @Nullable ImmutableEntry[tableSize];
+ @SuppressWarnings("unchecked")
+ Multisets.ImmutableEntry<E>[] hashTable = new Multisets.ImmutableEntry[tableSize];
int index = 0;
int hashCode = 0;
long size = 0;
- for (Entry<? extends E> entryWithWildcard : entries) {
- @SuppressWarnings("unchecked") // safe because we only read from it
- Entry<E> entry = (Entry<E>) entryWithWildcard;
+ for (Entry<? extends E> entry : entries) {
E element = checkNotNull(entry.getElement());
int count = entry.getCount();
int hash = element.hashCode();
int bucket = Hashing.smear(hash) & mask;
- ImmutableEntry<E> bucketHead = hashTable[bucket];
- ImmutableEntry<E> newEntry;
+ Multisets.ImmutableEntry<E> bucketHead = hashTable[bucket];
+ Multisets.ImmutableEntry<E> newEntry;
if (bucketHead == null) {
boolean canReuseEntry =
- entry instanceof ImmutableEntry && !(entry instanceof NonTerminalEntry);
+ entry instanceof Multisets.ImmutableEntry && !(entry instanceof NonTerminalEntry);
newEntry =
- canReuseEntry ? (ImmutableEntry<E>) entry : new ImmutableEntry<E>(element, count);
+ canReuseEntry
+ ? (Multisets.ImmutableEntry<E>) entry
+ : new Multisets.ImmutableEntry<E>(element, count);
} else {
newEntry = new NonTerminalEntry<E>(element, count, bucketHead);
}
@@ -85,10 +81,12 @@
entryArray, hashTable, Ints.saturatedCast(size), hashCode, null);
}
- private static boolean hashFloodingDetected(@Nullable ImmutableEntry<?>[] hashTable) {
+ private static boolean hashFloodingDetected(Multisets.ImmutableEntry<?>[] hashTable) {
for (int i = 0; i < hashTable.length; i++) {
int bucketLength = 0;
- for (ImmutableEntry<?> entry = hashTable[i]; entry != null; entry = entry.nextInBucket()) {
+ for (Multisets.ImmutableEntry<?> entry = hashTable[i];
+ entry != null;
+ entry = entry.nextInBucket()) {
bucketLength++;
if (bucketLength > MAX_HASH_BUCKET_LENGTH) {
return true;
@@ -117,19 +115,19 @@
*/
@VisibleForTesting static final int MAX_HASH_BUCKET_LENGTH = 9;
- private final transient ImmutableEntry<E>[] entries;
- private final transient @Nullable ImmutableEntry<?>[] hashTable;
+ private final transient Multisets.ImmutableEntry<E>[] entries;
+ private final transient Multisets.ImmutableEntry<E> @Nullable [] hashTable;
private final transient int size;
private final transient int hashCode;
- @LazyInit @CheckForNull private transient ImmutableSet<E> elementSet;
+ @LazyInit private transient ImmutableSet<E> elementSet;
private RegularImmutableMultiset(
ImmutableEntry<E>[] entries,
- @Nullable ImmutableEntry<?>[] hashTable,
+ ImmutableEntry<E>[] hashTable,
int size,
int hashCode,
- @CheckForNull ImmutableSet<E> elementSet) {
+ ImmutableSet<E> elementSet) {
this.entries = entries;
this.hashTable = hashTable;
this.size = size;
@@ -137,8 +135,8 @@
this.elementSet = elementSet;
}
- private static final class NonTerminalEntry<E> extends ImmutableEntry<E> {
- private final ImmutableEntry<E> nextInBucket;
+ private static final class NonTerminalEntry<E> extends Multisets.ImmutableEntry<E> {
+ private final Multisets.ImmutableEntry<E> nextInBucket;
NonTerminalEntry(E element, int count, ImmutableEntry<E> nextInBucket) {
super(element, count);
@@ -157,14 +155,14 @@
}
@Override
- public int count(@CheckForNull Object element) {
- @Nullable ImmutableEntry<?>[] hashTable = this.hashTable;
- if (element == null || hashTable.length == 0) {
+ public int count(@Nullable Object element) {
+ Multisets.ImmutableEntry<E>[] hashTable = this.hashTable;
+ if (element == null || hashTable == null) {
return 0;
}
int hash = Hashing.smearedHash(element);
int mask = hashTable.length - 1;
- for (ImmutableEntry<?> entry = hashTable[hash & mask];
+ for (Multisets.ImmutableEntry<E> entry = hashTable[hash & mask];
entry != null;
entry = entry.nextInBucket()) {
if (Objects.equal(element, entry.getElement())) {
diff --git a/guava/src/com/google/common/collect/RegularImmutableSet.java b/guava/src/com/google/common/collect/RegularImmutableSet.java
index 211c893..d4d2f20 100644
--- a/guava/src/com/google/common/collect/RegularImmutableSet.java
+++ b/guava/src/com/google/common/collect/RegularImmutableSet.java
@@ -20,7 +20,6 @@
import com.google.common.annotations.VisibleForTesting;
import java.util.Spliterator;
import java.util.Spliterators;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -30,30 +29,28 @@
*/
@GwtCompatible(serializable = true, emulated = true)
@SuppressWarnings("serial") // uses writeReplace(), not default serialization
-@ElementTypesAreNonnullByDefault
-final class RegularImmutableSet<E> extends ImmutableSet.CachingAsList<E> {
- private static final Object[] EMPTY_ARRAY = new Object[0];
+final class RegularImmutableSet<E> extends ImmutableSet<E> {
static final RegularImmutableSet<Object> EMPTY =
- new RegularImmutableSet<>(EMPTY_ARRAY, 0, EMPTY_ARRAY, 0);
+ new RegularImmutableSet<>(new Object[0], 0, null, 0);
private final transient Object[] elements;
- private final transient int hashCode;
- // the same values as `elements` in hashed positions (plus nulls)
- @VisibleForTesting final transient @Nullable Object[] table;
+ // the same elements in hashed positions (plus nulls)
+ @VisibleForTesting final transient Object[] table;
// 'and' with an int to get a valid table index.
private final transient int mask;
+ private final transient int hashCode;
- RegularImmutableSet(Object[] elements, int hashCode, @Nullable Object[] table, int mask) {
+ RegularImmutableSet(Object[] elements, int hashCode, Object[] table, int mask) {
this.elements = elements;
- this.hashCode = hashCode;
this.table = table;
this.mask = mask;
+ this.hashCode = hashCode;
}
@Override
- public boolean contains(@CheckForNull Object target) {
- @Nullable Object[] table = this.table;
- if (target == null || table.length == 0) {
+ public boolean contains(@Nullable Object target) {
+ Object[] table = this.table;
+ if (target == null || table == null) {
return false;
}
for (int i = Hashing.smearedHash(target); ; i++) {
@@ -98,16 +95,14 @@
}
@Override
- int copyIntoArray(@Nullable Object[] dst, int offset) {
+ int copyIntoArray(Object[] dst, int offset) {
System.arraycopy(elements, 0, dst, offset, elements.length);
return offset + elements.length;
}
@Override
ImmutableList<E> createAsList() {
- return (table.length == 0)
- ? ImmutableList.<E>of()
- : new RegularImmutableAsList<E>(this, elements);
+ return (table == null) ? ImmutableList.<E>of() : new RegularImmutableAsList<E>(this, elements);
}
@Override
diff --git a/guava/src/com/google/common/collect/RegularImmutableSortedMultiset.java b/guava/src/com/google/common/collect/RegularImmutableSortedMultiset.java
index 4b7ba87..3056d56 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 javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* An immutable sorted multiset with one or more distinct elements.
@@ -32,7 +32,6 @@
*/
@SuppressWarnings("serial") // uses writeReplace, not default serialization
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
final class RegularImmutableSortedMultiset<E> extends ImmutableSortedMultiset<E> {
private static final long[] ZERO_CUMULATIVE_COUNTS = {0};
@@ -77,19 +76,17 @@
}
@Override
- @CheckForNull
public Entry<E> firstEntry() {
return isEmpty() ? null : getEntry(0);
}
@Override
- @CheckForNull
public Entry<E> lastEntry() {
return isEmpty() ? null : getEntry(length - 1);
}
@Override
- public int count(@CheckForNull 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 fcb683f..c659ada 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 javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* An immutable sorted set with one or more elements. TODO(jlevy): Consider separate class for a
@@ -39,7 +39,6 @@
*/
@GwtCompatible(serializable = true, emulated = true)
@SuppressWarnings({"serial", "rawtypes"})
-@ElementTypesAreNonnullByDefault
final class RegularImmutableSortedSet<E> extends ImmutableSortedSet<E> {
static final RegularImmutableSortedSet<Comparable> NATURAL_EMPTY_SET =
new RegularImmutableSortedSet<>(ImmutableList.<Comparable>of(), Ordering.natural());
@@ -52,7 +51,6 @@
}
@Override
- @CheckForNull
Object[] internalArray() {
return elements.internalArray();
}
@@ -94,7 +92,7 @@
}
@Override
- public boolean contains(@CheckForNull Object o) {
+ public boolean contains(@Nullable Object o) {
try {
return o != null && unsafeBinarySearch(o) >= 0;
} catch (ClassCastException e) {
@@ -169,7 +167,7 @@
}
@Override
- public boolean equals(@CheckForNull Object object) {
+ public boolean equals(@Nullable Object object) {
if (object == this) {
return true;
}
@@ -222,28 +220,24 @@
}
@Override
- @CheckForNull
public E lower(E element) {
int index = headIndex(element, false) - 1;
return (index == -1) ? null : elements.get(index);
}
@Override
- @CheckForNull
public E floor(E element) {
int index = headIndex(element, true) - 1;
return (index == -1) ? null : elements.get(index);
}
@Override
- @CheckForNull
public E ceiling(E element) {
int index = tailIndex(element, true);
return (index == size()) ? null : elements.get(index);
}
@Override
- @CheckForNull
public E higher(E element) {
int index = tailIndex(element, false);
return (index == size()) ? null : elements.get(index);
@@ -303,7 +297,7 @@
}
@Override
- int indexOf(@CheckForNull 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 24434c5..1511fa2 100644
--- a/guava/src/com/google/common/collect/RegularImmutableTable.java
+++ b/guava/src/com/google/common/collect/RegularImmutableTable.java
@@ -24,7 +24,7 @@
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* An implementation of {@link ImmutableTable} holding an arbitrary number of cells.
@@ -32,7 +32,6 @@
* @author Gregory Kick
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
abstract class RegularImmutableTable<R, C, V> extends ImmutableTable<R, C, V> {
RegularImmutableTable() {}
@@ -56,7 +55,7 @@
}
@Override
- public boolean contains(@CheckForNull 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());
@@ -98,8 +97,8 @@
static <R, C, V> RegularImmutableTable<R, C, V> forCells(
List<Cell<R, C, V>> cells,
- @CheckForNull final Comparator<? super R> rowComparator,
- @CheckForNull final Comparator<? super C> columnComparator) {
+ final @Nullable Comparator<? super R> rowComparator,
+ final @Nullable Comparator<? super C> columnComparator) {
checkNotNull(cells);
if (rowComparator != null || columnComparator != null) {
/*
@@ -136,8 +135,8 @@
private static <R, C, V> RegularImmutableTable<R, C, V> forCellsInternal(
Iterable<Cell<R, C, V>> cells,
- @CheckForNull Comparator<? super R> rowComparator,
- @CheckForNull Comparator<? super C> columnComparator) {
+ @Nullable Comparator<? super R> rowComparator,
+ @Nullable Comparator<? super C> columnComparator) {
Set<R> rowSpaceBuilder = new LinkedHashSet<>();
Set<C> columnSpaceBuilder = new LinkedHashSet<>();
ImmutableList<Cell<R, C, V>> cellList = ImmutableList.copyOf(cells);
@@ -175,7 +174,7 @@
* We could have declared this method 'static' but the additional compile-time checks achieved by
* referencing the type variables seem worthwhile.
*/
- final void checkNoDuplicate(R rowKey, C columnKey, @CheckForNull V existingValue, V newValue) {
+ final void checkNoDuplicate(R rowKey, C columnKey, V existingValue, V newValue) {
checkArgument(
existingValue == null,
"Duplicate key: (row=%s, column=%s), values: [%s, %s].",
diff --git a/guava/src/com/google/common/collect/ReverseNaturalOrdering.java b/guava/src/com/google/common/collect/ReverseNaturalOrdering.java
index f0c40cb..612d846 100644
--- a/guava/src/com/google/common/collect/ReverseNaturalOrdering.java
+++ b/guava/src/com/google/common/collect/ReverseNaturalOrdering.java
@@ -25,64 +25,63 @@
/** An ordering that uses the reverse of the natural order of the values. */
@GwtCompatible(serializable = true)
@SuppressWarnings({"unchecked", "rawtypes"}) // TODO(kevinb): the right way to explain this??
-@ElementTypesAreNonnullByDefault
-final class ReverseNaturalOrdering extends Ordering<Comparable<?>> implements Serializable {
+final class ReverseNaturalOrdering extends Ordering<Comparable> implements Serializable {
static final ReverseNaturalOrdering INSTANCE = new ReverseNaturalOrdering();
@Override
- public int compare(Comparable<?> left, Comparable<?> right) {
+ public int compare(Comparable left, Comparable right) {
checkNotNull(left); // right null is caught later
if (left == right) {
return 0;
}
- return ((Comparable<Object>) right).compareTo(left);
+ return right.compareTo(left);
}
@Override
- public <S extends Comparable<?>> Ordering<S> reverse() {
+ public <S extends Comparable> Ordering<S> reverse() {
return Ordering.natural();
}
// Override the min/max methods to "hoist" delegation outside loops
@Override
- public <E extends Comparable<?>> E min(E a, E b) {
+ public <E extends Comparable> E min(E a, E b) {
return NaturalOrdering.INSTANCE.max(a, b);
}
@Override
- public <E extends Comparable<?>> E min(E a, E b, E c, E... rest) {
+ public <E extends Comparable> E min(E a, E b, E c, E... rest) {
return NaturalOrdering.INSTANCE.max(a, b, c, rest);
}
@Override
- public <E extends Comparable<?>> E min(Iterator<E> iterator) {
+ public <E extends Comparable> E min(Iterator<E> iterator) {
return NaturalOrdering.INSTANCE.max(iterator);
}
@Override
- public <E extends Comparable<?>> E min(Iterable<E> iterable) {
+ public <E extends Comparable> E min(Iterable<E> iterable) {
return NaturalOrdering.INSTANCE.max(iterable);
}
@Override
- public <E extends Comparable<?>> E max(E a, E b) {
+ public <E extends Comparable> E max(E a, E b) {
return NaturalOrdering.INSTANCE.min(a, b);
}
@Override
- public <E extends Comparable<?>> E max(E a, E b, E c, E... rest) {
+ public <E extends Comparable> E max(E a, E b, E c, E... rest) {
return NaturalOrdering.INSTANCE.min(a, b, c, rest);
}
@Override
- public <E extends Comparable<?>> E max(Iterator<E> iterator) {
+ public <E extends Comparable> E max(Iterator<E> iterator) {
return NaturalOrdering.INSTANCE.min(iterator);
}
@Override
- public <E extends Comparable<?>> E max(Iterable<E> iterable) {
+ public <E extends Comparable> E max(Iterable<E> iterable) {
return NaturalOrdering.INSTANCE.min(iterable);
}
diff --git a/guava/src/com/google/common/collect/ReverseOrdering.java b/guava/src/com/google/common/collect/ReverseOrdering.java
index 6c1e74d..ab9c3ac 100644
--- a/guava/src/com/google/common/collect/ReverseOrdering.java
+++ b/guava/src/com/google/common/collect/ReverseOrdering.java
@@ -21,14 +21,11 @@
import com.google.common.annotations.GwtCompatible;
import java.io.Serializable;
import java.util.Iterator;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/** An ordering that uses the reverse of a given order. */
@GwtCompatible(serializable = true)
-@ElementTypesAreNonnullByDefault
-final class ReverseOrdering<T extends @Nullable Object> extends Ordering<T>
- implements Serializable {
+final class ReverseOrdering<T> extends Ordering<T> implements Serializable {
final Ordering<? super T> forwardOrder;
ReverseOrdering(Ordering<? super T> forwardOrder) {
@@ -36,7 +33,7 @@
}
@Override
- public int compare(@ParametricNullness T a, @ParametricNullness T b) {
+ public int compare(T a, T b) {
return forwardOrder.compare(b, a);
}
@@ -49,13 +46,12 @@
// Override the min/max methods to "hoist" delegation outside loops
@Override
- public <E extends T> E min(@ParametricNullness E a, @ParametricNullness E b) {
+ public <E extends T> E min(E a, E b) {
return forwardOrder.max(a, b);
}
@Override
- public <E extends T> E min(
- @ParametricNullness E a, @ParametricNullness E b, @ParametricNullness E c, E... rest) {
+ public <E extends T> E min(E a, E b, E c, E... rest) {
return forwardOrder.max(a, b, c, rest);
}
@@ -70,13 +66,12 @@
}
@Override
- public <E extends T> E max(@ParametricNullness E a, @ParametricNullness E b) {
+ public <E extends T> E max(E a, E b) {
return forwardOrder.min(a, b);
}
@Override
- public <E extends T> E max(
- @ParametricNullness E a, @ParametricNullness E b, @ParametricNullness E c, E... rest) {
+ public <E extends T> E max(E a, E b, E c, E... rest) {
return forwardOrder.min(a, b, c, rest);
}
@@ -96,7 +91,7 @@
}
@Override
- public boolean equals(@CheckForNull Object object) {
+ public boolean equals(@Nullable Object object) {
if (object == this) {
return true;
}
diff --git a/guava/src/com/google/common/collect/RowSortedTable.java b/guava/src/com/google/common/collect/RowSortedTable.java
index 2c2d773..9cdae79 100644
--- a/guava/src/com/google/common/collect/RowSortedTable.java
+++ b/guava/src/com/google/common/collect/RowSortedTable.java
@@ -21,7 +21,6 @@
import java.util.Set;
import java.util.SortedMap;
import java.util.SortedSet;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Interface that extends {@code Table} and whose rows are sorted.
@@ -34,10 +33,7 @@
* @since 8.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-public interface RowSortedTable<
- R extends @Nullable Object, C extends @Nullable Object, V extends @Nullable Object>
- extends Table<R, C, V> {
+public interface RowSortedTable<R, C, V> extends Table<R, C, V> {
/**
* {@inheritDoc}
*
diff --git a/guava/src/com/google/common/collect/Serialization.java b/guava/src/com/google/common/collect/Serialization.java
index 5e88067..929a48f 100644
--- a/guava/src/com/google/common/collect/Serialization.java
+++ b/guava/src/com/google/common/collect/Serialization.java
@@ -23,7 +23,6 @@
import java.lang.reflect.Field;
import java.util.Collection;
import java.util.Map;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Provides static methods for serializing collection classes.
@@ -34,7 +33,6 @@
* @author Jared Levy
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
final class Serialization {
private Serialization() {}
@@ -56,8 +54,7 @@
* <p>The serialized output consists of the number of entries, first key, first value, second key,
* second value, and so on.
*/
- static <K extends @Nullable Object, V extends @Nullable Object> void writeMap(
- Map<K, V> map, ObjectOutputStream stream) throws IOException {
+ static <K, V> void writeMap(Map<K, V> map, ObjectOutputStream stream) throws IOException {
stream.writeInt(map.size());
for (Map.Entry<K, V> entry : map.entrySet()) {
stream.writeObject(entry.getKey());
@@ -69,8 +66,8 @@
* Populates a map by reading an input stream, as part of deserialization. See {@link #writeMap}
* for the data format.
*/
- static <K extends @Nullable Object, V extends @Nullable Object> void populateMap(
- Map<K, V> map, ObjectInputStream stream) throws IOException, ClassNotFoundException {
+ static <K, V> void populateMap(Map<K, V> map, ObjectInputStream stream)
+ throws IOException, ClassNotFoundException {
int size = stream.readInt();
populateMap(map, stream, size);
}
@@ -79,8 +76,7 @@
* Populates a map by reading an input stream, as part of deserialization. See {@link #writeMap}
* for the data format. The size is determined by a prior call to {@link #readCount}.
*/
- static <K extends @Nullable Object, V extends @Nullable Object> void populateMap(
- Map<K, V> map, ObjectInputStream stream, int size)
+ static <K, V> void populateMap(Map<K, V> map, ObjectInputStream stream, int size)
throws IOException, ClassNotFoundException {
for (int i = 0; i < size; i++) {
@SuppressWarnings("unchecked") // reading data stored by writeMap
@@ -98,8 +94,8 @@
* <p>The serialized output consists of the number of distinct elements, the first element, its
* count, the second element, its count, and so on.
*/
- static <E extends @Nullable Object> void writeMultiset(
- Multiset<E> multiset, ObjectOutputStream stream) throws IOException {
+ static <E> void writeMultiset(Multiset<E> multiset, ObjectOutputStream stream)
+ throws IOException {
int entryCount = multiset.entrySet().size();
stream.writeInt(entryCount);
for (Multiset.Entry<E> entry : multiset.entrySet()) {
@@ -112,8 +108,8 @@
* Populates a multiset by reading an input stream, as part of deserialization. See {@link
* #writeMultiset} for the data format.
*/
- static <E extends @Nullable Object> void populateMultiset(
- Multiset<E> multiset, ObjectInputStream stream) throws IOException, ClassNotFoundException {
+ static <E> void populateMultiset(Multiset<E> multiset, ObjectInputStream stream)
+ throws IOException, ClassNotFoundException {
int distinctElements = stream.readInt();
populateMultiset(multiset, stream, distinctElements);
}
@@ -123,7 +119,7 @@
* #writeMultiset} for the data format. The number of distinct elements is determined by a prior
* call to {@link #readCount}.
*/
- static <E extends @Nullable Object> void populateMultiset(
+ static <E> void populateMultiset(
Multiset<E> multiset, ObjectInputStream stream, int distinctElements)
throws IOException, ClassNotFoundException {
for (int i = 0; i < distinctElements; i++) {
@@ -142,8 +138,8 @@
* <p>The serialized output consists of the number of distinct keys, and then for each distinct
* key: the key, the number of values for that key, and the key's values.
*/
- static <K extends @Nullable Object, V extends @Nullable Object> void writeMultimap(
- Multimap<K, V> multimap, ObjectOutputStream stream) throws IOException {
+ static <K, V> void writeMultimap(Multimap<K, V> multimap, ObjectOutputStream stream)
+ throws IOException {
stream.writeInt(multimap.asMap().size());
for (Map.Entry<K, Collection<V>> entry : multimap.asMap().entrySet()) {
stream.writeObject(entry.getKey());
@@ -158,8 +154,7 @@
* Populates a multimap by reading an input stream, as part of deserialization. See {@link
* #writeMultimap} for the data format.
*/
- static <K extends @Nullable Object, V extends @Nullable Object> void populateMultimap(
- Multimap<K, V> multimap, ObjectInputStream stream)
+ static <K, V> void populateMultimap(Multimap<K, V> multimap, ObjectInputStream stream)
throws IOException, ClassNotFoundException {
int distinctKeys = stream.readInt();
populateMultimap(multimap, stream, distinctKeys);
@@ -170,7 +165,7 @@
* #writeMultimap} for the data format. The number of distinct keys is determined by a prior call
* to {@link #readCount}.
*/
- static <K extends @Nullable Object, V extends @Nullable Object> void populateMultimap(
+ static <K, V> void populateMultimap(
Multimap<K, V> multimap, ObjectInputStream stream, int distinctKeys)
throws IOException, ClassNotFoundException {
for (int i = 0; i < distinctKeys; i++) {
diff --git a/guava/src/com/google/common/collect/SetMultimap.java b/guava/src/com/google/common/collect/SetMultimap.java
index 216533e..90e6e1b 100644
--- a/guava/src/com/google/common/collect/SetMultimap.java
+++ b/guava/src/com/google/common/collect/SetMultimap.java
@@ -22,7 +22,6 @@
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -42,9 +41,6 @@
* {@code equals} comparisons. Use caution if mutable objects are used as keys or values in a {@code
* SetMultimap}.
*
- * <p><b>Warning:</b> Do not modify either a key <i>or a value</i> of a {@code SetMultimap} in a way
- * that affects its {@link Object#equals} behavior. Undefined behavior and bugs will result.
- *
* <p>See the Guava User Guide article on <a href=
* "https://github.com/google/guava/wiki/NewCollectionTypesExplained#multimap"> {@code
* Multimap}</a>.
@@ -53,9 +49,7 @@
* @since 2.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-public interface SetMultimap<K extends @Nullable Object, V extends @Nullable Object>
- extends Multimap<K, V> {
+public interface SetMultimap<K, V> extends Multimap<K, V> {
/**
* {@inheritDoc}
*
@@ -64,7 +58,7 @@
* interface.
*/
@Override
- Set<V> get(@ParametricNullness K key);
+ Set<V> get(@Nullable K key);
/**
* {@inheritDoc}
@@ -75,7 +69,7 @@
*/
@CanIgnoreReturnValue
@Override
- Set<V> removeAll(@CheckForNull Object key);
+ Set<V> removeAll(@Nullable Object key);
/**
* {@inheritDoc}
@@ -88,7 +82,7 @@
*/
@CanIgnoreReturnValue
@Override
- Set<V> replaceValues(@ParametricNullness K key, Iterable<? extends V> values);
+ Set<V> replaceValues(K key, Iterable<? extends V> values);
/**
* {@inheritDoc}
@@ -120,5 +114,5 @@
* empty {@code ListMultimap}.
*/
@Override
- boolean equals(@CheckForNull 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 5338bd2..3ad0f9d 100644
--- a/guava/src/com/google/common/collect/Sets.java
+++ b/guava/src/com/google/common/collect/Sets.java
@@ -28,7 +28,6 @@
import com.google.common.collect.Collections2.FilteredCollection;
import com.google.common.math.IntMath;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
-import com.google.errorprone.annotations.DoNotCall;
import java.io.Serializable;
import java.util.AbstractSet;
import java.util.Arrays;
@@ -52,7 +51,6 @@
import java.util.function.Consumer;
import java.util.stream.Collector;
import java.util.stream.Stream;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -68,7 +66,6 @@
* @since 2.0
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
public final class Sets {
private Sets() {}
@@ -76,7 +73,7 @@
* {@link AbstractSet} substitute without the potentially-quadratic {@code removeAll}
* implementation.
*/
- abstract static class ImprovedAbstractSet<E extends @Nullable Object> extends AbstractSet<E> {
+ abstract static class ImprovedAbstractSet<E> extends AbstractSet<E> {
@Override
public boolean removeAll(Collection<?> c) {
return removeAllImpl(this, c);
@@ -140,6 +137,42 @@
}
}
+ private static final class Accumulator<E extends Enum<E>> {
+ static final Collector<Enum<?>, ?, ImmutableSet<? extends Enum<?>>> TO_IMMUTABLE_ENUM_SET =
+ (Collector)
+ Collector.<Enum, Accumulator, ImmutableSet<?>>of(
+ Accumulator::new,
+ Accumulator::add,
+ Accumulator::combine,
+ Accumulator::toImmutableSet,
+ Collector.Characteristics.UNORDERED);
+
+ private @Nullable EnumSet<E> set;
+
+ void add(E e) {
+ if (set == null) {
+ set = EnumSet.of(e);
+ } else {
+ set.add(e);
+ }
+ }
+
+ Accumulator<E> combine(Accumulator<E> other) {
+ if (this.set == null) {
+ return other;
+ } else if (other.set == null) {
+ return this;
+ } else {
+ this.set.addAll(other.set);
+ return this;
+ }
+ }
+
+ ImmutableSet<E> toImmutableSet() {
+ return (set == null) ? ImmutableSet.<E>of() : ImmutableEnumSet.asImmutable(set);
+ }
+ }
+
/**
* Returns a {@code Collector} that accumulates the input elements into a new {@code ImmutableSet}
* with an implementation specialized for enums. Unlike {@link ImmutableSet#toImmutableSet}, the
@@ -148,7 +181,7 @@
* @since 21.0
*/
public static <E extends Enum<E>> Collector<E, ?, ImmutableSet<E>> toImmutableEnumSet() {
- return CollectCollectors.toImmutableEnumSet();
+ return (Collector) Accumulator.TO_IMMUTABLE_ENUM_SET;
}
/**
@@ -177,7 +210,7 @@
* deprecated. Instead, use the {@code HashSet} constructor directly, taking advantage of the new
* <a href="http://goo.gl/iz2Wi">"diamond" syntax</a>.
*/
- public static <E extends @Nullable Object> HashSet<E> newHashSet() {
+ public static <E> HashSet<E> newHashSet() {
return new HashSet<E>();
}
@@ -194,7 +227,7 @@
* asList}{@code (...))}, or for creating an empty set then calling {@link Collections#addAll}.
* This method is not actually very useful and will likely be deprecated in the future.
*/
- public static <E extends @Nullable Object> HashSet<E> newHashSet(E... elements) {
+ public static <E> HashSet<E> newHashSet(E... elements) {
HashSet<E> set = newHashSetWithExpectedSize(elements.length);
Collections.addAll(set, elements);
return set;
@@ -218,7 +251,7 @@
*
* <p>Overall, this method is not very useful and will likely be deprecated in the future.
*/
- public static <E extends @Nullable Object> HashSet<E> newHashSet(Iterable<? extends E> elements) {
+ public static <E> HashSet<E> newHashSet(Iterable<? extends E> elements) {
return (elements instanceof Collection)
? new HashSet<E>((Collection<? extends E>) elements)
: newHashSet(elements.iterator());
@@ -236,7 +269,7 @@
*
* <p>Overall, this method is not very useful and will likely be deprecated in the future.
*/
- public static <E extends @Nullable Object> HashSet<E> newHashSet(Iterator<? extends E> elements) {
+ public static <E> HashSet<E> newHashSet(Iterator<? extends E> elements) {
HashSet<E> set = newHashSet();
Iterators.addAll(set, elements);
return set;
@@ -254,8 +287,7 @@
* without resizing
* @throws IllegalArgumentException if {@code expectedSize} is negative
*/
- public static <E extends @Nullable Object> HashSet<E> newHashSetWithExpectedSize(
- int expectedSize) {
+ public static <E> HashSet<E> newHashSetWithExpectedSize(int expectedSize) {
return new HashSet<E>(Maps.capacity(expectedSize));
}
@@ -270,7 +302,7 @@
* @since 15.0
*/
public static <E> Set<E> newConcurrentHashSet() {
- return Platform.newConcurrentHashSet();
+ return Collections.newSetFromMap(new ConcurrentHashMap<E, Boolean>());
}
/**
@@ -305,7 +337,7 @@
*
* @return a new, empty {@code LinkedHashSet}
*/
- public static <E extends @Nullable Object> LinkedHashSet<E> newLinkedHashSet() {
+ public static <E> LinkedHashSet<E> newLinkedHashSet() {
return new LinkedHashSet<E>();
}
@@ -324,8 +356,7 @@
* @param elements the elements that the set should contain, in order
* @return a new {@code LinkedHashSet} containing those elements (minus duplicates)
*/
- public static <E extends @Nullable Object> LinkedHashSet<E> newLinkedHashSet(
- Iterable<? extends E> elements) {
+ public static <E> LinkedHashSet<E> newLinkedHashSet(Iterable<? extends E> elements) {
if (elements instanceof Collection) {
return new LinkedHashSet<E>((Collection<? extends E>) elements);
}
@@ -346,8 +377,7 @@
* @throws IllegalArgumentException if {@code expectedSize} is negative
* @since 11.0
*/
- public static <E extends @Nullable Object> LinkedHashSet<E> newLinkedHashSetWithExpectedSize(
- int expectedSize) {
+ public static <E> LinkedHashSet<E> newLinkedHashSetWithExpectedSize(int expectedSize) {
return new LinkedHashSet<E>(Maps.capacity(expectedSize));
}
@@ -412,8 +442,7 @@
* @return a new, empty {@code TreeSet}
* @throws NullPointerException if {@code comparator} is null
*/
- public static <E extends @Nullable Object> TreeSet<E> newTreeSet(
- Comparator<? super E> comparator) {
+ public static <E> TreeSet<E> newTreeSet(Comparator<? super E> comparator) {
return new TreeSet<E>(checkNotNull(comparator));
}
@@ -426,7 +455,7 @@
*
* @since 8.0
*/
- public static <E extends @Nullable Object> Set<E> newIdentityHashSet() {
+ public static <E> Set<E> newIdentityHashSet() {
return Collections.newSetFromMap(Maps.<E, Boolean>newIdentityHashMap());
}
@@ -440,7 +469,7 @@
* @since 12.0
*/
@GwtIncompatible // CopyOnWriteArraySet
- public static <E extends @Nullable Object> CopyOnWriteArraySet<E> newCopyOnWriteArraySet() {
+ public static <E> CopyOnWriteArraySet<E> newCopyOnWriteArraySet() {
return new CopyOnWriteArraySet<E>();
}
@@ -452,8 +481,7 @@
* @since 12.0
*/
@GwtIncompatible // CopyOnWriteArraySet
- public static <E extends @Nullable Object> CopyOnWriteArraySet<E> newCopyOnWriteArraySet(
- Iterable<? extends E> elements) {
+ public static <E> CopyOnWriteArraySet<E> newCopyOnWriteArraySet(Iterable<? extends E> elements) {
// We copy elements to an ArrayList first, rather than incurring the
// quadratic cost of adding them to the COWAS directly.
Collection<? extends E> elementsCollection =
@@ -541,8 +569,7 @@
* @deprecated Use {@link Collections#newSetFromMap} instead.
*/
@Deprecated
- public static <E extends @Nullable Object> Set<E> newSetFromMap(
- Map<E, Boolean> map) {
+ public static <E> Set<E> newSetFromMap(Map<E, Boolean> map) {
return Collections.newSetFromMap(map);
}
@@ -555,7 +582,7 @@
*
* @since 2.0
*/
- public abstract static class SetView<E extends @Nullable Object> extends AbstractSet<E> {
+ public abstract static class SetView<E> extends AbstractSet<E> {
private SetView() {} // no subclasses but our own
/**
@@ -566,7 +593,6 @@
* nonstandard notion of equivalence, for example if it is a {@link TreeSet} using a comparator
* that is inconsistent with {@link Object#equals(Object)}.
*/
- @SuppressWarnings("nullness") // Unsafe, but we can't fix it now.
public ImmutableSet<E> immutableCopy() {
return ImmutableSet.copyOf(this);
}
@@ -595,8 +621,7 @@
@CanIgnoreReturnValue
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
- public final boolean add(@ParametricNullness E e) {
+ public final boolean add(E e) {
throw new UnsupportedOperationException();
}
@@ -609,8 +634,7 @@
@CanIgnoreReturnValue
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
- public final boolean remove(@CheckForNull Object object) {
+ public final boolean remove(Object object) {
throw new UnsupportedOperationException();
}
@@ -623,7 +647,6 @@
@CanIgnoreReturnValue
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
public final boolean addAll(Collection<? extends E> newElements) {
throw new UnsupportedOperationException();
}
@@ -637,7 +660,6 @@
@CanIgnoreReturnValue
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
public final boolean removeAll(Collection<?> oldElements) {
throw new UnsupportedOperationException();
}
@@ -651,7 +673,6 @@
@CanIgnoreReturnValue
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
public final boolean removeIf(java.util.function.Predicate<? super E> filter) {
throw new UnsupportedOperationException();
}
@@ -665,7 +686,6 @@
@CanIgnoreReturnValue
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
public final boolean retainAll(Collection<?> elementsToKeep) {
throw new UnsupportedOperationException();
}
@@ -678,7 +698,6 @@
*/
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
public final void clear() {
throw new UnsupportedOperationException();
}
@@ -699,11 +718,10 @@
* that is not contained in {@code set1}.
*
* <p>Results are undefined if {@code set1} and {@code set2} are sets based on different
- * equivalence relations, for example if {@code set1} is a {@link HashSet} and {@code set2} is a
- * {@link TreeSet} or the {@link Map#keySet} of an {@code IdentityHashMap}.
+ * equivalence relations (as {@link HashSet}, {@link TreeSet}, and the {@link Map#keySet} of an
+ * {@code IdentityHashMap} all are).
*/
- public static <E extends @Nullable Object> SetView<E> union(
- final Set<? extends E> set1, final Set<? extends E> set2) {
+ public static <E> SetView<E> union(final Set<? extends E> set1, final Set<? extends E> set2) {
checkNotNull(set1, "set1");
checkNotNull(set2, "set2");
@@ -731,7 +749,6 @@
final Iterator<? extends E> itr2 = set2.iterator();
@Override
- @CheckForNull
protected E computeNext() {
if (itr1.hasNext()) {
return itr1.next();
@@ -749,7 +766,7 @@
@Override
public Stream<E> stream() {
- return Stream.concat(set1.stream(), set2.stream().filter((E e) -> !set1.contains(e)));
+ return Stream.concat(set1.stream(), set2.stream().filter(e -> !set1.contains(e)));
}
@Override
@@ -758,7 +775,7 @@
}
@Override
- public boolean contains(@CheckForNull Object object) {
+ public boolean contains(Object object) {
return set1.contains(object) || set2.contains(object);
}
@@ -770,7 +787,6 @@
}
@Override
- @SuppressWarnings("nullness") // see supertype
public ImmutableSet<E> immutableCopy() {
return new ImmutableSet.Builder<E>().addAll(set1).addAll(set2).build();
}
@@ -783,8 +799,8 @@
* matches that of {@code set1}.
*
* <p>Results are undefined if {@code set1} and {@code set2} are sets based on different
- * equivalence relations, for example if {@code set1} is a {@link HashSet} and {@code set2} is a
- * {@link TreeSet} or the {@link Map#keySet} of an {@code IdentityHashMap}.
+ * equivalence relations (as {@code HashSet}, {@code TreeSet}, and the keySet of an {@code
+ * IdentityHashMap} all are).
*
* <p><b>Note:</b> The returned view performs slightly better when {@code set1} is the smaller of
* the two sets. If you have reason to believe one of your sets will generally be smaller than the
@@ -804,8 +820,7 @@
*
* <p>This is unfortunate, but should come up only very rarely.
*/
- public static <E extends @Nullable Object> SetView<E> intersection(
- final Set<E> set1, final Set<?> set2) {
+ public static <E> SetView<E> intersection(final Set<E> set1, final Set<?> set2) {
checkNotNull(set1, "set1");
checkNotNull(set2, "set2");
@@ -816,7 +831,6 @@
final Iterator<E> itr = set1.iterator();
@Override
- @CheckForNull
protected E computeNext() {
while (itr.hasNext()) {
E e = itr.next();
@@ -856,7 +870,7 @@
}
@Override
- public boolean contains(@CheckForNull Object object) {
+ public boolean contains(Object object) {
return set1.contains(object) && set2.contains(object);
}
@@ -874,11 +888,10 @@
* order of the returned set matches that of {@code set1}.
*
* <p>Results are undefined if {@code set1} and {@code set2} are sets based on different
- * equivalence relations, for example if {@code set1} is a {@link HashSet} and {@code set2} is a
- * {@link TreeSet} or the {@link Map#keySet} of an {@code IdentityHashMap}.
+ * equivalence relations (as {@code HashSet}, {@code TreeSet}, and the keySet of an {@code
+ * IdentityHashMap} all are).
*/
- public static <E extends @Nullable Object> SetView<E> difference(
- final Set<E> set1, final Set<?> set2) {
+ public static <E> SetView<E> difference(final Set<E> set1, final Set<?> set2) {
checkNotNull(set1, "set1");
checkNotNull(set2, "set2");
@@ -889,7 +902,6 @@
final Iterator<E> itr = set1.iterator();
@Override
- @CheckForNull
protected E computeNext() {
while (itr.hasNext()) {
E e = itr.next();
@@ -929,7 +941,7 @@
}
@Override
- public boolean contains(@CheckForNull Object element) {
+ public boolean contains(Object element) {
return set1.contains(element) && !set2.contains(element);
}
};
@@ -941,12 +953,12 @@
* both. The iteration order of the returned set is undefined.
*
* <p>Results are undefined if {@code set1} and {@code set2} are sets based on different
- * equivalence relations, for example if {@code set1} is a {@link HashSet} and {@code set2} is a
- * {@link TreeSet} or the {@link Map#keySet} of an {@code IdentityHashMap}.
+ * equivalence relations (as {@code HashSet}, {@code TreeSet}, and the keySet of an {@code
+ * IdentityHashMap} all are).
*
* @since 3.0
*/
- public static <E extends @Nullable Object> SetView<E> symmetricDifference(
+ public static <E> SetView<E> symmetricDifference(
final Set<? extends E> set1, final Set<? extends E> set2) {
checkNotNull(set1, "set1");
checkNotNull(set2, "set2");
@@ -958,7 +970,6 @@
final Iterator<? extends E> itr2 = set2.iterator();
return new AbstractIterator<E>() {
@Override
- @CheckForNull
public E computeNext() {
while (itr1.hasNext()) {
E elem1 = itr1.next();
@@ -999,7 +1010,7 @@
}
@Override
- public boolean contains(@CheckForNull Object element) {
+ public boolean contains(Object element) {
return set1.contains(element) ^ set2.contains(element);
}
};
@@ -1032,8 +1043,7 @@
* you to migrate to streams.
*/
// TODO(kevinb): how to omit that last sentence when building GWT javadoc?
- public static <E extends @Nullable Object> Set<E> filter(
- Set<E> unfiltered, Predicate<? super E> predicate) {
+ public static <E> Set<E> filter(Set<E> unfiltered, Predicate<? super E> predicate) {
if (unfiltered instanceof SortedSet) {
return filter((SortedSet<E>) unfiltered, predicate);
}
@@ -1072,8 +1082,7 @@
*
* @since 11.0
*/
- public static <E extends @Nullable Object> SortedSet<E> filter(
- SortedSet<E> unfiltered, Predicate<? super E> predicate) {
+ public static <E> SortedSet<E> filter(SortedSet<E> unfiltered, Predicate<? super E> predicate) {
if (unfiltered instanceof FilteredSet) {
// Support clear(), removeAll(), and retainAll() when filtering a filtered
// collection.
@@ -1111,7 +1120,7 @@
*/
@GwtIncompatible // NavigableSet
@SuppressWarnings("unchecked")
- public static <E extends @Nullable Object> NavigableSet<E> filter(
+ public static <E> NavigableSet<E> filter(
NavigableSet<E> unfiltered, Predicate<? super E> predicate) {
if (unfiltered instanceof FilteredSet) {
// Support clear(), removeAll(), and retainAll() when filtering a filtered
@@ -1124,14 +1133,13 @@
return new FilteredNavigableSet<E>(checkNotNull(unfiltered), checkNotNull(predicate));
}
- private static class FilteredSet<E extends @Nullable Object> extends FilteredCollection<E>
- implements Set<E> {
+ private static class FilteredSet<E> extends FilteredCollection<E> implements Set<E> {
FilteredSet(Set<E> unfiltered, Predicate<? super E> predicate) {
super(unfiltered, predicate);
}
@Override
- public boolean equals(@CheckForNull Object object) {
+ public boolean equals(@Nullable Object object) {
return equalsImpl(this, object);
}
@@ -1141,43 +1149,39 @@
}
}
- private static class FilteredSortedSet<E extends @Nullable Object> extends FilteredSet<E>
- implements SortedSet<E> {
+ private static class FilteredSortedSet<E> extends FilteredSet<E> implements SortedSet<E> {
FilteredSortedSet(SortedSet<E> unfiltered, Predicate<? super E> predicate) {
super(unfiltered, predicate);
}
@Override
- @CheckForNull
public Comparator<? super E> comparator() {
return ((SortedSet<E>) unfiltered).comparator();
}
@Override
- public SortedSet<E> subSet(@ParametricNullness E fromElement, @ParametricNullness E toElement) {
+ public SortedSet<E> subSet(E fromElement, E toElement) {
return new FilteredSortedSet<E>(
((SortedSet<E>) unfiltered).subSet(fromElement, toElement), predicate);
}
@Override
- public SortedSet<E> headSet(@ParametricNullness E toElement) {
+ public SortedSet<E> headSet(E toElement) {
return new FilteredSortedSet<E>(((SortedSet<E>) unfiltered).headSet(toElement), predicate);
}
@Override
- public SortedSet<E> tailSet(@ParametricNullness E fromElement) {
+ public SortedSet<E> tailSet(E fromElement) {
return new FilteredSortedSet<E>(((SortedSet<E>) unfiltered).tailSet(fromElement), predicate);
}
@Override
- @ParametricNullness
public E first() {
return Iterators.find(unfiltered.iterator(), predicate);
}
@Override
- @ParametricNullness
public E last() {
SortedSet<E> sortedUnfiltered = (SortedSet<E>) unfiltered;
while (true) {
@@ -1191,7 +1195,7 @@
}
@GwtIncompatible // NavigableSet
- private static class FilteredNavigableSet<E extends @Nullable Object> extends FilteredSortedSet<E>
+ private static class FilteredNavigableSet<E> extends FilteredSortedSet<E>
implements NavigableSet<E> {
FilteredNavigableSet(NavigableSet<E> unfiltered, Predicate<? super E> predicate) {
super(unfiltered, predicate);
@@ -1202,37 +1206,31 @@
}
@Override
- @CheckForNull
- public E lower(@ParametricNullness E e) {
+ public @Nullable E lower(E e) {
return Iterators.find(unfiltered().headSet(e, false).descendingIterator(), predicate, null);
}
@Override
- @CheckForNull
- public E floor(@ParametricNullness E e) {
+ public @Nullable E floor(E e) {
return Iterators.find(unfiltered().headSet(e, true).descendingIterator(), predicate, null);
}
@Override
- @CheckForNull
- public E ceiling(@ParametricNullness E e) {
+ public E ceiling(E e) {
return Iterables.find(unfiltered().tailSet(e, true), predicate, null);
}
@Override
- @CheckForNull
- public E higher(@ParametricNullness E e) {
+ public E higher(E e) {
return Iterables.find(unfiltered().tailSet(e, false), predicate, null);
}
@Override
- @CheckForNull
public E pollFirst() {
return Iterables.removeFirstMatching(unfiltered(), predicate);
}
@Override
- @CheckForNull
public E pollLast() {
return Iterables.removeFirstMatching(unfiltered().descendingSet(), predicate);
}
@@ -1248,28 +1246,24 @@
}
@Override
- @ParametricNullness
public E last() {
return Iterators.find(unfiltered().descendingIterator(), predicate);
}
@Override
public NavigableSet<E> subSet(
- @ParametricNullness E fromElement,
- boolean fromInclusive,
- @ParametricNullness E toElement,
- boolean toInclusive) {
+ E fromElement, boolean fromInclusive, E toElement, boolean toInclusive) {
return filter(
unfiltered().subSet(fromElement, fromInclusive, toElement, toInclusive), predicate);
}
@Override
- public NavigableSet<E> headSet(@ParametricNullness E toElement, boolean inclusive) {
+ public NavigableSet<E> headSet(E toElement, boolean inclusive) {
return filter(unfiltered().headSet(toElement, inclusive), predicate);
}
@Override
- public NavigableSet<E> tailSet(@ParametricNullness E fromElement, boolean inclusive) {
+ public NavigableSet<E> tailSet(E fromElement, boolean inclusive) {
return filter(unfiltered().tailSet(fromElement, inclusive), predicate);
}
}
@@ -1435,7 +1429,7 @@
}
@Override
- public boolean contains(@CheckForNull Object object) {
+ public boolean contains(@Nullable Object object) {
if (!(object instanceof List)) {
return false;
}
@@ -1454,7 +1448,7 @@
}
@Override
- public boolean equals(@CheckForNull 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) {
@@ -1554,7 +1548,7 @@
}
@Override
- public boolean contains(@CheckForNull Object o) {
+ public boolean contains(@Nullable Object o) {
Integer index = inputSet.get(o);
return index != null && (mask & (1 << index)) != 0;
}
@@ -1590,7 +1584,7 @@
}
@Override
- public boolean contains(@CheckForNull Object obj) {
+ public boolean contains(@Nullable Object obj) {
if (obj instanceof Set) {
Set<?> set = (Set<?>) obj;
return inputSet.keySet().containsAll(set);
@@ -1599,7 +1593,7 @@
}
@Override
- public boolean equals(@CheckForNull Object obj) {
+ public boolean equals(@Nullable Object obj) {
if (obj instanceof PowerSet) {
PowerSet<?> that = (PowerSet<?>) obj;
return inputSet.keySet().equals(that.inputSet.keySet());
@@ -1659,7 +1653,7 @@
}
return new AbstractSet<Set<E>>() {
@Override
- public boolean contains(@CheckForNull Object o) {
+ public boolean contains(@Nullable Object o) {
if (o instanceof Set) {
Set<?> s = (Set<?>) o;
return s.size() == size && index.keySet().containsAll(s);
@@ -1673,7 +1667,6 @@
final BitSet bits = new BitSet(index.size());
@Override
- @CheckForNull
protected Set<E> computeNext() {
if (bits.isEmpty()) {
bits.set(0, size);
@@ -1705,7 +1698,7 @@
final BitSet copy = (BitSet) bits.clone();
return new AbstractSet<E>() {
@Override
- public boolean contains(@CheckForNull Object o) {
+ public boolean contains(@Nullable Object o) {
Integer i = index.get(o);
return i != null && copy.get(i);
}
@@ -1716,7 +1709,6 @@
int i = -1;
@Override
- @CheckForNull
protected E computeNext() {
i = copy.nextSetBit(i + 1);
if (i == -1) {
@@ -1761,7 +1753,7 @@
}
/** An implementation for {@link Set#equals(Object)}. */
- static boolean equalsImpl(Set<?> s, @CheckForNull Object object) {
+ static boolean equalsImpl(Set<?> s, @Nullable Object object) {
if (s == object) {
return true;
}
@@ -1790,16 +1782,15 @@
* @return an unmodifiable view of the specified navigable set
* @since 12.0
*/
- public static <E extends @Nullable Object> NavigableSet<E> unmodifiableNavigableSet(
- NavigableSet<E> set) {
+ public static <E> NavigableSet<E> unmodifiableNavigableSet(NavigableSet<E> set) {
if (set instanceof ImmutableCollection || set instanceof UnmodifiableNavigableSet) {
return set;
}
return new UnmodifiableNavigableSet<E>(set);
}
- static final class UnmodifiableNavigableSet<E extends @Nullable Object>
- extends ForwardingSortedSet<E> implements NavigableSet<E>, Serializable {
+ static final class UnmodifiableNavigableSet<E> extends ForwardingSortedSet<E>
+ implements NavigableSet<E>, Serializable {
private final NavigableSet<E> delegate;
private final SortedSet<E> unmodifiableDelegate;
@@ -1836,42 +1827,36 @@
}
@Override
- @CheckForNull
- public E lower(@ParametricNullness E e) {
+ public E lower(E e) {
return delegate.lower(e);
}
@Override
- @CheckForNull
- public E floor(@ParametricNullness E e) {
+ public E floor(E e) {
return delegate.floor(e);
}
@Override
- @CheckForNull
- public E ceiling(@ParametricNullness E e) {
+ public E ceiling(E e) {
return delegate.ceiling(e);
}
@Override
- @CheckForNull
- public E higher(@ParametricNullness E e) {
+ public E higher(E e) {
return delegate.higher(e);
}
@Override
- @CheckForNull
public E pollFirst() {
throw new UnsupportedOperationException();
}
@Override
- @CheckForNull
public E pollLast() {
throw new UnsupportedOperationException();
}
- @CheckForNull private transient UnmodifiableNavigableSet<E> descendingSet;
+ private transient @Nullable UnmodifiableNavigableSet<E> descendingSet;
@Override
public NavigableSet<E> descendingSet() {
@@ -1890,21 +1875,18 @@
@Override
public NavigableSet<E> subSet(
- @ParametricNullness E fromElement,
- boolean fromInclusive,
- @ParametricNullness E toElement,
- boolean toInclusive) {
+ E fromElement, boolean fromInclusive, E toElement, boolean toInclusive) {
return unmodifiableNavigableSet(
delegate.subSet(fromElement, fromInclusive, toElement, toInclusive));
}
@Override
- public NavigableSet<E> headSet(@ParametricNullness E toElement, boolean inclusive) {
+ public NavigableSet<E> headSet(E toElement, boolean inclusive) {
return unmodifiableNavigableSet(delegate.headSet(toElement, inclusive));
}
@Override
- public NavigableSet<E> tailSet(@ParametricNullness E fromElement, boolean inclusive) {
+ public NavigableSet<E> tailSet(E fromElement, boolean inclusive) {
return unmodifiableNavigableSet(delegate.tailSet(fromElement, inclusive));
}
@@ -1957,8 +1939,7 @@
* @since 13.0
*/
@GwtIncompatible // NavigableSet
- public static <E extends @Nullable Object> NavigableSet<E> synchronizedNavigableSet(
- NavigableSet<E> navigableSet) {
+ public static <E> NavigableSet<E> synchronizedNavigableSet(NavigableSet<E> navigableSet) {
return Synchronized.navigableSet(navigableSet);
}
@@ -1991,7 +1972,7 @@
}
@GwtIncompatible // NavigableSet
- static class DescendingSet<E extends @Nullable Object> extends ForwardingNavigableSet<E> {
+ static class DescendingSet<E> extends ForwardingNavigableSet<E> {
private final NavigableSet<E> forward;
DescendingSet(NavigableSet<E> forward) {
@@ -2004,37 +1985,31 @@
}
@Override
- @CheckForNull
- public E lower(@ParametricNullness E e) {
+ public E lower(E e) {
return forward.higher(e);
}
@Override
- @CheckForNull
- public E floor(@ParametricNullness E e) {
+ public E floor(E e) {
return forward.ceiling(e);
}
@Override
- @CheckForNull
- public E ceiling(@ParametricNullness E e) {
+ public E ceiling(E e) {
return forward.floor(e);
}
@Override
- @CheckForNull
- public E higher(@ParametricNullness E e) {
+ public E higher(E e) {
return forward.lower(e);
}
@Override
- @CheckForNull
public E pollFirst() {
return forward.pollLast();
}
@Override
- @CheckForNull
public E pollLast() {
return forward.pollFirst();
}
@@ -2051,35 +2026,32 @@
@Override
public NavigableSet<E> subSet(
- @ParametricNullness E fromElement,
- boolean fromInclusive,
- @ParametricNullness E toElement,
- boolean toInclusive) {
+ E fromElement, boolean fromInclusive, E toElement, boolean toInclusive) {
return forward.subSet(toElement, toInclusive, fromElement, fromInclusive).descendingSet();
}
@Override
- public SortedSet<E> subSet(@ParametricNullness E fromElement, @ParametricNullness E toElement) {
+ public SortedSet<E> subSet(E fromElement, E toElement) {
return standardSubSet(fromElement, toElement);
}
@Override
- public NavigableSet<E> headSet(@ParametricNullness E toElement, boolean inclusive) {
+ public NavigableSet<E> headSet(E toElement, boolean inclusive) {
return forward.tailSet(toElement, inclusive).descendingSet();
}
@Override
- public SortedSet<E> headSet(@ParametricNullness E toElement) {
+ public SortedSet<E> headSet(E toElement) {
return standardHeadSet(toElement);
}
@Override
- public NavigableSet<E> tailSet(@ParametricNullness E fromElement, boolean inclusive) {
+ public NavigableSet<E> tailSet(E fromElement, boolean inclusive) {
return forward.headSet(fromElement, inclusive).descendingSet();
}
@Override
- public SortedSet<E> tailSet(@ParametricNullness E fromElement) {
+ public SortedSet<E> tailSet(E fromElement) {
return standardTailSet(fromElement);
}
@@ -2095,18 +2067,16 @@
}
// If we inline this, we get a javac error.
- private static <T extends @Nullable Object> Ordering<T> reverse(Comparator<T> forward) {
+ private static <T> Ordering<T> reverse(Comparator<T> forward) {
return Ordering.from(forward).reverse();
}
@Override
- @ParametricNullness
public E first() {
return forward.last();
}
@Override
- @ParametricNullness
public E last() {
return forward.first();
}
@@ -2117,13 +2087,12 @@
}
@Override
- public @Nullable Object[] toArray() {
+ public Object[] toArray() {
return standardToArray();
}
@Override
- @SuppressWarnings("nullness") // b/192354773 in our checker affects toArray declarations
- public <T extends @Nullable Object> T[] toArray(T[] array) {
+ public <T> T[] toArray(T[] array) {
return standardToArray(array);
}
diff --git a/guava/src/com/google/common/collect/SingletonImmutableBiMap.java b/guava/src/com/google/common/collect/SingletonImmutableBiMap.java
index c5fb2b2..ea6f275 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 javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Implementation of {@link ImmutableMap} with exactly one entry.
@@ -33,7 +33,6 @@
*/
@GwtCompatible(serializable = true, emulated = true)
@SuppressWarnings("serial") // uses writeReplace(), not default serialization
-@ElementTypesAreNonnullByDefault
final class SingletonImmutableBiMap<K, V> extends ImmutableBiMap<K, V> {
final transient K singleKey;
@@ -53,8 +52,7 @@
}
@Override
- @CheckForNull
- public V get(@CheckForNull Object key) {
+ public V get(@Nullable Object key) {
return singleKey.equals(key) ? singleValue : null;
}
@@ -69,12 +67,12 @@
}
@Override
- public boolean containsKey(@CheckForNull Object key) {
+ public boolean containsKey(@Nullable Object key) {
return singleKey.equals(key);
}
@Override
- public boolean containsValue(@CheckForNull Object value) {
+ public boolean containsValue(@Nullable Object value) {
return singleValue.equals(value);
}
@@ -93,8 +91,8 @@
return ImmutableSet.of(singleKey);
}
- @CheckForNull private final transient ImmutableBiMap<V, K> inverse;
- @LazyInit @RetainedWith @CheckForNull private transient ImmutableBiMap<V, K> lazyInverse;
+ private final transient @Nullable ImmutableBiMap<V, K> inverse;
+ @LazyInit @RetainedWith private transient @Nullable ImmutableBiMap<V, K> lazyInverse;
@Override
public ImmutableBiMap<V, K> inverse() {
diff --git a/guava/src/com/google/common/collect/SingletonImmutableList.java b/guava/src/com/google/common/collect/SingletonImmutableList.java
index a7ac8b3..eec0daa 100644
--- a/guava/src/com/google/common/collect/SingletonImmutableList.java
+++ b/guava/src/com/google/common/collect/SingletonImmutableList.java
@@ -30,7 +30,6 @@
*/
@GwtCompatible(serializable = true, emulated = true)
@SuppressWarnings("serial") // uses writeReplace(), not default serialization
-@ElementTypesAreNonnullByDefault
final class SingletonImmutableList<E> extends ImmutableList<E> {
final transient E element;
diff --git a/guava/src/com/google/common/collect/SingletonImmutableSet.java b/guava/src/com/google/common/collect/SingletonImmutableSet.java
index 088cb80..0f882b3 100644
--- a/guava/src/com/google/common/collect/SingletonImmutableSet.java
+++ b/guava/src/com/google/common/collect/SingletonImmutableSet.java
@@ -18,8 +18,7 @@
import com.google.common.annotations.GwtCompatible;
import com.google.common.base.Preconditions;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
+import com.google.errorprone.annotations.concurrent.LazyInit;
/**
* Implementation of {@link ImmutableSet} with exactly one element.
@@ -29,24 +28,35 @@
*/
@GwtCompatible(serializable = true, emulated = true)
@SuppressWarnings("serial") // uses writeReplace(), not default serialization
-@ElementTypesAreNonnullByDefault
final class SingletonImmutableSet<E> extends ImmutableSet<E> {
- // We deliberately avoid caching the asList and hashCode here, to ensure that with
- // compressed oops, a SingletonImmutableSet packs all the way down to the optimal 16 bytes.
final transient E element;
+ // This is transient because it will be recalculated on the first
+ // call to hashCode().
+ //
+ // A race condition is avoided since threads will either see that the value
+ // is zero and recalculate it themselves, or two threads will see it at
+ // the same time, and both recalculate it. If the cachedHashCode is 0,
+ // it will always be recalculated, unfortunately.
+ @LazyInit private transient int cachedHashCode;
SingletonImmutableSet(E element) {
this.element = Preconditions.checkNotNull(element);
}
+ SingletonImmutableSet(E element, int hashCode) {
+ // Guaranteed to be non-null by the presence of the pre-computed hash code.
+ this.element = element;
+ cachedHashCode = hashCode;
+ }
+
@Override
public int size() {
return 1;
}
@Override
- public boolean contains(@CheckForNull Object target) {
+ public boolean contains(Object target) {
return element.equals(target);
}
@@ -56,7 +66,7 @@
}
@Override
- public ImmutableList<E> asList() {
+ ImmutableList<E> createAsList() {
return ImmutableList.of(element);
}
@@ -66,14 +76,24 @@
}
@Override
- int copyIntoArray(@Nullable Object[] dst, int offset) {
+ int copyIntoArray(Object[] dst, int offset) {
dst[offset] = element;
return offset + 1;
}
@Override
public final int hashCode() {
- return element.hashCode();
+ // Racy single-check.
+ int code = cachedHashCode;
+ if (code == 0) {
+ cachedHashCode = code = element.hashCode();
+ }
+ return code;
+ }
+
+ @Override
+ boolean isHashCodeFast() {
+ return cachedHashCode != 0;
}
@Override
diff --git a/guava/src/com/google/common/collect/SingletonImmutableTable.java b/guava/src/com/google/common/collect/SingletonImmutableTable.java
index cfaeadb..58a182c 100644
--- a/guava/src/com/google/common/collect/SingletonImmutableTable.java
+++ b/guava/src/com/google/common/collect/SingletonImmutableTable.java
@@ -27,7 +27,6 @@
* @author Gregory Kick
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
class SingletonImmutableTable<R, C, V> extends ImmutableTable<R, C, V> {
final R singleRowKey;
final C singleColumnKey;
diff --git a/guava/src/com/google/common/collect/SortedIterable.java b/guava/src/com/google/common/collect/SortedIterable.java
index 64ec08e..d46e8af 100644
--- a/guava/src/com/google/common/collect/SortedIterable.java
+++ b/guava/src/com/google/common/collect/SortedIterable.java
@@ -17,7 +17,6 @@
import com.google.common.annotations.GwtCompatible;
import java.util.Comparator;
import java.util.Iterator;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* An {@code Iterable} whose elements are sorted relative to a {@code Comparator}, typically
@@ -26,8 +25,7 @@
* @author Louis Wasserman
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-interface SortedIterable<T extends @Nullable Object> extends Iterable<T> {
+interface SortedIterable<T> extends Iterable<T> {
/**
* Returns the {@code Comparator} by which the elements of this iterable are ordered, or {@code
* Ordering.natural()} if the elements are ordered by their natural ordering.
diff --git a/guava/src/com/google/common/collect/SortedIterables.java b/guava/src/com/google/common/collect/SortedIterables.java
index 68b231a..2c0aa7c 100644
--- a/guava/src/com/google/common/collect/SortedIterables.java
+++ b/guava/src/com/google/common/collect/SortedIterables.java
@@ -19,7 +19,6 @@
import com.google.common.annotations.GwtCompatible;
import java.util.Comparator;
import java.util.SortedSet;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Utilities for dealing with sorted collections of all types.
@@ -27,7 +26,6 @@
* @author Louis Wasserman
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
final class SortedIterables {
private SortedIterables() {}
@@ -51,8 +49,7 @@
@SuppressWarnings("unchecked")
// if sortedSet.comparator() is null, the set must be naturally ordered
- public static <E extends @Nullable Object> Comparator<? super E> comparator(
- SortedSet<E> sortedSet) {
+ public static <E> Comparator<? super E> comparator(SortedSet<E> sortedSet) {
Comparator<? super E> result = sortedSet.comparator();
if (result == null) {
result = (Comparator<? super E>) Ordering.natural();
diff --git a/guava/src/com/google/common/collect/SortedLists.java b/guava/src/com/google/common/collect/SortedLists.java
index 0ebaab2..339e7fc 100644
--- a/guava/src/com/google/common/collect/SortedLists.java
+++ b/guava/src/com/google/common/collect/SortedLists.java
@@ -35,38 +35,29 @@
* @author Louis Wasserman
*/
@GwtCompatible
-@Beta
-@ElementTypesAreNonnullByDefault
-final class SortedLists {
+@Beta final class SortedLists {
private SortedLists() {}
/**
* A specification for which index to return if the list contains at least one element that
* compares as equal to the key.
- */
- enum KeyPresentBehavior {
+ */ enum KeyPresentBehavior {
/**
* Return the index of any list element that compares as equal to the key. No guarantees are
* made as to which index is returned, if more than one element compares as equal to the key.
*/
ANY_PRESENT {
@Override
- <E extends @Nullable Object> int resultIndex(
- Comparator<? super E> comparator,
- @ParametricNullness E key,
- List<? extends E> list,
- int foundIndex) {
+ <E> int resultIndex(
+ Comparator<? super E> comparator, E key, List<? extends E> list, int foundIndex) {
return foundIndex;
}
},
/** Return the index of the last list element that compares as equal to the key. */
LAST_PRESENT {
@Override
- <E extends @Nullable Object> int resultIndex(
- Comparator<? super E> comparator,
- @ParametricNullness E key,
- List<? extends E> list,
- int foundIndex) {
+ <E> int resultIndex(
+ Comparator<? super E> comparator, E key, List<? extends E> list, int foundIndex) {
// Of course, we have to use binary search to find the precise
// breakpoint...
int lower = foundIndex;
@@ -87,11 +78,8 @@
/** Return the index of the first list element that compares as equal to the key. */
FIRST_PRESENT {
@Override
- <E extends @Nullable Object> int resultIndex(
- Comparator<? super E> comparator,
- @ParametricNullness E key,
- List<? extends E> list,
- int foundIndex) {
+ <E> int resultIndex(
+ Comparator<? super E> comparator, E key, List<? extends E> list, int foundIndex) {
// Of course, we have to use binary search to find the precise
// breakpoint...
int lower = 0;
@@ -116,11 +104,8 @@
*/
FIRST_AFTER {
@Override
- public <E extends @Nullable Object> int resultIndex(
- Comparator<? super E> comparator,
- @ParametricNullness E key,
- List<? extends E> list,
- int foundIndex) {
+ public <E> int resultIndex(
+ Comparator<? super E> comparator, E key, List<? extends E> list, int foundIndex) {
return LAST_PRESENT.resultIndex(comparator, key, list, foundIndex) + 1;
}
},
@@ -130,27 +115,20 @@
*/
LAST_BEFORE {
@Override
- public <E extends @Nullable Object> int resultIndex(
- Comparator<? super E> comparator,
- @ParametricNullness E key,
- List<? extends E> list,
- int foundIndex) {
+ public <E> int resultIndex(
+ Comparator<? super E> comparator, E key, List<? extends E> list, int foundIndex) {
return FIRST_PRESENT.resultIndex(comparator, key, list, foundIndex) - 1;
}
};
- abstract <E extends @Nullable Object> int resultIndex(
- Comparator<? super E> comparator,
- @ParametricNullness E key,
- List<? extends E> list,
- int foundIndex);
+ abstract <E> int resultIndex(
+ Comparator<? super E> comparator, E key, List<? extends E> list, int foundIndex);
}
/**
* A specification for which index to return if the list contains no elements that compare as
* equal to the key.
- */
- enum KeyAbsentBehavior {
+ */ enum KeyAbsentBehavior {
/**
* Return the index of the next lower element in the list, or {@code -1} if there is no such
* element.
@@ -215,13 +193,12 @@
* <p>Equivalent to {@link #binarySearch(List, Function, Object, Comparator, KeyPresentBehavior,
* KeyAbsentBehavior)} using {@link Ordering#natural}.
*/
- public static <E extends @Nullable Object, K extends Comparable> int binarySearch(
+ public static <E, K extends Comparable> int binarySearch(
List<E> list,
Function<? super E, K> keyFunction,
- K key,
+ @Nullable K key,
KeyPresentBehavior presentBehavior,
KeyAbsentBehavior absentBehavior) {
- checkNotNull(key);
return binarySearch(
list, keyFunction, key, Ordering.natural(), presentBehavior, absentBehavior);
}
@@ -233,10 +210,10 @@
* KeyAbsentBehavior)} using {@link Lists#transform(List, Function) Lists.transform(list,
* keyFunction)}.
*/
- public static <E extends @Nullable Object, K extends @Nullable Object> int binarySearch(
+ public static <E, K> int binarySearch(
List<E> list,
Function<? super E, K> keyFunction,
- @ParametricNullness K key,
+ @Nullable K key,
Comparator<? super K> keyComparator,
KeyPresentBehavior presentBehavior,
KeyAbsentBehavior absentBehavior) {
@@ -267,9 +244,9 @@
* @return the index determined by the {@code KeyPresentBehavior}, if the key is in the list;
* otherwise the index determined by the {@code KeyAbsentBehavior}.
*/
- public static <E extends @Nullable Object> int binarySearch(
+ public static <E> int binarySearch(
List<? extends E> list,
- @ParametricNullness E key,
+ @Nullable E key,
Comparator<? super E> comparator,
KeyPresentBehavior presentBehavior,
KeyAbsentBehavior absentBehavior) {
diff --git a/guava/src/com/google/common/collect/SortedMapDifference.java b/guava/src/com/google/common/collect/SortedMapDifference.java
index 46cac8a..4715e93 100644
--- a/guava/src/com/google/common/collect/SortedMapDifference.java
+++ b/guava/src/com/google/common/collect/SortedMapDifference.java
@@ -18,7 +18,6 @@
import com.google.common.annotations.GwtCompatible;
import java.util.SortedMap;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* An object representing the differences between two sorted maps.
@@ -27,9 +26,7 @@
* @since 8.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-public interface SortedMapDifference<K extends @Nullable Object, V extends @Nullable Object>
- extends MapDifference<K, V> {
+public interface SortedMapDifference<K, V> extends MapDifference<K, V> {
@Override
SortedMap<K, V> entriesOnlyOnLeft();
diff --git a/guava/src/com/google/common/collect/SortedMultiset.java b/guava/src/com/google/common/collect/SortedMultiset.java
index 68932f5..2635b37 100644
--- a/guava/src/com/google/common/collect/SortedMultiset.java
+++ b/guava/src/com/google/common/collect/SortedMultiset.java
@@ -22,8 +22,6 @@
import java.util.Iterator;
import java.util.NavigableSet;
import java.util.Set;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* A {@link Multiset} which maintains the ordering of its elements, according to either their
@@ -44,9 +42,7 @@
* @since 11.0
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
-public interface SortedMultiset<E extends @Nullable Object>
- extends SortedMultisetBridge<E>, SortedIterable<E> {
+public interface SortedMultiset<E> extends SortedMultisetBridge<E>, SortedIterable<E> {
/**
* Returns the comparator that orders this multiset, or {@link Ordering#natural()} if the natural
* ordering of the elements is used.
@@ -58,28 +54,24 @@
* Returns the entry of the first element in this multiset, or {@code null} if this multiset is
* empty.
*/
- @CheckForNull
Entry<E> firstEntry();
/**
* Returns the entry of the last element in this multiset, or {@code null} if this multiset is
* empty.
*/
- @CheckForNull
Entry<E> lastEntry();
/**
* Returns and removes the entry associated with the lowest element in this multiset, or returns
* {@code null} if this multiset is empty.
*/
- @CheckForNull
Entry<E> pollFirstEntry();
/**
* Returns and removes the entry associated with the greatest element in this multiset, or returns
* {@code null} if this multiset is empty.
*/
- @CheckForNull
Entry<E> pollLastEntry();
/**
@@ -123,7 +115,7 @@
* <p>The returned multiset will throw an {@link IllegalArgumentException} on attempts to add
* elements outside its range.
*/
- SortedMultiset<E> headMultiset(@ParametricNullness E upperBound, BoundType boundType);
+ SortedMultiset<E> headMultiset(E upperBound, BoundType boundType);
/**
* Returns a view of this multiset restricted to the range between {@code lowerBound} and {@code
@@ -138,10 +130,7 @@
* lowerBoundType).headMultiset(upperBound, upperBoundType)}.
*/
SortedMultiset<E> subMultiset(
- @ParametricNullness E lowerBound,
- BoundType lowerBoundType,
- @ParametricNullness E upperBound,
- BoundType upperBoundType);
+ E lowerBound, BoundType lowerBoundType, E upperBound, BoundType upperBoundType);
/**
* Returns a view of this multiset restricted to the elements greater than {@code lowerBound},
@@ -152,5 +141,5 @@
* <p>The returned multiset will throw an {@link IllegalArgumentException} on attempts to add
* elements outside its range.
*/
- SortedMultiset<E> tailMultiset(@ParametricNullness E lowerBound, BoundType boundType);
+ SortedMultiset<E> tailMultiset(E lowerBound, BoundType boundType);
}
diff --git a/guava/src/com/google/common/collect/SortedMultisetBridge.java b/guava/src/com/google/common/collect/SortedMultisetBridge.java
index 72d50be..064cb75 100644
--- a/guava/src/com/google/common/collect/SortedMultisetBridge.java
+++ b/guava/src/com/google/common/collect/SortedMultisetBridge.java
@@ -18,7 +18,6 @@
import com.google.common.annotations.GwtIncompatible;
import java.util.SortedSet;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Superinterface of {@link SortedMultiset} to introduce a bridge method for {@code elementSet()},
@@ -28,8 +27,7 @@
* @author Louis Wasserman
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
-interface SortedMultisetBridge<E extends @Nullable Object> extends Multiset<E> {
+interface SortedMultisetBridge<E> extends Multiset<E> {
@Override
SortedSet<E> elementSet();
}
diff --git a/guava/src/com/google/common/collect/SortedMultisets.java b/guava/src/com/google/common/collect/SortedMultisets.java
index 1d1940c..a928959 100644
--- a/guava/src/com/google/common/collect/SortedMultisets.java
+++ b/guava/src/com/google/common/collect/SortedMultisets.java
@@ -28,7 +28,6 @@
import java.util.NavigableSet;
import java.util.NoSuchElementException;
import java.util.SortedSet;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -37,14 +36,11 @@
* @author Louis Wasserman
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
final class SortedMultisets {
private SortedMultisets() {}
/** A skeleton implementation for {@link SortedMultiset#elementSet}. */
- @SuppressWarnings("JdkObsolete") // TODO(b/6160855): Switch GWT emulations to NavigableSet.
- static class ElementSet<E extends @Nullable Object> extends Multisets.ElementSet<E>
- implements SortedSet<E> {
+ static class ElementSet<E> extends Multisets.ElementSet<E> implements SortedSet<E> {
@Weak private final SortedMultiset<E> multiset;
ElementSet(SortedMultiset<E> multiset) {
@@ -67,28 +63,26 @@
}
@Override
- public SortedSet<E> subSet(@ParametricNullness E fromElement, @ParametricNullness E toElement) {
+ public SortedSet<E> subSet(E fromElement, E toElement) {
return multiset().subMultiset(fromElement, CLOSED, toElement, OPEN).elementSet();
}
@Override
- public SortedSet<E> headSet(@ParametricNullness E toElement) {
+ public SortedSet<E> headSet(E toElement) {
return multiset().headMultiset(toElement, OPEN).elementSet();
}
@Override
- public SortedSet<E> tailSet(@ParametricNullness E fromElement) {
+ public SortedSet<E> tailSet(E fromElement) {
return multiset().tailMultiset(fromElement, CLOSED).elementSet();
}
@Override
- @ParametricNullness
public E first() {
return getElementOrThrow(multiset().firstEntry());
}
@Override
- @ParametricNullness
public E last() {
return getElementOrThrow(multiset().lastEntry());
}
@@ -96,33 +90,28 @@
/** A skeleton navigable implementation for {@link SortedMultiset#elementSet}. */
@GwtIncompatible // Navigable
- static class NavigableElementSet<E extends @Nullable Object> extends ElementSet<E>
- implements NavigableSet<E> {
+ static class NavigableElementSet<E> extends ElementSet<E> implements NavigableSet<E> {
NavigableElementSet(SortedMultiset<E> multiset) {
super(multiset);
}
@Override
- @CheckForNull
- public E lower(@ParametricNullness E e) {
+ public E lower(E e) {
return getElementOrNull(multiset().headMultiset(e, OPEN).lastEntry());
}
@Override
- @CheckForNull
- public E floor(@ParametricNullness E e) {
+ public E floor(E e) {
return getElementOrNull(multiset().headMultiset(e, CLOSED).lastEntry());
}
@Override
- @CheckForNull
- public E ceiling(@ParametricNullness E e) {
+ public E ceiling(E e) {
return getElementOrNull(multiset().tailMultiset(e, CLOSED).firstEntry());
}
@Override
- @CheckForNull
- public E higher(@ParametricNullness E e) {
+ public E higher(E e) {
return getElementOrNull(multiset().tailMultiset(e, OPEN).firstEntry());
}
@@ -137,23 +126,18 @@
}
@Override
- @CheckForNull
public E pollFirst() {
return getElementOrNull(multiset().pollFirstEntry());
}
@Override
- @CheckForNull
public E pollLast() {
return getElementOrNull(multiset().pollLastEntry());
}
@Override
public NavigableSet<E> subSet(
- @ParametricNullness E fromElement,
- boolean fromInclusive,
- @ParametricNullness E toElement,
- boolean toInclusive) {
+ E fromElement, boolean fromInclusive, E toElement, boolean toInclusive) {
return new NavigableElementSet<E>(
multiset()
.subMultiset(
@@ -162,27 +146,26 @@
}
@Override
- public NavigableSet<E> headSet(@ParametricNullness E toElement, boolean inclusive) {
+ public NavigableSet<E> headSet(E toElement, boolean inclusive) {
return new NavigableElementSet<E>(
multiset().headMultiset(toElement, BoundType.forBoolean(inclusive)));
}
@Override
- public NavigableSet<E> tailSet(@ParametricNullness E fromElement, boolean inclusive) {
+ public NavigableSet<E> tailSet(E fromElement, boolean inclusive) {
return new NavigableElementSet<E>(
multiset().tailMultiset(fromElement, BoundType.forBoolean(inclusive)));
}
}
- private static <E extends @Nullable Object> E getElementOrThrow(@CheckForNull Entry<E> entry) {
+ private static <E> E getElementOrThrow(Entry<E> entry) {
if (entry == null) {
throw new NoSuchElementException();
}
return entry.getElement();
}
- @CheckForNull
- private static <E extends @Nullable Object> E getElementOrNull(@CheckForNull Entry<E> entry) {
+ private static <E> E getElementOrNull(@Nullable Entry<E> 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 8449014..9f073bf 100644
--- a/guava/src/com/google/common/collect/SortedSetMultimap.java
+++ b/guava/src/com/google/common/collect/SortedSetMultimap.java
@@ -24,7 +24,6 @@
import java.util.Set;
import java.util.SortedMap;
import java.util.SortedSet;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -38,10 +37,6 @@
* Though the method signature doesn't say so explicitly, the map returned by {@link #asMap} has
* {@code SortedSet} values.
*
- * <p><b>Warning:</b> As in all {@link SetMultimap}s, do not modify either a key <i>or a value</i>
- * of a {@code SortedSetMultimap} in a way that affects its {@link Object#equals} behavior (or its
- * position in the order of the values). Undefined behavior and bugs will result.
- *
* <p>See the Guava User Guide article on <a href=
* "https://github.com/google/guava/wiki/NewCollectionTypesExplained#multimap"> {@code
* Multimap}</a>.
@@ -50,9 +45,7 @@
* @since 2.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-public interface SortedSetMultimap<K extends @Nullable Object, V extends @Nullable Object>
- extends SetMultimap<K, V> {
+public interface SortedSetMultimap<K, V> extends SetMultimap<K, V> {
// Following Javadoc copied from Multimap.
/**
@@ -66,7 +59,7 @@
* {@link Multimap} interface.
*/
@Override
- SortedSet<V> get(@ParametricNullness K key);
+ SortedSet<V> get(@Nullable K key);
/**
* Removes all values associated with a given key.
@@ -77,7 +70,7 @@
*/
@CanIgnoreReturnValue
@Override
- SortedSet<V> removeAll(@CheckForNull Object key);
+ SortedSet<V> removeAll(@Nullable Object key);
/**
* Stores a collection of values with the same key, replacing any existing values for that key.
@@ -90,7 +83,7 @@
*/
@CanIgnoreReturnValue
@Override
- SortedSet<V> replaceValues(@ParametricNullness K key, Iterable<? extends V> values);
+ SortedSet<V> replaceValues(K key, Iterable<? extends V> values);
/**
* Returns a map view that associates each key with the corresponding values in the multimap.
@@ -116,6 +109,5 @@
* Returns the comparator that orders the multimap values, with {@code null} indicating that
* natural ordering is used.
*/
- @CheckForNull
Comparator<? super V> valueComparator();
}
diff --git a/guava/src/com/google/common/collect/SparseImmutableTable.java b/guava/src/com/google/common/collect/SparseImmutableTable.java
index b314f7b..a7fe85d 100644
--- a/guava/src/com/google/common/collect/SparseImmutableTable.java
+++ b/guava/src/com/google/common/collect/SparseImmutableTable.java
@@ -14,8 +14,6 @@
package com.google.common.collect;
-import static java.util.Objects.requireNonNull;
-
import com.google.common.annotations.GwtCompatible;
import com.google.errorprone.annotations.Immutable;
import java.util.LinkedHashMap;
@@ -25,7 +23,6 @@
/** A {@code RegularImmutableTable} optimized for sparse data. */
@GwtCompatible
@Immutable(containerOf = {"R", "C", "V"})
-@ElementTypesAreNonnullByDefault
final class SparseImmutableTable<R, C, V> extends RegularImmutableTable<R, C, V> {
static final ImmutableTable<Object, Object, Object> EMPTY =
new SparseImmutableTable<>(
@@ -64,16 +61,12 @@
C columnKey = cell.getColumnKey();
V value = cell.getValue();
- /*
- * These requireNonNull calls are safe because we construct the maps to hold all the provided
- * cells.
- */
- cellRowIndices[i] = requireNonNull(rowIndex.get(rowKey));
- Map<C, V> thisRow = requireNonNull(rows.get(rowKey));
+ cellRowIndices[i] = rowIndex.get(rowKey);
+ Map<C, V> thisRow = rows.get(rowKey);
cellColumnInRowIndices[i] = thisRow.size();
V oldValue = thisRow.put(columnKey, value);
checkNoDuplicate(rowKey, columnKey, oldValue, value);
- requireNonNull(columns.get(columnKey)).put(rowKey, value);
+ columns.get(columnKey).put(rowKey, value);
}
this.cellRowIndices = cellRowIndices;
this.cellColumnInRowIndices = cellColumnInRowIndices;
@@ -135,8 +128,7 @@
int[] cellColumnIndices = new int[cellSet().size()];
int i = 0;
for (Cell<R, C, V> cell : cellSet()) {
- // requireNonNull is safe because the cell exists in the table.
- cellColumnIndices[i++] = requireNonNull(columnKeyToIndex.get(cell.getColumnKey()));
+ cellColumnIndices[i++] = columnKeyToIndex.get(cell.getColumnKey());
}
return SerializedForm.create(this, cellRowIndices, cellColumnIndices);
}
diff --git a/guava/src/com/google/common/collect/StandardRowSortedTable.java b/guava/src/com/google/common/collect/StandardRowSortedTable.java
index bea5b7b..19a14c3 100644
--- a/guava/src/com/google/common/collect/StandardRowSortedTable.java
+++ b/guava/src/com/google/common/collect/StandardRowSortedTable.java
@@ -26,7 +26,6 @@
import java.util.Set;
import java.util.SortedMap;
import java.util.SortedSet;
-import javax.annotation.CheckForNull;
/**
* Implementation of {@code Table} whose iteration ordering across row keys is sorted by their
@@ -46,7 +45,6 @@
* @author Jared Levy
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
class StandardRowSortedTable<R, C, V> extends StandardTable<R, C, V>
implements RowSortedTable<R, C, V> {
/*
@@ -104,7 +102,6 @@
}
@Override
- @CheckForNull
public Comparator<? super R> comparator() {
return sortedBackingMap().comparator();
}
diff --git a/guava/src/com/google/common/collect/StandardTable.java b/guava/src/com/google/common/collect/StandardTable.java
index 06defb0..6adc4dc 100644
--- a/guava/src/com/google/common/collect/StandardTable.java
+++ b/guava/src/com/google/common/collect/StandardTable.java
@@ -23,8 +23,6 @@
import static com.google.common.base.Predicates.not;
import static com.google.common.collect.Maps.safeContainsKey;
import static com.google.common.collect.Maps.safeGet;
-import static com.google.common.collect.NullnessCasts.uncheckedCastNullableTToT;
-import static java.util.Objects.requireNonNull;
import com.google.common.annotations.GwtCompatible;
import com.google.common.base.Function;
@@ -44,7 +42,7 @@
import java.util.Set;
import java.util.Spliterator;
import java.util.Spliterators;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* {@link Table} implementation backed by a map that associates row keys with column key / value
@@ -66,7 +64,6 @@
* @author Jared Levy
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
class StandardTable<R, C, V> extends AbstractTable<R, C, V> implements Serializable {
@GwtTransient final Map<R, Map<C, V>> backingMap;
@GwtTransient final Supplier<? extends Map<C, V>> factory;
@@ -79,12 +76,12 @@
// Accessors
@Override
- public boolean contains(@CheckForNull Object rowKey, @CheckForNull Object columnKey) {
+ public boolean contains(@Nullable Object rowKey, @Nullable Object columnKey) {
return rowKey != null && columnKey != null && super.contains(rowKey, columnKey);
}
@Override
- public boolean containsColumn(@CheckForNull Object columnKey) {
+ public boolean containsColumn(@Nullable Object columnKey) {
if (columnKey == null) {
return false;
}
@@ -97,18 +94,17 @@
}
@Override
- public boolean containsRow(@CheckForNull Object rowKey) {
+ public boolean containsRow(@Nullable Object rowKey) {
return rowKey != null && safeContainsKey(backingMap, rowKey);
}
@Override
- public boolean containsValue(@CheckForNull Object value) {
+ public boolean containsValue(@Nullable Object value) {
return value != null && super.containsValue(value);
}
@Override
- @CheckForNull
- public V get(@CheckForNull Object rowKey, @CheckForNull Object columnKey) {
+ public V get(@Nullable Object rowKey, @Nullable Object columnKey) {
return (rowKey == null || columnKey == null) ? null : super.get(rowKey, columnKey);
}
@@ -144,7 +140,6 @@
@CanIgnoreReturnValue
@Override
- @CheckForNull
public V put(R rowKey, C columnKey, V value) {
checkNotNull(rowKey);
checkNotNull(columnKey);
@@ -154,8 +149,7 @@
@CanIgnoreReturnValue
@Override
- @CheckForNull
- public V remove(@CheckForNull Object rowKey, @CheckForNull Object columnKey) {
+ public V remove(@Nullable Object rowKey, @Nullable Object columnKey) {
if ((rowKey == null) || (columnKey == null)) {
return null;
}
@@ -171,7 +165,7 @@
}
@CanIgnoreReturnValue
- private Map<R, V> removeColumn(@CheckForNull Object column) {
+ private Map<R, V> removeColumn(Object column) {
Map<R, V> output = new LinkedHashMap<>();
Iterator<Entry<R, Map<C, V>>> iterator = backingMap.entrySet().iterator();
while (iterator.hasNext()) {
@@ -187,14 +181,12 @@
return output;
}
- private boolean containsMapping(
- @CheckForNull Object rowKey, @CheckForNull Object columnKey, @CheckForNull Object value) {
+ private boolean containsMapping(Object rowKey, Object columnKey, Object value) {
return value != null && value.equals(get(rowKey, columnKey));
}
/** Remove a row key / column key / value mapping, if present. */
- private boolean removeMapping(
- @CheckForNull Object rowKey, @CheckForNull Object columnKey, @CheckForNull Object value) {
+ private boolean removeMapping(Object rowKey, Object columnKey, Object value) {
if (containsMapping(rowKey, columnKey, value)) {
remove(rowKey, columnKey);
return true;
@@ -242,7 +234,7 @@
private class CellIterator implements Iterator<Cell<R, C, V>> {
final Iterator<Entry<R, Map<C, V>>> rowIterator = backingMap.entrySet().iterator();
- @CheckForNull Entry<R, Map<C, V>> rowEntry;
+ @Nullable Entry<R, Map<C, V>> rowEntry;
Iterator<Entry<C, V>> columnIterator = Iterators.emptyModifiableIterator();
@Override
@@ -256,20 +248,6 @@
rowEntry = rowIterator.next();
columnIterator = rowEntry.getValue().entrySet().iterator();
}
- /*
- * requireNonNull is safe because:
- *
- * - columnIterator started off pointing to an empty iterator, so we must have entered the
- * `if` body above at least once. Thus, if we got this far, that `if` body initialized
- * rowEntry at least once.
- *
- * - The only case in which rowEntry is cleared (during remove() below) happens only if the
- * caller removed every element from columnIterator. During that process, we would have had
- * to iterate it to exhaustion. Then we can apply the logic above about an empty
- * columnIterator. (This assumes no concurrent modification, but behavior under concurrent
- * modification is undefined, anyway.)
- */
- requireNonNull(rowEntry);
Entry<C, V> columnEntry = columnIterator.next();
return Tables.immutableCell(rowEntry.getKey(), columnEntry.getKey(), columnEntry.getValue());
}
@@ -277,17 +255,7 @@
@Override
public void remove() {
columnIterator.remove();
- /*
- * requireNonNull is safe because:
- *
- * - columnIterator.remove() succeeded, so it must have returned a value, so it must have been
- * initialized by next() -- which initializes rowEntry, too.
- *
- * - rowEntry isn't cleared except below. If it was cleared below, then either
- * columnIterator.remove() would have failed above (if the user hasn't called next() since
- * then) or rowEntry would have been initialized by next() (as discussed above).
- */
- if (requireNonNull(rowEntry).getValue().isEmpty()) {
+ if (rowEntry.getValue().isEmpty()) {
rowIterator.remove();
rowEntry = null;
}
@@ -320,43 +288,39 @@
this.rowKey = checkNotNull(rowKey);
}
- @CheckForNull Map<C, V> backingRowMap;
+ @Nullable Map<C, V> backingRowMap;
- final void updateBackingRowMapField() {
- if (backingRowMap == null || (backingRowMap.isEmpty() && backingMap.containsKey(rowKey))) {
- backingRowMap = computeBackingRowMap();
- }
+ Map<C, V> backingRowMap() {
+ return (backingRowMap == null || (backingRowMap.isEmpty() && backingMap.containsKey(rowKey)))
+ ? backingRowMap = computeBackingRowMap()
+ : backingRowMap;
}
- @CheckForNull
Map<C, V> computeBackingRowMap() {
return backingMap.get(rowKey);
}
// Call this every time we perform a removal.
void maintainEmptyInvariant() {
- updateBackingRowMapField();
- if (backingRowMap != null && backingRowMap.isEmpty()) {
+ if (backingRowMap() != null && backingRowMap.isEmpty()) {
backingMap.remove(rowKey);
backingRowMap = null;
}
}
@Override
- public boolean containsKey(@CheckForNull Object key) {
- updateBackingRowMapField();
+ public boolean containsKey(Object key) {
+ Map<C, V> backingRowMap = backingRowMap();
return (key != null && backingRowMap != null) && Maps.safeContainsKey(backingRowMap, key);
}
@Override
- @CheckForNull
- public V get(@CheckForNull Object key) {
- updateBackingRowMapField();
+ public V get(Object key) {
+ Map<C, V> backingRowMap = backingRowMap();
return (key != null && backingRowMap != null) ? Maps.safeGet(backingRowMap, key) : null;
}
@Override
- @CheckForNull
public V put(C key, V value) {
checkNotNull(key);
checkNotNull(value);
@@ -367,9 +331,8 @@
}
@Override
- @CheckForNull
- public V remove(@CheckForNull Object key) {
- updateBackingRowMapField();
+ public V remove(Object key) {
+ Map<C, V> backingRowMap = backingRowMap();
if (backingRowMap == null) {
return null;
}
@@ -380,7 +343,7 @@
@Override
public void clear() {
- updateBackingRowMapField();
+ Map<C, V> backingRowMap = backingRowMap();
if (backingRowMap != null) {
backingRowMap.clear();
}
@@ -389,17 +352,17 @@
@Override
public int size() {
- updateBackingRowMapField();
- return (backingRowMap == null) ? 0 : backingRowMap.size();
+ Map<C, V> map = backingRowMap();
+ return (map == null) ? 0 : map.size();
}
@Override
Iterator<Entry<C, V>> entryIterator() {
- updateBackingRowMapField();
- if (backingRowMap == null) {
+ final Map<C, V> map = backingRowMap();
+ if (map == null) {
return Iterators.emptyModifiableIterator();
}
- final Iterator<Entry<C, V>> iterator = backingRowMap.entrySet().iterator();
+ final Iterator<Entry<C, V>> iterator = map.entrySet().iterator();
return new Iterator<Entry<C, V>>() {
@Override
public boolean hasNext() {
@@ -421,11 +384,11 @@
@Override
Spliterator<Entry<C, V>> entrySpliterator() {
- updateBackingRowMapField();
- if (backingRowMap == null) {
+ Map<C, V> map = backingRowMap();
+ if (map == null) {
return Spliterators.emptySpliterator();
}
- return CollectSpliterators.map(backingRowMap.entrySet().spliterator(), this::wrapEntry);
+ return CollectSpliterators.map(map.entrySet().spliterator(), this::wrapEntry);
}
Entry<C, V> wrapEntry(final Entry<C, V> entry) {
@@ -441,7 +404,7 @@
}
@Override
- public boolean equals(@CheckForNull Object object) {
+ public boolean equals(Object object) {
// TODO(lowasser): identify why this affects GWT tests
return standardEquals(object);
}
@@ -467,25 +430,22 @@
}
@Override
- @CheckForNull
public V put(R key, V value) {
return StandardTable.this.put(key, columnKey, value);
}
@Override
- @CheckForNull
- public V get(@CheckForNull Object key) {
+ public V get(Object key) {
return StandardTable.this.get(key, columnKey);
}
@Override
- public boolean containsKey(@CheckForNull Object key) {
+ public boolean containsKey(Object key) {
return StandardTable.this.contains(key, columnKey);
}
@Override
- @CheckForNull
- public V remove(@CheckForNull Object key) {
+ public V remove(Object key) {
return StandardTable.this.remove(key, columnKey);
}
@@ -543,7 +503,7 @@
}
@Override
- public boolean contains(@CheckForNull Object o) {
+ public boolean contains(Object o) {
if (o instanceof Entry) {
Entry<?, ?> entry = (Entry<?, ?>) o;
return containsMapping(entry.getKey(), columnKey, entry.getValue());
@@ -552,7 +512,7 @@
}
@Override
- public boolean remove(@CheckForNull Object obj) {
+ public boolean remove(Object obj) {
if (obj instanceof Entry) {
Entry<?, ?> entry = (Entry<?, ?>) obj;
return removeMapping(entry.getKey(), columnKey, entry.getValue());
@@ -570,7 +530,6 @@
final Iterator<Entry<R, Map<C, V>>> iterator = backingMap.entrySet().iterator();
@Override
- @CheckForNull
protected Entry<R, V> computeNext() {
while (iterator.hasNext()) {
final Entry<R, Map<C, V>> entry = iterator.next();
@@ -589,22 +548,7 @@
@Override
public V setValue(V value) {
- /*
- * The cast is safe because of the containsKey check above. (Well, it's possible for
- * the map to change between that call and this one. But if that happens, the
- * behavior is undefined because of the concurrent mutation.)
- *
- * (Our prototype checker happens to be "smart" enough to understand this for the
- * *get* call in getValue but not for the *put* call here.)
- *
- * (Arguably we should use requireNonNull rather than uncheckedCastNullableTToT: We
- * know that V is a non-null type because that's the only kind of value type that
- * StandardTable supports. Thus, requireNonNull is safe as long as the cell is still
- * present. (And if it's not present, behavior is undefined.) However, that's a
- * behavior change relative to the old code, so it didn't seem worth risking.)
- */
- return uncheckedCastNullableTToT(
- entry.getValue().put(columnKey, checkNotNull(value)));
+ return entry.getValue().put(columnKey, checkNotNull(value));
}
}
return new EntryImpl();
@@ -626,12 +570,12 @@
}
@Override
- public boolean contains(@CheckForNull Object obj) {
+ public boolean contains(Object obj) {
return StandardTable.this.contains(obj, columnKey);
}
@Override
- public boolean remove(@CheckForNull Object obj) {
+ public boolean remove(Object obj) {
return StandardTable.this.remove(obj, columnKey) != null;
}
@@ -653,7 +597,7 @@
}
@Override
- public boolean remove(@CheckForNull Object obj) {
+ public boolean remove(Object obj) {
return obj != null && removeFromColumnIf(Maps.<V>valuePredicateOnEntries(equalTo(obj)));
}
@@ -674,7 +618,7 @@
return rowMap().keySet();
}
- @CheckForNull private transient Set<C> columnKeySet;
+ private transient @Nullable Set<C> columnKeySet;
/**
* {@inheritDoc}
@@ -703,7 +647,7 @@
}
@Override
- public boolean remove(@CheckForNull Object obj) {
+ public boolean remove(Object obj) {
if (obj == null) {
return false;
}
@@ -758,7 +702,7 @@
}
@Override
- public boolean contains(@CheckForNull Object obj) {
+ public boolean contains(Object obj) {
return containsColumn(obj);
}
}
@@ -776,7 +720,6 @@
Iterator<Entry<C, V>> entryIterator = Iterators.emptyIterator();
@Override
- @CheckForNull
protected C computeNext() {
while (true) {
if (entryIterator.hasNext()) {
@@ -805,7 +748,7 @@
return super.values();
}
- @CheckForNull private transient Map<R, Map<C, V>> rowMap;
+ private transient @Nullable Map<R, Map<C, V>> rowMap;
@Override
public Map<R, Map<C, V>> rowMap() {
@@ -820,22 +763,19 @@
@WeakOuter
class RowMap extends ViewCachingAbstractMap<R, Map<C, V>> {
@Override
- public boolean containsKey(@CheckForNull Object key) {
+ public boolean containsKey(Object key) {
return containsRow(key);
}
// performing cast only when key is in backing map and has the correct type
@SuppressWarnings("unchecked")
@Override
- @CheckForNull
- public Map<C, V> get(@CheckForNull Object key) {
- // requireNonNull is safe because of the containsRow check.
- return containsRow(key) ? row((R) requireNonNull(key)) : null;
+ public Map<C, V> get(Object key) {
+ return containsRow(key) ? row((R) key) : null;
}
@Override
- @CheckForNull
- public Map<C, V> remove(@CheckForNull Object key) {
+ public Map<C, V> remove(Object key) {
return (key == null) ? null : backingMap.remove(key);
}
@@ -864,7 +804,7 @@
}
@Override
- public boolean contains(@CheckForNull Object obj) {
+ public boolean contains(Object obj) {
if (obj instanceof Entry) {
Entry<?, ?> entry = (Entry<?, ?>) obj;
return entry.getKey() != null
@@ -875,7 +815,7 @@
}
@Override
- public boolean remove(@CheckForNull Object obj) {
+ public boolean remove(Object obj) {
if (obj instanceof Entry) {
Entry<?, ?> entry = (Entry<?, ?>) obj;
return entry.getKey() != null
@@ -887,7 +827,7 @@
}
}
- @CheckForNull private transient ColumnMap columnMap;
+ private transient @Nullable ColumnMap columnMap;
@Override
public Map<C, Map<R, V>> columnMap() {
@@ -901,20 +841,17 @@
// has the correct type.
@SuppressWarnings("unchecked")
@Override
- @CheckForNull
- public Map<R, V> get(@CheckForNull Object key) {
- // requireNonNull is safe because of the containsColumn check.
- return containsColumn(key) ? column((C) requireNonNull(key)) : null;
+ public Map<R, V> get(Object key) {
+ return containsColumn(key) ? column((C) key) : null;
}
@Override
- public boolean containsKey(@CheckForNull Object key) {
+ public boolean containsKey(Object key) {
return containsColumn(key);
}
@Override
- @CheckForNull
- public Map<R, V> remove(@CheckForNull Object key) {
+ public Map<R, V> remove(Object key) {
return containsColumn(key) ? removeColumn(key) : null;
}
@@ -953,24 +890,23 @@
}
@Override
- public boolean contains(@CheckForNull Object obj) {
+ public boolean contains(Object obj) {
if (obj instanceof Entry) {
Entry<?, ?> entry = (Entry<?, ?>) obj;
if (containsColumn(entry.getKey())) {
- // requireNonNull is safe because of the containsColumn check.
- return requireNonNull(get(entry.getKey())).equals(entry.getValue());
+ // The cast to C occurs only when the key is in the map, implying
+ // that it has the correct type.
+ @SuppressWarnings("unchecked")
+ C columnKey = (C) entry.getKey();
+ return get(columnKey).equals(entry.getValue());
}
}
return false;
}
@Override
- public boolean remove(@CheckForNull Object obj) {
- /*
- * `o instanceof Entry` is guaranteed by `contains`, but we check it here to satisfy our
- * nullness checker.
- */
- if (contains(obj) && obj instanceof Entry) {
+ public boolean remove(Object obj) {
+ if (contains(obj)) {
Entry<?, ?> entry = (Entry<?, ?>) obj;
removeColumn(entry.getKey());
return true;
@@ -1011,7 +947,7 @@
}
@Override
- public boolean remove(@CheckForNull Object obj) {
+ public boolean remove(Object obj) {
for (Entry<C, Map<R, V>> entry : ColumnMap.this.entrySet()) {
if (entry.getValue().equals(obj)) {
removeColumn(entry.getKey());
diff --git a/guava/src/com/google/common/collect/Streams.java b/guava/src/com/google/common/collect/Streams.java
index 3bf8382..333fc2a 100644
--- a/guava/src/com/google/common/collect/Streams.java
+++ b/guava/src/com/google/common/collect/Streams.java
@@ -17,14 +17,11 @@
package com.google.common.collect;
import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.collect.NullnessCasts.uncheckedCastNullableTToT;
-import static java.util.Objects.requireNonNull;
+import static com.google.common.base.Preconditions.checkState;
import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtCompatible;
import com.google.common.math.LongMath;
-import com.google.errorprone.annotations.InlineMe;
-import com.google.errorprone.annotations.InlineMeValidationDisabled;
import java.util.ArrayDeque;
import java.util.Collection;
import java.util.Deque;
@@ -48,7 +45,6 @@
import java.util.stream.LongStream;
import java.util.stream.Stream;
import java.util.stream.StreamSupport;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -57,13 +53,12 @@
* @since 21.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
public final class Streams {
/**
* Returns a sequential {@link Stream} of the contents of {@code iterable}, delegating to {@link
* Collection#stream} if possible.
*/
- public static <T extends @Nullable Object> Stream<T> stream(Iterable<T> iterable) {
+ public static <T> Stream<T> stream(Iterable<T> iterable) {
return (iterable instanceof Collection)
? ((Collection<T>) iterable).stream()
: StreamSupport.stream(iterable.spliterator(), false);
@@ -76,8 +71,7 @@
*/
@Beta
@Deprecated
- @InlineMe(replacement = "collection.stream()")
- public static <T extends @Nullable Object> Stream<T> stream(Collection<T> collection) {
+ public static <T> Stream<T> stream(Collection<T> collection) {
return collection.stream();
}
@@ -86,7 +80,7 @@
* {@code iterator} directly after passing it to this method.
*/
@Beta
- public static <T extends @Nullable Object> Stream<T> stream(Iterator<T> iterator) {
+ public static <T> Stream<T> stream(Iterator<T> iterator) {
return StreamSupport.stream(Spliterators.spliteratorUnknownSize(iterator, 0), false);
}
@@ -106,8 +100,6 @@
* <p><b>Java 9 users:</b> use {@code optional.stream()} instead.
*/
@Beta
- @InlineMe(replacement = "optional.stream()")
- @InlineMeValidationDisabled("Java 9+ API only")
public static <T> Stream<T> stream(java.util.Optional<T> optional) {
return optional.isPresent() ? Stream.of(optional.get()) : Stream.empty();
}
@@ -119,8 +111,6 @@
* <p><b>Java 9 users:</b> use {@code optional.stream()} instead.
*/
@Beta
- @InlineMe(replacement = "optional.stream()")
- @InlineMeValidationDisabled("Java 9+ API only")
public static IntStream stream(OptionalInt optional) {
return optional.isPresent() ? IntStream.of(optional.getAsInt()) : IntStream.empty();
}
@@ -132,8 +122,6 @@
* <p><b>Java 9 users:</b> use {@code optional.stream()} instead.
*/
@Beta
- @InlineMe(replacement = "optional.stream()")
- @InlineMeValidationDisabled("Java 9+ API only")
public static LongStream stream(OptionalLong optional) {
return optional.isPresent() ? LongStream.of(optional.getAsLong()) : LongStream.empty();
}
@@ -145,8 +133,6 @@
* <p><b>Java 9 users:</b> use {@code optional.stream()} instead.
*/
@Beta
- @InlineMe(replacement = "optional.stream()")
- @InlineMeValidationDisabled("Java 9+ API only")
public static DoubleStream stream(OptionalDouble optional) {
return optional.isPresent() ? DoubleStream.of(optional.getAsDouble()) : DoubleStream.empty();
}
@@ -168,7 +154,7 @@
* @see Stream#concat(Stream, Stream)
*/
@SafeVarargs
- public static <T extends @Nullable Object> Stream<T> concat(Stream<? extends T>... streams) {
+ public static <T> Stream<T> concat(Stream<? extends T>... streams) {
// TODO(lowasser): consider an implementation that can support SUBSIZED
boolean isParallel = false;
int characteristics = Spliterator.ORDERED | Spliterator.SIZED | Spliterator.NONNULL;
@@ -314,9 +300,8 @@
* This may harm parallel performance.
*/
@Beta
- public static <A extends @Nullable Object, B extends @Nullable Object, R extends @Nullable Object>
- Stream<R> zip(
- Stream<A> streamA, Stream<B> streamB, BiFunction<? super A, ? super B, R> function) {
+ public static <A, B, R> Stream<R> zip(
+ Stream<A> streamA, Stream<B> streamB, BiFunction<? super A, ? super B, R> function) {
checkNotNull(streamA);
checkNotNull(streamB);
checkNotNull(function);
@@ -377,7 +362,7 @@
* @since 22.0
*/
@Beta
- public static <A extends @Nullable Object, B extends @Nullable Object> void forEachPair(
+ public static <A, B> void forEachPair(
Stream<A> streamA, Stream<B> streamB, BiConsumer<? super A, ? super B> consumer) {
checkNotNull(consumer);
@@ -393,11 +378,11 @@
}
// Use this carefully - it doesn't implement value semantics
- private static class TemporaryPair<A extends @Nullable Object, B extends @Nullable Object> {
- @ParametricNullness final A a;
- @ParametricNullness final B b;
+ private static class TemporaryPair<A, B> {
+ final A a;
+ final B b;
- TemporaryPair(@ParametricNullness A a, @ParametricNullness B b) {
+ TemporaryPair(A a, B b) {
this.a = a;
this.b = b;
}
@@ -426,7 +411,7 @@
* was defined.
*/
@Beta
- public static <T extends @Nullable Object, R extends @Nullable Object> Stream<R> mapWithIndex(
+ public static <T, R> Stream<R> mapWithIndex(
Stream<T> stream, FunctionWithIndex<? super T, ? extends R> function) {
checkNotNull(stream);
checkNotNull(function);
@@ -454,14 +439,14 @@
.onClose(stream::close);
}
class Splitr extends MapWithIndexSpliterator<Spliterator<T>, R, Splitr> implements Consumer<T> {
- @CheckForNull T holder;
+ @Nullable T holder;
Splitr(Spliterator<T> splitr, long index) {
super(splitr, index);
}
@Override
- public void accept(@ParametricNullness T t) {
+ public void accept(@Nullable T t) {
this.holder = t;
}
@@ -469,8 +454,7 @@
public boolean tryAdvance(Consumer<? super R> action) {
if (fromSpliterator.tryAdvance(this)) {
try {
- // The cast is safe because tryAdvance puts a T into `holder`.
- action.accept(function.apply(uncheckedCastNullableTToT(holder), index++));
+ action.accept(function.apply(holder, index++));
return true;
} finally {
holder = null;
@@ -510,8 +494,7 @@
* was defined.
*/
@Beta
- public static <R extends @Nullable Object> Stream<R> mapWithIndex(
- IntStream stream, IntFunctionWithIndex<R> function) {
+ public static <R> Stream<R> mapWithIndex(IntStream stream, IntFunctionWithIndex<R> function) {
checkNotNull(stream);
checkNotNull(function);
boolean isParallel = stream.isParallel();
@@ -590,8 +573,7 @@
* was defined.
*/
@Beta
- public static <R extends @Nullable Object> Stream<R> mapWithIndex(
- LongStream stream, LongFunctionWithIndex<R> function) {
+ public static <R> Stream<R> mapWithIndex(LongStream stream, LongFunctionWithIndex<R> function) {
checkNotNull(stream);
checkNotNull(function);
boolean isParallel = stream.isParallel();
@@ -670,7 +652,7 @@
* was defined.
*/
@Beta
- public static <R extends @Nullable Object> Stream<R> mapWithIndex(
+ public static <R> Stream<R> mapWithIndex(
DoubleStream stream, DoubleFunctionWithIndex<R> function) {
checkNotNull(stream);
checkNotNull(function);
@@ -736,16 +718,13 @@
* @since 21.0
*/
@Beta
- public interface FunctionWithIndex<T extends @Nullable Object, R extends @Nullable Object> {
+ public interface FunctionWithIndex<T, R> {
/** Applies this function to the given argument and its index within a stream. */
- @ParametricNullness
- R apply(@ParametricNullness T from, long index);
+ R apply(T from, long index);
}
private abstract static class MapWithIndexSpliterator<
- F extends Spliterator<?>,
- R extends @Nullable Object,
- S extends MapWithIndexSpliterator<F, R, S>>
+ F extends Spliterator<?>, R, S extends MapWithIndexSpliterator<F, R, S>>
implements Spliterator<R> {
final F fromSpliterator;
long index;
@@ -758,14 +737,12 @@
abstract S createSplit(F from, long i);
@Override
- @CheckForNull
public S trySplit() {
- Spliterator<?> splitOrNull = fromSpliterator.trySplit();
- if (splitOrNull == null) {
+ @SuppressWarnings("unchecked")
+ F split = (F) fromSpliterator.trySplit();
+ if (split == null) {
return null;
}
- @SuppressWarnings("unchecked")
- F split = (F) splitOrNull;
S result = createSplit(split, index);
this.index += split.getExactSizeIfKnown();
return result;
@@ -792,9 +769,8 @@
* @since 21.0
*/
@Beta
- public interface IntFunctionWithIndex<R extends @Nullable Object> {
+ public interface IntFunctionWithIndex<R> {
/** Applies this function to the given argument and its index within a stream. */
- @ParametricNullness
R apply(int from, long index);
}
@@ -807,9 +783,8 @@
* @since 21.0
*/
@Beta
- public interface LongFunctionWithIndex<R extends @Nullable Object> {
+ public interface LongFunctionWithIndex<R> {
/** Applies this function to the given argument and its index within a stream. */
- @ParametricNullness
R apply(long from, long index);
}
@@ -822,9 +797,8 @@
* @since 21.0
*/
@Beta
- public interface DoubleFunctionWithIndex<R extends @Nullable Object> {
+ public interface DoubleFunctionWithIndex<R> {
/** Applies this function to the given argument and its index within a stream. */
- @ParametricNullness
R apply(double from, long index);
}
@@ -843,34 +817,20 @@
* @see Stream#findFirst()
* @throws NullPointerException if the last element of the stream is null
*/
- /*
- * By declaring <T> instead of <T extends @Nullable Object>, we declare this method as requiring a
- * stream whose elements are non-null. However, the method goes out of its way to still handle
- * nulls in the stream. This means that the method can safely be used with a stream that contains
- * nulls as long as the *last* element is *not* null.
- *
- * (To "go out of its way," the method tracks a `set` bit so that it can distinguish "the final
- * split has a last element of null, so throw NPE" from "the final split was empty, so look for an
- * element in the prior one.")
- */
@Beta
public static <T> java.util.Optional<T> findLast(Stream<T> stream) {
class OptionalState {
boolean set = false;
- @CheckForNull T value = null;
+ T value = null;
- void set(T value) {
+ void set(@Nullable T value) {
this.set = true;
this.value = value;
}
T get() {
- /*
- * requireNonNull is safe because we call get() only if we've previously called set().
- *
- * (For further discussion of nullness, see the comment above the method.)
- */
- return requireNonNull(value);
+ checkState(set);
+ return value;
}
}
OptionalState state = new OptionalState();
@@ -936,7 +896,7 @@
public static OptionalInt findLast(IntStream stream) {
// findLast(Stream) does some allocation, so we might as well box some more
java.util.Optional<Integer> boxedLast = findLast(stream.boxed());
- return boxedLast.map(OptionalInt::of).orElseGet(OptionalInt::empty);
+ return boxedLast.isPresent() ? OptionalInt.of(boxedLast.get()) : OptionalInt.empty();
}
/**
@@ -955,7 +915,7 @@
public static OptionalLong findLast(LongStream stream) {
// findLast(Stream) does some allocation, so we might as well box some more
java.util.Optional<Long> boxedLast = findLast(stream.boxed());
- return boxedLast.map(OptionalLong::of).orElseGet(OptionalLong::empty);
+ return boxedLast.isPresent() ? OptionalLong.of(boxedLast.get()) : OptionalLong.empty();
}
/**
@@ -974,7 +934,7 @@
public static OptionalDouble findLast(DoubleStream stream) {
// findLast(Stream) does some allocation, so we might as well box some more
java.util.Optional<Double> boxedLast = findLast(stream.boxed());
- return boxedLast.map(OptionalDouble::of).orElseGet(OptionalDouble::empty);
+ return boxedLast.isPresent() ? OptionalDouble.of(boxedLast.get()) : OptionalDouble.empty();
}
private Streams() {}
diff --git a/guava/src/com/google/common/collect/Synchronized.java b/guava/src/com/google/common/collect/Synchronized.java
index 25e2870..0f175cc 100644
--- a/guava/src/com/google/common/collect/Synchronized.java
+++ b/guava/src/com/google/common/collect/Synchronized.java
@@ -32,6 +32,7 @@
import java.util.List;
import java.util.ListIterator;
import java.util.Map;
+import java.util.Map.Entry;
import java.util.NavigableMap;
import java.util.NavigableSet;
import java.util.Queue;
@@ -47,7 +48,6 @@
import java.util.function.Predicate;
import java.util.function.UnaryOperator;
import java.util.stream.Stream;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -63,16 +63,6 @@
* @author Jared Levy
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
-/*
- * I have decided not to bother adding @ParametricNullness annotations in this class. Adding them is
- * a lot of busy work, and the annotation matters only when the APIs to be annotated are visible to
- * Kotlin code. In this class, nothing is publicly visible (nor exposed indirectly through a
- * publicly visible subclass), and I doubt any of our current or future Kotlin extensions for the
- * package will refer to the class. Plus, @ParametricNullness is only a temporary workaround,
- * anyway, so we just need to get by without the annotations here until Kotlin better understands
- * our other nullness annotations.
- */
final class Synchronized {
private Synchronized() {}
@@ -80,7 +70,7 @@
final Object delegate;
final Object mutex;
- SynchronizedObject(Object delegate, @CheckForNull Object mutex) {
+ SynchronizedObject(Object delegate, @Nullable Object mutex) {
this.delegate = checkNotNull(delegate);
this.mutex = (mutex == null) ? this : mutex;
}
@@ -114,15 +104,13 @@
private static final long serialVersionUID = 0;
}
- private static <E extends @Nullable Object> Collection<E> collection(
- Collection<E> collection, @CheckForNull Object mutex) {
+ private static <E> Collection<E> collection(Collection<E> collection, @Nullable Object mutex) {
return new SynchronizedCollection<E>(collection, mutex);
}
@VisibleForTesting
- static class SynchronizedCollection<E extends @Nullable Object> extends SynchronizedObject
- implements Collection<E> {
- private SynchronizedCollection(Collection<E> delegate, @CheckForNull Object mutex) {
+ static class SynchronizedCollection<E> extends SynchronizedObject implements Collection<E> {
+ private SynchronizedCollection(Collection<E> delegate, @Nullable Object mutex) {
super(delegate, mutex);
}
@@ -154,7 +142,7 @@
}
@Override
- public boolean contains(@CheckForNull Object o) {
+ public boolean contains(Object o) {
synchronized (mutex) {
return delegate().contains(o);
}
@@ -208,7 +196,7 @@
}
@Override
- public boolean remove(@CheckForNull Object o) {
+ public boolean remove(Object o) {
synchronized (mutex) {
return delegate().remove(o);
}
@@ -243,15 +231,14 @@
}
@Override
- public @Nullable Object[] toArray() {
+ public Object[] toArray() {
synchronized (mutex) {
return delegate().toArray();
}
}
@Override
- @SuppressWarnings("nullness") // b/192354773 in our checker affects toArray declarations
- public <T extends @Nullable Object> T[] toArray(T[] a) {
+ public <T> T[] toArray(T[] a) {
synchronized (mutex) {
return delegate().toArray(a);
}
@@ -261,14 +248,13 @@
}
@VisibleForTesting
- static <E extends @Nullable Object> Set<E> set(Set<E> set, @CheckForNull Object mutex) {
+ static <E> Set<E> set(Set<E> set, @Nullable Object mutex) {
return new SynchronizedSet<E>(set, mutex);
}
- static class SynchronizedSet<E extends @Nullable Object> extends SynchronizedCollection<E>
- implements Set<E> {
+ static class SynchronizedSet<E> extends SynchronizedCollection<E> implements Set<E> {
- SynchronizedSet(Set<E> delegate, @CheckForNull Object mutex) {
+ SynchronizedSet(Set<E> delegate, @Nullable Object mutex) {
super(delegate, mutex);
}
@@ -278,7 +264,7 @@
}
@Override
- public boolean equals(@CheckForNull Object o) {
+ public boolean equals(Object o) {
if (o == this) {
return true;
}
@@ -297,14 +283,12 @@
private static final long serialVersionUID = 0;
}
- private static <E extends @Nullable Object> SortedSet<E> sortedSet(
- SortedSet<E> set, @CheckForNull Object mutex) {
+ private static <E> SortedSet<E> sortedSet(SortedSet<E> set, @Nullable Object mutex) {
return new SynchronizedSortedSet<E>(set, mutex);
}
- static class SynchronizedSortedSet<E extends @Nullable Object> extends SynchronizedSet<E>
- implements SortedSet<E> {
- SynchronizedSortedSet(SortedSet<E> delegate, @CheckForNull Object mutex) {
+ static class SynchronizedSortedSet<E> extends SynchronizedSet<E> implements SortedSet<E> {
+ SynchronizedSortedSet(SortedSet<E> delegate, @Nullable Object mutex) {
super(delegate, mutex);
}
@@ -314,7 +298,6 @@
}
@Override
- @CheckForNull
public Comparator<? super E> comparator() {
synchronized (mutex) {
return delegate().comparator();
@@ -359,16 +342,14 @@
private static final long serialVersionUID = 0;
}
- private static <E extends @Nullable Object> List<E> list(
- List<E> list, @CheckForNull Object mutex) {
+ private static <E> List<E> list(List<E> list, @Nullable Object mutex) {
return (list instanceof RandomAccess)
? new SynchronizedRandomAccessList<E>(list, mutex)
: new SynchronizedList<E>(list, mutex);
}
- private static class SynchronizedList<E extends @Nullable Object>
- extends SynchronizedCollection<E> implements List<E> {
- SynchronizedList(List<E> delegate, @CheckForNull Object mutex) {
+ private static class SynchronizedList<E> extends SynchronizedCollection<E> implements List<E> {
+ SynchronizedList(List<E> delegate, @Nullable Object mutex) {
super(delegate, mutex);
}
@@ -399,14 +380,14 @@
}
@Override
- public int indexOf(@CheckForNull Object o) {
+ public int indexOf(Object o) {
synchronized (mutex) {
return delegate().indexOf(o);
}
}
@Override
- public int lastIndexOf(@CheckForNull Object o) {
+ public int lastIndexOf(Object o) {
synchronized (mutex) {
return delegate().lastIndexOf(o);
}
@@ -458,7 +439,7 @@
}
@Override
- public boolean equals(@CheckForNull Object o) {
+ public boolean equals(Object o) {
if (o == this) {
return true;
}
@@ -477,29 +458,28 @@
private static final long serialVersionUID = 0;
}
- private static class SynchronizedRandomAccessList<E extends @Nullable Object>
- extends SynchronizedList<E> implements RandomAccess {
- SynchronizedRandomAccessList(List<E> list, @CheckForNull Object mutex) {
+ private static class SynchronizedRandomAccessList<E> extends SynchronizedList<E>
+ implements RandomAccess {
+ SynchronizedRandomAccessList(List<E> list, @Nullable Object mutex) {
super(list, mutex);
}
private static final long serialVersionUID = 0;
}
- static <E extends @Nullable Object> Multiset<E> multiset(
- Multiset<E> multiset, @CheckForNull Object mutex) {
+ static <E> Multiset<E> multiset(Multiset<E> multiset, @Nullable Object mutex) {
if (multiset instanceof SynchronizedMultiset || multiset instanceof ImmutableMultiset) {
return multiset;
}
return new SynchronizedMultiset<E>(multiset, mutex);
}
- private static class SynchronizedMultiset<E extends @Nullable Object>
- extends SynchronizedCollection<E> implements Multiset<E> {
- @CheckForNull transient Set<E> elementSet;
- @CheckForNull transient Set<Multiset.Entry<E>> entrySet;
+ private static class SynchronizedMultiset<E> extends SynchronizedCollection<E>
+ implements Multiset<E> {
+ transient @Nullable Set<E> elementSet;
+ transient @Nullable Set<Entry<E>> entrySet;
- SynchronizedMultiset(Multiset<E> delegate, @CheckForNull Object mutex) {
+ SynchronizedMultiset(Multiset<E> delegate, @Nullable Object mutex) {
super(delegate, mutex);
}
@@ -509,7 +489,7 @@
}
@Override
- public int count(@CheckForNull Object o) {
+ public int count(Object o) {
synchronized (mutex) {
return delegate().count(o);
}
@@ -523,7 +503,7 @@
}
@Override
- public int remove(@CheckForNull Object o, int n) {
+ public int remove(Object o, int n) {
synchronized (mutex) {
return delegate().remove(o, n);
}
@@ -554,7 +534,7 @@
}
@Override
- public Set<Multiset.Entry<E>> entrySet() {
+ public Set<Entry<E>> entrySet() {
synchronized (mutex) {
if (entrySet == null) {
entrySet = typePreservingSet(delegate().entrySet(), mutex);
@@ -564,7 +544,7 @@
}
@Override
- public boolean equals(@CheckForNull Object o) {
+ public boolean equals(Object o) {
if (o == this) {
return true;
}
@@ -583,21 +563,20 @@
private static final long serialVersionUID = 0;
}
- static <K extends @Nullable Object, V extends @Nullable Object> Multimap<K, V> multimap(
- Multimap<K, V> multimap, @CheckForNull Object mutex) {
+ static <K, V> Multimap<K, V> multimap(Multimap<K, V> multimap, @Nullable Object mutex) {
if (multimap instanceof SynchronizedMultimap || multimap instanceof BaseImmutableMultimap) {
return multimap;
}
return new SynchronizedMultimap<>(multimap, mutex);
}
- private static class SynchronizedMultimap<K extends @Nullable Object, V extends @Nullable Object>
- extends SynchronizedObject implements Multimap<K, V> {
- @CheckForNull transient Set<K> keySet;
- @CheckForNull transient Collection<V> valuesCollection;
- @CheckForNull transient Collection<Map.Entry<K, V>> entries;
- @CheckForNull transient Map<K, Collection<V>> asMap;
- @CheckForNull transient Multiset<K> keys;
+ private static class SynchronizedMultimap<K, V> extends SynchronizedObject
+ implements Multimap<K, V> {
+ transient @Nullable Set<K> keySet;
+ transient @Nullable Collection<V> valuesCollection;
+ transient @Nullable Collection<Entry<K, V>> entries;
+ transient @Nullable Map<K, Collection<V>> asMap;
+ transient @Nullable Multiset<K> keys;
@SuppressWarnings("unchecked")
@Override
@@ -605,7 +584,7 @@
return (Multimap<K, V>) super.delegate();
}
- SynchronizedMultimap(Multimap<K, V> delegate, @CheckForNull Object mutex) {
+ SynchronizedMultimap(Multimap<K, V> delegate, @Nullable Object mutex) {
super(delegate, mutex);
}
@@ -624,21 +603,21 @@
}
@Override
- public boolean containsKey(@CheckForNull Object key) {
+ public boolean containsKey(Object key) {
synchronized (mutex) {
return delegate().containsKey(key);
}
}
@Override
- public boolean containsValue(@CheckForNull Object value) {
+ public boolean containsValue(Object value) {
synchronized (mutex) {
return delegate().containsValue(value);
}
}
@Override
- public boolean containsEntry(@CheckForNull Object key, @CheckForNull Object value) {
+ public boolean containsEntry(Object key, Object value) {
synchronized (mutex) {
return delegate().containsEntry(key, value);
}
@@ -680,14 +659,14 @@
}
@Override
- public boolean remove(@CheckForNull Object key, @CheckForNull Object value) {
+ public boolean remove(Object key, Object value) {
synchronized (mutex) {
return delegate().remove(key, value);
}
}
@Override
- public Collection<V> removeAll(@CheckForNull Object key) {
+ public Collection<V> removeAll(Object key) {
synchronized (mutex) {
return delegate().removeAll(key); // copy not synchronized
}
@@ -721,7 +700,7 @@
}
@Override
- public Collection<Map.Entry<K, V>> entries() {
+ public Collection<Entry<K, V>> entries() {
synchronized (mutex) {
if (entries == null) {
entries = typePreservingCollection(delegate().entries(), mutex);
@@ -758,7 +737,7 @@
}
@Override
- public boolean equals(@CheckForNull Object o) {
+ public boolean equals(Object o) {
if (o == this) {
return true;
}
@@ -777,18 +756,17 @@
private static final long serialVersionUID = 0;
}
- static <K extends @Nullable Object, V extends @Nullable Object> ListMultimap<K, V> listMultimap(
- ListMultimap<K, V> multimap, @CheckForNull Object mutex) {
+ static <K, V> ListMultimap<K, V> listMultimap(
+ ListMultimap<K, V> multimap, @Nullable Object mutex) {
if (multimap instanceof SynchronizedListMultimap || multimap instanceof BaseImmutableMultimap) {
return multimap;
}
return new SynchronizedListMultimap<>(multimap, mutex);
}
- private static class SynchronizedListMultimap<
- K extends @Nullable Object, V extends @Nullable Object>
- extends SynchronizedMultimap<K, V> implements ListMultimap<K, V> {
- SynchronizedListMultimap(ListMultimap<K, V> delegate, @CheckForNull Object mutex) {
+ private static class SynchronizedListMultimap<K, V> extends SynchronizedMultimap<K, V>
+ implements ListMultimap<K, V> {
+ SynchronizedListMultimap(ListMultimap<K, V> delegate, @Nullable Object mutex) {
super(delegate, mutex);
}
@@ -805,7 +783,7 @@
}
@Override
- public List<V> removeAll(@CheckForNull Object key) {
+ public List<V> removeAll(Object key) {
synchronized (mutex) {
return delegate().removeAll(key); // copy not synchronized
}
@@ -821,20 +799,18 @@
private static final long serialVersionUID = 0;
}
- static <K extends @Nullable Object, V extends @Nullable Object> SetMultimap<K, V> setMultimap(
- SetMultimap<K, V> multimap, @CheckForNull Object mutex) {
+ static <K, V> SetMultimap<K, V> setMultimap(SetMultimap<K, V> multimap, @Nullable Object mutex) {
if (multimap instanceof SynchronizedSetMultimap || multimap instanceof BaseImmutableMultimap) {
return multimap;
}
return new SynchronizedSetMultimap<>(multimap, mutex);
}
- private static class SynchronizedSetMultimap<
- K extends @Nullable Object, V extends @Nullable Object>
- extends SynchronizedMultimap<K, V> implements SetMultimap<K, V> {
- @CheckForNull transient Set<Map.Entry<K, V>> entrySet;
+ private static class SynchronizedSetMultimap<K, V> extends SynchronizedMultimap<K, V>
+ implements SetMultimap<K, V> {
+ transient @Nullable Set<Entry<K, V>> entrySet;
- SynchronizedSetMultimap(SetMultimap<K, V> delegate, @CheckForNull Object mutex) {
+ SynchronizedSetMultimap(SetMultimap<K, V> delegate, @Nullable Object mutex) {
super(delegate, mutex);
}
@@ -851,7 +827,7 @@
}
@Override
- public Set<V> removeAll(@CheckForNull Object key) {
+ public Set<V> removeAll(Object key) {
synchronized (mutex) {
return delegate().removeAll(key); // copy not synchronized
}
@@ -865,7 +841,7 @@
}
@Override
- public Set<Map.Entry<K, V>> entries() {
+ public Set<Entry<K, V>> entries() {
synchronized (mutex) {
if (entrySet == null) {
entrySet = set(delegate().entries(), mutex);
@@ -877,19 +853,17 @@
private static final long serialVersionUID = 0;
}
- static <K extends @Nullable Object, V extends @Nullable Object>
- SortedSetMultimap<K, V> sortedSetMultimap(
- SortedSetMultimap<K, V> multimap, @CheckForNull Object mutex) {
+ static <K, V> SortedSetMultimap<K, V> sortedSetMultimap(
+ SortedSetMultimap<K, V> multimap, @Nullable Object mutex) {
if (multimap instanceof SynchronizedSortedSetMultimap) {
return multimap;
}
return new SynchronizedSortedSetMultimap<>(multimap, mutex);
}
- private static class SynchronizedSortedSetMultimap<
- K extends @Nullable Object, V extends @Nullable Object>
- extends SynchronizedSetMultimap<K, V> implements SortedSetMultimap<K, V> {
- SynchronizedSortedSetMultimap(SortedSetMultimap<K, V> delegate, @CheckForNull Object mutex) {
+ private static class SynchronizedSortedSetMultimap<K, V> extends SynchronizedSetMultimap<K, V>
+ implements SortedSetMultimap<K, V> {
+ SynchronizedSortedSetMultimap(SortedSetMultimap<K, V> delegate, @Nullable Object mutex) {
super(delegate, mutex);
}
@@ -906,7 +880,7 @@
}
@Override
- public SortedSet<V> removeAll(@CheckForNull Object key) {
+ public SortedSet<V> removeAll(Object key) {
synchronized (mutex) {
return delegate().removeAll(key); // copy not synchronized
}
@@ -920,7 +894,6 @@
}
@Override
- @CheckForNull
public Comparator<? super V> valueComparator() {
synchronized (mutex) {
return delegate().valueComparator();
@@ -930,8 +903,8 @@
private static final long serialVersionUID = 0;
}
- private static <E extends @Nullable Object> Collection<E> typePreservingCollection(
- Collection<E> collection, @CheckForNull Object mutex) {
+ private static <E> Collection<E> typePreservingCollection(
+ Collection<E> collection, @Nullable Object mutex) {
if (collection instanceof SortedSet) {
return sortedSet((SortedSet<E>) collection, mutex);
}
@@ -944,8 +917,7 @@
return collection(collection, mutex);
}
- private static <E extends @Nullable Object> Set<E> typePreservingSet(
- Set<E> set, @CheckForNull Object mutex) {
+ private static <E> Set<E> typePreservingSet(Set<E> set, @Nullable Object mutex) {
if (set instanceof SortedSet) {
return sortedSet((SortedSet<E>) set, mutex);
} else {
@@ -953,24 +925,22 @@
}
}
- private static class SynchronizedAsMapEntries<
- K extends @Nullable Object, V extends @Nullable Object>
- extends SynchronizedSet<Map.Entry<K, Collection<V>>> {
- SynchronizedAsMapEntries(
- Set<Map.Entry<K, Collection<V>>> delegate, @CheckForNull Object mutex) {
+ private static class SynchronizedAsMapEntries<K, V>
+ extends SynchronizedSet<Entry<K, Collection<V>>> {
+ SynchronizedAsMapEntries(Set<Entry<K, Collection<V>>> delegate, @Nullable Object mutex) {
super(delegate, mutex);
}
@Override
- public Iterator<Map.Entry<K, Collection<V>>> iterator() {
+ public Iterator<Entry<K, Collection<V>>> iterator() {
// Must be manually synchronized.
- return new TransformedIterator<Map.Entry<K, Collection<V>>, Map.Entry<K, Collection<V>>>(
+ return new TransformedIterator<Entry<K, Collection<V>>, Entry<K, Collection<V>>>(
super.iterator()) {
@Override
- Map.Entry<K, Collection<V>> transform(final Map.Entry<K, Collection<V>> entry) {
+ Entry<K, Collection<V>> transform(final Entry<K, Collection<V>> entry) {
return new ForwardingMapEntry<K, Collection<V>>() {
@Override
- protected Map.Entry<K, Collection<V>> delegate() {
+ protected Entry<K, Collection<V>> delegate() {
return entry;
}
@@ -988,27 +958,19 @@
@Override
public Object[] toArray() {
synchronized (mutex) {
- /*
- * toArrayImpl returns `@Nullable Object[]` rather than `Object[]` but only because it can
- * be used with collections that may contain null. This collection never contains nulls, so
- * we can treat it as a plain `Object[]`.
- */
- @SuppressWarnings("nullness")
- Object[] result = (Object[]) ObjectArrays.toArrayImpl(delegate());
- return result;
+ return ObjectArrays.toArrayImpl(delegate());
}
}
@Override
- @SuppressWarnings("nullness") // b/192354773 in our checker affects toArray declarations
- public <T extends @Nullable Object> T[] toArray(T[] array) {
+ public <T> T[] toArray(T[] array) {
synchronized (mutex) {
return ObjectArrays.toArrayImpl(delegate(), array);
}
}
@Override
- public boolean contains(@CheckForNull Object o) {
+ public boolean contains(Object o) {
synchronized (mutex) {
return Maps.containsEntryImpl(delegate(), o);
}
@@ -1022,7 +984,7 @@
}
@Override
- public boolean equals(@CheckForNull Object o) {
+ public boolean equals(Object o) {
if (o == this) {
return true;
}
@@ -1032,7 +994,7 @@
}
@Override
- public boolean remove(@CheckForNull Object o) {
+ public boolean remove(Object o) {
synchronized (mutex) {
return Maps.removeEntryImpl(delegate(), o);
}
@@ -1056,18 +1018,16 @@
}
@VisibleForTesting
- static <K extends @Nullable Object, V extends @Nullable Object> Map<K, V> map(
- Map<K, V> map, @CheckForNull Object mutex) {
+ static <K, V> Map<K, V> map(Map<K, V> map, @Nullable Object mutex) {
return new SynchronizedMap<>(map, mutex);
}
- private static class SynchronizedMap<K extends @Nullable Object, V extends @Nullable Object>
- extends SynchronizedObject implements Map<K, V> {
- @CheckForNull transient Set<K> keySet;
- @CheckForNull transient Collection<V> values;
- @CheckForNull transient Set<Map.Entry<K, V>> entrySet;
+ private static class SynchronizedMap<K, V> extends SynchronizedObject implements Map<K, V> {
+ transient @Nullable Set<K> keySet;
+ transient @Nullable Collection<V> values;
+ transient @Nullable Set<Entry<K, V>> entrySet;
- SynchronizedMap(Map<K, V> delegate, @CheckForNull Object mutex) {
+ SynchronizedMap(Map<K, V> delegate, @Nullable Object mutex) {
super(delegate, mutex);
}
@@ -1085,21 +1045,21 @@
}
@Override
- public boolean containsKey(@CheckForNull Object key) {
+ public boolean containsKey(Object key) {
synchronized (mutex) {
return delegate().containsKey(key);
}
}
@Override
- public boolean containsValue(@CheckForNull Object value) {
+ public boolean containsValue(Object value) {
synchronized (mutex) {
return delegate().containsValue(value);
}
}
@Override
- public Set<Map.Entry<K, V>> entrySet() {
+ public Set<Entry<K, V>> entrySet() {
synchronized (mutex) {
if (entrySet == null) {
entrySet = set(delegate().entrySet(), mutex);
@@ -1116,16 +1076,14 @@
}
@Override
- @CheckForNull
- public V get(@CheckForNull Object key) {
+ public V get(Object key) {
synchronized (mutex) {
return delegate().get(key);
}
}
@Override
- @CheckForNull
- public V getOrDefault(@CheckForNull Object key, @CheckForNull V defaultValue) {
+ public V getOrDefault(Object key, V defaultValue) {
synchronized (mutex) {
return delegate().getOrDefault(key, defaultValue);
}
@@ -1149,7 +1107,6 @@
}
@Override
- @CheckForNull
public V put(K key, V value) {
synchronized (mutex) {
return delegate().put(key, value);
@@ -1157,7 +1114,6 @@
}
@Override
- @CheckForNull
public V putIfAbsent(K key, V value) {
synchronized (mutex) {
return delegate().putIfAbsent(key, value);
@@ -1172,7 +1128,6 @@
}
@Override
- @CheckForNull
public V replace(K key, V value) {
synchronized (mutex) {
return delegate().replace(key, value);
@@ -1224,15 +1179,14 @@
}
@Override
- @CheckForNull
- public V remove(@CheckForNull Object key) {
+ public V remove(Object key) {
synchronized (mutex) {
return delegate().remove(key);
}
}
@Override
- public boolean remove(@CheckForNull Object key, @CheckForNull Object value) {
+ public boolean remove(Object key, Object value) {
synchronized (mutex) {
return delegate().remove(key, value);
}
@@ -1256,7 +1210,7 @@
}
@Override
- public boolean equals(@CheckForNull Object o) {
+ public boolean equals(Object o) {
if (o == this) {
return true;
}
@@ -1275,15 +1229,14 @@
private static final long serialVersionUID = 0;
}
- static <K extends @Nullable Object, V extends @Nullable Object> SortedMap<K, V> sortedMap(
- SortedMap<K, V> sortedMap, @CheckForNull Object mutex) {
+ static <K, V> SortedMap<K, V> sortedMap(SortedMap<K, V> sortedMap, @Nullable Object mutex) {
return new SynchronizedSortedMap<>(sortedMap, mutex);
}
- static class SynchronizedSortedMap<K extends @Nullable Object, V extends @Nullable Object>
- extends SynchronizedMap<K, V> implements SortedMap<K, V> {
+ static class SynchronizedSortedMap<K, V> extends SynchronizedMap<K, V>
+ implements SortedMap<K, V> {
- SynchronizedSortedMap(SortedMap<K, V> delegate, @CheckForNull Object mutex) {
+ SynchronizedSortedMap(SortedMap<K, V> delegate, @Nullable Object mutex) {
super(delegate, mutex);
}
@@ -1293,7 +1246,6 @@
}
@Override
- @CheckForNull
public Comparator<? super K> comparator() {
synchronized (mutex) {
return delegate().comparator();
@@ -1338,8 +1290,7 @@
private static final long serialVersionUID = 0;
}
- static <K extends @Nullable Object, V extends @Nullable Object> BiMap<K, V> biMap(
- BiMap<K, V> bimap, @CheckForNull Object mutex) {
+ static <K, V> BiMap<K, V> biMap(BiMap<K, V> bimap, @Nullable Object mutex) {
if (bimap instanceof SynchronizedBiMap || bimap instanceof ImmutableBiMap) {
return bimap;
}
@@ -1347,13 +1298,13 @@
}
@VisibleForTesting
- static class SynchronizedBiMap<K extends @Nullable Object, V extends @Nullable Object>
- extends SynchronizedMap<K, V> implements BiMap<K, V>, Serializable {
- @CheckForNull private transient Set<V> valueSet;
- @RetainedWith @CheckForNull private transient BiMap<V, K> inverse;
+ static class SynchronizedBiMap<K, V> extends SynchronizedMap<K, V>
+ implements BiMap<K, V>, Serializable {
+ private transient @Nullable Set<V> valueSet;
+ @RetainedWith private transient @Nullable BiMap<V, K> inverse;
private SynchronizedBiMap(
- BiMap<K, V> delegate, @CheckForNull Object mutex, @CheckForNull BiMap<V, K> inverse) {
+ BiMap<K, V> delegate, @Nullable Object mutex, @Nullable BiMap<V, K> inverse) {
super(delegate, mutex);
this.inverse = inverse;
}
@@ -1374,7 +1325,6 @@
}
@Override
- @CheckForNull
public V forcePut(K key, V value) {
synchronized (mutex) {
return delegate().forcePut(key, value);
@@ -1394,18 +1344,16 @@
private static final long serialVersionUID = 0;
}
- private static class SynchronizedAsMap<K extends @Nullable Object, V extends @Nullable Object>
- extends SynchronizedMap<K, Collection<V>> {
- @CheckForNull transient Set<Map.Entry<K, Collection<V>>> asMapEntrySet;
- @CheckForNull transient Collection<Collection<V>> asMapValues;
+ private static class SynchronizedAsMap<K, V> extends SynchronizedMap<K, Collection<V>> {
+ transient @Nullable Set<Entry<K, Collection<V>>> asMapEntrySet;
+ transient @Nullable Collection<Collection<V>> asMapValues;
- SynchronizedAsMap(Map<K, Collection<V>> delegate, @CheckForNull Object mutex) {
+ SynchronizedAsMap(Map<K, Collection<V>> delegate, @Nullable Object mutex) {
super(delegate, mutex);
}
@Override
- @CheckForNull
- public Collection<V> get(@CheckForNull Object key) {
+ public Collection<V> get(Object key) {
synchronized (mutex) {
Collection<V> collection = super.get(key);
return (collection == null) ? null : typePreservingCollection(collection, mutex);
@@ -1413,7 +1361,7 @@
}
@Override
- public Set<Map.Entry<K, Collection<V>>> entrySet() {
+ public Set<Entry<K, Collection<V>>> entrySet() {
synchronized (mutex) {
if (asMapEntrySet == null) {
asMapEntrySet = new SynchronizedAsMapEntries<>(delegate().entrySet(), mutex);
@@ -1433,7 +1381,7 @@
}
@Override
- public boolean containsValue(@CheckForNull Object o) {
+ public boolean containsValue(Object o) {
// values() and its contains() method are both synchronized.
return values().contains(o);
}
@@ -1441,9 +1389,8 @@
private static final long serialVersionUID = 0;
}
- private static class SynchronizedAsMapValues<V extends @Nullable Object>
- extends SynchronizedCollection<Collection<V>> {
- SynchronizedAsMapValues(Collection<Collection<V>> delegate, @CheckForNull Object mutex) {
+ private static class SynchronizedAsMapValues<V> extends SynchronizedCollection<Collection<V>> {
+ SynchronizedAsMapValues(Collection<Collection<V>> delegate, @Nullable Object mutex) {
super(delegate, mutex);
}
@@ -1463,9 +1410,9 @@
@GwtIncompatible // NavigableSet
@VisibleForTesting
- static class SynchronizedNavigableSet<E extends @Nullable Object> extends SynchronizedSortedSet<E>
+ static class SynchronizedNavigableSet<E> extends SynchronizedSortedSet<E>
implements NavigableSet<E> {
- SynchronizedNavigableSet(NavigableSet<E> delegate, @CheckForNull Object mutex) {
+ SynchronizedNavigableSet(NavigableSet<E> delegate, @Nullable Object mutex) {
super(delegate, mutex);
}
@@ -1475,7 +1422,6 @@
}
@Override
- @CheckForNull
public E ceiling(E e) {
synchronized (mutex) {
return delegate().ceiling(e);
@@ -1487,7 +1433,7 @@
return delegate().descendingIterator(); // manually synchronized
}
- @CheckForNull transient NavigableSet<E> descendingSet;
+ transient @Nullable NavigableSet<E> descendingSet;
@Override
public NavigableSet<E> descendingSet() {
@@ -1502,7 +1448,6 @@
}
@Override
- @CheckForNull
public E floor(E e) {
synchronized (mutex) {
return delegate().floor(e);
@@ -1522,7 +1467,6 @@
}
@Override
- @CheckForNull
public E higher(E e) {
synchronized (mutex) {
return delegate().higher(e);
@@ -1530,7 +1474,6 @@
}
@Override
- @CheckForNull
public E lower(E e) {
synchronized (mutex) {
return delegate().lower(e);
@@ -1538,7 +1481,6 @@
}
@Override
- @CheckForNull
public E pollFirst() {
synchronized (mutex) {
return delegate().pollFirst();
@@ -1546,7 +1488,6 @@
}
@Override
- @CheckForNull
public E pollLast() {
synchronized (mutex) {
return delegate().pollLast();
@@ -1583,34 +1524,32 @@
}
@GwtIncompatible // NavigableSet
- static <E extends @Nullable Object> NavigableSet<E> navigableSet(
- NavigableSet<E> navigableSet, @CheckForNull Object mutex) {
+ static <E> NavigableSet<E> navigableSet(NavigableSet<E> navigableSet, @Nullable Object mutex) {
return new SynchronizedNavigableSet<E>(navigableSet, mutex);
}
@GwtIncompatible // NavigableSet
- static <E extends @Nullable Object> NavigableSet<E> navigableSet(NavigableSet<E> navigableSet) {
+ static <E> NavigableSet<E> navigableSet(NavigableSet<E> navigableSet) {
return navigableSet(navigableSet, null);
}
@GwtIncompatible // NavigableMap
- static <K extends @Nullable Object, V extends @Nullable Object> NavigableMap<K, V> navigableMap(
- NavigableMap<K, V> navigableMap) {
+ static <K, V> NavigableMap<K, V> navigableMap(NavigableMap<K, V> navigableMap) {
return navigableMap(navigableMap, null);
}
@GwtIncompatible // NavigableMap
- static <K extends @Nullable Object, V extends @Nullable Object> NavigableMap<K, V> navigableMap(
- NavigableMap<K, V> navigableMap, @CheckForNull Object mutex) {
+ static <K, V> NavigableMap<K, V> navigableMap(
+ NavigableMap<K, V> navigableMap, @Nullable Object mutex) {
return new SynchronizedNavigableMap<>(navigableMap, mutex);
}
@GwtIncompatible // NavigableMap
@VisibleForTesting
- static class SynchronizedNavigableMap<K extends @Nullable Object, V extends @Nullable Object>
- extends SynchronizedSortedMap<K, V> implements NavigableMap<K, V> {
+ static class SynchronizedNavigableMap<K, V> extends SynchronizedSortedMap<K, V>
+ implements NavigableMap<K, V> {
- SynchronizedNavigableMap(NavigableMap<K, V> delegate, @CheckForNull Object mutex) {
+ SynchronizedNavigableMap(NavigableMap<K, V> delegate, @Nullable Object mutex) {
super(delegate, mutex);
}
@@ -1620,22 +1559,20 @@
}
@Override
- @CheckForNull
- public Map.Entry<K, V> ceilingEntry(K key) {
+ public Entry<K, V> ceilingEntry(K key) {
synchronized (mutex) {
return nullableSynchronizedEntry(delegate().ceilingEntry(key), mutex);
}
}
@Override
- @CheckForNull
public K ceilingKey(K key) {
synchronized (mutex) {
return delegate().ceilingKey(key);
}
}
- @CheckForNull transient NavigableSet<K> descendingKeySet;
+ transient @Nullable NavigableSet<K> descendingKeySet;
@Override
public NavigableSet<K> descendingKeySet() {
@@ -1647,7 +1584,7 @@
}
}
- @CheckForNull transient NavigableMap<K, V> descendingMap;
+ transient @Nullable NavigableMap<K, V> descendingMap;
@Override
public NavigableMap<K, V> descendingMap() {
@@ -1660,23 +1597,20 @@
}
@Override
- @CheckForNull
- public Map.Entry<K, V> firstEntry() {
+ public Entry<K, V> firstEntry() {
synchronized (mutex) {
return nullableSynchronizedEntry(delegate().firstEntry(), mutex);
}
}
@Override
- @CheckForNull
- public Map.Entry<K, V> floorEntry(K key) {
+ public Entry<K, V> floorEntry(K key) {
synchronized (mutex) {
return nullableSynchronizedEntry(delegate().floorEntry(key), mutex);
}
}
@Override
- @CheckForNull
public K floorKey(K key) {
synchronized (mutex) {
return delegate().floorKey(key);
@@ -1696,15 +1630,13 @@
}
@Override
- @CheckForNull
- public Map.Entry<K, V> higherEntry(K key) {
+ public Entry<K, V> higherEntry(K key) {
synchronized (mutex) {
return nullableSynchronizedEntry(delegate().higherEntry(key), mutex);
}
}
@Override
- @CheckForNull
public K higherKey(K key) {
synchronized (mutex) {
return delegate().higherKey(key);
@@ -1712,23 +1644,20 @@
}
@Override
- @CheckForNull
- public Map.Entry<K, V> lastEntry() {
+ public Entry<K, V> lastEntry() {
synchronized (mutex) {
return nullableSynchronizedEntry(delegate().lastEntry(), mutex);
}
}
@Override
- @CheckForNull
- public Map.Entry<K, V> lowerEntry(K key) {
+ public Entry<K, V> lowerEntry(K key) {
synchronized (mutex) {
return nullableSynchronizedEntry(delegate().lowerEntry(key), mutex);
}
}
@Override
- @CheckForNull
public K lowerKey(K key) {
synchronized (mutex) {
return delegate().lowerKey(key);
@@ -1740,7 +1669,7 @@
return navigableKeySet();
}
- @CheckForNull transient NavigableSet<K> navigableKeySet;
+ transient @Nullable NavigableSet<K> navigableKeySet;
@Override
public NavigableSet<K> navigableKeySet() {
@@ -1753,16 +1682,14 @@
}
@Override
- @CheckForNull
- public Map.Entry<K, V> pollFirstEntry() {
+ public Entry<K, V> pollFirstEntry() {
synchronized (mutex) {
return nullableSynchronizedEntry(delegate().pollFirstEntry(), mutex);
}
}
@Override
- @CheckForNull
- public Map.Entry<K, V> pollLastEntry() {
+ public Entry<K, V> pollLastEntry() {
synchronized (mutex) {
return nullableSynchronizedEntry(delegate().pollLastEntry(), mutex);
}
@@ -1797,10 +1724,8 @@
}
@GwtIncompatible // works but is needed only for NavigableMap
- @CheckForNull
- private static <K extends @Nullable Object, V extends @Nullable Object>
- Map.Entry<K, V> nullableSynchronizedEntry(
- @CheckForNull Map.Entry<K, V> entry, @CheckForNull Object mutex) {
+ private static <K, V> Entry<K, V> nullableSynchronizedEntry(
+ @Nullable Entry<K, V> entry, @Nullable Object mutex) {
if (entry == null) {
return null;
}
@@ -1808,21 +1733,20 @@
}
@GwtIncompatible // works but is needed only for NavigableMap
- private static class SynchronizedEntry<K extends @Nullable Object, V extends @Nullable Object>
- extends SynchronizedObject implements Map.Entry<K, V> {
+ private static class SynchronizedEntry<K, V> extends SynchronizedObject implements Entry<K, V> {
- SynchronizedEntry(Map.Entry<K, V> delegate, @CheckForNull Object mutex) {
+ SynchronizedEntry(Entry<K, V> delegate, @Nullable Object mutex) {
super(delegate, mutex);
}
@SuppressWarnings("unchecked") // guaranteed by the constructor
@Override
- Map.Entry<K, V> delegate() {
- return (Map.Entry<K, V>) super.delegate();
+ Entry<K, V> delegate() {
+ return (Entry<K, V>) super.delegate();
}
@Override
- public boolean equals(@CheckForNull Object obj) {
+ public boolean equals(Object obj) {
synchronized (mutex) {
return delegate().equals(obj);
}
@@ -1859,14 +1783,13 @@
private static final long serialVersionUID = 0;
}
- static <E extends @Nullable Object> Queue<E> queue(Queue<E> queue, @CheckForNull Object mutex) {
+ static <E> Queue<E> queue(Queue<E> queue, @Nullable Object mutex) {
return (queue instanceof SynchronizedQueue) ? queue : new SynchronizedQueue<E>(queue, mutex);
}
- private static class SynchronizedQueue<E extends @Nullable Object>
- extends SynchronizedCollection<E> implements Queue<E> {
+ private static class SynchronizedQueue<E> extends SynchronizedCollection<E> implements Queue<E> {
- SynchronizedQueue(Queue<E> delegate, @CheckForNull Object mutex) {
+ SynchronizedQueue(Queue<E> delegate, @Nullable Object mutex) {
super(delegate, mutex);
}
@@ -1890,7 +1813,6 @@
}
@Override
- @CheckForNull
public E peek() {
synchronized (mutex) {
return delegate().peek();
@@ -1898,7 +1820,6 @@
}
@Override
- @CheckForNull
public E poll() {
synchronized (mutex) {
return delegate().poll();
@@ -1915,14 +1836,13 @@
private static final long serialVersionUID = 0;
}
- static <E extends @Nullable Object> Deque<E> deque(Deque<E> deque, @CheckForNull Object mutex) {
+ static <E> Deque<E> deque(Deque<E> deque, @Nullable Object mutex) {
return new SynchronizedDeque<E>(deque, mutex);
}
- private static final class SynchronizedDeque<E extends @Nullable Object>
- extends SynchronizedQueue<E> implements Deque<E> {
+ private static final class SynchronizedDeque<E> extends SynchronizedQueue<E> implements Deque<E> {
- SynchronizedDeque(Deque<E> delegate, @CheckForNull Object mutex) {
+ SynchronizedDeque(Deque<E> delegate, @Nullable Object mutex) {
super(delegate, mutex);
}
@@ -1974,7 +1894,6 @@
}
@Override
- @CheckForNull
public E pollFirst() {
synchronized (mutex) {
return delegate().pollFirst();
@@ -1982,7 +1901,6 @@
}
@Override
- @CheckForNull
public E pollLast() {
synchronized (mutex) {
return delegate().pollLast();
@@ -2004,7 +1922,6 @@
}
@Override
- @CheckForNull
public E peekFirst() {
synchronized (mutex) {
return delegate().peekFirst();
@@ -2012,7 +1929,6 @@
}
@Override
- @CheckForNull
public E peekLast() {
synchronized (mutex) {
return delegate().peekLast();
@@ -2020,14 +1936,14 @@
}
@Override
- public boolean removeFirstOccurrence(@CheckForNull Object o) {
+ public boolean removeFirstOccurrence(Object o) {
synchronized (mutex) {
return delegate().removeFirstOccurrence(o);
}
}
@Override
- public boolean removeLastOccurrence(@CheckForNull Object o) {
+ public boolean removeLastOccurrence(Object o) {
synchronized (mutex) {
return delegate().removeLastOccurrence(o);
}
@@ -2057,16 +1973,14 @@
private static final long serialVersionUID = 0;
}
- static <R extends @Nullable Object, C extends @Nullable Object, V extends @Nullable Object>
- Table<R, C, V> table(Table<R, C, V> table, @CheckForNull Object mutex) {
+ static <R, C, V> Table<R, C, V> table(Table<R, C, V> table, Object mutex) {
return new SynchronizedTable<>(table, mutex);
}
- private static final class SynchronizedTable<
- R extends @Nullable Object, C extends @Nullable Object, V extends @Nullable Object>
- extends SynchronizedObject implements Table<R, C, V> {
+ private static final class SynchronizedTable<R, C, V> extends SynchronizedObject
+ implements Table<R, C, V> {
- SynchronizedTable(Table<R, C, V> delegate, @CheckForNull Object mutex) {
+ SynchronizedTable(Table<R, C, V> delegate, Object mutex) {
super(delegate, mutex);
}
@@ -2077,36 +1991,35 @@
}
@Override
- public boolean contains(@CheckForNull Object rowKey, @CheckForNull Object columnKey) {
+ public boolean contains(@Nullable Object rowKey, @Nullable Object columnKey) {
synchronized (mutex) {
return delegate().contains(rowKey, columnKey);
}
}
@Override
- public boolean containsRow(@CheckForNull Object rowKey) {
+ public boolean containsRow(@Nullable Object rowKey) {
synchronized (mutex) {
return delegate().containsRow(rowKey);
}
}
@Override
- public boolean containsColumn(@CheckForNull Object columnKey) {
+ public boolean containsColumn(@Nullable Object columnKey) {
synchronized (mutex) {
return delegate().containsColumn(columnKey);
}
}
@Override
- public boolean containsValue(@CheckForNull Object value) {
+ public boolean containsValue(@Nullable Object value) {
synchronized (mutex) {
return delegate().containsValue(value);
}
}
@Override
- @CheckForNull
- public V get(@CheckForNull Object rowKey, @CheckForNull Object columnKey) {
+ public V get(@Nullable Object rowKey, @Nullable Object columnKey) {
synchronized (mutex) {
return delegate().get(rowKey, columnKey);
}
@@ -2134,8 +2047,7 @@
}
@Override
- @CheckForNull
- public V put(R rowKey, C columnKey, V value) {
+ public V put(@Nullable R rowKey, @Nullable C columnKey, @Nullable V value) {
synchronized (mutex) {
return delegate().put(rowKey, columnKey, value);
}
@@ -2149,22 +2061,21 @@
}
@Override
- @CheckForNull
- public V remove(@CheckForNull Object rowKey, @CheckForNull Object columnKey) {
+ public V remove(@Nullable Object rowKey, @Nullable Object columnKey) {
synchronized (mutex) {
return delegate().remove(rowKey, columnKey);
}
}
@Override
- public Map<C, V> row(R rowKey) {
+ public Map<C, V> row(@Nullable R rowKey) {
synchronized (mutex) {
return map(delegate().row(rowKey), mutex);
}
}
@Override
- public Map<R, V> column(C columnKey) {
+ public Map<R, V> column(@Nullable C columnKey) {
synchronized (mutex) {
return map(delegate().column(columnKey), mutex);
}
@@ -2238,7 +2149,7 @@
}
@Override
- public boolean equals(@CheckForNull 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 97d3f70..136ec17 100644
--- a/guava/src/com/google/common/collect/Table.java
+++ b/guava/src/com/google/common/collect/Table.java
@@ -24,7 +24,6 @@
import java.util.Collection;
import java.util.Map;
import java.util.Set;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -56,9 +55,7 @@
*/
@DoNotMock("Use ImmutableTable, HashBasedTable, or another implementation")
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-public interface Table<
- R extends @Nullable Object, C extends @Nullable Object, V extends @Nullable Object> {
+public interface Table<R, C, V> {
// TODO(jlevy): Consider adding methods similar to ConcurrentMap methods.
// Accessors
@@ -70,29 +67,29 @@
* @param columnKey key of column to search for
*/
boolean contains(
- @CompatibleWith("R") @CheckForNull Object rowKey,
- @CompatibleWith("C") @CheckForNull 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(@CompatibleWith("R") @CheckForNull 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(@CompatibleWith("C") @CheckForNull 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(@CompatibleWith("V") @CheckForNull 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
@@ -101,10 +98,10 @@
* @param rowKey key of row to search for
* @param columnKey key of column to search for
*/
- @CheckForNull
+ @Nullable
V get(
- @CompatibleWith("R") @CheckForNull Object rowKey,
- @CompatibleWith("C") @CheckForNull Object columnKey);
+ @Nullable @CompatibleWith("R") Object rowKey,
+ @Nullable @CompatibleWith("C") Object columnKey);
/** Returns {@code true} if the table contains no mappings. */
boolean isEmpty();
@@ -117,7 +114,7 @@
* cell views, as returned by {@link #cellSet}, are equal.
*/
@Override
- boolean equals(@CheckForNull 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
@@ -142,8 +139,8 @@
* for the keys
*/
@CanIgnoreReturnValue
- @CheckForNull
- V put(@ParametricNullness R rowKey, @ParametricNullness C columnKey, @ParametricNullness V value);
+ @Nullable
+ V put(R rowKey, C columnKey, V value);
/**
* Copies all mappings from the specified table to this table. The effect is equivalent to calling
@@ -161,10 +158,10 @@
* @return the value previously associated with the keys, or {@code null} if no such value existed
*/
@CanIgnoreReturnValue
- @CheckForNull
+ @Nullable
V remove(
- @CompatibleWith("R") @CheckForNull Object rowKey,
- @CompatibleWith("C") @CheckForNull Object columnKey);
+ @Nullable @CompatibleWith("R") Object rowKey,
+ @Nullable @CompatibleWith("C") Object columnKey);
// Views
@@ -178,7 +175,7 @@
* @param rowKey key of row to search for in the table
* @return the corresponding map from column keys to values
*/
- Map<C, V> row(@ParametricNullness R rowKey);
+ Map<C, V> row(R rowKey);
/**
* Returns a view of all mappings that have the given column key. For each row key / column key /
@@ -190,7 +187,7 @@
* @param columnKey key of column to search for in the table
* @return the corresponding map from row keys to values
*/
- Map<R, V> column(@ParametricNullness C columnKey);
+ Map<R, V> column(C columnKey);
/**
* Returns a set of all row key / column key / value triplets. Changes to the returned set will
@@ -256,18 +253,17 @@
*
* @since 7.0
*/
- interface Cell<
- R extends @Nullable Object, C extends @Nullable Object, V extends @Nullable Object> {
+ interface Cell<R, C, V> {
/** Returns the row key of this cell. */
- @ParametricNullness
+ @Nullable
R getRowKey();
/** Returns the column key of this cell. */
- @ParametricNullness
+ @Nullable
C getColumnKey();
/** Returns the value of this cell. */
- @ParametricNullness
+ @Nullable
V getValue();
/**
@@ -275,7 +271,7 @@
* equal row keys, column keys, and values.
*/
@Override
- boolean equals(@CheckForNull Object obj);
+ boolean equals(@Nullable Object obj);
/**
* Returns the hash code of this cell.
diff --git a/guava/src/com/google/common/collect/TableCollectors.java b/guava/src/com/google/common/collect/TableCollectors.java
deleted file mode 100644
index 99ab810..0000000
--- a/guava/src/com/google/common/collect/TableCollectors.java
+++ /dev/null
@@ -1,222 +0,0 @@
-/*
- * Copyright (C) 2009 The Guava Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.common.collect;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import com.google.common.annotations.GwtCompatible;
-import com.google.common.collect.Tables.AbstractCell;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.function.BinaryOperator;
-import java.util.function.Function;
-import java.util.function.Supplier;
-import java.util.stream.Collector;
-import org.checkerframework.checker.nullness.qual.Nullable;
-
-/** Collectors utilities for {@code common.collect.Table} internals. */
-@GwtCompatible
-@ElementTypesAreNonnullByDefault
-final class TableCollectors {
-
- static <T extends @Nullable Object, R, C, V>
- Collector<T, ?, ImmutableTable<R, C, V>> toImmutableTable(
- Function<? super T, ? extends R> rowFunction,
- Function<? super T, ? extends C> columnFunction,
- Function<? super T, ? extends V> valueFunction) {
- checkNotNull(rowFunction, "rowFunction");
- checkNotNull(columnFunction, "columnFunction");
- checkNotNull(valueFunction, "valueFunction");
- return Collector.of(
- (Supplier<ImmutableTable.Builder<R, C, V>>) ImmutableTable.Builder::new,
- (builder, t) ->
- builder.put(rowFunction.apply(t), columnFunction.apply(t), valueFunction.apply(t)),
- ImmutableTable.Builder::combine,
- ImmutableTable.Builder::build);
- }
-
- static <T extends @Nullable Object, R, C, V>
- Collector<T, ?, ImmutableTable<R, C, V>> toImmutableTable(
- Function<? super T, ? extends R> rowFunction,
- Function<? super T, ? extends C> columnFunction,
- Function<? super T, ? extends V> valueFunction,
- BinaryOperator<V> mergeFunction) {
-
- checkNotNull(rowFunction, "rowFunction");
- checkNotNull(columnFunction, "columnFunction");
- checkNotNull(valueFunction, "valueFunction");
- checkNotNull(mergeFunction, "mergeFunction");
-
- /*
- * No mutable Table exactly matches the insertion order behavior of ImmutableTable.Builder, but
- * the Builder can't efficiently support merging of duplicate values. Getting around this
- * requires some work.
- */
-
- return Collector.of(
- () -> new ImmutableTableCollectorState<R, C, V>()
- /* GWT isn't currently playing nicely with constructor references? */ ,
- (state, input) ->
- state.put(
- rowFunction.apply(input),
- columnFunction.apply(input),
- valueFunction.apply(input),
- mergeFunction),
- (s1, s2) -> s1.combine(s2, mergeFunction),
- state -> state.toTable());
- }
-
- static <
- T extends @Nullable Object,
- R extends @Nullable Object,
- C extends @Nullable Object,
- V extends @Nullable Object,
- I extends Table<R, C, V>>
- Collector<T, ?, I> toTable(
- java.util.function.Function<? super T, ? extends R> rowFunction,
- java.util.function.Function<? super T, ? extends C> columnFunction,
- java.util.function.Function<? super T, ? extends V> valueFunction,
- java.util.function.Supplier<I> tableSupplier) {
- return toTable(
- rowFunction,
- columnFunction,
- valueFunction,
- (v1, v2) -> {
- throw new IllegalStateException("Conflicting values " + v1 + " and " + v2);
- },
- tableSupplier);
- }
-
- static <
- T extends @Nullable Object,
- R extends @Nullable Object,
- C extends @Nullable Object,
- V extends @Nullable Object,
- I extends Table<R, C, V>>
- Collector<T, ?, I> toTable(
- java.util.function.Function<? super T, ? extends R> rowFunction,
- java.util.function.Function<? super T, ? extends C> columnFunction,
- java.util.function.Function<? super T, ? extends V> valueFunction,
- BinaryOperator<V> mergeFunction,
- java.util.function.Supplier<I> tableSupplier) {
- checkNotNull(rowFunction);
- checkNotNull(columnFunction);
- checkNotNull(valueFunction);
- checkNotNull(mergeFunction);
- checkNotNull(tableSupplier);
- return Collector.of(
- tableSupplier,
- (table, input) ->
- mergeTables(
- table,
- rowFunction.apply(input),
- columnFunction.apply(input),
- valueFunction.apply(input),
- mergeFunction),
- (table1, table2) -> {
- for (Table.Cell<R, C, V> cell2 : table2.cellSet()) {
- mergeTables(
- table1, cell2.getRowKey(), cell2.getColumnKey(), cell2.getValue(), mergeFunction);
- }
- return table1;
- });
- }
-
- private static final class ImmutableTableCollectorState<R, C, V> {
- final List<MutableCell<R, C, V>> insertionOrder = new ArrayList<>();
- final Table<R, C, MutableCell<R, C, V>> table = HashBasedTable.create();
-
- void put(R row, C column, V value, BinaryOperator<V> merger) {
- MutableCell<R, C, V> oldCell = table.get(row, column);
- if (oldCell == null) {
- MutableCell<R, C, V> cell = new MutableCell<>(row, column, value);
- insertionOrder.add(cell);
- table.put(row, column, cell);
- } else {
- oldCell.merge(value, merger);
- }
- }
-
- ImmutableTableCollectorState<R, C, V> combine(
- ImmutableTableCollectorState<R, C, V> other, BinaryOperator<V> merger) {
- for (MutableCell<R, C, V> cell : other.insertionOrder) {
- put(cell.getRowKey(), cell.getColumnKey(), cell.getValue(), merger);
- }
- return this;
- }
-
- ImmutableTable<R, C, V> toTable() {
- return ImmutableTable.copyOf(insertionOrder);
- }
- }
-
- private static final class MutableCell<R, C, V> extends AbstractCell<R, C, V> {
- private final R row;
- private final C column;
- private V value;
-
- MutableCell(R row, C column, V value) {
- this.row = checkNotNull(row, "row");
- this.column = checkNotNull(column, "column");
- this.value = checkNotNull(value, "value");
- }
-
- @Override
- public R getRowKey() {
- return row;
- }
-
- @Override
- public C getColumnKey() {
- return column;
- }
-
- @Override
- public V getValue() {
- return value;
- }
-
- void merge(V value, BinaryOperator<V> mergeFunction) {
- checkNotNull(value, "value");
- this.value = checkNotNull(mergeFunction.apply(this.value, value), "mergeFunction.apply");
- }
- }
-
- private static <
- R extends @Nullable Object, C extends @Nullable Object, V extends @Nullable Object>
- void mergeTables(
- Table<R, C, V> table,
- @ParametricNullness R row,
- @ParametricNullness C column,
- @ParametricNullness V value,
- BinaryOperator<V> mergeFunction) {
- checkNotNull(value);
- V oldValue = table.get(row, column);
- if (oldValue == null) {
- table.put(row, column, value);
- } else {
- V newValue = mergeFunction.apply(oldValue, value);
- if (newValue == null) {
- table.remove(row, column);
- } else {
- table.put(row, column, newValue);
- }
- }
- }
-
- private TableCollectors() {}
-}
diff --git a/guava/src/com/google/common/collect/Tables.java b/guava/src/com/google/common/collect/Tables.java
index 2d743f0..fc913ec 100644
--- a/guava/src/com/google/common/collect/Tables.java
+++ b/guava/src/com/google/common/collect/Tables.java
@@ -18,7 +18,6 @@
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.collect.NullnessCasts.uncheckedCastNullableTToT;
import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtCompatible;
@@ -37,7 +36,6 @@
import java.util.Spliterator;
import java.util.function.BinaryOperator;
import java.util.stream.Collector;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -51,7 +49,6 @@
* @since 7.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
public final class Tables {
private Tables() {}
@@ -63,23 +60,22 @@
* <p>If multiple input elements map to the same row and column, an {@code IllegalStateException}
* is thrown when the collection operation is performed.
*
- * <p>To collect to an {@link ImmutableTable}, use {@link ImmutableTable#toImmutableTable}.
- *
* @since 21.0
*/
@Beta
- public static <
- T extends @Nullable Object,
- R extends @Nullable Object,
- C extends @Nullable Object,
- V extends @Nullable Object,
- I extends Table<R, C, V>>
- Collector<T, ?, I> toTable(
- java.util.function.Function<? super T, ? extends R> rowFunction,
- java.util.function.Function<? super T, ? extends C> columnFunction,
- java.util.function.Function<? super T, ? extends V> valueFunction,
- java.util.function.Supplier<I> tableSupplier) {
- return TableCollectors.toTable(rowFunction, columnFunction, valueFunction, tableSupplier);
+ public static <T, R, C, V, I extends Table<R, C, V>> Collector<T, ?, I> toTable(
+ java.util.function.Function<? super T, ? extends R> rowFunction,
+ java.util.function.Function<? super T, ? extends C> columnFunction,
+ java.util.function.Function<? super T, ? extends V> valueFunction,
+ java.util.function.Supplier<I> tableSupplier) {
+ return toTable(
+ rowFunction,
+ columnFunction,
+ valueFunction,
+ (v1, v2) -> {
+ throw new IllegalStateException("Conflicting values " + v1 + " and " + v2);
+ },
+ tableSupplier);
}
/**
@@ -96,20 +92,48 @@
*
* @since 21.0
*/
- public static <
- T extends @Nullable Object,
- R extends @Nullable Object,
- C extends @Nullable Object,
- V extends @Nullable Object,
- I extends Table<R, C, V>>
- Collector<T, ?, I> toTable(
- java.util.function.Function<? super T, ? extends R> rowFunction,
- java.util.function.Function<? super T, ? extends C> columnFunction,
- java.util.function.Function<? super T, ? extends V> valueFunction,
- BinaryOperator<V> mergeFunction,
- java.util.function.Supplier<I> tableSupplier) {
- return TableCollectors.toTable(
- rowFunction, columnFunction, valueFunction, mergeFunction, tableSupplier);
+ public static <T, R, C, V, I extends Table<R, C, V>> Collector<T, ?, I> toTable(
+ java.util.function.Function<? super T, ? extends R> rowFunction,
+ java.util.function.Function<? super T, ? extends C> columnFunction,
+ java.util.function.Function<? super T, ? extends V> valueFunction,
+ BinaryOperator<V> mergeFunction,
+ java.util.function.Supplier<I> tableSupplier) {
+ checkNotNull(rowFunction);
+ checkNotNull(columnFunction);
+ checkNotNull(valueFunction);
+ checkNotNull(mergeFunction);
+ checkNotNull(tableSupplier);
+ return Collector.of(
+ tableSupplier,
+ (table, input) ->
+ merge(
+ table,
+ rowFunction.apply(input),
+ columnFunction.apply(input),
+ valueFunction.apply(input),
+ mergeFunction),
+ (table1, table2) -> {
+ for (Table.Cell<R, C, V> cell2 : table2.cellSet()) {
+ merge(table1, cell2.getRowKey(), cell2.getColumnKey(), cell2.getValue(), mergeFunction);
+ }
+ return table1;
+ });
+ }
+
+ private static <R, C, V> void merge(
+ Table<R, C, V> table, R row, C column, V value, BinaryOperator<V> mergeFunction) {
+ checkNotNull(value);
+ V oldValue = table.get(row, column);
+ if (oldValue == null) {
+ table.put(row, column, value);
+ } else {
+ V newValue = mergeFunction.apply(oldValue, value);
+ if (newValue == null) {
+ table.remove(row, column);
+ } else {
+ table.put(row, column, newValue);
+ }
+ }
}
/**
@@ -121,44 +145,33 @@
* @param columnKey the column key to be associated with the returned cell
* @param value the value to be associated with the returned cell
*/
- public static <R extends @Nullable Object, C extends @Nullable Object, V extends @Nullable Object>
- Cell<R, C, V> immutableCell(
- @ParametricNullness R rowKey,
- @ParametricNullness C columnKey,
- @ParametricNullness V value) {
+ public static <R, C, V> Cell<R, C, V> immutableCell(
+ @Nullable R rowKey, @Nullable C columnKey, @Nullable V value) {
return new ImmutableCell<>(rowKey, columnKey, value);
}
- static final class ImmutableCell<
- R extends @Nullable Object, C extends @Nullable Object, V extends @Nullable Object>
- extends AbstractCell<R, C, V> implements Serializable {
- @ParametricNullness private final R rowKey;
- @ParametricNullness private final C columnKey;
- @ParametricNullness private final V value;
+ static final class ImmutableCell<R, C, V> extends AbstractCell<R, C, V> implements Serializable {
+ private final @Nullable R rowKey;
+ private final @Nullable C columnKey;
+ private final @Nullable V value;
- ImmutableCell(
- @ParametricNullness R rowKey,
- @ParametricNullness C columnKey,
- @ParametricNullness V value) {
+ ImmutableCell(@Nullable R rowKey, @Nullable C columnKey, @Nullable V value) {
this.rowKey = rowKey;
this.columnKey = columnKey;
this.value = value;
}
@Override
- @ParametricNullness
public R getRowKey() {
return rowKey;
}
@Override
- @ParametricNullness
public C getColumnKey() {
return columnKey;
}
@Override
- @ParametricNullness
public V getValue() {
return value;
}
@@ -166,14 +179,12 @@
private static final long serialVersionUID = 0;
}
- abstract static class AbstractCell<
- R extends @Nullable Object, C extends @Nullable Object, V extends @Nullable Object>
- implements Cell<R, C, V> {
+ abstract static class AbstractCell<R, C, V> implements Cell<R, C, V> {
// needed for serialization
AbstractCell() {}
@Override
- public boolean equals(@CheckForNull Object obj) {
+ public boolean equals(Object obj) {
if (obj == this) {
return true;
}
@@ -209,16 +220,13 @@
* columnKeySet().iterator()} doesn't. With a transposed {@link HashBasedTable}, it's the other
* way around.
*/
- public static <R extends @Nullable Object, C extends @Nullable Object, V extends @Nullable Object>
- Table<C, R, V> transpose(Table<R, C, V> table) {
+ public static <R, C, V> Table<C, R, V> transpose(Table<R, C, V> table) {
return (table instanceof TransposeTable)
? ((TransposeTable<R, C, V>) table).original
: new TransposeTable<C, R, V>(table);
}
- private static class TransposeTable<
- C extends @Nullable Object, R extends @Nullable Object, V extends @Nullable Object>
- extends AbstractTable<C, R, V> {
+ private static class TransposeTable<C, R, V> extends AbstractTable<C, R, V> {
final Table<R, C, V> original;
TransposeTable(Table<R, C, V> original) {
@@ -231,7 +239,7 @@
}
@Override
- public Map<C, V> column(@ParametricNullness R columnKey) {
+ public Map<C, V> column(R columnKey) {
return original.row(columnKey);
}
@@ -246,37 +254,32 @@
}
@Override
- public boolean contains(@CheckForNull Object rowKey, @CheckForNull Object columnKey) {
+ public boolean contains(@Nullable Object rowKey, @Nullable Object columnKey) {
return original.contains(columnKey, rowKey);
}
@Override
- public boolean containsColumn(@CheckForNull Object columnKey) {
+ public boolean containsColumn(@Nullable Object columnKey) {
return original.containsRow(columnKey);
}
@Override
- public boolean containsRow(@CheckForNull Object rowKey) {
+ public boolean containsRow(@Nullable Object rowKey) {
return original.containsColumn(rowKey);
}
@Override
- public boolean containsValue(@CheckForNull Object value) {
+ public boolean containsValue(@Nullable Object value) {
return original.containsValue(value);
}
@Override
- @CheckForNull
- public V get(@CheckForNull Object rowKey, @CheckForNull Object columnKey) {
+ public V get(@Nullable Object rowKey, @Nullable Object columnKey) {
return original.get(columnKey, rowKey);
}
@Override
- @CheckForNull
- public V put(
- @ParametricNullness C rowKey,
- @ParametricNullness R columnKey,
- @ParametricNullness V value) {
+ public V put(C rowKey, R columnKey, V value) {
return original.put(columnKey, rowKey, value);
}
@@ -286,13 +289,12 @@
}
@Override
- @CheckForNull
- public V remove(@CheckForNull Object rowKey, @CheckForNull Object columnKey) {
+ public V remove(@Nullable Object rowKey, @Nullable Object columnKey) {
return original.remove(columnKey, rowKey);
}
@Override
- public Map<R, V> row(@ParametricNullness C rowKey) {
+ public Map<R, V> row(C rowKey) {
return original.column(rowKey);
}
@@ -407,22 +409,12 @@
* @since 10.0
*/
@Beta
- public static <
- R extends @Nullable Object,
- C extends @Nullable Object,
- V1 extends @Nullable Object,
- V2 extends @Nullable Object>
- Table<R, C, V2> transformValues(
- Table<R, C, V1> fromTable, Function<? super V1, V2> function) {
+ public static <R, C, V1, V2> Table<R, C, V2> transformValues(
+ Table<R, C, V1> fromTable, Function<? super V1, V2> function) {
return new TransformedTable<>(fromTable, function);
}
- private static class TransformedTable<
- R extends @Nullable Object,
- C extends @Nullable Object,
- V1 extends @Nullable Object,
- V2 extends @Nullable Object>
- extends AbstractTable<R, C, V2> {
+ private static class TransformedTable<R, C, V1, V2> extends AbstractTable<R, C, V2> {
final Table<R, C, V1> fromTable;
final Function<? super V1, V2> function;
@@ -432,19 +424,15 @@
}
@Override
- public boolean contains(@CheckForNull Object rowKey, @CheckForNull Object columnKey) {
+ public boolean contains(Object rowKey, Object columnKey) {
return fromTable.contains(rowKey, columnKey);
}
@Override
- @CheckForNull
- public V2 get(@CheckForNull Object rowKey, @CheckForNull Object columnKey) {
+ public V2 get(Object rowKey, Object columnKey) {
// The function is passed a null input only when the table contains a null
// value.
- // The cast is safe because of the contains() check.
- return contains(rowKey, columnKey)
- ? function.apply(uncheckedCastNullableTToT(fromTable.get(rowKey, columnKey)))
- : null;
+ return contains(rowKey, columnKey) ? function.apply(fromTable.get(rowKey, columnKey)) : null;
}
@Override
@@ -458,11 +446,7 @@
}
@Override
- @CheckForNull
- public V2 put(
- @ParametricNullness R rowKey,
- @ParametricNullness C columnKey,
- @ParametricNullness V2 value) {
+ public V2 put(R rowKey, C columnKey, V2 value) {
throw new UnsupportedOperationException();
}
@@ -472,21 +456,19 @@
}
@Override
- @CheckForNull
- public V2 remove(@CheckForNull Object rowKey, @CheckForNull Object columnKey) {
+ public V2 remove(Object rowKey, Object columnKey) {
return contains(rowKey, columnKey)
- // The cast is safe because of the contains() check.
- ? function.apply(uncheckedCastNullableTToT(fromTable.remove(rowKey, columnKey)))
+ ? function.apply(fromTable.remove(rowKey, columnKey))
: null;
}
@Override
- public Map<C, V2> row(@ParametricNullness R rowKey) {
+ public Map<C, V2> row(R rowKey) {
return Maps.transformValues(fromTable.row(rowKey), function);
}
@Override
- public Map<R, V2> column(@ParametricNullness C columnKey) {
+ public Map<R, V2> column(C columnKey) {
return Maps.transformValues(fromTable.column(columnKey), function);
}
@@ -562,14 +544,13 @@
*
* @since 11.0
*/
- public static <R extends @Nullable Object, C extends @Nullable Object, V extends @Nullable Object>
- Table<R, C, V> unmodifiableTable(Table<? extends R, ? extends C, ? extends V> table) {
+ public static <R, C, V> Table<R, C, V> unmodifiableTable(
+ Table<? extends R, ? extends C, ? extends V> table) {
return new UnmodifiableTable<>(table);
}
- private static class UnmodifiableTable<
- R extends @Nullable Object, C extends @Nullable Object, V extends @Nullable Object>
- extends ForwardingTable<R, C, V> implements Serializable {
+ private static class UnmodifiableTable<R, C, V> extends ForwardingTable<R, C, V>
+ implements Serializable {
final Table<? extends R, ? extends C, ? extends V> delegate;
UnmodifiableTable(Table<? extends R, ? extends C, ? extends V> delegate) {
@@ -593,7 +574,7 @@
}
@Override
- public Map<R, V> column(@ParametricNullness C columnKey) {
+ public Map<R, V> column(@Nullable C columnKey) {
return Collections.unmodifiableMap(super.column(columnKey));
}
@@ -609,11 +590,7 @@
}
@Override
- @CheckForNull
- public V put(
- @ParametricNullness R rowKey,
- @ParametricNullness C columnKey,
- @ParametricNullness V value) {
+ public V put(@Nullable R rowKey, @Nullable C columnKey, @Nullable V value) {
throw new UnsupportedOperationException();
}
@@ -623,13 +600,12 @@
}
@Override
- @CheckForNull
- public V remove(@CheckForNull Object rowKey, @CheckForNull Object columnKey) {
+ public V remove(@Nullable Object rowKey, @Nullable Object columnKey) {
throw new UnsupportedOperationException();
}
@Override
- public Map<C, V> row(@ParametricNullness R rowKey) {
+ public Map<C, V> row(@Nullable R rowKey) {
return Collections.unmodifiableMap(super.row(rowKey));
}
@@ -665,9 +641,8 @@
* @since 11.0
*/
@Beta
- public static <R extends @Nullable Object, C extends @Nullable Object, V extends @Nullable Object>
- RowSortedTable<R, C, V> unmodifiableRowSortedTable(
- RowSortedTable<R, ? extends C, ? extends V> table) {
+ public static <R, C, V> RowSortedTable<R, C, V> unmodifiableRowSortedTable(
+ RowSortedTable<R, ? extends C, ? extends V> table) {
/*
* It's not ? extends R, because it's technically not covariant in R. Specifically,
* table.rowMap().comparator() could return a comparator that only works for the ? extends R.
@@ -676,9 +651,8 @@
return new UnmodifiableRowSortedMap<>(table);
}
- static final class UnmodifiableRowSortedMap<
- R extends @Nullable Object, C extends @Nullable Object, V extends @Nullable Object>
- extends UnmodifiableTable<R, C, V> implements RowSortedTable<R, C, V> {
+ static final class UnmodifiableRowSortedMap<R, C, V> extends UnmodifiableTable<R, C, V>
+ implements RowSortedTable<R, C, V> {
public UnmodifiableRowSortedMap(RowSortedTable<R, ? extends C, ? extends V> delegate) {
super(delegate);
@@ -704,8 +678,7 @@
}
@SuppressWarnings("unchecked")
- private static <K extends @Nullable Object, V extends @Nullable Object>
- Function<Map<K, V>, Map<K, V>> unmodifiableWrapper() {
+ private static <K, V> Function<Map<K, V>, Map<K, V>> unmodifiableWrapper() {
return (Function) UNMODIFIABLE_WRAPPER;
}
@@ -746,12 +719,11 @@
* @return a synchronized view of the specified table
* @since 22.0
*/
- public static <R extends @Nullable Object, C extends @Nullable Object, V extends @Nullable Object>
- Table<R, C, V> synchronizedTable(Table<R, C, V> table) {
+ public static <R, C, V> Table<R, C, V> synchronizedTable(Table<R, C, V> table) {
return Synchronized.table(table, null);
}
- static boolean equalsImpl(Table<?, ?, ?> table, @CheckForNull 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 8411fcd..09f38aa 100644
--- a/guava/src/com/google/common/collect/TopKSelector.java
+++ b/guava/src/com/google/common/collect/TopKSelector.java
@@ -18,7 +18,6 @@
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.collect.NullnessCasts.uncheckedCastNullableTToT;
import com.google.common.annotations.GwtCompatible;
import com.google.common.math.IntMath;
@@ -29,7 +28,6 @@
import java.util.Iterator;
import java.util.List;
import java.util.stream.Stream;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -53,10 +51,7 @@
*
* @author Louis Wasserman
*/
-@GwtCompatible
-@ElementTypesAreNonnullByDefault
-final class TopKSelector<
- T extends @Nullable Object> {
+@GwtCompatible final class TopKSelector<T> {
/**
* Returns a {@code TopKSelector} that collects the lowest {@code k} elements added to it,
@@ -75,8 +70,7 @@
*
* @throws IllegalArgumentException if {@code k < 0} or {@code k > Integer.MAX_VALUE / 2}
*/
- public static <T extends @Nullable Object> TopKSelector<T> least(
- int k, Comparator<? super T> comparator) {
+ public static <T> TopKSelector<T> least(int k, Comparator<? super T> comparator) {
return new TopKSelector<T>(comparator, k);
}
@@ -97,8 +91,7 @@
*
* @throws IllegalArgumentException if {@code k < 0} or {@code k > Integer.MAX_VALUE / 2}
*/
- public static <T extends @Nullable Object> TopKSelector<T> greatest(
- int k, Comparator<? super T> comparator) {
+ public static <T> TopKSelector<T> greatest(int k, Comparator<? super T> comparator) {
return new TopKSelector<T>(Ordering.from(comparator).reverse(), k);
}
@@ -110,14 +103,14 @@
* for the top k elements. Whenever the buffer is filled, we quickselect the top k elements to the
* range [0, k) and ignore the remaining elements.
*/
- private final @Nullable T[] buffer;
+ private final T[] buffer;
private int bufferSize;
/**
* 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.
*/
- @CheckForNull private T threshold;
+ private @Nullable T threshold;
private TopKSelector(Comparator<? super T> comparator, int k) {
this.comparator = checkNotNull(comparator, "comparator");
@@ -133,7 +126,7 @@
* Adds {@code elem} as a candidate for the top {@code k} elements. This operation takes amortized
* O(1) time.
*/
- public void offer(@ParametricNullness T elem) {
+ public void offer(@Nullable T elem) {
if (k == 0) {
return;
} else if (bufferSize == 0) {
@@ -142,12 +135,10 @@
bufferSize = 1;
} else if (bufferSize < k) {
buffer[bufferSize++] = elem;
- // uncheckedCastNullableTToT is safe because bufferSize > 0.
- if (comparator.compare(elem, uncheckedCastNullableTToT(threshold)) > 0) {
+ if (comparator.compare(elem, threshold) > 0) {
threshold = elem;
}
- // uncheckedCastNullableTToT is safe because bufferSize > 0.
- } else if (comparator.compare(elem, uncheckedCastNullableTToT(threshold)) < 0) {
+ } else if (comparator.compare(elem, threshold) < 0) {
// Otherwise, we can ignore elem; we've seen k better elements.
buffer[bufferSize++] = elem;
if (bufferSize == 2 * k) {
@@ -186,17 +177,15 @@
iterations++;
if (iterations >= maxIterations) {
// We've already taken O(k log k), let's make sure we don't take longer than O(k log k).
- Arrays.sort(buffer, left, right + 1, comparator);
+ Arrays.sort(buffer, left, right, comparator);
break;
}
}
bufferSize = k;
- threshold = uncheckedCastNullableTToT(buffer[minThresholdPosition]);
+ threshold = buffer[minThresholdPosition];
for (int i = minThresholdPosition + 1; i < k; i++) {
- if (comparator.compare(
- uncheckedCastNullableTToT(buffer[i]), uncheckedCastNullableTToT(threshold))
- > 0) {
+ if (comparator.compare(buffer[i], threshold) > 0) {
threshold = buffer[i];
}
}
@@ -209,12 +198,12 @@
* (pivotNewIndex, right] is greater than pivotValue.
*/
private int partition(int left, int right, int pivotIndex) {
- T pivotValue = uncheckedCastNullableTToT(buffer[pivotIndex]);
+ T pivotValue = buffer[pivotIndex];
buffer[pivotIndex] = buffer[right];
int pivotNewIndex = left;
for (int i = left; i < right; i++) {
- if (comparator.compare(uncheckedCastNullableTToT(buffer[i]), pivotValue) < 0) {
+ if (comparator.compare(buffer[i], pivotValue) < 0) {
swap(pivotNewIndex, i);
pivotNewIndex++;
}
@@ -232,7 +221,7 @@
TopKSelector<T> combine(TopKSelector<T> other) {
for (int i = 0; i < other.bufferSize; i++) {
- this.offer(uncheckedCastNullableTToT(other.buffer[i]));
+ this.offer(other.buffer[i]);
}
return this;
}
diff --git a/guava/src/com/google/common/collect/TransformedIterator.java b/guava/src/com/google/common/collect/TransformedIterator.java
index 2456cec..b7214b8 100644
--- a/guava/src/com/google/common/collect/TransformedIterator.java
+++ b/guava/src/com/google/common/collect/TransformedIterator.java
@@ -20,7 +20,6 @@
import com.google.common.annotations.GwtCompatible;
import java.util.Iterator;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* An iterator that transforms a backing iterator; for internal use. This avoids the object overhead
@@ -29,17 +28,14 @@
* @author Louis Wasserman
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-abstract class TransformedIterator<F extends @Nullable Object, T extends @Nullable Object>
- implements Iterator<T> {
+abstract class TransformedIterator<F, T> implements Iterator<T> {
final Iterator<? extends F> backingIterator;
TransformedIterator(Iterator<? extends F> backingIterator) {
this.backingIterator = checkNotNull(backingIterator);
}
- @ParametricNullness
- abstract T transform(@ParametricNullness F from);
+ abstract T transform(F from);
@Override
public final boolean hasNext() {
@@ -47,7 +43,6 @@
}
@Override
- @ParametricNullness
public final T next() {
return transform(backingIterator.next());
}
diff --git a/guava/src/com/google/common/collect/TransformedListIterator.java b/guava/src/com/google/common/collect/TransformedListIterator.java
index 66b42e4..ac2eea1 100644
--- a/guava/src/com/google/common/collect/TransformedListIterator.java
+++ b/guava/src/com/google/common/collect/TransformedListIterator.java
@@ -19,7 +19,6 @@
import com.google.common.annotations.GwtCompatible;
import com.google.common.base.Function;
import java.util.ListIterator;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* An iterator that transforms a backing list iterator; for internal use. This avoids the object
@@ -28,9 +27,8 @@
* @author Louis Wasserman
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-abstract class TransformedListIterator<F extends @Nullable Object, T extends @Nullable Object>
- extends TransformedIterator<F, T> implements ListIterator<T> {
+abstract class TransformedListIterator<F, T> extends TransformedIterator<F, T>
+ implements ListIterator<T> {
TransformedListIterator(ListIterator<? extends F> backingIterator) {
super(backingIterator);
}
@@ -45,7 +43,6 @@
}
@Override
- @ParametricNullness
public final T previous() {
return transform(backingIterator().previous());
}
@@ -61,12 +58,12 @@
}
@Override
- public void set(@ParametricNullness T element) {
+ public void set(T element) {
throw new UnsupportedOperationException();
}
@Override
- public void add(@ParametricNullness T element) {
+ public void add(T element) {
throw new UnsupportedOperationException();
}
}
diff --git a/guava/src/com/google/common/collect/TreeBasedTable.java b/guava/src/com/google/common/collect/TreeBasedTable.java
index 315404a..510f75c 100644
--- a/guava/src/com/google/common/collect/TreeBasedTable.java
+++ b/guava/src/com/google/common/collect/TreeBasedTable.java
@@ -18,7 +18,6 @@
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
-import static java.util.Objects.requireNonNull;
import com.google.common.annotations.GwtCompatible;
import com.google.common.base.Function;
@@ -32,7 +31,7 @@
import java.util.SortedMap;
import java.util.SortedSet;
import java.util.TreeMap;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Implementation of {@code Table} whose row keys and column keys are ordered by their natural
@@ -67,7 +66,6 @@
* @since 7.0
*/
@GwtCompatible(serializable = true)
-@ElementTypesAreNonnullByDefault
public class TreeBasedTable<R, C, V> extends StandardRowSortedTable<R, C, V> {
private final Comparator<? super C> columnComparator;
@@ -137,11 +135,7 @@
*/
@Deprecated
public Comparator<? super R> rowComparator() {
- /*
- * requireNonNull is safe because the factories require non-null Comparators, which they pass on
- * to the backing collections.
- */
- return requireNonNull(rowKeySet().comparator());
+ return rowKeySet().comparator();
}
/**
@@ -175,14 +169,14 @@
}
private class TreeRow extends Row implements SortedMap<C, V> {
- @CheckForNull final C lowerBound;
- @CheckForNull final C upperBound;
+ final @Nullable C lowerBound;
+ final @Nullable C upperBound;
TreeRow(R rowKey) {
this(rowKey, null, null);
}
- TreeRow(R rowKey, @CheckForNull C lowerBound, @CheckForNull C upperBound) {
+ TreeRow(R rowKey, @Nullable C lowerBound, @Nullable C upperBound) {
super(rowKey);
this.lowerBound = lowerBound;
this.upperBound = upperBound;
@@ -207,7 +201,7 @@
return cmp.compare(a, b);
}
- boolean rangeContains(@CheckForNull Object o) {
+ boolean rangeContains(@Nullable Object o) {
return o != null
&& (lowerBound == null || compare(lowerBound, o) <= 0)
&& (upperBound == null || compare(upperBound, o) > 0);
@@ -233,36 +227,43 @@
@Override
public C firstKey() {
- updateBackingRowMapField();
- if (backingRowMap == null) {
+ SortedMap<C, V> backing = backingRowMap();
+ if (backing == null) {
throw new NoSuchElementException();
}
- return ((SortedMap<C, V>) backingRowMap).firstKey();
+ return backingRowMap().firstKey();
}
@Override
public C lastKey() {
- updateBackingRowMapField();
- if (backingRowMap == null) {
+ SortedMap<C, V> backing = backingRowMap();
+ if (backing == null) {
throw new NoSuchElementException();
}
- return ((SortedMap<C, V>) backingRowMap).lastKey();
+ return backingRowMap().lastKey();
}
- @CheckForNull transient SortedMap<C, V> wholeRow;
+ transient @Nullable SortedMap<C, V> wholeRow;
- // If the row was previously empty, we check if there's a new row here every time we're queried.
- void updateWholeRowField() {
+ /*
+ * If the row was previously empty, we check if there's a new row here every
+ * time we're queried.
+ */
+ SortedMap<C, V> wholeRow() {
if (wholeRow == null || (wholeRow.isEmpty() && backingMap.containsKey(rowKey))) {
wholeRow = (SortedMap<C, V>) backingMap.get(rowKey);
}
+ return wholeRow;
}
@Override
- @CheckForNull
+ SortedMap<C, V> backingRowMap() {
+ return (SortedMap<C, V>) super.backingRowMap();
+ }
+
+ @Override
SortedMap<C, V> computeBackingRowMap() {
- updateWholeRowField();
- SortedMap<C, V> map = wholeRow;
+ SortedMap<C, V> map = wholeRow();
if (map != null) {
if (lowerBound != null) {
map = map.tailMap(lowerBound);
@@ -277,8 +278,7 @@
@Override
void maintainEmptyInvariant() {
- updateWholeRowField();
- if (wholeRow != null && wholeRow.isEmpty()) {
+ if (wholeRow() != null && wholeRow.isEmpty()) {
backingMap.remove(rowKey);
wholeRow = null;
backingRowMap = null;
@@ -286,12 +286,11 @@
}
@Override
- public boolean containsKey(@CheckForNull Object key) {
+ public boolean containsKey(Object key) {
return rangeContains(key) && super.containsKey(key);
}
@Override
- @CheckForNull
public V put(C key, V value) {
checkArgument(rangeContains(checkNotNull(key)));
return super.put(key, value);
@@ -328,10 +327,9 @@
comparator);
return new AbstractIterator<C>() {
- @CheckForNull C lastValue;
+ @Nullable C lastValue;
@Override
- @CheckForNull
protected C computeNext() {
while (merged.hasNext()) {
C next = merged.next();
diff --git a/guava/src/com/google/common/collect/TreeMultimap.java b/guava/src/com/google/common/collect/TreeMultimap.java
index 04ae207..82c97af 100644
--- a/guava/src/com/google/common/collect/TreeMultimap.java
+++ b/guava/src/com/google/common/collect/TreeMultimap.java
@@ -72,9 +72,7 @@
* @since 2.0
*/
@GwtCompatible(serializable = true, emulated = true)
-@ElementTypesAreNonnullByDefault
-public class TreeMultimap<K extends @Nullable Object, V extends @Nullable Object>
- extends AbstractSortedKeySortedSetMultimap<K, V> {
+public class TreeMultimap<K, V> extends AbstractSortedKeySortedSetMultimap<K, V> {
private transient Comparator<? super K> keyComparator;
private transient Comparator<? super V> valueComparator;
@@ -92,7 +90,7 @@
* @param keyComparator the comparator that determines the key ordering
* @param valueComparator the comparator that determines the value ordering
*/
- public static <K extends @Nullable Object, V extends @Nullable Object> TreeMultimap<K, V> create(
+ public static <K, V> TreeMultimap<K, V> create(
Comparator<? super K> keyComparator, Comparator<? super V> valueComparator) {
return new TreeMultimap<>(checkNotNull(keyComparator), checkNotNull(valueComparator));
}
@@ -140,7 +138,7 @@
}
@Override
- Collection<V> createCollection(@ParametricNullness K key) {
+ Collection<V> createCollection(@Nullable K key) {
if (key == null) {
keyComparator().compare(key, key);
}
@@ -165,7 +163,7 @@
/** @since 14.0 (present with return type {@code SortedSet} since 2.0) */
@Override
@GwtIncompatible // NavigableSet
- public NavigableSet<V> get(@ParametricNullness K key) {
+ public NavigableSet<V> get(@Nullable K key) {
return (NavigableSet<V>) super.get(key);
}
diff --git a/guava/src/com/google/common/collect/TreeMultiset.java b/guava/src/com/google/common/collect/TreeMultiset.java
index dcc3f68..da3a63c 100644
--- a/guava/src/com/google/common/collect/TreeMultiset.java
+++ b/guava/src/com/google/common/collect/TreeMultiset.java
@@ -20,8 +20,7 @@
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkState;
import static com.google.common.collect.CollectPreconditions.checkNonnegative;
-import static com.google.common.collect.NullnessCasts.uncheckedCastNullableTToT;
-import static java.util.Objects.requireNonNull;
+import static com.google.common.collect.CollectPreconditions.checkRemove;
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.GwtIncompatible;
@@ -37,7 +36,6 @@
import java.util.Iterator;
import java.util.NoSuchElementException;
import java.util.function.ObjIntConsumer;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -59,9 +57,7 @@
* @since 2.0
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
-public final class TreeMultiset<E extends @Nullable Object> extends AbstractSortedMultiset<E>
- implements Serializable {
+public final class TreeMultiset<E> extends AbstractSortedMultiset<E> implements Serializable {
/**
* Creates a new, empty multiset, sorted according to the elements' natural order. All elements
@@ -91,8 +87,7 @@
* indicates that the elements' <i>natural ordering</i> should be used.
*/
@SuppressWarnings("unchecked")
- public static <E extends @Nullable Object> TreeMultiset<E> create(
- @CheckForNull Comparator<? super E> comparator) {
+ public static <E> TreeMultiset<E> create(@Nullable Comparator<? super E> comparator) {
return (comparator == null)
? new TreeMultiset<E>((Comparator) Ordering.natural())
: new TreeMultiset<E>(comparator);
@@ -127,7 +122,7 @@
TreeMultiset(Comparator<? super E> comparator) {
super(comparator);
this.range = GeneralRange.all(comparator);
- this.header = new AvlNode<>();
+ this.header = new AvlNode<E>(null, 1);
successor(header, header);
this.rootReference = new Reference<>();
}
@@ -141,7 +136,7 @@
}
@Override
- long treeAggregate(@CheckForNull AvlNode<?> root) {
+ long treeAggregate(@Nullable AvlNode<?> root) {
return (root == null) ? 0 : root.totalCount;
}
},
@@ -152,14 +147,14 @@
}
@Override
- long treeAggregate(@CheckForNull AvlNode<?> root) {
+ long treeAggregate(@Nullable AvlNode<?> root) {
return (root == null) ? 0 : root.distinctElements;
}
};
abstract int nodeAggregate(AvlNode<?> node);
- abstract long treeAggregate(@CheckForNull AvlNode<?> root);
+ abstract long treeAggregate(@Nullable AvlNode<?> root);
}
private long aggregateForEntries(Aggregate aggr) {
@@ -174,14 +169,11 @@
return total;
}
- private long aggregateBelowRange(Aggregate aggr, @CheckForNull AvlNode<E> node) {
+ private long aggregateBelowRange(Aggregate aggr, @Nullable AvlNode<E> node) {
if (node == null) {
return 0;
}
- // The cast is safe because we call this method only if hasLowerBound().
- int cmp =
- comparator()
- .compare(uncheckedCastNullableTToT(range.getLowerEndpoint()), node.getElement());
+ int cmp = comparator().compare(range.getLowerEndpoint(), node.elem);
if (cmp < 0) {
return aggregateBelowRange(aggr, node.left);
} else if (cmp == 0) {
@@ -200,14 +192,11 @@
}
}
- private long aggregateAboveRange(Aggregate aggr, @CheckForNull AvlNode<E> node) {
+ private long aggregateAboveRange(Aggregate aggr, @Nullable AvlNode<E> node) {
if (node == null) {
return 0;
}
- // The cast is safe because we call this method only if hasUpperBound().
- int cmp =
- comparator()
- .compare(uncheckedCastNullableTToT(range.getUpperEndpoint()), node.getElement());
+ int cmp = comparator().compare(range.getUpperEndpoint(), node.elem);
if (cmp > 0) {
return aggregateAboveRange(aggr, node.right);
} else if (cmp == 0) {
@@ -236,12 +225,12 @@
return Ints.saturatedCast(aggregateForEntries(Aggregate.DISTINCT));
}
- static int distinctElements(@CheckForNull AvlNode<?> node) {
+ static int distinctElements(@Nullable AvlNode<?> node) {
return (node == null) ? 0 : node.distinctElements;
}
@Override
- public int count(@CheckForNull Object element) {
+ public int count(@Nullable Object element) {
try {
@SuppressWarnings("unchecked")
E e = (E) element;
@@ -257,7 +246,7 @@
@CanIgnoreReturnValue
@Override
- public int add(@ParametricNullness E element, int occurrences) {
+ public int add(@Nullable E element, int occurrences) {
checkNonnegative(occurrences, "occurrences");
if (occurrences == 0) {
return count(element);
@@ -279,7 +268,7 @@
@CanIgnoreReturnValue
@Override
- public int remove(@CheckForNull Object element, int occurrences) {
+ public int remove(@Nullable Object element, int occurrences) {
checkNonnegative(occurrences, "occurrences");
if (occurrences == 0) {
return count(element);
@@ -303,7 +292,7 @@
@CanIgnoreReturnValue
@Override
- public int setCount(@ParametricNullness E element, int count) {
+ public int setCount(@Nullable E element, int count) {
checkNonnegative(count, "count");
if (!range.contains(element)) {
checkArgument(count == 0);
@@ -325,7 +314,7 @@
@CanIgnoreReturnValue
@Override
- public boolean setCount(@ParametricNullness 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));
@@ -351,8 +340,8 @@
public void clear() {
if (!range.hasLowerBound() && !range.hasUpperBound()) {
// We can do this in O(n) rather than removing one by one, which could force rebalancing.
- for (AvlNode<E> current = header.succ(); current != header; ) {
- AvlNode<E> next = current.succ();
+ for (AvlNode<E> current = header.succ; current != header; ) {
+ AvlNode<E> next = current.succ;
current.elemCount = 0;
// Also clear these fields so that one deleted Entry doesn't retain all elements.
@@ -374,7 +363,6 @@
private Entry<E> wrapEntry(final AvlNode<E> baseEntry) {
return new Multisets.AbstractEntry<E>() {
@Override
- @ParametricNullness
public E getElement() {
return baseEntry.getElement();
}
@@ -392,50 +380,46 @@
}
/** Returns the first node in the tree that is in range. */
- @CheckForNull
- private AvlNode<E> firstNode() {
+ private @Nullable AvlNode<E> firstNode() {
AvlNode<E> root = rootReference.get();
if (root == null) {
return null;
}
AvlNode<E> node;
if (range.hasLowerBound()) {
- // The cast is safe because of the hasLowerBound check.
- E endpoint = uncheckedCastNullableTToT(range.getLowerEndpoint());
- node = root.ceiling(comparator(), endpoint);
+ E endpoint = range.getLowerEndpoint();
+ node = rootReference.get().ceiling(comparator(), endpoint);
if (node == null) {
return null;
}
if (range.getLowerBoundType() == BoundType.OPEN
&& comparator().compare(endpoint, node.getElement()) == 0) {
- node = node.succ();
+ node = node.succ;
}
} else {
- node = header.succ();
+ node = header.succ;
}
return (node == header || !range.contains(node.getElement())) ? null : node;
}
- @CheckForNull
- private AvlNode<E> lastNode() {
+ private @Nullable AvlNode<E> lastNode() {
AvlNode<E> root = rootReference.get();
if (root == null) {
return null;
}
AvlNode<E> node;
if (range.hasUpperBound()) {
- // The cast is safe because of the hasUpperBound check.
- E endpoint = uncheckedCastNullableTToT(range.getUpperEndpoint());
- node = root.floor(comparator(), endpoint);
+ E endpoint = range.getUpperEndpoint();
+ node = rootReference.get().floor(comparator(), endpoint);
if (node == null) {
return null;
}
if (range.getUpperBoundType() == BoundType.OPEN
&& comparator().compare(endpoint, node.getElement()) == 0) {
- node = node.pred();
+ node = node.pred;
}
} else {
- node = header.pred();
+ node = header.pred;
}
return (node == header || !range.contains(node.getElement())) ? null : node;
}
@@ -448,8 +432,8 @@
@Override
Iterator<Entry<E>> entryIterator() {
return new Iterator<Entry<E>>() {
- @CheckForNull AvlNode<E> current = firstNode();
- @CheckForNull Entry<E> prevEntry;
+ AvlNode<E> current = firstNode();
+ @Nullable Entry<E> prevEntry;
@Override
public boolean hasNext() {
@@ -468,20 +452,19 @@
if (!hasNext()) {
throw new NoSuchElementException();
}
- // requireNonNull is safe because current is only nulled out after iteration is complete.
- Entry<E> result = wrapEntry(requireNonNull(current));
+ Entry<E> result = wrapEntry(current);
prevEntry = result;
- if (current.succ() == header) {
+ if (current.succ == header) {
current = null;
} else {
- current = current.succ();
+ current = current.succ;
}
return result;
}
@Override
public void remove() {
- checkState(prevEntry != null, "no calls to next() since the last call to remove()");
+ checkRemove(prevEntry != null);
setCount(prevEntry.getElement(), 0);
prevEntry = null;
}
@@ -491,8 +474,8 @@
@Override
Iterator<Entry<E>> descendingEntryIterator() {
return new Iterator<Entry<E>>() {
- @CheckForNull AvlNode<E> current = lastNode();
- @CheckForNull Entry<E> prevEntry = null;
+ AvlNode<E> current = lastNode();
+ Entry<E> prevEntry = null;
@Override
public boolean hasNext() {
@@ -511,21 +494,19 @@
if (!hasNext()) {
throw new NoSuchElementException();
}
- // requireNonNull is safe because current is only nulled out after iteration is complete.
- requireNonNull(current);
Entry<E> result = wrapEntry(current);
prevEntry = result;
- if (current.pred() == header) {
+ if (current.pred == header) {
current = null;
} else {
- current = current.pred();
+ current = current.pred;
}
return result;
}
@Override
public void remove() {
- checkState(prevEntry != null, "no calls to next() since the last call to remove()");
+ checkRemove(prevEntry != null);
setCount(prevEntry.getElement(), 0);
prevEntry = null;
}
@@ -537,7 +518,7 @@
checkNotNull(action);
for (AvlNode<E> node = firstNode();
node != header && node != null && !range.tooHigh(node.getElement());
- node = node.succ()) {
+ node = node.succ) {
action.accept(node.getElement(), node.getCount());
}
}
@@ -548,7 +529,7 @@
}
@Override
- public SortedMultiset<E> headMultiset(@ParametricNullness E upperBound, BoundType boundType) {
+ public SortedMultiset<E> headMultiset(@Nullable E upperBound, BoundType boundType) {
return new TreeMultiset<E>(
rootReference,
range.intersect(GeneralRange.upTo(comparator(), upperBound, boundType)),
@@ -556,7 +537,7 @@
}
@Override
- public SortedMultiset<E> tailMultiset(@ParametricNullness E lowerBound, BoundType boundType) {
+ public SortedMultiset<E> tailMultiset(@Nullable E lowerBound, BoundType boundType) {
return new TreeMultiset<E>(
rootReference,
range.intersect(GeneralRange.downTo(comparator(), lowerBound, boundType)),
@@ -564,14 +545,13 @@
}
private static final class Reference<T> {
- @CheckForNull private T value;
+ private @Nullable T value;
- @CheckForNull
- public T get() {
+ public @Nullable T get() {
return value;
}
- public void checkAndSet(@CheckForNull T expected, @CheckForNull T newValue) {
+ public void checkAndSet(@Nullable T expected, T newValue) {
if (value != expected) {
throw new ConcurrentModificationException();
}
@@ -583,18 +563,8 @@
}
}
- private static final class AvlNode<E extends @Nullable Object> {
- /*
- * For "normal" nodes, the type of this field is `E`, not `@Nullable E` (though note that E is a
- * type that can include null, as in a TreeMultiset<@Nullable String>).
- *
- * For the header node, though, this field contains `null`, regardless of the type of the
- * multiset.
- *
- * Most code that operates on an AvlNode never operates on the header node. Such code can access
- * the elem field without a null check by calling getElement().
- */
- @CheckForNull private final E elem;
+ private static final class AvlNode<E> {
+ private final @Nullable E elem;
// elemCount is 0 iff this node has been deleted.
private int elemCount;
@@ -602,23 +572,12 @@
private int distinctElements;
private long totalCount;
private int height;
- @CheckForNull private AvlNode<E> left;
- @CheckForNull private AvlNode<E> right;
- /*
- * pred and succ are nullable after construction, but we always call successor() to initialize
- * them immediately thereafter.
- *
- * They may be subsequently nulled out by TreeMultiset.clear(). I think that the only place that
- * we can reference a node whose fields have been cleared is inside the iterator (and presumably
- * only under concurrent modification).
- *
- * To access these fields when you know that they are not null, call the pred() and succ()
- * methods, which perform null checks before returning the fields.
- */
- @CheckForNull private AvlNode<E> pred;
- @CheckForNull private AvlNode<E> succ;
+ private @Nullable AvlNode<E> left;
+ private @Nullable AvlNode<E> right;
+ private @Nullable AvlNode<E> pred;
+ private @Nullable AvlNode<E> succ;
- AvlNode(@ParametricNullness E elem, int elemCount) {
+ AvlNode(@Nullable E elem, int elemCount) {
checkArgument(elemCount > 0);
this.elem = elem;
this.elemCount = elemCount;
@@ -629,24 +588,8 @@
this.right = null;
}
- /** Constructor for the header node. */
- AvlNode() {
- this.elem = null;
- this.elemCount = 1;
- }
-
- // For discussion of pred() and succ(), see the comment on the pred and succ fields.
-
- private AvlNode<E> pred() {
- return requireNonNull(pred);
- }
-
- private AvlNode<E> succ() {
- return requireNonNull(succ);
- }
-
- int count(Comparator<? super E> comparator, @ParametricNullness E e) {
- int cmp = comparator.compare(e, getElement());
+ public int count(Comparator<? super E> comparator, E e) {
+ int cmp = comparator.compare(e, elem);
if (cmp < 0) {
return (left == null) ? 0 : left.count(comparator, e);
} else if (cmp > 0) {
@@ -656,31 +599,30 @@
}
}
- private AvlNode<E> addRightChild(@ParametricNullness E e, int count) {
+ private AvlNode<E> addRightChild(E e, int count) {
right = new AvlNode<E>(e, count);
- successor(this, right, succ());
+ successor(this, right, succ);
height = Math.max(2, height);
distinctElements++;
totalCount += count;
return this;
}
- private AvlNode<E> addLeftChild(@ParametricNullness E e, int count) {
+ private AvlNode<E> addLeftChild(E e, int count) {
left = new AvlNode<E>(e, count);
- successor(pred(), left, this);
+ successor(pred, left, this);
height = Math.max(2, height);
distinctElements++;
totalCount += count;
return this;
}
- AvlNode<E> add(
- Comparator<? super E> comparator, @ParametricNullness E e, int count, int[] result) {
+ AvlNode<E> add(Comparator<? super E> 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. =(
*/
- int cmp = comparator.compare(e, getElement());
+ int cmp = comparator.compare(e, elem);
if (cmp < 0) {
AvlNode<E> initLeft = left;
if (initLeft == null) {
@@ -720,10 +662,8 @@
return this;
}
- @CheckForNull
- AvlNode<E> remove(
- Comparator<? super E> comparator, @ParametricNullness E e, int count, int[] result) {
- int cmp = comparator.compare(e, getElement());
+ AvlNode<E> remove(Comparator<? super E> comparator, @Nullable E e, int count, int[] result) {
+ int cmp = comparator.compare(e, elem);
if (cmp < 0) {
AvlNode<E> initLeft = left;
if (initLeft == null) {
@@ -773,10 +713,8 @@
}
}
- @CheckForNull
- AvlNode<E> setCount(
- Comparator<? super E> comparator, @ParametricNullness E e, int count, int[] result) {
- int cmp = comparator.compare(e, getElement());
+ AvlNode<E> setCount(Comparator<? super E> comparator, @Nullable E e, int count, int[] result) {
+ int cmp = comparator.compare(e, elem);
if (cmp < 0) {
AvlNode<E> initLeft = left;
if (initLeft == null) {
@@ -823,14 +761,13 @@
return this;
}
- @CheckForNull
AvlNode<E> setCount(
Comparator<? super E> comparator,
- @ParametricNullness E e,
+ @Nullable E e,
int expectedCount,
int newCount,
int[] result) {
- int cmp = comparator.compare(e, getElement());
+ int cmp = comparator.compare(e, elem);
if (cmp < 0) {
AvlNode<E> initLeft = left;
if (initLeft == null) {
@@ -887,17 +824,16 @@
return this;
}
- @CheckForNull
private AvlNode<E> deleteMe() {
int oldElemCount = this.elemCount;
this.elemCount = 0;
- successor(pred(), succ());
+ successor(pred, succ);
if (left == null) {
return right;
} else if (right == null) {
return left;
} else if (left.height >= right.height) {
- AvlNode<E> newTop = pred();
+ AvlNode<E> newTop = pred;
// newTop is the maximum node in my left subtree
newTop.left = left.removeMax(newTop);
newTop.right = right;
@@ -905,7 +841,7 @@
newTop.totalCount = totalCount - oldElemCount;
return newTop.rebalance();
} else {
- AvlNode<E> newTop = succ();
+ AvlNode<E> newTop = succ;
newTop.right = right.removeMin(newTop);
newTop.left = left;
newTop.distinctElements = distinctElements - 1;
@@ -915,7 +851,6 @@
}
// Removes the minimum node from this subtree to be reused elsewhere
- @CheckForNull
private AvlNode<E> removeMin(AvlNode<E> node) {
if (left == null) {
return right;
@@ -928,7 +863,6 @@
}
// Removes the maximum node from this subtree to be reused elsewhere
- @CheckForNull
private AvlNode<E> removeMax(AvlNode<E> node) {
if (right == null) {
return left;
@@ -958,15 +892,11 @@
private AvlNode<E> rebalance() {
switch (balanceFactor()) {
case -2:
- // requireNonNull is safe because right must exist in order to get a negative factor.
- requireNonNull(right);
if (right.balanceFactor() > 0) {
right = right.rotateRight();
}
return rotateLeft();
case 2:
- // requireNonNull is safe because left must exist in order to get a positive factor.
- requireNonNull(left);
if (left.balanceFactor() < 0) {
left = left.rotateLeft();
}
@@ -1005,17 +935,16 @@
return newTop;
}
- private static long totalCount(@CheckForNull AvlNode<?> node) {
+ private static long totalCount(@Nullable AvlNode<?> node) {
return (node == null) ? 0 : node.totalCount;
}
- private static int height(@CheckForNull AvlNode<?> node) {
+ private static int height(@Nullable AvlNode<?> node) {
return (node == null) ? 0 : node.height;
}
- @CheckForNull
- private AvlNode<E> ceiling(Comparator<? super E> comparator, @ParametricNullness E e) {
- int cmp = comparator.compare(e, getElement());
+ private @Nullable AvlNode<E> ceiling(Comparator<? super E> comparator, E e) {
+ int cmp = comparator.compare(e, elem);
if (cmp < 0) {
return (left == null) ? this : MoreObjects.firstNonNull(left.ceiling(comparator, e), this);
} else if (cmp == 0) {
@@ -1025,9 +954,8 @@
}
}
- @CheckForNull
- private AvlNode<E> floor(Comparator<? super E> comparator, @ParametricNullness E e) {
- int cmp = comparator.compare(e, getElement());
+ private @Nullable AvlNode<E> floor(Comparator<? super E> comparator, E e) {
+ int cmp = comparator.compare(e, elem);
if (cmp > 0) {
return (right == null) ? this : MoreObjects.firstNonNull(right.floor(comparator, e), this);
} else if (cmp == 0) {
@@ -1037,10 +965,8 @@
}
}
- @ParametricNullness
E getElement() {
- // For discussion of this cast, see the comment on the elem field.
- return uncheckedCastNullableTToT(elem);
+ return elem;
}
int getCount() {
@@ -1053,13 +979,12 @@
}
}
- private static <T extends @Nullable Object> void successor(AvlNode<T> a, AvlNode<T> b) {
+ private static <T> void successor(AvlNode<T> a, AvlNode<T> b) {
a.succ = b;
b.pred = a;
}
- private static <T extends @Nullable Object> void successor(
- AvlNode<T> a, AvlNode<T> b, AvlNode<T> c) {
+ private static <T> void successor(AvlNode<T> a, AvlNode<T> b, AvlNode<T> c) {
successor(a, b);
successor(b, c);
}
@@ -1092,7 +1017,7 @@
.set(this, GeneralRange.all(comparator));
Serialization.getFieldSetter(TreeMultiset.class, "rootReference")
.set(this, new Reference<AvlNode<E>>());
- AvlNode<E> header = new AvlNode<>();
+ AvlNode<E> header = new AvlNode<E>(null, 1);
Serialization.getFieldSetter(TreeMultiset.class, "header").set(this, header);
successor(header, header);
Serialization.populateMultiset(this, stream);
diff --git a/guava/src/com/google/common/collect/TreeRangeMap.java b/guava/src/com/google/common/collect/TreeRangeMap.java
index a920089..69491d4 100644
--- a/guava/src/com/google/common/collect/TreeRangeMap.java
+++ b/guava/src/com/google/common/collect/TreeRangeMap.java
@@ -21,7 +21,6 @@
import static com.google.common.base.Predicates.compose;
import static com.google.common.base.Predicates.in;
import static com.google.common.base.Predicates.not;
-import static java.util.Objects.requireNonNull;
import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtIncompatible;
@@ -39,7 +38,6 @@
import java.util.NoSuchElementException;
import java.util.Set;
import java.util.function.BiFunction;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -53,7 +51,6 @@
*/
@Beta
@GwtIncompatible // NavigableMap
-@ElementTypesAreNonnullByDefault
public final class TreeRangeMap<K extends Comparable, V> implements RangeMap<K, V> {
private final NavigableMap<Cut<K>, RangeMapEntry<K, V>> entriesByLowerBound;
@@ -104,15 +101,13 @@
}
@Override
- @CheckForNull
- public V get(K key) {
+ public @Nullable V get(K key) {
Entry<Range<K>, V> entry = getEntry(key);
return (entry == null) ? null : entry.getValue();
}
@Override
- @CheckForNull
- public Entry<Range<K>, V> getEntry(K key) {
+ public @Nullable Entry<Range<K>, V> getEntry(K key) {
Entry<Cut<K>, RangeMapEntry<K, V>> mapEntry =
entriesByLowerBound.floorEntry(Cut.belowValue(key));
if (mapEntry != null && mapEntry.getValue().contains(key)) {
@@ -159,7 +154,7 @@
/** Returns the range that spans the given range and entry, if the entry can be coalesced. */
private static <K extends Comparable, V> Range<K> coalesce(
- Range<K> range, V value, @CheckForNull Entry<Cut<K>, RangeMapEntry<K, V>> entry) {
+ Range<K> range, V value, @Nullable Entry<Cut<K>, RangeMapEntry<K, V>> entry) {
if (entry != null
&& entry.getValue().getKey().isConnected(range)
&& entry.getValue().getValue().equals(value)) {
@@ -184,8 +179,7 @@
public Range<K> span() {
Entry<Cut<K>, RangeMapEntry<K, V>> firstEntry = entriesByLowerBound.firstEntry();
Entry<Cut<K>, RangeMapEntry<K, V>> lastEntry = entriesByLowerBound.lastEntry();
- // Either both are null or neither is, but we check both to satisfy the nullness checker.
- if (firstEntry == null || lastEntry == null) {
+ if (firstEntry == null) {
throw new NoSuchElementException();
}
return Range.create(
@@ -268,8 +262,8 @@
@Override
public void merge(
Range<K> range,
- @CheckForNull V value,
- BiFunction<? super V, ? super @Nullable V, ? extends @Nullable V> remappingFunction) {
+ @Nullable V value,
+ BiFunction<? super V, ? super V, ? extends V> remappingFunction) {
checkNotNull(range);
checkNotNull(remappingFunction);
@@ -340,13 +334,12 @@
}
@Override
- public boolean containsKey(@CheckForNull Object key) {
+ public boolean containsKey(@Nullable Object key) {
return get(key) != null;
}
@Override
- @CheckForNull
- public V get(@CheckForNull Object key) {
+ public V get(@Nullable Object key) {
if (key instanceof Range) {
Range<?> range = (Range<?>) key;
RangeMapEntry<K, V> rangeMapEntry = entriesByLowerBound.get(range.lowerBound);
@@ -379,45 +372,42 @@
@SuppressWarnings("unchecked")
private RangeMap<K, V> emptySubRangeMap() {
- return (RangeMap<K, V>) (RangeMap<?, ?>) EMPTY_SUB_RANGE_MAP;
+ return EMPTY_SUB_RANGE_MAP;
}
- @SuppressWarnings("ConstantCaseForConstants") // This RangeMap is immutable.
- private static final RangeMap<Comparable<?>, Object> EMPTY_SUB_RANGE_MAP =
- new RangeMap<Comparable<?>, Object>() {
+ private static final RangeMap EMPTY_SUB_RANGE_MAP =
+ new RangeMap() {
@Override
- @CheckForNull
- public Object get(Comparable<?> key) {
+ public @Nullable Object get(Comparable key) {
return null;
}
@Override
- @CheckForNull
- public Entry<Range<Comparable<?>>, Object> getEntry(Comparable<?> key) {
+ public @Nullable Entry<Range, Object> getEntry(Comparable key) {
return null;
}
@Override
- public Range<Comparable<?>> span() {
+ public Range span() {
throw new NoSuchElementException();
}
@Override
- public void put(Range<Comparable<?>> range, Object value) {
+ public void put(Range range, Object value) {
checkNotNull(range);
throw new IllegalArgumentException(
"Cannot insert range " + range + " into an empty subRangeMap");
}
@Override
- public void putCoalescing(Range<Comparable<?>> range, Object value) {
+ public void putCoalescing(Range range, Object value) {
checkNotNull(range);
throw new IllegalArgumentException(
"Cannot insert range " + range + " into an empty subRangeMap");
}
@Override
- public void putAll(RangeMap<Comparable<?>, Object> rangeMap) {
+ public void putAll(RangeMap rangeMap) {
if (!rangeMap.asMapOfRanges().isEmpty()) {
throw new IllegalArgumentException(
"Cannot putAll(nonEmptyRangeMap) into an empty subRangeMap");
@@ -428,32 +418,30 @@
public void clear() {}
@Override
- public void remove(Range<Comparable<?>> range) {
+ public void remove(Range range) {
checkNotNull(range);
}
@Override
- public void merge(
- Range<Comparable<?>> range,
- @CheckForNull Object value,
- BiFunction<? super Object, ? super Object, ? extends Object> remappingFunction) {
+ @SuppressWarnings("rawtypes") // necessary for static EMPTY_SUB_RANGE_MAP instance
+ public void merge(Range range, @Nullable Object value, BiFunction remappingFunction) {
checkNotNull(range);
throw new IllegalArgumentException(
"Cannot merge range " + range + " into an empty subRangeMap");
}
@Override
- public Map<Range<Comparable<?>>, Object> asMapOfRanges() {
+ public Map<Range, Object> asMapOfRanges() {
return Collections.emptyMap();
}
@Override
- public Map<Range<Comparable<?>>, Object> asDescendingMapOfRanges() {
+ public Map<Range, Object> asDescendingMapOfRanges() {
return Collections.emptyMap();
}
@Override
- public RangeMap<Comparable<?>, Object> subRangeMap(Range<Comparable<?>> range) {
+ public RangeMap subRangeMap(Range range) {
checkNotNull(range);
return this;
}
@@ -468,14 +456,12 @@
}
@Override
- @CheckForNull
- public V get(K key) {
+ public @Nullable V get(K key) {
return subRange.contains(key) ? TreeRangeMap.this.get(key) : null;
}
@Override
- @CheckForNull
- public Entry<Range<K>, V> getEntry(K key) {
+ public @Nullable Entry<Range<K>, V> getEntry(K key) {
if (subRange.contains(key)) {
Entry<Range<K>, V> entry = TreeRangeMap.this.getEntry(key);
if (entry != null) {
@@ -561,8 +547,8 @@
@Override
public void merge(
Range<K> range,
- @CheckForNull V value,
- BiFunction<? super V, ? super @Nullable V, ? extends @Nullable V> remappingFunction) {
+ @Nullable V value,
+ BiFunction<? super V, ? super V, ? extends V> remappingFunction) {
checkArgument(
subRange.encloses(range),
"Cannot merge range %s into a subRangeMap(%s)",
@@ -603,7 +589,6 @@
return new AbstractIterator<Entry<Range<K>, V>>() {
@Override
- @CheckForNull
protected Entry<Range<K>, V> computeNext() {
if (backingItr.hasNext()) {
RangeMapEntry<K, V> entry = backingItr.next();
@@ -620,7 +605,7 @@
}
@Override
- public boolean equals(@CheckForNull Object o) {
+ public boolean equals(@Nullable Object o) {
if (o instanceof RangeMap) {
RangeMap<?, ?> rangeMap = (RangeMap<?, ?>) o;
return asMapOfRanges().equals(rangeMap.asMapOfRanges());
@@ -641,13 +626,12 @@
class SubRangeMapAsMap extends AbstractMap<Range<K>, V> {
@Override
- public boolean containsKey(@CheckForNull Object key) {
+ public boolean containsKey(Object key) {
return get(key) != null;
}
@Override
- @CheckForNull
- public V get(@CheckForNull Object key) {
+ public V get(Object key) {
try {
if (key instanceof Range) {
@SuppressWarnings("unchecked") // we catch ClassCastExceptions
@@ -680,13 +664,11 @@
}
@Override
- @CheckForNull
- public V remove(@CheckForNull Object key) {
+ public V remove(Object key) {
V value = get(key);
if (value != null) {
- // it's definitely in the map, so the cast and requireNonNull are safe
- @SuppressWarnings("unchecked")
- Range<K> range = (Range<K>) requireNonNull(key);
+ @SuppressWarnings("unchecked") // it's definitely in the map, so safe
+ Range<K> range = (Range<K>) key;
TreeRangeMap.this.remove(range);
return value;
}
@@ -715,7 +697,7 @@
public Set<Range<K>> keySet() {
return new Maps.KeySet<Range<K>, V>(SubRangeMapAsMap.this) {
@Override
- public boolean remove(@CheckForNull Object o) {
+ public boolean remove(@Nullable Object o) {
return SubRangeMapAsMap.this.remove(o) != null;
}
@@ -768,7 +750,6 @@
return new AbstractIterator<Entry<Range<K>, V>>() {
@Override
- @CheckForNull
protected Entry<Range<K>, V> computeNext() {
while (backingItr.hasNext()) {
RangeMapEntry<K, V> entry = backingItr.next();
@@ -802,7 +783,7 @@
}
@Override
- public boolean equals(@CheckForNull 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 8308880..58cdac1 100644
--- a/guava/src/com/google/common/collect/TreeRangeSet.java
+++ b/guava/src/com/google/common/collect/TreeRangeSet.java
@@ -30,7 +30,7 @@
import java.util.NoSuchElementException;
import java.util.Set;
import java.util.TreeMap;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* An implementation of {@link RangeSet} backed by a {@link TreeMap}.
@@ -40,7 +40,6 @@
*/
@Beta
@GwtIncompatible // uses NavigableMap
-@ElementTypesAreNonnullByDefault
public class TreeRangeSet<C extends Comparable<?>> extends AbstractRangeSet<C>
implements Serializable {
@@ -77,8 +76,8 @@
this.rangesByLowerBound = rangesByLowerCut;
}
- @CheckForNull private transient Set<Range<C>> asRanges;
- @CheckForNull private transient Set<Range<C>> asDescendingSetOfRanges;
+ private transient @Nullable Set<Range<C>> asRanges;
+ private transient @Nullable Set<Range<C>> asDescendingSetOfRanges;
@Override
public Set<Range<C>> asRanges() {
@@ -113,14 +112,13 @@
}
@Override
- public boolean equals(@CheckForNull Object o) {
+ public boolean equals(@Nullable Object o) {
return Sets.equalsImpl(this, o);
}
}
@Override
- @CheckForNull
- public Range<C> rangeContaining(C value) {
+ public @Nullable Range<C> rangeContaining(C value) {
checkNotNull(value);
Entry<Cut<C>, Range<C>> floorEntry = rangesByLowerBound.floorEntry(Cut.belowValue(value));
if (floorEntry != null && floorEntry.getValue().contains(value)) {
@@ -153,8 +151,7 @@
return floorEntry != null && floorEntry.getValue().encloses(range);
}
- @CheckForNull
- private Range<C> rangeEnclosing(Range<C> range) {
+ private @Nullable Range<C> rangeEnclosing(Range<C> range) {
checkNotNull(range);
Entry<Cut<C>, Range<C>> floorEntry = rangesByLowerBound.floorEntry(range.lowerBound);
return (floorEntry != null && floorEntry.getValue().encloses(range))
@@ -166,11 +163,7 @@
public Range<C> span() {
Entry<Cut<C>, Range<C>> firstEntry = rangesByLowerBound.firstEntry();
Entry<Cut<C>, Range<C>> lastEntry = rangesByLowerBound.lastEntry();
- if (firstEntry == null || lastEntry == null) {
- /*
- * Either both are null or neither is: Either the set is empty, or it's not. But we check both
- * to make the nullness checker happy.
- */
+ if (firstEntry == null) {
throw new NoSuchElementException();
}
return Range.create(firstEntry.getValue().lowerBound, lastEntry.getValue().upperBound);
@@ -274,7 +267,7 @@
}
}
- @CheckForNull private transient RangeSet<C> complement;
+ private transient @Nullable RangeSet<C> complement;
@Override
public RangeSet<C> complement() {
@@ -337,13 +330,12 @@
}
@Override
- public boolean containsKey(@CheckForNull Object key) {
+ public boolean containsKey(@Nullable Object key) {
return get(key) != null;
}
@Override
- @CheckForNull
- public Range<C> get(@CheckForNull Object key) {
+ public Range<C> get(@Nullable Object key) {
if (key instanceof Cut) {
try {
@SuppressWarnings("unchecked") // we catch CCEs
@@ -388,7 +380,6 @@
}
return new AbstractIterator<Entry<Cut<C>, Range<C>>>() {
@Override
- @CheckForNull
protected Entry<Cut<C>, Range<C>> computeNext() {
if (!backingItr.hasNext()) {
return endOfData();
@@ -422,7 +413,6 @@
}
return new AbstractIterator<Entry<Cut<C>, Range<C>>>() {
@Override
- @CheckForNull
protected Entry<Cut<C>, Range<C>> computeNext() {
if (!backingItr.hasNext()) {
return endOfData();
@@ -544,7 +534,6 @@
Cut<C> nextComplementRangeLowerBound = firstComplementRangeLowerBound;
@Override
- @CheckForNull
protected Entry<Cut<C>, Range<C>> computeNext() {
if (complementLowerBoundWindow.upperBound.isLessThan(nextComplementRangeLowerBound)
|| nextComplementRangeLowerBound == Cut.<C>aboveAll()) {
@@ -606,7 +595,6 @@
Cut<C> nextComplementRangeUpperBound = firstComplementRangeUpperBound;
@Override
- @CheckForNull
protected Entry<Cut<C>, Range<C>> computeNext() {
if (nextComplementRangeUpperBound == Cut.<C>belowAll()) {
return endOfData();
@@ -634,8 +622,7 @@
}
@Override
- @CheckForNull
- public Range<C> get(@CheckForNull Object key) {
+ public @Nullable Range<C> get(Object key) {
if (key instanceof Cut) {
try {
@SuppressWarnings("unchecked")
@@ -653,7 +640,7 @@
}
@Override
- public boolean containsKey(@CheckForNull Object key) {
+ public boolean containsKey(Object key) {
return get(key) != null;
}
}
@@ -747,13 +734,12 @@
}
@Override
- public boolean containsKey(@CheckForNull Object key) {
+ public boolean containsKey(@Nullable Object key) {
return get(key) != null;
}
@Override
- @CheckForNull
- public Range<C> get(@CheckForNull Object key) {
+ public @Nullable Range<C> get(@Nullable Object key) {
if (key instanceof Cut) {
try {
@SuppressWarnings("unchecked") // we catch CCE's
@@ -808,7 +794,6 @@
.min(lowerBoundWindow.upperBound, Cut.belowValue(restriction.upperBound));
return new AbstractIterator<Entry<Cut<C>, Range<C>>>() {
@Override
- @CheckForNull
protected Entry<Cut<C>, Range<C>> computeNext() {
if (!completeRangeItr.hasNext()) {
return endOfData();
@@ -842,7 +827,6 @@
.iterator();
return new AbstractIterator<Entry<Cut<C>, Range<C>>>() {
@Override
- @CheckForNull
protected Entry<Cut<C>, Range<C>> computeNext() {
if (!completeRangeItr.hasNext()) {
return endOfData();
@@ -892,8 +876,7 @@
}
@Override
- @CheckForNull
- public Range<C> rangeContaining(C value) {
+ public @Nullable Range<C> rangeContaining(C value) {
if (!restriction.contains(value)) {
return null;
}
diff --git a/guava/src/com/google/common/collect/TreeTraverser.java b/guava/src/com/google/common/collect/TreeTraverser.java
index b5d2a42..9109252 100644
--- a/guava/src/com/google/common/collect/TreeTraverser.java
+++ b/guava/src/com/google/common/collect/TreeTraverser.java
@@ -26,7 +26,6 @@
import java.util.Iterator;
import java.util.Queue;
import java.util.function.Consumer;
-import javax.annotation.CheckForNull;
/**
* Views elements of a type {@code T} as nodes in a tree, and provides methods to traverse the trees
@@ -75,7 +74,6 @@
@Deprecated
@Beta
@GwtCompatible
-@ElementTypesAreNonnullByDefault
public abstract class TreeTraverser<T> {
/**
@@ -224,7 +222,6 @@
}
@Override
- @CheckForNull
protected T computeNext() {
while (!stack.isEmpty()) {
PostOrderNode<T> top = stack.getLast();
diff --git a/guava/src/com/google/common/collect/UnmodifiableIterator.java b/guava/src/com/google/common/collect/UnmodifiableIterator.java
index 03e52aa..f0f76b2 100644
--- a/guava/src/com/google/common/collect/UnmodifiableIterator.java
+++ b/guava/src/com/google/common/collect/UnmodifiableIterator.java
@@ -17,9 +17,7 @@
package com.google.common.collect;
import com.google.common.annotations.GwtCompatible;
-import com.google.errorprone.annotations.DoNotCall;
import java.util.Iterator;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* An iterator that does not support {@link #remove}.
@@ -32,8 +30,7 @@
* @since 2.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-public abstract class UnmodifiableIterator<E extends @Nullable Object> implements Iterator<E> {
+public abstract class UnmodifiableIterator<E> implements Iterator<E> {
/** Constructor for use by subclasses. */
protected UnmodifiableIterator() {}
@@ -45,7 +42,6 @@
*/
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
public final void remove() {
throw new UnsupportedOperationException();
}
diff --git a/guava/src/com/google/common/collect/UnmodifiableListIterator.java b/guava/src/com/google/common/collect/UnmodifiableListIterator.java
index f3d3b92..ec4219c 100644
--- a/guava/src/com/google/common/collect/UnmodifiableListIterator.java
+++ b/guava/src/com/google/common/collect/UnmodifiableListIterator.java
@@ -17,9 +17,7 @@
package com.google.common.collect;
import com.google.common.annotations.GwtCompatible;
-import com.google.errorprone.annotations.DoNotCall;
import java.util.ListIterator;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* A list iterator that does not support {@link #remove}, {@link #add}, or {@link #set}.
@@ -28,9 +26,8 @@
* @author Louis Wasserman
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-public abstract class UnmodifiableListIterator<E extends @Nullable Object>
- extends UnmodifiableIterator<E> implements ListIterator<E> {
+public abstract class UnmodifiableListIterator<E> extends UnmodifiableIterator<E>
+ implements ListIterator<E> {
/** Constructor for use by subclasses. */
protected UnmodifiableListIterator() {}
@@ -42,8 +39,7 @@
*/
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
- public final void add(@ParametricNullness E e) {
+ public final void add(E e) {
throw new UnsupportedOperationException();
}
@@ -55,8 +51,7 @@
*/
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
- public final void set(@ParametricNullness E e) {
+ public final void set(E e) {
throw new UnsupportedOperationException();
}
}
diff --git a/guava/src/com/google/common/collect/UnmodifiableSortedMultiset.java b/guava/src/com/google/common/collect/UnmodifiableSortedMultiset.java
index 59bd2ce..d7a20cc 100644
--- a/guava/src/com/google/common/collect/UnmodifiableSortedMultiset.java
+++ b/guava/src/com/google/common/collect/UnmodifiableSortedMultiset.java
@@ -20,7 +20,6 @@
import com.google.common.collect.Multisets.UnmodifiableMultiset;
import java.util.Comparator;
import java.util.NavigableSet;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -31,8 +30,7 @@
* @author Louis Wasserman
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
-final class UnmodifiableSortedMultiset<E extends @Nullable Object> extends UnmodifiableMultiset<E>
+final class UnmodifiableSortedMultiset<E> extends UnmodifiableMultiset<E>
implements SortedMultiset<E> {
UnmodifiableSortedMultiset(SortedMultiset<E> delegate) {
super(delegate);
@@ -58,7 +56,7 @@
return (NavigableSet<E>) super.elementSet();
}
- @CheckForNull private transient UnmodifiableSortedMultiset<E> descendingMultiset;
+ private transient @Nullable UnmodifiableSortedMultiset<E> descendingMultiset;
@Override
public SortedMultiset<E> descendingMultiset() {
@@ -72,46 +70,39 @@
}
@Override
- @CheckForNull
public Entry<E> firstEntry() {
return delegate().firstEntry();
}
@Override
- @CheckForNull
public Entry<E> lastEntry() {
return delegate().lastEntry();
}
@Override
- @CheckForNull
public Entry<E> pollFirstEntry() {
throw new UnsupportedOperationException();
}
@Override
- @CheckForNull
public Entry<E> pollLastEntry() {
throw new UnsupportedOperationException();
}
@Override
- public SortedMultiset<E> headMultiset(@ParametricNullness E upperBound, BoundType boundType) {
+ public SortedMultiset<E> headMultiset(E upperBound, BoundType boundType) {
return Multisets.unmodifiableSortedMultiset(delegate().headMultiset(upperBound, boundType));
}
@Override
public SortedMultiset<E> subMultiset(
- @ParametricNullness E lowerBound,
- BoundType lowerBoundType,
- @ParametricNullness E upperBound,
- BoundType upperBoundType) {
+ E lowerBound, BoundType lowerBoundType, E upperBound, BoundType upperBoundType) {
return Multisets.unmodifiableSortedMultiset(
delegate().subMultiset(lowerBound, lowerBoundType, upperBound, upperBoundType));
}
@Override
- public SortedMultiset<E> tailMultiset(@ParametricNullness E lowerBound, BoundType boundType) {
+ public SortedMultiset<E> tailMultiset(E lowerBound, BoundType boundType) {
return Multisets.unmodifiableSortedMultiset(delegate().tailMultiset(lowerBound, boundType));
}
diff --git a/guava/src/com/google/common/collect/UsingToStringOrdering.java b/guava/src/com/google/common/collect/UsingToStringOrdering.java
index 3443b43..3167946 100644
--- a/guava/src/com/google/common/collect/UsingToStringOrdering.java
+++ b/guava/src/com/google/common/collect/UsingToStringOrdering.java
@@ -21,7 +21,6 @@
/** An ordering that uses the natural order of the string representation of the values. */
@GwtCompatible(serializable = true)
-@ElementTypesAreNonnullByDefault
final class UsingToStringOrdering extends Ordering<Object> implements Serializable {
static final UsingToStringOrdering INSTANCE = new UsingToStringOrdering();
diff --git a/guava/src/com/google/common/collect/package-info.java b/guava/src/com/google/common/collect/package-info.java
index d46e65f..f9f6758 100644
--- a/guava/src/com/google/common/collect/package-info.java
+++ b/guava/src/com/google/common/collect/package-info.java
@@ -97,7 +97,6 @@
*
* <ul>
* <li>{@link com.google.common.collect.ImmutableMultiset}
- * <li>{@link com.google.common.collect.ImmutableSortedMultiset}
* <li>{@link com.google.common.collect.HashMultiset}
* <li>{@link com.google.common.collect.LinkedHashMultiset}
* <li>{@link com.google.common.collect.TreeMultiset}
diff --git a/guava/src/com/google/common/escape/ArrayBasedCharEscaper.java b/guava/src/com/google/common/escape/ArrayBasedCharEscaper.java
index 20e8563..91e48e6 100644
--- a/guava/src/com/google/common/escape/ArrayBasedCharEscaper.java
+++ b/guava/src/com/google/common/escape/ArrayBasedCharEscaper.java
@@ -19,7 +19,6 @@
import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtCompatible;
import java.util.Map;
-import javax.annotation.CheckForNull;
/**
* A {@link CharEscaper} that uses an array to quickly look up replacement characters for a given
@@ -43,7 +42,6 @@
*/
@Beta
@GwtCompatible
-@ElementTypesAreNonnullByDefault
public abstract class ArrayBasedCharEscaper extends CharEscaper {
// The replacement array (see ArrayBasedEscaperMap).
private final char[][] replacements;
@@ -119,11 +117,8 @@
* Escapes a single character using the replacement array and safe range values. If the given
* character does not have an explicit replacement and lies outside the safe range then {@link
* #escapeUnsafe} is called.
- *
- * @return the replacement characters, or {@code null} if no escaping was required
*/
@Override
- @CheckForNull
protected final char[] escape(char c) {
if (c < replacementsLength) {
char[] chars = replacements[c];
@@ -150,6 +145,5 @@
* @return the replacement characters, or {@code null} if no escaping was required
*/
// TODO(dbeaumont,cpovirk): Rename this something better once refactoring done
- @CheckForNull
protected abstract char[] escapeUnsafe(char c);
}
diff --git a/guava/src/com/google/common/escape/ArrayBasedEscaperMap.java b/guava/src/com/google/common/escape/ArrayBasedEscaperMap.java
index a0883fe..400c3b1 100644
--- a/guava/src/com/google/common/escape/ArrayBasedEscaperMap.java
+++ b/guava/src/com/google/common/escape/ArrayBasedEscaperMap.java
@@ -38,7 +38,6 @@
*/
@Beta
@GwtCompatible
-@ElementTypesAreNonnullByDefault
public final class ArrayBasedEscaperMap {
/**
* Returns a new ArrayBasedEscaperMap for creating ArrayBasedCharEscaper or
@@ -74,7 +73,7 @@
}
char max = Collections.max(map.keySet());
char[][] replacements = new char[max + 1][];
- for (Character c : map.keySet()) {
+ for (char c : map.keySet()) {
replacements[c] = map.get(c).toCharArray();
}
return replacements;
diff --git a/guava/src/com/google/common/escape/ArrayBasedUnicodeEscaper.java b/guava/src/com/google/common/escape/ArrayBasedUnicodeEscaper.java
index 5ea7807..756abce 100644
--- a/guava/src/com/google/common/escape/ArrayBasedUnicodeEscaper.java
+++ b/guava/src/com/google/common/escape/ArrayBasedUnicodeEscaper.java
@@ -19,7 +19,6 @@
import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtCompatible;
import java.util.Map;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -43,7 +42,6 @@
*/
@Beta
@GwtCompatible
-@ElementTypesAreNonnullByDefault
public abstract class ArrayBasedUnicodeEscaper extends UnicodeEscaper {
// The replacement array (see ArrayBasedEscaperMap).
private final char[][] replacements;
@@ -159,11 +157,8 @@
* Escapes a single Unicode code point using the replacement array and safe range values. If the
* given character does not have an explicit replacement and lies outside the safe range then
* {@link #escapeUnsafe} is called.
- *
- * @return the replacement characters, or {@code null} if no escaping was required
*/
@Override
- @CheckForNull
protected final char[] escape(int cp) {
if (cp < replacementsLength) {
char[] chars = replacements[cp];
@@ -204,6 +199,5 @@
* @param cp the Unicode code point to escape
* @return the replacement characters, or {@code null} if no escaping was required
*/
- @CheckForNull
protected abstract char[] escapeUnsafe(int cp);
}
diff --git a/guava/src/com/google/common/escape/CharEscaper.java b/guava/src/com/google/common/escape/CharEscaper.java
index 55090f6..b8ffee3 100644
--- a/guava/src/com/google/common/escape/CharEscaper.java
+++ b/guava/src/com/google/common/escape/CharEscaper.java
@@ -18,7 +18,6 @@
import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtCompatible;
-import javax.annotation.CheckForNull;
/**
* An object that converts literal text into a format safe for inclusion in a particular context
@@ -42,7 +41,6 @@
*/
@Beta
@GwtCompatible
-@ElementTypesAreNonnullByDefault
public abstract class CharEscaper extends Escaper {
/** Constructor for use by subclasses. */
protected CharEscaper() {}
@@ -82,7 +80,6 @@
* @param c the character to escape if necessary
* @return the replacement characters, or {@code null} if no escaping was needed
*/
- @CheckForNull
protected abstract char[] escape(char c);
/**
diff --git a/guava/src/com/google/common/escape/CharEscaperBuilder.java b/guava/src/com/google/common/escape/CharEscaperBuilder.java
index cbe6958..dba855f 100644
--- a/guava/src/com/google/common/escape/CharEscaperBuilder.java
+++ b/guava/src/com/google/common/escape/CharEscaperBuilder.java
@@ -22,8 +22,6 @@
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Simple helper class to build a "sparse" array of objects based on the indexes that were added to
@@ -36,17 +34,16 @@
*/
@Beta
@GwtCompatible
-@ElementTypesAreNonnullByDefault
public final class CharEscaperBuilder {
/**
* Simple decorator that turns an array of replacement char[]s into a CharEscaper, this results in
* a very fast escape method.
*/
private static class CharArrayDecorator extends CharEscaper {
- private final char[] @Nullable [] replacements;
+ private final char[][] replacements;
private final int replaceLength;
- CharArrayDecorator(char[] @Nullable [] replacements) {
+ CharArrayDecorator(char[][] replacements) {
this.replacements = replacements;
this.replaceLength = replacements.length;
}
@@ -68,7 +65,6 @@
}
@Override
- @CheckForNull
protected char[] escape(char c) {
return c < replaceLength ? replacements[c] : null;
}
@@ -112,7 +108,7 @@
*
* @return a "sparse" array that holds the replacement mappings.
*/
- public char[] @Nullable [] toArray() {
+ public char[][] toArray() {
char[][] result = new char[max + 1][];
for (Entry<Character, String> entry : map.entrySet()) {
result[entry.getKey()] = entry.getValue().toCharArray();
diff --git a/guava/src/com/google/common/escape/ElementTypesAreNonnullByDefault.java b/guava/src/com/google/common/escape/ElementTypesAreNonnullByDefault.java
deleted file mode 100644
index 992c9a3..0000000
--- a/guava/src/com/google/common/escape/ElementTypesAreNonnullByDefault.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) 2021 The Guava Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.common.escape;
-
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.PARAMETER;
-import static java.lang.annotation.ElementType.TYPE;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-import com.google.common.annotations.GwtCompatible;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-import javax.annotation.Nonnull;
-import javax.annotation.meta.TypeQualifierDefault;
-
-/**
- * Marks all "top-level" types as non-null in a way that is recognized by Kotlin. Note that this
- * unfortunately includes type-variable usages, so we also provide {@link ParametricNullness} to
- * "undo" it as best we can.
- */
-@GwtCompatible
-@Retention(RUNTIME)
-@Target(TYPE)
-@TypeQualifierDefault({FIELD, METHOD, PARAMETER})
-@Nonnull
-@interface ElementTypesAreNonnullByDefault {}
diff --git a/guava/src/com/google/common/escape/Escaper.java b/guava/src/com/google/common/escape/Escaper.java
index cdfe4e9..0d32a09 100644
--- a/guava/src/com/google/common/escape/Escaper.java
+++ b/guava/src/com/google/common/escape/Escaper.java
@@ -56,7 +56,6 @@
*/
@DoNotMock("Use Escapers.nullEscaper() or another methods from the *Escapers classes")
@GwtCompatible
-@ElementTypesAreNonnullByDefault
public abstract class Escaper {
// TODO(dbeaumont): evaluate custom implementations, considering package private constructor.
/** Constructor for use by subclasses. */
diff --git a/guava/src/com/google/common/escape/Escapers.java b/guava/src/com/google/common/escape/Escapers.java
index 41af668..6fa8365 100644
--- a/guava/src/com/google/common/escape/Escapers.java
+++ b/guava/src/com/google/common/escape/Escapers.java
@@ -21,7 +21,6 @@
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import java.util.HashMap;
import java.util.Map;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -33,7 +32,6 @@
*/
@Beta
@GwtCompatible
-@ElementTypesAreNonnullByDefault
public final class Escapers {
private Escapers() {}
@@ -54,7 +52,6 @@
}
@Override
- @CheckForNull
protected char[] escape(char c) {
// TODO: Fix tests not to call this directly and make it throw an error.
return null;
@@ -98,7 +95,7 @@
private final Map<Character, String> replacementMap = new HashMap<>();
private char safeMin = Character.MIN_VALUE;
private char safeMax = Character.MAX_VALUE;
- @CheckForNull private String unsafeReplacement = null;
+ private String unsafeReplacement = null;
// The constructor is exposed via the builder() method above.
private Builder() {}
@@ -154,12 +151,10 @@
/** Returns a new escaper based on the current state of the builder. */
public Escaper build() {
return new ArrayBasedCharEscaper(replacementMap, safeMin, safeMax) {
- @CheckForNull
private final char[] replacementChars =
unsafeReplacement != null ? unsafeReplacement.toCharArray() : null;
@Override
- @CheckForNull
protected char[] escapeUnsafe(char c) {
return replacementChars;
}
@@ -203,7 +198,6 @@
* @param c the character to escape if necessary
* @return the replacement string, or {@code null} if no escaping was needed
*/
- @CheckForNull
public static String computeReplacement(CharEscaper escaper, char c) {
return stringOrNull(escaper.escape(c));
}
@@ -217,13 +211,11 @@
* @param cp the Unicode code point to escape if necessary
* @return the replacement string, or {@code null} if no escaping was needed
*/
- @CheckForNull
public static String computeReplacement(UnicodeEscaper escaper, int cp) {
return stringOrNull(escaper.escape(cp));
}
- @CheckForNull
- private static String stringOrNull(@CheckForNull char[] in) {
+ private static String stringOrNull(char[] in) {
return (in == null) ? null : new String(in);
}
@@ -231,7 +223,6 @@
private static UnicodeEscaper wrap(final CharEscaper escaper) {
return new UnicodeEscaper() {
@Override
- @CheckForNull
protected char[] escape(int cp) {
// If a code point maps to a single character, just escape that.
if (cp < Character.MIN_SUPPLEMENTARY_CODE_POINT) {
diff --git a/guava/src/com/google/common/escape/ParametricNullness.java b/guava/src/com/google/common/escape/ParametricNullness.java
deleted file mode 100644
index 2f03d59..0000000
--- a/guava/src/com/google/common/escape/ParametricNullness.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2021 The Guava Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.common.escape;
-
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.PARAMETER;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-import static javax.annotation.meta.When.UNKNOWN;
-
-import com.google.common.annotations.GwtCompatible;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-import javax.annotation.Nonnull;
-import javax.annotation.meta.TypeQualifierNickname;
-
-/**
- * Marks a "top-level" type-variable usage as (a) a Kotlin platform type when the type argument is
- * non-nullable and (b) nullable when the type argument is nullable. This is the closest we can get
- * to "non-nullable when non-nullable; nullable when nullable" (like the Android <a
- * href="https://android.googlesource.com/platform/libcore/+/master/luni/src/main/java/libcore/util/NullFromTypeParam.java">{@code
- * NullFromTypeParam}</a>). We use this to "undo" {@link ElementTypesAreNonnullByDefault}.
- */
-@GwtCompatible
-@Retention(RUNTIME)
-@Target({FIELD, METHOD, PARAMETER})
-@TypeQualifierNickname
-@Nonnull(when = UNKNOWN)
-@interface ParametricNullness {}
diff --git a/guava/src/com/google/common/escape/Platform.java b/guava/src/com/google/common/escape/Platform.java
index dc6610c..99a7d4f 100644
--- a/guava/src/com/google/common/escape/Platform.java
+++ b/guava/src/com/google/common/escape/Platform.java
@@ -22,7 +22,6 @@
* @author Jesse Wilson
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
final class Platform {
private Platform() {}
diff --git a/guava/src/com/google/common/escape/UnicodeEscaper.java b/guava/src/com/google/common/escape/UnicodeEscaper.java
index c10ae34..0642162 100644
--- a/guava/src/com/google/common/escape/UnicodeEscaper.java
+++ b/guava/src/com/google/common/escape/UnicodeEscaper.java
@@ -18,7 +18,6 @@
import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtCompatible;
-import javax.annotation.CheckForNull;
/**
* An {@link Escaper} that converts literal text into a format safe for inclusion in a particular
@@ -52,7 +51,6 @@
*/
@Beta
@GwtCompatible
-@ElementTypesAreNonnullByDefault
public abstract class UnicodeEscaper extends Escaper {
/** The amount of padding (chars) to use when growing the escape buffer. */
private static final int DEST_PAD = 32;
@@ -79,7 +77,6 @@
* @param cp the Unicode code point to escape if necessary
* @return the replacement characters, or {@code null} if no escaping was needed
*/
- @CheckForNull
protected abstract char[] escape(int cp);
/**
diff --git a/guava/src/com/google/common/eventbus/AllowConcurrentEvents.java b/guava/src/com/google/common/eventbus/AllowConcurrentEvents.java
index 28bc4b2..4c749b4 100644
--- a/guava/src/com/google/common/eventbus/AllowConcurrentEvents.java
+++ b/guava/src/com/google/common/eventbus/AllowConcurrentEvents.java
@@ -14,6 +14,7 @@
package com.google.common.eventbus;
+import com.google.common.annotations.Beta;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -30,5 +31,5 @@
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
-@ElementTypesAreNonnullByDefault
+@Beta
public @interface AllowConcurrentEvents {}
diff --git a/guava/src/com/google/common/eventbus/AsyncEventBus.java b/guava/src/com/google/common/eventbus/AsyncEventBus.java
index 4f387a7..8650a8d 100644
--- a/guava/src/com/google/common/eventbus/AsyncEventBus.java
+++ b/guava/src/com/google/common/eventbus/AsyncEventBus.java
@@ -14,6 +14,7 @@
package com.google.common.eventbus;
+import com.google.common.annotations.Beta;
import java.util.concurrent.Executor;
/**
@@ -23,7 +24,7 @@
* @author Cliff Biffle
* @since 10.0
*/
-@ElementTypesAreNonnullByDefault
+@Beta
public class AsyncEventBus extends EventBus {
/**
diff --git a/guava/src/com/google/common/eventbus/DeadEvent.java b/guava/src/com/google/common/eventbus/DeadEvent.java
index 2cdb23f..6dbfee5 100644
--- a/guava/src/com/google/common/eventbus/DeadEvent.java
+++ b/guava/src/com/google/common/eventbus/DeadEvent.java
@@ -16,6 +16,7 @@
import static com.google.common.base.Preconditions.checkNotNull;
+import com.google.common.annotations.Beta;
import com.google.common.base.MoreObjects;
/**
@@ -27,7 +28,7 @@
* @author Cliff Biffle
* @since 10.0
*/
-@ElementTypesAreNonnullByDefault
+@Beta
public class DeadEvent {
private final Object source;
diff --git a/guava/src/com/google/common/eventbus/Dispatcher.java b/guava/src/com/google/common/eventbus/Dispatcher.java
index ff1ae2a..11e2de1 100644
--- a/guava/src/com/google/common/eventbus/Dispatcher.java
+++ b/guava/src/com/google/common/eventbus/Dispatcher.java
@@ -31,7 +31,6 @@
*
* @author Colin Decker
*/
-@ElementTypesAreNonnullByDefault
abstract class Dispatcher {
/**
diff --git a/guava/src/com/google/common/eventbus/ElementTypesAreNonnullByDefault.java b/guava/src/com/google/common/eventbus/ElementTypesAreNonnullByDefault.java
deleted file mode 100644
index e8542bb..0000000
--- a/guava/src/com/google/common/eventbus/ElementTypesAreNonnullByDefault.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) 2021 The Guava Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.common.eventbus;
-
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.PARAMETER;
-import static java.lang.annotation.ElementType.TYPE;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-import com.google.common.annotations.GwtCompatible;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-import javax.annotation.Nonnull;
-import javax.annotation.meta.TypeQualifierDefault;
-
-/**
- * Marks all "top-level" types as non-null in a way that is recognized by Kotlin. Note that this
- * unfortunately includes type-variable usages, so we also provide {@link ParametricNullness} to
- * "undo" it as best we can.
- */
-@GwtCompatible
-@Retention(RUNTIME)
-@Target(TYPE)
-@TypeQualifierDefault({FIELD, METHOD, PARAMETER})
-@Nonnull
-@interface ElementTypesAreNonnullByDefault {}
diff --git a/guava/src/com/google/common/eventbus/EventBus.java b/guava/src/com/google/common/eventbus/EventBus.java
index 4afc197..e505399 100644
--- a/guava/src/com/google/common/eventbus/EventBus.java
+++ b/guava/src/com/google/common/eventbus/EventBus.java
@@ -16,6 +16,7 @@
import static com.google.common.base.Preconditions.checkNotNull;
+import com.google.common.annotations.Beta;
import com.google.common.base.MoreObjects;
import com.google.common.util.concurrent.MoreExecutors;
import java.lang.reflect.Method;
@@ -28,62 +29,6 @@
/**
* Dispatches events to listeners, and provides ways for listeners to register themselves.
*
- * <h2>Avoid EventBus</h2>
- *
- * <p><b>We recommend against using EventBus.</b> It was designed many years ago, and newer
- * libraries offer better ways to decouple components and react to events.
- *
- * <p>To decouple components, we recommend a dependency-injection framework. For Android code, most
- * apps use <a href="https://dagger.dev">Dagger</a>. For server code, common options include <a
- * href="https://github.com/google/guice/wiki/Motivation">Guice</a> and <a
- * href="https://docs.spring.io/spring-framework/docs/current/reference/html/core.html#beans-introduction">Spring</a>.
- * Frameworks typically offer a way to register multiple listeners independently and then request
- * them together as a set (<a href="https://dagger.dev/dev-guide/multibindings">Dagger</a>, <a
- * href="https://github.com/google/guice/wiki/Multibindings">Guice</a>, <a
- * href="https://docs.spring.io/spring-framework/docs/current/reference/html/core.html#beans-autowired-annotation">Spring</a>).
- *
- * <p>To react to events, we recommend a reactive-streams framework like <a
- * href="https://github.com/ReactiveX/RxJava/wiki">RxJava</a> (supplemented with its <a
- * href="https://github.com/ReactiveX/RxAndroid">RxAndroid</a> extension if you are building for
- * Android) or <a href="https://projectreactor.io/">Project Reactor</a>. (For the basics of
- * translating code from using an event bus to using a reactive-streams framework, see these two
- * guides: <a href="https://blog.jkl.gg/implementing-an-event-bus-with-rxjava-rxbus/">1</a>, <a
- * href="https://lorentzos.com/rxjava-as-event-bus-the-right-way-10a36bdd49ba">2</a>.) Some usages
- * of EventBus may be better written using <a
- * href="https://kotlinlang.org/docs/coroutines-guide.html">Kotlin coroutines</a>, including <a
- * href="https://kotlinlang.org/docs/flow.html">Flow</a> and <a
- * href="https://kotlinlang.org/docs/channels.html">Channels</a>. Yet other usages are better served
- * by individual libraries that provide specialized support for particular use cases.
- *
- * <p>Disadvantages of EventBus include:
- *
- * <ul>
- * <li>It makes the cross-references between producer and subscriber harder to find. This can
- * complicate debugging, lead to unintentional reentrant calls, and force apps to eagerly
- * initialize all possible subscribers at startup time.
- * <li>It uses reflection in ways that break when code is processed by optimizers/minimizers like
- * <a href="https://developer.android.com/studio/build/shrink-code">R8 and Proguard</a>.
- * <li>It doesn't offer a way to wait for multiple events before taking action. For example, it
- * doesn't offer a way to wait for multiple producers to all report that they're "ready," nor
- * does it offer a way to batch multiple events from a single producer together.
- * <li>It doesn't support backpressure and other features needed for resilience.
- * <li>It doesn't provide much control of threading.
- * <li>It doesn't offer much monitoring.
- * <li>It doesn't propagate exceptions, so apps don't have a way to react to them.
- * <li>It doesn't interoperate well with RxJava, coroutines, and other more commonly used
- * alternatives.
- * <li>It imposes requirements on the lifecycle of its subscribers. For example, if an event
- * occurs between when one subscriber is removed and the next subscriber is added, the event
- * is dropped.
- * <li>Its performance is suboptimal, especially under Android.
- * <li>It <a href="https://github.com/google/guava/issues/1431">doesn't support parameterized
- * types</a>.
- * <li>With the introduction of lambdas in Java 8, EventBus went from less verbose than listeners
- * to <a href="https://github.com/google/guava/issues/3311">more verbose</a>.
- * </ul>
- *
- * <h2>EventBus Summary</h2>
- *
* <p>The EventBus allows publish-subscribe-style communication between components without requiring
* the components to explicitly register with one another (and thus be aware of each other). It is
* designed exclusively to replace traditional Java in-process event distribution using explicit
@@ -147,7 +92,7 @@
* @author Cliff Biffle
* @since 10.0
*/
-@ElementTypesAreNonnullByDefault
+@Beta
public class EventBus {
private static final Logger logger = Logger.getLogger(EventBus.class.getName());
diff --git a/guava/src/com/google/common/eventbus/ParametricNullness.java b/guava/src/com/google/common/eventbus/ParametricNullness.java
deleted file mode 100644
index fc5bb17..0000000
--- a/guava/src/com/google/common/eventbus/ParametricNullness.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2021 The Guava Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.common.eventbus;
-
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.PARAMETER;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-import static javax.annotation.meta.When.UNKNOWN;
-
-import com.google.common.annotations.GwtCompatible;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-import javax.annotation.Nonnull;
-import javax.annotation.meta.TypeQualifierNickname;
-
-/**
- * Marks a "top-level" type-variable usage as (a) a Kotlin platform type when the type argument is
- * non-nullable and (b) nullable when the type argument is nullable. This is the closest we can get
- * to "non-nullable when non-nullable; nullable when nullable" (like the Android <a
- * href="https://android.googlesource.com/platform/libcore/+/master/luni/src/main/java/libcore/util/NullFromTypeParam.java">{@code
- * NullFromTypeParam}</a>). We use this to "undo" {@link ElementTypesAreNonnullByDefault}.
- */
-@GwtCompatible
-@Retention(RUNTIME)
-@Target({FIELD, METHOD, PARAMETER})
-@TypeQualifierNickname
-@Nonnull(when = UNKNOWN)
-@interface ParametricNullness {}
diff --git a/guava/src/com/google/common/eventbus/Subscribe.java b/guava/src/com/google/common/eventbus/Subscribe.java
index 88477f1..52b999d 100644
--- a/guava/src/com/google/common/eventbus/Subscribe.java
+++ b/guava/src/com/google/common/eventbus/Subscribe.java
@@ -14,6 +14,7 @@
package com.google.common.eventbus;
+import com.google.common.annotations.Beta;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -35,5 +36,5 @@
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
-@ElementTypesAreNonnullByDefault
+@Beta
public @interface Subscribe {}
diff --git a/guava/src/com/google/common/eventbus/Subscriber.java b/guava/src/com/google/common/eventbus/Subscriber.java
index 73e7f42..ddc4963 100644
--- a/guava/src/com/google/common/eventbus/Subscriber.java
+++ b/guava/src/com/google/common/eventbus/Subscriber.java
@@ -21,7 +21,7 @@
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.concurrent.Executor;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* A subscriber method on a specific object, plus the executor that should be used for dispatching
@@ -32,7 +32,6 @@
*
* @author Colin Decker
*/
-@ElementTypesAreNonnullByDefault
class Subscriber {
/** Creates a {@code Subscriber} for {@code method} on {@code listener}. */
@@ -109,7 +108,7 @@
}
@Override
- public final boolean equals(@CheckForNull Object obj) {
+ public final boolean equals(@Nullable Object obj) {
if (obj instanceof Subscriber) {
Subscriber that = (Subscriber) obj;
// Use == so that different equal instances will still receive events.
diff --git a/guava/src/com/google/common/eventbus/SubscriberExceptionContext.java b/guava/src/com/google/common/eventbus/SubscriberExceptionContext.java
index 63c7d55..6ddd86f 100644
--- a/guava/src/com/google/common/eventbus/SubscriberExceptionContext.java
+++ b/guava/src/com/google/common/eventbus/SubscriberExceptionContext.java
@@ -23,7 +23,6 @@
*
* @since 16.0
*/
-@ElementTypesAreNonnullByDefault
public class SubscriberExceptionContext {
private final EventBus eventBus;
private final Object event;
@@ -32,7 +31,7 @@
/**
* @param eventBus The {@link EventBus} that handled the event and the subscriber. Useful for
- * broadcasting a new event based on the error.
+ * broadcasting a a new event based on the error.
* @param event The event object that caused the subscriber to throw.
* @param subscriber The source subscriber context.
* @param subscriberMethod the subscribed method.
@@ -47,7 +46,7 @@
/**
* @return The {@link EventBus} that handled the event and the subscriber. Useful for broadcasting
- * a new event based on the error.
+ * a a new event based on the error.
*/
public EventBus getEventBus() {
return eventBus;
diff --git a/guava/src/com/google/common/eventbus/SubscriberExceptionHandler.java b/guava/src/com/google/common/eventbus/SubscriberExceptionHandler.java
index 1c2fbb1..c239ad7 100644
--- a/guava/src/com/google/common/eventbus/SubscriberExceptionHandler.java
+++ b/guava/src/com/google/common/eventbus/SubscriberExceptionHandler.java
@@ -14,13 +14,11 @@
package com.google.common.eventbus;
-
/**
* Handler for exceptions thrown by event subscribers.
*
* @since 16.0
*/
-@ElementTypesAreNonnullByDefault
public interface SubscriberExceptionHandler {
/** Handles exceptions thrown by subscribers. */
void handleException(Throwable exception, SubscriberExceptionContext context);
diff --git a/guava/src/com/google/common/eventbus/SubscriberRegistry.java b/guava/src/com/google/common/eventbus/SubscriberRegistry.java
index 46e9820..876af8b 100644
--- a/guava/src/com/google/common/eventbus/SubscriberRegistry.java
+++ b/guava/src/com/google/common/eventbus/SubscriberRegistry.java
@@ -46,14 +46,13 @@
import java.util.Set;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.CopyOnWriteArraySet;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Registry of subscribers to a single event bus.
*
* @author Colin Decker
*/
-@ElementTypesAreNonnullByDefault
final class SubscriberRegistry {
/**
@@ -259,7 +258,7 @@
}
@Override
- public boolean equals(@CheckForNull Object o) {
+ public boolean equals(@Nullable Object o) {
if (o instanceof MethodIdentifier) {
MethodIdentifier ident = (MethodIdentifier) o;
return name.equals(ident.name) && parameterTypes.equals(ident.parameterTypes);
diff --git a/guava/src/com/google/common/graph/AbstractBaseGraph.java b/guava/src/com/google/common/graph/AbstractBaseGraph.java
index c4be6b6..352df19 100644
--- a/guava/src/com/google/common/graph/AbstractBaseGraph.java
+++ b/guava/src/com/google/common/graph/AbstractBaseGraph.java
@@ -30,7 +30,7 @@
import com.google.common.primitives.Ints;
import java.util.AbstractSet;
import java.util.Set;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* This class provides a skeletal implementation of {@link BaseGraph}.
@@ -41,7 +41,6 @@
* @author James Sexton
* @param <N> Node parameter type
*/
-@ElementTypesAreNonnullByDefault
abstract class AbstractBaseGraph<N> implements BaseGraph<N> {
/**
@@ -77,7 +76,7 @@
}
@Override
- public boolean remove(@CheckForNull Object o) {
+ public boolean remove(Object o) {
throw new UnsupportedOperationException();
}
@@ -86,7 +85,7 @@
// Graph<LinkedList>.
@SuppressWarnings("unchecked")
@Override
- public boolean contains(@CheckForNull 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 ac452d4..9afaf3e 100644
--- a/guava/src/com/google/common/graph/AbstractDirectedNetworkConnections.java
+++ b/guava/src/com/google/common/graph/AbstractDirectedNetworkConnections.java
@@ -20,7 +20,6 @@
import static com.google.common.base.Preconditions.checkState;
import static com.google.common.graph.Graphs.checkNonNegative;
import static com.google.common.graph.Graphs.checkPositive;
-import static java.util.Objects.requireNonNull;
import com.google.common.collect.Iterables;
import com.google.common.collect.Iterators;
@@ -31,7 +30,7 @@
import java.util.Collections;
import java.util.Map;
import java.util.Set;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* A base implementation of {@link NetworkConnections} for directed networks.
@@ -40,17 +39,17 @@
* @param <N> Node parameter type
* @param <E> Edge parameter type
*/
-@ElementTypesAreNonnullByDefault
abstract class AbstractDirectedNetworkConnections<N, E> implements NetworkConnections<N, E> {
/** Keys are edges incoming to the origin node, values are the source node. */
- final Map<E, N> inEdgeMap;
+ protected final Map<E, N> inEdgeMap;
/** Keys are edges outgoing from the origin node, values are the target node. */
- final Map<E, N> outEdgeMap;
+ protected final Map<E, N> outEdgeMap;
private int selfLoopCount;
- AbstractDirectedNetworkConnections(Map<E, N> inEdgeMap, Map<E, N> outEdgeMap, int selfLoopCount) {
+ protected AbstractDirectedNetworkConnections(
+ Map<E, N> inEdgeMap, Map<E, N> outEdgeMap, int selfLoopCount) {
this.inEdgeMap = checkNotNull(inEdgeMap);
this.outEdgeMap = checkNotNull(outEdgeMap);
this.selfLoopCount = checkNonNegative(selfLoopCount);
@@ -80,7 +79,7 @@
}
@Override
- public boolean contains(@CheckForNull Object obj) {
+ public boolean contains(@Nullable Object obj) {
return inEdgeMap.containsKey(obj) || outEdgeMap.containsKey(obj);
}
};
@@ -100,8 +99,7 @@
public N adjacentNode(E edge) {
// Since the reference node is defined to be 'source' for directed graphs,
// we can assume this edge lives in the set of outgoing edges.
- // (We're relying on callers to call this method only with an edge that's in the graph.)
- return requireNonNull(outEdgeMap.get(edge));
+ return checkNotNull(outEdgeMap.get(edge));
}
@Override
@@ -110,15 +108,13 @@
checkNonNegative(--selfLoopCount);
}
N previousNode = inEdgeMap.remove(edge);
- // We're relying on callers to call this method only with an edge that's in the graph.
- return requireNonNull(previousNode);
+ return checkNotNull(previousNode);
}
@Override
public N removeOutEdge(E edge) {
N previousNode = outEdgeMap.remove(edge);
- // We're relying on callers to call this method only with an edge that's in the graph.
- return requireNonNull(previousNode);
+ return checkNotNull(previousNode);
}
@Override
diff --git a/guava/src/com/google/common/graph/AbstractGraph.java b/guava/src/com/google/common/graph/AbstractGraph.java
index 9402be5..986c94b 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 javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* This class provides a skeletal implementation of {@link Graph}. It is recommended to extend this
@@ -28,11 +28,10 @@
* @since 20.0
*/
@Beta
-@ElementTypesAreNonnullByDefault
public abstract class AbstractGraph<N> extends AbstractBaseGraph<N> implements Graph<N> {
@Override
- public final boolean equals(@CheckForNull Object obj) {
+ public final boolean equals(@Nullable Object obj) {
if (obj == this) {
return true;
}
diff --git a/guava/src/com/google/common/graph/AbstractGraphBuilder.java b/guava/src/com/google/common/graph/AbstractGraphBuilder.java
index a4e1543..84e461a 100644
--- a/guava/src/com/google/common/graph/AbstractGraphBuilder.java
+++ b/guava/src/com/google/common/graph/AbstractGraphBuilder.java
@@ -23,7 +23,6 @@
*
* @author James Sexton
*/
-@ElementTypesAreNonnullByDefault
abstract class AbstractGraphBuilder<N> {
final boolean directed;
boolean allowsSelfLoops = false;
diff --git a/guava/src/com/google/common/graph/AbstractNetwork.java b/guava/src/com/google/common/graph/AbstractNetwork.java
index d6bf4c3..648ee9b 100644
--- a/guava/src/com/google/common/graph/AbstractNetwork.java
+++ b/guava/src/com/google/common/graph/AbstractNetwork.java
@@ -35,7 +35,7 @@
import java.util.Map;
import java.util.Optional;
import java.util.Set;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* This class provides a skeletal implementation of {@link Network}. It is recommended to extend
@@ -50,7 +50,6 @@
* @since 20.0
*/
@Beta
-@ElementTypesAreNonnullByDefault
public abstract class AbstractNetwork<N, E> implements Network<N, E> {
@Override
@@ -91,7 +90,7 @@
// Network<LinkedList>.
@SuppressWarnings("unchecked")
@Override
- public boolean contains(@CheckForNull Object obj) {
+ public boolean contains(@Nullable Object obj) {
if (!(obj instanceof EndpointPair)) {
return false;
}
@@ -207,8 +206,7 @@
}
@Override
- @CheckForNull
- public E edgeConnectingOrNull(N nodeU, N nodeV) {
+ public @Nullable E edgeConnectingOrNull(N nodeU, N nodeV) {
Set<E> edgesConnecting = edgesConnecting(nodeU, nodeV);
switch (edgesConnecting.size()) {
case 0:
@@ -221,8 +219,7 @@
}
@Override
- @CheckForNull
- public E edgeConnectingOrNull(EndpointPair<N> endpoints) {
+ public @Nullable E edgeConnectingOrNull(EndpointPair<N> endpoints) {
validateEndpoints(endpoints);
return edgeConnectingOrNull(endpoints.nodeU(), endpoints.nodeV());
}
@@ -257,7 +254,7 @@
}
@Override
- public final boolean equals(@CheckForNull Object obj) {
+ public final boolean equals(@Nullable Object obj) {
if (obj == this) {
return true;
}
diff --git a/guava/src/com/google/common/graph/AbstractUndirectedNetworkConnections.java b/guava/src/com/google/common/graph/AbstractUndirectedNetworkConnections.java
index 8f736d7..03279d0 100644
--- a/guava/src/com/google/common/graph/AbstractUndirectedNetworkConnections.java
+++ b/guava/src/com/google/common/graph/AbstractUndirectedNetworkConnections.java
@@ -18,12 +18,10 @@
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkState;
-import static java.util.Objects.requireNonNull;
import java.util.Collections;
import java.util.Map;
import java.util.Set;
-import javax.annotation.CheckForNull;
/**
* A base implementation of {@link NetworkConnections} for undirected networks.
@@ -32,12 +30,11 @@
* @param <N> Node parameter type
* @param <E> Edge parameter type
*/
-@ElementTypesAreNonnullByDefault
abstract class AbstractUndirectedNetworkConnections<N, E> implements NetworkConnections<N, E> {
/** Keys are edges incident to the origin node, values are the node at the other end. */
- final Map<E, N> incidentEdgeMap;
+ protected final Map<E, N> incidentEdgeMap;
- AbstractUndirectedNetworkConnections(Map<E, N> incidentEdgeMap) {
+ protected AbstractUndirectedNetworkConnections(Map<E, N> incidentEdgeMap) {
this.incidentEdgeMap = checkNotNull(incidentEdgeMap);
}
@@ -68,12 +65,10 @@
@Override
public N adjacentNode(E edge) {
- // We're relying on callers to call this method only with an edge that's in the graph.
- return requireNonNull(incidentEdgeMap.get(edge));
+ return checkNotNull(incidentEdgeMap.get(edge));
}
@Override
- @CheckForNull
public N removeInEdge(E edge, boolean isSelfLoop) {
if (!isSelfLoop) {
return removeOutEdge(edge);
@@ -84,8 +79,7 @@
@Override
public N removeOutEdge(E edge) {
N previousNode = incidentEdgeMap.remove(edge);
- // We're relying on callers to call this method only with an edge that's in the graph.
- return requireNonNull(previousNode);
+ return checkNotNull(previousNode);
}
@Override
diff --git a/guava/src/com/google/common/graph/AbstractValueGraph.java b/guava/src/com/google/common/graph/AbstractValueGraph.java
index 5b8e520..c83cff5 100644
--- a/guava/src/com/google/common/graph/AbstractValueGraph.java
+++ b/guava/src/com/google/common/graph/AbstractValueGraph.java
@@ -16,15 +16,13 @@
package com.google.common.graph;
-import static java.util.Objects.requireNonNull;
-
import com.google.common.annotations.Beta;
import com.google.common.base.Function;
import com.google.common.collect.Maps;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* This class provides a skeletal implementation of {@link ValueGraph}. It is recommended to extend
@@ -39,7 +37,6 @@
* @since 20.0
*/
@Beta
-@ElementTypesAreNonnullByDefault
public abstract class AbstractValueGraph<N, V> extends AbstractBaseGraph<N>
implements ValueGraph<N, V> {
@@ -119,7 +116,7 @@
}
@Override
- public final boolean equals(@CheckForNull Object obj) {
+ public final boolean equals(@Nullable Object obj) {
if (obj == this) {
return true;
}
@@ -156,8 +153,7 @@
new Function<EndpointPair<N>, V>() {
@Override
public V apply(EndpointPair<N> edge) {
- // requireNonNull is safe because the endpoint pair comes from the graph.
- return requireNonNull(graph.edgeValueOrDefault(edge.nodeU(), edge.nodeV(), null));
+ return graph.edgeValueOrDefault(edge.nodeU(), edge.nodeV(), null);
}
};
return Maps.asMap(graph.edges(), edgeToValueFn);
diff --git a/guava/src/com/google/common/graph/BaseGraph.java b/guava/src/com/google/common/graph/BaseGraph.java
index 68813e1..1df5de7 100644
--- a/guava/src/com/google/common/graph/BaseGraph.java
+++ b/guava/src/com/google/common/graph/BaseGraph.java
@@ -24,7 +24,6 @@
* @author James Sexton
* @param <N> Node parameter type
*/
-@ElementTypesAreNonnullByDefault
interface BaseGraph<N> extends SuccessorsFunction<N>, PredecessorsFunction<N> {
//
// Graph-level accessors
diff --git a/guava/src/com/google/common/graph/DirectedGraphConnections.java b/guava/src/com/google/common/graph/DirectedGraphConnections.java
index 23083da..3838bcf 100644
--- a/guava/src/com/google/common/graph/DirectedGraphConnections.java
+++ b/guava/src/com/google/common/graph/DirectedGraphConnections.java
@@ -40,7 +40,7 @@
import java.util.Map.Entry;
import java.util.Set;
import java.util.concurrent.atomic.AtomicBoolean;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* An implementation of {@link GraphConnections} for directed graphs.
@@ -50,7 +50,6 @@
* @param <N> Node parameter type
* @param <V> Value parameter type
*/
-@ElementTypesAreNonnullByDefault
final class DirectedGraphConnections<N, V> implements GraphConnections<N, V> {
/**
* A wrapper class to indicate a node is both a predecessor and successor while still providing
@@ -83,7 +82,7 @@
}
@Override
- public boolean equals(@CheckForNull Object that) {
+ public boolean equals(Object that) {
if (that instanceof Pred) {
return this.node.equals(((Pred<?>) that).node);
} else {
@@ -104,7 +103,7 @@
}
@Override
- public boolean equals(@CheckForNull Object that) {
+ public boolean equals(Object that) {
if (that instanceof Succ) {
return this.node.equals(((Succ<?>) that).node);
} else {
@@ -134,14 +133,14 @@
* LinkedHashMap combines two such edges into a single node-value pair, even though the edges may
* not have been inserted consecutively.
*/
- @CheckForNull private final List<NodeConnection<N>> orderedNodeConnections;
+ @Nullable private final List<NodeConnection<N>> orderedNodeConnections;
private int predecessorCount;
private int successorCount;
private DirectedGraphConnections(
Map<N, Object> adjacentNodeValues,
- @CheckForNull List<NodeConnection<N>> orderedNodeConnections,
+ @Nullable List<NodeConnection<N>> orderedNodeConnections,
int predecessorCount,
int successorCount) {
this.adjacentNodeValues = checkNotNull(adjacentNodeValues);
@@ -243,7 +242,6 @@
final Set<N> seenNodes = new HashSet<>();
return new AbstractIterator<N>() {
@Override
- @CheckForNull
protected N computeNext() {
while (nodeConnections.hasNext()) {
NodeConnection<N> nodeConnection = nodeConnections.next();
@@ -263,7 +261,7 @@
}
@Override
- public boolean contains(@CheckForNull Object obj) {
+ public boolean contains(@Nullable Object obj) {
return adjacentNodeValues.containsKey(obj);
}
};
@@ -279,7 +277,6 @@
final Iterator<Entry<N, Object>> entries = adjacentNodeValues.entrySet().iterator();
return new AbstractIterator<N>() {
@Override
- @CheckForNull
protected N computeNext() {
while (entries.hasNext()) {
Entry<N, Object> entry = entries.next();
@@ -294,7 +291,6 @@
final Iterator<NodeConnection<N>> nodeConnections = orderedNodeConnections.iterator();
return new AbstractIterator<N>() {
@Override
- @CheckForNull
protected N computeNext() {
while (nodeConnections.hasNext()) {
NodeConnection<N> nodeConnection = nodeConnections.next();
@@ -314,7 +310,7 @@
}
@Override
- public boolean contains(@CheckForNull Object obj) {
+ public boolean contains(@Nullable Object obj) {
return isPredecessor(adjacentNodeValues.get(obj));
}
};
@@ -329,7 +325,6 @@
final Iterator<Entry<N, Object>> entries = adjacentNodeValues.entrySet().iterator();
return new AbstractIterator<N>() {
@Override
- @CheckForNull
protected N computeNext() {
while (entries.hasNext()) {
Entry<N, Object> entry = entries.next();
@@ -344,7 +339,6 @@
final Iterator<NodeConnection<N>> nodeConnections = orderedNodeConnections.iterator();
return new AbstractIterator<N>() {
@Override
- @CheckForNull
protected N computeNext() {
while (nodeConnections.hasNext()) {
NodeConnection<N> nodeConnection = nodeConnections.next();
@@ -364,7 +358,7 @@
}
@Override
- public boolean contains(@CheckForNull Object obj) {
+ public boolean contains(@Nullable Object obj) {
return isSuccessor(adjacentNodeValues.get(obj));
}
};
@@ -413,7 +407,6 @@
final AtomicBoolean alreadySeenSelfLoop = new AtomicBoolean(false);
return new AbstractIterator<EndpointPair<N>>() {
@Override
- @CheckForNull
protected EndpointPair<N> computeNext() {
while (resultWithDoubleSelfLoop.hasNext()) {
EndpointPair<N> edge = resultWithDoubleSelfLoop.next();
@@ -432,7 +425,6 @@
@SuppressWarnings("unchecked")
@Override
- @CheckForNull
public V value(N node) {
checkNotNull(node);
Object value = adjacentNodeValues.get(node);
@@ -474,7 +466,6 @@
@SuppressWarnings("unchecked")
@Override
- @CheckForNull
public V removeSuccessor(Object node) {
checkNotNull(node);
Object previousValue = adjacentNodeValues.get(node);
@@ -498,14 +489,7 @@
}
}
- /*
- * TODO(cpovirk): `return (V) removedValue` once our checker permits that.
- *
- * (We promoted a class of warnings into errors because sometimes they indicate real problems.
- * But now we need to "undo" some instance of spurious errors, as discussed in
- * https://github.com/jspecify/checker-framework/issues/8.)
- */
- return removedValue == null ? null : (V) removedValue;
+ return (V) removedValue;
}
@Override
@@ -538,7 +522,6 @@
@SuppressWarnings("unchecked")
@Override
- @CheckForNull
public V addSuccessor(N node, V value) {
Object previousValue = adjacentNodeValues.put(node, value);
Object previousSuccessor;
@@ -563,15 +546,14 @@
}
}
- // See the comment on the similar cast in removeSuccessor.
- return previousSuccessor == null ? null : (V) previousSuccessor;
+ return (V) previousSuccessor;
}
- private static boolean isPredecessor(@CheckForNull Object value) {
+ private static boolean isPredecessor(@Nullable Object value) {
return (value == PRED) || (value instanceof PredAndSucc);
}
- private static boolean isSuccessor(@CheckForNull 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 05f40c2..4a560ae 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 javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* An implementation of {@link NetworkConnections} for directed networks with parallel edges.
@@ -39,7 +39,6 @@
* @param <N> Node parameter type
* @param <E> Edge parameter type
*/
-@ElementTypesAreNonnullByDefault
final class DirectedMultiNetworkConnections<N, E> extends AbstractDirectedNetworkConnections<N, E> {
private DirectedMultiNetworkConnections(
@@ -60,7 +59,7 @@
ImmutableMap.copyOf(inEdges), ImmutableMap.copyOf(outEdges), selfLoopCount);
}
- @CheckForNull @LazyInit private transient Reference<Multiset<N>> predecessorsReference;
+ @LazyInit private transient Reference<Multiset<N>> predecessorsReference;
@Override
public Set<N> predecessors() {
@@ -76,7 +75,7 @@
return predecessors;
}
- @CheckForNull @LazyInit private transient Reference<Multiset<N>> successorsReference;
+ @LazyInit private transient Reference<Multiset<N>> successorsReference;
@Override
public Set<N> successors() {
@@ -140,8 +139,7 @@
}
}
- @CheckForNull
- private static <T> T getReference(@CheckForNull Reference<T> reference) {
+ private static <T> @Nullable T getReference(@Nullable Reference<T> reference) {
return (reference == null) ? null : reference.get();
}
}
diff --git a/guava/src/com/google/common/graph/DirectedNetworkConnections.java b/guava/src/com/google/common/graph/DirectedNetworkConnections.java
index c2a25a5..2a0b010 100644
--- a/guava/src/com/google/common/graph/DirectedNetworkConnections.java
+++ b/guava/src/com/google/common/graph/DirectedNetworkConnections.java
@@ -32,10 +32,10 @@
* @param <N> Node parameter type
* @param <E> Edge parameter type
*/
-@ElementTypesAreNonnullByDefault
final class DirectedNetworkConnections<N, E> extends AbstractDirectedNetworkConnections<N, E> {
- DirectedNetworkConnections(Map<E, N> inEdgeMap, Map<E, N> outEdgeMap, int selfLoopCount) {
+ protected DirectedNetworkConnections(
+ Map<E, N> inEdgeMap, Map<E, N> outEdgeMap, int selfLoopCount) {
super(inEdgeMap, outEdgeMap, selfLoopCount);
}
diff --git a/guava/src/com/google/common/graph/EdgesConnecting.java b/guava/src/com/google/common/graph/EdgesConnecting.java
index 797970b..1c46735 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 javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* A class to represent the set of edges connecting an (implicit) origin node to a target node.
@@ -34,7 +34,6 @@
* @author James Sexton
* @param <E> Edge parameter type
*/
-@ElementTypesAreNonnullByDefault
final class EdgesConnecting<E> extends AbstractSet<E> {
private final Map<?, E> nodeToOutEdge;
@@ -59,13 +58,12 @@
}
@Override
- public boolean contains(@CheckForNull Object edge) {
+ public boolean contains(@Nullable Object edge) {
E connectingEdge = getConnectingEdge();
return (connectingEdge != null && connectingEdge.equals(edge));
}
- @CheckForNull
- private E getConnectingEdge() {
+ private @Nullable 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 ea13674..257bdd6 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 javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Used to represent the order of elements in a data structure that supports different options for
@@ -46,13 +46,11 @@
*/
@Beta
@Immutable
-@ElementTypesAreNonnullByDefault
public final class ElementOrder<T> {
private final Type type;
@SuppressWarnings("Immutable") // Hopefully the comparator provided is immutable!
- @CheckForNull
- private final Comparator<T> comparator;
+ private final @Nullable Comparator<T> comparator;
/**
* The type of ordering that this object specifies.
@@ -72,7 +70,7 @@
SORTED
}
- private ElementOrder(Type type, @CheckForNull Comparator<T> comparator) {
+ private ElementOrder(Type type, @Nullable Comparator<T> comparator) {
this.type = checkNotNull(type);
this.comparator = comparator;
checkState((type == Type.SORTED) == (comparator != null));
@@ -161,7 +159,7 @@
}
@Override
- public boolean equals(@CheckForNull Object obj) {
+ public boolean equals(@Nullable Object obj) {
if (obj == this) {
return true;
}
diff --git a/guava/src/com/google/common/graph/ElementTypesAreNonnullByDefault.java b/guava/src/com/google/common/graph/ElementTypesAreNonnullByDefault.java
deleted file mode 100644
index 0798de0..0000000
--- a/guava/src/com/google/common/graph/ElementTypesAreNonnullByDefault.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) 2021 The Guava Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.common.graph;
-
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.PARAMETER;
-import static java.lang.annotation.ElementType.TYPE;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-import com.google.common.annotations.GwtCompatible;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-import javax.annotation.Nonnull;
-import javax.annotation.meta.TypeQualifierDefault;
-
-/**
- * Marks all "top-level" types as non-null in a way that is recognized by Kotlin. Note that this
- * unfortunately includes type-variable usages, so we also provide {@link ParametricNullness} to
- * "undo" it as best we can.
- */
-@GwtCompatible
-@Retention(RUNTIME)
-@Target(TYPE)
-@TypeQualifierDefault({FIELD, METHOD, PARAMETER})
-@Nonnull
-@interface ElementTypesAreNonnullByDefault {}
diff --git a/guava/src/com/google/common/graph/EndpointPair.java b/guava/src/com/google/common/graph/EndpointPair.java
index 7aa3860..c876634 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 javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* An immutable pair representing the two endpoints of an edge in a graph. The {@link EndpointPair}
@@ -39,7 +39,6 @@
*/
@Beta
@Immutable(containerOf = {"N"})
-@ElementTypesAreNonnullByDefault
public abstract class EndpointPair<N> implements Iterable<N> {
private final N nodeU;
private final N nodeV;
@@ -104,9 +103,8 @@
* Returns the node that is adjacent to {@code node} along the origin edge.
*
* @throws IllegalArgumentException if this {@link EndpointPair} does not contain {@code node}
- * @since 20.0 (but the argument type was changed from {@code Object} to {@code N} in 31.0)
*/
- public final N adjacentNode(N node) {
+ public final N adjacentNode(Object node) {
if (node.equals(nodeU)) {
return nodeV;
} else if (node.equals(nodeV)) {
@@ -134,7 +132,7 @@
* ordered {@link EndpointPair} is never equal to an unordered {@link EndpointPair}.
*/
@Override
- public abstract boolean equals(@CheckForNull Object obj);
+ public abstract boolean equals(@Nullable Object obj);
/**
* The hashcode of an ordered {@link EndpointPair} is equal to {@code Objects.hashCode(source(),
@@ -165,7 +163,7 @@
}
@Override
- public boolean equals(@CheckForNull Object obj) {
+ public boolean equals(@Nullable Object obj) {
if (obj == this) {
return true;
}
@@ -213,7 +211,7 @@
}
@Override
- public boolean equals(@CheckForNull Object obj) {
+ public boolean equals(@Nullable Object obj) {
if (obj == this) {
return true;
}
diff --git a/guava/src/com/google/common/graph/EndpointPairIterator.java b/guava/src/com/google/common/graph/EndpointPairIterator.java
index 7096dbe..c4e6e07 100644
--- a/guava/src/com/google/common/graph/EndpointPairIterator.java
+++ b/guava/src/com/google/common/graph/EndpointPairIterator.java
@@ -17,30 +17,24 @@
package com.google.common.graph;
import static com.google.common.base.Preconditions.checkState;
-import static java.util.Objects.requireNonNull;
import com.google.common.collect.AbstractIterator;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Sets;
import java.util.Iterator;
import java.util.Set;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* A class to facilitate the set returned by {@link Graph#edges()}.
*
* @author James Sexton
*/
-@ElementTypesAreNonnullByDefault
abstract class EndpointPairIterator<N> extends AbstractIterator<EndpointPair<N>> {
private final BaseGraph<N> graph;
private final Iterator<N> nodeIterator;
- @CheckForNull
- N node = null; // null is safe as an initial value because graphs don't allow null nodes
-
- Iterator<N> successorIterator = ImmutableSet.<N>of().iterator();
+ protected N node = null; // null is safe as an initial value because graphs don't allow null nodes
+ protected Iterator<N> successorIterator = ImmutableSet.<N>of().iterator();
static <N> EndpointPairIterator<N> of(BaseGraph<N> graph) {
return graph.isDirected() ? new Directed<N>(graph) : new Undirected<N>(graph);
@@ -55,7 +49,7 @@
* Called after {@link #successorIterator} is exhausted. Advances {@link #node} to the next node
* and updates {@link #successorIterator} to iterate through the successors of {@link #node}.
*/
- final boolean advance() {
+ protected final boolean advance() {
checkState(!successorIterator.hasNext());
if (!nodeIterator.hasNext()) {
return false;
@@ -75,12 +69,10 @@
}
@Override
- @CheckForNull
protected EndpointPair<N> computeNext() {
while (true) {
if (successorIterator.hasNext()) {
- // requireNonNull is safe because successorIterator is empty until we set this.node.
- return EndpointPair.ordered(requireNonNull(node), successorIterator.next());
+ return EndpointPair.ordered(node, successorIterator.next());
}
if (!advance()) {
return endOfData();
@@ -116,28 +108,20 @@
* </pre>
*/
private static final class Undirected<N> extends EndpointPairIterator<N> {
- // It's a little weird that we add `null` to this set, but it makes for slightly simpler code.
- @CheckForNull private Set<@Nullable N> visitedNodes;
+ private Set<N> visitedNodes;
private Undirected(BaseGraph<N> graph) {
super(graph);
- this.visitedNodes = Sets.newHashSetWithExpectedSize(graph.nodes().size() + 1);
+ this.visitedNodes = Sets.newHashSetWithExpectedSize(graph.nodes().size());
}
@Override
- @CheckForNull
protected EndpointPair<N> computeNext() {
while (true) {
- /*
- * requireNonNull is safe because visitedNodes isn't cleared until this method calls
- * endOfData() (after which this method is never called again).
- */
- requireNonNull(visitedNodes);
while (successorIterator.hasNext()) {
N otherNode = successorIterator.next();
if (!visitedNodes.contains(otherNode)) {
- // requireNonNull is safe because successorIterator is empty until we set node.
- return EndpointPair.unordered(requireNonNull(node), otherNode);
+ return EndpointPair.unordered(node, otherNode);
}
}
// Add to visited set *after* processing neighbors so we still include self-loops.
diff --git a/guava/src/com/google/common/graph/ForwardingGraph.java b/guava/src/com/google/common/graph/ForwardingGraph.java
index f4ddf42..4a3ab8c 100644
--- a/guava/src/com/google/common/graph/ForwardingGraph.java
+++ b/guava/src/com/google/common/graph/ForwardingGraph.java
@@ -24,10 +24,9 @@
*
* @author James Sexton
*/
-@ElementTypesAreNonnullByDefault
abstract class ForwardingGraph<N> extends AbstractGraph<N> {
- abstract BaseGraph<N> delegate();
+ protected abstract BaseGraph<N> delegate();
@Override
public Set<N> nodes() {
diff --git a/guava/src/com/google/common/graph/ForwardingNetwork.java b/guava/src/com/google/common/graph/ForwardingNetwork.java
index 9f1c6e7..76347b1 100644
--- a/guava/src/com/google/common/graph/ForwardingNetwork.java
+++ b/guava/src/com/google/common/graph/ForwardingNetwork.java
@@ -18,7 +18,6 @@
import java.util.Optional;
import java.util.Set;
-import javax.annotation.CheckForNull;
/**
* A class to allow {@link Network} implementations to be backed by a provided delegate. This is not
@@ -27,10 +26,9 @@
* @author James Sexton
* @author Joshua O'Madadhain
*/
-@ElementTypesAreNonnullByDefault
abstract class ForwardingNetwork<N, E> extends AbstractNetwork<N, E> {
- abstract Network<N, E> delegate();
+ protected abstract Network<N, E> delegate();
@Override
public Set<N> nodes() {
@@ -143,13 +141,11 @@
}
@Override
- @CheckForNull
public E edgeConnectingOrNull(N nodeU, N nodeV) {
return delegate().edgeConnectingOrNull(nodeU, nodeV);
}
@Override
- @CheckForNull
public E edgeConnectingOrNull(EndpointPair<N> endpoints) {
return delegate().edgeConnectingOrNull(endpoints);
}
diff --git a/guava/src/com/google/common/graph/ForwardingValueGraph.java b/guava/src/com/google/common/graph/ForwardingValueGraph.java
index fcd5d28..8db773f 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 javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* A class to allow {@link ValueGraph} implementations to be backed by a provided delegate. This is
@@ -27,10 +27,9 @@
* @author James Sexton
* @author Joshua O'Madadhain
*/
-@ElementTypesAreNonnullByDefault
abstract class ForwardingValueGraph<N, V> extends AbstractValueGraph<N, V> {
- abstract ValueGraph<N, V> delegate();
+ protected abstract ValueGraph<N, V> delegate();
@Override
public Set<N> nodes() {
@@ -117,14 +116,12 @@
}
@Override
- @CheckForNull
- public V edgeValueOrDefault(N nodeU, N nodeV, @CheckForNull V defaultValue) {
+ public @Nullable V edgeValueOrDefault(N nodeU, N nodeV, @Nullable V defaultValue) {
return delegate().edgeValueOrDefault(nodeU, nodeV, defaultValue);
}
@Override
- @CheckForNull
- public V edgeValueOrDefault(EndpointPair<N> endpoints, @CheckForNull V defaultValue) {
+ public @Nullable V edgeValueOrDefault(EndpointPair<N> endpoints, @Nullable V defaultValue) {
return delegate().edgeValueOrDefault(endpoints, defaultValue);
}
}
diff --git a/guava/src/com/google/common/graph/Graph.java b/guava/src/com/google/common/graph/Graph.java
index 5dc0e71..84f9695 100644
--- a/guava/src/com/google/common/graph/Graph.java
+++ b/guava/src/com/google/common/graph/Graph.java
@@ -20,7 +20,7 @@
import com.google.errorprone.annotations.DoNotMock;
import java.util.Collection;
import java.util.Set;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* An interface for <a
@@ -103,7 +103,6 @@
*/
@Beta
@DoNotMock("Use GraphBuilder to create a real instance")
-@ElementTypesAreNonnullByDefault
public interface Graph<N> extends BaseGraph<N> {
//
// Graph-level accessors
@@ -290,7 +289,7 @@
* <p>A reference implementation of this is provided by {@link AbstractGraph#equals(Object)}.
*/
@Override
- boolean equals(@CheckForNull 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/GraphBuilder.java b/guava/src/com/google/common/graph/GraphBuilder.java
index d57ed37..f00d7b1 100644
--- a/guava/src/com/google/common/graph/GraphBuilder.java
+++ b/guava/src/com/google/common/graph/GraphBuilder.java
@@ -64,7 +64,6 @@
*/
@Beta
@DoNotMock
-@ElementTypesAreNonnullByDefault
public final class GraphBuilder<N> extends AbstractGraphBuilder<N> {
/** Creates a new instance with the specified edge directionality. */
diff --git a/guava/src/com/google/common/graph/GraphConnections.java b/guava/src/com/google/common/graph/GraphConnections.java
index 7d4f8f0..bed5508 100644
--- a/guava/src/com/google/common/graph/GraphConnections.java
+++ b/guava/src/com/google/common/graph/GraphConnections.java
@@ -19,7 +19,7 @@
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import java.util.Iterator;
import java.util.Set;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* An interface for representing and manipulating an origin node's adjacent nodes and edge values in
@@ -29,7 +29,6 @@
* @param <N> Node parameter type
* @param <V> Value parameter type
*/
-@ElementTypesAreNonnullByDefault
interface GraphConnections<N, V> {
Set<N> adjacentNodes();
@@ -49,7 +48,7 @@
* Returns the value associated with the edge connecting the origin node to {@code node}, or null
* if there is no such edge.
*/
- @CheckForNull
+ @Nullable
V value(N node);
/** Remove {@code node} from the set of predecessors. */
@@ -60,7 +59,6 @@
* the edge connecting the two nodes.
*/
@CanIgnoreReturnValue
- @CheckForNull
V removeSuccessor(N node);
/**
@@ -75,6 +73,5 @@
* the value previously associated with the edge connecting the two nodes.
*/
@CanIgnoreReturnValue
- @CheckForNull
V addSuccessor(N node, V value);
}
diff --git a/guava/src/com/google/common/graph/GraphConstants.java b/guava/src/com/google/common/graph/GraphConstants.java
index ae224fd..224c6d2 100644
--- a/guava/src/com/google/common/graph/GraphConstants.java
+++ b/guava/src/com/google/common/graph/GraphConstants.java
@@ -16,9 +16,7 @@
package com.google.common.graph;
-
/** A utility class to hold various constants used by the Guava Graph library. */
-@ElementTypesAreNonnullByDefault
final class GraphConstants {
private GraphConstants() {}
diff --git a/guava/src/com/google/common/graph/Graphs.java b/guava/src/com/google/common/graph/Graphs.java
index 6ab9f56..35f0efe 100644
--- a/guava/src/com/google/common/graph/Graphs.java
+++ b/guava/src/com/google/common/graph/Graphs.java
@@ -18,7 +18,6 @@
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.graph.GraphConstants.NODE_NOT_IN_GRAPH;
-import static java.util.Objects.requireNonNull;
import com.google.common.annotations.Beta;
import com.google.common.base.Function;
@@ -34,7 +33,7 @@
import java.util.Map;
import java.util.Optional;
import java.util.Set;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Static utility methods for {@link Graph}, {@link ValueGraph}, and {@link Network} instances.
@@ -44,7 +43,6 @@
* @since 20.0
*/
@Beta
-@ElementTypesAreNonnullByDefault
public final class Graphs {
private Graphs() {}
@@ -101,10 +99,7 @@
* cycle in the graph.
*/
private static <N> boolean subgraphHasCycle(
- Graph<N> graph,
- Map<Object, NodeVisitState> visitedNodes,
- N node,
- @CheckForNull N previousNode) {
+ Graph<N> graph, Map<Object, NodeVisitState> visitedNodes, N node, @Nullable N previousNode) {
NodeVisitState state = visitedNodes.get(node);
if (state == NodeVisitState.COMPLETE) {
return false;
@@ -131,7 +126,7 @@
* from B to A).
*/
private static boolean canTraverseWithoutReusingEdge(
- Graph<?> graph, Object nextNode, @CheckForNull Object previousNode) {
+ Graph<?> graph, Object nextNode, @Nullable Object previousNode) {
if (graph.isDirected() || !Objects.equal(previousNode, nextNode)) {
return true;
}
@@ -268,7 +263,7 @@
}
@Override
- Graph<N> delegate() {
+ protected Graph<N> delegate() {
return graph;
}
@@ -330,7 +325,7 @@
}
@Override
- ValueGraph<N, V> delegate() {
+ protected ValueGraph<N, V> delegate() {
return graph;
}
@@ -375,14 +370,12 @@
}
@Override
- @CheckForNull
- public V edgeValueOrDefault(N nodeU, N nodeV, @CheckForNull V defaultValue) {
+ public @Nullable V edgeValueOrDefault(N nodeU, N nodeV, @Nullable V defaultValue) {
return delegate().edgeValueOrDefault(nodeV, nodeU, defaultValue); // transpose
}
@Override
- @CheckForNull
- public V edgeValueOrDefault(EndpointPair<N> endpoints, @CheckForNull V defaultValue) {
+ public @Nullable V edgeValueOrDefault(EndpointPair<N> endpoints, @Nullable V defaultValue) {
return delegate().edgeValueOrDefault(transpose(endpoints), defaultValue);
}
}
@@ -395,7 +388,7 @@
}
@Override
- Network<N, E> delegate() {
+ protected Network<N, E> delegate() {
return network;
}
@@ -456,13 +449,11 @@
}
@Override
- @CheckForNull
public E edgeConnectingOrNull(N nodeU, N nodeV) {
return delegate().edgeConnectingOrNull(nodeV, nodeU); // transpose
}
@Override
- @CheckForNull
public E edgeConnectingOrNull(EndpointPair<N> endpoints) {
return delegate().edgeConnectingOrNull(transpose(endpoints));
}
@@ -525,11 +516,8 @@
for (N node : subgraph.nodes()) {
for (N successorNode : graph.successors(node)) {
if (subgraph.nodes().contains(successorNode)) {
- // requireNonNull is safe because the endpoint pair comes from the graph.
subgraph.putEdgeValue(
- node,
- successorNode,
- requireNonNull(graph.edgeValueOrDefault(node, successorNode, null)));
+ node, successorNode, graph.edgeValueOrDefault(node, successorNode, null));
}
}
}
@@ -584,11 +572,8 @@
copy.addNode(node);
}
for (EndpointPair<N> edge : graph.edges()) {
- // requireNonNull is safe because the endpoint pair comes from the graph.
copy.putEdgeValue(
- edge.nodeU(),
- edge.nodeV(),
- requireNonNull(graph.edgeValueOrDefault(edge.nodeU(), edge.nodeV(), null)));
+ edge.nodeU(), edge.nodeV(), graph.edgeValueOrDefault(edge.nodeU(), edge.nodeV(), null));
}
return copy;
}
diff --git a/guava/src/com/google/common/graph/ImmutableGraph.java b/guava/src/com/google/common/graph/ImmutableGraph.java
index afad211..4027ca8 100644
--- a/guava/src/com/google/common/graph/ImmutableGraph.java
+++ b/guava/src/com/google/common/graph/ImmutableGraph.java
@@ -45,7 +45,6 @@
*/
@Beta
@Immutable(containerOf = {"N"})
-@ElementTypesAreNonnullByDefault
public class ImmutableGraph<N> extends ForwardingGraph<N> {
@SuppressWarnings("Immutable") // The backing graph must be immutable.
private final BaseGraph<N> backingGraph;
@@ -101,7 +100,7 @@
}
@Override
- BaseGraph<N> delegate() {
+ protected BaseGraph<N> delegate() {
return backingGraph;
}
diff --git a/guava/src/com/google/common/graph/ImmutableNetwork.java b/guava/src/com/google/common/graph/ImmutableNetwork.java
index cb636aa..b35d722 100644
--- a/guava/src/com/google/common/graph/ImmutableNetwork.java
+++ b/guava/src/com/google/common/graph/ImmutableNetwork.java
@@ -46,7 +46,6 @@
@Beta
@Immutable(containerOf = {"N", "E"})
@SuppressWarnings("Immutable") // Extends StandardNetwork but uses ImmutableMaps.
-@ElementTypesAreNonnullByDefault
public final class ImmutableNetwork<N, E> extends StandardNetwork<N, E> {
private ImmutableNetwork(Network<N, E> network) {
diff --git a/guava/src/com/google/common/graph/ImmutableValueGraph.java b/guava/src/com/google/common/graph/ImmutableValueGraph.java
index a1567da..f2e2386 100644
--- a/guava/src/com/google/common/graph/ImmutableValueGraph.java
+++ b/guava/src/com/google/common/graph/ImmutableValueGraph.java
@@ -17,7 +17,6 @@
package com.google.common.graph;
import static com.google.common.base.Preconditions.checkNotNull;
-import static java.util.Objects.requireNonNull;
import com.google.common.annotations.Beta;
import com.google.common.base.Function;
@@ -44,7 +43,6 @@
@Beta
@Immutable(containerOf = {"N", "V"})
@SuppressWarnings("Immutable") // Extends StandardValueGraph but uses ImmutableMaps.
-@ElementTypesAreNonnullByDefault
public final class ImmutableValueGraph<N, V> extends StandardValueGraph<N, V> {
private ImmutableValueGraph(ValueGraph<N, V> graph) {
@@ -96,8 +94,7 @@
new Function<N, V>() {
@Override
public V apply(N successorNode) {
- // requireNonNull is safe because the endpoint pair comes from the graph.
- return requireNonNull(graph.edgeValueOrDefault(node, successorNode, null));
+ return graph.edgeValueOrDefault(node, successorNode, null);
}
};
return graph.isDirected()
diff --git a/guava/src/com/google/common/graph/IncidentEdgeSet.java b/guava/src/com/google/common/graph/IncidentEdgeSet.java
index ac94b65..f306a67 100644
--- a/guava/src/com/google/common/graph/IncidentEdgeSet.java
+++ b/guava/src/com/google/common/graph/IncidentEdgeSet.java
@@ -18,16 +18,15 @@
import java.util.AbstractSet;
import java.util.Set;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Abstract base class for an incident edges set that allows different implementations of {@link
* AbstractSet#iterator()}.
*/
-@ElementTypesAreNonnullByDefault
abstract class IncidentEdgeSet<N> extends AbstractSet<EndpointPair<N>> {
- final N node;
- final BaseGraph<N> graph;
+ protected final N node;
+ protected final BaseGraph<N> graph;
IncidentEdgeSet(BaseGraph<N> graph, N node) {
this.graph = graph;
@@ -35,7 +34,7 @@
}
@Override
- public boolean remove(@CheckForNull Object o) {
+ public boolean remove(Object o) {
throw new UnsupportedOperationException();
}
@@ -51,7 +50,7 @@
}
@Override
- public boolean contains(@CheckForNull Object obj) {
+ public boolean contains(@Nullable Object obj) {
if (!(obj instanceof EndpointPair)) {
return false;
}
diff --git a/guava/src/com/google/common/graph/MapIteratorCache.java b/guava/src/com/google/common/graph/MapIteratorCache.java
index aae9187..182a67f 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 javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* A map-like data structure that wraps a backing map and caches values while iterating through
@@ -41,7 +41,6 @@
*
* @author James Sexton
*/
-@ElementTypesAreNonnullByDefault
class MapIteratorCache<K, V> {
private final Map<K, V> backingMap;
@@ -54,57 +53,43 @@
* while writing to it in another. All it does is help with _reading_ from multiple threads
* concurrently. For more information, see AbstractNetworkTest.concurrentIteration.
*/
- @CheckForNull private transient volatile Entry<K, V> cacheEntry;
+ private transient volatile @Nullable Entry<K, V> cacheEntry;
MapIteratorCache(Map<K, V> backingMap) {
this.backingMap = checkNotNull(backingMap);
}
@CanIgnoreReturnValue
- @CheckForNull
- final V put(K key, V value) {
- checkNotNull(key);
- checkNotNull(value);
+ public final V put(@Nullable K key, @Nullable V value) {
clearCache();
return backingMap.put(key, value);
}
@CanIgnoreReturnValue
- @CheckForNull
- final V remove(Object key) {
- checkNotNull(key);
+ public final V remove(@Nullable Object key) {
clearCache();
return backingMap.remove(key);
}
- final void clear() {
+ public final void clear() {
clearCache();
backingMap.clear();
}
- @CheckForNull
- V get(Object key) {
- checkNotNull(key);
+ public V get(@Nullable Object key) {
V value = getIfCached(key);
- // TODO(b/192579700): Use a ternary once it no longer confuses our nullness checker.
- if (value == null) {
- return getWithoutCaching(key);
- } else {
- return value;
- }
+ return (value != null) ? value : getWithoutCaching(key);
}
- @CheckForNull
- final V getWithoutCaching(Object key) {
- checkNotNull(key);
+ public final V getWithoutCaching(@Nullable Object key) {
return backingMap.get(key);
}
- final boolean containsKey(@CheckForNull Object key) {
+ public final boolean containsKey(@Nullable Object key) {
return getIfCached(key) != null || backingMap.containsKey(key);
}
- final Set<K> unmodifiableKeySet() {
+ public final Set<K> unmodifiableKeySet() {
return new AbstractSet<K>() {
@Override
public UnmodifiableIterator<K> iterator() {
@@ -131,16 +116,15 @@
}
@Override
- public boolean contains(@CheckForNull Object key) {
+ public boolean contains(@Nullable Object key) {
return containsKey(key);
}
};
}
- // Internal methods (package-visible, but treat as only subclass-visible)
+ // Internal methods ('protected' is still package-visible, but treat as only subclass-visible)
- @CheckForNull
- V getIfCached(@CheckForNull Object key) {
+ protected V getIfCached(@Nullable Object key) {
Entry<K, V> entry = cacheEntry; // store local reference for thread-safety
// Check cache. We use == on purpose because it's cheaper and a cache miss is ok.
@@ -150,7 +134,7 @@
return null;
}
- void clearCache() {
+ protected void clearCache() {
cacheEntry = null;
}
}
diff --git a/guava/src/com/google/common/graph/MapRetrievalCache.java b/guava/src/com/google/common/graph/MapRetrievalCache.java
index ada78f2..3a406e9 100644
--- a/guava/src/com/google/common/graph/MapRetrievalCache.java
+++ b/guava/src/com/google/common/graph/MapRetrievalCache.java
@@ -16,10 +16,8 @@
package com.google.common.graph;
-import static com.google.common.base.Preconditions.checkNotNull;
-
import java.util.Map;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* A {@link MapIteratorCache} that adds additional caching. In addition to the caching provided by
@@ -27,11 +25,10 @@
*
* @author James Sexton
*/
-@ElementTypesAreNonnullByDefault
-final class MapRetrievalCache<K, V> extends MapIteratorCache<K, V> {
+class MapRetrievalCache<K, V> extends MapIteratorCache<K, V> {
// See the note about volatile in the superclass.
- @CheckForNull private transient volatile CacheEntry<K, V> cacheEntry1;
- @CheckForNull private transient volatile CacheEntry<K, V> cacheEntry2;
+ private transient volatile @Nullable CacheEntry<K, V> cacheEntry1;
+ private transient volatile @Nullable CacheEntry<K, V> cacheEntry2;
MapRetrievalCache(Map<K, V> backingMap) {
super(backingMap);
@@ -39,9 +36,7 @@
@SuppressWarnings("unchecked") // Safe because we only cast if key is found in map.
@Override
- @CheckForNull
- V get(Object key) {
- checkNotNull(key);
+ public V get(@Nullable Object key) {
V value = getIfCached(key);
if (value != null) {
return value;
@@ -54,11 +49,10 @@
return value;
}
- // Internal methods (package-visible, but treat as only subclass-visible)
+ // Internal methods ('protected' is still package-visible, but treat as only subclass-visible)
@Override
- @CheckForNull
- V getIfCached(@CheckForNull Object key) {
+ protected V getIfCached(@Nullable Object key) {
V value = super.getIfCached(key);
if (value != null) {
return value;
@@ -84,7 +78,7 @@
}
@Override
- void clearCache() {
+ protected void clearCache() {
super.clearCache();
cacheEntry1 = null;
cacheEntry2 = null;
diff --git a/guava/src/com/google/common/graph/MultiEdgesConnecting.java b/guava/src/com/google/common/graph/MultiEdgesConnecting.java
index 8a4250e..5bddfbb 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 javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* A class to represent the set of edges connecting an (implicit) origin node to a target node.
@@ -35,7 +35,6 @@
* @author James Sexton
* @param <E> Edge parameter type
*/
-@ElementTypesAreNonnullByDefault
abstract class MultiEdgesConnecting<E> extends AbstractSet<E> {
private final Map<E, ?> outEdgeToNode;
@@ -51,7 +50,6 @@
final Iterator<? extends Entry<E, ?>> entries = outEdgeToNode.entrySet().iterator();
return new AbstractIterator<E>() {
@Override
- @CheckForNull
protected E computeNext() {
while (entries.hasNext()) {
Entry<E, ?> entry = entries.next();
@@ -65,7 +63,7 @@
}
@Override
- public boolean contains(@CheckForNull Object edge) {
+ public boolean contains(@Nullable Object edge) {
return targetNode.equals(outEdgeToNode.get(edge));
}
}
diff --git a/guava/src/com/google/common/graph/MutableGraph.java b/guava/src/com/google/common/graph/MutableGraph.java
index b1f3359..8324079 100644
--- a/guava/src/com/google/common/graph/MutableGraph.java
+++ b/guava/src/com/google/common/graph/MutableGraph.java
@@ -29,7 +29,6 @@
* @since 20.0
*/
@Beta
-@ElementTypesAreNonnullByDefault
public interface MutableGraph<N> extends Graph<N> {
/**
diff --git a/guava/src/com/google/common/graph/MutableNetwork.java b/guava/src/com/google/common/graph/MutableNetwork.java
index 64acb13..d702903 100644
--- a/guava/src/com/google/common/graph/MutableNetwork.java
+++ b/guava/src/com/google/common/graph/MutableNetwork.java
@@ -30,7 +30,6 @@
* @since 20.0
*/
@Beta
-@ElementTypesAreNonnullByDefault
public interface MutableNetwork<N, E> extends Network<N, E> {
/**
diff --git a/guava/src/com/google/common/graph/MutableValueGraph.java b/guava/src/com/google/common/graph/MutableValueGraph.java
index f32d2ee..70b286d 100644
--- a/guava/src/com/google/common/graph/MutableValueGraph.java
+++ b/guava/src/com/google/common/graph/MutableValueGraph.java
@@ -18,7 +18,6 @@
import com.google.common.annotations.Beta;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
-import javax.annotation.CheckForNull;
/**
* A subinterface of {@link ValueGraph} which adds mutation methods. When mutation is not required,
@@ -30,7 +29,6 @@
* @since 20.0
*/
@Beta
-@ElementTypesAreNonnullByDefault
public interface MutableValueGraph<N, V> extends ValueGraph<N, V> {
/**
@@ -61,7 +59,6 @@
* #allowsSelfLoops()}
*/
@CanIgnoreReturnValue
- @CheckForNull
V putEdgeValue(N nodeU, N nodeV, V value);
/**
@@ -86,7 +83,6 @@
* @since 27.1
*/
@CanIgnoreReturnValue
- @CheckForNull
V putEdgeValue(EndpointPair<N> endpoints, V value);
/**
@@ -104,7 +100,6 @@
* nodeV}, or null if there was no such edge.
*/
@CanIgnoreReturnValue
- @CheckForNull
V removeEdge(N nodeU, N nodeV);
/**
@@ -117,6 +112,5 @@
* @since 27.1
*/
@CanIgnoreReturnValue
- @CheckForNull
V removeEdge(EndpointPair<N> endpoints);
}
diff --git a/guava/src/com/google/common/graph/Network.java b/guava/src/com/google/common/graph/Network.java
index c700d33..6bb8452 100644
--- a/guava/src/com/google/common/graph/Network.java
+++ b/guava/src/com/google/common/graph/Network.java
@@ -20,7 +20,7 @@
import com.google.errorprone.annotations.DoNotMock;
import java.util.Optional;
import java.util.Set;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* An interface for <a
@@ -104,7 +104,6 @@
*/
@Beta
@DoNotMock("Use NetworkBuilder to create a real instance")
-@ElementTypesAreNonnullByDefault
public interface Network<N, E> extends SuccessorsFunction<N>, PredecessorsFunction<N> {
//
// Network-level accessors
@@ -349,7 +348,7 @@
* network
* @since 23.0
*/
- @CheckForNull
+ @Nullable
E edgeConnectingOrNull(N nodeU, N nodeV);
/**
@@ -364,7 +363,7 @@
* @throws IllegalArgumentException if the endpoints are unordered and the graph is directed
* @since 27.1
*/
- @CheckForNull
+ @Nullable
E edgeConnectingOrNull(EndpointPair<N> endpoints);
/**
@@ -416,7 +415,7 @@
* <p>A reference implementation of this is provided by {@link AbstractNetwork#equals(Object)}.
*/
@Override
- boolean equals(@CheckForNull 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/NetworkBuilder.java b/guava/src/com/google/common/graph/NetworkBuilder.java
index 9689444..d289ee2 100644
--- a/guava/src/com/google/common/graph/NetworkBuilder.java
+++ b/guava/src/com/google/common/graph/NetworkBuilder.java
@@ -67,7 +67,6 @@
* @since 20.0
*/
@Beta
-@ElementTypesAreNonnullByDefault
public final class NetworkBuilder<N, E> extends AbstractGraphBuilder<N> {
boolean allowsParallelEdges = false;
ElementOrder<? super E> edgeOrder = ElementOrder.insertion();
diff --git a/guava/src/com/google/common/graph/NetworkConnections.java b/guava/src/com/google/common/graph/NetworkConnections.java
index 94d1780..16a68d6 100644
--- a/guava/src/com/google/common/graph/NetworkConnections.java
+++ b/guava/src/com/google/common/graph/NetworkConnections.java
@@ -18,7 +18,6 @@
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import java.util.Set;
-import javax.annotation.CheckForNull;
/**
* An interface for representing and manipulating an origin node's adjacent nodes and incident edges
@@ -28,7 +27,6 @@
* @param <N> Node parameter type
* @param <E> Edge parameter type
*/
-@ElementTypesAreNonnullByDefault
interface NetworkConnections<N, E> {
Set<N> adjacentNodes();
@@ -62,7 +60,6 @@
* <p>In the undirected case, returns {@code null} if {@code isSelfLoop} is true.
*/
@CanIgnoreReturnValue
- @CheckForNull
N removeInEdge(E edge, boolean isSelfLoop);
/** Remove {@code edge} from the set of outgoing edges. Returns the former successor node. */
diff --git a/guava/src/com/google/common/graph/ParametricNullness.java b/guava/src/com/google/common/graph/ParametricNullness.java
deleted file mode 100644
index 62534eb..0000000
--- a/guava/src/com/google/common/graph/ParametricNullness.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2021 The Guava Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.common.graph;
-
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.PARAMETER;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-import static javax.annotation.meta.When.UNKNOWN;
-
-import com.google.common.annotations.GwtCompatible;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-import javax.annotation.Nonnull;
-import javax.annotation.meta.TypeQualifierNickname;
-
-/**
- * Marks a "top-level" type-variable usage as (a) a Kotlin platform type when the type argument is
- * non-nullable and (b) nullable when the type argument is nullable. This is the closest we can get
- * to "non-nullable when non-nullable; nullable when nullable" (like the Android <a
- * href="https://android.googlesource.com/platform/libcore/+/master/luni/src/main/java/libcore/util/NullFromTypeParam.java">{@code
- * NullFromTypeParam}</a>). We use this to "undo" {@link ElementTypesAreNonnullByDefault}.
- */
-@GwtCompatible
-@Retention(RUNTIME)
-@Target({FIELD, METHOD, PARAMETER})
-@TypeQualifierNickname
-@Nonnull(when = UNKNOWN)
-@interface ParametricNullness {}
diff --git a/guava/src/com/google/common/graph/PredecessorsFunction.java b/guava/src/com/google/common/graph/PredecessorsFunction.java
index 750a8ac..f9ca48a 100644
--- a/guava/src/com/google/common/graph/PredecessorsFunction.java
+++ b/guava/src/com/google/common/graph/PredecessorsFunction.java
@@ -80,7 +80,6 @@
*/
@Beta
@DoNotMock("Implement with a lambda, or use GraphBuilder to build a Graph with the desired edges")
-@ElementTypesAreNonnullByDefault
public interface PredecessorsFunction<N> {
/**
diff --git a/guava/src/com/google/common/graph/StandardMutableGraph.java b/guava/src/com/google/common/graph/StandardMutableGraph.java
index 1be9640..41acccf 100644
--- a/guava/src/com/google/common/graph/StandardMutableGraph.java
+++ b/guava/src/com/google/common/graph/StandardMutableGraph.java
@@ -28,7 +28,6 @@
* @author James Sexton
* @param <N> Node parameter type
*/
-@ElementTypesAreNonnullByDefault
final class StandardMutableGraph<N> extends ForwardingGraph<N> implements MutableGraph<N> {
private final MutableValueGraph<N, Presence> backingValueGraph;
@@ -38,7 +37,7 @@
}
@Override
- BaseGraph<N> delegate() {
+ protected BaseGraph<N> delegate() {
return backingValueGraph;
}
diff --git a/guava/src/com/google/common/graph/StandardMutableNetwork.java b/guava/src/com/google/common/graph/StandardMutableNetwork.java
index c58b6d3..8cfe9c5 100644
--- a/guava/src/com/google/common/graph/StandardMutableNetwork.java
+++ b/guava/src/com/google/common/graph/StandardMutableNetwork.java
@@ -22,7 +22,6 @@
import static com.google.common.graph.GraphConstants.PARALLEL_EDGES_NOT_ALLOWED;
import static com.google.common.graph.GraphConstants.REUSING_EDGE;
import static com.google.common.graph.GraphConstants.SELF_LOOPS_NOT_ALLOWED;
-import static java.util.Objects.requireNonNull;
import com.google.common.collect.ImmutableList;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
@@ -40,7 +39,6 @@
* @param <N> Node parameter type
* @param <E> Edge parameter type
*/
-@ElementTypesAreNonnullByDefault
final class StandardMutableNetwork<N, E> extends StandardNetwork<N, E>
implements MutableNetwork<N, E> {
@@ -154,10 +152,9 @@
return false;
}
- // requireNonNull is safe because of the edgeToReferenceNode check above.
- NetworkConnections<N, E> connectionsU = requireNonNull(nodeConnections.get(nodeU));
+ NetworkConnections<N, E> connectionsU = nodeConnections.get(nodeU);
N nodeV = connectionsU.adjacentNode(edge);
- NetworkConnections<N, E> connectionsV = requireNonNull(nodeConnections.get(nodeV));
+ NetworkConnections<N, E> connectionsV = nodeConnections.get(nodeV);
connectionsU.removeOutEdge(edge);
connectionsV.removeInEdge(edge, allowsSelfLoops() && nodeU.equals(nodeV));
edgeToReferenceNode.remove(edge);
diff --git a/guava/src/com/google/common/graph/StandardMutableValueGraph.java b/guava/src/com/google/common/graph/StandardMutableValueGraph.java
index 0ea641a..558d8d6 100644
--- a/guava/src/com/google/common/graph/StandardMutableValueGraph.java
+++ b/guava/src/com/google/common/graph/StandardMutableValueGraph.java
@@ -22,10 +22,8 @@
import static com.google.common.graph.GraphConstants.SELF_LOOPS_NOT_ALLOWED;
import static com.google.common.graph.Graphs.checkNonNegative;
import static com.google.common.graph.Graphs.checkPositive;
-import static java.util.Objects.requireNonNull;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
-import javax.annotation.CheckForNull;
/**
* Standard implementation of {@link MutableValueGraph} that supports both directed and undirected
@@ -40,7 +38,6 @@
* @param <N> Node parameter type
* @param <V> Value parameter type
*/
-@ElementTypesAreNonnullByDefault
final class StandardMutableValueGraph<N, V> extends StandardValueGraph<N, V>
implements MutableValueGraph<N, V> {
@@ -84,7 +81,6 @@
@Override
@CanIgnoreReturnValue
- @CheckForNull
public V putEdgeValue(N nodeU, N nodeV, V value) {
checkNotNull(nodeU, "nodeU");
checkNotNull(nodeV, "nodeV");
@@ -112,7 +108,6 @@
@Override
@CanIgnoreReturnValue
- @CheckForNull
public V putEdgeValue(EndpointPair<N> endpoints, V value) {
validateEndpoints(endpoints);
return putEdgeValue(endpoints.nodeU(), endpoints.nodeV(), value);
@@ -137,16 +132,12 @@
}
for (N successor : connections.successors()) {
- // requireNonNull is safe because the node is a successor.
- requireNonNull(nodeConnections.getWithoutCaching(successor)).removePredecessor(node);
+ nodeConnections.getWithoutCaching(successor).removePredecessor(node);
--edgeCount;
}
if (isDirected()) { // In undirected graphs, the successor and predecessor sets are equal.
for (N predecessor : connections.predecessors()) {
- // requireNonNull is safe because the node is a predecessor.
- checkState(
- requireNonNull(nodeConnections.getWithoutCaching(predecessor)).removeSuccessor(node)
- != null);
+ checkState(nodeConnections.getWithoutCaching(predecessor).removeSuccessor(node) != null);
--edgeCount;
}
}
@@ -157,7 +148,6 @@
@Override
@CanIgnoreReturnValue
- @CheckForNull
public V removeEdge(N nodeU, N nodeV) {
checkNotNull(nodeU, "nodeU");
checkNotNull(nodeV, "nodeV");
@@ -178,7 +168,6 @@
@Override
@CanIgnoreReturnValue
- @CheckForNull
public V removeEdge(EndpointPair<N> endpoints) {
validateEndpoints(endpoints);
return removeEdge(endpoints.nodeU(), endpoints.nodeV());
diff --git a/guava/src/com/google/common/graph/StandardNetwork.java b/guava/src/com/google/common/graph/StandardNetwork.java
index 2aa103f..1b82301 100644
--- a/guava/src/com/google/common/graph/StandardNetwork.java
+++ b/guava/src/com/google/common/graph/StandardNetwork.java
@@ -22,12 +22,12 @@
import static com.google.common.graph.GraphConstants.DEFAULT_NODE_COUNT;
import static com.google.common.graph.GraphConstants.EDGE_NOT_IN_GRAPH;
import static com.google.common.graph.GraphConstants.NODE_NOT_IN_GRAPH;
-import static java.util.Objects.requireNonNull;
import com.google.common.collect.ImmutableSet;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Standard implementation of {@link Network} that supports the options supplied by {@link
@@ -48,7 +48,6 @@
* @param <N> Node parameter type
* @param <E> Edge parameter type
*/
-@ElementTypesAreNonnullByDefault
class StandardNetwork<N, E> extends AbstractNetwork<N, E> {
private final boolean isDirected;
private final boolean allowsParallelEdges;
@@ -56,11 +55,11 @@
private final ElementOrder<N> nodeOrder;
private final ElementOrder<E> edgeOrder;
- final MapIteratorCache<N, NetworkConnections<N, E>> nodeConnections;
+ protected final MapIteratorCache<N, NetworkConnections<N, E>> nodeConnections;
// We could make this a Map<E, EndpointPair<N>>. It would make incidentNodes(edge) slightly
// faster, but also make Networks consume 5 to 20+% (increasing with average degree) more memory.
- final MapIteratorCache<E, N> edgeToReferenceNode; // referenceNode == source if directed
+ protected final MapIteratorCache<E, N> edgeToReferenceNode; // referenceNode == source if directed
/** Constructs a graph with the properties specified in {@code builder}. */
StandardNetwork(NetworkBuilder<? super N, ? super E> builder) {
@@ -136,8 +135,7 @@
@Override
public EndpointPair<N> incidentNodes(E edge) {
N nodeU = checkedReferenceNode(edge);
- // requireNonNull is safe because checkedReferenceNode made sure the edge is in the network.
- N nodeV = requireNonNull(nodeConnections.get(nodeU)).adjacentNode(edge);
+ N nodeV = nodeConnections.get(nodeU).adjacentNode(edge);
return EndpointPair.of(this, nodeU, nodeV);
}
@@ -176,7 +174,7 @@
return checkedConnections(node).successors();
}
- final NetworkConnections<N, E> checkedConnections(N node) {
+ protected final NetworkConnections<N, E> checkedConnections(N node) {
NetworkConnections<N, E> connections = nodeConnections.get(node);
if (connections == null) {
checkNotNull(node);
@@ -185,7 +183,7 @@
return connections;
}
- final N checkedReferenceNode(E edge) {
+ protected final N checkedReferenceNode(E edge) {
N referenceNode = edgeToReferenceNode.get(edge);
if (referenceNode == null) {
checkNotNull(edge);
@@ -194,11 +192,11 @@
return referenceNode;
}
- final boolean containsNode(N node) {
+ protected final boolean containsNode(@Nullable N node) {
return nodeConnections.containsKey(node);
}
- final boolean containsEdge(E edge) {
+ protected final boolean containsEdge(@Nullable E edge) {
return edgeToReferenceNode.containsKey(edge);
}
}
diff --git a/guava/src/com/google/common/graph/StandardValueGraph.java b/guava/src/com/google/common/graph/StandardValueGraph.java
index f2c71bc..8da0b0f 100644
--- a/guava/src/com/google/common/graph/StandardValueGraph.java
+++ b/guava/src/com/google/common/graph/StandardValueGraph.java
@@ -24,7 +24,7 @@
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Standard implementation of {@link ValueGraph} that supports the options supplied by {@link
@@ -43,15 +43,14 @@
* @param <N> Node parameter type
* @param <V> Value parameter type
*/
-@ElementTypesAreNonnullByDefault
class StandardValueGraph<N, V> extends AbstractValueGraph<N, V> {
private final boolean isDirected;
private final boolean allowsSelfLoops;
private final ElementOrder<N> nodeOrder;
- final MapIteratorCache<N, GraphConnections<N, V>> nodeConnections;
+ protected final MapIteratorCache<N, GraphConnections<N, V>> nodeConnections;
- long edgeCount; // must be updated when edges are added or removed
+ protected long edgeCount; // must be updated when edges are added or removed
/** Constructs a graph with the properties specified in {@code builder}. */
StandardValueGraph(AbstractGraphBuilder<? super N> builder) {
@@ -130,27 +129,25 @@
@Override
public boolean hasEdgeConnecting(N nodeU, N nodeV) {
- return hasEdgeConnectingInternal(checkNotNull(nodeU), checkNotNull(nodeV));
+ return hasEdgeConnecting_internal(checkNotNull(nodeU), checkNotNull(nodeV));
}
@Override
public boolean hasEdgeConnecting(EndpointPair<N> endpoints) {
checkNotNull(endpoints);
return isOrderingCompatible(endpoints)
- && hasEdgeConnectingInternal(endpoints.nodeU(), endpoints.nodeV());
+ && hasEdgeConnecting_internal(endpoints.nodeU(), endpoints.nodeV());
}
@Override
- @CheckForNull
- public V edgeValueOrDefault(N nodeU, N nodeV, @CheckForNull V defaultValue) {
- return edgeValueOrDefaultInternal(checkNotNull(nodeU), checkNotNull(nodeV), defaultValue);
+ public @Nullable V edgeValueOrDefault(N nodeU, N nodeV, @Nullable V defaultValue) {
+ return edgeValueOrDefault_internal(checkNotNull(nodeU), checkNotNull(nodeV), defaultValue);
}
@Override
- @CheckForNull
- public V edgeValueOrDefault(EndpointPair<N> endpoints, @CheckForNull V defaultValue) {
+ public @Nullable V edgeValueOrDefault(EndpointPair<N> endpoints, @Nullable V defaultValue) {
validateEndpoints(endpoints);
- return edgeValueOrDefaultInternal(endpoints.nodeU(), endpoints.nodeV(), defaultValue);
+ return edgeValueOrDefault_internal(endpoints.nodeU(), endpoints.nodeV(), defaultValue);
}
@Override
@@ -158,7 +155,7 @@
return edgeCount;
}
- private final GraphConnections<N, V> checkedConnections(N node) {
+ protected final GraphConnections<N, V> checkedConnections(N node) {
GraphConnections<N, V> connections = nodeConnections.get(node);
if (connections == null) {
checkNotNull(node);
@@ -167,24 +164,18 @@
return connections;
}
- final boolean containsNode(@CheckForNull N node) {
+ protected final boolean containsNode(@Nullable N node) {
return nodeConnections.containsKey(node);
}
- private final boolean hasEdgeConnectingInternal(N nodeU, N nodeV) {
+ protected final boolean hasEdgeConnecting_internal(N nodeU, N nodeV) {
GraphConnections<N, V> connectionsU = nodeConnections.get(nodeU);
return (connectionsU != null) && connectionsU.successors().contains(nodeV);
}
- @CheckForNull
- private final V edgeValueOrDefaultInternal(N nodeU, N nodeV, @CheckForNull V defaultValue) {
+ protected final V edgeValueOrDefault_internal(N nodeU, N nodeV, V defaultValue) {
GraphConnections<N, V> connectionsU = nodeConnections.get(nodeU);
V value = (connectionsU == null) ? null : connectionsU.value(nodeV);
- // TODO(b/192579700): Use a ternary once it no longer confuses our nullness checker.
- if (value == null) {
- return defaultValue;
- } else {
- return value;
- }
+ return value == null ? defaultValue : value;
}
}
diff --git a/guava/src/com/google/common/graph/SuccessorsFunction.java b/guava/src/com/google/common/graph/SuccessorsFunction.java
index c29bb4b..f74f437 100644
--- a/guava/src/com/google/common/graph/SuccessorsFunction.java
+++ b/guava/src/com/google/common/graph/SuccessorsFunction.java
@@ -80,7 +80,6 @@
*/
@Beta
@DoNotMock("Implement with a lambda, or use GraphBuilder to build a Graph with the desired edges")
-@ElementTypesAreNonnullByDefault
public interface SuccessorsFunction<N> {
/**
diff --git a/guava/src/com/google/common/graph/Traverser.java b/guava/src/com/google/common/graph/Traverser.java
index 5a36f9f..be0eecb 100644
--- a/guava/src/com/google/common/graph/Traverser.java
+++ b/guava/src/com/google/common/graph/Traverser.java
@@ -18,7 +18,6 @@
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
-import static java.util.Objects.requireNonNull;
import com.google.common.annotations.Beta;
import com.google.common.collect.AbstractIterator;
@@ -29,7 +28,7 @@
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
-import javax.annotation.CheckForNull;
+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)
@@ -64,7 +63,6 @@
@DoNotMock(
"Call forGraph or forTree, passing a lambda or a Graph with the desired edges (built with"
+ " GraphBuilder)")
-@ElementTypesAreNonnullByDefault
public abstract class Traverser<N> {
private final SuccessorsFunction<N> successorFunction;
@@ -385,20 +383,10 @@
final Set<N> visited = new HashSet<>();
return new Traversal<N>(graph) {
@Override
- @CheckForNull
N visitNext(Deque<Iterator<? extends N>> horizon) {
Iterator<? extends N> top = horizon.getFirst();
while (top.hasNext()) {
- N element = top.next();
- // requireNonNull is safe because horizon contains only graph nodes.
- /*
- * TODO(cpovirk): Replace these two statements with one (`N element =
- * requireNonNull(top.next())`) once our checker supports it.
- *
- * (The problem is likely
- * https://github.com/jspecify/nullness-checker-for-checker-framework/blob/61aafa4ae52594830cfc2d61c8b113009dbdb045/src/main/java/com/google/jspecify/nullness/NullSpecAnnotatedTypeFactory.java#L896)
- */
- requireNonNull(element);
+ N element = checkNotNull(top.next());
if (visited.add(element)) {
return element;
}
@@ -411,7 +399,6 @@
static <N> Traversal<N> inTree(SuccessorsFunction<N> tree) {
return new Traversal<N>(tree) {
- @CheckForNull
@Override
N visitNext(Deque<Iterator<? extends N>> horizon) {
Iterator<? extends N> top = horizon.getFirst();
@@ -443,7 +430,6 @@
horizon.add(startNodes);
return new AbstractIterator<N>() {
@Override
- @CheckForNull
protected N computeNext() {
do {
N next = visitNext(horizon);
@@ -468,7 +454,6 @@
horizon.add(startNodes);
return new AbstractIterator<N>() {
@Override
- @CheckForNull
protected N computeNext() {
for (N next = visitNext(horizon); next != null; next = visitNext(horizon)) {
Iterator<? extends N> successors = successorFunction.successors(next).iterator();
@@ -478,11 +463,7 @@
horizon.addFirst(successors);
ancestorStack.push(next);
}
- // TODO(b/192579700): Use a ternary once it no longer confuses our nullness checker.
- if (!ancestorStack.isEmpty()) {
- return ancestorStack.pop();
- }
- return endOfData();
+ return ancestorStack.isEmpty() ? endOfData() : ancestorStack.pop();
}
};
}
@@ -497,7 +478,7 @@
* into {@code horizon} between calls to {@code visitNext()}. This causes them to receive
* additional values interleaved with those shown above.)
*/
- @CheckForNull
+ @Nullable
abstract N visitNext(Deque<Iterator<? extends N>> horizon);
}
diff --git a/guava/src/com/google/common/graph/UndirectedGraphConnections.java b/guava/src/com/google/common/graph/UndirectedGraphConnections.java
index 085e3a7..49689f9 100644
--- a/guava/src/com/google/common/graph/UndirectedGraphConnections.java
+++ b/guava/src/com/google/common/graph/UndirectedGraphConnections.java
@@ -29,7 +29,6 @@
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;
-import javax.annotation.CheckForNull;
/**
* An implementation of {@link GraphConnections} for undirected graphs.
@@ -38,7 +37,6 @@
* @param <N> Node parameter type
* @param <V> Value parameter type
*/
-@ElementTypesAreNonnullByDefault
final class UndirectedGraphConnections<N, V> implements GraphConnections<N, V> {
private final Map<N, V> adjacentNodeValues;
@@ -91,7 +89,6 @@
}
@Override
- @CheckForNull
public V value(N node) {
return adjacentNodeValues.get(node);
}
@@ -103,7 +100,6 @@
}
@Override
- @CheckForNull
public V removeSuccessor(N node) {
return adjacentNodeValues.remove(node);
}
@@ -115,7 +111,6 @@
}
@Override
- @CheckForNull
public V addSuccessor(N node, V value) {
return adjacentNodeValues.put(node, value);
}
diff --git a/guava/src/com/google/common/graph/UndirectedMultiNetworkConnections.java b/guava/src/com/google/common/graph/UndirectedMultiNetworkConnections.java
index a5c45ca..a96a595 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 javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* An implementation of {@link NetworkConnections} for undirected networks with parallel edges.
@@ -39,7 +39,6 @@
* @param <N> Node parameter type
* @param <E> Edge parameter type
*/
-@ElementTypesAreNonnullByDefault
final class UndirectedMultiNetworkConnections<N, E>
extends AbstractUndirectedNetworkConnections<N, E> {
@@ -56,7 +55,7 @@
return new UndirectedMultiNetworkConnections<>(ImmutableMap.copyOf(incidentEdges));
}
- @CheckForNull @LazyInit private transient Reference<Multiset<N>> adjacentNodesReference;
+ @LazyInit private transient Reference<Multiset<N>> adjacentNodesReference;
@Override
public Set<N> adjacentNodes() {
@@ -83,7 +82,6 @@
}
@Override
- @CheckForNull
public N removeInEdge(E edge, boolean isSelfLoop) {
if (!isSelfLoop) {
return removeOutEdge(edge);
@@ -117,8 +115,7 @@
}
}
- @CheckForNull
- private static <T> T getReference(@CheckForNull Reference<T> reference) {
+ private static <T> @Nullable T getReference(@Nullable Reference<T> reference) {
return (reference == null) ? null : reference.get();
}
}
diff --git a/guava/src/com/google/common/graph/UndirectedNetworkConnections.java b/guava/src/com/google/common/graph/UndirectedNetworkConnections.java
index 38cb763..1e253dd 100644
--- a/guava/src/com/google/common/graph/UndirectedNetworkConnections.java
+++ b/guava/src/com/google/common/graph/UndirectedNetworkConnections.java
@@ -32,10 +32,9 @@
* @param <N> Node parameter type
* @param <E> Edge parameter type
*/
-@ElementTypesAreNonnullByDefault
final class UndirectedNetworkConnections<N, E> extends AbstractUndirectedNetworkConnections<N, E> {
- UndirectedNetworkConnections(Map<E, N> incidentEdgeMap) {
+ protected UndirectedNetworkConnections(Map<E, N> incidentEdgeMap) {
super(incidentEdgeMap);
}
diff --git a/guava/src/com/google/common/graph/ValueGraph.java b/guava/src/com/google/common/graph/ValueGraph.java
index a13e87e..ed27058 100644
--- a/guava/src/com/google/common/graph/ValueGraph.java
+++ b/guava/src/com/google/common/graph/ValueGraph.java
@@ -20,7 +20,7 @@
import java.util.Collection;
import java.util.Optional;
import java.util.Set;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* An interface for <a
@@ -108,7 +108,6 @@
* @since 20.0
*/
@Beta
-@ElementTypesAreNonnullByDefault
public interface ValueGraph<N, V> extends BaseGraph<N> {
//
// ValueGraph-level accessors
@@ -310,8 +309,8 @@
* @throws IllegalArgumentException if {@code nodeU} or {@code nodeV} is not an element of this
* graph
*/
- @CheckForNull
- V edgeValueOrDefault(N nodeU, N nodeV, @CheckForNull V defaultValue);
+ @Nullable
+ V edgeValueOrDefault(N nodeU, N nodeV, @Nullable V defaultValue);
/**
* Returns the value of the edge that connects {@code endpoints} (in the order, if any, specified
@@ -323,8 +322,8 @@
* @throws IllegalArgumentException if the endpoints are unordered and the graph is directed
* @since 27.1
*/
- @CheckForNull
- V edgeValueOrDefault(EndpointPair<N> endpoints, @CheckForNull V defaultValue);
+ @Nullable
+ V edgeValueOrDefault(EndpointPair<N> endpoints, @Nullable V defaultValue);
//
// ValueGraph identity
@@ -351,7 +350,7 @@
* <p>A reference implementation of this is provided by {@link AbstractValueGraph#equals(Object)}.
*/
@Override
- boolean equals(@CheckForNull 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/graph/ValueGraphBuilder.java b/guava/src/com/google/common/graph/ValueGraphBuilder.java
index ce146c3..4fc752d 100644
--- a/guava/src/com/google/common/graph/ValueGraphBuilder.java
+++ b/guava/src/com/google/common/graph/ValueGraphBuilder.java
@@ -66,7 +66,6 @@
* @since 20.0
*/
@Beta
-@ElementTypesAreNonnullByDefault
public final class ValueGraphBuilder<N, V> extends AbstractGraphBuilder<N> {
/** Creates a new instance with the specified edge directionality. */
diff --git a/guava/src/com/google/common/hash/AbstractByteHasher.java b/guava/src/com/google/common/hash/AbstractByteHasher.java
index 9f7e041..48d48c4 100644
--- a/guava/src/com/google/common/hash/AbstractByteHasher.java
+++ b/guava/src/com/google/common/hash/AbstractByteHasher.java
@@ -32,7 +32,6 @@
* @author Colin Decker
*/
@CanIgnoreReturnValue
-@ElementTypesAreNonnullByDefault
abstract class AbstractByteHasher extends AbstractHasher {
private final ByteBuffer scratch = ByteBuffer.allocate(8).order(ByteOrder.LITTLE_ENDIAN);
diff --git a/guava/src/com/google/common/hash/AbstractCompositeHashFunction.java b/guava/src/com/google/common/hash/AbstractCompositeHashFunction.java
index 4b69bb7..048e6c2 100644
--- a/guava/src/com/google/common/hash/AbstractCompositeHashFunction.java
+++ b/guava/src/com/google/common/hash/AbstractCompositeHashFunction.java
@@ -20,7 +20,6 @@
import com.google.errorprone.annotations.Immutable;
import java.nio.ByteBuffer;
import java.nio.charset.Charset;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* An abstract composition of multiple hash functions. {@linkplain #newHasher()} delegates to the
@@ -30,7 +29,6 @@
* @author Dimitris Andreou
*/
@Immutable
-@ElementTypesAreNonnullByDefault
abstract class AbstractCompositeHashFunction extends AbstractHashFunction {
@SuppressWarnings("Immutable") // array not modified after creation
@@ -179,8 +177,7 @@
}
@Override
- public <T extends @Nullable Object> Hasher putObject(
- @ParametricNullness T instance, Funnel<? super T> funnel) {
+ public <T> Hasher putObject(T instance, Funnel<? super T> funnel) {
for (Hasher hasher : hashers) {
hasher.putObject(instance, funnel);
}
diff --git a/guava/src/com/google/common/hash/AbstractHashFunction.java b/guava/src/com/google/common/hash/AbstractHashFunction.java
index 7308556..6184189 100644
--- a/guava/src/com/google/common/hash/AbstractHashFunction.java
+++ b/guava/src/com/google/common/hash/AbstractHashFunction.java
@@ -20,7 +20,6 @@
import com.google.errorprone.annotations.Immutable;
import java.nio.ByteBuffer;
import java.nio.charset.Charset;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Skeleton implementation of {@link HashFunction} in terms of {@link #newHasher()}.
@@ -28,11 +27,9 @@
* <p>TODO(lowasser): make public
*/
@Immutable
-@ElementTypesAreNonnullByDefault
abstract class AbstractHashFunction implements HashFunction {
@Override
- public <T extends @Nullable Object> HashCode hashObject(
- @ParametricNullness T instance, Funnel<? super T> funnel) {
+ public <T> HashCode hashObject(T instance, Funnel<? super T> funnel) {
return newHasher().putObject(instance, funnel).hash();
}
diff --git a/guava/src/com/google/common/hash/AbstractHasher.java b/guava/src/com/google/common/hash/AbstractHasher.java
index c72e05b..326aa8d 100644
--- a/guava/src/com/google/common/hash/AbstractHasher.java
+++ b/guava/src/com/google/common/hash/AbstractHasher.java
@@ -18,7 +18,6 @@
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import java.nio.ByteBuffer;
import java.nio.charset.Charset;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* An abstract implementation of {@link Hasher}, which only requires subtypes to implement {@link
@@ -27,7 +26,6 @@
* @author Dimitris Andreou
*/
@CanIgnoreReturnValue
-@ElementTypesAreNonnullByDefault
abstract class AbstractHasher implements Hasher {
@Override
public final Hasher putBoolean(boolean b) {
@@ -116,8 +114,7 @@
}
@Override
- public <T extends @Nullable Object> Hasher putObject(
- @ParametricNullness T instance, Funnel<? super T> funnel) {
+ public <T> Hasher putObject(T instance, Funnel<? super T> funnel) {
funnel.funnel(instance, this);
return this;
}
diff --git a/guava/src/com/google/common/hash/AbstractNonStreamingHashFunction.java b/guava/src/com/google/common/hash/AbstractNonStreamingHashFunction.java
index 4969e35..54c76de 100644
--- a/guava/src/com/google/common/hash/AbstractNonStreamingHashFunction.java
+++ b/guava/src/com/google/common/hash/AbstractNonStreamingHashFunction.java
@@ -30,7 +30,6 @@
* @author Dimitris Andreou
*/
@Immutable
-@ElementTypesAreNonnullByDefault
abstract class AbstractNonStreamingHashFunction extends AbstractHashFunction {
@Override
public Hasher newHasher() {
diff --git a/guava/src/com/google/common/hash/AbstractStreamingHasher.java b/guava/src/com/google/common/hash/AbstractStreamingHasher.java
index a987b48..67de74b 100644
--- a/guava/src/com/google/common/hash/AbstractStreamingHasher.java
+++ b/guava/src/com/google/common/hash/AbstractStreamingHasher.java
@@ -29,7 +29,6 @@
*/
// TODO(kevinb): this class still needs some design-and-document-for-inheritance love
@CanIgnoreReturnValue
-@ElementTypesAreNonnullByDefault
abstract class AbstractStreamingHasher extends AbstractHasher {
/** Buffer via which we pass data to the hash algorithm (the implementor) */
private final ByteBuffer buffer;
diff --git a/guava/src/com/google/common/hash/BloomFilter.java b/guava/src/com/google/common/hash/BloomFilter.java
index e0affaa..ba493eb 100644
--- a/guava/src/com/google/common/hash/BloomFilter.java
+++ b/guava/src/com/google/common/hash/BloomFilter.java
@@ -34,7 +34,6 @@
import java.io.Serializable;
import java.math.RoundingMode;
import java.util.stream.Collector;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -43,7 +42,7 @@
* but if it claims that an element is <i>not</i> contained in it, then this is definitely true.
*
* <p>If you are unfamiliar with Bloom filters, this nice <a
- * href="http://llimllib.github.io/bloomfilter-tutorial/">tutorial</a> may help you understand how
+ * href="http://llimllib.github.com/bloomfilter-tutorial/">tutorial</a> may help you understand how
* they work.
*
* <p>The false positive probability ({@code FPP}) of a Bloom filter is defined as the probability
@@ -65,8 +64,7 @@
* @since 11.0 (thread-safe since 23.0)
*/
@Beta
-@ElementTypesAreNonnullByDefault
-public final class BloomFilter<T extends @Nullable Object> implements Predicate<T>, Serializable {
+public final class BloomFilter<T> implements Predicate<T>, Serializable {
/**
* A strategy to translate T instances, to {@code numHashFunctions} bit indexes.
*
@@ -79,21 +77,15 @@
*
* <p>Returns whether any bits changed as a result of this operation.
*/
- <T extends @Nullable Object> boolean put(
- @ParametricNullness T object,
- Funnel<? super T> funnel,
- int numHashFunctions,
- LockFreeBitArray bits);
+ <T> boolean put(
+ T object, Funnel<? super T> funnel, int numHashFunctions, LockFreeBitArray bits);
/**
* Queries {@code numHashFunctions} bits of the given bit array, by hashing a user element;
* returns {@code true} if and only if all selected bits are set.
*/
- <T extends @Nullable Object> boolean mightContain(
- @ParametricNullness T object,
- Funnel<? super T> funnel,
- int numHashFunctions,
- LockFreeBitArray bits);
+ <T> boolean mightContain(
+ T object, Funnel<? super T> funnel, int numHashFunctions, LockFreeBitArray bits);
/**
* Identifier used to encode this strategy, when marshalled as part of a BloomFilter. Only
@@ -143,7 +135,7 @@
* Returns {@code true} if the element <i>might</i> have been put in this Bloom filter, {@code
* false} if this is <i>definitely</i> not the case.
*/
- public boolean mightContain(@ParametricNullness T object) {
+ public boolean mightContain(T object) {
return strategy.mightContain(object, funnel, numHashFunctions, bits);
}
@@ -153,7 +145,7 @@
*/
@Deprecated
@Override
- public boolean apply(@ParametricNullness T input) {
+ public boolean apply(T input) {
return mightContain(input);
}
@@ -169,7 +161,7 @@
* @since 12.0 (present in 11.0 with {@code void} return type})
*/
@CanIgnoreReturnValue
- public boolean put(@ParametricNullness T object) {
+ public boolean put(T object) {
return strategy.put(object, funnel, numHashFunctions, bits);
}
@@ -276,7 +268,7 @@
}
@Override
- public boolean equals(@CheckForNull Object object) {
+ public boolean equals(@Nullable Object object) {
if (object == this) {
return true;
}
@@ -316,7 +308,7 @@
* @return a {@code Collector} generating a {@code BloomFilter} of the received elements
* @since 23.0
*/
- public static <T extends @Nullable Object> Collector<T, ?, BloomFilter<T>> toBloomFilter(
+ public static <T> Collector<T, ?, BloomFilter<T>> toBloomFilter(
Funnel<? super T> funnel, long expectedInsertions) {
return toBloomFilter(funnel, expectedInsertions, 0.03);
}
@@ -343,7 +335,7 @@
* @return a {@code Collector} generating a {@code BloomFilter} of the received elements
* @since 23.0
*/
- public static <T extends @Nullable Object> Collector<T, ?, BloomFilter<T>> toBloomFilter(
+ public static <T> Collector<T, ?, BloomFilter<T>> toBloomFilter(
Funnel<? super T> funnel, long expectedInsertions, double fpp) {
checkNotNull(funnel);
checkArgument(
@@ -381,7 +373,7 @@
* @param fpp the desired false positive probability (must be positive and less than 1.0)
* @return a {@code BloomFilter}
*/
- public static <T extends @Nullable Object> BloomFilter<T> create(
+ public static <T> BloomFilter<T> create(
Funnel<? super T> funnel, int expectedInsertions, double fpp) {
return create(funnel, (long) expectedInsertions, fpp);
}
@@ -407,13 +399,13 @@
* @return a {@code BloomFilter}
* @since 19.0
*/
- public static <T extends @Nullable Object> BloomFilter<T> create(
+ public static <T> BloomFilter<T> create(
Funnel<? super T> funnel, long expectedInsertions, double fpp) {
return create(funnel, expectedInsertions, fpp, BloomFilterStrategies.MURMUR128_MITZ_64);
}
@VisibleForTesting
- static <T extends @Nullable Object> BloomFilter<T> create(
+ static <T> BloomFilter<T> create(
Funnel<? super T> funnel, long expectedInsertions, double fpp, Strategy strategy) {
checkNotNull(funnel);
checkArgument(
@@ -458,8 +450,7 @@
* BloomFilter}; must be positive
* @return a {@code BloomFilter}
*/
- public static <T extends @Nullable Object> BloomFilter<T> create(
- Funnel<? super T> funnel, int expectedInsertions) {
+ public static <T> BloomFilter<T> create(Funnel<? super T> funnel, int expectedInsertions) {
return create(funnel, (long) expectedInsertions);
}
@@ -483,8 +474,7 @@
* @return a {@code BloomFilter}
* @since 19.0
*/
- public static <T extends @Nullable Object> BloomFilter<T> create(
- Funnel<? super T> funnel, long expectedInsertions) {
+ public static <T> BloomFilter<T> create(Funnel<? super T> funnel, long expectedInsertions) {
return create(funnel, expectedInsertions, 0.03); // FYI, for 3%, we always get 5 hash functions
}
@@ -537,7 +527,7 @@
return new SerialForm<T>(this);
}
- private static class SerialForm<T extends @Nullable Object> implements Serializable {
+ private static class SerialForm<T> implements Serializable {
final long[] data;
final int numHashFunctions;
final Funnel<? super T> funnel;
@@ -590,8 +580,8 @@
* @throws IOException if the InputStream throws an {@code IOException}, or if its data does not
* appear to be a BloomFilter serialized using the {@linkplain #writeTo(OutputStream)} method.
*/
- public static <T extends @Nullable Object> BloomFilter<T> readFrom(
- InputStream in, Funnel<? super T> funnel) throws IOException {
+ public static <T> BloomFilter<T> readFrom(InputStream in, Funnel<? super T> funnel)
+ throws IOException {
checkNotNull(in, "InputStream");
checkNotNull(funnel, "Funnel");
int strategyOrdinal = -1;
diff --git a/guava/src/com/google/common/hash/BloomFilterStrategies.java b/guava/src/com/google/common/hash/BloomFilterStrategies.java
index 3a012f3..1b4abea 100644
--- a/guava/src/com/google/common/hash/BloomFilterStrategies.java
+++ b/guava/src/com/google/common/hash/BloomFilterStrategies.java
@@ -22,7 +22,6 @@
import java.math.RoundingMode;
import java.util.Arrays;
import java.util.concurrent.atomic.AtomicLongArray;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -37,7 +36,6 @@
* @author Dimitris Andreou
* @author Kurt Alfred Kluever
*/
-@ElementTypesAreNonnullByDefault
enum BloomFilterStrategies implements BloomFilter.Strategy {
/**
* See "Less Hashing, Same Performance: Building a Better Bloom Filter" by Adam Kirsch and Michael
@@ -46,11 +44,8 @@
*/
MURMUR128_MITZ_32() {
@Override
- public <T extends @Nullable Object> boolean put(
- @ParametricNullness T object,
- Funnel<? super T> funnel,
- int numHashFunctions,
- LockFreeBitArray bits) {
+ public <T> boolean put(
+ T object, Funnel<? super T> funnel, int numHashFunctions, LockFreeBitArray bits) {
long bitSize = bits.bitSize();
long hash64 = Hashing.murmur3_128().hashObject(object, funnel).asLong();
int hash1 = (int) hash64;
@@ -69,11 +64,8 @@
}
@Override
- public <T extends @Nullable Object> boolean mightContain(
- @ParametricNullness T object,
- Funnel<? super T> funnel,
- int numHashFunctions,
- LockFreeBitArray bits) {
+ public <T> boolean mightContain(
+ T object, Funnel<? super T> funnel, int numHashFunctions, LockFreeBitArray bits) {
long bitSize = bits.bitSize();
long hash64 = Hashing.murmur3_128().hashObject(object, funnel).asLong();
int hash1 = (int) hash64;
@@ -100,11 +92,8 @@
*/
MURMUR128_MITZ_64() {
@Override
- public <T extends @Nullable Object> boolean put(
- @ParametricNullness T object,
- Funnel<? super T> funnel,
- int numHashFunctions,
- LockFreeBitArray bits) {
+ public <T> boolean put(
+ T object, Funnel<? super T> funnel, int numHashFunctions, LockFreeBitArray bits) {
long bitSize = bits.bitSize();
byte[] bytes = Hashing.murmur3_128().hashObject(object, funnel).getBytesInternal();
long hash1 = lowerEight(bytes);
@@ -121,11 +110,8 @@
}
@Override
- public <T extends @Nullable Object> boolean mightContain(
- @ParametricNullness T object,
- Funnel<? super T> funnel,
- int numHashFunctions,
- LockFreeBitArray bits) {
+ public <T> boolean mightContain(
+ T object, Funnel<? super T> funnel, int numHashFunctions, LockFreeBitArray bits) {
long bitSize = bits.bitSize();
byte[] bytes = Hashing.murmur3_128().hashObject(object, funnel).getBytesInternal();
long hash1 = lowerEight(bytes);
@@ -285,7 +271,7 @@
}
@Override
- public boolean equals(@CheckForNull 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/ChecksumHashFunction.java b/guava/src/com/google/common/hash/ChecksumHashFunction.java
index 159adbb..380c3a3 100644
--- a/guava/src/com/google/common/hash/ChecksumHashFunction.java
+++ b/guava/src/com/google/common/hash/ChecksumHashFunction.java
@@ -27,7 +27,6 @@
* @author Colin Decker
*/
@Immutable
-@ElementTypesAreNonnullByDefault
final class ChecksumHashFunction extends AbstractHashFunction implements Serializable {
private final ImmutableSupplier<? extends Checksum> checksumSupplier;
private final int bits;
diff --git a/guava/src/com/google/common/hash/Crc32cHashFunction.java b/guava/src/com/google/common/hash/Crc32cHashFunction.java
index 8e17e65..02db525 100644
--- a/guava/src/com/google/common/hash/Crc32cHashFunction.java
+++ b/guava/src/com/google/common/hash/Crc32cHashFunction.java
@@ -15,7 +15,6 @@
package com.google.common.hash;
import com.google.errorprone.annotations.Immutable;
-import java.nio.ByteBuffer;
/**
* This class generates a CRC32C checksum, defined by RFC 3720, Section 12.1. The generator
@@ -24,7 +23,6 @@
* @author Kurt Alfred Kluever
*/
@Immutable
-@ElementTypesAreNonnullByDefault
final class Crc32cHashFunction extends AbstractHashFunction {
static final HashFunction CRC_32_C = new Crc32cHashFunction();
@@ -43,332 +41,88 @@
return "Hashing.crc32c()";
}
- static final class Crc32cHasher extends AbstractStreamingHasher {
+ static final class Crc32cHasher extends AbstractByteHasher {
- /*
- * The striding algorithm works roughly as follows: it is universally the case that
- * CRC(x ^ y) == CRC(x) ^ CRC(y). The approach we take is to break the message as follows,
- * with each letter representing a 4-byte word: ABCDABCDABCDABCD... and to calculate
- * CRC(A000A000A000...), CRC(0B000B000B...), CRC(00C000C000C...), CRC(000D000D000D...)
- * and then to XOR them together. The STRIDE_TABLE enables us to hash an int followed by 12
- * zero bytes (3 ints), while the BYTE_TABLE is for advancing one byte at a time.
- * This algorithm is due to the paper "Everything we know about CRC but [are] afraid to forget"
- * by Kadatch and Jenkins, 2010.
- */
-
- Crc32cHasher() {
- super(16);
- }
-
- private boolean finished = false;
-
- /*
- * This trick allows us to avoid having separate states for "first four ints" and "all other
- * four int chunks." The state we want after the first four bytes is
- *
- * crc0 = ~int0
- * crc1 = int1
- * crc2 = int2
- * crc3 = int3
- *
- * ...so we set crc0 so that computeForWord(crc0) = -1 and xoring it with the first int
- * gives us the desired result. computeForWord(0) == 0, so all the others do the right thing.
- */
- private int crc0 = INVERSE_COMPUTE_FOR_WORD_OF_ALL_1S;
- private int crc1 = 0;
- private int crc2 = 0;
- private int crc3 = 0;
-
- @Override
- protected void process(ByteBuffer bb) {
- if (finished) {
- throw new IllegalStateException(
- "The behavior of calling any method after calling hash() is undefined.");
- }
- while (bb.remaining() >= 16) {
- crc0 = computeForWord(crc0);
- crc1 = computeForWord(crc1);
- crc2 = computeForWord(crc2);
- crc3 = computeForWord(crc3);
- crc0 ^= bb.getInt();
- crc1 ^= bb.getInt();
- crc2 ^= bb.getInt();
- crc3 ^= bb.getInt();
- }
- }
-
- @Override
- protected void processRemaining(ByteBuffer bb) {
- if (finished) {
- return;
- }
- crc0 = combine(0, crc0);
- crc0 = combine(crc0, crc1);
- crc0 = combine(crc0, crc2);
- crc0 = combine(crc0, crc3);
- while (bb.hasRemaining()) {
- crc0 = (crc0 >>> 8) ^ BYTE_TABLE[(bb.get() ^ crc0) & 0xFF];
- }
- finished = true;
- }
-
- @Override
- protected HashCode makeHash() {
- if (!finished) {
- // processRemaining does teardown we always want to do -- the folding together of the four
- // rolling CRCs. So we call it on an empty ByteBuffer if we didn't already.
- processRemaining(EMPTY);
- }
- return HashCode.fromInt(~crc0);
- }
-
- static final int[] BYTE_TABLE = {
- 0x00000000, 0xf26b8303, 0xe13b70f7, 0x1350f3f4, 0xc79a971f, 0x35f1141c,
- 0x26a1e7e8, 0xd4ca64eb, 0x8ad958cf, 0x78b2dbcc, 0x6be22838, 0x9989ab3b,
- 0x4d43cfd0, 0xbf284cd3, 0xac78bf27, 0x5e133c24, 0x105ec76f, 0xe235446c,
- 0xf165b798, 0x030e349b, 0xd7c45070, 0x25afd373, 0x36ff2087, 0xc494a384,
- 0x9a879fa0, 0x68ec1ca3, 0x7bbcef57, 0x89d76c54, 0x5d1d08bf, 0xaf768bbc,
- 0xbc267848, 0x4e4dfb4b, 0x20bd8ede, 0xd2d60ddd, 0xc186fe29, 0x33ed7d2a,
- 0xe72719c1, 0x154c9ac2, 0x061c6936, 0xf477ea35, 0xaa64d611, 0x580f5512,
- 0x4b5fa6e6, 0xb93425e5, 0x6dfe410e, 0x9f95c20d, 0x8cc531f9, 0x7eaeb2fa,
- 0x30e349b1, 0xc288cab2, 0xd1d83946, 0x23b3ba45, 0xf779deae, 0x05125dad,
- 0x1642ae59, 0xe4292d5a, 0xba3a117e, 0x4851927d, 0x5b016189, 0xa96ae28a,
- 0x7da08661, 0x8fcb0562, 0x9c9bf696, 0x6ef07595, 0x417b1dbc, 0xb3109ebf,
- 0xa0406d4b, 0x522bee48, 0x86e18aa3, 0x748a09a0, 0x67dafa54, 0x95b17957,
- 0xcba24573, 0x39c9c670, 0x2a993584, 0xd8f2b687, 0x0c38d26c, 0xfe53516f,
- 0xed03a29b, 0x1f682198, 0x5125dad3, 0xa34e59d0, 0xb01eaa24, 0x42752927,
- 0x96bf4dcc, 0x64d4cecf, 0x77843d3b, 0x85efbe38, 0xdbfc821c, 0x2997011f,
- 0x3ac7f2eb, 0xc8ac71e8, 0x1c661503, 0xee0d9600, 0xfd5d65f4, 0x0f36e6f7,
- 0x61c69362, 0x93ad1061, 0x80fde395, 0x72966096, 0xa65c047d, 0x5437877e,
- 0x4767748a, 0xb50cf789, 0xeb1fcbad, 0x197448ae, 0x0a24bb5a, 0xf84f3859,
- 0x2c855cb2, 0xdeeedfb1, 0xcdbe2c45, 0x3fd5af46, 0x7198540d, 0x83f3d70e,
- 0x90a324fa, 0x62c8a7f9, 0xb602c312, 0x44694011, 0x5739b3e5, 0xa55230e6,
- 0xfb410cc2, 0x092a8fc1, 0x1a7a7c35, 0xe811ff36, 0x3cdb9bdd, 0xceb018de,
- 0xdde0eb2a, 0x2f8b6829, 0x82f63b78, 0x709db87b, 0x63cd4b8f, 0x91a6c88c,
- 0x456cac67, 0xb7072f64, 0xa457dc90, 0x563c5f93, 0x082f63b7, 0xfa44e0b4,
- 0xe9141340, 0x1b7f9043, 0xcfb5f4a8, 0x3dde77ab, 0x2e8e845f, 0xdce5075c,
- 0x92a8fc17, 0x60c37f14, 0x73938ce0, 0x81f80fe3, 0x55326b08, 0xa759e80b,
- 0xb4091bff, 0x466298fc, 0x1871a4d8, 0xea1a27db, 0xf94ad42f, 0x0b21572c,
- 0xdfeb33c7, 0x2d80b0c4, 0x3ed04330, 0xccbbc033, 0xa24bb5a6, 0x502036a5,
- 0x4370c551, 0xb11b4652, 0x65d122b9, 0x97baa1ba, 0x84ea524e, 0x7681d14d,
- 0x2892ed69, 0xdaf96e6a, 0xc9a99d9e, 0x3bc21e9d, 0xef087a76, 0x1d63f975,
- 0x0e330a81, 0xfc588982, 0xb21572c9, 0x407ef1ca, 0x532e023e, 0xa145813d,
- 0x758fe5d6, 0x87e466d5, 0x94b49521, 0x66df1622, 0x38cc2a06, 0xcaa7a905,
- 0xd9f75af1, 0x2b9cd9f2, 0xff56bd19, 0x0d3d3e1a, 0x1e6dcdee, 0xec064eed,
- 0xc38d26c4, 0x31e6a5c7, 0x22b65633, 0xd0ddd530, 0x0417b1db, 0xf67c32d8,
- 0xe52cc12c, 0x1747422f, 0x49547e0b, 0xbb3ffd08, 0xa86f0efc, 0x5a048dff,
- 0x8ecee914, 0x7ca56a17, 0x6ff599e3, 0x9d9e1ae0, 0xd3d3e1ab, 0x21b862a8,
- 0x32e8915c, 0xc083125f, 0x144976b4, 0xe622f5b7, 0xf5720643, 0x07198540,
- 0x590ab964, 0xab613a67, 0xb831c993, 0x4a5a4a90, 0x9e902e7b, 0x6cfbad78,
- 0x7fab5e8c, 0x8dc0dd8f, 0xe330a81a, 0x115b2b19, 0x020bd8ed, 0xf0605bee,
- 0x24aa3f05, 0xd6c1bc06, 0xc5914ff2, 0x37faccf1, 0x69e9f0d5, 0x9b8273d6,
- 0x88d28022, 0x7ab90321, 0xae7367ca, 0x5c18e4c9, 0x4f48173d, 0xbd23943e,
- 0xf36e6f75, 0x0105ec76, 0x12551f82, 0xe03e9c81, 0x34f4f86a, 0xc69f7b69,
- 0xd5cf889d, 0x27a40b9e, 0x79b737ba, 0x8bdcb4b9, 0x988c474d, 0x6ae7c44e,
+ // The CRC table, generated from the polynomial 0x11EDC6F41.
+ static final int[] CRC_TABLE = {
+ 0x00000000, 0xf26b8303, 0xe13b70f7, 0x1350f3f4,
+ 0xc79a971f, 0x35f1141c, 0x26a1e7e8, 0xd4ca64eb,
+ 0x8ad958cf, 0x78b2dbcc, 0x6be22838, 0x9989ab3b,
+ 0x4d43cfd0, 0xbf284cd3, 0xac78bf27, 0x5e133c24,
+ 0x105ec76f, 0xe235446c, 0xf165b798, 0x030e349b,
+ 0xd7c45070, 0x25afd373, 0x36ff2087, 0xc494a384,
+ 0x9a879fa0, 0x68ec1ca3, 0x7bbcef57, 0x89d76c54,
+ 0x5d1d08bf, 0xaf768bbc, 0xbc267848, 0x4e4dfb4b,
+ 0x20bd8ede, 0xd2d60ddd, 0xc186fe29, 0x33ed7d2a,
+ 0xe72719c1, 0x154c9ac2, 0x061c6936, 0xf477ea35,
+ 0xaa64d611, 0x580f5512, 0x4b5fa6e6, 0xb93425e5,
+ 0x6dfe410e, 0x9f95c20d, 0x8cc531f9, 0x7eaeb2fa,
+ 0x30e349b1, 0xc288cab2, 0xd1d83946, 0x23b3ba45,
+ 0xf779deae, 0x05125dad, 0x1642ae59, 0xe4292d5a,
+ 0xba3a117e, 0x4851927d, 0x5b016189, 0xa96ae28a,
+ 0x7da08661, 0x8fcb0562, 0x9c9bf696, 0x6ef07595,
+ 0x417b1dbc, 0xb3109ebf, 0xa0406d4b, 0x522bee48,
+ 0x86e18aa3, 0x748a09a0, 0x67dafa54, 0x95b17957,
+ 0xcba24573, 0x39c9c670, 0x2a993584, 0xd8f2b687,
+ 0x0c38d26c, 0xfe53516f, 0xed03a29b, 0x1f682198,
+ 0x5125dad3, 0xa34e59d0, 0xb01eaa24, 0x42752927,
+ 0x96bf4dcc, 0x64d4cecf, 0x77843d3b, 0x85efbe38,
+ 0xdbfc821c, 0x2997011f, 0x3ac7f2eb, 0xc8ac71e8,
+ 0x1c661503, 0xee0d9600, 0xfd5d65f4, 0x0f36e6f7,
+ 0x61c69362, 0x93ad1061, 0x80fde395, 0x72966096,
+ 0xa65c047d, 0x5437877e, 0x4767748a, 0xb50cf789,
+ 0xeb1fcbad, 0x197448ae, 0x0a24bb5a, 0xf84f3859,
+ 0x2c855cb2, 0xdeeedfb1, 0xcdbe2c45, 0x3fd5af46,
+ 0x7198540d, 0x83f3d70e, 0x90a324fa, 0x62c8a7f9,
+ 0xb602c312, 0x44694011, 0x5739b3e5, 0xa55230e6,
+ 0xfb410cc2, 0x092a8fc1, 0x1a7a7c35, 0xe811ff36,
+ 0x3cdb9bdd, 0xceb018de, 0xdde0eb2a, 0x2f8b6829,
+ 0x82f63b78, 0x709db87b, 0x63cd4b8f, 0x91a6c88c,
+ 0x456cac67, 0xb7072f64, 0xa457dc90, 0x563c5f93,
+ 0x082f63b7, 0xfa44e0b4, 0xe9141340, 0x1b7f9043,
+ 0xcfb5f4a8, 0x3dde77ab, 0x2e8e845f, 0xdce5075c,
+ 0x92a8fc17, 0x60c37f14, 0x73938ce0, 0x81f80fe3,
+ 0x55326b08, 0xa759e80b, 0xb4091bff, 0x466298fc,
+ 0x1871a4d8, 0xea1a27db, 0xf94ad42f, 0x0b21572c,
+ 0xdfeb33c7, 0x2d80b0c4, 0x3ed04330, 0xccbbc033,
+ 0xa24bb5a6, 0x502036a5, 0x4370c551, 0xb11b4652,
+ 0x65d122b9, 0x97baa1ba, 0x84ea524e, 0x7681d14d,
+ 0x2892ed69, 0xdaf96e6a, 0xc9a99d9e, 0x3bc21e9d,
+ 0xef087a76, 0x1d63f975, 0x0e330a81, 0xfc588982,
+ 0xb21572c9, 0x407ef1ca, 0x532e023e, 0xa145813d,
+ 0x758fe5d6, 0x87e466d5, 0x94b49521, 0x66df1622,
+ 0x38cc2a06, 0xcaa7a905, 0xd9f75af1, 0x2b9cd9f2,
+ 0xff56bd19, 0x0d3d3e1a, 0x1e6dcdee, 0xec064eed,
+ 0xc38d26c4, 0x31e6a5c7, 0x22b65633, 0xd0ddd530,
+ 0x0417b1db, 0xf67c32d8, 0xe52cc12c, 0x1747422f,
+ 0x49547e0b, 0xbb3ffd08, 0xa86f0efc, 0x5a048dff,
+ 0x8ecee914, 0x7ca56a17, 0x6ff599e3, 0x9d9e1ae0,
+ 0xd3d3e1ab, 0x21b862a8, 0x32e8915c, 0xc083125f,
+ 0x144976b4, 0xe622f5b7, 0xf5720643, 0x07198540,
+ 0x590ab964, 0xab613a67, 0xb831c993, 0x4a5a4a90,
+ 0x9e902e7b, 0x6cfbad78, 0x7fab5e8c, 0x8dc0dd8f,
+ 0xe330a81a, 0x115b2b19, 0x020bd8ed, 0xf0605bee,
+ 0x24aa3f05, 0xd6c1bc06, 0xc5914ff2, 0x37faccf1,
+ 0x69e9f0d5, 0x9b8273d6, 0x88d28022, 0x7ab90321,
+ 0xae7367ca, 0x5c18e4c9, 0x4f48173d, 0xbd23943e,
+ 0xf36e6f75, 0x0105ec76, 0x12551f82, 0xe03e9c81,
+ 0x34f4f86a, 0xc69f7b69, 0xd5cf889d, 0x27a40b9e,
+ 0x79b737ba, 0x8bdcb4b9, 0x988c474d, 0x6ae7c44e,
0xbe2da0a5, 0x4c4623a6, 0x5f16d052, 0xad7d5351
};
- static final int[][] STRIDE_TABLE = {
- {
- 0x00000000, 0x30d23865, 0x61a470ca, 0x517648af, 0xc348e194, 0xf39ad9f1,
- 0xa2ec915e, 0x923ea93b, 0x837db5d9, 0xb3af8dbc, 0xe2d9c513, 0xd20bfd76,
- 0x4035544d, 0x70e76c28, 0x21912487, 0x11431ce2, 0x03171d43, 0x33c52526,
- 0x62b36d89, 0x526155ec, 0xc05ffcd7, 0xf08dc4b2, 0xa1fb8c1d, 0x9129b478,
- 0x806aa89a, 0xb0b890ff, 0xe1ced850, 0xd11ce035, 0x4322490e, 0x73f0716b,
- 0x228639c4, 0x125401a1, 0x062e3a86, 0x36fc02e3, 0x678a4a4c, 0x57587229,
- 0xc566db12, 0xf5b4e377, 0xa4c2abd8, 0x941093bd, 0x85538f5f, 0xb581b73a,
- 0xe4f7ff95, 0xd425c7f0, 0x461b6ecb, 0x76c956ae, 0x27bf1e01, 0x176d2664,
- 0x053927c5, 0x35eb1fa0, 0x649d570f, 0x544f6f6a, 0xc671c651, 0xf6a3fe34,
- 0xa7d5b69b, 0x97078efe, 0x8644921c, 0xb696aa79, 0xe7e0e2d6, 0xd732dab3,
- 0x450c7388, 0x75de4bed, 0x24a80342, 0x147a3b27, 0x0c5c750c, 0x3c8e4d69,
- 0x6df805c6, 0x5d2a3da3, 0xcf149498, 0xffc6acfd, 0xaeb0e452, 0x9e62dc37,
- 0x8f21c0d5, 0xbff3f8b0, 0xee85b01f, 0xde57887a, 0x4c692141, 0x7cbb1924,
- 0x2dcd518b, 0x1d1f69ee, 0x0f4b684f, 0x3f99502a, 0x6eef1885, 0x5e3d20e0,
- 0xcc0389db, 0xfcd1b1be, 0xada7f911, 0x9d75c174, 0x8c36dd96, 0xbce4e5f3,
- 0xed92ad5c, 0xdd409539, 0x4f7e3c02, 0x7fac0467, 0x2eda4cc8, 0x1e0874ad,
- 0x0a724f8a, 0x3aa077ef, 0x6bd63f40, 0x5b040725, 0xc93aae1e, 0xf9e8967b,
- 0xa89eded4, 0x984ce6b1, 0x890ffa53, 0xb9ddc236, 0xe8ab8a99, 0xd879b2fc,
- 0x4a471bc7, 0x7a9523a2, 0x2be36b0d, 0x1b315368, 0x096552c9, 0x39b76aac,
- 0x68c12203, 0x58131a66, 0xca2db35d, 0xfaff8b38, 0xab89c397, 0x9b5bfbf2,
- 0x8a18e710, 0xbacadf75, 0xebbc97da, 0xdb6eafbf, 0x49500684, 0x79823ee1,
- 0x28f4764e, 0x18264e2b, 0x18b8ea18, 0x286ad27d, 0x791c9ad2, 0x49cea2b7,
- 0xdbf00b8c, 0xeb2233e9, 0xba547b46, 0x8a864323, 0x9bc55fc1, 0xab1767a4,
- 0xfa612f0b, 0xcab3176e, 0x588dbe55, 0x685f8630, 0x3929ce9f, 0x09fbf6fa,
- 0x1baff75b, 0x2b7dcf3e, 0x7a0b8791, 0x4ad9bff4, 0xd8e716cf, 0xe8352eaa,
- 0xb9436605, 0x89915e60, 0x98d24282, 0xa8007ae7, 0xf9763248, 0xc9a40a2d,
- 0x5b9aa316, 0x6b489b73, 0x3a3ed3dc, 0x0aecebb9, 0x1e96d09e, 0x2e44e8fb,
- 0x7f32a054, 0x4fe09831, 0xddde310a, 0xed0c096f, 0xbc7a41c0, 0x8ca879a5,
- 0x9deb6547, 0xad395d22, 0xfc4f158d, 0xcc9d2de8, 0x5ea384d3, 0x6e71bcb6,
- 0x3f07f419, 0x0fd5cc7c, 0x1d81cddd, 0x2d53f5b8, 0x7c25bd17, 0x4cf78572,
- 0xdec92c49, 0xee1b142c, 0xbf6d5c83, 0x8fbf64e6, 0x9efc7804, 0xae2e4061,
- 0xff5808ce, 0xcf8a30ab, 0x5db49990, 0x6d66a1f5, 0x3c10e95a, 0x0cc2d13f,
- 0x14e49f14, 0x2436a771, 0x7540efde, 0x4592d7bb, 0xd7ac7e80, 0xe77e46e5,
- 0xb6080e4a, 0x86da362f, 0x97992acd, 0xa74b12a8, 0xf63d5a07, 0xc6ef6262,
- 0x54d1cb59, 0x6403f33c, 0x3575bb93, 0x05a783f6, 0x17f38257, 0x2721ba32,
- 0x7657f29d, 0x4685caf8, 0xd4bb63c3, 0xe4695ba6, 0xb51f1309, 0x85cd2b6c,
- 0x948e378e, 0xa45c0feb, 0xf52a4744, 0xc5f87f21, 0x57c6d61a, 0x6714ee7f,
- 0x3662a6d0, 0x06b09eb5, 0x12caa592, 0x22189df7, 0x736ed558, 0x43bced3d,
- 0xd1824406, 0xe1507c63, 0xb02634cc, 0x80f40ca9, 0x91b7104b, 0xa165282e,
- 0xf0136081, 0xc0c158e4, 0x52fff1df, 0x622dc9ba, 0x335b8115, 0x0389b970,
- 0x11ddb8d1, 0x210f80b4, 0x7079c81b, 0x40abf07e, 0xd2955945, 0xe2476120,
- 0xb331298f, 0x83e311ea, 0x92a00d08, 0xa272356d, 0xf3047dc2, 0xc3d645a7,
- 0x51e8ec9c, 0x613ad4f9, 0x304c9c56, 0x009ea433,
- },
- {
- 0x00000000, 0x54075546, 0xa80eaa8c, 0xfc09ffca, 0x55f123e9, 0x01f676af,
- 0xfdff8965, 0xa9f8dc23, 0xabe247d2, 0xffe51294, 0x03eced5e, 0x57ebb818,
- 0xfe13643b, 0xaa14317d, 0x561dceb7, 0x021a9bf1, 0x5228f955, 0x062fac13,
- 0xfa2653d9, 0xae21069f, 0x07d9dabc, 0x53de8ffa, 0xafd77030, 0xfbd02576,
- 0xf9cabe87, 0xadcdebc1, 0x51c4140b, 0x05c3414d, 0xac3b9d6e, 0xf83cc828,
- 0x043537e2, 0x503262a4, 0xa451f2aa, 0xf056a7ec, 0x0c5f5826, 0x58580d60,
- 0xf1a0d143, 0xa5a78405, 0x59ae7bcf, 0x0da92e89, 0x0fb3b578, 0x5bb4e03e,
- 0xa7bd1ff4, 0xf3ba4ab2, 0x5a429691, 0x0e45c3d7, 0xf24c3c1d, 0xa64b695b,
- 0xf6790bff, 0xa27e5eb9, 0x5e77a173, 0x0a70f435, 0xa3882816, 0xf78f7d50,
- 0x0b86829a, 0x5f81d7dc, 0x5d9b4c2d, 0x099c196b, 0xf595e6a1, 0xa192b3e7,
- 0x086a6fc4, 0x5c6d3a82, 0xa064c548, 0xf463900e, 0x4d4f93a5, 0x1948c6e3,
- 0xe5413929, 0xb1466c6f, 0x18beb04c, 0x4cb9e50a, 0xb0b01ac0, 0xe4b74f86,
- 0xe6add477, 0xb2aa8131, 0x4ea37efb, 0x1aa42bbd, 0xb35cf79e, 0xe75ba2d8,
- 0x1b525d12, 0x4f550854, 0x1f676af0, 0x4b603fb6, 0xb769c07c, 0xe36e953a,
- 0x4a964919, 0x1e911c5f, 0xe298e395, 0xb69fb6d3, 0xb4852d22, 0xe0827864,
- 0x1c8b87ae, 0x488cd2e8, 0xe1740ecb, 0xb5735b8d, 0x497aa447, 0x1d7df101,
- 0xe91e610f, 0xbd193449, 0x4110cb83, 0x15179ec5, 0xbcef42e6, 0xe8e817a0,
- 0x14e1e86a, 0x40e6bd2c, 0x42fc26dd, 0x16fb739b, 0xeaf28c51, 0xbef5d917,
- 0x170d0534, 0x430a5072, 0xbf03afb8, 0xeb04fafe, 0xbb36985a, 0xef31cd1c,
- 0x133832d6, 0x473f6790, 0xeec7bbb3, 0xbac0eef5, 0x46c9113f, 0x12ce4479,
- 0x10d4df88, 0x44d38ace, 0xb8da7504, 0xecdd2042, 0x4525fc61, 0x1122a927,
- 0xed2b56ed, 0xb92c03ab, 0x9a9f274a, 0xce98720c, 0x32918dc6, 0x6696d880,
- 0xcf6e04a3, 0x9b6951e5, 0x6760ae2f, 0x3367fb69, 0x317d6098, 0x657a35de,
- 0x9973ca14, 0xcd749f52, 0x648c4371, 0x308b1637, 0xcc82e9fd, 0x9885bcbb,
- 0xc8b7de1f, 0x9cb08b59, 0x60b97493, 0x34be21d5, 0x9d46fdf6, 0xc941a8b0,
- 0x3548577a, 0x614f023c, 0x635599cd, 0x3752cc8b, 0xcb5b3341, 0x9f5c6607,
- 0x36a4ba24, 0x62a3ef62, 0x9eaa10a8, 0xcaad45ee, 0x3eced5e0, 0x6ac980a6,
- 0x96c07f6c, 0xc2c72a2a, 0x6b3ff609, 0x3f38a34f, 0xc3315c85, 0x973609c3,
- 0x952c9232, 0xc12bc774, 0x3d2238be, 0x69256df8, 0xc0ddb1db, 0x94dae49d,
- 0x68d31b57, 0x3cd44e11, 0x6ce62cb5, 0x38e179f3, 0xc4e88639, 0x90efd37f,
- 0x39170f5c, 0x6d105a1a, 0x9119a5d0, 0xc51ef096, 0xc7046b67, 0x93033e21,
- 0x6f0ac1eb, 0x3b0d94ad, 0x92f5488e, 0xc6f21dc8, 0x3afbe202, 0x6efcb744,
- 0xd7d0b4ef, 0x83d7e1a9, 0x7fde1e63, 0x2bd94b25, 0x82219706, 0xd626c240,
- 0x2a2f3d8a, 0x7e2868cc, 0x7c32f33d, 0x2835a67b, 0xd43c59b1, 0x803b0cf7,
- 0x29c3d0d4, 0x7dc48592, 0x81cd7a58, 0xd5ca2f1e, 0x85f84dba, 0xd1ff18fc,
- 0x2df6e736, 0x79f1b270, 0xd0096e53, 0x840e3b15, 0x7807c4df, 0x2c009199,
- 0x2e1a0a68, 0x7a1d5f2e, 0x8614a0e4, 0xd213f5a2, 0x7beb2981, 0x2fec7cc7,
- 0xd3e5830d, 0x87e2d64b, 0x73814645, 0x27861303, 0xdb8fecc9, 0x8f88b98f,
- 0x267065ac, 0x727730ea, 0x8e7ecf20, 0xda799a66, 0xd8630197, 0x8c6454d1,
- 0x706dab1b, 0x246afe5d, 0x8d92227e, 0xd9957738, 0x259c88f2, 0x719bddb4,
- 0x21a9bf10, 0x75aeea56, 0x89a7159c, 0xdda040da, 0x74589cf9, 0x205fc9bf,
- 0xdc563675, 0x88516333, 0x8a4bf8c2, 0xde4cad84, 0x2245524e, 0x76420708,
- 0xdfbadb2b, 0x8bbd8e6d, 0x77b471a7, 0x23b324e1,
- },
- {
- 0x00000000, 0x678efd01, 0xcf1dfa02, 0xa8930703, 0x9bd782f5, 0xfc597ff4,
- 0x54ca78f7, 0x334485f6, 0x3243731b, 0x55cd8e1a, 0xfd5e8919, 0x9ad07418,
- 0xa994f1ee, 0xce1a0cef, 0x66890bec, 0x0107f6ed, 0x6486e636, 0x03081b37,
- 0xab9b1c34, 0xcc15e135, 0xff5164c3, 0x98df99c2, 0x304c9ec1, 0x57c263c0,
- 0x56c5952d, 0x314b682c, 0x99d86f2f, 0xfe56922e, 0xcd1217d8, 0xaa9cead9,
- 0x020fedda, 0x658110db, 0xc90dcc6c, 0xae83316d, 0x0610366e, 0x619ecb6f,
- 0x52da4e99, 0x3554b398, 0x9dc7b49b, 0xfa49499a, 0xfb4ebf77, 0x9cc04276,
- 0x34534575, 0x53ddb874, 0x60993d82, 0x0717c083, 0xaf84c780, 0xc80a3a81,
- 0xad8b2a5a, 0xca05d75b, 0x6296d058, 0x05182d59, 0x365ca8af, 0x51d255ae,
- 0xf94152ad, 0x9ecfafac, 0x9fc85941, 0xf846a440, 0x50d5a343, 0x375b5e42,
- 0x041fdbb4, 0x639126b5, 0xcb0221b6, 0xac8cdcb7, 0x97f7ee29, 0xf0791328,
- 0x58ea142b, 0x3f64e92a, 0x0c206cdc, 0x6bae91dd, 0xc33d96de, 0xa4b36bdf,
- 0xa5b49d32, 0xc23a6033, 0x6aa96730, 0x0d279a31, 0x3e631fc7, 0x59ede2c6,
- 0xf17ee5c5, 0x96f018c4, 0xf371081f, 0x94fff51e, 0x3c6cf21d, 0x5be20f1c,
- 0x68a68aea, 0x0f2877eb, 0xa7bb70e8, 0xc0358de9, 0xc1327b04, 0xa6bc8605,
- 0x0e2f8106, 0x69a17c07, 0x5ae5f9f1, 0x3d6b04f0, 0x95f803f3, 0xf276fef2,
- 0x5efa2245, 0x3974df44, 0x91e7d847, 0xf6692546, 0xc52da0b0, 0xa2a35db1,
- 0x0a305ab2, 0x6dbea7b3, 0x6cb9515e, 0x0b37ac5f, 0xa3a4ab5c, 0xc42a565d,
- 0xf76ed3ab, 0x90e02eaa, 0x387329a9, 0x5ffdd4a8, 0x3a7cc473, 0x5df23972,
- 0xf5613e71, 0x92efc370, 0xa1ab4686, 0xc625bb87, 0x6eb6bc84, 0x09384185,
- 0x083fb768, 0x6fb14a69, 0xc7224d6a, 0xa0acb06b, 0x93e8359d, 0xf466c89c,
- 0x5cf5cf9f, 0x3b7b329e, 0x2a03aaa3, 0x4d8d57a2, 0xe51e50a1, 0x8290ada0,
- 0xb1d42856, 0xd65ad557, 0x7ec9d254, 0x19472f55, 0x1840d9b8, 0x7fce24b9,
- 0xd75d23ba, 0xb0d3debb, 0x83975b4d, 0xe419a64c, 0x4c8aa14f, 0x2b045c4e,
- 0x4e854c95, 0x290bb194, 0x8198b697, 0xe6164b96, 0xd552ce60, 0xb2dc3361,
- 0x1a4f3462, 0x7dc1c963, 0x7cc63f8e, 0x1b48c28f, 0xb3dbc58c, 0xd455388d,
- 0xe711bd7b, 0x809f407a, 0x280c4779, 0x4f82ba78, 0xe30e66cf, 0x84809bce,
- 0x2c139ccd, 0x4b9d61cc, 0x78d9e43a, 0x1f57193b, 0xb7c41e38, 0xd04ae339,
- 0xd14d15d4, 0xb6c3e8d5, 0x1e50efd6, 0x79de12d7, 0x4a9a9721, 0x2d146a20,
- 0x85876d23, 0xe2099022, 0x878880f9, 0xe0067df8, 0x48957afb, 0x2f1b87fa,
- 0x1c5f020c, 0x7bd1ff0d, 0xd342f80e, 0xb4cc050f, 0xb5cbf3e2, 0xd2450ee3,
- 0x7ad609e0, 0x1d58f4e1, 0x2e1c7117, 0x49928c16, 0xe1018b15, 0x868f7614,
- 0xbdf4448a, 0xda7ab98b, 0x72e9be88, 0x15674389, 0x2623c67f, 0x41ad3b7e,
- 0xe93e3c7d, 0x8eb0c17c, 0x8fb73791, 0xe839ca90, 0x40aacd93, 0x27243092,
- 0x1460b564, 0x73ee4865, 0xdb7d4f66, 0xbcf3b267, 0xd972a2bc, 0xbefc5fbd,
- 0x166f58be, 0x71e1a5bf, 0x42a52049, 0x252bdd48, 0x8db8da4b, 0xea36274a,
- 0xeb31d1a7, 0x8cbf2ca6, 0x242c2ba5, 0x43a2d6a4, 0x70e65352, 0x1768ae53,
- 0xbffba950, 0xd8755451, 0x74f988e6, 0x137775e7, 0xbbe472e4, 0xdc6a8fe5,
- 0xef2e0a13, 0x88a0f712, 0x2033f011, 0x47bd0d10, 0x46bafbfd, 0x213406fc,
- 0x89a701ff, 0xee29fcfe, 0xdd6d7908, 0xbae38409, 0x1270830a, 0x75fe7e0b,
- 0x107f6ed0, 0x77f193d1, 0xdf6294d2, 0xb8ec69d3, 0x8ba8ec25, 0xec261124,
- 0x44b51627, 0x233beb26, 0x223c1dcb, 0x45b2e0ca, 0xed21e7c9, 0x8aaf1ac8,
- 0xb9eb9f3e, 0xde65623f, 0x76f6653c, 0x1178983d,
- },
- {
- 0x00000000, 0xf20c0dfe, 0xe1f46d0d, 0x13f860f3, 0xc604aceb, 0x3408a115,
- 0x27f0c1e6, 0xd5fccc18, 0x89e52f27, 0x7be922d9, 0x6811422a, 0x9a1d4fd4,
- 0x4fe183cc, 0xbded8e32, 0xae15eec1, 0x5c19e33f, 0x162628bf, 0xe42a2541,
- 0xf7d245b2, 0x05de484c, 0xd0228454, 0x222e89aa, 0x31d6e959, 0xc3dae4a7,
- 0x9fc30798, 0x6dcf0a66, 0x7e376a95, 0x8c3b676b, 0x59c7ab73, 0xabcba68d,
- 0xb833c67e, 0x4a3fcb80, 0x2c4c517e, 0xde405c80, 0xcdb83c73, 0x3fb4318d,
- 0xea48fd95, 0x1844f06b, 0x0bbc9098, 0xf9b09d66, 0xa5a97e59, 0x57a573a7,
- 0x445d1354, 0xb6511eaa, 0x63add2b2, 0x91a1df4c, 0x8259bfbf, 0x7055b241,
- 0x3a6a79c1, 0xc866743f, 0xdb9e14cc, 0x29921932, 0xfc6ed52a, 0x0e62d8d4,
- 0x1d9ab827, 0xef96b5d9, 0xb38f56e6, 0x41835b18, 0x527b3beb, 0xa0773615,
- 0x758bfa0d, 0x8787f7f3, 0x947f9700, 0x66739afe, 0x5898a2fc, 0xaa94af02,
- 0xb96ccff1, 0x4b60c20f, 0x9e9c0e17, 0x6c9003e9, 0x7f68631a, 0x8d646ee4,
- 0xd17d8ddb, 0x23718025, 0x3089e0d6, 0xc285ed28, 0x17792130, 0xe5752cce,
- 0xf68d4c3d, 0x048141c3, 0x4ebe8a43, 0xbcb287bd, 0xaf4ae74e, 0x5d46eab0,
- 0x88ba26a8, 0x7ab62b56, 0x694e4ba5, 0x9b42465b, 0xc75ba564, 0x3557a89a,
- 0x26afc869, 0xd4a3c597, 0x015f098f, 0xf3530471, 0xe0ab6482, 0x12a7697c,
- 0x74d4f382, 0x86d8fe7c, 0x95209e8f, 0x672c9371, 0xb2d05f69, 0x40dc5297,
- 0x53243264, 0xa1283f9a, 0xfd31dca5, 0x0f3dd15b, 0x1cc5b1a8, 0xeec9bc56,
- 0x3b35704e, 0xc9397db0, 0xdac11d43, 0x28cd10bd, 0x62f2db3d, 0x90fed6c3,
- 0x8306b630, 0x710abbce, 0xa4f677d6, 0x56fa7a28, 0x45021adb, 0xb70e1725,
- 0xeb17f41a, 0x191bf9e4, 0x0ae39917, 0xf8ef94e9, 0x2d1358f1, 0xdf1f550f,
- 0xcce735fc, 0x3eeb3802, 0xb13145f8, 0x433d4806, 0x50c528f5, 0xa2c9250b,
- 0x7735e913, 0x8539e4ed, 0x96c1841e, 0x64cd89e0, 0x38d46adf, 0xcad86721,
- 0xd92007d2, 0x2b2c0a2c, 0xfed0c634, 0x0cdccbca, 0x1f24ab39, 0xed28a6c7,
- 0xa7176d47, 0x551b60b9, 0x46e3004a, 0xb4ef0db4, 0x6113c1ac, 0x931fcc52,
- 0x80e7aca1, 0x72eba15f, 0x2ef24260, 0xdcfe4f9e, 0xcf062f6d, 0x3d0a2293,
- 0xe8f6ee8b, 0x1afae375, 0x09028386, 0xfb0e8e78, 0x9d7d1486, 0x6f711978,
- 0x7c89798b, 0x8e857475, 0x5b79b86d, 0xa975b593, 0xba8dd560, 0x4881d89e,
- 0x14983ba1, 0xe694365f, 0xf56c56ac, 0x07605b52, 0xd29c974a, 0x20909ab4,
- 0x3368fa47, 0xc164f7b9, 0x8b5b3c39, 0x795731c7, 0x6aaf5134, 0x98a35cca,
- 0x4d5f90d2, 0xbf539d2c, 0xacabfddf, 0x5ea7f021, 0x02be131e, 0xf0b21ee0,
- 0xe34a7e13, 0x114673ed, 0xc4babff5, 0x36b6b20b, 0x254ed2f8, 0xd742df06,
- 0xe9a9e704, 0x1ba5eafa, 0x085d8a09, 0xfa5187f7, 0x2fad4bef, 0xdda14611,
- 0xce5926e2, 0x3c552b1c, 0x604cc823, 0x9240c5dd, 0x81b8a52e, 0x73b4a8d0,
- 0xa64864c8, 0x54446936, 0x47bc09c5, 0xb5b0043b, 0xff8fcfbb, 0x0d83c245,
- 0x1e7ba2b6, 0xec77af48, 0x398b6350, 0xcb876eae, 0xd87f0e5d, 0x2a7303a3,
- 0x766ae09c, 0x8466ed62, 0x979e8d91, 0x6592806f, 0xb06e4c77, 0x42624189,
- 0x519a217a, 0xa3962c84, 0xc5e5b67a, 0x37e9bb84, 0x2411db77, 0xd61dd689,
- 0x03e11a91, 0xf1ed176f, 0xe215779c, 0x10197a62, 0x4c00995d, 0xbe0c94a3,
- 0xadf4f450, 0x5ff8f9ae, 0x8a0435b6, 0x78083848, 0x6bf058bb, 0x99fc5545,
- 0xd3c39ec5, 0x21cf933b, 0x3237f3c8, 0xc03bfe36, 0x15c7322e, 0xe7cb3fd0,
- 0xf4335f23, 0x063f52dd, 0x5a26b1e2, 0xa82abc1c, 0xbbd2dcef, 0x49ded111,
- 0x9c221d09, 0x6e2e10f7, 0x7dd67004, 0x8fda7dfa,
- },
- };
+ private int crc = 0;
- // Value x picked so computeForWord(x) == ~0, found by exhaustive search.
- static final int INVERSE_COMPUTE_FOR_WORD_OF_ALL_1S = 0xeee3ddcd;
-
- static int computeForWord(int word) {
- return STRIDE_TABLE[3][word & 0xFF]
- ^ STRIDE_TABLE[2][(word >>> 8) & 0xFF]
- ^ STRIDE_TABLE[1][(word >>> 16) & 0xFF]
- ^ STRIDE_TABLE[0][word >>> 24];
+ @Override
+ public void update(byte b) {
+ crc ^= 0xFFFFFFFF;
+ // See Hacker's Delight 2nd Edition, Figure 14-7.
+ crc = ~((crc >>> 8) ^ CRC_TABLE[(crc ^ b) & 0xFF]);
}
- static int combine(int csum, int crc) {
- csum ^= crc;
- for (int i = 0; i < 4; i++) {
- csum = (csum >>> 8) ^ BYTE_TABLE[csum & 0xFF];
- }
- return csum;
+ @Override
+ public HashCode hash() {
+ return HashCode.fromInt(crc);
}
-
- private static final ByteBuffer EMPTY = ByteBuffer.allocate(0);
}
}
diff --git a/guava/src/com/google/common/hash/ElementTypesAreNonnullByDefault.java b/guava/src/com/google/common/hash/ElementTypesAreNonnullByDefault.java
deleted file mode 100644
index a2382b3..0000000
--- a/guava/src/com/google/common/hash/ElementTypesAreNonnullByDefault.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) 2021 The Guava Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.common.hash;
-
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.PARAMETER;
-import static java.lang.annotation.ElementType.TYPE;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-import com.google.common.annotations.GwtCompatible;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-import javax.annotation.Nonnull;
-import javax.annotation.meta.TypeQualifierDefault;
-
-/**
- * Marks all "top-level" types as non-null in a way that is recognized by Kotlin. Note that this
- * unfortunately includes type-variable usages, so we also provide {@link ParametricNullness} to
- * "undo" it as best we can.
- */
-@GwtCompatible
-@Retention(RUNTIME)
-@Target(TYPE)
-@TypeQualifierDefault({FIELD, METHOD, PARAMETER})
-@Nonnull
-@interface ElementTypesAreNonnullByDefault {}
diff --git a/guava/src/com/google/common/hash/FarmHashFingerprint64.java b/guava/src/com/google/common/hash/FarmHashFingerprint64.java
index 7d6a398..30eab5f 100644
--- a/guava/src/com/google/common/hash/FarmHashFingerprint64.java
+++ b/guava/src/com/google/common/hash/FarmHashFingerprint64.java
@@ -38,7 +38,6 @@
* @author Kyle Maddison
* @author Geoff Pike
*/
-@ElementTypesAreNonnullByDefault
final class FarmHashFingerprint64 extends AbstractNonStreamingHashFunction {
static final HashFunction FARMHASH_FINGERPRINT_64 = new FarmHashFingerprint64();
diff --git a/guava/src/com/google/common/hash/Funnel.java b/guava/src/com/google/common/hash/Funnel.java
index 9d80dab..2c6a7b9 100644
--- a/guava/src/com/google/common/hash/Funnel.java
+++ b/guava/src/com/google/common/hash/Funnel.java
@@ -17,7 +17,6 @@
import com.google.common.annotations.Beta;
import com.google.errorprone.annotations.DoNotMock;
import java.io.Serializable;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* An object which can send data from an object of type {@code T} into a {@code PrimitiveSink}.
@@ -44,8 +43,7 @@
*/
@Beta
@DoNotMock("Implement with a lambda")
-@ElementTypesAreNonnullByDefault
-public interface Funnel<T extends @Nullable Object> extends Serializable {
+public interface Funnel<T> extends Serializable {
/**
* Sends a stream of data from the {@code from} object into the sink {@code into}. There is no
@@ -53,5 +51,5 @@
*
* @since 12.0 (in Guava 11.0, {@code PrimitiveSink} was named {@code Sink})
*/
- void funnel(@ParametricNullness T from, PrimitiveSink into);
+ void funnel(T from, PrimitiveSink into);
}
diff --git a/guava/src/com/google/common/hash/Funnels.java b/guava/src/com/google/common/hash/Funnels.java
index 6673836..6051bfd 100644
--- a/guava/src/com/google/common/hash/Funnels.java
+++ b/guava/src/com/google/common/hash/Funnels.java
@@ -19,7 +19,6 @@
import java.io.OutputStream;
import java.io.Serializable;
import java.nio.charset.Charset;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -29,7 +28,6 @@
* @since 11.0
*/
@Beta
-@ElementTypesAreNonnullByDefault
public final class Funnels {
private Funnels() {}
@@ -105,7 +103,7 @@
}
@Override
- public boolean equals(@CheckForNull Object o) {
+ public boolean equals(@Nullable Object o) {
if (o instanceof StringCharsetFunnel) {
StringCharsetFunnel funnel = (StringCharsetFunnel) o;
return this.charset.equals(funnel.charset);
@@ -166,13 +164,11 @@
*
* @since 15.0
*/
- public static <E extends @Nullable Object> Funnel<Iterable<? extends E>> sequentialFunnel(
- Funnel<E> elementFunnel) {
+ public static <E> Funnel<Iterable<? extends E>> sequentialFunnel(Funnel<E> elementFunnel) {
return new SequentialFunnel<E>(elementFunnel);
}
- private static class SequentialFunnel<E extends @Nullable Object>
- implements Funnel<Iterable<? extends E>>, Serializable {
+ private static class SequentialFunnel<E> implements Funnel<Iterable<? extends E>>, Serializable {
private final Funnel<E> elementFunnel;
SequentialFunnel(Funnel<E> elementFunnel) {
@@ -192,7 +188,7 @@
}
@Override
- public boolean equals(@CheckForNull 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 fde2a86..b6a5ff8 100644
--- a/guava/src/com/google/common/hash/HashCode.java
+++ b/guava/src/com/google/common/hash/HashCode.java
@@ -18,12 +18,13 @@
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkState;
+import com.google.common.annotations.Beta;
import com.google.common.base.Preconditions;
import com.google.common.primitives.Ints;
import com.google.common.primitives.UnsignedInts;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import java.io.Serializable;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* An immutable hash code of arbitrary bit length.
@@ -32,7 +33,7 @@
* @author Kurt Alfred Kluever
* @since 11.0
*/
-@ElementTypesAreNonnullByDefault
+@Beta
public abstract class HashCode {
HashCode() {}
@@ -368,7 +369,7 @@
* to protect against <a href="http://en.wikipedia.org/wiki/Timing_attack">timing attacks</a>.
*/
@Override
- public final boolean equals(@CheckForNull Object object) {
+ public final boolean equals(@Nullable Object object) {
if (object instanceof HashCode) {
HashCode that = (HashCode) object;
return bits() == that.bits() && equalsSameBits(that);
@@ -401,10 +402,10 @@
* Returns a string containing each byte of {@link #asBytes}, in order, as a two-digit unsigned
* hexadecimal number in lower case.
*
- * <p>Note that if the output is considered to be a single hexadecimal number, whether this string
- * is big-endian or little-endian depends on the byte order of {@link #asBytes}. This may be
- * surprising for implementations of {@code HashCode} that represent the number in big-endian
- * since everything else in the hashing API uniformly treats multibyte values as little-endian.
+ * <p>Note that if the output is considered to be a single hexadecimal number, this hash code's
+ * bytes are the <i>big-endian</i> representation of that number. This may be surprising since
+ * everything else in the hashing API uniformly treats multibyte values as little-endian. But this
+ * format conveniently matches that of utilities such as the UNIX {@code md5sum} command.
*
* <p>To create a {@code HashCode} from its string representation, see {@link #fromString}.
*/
diff --git a/guava/src/com/google/common/hash/HashFunction.java b/guava/src/com/google/common/hash/HashFunction.java
index d4b7f8a..7884259 100644
--- a/guava/src/com/google/common/hash/HashFunction.java
+++ b/guava/src/com/google/common/hash/HashFunction.java
@@ -14,11 +14,11 @@
package com.google.common.hash;
+import com.google.common.annotations.Beta;
import com.google.common.primitives.Ints;
import com.google.errorprone.annotations.Immutable;
import java.nio.ByteBuffer;
import java.nio.charset.Charset;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* A hash function is a collision-averse pure function that maps an arbitrary block of data to a
@@ -115,8 +115,8 @@
* @author Kevin Bourrillion
* @since 11.0
*/
+@Beta
@Immutable
-@ElementTypesAreNonnullByDefault
public interface HashFunction {
/**
* Begins a new hash code computation by returning an initialized, stateful {@code Hasher}
@@ -211,8 +211,7 @@
*
* @since 14.0
*/
- <T extends @Nullable Object> HashCode hashObject(
- @ParametricNullness T instance, Funnel<? super T> funnel);
+ <T> HashCode hashObject(T instance, Funnel<? super T> funnel);
/**
* Returns the number of bits (a multiple of 32) that each hash code produced by this hash
diff --git a/guava/src/com/google/common/hash/Hasher.java b/guava/src/com/google/common/hash/Hasher.java
index b3f24fa..ae9ae5f 100644
--- a/guava/src/com/google/common/hash/Hasher.java
+++ b/guava/src/com/google/common/hash/Hasher.java
@@ -18,7 +18,6 @@
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import java.nio.ByteBuffer;
import java.nio.charset.Charset;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* A {@link PrimitiveSink} that can compute a hash code after reading the input. Each hasher should
@@ -55,7 +54,6 @@
*/
@Beta
@CanIgnoreReturnValue
-@ElementTypesAreNonnullByDefault
public interface Hasher extends PrimitiveSink {
@Override
Hasher putByte(byte b);
@@ -121,8 +119,7 @@
Hasher putString(CharSequence charSequence, Charset charset);
/** A simple convenience for {@code funnel.funnel(object, this)}. */
- <T extends @Nullable Object> Hasher putObject(
- @ParametricNullness T instance, Funnel<? super T> funnel);
+ <T> Hasher putObject(T instance, Funnel<? super T> funnel);
/**
* Computes a hash code based on the data that have been provided to this hasher. The result is
diff --git a/guava/src/com/google/common/hash/Hashing.java b/guava/src/com/google/common/hash/Hashing.java
index dd65367..a5340a6 100644
--- a/guava/src/com/google/common/hash/Hashing.java
+++ b/guava/src/com/google/common/hash/Hashing.java
@@ -27,8 +27,8 @@
import java.util.zip.Adler32;
import java.util.zip.CRC32;
import java.util.zip.Checksum;
-import javax.annotation.CheckForNull;
import javax.crypto.spec.SecretKeySpec;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Static methods to obtain {@link HashFunction} instances, and other static hashing-related
@@ -43,7 +43,6 @@
* @since 11.0
*/
@Beta
-@ElementTypesAreNonnullByDefault
public final class Hashing {
/**
* Returns a general-purpose, <b>temporary-use</b>, non-cryptographic hash function. The algorithm
@@ -94,53 +93,12 @@
/**
* Returns a hash function implementing the <a
* href="https://github.com/aappleby/smhasher/blob/master/src/MurmurHash3.cpp">32-bit murmur3
- * algorithm, x86 variant</a> (little-endian variant), using the given seed value, <b>with a known
- * bug</b> as described in the deprecation text.
- *
- * <p>The C++ equivalent is the MurmurHash3_x86_32 function (Murmur3A), which however does not
- * have the bug.
- *
- * @deprecated This implementation produces incorrect hash values from the {@link
- * HashFunction#hashString} method if the string contains non-BMP characters. Use {@link
- * #murmur3_32_fixed(int)} instead.
- */
- @Deprecated
- public static HashFunction murmur3_32(int seed) {
- return new Murmur3_32HashFunction(seed, /* supplementaryPlaneFix= */ false);
- }
-
- /**
- * Returns a hash function implementing the <a
- * href="https://github.com/aappleby/smhasher/blob/master/src/MurmurHash3.cpp">32-bit murmur3
- * algorithm, x86 variant</a> (little-endian variant), using the given seed value, <b>with a known
- * bug</b> as described in the deprecation text.
- *
- * <p>The C++ equivalent is the MurmurHash3_x86_32 function (Murmur3A), which however does not
- * have the bug.
- *
- * @deprecated This implementation produces incorrect hash values from the {@link
- * HashFunction#hashString} method if the string contains non-BMP characters. Use {@link
- * #murmur3_32_fixed()} instead.
- */
- @Deprecated
- public static HashFunction murmur3_32() {
- return Murmur3_32HashFunction.MURMUR3_32;
- }
-
- /**
- * Returns a hash function implementing the <a
- * href="https://github.com/aappleby/smhasher/blob/master/src/MurmurHash3.cpp">32-bit murmur3
* algorithm, x86 variant</a> (little-endian variant), using the given seed value.
*
* <p>The exact C++ equivalent is the MurmurHash3_x86_32 function (Murmur3A).
- *
- * <p>This method is called {@code murmur3_32_fixed} because it fixes a bug in the {@code
- * HashFunction} returned by the original {@code murmur3_32} method.
- *
- * @since 31.0
*/
- public static HashFunction murmur3_32_fixed(int seed) {
- return new Murmur3_32HashFunction(seed, /* supplementaryPlaneFix= */ true);
+ public static HashFunction murmur3_32(int seed) {
+ return new Murmur3_32HashFunction(seed);
}
/**
@@ -149,14 +107,9 @@
* algorithm, x86 variant</a> (little-endian variant), using a seed value of zero.
*
* <p>The exact C++ equivalent is the MurmurHash3_x86_32 function (Murmur3A).
- *
- * <p>This method is called {@code murmur3_32_fixed} because it fixes a bug in the {@code
- * HashFunction} returned by the original {@code murmur3_32} method.
- *
- * @since 31.0
*/
- public static HashFunction murmur3_32_fixed() {
- return Murmur3_32HashFunction.MURMUR3_32_FIXED;
+ public static HashFunction murmur3_32() {
+ return Murmur3_32HashFunction.MURMUR3_32;
}
/**
@@ -281,6 +234,7 @@
* Returns a hash function implementing the Message Authentication Code (MAC) algorithm, using the
* MD5 (128 hash bits) hash function and the given secret key.
*
+ *
* @param key the secret key
* @throws IllegalArgumentException if the given key is inappropriate for initializing this MAC
* @since 20.0
@@ -294,6 +248,7 @@
* MD5 (128 hash bits) hash function and a {@link SecretKeySpec} created from the given byte array
* and the MD5 algorithm.
*
+ *
* @param key the key material of the secret key
* @since 20.0
*/
@@ -305,6 +260,7 @@
* Returns a hash function implementing the Message Authentication Code (MAC) algorithm, using the
* SHA-1 (160 hash bits) hash function and the given secret key.
*
+ *
* @param key the secret key
* @throws IllegalArgumentException if the given key is inappropriate for initializing this MAC
* @since 20.0
@@ -318,6 +274,7 @@
* SHA-1 (160 hash bits) hash function and a {@link SecretKeySpec} created from the given byte
* array and the SHA-1 algorithm.
*
+ *
* @param key the key material of the secret key
* @since 20.0
*/
@@ -329,6 +286,7 @@
* Returns a hash function implementing the Message Authentication Code (MAC) algorithm, using the
* SHA-256 (256 hash bits) hash function and the given secret key.
*
+ *
* @param key the secret key
* @throws IllegalArgumentException if the given key is inappropriate for initializing this MAC
* @since 20.0
@@ -342,6 +300,7 @@
* SHA-256 (256 hash bits) hash function and a {@link SecretKeySpec} created from the given byte
* array and the SHA-256 algorithm.
*
+ *
* @param key the key material of the secret key
* @since 20.0
*/
@@ -353,6 +312,7 @@
* Returns a hash function implementing the Message Authentication Code (MAC) algorithm, using the
* SHA-512 (512 hash bits) hash function and the given secret key.
*
+ *
* @param key the secret key
* @throws IllegalArgumentException if the given key is inappropriate for initializing this MAC
* @since 20.0
@@ -366,6 +326,7 @@
* SHA-512 (512 hash bits) hash function and a {@link SecretKeySpec} created from the given byte
* array and the SHA-512 algorithm.
*
+ *
* @param key the key material of the secret key
* @since 20.0
*/
@@ -496,6 +457,7 @@
* traffic to {@code charlie}, rather than letting {@code bravo} keep its traffic.
* </ul>
*
+ *
* <p>See the <a href="http://en.wikipedia.org/wiki/Consistent_hashing">Wikipedia article on
* consistent hashing</a> for more information.
*/
@@ -530,6 +492,7 @@
* traffic to {@code charlie}, rather than letting {@code bravo} keep its traffic.
* </ul>
*
+ *
* <p>See the <a href="http://en.wikipedia.org/wiki/Consistent_hashing">Wikipedia article on
* consistent hashing</a> for more information.
*/
@@ -680,7 +643,7 @@
}
@Override
- public boolean equals(@CheckForNull 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/HashingInputStream.java b/guava/src/com/google/common/hash/HashingInputStream.java
index bf9464c..f49dfd6 100644
--- a/guava/src/com/google/common/hash/HashingInputStream.java
+++ b/guava/src/com/google/common/hash/HashingInputStream.java
@@ -29,7 +29,6 @@
* @since 16.0
*/
@Beta
-@ElementTypesAreNonnullByDefault
public final class HashingInputStream extends FilterInputStream {
private final Hasher hasher;
diff --git a/guava/src/com/google/common/hash/HashingOutputStream.java b/guava/src/com/google/common/hash/HashingOutputStream.java
index f138bba..7a1c8d8 100644
--- a/guava/src/com/google/common/hash/HashingOutputStream.java
+++ b/guava/src/com/google/common/hash/HashingOutputStream.java
@@ -28,7 +28,6 @@
* @since 16.0
*/
@Beta
-@ElementTypesAreNonnullByDefault
public final class HashingOutputStream extends FilterOutputStream {
private final Hasher hasher;
diff --git a/guava/src/com/google/common/hash/ImmutableSupplier.java b/guava/src/com/google/common/hash/ImmutableSupplier.java
index 24f711a..f90352a 100644
--- a/guava/src/com/google/common/hash/ImmutableSupplier.java
+++ b/guava/src/com/google/common/hash/ImmutableSupplier.java
@@ -21,7 +21,5 @@
* Explicitly named subinterface of {@link Supplier} that can be marked {@literal @}{@link
* Immutable}.
*/
-// TODO(cpovirk): Should we just use ChecksumType directly instead of defining this type?
@Immutable
-@ElementTypesAreNonnullByDefault
interface ImmutableSupplier<T> extends Supplier<T> {}
diff --git a/guava/src/com/google/common/hash/Java8Compatibility.java b/guava/src/com/google/common/hash/Java8Compatibility.java
index c15f2b3..52f71e7 100644
--- a/guava/src/com/google/common/hash/Java8Compatibility.java
+++ b/guava/src/com/google/common/hash/Java8Compatibility.java
@@ -22,7 +22,6 @@
* https://github.com/google/guava/issues/3990
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
final class Java8Compatibility {
static void clear(Buffer b) {
b.clear();
diff --git a/guava/src/com/google/common/hash/LittleEndianByteArray.java b/guava/src/com/google/common/hash/LittleEndianByteArray.java
index 15d8b2c..22ef4f0 100644
--- a/guava/src/com/google/common/hash/LittleEndianByteArray.java
+++ b/guava/src/com/google/common/hash/LittleEndianByteArray.java
@@ -24,7 +24,6 @@
* @author Kevin Damm
* @author Kyle Maddison
*/
-@ElementTypesAreNonnullByDefault
final class LittleEndianByteArray {
/** The instance that actually does the work; delegates to Unsafe or a pure-Java fallback. */
diff --git a/guava/src/com/google/common/hash/LongAddable.java b/guava/src/com/google/common/hash/LongAddable.java
index 5c6a7f0..a95eece 100644
--- a/guava/src/com/google/common/hash/LongAddable.java
+++ b/guava/src/com/google/common/hash/LongAddable.java
@@ -14,13 +14,11 @@
package com.google.common.hash;
-
/**
* Abstract interface for objects that can concurrently add longs.
*
* @author Louis Wasserman
*/
-@ElementTypesAreNonnullByDefault
interface LongAddable {
void increment();
diff --git a/guava/src/com/google/common/hash/LongAddables.java b/guava/src/com/google/common/hash/LongAddables.java
index 370030d..d2768bc 100644
--- a/guava/src/com/google/common/hash/LongAddables.java
+++ b/guava/src/com/google/common/hash/LongAddables.java
@@ -22,7 +22,6 @@
*
* @author Louis Wasserman
*/
-@ElementTypesAreNonnullByDefault
final class LongAddables {
private static final Supplier<LongAddable> SUPPLIER;
diff --git a/guava/src/com/google/common/hash/LongAdder.java b/guava/src/com/google/common/hash/LongAdder.java
index dc864aa..bd08428 100644
--- a/guava/src/com/google/common/hash/LongAdder.java
+++ b/guava/src/com/google/common/hash/LongAdder.java
@@ -38,7 +38,6 @@
* @since 1.8
* @author Doug Lea
*/
-@ElementTypesAreNonnullByDefault
final class LongAdder extends Striped64 implements Serializable, LongAddable {
private static final long serialVersionUID = 7249069246863182397L;
diff --git a/guava/src/com/google/common/hash/MacHashFunction.java b/guava/src/com/google/common/hash/MacHashFunction.java
index 031b1c0..ed1841c 100644
--- a/guava/src/com/google/common/hash/MacHashFunction.java
+++ b/guava/src/com/google/common/hash/MacHashFunction.java
@@ -30,7 +30,6 @@
* @author Kurt Alfred Kluever
*/
@Immutable
-@ElementTypesAreNonnullByDefault
final class MacHashFunction extends AbstractHashFunction {
@SuppressWarnings("Immutable") // cloned before each use
diff --git a/guava/src/com/google/common/hash/MessageDigestHashFunction.java b/guava/src/com/google/common/hash/MessageDigestHashFunction.java
index 48b47b0..5c48c7d 100644
--- a/guava/src/com/google/common/hash/MessageDigestHashFunction.java
+++ b/guava/src/com/google/common/hash/MessageDigestHashFunction.java
@@ -32,7 +32,6 @@
* @author Dimitris Andreou
*/
@Immutable
-@ElementTypesAreNonnullByDefault
final class MessageDigestHashFunction extends AbstractHashFunction implements Serializable {
@SuppressWarnings("Immutable") // cloned before each use
diff --git a/guava/src/com/google/common/hash/Murmur3_128HashFunction.java b/guava/src/com/google/common/hash/Murmur3_128HashFunction.java
index d1304f8..4cb7adc 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 javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* See MurmurHash3_x64_128 in <a href="http://smhasher.googlecode.com/svn/trunk/MurmurHash3.cpp">the
@@ -41,7 +41,6 @@
* @author Dimitris Andreou
*/
@Immutable
-@ElementTypesAreNonnullByDefault
final class Murmur3_128HashFunction extends AbstractHashFunction implements Serializable {
static final HashFunction MURMUR3_128 = new Murmur3_128HashFunction(0);
@@ -71,7 +70,7 @@
}
@Override
- public boolean equals(@CheckForNull 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 a47184b..4a21383 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 javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* See MurmurHash3_x86_32 in <a
@@ -51,17 +51,11 @@
* @author Kurt Alfred Kluever
*/
@Immutable
-@ElementTypesAreNonnullByDefault
final class Murmur3_32HashFunction extends AbstractHashFunction implements Serializable {
- static final HashFunction MURMUR3_32 =
- new Murmur3_32HashFunction(0, /* supplementaryPlaneFix= */ false);
- static final HashFunction MURMUR3_32_FIXED =
- new Murmur3_32HashFunction(0, /* supplementaryPlaneFix= */ true);
+ static final HashFunction MURMUR3_32 = new Murmur3_32HashFunction(0);
- // We can include the non-BMP fix here because Hashing.goodFastHash stresses that the hash is a
- // temporary-use one. Therefore it shouldn't be persisted.
static final HashFunction GOOD_FAST_HASH_32 =
- new Murmur3_32HashFunction(Hashing.GOOD_FAST_HASH_SEED, /* supplementaryPlaneFix= */ true);
+ new Murmur3_32HashFunction(Hashing.GOOD_FAST_HASH_SEED);
private static final int CHUNK_SIZE = 4;
@@ -69,11 +63,9 @@
private static final int C2 = 0x1b873593;
private final int seed;
- private final boolean supplementaryPlaneFix;
- Murmur3_32HashFunction(int seed, boolean supplementaryPlaneFix) {
+ Murmur3_32HashFunction(int seed) {
this.seed = seed;
- this.supplementaryPlaneFix = supplementaryPlaneFix;
}
@Override
@@ -92,10 +84,10 @@
}
@Override
- public boolean equals(@CheckForNull Object object) {
+ public boolean equals(@Nullable Object object) {
if (object instanceof Murmur3_32HashFunction) {
Murmur3_32HashFunction other = (Murmur3_32HashFunction) object;
- return seed == other.seed && supplementaryPlaneFix == other.supplementaryPlaneFix;
+ return seed == other.seed;
}
return false;
}
@@ -198,9 +190,6 @@
}
i++;
buffer |= codePointToFourUtf8Bytes(codePoint) << shift;
- if (supplementaryPlaneFix) { // bug compatibility: earlier versions did not have this add
- shift += 32;
- }
len += 4;
}
@@ -402,22 +391,20 @@
}
private static long codePointToFourUtf8Bytes(int codePoint) {
- // codePoint has at most 21 bits
- return ((0xFL << 4) | (codePoint >>> 18))
+ return (((0xFL << 4) | (codePoint >>> 18)) & 0xFF)
| ((0x80L | (0x3F & (codePoint >>> 12))) << 8)
| ((0x80L | (0x3F & (codePoint >>> 6))) << 16)
| ((0x80L | (0x3F & codePoint)) << 24);
}
private static long charToThreeUtf8Bytes(char c) {
- return ((0x7L << 5) | (c >>> 12))
+ return (((0xF << 5) | (c >>> 12)) & 0xFF)
| ((0x80 | (0x3F & (c >>> 6))) << 8)
| ((0x80 | (0x3F & c)) << 16);
}
private static long charToTwoUtf8Bytes(char c) {
- // c has at most 11 bits
- return ((0x3L << 6) | (c >>> 6)) | ((0x80 | (0x3F & c)) << 8);
+ return (((0xF << 6) | (c >>> 6)) & 0xFF) | ((0x80 | (0x3F & c)) << 8);
}
private static final long serialVersionUID = 0L;
diff --git a/guava/src/com/google/common/hash/ParametricNullness.java b/guava/src/com/google/common/hash/ParametricNullness.java
deleted file mode 100644
index 2ae8d42..0000000
--- a/guava/src/com/google/common/hash/ParametricNullness.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2021 The Guava Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.common.hash;
-
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.PARAMETER;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-import static javax.annotation.meta.When.UNKNOWN;
-
-import com.google.common.annotations.GwtCompatible;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-import javax.annotation.Nonnull;
-import javax.annotation.meta.TypeQualifierNickname;
-
-/**
- * Marks a "top-level" type-variable usage as (a) a Kotlin platform type when the type argument is
- * non-nullable and (b) nullable when the type argument is nullable. This is the closest we can get
- * to "non-nullable when non-nullable; nullable when nullable" (like the Android <a
- * href="https://android.googlesource.com/platform/libcore/+/master/luni/src/main/java/libcore/util/NullFromTypeParam.java">{@code
- * NullFromTypeParam}</a>). We use this to "undo" {@link ElementTypesAreNonnullByDefault}.
- */
-@GwtCompatible
-@Retention(RUNTIME)
-@Target({FIELD, METHOD, PARAMETER})
-@TypeQualifierNickname
-@Nonnull(when = UNKNOWN)
-@interface ParametricNullness {}
diff --git a/guava/src/com/google/common/hash/PrimitiveSink.java b/guava/src/com/google/common/hash/PrimitiveSink.java
index a29ba4e..ffeb8fd 100644
--- a/guava/src/com/google/common/hash/PrimitiveSink.java
+++ b/guava/src/com/google/common/hash/PrimitiveSink.java
@@ -27,7 +27,6 @@
*/
@Beta
@CanIgnoreReturnValue
-@ElementTypesAreNonnullByDefault
public interface PrimitiveSink {
/**
* Puts a byte into this sink.
diff --git a/guava/src/com/google/common/hash/SipHashFunction.java b/guava/src/com/google/common/hash/SipHashFunction.java
index a226b61..6ec8a63 100644
--- a/guava/src/com/google/common/hash/SipHashFunction.java
+++ b/guava/src/com/google/common/hash/SipHashFunction.java
@@ -24,7 +24,7 @@
import com.google.errorprone.annotations.Immutable;
import java.io.Serializable;
import java.nio.ByteBuffer;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* {@link HashFunction} implementation of SipHash-c-d.
@@ -34,7 +34,6 @@
* @author Daniel J. Bernstein
*/
@Immutable
-@ElementTypesAreNonnullByDefault
final class SipHashFunction extends AbstractHashFunction implements Serializable {
static final HashFunction SIP_HASH_24 =
new SipHashFunction(2, 4, 0x0706050403020100L, 0x0f0e0d0c0b0a0908L);
@@ -82,7 +81,7 @@
}
@Override
- public boolean equals(@CheckForNull Object object) {
+ public boolean equals(@Nullable Object object) {
if (object instanceof SipHashFunction) {
SipHashFunction other = (SipHashFunction) object;
return (c == other.c) && (d == other.d) && (k0 == other.k0) && (k1 == other.k1);
diff --git a/guava/src/com/google/common/hash/Striped64.java b/guava/src/com/google/common/hash/Striped64.java
index 1a0671c..3f6cf1b 100644
--- a/guava/src/com/google/common/hash/Striped64.java
+++ b/guava/src/com/google/common/hash/Striped64.java
@@ -13,7 +13,6 @@
import com.google.common.annotations.GwtIncompatible;
import java.util.Random;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -22,7 +21,6 @@
* so.
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
abstract class Striped64 extends Number {
/*
* This class maintains a lazily-initialized table of atomically
@@ -127,7 +125,7 @@
* class, we use a suboptimal int[] representation to avoid introducing a new type that can impede
* class-unloading when ThreadLocals are not removed.
*/
- static final ThreadLocal<int @Nullable []> threadHashCode = new ThreadLocal<>();
+ static final ThreadLocal<int[]> threadHashCode = new ThreadLocal<>();
/** Generator of new random hash codes */
static final Random rng = new Random();
@@ -136,7 +134,7 @@
static final int NCPU = Runtime.getRuntime().availableProcessors();
/** Table of cells. When non-null, size is a power of 2. */
- @CheckForNull 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
@@ -179,7 +177,7 @@
* @param hc the hash code holder
* @param wasUncontended false if CAS failed before call
*/
- final void retryUpdate(long x, @CheckForNull int[] hc, boolean wasUncontended) {
+ final void retryUpdate(long x, int @Nullable [] hc, boolean wasUncontended) {
int h;
if (hc == null) {
threadHashCode.set(hc = new int[1]); // Initialize randomly
diff --git a/guava/src/com/google/common/html/ElementTypesAreNonnullByDefault.java b/guava/src/com/google/common/html/ElementTypesAreNonnullByDefault.java
deleted file mode 100644
index a28b716..0000000
--- a/guava/src/com/google/common/html/ElementTypesAreNonnullByDefault.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) 2021 The Guava Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.common.html;
-
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.PARAMETER;
-import static java.lang.annotation.ElementType.TYPE;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-import com.google.common.annotations.GwtCompatible;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-import javax.annotation.Nonnull;
-import javax.annotation.meta.TypeQualifierDefault;
-
-/**
- * Marks all "top-level" types as non-null in a way that is recognized by Kotlin. Note that this
- * unfortunately includes type-variable usages, so we also provide {@link ParametricNullness} to
- * "undo" it as best we can.
- */
-@GwtCompatible
-@Retention(RUNTIME)
-@Target(TYPE)
-@TypeQualifierDefault({FIELD, METHOD, PARAMETER})
-@Nonnull
-@interface ElementTypesAreNonnullByDefault {}
diff --git a/guava/src/com/google/common/html/HtmlEscapers.java b/guava/src/com/google/common/html/HtmlEscapers.java
index c426388..29eebe8 100644
--- a/guava/src/com/google/common/html/HtmlEscapers.java
+++ b/guava/src/com/google/common/html/HtmlEscapers.java
@@ -35,7 +35,6 @@
* @since 15.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
public final class HtmlEscapers {
/**
* Returns an {@link Escaper} instance that escapes HTML metacharacters as specified by <a
diff --git a/guava/src/com/google/common/html/ParametricNullness.java b/guava/src/com/google/common/html/ParametricNullness.java
deleted file mode 100644
index 9a62c35..0000000
--- a/guava/src/com/google/common/html/ParametricNullness.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2021 The Guava Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.common.html;
-
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.PARAMETER;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-import static javax.annotation.meta.When.UNKNOWN;
-
-import com.google.common.annotations.GwtCompatible;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-import javax.annotation.Nonnull;
-import javax.annotation.meta.TypeQualifierNickname;
-
-/**
- * Marks a "top-level" type-variable usage as (a) a Kotlin platform type when the type argument is
- * non-nullable and (b) nullable when the type argument is nullable. This is the closest we can get
- * to "non-nullable when non-nullable; nullable when nullable" (like the Android <a
- * href="https://android.googlesource.com/platform/libcore/+/master/luni/src/main/java/libcore/util/NullFromTypeParam.java">{@code
- * NullFromTypeParam}</a>). We use this to "undo" {@link ElementTypesAreNonnullByDefault}.
- */
-@GwtCompatible
-@Retention(RUNTIME)
-@Target({FIELD, METHOD, PARAMETER})
-@TypeQualifierNickname
-@Nonnull(when = UNKNOWN)
-@interface ParametricNullness {}
diff --git a/guava/src/com/google/common/io/AppendableWriter.java b/guava/src/com/google/common/io/AppendableWriter.java
index d9aab34..85b137e 100644
--- a/guava/src/com/google/common/io/AppendableWriter.java
+++ b/guava/src/com/google/common/io/AppendableWriter.java
@@ -21,7 +21,7 @@
import java.io.Flushable;
import java.io.IOException;
import java.io.Writer;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Writer that places all output on an {@link Appendable} target. If the target is {@link Flushable}
@@ -32,7 +32,6 @@
* @since 1.0
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
class AppendableWriter extends Writer {
private final Appendable target;
private boolean closed;
@@ -69,15 +68,13 @@
}
@Override
- public void write(String str) throws IOException {
- checkNotNull(str);
+ public void write(@Nullable String str) throws IOException {
checkNotClosed();
target.append(str);
}
@Override
- public void write(String str, int off, int len) throws IOException {
- checkNotNull(str);
+ public void write(@Nullable String str, int off, int len) throws IOException {
checkNotClosed();
// tricky: append takes start, end pair...
target.append(str, off, off + len);
@@ -107,14 +104,14 @@
}
@Override
- public Writer append(@CheckForNull CharSequence charSeq) throws IOException {
+ public Writer append(@Nullable CharSequence charSeq) throws IOException {
checkNotClosed();
target.append(charSeq);
return this;
}
@Override
- public Writer append(@CheckForNull CharSequence charSeq, int start, int end) throws IOException {
+ public Writer append(@Nullable CharSequence charSeq, int start, int end) throws IOException {
checkNotClosed();
target.append(charSeq, start, end);
return this;
diff --git a/guava/src/com/google/common/io/BaseEncoding.java b/guava/src/com/google/common/io/BaseEncoding.java
index f42857c..e2b7e00 100644
--- a/guava/src/com/google/common/io/BaseEncoding.java
+++ b/guava/src/com/google/common/io/BaseEncoding.java
@@ -35,7 +35,7 @@
import java.io.Reader;
import java.io.Writer;
import java.util.Arrays;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* A binary encoding scheme for reversibly translating between byte sequences and printable ASCII
@@ -122,7 +122,6 @@
* @since 14.0
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
public abstract class BaseEncoding {
// TODO(lowasser): consider making encodeTo(Appendable, byte[], int, int) public.
@@ -191,10 +190,11 @@
private static byte[] extract(byte[] result, int length) {
if (length == result.length) {
return result;
+ } else {
+ byte[] trunc = new byte[length];
+ System.arraycopy(result, 0, trunc, 0, length);
+ return trunc;
}
- byte[] trunc = new byte[length];
- System.arraycopy(result, 0, trunc, 0, length);
- return trunc;
}
/**
@@ -226,8 +226,7 @@
*
* @throws DecodingException if the input is not a valid encoded string according to this
* encoding.
- */
- final byte[] decodeChecked(CharSequence chars)
+ */ final byte[] decodeChecked(CharSequence chars)
throws DecodingException {
chars = trimTrailingPadding(chars);
byte[] tmp = new byte[maxDecodedSize(chars.length())];
@@ -517,25 +516,27 @@
Alphabet upperCase() {
if (!hasLowerCase()) {
return this;
+ } else {
+ checkState(!hasUpperCase(), "Cannot call upperCase() on a mixed-case alphabet");
+ char[] upperCased = new char[chars.length];
+ for (int i = 0; i < chars.length; i++) {
+ upperCased[i] = Ascii.toUpperCase(chars[i]);
+ }
+ return new Alphabet(name + ".upperCase()", upperCased);
}
- checkState(!hasUpperCase(), "Cannot call upperCase() on a mixed-case alphabet");
- char[] upperCased = new char[chars.length];
- for (int i = 0; i < chars.length; i++) {
- upperCased[i] = Ascii.toUpperCase(chars[i]);
- }
- return new Alphabet(name + ".upperCase()", upperCased);
}
Alphabet lowerCase() {
if (!hasUpperCase()) {
return this;
+ } else {
+ checkState(!hasLowerCase(), "Cannot call lowerCase() on a mixed-case alphabet");
+ char[] lowerCased = new char[chars.length];
+ for (int i = 0; i < chars.length; i++) {
+ lowerCased[i] = Ascii.toLowerCase(chars[i]);
+ }
+ return new Alphabet(name + ".lowerCase()", lowerCased);
}
- checkState(!hasLowerCase(), "Cannot call lowerCase() on a mixed-case alphabet");
- char[] lowerCased = new char[chars.length];
- for (int i = 0; i < chars.length; i++) {
- lowerCased[i] = Ascii.toLowerCase(chars[i]);
- }
- return new Alphabet(name + ".lowerCase()", lowerCased);
}
public boolean matches(char c) {
@@ -548,7 +549,7 @@
}
@Override
- public boolean equals(@CheckForNull Object other) {
+ public boolean equals(@Nullable Object other) {
if (other instanceof Alphabet) {
Alphabet that = (Alphabet) other;
return Arrays.equals(this.chars, that.chars);
@@ -566,13 +567,13 @@
// TODO(lowasser): provide a useful toString
final Alphabet alphabet;
- @CheckForNull final Character paddingChar;
+ final @Nullable Character paddingChar;
- StandardBaseEncoding(String name, String alphabetChars, @CheckForNull Character paddingChar) {
+ StandardBaseEncoding(String name, String alphabetChars, @Nullable Character paddingChar) {
this(new Alphabet(name, alphabetChars.toCharArray()), paddingChar);
}
- StandardBaseEncoding(Alphabet alphabet, @CheckForNull Character paddingChar) {
+ StandardBaseEncoding(Alphabet alphabet, @Nullable Character paddingChar) {
this.alphabet = checkNotNull(alphabet);
checkArgument(
paddingChar == null || !alphabet.matches(paddingChar),
@@ -830,8 +831,8 @@
return new SeparatedBaseEncoding(this, separator, afterEveryChars);
}
- @LazyInit @CheckForNull private transient BaseEncoding upperCase;
- @LazyInit @CheckForNull private transient BaseEncoding lowerCase;
+ @LazyInit private transient @Nullable BaseEncoding upperCase;
+ @LazyInit private transient @Nullable BaseEncoding lowerCase;
@Override
public BaseEncoding upperCase() {
@@ -853,7 +854,7 @@
return result;
}
- BaseEncoding newInstance(Alphabet alphabet, @CheckForNull Character paddingChar) {
+ BaseEncoding newInstance(Alphabet alphabet, @Nullable Character paddingChar) {
return new StandardBaseEncoding(alphabet, paddingChar);
}
@@ -872,7 +873,7 @@
}
@Override
- public boolean equals(@CheckForNull Object other) {
+ public boolean equals(@Nullable Object other) {
if (other instanceof StandardBaseEncoding) {
StandardBaseEncoding that = (StandardBaseEncoding) other;
return this.alphabet.equals(that.alphabet)
@@ -929,17 +930,17 @@
}
@Override
- BaseEncoding newInstance(Alphabet alphabet, @CheckForNull Character paddingChar) {
+ BaseEncoding newInstance(Alphabet alphabet, @Nullable Character paddingChar) {
return new Base16Encoding(alphabet);
}
}
static final class Base64Encoding extends StandardBaseEncoding {
- Base64Encoding(String name, String alphabetChars, @CheckForNull Character paddingChar) {
+ Base64Encoding(String name, String alphabetChars, @Nullable Character paddingChar) {
this(new Alphabet(name, alphabetChars.toCharArray()), paddingChar);
}
- private Base64Encoding(Alphabet alphabet, @CheckForNull Character paddingChar) {
+ private Base64Encoding(Alphabet alphabet, @Nullable Character paddingChar) {
super(alphabet, paddingChar);
checkArgument(alphabet.chars.length == 64);
}
@@ -986,7 +987,7 @@
}
@Override
- BaseEncoding newInstance(Alphabet alphabet, @CheckForNull Character paddingChar) {
+ BaseEncoding newInstance(Alphabet alphabet, @Nullable Character paddingChar) {
return new Base64Encoding(alphabet, paddingChar);
}
}
@@ -1037,12 +1038,12 @@
}
@Override
- public Appendable append(@CheckForNull CharSequence chars, int off, int len) {
+ public Appendable append(@Nullable CharSequence chars, int off, int len) throws IOException {
throw new UnsupportedOperationException();
}
@Override
- public Appendable append(@CheckForNull CharSequence chars) {
+ public Appendable append(@Nullable CharSequence chars) throws IOException {
throw new UnsupportedOperationException();
}
};
diff --git a/guava/src/com/google/common/io/ByteArrayDataInput.java b/guava/src/com/google/common/io/ByteArrayDataInput.java
index cf84fcc..bef1431 100644
--- a/guava/src/com/google/common/io/ByteArrayDataInput.java
+++ b/guava/src/com/google/common/io/ByteArrayDataInput.java
@@ -18,7 +18,6 @@
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import java.io.DataInput;
import java.io.IOException;
-import javax.annotation.CheckForNull;
/**
* An extension of {@code DataInput} for reading from in-memory byte arrays; its methods offer
@@ -33,7 +32,6 @@
* @since 1.0
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public interface ByteArrayDataInput extends DataInput {
@Override
void readFully(byte b[]);
@@ -88,7 +86,6 @@
@CanIgnoreReturnValue // to skip a line
@Override
- @CheckForNull
String readLine();
@CanIgnoreReturnValue // to skip a field
diff --git a/guava/src/com/google/common/io/ByteArrayDataOutput.java b/guava/src/com/google/common/io/ByteArrayDataOutput.java
index 3739073..e1ad6ab 100644
--- a/guava/src/com/google/common/io/ByteArrayDataOutput.java
+++ b/guava/src/com/google/common/io/ByteArrayDataOutput.java
@@ -26,7 +26,6 @@
* @since 1.0
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public interface ByteArrayDataOutput extends DataOutput {
@Override
void write(int b);
diff --git a/guava/src/com/google/common/io/ByteProcessor.java b/guava/src/com/google/common/io/ByteProcessor.java
index 98ea3ff..115c735 100644
--- a/guava/src/com/google/common/io/ByteProcessor.java
+++ b/guava/src/com/google/common/io/ByteProcessor.java
@@ -19,7 +19,6 @@
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import com.google.errorprone.annotations.DoNotMock;
import java.io.IOException;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* A callback interface to process bytes from a stream.
@@ -33,8 +32,7 @@
@Beta
@DoNotMock("Implement it normally")
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
-public interface ByteProcessor<T extends @Nullable Object> {
+public interface ByteProcessor<T> {
/**
* This method will be called for each chunk of bytes in an input stream. The implementation
* should process the bytes from {@code buf[off]} through {@code buf[off + len - 1]} (inclusive).
@@ -48,6 +46,5 @@
boolean processBytes(byte[] buf, int off, int len) throws IOException;
/** Return the result of processing all the bytes. */
- @ParametricNullness
T getResult();
}
diff --git a/guava/src/com/google/common/io/ByteSink.java b/guava/src/com/google/common/io/ByteSink.java
index 7a6af6f..ffba6e0 100644
--- a/guava/src/com/google/common/io/ByteSink.java
+++ b/guava/src/com/google/common/io/ByteSink.java
@@ -46,7 +46,6 @@
* @author Colin Decker
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public abstract class ByteSink {
/** Constructor for use by subclasses. */
diff --git a/guava/src/com/google/common/io/ByteSource.java b/guava/src/com/google/common/io/ByteSource.java
index c8da967..19f3a43 100644
--- a/guava/src/com/google/common/io/ByteSource.java
+++ b/guava/src/com/google/common/io/ByteSource.java
@@ -40,7 +40,6 @@
import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* A readable source of bytes, such as a file. Unlike an {@link InputStream}, a {@code ByteSource}
@@ -58,23 +57,10 @@
* doing something and finally closing the stream that was opened.
* </ul>
*
- * <p><b>Note:</b> In general, {@code ByteSource} is intended to be used for "file-like" sources
- * that provide streams that are:
- *
- * <ul>
- * <li><b>Finite:</b> Many operations, such as {@link #size()} and {@link #read()}, will either
- * block indefinitely or fail if the source creates an infinite stream.
- * <li><b>Non-destructive:</b> A <i>destructive</i> stream will consume or otherwise alter the
- * bytes of the source as they are read from it. A source that provides such streams will not
- * be reusable, and operations that read from the stream (including {@link #size()}, in some
- * implementations) will prevent further operations from completing as expected.
- * </ul>
- *
* @since 14.0
* @author Colin Decker
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public abstract class ByteSource {
/** Constructor for use by subclasses. */
@@ -316,7 +302,7 @@
*/
@Beta
@CanIgnoreReturnValue // some processors won't return a useful result
- public <T extends @Nullable Object> T read(ByteProcessor<T> processor) throws IOException {
+ public <T> T read(ByteProcessor<T> processor) throws IOException {
checkNotNull(processor);
Closer closer = Closer.create();
@@ -430,7 +416,7 @@
* Returns a view of the given byte array as a {@link ByteSource}. To view only a specific range
* in the array, use {@code ByteSource.wrap(b).slice(offset, length)}.
*
- * <p>Note that the given byte array may be passed directly to methods on, for example, {@code
+ * <p>Note that the given byte array may be be passed directly to methods on, for example, {@code
* OutputStream} (when {@code copyTo(OutputStream)} is called on the resulting {@code
* ByteSource}). This could allow a malicious {@code OutputStream} implementation to modify the
* contents of the array, but provides better performance in the normal case.
@@ -620,8 +606,7 @@
@SuppressWarnings("CheckReturnValue") // it doesn't matter what processBytes returns here
@Override
- @ParametricNullness
- public <T extends @Nullable Object> T read(ByteProcessor<T> processor) throws IOException {
+ public <T> T read(ByteProcessor<T> processor) throws IOException {
processor.processBytes(bytes, offset, length);
return processor.getResult();
}
diff --git a/guava/src/com/google/common/io/ByteStreams.java b/guava/src/com/google/common/io/ByteStreams.java
index 2f1f669..bdb24db 100644
--- a/guava/src/com/google/common/io/ByteStreams.java
+++ b/guava/src/com/google/common/io/ByteStreams.java
@@ -41,8 +41,6 @@
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Queue;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Provides utility methods for working with byte arrays and I/O streams.
@@ -52,7 +50,6 @@
* @since 1.0
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public final class ByteStreams {
private static final int BUFFER_SIZE = 8192;
@@ -441,7 +438,6 @@
}
@Override
- @CheckForNull
public String readLine() {
try {
return input.readLine();
@@ -873,9 +869,7 @@
*/
@Beta
@CanIgnoreReturnValue // some processors won't return a useful result
- @ParametricNullness
- public static <T extends @Nullable Object> T readBytes(
- InputStream input, ByteProcessor<T> processor) throws IOException {
+ public static <T> T readBytes(InputStream input, ByteProcessor<T> processor) throws IOException {
checkNotNull(input);
checkNotNull(processor);
diff --git a/guava/src/com/google/common/io/CharSequenceReader.java b/guava/src/com/google/common/io/CharSequenceReader.java
index 790e266..4cbeda1 100644
--- a/guava/src/com/google/common/io/CharSequenceReader.java
+++ b/guava/src/com/google/common/io/CharSequenceReader.java
@@ -17,13 +17,11 @@
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkPositionIndexes;
-import static java.util.Objects.requireNonNull;
import com.google.common.annotations.GwtIncompatible;
import java.io.IOException;
import java.io.Reader;
import java.nio.CharBuffer;
-import javax.annotation.CheckForNull;
/**
* A {@link Reader} that reads the characters in a {@link CharSequence}. Like {@code StringReader},
@@ -33,10 +31,9 @@
*/
// TODO(cgdecker): make this public? as a type, or a method in CharStreams?
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
final class CharSequenceReader extends Reader {
- @CheckForNull private CharSequence seq;
+ private CharSequence seq;
private int pos;
private int mark;
@@ -56,27 +53,13 @@
}
private int remaining() {
- requireNonNull(seq); // safe as long as we call this only after checkOpen
return seq.length() - pos;
}
- /*
- * To avoid the need to call requireNonNull so much, we could consider more clever approaches,
- * such as:
- *
- * - Make checkOpen return the non-null `seq`. Then callers can assign that to a local variable or
- * even back to `this.seq`. However, that may suggest that we're defending against concurrent
- * mutation, which is not an actual risk because we use `synchronized`.
- * - Make `remaining` require a non-null `seq` argument. But this is a bit weird because the
- * method, while it would avoid the instance field `seq` would still access the instance field
- * `pos`.
- */
-
@Override
public synchronized int read(CharBuffer target) throws IOException {
checkNotNull(target);
checkOpen();
- requireNonNull(seq); // safe because of checkOpen
if (!hasRemaining()) {
return -1;
}
@@ -90,7 +73,6 @@
@Override
public synchronized int read() throws IOException {
checkOpen();
- requireNonNull(seq); // safe because of checkOpen
return hasRemaining() ? seq.charAt(pos++) : -1;
}
@@ -98,7 +80,6 @@
public synchronized int read(char[] cbuf, int off, int len) throws IOException {
checkPositionIndexes(off, off + len, cbuf.length);
checkOpen();
- requireNonNull(seq); // safe because of checkOpen
if (!hasRemaining()) {
return -1;
}
diff --git a/guava/src/com/google/common/io/CharSink.java b/guava/src/com/google/common/io/CharSink.java
index f804dae..7197265 100644
--- a/guava/src/com/google/common/io/CharSink.java
+++ b/guava/src/com/google/common/io/CharSink.java
@@ -51,7 +51,6 @@
* @author Colin Decker
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public abstract class CharSink {
/** Constructor for use by subclasses. */
diff --git a/guava/src/com/google/common/io/CharSource.java b/guava/src/com/google/common/io/CharSource.java
index 24a67af..ac3df0c 100644
--- a/guava/src/com/google/common/io/CharSource.java
+++ b/guava/src/com/google/common/io/CharSource.java
@@ -39,7 +39,6 @@
import java.util.List;
import java.util.function.Consumer;
import java.util.stream.Stream;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -66,23 +65,10 @@
* <p>Any {@link ByteSource} containing text encoded with a specific {@linkplain Charset character
* encoding} may be viewed as a {@code CharSource} using {@link ByteSource#asCharSource(Charset)}.
*
- * <p><b>Note:</b> In general, {@code CharSource} is intended to be used for "file-like" sources
- * that provide readers that are:
- *
- * <ul>
- * <li><b>Finite:</b> Many operations, such as {@link #length()} and {@link #read()}, will either
- * block indefinitely or fail if the source creates an infinite reader.
- * <li><b>Non-destructive:</b> A <i>destructive</i> reader will consume or otherwise alter the
- * source as they are read from it. A source that provides such readers will not be reusable,
- * and operations that read from the stream (including {@link #length()}, in some
- * implementations) will prevent further operations from completing as expected.
- * </ul>
- *
* @since 14.0
* @author Colin Decker
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public abstract class CharSource {
/** Constructor for use by subclasses. */
@@ -309,8 +295,7 @@
*
* @throws IOException if an I/O error occurs while reading from this source
*/
- @CheckForNull
- public String readFirstLine() throws IOException {
+ public @Nullable String readFirstLine() throws IOException {
Closer closer = Closer.create();
try {
BufferedReader reader = closer.register(openBufferedStream());
@@ -366,8 +351,7 @@
*/
@Beta
@CanIgnoreReturnValue // some processors won't return a useful result
- @ParametricNullness
- public <T extends @Nullable Object> T readLines(LineProcessor<T> processor) throws IOException {
+ public <T> T readLines(LineProcessor<T> processor) throws IOException {
checkNotNull(processor);
Closer closer = Closer.create();
@@ -579,7 +563,6 @@
Iterator<String> lines = LINE_SPLITTER.split(seq).iterator();
@Override
- @CheckForNull
protected String computeNext() {
if (lines.hasNext()) {
String next = lines.next();
@@ -599,7 +582,6 @@
}
@Override
- @CheckForNull
public String readFirstLine() {
Iterator<String> lines = linesIterator();
return lines.hasNext() ? lines.next() : null;
@@ -611,8 +593,7 @@
}
@Override
- @ParametricNullness
- public <T extends @Nullable Object> T readLines(LineProcessor<T> processor) throws IOException {
+ public <T> T readLines(LineProcessor<T> processor) throws IOException {
Iterator<String> lines = linesIterator();
while (lines.hasNext()) {
if (!processor.processLine(lines.next())) {
diff --git a/guava/src/com/google/common/io/CharStreams.java b/guava/src/com/google/common/io/CharStreams.java
index c414194..dd54253 100644
--- a/guava/src/com/google/common/io/CharStreams.java
+++ b/guava/src/com/google/common/io/CharStreams.java
@@ -28,7 +28,6 @@
import java.nio.CharBuffer;
import java.util.ArrayList;
import java.util.List;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -46,7 +45,6 @@
* @since 1.0
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public final class CharStreams {
// 2K chars (4K bytes)
@@ -79,19 +77,19 @@
} else {
return copyReaderToWriter((Reader) from, asWriter(to));
}
+ } else {
+ checkNotNull(from);
+ checkNotNull(to);
+ long total = 0;
+ CharBuffer buf = createBuffer();
+ while (from.read(buf) != -1) {
+ Java8Compatibility.flip(buf);
+ to.append(buf);
+ total += buf.remaining();
+ Java8Compatibility.clear(buf);
+ }
+ return total;
}
-
- checkNotNull(from);
- checkNotNull(to);
- long total = 0;
- CharBuffer buf = createBuffer();
- while (from.read(buf) != -1) {
- Java8Compatibility.flip(buf);
- to.append(buf);
- total += buf.remaining();
- Java8Compatibility.clear(buf);
- }
- return total;
}
// TODO(lukes): consider allowing callers to pass in a buffer to use, some callers would be able
@@ -217,9 +215,7 @@
*/
@Beta
@CanIgnoreReturnValue // some processors won't return a useful result
- @ParametricNullness
- public static <T extends @Nullable Object> T readLines(
- Readable readable, LineProcessor<T> processor) throws IOException {
+ public static <T> T readLines(Readable readable, LineProcessor<T> processor) throws IOException {
checkNotNull(readable);
checkNotNull(processor);
@@ -311,12 +307,12 @@
}
@Override
- public Writer append(@CheckForNull CharSequence csq) {
+ public Writer append(@Nullable CharSequence csq) {
return this;
}
@Override
- public Writer append(@CheckForNull CharSequence csq, int start, int end) {
+ public Writer append(@Nullable CharSequence csq, int start, int end) {
checkPositionIndexes(start, end, csq == null ? "null".length() : csq.length());
return this;
}
diff --git a/guava/src/com/google/common/io/Closeables.java b/guava/src/com/google/common/io/Closeables.java
index b45f5f0..3adcb19 100644
--- a/guava/src/com/google/common/io/Closeables.java
+++ b/guava/src/com/google/common/io/Closeables.java
@@ -23,7 +23,7 @@
import java.io.Reader;
import java.util.logging.Level;
import java.util.logging.Logger;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Utility methods for working with {@link Closeable} objects.
@@ -33,7 +33,6 @@
*/
@Beta
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public final class Closeables {
@VisibleForTesting static final Logger logger = Logger.getLogger(Closeables.class.getName());
@@ -70,7 +69,7 @@
* @throws IOException if {@code swallowIOException} is false and {@code close} throws an {@code
* IOException}.
*/
- public static void close(@CheckForNull Closeable closeable, boolean swallowIOException)
+ public static void close(@Nullable Closeable closeable, boolean swallowIOException)
throws IOException {
if (closeable == null) {
return;
@@ -100,7 +99,7 @@
* does nothing
* @since 17.0
*/
- public static void closeQuietly(@CheckForNull InputStream inputStream) {
+ public static void closeQuietly(@Nullable InputStream inputStream) {
try {
close(inputStream, true);
} catch (IOException impossible) {
@@ -121,7 +120,7 @@
* @param reader the reader to be closed, or {@code null} in which case this method does nothing
* @since 17.0
*/
- public static void closeQuietly(@CheckForNull Reader reader) {
+ public static void closeQuietly(@Nullable Reader reader) {
try {
close(reader, true);
} catch (IOException impossible) {
diff --git a/guava/src/com/google/common/io/Closer.java b/guava/src/com/google/common/io/Closer.java
index 12998ef..82cfcb4 100644
--- a/guava/src/com/google/common/io/Closer.java
+++ b/guava/src/com/google/common/io/Closer.java
@@ -27,7 +27,6 @@
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.logging.Level;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -89,16 +88,13 @@
// Coffee's for {@link Closer closers} only.
@Beta
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public final class Closer implements Closeable {
/** The suppressor implementation to use for the current Java version. */
- private static final Suppressor SUPPRESSOR;
-
- static {
- SuppressingSuppressor suppressingSuppressor = SuppressingSuppressor.tryCreate();
- SUPPRESSOR = suppressingSuppressor == null ? LoggingSuppressor.INSTANCE : suppressingSuppressor;
- }
+ private static final Suppressor SUPPRESSOR =
+ SuppressingSuppressor.isAvailable()
+ ? SuppressingSuppressor.INSTANCE
+ : LoggingSuppressor.INSTANCE;
/** Creates a new {@link Closer}. */
public static Closer create() {
@@ -109,7 +105,7 @@
// only need space for 2 elements in most cases, so try to use the smallest array possible
private final Deque<Closeable> stack = new ArrayDeque<>(4);
- @CheckForNull private Throwable thrown;
+ private @Nullable Throwable thrown;
@VisibleForTesting
Closer(Suppressor suppressor) {
@@ -124,8 +120,7 @@
*/
// close. this word no longer has any meaning to me.
@CanIgnoreReturnValue
- @ParametricNullness
- public <C extends @Nullable Closeable> C register(@ParametricNullness C closeable) {
+ public <C extends Closeable> C register(@Nullable C closeable) {
if (closeable != null) {
stack.addFirst(closeable);
}
@@ -262,21 +257,21 @@
*/
@VisibleForTesting
static final class SuppressingSuppressor implements Suppressor {
- @CheckForNull
- static SuppressingSuppressor tryCreate() {
- Method addSuppressed;
+
+ static final SuppressingSuppressor INSTANCE = new SuppressingSuppressor();
+
+ static boolean isAvailable() {
+ return addSuppressed != null;
+ }
+
+ static final Method addSuppressed = addSuppressedMethodOrNull();
+
+ private static Method addSuppressedMethodOrNull() {
try {
- addSuppressed = Throwable.class.getMethod("addSuppressed", Throwable.class);
+ return Throwable.class.getMethod("addSuppressed", Throwable.class);
} catch (Throwable e) {
return null;
}
- return new SuppressingSuppressor(addSuppressed);
- }
-
- private final Method addSuppressed;
-
- private SuppressingSuppressor(Method addSuppressed) {
- this.addSuppressed = addSuppressed;
}
@Override
diff --git a/guava/src/com/google/common/io/CountingInputStream.java b/guava/src/com/google/common/io/CountingInputStream.java
index a37807a..b015aca 100644
--- a/guava/src/com/google/common/io/CountingInputStream.java
+++ b/guava/src/com/google/common/io/CountingInputStream.java
@@ -30,7 +30,6 @@
*/
@Beta
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public final class CountingInputStream extends FilterInputStream {
private long count;
diff --git a/guava/src/com/google/common/io/CountingOutputStream.java b/guava/src/com/google/common/io/CountingOutputStream.java
index cf62b9c..8a3d170 100644
--- a/guava/src/com/google/common/io/CountingOutputStream.java
+++ b/guava/src/com/google/common/io/CountingOutputStream.java
@@ -16,6 +16,7 @@
import static com.google.common.base.Preconditions.checkNotNull;
+import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtIncompatible;
import java.io.FilterOutputStream;
import java.io.IOException;
@@ -27,8 +28,8 @@
* @author Chris Nokleberg
* @since 1.0
*/
+@Beta
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public final class CountingOutputStream extends FilterOutputStream {
private long count;
diff --git a/guava/src/com/google/common/io/ElementTypesAreNonnullByDefault.java b/guava/src/com/google/common/io/ElementTypesAreNonnullByDefault.java
deleted file mode 100644
index 48bc10f..0000000
--- a/guava/src/com/google/common/io/ElementTypesAreNonnullByDefault.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) 2021 The Guava Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.common.io;
-
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.PARAMETER;
-import static java.lang.annotation.ElementType.TYPE;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-import com.google.common.annotations.GwtCompatible;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-import javax.annotation.Nonnull;
-import javax.annotation.meta.TypeQualifierDefault;
-
-/**
- * Marks all "top-level" types as non-null in a way that is recognized by Kotlin. Note that this
- * unfortunately includes type-variable usages, so we also provide {@link ParametricNullness} to
- * "undo" it as best we can.
- */
-@GwtCompatible
-@Retention(RUNTIME)
-@Target(TYPE)
-@TypeQualifierDefault({FIELD, METHOD, PARAMETER})
-@Nonnull
-@interface ElementTypesAreNonnullByDefault {}
diff --git a/guava/src/com/google/common/io/FileBackedOutputStream.java b/guava/src/com/google/common/io/FileBackedOutputStream.java
index 9912e2f..8d8effc 100644
--- a/guava/src/com/google/common/io/FileBackedOutputStream.java
+++ b/guava/src/com/google/common/io/FileBackedOutputStream.java
@@ -14,8 +14,6 @@
package com.google.common.io;
-import static java.util.Objects.requireNonNull;
-
import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtIncompatible;
import com.google.common.annotations.VisibleForTesting;
@@ -28,7 +26,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* An {@link OutputStream} that starts buffering to a byte array, but switches to file buffering
@@ -52,23 +50,20 @@
*/
@Beta
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public final class FileBackedOutputStream extends OutputStream {
private final int fileThreshold;
private final boolean resetOnFinalize;
private final ByteSource source;
- @CheckForNull private final File parentDirectory;
+ @Nullable private final File parentDirectory;
@GuardedBy("this")
private OutputStream out;
@GuardedBy("this")
- @CheckForNull
private MemoryOutput memory;
@GuardedBy("this")
- @CheckForNull
- private File file;
+ private @Nullable File file;
/** ByteArrayOutputStream that exposes its internals. */
private static class MemoryOutput extends ByteArrayOutputStream {
@@ -83,7 +78,6 @@
/** Returns the file holding the data (possibly null). */
@VisibleForTesting
- @CheckForNull
synchronized File getFile() {
return file;
}
@@ -111,7 +105,7 @@
}
private FileBackedOutputStream(
- int fileThreshold, boolean resetOnFinalize, @CheckForNull File parentDirectory) {
+ int fileThreshold, boolean resetOnFinalize, @Nullable File parentDirectory) {
this.fileThreshold = fileThreshold;
this.resetOnFinalize = resetOnFinalize;
this.parentDirectory = parentDirectory;
@@ -159,8 +153,6 @@
if (file != null) {
return new FileInputStream(file);
} else {
- // requireNonNull is safe because we always have either `file` or `memory`.
- requireNonNull(memory);
return new ByteArrayInputStream(memory.getBuffer(), 0, memory.getCount());
}
}
@@ -224,24 +216,19 @@
*/
@GuardedBy("this")
private void update(int len) throws IOException {
- if (memory != null && (memory.getCount() + len > fileThreshold)) {
+ if (file == null && (memory.getCount() + len > fileThreshold)) {
File temp = File.createTempFile("FileBackedOutputStream", null, parentDirectory);
if (resetOnFinalize) {
// Finalizers are not guaranteed to be called on system shutdown;
// this is insurance.
temp.deleteOnExit();
}
- try {
- FileOutputStream transfer = new FileOutputStream(temp);
- transfer.write(memory.getBuffer(), 0, memory.getCount());
- transfer.flush();
- // We've successfully transferred the data; switch to writing to file
- out = transfer;
- } catch (IOException e) {
- temp.delete();
- throw e;
- }
+ FileOutputStream transfer = new FileOutputStream(temp);
+ transfer.write(memory.getBuffer(), 0, memory.getCount());
+ transfer.flush();
+ // We've successfully transferred the data; switch to writing to file
+ out = transfer;
file = temp;
memory = null;
}
diff --git a/guava/src/com/google/common/io/FileWriteMode.java b/guava/src/com/google/common/io/FileWriteMode.java
index 86872d1..2c69a2e 100644
--- a/guava/src/com/google/common/io/FileWriteMode.java
+++ b/guava/src/com/google/common/io/FileWriteMode.java
@@ -23,7 +23,6 @@
* @author Colin Decker
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public enum FileWriteMode {
/** Specifies that writes to the opened file should append to the end of the file. */
APPEND
diff --git a/guava/src/com/google/common/io/Files.java b/guava/src/com/google/common/io/Files.java
index bf6289e..73eb656 100644
--- a/guava/src/com/google/common/io/Files.java
+++ b/guava/src/com/google/common/io/Files.java
@@ -52,8 +52,6 @@
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Provides utility methods for working with {@linkplain File files}.
@@ -66,7 +64,6 @@
* @since 1.0
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public final class Files {
/** Maximum loop count when creating temp directories. */
@@ -532,7 +529,6 @@
*/
@Beta
@Deprecated
- @CheckForNull
public
static String readFirstLine(File file, Charset charset) throws IOException {
return asCharSource(file, charset).readFirstLine();
@@ -592,10 +588,8 @@
@Beta
@Deprecated
@CanIgnoreReturnValue // some processors won't return a useful result
- @ParametricNullness
public
- static <T extends @Nullable Object> T readLines(
- File file, Charset charset, LineProcessor<T> callback) throws IOException {
+ static <T> T readLines(File file, Charset charset, LineProcessor<T> callback) throws IOException {
return asCharSource(file, charset).readLines(callback);
}
@@ -614,10 +608,8 @@
@Beta
@Deprecated
@CanIgnoreReturnValue // some processors won't return a useful result
- @ParametricNullness
public
- static <T extends @Nullable Object> T readBytes(File file, ByteProcessor<T> processor)
- throws IOException {
+ static <T> T readBytes(File file, ByteProcessor<T> processor) throws IOException {
return asByteSource(file).read(processor);
}
diff --git a/guava/src/com/google/common/io/Flushables.java b/guava/src/com/google/common/io/Flushables.java
index 1f795a2..9b1d6a0 100644
--- a/guava/src/com/google/common/io/Flushables.java
+++ b/guava/src/com/google/common/io/Flushables.java
@@ -29,7 +29,6 @@
*/
@Beta
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public final class Flushables {
private static final Logger logger = Logger.getLogger(Flushables.class.getName());
diff --git a/guava/src/com/google/common/io/InsecureRecursiveDeleteException.java b/guava/src/com/google/common/io/InsecureRecursiveDeleteException.java
index 4140936..7d07805 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 javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Exception indicating that a recursive delete can't be performed because the file system does not
@@ -38,10 +38,9 @@
@Beta
@GwtIncompatible
@J2ObjCIncompatible // java.nio.file
-@ElementTypesAreNonnullByDefault
public final class InsecureRecursiveDeleteException extends FileSystemException {
- public InsecureRecursiveDeleteException(@CheckForNull 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/Java8Compatibility.java b/guava/src/com/google/common/io/Java8Compatibility.java
index 705d97b..62b5c2e 100644
--- a/guava/src/com/google/common/io/Java8Compatibility.java
+++ b/guava/src/com/google/common/io/Java8Compatibility.java
@@ -22,7 +22,6 @@
* https://github.com/google/guava/issues/3990
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
final class Java8Compatibility {
static void clear(Buffer b) {
b.clear();
@@ -36,17 +35,9 @@
b.limit(limit);
}
- static void mark(Buffer b) {
- b.mark();
- }
-
static void position(Buffer b, int position) {
b.position(position);
}
- static void reset(Buffer b) {
- b.reset();
- }
-
private Java8Compatibility() {}
}
diff --git a/guava/src/com/google/common/io/LineBuffer.java b/guava/src/com/google/common/io/LineBuffer.java
index f944abc..a8e775c 100644
--- a/guava/src/com/google/common/io/LineBuffer.java
+++ b/guava/src/com/google/common/io/LineBuffer.java
@@ -30,7 +30,6 @@
* @since 1.0
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
abstract class LineBuffer {
/** Holds partial line contents. */
private StringBuilder line = new StringBuilder();
diff --git a/guava/src/com/google/common/io/LineProcessor.java b/guava/src/com/google/common/io/LineProcessor.java
index e28bebc..65ded53 100644
--- a/guava/src/com/google/common/io/LineProcessor.java
+++ b/guava/src/com/google/common/io/LineProcessor.java
@@ -18,7 +18,6 @@
import com.google.common.annotations.GwtIncompatible;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import java.io.IOException;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* A callback to be used with the streaming {@code readLines} methods.
@@ -31,8 +30,7 @@
*/
@Beta
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
-public interface LineProcessor<T extends @Nullable Object> {
+public interface LineProcessor<T> {
/**
* This method will be called once for each line.
@@ -44,6 +42,5 @@
boolean processLine(String line) throws IOException;
/** Return the result of processing all the lines. */
- @ParametricNullness
T getResult();
}
diff --git a/guava/src/com/google/common/io/LineReader.java b/guava/src/com/google/common/io/LineReader.java
index 2c57ac4..55b659f2 100644
--- a/guava/src/com/google/common/io/LineReader.java
+++ b/guava/src/com/google/common/io/LineReader.java
@@ -23,9 +23,9 @@
import java.io.IOException;
import java.io.Reader;
import java.nio.CharBuffer;
-import java.util.ArrayDeque;
+import java.util.LinkedList;
import java.util.Queue;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* A class for reading lines of text. Provides the same functionality as {@link
@@ -37,14 +37,13 @@
*/
@Beta
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public final class LineReader {
private final Readable readable;
- @CheckForNull private final Reader reader;
+ private final @Nullable Reader reader;
private final CharBuffer cbuf = createBuffer();
private final char[] buf = cbuf.array();
- private final Queue<String> lines = new ArrayDeque<>();
+ private final Queue<String> lines = new LinkedList<>();
private final LineBuffer lineBuf =
new LineBuffer() {
@Override
@@ -69,7 +68,6 @@
* @throws IOException if an I/O error occurs
*/
@CanIgnoreReturnValue // to skip a line
- @CheckForNull
public String readLine() throws IOException {
while (lines.peek() == null) {
Java8Compatibility.clear(cbuf);
diff --git a/guava/src/com/google/common/io/LittleEndianDataInputStream.java b/guava/src/com/google/common/io/LittleEndianDataInputStream.java
index 88c8e27..7d9c88b 100644
--- a/guava/src/com/google/common/io/LittleEndianDataInputStream.java
+++ b/guava/src/com/google/common/io/LittleEndianDataInputStream.java
@@ -20,7 +20,6 @@
import com.google.common.primitives.Ints;
import com.google.common.primitives.Longs;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
-import com.google.errorprone.annotations.DoNotCall;
import java.io.DataInput;
import java.io.DataInputStream;
import java.io.EOFException;
@@ -41,7 +40,6 @@
*/
@Beta
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public final class LittleEndianDataInputStream extends FilterInputStream implements DataInput {
/**
@@ -56,7 +54,6 @@
/** This method will throw an {@link UnsupportedOperationException}. */
@CanIgnoreReturnValue // to skip a line
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
public String readLine() {
throw new UnsupportedOperationException("readLine is not supported");
}
diff --git a/guava/src/com/google/common/io/LittleEndianDataOutputStream.java b/guava/src/com/google/common/io/LittleEndianDataOutputStream.java
index 6e51aff..e5e398f 100644
--- a/guava/src/com/google/common/io/LittleEndianDataOutputStream.java
+++ b/guava/src/com/google/common/io/LittleEndianDataOutputStream.java
@@ -37,7 +37,6 @@
*/
@Beta
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public final class LittleEndianDataOutputStream extends FilterOutputStream implements DataOutput {
/**
diff --git a/guava/src/com/google/common/io/MoreFiles.java b/guava/src/com/google/common/io/MoreFiles.java
index ffe200d..364d5c6 100644
--- a/guava/src/com/google/common/io/MoreFiles.java
+++ b/guava/src/com/google/common/io/MoreFiles.java
@@ -17,9 +17,7 @@
package com.google.common.io;
import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.collect.Iterables.getOnlyElement;
import static java.nio.file.LinkOption.NOFOLLOW_LINKS;
-import static java.util.Objects.requireNonNull;
import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtIncompatible;
@@ -55,7 +53,7 @@
import java.util.Arrays;
import java.util.Collection;
import java.util.stream.Stream;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Static utilities for use with {@link Path} instances, intended to complement {@link Files}.
@@ -70,7 +68,6 @@
@Beta
@GwtIncompatible
@J2ObjCIncompatible // java.nio.file
-@ElementTypesAreNonnullByDefault
public final class MoreFiles {
private MoreFiles() {}
@@ -535,13 +532,7 @@
if (parent instanceof SecureDirectoryStream) {
sdsSupported = true;
exceptions =
- deleteRecursivelySecure(
- (SecureDirectoryStream<Path>) parent,
- /*
- * requireNonNull is safe because paths have file names when they have parents,
- * and we checked for a parent at the beginning of the method.
- */
- requireNonNull(path.getFileName()));
+ deleteRecursivelySecure((SecureDirectoryStream<Path>) parent, path.getFileName());
}
}
@@ -621,8 +612,7 @@
* Secure recursive delete using {@code SecureDirectoryStream}. Returns a collection of exceptions
* that occurred or null if no exceptions were thrown.
*/
- @CheckForNull
- private static Collection<IOException> deleteRecursivelySecure(
+ private static @Nullable Collection<IOException> deleteRecursivelySecure(
SecureDirectoryStream<Path> dir, Path path) {
Collection<IOException> exceptions = null;
try {
@@ -650,8 +640,7 @@
* 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.
*/
- @CheckForNull
- private static Collection<IOException> deleteDirectoryContentsSecure(
+ private static @Nullable Collection<IOException> deleteDirectoryContentsSecure(
SecureDirectoryStream<Path> dir) {
Collection<IOException> exceptions = null;
try {
@@ -669,8 +658,7 @@
* 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.
*/
- @CheckForNull
- private static Collection<IOException> deleteRecursivelyInsecure(Path path) {
+ private static @Nullable Collection<IOException> deleteRecursivelyInsecure(Path path) {
Collection<IOException> exceptions = null;
try {
if (Files.isDirectory(path, NOFOLLOW_LINKS)) {
@@ -696,8 +684,7 @@
* support {@code SecureDirectoryStream}. Returns a collection of exceptions that occurred or null
* if no exceptions were thrown.
*/
- @CheckForNull
- private static Collection<IOException> deleteDirectoryContentsInsecure(
+ private static @Nullable Collection<IOException> deleteDirectoryContentsInsecure(
DirectoryStream<Path> dir) {
Collection<IOException> exceptions = null;
try {
@@ -716,8 +703,7 @@
* 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.
*/
- @CheckForNull
- private static Path getParentPath(Path path) {
+ private static @Nullable Path getParentPath(Path path) {
Path parent = path.getParent();
// Paths that have a parent:
@@ -763,7 +749,7 @@
* the collection.
*/
private static Collection<IOException> addException(
- @CheckForNull Collection<IOException> exceptions, IOException e) {
+ @Nullable Collection<IOException> exceptions, IOException e) {
if (exceptions == null) {
exceptions = new ArrayList<>(); // don't need Set semantics
}
@@ -776,10 +762,8 @@
* null, the other collection is returned. Otherwise, the elements of {@code other} are added to
* {@code exceptions} and {@code exceptions} is returned.
*/
- @CheckForNull
- private static Collection<IOException> concat(
- @CheckForNull Collection<IOException> exceptions,
- @CheckForNull Collection<IOException> other) {
+ private static @Nullable Collection<IOException> concat(
+ @Nullable Collection<IOException> exceptions, @Nullable Collection<IOException> other) {
if (exceptions == null) {
return other;
} else if (other != null) {
@@ -789,19 +773,11 @@
}
/**
- * Throws an exception indicating that one or more files couldn't be deleted when deleting {@code
- * path} or its contents.
- *
- * <p>If there is only one exception in the collection, and it is a {@link NoSuchFileException}
- * thrown because {@code path} itself didn't exist, then throws that exception. Otherwise, the
- * thrown exception contains all the exceptions in the given collection as suppressed exceptions.
+ * Throws an exception indicating that one or more files couldn't be deleted. The thrown exception
+ * contains all the exceptions in the given collection as suppressed exceptions.
*/
private static void throwDeleteFailed(Path path, Collection<IOException> exceptions)
throws FileSystemException {
- NoSuchFileException pathNotFound = pathNotFound(path, exceptions);
- if (pathNotFound != null) {
- throw pathNotFound;
- }
// TODO(cgdecker): Should there be a custom exception type for this?
// Also, should we try to include the Path of each file we may have failed to delete rather
// than just the exceptions that occurred?
@@ -815,53 +791,4 @@
}
throw deleteFailed;
}
-
- @CheckForNull
- private static NoSuchFileException pathNotFound(Path path, Collection<IOException> exceptions) {
- if (exceptions.size() != 1) {
- return null;
- }
- IOException exception = getOnlyElement(exceptions);
- if (!(exception instanceof NoSuchFileException)) {
- return null;
- }
- NoSuchFileException noSuchFileException = (NoSuchFileException) exception;
- String exceptionFile = noSuchFileException.getFile();
- if (exceptionFile == null) {
- /*
- * It's not clear whether this happens in practice, especially with the filesystem
- * implementations that are built into java.nio.
- */
- return null;
- }
- Path parentPath = getParentPath(path);
- if (parentPath == null) {
- /*
- * This is probably impossible:
- *
- * - In deleteRecursively, we require the path argument to have a parent.
- *
- * - In deleteDirectoryContents, the path argument may have no parent. Fortunately, all the
- * *other* paths we process will be descendants of that. That leaves only the original path
- * argument for us to consider. And the only place we call pathNotFound is from
- * throwDeleteFailed, and the other place that we call throwDeleteFailed inside
- * deleteDirectoryContents is when an exception is thrown during the recursive steps. Any
- * failure during the initial lookup of the path argument itself is rethrown directly. So
- * any exception that we're seeing here is from a descendant, which naturally has a parent.
- * I think.
- *
- * Still, if this can happen somehow (a weird filesystem implementation that lets callers
- * change its working directly concurrently with a call to deleteDirectoryContents?), it makes
- * more sense for us to fall back to a generic FileSystemException (by returning null here)
- * than to dereference parentPath and end up producing NullPointerException.
- */
- return null;
- }
- // requireNonNull is safe because paths have file names when they have parents.
- Path pathResolvedFromParent = parentPath.resolve(requireNonNull(path.getFileName()));
- if (exceptionFile.equals(pathResolvedFromParent.toString())) {
- return noSuchFileException;
- }
- return null;
- }
}
diff --git a/guava/src/com/google/common/io/MultiInputStream.java b/guava/src/com/google/common/io/MultiInputStream.java
index 9a7e0fd..71a97d3 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 javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* An {@link InputStream} that concatenates multiple substreams. At most one stream will be open at
@@ -30,11 +30,10 @@
* @since 1.0
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
final class MultiInputStream extends InputStream {
private Iterator<? extends ByteSource> it;
- @CheckForNull private InputStream in;
+ private @Nullable InputStream in;
/**
* Creates a new instance.
@@ -91,8 +90,7 @@
}
@Override
- public int read(byte[] b, int off, int len) throws IOException {
- checkNotNull(b);
+ 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 cc36e52..135f32e 100644
--- a/guava/src/com/google/common/io/MultiReader.java
+++ b/guava/src/com/google/common/io/MultiReader.java
@@ -14,14 +14,12 @@
package com.google.common.io;
-import static com.google.common.base.Preconditions.checkNotNull;
-
import com.google.common.annotations.GwtIncompatible;
import com.google.common.base.Preconditions;
import java.io.IOException;
import java.io.Reader;
import java.util.Iterator;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* A {@link Reader} that concatenates multiple readers.
@@ -30,10 +28,9 @@
* @since 1.0
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
class MultiReader extends Reader {
private final Iterator<? extends CharSource> it;
- @CheckForNull private Reader current;
+ private @Nullable Reader current;
MultiReader(Iterator<? extends CharSource> readers) throws IOException {
this.it = readers;
@@ -49,8 +46,7 @@
}
@Override
- public int read(char[] cbuf, int off, int len) throws IOException {
- checkNotNull(cbuf);
+ 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/ParametricNullness.java b/guava/src/com/google/common/io/ParametricNullness.java
deleted file mode 100644
index afa0db1..0000000
--- a/guava/src/com/google/common/io/ParametricNullness.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2021 The Guava Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.common.io;
-
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.PARAMETER;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-import static javax.annotation.meta.When.UNKNOWN;
-
-import com.google.common.annotations.GwtCompatible;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-import javax.annotation.Nonnull;
-import javax.annotation.meta.TypeQualifierNickname;
-
-/**
- * Marks a "top-level" type-variable usage as (a) a Kotlin platform type when the type argument is
- * non-nullable and (b) nullable when the type argument is nullable. This is the closest we can get
- * to "non-nullable when non-nullable; nullable when nullable" (like the Android <a
- * href="https://android.googlesource.com/platform/libcore/+/master/luni/src/main/java/libcore/util/NullFromTypeParam.java">{@code
- * NullFromTypeParam}</a>). We use this to "undo" {@link ElementTypesAreNonnullByDefault}.
- */
-@GwtCompatible
-@Retention(RUNTIME)
-@Target({FIELD, METHOD, PARAMETER})
-@TypeQualifierNickname
-@Nonnull(when = UNKNOWN)
-@interface ParametricNullness {}
diff --git a/guava/src/com/google/common/io/PatternFilenameFilter.java b/guava/src/com/google/common/io/PatternFilenameFilter.java
index 3cb2371..4058e7d 100644
--- a/guava/src/com/google/common/io/PatternFilenameFilter.java
+++ b/guava/src/com/google/common/io/PatternFilenameFilter.java
@@ -21,6 +21,7 @@
import java.io.FilenameFilter;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* File name filter that only accepts files matching a regular expression. This class is thread-safe
@@ -31,7 +32,6 @@
*/
@Beta
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public final class PatternFilenameFilter implements FilenameFilter {
private final Pattern pattern;
@@ -55,21 +55,8 @@
this.pattern = Preconditions.checkNotNull(pattern);
}
- /*
- * Our implementation works fine with a null `dir`. However, there's nothing in the documentation
- * of the supertype that suggests that implementations are expected to tolerate null. That said, I
- * see calls in Google code that pass a null `dir` to a FilenameFilter.... So let's declare the
- * parameter as non-nullable (since passing null to a FilenameFilter is unsafe in general), but if
- * someone still manages to pass null, let's continue to have the method work.
- *
- * (PatternFilenameFilter is of course one of those classes that shouldn't be a publicly visible
- * class to begin with but rather something returned from a static factory method whose declared
- * return type is plain FilenameFilter. If we made such a change, then the annotation we choose
- * here would have no significance to end users, who would be forced to conform to the signature
- * used in FilenameFilter.)
- */
@Override
- public boolean accept(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/io/ReaderInputStream.java b/guava/src/com/google/common/io/ReaderInputStream.java
index 75f8a3e..eeb64e4 100644
--- a/guava/src/com/google/common/io/ReaderInputStream.java
+++ b/guava/src/com/google/common/io/ReaderInputStream.java
@@ -44,7 +44,6 @@
* @author Chris Nokleberg
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
final class ReaderInputStream extends InputStream {
private final Reader reader;
private final CharsetEncoder encoder;
diff --git a/guava/src/com/google/common/io/RecursiveDeleteOption.java b/guava/src/com/google/common/io/RecursiveDeleteOption.java
index 1bb27a1..20ec7d2 100644
--- a/guava/src/com/google/common/io/RecursiveDeleteOption.java
+++ b/guava/src/com/google/common/io/RecursiveDeleteOption.java
@@ -31,7 +31,6 @@
@Beta
@GwtIncompatible
@J2ObjCIncompatible // java.nio.file
-@ElementTypesAreNonnullByDefault
public enum RecursiveDeleteOption {
/**
* Specifies that the recursive delete should not throw an exception when it can't be guaranteed
diff --git a/guava/src/com/google/common/io/Resources.java b/guava/src/com/google/common/io/Resources.java
index cc595fc..d64bf3d 100644
--- a/guava/src/com/google/common/io/Resources.java
+++ b/guava/src/com/google/common/io/Resources.java
@@ -29,7 +29,6 @@
import java.net.URL;
import java.nio.charset.Charset;
import java.util.List;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Provides utility methods for working with resources in the classpath. Note that even though these
@@ -45,7 +44,6 @@
*/
@Beta
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public final class Resources {
private Resources() {}
@@ -123,9 +121,8 @@
* @throws IOException if an I/O error occurs
*/
@CanIgnoreReturnValue // some processors won't return a useful result
- @ParametricNullness
- public static <T extends @Nullable Object> T readLines(
- URL url, Charset charset, LineProcessor<T> callback) throws IOException {
+ public static <T> T readLines(URL url, Charset charset, LineProcessor<T> callback)
+ throws IOException {
return asCharSource(url, charset).readLines(callback);
}
diff --git a/guava/src/com/google/common/math/BigDecimalMath.java b/guava/src/com/google/common/math/BigDecimalMath.java
index 33a55d3..b5c23f8 100644
--- a/guava/src/com/google/common/math/BigDecimalMath.java
+++ b/guava/src/com/google/common/math/BigDecimalMath.java
@@ -25,7 +25,6 @@
* @since 30.0
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public class BigDecimalMath {
private BigDecimalMath() {}
diff --git a/guava/src/com/google/common/math/BigIntegerMath.java b/guava/src/com/google/common/math/BigIntegerMath.java
index 6ef1e81..bf443e9 100644
--- a/guava/src/com/google/common/math/BigIntegerMath.java
+++ b/guava/src/com/google/common/math/BigIntegerMath.java
@@ -48,7 +48,6 @@
* @since 11.0
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
public final class BigIntegerMath {
/**
* Returns the smallest power of two greater than or equal to {@code x}. This is equivalent to
diff --git a/guava/src/com/google/common/math/DoubleMath.java b/guava/src/com/google/common/math/DoubleMath.java
index cdd0a4b..8745e41 100644
--- a/guava/src/com/google/common/math/DoubleMath.java
+++ b/guava/src/com/google/common/math/DoubleMath.java
@@ -46,7 +46,6 @@
* @since 11.0
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
public final class DoubleMath {
/*
* This method returns a value y such that rounding y DOWN (towards zero) gives the same result as
@@ -433,7 +432,7 @@
@Deprecated
public static double mean(int... values) {
checkArgument(values.length > 0, "Cannot take mean of 0 values");
- // The upper bound on the length of an array and the bounds on the int values mean that, in
+ // The upper bound on the the length of an array and the bounds on the int values mean that, in
// this case only, we can compute the sum as a long without risking overflow or loss of
// precision. So we do that, as it's slightly quicker than the Knuth algorithm.
long sum = 0;
diff --git a/guava/src/com/google/common/math/DoubleUtils.java b/guava/src/com/google/common/math/DoubleUtils.java
index d4a07e9..4183195 100644
--- a/guava/src/com/google/common/math/DoubleUtils.java
+++ b/guava/src/com/google/common/math/DoubleUtils.java
@@ -33,7 +33,6 @@
* @author Louis Wasserman
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
final class DoubleUtils {
private DoubleUtils() {}
diff --git a/guava/src/com/google/common/math/ElementTypesAreNonnullByDefault.java b/guava/src/com/google/common/math/ElementTypesAreNonnullByDefault.java
deleted file mode 100644
index 84999ea..0000000
--- a/guava/src/com/google/common/math/ElementTypesAreNonnullByDefault.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) 2021 The Guava Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.common.math;
-
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.PARAMETER;
-import static java.lang.annotation.ElementType.TYPE;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-import com.google.common.annotations.GwtCompatible;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-import javax.annotation.Nonnull;
-import javax.annotation.meta.TypeQualifierDefault;
-
-/**
- * Marks all "top-level" types as non-null in a way that is recognized by Kotlin. Note that this
- * unfortunately includes type-variable usages, so we also provide {@link ParametricNullness} to
- * "undo" it as best we can.
- */
-@GwtCompatible
-@Retention(RUNTIME)
-@Target(TYPE)
-@TypeQualifierDefault({FIELD, METHOD, PARAMETER})
-@Nonnull
-@interface ElementTypesAreNonnullByDefault {}
diff --git a/guava/src/com/google/common/math/IntMath.java b/guava/src/com/google/common/math/IntMath.java
index 17a18c6..78aedda 100644
--- a/guava/src/com/google/common/math/IntMath.java
+++ b/guava/src/com/google/common/math/IntMath.java
@@ -48,7 +48,6 @@
* @since 11.0
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
public final class IntMath {
// NOTE: Whenever both tests are cheap and functional, it's faster to use &, | instead of &&, ||
diff --git a/guava/src/com/google/common/math/LinearTransformation.java b/guava/src/com/google/common/math/LinearTransformation.java
index 4cc1eb8..485b046 100644
--- a/guava/src/com/google/common/math/LinearTransformation.java
+++ b/guava/src/com/google/common/math/LinearTransformation.java
@@ -21,7 +21,6 @@
import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtIncompatible;
import com.google.errorprone.annotations.concurrent.LazyInit;
-import javax.annotation.CheckForNull;
/**
* The representation of a linear transformation between real numbers {@code x} and {@code y}.
@@ -36,7 +35,6 @@
*/
@Beta
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public abstract class LinearTransformation {
/**
@@ -163,7 +161,7 @@
final double slope;
final double yIntercept;
- @CheckForNull @LazyInit LinearTransformation inverse;
+ @LazyInit LinearTransformation inverse;
RegularLinearTransformation(double slope, double yIntercept) {
this.slope = slope;
@@ -221,7 +219,7 @@
final double x;
- @CheckForNull @LazyInit LinearTransformation inverse;
+ @LazyInit LinearTransformation inverse;
VerticalLinearTransformation(double x) {
this.x = x;
diff --git a/guava/src/com/google/common/math/LongMath.java b/guava/src/com/google/common/math/LongMath.java
index 1e67812..420b48a 100644
--- a/guava/src/com/google/common/math/LongMath.java
+++ b/guava/src/com/google/common/math/LongMath.java
@@ -49,7 +49,6 @@
* @since 11.0
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
public final class LongMath {
// NOTE: Whenever both tests are cheap and functional, it's faster to use &, | instead of &&, ||
diff --git a/guava/src/com/google/common/math/MathPreconditions.java b/guava/src/com/google/common/math/MathPreconditions.java
index 37d608a..ec860d0 100644
--- a/guava/src/com/google/common/math/MathPreconditions.java
+++ b/guava/src/com/google/common/math/MathPreconditions.java
@@ -18,6 +18,7 @@
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import java.math.BigInteger;
import java.math.RoundingMode;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* A collection of preconditions for math functions.
@@ -26,51 +27,50 @@
*/
@GwtCompatible
@CanIgnoreReturnValue
-@ElementTypesAreNonnullByDefault
final class MathPreconditions {
- static int checkPositive(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(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(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(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(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(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(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 31ab9b7..6b9c778 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 javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* An immutable value object capturing some basic statistics about a collection of paired double
@@ -39,7 +39,6 @@
*/
@Beta
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public final class PairedStats implements Serializable {
private final Stats xStats;
@@ -214,7 +213,7 @@
* guarantees {@code strictfp}-like semantics.)
*/
@Override
- public boolean equals(@CheckForNull Object obj) {
+ public boolean equals(@Nullable Object obj) {
if (obj == null) {
return false;
}
diff --git a/guava/src/com/google/common/math/PairedStatsAccumulator.java b/guava/src/com/google/common/math/PairedStatsAccumulator.java
index 072ef13..a988495 100644
--- a/guava/src/com/google/common/math/PairedStatsAccumulator.java
+++ b/guava/src/com/google/common/math/PairedStatsAccumulator.java
@@ -32,7 +32,6 @@
*/
@Beta
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public final class PairedStatsAccumulator {
// These fields must satisfy the requirements of PairedStats' constructor as well as those of the
diff --git a/guava/src/com/google/common/math/ParametricNullness.java b/guava/src/com/google/common/math/ParametricNullness.java
deleted file mode 100644
index c079b97..0000000
--- a/guava/src/com/google/common/math/ParametricNullness.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2021 The Guava Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.common.math;
-
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.PARAMETER;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-import static javax.annotation.meta.When.UNKNOWN;
-
-import com.google.common.annotations.GwtCompatible;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-import javax.annotation.Nonnull;
-import javax.annotation.meta.TypeQualifierNickname;
-
-/**
- * Marks a "top-level" type-variable usage as (a) a Kotlin platform type when the type argument is
- * non-nullable and (b) nullable when the type argument is nullable. This is the closest we can get
- * to "non-nullable when non-nullable; nullable when nullable" (like the Android <a
- * href="https://android.googlesource.com/platform/libcore/+/master/luni/src/main/java/libcore/util/NullFromTypeParam.java">{@code
- * NullFromTypeParam}</a>). We use this to "undo" {@link ElementTypesAreNonnullByDefault}.
- */
-@GwtCompatible
-@Retention(RUNTIME)
-@Target({FIELD, METHOD, PARAMETER})
-@TypeQualifierNickname
-@Nonnull(when = UNKNOWN)
-@interface ParametricNullness {}
diff --git a/guava/src/com/google/common/math/Quantiles.java b/guava/src/com/google/common/math/Quantiles.java
index 6ddea9b..7aac58f 100644
--- a/guava/src/com/google/common/math/Quantiles.java
+++ b/guava/src/com/google/common/math/Quantiles.java
@@ -128,7 +128,6 @@
*/
@Beta
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public final class Quantiles {
/** Specifies the computation of a median (i.e. the 1st 2-quantile). */
diff --git a/guava/src/com/google/common/math/Stats.java b/guava/src/com/google/common/math/Stats.java
index 20c9466..74537a7 100644
--- a/guava/src/com/google/common/math/Stats.java
+++ b/guava/src/com/google/common/math/Stats.java
@@ -36,7 +36,7 @@
import java.util.stream.DoubleStream;
import java.util.stream.IntStream;
import java.util.stream.LongStream;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* A bundle of statistical summary values -- sum, count, mean/average, min and max, and several
@@ -64,7 +64,6 @@
*/
@Beta
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public final class Stats implements Serializable {
private final long count;
@@ -417,7 +416,7 @@
* {@code strictfp}-like semantics.)
*/
@Override
- public boolean equals(@CheckForNull Object obj) {
+ public boolean equals(@Nullable Object obj) {
if (obj == null) {
return false;
}
diff --git a/guava/src/com/google/common/math/StatsAccumulator.java b/guava/src/com/google/common/math/StatsAccumulator.java
index b28229c..0670cb1 100644
--- a/guava/src/com/google/common/math/StatsAccumulator.java
+++ b/guava/src/com/google/common/math/StatsAccumulator.java
@@ -37,7 +37,6 @@
*/
@Beta
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public final class StatsAccumulator {
// These fields must satisfy the requirements of Stats' constructor as well as those of the stat
diff --git a/guava/src/com/google/common/math/ToDoubleRounder.java b/guava/src/com/google/common/math/ToDoubleRounder.java
index 2e7e7fa..7525e3f 100644
--- a/guava/src/com/google/common/math/ToDoubleRounder.java
+++ b/guava/src/com/google/common/math/ToDoubleRounder.java
@@ -25,7 +25,6 @@
* a {@link RoundingMode}.
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
abstract class ToDoubleRounder<X extends Number & Comparable<X>> {
/**
* Returns x rounded to either the greatest double less than or equal to the precise value of x,
diff --git a/guava/src/com/google/common/net/ElementTypesAreNonnullByDefault.java b/guava/src/com/google/common/net/ElementTypesAreNonnullByDefault.java
deleted file mode 100644
index d8cfd73..0000000
--- a/guava/src/com/google/common/net/ElementTypesAreNonnullByDefault.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) 2021 The Guava Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.common.net;
-
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.PARAMETER;
-import static java.lang.annotation.ElementType.TYPE;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-import com.google.common.annotations.GwtCompatible;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-import javax.annotation.Nonnull;
-import javax.annotation.meta.TypeQualifierDefault;
-
-/**
- * Marks all "top-level" types as non-null in a way that is recognized by Kotlin. Note that this
- * unfortunately includes type-variable usages, so we also provide {@link ParametricNullness} to
- * "undo" it as best we can.
- */
-@GwtCompatible
-@Retention(RUNTIME)
-@Target(TYPE)
-@TypeQualifierDefault({FIELD, METHOD, PARAMETER})
-@Nonnull
-@interface ElementTypesAreNonnullByDefault {}
diff --git a/guava/src/com/google/common/net/HostAndPort.java b/guava/src/com/google/common/net/HostAndPort.java
index 19e6b67..c01b87a 100644
--- a/guava/src/com/google/common/net/HostAndPort.java
+++ b/guava/src/com/google/common/net/HostAndPort.java
@@ -20,12 +20,11 @@
import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtCompatible;
-import com.google.common.base.CharMatcher;
import com.google.common.base.Objects;
import com.google.common.base.Strings;
import com.google.errorprone.annotations.Immutable;
import java.io.Serializable;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* An immutable representation of a host and port.
@@ -63,7 +62,6 @@
@Beta
@Immutable
@GwtCompatible
-@ElementTypesAreNonnullByDefault
public final class HostAndPort implements Serializable {
/** Magic value indicating the absence of a port number. */
private static final int NO_PORT = -1;
@@ -191,10 +189,7 @@
if (!Strings.isNullOrEmpty(portString)) {
// Try to parse the whole port string as a number.
// JDK7 accepts leading plus signs. We don't want to.
- checkArgument(
- !portString.startsWith("+") && CharMatcher.ascii().matchesAllOf(portString),
- "Unparseable port number: %s",
- hostPortString);
+ checkArgument(!portString.startsWith("+"), "Unparseable port number: %s", hostPortString);
try {
port = Integer.parseInt(portString);
} catch (NumberFormatException e) {
@@ -214,12 +209,14 @@
* @throws IllegalArgumentException if parsing the bracketed host-port string fails.
*/
private static String[] getHostAndPortFromBracketedHost(String hostPortString) {
+ int colonIndex = 0;
+ int closeBracketIndex = 0;
checkArgument(
hostPortString.charAt(0) == '[',
"Bracketed host-port string must start with a bracket: %s",
hostPortString);
- int colonIndex = hostPortString.indexOf(':');
- int closeBracketIndex = hostPortString.lastIndexOf(']');
+ colonIndex = hostPortString.indexOf(':');
+ closeBracketIndex = hostPortString.lastIndexOf(']');
checkArgument(
colonIndex > -1 && closeBracketIndex > colonIndex,
"Invalid bracketed host/port: %s",
@@ -280,7 +277,7 @@
}
@Override
- public boolean equals(@CheckForNull Object other) {
+ public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}
diff --git a/guava/src/com/google/common/net/HostSpecifier.java b/guava/src/com/google/common/net/HostSpecifier.java
index 7448944..bb523a0 100644
--- a/guava/src/com/google/common/net/HostSpecifier.java
+++ b/guava/src/com/google/common/net/HostSpecifier.java
@@ -19,7 +19,7 @@
import com.google.common.base.Preconditions;
import java.net.InetAddress;
import java.text.ParseException;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* A syntactically valid host specifier, suitable for use in a URI. This may be either a numeric IP
@@ -43,7 +43,6 @@
*/
@Beta
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public final class HostSpecifier {
private final String canonicalForm;
@@ -138,7 +137,7 @@
}
@Override
- public boolean equals(@CheckForNull Object other) {
+ public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}
diff --git a/guava/src/com/google/common/net/HttpHeaders.java b/guava/src/com/google/common/net/HttpHeaders.java
index f318da1..11a5b50 100644
--- a/guava/src/com/google/common/net/HttpHeaders.java
+++ b/guava/src/com/google/common/net/HttpHeaders.java
@@ -28,11 +28,11 @@
* <li><a href="http://www.ietf.org/rfc/rfc5988.txt">RFC 5988</a>
* </ul>
*
+ *
* @author Kurt Alfred Kluever
* @since 11.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
public final class HttpHeaders {
private HttpHeaders() {}
@@ -129,13 +129,6 @@
public static final String MAX_FORWARDS = "Max-Forwards";
/** The HTTP {@code Origin} header field name. */
public static final String ORIGIN = "Origin";
- /**
- * The HTTP <a href="https://github.com/WICG/origin-isolation">{@code Origin-Isolation}</a> header
- * field name.
- *
- * @since 30.1
- */
- public static final String ORIGIN_ISOLATION = "Origin-Isolation";
/** The HTTP {@code Proxy-Authorization} header field name. */
public static final String PROXY_AUTHORIZATION = "Proxy-Authorization";
/** The HTTP {@code Range} header field name. */
@@ -305,12 +298,6 @@
/** The HTTP {@code Location} header field name. */
public static final String LOCATION = "Location";
/**
- * The HTTP {@code Keep-Alive} header field name.
- *
- * @since 31.0
- */
- public static final String KEEP_ALIVE = "Keep-Alive";
- /**
* The HTTP <a href="https://googlechrome.github.io/OriginTrials/#header">{@code Origin-Trial}</a>
* header field name.
*
@@ -388,45 +375,6 @@
public static final String DNT = "DNT";
/** The HTTP {@code X-Content-Type-Options} header field name. */
public static final String X_CONTENT_TYPE_OPTIONS = "X-Content-Type-Options";
- /**
- * The HTTP <a
- * href="https://iabtechlab.com/wp-content/uploads/2019/06/VAST_4.2_final_june26.pdf">{@code
- * X-Device-IP}</a> header field name. Header used for VAST requests to provide the IP address of
- * the device on whose behalf the request is being made.
- *
- * @since 31.0
- */
- public static final String X_DEVICE_IP = "X-Device-IP";
- /**
- * The HTTP <a
- * href="https://iabtechlab.com/wp-content/uploads/2019/06/VAST_4.2_final_june26.pdf">{@code
- * X-Device-Referer}</a> header field name. Header used for VAST requests to provide the {@link
- * #REFERER} header value that the on-behalf-of client would have used when making a request
- * itself.
- *
- * @since 31.0
- */
- public static final String X_DEVICE_REFERER = "X-Device-Referer";
- /**
- * The HTTP <a
- * href="https://iabtechlab.com/wp-content/uploads/2019/06/VAST_4.2_final_june26.pdf">{@code
- * X-Device-Accept-Language}</a> header field name. Header used for VAST requests to provide the
- * {@link #ACCEPT_LANGUAGE} header value that the on-behalf-of client would have used when making
- * a request itself.
- *
- * @since 31.0
- */
- public static final String X_DEVICE_ACCEPT_LANGUAGE = "X-Device-Accept-Language";
- /**
- * The HTTP <a
- * href="https://iabtechlab.com/wp-content/uploads/2019/06/VAST_4.2_final_june26.pdf">{@code
- * X-Device-Requested-With}</a> header field name. Header used for VAST requests to provide the
- * {@link #X_REQUESTED_WITH} header value that the on-behalf-of client would have used when making
- * a request itself.
- *
- * @since 31.0
- */
- public static final String X_DEVICE_REQUESTED_WITH = "X-Device-Requested-With";
/** The HTTP {@code X-Do-Not-Track} header field name. */
public static final String X_DO_NOT_TRACK = "X-Do-Not-Track";
/** The HTTP {@code X-Forwarded-For} header field name (superseded by {@code Forwarded}). */
@@ -463,12 +411,6 @@
* @since 15.0
*/
@Beta public static final String PUBLIC_KEY_PINS_REPORT_ONLY = "Public-Key-Pins-Report-Only";
- /**
- * The HTTP {@code X-Request-ID} header field name.
- *
- * @since 30.1
- */
- public static final String X_REQUEST_ID = "X-Request-ID";
/** The HTTP {@code X-Requested-With} header field name. */
public static final String X_REQUESTED_WITH = "X-Requested-With";
/** The HTTP {@code X-User-IP} header field name. */
@@ -533,100 +475,6 @@
public static final String X_MOZ = "X-Moz";
/**
- * The HTTP <a
- * href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Device-Memory">{@code
- * Device-Memory}</a> header field name.
- *
- * @since 31.0
- */
- public static final String DEVICE_MEMORY = "Device-Memory";
-
- /**
- * The HTTP <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Downlink">{@code
- * Downlink}</a> header field name.
- *
- * @since 31.0
- */
- public static final String DOWNLINK = "Downlink";
-
- /**
- * The HTTP <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/ECT">{@code
- * ECT}</a> header field name.
- *
- * @since 31.0
- */
- public static final String ECT = "ECT";
-
- /**
- * The HTTP <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/RTT">{@code
- * RTT}</a> header field name.
- *
- * @since 31.0
- */
- public static final String RTT = "RTT";
-
- /**
- * The HTTP <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Save-Data">{@code
- * Save-Data}</a> header field name.
- *
- * @since 31.0
- */
- public static final String SAVE_DATA = "Save-Data";
-
- /**
- * The HTTP <a
- * href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Viewport-Width">{@code
- * Viewport-Width}</a> header field name.
- *
- * @since 31.0
- */
- public static final String VIEWPORT_WIDTH = "Viewport-Width";
-
- /**
- * The HTTP <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Width">{@code
- * Width}</a> header field name.
- *
- * @since 31.0
- */
- public static final String WIDTH = "Width";
-
- /**
- * The HTTP <a href="https://www.w3.org/TR/permissions-policy-1/">{@code Permissions-Policy}</a>
- * header field name.
- *
- * @since 31.0
- */
- public static final String PERMISSIONS_POLICY = "Permissions-Policy";
-
- /**
- * The HTTP <a
- * href="https://wicg.github.io/user-preference-media-features-headers/#sec-ch-prefers-color-scheme">{@code
- * Sec-CH-Prefers-Color-Scheme}</a> header field name.
- *
- * <p>This header is experimental.
- *
- * @since 31.0
- */
- public static final String SEC_CH_PREFERS_COLOR_SCHEME = "Sec-CH-Prefers-Color-Scheme";
-
- /**
- * The HTTP <a
- * href="https://www.rfc-editor.org/rfc/rfc8942#name-the-accept-ch-response-head">{@code
- * Accept-CH}</a> header field name.
- *
- * @since 31.0
- */
- public static final String ACCEPT_CH = "Accept-CH";
- /**
- * The HTTP <a
- * href="https://datatracker.ietf.org/doc/html/draft-davidben-http-client-hint-reliability-03.txt#section-3">{@code
- * Critical-CH}</a> header field name.
- *
- * @since 31.0
- */
- public static final String CRITICAL_CH = "Critical-CH";
-
- /**
* The HTTP <a href="https://wicg.github.io/ua-client-hints/#sec-ch-ua">{@code Sec-CH-UA}</a>
* header field name.
*
@@ -634,54 +482,47 @@
*/
public static final String SEC_CH_UA = "Sec-CH-UA";
/**
- * The HTTP <a href="https://wicg.github.io/ua-client-hints/#sec-ch-ua-arch">{@code
+ * The HTTP <a href="https://wicg.github.io/ua-client-hints/#sec-ch-arch">{@code
* Sec-CH-UA-Arch}</a> header field name.
*
* @since 30.0
*/
public static final String SEC_CH_UA_ARCH = "Sec-CH-UA-Arch";
/**
- * The HTTP <a href="https://wicg.github.io/ua-client-hints/#sec-ch-ua-model">{@code
+ * The HTTP <a href="https://wicg.github.io/ua-client-hints/#sec-ch-model">{@code
* Sec-CH-UA-Model}</a> header field name.
*
* @since 30.0
*/
public static final String SEC_CH_UA_MODEL = "Sec-CH-UA-Model";
/**
- * The HTTP <a href="https://wicg.github.io/ua-client-hints/#sec-ch-ua-platform">{@code
+ * The HTTP <a href="https://wicg.github.io/ua-client-hints/#sec-ch-platform">{@code
* Sec-CH-UA-Platform}</a> header field name.
*
* @since 30.0
*/
public static final String SEC_CH_UA_PLATFORM = "Sec-CH-UA-Platform";
/**
- * The HTTP <a href="https://wicg.github.io/ua-client-hints/#sec-ch-ua-platform-version">{@code
+ * The HTTP <a href="https://wicg.github.io/ua-client-hints/#sec-ch-platform-version">{@code
* Sec-CH-UA-Platform-Version}</a> header field name.
*
* @since 30.0
*/
public static final String SEC_CH_UA_PLATFORM_VERSION = "Sec-CH-UA-Platform-Version";
/**
- * The HTTP <a href="https://wicg.github.io/ua-client-hints/#sec-ch-ua-full-version">{@code
+ * The HTTP <a href="https://wicg.github.io/ua-client-hints/#sec-ch-full-version">{@code
* Sec-CH-UA-Full-Version}</a> header field name.
*
* @since 30.0
*/
public static final String SEC_CH_UA_FULL_VERSION = "Sec-CH-UA-Full-Version";
/**
- * The HTTP <a href="https://wicg.github.io/ua-client-hints/#sec-ch-ua-mobile">{@code
+ * The HTTP <a href="https://wicg.github.io/ua-client-hints/#sec-ch-mobile">{@code
* Sec-CH-UA-Mobile}</a> header field name.
*
* @since 30.0
*/
public static final String SEC_CH_UA_MOBILE = "Sec-CH-UA-Mobile";
- /**
- * The HTTP <a href="https://wicg.github.io/ua-client-hints/#sec-ch-ua-bitness">{@code
- * Sec-CH-UA-Bitness}</a> header field name.
- *
- * @since 31.0
- */
- public static final String SEC_CH_UA_BITNESS = "Sec-CH-UA-Bitness";
/**
* The HTTP <a href="https://w3c.github.io/webappsec-fetch-metadata/">{@code Sec-Fetch-Dest}</a>
diff --git a/guava/src/com/google/common/net/InetAddresses.java b/guava/src/com/google/common/net/InetAddresses.java
index 4e2aa69..d0881e8 100644
--- a/guava/src/com/google/common/net/InetAddresses.java
+++ b/guava/src/com/google/common/net/InetAddresses.java
@@ -32,7 +32,7 @@
import java.nio.ByteBuffer;
import java.util.Arrays;
import java.util.Locale;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Static utility methods pertaining to {@link InetAddress} instances.
@@ -97,7 +97,6 @@
*/
@Beta
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public final class InetAddresses {
private static final int IPV4_PART_COUNT = 4;
private static final int IPV6_PART_COUNT = 8;
@@ -134,11 +133,6 @@
*
* <p>Anything after a {@code %} in an IPv6 address is ignored (assumed to be a Scope ID).
*
- * <p>This method accepts non-ASCII digits, for example {@code "192.168.0.1"} (those are fullwidth
- * characters). That is consistent with {@link InetAddress}, but not with various RFCs. If you
- * want to accept ASCII digits only, you can use something like {@code
- * CharMatcher.ascii().matchesAllOf(ipString)}.
- *
* @param ipString {@code String} containing an IPv4 or IPv6 string literal, e.g. {@code
* "192.168.0.1"} or {@code "2001:db8::1"}
* @return {@link InetAddress} representing the argument
@@ -159,11 +153,6 @@
* Returns {@code true} if the supplied string is a valid IP string literal, {@code false}
* otherwise.
*
- * <p>This method accepts non-ASCII digits, for example {@code "192.168.0.1"} (those are fullwidth
- * characters). That is consistent with {@link InetAddress}, but not with various RFCs. If you
- * want to accept ASCII digits only, you can use something like {@code
- * CharMatcher.ascii().matchesAllOf(ipString)}.
- *
* @param ipString {@code String} to evaluated as an IP string literal
* @return {@code true} if the argument is a valid IP string literal
*/
@@ -172,9 +161,7 @@
}
/** Returns {@code null} if unable to parse into a {@code byte[]}. */
- @CheckForNull
- private static byte[] ipStringToBytes(String ipStringParam) {
- String ipString = ipStringParam;
+ private static byte @Nullable [] ipStringToBytes(String ipString) {
// Make a first pass to categorize the characters in this string.
boolean hasColon = false;
boolean hasDot = false;
@@ -217,8 +204,7 @@
return null;
}
- @CheckForNull
- private static byte[] textToNumericFormatV4(String ipString) {
+ private static byte @Nullable [] textToNumericFormatV4(String ipString) {
if (IPV4_DELIMITER_MATCHER.countIn(ipString) + 1 != IPV4_PART_COUNT) {
return null; // Wrong number of parts
}
@@ -243,8 +229,7 @@
return bytes;
}
- @CheckForNull
- private static byte[] textToNumericFormatV6(String ipString) {
+ private static byte @Nullable [] textToNumericFormatV6(String ipString) {
// An address can have [2..8] colons.
int delimiterCount = IPV6_DELIMITER_MATCHER.countIn(ipString);
if (delimiterCount < 2 || delimiterCount > IPV6_PART_COUNT) {
@@ -314,8 +299,7 @@
return rawBytes.array();
}
- @CheckForNull
- private static String convertDottedQuadToHex(String ipString) {
+ private static @Nullable String convertDottedQuadToHex(String ipString) {
int lastColon = ipString.lastIndexOf(':');
String initialPart = ipString.substring(0, lastColon + 1);
String dottedQuad = ipString.substring(lastColon + 1);
@@ -512,15 +496,10 @@
* Returns an InetAddress representing the literal IPv4 or IPv6 host portion of a URL, encoded in
* the format specified by RFC 3986 section 3.2.2.
*
- * <p>This method is similar to {@link InetAddresses#forString(String)}, however, it requires that
- * IPv6 addresses are surrounded by square brackets.
+ * <p>This function is similar to {@link InetAddresses#forString(String)}, however, it requires
+ * that IPv6 addresses are surrounded by square brackets.
*
- * <p>This method is the inverse of {@link InetAddresses#toUriString(java.net.InetAddress)}.
- *
- * <p>This method accepts non-ASCII digits, for example {@code "192.168.0.1"} (those are fullwidth
- * characters). That is consistent with {@link InetAddress}, but not with various RFCs. If you
- * want to accept ASCII digits only, you can use something like {@code
- * CharMatcher.ascii().matchesAllOf(ipString)}.
+ * <p>This function is the inverse of {@link InetAddresses#toUriString(java.net.InetAddress)}.
*
* @param hostAddr A RFC 3986 section 3.2.2 encoded IPv4 or IPv6 address
* @return an InetAddress representing the address in {@code hostAddr}
@@ -536,8 +515,7 @@
return addr;
}
- @CheckForNull
- private static InetAddress forUriStringNoThrow(String hostAddr) {
+ private static @Nullable InetAddress forUriStringNoThrow(String hostAddr) {
checkNotNull(hostAddr);
// Decide if this should be an IPv6 or IPv4 address.
@@ -564,11 +542,6 @@
* Returns {@code true} if the supplied string is a valid URI IP string literal, {@code false}
* otherwise.
*
- * <p>This method accepts non-ASCII digits, for example {@code "192.168.0.1"} (those are fullwidth
- * characters). That is consistent with {@link InetAddress}, but not with various RFCs. If you
- * want to accept ASCII digits only, you can use something like {@code
- * CharMatcher.ascii().matchesAllOf(ipString)}.
- *
* @param ipString {@code String} to evaluated as an IP URI host string literal
* @return {@code true} if the argument is a valid IP URI host
*/
@@ -685,7 +658,7 @@
*/
// TODO: why is this public?
public TeredoInfo(
- @CheckForNull Inet4Address server, @CheckForNull Inet4Address client, int port, int flags) {
+ @Nullable Inet4Address server, @Nullable Inet4Address client, int port, int flags) {
checkArgument(
(port >= 0) && (port <= 0xffff), "port '%s' is out of range (0 <= port <= 0xffff)", port);
checkArgument(
@@ -864,10 +837,6 @@
* obscure {@link Inet6Address} methods, but it would be unwise to depend on such a
* poorly-documented feature.)
*
- * <p>This method accepts non-ASCII digits. That is consistent with {@link InetAddress}, but not
- * with various RFCs. If you want to accept ASCII digits only, you can use something like {@code
- * CharMatcher.ascii().matchesAllOf(ipString)}.
- *
* @param ipString {@code String} to be examined for embedded IPv4-mapped IPv6 address format
* @return {@code true} if the argument is a valid "mapped" address
* @since 10.0
@@ -895,7 +864,7 @@
*
* <p>HACK: As long as applications continue to use IPv4 addresses for indexing into tables,
* accounting, et cetera, it may be necessary to <b>coerce</b> IPv6 addresses into IPv4 addresses.
- * This method does so by hashing 64 bits of the IPv6 address into {@code 224.0.0.0/3} (64 bits
+ * This function does so by hashing 64 bits of the IPv6 address into {@code 224.0.0.0/3} (64 bits
* into 29 bits):
*
* <ul>
@@ -905,7 +874,7 @@
*
* <p>A "coerced" IPv4 address is equivalent to itself.
*
- * <p>NOTE: This method is failsafe for security purposes: ALL IPv6 addresses (except localhost
+ * <p>NOTE: This function is failsafe for security purposes: ALL IPv6 addresses (except localhost
* (::1)) are hashed to avoid the security risk associated with extracting an embedded IPv4
* address that might permit elevated privileges.
*
@@ -943,7 +912,7 @@
}
// Many strategies for hashing are possible. This might suffice for now.
- int coercedHash = Hashing.murmur3_32_fixed().hashLong(addressAsLong).asInt();
+ int coercedHash = Hashing.murmur3_32().hashLong(addressAsLong).asInt();
// Squash into 224/4 Multicast and 240/4 Reserved space (i.e. 224/3).
coercedHash |= 0xe0000000;
@@ -1141,8 +1110,8 @@
*/
public static boolean isMaximum(InetAddress address) {
byte[] addr = address.getAddress();
- for (byte b : addr) {
- if (b != (byte) 0xff) {
+ for (int i = 0; i < addr.length; i++) {
+ if (addr[i] != (byte) 0xff) {
return false;
}
}
diff --git a/guava/src/com/google/common/net/InternetDomainName.java b/guava/src/com/google/common/net/InternetDomainName.java
index 5873449..c541413 100644
--- a/guava/src/com/google/common/net/InternetDomainName.java
+++ b/guava/src/com/google/common/net/InternetDomainName.java
@@ -30,7 +30,7 @@
import com.google.thirdparty.publicsuffix.PublicSuffixPatterns;
import com.google.thirdparty.publicsuffix.PublicSuffixType;
import java.util.List;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* An immutable well-formed internet domain name, such as {@code com} or {@code foo.co.uk}. Only
@@ -74,7 +74,6 @@
@Beta
@GwtCompatible(emulated = true)
@Immutable
-@ElementTypesAreNonnullByDefault
public final class InternetDomainName {
private static final CharMatcher DOTS_MATCHER = CharMatcher.anyOf(".\u3002\uFF0E\uFF61");
@@ -201,6 +200,7 @@
* href="https://tools.ietf.org/html/rfc1123#section-2">RFC 1123</a>.
* </ul>
*
+ *
* @param domain A domain name (not IP address)
* @throws IllegalArgumentException if {@code domain} is not syntactically valid according to
* {@link #isValid}
@@ -354,7 +354,6 @@
*
* @since 6.0
*/
- @CheckForNull
public InternetDomainName publicSuffix() {
return hasPublicSuffix() ? ancestor(publicSuffixIndex) : null;
}
@@ -463,7 +462,6 @@
*
* @since 23.3
*/
- @CheckForNull
public InternetDomainName registrySuffix() {
return hasRegistrySuffix() ? ancestor(registrySuffixIndex) : null;
}
@@ -624,7 +622,7 @@
* version of the same domain name would not be considered equal.
*/
@Override
- public boolean equals(@CheckForNull Object object) {
+ public boolean equals(@Nullable Object object) {
if (object == this) {
return true;
}
diff --git a/guava/src/com/google/common/net/MediaType.java b/guava/src/com/google/common/net/MediaType.java
index ca47161..f52f24e 100644
--- a/guava/src/com/google/common/net/MediaType.java
+++ b/guava/src/com/google/common/net/MediaType.java
@@ -45,7 +45,7 @@
import java.util.Collection;
import java.util.Map;
import java.util.Map.Entry;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Represents an <a href="http://en.wikipedia.org/wiki/Internet_media_type">Internet Media Type</a>
@@ -75,7 +75,6 @@
@Beta
@GwtCompatible
@Immutable
-@ElementTypesAreNonnullByDefault
public final class MediaType {
private static final String CHARSET_ATTRIBUTE = "charset";
private static final ImmutableListMultimap<String, String> UTF_8_CONSTANT_PARAMETERS =
@@ -764,11 +763,11 @@
private final String subtype;
private final ImmutableListMultimap<String, String> parameters;
- @LazyInit @CheckForNull private String toString;
+ @LazyInit private String toString;
@LazyInit private int hashCode;
- @LazyInit @CheckForNull private Optional<Charset> parsedCharset;
+ @LazyInit private Optional<Charset> parsedCharset;
private MediaType(String type, String subtype, ImmutableListMultimap<String, String> parameters) {
this.type = type;
@@ -1136,7 +1135,7 @@
}
@Override
- public boolean equals(@CheckForNull Object obj) {
+ public boolean equals(@Nullable Object obj) {
if (obj == this) {
return true;
} else if (obj instanceof MediaType) {
diff --git a/guava/src/com/google/common/net/ParametricNullness.java b/guava/src/com/google/common/net/ParametricNullness.java
deleted file mode 100644
index acc3eab..0000000
--- a/guava/src/com/google/common/net/ParametricNullness.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2021 The Guava Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.common.net;
-
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.PARAMETER;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-import static javax.annotation.meta.When.UNKNOWN;
-
-import com.google.common.annotations.GwtCompatible;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-import javax.annotation.Nonnull;
-import javax.annotation.meta.TypeQualifierNickname;
-
-/**
- * Marks a "top-level" type-variable usage as (a) a Kotlin platform type when the type argument is
- * non-nullable and (b) nullable when the type argument is nullable. This is the closest we can get
- * to "non-nullable when non-nullable; nullable when nullable" (like the Android <a
- * href="https://android.googlesource.com/platform/libcore/+/master/luni/src/main/java/libcore/util/NullFromTypeParam.java">{@code
- * NullFromTypeParam}</a>). We use this to "undo" {@link ElementTypesAreNonnullByDefault}.
- */
-@GwtCompatible
-@Retention(RUNTIME)
-@Target({FIELD, METHOD, PARAMETER})
-@TypeQualifierNickname
-@Nonnull(when = UNKNOWN)
-@interface ParametricNullness {}
diff --git a/guava/src/com/google/common/net/PercentEscaper.java b/guava/src/com/google/common/net/PercentEscaper.java
index 7c7de9b..554d04d 100644
--- a/guava/src/com/google/common/net/PercentEscaper.java
+++ b/guava/src/com/google/common/net/PercentEscaper.java
@@ -19,7 +19,6 @@
import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtCompatible;
import com.google.common.escape.UnicodeEscaper;
-import javax.annotation.CheckForNull;
/**
* A {@code UnicodeEscaper} that escapes some set of Java characters using a UTF-8 based percent
@@ -52,7 +51,6 @@
*/
@Beta
@GwtCompatible
-@ElementTypesAreNonnullByDefault
public final class PercentEscaper extends UnicodeEscaper {
// In some escapers spaces are escaped to '+'
@@ -157,7 +155,6 @@
/** Escapes the given Unicode code point in UTF-8. */
@Override
- @CheckForNull
protected char[] escape(int cp) {
// We should never get negative values here but if we do it will throw an
// IndexOutOfBoundsException, so at least it will get spotted.
diff --git a/guava/src/com/google/common/net/UrlEscapers.java b/guava/src/com/google/common/net/UrlEscapers.java
index c7e15ef..d4b9f94 100644
--- a/guava/src/com/google/common/net/UrlEscapers.java
+++ b/guava/src/com/google/common/net/UrlEscapers.java
@@ -24,12 +24,12 @@
* escaping with {@link com.google.common.html.HtmlEscapers} or {@link
* com.google.common.xml.XmlEscapers}.
*
+ *
* @author David Beaumont
* @author Chris Povirk
* @since 15.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
public final class UrlEscapers {
private UrlEscapers() {}
diff --git a/guava/src/com/google/common/primitives/Booleans.java b/guava/src/com/google/common/primitives/Booleans.java
index 522049b..11ce062 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 javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Static utility methods pertaining to {@code boolean} primitives, that are not already found in
@@ -42,7 +42,6 @@
* @since 1.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
public final class Booleans {
private Booleans() {}
@@ -409,14 +408,14 @@
}
@Override
- public boolean contains(@CheckForNull Object target) {
+ public boolean contains(Object target) {
// Overridden to prevent a ton of boxing
return (target instanceof Boolean)
&& Booleans.indexOf(array, (Boolean) target, start, end) != -1;
}
@Override
- public int indexOf(@CheckForNull Object target) {
+ public int indexOf(Object target) {
// Overridden to prevent a ton of boxing
if (target instanceof Boolean) {
int i = Booleans.indexOf(array, (Boolean) target, start, end);
@@ -428,7 +427,7 @@
}
@Override
- public int lastIndexOf(@CheckForNull Object target) {
+ public int lastIndexOf(Object target) {
// Overridden to prevent a ton of boxing
if (target instanceof Boolean) {
int i = Booleans.lastIndexOf(array, (Boolean) target, start, end);
@@ -459,7 +458,7 @@
}
@Override
- public boolean equals(@CheckForNull 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 62997f3..dd8aea0 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 javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Static utility methods pertaining to {@code byte} primitives, that are not already found in
@@ -44,7 +44,6 @@
// TODO(kevinb): how to prevent warning on UnsignedBytes when building GWT
// javadoc?
@GwtCompatible
-@ElementTypesAreNonnullByDefault
public final class Bytes {
private Bytes() {}
@@ -271,13 +270,13 @@
}
@Override
- public boolean contains(@CheckForNull Object target) {
+ public boolean contains(Object target) {
// Overridden to prevent a ton of boxing
return (target instanceof Byte) && Bytes.indexOf(array, (Byte) target, start, end) != -1;
}
@Override
- public int indexOf(@CheckForNull Object target) {
+ public int indexOf(Object target) {
// Overridden to prevent a ton of boxing
if (target instanceof Byte) {
int i = Bytes.indexOf(array, (Byte) target, start, end);
@@ -289,7 +288,7 @@
}
@Override
- public int lastIndexOf(@CheckForNull Object target) {
+ public int lastIndexOf(Object target) {
// Overridden to prevent a ton of boxing
if (target instanceof Byte) {
int i = Bytes.lastIndexOf(array, (Byte) target, start, end);
@@ -320,7 +319,7 @@
}
@Override
- public boolean equals(@CheckForNull 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 4a2e3a3..4cdc2ff 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 javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Static utility methods pertaining to {@code char} primitives, that are not already found in
@@ -46,7 +46,6 @@
* @since 1.0
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
public final class Chars {
private Chars() {}
@@ -541,14 +540,14 @@
}
@Override
- public boolean contains(@CheckForNull Object target) {
+ public boolean contains(Object target) {
// Overridden to prevent a ton of boxing
return (target instanceof Character)
&& Chars.indexOf(array, (Character) target, start, end) != -1;
}
@Override
- public int indexOf(@CheckForNull Object target) {
+ public int indexOf(Object target) {
// Overridden to prevent a ton of boxing
if (target instanceof Character) {
int i = Chars.indexOf(array, (Character) target, start, end);
@@ -560,7 +559,7 @@
}
@Override
- public int lastIndexOf(@CheckForNull Object target) {
+ public int lastIndexOf(Object target) {
// Overridden to prevent a ton of boxing
if (target instanceof Character) {
int i = Chars.lastIndexOf(array, (Character) target, start, end);
@@ -591,7 +590,7 @@
}
@Override
- public boolean equals(@CheckForNull 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 fab3cf6..0ef1b74 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.RandomAccess;
import java.util.Spliterator;
import java.util.Spliterators;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Static utility methods pertaining to {@code double} primitives, that are not already found in
@@ -49,7 +49,6 @@
* @since 1.0
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
public final class Doubles extends DoublesMethodsForWeb {
private Doubles() {}
@@ -561,14 +560,14 @@
}
@Override
- public boolean contains(@CheckForNull Object target) {
+ public boolean contains(Object target) {
// Overridden to prevent a ton of boxing
return (target instanceof Double)
&& Doubles.indexOf(array, (Double) target, start, end) != -1;
}
@Override
- public int indexOf(@CheckForNull Object target) {
+ public int indexOf(Object target) {
// Overridden to prevent a ton of boxing
if (target instanceof Double) {
int i = Doubles.indexOf(array, (Double) target, start, end);
@@ -580,7 +579,7 @@
}
@Override
- public int lastIndexOf(@CheckForNull Object target) {
+ public int lastIndexOf(Object target) {
// Overridden to prevent a ton of boxing
if (target instanceof Double) {
int i = Doubles.lastIndexOf(array, (Double) target, start, end);
@@ -611,7 +610,7 @@
}
@Override
- public boolean equals(@CheckForNull Object object) {
+ public boolean equals(@Nullable Object object) {
if (object == this) {
return true;
}
@@ -710,8 +709,7 @@
*/
@Beta
@GwtIncompatible // regular expressions
- @CheckForNull
- public static Double tryParse(String string) {
+ public static @Nullable Double tryParse(String string) {
if (FLOATING_POINT_PATTERN.matcher(string).matches()) {
// TODO(lowasser): could be potentially optimized, but only with
// extensive testing
diff --git a/guava/src/com/google/common/primitives/DoublesMethodsForWeb.java b/guava/src/com/google/common/primitives/DoublesMethodsForWeb.java
index 949cbe0..04d9651 100644
--- a/guava/src/com/google/common/primitives/DoublesMethodsForWeb.java
+++ b/guava/src/com/google/common/primitives/DoublesMethodsForWeb.java
@@ -21,5 +21,4 @@
* version.
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
abstract class DoublesMethodsForWeb {}
diff --git a/guava/src/com/google/common/primitives/ElementTypesAreNonnullByDefault.java b/guava/src/com/google/common/primitives/ElementTypesAreNonnullByDefault.java
deleted file mode 100644
index 44f6869..0000000
--- a/guava/src/com/google/common/primitives/ElementTypesAreNonnullByDefault.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) 2021 The Guava Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.common.primitives;
-
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.PARAMETER;
-import static java.lang.annotation.ElementType.TYPE;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-import com.google.common.annotations.GwtCompatible;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-import javax.annotation.Nonnull;
-import javax.annotation.meta.TypeQualifierDefault;
-
-/**
- * Marks all "top-level" types as non-null in a way that is recognized by Kotlin. Note that this
- * unfortunately includes type-variable usages, so we also provide {@link ParametricNullness} to
- * "undo" it as best we can.
- */
-@GwtCompatible
-@Retention(RUNTIME)
-@Target(TYPE)
-@TypeQualifierDefault({FIELD, METHOD, PARAMETER})
-@Nonnull
-@interface ElementTypesAreNonnullByDefault {}
diff --git a/guava/src/com/google/common/primitives/Floats.java b/guava/src/com/google/common/primitives/Floats.java
index b038cb2..fd5363b 100644
--- a/guava/src/com/google/common/primitives/Floats.java
+++ b/guava/src/com/google/common/primitives/Floats.java
@@ -34,7 +34,7 @@
import java.util.Comparator;
import java.util.List;
import java.util.RandomAccess;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Static utility methods pertaining to {@code float} primitives, that are not already found in
@@ -47,7 +47,6 @@
* @since 1.0
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
public final class Floats extends FloatsMethodsForWeb {
private Floats() {}
@@ -548,13 +547,13 @@
}
@Override
- public boolean contains(@CheckForNull Object target) {
+ public boolean contains(Object target) {
// Overridden to prevent a ton of boxing
return (target instanceof Float) && Floats.indexOf(array, (Float) target, start, end) != -1;
}
@Override
- public int indexOf(@CheckForNull Object target) {
+ public int indexOf(Object target) {
// Overridden to prevent a ton of boxing
if (target instanceof Float) {
int i = Floats.indexOf(array, (Float) target, start, end);
@@ -566,7 +565,7 @@
}
@Override
- public int lastIndexOf(@CheckForNull Object target) {
+ public int lastIndexOf(Object target) {
// Overridden to prevent a ton of boxing
if (target instanceof Float) {
int i = Floats.lastIndexOf(array, (Float) target, start, end);
@@ -597,7 +596,7 @@
}
@Override
- public boolean equals(@CheckForNull Object object) {
+ public boolean equals(@Nullable Object object) {
if (object == this) {
return true;
}
@@ -662,8 +661,7 @@
*/
@Beta
@GwtIncompatible // regular expressions
- @CheckForNull
- public static Float tryParse(String string) {
+ public static @Nullable Float tryParse(String string) {
if (Doubles.FLOATING_POINT_PATTERN.matcher(string).matches()) {
// TODO(lowasser): could be potentially optimized, but only with
// extensive testing
diff --git a/guava/src/com/google/common/primitives/FloatsMethodsForWeb.java b/guava/src/com/google/common/primitives/FloatsMethodsForWeb.java
index 801e2f3..acdb42f 100644
--- a/guava/src/com/google/common/primitives/FloatsMethodsForWeb.java
+++ b/guava/src/com/google/common/primitives/FloatsMethodsForWeb.java
@@ -21,5 +21,4 @@
* version.
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
abstract class FloatsMethodsForWeb {}
diff --git a/guava/src/com/google/common/primitives/ImmutableDoubleArray.java b/guava/src/com/google/common/primitives/ImmutableDoubleArray.java
index 9731c11..9d0f05c 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 javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* An immutable array of {@code double} values, with an API resembling {@link List}.
@@ -88,7 +88,6 @@
@Beta
@GwtCompatible
@Immutable
-@ElementTypesAreNonnullByDefault
public final class ImmutableDoubleArray implements Serializable {
private static final ImmutableDoubleArray EMPTY = new ImmutableDoubleArray(new double[0]);
@@ -484,17 +483,17 @@
}
@Override
- public boolean contains(@CheckForNull Object target) {
+ public boolean contains(Object target) {
return indexOf(target) >= 0;
}
@Override
- public int indexOf(@CheckForNull Object target) {
+ public int indexOf(Object target) {
return target instanceof Double ? parent.indexOf((Double) target) : -1;
}
@Override
- public int lastIndexOf(@CheckForNull Object target) {
+ public int lastIndexOf(Object target) {
return target instanceof Double ? parent.lastIndexOf((Double) target) : -1;
}
@@ -510,7 +509,7 @@
}
@Override
- public boolean equals(@CheckForNull Object object) {
+ public boolean equals(@Nullable Object object) {
if (object instanceof AsList) {
AsList that = (AsList) object;
return this.parent.equals(that.parent);
@@ -550,7 +549,7 @@
* values as this one, in the same order. Values are compared as if by {@link Double#equals}.
*/
@Override
- public boolean equals(@CheckForNull 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 cc3c671..643e609 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 javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* An immutable array of {@code int} values, with an API resembling {@link List}.
@@ -88,7 +88,6 @@
@Beta
@GwtCompatible
@Immutable
-@ElementTypesAreNonnullByDefault
public final class ImmutableIntArray implements Serializable {
private static final ImmutableIntArray EMPTY = new ImmutableIntArray(new int[0]);
@@ -479,17 +478,17 @@
}
@Override
- public boolean contains(@CheckForNull Object target) {
+ public boolean contains(Object target) {
return indexOf(target) >= 0;
}
@Override
- public int indexOf(@CheckForNull Object target) {
+ public int indexOf(Object target) {
return target instanceof Integer ? parent.indexOf((Integer) target) : -1;
}
@Override
- public int lastIndexOf(@CheckForNull Object target) {
+ public int lastIndexOf(Object target) {
return target instanceof Integer ? parent.lastIndexOf((Integer) target) : -1;
}
@@ -505,7 +504,7 @@
}
@Override
- public boolean equals(@CheckForNull Object object) {
+ public boolean equals(@Nullable Object object) {
if (object instanceof AsList) {
AsList that = (AsList) object;
return this.parent.equals(that.parent);
@@ -545,7 +544,7 @@
* values as this one, in the same order.
*/
@Override
- public boolean equals(@CheckForNull 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 c8f7037..dde8f80 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 javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* An immutable array of {@code long} values, with an API resembling {@link List}.
@@ -88,7 +88,6 @@
@Beta
@GwtCompatible
@Immutable
-@ElementTypesAreNonnullByDefault
public final class ImmutableLongArray implements Serializable {
private static final ImmutableLongArray EMPTY = new ImmutableLongArray(new long[0]);
@@ -481,17 +480,17 @@
}
@Override
- public boolean contains(@CheckForNull Object target) {
+ public boolean contains(Object target) {
return indexOf(target) >= 0;
}
@Override
- public int indexOf(@CheckForNull Object target) {
+ public int indexOf(Object target) {
return target instanceof Long ? parent.indexOf((Long) target) : -1;
}
@Override
- public int lastIndexOf(@CheckForNull Object target) {
+ public int lastIndexOf(Object target) {
return target instanceof Long ? parent.lastIndexOf((Long) target) : -1;
}
@@ -507,7 +506,7 @@
}
@Override
- public boolean equals(@CheckForNull Object object) {
+ public boolean equals(@Nullable Object object) {
if (object instanceof AsList) {
AsList that = (AsList) object;
return this.parent.equals(that.parent);
@@ -547,7 +546,7 @@
* values as this one, in the same order.
*/
@Override
- public boolean equals(@CheckForNull 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 b63b0f9..ad8c8c1 100644
--- a/guava/src/com/google/common/primitives/Ints.java
+++ b/guava/src/com/google/common/primitives/Ints.java
@@ -33,7 +33,7 @@
import java.util.RandomAccess;
import java.util.Spliterator;
import java.util.Spliterators;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Static utility methods pertaining to {@code int} primitives, that are not already found in either
@@ -46,7 +46,6 @@
* @since 1.0
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
public final class Ints extends IntsMethodsForWeb {
private Ints() {}
@@ -601,13 +600,13 @@
}
@Override
- public boolean contains(@CheckForNull Object target) {
+ public boolean contains(Object target) {
// Overridden to prevent a ton of boxing
return (target instanceof Integer) && Ints.indexOf(array, (Integer) target, start, end) != -1;
}
@Override
- public int indexOf(@CheckForNull Object target) {
+ public int indexOf(Object target) {
// Overridden to prevent a ton of boxing
if (target instanceof Integer) {
int i = Ints.indexOf(array, (Integer) target, start, end);
@@ -619,7 +618,7 @@
}
@Override
- public int lastIndexOf(@CheckForNull Object target) {
+ public int lastIndexOf(Object target) {
// Overridden to prevent a ton of boxing
if (target instanceof Integer) {
int i = Ints.lastIndexOf(array, (Integer) target, start, end);
@@ -650,7 +649,7 @@
}
@Override
- public boolean equals(@CheckForNull Object object) {
+ public boolean equals(@Nullable Object object) {
if (object == this) {
return true;
}
@@ -714,8 +713,7 @@
* @since 11.0
*/
@Beta
- @CheckForNull
- public static Integer tryParse(String string) {
+ public static @Nullable Integer tryParse(String string) {
return tryParse(string, 10);
}
@@ -740,8 +738,7 @@
* @since 19.0
*/
@Beta
- @CheckForNull
- public static Integer tryParse(String string, int radix) {
+ public static @Nullable Integer tryParse(String string, int radix) {
Long result = Longs.tryParse(string, radix);
if (result == null || result.longValue() != result.intValue()) {
return null;
diff --git a/guava/src/com/google/common/primitives/IntsMethodsForWeb.java b/guava/src/com/google/common/primitives/IntsMethodsForWeb.java
index c59c6b0..cb87bd2 100644
--- a/guava/src/com/google/common/primitives/IntsMethodsForWeb.java
+++ b/guava/src/com/google/common/primitives/IntsMethodsForWeb.java
@@ -21,5 +21,4 @@
* version.
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
abstract class IntsMethodsForWeb {}
diff --git a/guava/src/com/google/common/primitives/Longs.java b/guava/src/com/google/common/primitives/Longs.java
index 98c055e..e496f00 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 javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Static utility methods pertaining to {@code long} primitives, that are not already found in
@@ -45,7 +45,6 @@
* @since 1.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
public final class Longs {
private Longs() {}
@@ -364,8 +363,7 @@
* @since 14.0
*/
@Beta
- @CheckForNull
- public static Long tryParse(String string) {
+ public static @Nullable Long tryParse(String string) {
return tryParse(string, 10);
}
@@ -390,8 +388,7 @@
* @since 19.0
*/
@Beta
- @CheckForNull
- public static Long tryParse(String string, int radix) {
+ public static @Nullable Long tryParse(String string, int radix) {
if (checkNotNull(string).isEmpty()) {
return null;
}
@@ -697,13 +694,13 @@
}
@Override
- public boolean contains(@CheckForNull Object target) {
+ public boolean contains(Object target) {
// Overridden to prevent a ton of boxing
return (target instanceof Long) && Longs.indexOf(array, (Long) target, start, end) != -1;
}
@Override
- public int indexOf(@CheckForNull Object target) {
+ public int indexOf(Object target) {
// Overridden to prevent a ton of boxing
if (target instanceof Long) {
int i = Longs.indexOf(array, (Long) target, start, end);
@@ -715,7 +712,7 @@
}
@Override
- public int lastIndexOf(@CheckForNull Object target) {
+ public int lastIndexOf(Object target) {
// Overridden to prevent a ton of boxing
if (target instanceof Long) {
int i = Longs.lastIndexOf(array, (Long) target, start, end);
@@ -746,7 +743,7 @@
}
@Override
- public boolean equals(@CheckForNull Object object) {
+ public boolean equals(@Nullable Object object) {
if (object == this) {
return true;
}
diff --git a/guava/src/com/google/common/primitives/ParametricNullness.java b/guava/src/com/google/common/primitives/ParametricNullness.java
deleted file mode 100644
index 17d606c..0000000
--- a/guava/src/com/google/common/primitives/ParametricNullness.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2021 The Guava Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.common.primitives;
-
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.PARAMETER;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-import static javax.annotation.meta.When.UNKNOWN;
-
-import com.google.common.annotations.GwtCompatible;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-import javax.annotation.Nonnull;
-import javax.annotation.meta.TypeQualifierNickname;
-
-/**
- * Marks a "top-level" type-variable usage as (a) a Kotlin platform type when the type argument is
- * non-nullable and (b) nullable when the type argument is nullable. This is the closest we can get
- * to "non-nullable when non-nullable; nullable when nullable" (like the Android <a
- * href="https://android.googlesource.com/platform/libcore/+/master/luni/src/main/java/libcore/util/NullFromTypeParam.java">{@code
- * NullFromTypeParam}</a>). We use this to "undo" {@link ElementTypesAreNonnullByDefault}.
- */
-@GwtCompatible
-@Retention(RUNTIME)
-@Target({FIELD, METHOD, PARAMETER})
-@TypeQualifierNickname
-@Nonnull(when = UNKNOWN)
-@interface ParametricNullness {}
diff --git a/guava/src/com/google/common/primitives/ParseRequest.java b/guava/src/com/google/common/primitives/ParseRequest.java
index a102d69..97b0f1b 100644
--- a/guava/src/com/google/common/primitives/ParseRequest.java
+++ b/guava/src/com/google/common/primitives/ParseRequest.java
@@ -18,7 +18,6 @@
/** A string to be parsed as a number and the radix to interpret it in. */
@GwtCompatible
-@ElementTypesAreNonnullByDefault
final class ParseRequest {
final String rawValue;
final int radix;
diff --git a/guava/src/com/google/common/primitives/Platform.java b/guava/src/com/google/common/primitives/Platform.java
index ca31689..1273c04 100644
--- a/guava/src/com/google/common/primitives/Platform.java
+++ b/guava/src/com/google/common/primitives/Platform.java
@@ -18,7 +18,6 @@
/** Methods factored out so that they can be emulated differently in GWT. */
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
final class Platform {
private static final java.util.logging.Logger logger =
java.util.logging.Logger.getLogger(Platform.class.getName());
@@ -42,6 +41,7 @@
+ " warning because you are sending a Guava type over GWT-RPC, which will break. You"
+ " can identify which type by looking at the class name in the attached stack trace.",
new Throwable());
+
}
private Platform() {}
diff --git a/guava/src/com/google/common/primitives/Primitives.java b/guava/src/com/google/common/primitives/Primitives.java
index 7ceed03..1bdc740 100644
--- a/guava/src/com/google/common/primitives/Primitives.java
+++ b/guava/src/com/google/common/primitives/Primitives.java
@@ -30,7 +30,6 @@
* @since 1.0
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public final class Primitives {
private Primitives() {}
diff --git a/guava/src/com/google/common/primitives/Shorts.java b/guava/src/com/google/common/primitives/Shorts.java
index 09e0f7c..fa480dd 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 javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Static utility methods pertaining to {@code short} primitives, that are not already found in
@@ -44,7 +44,6 @@
* @since 1.0
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
public final class Shorts extends ShortsMethodsForWeb {
private Shorts() {}
@@ -593,13 +592,13 @@
}
@Override
- public boolean contains(@CheckForNull 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(@CheckForNull 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);
@@ -611,7 +610,7 @@
}
@Override
- public int lastIndexOf(@CheckForNull 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);
@@ -642,7 +641,7 @@
}
@Override
- public boolean equals(@CheckForNull Object object) {
+ public boolean equals(@Nullable Object object) {
if (object == this) {
return true;
}
diff --git a/guava/src/com/google/common/primitives/ShortsMethodsForWeb.java b/guava/src/com/google/common/primitives/ShortsMethodsForWeb.java
index bb0ff10..c362768 100644
--- a/guava/src/com/google/common/primitives/ShortsMethodsForWeb.java
+++ b/guava/src/com/google/common/primitives/ShortsMethodsForWeb.java
@@ -21,5 +21,4 @@
* version.
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
abstract class ShortsMethodsForWeb {}
diff --git a/guava/src/com/google/common/primitives/SignedBytes.java b/guava/src/com/google/common/primitives/SignedBytes.java
index 5fabaab..e475c41 100644
--- a/guava/src/com/google/common/primitives/SignedBytes.java
+++ b/guava/src/com/google/common/primitives/SignedBytes.java
@@ -36,7 +36,6 @@
// TODO(kevinb): how to prevent warning on UnsignedBytes when building GWT
// javadoc?
@GwtCompatible
-@ElementTypesAreNonnullByDefault
public final class SignedBytes {
private SignedBytes() {}
diff --git a/guava/src/com/google/common/primitives/UnsignedBytes.java b/guava/src/com/google/common/primitives/UnsignedBytes.java
index bf9a306..4275f8a 100644
--- a/guava/src/com/google/common/primitives/UnsignedBytes.java
+++ b/guava/src/com/google/common/primitives/UnsignedBytes.java
@@ -17,7 +17,6 @@
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkPositionIndexes;
-import static java.util.Objects.requireNonNull;
import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtIncompatible;
@@ -44,7 +43,6 @@
* @since 1.0
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public final class UnsignedBytes {
private UnsignedBytes() {}
@@ -439,12 +437,9 @@
try {
Class<?> theClass = Class.forName(UNSAFE_COMPARATOR_NAME);
- // requireNonNull is safe because the class is an enum.
- Object[] constants = requireNonNull(theClass.getEnumConstants());
-
// yes, UnsafeComparator does implement Comparator<byte[]>
@SuppressWarnings("unchecked")
- Comparator<byte[]> comparator = (Comparator<byte[]>) constants[0];
+ Comparator<byte[]> comparator = (Comparator<byte[]>) theClass.getEnumConstants()[0];
return comparator;
} catch (Throwable t) { // ensure we really catch *everything*
return lexicographicalComparatorJavaImpl();
diff --git a/guava/src/com/google/common/primitives/UnsignedInteger.java b/guava/src/com/google/common/primitives/UnsignedInteger.java
index 0b30cef..1796ac1 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 javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* A wrapper class for unsigned {@code int} values, supporting arithmetic operations.
@@ -39,7 +39,6 @@
* @since 11.0
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
public final class UnsignedInteger extends Number implements Comparable<UnsignedInteger> {
public static final UnsignedInteger ZERO = fromIntBits(0);
public static final UnsignedInteger ONE = fromIntBits(1);
@@ -227,7 +226,7 @@
}
@Override
- public boolean equals(@CheckForNull 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/UnsignedInts.java b/guava/src/com/google/common/primitives/UnsignedInts.java
index ec6474e..9eda969 100644
--- a/guava/src/com/google/common/primitives/UnsignedInts.java
+++ b/guava/src/com/google/common/primitives/UnsignedInts.java
@@ -47,7 +47,6 @@
*/
@Beta
@GwtCompatible
-@ElementTypesAreNonnullByDefault
public final class UnsignedInts {
static final long INT_MASK = 0xffffffffL;
diff --git a/guava/src/com/google/common/primitives/UnsignedLong.java b/guava/src/com/google/common/primitives/UnsignedLong.java
index d803634..07f785b 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 javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* A wrapper class for unsigned {@code long} values, supporting arithmetic operations.
@@ -38,7 +38,6 @@
* @since 11.0
*/
@GwtCompatible(serializable = true)
-@ElementTypesAreNonnullByDefault
public final class UnsignedLong extends Number implements Comparable<UnsignedLong>, Serializable {
private static final long UNSIGNED_MASK = 0x7fffffffffffffffL;
@@ -196,12 +195,12 @@
*/
@Override
public float floatValue() {
- if (value >= 0) {
- return (float) value;
+ @SuppressWarnings("cast")
+ float fValue = (float) (value & UNSIGNED_MASK);
+ if (value < 0) {
+ fValue += 0x1.0p63f;
}
- // The top bit is set, which means that the float value is going to come from the top 24 bits.
- // So we can ignore the bottom 8, except for rounding. See doubleValue() for more.
- return (float) ((value >>> 1) | (value & 1)) * 2f;
+ return fValue;
}
/**
@@ -210,15 +209,12 @@
*/
@Override
public double doubleValue() {
- if (value >= 0) {
- return (double) value;
+ @SuppressWarnings("cast")
+ double dValue = (double) (value & UNSIGNED_MASK);
+ if (value < 0) {
+ dValue += 0x1.0p63;
}
- // The top bit is set, which means that the double value is going to come from the top 53 bits.
- // So we can ignore the bottom 11, except for rounding. We can unsigned-shift right 1, aka
- // unsigned-divide by 2, and convert that. Then we'll get exactly half of the desired double
- // value. But in the specific case where the bottom two bits of the original number are 01, we
- // want to replace that with 1 in the shifted value for correct rounding.
- return (double) ((value >>> 1) | (value & 1)) * 2.0;
+ return dValue;
}
/** Returns the value of this {@code UnsignedLong} as a {@link BigInteger}. */
@@ -242,7 +238,7 @@
}
@Override
- public boolean equals(@CheckForNull 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/primitives/UnsignedLongs.java b/guava/src/com/google/common/primitives/UnsignedLongs.java
index 31c51cc..a1fccc2 100644
--- a/guava/src/com/google/common/primitives/UnsignedLongs.java
+++ b/guava/src/com/google/common/primitives/UnsignedLongs.java
@@ -50,7 +50,6 @@
*/
@Beta
@GwtCompatible
-@ElementTypesAreNonnullByDefault
public final class UnsignedLongs {
private UnsignedLongs() {}
diff --git a/guava/src/com/google/common/reflect/AbstractInvocationHandler.java b/guava/src/com/google/common/reflect/AbstractInvocationHandler.java
index 4666f99..45aea77 100644
--- a/guava/src/com/google/common/reflect/AbstractInvocationHandler.java
+++ b/guava/src/com/google/common/reflect/AbstractInvocationHandler.java
@@ -19,7 +19,6 @@
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.Arrays;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -40,7 +39,6 @@
* @since 12.0
*/
@Beta
-@ElementTypesAreNonnullByDefault
public abstract class AbstractInvocationHandler implements InvocationHandler {
private static final Object[] NO_ARGS = {};
@@ -61,8 +59,7 @@
* </ul>
*/
@Override
- @CheckForNull
- public final Object invoke(Object proxy, Method method, @CheckForNull @Nullable Object[] args)
+ public final Object invoke(Object proxy, Method method, Object @Nullable [] args)
throws Throwable {
if (args == null) {
args = NO_ARGS;
@@ -97,8 +94,7 @@
* <p>Unlike {@link #invoke}, {@code args} will never be null. When the method has no parameter,
* an empty array is passed in.
*/
- @CheckForNull
- protected abstract Object handleInvocation(Object proxy, Method method, @Nullable Object[] args)
+ protected abstract Object handleInvocation(Object proxy, Method method, Object[] args)
throws Throwable;
/**
@@ -113,7 +109,7 @@
* <p>Subclasses can override this method to provide custom equality.
*/
@Override
- public boolean equals(@CheckForNull Object obj) {
+ public boolean equals(Object obj) {
return super.equals(obj);
}
diff --git a/guava/src/com/google/common/reflect/ClassPath.java b/guava/src/com/google/common/reflect/ClassPath.java
index de693da..c4f9d0f 100644
--- a/guava/src/com/google/common/reflect/ClassPath.java
+++ b/guava/src/com/google/common/reflect/ClassPath.java
@@ -30,6 +30,9 @@
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Maps;
+import com.google.common.collect.MultimapBuilder;
+import com.google.common.collect.SetMultimap;
+import com.google.common.collect.Sets;
import com.google.common.io.ByteSource;
import com.google.common.io.CharSource;
import com.google.common.io.Resources;
@@ -51,40 +54,19 @@
import java.util.jar.JarFile;
import java.util.jar.Manifest;
import java.util.logging.Logger;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Scans the source of a {@link ClassLoader} and finds all loadable classes and resources.
*
- * <h2>Prefer <a href="https://github.com/classgraph/classgraph/wiki">ClassGraph</a> over {@code
- * ClassPath}</h2>
- *
- * <p>We recommend using <a href="https://github.com/classgraph/classgraph/wiki">ClassGraph</a>
- * instead of {@code ClassPath}. ClassGraph improves upon {@code ClassPath} in several ways,
- * including addressing many of its limitations. Limitations of {@code ClassPath} include:
+ * <p><b>Warning:</b> Current limitations:
*
* <ul>
- * <li>It looks only for files and JARs in URLs available from {@link URLClassLoader} instances or
- * the {@linkplain ClassLoader#getSystemClassLoader() system class loader}. This means it does
- * not look for classes in the <i>module path</i>.
- * <li>It understands only {@code file:} URLs. This means that it does not understand <a
- * href="https://openjdk.java.net/jeps/220">{@code jrt:/} URLs</a>, among <a
- * href="https://github.com/classgraph/classgraph/wiki/Classpath-specification-mechanisms">others</a>.
- * <li>It does not know how to look for classes when running under an Android VM. (ClassGraph does
- * not support this directly, either, but ClassGraph documents how to <a
- * href="https://github.com/classgraph/classgraph/wiki/Build-Time-Scanning">perform build-time
- * classpath scanning and make the results available to an Android app</a>.)
- * <li>Like all of Guava, it is not tested under Windows. We have gotten <a
- * href="https://github.com/google/guava/issues/2130">a report of a specific bug under
- * Windows</a>.
- * <li>It <a href="https://github.com/google/guava/issues/2712">returns only one resource for a
- * given path</a>, even if resources with that path appear in multiple jars or directories.
- * <li>It assumes that <a href="https://github.com/google/guava/issues/3349">any class with a
- * {@code $} in its name is a nested class</a>.
+ * <li>Looks only for files and JARs in URLs available from {@link URLClassLoader} instances or
+ * the {@linkplain ClassLoader#getSystemClassLoader() system class loader}.
+ * <li>Only understands {@code file:} URLs.
* </ul>
*
- * <h2>{@code ClassPath} and symlinks</h2>
- *
* <p>In the case of directory classloaders, symlinks are supported but cycles are not traversed.
* This guarantees discovery of each <em>unique</em> loadable resource. However, not all possible
* aliases for resources on cyclic paths will be listed.
@@ -93,10 +75,17 @@
* @since 14.0
*/
@Beta
-@ElementTypesAreNonnullByDefault
public final class ClassPath {
private static final Logger logger = Logger.getLogger(ClassPath.class.getName());
+ private static final Predicate<ClassInfo> IS_TOP_LEVEL =
+ new Predicate<ClassInfo>() {
+ @Override
+ public boolean apply(ClassInfo info) {
+ return info.className.indexOf('$') == -1;
+ }
+ };
+
/** Separator for the Class-Path manifest attribute value in jar files. */
private static final Splitter CLASS_PATH_ATTRIBUTE_SEPARATOR =
Splitter.on(" ").omitEmptyStrings();
@@ -126,21 +115,9 @@
* failed.
*/
public static ClassPath from(ClassLoader classloader) throws IOException {
- ImmutableSet<LocationInfo> locations = locationsFrom(classloader);
-
- // Add all locations to the scanned set so that in a classpath [jar1, jar2], where jar1 has a
- // manifest with Class-Path pointing to jar2, we won't scan jar2 twice.
- Set<File> scanned = new HashSet<>();
- for (LocationInfo location : locations) {
- scanned.add(location.file());
- }
-
- // Scan all locations
- ImmutableSet.Builder<ResourceInfo> builder = ImmutableSet.builder();
- for (LocationInfo location : locations) {
- builder.addAll(location.scanResources(scanned));
- }
- return new ClassPath(builder.build());
+ DefaultScanner scanner = new DefaultScanner();
+ scanner.scan(classloader);
+ return new ClassPath(scanner.getResources());
}
/**
@@ -160,21 +137,9 @@
return FluentIterable.from(resources).filter(ClassInfo.class).toSet();
}
- /**
- * Returns all top level classes loadable from the current class path. Note that "top-level-ness"
- * is determined heuristically by class name (see {@link ClassInfo#isTopLevel}).
- */
+ /** Returns all top level classes loadable from the current class path. */
public ImmutableSet<ClassInfo> getTopLevelClasses() {
- return FluentIterable.from(resources)
- .filter(ClassInfo.class)
- .filter(
- new Predicate<ClassInfo>() {
- @Override
- public boolean apply(ClassInfo info) {
- return info.isTopLevel();
- }
- })
- .toSet();
+ return FluentIterable.from(resources).filter(ClassInfo.class).filter(IS_TOP_LEVEL).toSet();
}
/** Returns all top level classes whose package name is {@code packageName}. */
@@ -287,7 +252,7 @@
}
@Override
- public boolean equals(@CheckForNull Object obj) {
+ public boolean equals(Object obj) {
if (obj instanceof ResourceInfo) {
ResourceInfo that = (ResourceInfo) obj;
return resourceName.equals(that.resourceName) && loader == that.loader;
@@ -319,13 +284,8 @@
/**
* Returns the package name of the class, without attempting to load the class.
*
- * <p>Behaves similarly to {@code class.getPackage().}{@link Package#getName() getName()} but
- * does not require the class (or package) to be loaded.
- *
- * <p>But note that this method may behave differently for a class in the default package: For
- * such classes, this method always returns an empty string. But under some version of Java,
- * {@code class.getPackage().getName()} produces a {@code NullPointerException} because {@code
- * class.getPackage()} returns {@code null}.
+ * <p>Behaves identically to {@link Package#getName()} but does not require the class (or
+ * package) to be loaded.
*/
public String getPackageName() {
return Reflection.getPackageName(className);
@@ -334,11 +294,8 @@
/**
* Returns the simple name of the underlying class as given in the source code.
*
- * <p>Behaves similarly to {@link Class#getSimpleName()} but does not require the class to be
+ * <p>Behaves identically to {@link Class#getSimpleName()} but does not require the class to be
* loaded.
- *
- * <p>But note that this class uses heuristics to identify the simple name. See a related
- * discussion in <a href="https://github.com/google/guava/issues/3349">issue 3349</a>.
*/
public String getSimpleName() {
int lastDollarSign = className.lastIndexOf('$');
@@ -368,18 +325,6 @@
}
/**
- * Returns true if the class name "looks to be" top level (not nested), that is, it includes no
- * '$' in the name. This method may return false for a top-level class that's intentionally
- * named with the '$' character. If this is a concern, you could use {@link #load} and then
- * check on the loaded {@link Class} object instead.
- *
- * @since 30.1
- */
- public boolean isTopLevel() {
- return className.indexOf('$') == -1;
- }
-
- /**
* Loads (but doesn't link or initialize) the class.
*
* @throws LinkageError when there were errors in loading classes that this class depends on.
@@ -401,64 +346,36 @@
}
/**
- * Returns all locations that {@code classloader} and parent loaders load classes and resources
- * from. Callers can {@linkplain LocationInfo#scanResources scan} individual locations selectively
- * or even in parallel.
+ * Abstract class that scans through the class path represented by a {@link ClassLoader} and calls
+ * {@link #scanDirectory} and {@link #scanJarFile} for directories and jar files on the class path
+ * respectively.
*/
- static ImmutableSet<LocationInfo> locationsFrom(ClassLoader classloader) {
- ImmutableSet.Builder<LocationInfo> builder = ImmutableSet.builder();
- for (Map.Entry<File, ClassLoader> entry : getClassPathEntries(classloader).entrySet()) {
- builder.add(new LocationInfo(entry.getKey(), entry.getValue()));
- }
- return builder.build();
- }
+ abstract static class Scanner {
- /**
- * Represents a single location (a directory or a jar file) in the class path and is responsible
- * for scanning resources from this location.
- */
- static final class LocationInfo {
- final File home;
- private final ClassLoader classloader;
+ // We only scan each file once independent of the classloader that resource might be associated
+ // with. Use concurrent set so that subclasses can be thread-safe.
+ private final Set<File> scannedUris = Sets.newConcurrentHashSet();
- LocationInfo(File home, ClassLoader classloader) {
- this.home = checkNotNull(home);
- this.classloader = checkNotNull(classloader);
+ public final void scan(ClassLoader classloader) throws IOException {
+ for (Map.Entry<File, ClassLoader> entry : getClassPathEntries(classloader).entrySet()) {
+ scan(entry.getKey(), entry.getValue());
+ }
}
- /** Returns the file this location is from. */
- public final File file() {
- return home;
- }
-
- /** Scans this location and returns all scanned resources. */
- public ImmutableSet<ResourceInfo> scanResources() throws IOException {
- return scanResources(new HashSet<File>());
+ @VisibleForTesting
+ final void scan(File file, ClassLoader classloader) throws IOException {
+ if (scannedUris.add(file.getCanonicalFile())) {
+ scanFrom(file, classloader);
+ }
}
/**
- * Scans this location and returns all scanned resources.
- *
- * <p>This file and jar files from "Class-Path" entry in the scanned manifest files will be
- * added to {@code scannedFiles}.
- *
- * <p>A file will be scanned at most once even if specified multiple times by one or multiple
- * jar files' "Class-Path" manifest entries. Particularly, if a jar file from the "Class-Path"
- * manifest entry is already in {@code scannedFiles}, either because it was scanned earlier, or
- * it was intentionally added to the set by the caller, it will not be scanned again.
- *
- * <p>Note that when you call {@code location.scanResources(scannedFiles)}, the location will
- * always be scanned even if {@code scannedFiles} already contains it.
+ * Called each time a resource (uniqueness not guaranteed if the class path includes redundant
+ * entries)
*/
- public ImmutableSet<ResourceInfo> scanResources(Set<File> scannedFiles) throws IOException {
- ImmutableSet.Builder<ResourceInfo> builder = ImmutableSet.builder();
- scannedFiles.add(home);
- scan(home, scannedFiles, builder);
- return builder.build();
- }
+ protected abstract void scanResource(ResourceInfo resource) throws IOException;
- private void scan(File file, Set<File> scannedUris, ImmutableSet.Builder<ResourceInfo> builder)
- throws IOException {
+ protected void scanFrom(File file, ClassLoader classloader) throws IOException {
try {
if (!file.exists()) {
return;
@@ -469,15 +386,13 @@
return;
}
if (file.isDirectory()) {
- scanDirectory(file, builder);
+ scanDirectory(classloader, file);
} else {
- scanJar(file, scannedUris, builder);
+ scanJar(file, classloader);
}
}
- private void scanJar(
- File file, Set<File> scannedUris, ImmutableSet.Builder<ResourceInfo> builder)
- throws IOException {
+ private void scanJar(File file, ClassLoader classloader) throws IOException {
JarFile jarFile;
try {
jarFile = new JarFile(file);
@@ -487,37 +402,127 @@
}
try {
for (File path : getClassPathFromManifest(file, jarFile.getManifest())) {
- // We only scan each file once independent of the classloader that file might be
- // associated with.
- if (scannedUris.add(path.getCanonicalFile())) {
- scan(path, scannedUris, builder);
- }
+ scan(path, classloader);
}
- scanJarFile(jarFile, builder);
+ scanJarFile(classloader, jarFile);
} finally {
try {
jarFile.close();
- } catch (IOException ignored) { // similar to try-with-resources, but don't fail scanning
+ } catch (IOException ignored) {
}
}
}
- private void scanJarFile(JarFile file, ImmutableSet.Builder<ResourceInfo> builder) {
+ /**
+ * Returns the class path URIs specified by the {@code Class-Path} manifest attribute, according
+ * to <a
+ * href="http://docs.oracle.com/javase/8/docs/technotes/guides/jar/jar.html#Main_Attributes">JAR
+ * File Specification</a>. If {@code manifest} is null, it means the jar file has no manifest,
+ * and an empty set will be returned.
+ */
+ @VisibleForTesting
+ static ImmutableSet<File> getClassPathFromManifest(File jarFile, @Nullable Manifest manifest) {
+ if (manifest == null) {
+ return ImmutableSet.of();
+ }
+ ImmutableSet.Builder<File> builder = ImmutableSet.builder();
+ String classpathAttribute =
+ manifest.getMainAttributes().getValue(Attributes.Name.CLASS_PATH.toString());
+ if (classpathAttribute != null) {
+ for (String path : CLASS_PATH_ATTRIBUTE_SEPARATOR.split(classpathAttribute)) {
+ URL url;
+ try {
+ url = getClassPathEntry(jarFile, path);
+ } catch (MalformedURLException e) {
+ // Ignore bad entry
+ logger.warning("Invalid Class-Path entry: " + path);
+ continue;
+ }
+ if (url.getProtocol().equals("file")) {
+ builder.add(toFile(url));
+ }
+ }
+ }
+ return builder.build();
+ }
+
+ @VisibleForTesting
+ static ImmutableMap<File, ClassLoader> getClassPathEntries(ClassLoader classloader) {
+ LinkedHashMap<File, ClassLoader> entries = Maps.newLinkedHashMap();
+ // Search parent first, since it's the order ClassLoader#loadClass() uses.
+ ClassLoader parent = classloader.getParent();
+ if (parent != null) {
+ entries.putAll(getClassPathEntries(parent));
+ }
+ for (URL url : getClassLoaderUrls(classloader)) {
+ if (url.getProtocol().equals("file")) {
+ File file = toFile(url);
+ if (!entries.containsKey(file)) {
+ entries.put(file, classloader);
+ }
+ }
+ }
+ return ImmutableMap.copyOf(entries);
+ }
+
+ private static ImmutableList<URL> getClassLoaderUrls(ClassLoader classloader) {
+ if (classloader instanceof URLClassLoader) {
+ return ImmutableList.copyOf(((URLClassLoader) classloader).getURLs());
+ }
+ if (classloader.equals(ClassLoader.getSystemClassLoader())) {
+ return parseJavaClassPath();
+ }
+ return ImmutableList.of();
+ }
+
+ /**
+ * Returns the URLs in the class path specified by the {@code java.class.path} {@linkplain
+ * System#getProperty system property}.
+ */
+ @VisibleForTesting // TODO(b/65488446): Make this a public API.
+ static ImmutableList<URL> parseJavaClassPath() {
+ ImmutableList.Builder<URL> urls = ImmutableList.builder();
+ for (String entry : Splitter.on(PATH_SEPARATOR.value()).split(JAVA_CLASS_PATH.value())) {
+ try {
+ try {
+ urls.add(new File(entry).toURI().toURL());
+ } catch (SecurityException e) { // File.toURI checks to see if the file is a directory
+ urls.add(new URL("file", null, new File(entry).getAbsolutePath()));
+ }
+ } catch (MalformedURLException e) {
+ logger.log(WARNING, "malformed classpath entry: " + entry, e);
+ }
+ }
+ return urls.build();
+ }
+
+ /**
+ * Returns the absolute uri of the Class-Path entry value as specified in <a
+ * href="http://docs.oracle.com/javase/8/docs/technotes/guides/jar/jar.html#Main_Attributes">JAR
+ * File Specification</a>. Even though the specification only talks about relative urls,
+ * absolute urls are actually supported too (for example, in Maven surefire plugin).
+ */
+ @VisibleForTesting
+ static URL getClassPathEntry(File jarFile, String path) throws MalformedURLException {
+ return new URL(jarFile.toURI().toURL(), path);
+ }
+
+ @VisibleForTesting
+ void scanJarFile(ClassLoader classloader, JarFile file) throws IOException {
Enumeration<JarEntry> entries = file.entries();
while (entries.hasMoreElements()) {
JarEntry entry = entries.nextElement();
if (entry.isDirectory() || entry.getName().equals(JarFile.MANIFEST_NAME)) {
continue;
}
- builder.add(ResourceInfo.of(new File(file.getName()), entry.getName(), classloader));
+ scanResource(ResourceInfo.of(new File(file.getName()), entry.getName(), classloader));
}
}
- private void scanDirectory(File directory, ImmutableSet.Builder<ResourceInfo> builder)
- throws IOException {
+ private void scanDirectory(ClassLoader classloader, File directory) throws IOException {
Set<File> currentPath = new HashSet<>();
currentPath.add(directory.getCanonicalFile());
- scanDirectory(directory, "", currentPath, builder);
+ scanDirectory(directory, classloader, "", currentPath);
}
/**
@@ -526,16 +531,14 @@
* cycles; otherwise symlinks are traversed.
*
* @param directory the root of the directory to scan
+ * @param classloader the classloader that includes resources found in {@code directory}
* @param packagePrefix resource path prefix inside {@code classloader} for any files found
* under {@code directory}
* @param currentPath canonical files already visited in the current directory tree path, for
* cycle elimination
*/
private void scanDirectory(
- File directory,
- String packagePrefix,
- Set<File> currentPath,
- ImmutableSet.Builder<ResourceInfo> builder)
+ File directory, ClassLoader classloader, String packagePrefix, Set<File> currentPath)
throws IOException {
File[] files = directory.listFiles();
if (files == null) {
@@ -548,131 +551,32 @@
if (f.isDirectory()) {
File deref = f.getCanonicalFile();
if (currentPath.add(deref)) {
- scanDirectory(deref, packagePrefix + name + "/", currentPath, builder);
+ scanDirectory(deref, classloader, packagePrefix + name + "/", currentPath);
currentPath.remove(deref);
}
} else {
String resourceName = packagePrefix + name;
if (!resourceName.equals(JarFile.MANIFEST_NAME)) {
- builder.add(ResourceInfo.of(f, resourceName, classloader));
+ scanResource(ResourceInfo.of(f, resourceName, classloader));
}
}
}
}
-
- @Override
- public boolean equals(@CheckForNull Object obj) {
- if (obj instanceof LocationInfo) {
- LocationInfo that = (LocationInfo) obj;
- return home.equals(that.home) && classloader.equals(that.classloader);
- }
- return false;
- }
-
- @Override
- public int hashCode() {
- return home.hashCode();
- }
-
- @Override
- public String toString() {
- return home.toString();
- }
- }
-
- /**
- * Returns the class path URIs specified by the {@code Class-Path} manifest attribute, according
- * to <a
- * href="http://docs.oracle.com/javase/8/docs/technotes/guides/jar/jar.html#Main_Attributes">JAR
- * File Specification</a>. If {@code manifest} is null, it means the jar file has no manifest, and
- * an empty set will be returned.
- */
- @VisibleForTesting
- static ImmutableSet<File> getClassPathFromManifest(
- File jarFile, @CheckForNull Manifest manifest) {
- if (manifest == null) {
- return ImmutableSet.of();
- }
- ImmutableSet.Builder<File> builder = ImmutableSet.builder();
- String classpathAttribute =
- manifest.getMainAttributes().getValue(Attributes.Name.CLASS_PATH.toString());
- if (classpathAttribute != null) {
- for (String path : CLASS_PATH_ATTRIBUTE_SEPARATOR.split(classpathAttribute)) {
- URL url;
- try {
- url = getClassPathEntry(jarFile, path);
- } catch (MalformedURLException e) {
- // Ignore bad entry
- logger.warning("Invalid Class-Path entry: " + path);
- continue;
- }
- if (url.getProtocol().equals("file")) {
- builder.add(toFile(url));
- }
- }
- }
- return builder.build();
}
@VisibleForTesting
- static ImmutableMap<File, ClassLoader> getClassPathEntries(ClassLoader classloader) {
- LinkedHashMap<File, ClassLoader> entries = Maps.newLinkedHashMap();
- // Search parent first, since it's the order ClassLoader#loadClass() uses.
- ClassLoader parent = classloader.getParent();
- if (parent != null) {
- entries.putAll(getClassPathEntries(parent));
- }
- for (URL url : getClassLoaderUrls(classloader)) {
- if (url.getProtocol().equals("file")) {
- File file = toFile(url);
- if (!entries.containsKey(file)) {
- entries.put(file, classloader);
- }
- }
- }
- return ImmutableMap.copyOf(entries);
- }
+ static final class DefaultScanner extends Scanner {
+ private final SetMultimap<ClassLoader, ResourceInfo> resources =
+ MultimapBuilder.hashKeys().linkedHashSetValues().build();
- private static ImmutableList<URL> getClassLoaderUrls(ClassLoader classloader) {
- if (classloader instanceof URLClassLoader) {
- return ImmutableList.copyOf(((URLClassLoader) classloader).getURLs());
+ ImmutableSet<ResourceInfo> getResources() {
+ return ImmutableSet.copyOf(resources.values());
}
- if (classloader.equals(ClassLoader.getSystemClassLoader())) {
- return parseJavaClassPath();
- }
- return ImmutableList.of();
- }
- /**
- * Returns the URLs in the class path specified by the {@code java.class.path} {@linkplain
- * System#getProperty system property}.
- */
- @VisibleForTesting // TODO(b/65488446): Make this a public API.
- static ImmutableList<URL> parseJavaClassPath() {
- ImmutableList.Builder<URL> urls = ImmutableList.builder();
- for (String entry : Splitter.on(PATH_SEPARATOR.value()).split(JAVA_CLASS_PATH.value())) {
- try {
- try {
- urls.add(new File(entry).toURI().toURL());
- } catch (SecurityException e) { // File.toURI checks to see if the file is a directory
- urls.add(new URL("file", null, new File(entry).getAbsolutePath()));
- }
- } catch (MalformedURLException e) {
- logger.log(WARNING, "malformed classpath entry: " + entry, e);
- }
+ @Override
+ protected void scanResource(ResourceInfo resource) {
+ resources.put(resource.loader, resource);
}
- return urls.build();
- }
-
- /**
- * Returns the absolute uri of the Class-Path entry value as specified in <a
- * href="http://docs.oracle.com/javase/8/docs/technotes/guides/jar/jar.html#Main_Attributes">JAR
- * File Specification</a>. Even though the specification only talks about relative urls, absolute
- * urls are actually supported too (for example, in Maven surefire plugin).
- */
- @VisibleForTesting
- static URL getClassPathEntry(File jarFile, String path) throws MalformedURLException {
- return new URL(jarFile.toURI().toURL(), path);
}
@VisibleForTesting
diff --git a/guava/src/com/google/common/reflect/Element.java b/guava/src/com/google/common/reflect/Element.java
new file mode 100644
index 0000000..c63c09a
--- /dev/null
+++ b/guava/src/com/google/common/reflect/Element.java
@@ -0,0 +1,178 @@
+/*
+ * Copyright (C) 2012 The Guava Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package com.google.common.reflect;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.AccessibleObject;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.Member;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import org.checkerframework.checker.nullness.qual.Nullable;
+
+/**
+ * Represents either a {@link Field}, a {@link Method} or a {@link Constructor}. Provides
+ * convenience methods such as {@link #isPublic} and {@link #isPackagePrivate}.
+ *
+ * @author Ben Yu
+ */
+class Element extends AccessibleObject implements Member {
+
+ private final AccessibleObject accessibleObject;
+ private final Member member;
+
+ <M extends AccessibleObject & Member> Element(M member) {
+ checkNotNull(member);
+ this.accessibleObject = member;
+ this.member = member;
+ }
+
+ public TypeToken<?> getOwnerType() {
+ return TypeToken.of(getDeclaringClass());
+ }
+
+ @Override
+ public final boolean isAnnotationPresent(Class<? extends Annotation> annotationClass) {
+ return accessibleObject.isAnnotationPresent(annotationClass);
+ }
+
+ @Override
+ public final <A extends Annotation> A getAnnotation(Class<A> annotationClass) {
+ return accessibleObject.getAnnotation(annotationClass);
+ }
+
+ @Override
+ public final Annotation[] getAnnotations() {
+ return accessibleObject.getAnnotations();
+ }
+
+ @Override
+ public final Annotation[] getDeclaredAnnotations() {
+ return accessibleObject.getDeclaredAnnotations();
+ }
+
+ @Override
+ public final void setAccessible(boolean flag) throws SecurityException {
+ accessibleObject.setAccessible(flag);
+ }
+
+ @Override
+ public final boolean isAccessible() {
+ return accessibleObject.isAccessible();
+ }
+
+ @Override
+ public Class<?> getDeclaringClass() {
+ return member.getDeclaringClass();
+ }
+
+ @Override
+ public final String getName() {
+ return member.getName();
+ }
+
+ @Override
+ public final int getModifiers() {
+ return member.getModifiers();
+ }
+
+ @Override
+ public final boolean isSynthetic() {
+ return member.isSynthetic();
+ }
+
+ /** Returns true if the element is public. */
+ public final boolean isPublic() {
+ return Modifier.isPublic(getModifiers());
+ }
+
+ /** Returns true if the element is protected. */
+ public final boolean isProtected() {
+ return Modifier.isProtected(getModifiers());
+ }
+
+ /** Returns true if the element is package-private. */
+ public final boolean isPackagePrivate() {
+ return !isPrivate() && !isPublic() && !isProtected();
+ }
+
+ /** Returns true if the element is private. */
+ public final boolean isPrivate() {
+ return Modifier.isPrivate(getModifiers());
+ }
+
+ /** Returns true if the element is static. */
+ public final boolean isStatic() {
+ return Modifier.isStatic(getModifiers());
+ }
+
+ /**
+ * Returns {@code true} if this method is final, per {@code Modifier.isFinal(getModifiers())}.
+ *
+ * <p>Note that a method may still be effectively "final", or non-overridable when it has no
+ * {@code final} keyword. For example, it could be private, or it could be declared by a final
+ * class. To tell whether a method is overridable, use {@link Invokable#isOverridable}.
+ */
+ public final boolean isFinal() {
+ return Modifier.isFinal(getModifiers());
+ }
+
+ /** Returns true if the method is abstract. */
+ public final boolean isAbstract() {
+ return Modifier.isAbstract(getModifiers());
+ }
+
+ /** Returns true if the element is native. */
+ public final boolean isNative() {
+ return Modifier.isNative(getModifiers());
+ }
+
+ /** Returns true if the method is synchronized. */
+ public final boolean isSynchronized() {
+ return Modifier.isSynchronized(getModifiers());
+ }
+
+ /** Returns true if the field is volatile. */
+ final boolean isVolatile() {
+ return Modifier.isVolatile(getModifiers());
+ }
+
+ /** Returns true if the field is transient. */
+ final boolean isTransient() {
+ return Modifier.isTransient(getModifiers());
+ }
+
+ @Override
+ public boolean equals(@Nullable Object obj) {
+ if (obj instanceof Element) {
+ Element that = (Element) obj;
+ return getOwnerType().equals(that.getOwnerType()) && member.equals(that.member);
+ }
+ return false;
+ }
+
+ @Override
+ public int hashCode() {
+ return member.hashCode();
+ }
+
+ @Override
+ public String toString() {
+ return member.toString();
+ }
+}
diff --git a/guava/src/com/google/common/reflect/ElementTypesAreNonnullByDefault.java b/guava/src/com/google/common/reflect/ElementTypesAreNonnullByDefault.java
deleted file mode 100644
index 0e8ef3c..0000000
--- a/guava/src/com/google/common/reflect/ElementTypesAreNonnullByDefault.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) 2021 The Guava Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.common.reflect;
-
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.PARAMETER;
-import static java.lang.annotation.ElementType.TYPE;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-import com.google.common.annotations.GwtCompatible;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-import javax.annotation.Nonnull;
-import javax.annotation.meta.TypeQualifierDefault;
-
-/**
- * Marks all "top-level" types as non-null in a way that is recognized by Kotlin. Note that this
- * unfortunately includes type-variable usages, so we also provide {@link ParametricNullness} to
- * "undo" it as best we can.
- */
-@GwtCompatible
-@Retention(RUNTIME)
-@Target(TYPE)
-@TypeQualifierDefault({FIELD, METHOD, PARAMETER})
-@Nonnull
-@interface ElementTypesAreNonnullByDefault {}
diff --git a/guava/src/com/google/common/reflect/ImmutableTypeToInstanceMap.java b/guava/src/com/google/common/reflect/ImmutableTypeToInstanceMap.java
index 7fad5de..354fd19 100644
--- a/guava/src/com/google/common/reflect/ImmutableTypeToInstanceMap.java
+++ b/guava/src/com/google/common/reflect/ImmutableTypeToInstanceMap.java
@@ -18,7 +18,6 @@
import com.google.common.collect.ForwardingMap;
import com.google.common.collect.ImmutableMap;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
-import com.google.errorprone.annotations.DoNotCall;
import java.util.Map;
/**
@@ -120,7 +119,6 @@
@CanIgnoreReturnValue
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
public <T extends B> T putInstance(TypeToken<T> type, T value) {
throw new UnsupportedOperationException();
}
@@ -134,7 +132,6 @@
@CanIgnoreReturnValue
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
public <T extends B> T putInstance(Class<T> type, T value) {
throw new UnsupportedOperationException();
}
@@ -148,7 +145,6 @@
@CanIgnoreReturnValue
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
public B put(TypeToken<? extends B> key, B value) {
throw new UnsupportedOperationException();
}
@@ -161,7 +157,6 @@
*/
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
public void putAll(Map<? extends TypeToken<? extends B>, ? extends B> map) {
throw new UnsupportedOperationException();
}
diff --git a/guava/src/com/google/common/reflect/Invokable.java b/guava/src/com/google/common/reflect/Invokable.java
index e6d3b6c..e0a9ab5 100644
--- a/guava/src/com/google/common/reflect/Invokable.java
+++ b/guava/src/com/google/common/reflect/Invokable.java
@@ -21,9 +21,9 @@
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import java.lang.annotation.Annotation;
import java.lang.reflect.AccessibleObject;
-import java.lang.reflect.AnnotatedElement;
import java.lang.reflect.AnnotatedType;
import java.lang.reflect.Constructor;
+import java.lang.reflect.GenericDeclaration;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Member;
import java.lang.reflect.Method;
@@ -31,7 +31,6 @@
import java.lang.reflect.Type;
import java.lang.reflect.TypeVariable;
import java.util.Arrays;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -50,29 +49,17 @@
* assertEquals(new TypeToken<List<String>>() {}, invokable.getOwnerType());
* }</pre>
*
- * <p><b>Note:</b> earlier versions of this class inherited from {@link
- * java.lang.reflect.AccessibleObject AccessibleObject} and {@link
- * java.lang.reflect.GenericDeclaration GenericDeclaration}. Since version 31.0 that is no longer
- * the case. However, most methods from those types are present with the same signature in this
- * class.
- *
* @param <T> the type that owns this method or constructor.
* @param <R> the return type of (or supertype thereof) the method or the declaring type of the
* constructor.
* @author Ben Yu
- * @since 14.0 (no longer implements {@link AccessibleObject} or {@code GenericDeclaration} since
- * 31.0)
+ * @since 14.0
*/
@Beta
-@ElementTypesAreNonnullByDefault
-public abstract class Invokable<T, R> implements AnnotatedElement, Member {
- private final AccessibleObject accessibleObject;
- private final Member member;
+public abstract class Invokable<T, R> extends Element implements GenericDeclaration {
<M extends AccessibleObject & Member> Invokable(M member) {
- checkNotNull(member);
- this.accessibleObject = member;
- this.member = member;
+ super(member);
}
/** Returns {@link Invokable} of {@code method}. */
@@ -85,151 +72,6 @@
return new ConstructorInvokable<T>(constructor);
}
- @Override
- public final boolean isAnnotationPresent(Class<? extends Annotation> annotationClass) {
- return accessibleObject.isAnnotationPresent(annotationClass);
- }
-
- @Override
- @CheckForNull
- public final <A extends Annotation> A getAnnotation(Class<A> annotationClass) {
- return accessibleObject.getAnnotation(annotationClass);
- }
-
- @Override
- public final Annotation[] getAnnotations() {
- return accessibleObject.getAnnotations();
- }
-
- @Override
- public final Annotation[] getDeclaredAnnotations() {
- return accessibleObject.getDeclaredAnnotations();
- }
-
- // We ought to be able to implement GenericDeclaration instead its parent AnnotatedElement.
- // That would give us this method declaration. But for some reason, implementing
- // GenericDeclaration leads to weird errors in Android tests:
- // IncompatibleClassChangeError: interface not implemented
- /** See {@link java.lang.reflect.GenericDeclaration#getTypeParameters()}. */
- public abstract TypeVariable<?>[] getTypeParameters();
-
- /** See {@link java.lang.reflect.AccessibleObject#setAccessible(boolean)}. */
- public final void setAccessible(boolean flag) {
- accessibleObject.setAccessible(flag);
- }
-
- /** See {@link java.lang.reflect.AccessibleObject#trySetAccessible()}. */
- public final boolean trySetAccessible() {
- // We can't call accessibleObject.trySetAccessible since that was added in Java 9 and this code
- // should work on Java 8. So we emulate it this way.
- try {
- accessibleObject.setAccessible(true);
- return true;
- } catch (RuntimeException e) {
- return false;
- }
- }
-
- /** See {@link java.lang.reflect.AccessibleObject#isAccessible()}. */
- public final boolean isAccessible() {
- return accessibleObject.isAccessible();
- }
-
- @Override
- public final String getName() {
- return member.getName();
- }
-
- @Override
- public final int getModifiers() {
- return member.getModifiers();
- }
-
- @Override
- public final boolean isSynthetic() {
- return member.isSynthetic();
- }
-
- /** Returns true if the element is public. */
- public final boolean isPublic() {
- return Modifier.isPublic(getModifiers());
- }
-
- /** Returns true if the element is protected. */
- public final boolean isProtected() {
- return Modifier.isProtected(getModifiers());
- }
-
- /** Returns true if the element is package-private. */
- public final boolean isPackagePrivate() {
- return !isPrivate() && !isPublic() && !isProtected();
- }
-
- /** Returns true if the element is private. */
- public final boolean isPrivate() {
- return Modifier.isPrivate(getModifiers());
- }
-
- /** Returns true if the element is static. */
- public final boolean isStatic() {
- return Modifier.isStatic(getModifiers());
- }
-
- /**
- * Returns {@code true} if this method is final, per {@code Modifier.isFinal(getModifiers())}.
- *
- * <p>Note that a method may still be effectively "final", or non-overridable when it has no
- * {@code final} keyword. For example, it could be private, or it could be declared by a final
- * class. To tell whether a method is overridable, use {@link Invokable#isOverridable}.
- */
- public final boolean isFinal() {
- return Modifier.isFinal(getModifiers());
- }
-
- /** Returns true if the method is abstract. */
- public final boolean isAbstract() {
- return Modifier.isAbstract(getModifiers());
- }
-
- /** Returns true if the element is native. */
- public final boolean isNative() {
- return Modifier.isNative(getModifiers());
- }
-
- /** Returns true if the method is synchronized. */
- public final boolean isSynchronized() {
- return Modifier.isSynchronized(getModifiers());
- }
-
- /** Returns true if the field is volatile. */
- final boolean isVolatile() {
- return Modifier.isVolatile(getModifiers());
- }
-
- /** Returns true if the field is transient. */
- final boolean isTransient() {
- return Modifier.isTransient(getModifiers());
- }
-
- @Override
- public boolean equals(@CheckForNull Object obj) {
- if (obj instanceof Invokable) {
- Invokable<?, ?> that = (Invokable<?, ?>) obj;
- return getOwnerType().equals(that.getOwnerType()) && member.equals(that.member);
- }
- return false;
- }
-
- @Override
- public int hashCode() {
- return member.hashCode();
- }
-
- @Override
- public String toString() {
- return member.toString();
- }
-
/**
* Returns {@code true} if this is an overridable method. Constructors, private, static or final
* methods, or methods declared by final classes are not overridable.
@@ -252,11 +94,10 @@
* invocation conversion.
* @throws InvocationTargetException if the underlying method or constructor throws an exception.
*/
- // All subclasses are owned by us and we'll make sure to get the R type right, including nullness.
- @SuppressWarnings({"unchecked", "nullness"})
+ // All subclasses are owned by us and we'll make sure to get the R type right.
+ @SuppressWarnings("unchecked")
@CanIgnoreReturnValue
- @CheckForNull
- public final R invoke(@CheckForNull T receiver, @Nullable Object... args)
+ public final R invoke(@Nullable T receiver, Object... args)
throws InvocationTargetException, IllegalAccessException {
return (R) invokeInternal(receiver, checkNotNull(args));
}
@@ -325,18 +166,18 @@
@SuppressWarnings("unchecked") // The declaring class is T's raw class, or one of its supertypes.
@Override
public final Class<? super T> getDeclaringClass() {
- return (Class<? super T>) member.getDeclaringClass();
+ return (Class<? super T>) super.getDeclaringClass();
}
/** Returns the type of {@code T}. */
// Overridden in TypeToken#method() and TypeToken#constructor()
@SuppressWarnings("unchecked") // The declaring class is T.
+ @Override
public TypeToken<T> getOwnerType() {
return (TypeToken<T>) TypeToken.of(getDeclaringClass());
}
- @CheckForNull
- abstract Object invokeInternal(@CheckForNull Object receiver, @Nullable Object[] args)
+ abstract Object invokeInternal(@Nullable Object receiver, Object[] args)
throws InvocationTargetException, IllegalAccessException;
abstract Type[] getGenericParameterTypes();
@@ -362,8 +203,7 @@
}
@Override
- @CheckForNull
- final Object invokeInternal(@CheckForNull Object receiver, @Nullable Object[] args)
+ final Object invokeInternal(@Nullable Object receiver, Object[] args)
throws InvocationTargetException, IllegalAccessException {
return method.invoke(receiver, args);
}
@@ -427,7 +267,7 @@
}
@Override
- final Object invokeInternal(@CheckForNull Object receiver, @Nullable 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 2d21dbb..c7fe512 100644
--- a/guava/src/com/google/common/reflect/MutableTypeToInstanceMap.java
+++ b/guava/src/com/google/common/reflect/MutableTypeToInstanceMap.java
@@ -24,7 +24,6 @@
import com.google.common.collect.Iterators;
import com.google.common.collect.Maps;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
-import com.google.errorprone.annotations.DoNotCall;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
@@ -73,7 +72,6 @@
@CanIgnoreReturnValue
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
public B put(TypeToken<? extends B> key, B value) {
throw new UnsupportedOperationException("Please use putInstance() instead.");
}
@@ -86,7 +84,6 @@
*/
@Deprecated
@Override
- @DoNotCall("Always throws UnsupportedOperationException")
public void putAll(Map<? extends TypeToken<? extends B>, ? extends B> map) {
throw new UnsupportedOperationException("Please use putInstance() instead.");
}
diff --git a/guava/src/com/google/common/reflect/Parameter.java b/guava/src/com/google/common/reflect/Parameter.java
index 61ab85a..8065920 100644
--- a/guava/src/com/google/common/reflect/Parameter.java
+++ b/guava/src/com/google/common/reflect/Parameter.java
@@ -22,7 +22,6 @@
import java.lang.annotation.Annotation;
import java.lang.reflect.AnnotatedElement;
import java.lang.reflect.AnnotatedType;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -32,7 +31,6 @@
* @since 14.0
*/
@Beta
-@ElementTypesAreNonnullByDefault
public final class Parameter implements AnnotatedElement {
private final Invokable<?, ?> declaration;
@@ -70,8 +68,7 @@
}
@Override
- @CheckForNull
- public <A extends Annotation> A getAnnotation(Class<A> annotationType) {
+ public <A extends Annotation> @Nullable A getAnnotation(Class<A> annotationType) {
checkNotNull(annotationType);
for (Annotation annotation : annotations) {
if (annotationType.isInstance(annotation)) {
@@ -103,8 +100,7 @@
/** @since 18.0 */
// @Override on JDK8
@Override
- @CheckForNull
- public <A extends Annotation> A getDeclaredAnnotation(Class<A> annotationType) {
+ public <A extends Annotation> @Nullable A getDeclaredAnnotation(Class<A> annotationType) {
checkNotNull(annotationType);
return FluentIterable.from(annotations).filter(annotationType).first().orNull();
}
@@ -113,11 +109,7 @@
// @Override on JDK8
@Override
public <A extends Annotation> A[] getDeclaredAnnotationsByType(Class<A> annotationType) {
- @Nullable
- A[] result = FluentIterable.from(annotations).filter(annotationType).toArray(annotationType);
- @SuppressWarnings("nullness") // safe because the input list contains no nulls
- A[] cast = (A[]) result;
- return cast;
+ return FluentIterable.from(annotations).filter(annotationType).toArray(annotationType);
}
/** @since 25.1 */
@@ -127,7 +119,7 @@
}
@Override
- public boolean equals(@CheckForNull 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/ParametricNullness.java b/guava/src/com/google/common/reflect/ParametricNullness.java
deleted file mode 100644
index 588aa5f..0000000
--- a/guava/src/com/google/common/reflect/ParametricNullness.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2021 The Guava Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.common.reflect;
-
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.PARAMETER;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-import static javax.annotation.meta.When.UNKNOWN;
-
-import com.google.common.annotations.GwtCompatible;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-import javax.annotation.Nonnull;
-import javax.annotation.meta.TypeQualifierNickname;
-
-/**
- * Marks a "top-level" type-variable usage as (a) a Kotlin platform type when the type argument is
- * non-nullable and (b) nullable when the type argument is nullable. This is the closest we can get
- * to "non-nullable when non-nullable; nullable when nullable" (like the Android <a
- * href="https://android.googlesource.com/platform/libcore/+/master/luni/src/main/java/libcore/util/NullFromTypeParam.java">{@code
- * NullFromTypeParam}</a>). We use this to "undo" {@link ElementTypesAreNonnullByDefault}.
- */
-@GwtCompatible
-@Retention(RUNTIME)
-@Target({FIELD, METHOD, PARAMETER})
-@TypeQualifierNickname
-@Nonnull(when = UNKNOWN)
-@interface ParametricNullness {}
diff --git a/guava/src/com/google/common/reflect/Reflection.java b/guava/src/com/google/common/reflect/Reflection.java
index fa35f7f..4ad5dff 100644
--- a/guava/src/com/google/common/reflect/Reflection.java
+++ b/guava/src/com/google/common/reflect/Reflection.java
@@ -27,7 +27,6 @@
* @since 12.0
*/
@Beta
-@ElementTypesAreNonnullByDefault
public final class Reflection {
/**
diff --git a/guava/src/com/google/common/reflect/TypeCapture.java b/guava/src/com/google/common/reflect/TypeCapture.java
index 2be7b4f..effb382 100644
--- a/guava/src/com/google/common/reflect/TypeCapture.java
+++ b/guava/src/com/google/common/reflect/TypeCapture.java
@@ -24,7 +24,6 @@
*
* @author Ben Yu
*/
-@ElementTypesAreNonnullByDefault
abstract class TypeCapture<T> {
/** Returns the captured type. */
diff --git a/guava/src/com/google/common/reflect/TypeParameter.java b/guava/src/com/google/common/reflect/TypeParameter.java
index 9c64abb..586c912 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 javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Captures a free type variable that can be used in {@link TypeToken#where}. For example:
@@ -35,17 +35,6 @@
* @since 12.0
*/
@Beta
-@ElementTypesAreNonnullByDefault
-/*
- * A nullable bound would let users create a TypeParameter instance for a parameter with a nullable
- * bound. However, it would also let them create `new TypeParameter<@Nullable T>() {}`, which
- * wouldn't behave as users might expect. Additionally, it's not clear how the TypeToken API could
- * support even a "normal" `TypeParameter<T>` when `<T>` has a nullable bound. (See the discussion
- * on TypeToken.where.) So, in the interest of failing fast and encouraging the user to switch to a
- * non-null bound if possible, let's require a non-null bound here.
- *
- * TODO(cpovirk): Elaborate on "wouldn't behave as users might expect."
- */
public abstract class TypeParameter<T> extends TypeCapture<T> {
final TypeVariable<?> typeVariable;
@@ -62,7 +51,7 @@
}
@Override
- public final boolean equals(@CheckForNull 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 fbe48c1..339eb43 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 javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* An object of this class encapsulates type mappings from type variables. Mappings are established
@@ -52,7 +52,6 @@
* @since 15.0
*/
@Beta
-@ElementTypesAreNonnullByDefault
public final class TypeResolver {
private final TypeTable typeTable;
@@ -509,7 +508,7 @@
@Override
TypeVariable<?> captureAsTypeVariable(Type[] upperBounds) {
Set<Type> combined = new LinkedHashSet<>(asList(upperBounds));
- // Since this is an artificially generated type variable, we don't bother checking
+ // Since this is an artifically generated type variable, we don't bother checking
// subtyping between declared type bound and actual type bound. So it's possible that we
// may generate something like <capture#1-of ? extends Foo&SubFoo>.
// Checking subtype between declared and actual type bounds
@@ -528,8 +527,7 @@
return new WildcardCapturer(id);
}
- @CheckForNull
- private Type captureNullable(@CheckForNull Type type) {
+ private Type captureNullable(@Nullable Type type) {
if (type == null) {
return null;
}
@@ -563,7 +561,7 @@
}
@Override
- public boolean equals(@CheckForNull Object obj) {
+ public boolean equals(Object obj) {
if (obj instanceof TypeVariableKey) {
TypeVariableKey that = (TypeVariableKey) obj;
return equalsTypeVariable(that.var);
@@ -578,7 +576,6 @@
}
/** Wraps {@code t} in a {@code TypeVariableKey} if it's a type variable. */
- @CheckForNull
static TypeVariableKey forLookup(Type t) {
if (t instanceof TypeVariable) {
return new TypeVariableKey((TypeVariable<?>) t);
diff --git a/guava/src/com/google/common/reflect/TypeToken.java b/guava/src/com/google/common/reflect/TypeToken.java
index f107b70..88deff3 100644
--- a/guava/src/com/google/common/reflect/TypeToken.java
+++ b/guava/src/com/google/common/reflect/TypeToken.java
@@ -17,7 +17,6 @@
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkState;
-import static java.util.Objects.requireNonNull;
import com.google.common.annotations.Beta;
import com.google.common.annotations.VisibleForTesting;
@@ -47,7 +46,7 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* A {@link Type} with generics.
@@ -99,16 +98,15 @@
*/
@Beta
@SuppressWarnings("serial") // SimpleTypeToken is the serialized form.
-@ElementTypesAreNonnullByDefault
public abstract class TypeToken<T> extends TypeCapture<T> implements Serializable {
private final Type runtimeType;
/** Resolver for resolving parameter and field types with {@link #runtimeType} as context. */
- @CheckForNull private transient TypeResolver invariantTypeResolver;
+ private transient @Nullable TypeResolver invariantTypeResolver;
/** Resolver for resolving covariant types with {@link #runtimeType} as context. */
- @CheckForNull private transient TypeResolver covariantTypeResolver;
+ private transient @Nullable TypeResolver covariantTypeResolver;
/**
* Constructs a new type token of {@code T}.
@@ -222,17 +220,6 @@
* @param typeParam the parameter type variable
* @param typeArg the actual type to substitute
*/
- /*
- * TODO(cpovirk): Is there any way for us to support TypeParameter instances for type parameters
- * that have nullable bounds? Unfortunately, if we change the parameter to TypeParameter<? extends
- * @Nullable X>, then users might pass a TypeParameter<Y>, where Y is a subtype of X, while still
- * passing a TypeToken<X>. This would be invalid. Maybe we could accept a TypeParameter<@PolyNull
- * X> if we support such a thing? It would be weird or misleading for users to be able to pass
- * `new TypeParameter<@Nullable T>() {}` and have it act as a plain `TypeParameter<T>`, but
- * hopefully no one would do that, anyway. See also the comment on TypeParameter itself.
- *
- * TODO(cpovirk): Elaborate on this / merge with other comment?
- */
public final <X> TypeToken<T> where(TypeParameter<X> typeParam, TypeToken<X> typeArg) {
TypeResolver resolver =
new TypeResolver()
@@ -261,10 +248,6 @@
* @param typeParam the parameter type variable
* @param typeArg the actual type to substitute
*/
- /*
- * TODO(cpovirk): Is there any way for us to support TypeParameter instances for type parameters
- * that have nullable bounds? See discussion on the other overload of this method.
- */
public final <X> TypeToken<T> where(TypeParameter<X> typeParam, Class<X> typeArg) {
return where(typeParam, of(typeArg));
}
@@ -305,8 +288,7 @@
* if the bound is a class or extends from a class. This means that the returned type could be a
* type variable too.
*/
- @CheckForNull
- final TypeToken<? super T> getGenericSuperclass() {
+ final @Nullable TypeToken<? super T> getGenericSuperclass() {
if (runtimeType instanceof TypeVariable) {
// First bound is always the super class, if one exists.
return boundAsSuperclass(((TypeVariable<?>) runtimeType).getBounds()[0]);
@@ -324,8 +306,7 @@
return superToken;
}
- @CheckForNull
- private TypeToken<? super T> boundAsSuperclass(Type bound) {
+ private @Nullable TypeToken<? super T> boundAsSuperclass(Type bound) {
TypeToken<?> token = of(bound);
if (token.getRawType().isInterface()) {
return null;
@@ -577,8 +558,7 @@
* Returns the array component type if this type represents an array ({@code int[]}, {@code T[]},
* {@code <? extends Map<String, Integer>[]>} etc.), or else {@code null} is returned.
*/
- @CheckForNull
- public final TypeToken<?> getComponentType() {
+ public final @Nullable TypeToken<?> getComponentType() {
Type componentType = Types.getComponentType(runtimeType);
if (componentType == null) {
return null;
@@ -672,7 +652,7 @@
*/
public class TypeSet extends ForwardingSet<TypeToken<? super T>> implements Serializable {
- @CheckForNull private transient ImmutableSet<TypeToken<? super T>> types;
+ private transient @Nullable ImmutableSet<TypeToken<? super T>> types;
TypeSet() {}
@@ -718,7 +698,7 @@
private final class InterfaceSet extends TypeSet {
private final transient TypeSet allTypes;
- @CheckForNull private transient ImmutableSet<TypeToken<? super T>> interfaces;
+ private transient @Nullable ImmutableSet<TypeToken<? super T>> interfaces;
InterfaceSet(TypeSet allTypes) {
this.allTypes = allTypes;
@@ -771,7 +751,7 @@
private final class ClassSet extends TypeSet {
- @CheckForNull private transient ImmutableSet<TypeToken<? super T>> classes;
+ private transient @Nullable ImmutableSet<TypeToken<? super T>> classes;
@Override
protected Set<TypeToken<? super T>> delegate() {
@@ -836,7 +816,7 @@
* Returns true if {@code o} is another {@code TypeToken} that represents the same {@link Type}.
*/
@Override
- public boolean equals(@CheckForNull Object o) {
+ public boolean equals(@Nullable Object o) {
if (o instanceof TypeToken) {
TypeToken<?> that = (TypeToken<?>) o;
return runtimeType.equals(that.runtimeType);
@@ -1150,8 +1130,7 @@
* Returns the owner type of a {@link ParameterizedType} or enclosing class of a {@link Class}, or
* null otherwise.
*/
- @CheckForNull
- private Type getOwnerTypeIfPresent() {
+ private @Nullable Type getOwnerTypeIfPresent() {
if (runtimeType instanceof ParameterizedType) {
return ((ParameterizedType) runtimeType).getOwnerType();
} else if (runtimeType instanceof Class<?>) {
@@ -1240,19 +1219,11 @@
// with component type, we have lost generic type information
// Use raw type so that compiler allows us to call getSupertype()
@SuppressWarnings("rawtypes")
- TypeToken componentType = getComponentType();
- // TODO(cpovirk): checkArgument?
- if (componentType == null) {
- throw new IllegalArgumentException(supertype + " isn't a super type of " + this);
- }
+ TypeToken componentType =
+ checkNotNull(getComponentType(), "%s isn't a super type of %s", supertype, this);
// array is covariant. component type is super type, so is the array type.
@SuppressWarnings("unchecked") // going from raw type back to generics
- /*
- * requireNonNull is safe because we call getArraySupertype only after checking
- * supertype.isArray().
- */
- TypeToken<?> componentSupertype =
- componentType.getSupertype(requireNonNull(supertype.getComponentType()));
+ TypeToken<?> componentSupertype = componentType.getSupertype(supertype.getComponentType());
@SuppressWarnings("unchecked") // component type is super type, so is array type.
TypeToken<? super T> result =
(TypeToken<? super T>)
@@ -1262,14 +1233,8 @@
}
private TypeToken<? extends T> getArraySubtype(Class<?> subclass) {
- Class<?> subclassComponentType = subclass.getComponentType();
- if (subclassComponentType == null) {
- throw new IllegalArgumentException(subclass + " does not appear to be a subtype of " + this);
- }
// array is covariant. component type is subtype, so is the array type.
- // requireNonNull is safe because we call getArraySubtype only when isArray().
- TypeToken<?> componentSubtype =
- requireNonNull(getComponentType()).getSubtype(subclassComponentType);
+ TypeToken<?> componentSubtype = getComponentType().getSubtype(subclass.getComponentType());
@SuppressWarnings("unchecked") // component type is subtype, so is array type.
TypeToken<? extends T> result =
(TypeToken<? extends T>)
@@ -1342,7 +1307,7 @@
}
@Override
- @CheckForNull
+ @Nullable
TypeToken<?> getSuperclass(TypeToken<?> type) {
return type.getGenericSuperclass();
}
@@ -1361,7 +1326,7 @@
}
@Override
- @CheckForNull
+ @Nullable
Class<?> getSuperclass(Class<?> type) {
return type.getSuperclass();
}
@@ -1433,9 +1398,7 @@
new Ordering<K>() {
@Override
public int compare(K left, K right) {
- // requireNonNull is safe because we are passing keys in the map.
- return valueComparator.compare(
- requireNonNull(map.get(left)), requireNonNull(map.get(right)));
+ return valueComparator.compare(map.get(left), map.get(right));
}
};
return keyOrdering.immutableSortedCopy(map.keySet());
@@ -1445,8 +1408,7 @@
abstract Iterable<? extends K> getInterfaces(K type);
- @CheckForNull
- abstract K getSuperclass(K type);
+ abstract @Nullable K getSuperclass(K type);
private static class ForwardingTypeCollector<K> extends TypeCollector<K> {
@@ -1467,7 +1429,6 @@
}
@Override
- @CheckForNull
K getSuperclass(K type) {
return delegate.getSuperclass(type);
}
diff --git a/guava/src/com/google/common/reflect/TypeVisitor.java b/guava/src/com/google/common/reflect/TypeVisitor.java
index 416397b..3e8436d 100644
--- a/guava/src/com/google/common/reflect/TypeVisitor.java
+++ b/guava/src/com/google/common/reflect/TypeVisitor.java
@@ -21,7 +21,6 @@
import java.lang.reflect.TypeVariable;
import java.lang.reflect.WildcardType;
import java.util.Set;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Based on what a {@link Type} is, dispatch it to the corresponding {@code visit*} method. By
@@ -54,7 +53,6 @@
*
* @author Ben Yu
*/
-@ElementTypesAreNonnullByDefault
abstract class TypeVisitor {
private final Set<Type> visited = Sets.newHashSet();
@@ -63,7 +61,7 @@
* Visits the given types. Null types are ignored. This allows subclasses to call {@code
* visit(parameterizedType.getOwnerType())} safely without having to check nulls.
*/
- public final void visit(@Nullable Type... types) {
+ public final void visit(Type... types) {
for (Type type : types) {
if (type == null || !visited.add(type)) {
// null owner type, or already visited;
diff --git a/guava/src/com/google/common/reflect/Types.java b/guava/src/com/google/common/reflect/Types.java
index 0dc327d..42a1f78 100644
--- a/guava/src/com/google/common/reflect/Types.java
+++ b/guava/src/com/google/common/reflect/Types.java
@@ -17,7 +17,6 @@
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.collect.Iterables.transform;
-import static java.util.Objects.requireNonNull;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Function;
@@ -45,7 +44,6 @@
import java.util.Collection;
import java.util.Map.Entry;
import java.util.concurrent.atomic.AtomicReference;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -53,7 +51,6 @@
*
* @author Ben Yu
*/
-@ElementTypesAreNonnullByDefault
final class Types {
/** Class#toString without the "class " and "interface " prefixes */
@@ -89,7 +86,7 @@
* {@code ownerType}.
*/
static ParameterizedType newParameterizedTypeWithOwner(
- @CheckForNull Type ownerType, Class<?> rawType, Type... arguments) {
+ @Nullable Type ownerType, Class<?> rawType, Type... arguments) {
if (ownerType == null) {
return newParameterizedType(rawType, arguments);
}
@@ -109,14 +106,14 @@
private enum ClassOwnership {
OWNED_BY_ENCLOSING_CLASS {
@Override
- @CheckForNull
+ @Nullable
Class<?> getOwnerType(Class<?> rawType) {
return rawType.getEnclosingClass();
}
},
LOCAL_CLASS_HAS_NO_OWNER {
@Override
- @CheckForNull
+ @Nullable
Class<?> getOwnerType(Class<?> rawType) {
if (rawType.isLocalClass()) {
return null;
@@ -126,17 +123,14 @@
}
};
- @CheckForNull
- abstract Class<?> getOwnerType(Class<?> rawType);
+ abstract @Nullable Class<?> getOwnerType(Class<?> rawType);
static final ClassOwnership JVM_BEHAVIOR = detectJvmBehavior();
private static ClassOwnership detectJvmBehavior() {
class LocalClass<T> {}
Class<?> subclass = new LocalClass<String>() {}.getClass();
- // requireNonNull is safe because we're examining a type that's known to have a superclass.
- ParameterizedType parameterizedType =
- requireNonNull((ParameterizedType) subclass.getGenericSuperclass());
+ ParameterizedType parameterizedType = (ParameterizedType) subclass.getGenericSuperclass();
for (ClassOwnership behavior : ClassOwnership.values()) {
if (behavior.getOwnerType(LocalClass.class) == parameterizedType.getOwnerType()) {
return behavior;
@@ -177,10 +171,9 @@
return (type instanceof Class) ? ((Class<?>) type).getName() : type.toString();
}
- @CheckForNull
- static Type getComponentType(Type type) {
+ static @Nullable Type getComponentType(Type type) {
checkNotNull(type);
- final AtomicReference<@Nullable Type> result = new AtomicReference<>();
+ final AtomicReference<Type> result = new AtomicReference<>();
new TypeVisitor() {
@Override
void visitTypeVariable(TypeVariable<?> t) {
@@ -209,8 +202,7 @@
* Returns {@code ? extends X} if any of {@code bounds} is a subtype of {@code X[]}; or null
* otherwise.
*/
- @CheckForNull
- private static Type subtypeOfComponentType(Type[] bounds) {
+ private static @Nullable Type subtypeOfComponentType(Type[] bounds) {
for (Type bound : bounds) {
Type componentType = getComponentType(bound);
if (componentType != null) {
@@ -252,7 +244,7 @@
}
@Override
- public boolean equals(@CheckForNull Object obj) {
+ public boolean equals(Object obj) {
if (obj instanceof GenericArrayType) {
GenericArrayType that = (GenericArrayType) obj;
return Objects.equal(getGenericComponentType(), that.getGenericComponentType());
@@ -265,11 +257,11 @@
private static final class ParameterizedTypeImpl implements ParameterizedType, Serializable {
- @CheckForNull private final Type ownerType;
+ private final @Nullable Type ownerType;
private final ImmutableList<Type> argumentsList;
private final Class<?> rawType;
- ParameterizedTypeImpl(@CheckForNull 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");
@@ -289,7 +281,6 @@
}
@Override
- @CheckForNull
public Type getOwnerType() {
return ownerType;
}
@@ -316,7 +307,7 @@
}
@Override
- public boolean equals(@CheckForNull Object other) {
+ public boolean equals(Object other) {
if (!(other instanceof ParameterizedType)) {
return false;
}
@@ -392,9 +383,7 @@
}
@Override
- @CheckForNull
- public Object invoke(Object proxy, Method method, @CheckForNull @Nullable Object[] args)
- throws Throwable {
+ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
String methodName = method.getName();
Method typeVariableMethod = typeVariableMethods.get(methodName);
if (typeVariableMethod == null) {
@@ -449,7 +438,7 @@
}
@Override
- public boolean equals(@CheckForNull Object obj) {
+ public boolean equals(Object obj) {
if (NativeTypeVariableEquals.NATIVE_TYPE_VARIABLE_ONLY) {
// equal only to our TypeVariable implementation with identical bounds
if (obj != null
@@ -498,7 +487,7 @@
}
@Override
- public boolean equals(@CheckForNull Object obj) {
+ public boolean equals(Object obj) {
if (obj instanceof WildcardType) {
WildcardType that = (WildcardType) obj;
return lowerBounds.equals(Arrays.asList(that.getLowerBounds()))
diff --git a/guava/src/com/google/common/util/concurrent/AbstractCatchingFuture.java b/guava/src/com/google/common/util/concurrent/AbstractCatchingFuture.java
index 76eada2..850e310 100644
--- a/guava/src/com/google/common/util/concurrent/AbstractCatchingFuture.java
+++ b/guava/src/com/google/common/util/concurrent/AbstractCatchingFuture.java
@@ -17,7 +17,6 @@
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.util.concurrent.Futures.getDone;
import static com.google.common.util.concurrent.MoreExecutors.rejectionPropagatingExecutor;
-import static com.google.common.util.concurrent.NullnessCasts.uncheckedCastNullableTToT;
import static com.google.common.util.concurrent.Platform.isInstanceOfThrowableClass;
import com.google.common.annotations.GwtCompatible;
@@ -27,17 +26,13 @@
import com.google.errorprone.annotations.ForOverride;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executor;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/** Implementations of {@code Futures.catching*}. */
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-@SuppressWarnings("nullness") // TODO(b/147136275): Remove once our checker understands & and |.
-abstract class AbstractCatchingFuture<
- V extends @Nullable Object, X extends Throwable, F, T extends @Nullable Object>
+abstract class AbstractCatchingFuture<V, X extends Throwable, F, T>
extends FluentFuture.TrustedFuture<V> implements Runnable {
- static <V extends @Nullable Object, X extends Throwable> ListenableFuture<V> create(
+ static <V, X extends Throwable> ListenableFuture<V> create(
ListenableFuture<? extends V> input,
Class<X> exceptionType,
Function<? super X, ? extends V> fallback,
@@ -47,7 +42,7 @@
return future;
}
- static <X extends Throwable, V extends @Nullable Object> ListenableFuture<V> create(
+ static <X extends Throwable, V> ListenableFuture<V> create(
ListenableFuture<? extends V> input,
Class<X> exceptionType,
AsyncFunction<? super X, ? extends V> fallback,
@@ -61,9 +56,9 @@
* 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.
*/
- @CheckForNull ListenableFuture<? extends V> inputFuture;
- @CheckForNull Class<X> exceptionType;
- @CheckForNull F fallback;
+ @Nullable ListenableFuture<? extends V> inputFuture;
+ @Nullable Class<X> exceptionType;
+ @Nullable F fallback;
AbstractCatchingFuture(
ListenableFuture<? extends V> inputFuture, Class<X> exceptionType, F fallback) {
@@ -112,11 +107,7 @@
}
if (throwable == null) {
- /*
- * The cast is safe: There was no exception, so the assignment from getDone must have
- * succeeded.
- */
- set(uncheckedCastNullableTToT(sourceResult));
+ set(sourceResult);
return;
}
@@ -143,7 +134,6 @@
}
@Override
- @CheckForNull
protected String pendingToString() {
ListenableFuture<? extends V> localInputFuture = inputFuture;
Class<X> localExceptionType = exceptionType;
@@ -168,12 +158,11 @@
/** Template method for subtypes to actually run the fallback. */
@ForOverride
- @ParametricNullness
- abstract T doFallback(F fallback, X throwable) throws Exception;
+ abstract @Nullable T doFallback(F fallback, X throwable) throws Exception;
/** Template method for subtypes to actually set the result. */
@ForOverride
- abstract void setResult(@ParametricNullness T result);
+ abstract void setResult(@Nullable T result);
@Override
protected final void afterDone() {
@@ -187,7 +176,7 @@
* An {@link AbstractCatchingFuture} that delegates to an {@link AsyncFunction} and {@link
* #setFuture(ListenableFuture)}.
*/
- private static final class AsyncCatchingFuture<V extends @Nullable Object, X extends Throwable>
+ private static final class AsyncCatchingFuture<V, X extends Throwable>
extends AbstractCatchingFuture<
V, X, AsyncFunction<? super X, ? extends V>, ListenableFuture<? extends V>> {
AsyncCatchingFuture(
@@ -219,7 +208,7 @@
* An {@link AbstractCatchingFuture} that delegates to a {@link Function} and {@link
* #set(Object)}.
*/
- private static final class CatchingFuture<V extends @Nullable Object, X extends Throwable>
+ private static final class CatchingFuture<V, X extends Throwable>
extends AbstractCatchingFuture<V, X, Function<? super X, ? extends V>, V> {
CatchingFuture(
ListenableFuture<? extends V> input,
@@ -229,13 +218,13 @@
}
@Override
- @ParametricNullness
+ @Nullable
V doFallback(Function<? super X, ? extends V> fallback, X cause) throws Exception {
return fallback.apply(cause);
}
@Override
- void setResult(@ParametricNullness V result) {
+ void setResult(@Nullable V result) {
set(result);
}
}
diff --git a/guava/src/com/google/common/util/concurrent/AbstractExecutionThreadService.java b/guava/src/com/google/common/util/concurrent/AbstractExecutionThreadService.java
index df5b462..1bee501 100644
--- a/guava/src/com/google/common/util/concurrent/AbstractExecutionThreadService.java
+++ b/guava/src/com/google/common/util/concurrent/AbstractExecutionThreadService.java
@@ -34,7 +34,6 @@
* @since 1.0
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public abstract class AbstractExecutionThreadService implements Service {
private static final Logger logger =
Logger.getLogger(AbstractExecutionThreadService.class.getName());
diff --git a/guava/src/com/google/common/util/concurrent/AbstractFuture.java b/guava/src/com/google/common/util/concurrent/AbstractFuture.java
index e61c6ff..06feb5a 100644
--- a/guava/src/com/google/common/util/concurrent/AbstractFuture.java
+++ b/guava/src/com/google/common/util/concurrent/AbstractFuture.java
@@ -16,10 +16,8 @@
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Throwables.throwIfUnchecked;
-import static com.google.common.util.concurrent.NullnessCasts.uncheckedNull;
import static java.lang.Integer.toHexString;
import static java.lang.System.identityHashCode;
-import static java.util.Objects.requireNonNull;
import static java.util.concurrent.atomic.AtomicReferenceFieldUpdater.newUpdater;
import com.google.common.annotations.Beta;
@@ -45,7 +43,6 @@
import java.util.concurrent.locks.LockSupport;
import java.util.logging.Level;
import java.util.logging.Logger;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -67,14 +64,10 @@
* @author Luke Sandberg
* @since 1.0
*/
-@SuppressWarnings({
- "ShortCircuitBoolean", // we use non-short circuiting comparisons intentionally
- "nullness", // TODO(b/147136275): Remove once our checker understands & and |.
-})
+@SuppressWarnings("ShortCircuitBoolean") // we use non-short circuiting comparisons intentionally
@GwtCompatible(emulated = true)
@ReflectionSupport(value = ReflectionSupport.Level.FULL)
-@ElementTypesAreNonnullByDefault
-public abstract class AbstractFuture<V extends @Nullable Object> extends InternalFutureFailureAccess
+public abstract class AbstractFuture<V> extends InternalFutureFailureAccess
implements ListenableFuture<V> {
// NOTE: Whenever both tests are cheap and functional, it's faster to use &, | instead of &&, ||
@@ -98,24 +91,21 @@
* of this interface must also be an AbstractFuture and must not override or expose for overriding
* any of the public methods of ListenableFuture.
*/
- interface Trusted<V extends @Nullable Object> extends ListenableFuture<V> {}
+ interface Trusted<V> extends ListenableFuture<V> {}
/**
* A less abstract subclass of AbstractFuture. This can be used to optimize setFuture by ensuring
* that {@link #get} calls exactly the implementation of {@link AbstractFuture#get}.
*/
- abstract static class TrustedFuture<V extends @Nullable Object> extends AbstractFuture<V>
- implements Trusted<V> {
+ abstract static class TrustedFuture<V> extends AbstractFuture<V> implements Trusted<V> {
@CanIgnoreReturnValue
@Override
- @ParametricNullness
public final V get() throws InterruptedException, ExecutionException {
return super.get();
}
@CanIgnoreReturnValue
@Override
- @ParametricNullness
public final V get(long timeout, TimeUnit unit)
throws InterruptedException, ExecutionException, TimeoutException {
return super.get(timeout, unit);
@@ -201,8 +191,8 @@
private static final class Waiter {
static final Waiter TOMBSTONE = new Waiter(false /* ignored param */);
- @CheckForNull volatile Thread thread;
- @CheckForNull volatile Waiter next;
+ volatile @Nullable Thread thread;
+ volatile @Nullable Waiter next;
/**
* Constructor for the TOMBSTONE, avoids use of ATOMIC_HELPER in case this class is loaded
@@ -217,7 +207,7 @@
// non-volatile write to the next field. Should be made visible by subsequent CAS on waiters
// field.
- void setNext(@CheckForNull Waiter next) {
+ void setNext(Waiter next) {
ATOMIC_HELPER.putNext(this, next);
}
@@ -274,24 +264,17 @@
/** Listeners also form a stack through the {@link #listeners} field. */
private static final class Listener {
- static final Listener TOMBSTONE = new Listener();
- @CheckForNull // null only for TOMBSTONE
+ static final Listener TOMBSTONE = new Listener(null, null);
final Runnable task;
- @CheckForNull // null only for TOMBSTONE
final Executor executor;
// writes to next are made visible by subsequent CAS's on the listeners field
- @CheckForNull Listener next;
+ @Nullable Listener next;
Listener(Runnable task, Executor executor) {
this.task = task;
this.executor = executor;
}
-
- Listener() {
- this.task = null;
- this.executor = null;
- }
}
/** A special value to represent {@code null}. */
@@ -317,8 +300,8 @@
/** A special value to represent cancellation and the 'wasInterrupted' bit. */
private static final class Cancellation {
// constants to use when GENERATE_CANCELLATION_CAUSES = false
- @CheckForNull static final Cancellation CAUSELESS_INTERRUPTED;
- @CheckForNull static final Cancellation CAUSELESS_CANCELLED;
+ static final Cancellation CAUSELESS_INTERRUPTED;
+ static final Cancellation CAUSELESS_CANCELLED;
static {
if (GENERATE_CANCELLATION_CAUSES) {
@@ -331,16 +314,16 @@
}
final boolean wasInterrupted;
- @CheckForNull final Throwable cause;
+ final @Nullable Throwable cause;
- Cancellation(boolean wasInterrupted, @CheckForNull Throwable cause) {
+ Cancellation(boolean wasInterrupted, @Nullable Throwable cause) {
this.wasInterrupted = wasInterrupted;
this.cause = cause;
}
}
/** A special value that encodes the 'setFuture' state. */
- private static final class SetFuture<V extends @Nullable Object> implements Runnable {
+ private static final class SetFuture<V> implements Runnable {
final AbstractFuture<V> owner;
final ListenableFuture<? extends V> future;
@@ -379,13 +362,13 @@
* argument.
* </ul>
*/
- @CheckForNull private volatile Object value;
+ private volatile @Nullable Object value;
/** All listeners. */
- @CheckForNull private volatile Listener listeners;
+ private volatile @Nullable Listener listeners;
/** All waiting threads. */
- @CheckForNull private volatile Waiter waiters;
+ private volatile @Nullable Waiter waiters;
/** Constructor for use by subclasses. */
protected AbstractFuture() {}
@@ -424,7 +407,6 @@
*/
@CanIgnoreReturnValue
@Override
- @ParametricNullness
public V get(long timeout, TimeUnit unit)
throws InterruptedException, TimeoutException, ExecutionException {
// NOTE: if timeout < 0, remainingNanos will be < 0 and we will fall into the while(true) loop
@@ -477,8 +459,7 @@
}
// re-read value, if we get here then we must have observed a TOMBSTONE while trying to add a
// waiter.
- // requireNonNull is safe because value is always set before TOMBSTONE.
- return getDoneValue(requireNonNull(value));
+ return getDoneValue(value);
}
// If we get here then we have remainingNanos < SPIN_THRESHOLD_NANOS and there is no node on the
// waiters list
@@ -537,7 +518,6 @@
*/
@CanIgnoreReturnValue
@Override
- @ParametricNullness
public V get() throws InterruptedException, ExecutionException {
if (Thread.interrupted()) {
throw new InterruptedException();
@@ -573,12 +553,10 @@
}
// re-read value, if we get here then we must have observed a TOMBSTONE while trying to add a
// waiter.
- // requireNonNull is safe because value is always set before TOMBSTONE.
- return getDoneValue(requireNonNull(value));
+ return getDoneValue(value);
}
/** Unboxes {@code obj}. Assumes that obj is not {@code null} or a {@link SetFuture}. */
- @ParametricNullness
private V getDoneValue(Object obj) throws ExecutionException {
// While this seems like it might be too branch-y, simple benchmarking proves it to be
// unmeasurable (comparing done AbstractFutures with immediateFuture)
@@ -587,11 +565,7 @@
} else if (obj instanceof Failure) {
throw new ExecutionException(((Failure) obj).exception);
} else if (obj == NULL) {
- /*
- * It's safe to return null because we would only have stored it in the first place if it were
- * a valid value for V.
- */
- return uncheckedNull();
+ return null;
} else {
@SuppressWarnings("unchecked") // this is the only other option
V asV = (V) obj;
@@ -639,20 +613,9 @@
GENERATE_CANCELLATION_CAUSES
? new Cancellation(
mayInterruptIfRunning, new CancellationException("Future.cancel() was called."))
- /*
- * requireNonNull is safe because we've initialized these if
- * !GENERATE_CANCELLATION_CAUSES.
- *
- * TODO(cpovirk): Maybe it would be cleaner to define a CancellationSupplier interface
- * with two implementations, one that contains causeless Cancellation instances and
- * the other of which creates new Cancellation instances each time it's called? Yet
- * another alternative is to fill in a non-null value for each of the fields no matter
- * what and to just not use it if !GENERATE_CANCELLATION_CAUSES.
- */
- : requireNonNull(
- mayInterruptIfRunning
- ? Cancellation.CAUSELESS_INTERRUPTED
- : Cancellation.CAUSELESS_CANCELLED);
+ : (mayInterruptIfRunning
+ ? Cancellation.CAUSELESS_INTERRUPTED
+ : Cancellation.CAUSELESS_CANCELLED);
AbstractFuture<?> abstractFuture = this;
while (true) {
if (ATOMIC_HELPER.casValue(abstractFuture, localValue, valueToSet)) {
@@ -777,7 +740,7 @@
* @return true if the attempt was accepted, completing the {@code Future}
*/
@CanIgnoreReturnValue
- protected boolean set(@ParametricNullness V value) {
+ protected boolean set(@Nullable V value) {
Object valueToSet = value == null ? NULL : value;
if (ATOMIC_HELPER.casValue(this, null, valueToSet)) {
complete(this);
@@ -853,7 +816,7 @@
}
return false;
}
- SetFuture<V> valueToSet = new SetFuture<V>(this, future);
+ SetFuture valueToSet = new SetFuture<V>(this, future);
if (ATOMIC_HELPER.casValue(this, null, valueToSet)) {
// the listener is responsible for calling completeWithFuture, directExecutor is appropriate
// since all we are doing is unpacking a completed future which should be fast.
@@ -910,8 +873,7 @@
: Cancellation.CAUSELESS_CANCELLED;
}
}
- // requireNonNull is safe as long as we call this method only on completed futures.
- return requireNonNull(v);
+ return v;
}
if (future instanceof InternalFutureFailureAccess) {
Throwable throwable =
@@ -923,11 +885,7 @@
boolean wasCancelled = future.isCancelled();
// Don't allocate a CancellationException if it's not necessary
if (!GENERATE_CANCELLATION_CAUSES & wasCancelled) {
- /*
- * requireNonNull is safe because we've initialized CAUSELESS_CANCELLED if
- * !GENERATE_CANCELLATION_CAUSES.
- */
- return requireNonNull(Cancellation.CAUSELESS_CANCELLED);
+ return Cancellation.CAUSELESS_CANCELLED;
}
// Otherwise calculate the value by calling .get()
try {
@@ -970,9 +928,7 @@
* An inlined private copy of {@link Uninterruptibles#getUninterruptibly} used to break an
* internal dependency on other /util/concurrent classes.
*/
- @ParametricNullness
- private static <V extends @Nullable Object> V getUninterruptibly(Future<V> future)
- throws ExecutionException {
+ private static <V> V getUninterruptibly(Future<V> future) throws ExecutionException {
boolean interrupted = false;
try {
while (true) {
@@ -990,10 +946,7 @@
}
/** Unblocks all threads and runs all listeners. */
- private static void complete(AbstractFuture<?> param) {
- // Declare a "true" local variable so that the Checker Framework will infer nullness.
- AbstractFuture<?> future = param;
-
+ private static void complete(AbstractFuture<?> future) {
Listener next = null;
outer:
while (true) {
@@ -1010,11 +963,7 @@
while (next != null) {
Listener curr = next;
next = next.next;
- /*
- * requireNonNull is safe because the listener stack never contains TOMBSTONE until after
- * clearListeners.
- */
- Runnable task = requireNonNull(curr.task);
+ Runnable task = curr.task;
if (task instanceof SetFuture) {
SetFuture<?> setFuture = (SetFuture<?>) task;
// We unwind setFuture specifically to avoid StackOverflowErrors in the case of long
@@ -1031,11 +980,7 @@
}
// other wise the future we were trying to set is already done.
} else {
- /*
- * requireNonNull is safe because the listener stack never contains TOMBSTONE until after
- * clearListeners.
- */
- executeListener(task, requireNonNull(curr.executor));
+ executeListener(task, curr.executor);
}
}
break;
@@ -1079,14 +1024,7 @@
* @since 27.0
*/
@Override
- /*
- * We should annotate the superclass, InternalFutureFailureAccess, to say that its copy of this
- * method returns @Nullable, too. However, we're not sure if we want to make any changes to that
- * class, since it's in a separate artifact that we planned to release only a single version of.
- */
- @SuppressWarnings("nullness")
- @CheckForNull
- protected final Throwable tryInternalFastPathGetFailure() {
+ protected final @Nullable Throwable tryInternalFastPathGetFailure() {
if (this instanceof Trusted) {
Object obj = value;
if (obj instanceof Failure) {
@@ -1100,7 +1038,7 @@
* If this future has been cancelled (and possibly interrupted), cancels (and possibly interrupts)
* the given future (if available).
*/
- final void maybePropagateCancellationTo(@CheckForNull Future<?> related) {
+ final void maybePropagateCancellationTo(@Nullable Future<?> related) {
if (related != null & isCancelled()) {
related.cancel(wasInterrupted());
}
@@ -1121,8 +1059,7 @@
* Clears the {@link #listeners} list and prepends its contents to {@code onto}, least recently
* added first.
*/
- @CheckForNull
- private Listener clearListeners(@CheckForNull Listener onto) {
+ private Listener clearListeners(Listener onto) {
// We need to
// 1. atomically swap the listeners with TOMBSTONE, this is because addListener uses that to
// to synchronize with us
@@ -1170,8 +1107,7 @@
* @return null if an explanation cannot be provided (e.g. because the future is done).
* @since 23.0
*/
- @CheckForNull
- protected String pendingToString() {
+ protected @Nullable String pendingToString() {
// TODO(diamondm) consider moving this into addPendingString so it's always in the output
if (this instanceof ScheduledFuture) {
return "remaining delay=["
@@ -1236,7 +1172,7 @@
* implementation. Using a reconstruction of the default Object.toString() prevents OOMs and stack
* overflows, and helps avoid sensitive data inadvertently ending up in exception messages.
*/
- private void appendResultObject(StringBuilder builder, @CheckForNull Object o) {
+ private void appendResultObject(StringBuilder builder, Object o) {
if (o == null) {
builder.append("null");
} else if (o == this) {
@@ -1250,7 +1186,7 @@
}
/** Helper for printing user supplied objects into our toString method. */
- private void appendUserObject(StringBuilder builder, @CheckForNull Object o) {
+ private void appendUserObject(StringBuilder builder, Object o) {
// This is some basic recursion detection for when people create cycles via set/setFuture or
// when deep chains of futures exist resulting in a StackOverflowException. We could detect
// arbitrary cycles using a thread local but this should be a good enough solution (it is also
@@ -1291,18 +1227,16 @@
abstract void putThread(Waiter waiter, Thread newValue);
/** Non volatile write of the waiter to the {@link Waiter#next} field. */
- abstract void putNext(Waiter waiter, @CheckForNull Waiter newValue);
+ abstract void putNext(Waiter waiter, Waiter newValue);
/** Performs a CAS operation on the {@link #waiters} field. */
- abstract boolean casWaiters(
- AbstractFuture<?> future, @CheckForNull Waiter expect, @CheckForNull Waiter update);
+ abstract boolean casWaiters(AbstractFuture<?> future, Waiter expect, Waiter update);
/** Performs a CAS operation on the {@link #listeners} field. */
- abstract boolean casListeners(
- AbstractFuture<?> future, @CheckForNull Listener expect, Listener update);
+ abstract boolean casListeners(AbstractFuture<?> future, Listener expect, Listener update);
/** Performs a CAS operation on the {@link #value} field. */
- abstract boolean casValue(AbstractFuture<?> future, @CheckForNull Object expect, Object update);
+ abstract boolean casValue(AbstractFuture<?> future, Object expect, Object update);
}
/**
@@ -1311,7 +1245,6 @@
* <p>Static initialization of this class will fail if the {@link sun.misc.Unsafe} object cannot
* be accessed.
*/
- @SuppressWarnings("sunapi")
private static final class UnsafeAtomicHelper extends AtomicHelper {
static final sun.misc.Unsafe UNSAFE;
static final long LISTENERS_OFFSET;
@@ -1366,32 +1299,30 @@
}
@Override
- void putNext(Waiter waiter, @CheckForNull Waiter newValue) {
+ void putNext(Waiter waiter, Waiter newValue) {
UNSAFE.putObject(waiter, WAITER_NEXT_OFFSET, newValue);
}
/** Performs a CAS operation on the {@link #waiters} field. */
@Override
- boolean casWaiters(
- AbstractFuture<?> future, @CheckForNull Waiter expect, @CheckForNull Waiter update) {
+ boolean casWaiters(AbstractFuture<?> future, Waiter expect, Waiter update) {
return UNSAFE.compareAndSwapObject(future, WAITERS_OFFSET, expect, update);
}
/** Performs a CAS operation on the {@link #listeners} field. */
@Override
- boolean casListeners(AbstractFuture<?> future, @CheckForNull Listener expect, Listener update) {
+ boolean casListeners(AbstractFuture<?> future, Listener expect, Listener update) {
return UNSAFE.compareAndSwapObject(future, LISTENERS_OFFSET, expect, update);
}
/** Performs a CAS operation on the {@link #value} field. */
@Override
- boolean casValue(AbstractFuture<?> future, @CheckForNull Object expect, Object update) {
+ boolean casValue(AbstractFuture<?> future, Object expect, Object update) {
return UNSAFE.compareAndSwapObject(future, VALUE_OFFSET, expect, update);
}
}
/** {@link AtomicHelper} based on {@link AtomicReferenceFieldUpdater}. */
- @SuppressWarnings("rawtypes")
private static final class SafeAtomicHelper extends AtomicHelper {
final AtomicReferenceFieldUpdater<Waiter, Thread> waiterThreadUpdater;
final AtomicReferenceFieldUpdater<Waiter, Waiter> waiterNextUpdater;
@@ -1418,23 +1349,22 @@
}
@Override
- void putNext(Waiter waiter, @CheckForNull Waiter newValue) {
+ void putNext(Waiter waiter, Waiter newValue) {
waiterNextUpdater.lazySet(waiter, newValue);
}
@Override
- boolean casWaiters(
- AbstractFuture<?> future, @CheckForNull Waiter expect, @CheckForNull Waiter update) {
+ boolean casWaiters(AbstractFuture<?> future, Waiter expect, Waiter update) {
return waitersUpdater.compareAndSet(future, expect, update);
}
@Override
- boolean casListeners(AbstractFuture<?> future, @CheckForNull Listener expect, Listener update) {
+ boolean casListeners(AbstractFuture<?> future, Listener expect, Listener update) {
return listenersUpdater.compareAndSet(future, expect, update);
}
@Override
- boolean casValue(AbstractFuture<?> future, @CheckForNull Object expect, Object update) {
+ boolean casValue(AbstractFuture<?> future, Object expect, Object update) {
return valueUpdater.compareAndSet(future, expect, update);
}
}
@@ -1452,13 +1382,12 @@
}
@Override
- void putNext(Waiter waiter, @CheckForNull Waiter newValue) {
+ void putNext(Waiter waiter, Waiter newValue) {
waiter.next = newValue;
}
@Override
- boolean casWaiters(
- AbstractFuture<?> future, @CheckForNull Waiter expect, @CheckForNull Waiter update) {
+ boolean casWaiters(AbstractFuture<?> future, Waiter expect, Waiter update) {
synchronized (future) {
if (future.waiters == expect) {
future.waiters = update;
@@ -1469,7 +1398,7 @@
}
@Override
- boolean casListeners(AbstractFuture<?> future, @CheckForNull Listener expect, Listener update) {
+ boolean casListeners(AbstractFuture<?> future, Listener expect, Listener update) {
synchronized (future) {
if (future.listeners == expect) {
future.listeners = update;
@@ -1480,7 +1409,7 @@
}
@Override
- boolean casValue(AbstractFuture<?> future, @CheckForNull Object expect, Object update) {
+ boolean casValue(AbstractFuture<?> future, Object expect, Object update) {
synchronized (future) {
if (future.value == expect) {
future.value = update;
@@ -1492,7 +1421,7 @@
}
private static CancellationException cancellationExceptionWithCause(
- String message, @CheckForNull 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/AbstractIdleService.java b/guava/src/com/google/common/util/concurrent/AbstractIdleService.java
index fe9faf9..b49db7a 100644
--- a/guava/src/com/google/common/util/concurrent/AbstractIdleService.java
+++ b/guava/src/com/google/common/util/concurrent/AbstractIdleService.java
@@ -32,7 +32,6 @@
* @since 1.0
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public abstract class AbstractIdleService implements Service {
/* Thread names will look like {@code "MyService STARTING"}. */
diff --git a/guava/src/com/google/common/util/concurrent/AbstractListeningExecutorService.java b/guava/src/com/google/common/util/concurrent/AbstractListeningExecutorService.java
index fd5c5c9..960f40e 100644
--- a/guava/src/com/google/common/util/concurrent/AbstractListeningExecutorService.java
+++ b/guava/src/com/google/common/util/concurrent/AbstractListeningExecutorService.java
@@ -36,20 +36,18 @@
@Beta
@CanIgnoreReturnValue
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public abstract class AbstractListeningExecutorService extends AbstractExecutorService
implements ListeningExecutorService {
/** @since 19.0 (present with return type {@code ListenableFutureTask} since 14.0) */
@Override
- protected final <T extends @Nullable Object> RunnableFuture<T> newTaskFor(
- Runnable runnable, @ParametricNullness T value) {
+ protected final <T> RunnableFuture<T> newTaskFor(Runnable runnable, T value) {
return TrustedListenableFutureTask.create(runnable, value);
}
/** @since 19.0 (present with return type {@code ListenableFutureTask} since 14.0) */
@Override
- protected final <T extends @Nullable Object> RunnableFuture<T> newTaskFor(Callable<T> callable) {
+ protected final <T> RunnableFuture<T> newTaskFor(Callable<T> callable) {
return TrustedListenableFutureTask.create(callable);
}
@@ -59,13 +57,12 @@
}
@Override
- public <T extends @Nullable Object> ListenableFuture<T> submit(
- Runnable task, @ParametricNullness T result) {
+ public <T> ListenableFuture<T> submit(Runnable task, @Nullable T result) {
return (ListenableFuture<T>) super.submit(task, result);
}
@Override
- public <T extends @Nullable Object> ListenableFuture<T> submit(Callable<T> task) {
+ public <T> ListenableFuture<T> submit(Callable<T> task) {
return (ListenableFuture<T>) super.submit(task);
}
}
diff --git a/guava/src/com/google/common/util/concurrent/AbstractScheduledService.java b/guava/src/com/google/common/util/concurrent/AbstractScheduledService.java
index 87fb6df..a7a342a 100644
--- a/guava/src/com/google/common/util/concurrent/AbstractScheduledService.java
+++ b/guava/src/com/google/common/util/concurrent/AbstractScheduledService.java
@@ -16,10 +16,8 @@
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.util.concurrent.Futures.immediateCancelledFuture;
import static com.google.common.util.concurrent.Internal.toNanosSaturated;
import static com.google.common.util.concurrent.MoreExecutors.directExecutor;
-import static java.util.Objects.requireNonNull;
import com.google.common.annotations.GwtIncompatible;
import com.google.common.base.Supplier;
@@ -32,14 +30,12 @@
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.concurrent.locks.ReentrantLock;
import java.util.logging.Level;
import java.util.logging.Logger;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -100,7 +96,6 @@
* @since 11.0
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public abstract class AbstractScheduledService implements Service {
private static final Logger logger = Logger.getLogger(AbstractScheduledService.class.getName());
@@ -147,10 +142,9 @@
checkArgument(delay > 0, "delay must be > 0, found %s", delay);
return new Scheduler() {
@Override
- public Cancellable schedule(
+ public Future<?> schedule(
AbstractService service, ScheduledExecutorService executor, Runnable task) {
- return new FutureAsCancellable(
- executor.scheduleWithFixedDelay(task, initialDelay, delay, unit));
+ return executor.scheduleWithFixedDelay(task, initialDelay, delay, unit);
}
};
}
@@ -183,16 +177,15 @@
checkArgument(period > 0, "period must be > 0, found %s", period);
return new Scheduler() {
@Override
- public Cancellable schedule(
+ public Future<?> schedule(
AbstractService service, ScheduledExecutorService executor, Runnable task) {
- return new FutureAsCancellable(
- executor.scheduleAtFixedRate(task, initialDelay, period, unit));
+ return executor.scheduleAtFixedRate(task, initialDelay, period, unit);
}
};
}
/** Schedules the task to run on the provided executor on behalf of the service. */
- abstract Cancellable schedule(
+ abstract Future<?> schedule(
AbstractService service, ScheduledExecutorService executor, Runnable runnable);
private Scheduler() {}
@@ -206,8 +199,8 @@
// A handle to the running task so that we can stop it when a shutdown has been requested.
// These two fields are volatile because their values will be accessed from multiple threads.
- @CheckForNull private volatile Cancellable runningTask;
- @CheckForNull private volatile ScheduledExecutorService executorService;
+ private volatile @Nullable Future<?> runningTask;
+ private volatile @Nullable ScheduledExecutorService executorService;
// This lock protects the task so we can ensure that none of the template methods (startUp,
// shutDown or runOneIteration) run concurrently with one another.
@@ -221,11 +214,7 @@
public void run() {
lock.lock();
try {
- /*
- * requireNonNull is safe because Task isn't run (or at least it doesn't succeed in taking
- * the lock) until after it's scheduled and the runningTask field is set.
- */
- if (requireNonNull(runningTask).isCancelled()) {
+ if (runningTask.isCancelled()) {
// task may have been cancelled while blocked on the lock.
return;
}
@@ -240,8 +229,7 @@
ignored);
}
notifyFailed(t);
- // requireNonNull is safe now, just as it was above.
- requireNonNull(runningTask).cancel(false); // prevent future invocations.
+ runningTask.cancel(false); // prevent future invocations.
} finally {
lock.unlock();
}
@@ -285,9 +273,6 @@
@Override
protected final void doStop() {
- // Both requireNonNull calls are safe because doStop can run only after a successful doStart.
- requireNonNull(runningTask);
- requireNonNull(executorService);
runningTask.cancel(false);
executorService.execute(
new Runnable() {
@@ -360,9 +345,9 @@
* fails}. Subclasses may override this method to supply a custom {@link ScheduledExecutorService}
* instance. This method is guaranteed to only be called once.
*
- * <p>By default this returns a new {@link ScheduledExecutorService} with a single thread pool
- * that sets the name of the thread to the {@linkplain #serviceName() service name}. Also, the
- * pool will be {@linkplain ScheduledExecutorService#shutdown() shut down} when the service
+ * <p>By default this returns a new {@link ScheduledExecutorService} with a single thread thread
+ * pool that sets the name of the thread to the {@linkplain #serviceName() service name}. Also,
+ * the pool will be {@linkplain ScheduledExecutorService#shutdown() shut down} when the service
* {@linkplain Service.State#TERMINATED terminates} or {@linkplain Service.State#TERMINATED
* fails}.
*/
@@ -486,30 +471,6 @@
delegate.awaitTerminated(timeout, unit);
}
- interface Cancellable {
- void cancel(boolean mayInterruptIfRunning);
-
- boolean isCancelled();
- }
-
- private static final class FutureAsCancellable implements Cancellable {
- private final Future<?> delegate;
-
- FutureAsCancellable(Future<?> delegate) {
- this.delegate = delegate;
- }
-
- @Override
- public void cancel(boolean mayInterruptIfRunning) {
- delegate.cancel(mayInterruptIfRunning);
- }
-
- @Override
- public boolean isCancelled() {
- return delegate.isCancelled();
- }
- }
-
/**
* A {@link Scheduler} that provides a convenient way for the {@link AbstractScheduledService} to
* use a dynamically changing schedule. After every execution of the task, assuming it hasn't been
@@ -521,7 +482,7 @@
public abstract static class CustomScheduler extends Scheduler {
/** A callable class that can reschedule itself using a {@link CustomScheduler}. */
- private final class ReschedulableCallable implements Callable<@Nullable Void> {
+ private class ReschedulableCallable extends ForwardingFuture<Void> implements Callable<Void> {
/** The underlying task. */
private final Runnable wrappedRunnable;
@@ -533,27 +494,6 @@
* The service that is managing this callable. This is used so that failure can be reported
* properly.
*/
- /*
- * This reference is part of a reference cycle, which is typically something we want to avoid
- * under j2objc -- but it is not detected by our j2objc cycle test. The cycle:
- *
- * - CustomScheduler.service contains an instance of ServiceDelegate. (It needs it so that it
- * can call notifyFailed.)
- *
- * - ServiceDelegate.runningTask contains an instance of ReschedulableCallable (at least in
- * the case that the service is using CustomScheduler). (It needs it so that it can cancel
- * the task and detect whether it has been cancelled.)
- *
- * - ReschedulableCallable has a reference back to its enclosing CustomScheduler. (It needs it
- * so that it can call getNextSchedule).
- *
- * Maybe there is a way to avoid this cycle. But we think the cycle is safe enough to ignore:
- * Each task is retained for only as long as it is running -- so it's retained only as long as
- * it would already be retained by the underlying executor.
- *
- * If the cycle test starts reporting this cycle in the future, we should add an entry to
- * cycle_suppress_list.txt.
- */
private final AbstractService service;
/**
@@ -565,8 +505,7 @@
/** The future that represents the next execution of this task. */
@GuardedBy("lock")
- @CheckForNull
- private SupplantableFuture cancellationDelegate;
+ private @Nullable Future<Void> currentFuture;
ReschedulableCallable(
AbstractService service, ScheduledExecutorService executor, Runnable runnable) {
@@ -576,36 +515,32 @@
}
@Override
- @CheckForNull
public Void call() throws Exception {
wrappedRunnable.run();
reschedule();
return null;
}
- /**
- * Atomically reschedules this task and assigns the new future to {@link
- * #cancellationDelegate}.
- */
- @CanIgnoreReturnValue
- public Cancellable reschedule() {
+ /** Atomically reschedules this task and assigns the new future to {@link #currentFuture}. */
+ public void reschedule() {
// invoke the callback outside the lock, prevents some shenanigans.
Schedule schedule;
try {
schedule = CustomScheduler.this.getNextSchedule();
} catch (Throwable t) {
service.notifyFailed(t);
- return new FutureAsCancellable(immediateCancelledFuture());
+ return;
}
// We reschedule ourselves with a lock held for two reasons. 1. we want to make sure that
// cancel calls cancel on the correct future. 2. we want to make sure that the assignment
// to currentFuture doesn't race with itself so that currentFuture is assigned in the
// correct order.
Throwable scheduleFailure = null;
- Cancellable toReturn;
lock.lock();
try {
- toReturn = initializeOrUpdateCancellationDelegate(schedule);
+ if (currentFuture == null || !currentFuture.isCancelled()) {
+ currentFuture = executor.schedule(this, schedule.delay, schedule.unit);
+ }
} catch (Throwable e) {
// If an exception is thrown by the subclass then we need to make sure that the service
// notices and transitions to the FAILED state. We do it by calling notifyFailed directly
@@ -616,7 +551,6 @@
// the AbstractService could monitor the future directly. Rescheduling is still hard...
// but it would help with some of these lock ordering issues.
scheduleFailure = e;
- toReturn = new FutureAsCancellable(immediateCancelledFuture());
} finally {
lock.unlock();
}
@@ -624,63 +558,16 @@
if (scheduleFailure != null) {
service.notifyFailed(scheduleFailure);
}
- return toReturn;
}
- @GuardedBy("lock")
- /*
- * The GuardedBy checker warns us that we're not holding cancellationDelegate.lock. But in
- * fact we are holding it because it is the same as this.lock, which we know we are holding,
- * thanks to @GuardedBy above. (cancellationDelegate.lock is initialized to this.lock in the
- * call to `new SupplantableFuture` below.)
- */
- @SuppressWarnings("GuardedBy")
- private Cancellable initializeOrUpdateCancellationDelegate(Schedule schedule) {
- if (cancellationDelegate == null) {
- return cancellationDelegate = new SupplantableFuture(lock, submitToExecutor(schedule));
- }
- if (!cancellationDelegate.currentFuture.isCancelled()) {
- cancellationDelegate.currentFuture = submitToExecutor(schedule);
- }
- return cancellationDelegate;
- }
-
- private ScheduledFuture<@Nullable Void> submitToExecutor(Schedule schedule) {
- return executor.schedule(this, schedule.delay, schedule.unit);
- }
- }
-
- /**
- * Contains the most recently submitted {@code Future}, which may be cancelled or updated,
- * always under a lock.
- */
- private static final class SupplantableFuture implements Cancellable {
- private final ReentrantLock lock;
-
- @GuardedBy("lock")
- private Future<@Nullable Void> currentFuture;
-
- SupplantableFuture(ReentrantLock lock, Future<@Nullable Void> currentFuture) {
- this.lock = lock;
- this.currentFuture = currentFuture;
- }
-
+ // N.B. Only protect cancel and isCancelled because those are the only methods that are
+ // invoked by the AbstractScheduledService.
@Override
- public void cancel(boolean mayInterruptIfRunning) {
- /*
- * Lock to ensure that a task cannot be rescheduled while a cancel is ongoing.
- *
- * In theory, cancel() could execute arbitrary listeners -- bad to do while holding a lock.
- * However, we don't expose currentFuture to users, so they can't attach listeners. And the
- * Future might not even be a ListenableFuture, just a plain Future. That said, similar
- * problems can exist with methods like FutureTask.done(), not to mention slow calls to
- * Thread.interrupt() (as discussed in InterruptibleTask). At the end of the day, it's
- * unlikely that cancel() will be slow, so we can probably get away with calling it while
- * holding a lock. Still, it would be nice to avoid somehow.
- */
+ public boolean cancel(boolean mayInterruptIfRunning) {
+ // Ensure that a task cannot be rescheduled while a cancel is ongoing.
lock.lock();
try {
- currentFuture.cancel(mayInterruptIfRunning);
+ return currentFuture.cancel(mayInterruptIfRunning);
} finally {
lock.unlock();
}
@@ -695,12 +582,20 @@
lock.unlock();
}
}
+
+ @Override
+ protected Future<Void> delegate() {
+ throw new UnsupportedOperationException(
+ "Only cancel and isCancelled is supported by this future");
+ }
}
@Override
- final Cancellable schedule(
+ final Future<?> schedule(
AbstractService service, ScheduledExecutorService executor, Runnable runnable) {
- return new ReschedulableCallable(service, executor, runnable).reschedule();
+ ReschedulableCallable task = new ReschedulableCallable(service, executor, runnable);
+ task.reschedule();
+ return task;
}
/**
diff --git a/guava/src/com/google/common/util/concurrent/AbstractService.java b/guava/src/com/google/common/util/concurrent/AbstractService.java
index ae40096..f5d38ed 100644
--- a/guava/src/com/google/common/util/concurrent/AbstractService.java
+++ b/guava/src/com/google/common/util/concurrent/AbstractService.java
@@ -23,7 +23,6 @@
import static com.google.common.util.concurrent.Service.State.STARTING;
import static com.google.common.util.concurrent.Service.State.STOPPING;
import static com.google.common.util.concurrent.Service.State.TERMINATED;
-import static java.util.Objects.requireNonNull;
import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtIncompatible;
@@ -37,7 +36,7 @@
import java.util.concurrent.Executor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Base class for implementing services that can handle {@link #doStart} and {@link #doStop}
@@ -50,7 +49,6 @@
* @since 1.0
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public abstract class AbstractService implements Service {
private static final ListenerCallQueue.Event<Listener> STARTING_EVENT =
new ListenerCallQueue.Event<Listener>() {
@@ -172,7 +170,7 @@
@Override
public boolean isSatisfied() {
- return state().compareTo(TERMINATED) >= 0;
+ return state().isTerminal();
}
}
@@ -590,20 +588,20 @@
* The exception that caused this service to fail. This will be {@code null} unless the service
* has failed.
*/
- @CheckForNull final Throwable failure;
+ final @Nullable Throwable failure;
StateSnapshot(State internalState) {
this(internalState, false, null);
}
StateSnapshot(
- State internalState, boolean shutdownWhenStartupFinishes, @CheckForNull 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.",
internalState);
checkArgument(
- (failure != null) == (internalState == FAILED),
+ !(failure != null ^ internalState == FAILED),
"A failure cause should be set if and only if the state is failed. Got %s and %s "
+ "instead.",
internalState,
@@ -628,8 +626,7 @@
state == FAILED,
"failureCause() is only valid if the service has failed, service is %s",
state);
- // requireNonNull is safe because the constructor requires a non-null cause with state=FAILED.
- return requireNonNull(failure);
+ return failure;
}
}
}
diff --git a/guava/src/com/google/common/util/concurrent/AbstractTransformFuture.java b/guava/src/com/google/common/util/concurrent/AbstractTransformFuture.java
index dd68791..e254dc6 100644
--- a/guava/src/com/google/common/util/concurrent/AbstractTransformFuture.java
+++ b/guava/src/com/google/common/util/concurrent/AbstractTransformFuture.java
@@ -24,17 +24,13 @@
import java.util.concurrent.CancellationException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executor;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/** Implementations of {@code Futures.transform*}. */
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-@SuppressWarnings("nullness") // TODO(b/147136275): Remove once our checker understands & and |.
-abstract class AbstractTransformFuture<
- I extends @Nullable Object, O extends @Nullable Object, F, T extends @Nullable Object>
- extends FluentFuture.TrustedFuture<O> implements Runnable {
- static <I extends @Nullable Object, O extends @Nullable Object> ListenableFuture<O> create(
+abstract class AbstractTransformFuture<I, O, F, T> extends FluentFuture.TrustedFuture<O>
+ implements Runnable {
+ static <I, O> ListenableFuture<O> create(
ListenableFuture<I> input,
AsyncFunction<? super I, ? extends O> function,
Executor executor) {
@@ -44,7 +40,7 @@
return output;
}
- static <I extends @Nullable Object, O extends @Nullable Object> ListenableFuture<O> create(
+ static <I, O> ListenableFuture<O> create(
ListenableFuture<I> input, Function<? super I, ? extends O> function, Executor executor) {
checkNotNull(function);
TransformFuture<I, O> output = new TransformFuture<>(input, function);
@@ -56,8 +52,8 @@
* 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.
*/
- @CheckForNull ListenableFuture<? extends I> inputFuture;
- @CheckForNull F function;
+ @Nullable ListenableFuture<? extends I> inputFuture;
+ @Nullable F function;
AbstractTransformFuture(ListenableFuture<? extends I> inputFuture, F function) {
this.inputFuture = checkNotNull(inputFuture);
@@ -169,12 +165,11 @@
/** Template method for subtypes to actually run the transform. */
@ForOverride
- @ParametricNullness
- abstract T doTransform(F function, @ParametricNullness I result) throws Exception;
+ abstract @Nullable T doTransform(F function, @Nullable I result) throws Exception;
/** Template method for subtypes to actually set the result. */
@ForOverride
- abstract void setResult(@ParametricNullness T result);
+ abstract void setResult(@Nullable T result);
@Override
protected final void afterDone() {
@@ -184,7 +179,6 @@
}
@Override
- @CheckForNull
protected String pendingToString() {
ListenableFuture<? extends I> localInputFuture = inputFuture;
F localFunction = function;
@@ -205,8 +199,7 @@
* An {@link AbstractTransformFuture} that delegates to an {@link AsyncFunction} and {@link
* #setFuture(ListenableFuture)}.
*/
- private static final class AsyncTransformFuture<
- I extends @Nullable Object, O extends @Nullable Object>
+ private static final class AsyncTransformFuture<I, O>
extends AbstractTransformFuture<
I, O, AsyncFunction<? super I, ? extends O>, ListenableFuture<? extends O>> {
AsyncTransformFuture(
@@ -216,8 +209,7 @@
@Override
ListenableFuture<? extends O> doTransform(
- AsyncFunction<? super I, ? extends O> function, @ParametricNullness I input)
- throws Exception {
+ AsyncFunction<? super I, ? extends O> function, @Nullable I input) throws Exception {
ListenableFuture<? extends O> outputFuture = function.apply(input);
checkNotNull(
outputFuture,
@@ -237,7 +229,7 @@
* An {@link AbstractTransformFuture} that delegates to a {@link Function} and {@link
* #set(Object)}.
*/
- private static final class TransformFuture<I extends @Nullable Object, O extends @Nullable Object>
+ private static final class TransformFuture<I, O>
extends AbstractTransformFuture<I, O, Function<? super I, ? extends O>, O> {
TransformFuture(
ListenableFuture<? extends I> inputFuture, Function<? super I, ? extends O> function) {
@@ -245,13 +237,13 @@
}
@Override
- @ParametricNullness
- O doTransform(Function<? super I, ? extends O> function, @ParametricNullness I input) {
+ @Nullable
+ O doTransform(Function<? super I, ? extends O> function, @Nullable I input) {
return function.apply(input);
}
@Override
- void setResult(@ParametricNullness 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 a32e76c..596a5ae 100644
--- a/guava/src/com/google/common/util/concurrent/AggregateFuture.java
+++ b/guava/src/com/google/common/util/concurrent/AggregateFuture.java
@@ -20,7 +20,6 @@
import static com.google.common.util.concurrent.AggregateFuture.ReleaseResourcesReason.OUTPUT_FUTURE_DONE;
import static com.google.common.util.concurrent.Futures.getDone;
import static com.google.common.util.concurrent.MoreExecutors.directExecutor;
-import static java.util.Objects.requireNonNull;
import static java.util.logging.Level.SEVERE;
import com.google.common.annotations.GwtCompatible;
@@ -31,7 +30,6 @@
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.logging.Logger;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -41,9 +39,7 @@
* @param <OutputT> the type of the output (i.e. this) future
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-abstract class AggregateFuture<InputT extends @Nullable Object, OutputT extends @Nullable Object>
- extends AggregateFutureState<OutputT> {
+abstract class AggregateFuture<InputT, OutputT> extends AggregateFutureState<OutputT> {
private static final Logger logger = Logger.getLogger(AggregateFuture.class.getName());
/**
@@ -56,7 +52,7 @@
* 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.
*/
- @CheckForNull private ImmutableCollection<? extends ListenableFuture<? extends InputT>> futures;
+ private @Nullable ImmutableCollection<? extends ListenableFuture<? extends InputT>> futures;
private final boolean allMustSucceed;
private final boolean collectsValues;
@@ -91,7 +87,6 @@
}
@Override
- @CheckForNull
protected final String pendingToString() {
ImmutableCollection<? extends Future<?>> localFutures = futures;
if (localFutures != null) {
@@ -108,13 +103,6 @@
* we're guaranteed to have properly initialized the subclass.
*/
final void init() {
- /*
- * requireNonNull is safe because this is called from the constructor after `futures` is set but
- * before releaseResources could be called (because we have not yet set up any of the listeners
- * that could call it, nor exposed this Future for users to call cancel() on).
- */
- requireNonNull(futures);
-
// Corner case: List is empty.
if (futures.isEmpty()) {
handleAllCompleted();
@@ -246,14 +234,8 @@
final void addInitialException(Set<Throwable> seen) {
checkNotNull(seen);
if (!isCancelled()) {
- /*
- * requireNonNull is safe because this is a TrustedFuture, and we're calling this method only
- * if it has failed.
- *
- * TODO(cpovirk): Think about whether we could/should use Verify to check the return value of
- * addCausalChain.
- */
- boolean unused = addCausalChain(seen, requireNonNull(tryInternalFastPathGetFailure()));
+ // TODO(cpovirk): Think about whether we could/should use Verify to check this.
+ boolean unused = addCausalChain(seen, tryInternalFastPathGetFailure());
}
}
@@ -273,7 +255,7 @@
}
private void decrementCountAndMaybeComplete(
- @CheckForNull
+ @Nullable
ImmutableCollection<? extends Future<? extends InputT>>
futuresIfNeedToCollectAtCompletion) {
int newRemaining = decrementRemainingAndGet();
@@ -284,7 +266,7 @@
}
private void processCompleted(
- @CheckForNull
+ @Nullable
ImmutableCollection<? extends Future<? extends InputT>>
futuresIfNeedToCollectAtCompletion) {
if (futuresIfNeedToCollectAtCompletion != null) {
@@ -340,15 +322,12 @@
* If {@code allMustSucceed} is true, called as each future completes; otherwise, if {@code
* collectsValues} is true, called for each future when all futures complete.
*/
- abstract void collectOneValue(int index, @ParametricNullness InputT returnValue);
+ abstract void collectOneValue(int index, @Nullable InputT returnValue);
abstract void handleAllCompleted();
/** Adds the chain to the seen set, and returns whether all the chain was new to us. */
- private static boolean addCausalChain(Set<Throwable> seen, Throwable param) {
- // Declare a "true" local variable so that the Checker Framework will infer nullness.
- Throwable t = param;
-
+ private static boolean addCausalChain(Set<Throwable> seen, Throwable t) {
for (; t != null; t = t.getCause()) {
boolean firstTimeSeen = seen.add(t);
if (!firstTimeSeen) {
diff --git a/guava/src/com/google/common/util/concurrent/AggregateFutureState.java b/guava/src/com/google/common/util/concurrent/AggregateFutureState.java
index ee23ca0..f8398d8 100644
--- a/guava/src/com/google/common/util/concurrent/AggregateFutureState.java
+++ b/guava/src/com/google/common/util/concurrent/AggregateFutureState.java
@@ -15,7 +15,6 @@
package com.google.common.util.concurrent;
import static com.google.common.collect.Sets.newConcurrentHashSet;
-import static java.util.Objects.requireNonNull;
import static java.util.concurrent.atomic.AtomicIntegerFieldUpdater.newUpdater;
import static java.util.concurrent.atomic.AtomicReferenceFieldUpdater.newUpdater;
@@ -26,8 +25,6 @@
import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;
import java.util.logging.Level;
import java.util.logging.Logger;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* A helper which does some thread-safe operations for aggregate futures, which must be implemented
@@ -40,12 +37,10 @@
*/
@GwtCompatible(emulated = true)
@ReflectionSupport(value = ReflectionSupport.Level.FULL)
-@ElementTypesAreNonnullByDefault
-abstract class AggregateFutureState<OutputT extends @Nullable Object>
- extends AbstractFuture.TrustedFuture<OutputT> {
+abstract class AggregateFutureState<OutputT> extends AbstractFuture.TrustedFuture<OutputT> {
// Lazily initialized the first time we see an exception; not released until all the input futures
// have completed and we have processed them all.
- @CheckForNull private volatile Set<Throwable> seenExceptions = null;
+ private volatile Set<Throwable> seenExceptions = null;
private volatile int remaining;
@@ -59,7 +54,7 @@
try {
helper =
new SafeAtomicHelper(
- newUpdater(AggregateFutureState.class, Set.class, "seenExceptions"),
+ newUpdater(AggregateFutureState.class, (Class) Set.class, "seenExceptions"),
newUpdater(AggregateFutureState.class, "remaining"));
} catch (Throwable reflectionFailure) {
// Some Android 5.0.x Samsung devices have bugs in JDK reflection APIs that cause
@@ -129,11 +124,8 @@
* other callers have added to it.
*
* This read is guaranteed to get us the right value because we only set this once (here).
- *
- * requireNonNull is safe because either our compareAndSet succeeded or it failed because
- * another thread did it for us.
*/
- seenExceptionsLocal = requireNonNull(seenExceptions);
+ seenExceptionsLocal = seenExceptions;
}
return seenExceptionsLocal;
}
@@ -152,37 +144,32 @@
private abstract static class AtomicHelper {
/** Atomic compare-and-set of the {@link AggregateFutureState#seenExceptions} field. */
abstract void compareAndSetSeenExceptions(
- AggregateFutureState<?> state, @CheckForNull Set<Throwable> expect, Set<Throwable> update);
+ AggregateFutureState state, Set<Throwable> expect, Set<Throwable> update);
/** Atomic decrement-and-get of the {@link AggregateFutureState#remaining} field. */
- abstract int decrementAndGetRemainingCount(AggregateFutureState<?> state);
+ abstract int decrementAndGetRemainingCount(AggregateFutureState state);
}
private static final class SafeAtomicHelper extends AtomicHelper {
- final AtomicReferenceFieldUpdater<AggregateFutureState<?>, Set<Throwable>>
- seenExceptionsUpdater;
+ final AtomicReferenceFieldUpdater<AggregateFutureState, Set<Throwable>> seenExceptionsUpdater;
- final AtomicIntegerFieldUpdater<AggregateFutureState<?>> remainingCountUpdater;
+ final AtomicIntegerFieldUpdater<AggregateFutureState> remainingCountUpdater;
- @SuppressWarnings({"rawtypes", "unchecked"}) // Unavoidable with reflection API
SafeAtomicHelper(
AtomicReferenceFieldUpdater seenExceptionsUpdater,
AtomicIntegerFieldUpdater remainingCountUpdater) {
- this.seenExceptionsUpdater =
- (AtomicReferenceFieldUpdater<AggregateFutureState<?>, Set<Throwable>>)
- seenExceptionsUpdater;
- this.remainingCountUpdater =
- (AtomicIntegerFieldUpdater<AggregateFutureState<?>>) remainingCountUpdater;
+ this.seenExceptionsUpdater = seenExceptionsUpdater;
+ this.remainingCountUpdater = remainingCountUpdater;
}
@Override
void compareAndSetSeenExceptions(
- AggregateFutureState<?> state, @CheckForNull Set<Throwable> expect, Set<Throwable> update) {
+ AggregateFutureState state, Set<Throwable> expect, Set<Throwable> update) {
seenExceptionsUpdater.compareAndSet(state, expect, update);
}
@Override
- int decrementAndGetRemainingCount(AggregateFutureState<?> state) {
+ int decrementAndGetRemainingCount(AggregateFutureState state) {
return remainingCountUpdater.decrementAndGet(state);
}
}
@@ -190,7 +177,7 @@
private static final class SynchronizedAtomicHelper extends AtomicHelper {
@Override
void compareAndSetSeenExceptions(
- AggregateFutureState<?> state, @CheckForNull Set<Throwable> expect, Set<Throwable> update) {
+ AggregateFutureState state, Set<Throwable> expect, Set<Throwable> update) {
synchronized (state) {
if (state.seenExceptions == expect) {
state.seenExceptions = update;
@@ -199,7 +186,7 @@
}
@Override
- int decrementAndGetRemainingCount(AggregateFutureState<?> state) {
+ int decrementAndGetRemainingCount(AggregateFutureState state) {
synchronized (state) {
return --state.remaining;
}
diff --git a/guava/src/com/google/common/util/concurrent/AsyncCallable.java b/guava/src/com/google/common/util/concurrent/AsyncCallable.java
index 826f3c2..f39a882 100644
--- a/guava/src/com/google/common/util/concurrent/AsyncCallable.java
+++ b/guava/src/com/google/common/util/concurrent/AsyncCallable.java
@@ -17,7 +17,6 @@
import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtCompatible;
import java.util.concurrent.Future;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Computes a value, possibly asynchronously. For an example usage and more information, see {@link
@@ -31,8 +30,7 @@
@Beta
@FunctionalInterface
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-public interface AsyncCallable<V extends @Nullable Object> {
+public interface AsyncCallable<V> {
/**
* Computes a result {@code Future}. The output {@code Future} need not be {@linkplain
* Future#isDone done}, making {@code AsyncCallable} suitable for asynchronous derivations.
diff --git a/guava/src/com/google/common/util/concurrent/AsyncFunction.java b/guava/src/com/google/common/util/concurrent/AsyncFunction.java
index 3a19db4..bae9bce 100644
--- a/guava/src/com/google/common/util/concurrent/AsyncFunction.java
+++ b/guava/src/com/google/common/util/concurrent/AsyncFunction.java
@@ -27,8 +27,7 @@
*/
@GwtCompatible
@FunctionalInterface
-@ElementTypesAreNonnullByDefault
-public interface AsyncFunction<I extends @Nullable Object, O extends @Nullable Object> {
+public interface AsyncFunction<I, O> {
/**
* Returns an output {@code Future} to use in place of the given {@code input}. The output {@code
* Future} need not be {@linkplain Future#isDone done}, making {@code AsyncFunction} suitable for
@@ -36,5 +35,5 @@
*
* <p>Throwing an exception from this method is equivalent to returning a failing {@code Future}.
*/
- ListenableFuture<O> apply(@ParametricNullness I input) throws Exception;
+ ListenableFuture<O> apply(@Nullable I input) throws Exception;
}
diff --git a/guava/src/com/google/common/util/concurrent/AtomicDouble.java b/guava/src/com/google/common/util/concurrent/AtomicDouble.java
index 81da695..8f881dd 100644
--- a/guava/src/com/google/common/util/concurrent/AtomicDouble.java
+++ b/guava/src/com/google/common/util/concurrent/AtomicDouble.java
@@ -53,7 +53,6 @@
*/
@GwtIncompatible
@ReflectionSupport(value = ReflectionSupport.Level.FULL)
-@ElementTypesAreNonnullByDefault
public class AtomicDouble extends Number implements java.io.Serializable {
private static final long serialVersionUID = 0L;
diff --git a/guava/src/com/google/common/util/concurrent/AtomicDoubleArray.java b/guava/src/com/google/common/util/concurrent/AtomicDoubleArray.java
index 58407f5..5c4baa1 100644
--- a/guava/src/com/google/common/util/concurrent/AtomicDoubleArray.java
+++ b/guava/src/com/google/common/util/concurrent/AtomicDoubleArray.java
@@ -44,7 +44,6 @@
* @since 11.0
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public class AtomicDoubleArray implements java.io.Serializable {
private static final long serialVersionUID = 0L;
@@ -97,7 +96,7 @@
}
/**
- * Atomically sets the element at position {@code i} to the given value.
+ * Sets the element at position {@code i} to the given value.
*
* @param i the index
* @param newValue the new value
diff --git a/guava/src/com/google/common/util/concurrent/AtomicLongMap.java b/guava/src/com/google/common/util/concurrent/AtomicLongMap.java
index 456b3ac..b80ef2e 100644
--- a/guava/src/com/google/common/util/concurrent/AtomicLongMap.java
+++ b/guava/src/com/google/common/util/concurrent/AtomicLongMap.java
@@ -29,7 +29,7 @@
import java.util.concurrent.atomic.AtomicLong;
import java.util.function.LongBinaryOperator;
import java.util.function.LongUnaryOperator;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* A map containing {@code long} values that can be atomically updated. While writes to a
@@ -55,7 +55,6 @@
* @since 11.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
public final class AtomicLongMap<K> implements Serializable {
private final ConcurrentHashMap<K, Long> map;
@@ -263,7 +262,7 @@
return map.values().stream().mapToLong(Long::longValue).sum();
}
- @CheckForNull private transient Map<K, Long> asMap;
+ private transient @Nullable Map<K, Long> asMap;
/** Returns a live, read-only view of the map backing this {@code AtomicLongMap}. */
public Map<K, Long> asMap() {
diff --git a/guava/src/com/google/common/util/concurrent/Atomics.java b/guava/src/com/google/common/util/concurrent/Atomics.java
index c1b6964..191da95 100644
--- a/guava/src/com/google/common/util/concurrent/Atomics.java
+++ b/guava/src/com/google/common/util/concurrent/Atomics.java
@@ -26,7 +26,6 @@
* @since 10.0
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public final class Atomics {
private Atomics() {}
@@ -35,8 +34,8 @@
*
* @return a new {@code AtomicReference} with no initial value
*/
- public static <V> AtomicReference<@Nullable V> newReference() {
- return new AtomicReference<>();
+ public static <V> AtomicReference<V> newReference() {
+ return new AtomicReference<V>();
}
/**
@@ -45,9 +44,8 @@
* @param initialValue the initial value
* @return a new {@code AtomicReference} with the given initial value
*/
- public static <V extends @Nullable Object> AtomicReference<V> newReference(
- @ParametricNullness V initialValue) {
- return new AtomicReference<>(initialValue);
+ public static <V> AtomicReference<V> newReference(@Nullable V initialValue) {
+ return new AtomicReference<V>(initialValue);
}
/**
@@ -56,8 +54,8 @@
* @param length the length of the array
* @return a new {@code AtomicReferenceArray} with the given length
*/
- public static <E> AtomicReferenceArray<@Nullable E> newReferenceArray(int length) {
- return new AtomicReferenceArray<>(length);
+ public static <E> AtomicReferenceArray<E> newReferenceArray(int length) {
+ return new AtomicReferenceArray<E>(length);
}
/**
@@ -67,7 +65,7 @@
* @param array the array to copy elements from
* @return a new {@code AtomicReferenceArray} copied from the given array
*/
- public static <E extends @Nullable Object> AtomicReferenceArray<E> newReferenceArray(E[] array) {
- return new AtomicReferenceArray<>(array);
+ public static <E> AtomicReferenceArray<E> newReferenceArray(E[] array) {
+ return new AtomicReferenceArray<E>(array);
}
}
diff --git a/guava/src/com/google/common/util/concurrent/Callables.java b/guava/src/com/google/common/util/concurrent/Callables.java
index 47b5264..747ffa7 100644
--- a/guava/src/com/google/common/util/concurrent/Callables.java
+++ b/guava/src/com/google/common/util/concurrent/Callables.java
@@ -30,16 +30,13 @@
* @since 1.0
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
public final class Callables {
private Callables() {}
/** Creates a {@code Callable} which immediately returns a preset value each time it is called. */
- public static <T extends @Nullable Object> Callable<T> returning(
- @ParametricNullness final T value) {
+ public static <T> Callable<T> returning(final @Nullable T value) {
return new Callable<T>() {
@Override
- @ParametricNullness
public T call() {
return value;
}
@@ -56,7 +53,7 @@
*/
@Beta
@GwtIncompatible
- public static <T extends @Nullable Object> AsyncCallable<T> asAsyncCallable(
+ public static <T> AsyncCallable<T> asAsyncCallable(
final Callable<T> callable, final ListeningExecutorService listeningExecutorService) {
checkNotNull(callable);
checkNotNull(listeningExecutorService);
@@ -72,18 +69,18 @@
* Wraps the given callable such that for the duration of {@link Callable#call} the thread that is
* running will have the given name.
*
+ *
* @param callable The callable to wrap
* @param nameSupplier The supplier of thread names, {@link Supplier#get get} will be called once
* for each invocation of the wrapped callable.
*/
@GwtIncompatible // threads
- static <T extends @Nullable Object> Callable<T> threadRenaming(
+ static <T> Callable<T> threadRenaming(
final Callable<T> callable, final Supplier<String> nameSupplier) {
checkNotNull(nameSupplier);
checkNotNull(callable);
return new Callable<T>() {
@Override
- @ParametricNullness
public T call() throws Exception {
Thread currentThread = Thread.currentThread();
String oldName = currentThread.getName();
@@ -103,6 +100,7 @@
* Wraps the given runnable such that for the duration of {@link Runnable#run} the thread that is
* running with have the given name.
*
+ *
* @param task The Runnable to wrap
* @param nameSupplier The supplier of thread names, {@link Supplier#get get} will be called once
* for each invocation of the wrapped callable.
diff --git a/guava/src/com/google/common/util/concurrent/ClosingFuture.java b/guava/src/com/google/common/util/concurrent/ClosingFuture.java
index 8859fbc..d4c9265 100644
--- a/guava/src/com/google/common/util/concurrent/ClosingFuture.java
+++ b/guava/src/com/google/common/util/concurrent/ClosingFuture.java
@@ -59,7 +59,6 @@
import java.util.concurrent.RejectedExecutionException;
import java.util.concurrent.atomic.AtomicReference;
import java.util.logging.Logger;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -137,9 +136,8 @@
* <h4>Automatically closing</h4>
*
* You can extract a {@link Future} that represents the result of the last step in the pipeline by
- * calling {@link #finishToFuture()}. All objects the pipeline has captured for closing will begin
- * to be closed asynchronously <b>after</b> the returned {@code Future} is done: the future
- * completes before closing starts, rather than once it has finished.
+ * calling {@link #finishToFuture()}. When that final {@link Future} is done, all objects captured
+ * by all steps in the pipeline will be closed.
*
* <pre>{@code
* FluentFuture<UserName> userName =
@@ -192,9 +190,8 @@
// TODO(dpb): Consider reusing one CloseableList for the entire pipeline, modulo combinations.
@Beta // @Beta for one release.
@DoNotMock("Use ClosingFuture.from(Futures.immediate*Future)")
-@ElementTypesAreNonnullByDefault
// TODO(dpb): GWT compatibility.
-public final class ClosingFuture<V extends @Nullable Object> {
+public final class ClosingFuture<V> {
private static final Logger logger = Logger.getLogger(ClosingFuture.class.getName());
@@ -233,9 +230,8 @@
* @return the first argument
*/
@CanIgnoreReturnValue
- @ParametricNullness
public <C extends @Nullable Object & @Nullable AutoCloseable> C eventuallyClose(
- @ParametricNullness C closeable, Executor closingExecutor) {
+ C closeable, Executor closingExecutor) {
checkNotNull(closingExecutor);
if (closeable != null) {
list.add(closeable, closingExecutor);
@@ -258,29 +254,10 @@
* closer.eventuallyClose()} will be closed when the {@link ClosingFuture} pipeline is done (but
* not before this method completes), even if this method throws or the pipeline is cancelled.
*/
- @ParametricNullness
V call(DeferredCloser closer) throws Exception;
}
/**
- * An operation that computes a {@link ClosingFuture} of a result.
- *
- * @param <V> the type of the result
- * @since 30.1
- */
- @FunctionalInterface
- public interface AsyncClosingCallable<V extends @Nullable Object> {
- /**
- * Computes a result, or throws an exception if unable to do so.
- *
- * <p>Any objects that are passed to {@link DeferredCloser#eventuallyClose(Closeable, Executor)
- * closer.eventuallyClose()} will be closed when the {@link ClosingFuture} pipeline is done (but
- * not before this method completes), even if this method throws or the pipeline is cancelled.
- */
- ClosingFuture<V> call(DeferredCloser closer) throws Exception;
- }
-
- /**
* A function from an input to a result.
*
* @param <T> the type of the input to the function
@@ -296,8 +273,7 @@
* closer.eventuallyClose()} will be closed when the {@link ClosingFuture} pipeline is done (but
* not before this method completes), even if this method throws or the pipeline is cancelled.
*/
- @ParametricNullness
- U apply(DeferredCloser closer, @ParametricNullness T input) throws Exception;
+ U apply(DeferredCloser closer, T input) throws Exception;
}
/**
@@ -315,7 +291,7 @@
* closer.eventuallyClose()} will be closed when the {@link ClosingFuture} pipeline is done (but
* not before this method completes), even if this method throws or the pipeline is cancelled.
*/
- ClosingFuture<U> apply(DeferredCloser closer, @ParametricNullness T input) throws Exception;
+ ClosingFuture<U> apply(DeferredCloser closer, T input) throws Exception;
}
/**
@@ -328,7 +304,7 @@
* @param <V> the type of the value of a successful operation
* @see ClosingFuture#finishToValueAndCloser(ValueAndCloserConsumer, Executor)
*/
- public static final class ValueAndCloser<V extends @Nullable Object> {
+ public static final class ValueAndCloser<V> {
private final ClosingFuture<? extends V> closingFuture;
@@ -346,7 +322,7 @@
* @throws CancellationException if the computation was cancelled
* @throws ExecutionException if the computation threw an exception
*/
- @ParametricNullness
+ @Nullable
public V get() throws ExecutionException {
return getDone(closingFuture.future);
}
@@ -374,7 +350,7 @@
* @see ClosingFuture#finishToValueAndCloser(ValueAndCloserConsumer, Executor)
*/
@FunctionalInterface
- public interface ValueAndCloserConsumer<V extends @Nullable Object> {
+ public interface ValueAndCloserConsumer<V> {
/** Accepts a {@link ValueAndCloser} for the last step in a {@link ClosingFuture} pipeline. */
void accept(ValueAndCloser<V> valueAndCloser);
@@ -386,22 +362,11 @@
* @throws java.util.concurrent.RejectedExecutionException if the task cannot be scheduled for
* execution
*/
- public static <V extends @Nullable Object> ClosingFuture<V> submit(
- ClosingCallable<V> callable, Executor executor) {
+ public static <V> ClosingFuture<V> submit(ClosingCallable<V> callable, Executor executor) {
return new ClosingFuture<>(callable, executor);
}
- /**
- * Starts a {@link ClosingFuture} pipeline by submitting a callable block to an executor.
- *
- * @throws java.util.concurrent.RejectedExecutionException if the task cannot be scheduled for
- * execution
- * @since 30.1
- */
- public static <V extends @Nullable Object> ClosingFuture<V> submitAsync(
- AsyncClosingCallable<V> callable, Executor executor) {
- return new ClosingFuture<>(callable, executor);
- }
+ // TODO(dpb, cpovirk): Do we need submitAsync?
/**
* Starts a {@link ClosingFuture} pipeline with a {@link ListenableFuture}.
@@ -410,7 +375,7 @@
* implements {@link Closeable}. In order to start a pipeline with a value that will be closed
* when the pipeline is done, use {@link #submit(ClosingCallable, Executor)} instead.
*/
- public static <V extends @Nullable Object> ClosingFuture<V> from(ListenableFuture<V> future) {
+ public static <V> ClosingFuture<V> from(ListenableFuture<V> future) {
return new ClosingFuture<V>(future);
}
@@ -445,7 +410,7 @@
future,
new FutureCallback<@Nullable AutoCloseable>() {
@Override
- public void onSuccess(@CheckForNull AutoCloseable result) {
+ public void onSuccess(@Nullable AutoCloseable result) {
closingFuture.closeables.closer.eventuallyClose(result, closingExecutor);
}
@@ -498,8 +463,8 @@
* @throws IllegalStateException if a {@code ClosingFuture} has already been derived from any of
* the arguments, or if any has already been {@linkplain #finishToFuture() finished}
*/
- public static <V1 extends @Nullable Object, V2 extends @Nullable Object>
- Combiner2<V1, V2> whenAllSucceed(ClosingFuture<V1> future1, ClosingFuture<V2> future2) {
+ public static <V1, V2> Combiner2<V1, V2> whenAllSucceed(
+ ClosingFuture<V1> future1, ClosingFuture<V2> future2) {
return new Combiner2<>(future1, future2);
}
@@ -513,10 +478,8 @@
* @throws IllegalStateException if a {@code ClosingFuture} has already been derived from any of
* the arguments, or if any has already been {@linkplain #finishToFuture() finished}
*/
- public static <
- V1 extends @Nullable Object, V2 extends @Nullable Object, V3 extends @Nullable Object>
- Combiner3<V1, V2, V3> whenAllSucceed(
- ClosingFuture<V1> future1, ClosingFuture<V2> future2, ClosingFuture<V3> future3) {
+ public static <V1, V2, V3> Combiner3<V1, V2, V3> whenAllSucceed(
+ ClosingFuture<V1> future1, ClosingFuture<V2> future2, ClosingFuture<V3> future3) {
return new Combiner3<>(future1, future2, future3);
}
@@ -530,16 +493,11 @@
* @throws IllegalStateException if a {@code ClosingFuture} has already been derived from any of
* the arguments, or if any has already been {@linkplain #finishToFuture() finished}
*/
- public static <
- V1 extends @Nullable Object,
- V2 extends @Nullable Object,
- V3 extends @Nullable Object,
- V4 extends @Nullable Object>
- Combiner4<V1, V2, V3, V4> whenAllSucceed(
- ClosingFuture<V1> future1,
- ClosingFuture<V2> future2,
- ClosingFuture<V3> future3,
- ClosingFuture<V4> future4) {
+ public static <V1, V2, V3, V4> Combiner4<V1, V2, V3, V4> whenAllSucceed(
+ ClosingFuture<V1> future1,
+ ClosingFuture<V2> future2,
+ ClosingFuture<V3> future3,
+ ClosingFuture<V4> future4) {
return new Combiner4<>(future1, future2, future3, future4);
}
@@ -553,18 +511,12 @@
* @throws IllegalStateException if a {@code ClosingFuture} has already been derived from any of
* the arguments, or if any has already been {@linkplain #finishToFuture() finished}
*/
- public static <
- V1 extends @Nullable Object,
- V2 extends @Nullable Object,
- V3 extends @Nullable Object,
- V4 extends @Nullable Object,
- V5 extends @Nullable Object>
- Combiner5<V1, V2, V3, V4, V5> whenAllSucceed(
- ClosingFuture<V1> future1,
- ClosingFuture<V2> future2,
- ClosingFuture<V3> future3,
- ClosingFuture<V4> future4,
- ClosingFuture<V5> future5) {
+ public static <V1, V2, V3, V4, V5> Combiner5<V1, V2, V3, V4, V5> whenAllSucceed(
+ ClosingFuture<V1> future1,
+ ClosingFuture<V2> future2,
+ ClosingFuture<V3> future3,
+ ClosingFuture<V4> future4,
+ ClosingFuture<V5> future5) {
return new Combiner5<>(future1, future2, future3, future4, future5);
}
@@ -602,7 +554,6 @@
TrustedListenableFutureTask.create(
new Callable<V>() {
@Override
- @ParametricNullness
public V call() throws Exception {
return callable.call(closeables.closer);
}
@@ -616,32 +567,6 @@
this.future = task;
}
- private ClosingFuture(final AsyncClosingCallable<V> callable, Executor executor) {
- checkNotNull(callable);
- TrustedListenableFutureTask<V> task =
- TrustedListenableFutureTask.create(
- new AsyncCallable<V>() {
- @Override
- public ListenableFuture<V> call() throws Exception {
- CloseableList newCloseables = new CloseableList();
- try {
- ClosingFuture<V> closingFuture = callable.call(newCloseables.closer);
- closingFuture.becomeSubsumedInto(closeables);
- return closingFuture.future;
- } finally {
- closeables.add(newCloseables, directExecutor());
- }
- }
-
- @Override
- public String toString() {
- return callable.toString();
- }
- });
- executor.execute(task);
- this.future = task;
- }
-
/**
* Returns a future that finishes when this step does. Calling {@code get()} on the returned
* future returns {@code null} if the step is successful or throws the same exception that would
@@ -690,7 +615,7 @@
* one, or if this {@code ClosingFuture} has already been {@linkplain #finishToFuture()
* finished}
*/
- public <U extends @Nullable Object> ClosingFuture<U> transform(
+ public <U> ClosingFuture<U> transform(
final ClosingFunction<? super V, U> function, Executor executor) {
checkNotNull(function);
AsyncFunction<V, U> applyFunction =
@@ -784,7 +709,7 @@
* one, or if this {@code ClosingFuture} has already been {@linkplain #finishToFuture()
* finished}
*/
- public <U extends @Nullable Object> ClosingFuture<U> transformAsync(
+ public <U> ClosingFuture<U> transformAsync(
final AsyncClosingFunction<? super V, U> function, Executor executor) {
checkNotNull(function);
AsyncFunction<V, U> applyFunction =
@@ -828,8 +753,8 @@
* @param function transforms the value of a {@code ClosingFuture} step to a {@link
* ListenableFuture} with the value of a derived step
*/
- public static <V extends @Nullable Object, U extends @Nullable Object>
- AsyncClosingFunction<V, U> withoutCloser(final AsyncFunction<V, U> function) {
+ public static <V, U> AsyncClosingFunction<V, U> withoutCloser(
+ final AsyncFunction<V, U> function) {
checkNotNull(function);
return new AsyncClosingFunction<V, U>() {
@Override
@@ -1004,14 +929,9 @@
}
/**
- * Marks this step as the last step in the {@code ClosingFuture} pipeline.
- *
- * <p>The returned {@link Future} is completed when the pipeline's computation completes, or when
- * the pipeline is cancelled.
- *
- * <p>All objects the pipeline has captured for closing will begin to be closed asynchronously
- * <b>after</b> the returned {@code Future} is done: the future completes before closing starts,
- * rather than once it has finished.
+ * Marks this step as the last step in the {@code ClosingFuture} pipeline. When the returned
+ * {@link Future} is done, all objects captured for closing during the pipeline's computation will
+ * be closed.
*
* <p>After calling this method, you may not call {@link
* #finishToValueAndCloser(ValueAndCloserConsumer, Executor)}, this method, or any other
@@ -1098,7 +1018,7 @@
executor);
}
- private static <C extends @Nullable Object, V extends C> void provideValueAndCloser(
+ private static <C, V extends C> void provideValueAndCloser(
ValueAndCloserConsumer<C> consumer, ClosingFuture<V> closingFuture) {
consumer.accept(new ValueAndCloser<C>(closingFuture));
}
@@ -1134,7 +1054,7 @@
closeables.close();
}
- private <U extends @Nullable Object> ClosingFuture<U> derive(FluentFuture<U> future) {
+ private <U> ClosingFuture<U> derive(FluentFuture<U> future) {
ClosingFuture<U> derived = new ClosingFuture<>(future);
becomeSubsumedInto(derived.closeables);
return derived;
@@ -1170,7 +1090,6 @@
* CombiningCallable#call(DeferredCloser, Peeker)} or {@link
* AsyncCombiningCallable#call(DeferredCloser, Peeker)}
*/
- @ParametricNullness
public final <D extends @Nullable Object> D getDone(ClosingFuture<D> closingFuture)
throws ExecutionException {
checkState(beingCalled);
@@ -1178,7 +1097,6 @@
return Futures.getDone(closingFuture.future);
}
- @ParametricNullness
private <V extends @Nullable Object> V call(
CombiningCallable<V> combiner, CloseableList closeables) throws Exception {
beingCalled = true;
@@ -1253,7 +1171,6 @@
*
* @param peeker used to get the value of any of the input futures
*/
- @ParametricNullness
V call(DeferredCloser closer, Peeker peeker) throws Exception;
}
@@ -1302,12 +1219,11 @@
* <p>If the combiningCallable throws an {@code ExecutionException}, the cause of the thrown
* {@code ExecutionException} will be extracted and used as the failure of the derived step.
*/
- public <V extends @Nullable Object> ClosingFuture<V> call(
+ public <V> ClosingFuture<V> call(
final CombiningCallable<V> combiningCallable, Executor executor) {
Callable<V> callable =
new Callable<V>() {
@Override
- @ParametricNullness
public V call() throws Exception {
return new Peeker(inputs).call(combiningCallable, closeables);
}
@@ -1359,7 +1275,7 @@
* <p>The same warnings about doing heavyweight operations within {@link
* ClosingFuture#transformAsync(AsyncClosingFunction, Executor)} apply here.
*/
- public <V extends @Nullable Object> ClosingFuture<V> callAsync(
+ public <V> ClosingFuture<V> callAsync(
final AsyncCombiningCallable<V> combiningCallable, Executor executor) {
AsyncCallable<V> asyncCallable =
new AsyncCallable<V>() {
@@ -1379,7 +1295,7 @@
return derived;
}
- private FutureCombiner<@Nullable Object> futureCombiner() {
+ private FutureCombiner<Object> futureCombiner() {
return allMustSucceed
? Futures.whenAllSucceed(inputFutures())
: Futures.whenAllComplete(inputFutures());
@@ -1429,9 +1345,7 @@
* is done (but not before this method completes), even if this method throws or the pipeline
* is cancelled.
*/
- @ParametricNullness
- U apply(DeferredCloser closer, @ParametricNullness V1 value1, @ParametricNullness V2 value2)
- throws Exception;
+ U apply(DeferredCloser closer, V1 value1, V2 value2) throws Exception;
}
/**
@@ -1454,9 +1368,7 @@
* is done (but not before this method completes), even if this method throws or the pipeline
* is cancelled.
*/
- ClosingFuture<U> apply(
- DeferredCloser closer, @ParametricNullness V1 value1, @ParametricNullness V2 value2)
- throws Exception;
+ ClosingFuture<U> apply(DeferredCloser closer, V1 value1, V2 value2) throws Exception;
}
private final ClosingFuture<V1> future1;
@@ -1486,7 +1398,6 @@
return call(
new CombiningCallable<U>() {
@Override
- @ParametricNullness
public U call(DeferredCloser closer, Peeker peeker) throws Exception {
return function.apply(closer, peeker.getDone(future1), peeker.getDone(future2));
}
@@ -1588,13 +1499,7 @@
* is done (but not before this method completes), even if this method throws or the pipeline
* is cancelled.
*/
- @ParametricNullness
- U apply(
- DeferredCloser closer,
- @ParametricNullness V1 value1,
- @ParametricNullness V2 value2,
- @ParametricNullness V3 value3)
- throws Exception;
+ U apply(DeferredCloser closer, V1 value1, V2 value2, V3 v3) throws Exception;
}
/**
@@ -1620,11 +1525,7 @@
* is done (but not before this method completes), even if this method throws or the pipeline
* is cancelled.
*/
- ClosingFuture<U> apply(
- DeferredCloser closer,
- @ParametricNullness V1 value1,
- @ParametricNullness V2 value2,
- @ParametricNullness V3 value3)
+ ClosingFuture<U> apply(DeferredCloser closer, V1 value1, V2 value2, V3 value3)
throws Exception;
}
@@ -1658,7 +1559,6 @@
return call(
new CombiningCallable<U>() {
@Override
- @ParametricNullness
public U call(DeferredCloser closer, Peeker peeker) throws Exception {
return function.apply(
closer,
@@ -1774,14 +1674,7 @@
* is done (but not before this method completes), even if this method throws or the pipeline
* is cancelled.
*/
- @ParametricNullness
- U apply(
- DeferredCloser closer,
- @ParametricNullness V1 value1,
- @ParametricNullness V2 value2,
- @ParametricNullness V3 value3,
- @ParametricNullness V4 value4)
- throws Exception;
+ U apply(DeferredCloser closer, V1 value1, V2 value2, V3 value3, V4 value4) throws Exception;
}
/**
@@ -1810,12 +1703,7 @@
* is done (but not before this method completes), even if this method throws or the pipeline
* is cancelled.
*/
- ClosingFuture<U> apply(
- DeferredCloser closer,
- @ParametricNullness V1 value1,
- @ParametricNullness V2 value2,
- @ParametricNullness V3 value3,
- @ParametricNullness V4 value4)
+ ClosingFuture<U> apply(DeferredCloser closer, V1 value1, V2 value2, V3 value3, V4 value4)
throws Exception;
}
@@ -1854,7 +1742,6 @@
return call(
new CombiningCallable<U>() {
@Override
- @ParametricNullness
public U call(DeferredCloser closer, Peeker peeker) throws Exception {
return function.apply(
closer,
@@ -1977,14 +1864,7 @@
* is done (but not before this method completes), even if this method throws or the pipeline
* is cancelled.
*/
- @ParametricNullness
- U apply(
- DeferredCloser closer,
- @ParametricNullness V1 value1,
- @ParametricNullness V2 value2,
- @ParametricNullness V3 value3,
- @ParametricNullness V4 value4,
- @ParametricNullness V5 value5)
+ U apply(DeferredCloser closer, V1 value1, V2 value2, V3 value3, V4 value4, V5 value5)
throws Exception;
}
@@ -2017,12 +1897,7 @@
* is cancelled.
*/
ClosingFuture<U> apply(
- DeferredCloser closer,
- @ParametricNullness V1 value1,
- @ParametricNullness V2 value2,
- @ParametricNullness V3 value3,
- @ParametricNullness V4 value4,
- @ParametricNullness V5 value5)
+ DeferredCloser closer, V1 value1, V2 value2, V3 value3, V4 value4, V5 value5)
throws Exception;
}
@@ -2065,7 +1940,6 @@
return call(
new CombiningCallable<U>() {
@Override
- @ParametricNullness
public U call(DeferredCloser closer, Peeker peeker) throws Exception {
return function.apply(
closer,
@@ -2159,7 +2033,7 @@
}
}
- private static void closeQuietly(@CheckForNull final AutoCloseable closeable, Executor executor) {
+ private static void closeQuietly(final AutoCloseable closeable, Executor executor) {
if (closeable == null) {
return;
}
@@ -2201,12 +2075,10 @@
implements Closeable {
private final DeferredCloser closer = new DeferredCloser(this);
private volatile boolean closed;
- @CheckForNull private volatile CountDownLatch whenClosed;
+ private volatile CountDownLatch whenClosed;
- <V extends @Nullable Object, U extends @Nullable Object>
- ListenableFuture<U> applyClosingFunction(
- ClosingFunction<? super V, U> transformation, @ParametricNullness V input)
- throws Exception {
+ <V, U> ListenableFuture<U> applyClosingFunction(
+ ClosingFunction<? super V, U> transformation, V input) throws Exception {
// TODO(dpb): Consider ways to defer closing without creating a separate CloseableList.
CloseableList newCloseables = new CloseableList();
try {
@@ -2216,10 +2088,8 @@
}
}
- <V extends @Nullable Object, U extends @Nullable Object>
- FluentFuture<U> applyAsyncClosingFunction(
- AsyncClosingFunction<V, U> transformation, @ParametricNullness V input)
- throws Exception {
+ <V, U> FluentFuture<U> applyAsyncClosingFunction(
+ AsyncClosingFunction<V, U> transformation, V input) throws Exception {
// TODO(dpb): Consider ways to defer closing without creating a separate CloseableList.
CloseableList newCloseables = new CloseableList();
try {
@@ -2251,7 +2121,7 @@
}
}
- void add(@CheckForNull AutoCloseable closeable, Executor executor) {
+ void add(@Nullable AutoCloseable closeable, Executor executor) {
checkNotNull(executor);
if (closeable == null) {
return;
diff --git a/guava/src/com/google/common/util/concurrent/CollectionFuture.java b/guava/src/com/google/common/util/concurrent/CollectionFuture.java
index c106c15..9f0aa64 100644
--- a/guava/src/com/google/common/util/concurrent/CollectionFuture.java
+++ b/guava/src/com/google/common/util/concurrent/CollectionFuture.java
@@ -19,34 +19,32 @@
import com.google.common.annotations.GwtCompatible;
import com.google.common.collect.ImmutableCollection;
+import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
-import java.util.Collections;
import java.util.List;
-import javax.annotation.CheckForNull;
+import java.util.concurrent.Future;
import org.checkerframework.checker.nullness.qual.Nullable;
/** Aggregate future that collects (stores) results of each future. */
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
-abstract class CollectionFuture<V extends @Nullable Object, C extends @Nullable Object>
- extends AggregateFuture<V, C> {
+abstract class CollectionFuture<V, C> extends AggregateFuture<V, C> {
/*
* We access this field racily but safely. For discussion of a similar situation, see the comments
* on the fields of TimeoutFuture. This field is slightly different than the fields discussed
* there: cancel() never reads this field, only writes to it. That makes the race here completely
* harmless, rather than just 99.99% harmless.
*/
- @CheckForNull private List<@Nullable Present<V>> values;
+ private List<Present<V>> values;
CollectionFuture(
ImmutableCollection<? extends ListenableFuture<? extends V>> futures,
boolean allMustSucceed) {
super(futures, allMustSucceed, true);
- List<@Nullable Present<V>> values =
+ List<Present<V>> values =
futures.isEmpty()
- ? Collections.<@Nullable Present<V>>emptyList()
- : Lists.<@Nullable Present<V>>newArrayListWithCapacity(futures.size());
+ ? ImmutableList.<Present<V>>of()
+ : Lists.<Present<V>>newArrayListWithCapacity(futures.size());
// Populate the results list with null initially.
for (int i = 0; i < futures.size(); ++i) {
@@ -57,8 +55,8 @@
}
@Override
- final void collectOneValue(int index, @ParametricNullness V returnValue) {
- List<@Nullable Present<V>> localValues = values;
+ final void collectOneValue(int index, @Nullable V returnValue) {
+ List<Present<V>> localValues = values;
if (localValues != null) {
localValues.set(index, new Present<>(returnValue));
}
@@ -66,7 +64,7 @@
@Override
final void handleAllCompleted() {
- List<@Nullable Present<V>> localValues = values;
+ List<Present<V>> localValues = values;
if (localValues != null) {
set(combine(localValues));
}
@@ -78,11 +76,10 @@
this.values = null;
}
- abstract C combine(List<@Nullable Present<V>> values);
+ abstract C combine(List<Present<V>> values);
/** Used for {@link Futures#allAsList} and {@link Futures#successfulAsList}. */
- static final class ListFuture<V extends @Nullable Object>
- extends CollectionFuture<V, List<@Nullable V>> {
+ static final class ListFuture<V> extends CollectionFuture<V, List<V>> {
ListFuture(
ImmutableCollection<? extends ListenableFuture<? extends V>> futures,
boolean allMustSucceed) {
@@ -91,8 +88,8 @@
}
@Override
- public List<@Nullable V> combine(List<@Nullable Present<V>> values) {
- List<@Nullable V> result = newArrayListWithCapacity(values.size());
+ public List<V> combine(List<Present<V>> values) {
+ List<V> result = newArrayListWithCapacity(values.size());
for (Present<V> element : values) {
result.add(element != null ? element.value : null);
}
@@ -101,7 +98,7 @@
}
/** The result of a successful {@code Future}. */
- private static final class Present<V extends @Nullable Object> {
+ private static final class Present<V> {
V value;
Present(V value) {
diff --git a/guava/src/com/google/common/util/concurrent/CombinedFuture.java b/guava/src/com/google/common/util/concurrent/CombinedFuture.java
index c222111..b8b0e2c 100644
--- a/guava/src/com/google/common/util/concurrent/CombinedFuture.java
+++ b/guava/src/com/google/common/util/concurrent/CombinedFuture.java
@@ -25,15 +25,12 @@
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executor;
import java.util.concurrent.RejectedExecutionException;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/** Aggregate future that computes its value by calling a callable. */
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-final class CombinedFuture<V extends @Nullable Object>
- extends AggregateFuture<@Nullable Object, V> {
- @CheckForNull private CombinedFutureInterruptibleTask<?> task;
+final class CombinedFuture<V> extends AggregateFuture<Object, V> {
+ private CombinedFutureInterruptibleTask<?> task;
CombinedFuture(
ImmutableCollection<? extends ListenableFuture<?>> futures,
@@ -56,7 +53,7 @@
}
@Override
- void collectOneValue(int index, @CheckForNull Object returnValue) {}
+ void collectOneValue(int index, @Nullable Object returnValue) {}
@Override
void handleAllCompleted() {
@@ -90,8 +87,7 @@
}
@WeakOuter
- private abstract class CombinedFutureInterruptibleTask<T extends @Nullable Object>
- extends InterruptibleTask<T> {
+ private abstract class CombinedFutureInterruptibleTask<T> extends InterruptibleTask<T> {
private final Executor listenerExecutor;
CombinedFutureInterruptibleTask(Executor listenerExecutor) {
@@ -112,7 +108,7 @@
}
@Override
- final void afterRanInterruptiblySuccess(@ParametricNullness T result) {
+ final void afterRanInterruptibly(T result, Throwable error) {
/*
* The future no longer needs to interrupt this task, so it no longer needs a reference to it.
*
@@ -126,28 +122,20 @@
*/
CombinedFuture.this.task = null;
- setValue(result);
- }
-
- @Override
- final void afterRanInterruptiblyFailure(Throwable error) {
- // See afterRanInterruptiblySuccess.
- CombinedFuture.this.task = null;
-
- if (error instanceof ExecutionException) {
- /*
- * Cast to ExecutionException to satisfy our nullness checker, which (unsoundly but
- * *usually* safely) assumes that getCause() returns non-null on an ExecutionException.
- */
- CombinedFuture.this.setException(((ExecutionException) error).getCause());
- } else if (error instanceof CancellationException) {
- cancel(false);
+ if (error != null) {
+ if (error instanceof ExecutionException) {
+ CombinedFuture.this.setException(error.getCause());
+ } else if (error instanceof CancellationException) {
+ cancel(false);
+ } else {
+ CombinedFuture.this.setException(error);
+ }
} else {
- CombinedFuture.this.setException(error);
+ setValue(result);
}
}
- abstract void setValue(@ParametricNullness T value);
+ abstract void setValue(T value);
}
@WeakOuter
@@ -191,13 +179,12 @@
}
@Override
- @ParametricNullness
V runInterruptibly() throws Exception {
return callable.call();
}
@Override
- void setValue(@ParametricNullness V value) {
+ void setValue(V value) {
CombinedFuture.this.set(value);
}
diff --git a/guava/src/com/google/common/util/concurrent/CycleDetectingLockFactory.java b/guava/src/com/google/common/util/concurrent/CycleDetectingLockFactory.java
index b6b161d..67d2478 100644
--- a/guava/src/com/google/common/util/concurrent/CycleDetectingLockFactory.java
+++ b/guava/src/com/google/common/util/concurrent/CycleDetectingLockFactory.java
@@ -15,7 +15,6 @@
package com.google.common.util.concurrent;
import static com.google.common.base.Preconditions.checkNotNull;
-import static java.util.Objects.requireNonNull;
import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtIncompatible;
@@ -43,7 +42,7 @@
import java.util.concurrent.locks.ReentrantReadWriteLock;
import java.util.logging.Level;
import java.util.logging.Logger;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* The {@code CycleDetectingLockFactory} creates {@link ReentrantLock} instances and {@link
@@ -163,7 +162,6 @@
@Beta
@CanIgnoreReturnValue // TODO(cpovirk): Consider being more strict.
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public class CycleDetectingLockFactory {
/**
@@ -270,8 +268,7 @@
}
// A static mapping from an Enum type to its set of LockGraphNodes.
- private static final ConcurrentMap<
- Class<? extends Enum<?>>, Map<? extends Enum<?>, LockGraphNode>>
+ private static final ConcurrentMap<Class<? extends Enum>, Map<? extends Enum, LockGraphNode>>
lockGraphNodesPerType = new MapMaker().weakKeys().makeMap();
/** Creates a {@code CycleDetectingLockFactory.WithExplicitOrdering<E>}. */
@@ -286,15 +283,13 @@
return new WithExplicitOrdering<E>(policy, lockGraphNodes);
}
- @SuppressWarnings("unchecked")
- private static <E extends Enum<E>> Map<? extends E, LockGraphNode> getOrCreateNodes(
- Class<E> clazz) {
- Map<E, LockGraphNode> existing = (Map<E, LockGraphNode>) lockGraphNodesPerType.get(clazz);
+ private static Map<? extends Enum, LockGraphNode> getOrCreateNodes(Class<? extends Enum> clazz) {
+ Map<? extends Enum, LockGraphNode> existing = lockGraphNodesPerType.get(clazz);
if (existing != null) {
return existing;
}
- Map<E, LockGraphNode> created = createNodes(clazz);
- existing = (Map<E, LockGraphNode>) lockGraphNodesPerType.putIfAbsent(clazz, created);
+ Map<? extends Enum, LockGraphNode> created = createNodes(clazz);
+ existing = lockGraphNodesPerType.putIfAbsent(clazz, created);
return MoreObjects.firstNonNull(existing, created);
}
@@ -422,9 +417,7 @@
public ReentrantLock newReentrantLock(E rank, boolean fair) {
return policy == Policies.DISABLED
? new ReentrantLock(fair)
- // requireNonNull is safe because createNodes inserts an entry for every E.
- // (If the caller passes `null` for the `rank` parameter, this will throw, but that's OK.)
- : new CycleDetectingReentrantLock(requireNonNull(lockGraphNodes.get(rank)), fair);
+ : new CycleDetectingReentrantLock(lockGraphNodes.get(rank), fair);
}
/** Equivalent to {@code newReentrantReadWriteLock(rank, false)}. */
@@ -443,10 +436,7 @@
public ReentrantReadWriteLock newReentrantReadWriteLock(E rank, boolean fair) {
return policy == Policies.DISABLED
? new ReentrantReadWriteLock(fair)
- // requireNonNull is safe because createNodes inserts an entry for every E.
- // (If the caller passes `null` for the `rank` parameter, this will throw, but that's OK.)
- : new CycleDetectingReentrantReadWriteLock(
- requireNonNull(lockGraphNodes.get(rank)), fair);
+ : new CycleDetectingReentrantReadWriteLock(lockGraphNodes.get(rank), fair);
}
}
@@ -556,8 +546,7 @@
*/
@Override
public String getMessage() {
- // requireNonNull is safe because ExampleStackTrace sets a non-null message.
- StringBuilder message = new StringBuilder(requireNonNull(super.getMessage()));
+ StringBuilder message = new StringBuilder(super.getMessage());
for (Throwable t = conflictingStackTrace; t != null; t = t.getCause()) {
message.append(", ").append(t.getMessage());
}
@@ -610,8 +599,8 @@
}
void checkAcquiredLocks(Policy policy, List<LockGraphNode> acquiredLocks) {
- for (LockGraphNode acquiredLock : acquiredLocks) {
- checkAcquiredLock(policy, acquiredLock);
+ for (int i = 0, size = acquiredLocks.size(); i < size; i++) {
+ checkAcquiredLock(policy, acquiredLocks.get(i));
}
}
@@ -685,8 +674,7 @@
* @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.
*/
- @CheckForNull
- private ExampleStackTrace findPathTo(LockGraphNode node, Set<LockGraphNode> seen) {
+ private @Nullable ExampleStackTrace findPathTo(LockGraphNode node, Set<LockGraphNode> seen) {
if (!seen.add(this)) {
return null; // Already traversed this node.
}
diff --git a/guava/src/com/google/common/util/concurrent/DirectExecutor.java b/guava/src/com/google/common/util/concurrent/DirectExecutor.java
index 0c3a46b..3022971 100644
--- a/guava/src/com/google/common/util/concurrent/DirectExecutor.java
+++ b/guava/src/com/google/common/util/concurrent/DirectExecutor.java
@@ -22,7 +22,6 @@
* execute}.
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
enum DirectExecutor implements Executor {
INSTANCE;
diff --git a/guava/src/com/google/common/util/concurrent/ElementTypesAreNonnullByDefault.java b/guava/src/com/google/common/util/concurrent/ElementTypesAreNonnullByDefault.java
deleted file mode 100644
index 3487125..0000000
--- a/guava/src/com/google/common/util/concurrent/ElementTypesAreNonnullByDefault.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) 2021 The Guava Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.common.util.concurrent;
-
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.PARAMETER;
-import static java.lang.annotation.ElementType.TYPE;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-import com.google.common.annotations.GwtCompatible;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-import javax.annotation.Nonnull;
-import javax.annotation.meta.TypeQualifierDefault;
-
-/**
- * Marks all "top-level" types as non-null in a way that is recognized by Kotlin. Note that this
- * unfortunately includes type-variable usages, so we also provide {@link ParametricNullness} to
- * "undo" it as best we can.
- */
-@GwtCompatible
-@Retention(RUNTIME)
-@Target(TYPE)
-@TypeQualifierDefault({FIELD, METHOD, PARAMETER})
-@Nonnull
-@interface ElementTypesAreNonnullByDefault {}
diff --git a/guava/src/com/google/common/util/concurrent/ExecutionError.java b/guava/src/com/google/common/util/concurrent/ExecutionError.java
index deaff15..7663c15 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 javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* {@link Error} variant of {@link java.util.concurrent.ExecutionException}. As with {@code
@@ -28,29 +28,22 @@
* @since 10.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
public class ExecutionError extends Error {
- /*
- * Ideally, this class would have exposed only constructors that require a non-null cause. We
- * might try to move in that direction, but there are complications. See
- * https://github.com/jspecify/nullness-checker-for-checker-framework/blob/61aafa4ae52594830cfc2d61c8b113009dbdb045/src/main/java/com/google/jspecify/nullness/NullSpecTransfer.java#L789
- */
-
/** Creates a new instance with {@code null} as its detail message. */
protected ExecutionError() {}
/** Creates a new instance with the given detail message. */
- protected ExecutionError(@CheckForNull String message) {
+ protected ExecutionError(@Nullable String message) {
super(message);
}
/** Creates a new instance with the given detail message and cause. */
- public ExecutionError(@CheckForNull String message, @CheckForNull Error cause) {
+ public ExecutionError(@Nullable String message, @Nullable Error cause) {
super(message, cause);
}
/** Creates a new instance with the given cause. */
- public ExecutionError(@CheckForNull 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 96fc51c..1ff609b 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 javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* A support class for {@code ListenableFuture} implementations to manage their listeners. An
@@ -40,7 +40,6 @@
* @since 1.0
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public final class ExecutionList {
/** Logger to log exceptions caught when running runnables. */
private static final Logger log = Logger.getLogger(ExecutionList.class.getName());
@@ -50,8 +49,7 @@
* RunnableExecutorPair#next} field.
*/
@GuardedBy("this")
- @CheckForNull
- private RunnableExecutorPair runnables;
+ private @Nullable RunnableExecutorPair runnables;
@GuardedBy("this")
private boolean executed;
@@ -155,10 +153,9 @@
private static final class RunnableExecutorPair {
final Runnable runnable;
final Executor executor;
- @CheckForNull RunnableExecutorPair next;
+ @Nullable RunnableExecutorPair next;
- RunnableExecutorPair(
- Runnable runnable, Executor executor, @CheckForNull RunnableExecutorPair next) {
+ RunnableExecutorPair(Runnable runnable, Executor executor, RunnableExecutorPair next) {
this.runnable = runnable;
this.executor = executor;
this.next = next;
diff --git a/guava/src/com/google/common/util/concurrent/ExecutionSequencer.java b/guava/src/com/google/common/util/concurrent/ExecutionSequencer.java
index 148f50b..f589e08 100644
--- a/guava/src/com/google/common/util/concurrent/ExecutionSequencer.java
+++ b/guava/src/com/google/common/util/concurrent/ExecutionSequencer.java
@@ -23,14 +23,11 @@
import static com.google.common.util.concurrent.Futures.immediateFuture;
import static com.google.common.util.concurrent.Futures.immediateVoidFuture;
import static com.google.common.util.concurrent.MoreExecutors.directExecutor;
-import static java.util.Objects.requireNonNull;
import com.google.common.annotations.Beta;
import java.util.concurrent.Callable;
import java.util.concurrent.Executor;
import java.util.concurrent.atomic.AtomicReference;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Serializes execution of tasks, somewhat like an "asynchronous {@code synchronized} block." Each
@@ -81,7 +78,6 @@
* @since 26.0
*/
@Beta
-@ElementTypesAreNonnullByDefault
public final class ExecutionSequencer {
private ExecutionSequencer() {}
@@ -92,7 +88,7 @@
}
/** This reference acts as a pointer tracking the head of a linked list of ListenableFutures. */
- private final AtomicReference<ListenableFuture<@Nullable Void>> ref =
+ private final AtomicReference<ListenableFuture<Void>> ref =
new AtomicReference<>(immediateVoidFuture());
private ThreadConfinedTaskQueue latestTaskQueue = new ThreadConfinedTaskQueue();
@@ -126,11 +122,11 @@
* All the states where thread != currentThread are identical for our purposes, and so even
* though it's racy, we don't care which of those values we get, so no need to synchronize.
*/
- @CheckForNull Thread thread;
+ Thread thread;
/** Only used by the thread associated with this object */
- @CheckForNull Runnable nextTask;
+ Runnable nextTask;
/** Only used by the thread associated with this object */
- @CheckForNull Executor nextExecutor;
+ Executor nextExecutor;
}
/**
@@ -140,8 +136,7 @@
* execute, but if the output future is cancelled before {@link Callable#call()} is invoked,
* {@link Callable#call()} will not be invoked.
*/
- public <T extends @Nullable Object> ListenableFuture<T> submit(
- final Callable<T> callable, Executor executor) {
+ public <T> ListenableFuture<T> submit(final Callable<T> callable, Executor executor) {
checkNotNull(callable);
checkNotNull(executor);
return submitAsync(
@@ -166,7 +161,7 @@
* callable} or a callable that has begun to execute, but if the output future is cancelled before
* {@link AsyncCallable#call()} is invoked, {@link AsyncCallable#call()} will not be invoked.
*/
- public <T extends @Nullable Object> ListenableFuture<T> submitAsync(
+ public <T> ListenableFuture<T> submitAsync(
final AsyncCallable<T> callable, final Executor executor) {
checkNotNull(callable);
checkNotNull(executor);
@@ -197,9 +192,9 @@
* have completed - namely after oldFuture is done, and taskFuture has either completed or been
* cancelled before the callable started execution.
*/
- final SettableFuture<@Nullable Void> newFuture = SettableFuture.create();
+ final SettableFuture<Void> newFuture = SettableFuture.create();
- final ListenableFuture<@Nullable Void> oldFuture = ref.getAndSet(newFuture);
+ final ListenableFuture<Void> oldFuture = ref.getAndSet(newFuture);
// Invoke our task once the previous future completes.
final TrustedListenableFutureTask<T> taskFuture = TrustedListenableFutureTask.create(task);
@@ -284,6 +279,7 @@
* properties; for example, calling WeakReference.get() on Android will block during an
* otherwise-concurrent GC cycle.
*/
+ @SuppressWarnings("ShouldNotSubclass") // Saving an allocation here is worth it
private static final class TaskNonReentrantExecutor extends AtomicReference<RunningState>
implements Executor, Runnable {
@@ -291,22 +287,22 @@
* Used to update and read the latestTaskQueue field. Set to null once the runnable has been run
* or queued.
*/
- @CheckForNull ExecutionSequencer sequencer;
+ ExecutionSequencer sequencer;
/**
* Executor the task was set to run on. Set to null when the task has been queued, run, or
* cancelled.
*/
- @CheckForNull Executor delegate;
+ Executor delegate;
/**
* Set before calling delegate.execute(); set to null once run, so that it can be GCed; this
* object may live on after, if submitAsync returns an incomplete future.
*/
- @CheckForNull Runnable task;
+ Runnable task;
/** Thread that called execute(). Set in execute, cleared when delegate.execute() returns. */
- @CheckForNull Thread submitting;
+ Thread submitting;
private TaskNonReentrantExecutor(Executor delegate, ExecutionSequencer sequencer) {
super(NOT_RUN);
@@ -331,18 +327,8 @@
return;
}
submitting = Thread.currentThread();
-
try {
- /*
- * requireNonNull is safe because we don't null out `sequencer` except:
- *
- * - above, where we return (in which case we never get here)
- *
- * - in `run`, which can't run until this Runnable is submitted to an executor, which
- * doesn't happen until below. (And this Executor -- yes, the object is both a Runnable
- * and an Executor -- is used for only a single `execute` call.)
- */
- ThreadConfinedTaskQueue submittingTaskQueue = requireNonNull(sequencer).latestTaskQueue;
+ ThreadConfinedTaskQueue submittingTaskQueue = sequencer.latestTaskQueue;
if (submittingTaskQueue.thread == submitting) {
sequencer = null;
// Submit from inside a reentrant submit. We don't know if this one will be reentrant (and
@@ -351,12 +337,10 @@
// execution.
checkState(submittingTaskQueue.nextTask == null);
submittingTaskQueue.nextTask = task;
- // requireNonNull(delegate) is safe for reasons similar to requireNonNull(sequencer).
- submittingTaskQueue.nextExecutor = requireNonNull(delegate);
+ submittingTaskQueue.nextExecutor = delegate;
delegate = null;
} else {
- // requireNonNull(delegate) is safe for reasons similar to requireNonNull(sequencer).
- Executor localDelegate = requireNonNull(delegate);
+ Executor localDelegate = delegate;
delegate = null;
this.task = task;
localDelegate.execute(this);
@@ -375,11 +359,7 @@
public void run() {
Thread currentThread = Thread.currentThread();
if (currentThread != submitting) {
- /*
- * requireNonNull is safe because we set `task` before submitting this Runnable to an
- * Executor, and we don't null it out until here.
- */
- Runnable localTask = requireNonNull(task);
+ Runnable localTask = task;
task = null;
localTask.run();
return;
@@ -389,18 +369,6 @@
// latestTaskQueue, and queue rather than calling execute() directly.
ThreadConfinedTaskQueue executingTaskQueue = new ThreadConfinedTaskQueue();
executingTaskQueue.thread = currentThread;
- /*
- * requireNonNull is safe because we don't null out `sequencer` except:
- *
- * - after the requireNonNull call below. (And this object has its Runnable.run override
- * called only once, just as it has its Executor.execute override called only once.)
- *
- * - if we return immediately from `execute` (in which case we never get here)
- *
- * - in the "reentrant submit" case of `execute` (in which case we must have started running a
- * user task -- which means that we already got past this code (or else we exited early
- * above))
- */
// Unconditionally set; there is no risk of throwing away a queued task from another thread,
// because in order for the current task to run on this executor the previous task must have
// already started execution. Because each task on a TaskNonReentrantExecutor can only produce
@@ -410,11 +378,10 @@
// otherwise have another task queued on to it. Note the exception to this, cancellation, is
// specially handled in execute() - execute() calls triggered by cancellation are no-ops, and
// thus don't count.
- requireNonNull(sequencer).latestTaskQueue = executingTaskQueue;
+ sequencer.latestTaskQueue = executingTaskQueue;
sequencer = null;
try {
- // requireNonNull is safe, as discussed above.
- Runnable localTask = requireNonNull(task);
+ Runnable localTask = task;
task = null;
localTask.run();
// Now check if our task attempted to reentrantly execute the next task.
diff --git a/guava/src/com/google/common/util/concurrent/FakeTimeLimiter.java b/guava/src/com/google/common/util/concurrent/FakeTimeLimiter.java
index ddc9440..9dad51b 100644
--- a/guava/src/com/google/common/util/concurrent/FakeTimeLimiter.java
+++ b/guava/src/com/google/common/util/concurrent/FakeTimeLimiter.java
@@ -22,7 +22,6 @@
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* A TimeLimiter implementation which actually does not attempt to limit time at all. This may be
@@ -37,7 +36,6 @@
@Beta
@CanIgnoreReturnValue
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public final class FakeTimeLimiter implements TimeLimiter {
@Override
public <T> T newProxy(
@@ -49,9 +47,8 @@
}
@Override
- @ParametricNullness
- public <T extends @Nullable Object> T callWithTimeout(
- Callable<T> callable, long timeoutDuration, TimeUnit timeoutUnit) throws ExecutionException {
+ public <T> T callWithTimeout(Callable<T> callable, long timeoutDuration, TimeUnit timeoutUnit)
+ throws ExecutionException {
checkNotNull(callable);
checkNotNull(timeoutUnit);
try {
@@ -70,8 +67,7 @@
}
@Override
- @ParametricNullness
- public <T extends @Nullable Object> T callUninterruptiblyWithTimeout(
+ public <T> T callUninterruptiblyWithTimeout(
Callable<T> callable, long timeoutDuration, TimeUnit timeoutUnit) throws ExecutionException {
return callWithTimeout(callable, timeoutDuration, timeoutUnit);
}
diff --git a/guava/src/com/google/common/util/concurrent/FluentFuture.java b/guava/src/com/google/common/util/concurrent/FluentFuture.java
index 4320b78..88696ea 100644
--- a/guava/src/com/google/common/util/concurrent/FluentFuture.java
+++ b/guava/src/com/google/common/util/concurrent/FluentFuture.java
@@ -29,7 +29,6 @@
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* A {@link ListenableFuture} that supports fluent chains of operations. For example:
@@ -75,26 +74,22 @@
@Beta
@DoNotMock("Use FluentFuture.from(Futures.immediate*Future) or SettableFuture")
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
-public abstract class FluentFuture<V extends @Nullable Object>
- extends GwtFluentFutureCatchingSpecialization<V> {
+public abstract class FluentFuture<V> extends GwtFluentFutureCatchingSpecialization<V> {
/**
* A less abstract subclass of AbstractFuture. This can be used to optimize setFuture by ensuring
* that {@link #get} calls exactly the implementation of {@link AbstractFuture#get}.
*/
- abstract static class TrustedFuture<V extends @Nullable Object> extends FluentFuture<V>
+ abstract static class TrustedFuture<V> extends FluentFuture<V>
implements AbstractFuture.Trusted<V> {
@CanIgnoreReturnValue
@Override
- @ParametricNullness
public final V get() throws InterruptedException, ExecutionException {
return super.get();
}
@CanIgnoreReturnValue
@Override
- @ParametricNullness
public final V get(long timeout, TimeUnit unit)
throws InterruptedException, ExecutionException, TimeoutException {
return super.get(timeout, unit);
@@ -131,7 +126,7 @@
* directly. If not, it is wrapped in a {@code FluentFuture} that delegates all calls to the
* original {@code ListenableFuture}.
*/
- public static <V extends @Nullable Object> FluentFuture<V> from(ListenableFuture<V> future) {
+ public static <V> FluentFuture<V> from(ListenableFuture<V> future) {
return future instanceof FluentFuture
? (FluentFuture<V>) future
: new ForwardingFluentFuture<V>(future);
@@ -144,7 +139,7 @@
* @since 28.0
*/
@Deprecated
- public static <V extends @Nullable Object> FluentFuture<V> from(FluentFuture<V> future) {
+ public static <V> FluentFuture<V> from(FluentFuture<V> future) {
return checkNotNull(future);
}
@@ -327,7 +322,7 @@
* @return A future that holds result of the function (if the input succeeded) or the original
* input's failure (if not)
*/
- public final <T extends @Nullable Object> FluentFuture<T> transformAsync(
+ public final <T> FluentFuture<T> transformAsync(
AsyncFunction<? super V, T> function, Executor executor) {
return (FluentFuture<T>) Futures.transformAsync(this, function, executor);
}
@@ -364,8 +359,7 @@
* @param executor Executor to run the function in.
* @return A future that holds result of the transformation.
*/
- public final <T extends @Nullable Object> FluentFuture<T> transform(
- Function<? super V, T> function, Executor executor) {
+ public final <T> FluentFuture<T> transform(Function<? super V, T> function, Executor executor) {
return (FluentFuture<T>) Futures.transform(this, function, executor);
}
diff --git a/guava/src/com/google/common/util/concurrent/ForwardingBlockingDeque.java b/guava/src/com/google/common/util/concurrent/ForwardingBlockingDeque.java
index d0d72a8..2485966 100644
--- a/guava/src/com/google/common/util/concurrent/ForwardingBlockingDeque.java
+++ b/guava/src/com/google/common/util/concurrent/ForwardingBlockingDeque.java
@@ -21,7 +21,6 @@
import java.util.Collection;
import java.util.concurrent.BlockingDeque;
import java.util.concurrent.TimeUnit;
-import javax.annotation.CheckForNull;
/**
* A {@link BlockingDeque} which forwards all its method calls to another {@code BlockingDeque}.
@@ -45,7 +44,6 @@
* @since 21.0 (since 14.0 as {@link com.google.common.collect.ForwardingBlockingDeque})
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public abstract class ForwardingBlockingDeque<E> extends ForwardingDeque<E>
implements BlockingDeque<E> {
@@ -91,13 +89,11 @@
}
@Override
- @CheckForNull
public E pollFirst(long timeout, TimeUnit unit) throws InterruptedException {
return delegate().pollFirst(timeout, unit);
}
@Override
- @CheckForNull
public E pollLast(long timeout, TimeUnit unit) throws InterruptedException {
return delegate().pollLast(timeout, unit);
}
@@ -118,7 +114,6 @@
}
@Override
- @CheckForNull
public E poll(long timeout, TimeUnit unit) throws InterruptedException {
return delegate().poll(timeout, unit);
}
diff --git a/guava/src/com/google/common/util/concurrent/ForwardingBlockingQueue.java b/guava/src/com/google/common/util/concurrent/ForwardingBlockingQueue.java
index dc8511d..f5575a1 100644
--- a/guava/src/com/google/common/util/concurrent/ForwardingBlockingQueue.java
+++ b/guava/src/com/google/common/util/concurrent/ForwardingBlockingQueue.java
@@ -20,7 +20,6 @@
import java.util.Collection;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.TimeUnit;
-import javax.annotation.CheckForNull;
/**
* A {@link BlockingQueue} which forwards all its method calls to another {@link BlockingQueue}.
@@ -38,7 +37,6 @@
*/
@CanIgnoreReturnValue // TODO(cpovirk): Consider being more strict.
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public abstract class ForwardingBlockingQueue<E> extends ForwardingQueue<E>
implements BlockingQueue<E> {
@@ -64,7 +62,6 @@
}
@Override
- @CheckForNull
public E poll(long timeout, TimeUnit unit) throws InterruptedException {
return delegate().poll(timeout, unit);
}
diff --git a/guava/src/com/google/common/util/concurrent/ForwardingCondition.java b/guava/src/com/google/common/util/concurrent/ForwardingCondition.java
index d17f98c..62c4d4c 100644
--- a/guava/src/com/google/common/util/concurrent/ForwardingCondition.java
+++ b/guava/src/com/google/common/util/concurrent/ForwardingCondition.java
@@ -19,7 +19,6 @@
import java.util.concurrent.locks.Condition;
/** Forwarding wrapper around a {@code Condition}. */
-@ElementTypesAreNonnullByDefault
abstract class ForwardingCondition implements Condition {
abstract Condition delegate();
diff --git a/guava/src/com/google/common/util/concurrent/ForwardingExecutorService.java b/guava/src/com/google/common/util/concurrent/ForwardingExecutorService.java
index ed78b86..f9da1d4 100644
--- a/guava/src/com/google/common/util/concurrent/ForwardingExecutorService.java
+++ b/guava/src/com/google/common/util/concurrent/ForwardingExecutorService.java
@@ -25,7 +25,6 @@
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* An executor service which forwards all its method calls to another executor service. Subclasses
@@ -37,7 +36,6 @@
*/
@CanIgnoreReturnValue // TODO(cpovirk): Consider being more strict.
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public abstract class ForwardingExecutorService extends ForwardingObject
implements ExecutorService {
/** Constructor for use by subclasses. */
@@ -52,27 +50,26 @@
}
@Override
- public <T extends @Nullable Object> List<Future<T>> invokeAll(
- Collection<? extends Callable<T>> tasks) throws InterruptedException {
+ public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks)
+ throws InterruptedException {
return delegate().invokeAll(tasks);
}
@Override
- public <T extends @Nullable Object> List<Future<T>> invokeAll(
+ public <T> List<Future<T>> invokeAll(
Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit)
throws InterruptedException {
return delegate().invokeAll(tasks, timeout, unit);
}
@Override
- public <T extends @Nullable Object> T invokeAny(Collection<? extends Callable<T>> tasks)
+ public <T> T invokeAny(Collection<? extends Callable<T>> tasks)
throws InterruptedException, ExecutionException {
return delegate().invokeAny(tasks);
}
@Override
- public <T extends @Nullable Object> T invokeAny(
- Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit)
+ public <T> T invokeAny(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit)
throws InterruptedException, ExecutionException, TimeoutException {
return delegate().invokeAny(tasks, timeout, unit);
}
@@ -103,7 +100,7 @@
}
@Override
- public <T extends @Nullable Object> Future<T> submit(Callable<T> task) {
+ public <T> Future<T> submit(Callable<T> task) {
return delegate().submit(task);
}
@@ -113,8 +110,7 @@
}
@Override
- public <T extends @Nullable Object> Future<T> submit(
- Runnable task, @ParametricNullness T result) {
+ public <T> Future<T> submit(Runnable task, T result) {
return delegate().submit(task, result);
}
}
diff --git a/guava/src/com/google/common/util/concurrent/ForwardingFluentFuture.java b/guava/src/com/google/common/util/concurrent/ForwardingFluentFuture.java
index cb779c3..984fd68 100644
--- a/guava/src/com/google/common/util/concurrent/ForwardingFluentFuture.java
+++ b/guava/src/com/google/common/util/concurrent/ForwardingFluentFuture.java
@@ -21,7 +21,6 @@
import java.util.concurrent.Executor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* {@link FluentFuture} that forwards all calls to a delegate.
@@ -34,8 +33,7 @@
* forwards to that future and adds the desired methods.
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-final class ForwardingFluentFuture<V extends @Nullable Object> extends FluentFuture<V> {
+final class ForwardingFluentFuture<V> extends FluentFuture<V> {
private final ListenableFuture<V> delegate;
ForwardingFluentFuture(ListenableFuture<V> delegate) {
@@ -63,13 +61,11 @@
}
@Override
- @ParametricNullness
public V get() throws InterruptedException, ExecutionException {
return delegate.get();
}
@Override
- @ParametricNullness
public V get(long timeout, TimeUnit unit)
throws InterruptedException, ExecutionException, TimeoutException {
return delegate.get(timeout, unit);
diff --git a/guava/src/com/google/common/util/concurrent/ForwardingFuture.java b/guava/src/com/google/common/util/concurrent/ForwardingFuture.java
index 47002b0..165793b 100644
--- a/guava/src/com/google/common/util/concurrent/ForwardingFuture.java
+++ b/guava/src/com/google/common/util/concurrent/ForwardingFuture.java
@@ -22,7 +22,6 @@
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* A {@link Future} which forwards all its method calls to another future. Subclasses should
@@ -36,9 +35,7 @@
*/
@CanIgnoreReturnValue // TODO(cpovirk): Consider being more strict.
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-public abstract class ForwardingFuture<V extends @Nullable Object> extends ForwardingObject
- implements Future<V> {
+public abstract class ForwardingFuture<V> extends ForwardingObject implements Future<V> {
/** Constructor for use by subclasses. */
protected ForwardingFuture() {}
@@ -61,13 +58,11 @@
}
@Override
- @ParametricNullness
public V get() throws InterruptedException, ExecutionException {
return delegate().get();
}
@Override
- @ParametricNullness
public V get(long timeout, TimeUnit unit)
throws InterruptedException, ExecutionException, TimeoutException {
return delegate().get(timeout, unit);
@@ -80,8 +75,7 @@
*
* @since 9.0
*/
- public abstract static class SimpleForwardingFuture<V extends @Nullable Object>
- extends ForwardingFuture<V> {
+ public abstract static class SimpleForwardingFuture<V> extends ForwardingFuture<V> {
private final Future<V> delegate;
protected SimpleForwardingFuture(Future<V> delegate) {
diff --git a/guava/src/com/google/common/util/concurrent/ForwardingListenableFuture.java b/guava/src/com/google/common/util/concurrent/ForwardingListenableFuture.java
index 3868091..d3ed3c2 100644
--- a/guava/src/com/google/common/util/concurrent/ForwardingListenableFuture.java
+++ b/guava/src/com/google/common/util/concurrent/ForwardingListenableFuture.java
@@ -18,7 +18,6 @@
import com.google.common.base.Preconditions;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import java.util.concurrent.Executor;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* A {@link ListenableFuture} which forwards all its method calls to another future. Subclasses
@@ -32,9 +31,8 @@
*/
@CanIgnoreReturnValue // TODO(cpovirk): Consider being more strict.
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-public abstract class ForwardingListenableFuture<V extends @Nullable Object>
- extends ForwardingFuture<V> implements ListenableFuture<V> {
+public abstract class ForwardingListenableFuture<V> extends ForwardingFuture<V>
+ implements ListenableFuture<V> {
/** Constructor for use by subclasses. */
protected ForwardingListenableFuture() {}
@@ -54,7 +52,7 @@
*
* @since 9.0
*/
- public abstract static class SimpleForwardingListenableFuture<V extends @Nullable Object>
+ public abstract static class SimpleForwardingListenableFuture<V>
extends ForwardingListenableFuture<V> {
private final ListenableFuture<V> delegate;
diff --git a/guava/src/com/google/common/util/concurrent/ForwardingListeningExecutorService.java b/guava/src/com/google/common/util/concurrent/ForwardingListeningExecutorService.java
index fe25b86..48a49b8 100644
--- a/guava/src/com/google/common/util/concurrent/ForwardingListeningExecutorService.java
+++ b/guava/src/com/google/common/util/concurrent/ForwardingListeningExecutorService.java
@@ -17,7 +17,6 @@
import com.google.common.annotations.GwtIncompatible;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import java.util.concurrent.Callable;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* A listening executor service which forwards all its method calls to another listening executor
@@ -30,7 +29,6 @@
*/
@CanIgnoreReturnValue // TODO(cpovirk): Consider being more strict.
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public abstract class ForwardingListeningExecutorService extends ForwardingExecutorService
implements ListeningExecutorService {
/** Constructor for use by subclasses. */
@@ -40,7 +38,7 @@
protected abstract ListeningExecutorService delegate();
@Override
- public <T extends @Nullable Object> ListenableFuture<T> submit(Callable<T> task) {
+ public <T> ListenableFuture<T> submit(Callable<T> task) {
return delegate().submit(task);
}
@@ -50,8 +48,7 @@
}
@Override
- public <T extends @Nullable Object> ListenableFuture<T> submit(
- Runnable task, @ParametricNullness T result) {
+ public <T> ListenableFuture<T> submit(Runnable task, T result) {
return delegate().submit(task, result);
}
}
diff --git a/guava/src/com/google/common/util/concurrent/ForwardingLock.java b/guava/src/com/google/common/util/concurrent/ForwardingLock.java
index db2026a..8c50787 100644
--- a/guava/src/com/google/common/util/concurrent/ForwardingLock.java
+++ b/guava/src/com/google/common/util/concurrent/ForwardingLock.java
@@ -19,7 +19,6 @@
import java.util.concurrent.locks.Lock;
/** Forwarding wrapper around a {@code Lock}. */
-@ElementTypesAreNonnullByDefault
abstract class ForwardingLock implements Lock {
abstract Lock delegate();
diff --git a/guava/src/com/google/common/util/concurrent/FutureCallback.java b/guava/src/com/google/common/util/concurrent/FutureCallback.java
index f5684e7..b180477 100644
--- a/guava/src/com/google/common/util/concurrent/FutureCallback.java
+++ b/guava/src/com/google/common/util/concurrent/FutureCallback.java
@@ -29,10 +29,9 @@
* @since 10.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-public interface FutureCallback<V extends @Nullable Object> {
+public interface FutureCallback<V> {
/** Invoked with the result of the {@code Future} computation when it is successful. */
- void onSuccess(@ParametricNullness 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 43205b8..6bad226 100644
--- a/guava/src/com/google/common/util/concurrent/Futures.java
+++ b/guava/src/com/google/common/util/concurrent/Futures.java
@@ -19,7 +19,6 @@
import static com.google.common.util.concurrent.Internal.toNanosSaturated;
import static com.google.common.util.concurrent.MoreExecutors.directExecutor;
import static com.google.common.util.concurrent.Uninterruptibles.getUninterruptibly;
-import static java.util.Objects.requireNonNull;
import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtCompatible;
@@ -47,7 +46,6 @@
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicInteger;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -75,7 +73,6 @@
* @since 1.0
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
public final class Futures extends GwtFuturesCatchingSpecialization {
// A note on memory visibility.
@@ -130,8 +127,7 @@
* 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 <V extends @Nullable Object> ListenableFuture<V> immediateFuture(
- @ParametricNullness V value) {
+ public static <V> ListenableFuture<V> immediateFuture(@Nullable V value) {
if (value == null) {
// This cast is safe because null is assignable to V for all V (i.e. it is bivariant)
@SuppressWarnings("unchecked")
@@ -148,8 +144,8 @@
* @since 29.0
*/
@SuppressWarnings("unchecked")
- public static ListenableFuture<@Nullable Void> immediateVoidFuture() {
- return (ListenableFuture<@Nullable Void>) ImmediateFuture.NULL;
+ public static ListenableFuture<Void> immediateVoidFuture() {
+ return (ListenableFuture<Void>) ImmediateFuture.NULL;
}
/**
@@ -159,8 +155,7 @@
* returns {@code true}. Calling {@code get()} will immediately throw the provided {@code
* Throwable} wrapped in an {@code ExecutionException}.
*/
- public static <V extends @Nullable Object> ListenableFuture<V> immediateFailedFuture(
- Throwable throwable) {
+ public static <V> ListenableFuture<V> immediateFailedFuture(Throwable throwable) {
checkNotNull(throwable);
return new ImmediateFailedFuture<V>(throwable);
}
@@ -171,7 +166,7 @@
*
* @since 14.0
*/
- public static <V extends @Nullable Object> ListenableFuture<V> immediateCancelledFuture() {
+ public static <V> ListenableFuture<V> immediateCancelledFuture() {
return new ImmediateCancelledFuture<V>();
}
@@ -182,8 +177,7 @@
* @since 28.2
*/
@Beta
- public static <O extends @Nullable Object> ListenableFuture<O> submit(
- Callable<O> callable, Executor executor) {
+ public static <O> ListenableFuture<O> submit(Callable<O> callable, Executor executor) {
TrustedListenableFutureTask<O> task = TrustedListenableFutureTask.create(callable);
executor.execute(task);
return task;
@@ -197,9 +191,8 @@
* @since 28.2
*/
@Beta
- public static ListenableFuture<@Nullable Void> submit(Runnable runnable, Executor executor) {
- TrustedListenableFutureTask<@Nullable Void> task =
- TrustedListenableFutureTask.create(runnable, null);
+ public static ListenableFuture<Void> submit(Runnable runnable, Executor executor) {
+ TrustedListenableFutureTask<Void> task = TrustedListenableFutureTask.create(runnable, null);
executor.execute(task);
return task;
}
@@ -211,8 +204,7 @@
* @since 23.0
*/
@Beta
- public static <O extends @Nullable Object> ListenableFuture<O> submitAsync(
- AsyncCallable<O> callable, Executor executor) {
+ public static <O> ListenableFuture<O> submitAsync(AsyncCallable<O> callable, Executor executor) {
TrustedListenableFutureTask<O> task = TrustedListenableFutureTask.create(callable);
executor.execute(task);
return task;
@@ -226,7 +218,7 @@
*/
@Beta
@GwtIncompatible // java.util.concurrent.ScheduledExecutorService
- public static <O extends @Nullable Object> ListenableFuture<O> scheduleAsync(
+ public static <O> ListenableFuture<O> scheduleAsync(
AsyncCallable<O> callable, Duration delay, ScheduledExecutorService executorService) {
return scheduleAsync(callable, toNanosSaturated(delay), TimeUnit.NANOSECONDS, executorService);
}
@@ -240,7 +232,7 @@
@Beta
@GwtIncompatible // java.util.concurrent.ScheduledExecutorService
@SuppressWarnings("GoodTime") // should accept a java.time.Duration
- public static <O extends @Nullable Object> ListenableFuture<O> scheduleAsync(
+ public static <O> ListenableFuture<O> scheduleAsync(
AsyncCallable<O> callable,
long delay,
TimeUnit timeUnit,
@@ -297,7 +289,7 @@
*/
@Beta
@Partially.GwtIncompatible("AVAILABLE but requires exceptionType to be Throwable.class")
- public static <V extends @Nullable Object, X extends Throwable> ListenableFuture<V> catching(
+ public static <V, X extends Throwable> ListenableFuture<V> catching(
ListenableFuture<? extends V> input,
Class<X> exceptionType,
Function<? super X, ? extends V> fallback,
@@ -362,7 +354,7 @@
*/
@Beta
@Partially.GwtIncompatible("AVAILABLE but requires exceptionType to be Throwable.class")
- public static <V extends @Nullable Object, X extends Throwable> ListenableFuture<V> catchingAsync(
+ public static <V, X extends Throwable> ListenableFuture<V> catchingAsync(
ListenableFuture<? extends V> input,
Class<X> exceptionType,
AsyncFunction<? super X, ? extends V> fallback,
@@ -383,7 +375,7 @@
*/
@Beta
@GwtIncompatible // java.util.concurrent.ScheduledExecutorService
- public static <V extends @Nullable Object> ListenableFuture<V> withTimeout(
+ public static <V> ListenableFuture<V> withTimeout(
ListenableFuture<V> delegate, Duration time, ScheduledExecutorService scheduledExecutor) {
return withTimeout(delegate, toNanosSaturated(time), TimeUnit.NANOSECONDS, scheduledExecutor);
}
@@ -403,7 +395,7 @@
@Beta
@GwtIncompatible // java.util.concurrent.ScheduledExecutorService
@SuppressWarnings("GoodTime") // should accept a java.time.Duration
- public static <V extends @Nullable Object> ListenableFuture<V> withTimeout(
+ public static <V> ListenableFuture<V> withTimeout(
ListenableFuture<V> delegate,
long time,
TimeUnit unit,
@@ -447,11 +439,10 @@
* @since 19.0 (in 11.0 as {@code transform})
*/
@Beta
- public static <I extends @Nullable Object, O extends @Nullable Object>
- ListenableFuture<O> transformAsync(
- ListenableFuture<I> input,
- AsyncFunction<? super I, ? extends O> function,
- Executor executor) {
+ public static <I, O> ListenableFuture<O> transformAsync(
+ ListenableFuture<I> input,
+ AsyncFunction<? super I, ? extends O> function,
+ Executor executor) {
return AbstractTransformFuture.create(input, function, executor);
}
@@ -485,9 +476,8 @@
* @since 9.0 (in 2.0 as {@code compose})
*/
@Beta
- public static <I extends @Nullable Object, O extends @Nullable Object>
- ListenableFuture<O> transform(
- ListenableFuture<I> input, Function<? super I, ? extends O> function, Executor executor) {
+ public static <I, O> ListenableFuture<O> transform(
+ ListenableFuture<I> input, Function<? super I, ? extends O> function, Executor executor) {
return AbstractTransformFuture.create(input, function, executor);
}
@@ -513,7 +503,7 @@
*/
@Beta
@GwtIncompatible // TODO
- public static <I extends @Nullable Object, O extends @Nullable Object> Future<O> lazyTransform(
+ public static <I, O> Future<O> lazyTransform(
final Future<I> input, final Function<? super I, ? extends O> function) {
checkNotNull(input);
checkNotNull(function);
@@ -573,14 +563,8 @@
*/
@Beta
@SafeVarargs
- public static <V extends @Nullable Object> ListenableFuture<List<V>> allAsList(
- ListenableFuture<? extends V>... futures) {
- ListenableFuture<List<@Nullable V>> nullable =
- new ListFuture<V>(ImmutableList.copyOf(futures), true);
- // allAsList ensures that it fills the output list with V instances.
- @SuppressWarnings("nullness")
- ListenableFuture<List<V>> nonNull = nullable;
- return nonNull;
+ public static <V> ListenableFuture<List<V>> allAsList(ListenableFuture<? extends V>... futures) {
+ return new ListFuture<V>(ImmutableList.copyOf(futures), true);
}
/**
@@ -600,14 +584,9 @@
* @since 10.0
*/
@Beta
- public static <V extends @Nullable Object> ListenableFuture<List<V>> allAsList(
+ public static <V> ListenableFuture<List<V>> allAsList(
Iterable<? extends ListenableFuture<? extends V>> futures) {
- ListenableFuture<List<@Nullable V>> nullable =
- new ListFuture<V>(ImmutableList.copyOf(futures), true);
- // allAsList ensures that it fills the output list with V instances.
- @SuppressWarnings("nullness")
- ListenableFuture<List<V>> nonNull = nullable;
- return nonNull;
+ return new ListFuture<V>(ImmutableList.copyOf(futures), true);
}
/**
@@ -620,8 +599,7 @@
*/
@Beta
@SafeVarargs
- public static <V extends @Nullable Object> FutureCombiner<V> whenAllComplete(
- ListenableFuture<? extends V>... futures) {
+ public static <V> FutureCombiner<V> whenAllComplete(ListenableFuture<? extends V>... futures) {
return new FutureCombiner<V>(false, ImmutableList.copyOf(futures));
}
@@ -634,7 +612,7 @@
* @since 20.0
*/
@Beta
- public static <V extends @Nullable Object> FutureCombiner<V> whenAllComplete(
+ public static <V> FutureCombiner<V> whenAllComplete(
Iterable<? extends ListenableFuture<? extends V>> futures) {
return new FutureCombiner<V>(false, ImmutableList.copyOf(futures));
}
@@ -648,8 +626,7 @@
*/
@Beta
@SafeVarargs
- public static <V extends @Nullable Object> FutureCombiner<V> whenAllSucceed(
- ListenableFuture<? extends V>... futures) {
+ public static <V> FutureCombiner<V> whenAllSucceed(ListenableFuture<? extends V>... futures) {
return new FutureCombiner<V>(true, ImmutableList.copyOf(futures));
}
@@ -661,7 +638,7 @@
* @since 20.0
*/
@Beta
- public static <V extends @Nullable Object> FutureCombiner<V> whenAllSucceed(
+ public static <V> FutureCombiner<V> whenAllSucceed(
Iterable<? extends ListenableFuture<? extends V>> futures) {
return new FutureCombiner<V>(true, ImmutableList.copyOf(futures));
}
@@ -695,7 +672,7 @@
@Beta
@CanIgnoreReturnValue // TODO(cpovirk): Consider removing, especially if we provide run(Runnable)
@GwtCompatible
- public static final class FutureCombiner<V extends @Nullable Object> {
+ public static final class FutureCombiner<V> {
private final boolean allMustSucceed;
private final ImmutableList<ListenableFuture<? extends V>> futures;
@@ -719,8 +696,7 @@
*
* <p>Canceling this future will attempt to cancel all the component futures.
*/
- public <C extends @Nullable Object> ListenableFuture<C> callAsync(
- AsyncCallable<C> combiner, Executor executor) {
+ public <C> ListenableFuture<C> callAsync(AsyncCallable<C> combiner, Executor executor) {
return new CombinedFuture<C>(futures, allMustSucceed, executor, combiner);
}
@@ -739,8 +715,7 @@
* <p>Canceling this future will attempt to cancel all the component futures.
*/
@CanIgnoreReturnValue // TODO(cpovirk): Remove this
- public <C extends @Nullable Object> ListenableFuture<C> call(
- Callable<C> combiner, Executor executor) {
+ public <C> ListenableFuture<C> call(Callable<C> combiner, Executor executor) {
return new CombinedFuture<C>(futures, allMustSucceed, executor, combiner);
}
@@ -757,9 +732,8 @@
*/
public ListenableFuture<?> run(final Runnable combiner, Executor executor) {
return call(
- new Callable<@Nullable Void>() {
+ new Callable<Void>() {
@Override
- @CheckForNull
public Void call() throws Exception {
combiner.run();
return null;
@@ -777,8 +751,7 @@
* @since 15.0
*/
@Beta
- public static <V extends @Nullable Object> ListenableFuture<V> nonCancellationPropagating(
- ListenableFuture<V> future) {
+ public static <V> ListenableFuture<V> nonCancellationPropagating(ListenableFuture<V> future) {
if (future.isDone()) {
return future;
}
@@ -788,9 +761,9 @@
}
/** A wrapped future that does not propagate cancellation to its delegate. */
- private static final class NonCancellationPropagatingFuture<V extends @Nullable Object>
+ private static final class NonCancellationPropagatingFuture<V>
extends AbstractFuture.TrustedFuture<V> implements Runnable {
- @CheckForNull private ListenableFuture<V> delegate;
+ private ListenableFuture<V> delegate;
NonCancellationPropagatingFuture(final ListenableFuture<V> delegate) {
this.delegate = delegate;
@@ -807,7 +780,6 @@
}
@Override
- @CheckForNull
protected String pendingToString() {
ListenableFuture<V> localDelegate = delegate;
if (localDelegate != null) {
@@ -840,21 +812,9 @@
* @return a future that provides a list of the results of the component futures
* @since 10.0
*/
- /*
- * Another way to express this signature would be to bound <V> by @NonNull and accept LF<? extends
- * @Nullable V>. That might be better: There's currently no difference between the outputs users
- * get when calling this with <Foo> and calling it with <@Nullable Foo>. The only difference is
- * that calling it with <Foo> won't work when an input Future has a @Nullable type. So why even
- * make that error possible by giving callers the choice?
- *
- * On the other hand, the current signature is consistent with the similar allAsList method. And
- * eventually this method may go away entirely in favor of an API like
- * whenAllComplete().collectSuccesses(). That API would have a signature more like the current
- * one.
- */
@Beta
@SafeVarargs
- public static <V extends @Nullable Object> ListenableFuture<List<@Nullable V>> successfulAsList(
+ public static <V> ListenableFuture<List<V>> successfulAsList(
ListenableFuture<? extends V>... futures) {
return new ListFuture<V>(ImmutableList.copyOf(futures), false);
}
@@ -878,7 +838,7 @@
* @since 10.0
*/
@Beta
- public static <V extends @Nullable Object> ListenableFuture<List<@Nullable V>> successfulAsList(
+ public static <V> ListenableFuture<List<V>> successfulAsList(
Iterable<? extends ListenableFuture<? extends V>> futures) {
return new ListFuture<V>(ImmutableList.copyOf(futures), false);
}
@@ -905,12 +865,21 @@
* @since 17.0
*/
@Beta
- public static <T extends @Nullable Object> ImmutableList<ListenableFuture<T>> inCompletionOrder(
+ public static <T> ImmutableList<ListenableFuture<T>> inCompletionOrder(
Iterable<? extends ListenableFuture<? extends T>> futures) {
- ListenableFuture<? extends T>[] copy = gwtCompatibleToArray(futures);
+ // Can't use Iterables.toArray because it's not gwt compatible
+ final Collection<ListenableFuture<? extends T>> collection;
+ if (futures instanceof Collection) {
+ collection = (Collection<ListenableFuture<? extends T>>) futures;
+ } else {
+ collection = ImmutableList.copyOf(futures);
+ }
+ @SuppressWarnings("unchecked")
+ ListenableFuture<? extends T>[] copy =
+ (ListenableFuture<? extends T>[])
+ collection.toArray(new ListenableFuture[collection.size()]);
final InCompletionOrderState<T> state = new InCompletionOrderState<>(copy);
- ImmutableList.Builder<AbstractFuture<T>> delegatesBuilder =
- ImmutableList.builderWithExpectedSize(copy.length);
+ ImmutableList.Builder<AbstractFuture<T>> delegatesBuilder = ImmutableList.builder();
for (int i = 0; i < copy.length; i++) {
delegatesBuilder.add(new InCompletionOrderFuture<T>(state));
}
@@ -933,25 +902,11 @@
return delegatesCast;
}
- /** Can't use Iterables.toArray because it's not gwt compatible */
- @SuppressWarnings("unchecked")
- private static <T extends @Nullable Object> ListenableFuture<? extends T>[] gwtCompatibleToArray(
- Iterable<? extends ListenableFuture<? extends T>> futures) {
- final Collection<ListenableFuture<? extends T>> collection;
- if (futures instanceof Collection) {
- collection = (Collection<ListenableFuture<? extends T>>) futures;
- } else {
- collection = ImmutableList.copyOf(futures);
- }
- return (ListenableFuture<? extends T>[]) collection.toArray(new ListenableFuture<?>[0]);
- }
-
// This can't be a TrustedFuture, because TrustedFuture has clever optimizations that
// mean cancel won't be called if this Future is passed into setFuture, and then
// cancelled.
- private static final class InCompletionOrderFuture<T extends @Nullable Object>
- extends AbstractFuture<T> {
- @CheckForNull private InCompletionOrderState<T> state;
+ private static final class InCompletionOrderFuture<T> extends AbstractFuture<T> {
+ private InCompletionOrderState<T> state;
private InCompletionOrderFuture(InCompletionOrderState<T> state) {
this.state = state;
@@ -961,15 +916,7 @@
public boolean cancel(boolean interruptIfRunning) {
InCompletionOrderState<T> localState = state;
if (super.cancel(interruptIfRunning)) {
- /*
- * requireNonNull is generally safe: If cancel succeeded, then this Future was still
- * pending, so its `state` field hasn't been nulled out yet.
- *
- * OK, it's technically possible for this to fail in the presence of unsafe publishing, as
- * discussed in the comments in TimeoutFuture. TODO(cpovirk): Maybe check for null before
- * calling recordOutputCancellation?
- */
- requireNonNull(localState).recordOutputCancellation(interruptIfRunning);
+ localState.recordOutputCancellation(interruptIfRunning);
return true;
}
return false;
@@ -981,7 +928,6 @@
}
@Override
- @CheckForNull
protected String pendingToString() {
InCompletionOrderState<T> localState = state;
if (localState != null) {
@@ -997,15 +943,14 @@
}
}
- private static final class InCompletionOrderState<T extends @Nullable Object> {
+ private static final class InCompletionOrderState<T> {
// A happens-before edge between the writes of these fields and their reads exists, because
// in order to read these fields, the corresponding write to incompleteOutputCount must have
// been read.
private boolean wasCancelled = false;
private boolean shouldInterrupt = true;
private final AtomicInteger incompleteOutputCount;
- // We set the elements of the array to null as they complete.
- private final @Nullable ListenableFuture<? extends T>[] inputFutures;
+ private final ListenableFuture<? extends T>[] inputFutures;
private volatile int delegateIndex = 0;
private InCompletionOrderState(ListenableFuture<? extends T>[] inputFutures) {
@@ -1025,11 +970,7 @@
private void recordInputCompletion(
ImmutableList<AbstractFuture<T>> delegates, int inputFutureIndex) {
- /*
- * requireNonNull is safe because we accepted an Iterable of non-null Future instances, and we
- * don't overwrite an element in the array until after reading it.
- */
- ListenableFuture<? extends T> inputFuture = requireNonNull(inputFutures[inputFutureIndex]);
+ ListenableFuture<? extends T> inputFuture = inputFutures[inputFutureIndex];
// Null out our reference to this future, so it can be GCed
inputFutures[inputFutureIndex] = null;
for (int i = delegateIndex; i < delegates.size(); i++) {
@@ -1048,7 +989,7 @@
private void recordCompletion() {
if (incompleteOutputCount.decrementAndGet() == 0 && wasCancelled) {
- for (ListenableFuture<? extends T> toCancel : inputFutures) {
+ for (ListenableFuture<?> toCancel : inputFutures) {
if (toCancel != null) {
toCancel.cancel(shouldInterrupt);
}
@@ -1098,7 +1039,7 @@
* @param executor The executor to run {@code callback} when the future completes.
* @since 10.0
*/
- public static <V extends @Nullable Object> void addCallback(
+ public static <V> void addCallback(
final ListenableFuture<V> future,
final FutureCallback<? super V> callback,
Executor executor) {
@@ -1107,7 +1048,7 @@
}
/** See {@link #addCallback(ListenableFuture, FutureCallback, Executor)} for behavioral notes. */
- private static final class CallbackListener<V extends @Nullable Object> implements Runnable {
+ private static final class CallbackListener<V> implements Runnable {
final Future<V> future;
final FutureCallback<? super V> callback;
@@ -1166,8 +1107,7 @@
*/
@CanIgnoreReturnValue
// TODO(cpovirk): Consider calling getDone() in our own code.
- @ParametricNullness
- public static <V extends @Nullable Object> V getDone(Future<V> future) throws ExecutionException {
+ public static <V> V getDone(Future<V> future) throws ExecutionException {
/*
* We throw IllegalStateException, since the call could succeed later. Perhaps we "should" throw
* IllegalArgumentException, since the call could succeed with a different argument. Those
@@ -1175,6 +1115,7 @@
* IllegalArgumentException here, in part to keep its recommendation simple: Static methods
* should throw IllegalStateException only when they use static state.
*
+ *
* Why do we deviate here? The answer: We want for fluentFuture.getDone() to throw the same
* exception as Futures.getDone(fluentFuture).
*/
@@ -1227,9 +1168,8 @@
@Beta
@CanIgnoreReturnValue
@GwtIncompatible // reflection
- @ParametricNullness
- public static <V extends @Nullable Object, X extends Exception> V getChecked(
- Future<V> future, Class<X> exceptionClass) throws X {
+ public static <V, X extends Exception> V getChecked(Future<V> future, Class<X> exceptionClass)
+ throws X {
return FuturesGetChecked.getChecked(future, exceptionClass);
}
@@ -1279,8 +1219,7 @@
@Beta
@CanIgnoreReturnValue
@GwtIncompatible // reflection
- @ParametricNullness
- public static <V extends @Nullable Object, X extends Exception> V getChecked(
+ public static <V, X extends Exception> V getChecked(
Future<V> future, Class<X> exceptionClass, Duration timeout) throws X {
return getChecked(future, exceptionClass, toNanosSaturated(timeout), TimeUnit.NANOSECONDS);
}
@@ -1332,8 +1271,7 @@
@CanIgnoreReturnValue
@GwtIncompatible // reflection
@SuppressWarnings("GoodTime") // should accept a java.time.Duration
- @ParametricNullness
- public static <V extends @Nullable Object, X extends Exception> V getChecked(
+ public static <V, X extends Exception> V getChecked(
Future<V> future, Class<X> exceptionClass, long timeout, TimeUnit unit) throws X {
return FuturesGetChecked.getChecked(future, exceptionClass, timeout, unit);
}
@@ -1373,8 +1311,7 @@
* @since 10.0
*/
@CanIgnoreReturnValue
- @ParametricNullness
- public static <V extends @Nullable Object> V getUnchecked(Future<V> future) {
+ public static <V> V getUnchecked(Future<V> future) {
checkNotNull(future);
try {
return getUninterruptibly(future);
@@ -1404,7 +1341,7 @@
* the computation -- makes sense, and if we don't convert it, the user still has to write a
* try-catch block.
*
- * If you think you would use this method, let us know. You might also look into the
+ * If you think you would use this method, let us know. You might also also look into the
* Fork-Join framework: http://docs.oracle.com/javase/tutorial/essential/concurrency/forkjoin.html
*/
}
diff --git a/guava/src/com/google/common/util/concurrent/FuturesGetChecked.java b/guava/src/com/google/common/util/concurrent/FuturesGetChecked.java
index 6f09b80..2365040 100644
--- a/guava/src/com/google/common/util/concurrent/FuturesGetChecked.java
+++ b/guava/src/com/google/common/util/concurrent/FuturesGetChecked.java
@@ -35,25 +35,20 @@
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/** Static methods used to implement {@link Futures#getChecked(Future, Class)}. */
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
final class FuturesGetChecked {
@CanIgnoreReturnValue
- @ParametricNullness
- static <V extends @Nullable Object, X extends Exception> V getChecked(
- Future<V> future, Class<X> exceptionClass) throws X {
+ static <V, X extends Exception> V getChecked(Future<V> future, Class<X> exceptionClass) throws X {
return getChecked(bestGetCheckedTypeValidator(), future, exceptionClass);
}
/** Implementation of {@link Futures#getChecked(Future, Class)}. */
@CanIgnoreReturnValue
@VisibleForTesting
- @ParametricNullness
- static <V extends @Nullable Object, X extends Exception> V getChecked(
+ static <V, X extends Exception> V getChecked(
GetCheckedTypeValidator validator, Future<V> future, Class<X> exceptionClass) throws X {
validator.validateClass(exceptionClass);
try {
@@ -69,8 +64,7 @@
/** Implementation of {@link Futures#getChecked(Future, Class, long, TimeUnit)}. */
@CanIgnoreReturnValue
- @ParametricNullness
- static <V extends @Nullable Object, X extends Exception> V getChecked(
+ static <V, X extends Exception> V getChecked(
Future<V> future, Class<X> exceptionClass, long timeout, TimeUnit unit) throws X {
// TODO(cpovirk): benchmark a version of this method that accepts a GetCheckedTypeValidator
bestGetCheckedTypeValidator().validateClass(exceptionClass);
@@ -120,6 +114,7 @@
static final GetCheckedTypeValidator BEST_VALIDATOR = getBestValidator();
+ @IgnoreJRERequirement // getChecked falls back to another implementation if necessary
@J2ObjCIncompatible // ClassValue
enum ClassValueValidator implements GetCheckedTypeValidator {
INSTANCE;
@@ -190,8 +185,7 @@
*/
static GetCheckedTypeValidator getBestValidator() {
try {
- Class<? extends Enum> theClass =
- Class.forName(CLASS_VALUE_VALIDATOR_NAME).asSubclass(Enum.class);
+ Class<?> theClass = Class.forName(CLASS_VALUE_VALIDATOR_NAME);
return (GetCheckedTypeValidator) theClass.getEnumConstants()[0];
} catch (Throwable t) { // ensure we really catch *everything*
return weakSetValidator();
@@ -231,7 +225,7 @@
@SuppressWarnings({"unchecked", "rawtypes"})
List<Constructor<X>> constructors = (List) Arrays.asList(exceptionClass.getConstructors());
for (Constructor<X> constructor : preferringStrings(constructors)) {
- X instance = newFromConstructor(constructor, cause);
+ @Nullable X instance = newFromConstructor(constructor, cause);
if (instance != null) {
if (instance.getCause() == null) {
instance.initCause(cause);
@@ -262,8 +256,7 @@
})
.reverse();
- @CheckForNull
- private static <X> X newFromConstructor(Constructor<X> constructor, Throwable cause) {
+ private static <X> @Nullable X newFromConstructor(Constructor<X> constructor, Throwable cause) {
Class<?>[] paramTypes = constructor.getParameterTypes();
Object[] params = new Object[paramTypes.length];
for (int i = 0; i < paramTypes.length; i++) {
diff --git a/guava/src/com/google/common/util/concurrent/GwtFluentFutureCatchingSpecialization.java b/guava/src/com/google/common/util/concurrent/GwtFluentFutureCatchingSpecialization.java
index d29a673..e8acf62 100644
--- a/guava/src/com/google/common/util/concurrent/GwtFluentFutureCatchingSpecialization.java
+++ b/guava/src/com/google/common/util/concurrent/GwtFluentFutureCatchingSpecialization.java
@@ -15,7 +15,6 @@
package com.google.common.util.concurrent;
import com.google.common.annotations.GwtCompatible;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Hidden superclass of {@link FluentFuture} that provides us a place to declare special GWT
@@ -23,9 +22,7 @@
* FluentFuture.catching} family of methods. Those versions have slightly different signatures.
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
-abstract class GwtFluentFutureCatchingSpecialization<V extends @Nullable Object>
- extends AbstractFuture<V> {
+abstract class GwtFluentFutureCatchingSpecialization<V> extends AbstractFuture<V> {
/*
* This server copy of the class is empty. The corresponding GWT copy contains alternative
* versions of catching() and catchingAsync() with slightly different signatures from the ones
diff --git a/guava/src/com/google/common/util/concurrent/GwtFuturesCatchingSpecialization.java b/guava/src/com/google/common/util/concurrent/GwtFuturesCatchingSpecialization.java
index 95131ce..4626ce9 100644
--- a/guava/src/com/google/common/util/concurrent/GwtFuturesCatchingSpecialization.java
+++ b/guava/src/com/google/common/util/concurrent/GwtFuturesCatchingSpecialization.java
@@ -23,7 +23,6 @@
* different signatures.
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
abstract class GwtFuturesCatchingSpecialization {
/*
* This server copy of the class is empty. The corresponding GWT copy contains alternative
diff --git a/guava/src/com/google/common/util/concurrent/IgnoreJRERequirement.java b/guava/src/com/google/common/util/concurrent/IgnoreJRERequirement.java
new file mode 100644
index 0000000..b557ac6
--- /dev/null
+++ b/guava/src/com/google/common/util/concurrent/IgnoreJRERequirement.java
@@ -0,0 +1,17 @@
+/*
+ * Copyright 2019 The Guava Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package com.google.common.util.concurrent;
+
+@interface IgnoreJRERequirement {}
diff --git a/guava/src/com/google/common/util/concurrent/ImmediateFuture.java b/guava/src/com/google/common/util/concurrent/ImmediateFuture.java
index 81912f5..7bee37d 100644
--- a/guava/src/com/google/common/util/concurrent/ImmediateFuture.java
+++ b/guava/src/com/google/common/util/concurrent/ImmediateFuture.java
@@ -27,16 +27,15 @@
/** Implementation of {@link Futures#immediateFuture}. */
@GwtCompatible
-@ElementTypesAreNonnullByDefault
// TODO(cpovirk): Make this final (but that may break Mockito spy calls).
-class ImmediateFuture<V extends @Nullable Object> implements ListenableFuture<V> {
- static final ListenableFuture<?> NULL = new ImmediateFuture<@Nullable Object>(null);
+class ImmediateFuture<V> implements ListenableFuture<V> {
+ static final ListenableFuture<?> NULL = new ImmediateFuture<>(null);
private static final Logger log = Logger.getLogger(ImmediateFuture.class.getName());
- @ParametricNullness private final V value;
+ private final @Nullable V value;
- ImmediateFuture(@ParametricNullness V value) {
+ ImmediateFuture(@Nullable V value) {
this.value = value;
}
@@ -63,13 +62,11 @@
// TODO(lukes): Consider throwing InterruptedException when appropriate.
@Override
- @ParametricNullness
public V get() {
return value;
}
@Override
- @ParametricNullness
public V get(long timeout, TimeUnit unit) throws ExecutionException {
checkNotNull(unit);
return get();
@@ -91,13 +88,13 @@
return super.toString() + "[status=SUCCESS, result=[" + value + "]]";
}
- static final class ImmediateFailedFuture<V extends @Nullable Object> extends TrustedFuture<V> {
+ static final class ImmediateFailedFuture<V> extends TrustedFuture<V> {
ImmediateFailedFuture(Throwable thrown) {
setException(thrown);
}
}
- static final class ImmediateCancelledFuture<V extends @Nullable Object> extends TrustedFuture<V> {
+ static final class ImmediateCancelledFuture<V> extends TrustedFuture<V> {
ImmediateCancelledFuture() {
cancel(false);
}
diff --git a/guava/src/com/google/common/util/concurrent/Internal.java b/guava/src/com/google/common/util/concurrent/Internal.java
index 06bee2e..8f83823 100644
--- a/guava/src/com/google/common/util/concurrent/Internal.java
+++ b/guava/src/com/google/common/util/concurrent/Internal.java
@@ -19,7 +19,6 @@
/** This class is for {@code com.google.common.util.concurrent} use only! */
@GwtIncompatible // java.time.Duration
-@ElementTypesAreNonnullByDefault
final class Internal {
/**
diff --git a/guava/src/com/google/common/util/concurrent/InterruptibleTask.java b/guava/src/com/google/common/util/concurrent/InterruptibleTask.java
index 168adf2..7653776 100644
--- a/guava/src/com/google/common/util/concurrent/InterruptibleTask.java
+++ b/guava/src/com/google/common/util/concurrent/InterruptibleTask.java
@@ -14,26 +14,20 @@
package com.google.common.util.concurrent;
-import static com.google.common.util.concurrent.NullnessCasts.uncheckedCastNullableTToT;
-
import com.google.common.annotations.GwtCompatible;
-import com.google.common.annotations.VisibleForTesting;
import com.google.j2objc.annotations.ReflectionSupport;
import java.util.concurrent.atomic.AtomicReference;
-import java.util.concurrent.locks.AbstractOwnableSynchronizer;
import java.util.concurrent.locks.LockSupport;
import org.checkerframework.checker.nullness.qual.Nullable;
@GwtCompatible(emulated = true)
@ReflectionSupport(value = ReflectionSupport.Level.FULL)
-@ElementTypesAreNonnullByDefault
// Some Android 5.0.x Samsung devices have bugs in JDK reflection APIs that cause
// getDeclaredField to throw a NoSuchFieldException when the field is definitely there.
// Since this class only needs CAS on one field, we can avoid this bug by extending AtomicReference
// instead of using an AtomicReferenceFieldUpdater. This reference stores Thread instances
// and DONE/INTERRUPTED - they have a common ancestor of Runnable.
-abstract class InterruptibleTask<T extends @Nullable Object>
- extends AtomicReference<@Nullable Runnable> implements Runnable {
+abstract class InterruptibleTask<T> extends AtomicReference<Runnable> implements Runnable {
static {
// Prevent rare disastrous classloading in first call to LockSupport.park.
// See: https://bugs.openjdk.java.net/browse/JDK-8074773
@@ -48,6 +42,7 @@
// The thread executing the task publishes itself to the superclass' reference and the thread
// interrupting sets DONE when it has finished interrupting.
private static final Runnable DONE = new DoNothingRunnable();
+ private static final Runnable INTERRUPTING = new DoNothingRunnable();
private static final Runnable PARKED = new DoNothingRunnable();
// Why 1000? WHY NOT!
private static final int MAX_BUSY_WAIT_SPINS = 1000;
@@ -78,85 +73,68 @@
} finally {
// Attempt to set the task as done so that further attempts to interrupt will fail.
if (!compareAndSet(currentThread, DONE)) {
- waitForInterrupt(currentThread);
+ // If we were interrupted, it is possible that the interrupted bit hasn't been set yet. Wait
+ // for the interrupting thread to set DONE. See interruptTask().
+ // We want to wait so that we don't interrupt the _next_ thing run on the thread.
+ // Note: We don't reset the interrupted bit, just wait for it to be set.
+ // If this is a thread pool thread, the thread pool will reset it for us. Otherwise, the
+ // interrupted bit may have been intended for something else, so don't clear it.
+ boolean restoreInterruptedBit = false;
+ int spinCount = 0;
+ // Interrupting Cow Says:
+ // ______
+ // < Spin >
+ // ------
+ // \ ^__^
+ // \ (oo)\_______
+ // (__)\ )\/\
+ // ||----w |
+ // || ||
+ Runnable state = get();
+ while (state == INTERRUPTING || state == PARKED) {
+ spinCount++;
+ if (spinCount > MAX_BUSY_WAIT_SPINS) {
+ // If we have spun a lot just park ourselves.
+ // This will save CPU while we wait for a slow interrupting thread. In theory
+ // interruptTask() should be very fast but due to InterruptibleChannel and
+ // JavaLangAccess.blockedOn(Thread, Interruptible), it isn't predictable what work might
+ // be done. (e.g. close a file and flush buffers to disk). To protect ourselve from
+ // this we park ourselves and tell our interrupter that we did so.
+ if (state == PARKED || compareAndSet(INTERRUPTING, PARKED)) {
+ // Interrupting Cow Says:
+ // ______
+ // < Park >
+ // ------
+ // \ ^__^
+ // \ (oo)\_______
+ // (__)\ )\/\
+ // ||----w |
+ // || ||
+ // We need to clear the interrupted bit prior to calling park and maintain it in case
+ // we wake up spuriously.
+ restoreInterruptedBit = Thread.interrupted() || restoreInterruptedBit;
+ LockSupport.park(this);
+ }
+ } else {
+ Thread.yield();
+ }
+ state = get();
+ }
+ if (restoreInterruptedBit) {
+ currentThread.interrupt();
+ }
+ /*
+ * TODO(cpovirk): Clear interrupt status here? We currently don't, which means that an
+ * interrupt before, during, or after runInterruptibly() (unless it produced an
+ * InterruptedException caught above) can linger and affect listeners.
+ */
}
if (run) {
- if (error == null) {
- // The cast is safe because of the `run` and `error` checks.
- afterRanInterruptiblySuccess(uncheckedCastNullableTToT(result));
- } else {
- afterRanInterruptiblyFailure(error);
- }
+ afterRanInterruptibly(result, error);
}
}
}
- private void waitForInterrupt(Thread currentThread) {
- /*
- * If someone called cancel(true), it is possible that the interrupted bit hasn't been set yet.
- * Wait for the interrupting thread to set DONE. (See interruptTask().) We want to wait so that
- * the interrupting thread doesn't interrupt the _next_ thing to run on this thread.
- *
- * Note: We don't reset the interrupted bit, just wait for it to be set. If this is a thread
- * pool thread, the thread pool will reset it for us. Otherwise, the interrupted bit may have
- * been intended for something else, so don't clear it.
- */
- boolean restoreInterruptedBit = false;
- int spinCount = 0;
- // Interrupting Cow Says:
- // ______
- // < Spin >
- // ------
- // \ ^__^
- // \ (oo)\_______
- // (__)\ )\/\
- // ||----w |
- // || ||
- Runnable state = get();
- Blocker blocker = null;
- while (state instanceof Blocker || state == PARKED) {
- if (state instanceof Blocker) {
- blocker = (Blocker) state;
- }
- spinCount++;
- if (spinCount > MAX_BUSY_WAIT_SPINS) {
- /*
- * If we have spun a lot, just park ourselves. This will save CPU while we wait for a slow
- * interrupting thread. In theory, interruptTask() should be very fast, but due to
- * InterruptibleChannel and JavaLangAccess.blockedOn(Thread, Interruptible), it isn't
- * predictable what work might be done. (e.g., close a file and flush buffers to disk). To
- * protect ourselves from this, we park ourselves and tell our interrupter that we did so.
- */
- if (state == PARKED || compareAndSet(state, PARKED)) {
- // Interrupting Cow Says:
- // ______
- // < Park >
- // ------
- // \ ^__^
- // \ (oo)\_______
- // (__)\ )\/\
- // ||----w |
- // || ||
- // We need to clear the interrupted bit prior to calling park and maintain it in case we
- // wake up spuriously.
- restoreInterruptedBit = Thread.interrupted() || restoreInterruptedBit;
- LockSupport.park(blocker);
- }
- } else {
- Thread.yield();
- }
- state = get();
- }
- if (restoreInterruptedBit) {
- currentThread.interrupt();
- }
- /*
- * TODO(cpovirk): Clear interrupt status here? We currently don't, which means that an interrupt
- * before, during, or after runInterruptibly() (unless it produced an InterruptedException
- * caught above) can linger and affect listeners.
- */
- }
-
/**
* Called before runInterruptibly - if true, runInterruptibly and afterRanInterruptibly will not
* be called.
@@ -167,20 +145,13 @@
* Do interruptible work here - do not complete Futures here, as their listeners could be
* interrupted.
*/
- @ParametricNullness
abstract T runInterruptibly() throws Exception;
/**
* Any interruption that happens as a result of calling interruptTask will arrive before this
* method is called. Complete Futures here.
*/
- abstract void afterRanInterruptiblySuccess(@ParametricNullness T result);
-
- /**
- * Any interruption that happens as a result of calling interruptTask will arrive before this
- * method is called. Complete Futures here.
- */
- abstract void afterRanInterruptiblyFailure(Throwable error);
+ abstract void afterRanInterruptibly(@Nullable T result, @Nullable Throwable error);
/**
* Interrupts the running task. Because this internally calls {@link Thread#interrupt()} which can
@@ -191,59 +162,29 @@
// in this CAS, there's no risk of interrupting the wrong thread or interrupting a thread that
// isn't currently executing this task.
Runnable currentRunner = get();
- if (currentRunner instanceof Thread) {
- Blocker blocker = new Blocker(this);
- blocker.setOwner(Thread.currentThread());
- if (compareAndSet(currentRunner, blocker)) {
- // Thread.interrupt can throw arbitrary exceptions due to the nio InterruptibleChannel API
- // This will make sure that tasks don't get stuck busy waiting.
- // Some of this is fixed in jdk11 (see https://bugs.openjdk.java.net/browse/JDK-8198692) but
- // not all. See the test cases for examples on how this can happen.
- try {
- ((Thread) currentRunner).interrupt();
- } finally {
- Runnable prev = getAndSet(DONE);
- if (prev == PARKED) {
- LockSupport.unpark((Thread) currentRunner);
- }
+ if (currentRunner instanceof Thread && compareAndSet(currentRunner, INTERRUPTING)) {
+ // Thread.interrupt can throw aribitrary exceptions due to the nio InterruptibleChannel API
+ // This will make sure that tasks don't get stuck busy waiting.
+ // Some of this is fixed in jdk11 (see https://bugs.openjdk.java.net/browse/JDK-8198692) but
+ // not all. See the test cases for examples on how this can happen.
+ try {
+ ((Thread) currentRunner).interrupt();
+ } finally {
+ Runnable prev = getAndSet(DONE);
+ if (prev == PARKED) {
+ LockSupport.unpark((Thread) currentRunner);
}
}
}
}
- /**
- * Using this as the blocker object allows introspection and debugging tools to see that the
- * currentRunner thread is blocked on the progress of the interruptor thread, which can help
- * identify deadlocks.
- */
- @VisibleForTesting
- static final class Blocker extends AbstractOwnableSynchronizer implements Runnable {
- private final InterruptibleTask<?> task;
-
- private Blocker(InterruptibleTask<?> task) {
- this.task = task;
- }
-
- @Override
- public void run() {}
-
- private void setOwner(Thread thread) {
- super.setExclusiveOwnerThread(thread);
- }
-
- @Override
- public String toString() {
- return task.toString();
- }
- }
-
@Override
public final String toString() {
Runnable state = get();
final String result;
if (state == DONE) {
result = "running=[DONE]";
- } else if (state instanceof Blocker) {
+ } else if (state == INTERRUPTING) {
result = "running=[INTERRUPTED]";
} else if (state instanceof Thread) {
// getName is final on Thread, no need to worry about exceptions
diff --git a/guava/src/com/google/common/util/concurrent/JdkFutureAdapters.java b/guava/src/com/google/common/util/concurrent/JdkFutureAdapters.java
index 82f8d95..1b84302 100644
--- a/guava/src/com/google/common/util/concurrent/JdkFutureAdapters.java
+++ b/guava/src/com/google/common/util/concurrent/JdkFutureAdapters.java
@@ -24,7 +24,6 @@
import java.util.concurrent.Future;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.atomic.AtomicBoolean;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Utilities necessary for working with libraries that supply plain {@link Future} instances. Note
@@ -36,7 +35,6 @@
*/
@Beta
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public final class JdkFutureAdapters {
/**
* Assigns a thread to the given {@link Future} to provide {@link ListenableFuture} functionality.
@@ -51,8 +49,7 @@
* ListenableFutureTask}, {@link AbstractFuture}, and other utilities over creating plain {@code
* Future} instances to be upgraded to {@code ListenableFuture} after the fact.
*/
- public static <V extends @Nullable Object> ListenableFuture<V> listenInPoolThread(
- Future<V> future) {
+ public static <V> ListenableFuture<V> listenInPoolThread(Future<V> future) {
if (future instanceof ListenableFuture) {
return (ListenableFuture<V>) future;
}
@@ -79,8 +76,7 @@
*
* @since 12.0
*/
- public static <V extends @Nullable Object> ListenableFuture<V> listenInPoolThread(
- Future<V> future, Executor executor) {
+ public static <V> ListenableFuture<V> listenInPoolThread(Future<V> future, Executor executor) {
checkNotNull(executor);
if (future instanceof ListenableFuture) {
return (ListenableFuture<V>) future;
@@ -97,8 +93,8 @@
* <p>If the delegate future is interrupted or throws an unexpected unchecked exception, the
* listeners will not be invoked.
*/
- private static class ListenableFutureAdapter<V extends @Nullable Object>
- extends ForwardingFuture<V> implements ListenableFuture<V> {
+ private static class ListenableFutureAdapter<V> extends ForwardingFuture<V>
+ implements ListenableFuture<V> {
private static final ThreadFactory threadFactory =
new ThreadFactoryBuilder()
diff --git a/guava/src/com/google/common/util/concurrent/ListenableFuture.java b/guava/src/com/google/common/util/concurrent/ListenableFuture.java
index cf0199a..98e31ed 100644
--- a/guava/src/com/google/common/util/concurrent/ListenableFuture.java
+++ b/guava/src/com/google/common/util/concurrent/ListenableFuture.java
@@ -18,7 +18,6 @@
import java.util.concurrent.Executor;
import java.util.concurrent.Future;
import java.util.concurrent.RejectedExecutionException;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* A {@link Future} that accepts completion listeners. Each listener has an associated executor, and
@@ -100,32 +99,8 @@
* @author Nishant Thakkar
* @since 1.0
*/
-/*
- * Some of the annotations below were added after we released our separate
- * com.google.guava:listenablefuture:1.0 artifact. (For more on that artifact, see
- * https://github.com/google/guava/releases/tag/v27.0) This means that the copy of ListenableFuture
- * in com.google.guava:guava differs from the "frozen" copy in the listenablefuture artifact. This
- * could in principle cause problems for some users. Still, we expect that the benefits of the
- * nullness annotations in particular will outweigh the costs. (And it's worth noting that we have
- * released multiple ListenableFuture.class files that are not byte-for-byte compatible even from
- * the beginning, thanks to using different `-source -target` values for compiling our `-jre` and
- * `-android` "flavors.")
- *
- * (We could consider releasing a listenablefuture:1.0.1 someday. But we would want to look into how
- * that affects users, especially users of the Android Gradle Plugin, since the plugin developers
- * put in a special hack for us: https://issuetracker.google.com/issues/131431257)
- */
@DoNotMock("Use the methods in Futures (like immediateFuture) or SettableFuture")
-/*
- * It would make sense to also annotate this class with @ElementTypesAreNonnullByDefault. However,
- * it makes no difference because this class is already covered by the package-level
- * @ParametersAreNonnullByDefault, and this class declares only parameters, not return types or
- * fields. (Not to mention that we'll be removing all @*AreNonnullByDefault annotations after tools
- * understand .) And it's fortunate that the annotation makes no difference, because
- * we're seeing a breakage internally when we add that annotation :)
- *
- */
-public interface ListenableFuture<V extends @Nullable Object> extends Future<V> {
+public interface ListenableFuture<V> extends Future<V> {
/**
* Registers a listener to be {@linkplain Executor#execute(Runnable) run} on the given executor.
* The listener will run when the {@code Future}'s computation is {@linkplain Future#isDone()
diff --git a/guava/src/com/google/common/util/concurrent/ListenableFutureTask.java b/guava/src/com/google/common/util/concurrent/ListenableFutureTask.java
index 9fdcc53..eccc4d3 100644
--- a/guava/src/com/google/common/util/concurrent/ListenableFutureTask.java
+++ b/guava/src/com/google/common/util/concurrent/ListenableFutureTask.java
@@ -41,9 +41,7 @@
* @since 1.0
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
-public class ListenableFutureTask<V extends @Nullable Object> extends FutureTask<V>
- implements ListenableFuture<V> {
+public class ListenableFutureTask<V> extends FutureTask<V> implements ListenableFuture<V> {
// TODO(cpovirk): explore ways of making ListenableFutureTask final. There are some valid reasons
// such as BoundedQueueExecutorService to allow extends but it would be nice to make it final to
// avoid unintended usage.
@@ -58,7 +56,7 @@
* @param callable the callable task
* @since 10.0
*/
- public static <V extends @Nullable Object> ListenableFutureTask<V> create(Callable<V> callable) {
+ public static <V> ListenableFutureTask<V> create(Callable<V> callable) {
return new ListenableFutureTask<V>(callable);
}
@@ -72,8 +70,7 @@
* ListenableFutureTask.create(runnable, null)}
* @since 10.0
*/
- public static <V extends @Nullable Object> ListenableFutureTask<V> create(
- Runnable runnable, @ParametricNullness V result) {
+ public static <V> ListenableFutureTask<V> create(Runnable runnable, @Nullable V result) {
return new ListenableFutureTask<V>(runnable, result);
}
@@ -81,7 +78,7 @@
super(callable);
}
- ListenableFutureTask(Runnable runnable, @ParametricNullness V result) {
+ ListenableFutureTask(Runnable runnable, @Nullable V result) {
super(runnable, result);
}
@@ -92,7 +89,6 @@
@CanIgnoreReturnValue
@Override
- @ParametricNullness
public V get(long timeout, TimeUnit unit)
throws TimeoutException, InterruptedException, ExecutionException {
diff --git a/guava/src/com/google/common/util/concurrent/ListenableScheduledFuture.java b/guava/src/com/google/common/util/concurrent/ListenableScheduledFuture.java
index e5aa5e3..77fa5f7 100644
--- a/guava/src/com/google/common/util/concurrent/ListenableScheduledFuture.java
+++ b/guava/src/com/google/common/util/concurrent/ListenableScheduledFuture.java
@@ -17,7 +17,6 @@
import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtCompatible;
import java.util.concurrent.ScheduledFuture;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Helper interface to implement both {@link ListenableFuture} and {@link ScheduledFuture}.
@@ -27,6 +26,4 @@
*/
@Beta
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-public interface ListenableScheduledFuture<V extends @Nullable Object>
- extends ScheduledFuture<V>, ListenableFuture<V> {}
+public interface ListenableScheduledFuture<V> extends ScheduledFuture<V>, ListenableFuture<V> {}
diff --git a/guava/src/com/google/common/util/concurrent/ListenerCallQueue.java b/guava/src/com/google/common/util/concurrent/ListenerCallQueue.java
index ed8c906..ee6b5b9 100644
--- a/guava/src/com/google/common/util/concurrent/ListenerCallQueue.java
+++ b/guava/src/com/google/common/util/concurrent/ListenerCallQueue.java
@@ -53,7 +53,6 @@
* #dispatch} is expected to be called concurrently, it is idempotent.
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
final class ListenerCallQueue<L> {
// TODO(cpovirk): consider using the logger associated with listener.getClass().
private static final Logger logger = Logger.getLogger(ListenerCallQueue.class.getName());
@@ -124,7 +123,7 @@
/**
* A special purpose queue/executor that dispatches listener events serially on a configured
- * executor. Each event can be added and dispatched as separate phases.
+ * executor. Each event event can be added and dispatched as separate phases.
*
* <p>This class is very similar to {@link SequentialExecutor} with the exception that events can
* be added without necessarily executing immediately.
diff --git a/guava/src/com/google/common/util/concurrent/ListeningExecutorService.java b/guava/src/com/google/common/util/concurrent/ListeningExecutorService.java
index 83ea759..469eb67 100644
--- a/guava/src/com/google/common/util/concurrent/ListeningExecutorService.java
+++ b/guava/src/com/google/common/util/concurrent/ListeningExecutorService.java
@@ -23,7 +23,6 @@
import java.util.concurrent.Future;
import java.util.concurrent.RejectedExecutionException;
import java.util.concurrent.TimeUnit;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* An {@link ExecutorService} that returns {@link ListenableFuture} instances. To create an instance
@@ -37,14 +36,13 @@
"Use TestingExecutors.sameThreadScheduledExecutor, or wrap a real Executor from "
+ "java.util.concurrent.Executors with MoreExecutors.listeningDecorator")
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public interface ListeningExecutorService extends ExecutorService {
/**
* @return a {@code ListenableFuture} representing pending completion of the task
* @throws RejectedExecutionException {@inheritDoc}
*/
@Override
- <T extends @Nullable Object> ListenableFuture<T> submit(Callable<T> task);
+ <T> ListenableFuture<T> submit(Callable<T> task);
/**
* @return a {@code ListenableFuture} representing pending completion of the task
@@ -58,8 +56,7 @@
* @throws RejectedExecutionException {@inheritDoc}
*/
@Override
- <T extends @Nullable Object> ListenableFuture<T> submit(
- Runnable task, @ParametricNullness T result);
+ <T> ListenableFuture<T> submit(Runnable task, T result);
/**
* {@inheritDoc}
@@ -80,7 +77,7 @@
* @throws NullPointerException if any task is null
*/
@Override
- <T extends @Nullable Object> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks)
+ <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks)
throws InterruptedException;
/**
@@ -103,7 +100,7 @@
* @throws NullPointerException if any task is null
*/
@Override
- <T extends @Nullable Object> List<Future<T>> invokeAll(
+ <T> List<Future<T>> invokeAll(
Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit)
throws InterruptedException;
}
diff --git a/guava/src/com/google/common/util/concurrent/ListeningScheduledExecutorService.java b/guava/src/com/google/common/util/concurrent/ListeningScheduledExecutorService.java
index 25185b9..6410e83 100644
--- a/guava/src/com/google/common/util/concurrent/ListeningScheduledExecutorService.java
+++ b/guava/src/com/google/common/util/concurrent/ListeningScheduledExecutorService.java
@@ -21,7 +21,6 @@
import java.util.concurrent.Callable;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* A {@link ScheduledExecutorService} that returns {@link ListenableFuture} instances from its
@@ -33,7 +32,6 @@
* @since 10.0
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public interface ListeningScheduledExecutorService
extends ScheduledExecutorService, ListeningExecutorService {
@@ -52,16 +50,14 @@
/** @since 15.0 (previously returned ScheduledFuture) */
@Override
- <V extends @Nullable Object> ListenableScheduledFuture<V> schedule(
- Callable<V> callable, long delay, TimeUnit unit);
+ <V> ListenableScheduledFuture<V> schedule(Callable<V> callable, long delay, TimeUnit unit);
/**
* Duration-based overload of {@link #schedule(Callable, long, TimeUnit)}.
*
* @since 29.0
*/
- default <V extends @Nullable Object> ListenableScheduledFuture<V> schedule(
- Callable<V> callable, Duration delay) {
+ default <V> ListenableScheduledFuture<V> schedule(Callable<V> callable, Duration delay) {
return schedule(callable, toNanosSaturated(delay), TimeUnit.NANOSECONDS);
}
diff --git a/guava/src/com/google/common/util/concurrent/Monitor.java b/guava/src/com/google/common/util/concurrent/Monitor.java
index 6696b97..dcdd7b6 100644
--- a/guava/src/com/google/common/util/concurrent/Monitor.java
+++ b/guava/src/com/google/common/util/concurrent/Monitor.java
@@ -27,7 +27,7 @@
import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.ReentrantLock;
import java.util.function.BooleanSupplier;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* A synchronization abstraction supporting waiting on arbitrary boolean conditions.
@@ -203,7 +203,6 @@
@Beta
@GwtIncompatible
@SuppressWarnings("GuardedBy") // TODO(b/35466881): Fix or suppress.
-@ElementTypesAreNonnullByDefault
public final class Monitor {
// TODO(user): Use raw LockSupport or AbstractQueuedSynchronizer instead of ReentrantLock.
// TODO(user): "Port" jsr166 tests for ReentrantLock.
@@ -315,7 +314,7 @@
/** The next active guard */
@GuardedBy("monitor.lock")
- @CheckForNull
+ @Nullable
Guard next;
protected Guard(Monitor monitor) {
@@ -342,7 +341,6 @@
* A linked list threaded through the Guard.next field.
*/
@GuardedBy("lock")
- @CheckForNull
private Guard activeGuards = null;
/**
diff --git a/guava/src/com/google/common/util/concurrent/MoreExecutors.java b/guava/src/com/google/common/util/concurrent/MoreExecutors.java
index fc61fba..bc258ae 100644
--- a/guava/src/com/google/common/util/concurrent/MoreExecutors.java
+++ b/guava/src/com/google/common/util/concurrent/MoreExecutors.java
@@ -51,7 +51,6 @@
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Factory and utility methods for {@link java.util.concurrent.Executor}, {@link ExecutorService},
@@ -63,7 +62,6 @@
* @since 3.0
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
public final class MoreExecutors {
private MoreExecutors() {}
@@ -455,12 +453,6 @@
* (In simple cases, callers can avoid this by registering all tasks with the same {@link
* MoreExecutors#newSequentialExecutor} wrapper around {@code directExecutor()}. More
* complex cases may require using thread pools or making deeper changes.)
- * <li>If an exception propagates out of a {@code Runnable}, it is not necessarily seen by any
- * {@code UncaughtExceptionHandler} for the thread. For example, if the callback passed to
- * {@link Futures#addCallback} throws an exception, that exception will be typically be
- * logged by the {@link ListenableFuture} implementation, even if the thread is configured
- * to do something different. In other cases, no code will catch the exception, and it may
- * terminate whichever thread happens to trigger the execution.
* </ul>
*
* Additionally, beware of executing tasks with {@code directExecutor} while holding a lock. Since
@@ -480,6 +472,7 @@
* <p>This should be preferred to {@link #newDirectExecutorService()} because implementing the
* {@link ExecutorService} subinterface necessitates significant performance overhead.
*
+ *
* @since 18.0
*/
public static Executor directExecutor() {
@@ -618,11 +611,6 @@
public final void execute(Runnable command) {
delegate.execute(command);
}
-
- @Override
- public final String toString() {
- return super.toString() + "[" + delegate + "]";
- }
}
@GwtIncompatible // TODO
@@ -638,14 +626,13 @@
@Override
public ListenableScheduledFuture<?> schedule(Runnable command, long delay, TimeUnit unit) {
- TrustedListenableFutureTask<@Nullable Void> task =
- TrustedListenableFutureTask.create(command, null);
+ TrustedListenableFutureTask<Void> task = TrustedListenableFutureTask.create(command, null);
ScheduledFuture<?> scheduled = delegate.schedule(task, delay, unit);
- return new ListenableScheduledTask<@Nullable Void>(task, scheduled);
+ return new ListenableScheduledTask<>(task, scheduled);
}
@Override
- public <V extends @Nullable Object> ListenableScheduledFuture<V> schedule(
+ public <V> ListenableScheduledFuture<V> schedule(
Callable<V> callable, long delay, TimeUnit unit) {
TrustedListenableFutureTask<V> task = TrustedListenableFutureTask.create(callable);
ScheduledFuture<?> scheduled = delegate.schedule(task, delay, unit);
@@ -657,7 +644,7 @@
Runnable command, long initialDelay, long period, TimeUnit unit) {
NeverSuccessfulListenableFutureTask task = new NeverSuccessfulListenableFutureTask(command);
ScheduledFuture<?> scheduled = delegate.scheduleAtFixedRate(task, initialDelay, period, unit);
- return new ListenableScheduledTask<@Nullable Void>(task, scheduled);
+ return new ListenableScheduledTask<>(task, scheduled);
}
@Override
@@ -666,10 +653,10 @@
NeverSuccessfulListenableFutureTask task = new NeverSuccessfulListenableFutureTask(command);
ScheduledFuture<?> scheduled =
delegate.scheduleWithFixedDelay(task, initialDelay, delay, unit);
- return new ListenableScheduledTask<@Nullable Void>(task, scheduled);
+ return new ListenableScheduledTask<>(task, scheduled);
}
- private static final class ListenableScheduledTask<V extends @Nullable Object>
+ private static final class ListenableScheduledTask<V>
extends SimpleForwardingListenableFuture<V> implements ListenableScheduledFuture<V> {
private final ScheduledFuture<?> scheduledDelegate;
@@ -705,7 +692,7 @@
@GwtIncompatible // TODO
private static final class NeverSuccessfulListenableFutureTask
- extends AbstractFuture.TrustedFuture<@Nullable Void> implements Runnable {
+ extends AbstractFuture.TrustedFuture<Void> implements Runnable {
private final Runnable delegate;
public NeverSuccessfulListenableFutureTask(Runnable delegate) {
@@ -721,11 +708,6 @@
throw Throwables.propagate(t);
}
}
-
- @Override
- protected String pendingToString() {
- return "task=[" + delegate + "]";
- }
}
}
@@ -744,9 +726,7 @@
* An implementation of {@link ExecutorService#invokeAny} for {@link ListeningExecutorService}
* implementations.
*/
- @GwtIncompatible
- @ParametricNullness
- static <T extends @Nullable Object> T invokeAnyImpl(
+ @GwtIncompatible static <T> T invokeAnyImpl(
ListeningExecutorService executorService,
Collection<? extends Callable<T>> tasks,
boolean timed,
@@ -761,9 +741,7 @@
* implementations.
*/
@SuppressWarnings("GoodTime") // should accept a java.time.Duration
- @GwtIncompatible
- @ParametricNullness
- static <T extends @Nullable Object> T invokeAnyImpl(
+ @GwtIncompatible static <T> T invokeAnyImpl(
ListeningExecutorService executorService,
Collection<? extends Callable<T>> tasks,
boolean timed,
@@ -843,7 +821,7 @@
* Submits the task and adds a listener that adds the future to {@code queue} when it completes.
*/
@GwtIncompatible // TODO
- private static <T extends @Nullable Object> ListenableFuture<T> submitAndAddQueueListener(
+ private static <T> ListenableFuture<T> submitAndAddQueueListener(
ListeningExecutorService executorService,
Callable<T> task,
final BlockingQueue<Future<T>> queue) {
@@ -955,6 +933,7 @@
* right before each task is run. The renaming is best effort, if a {@link SecurityManager}
* prevents the renaming then it will be skipped but the tasks will still execute.
*
+ *
* @param executor The executor to decorate
* @param nameSupplier The source of names for each task
*/
@@ -978,6 +957,7 @@
* right before each task is run. The renaming is best effort, if a {@link SecurityManager}
* prevents the renaming then it will be skipped but the tasks will still execute.
*
+ *
* @param service The executor to decorate
* @param nameSupplier The source of names for each task
*/
@@ -988,7 +968,7 @@
checkNotNull(nameSupplier);
return new WrappingExecutorService(service) {
@Override
- protected <T extends @Nullable Object> Callable<T> wrapTask(Callable<T> callable) {
+ protected <T> Callable<T> wrapTask(Callable<T> callable) {
return Callables.threadRenaming(callable, nameSupplier);
}
@@ -1007,6 +987,7 @@
* right before each task is run. The renaming is best effort, if a {@link SecurityManager}
* prevents the renaming then it will be skipped but the tasks will still execute.
*
+ *
* @param service The executor to decorate
* @param nameSupplier The source of names for each task
*/
@@ -1017,7 +998,7 @@
checkNotNull(nameSupplier);
return new WrappingScheduledExecutorService(service) {
@Override
- protected <T extends @Nullable Object> Callable<T> wrapTask(Callable<T> callable) {
+ protected <T> Callable<T> wrapTask(Callable<T> callable) {
return Callables.threadRenaming(callable, nameSupplier);
}
diff --git a/guava/src/com/google/common/util/concurrent/NullnessCasts.java b/guava/src/com/google/common/util/concurrent/NullnessCasts.java
deleted file mode 100644
index 0a0d719..0000000
--- a/guava/src/com/google/common/util/concurrent/NullnessCasts.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Copyright (C) 2021 The Guava Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
- * or implied. See the License for the specific language governing permissions and limitations under
- * the License.
- */
-
-package com.google.common.util.concurrent;
-
-import com.google.common.annotations.GwtCompatible;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
-
-/** A utility method to perform unchecked casts to suppress errors produced by nullness analyses. */
-@GwtCompatible
-@ElementTypesAreNonnullByDefault
-final class NullnessCasts {
- /**
- * Accepts a {@code @Nullable T} and returns a plain {@code T}, without performing any check that
- * that conversion is safe.
- *
- * <p>This method is intended to help with usages of type parameters that have {@linkplain
- * ParametricNullness parametric nullness}. If a type parameter instead ranges over only non-null
- * types (or if the type is a non-variable type, like {@code String}), then code should almost
- * never use this method, preferring instead to call {@code requireNonNull} so as to benefit from
- * its runtime check.
- *
- * <p>An example use case for this method is in implementing an {@code Iterator<T>} whose {@code
- * next} field is lazily initialized. The type of that field would be {@code @Nullable T}, and the
- * code would be responsible for populating a "real" {@code T} (which might still be the value
- * {@code null}!) before returning it to callers. Depending on how the code is structured, a
- * nullness analysis might not understand that the field has been populated. To avoid that problem
- * without having to add {@code @SuppressWarnings}, the code can call this method.
- *
- * <p>Why <i>not</i> just add {@code SuppressWarnings}? The problem is that this method is
- * typically useful for {@code return} statements. That leaves the code with two options: Either
- * add the suppression to the whole method (which turns off checking for a large section of code),
- * or extract a variable, and put the suppression on that. However, a local variable typically
- * doesn't work: Because nullness analyses typically infer the nullness of local variables,
- * there's no way to assign a {@code @Nullable T} to a field {@code T foo;} and instruct the
- * analysis that that means "plain {@code T}" rather than the inferred type {@code @Nullable T}.
- * (Even if supported added {@code @NonNull}, that would not help, since the problem case
- * addressed by this method is the case in which {@code T} has parametric nullness -- and thus its
- * value may be legitimately {@code null}.)
- */
- @SuppressWarnings("nullness")
- @ParametricNullness
- static <T extends @Nullable Object> T uncheckedCastNullableTToT(@CheckForNull T t) {
- return t;
- }
-
- /**
- * Returns {@code null} cast to any type.
- *
- * <p>This method is intended to help with usages of type parameters that have {@linkplain
- * ParametricNullness parametric nullness}. Sometimes, code may receive a null {@code T} but store
- * a "null sentinel" to take its place. When the time comes to convert it back to a {@code T} to
- * return to a caller, the code needs to a way to return {@code null} from a method that returns
- * "plain {@code T}." This API provides that.
- */
- @SuppressWarnings("nullness")
- @ParametricNullness
- static <T extends @Nullable Object> T uncheckedNull() {
- return null;
- }
-
- private NullnessCasts() {}
-}
diff --git a/guava/src/com/google/common/util/concurrent/OverflowAvoidingLockSupport.java b/guava/src/com/google/common/util/concurrent/OverflowAvoidingLockSupport.java
index 3038ab7..aa07abf 100644
--- a/guava/src/com/google/common/util/concurrent/OverflowAvoidingLockSupport.java
+++ b/guava/src/com/google/common/util/concurrent/OverflowAvoidingLockSupport.java
@@ -17,20 +17,19 @@
import static java.lang.Math.min;
import java.util.concurrent.locks.LockSupport;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Works around an android bug, where parking for more than INT_MAX seconds can produce an abort
* signal on 32 bit devices running Android Q.
*/
-@ElementTypesAreNonnullByDefault
final class OverflowAvoidingLockSupport {
// Represents the max nanoseconds representable on a linux timespec with a 32 bit tv_sec
static final long MAX_NANOSECONDS_THRESHOLD = (1L + Integer.MAX_VALUE) * 1_000_000_000L - 1L;
private OverflowAvoidingLockSupport() {}
- static void parkNanos(@CheckForNull Object blocker, long nanos) {
+ static void parkNanos(@Nullable Object blocker, long nanos) {
// Even in the extremely unlikely event that a thread unblocks itself early after only 68 years,
// this is indistinguishable from a spurious wakeup, which LockSupport allows.
LockSupport.parkNanos(blocker, min(nanos, MAX_NANOSECONDS_THRESHOLD));
diff --git a/guava/src/com/google/common/util/concurrent/ParametricNullness.java b/guava/src/com/google/common/util/concurrent/ParametricNullness.java
deleted file mode 100644
index ebc5928..0000000
--- a/guava/src/com/google/common/util/concurrent/ParametricNullness.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2021 The Guava Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.common.util.concurrent;
-
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.PARAMETER;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-import static javax.annotation.meta.When.UNKNOWN;
-
-import com.google.common.annotations.GwtCompatible;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-import javax.annotation.Nonnull;
-import javax.annotation.meta.TypeQualifierNickname;
-
-/**
- * Marks a "top-level" type-variable usage as (a) a Kotlin platform type when the type argument is
- * non-nullable and (b) nullable when the type argument is nullable. This is the closest we can get
- * to "non-nullable when non-nullable; nullable when nullable" (like the Android <a
- * href="https://android.googlesource.com/platform/libcore/+/master/luni/src/main/java/libcore/util/NullFromTypeParam.java">{@code
- * NullFromTypeParam}</a>). We use this to "undo" {@link ElementTypesAreNonnullByDefault}.
- */
-@GwtCompatible
-@Retention(RUNTIME)
-@Target({FIELD, METHOD, PARAMETER})
-@TypeQualifierNickname
-@Nonnull(when = UNKNOWN)
-@interface ParametricNullness {}
diff --git a/guava/src/com/google/common/util/concurrent/Partially.java b/guava/src/com/google/common/util/concurrent/Partially.java
index 7aa16e7..c40ab4e 100644
--- a/guava/src/com/google/common/util/concurrent/Partially.java
+++ b/guava/src/com/google/common/util/concurrent/Partially.java
@@ -32,7 +32,6 @@
* version.
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
final class Partially {
/**
* The presence of this annotation on an API indicates that the method <i>may</i> be used with the
diff --git a/guava/src/com/google/common/util/concurrent/Platform.java b/guava/src/com/google/common/util/concurrent/Platform.java
index cfb96a0..f27bfb3 100644
--- a/guava/src/com/google/common/util/concurrent/Platform.java
+++ b/guava/src/com/google/common/util/concurrent/Platform.java
@@ -15,14 +15,13 @@
package com.google.common.util.concurrent;
import com.google.common.annotations.GwtCompatible;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/** Methods factored out so that they can be emulated differently in GWT. */
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
final class Platform {
static boolean isInstanceOfThrowableClass(
- @CheckForNull Throwable t, Class<? extends Throwable> expectedClass) {
+ @Nullable Throwable t, Class<? extends Throwable> expectedClass) {
return expectedClass.isInstance(t);
}
diff --git a/guava/src/com/google/common/util/concurrent/RateLimiter.java b/guava/src/com/google/common/util/concurrent/RateLimiter.java
index 4b8b025..ec041d4 100644
--- a/guava/src/com/google/common/util/concurrent/RateLimiter.java
+++ b/guava/src/com/google/common/util/concurrent/RateLimiter.java
@@ -31,7 +31,7 @@
import java.time.Duration;
import java.util.Locale;
import java.util.concurrent.TimeUnit;
-import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* A rate limiter. Conceptually, a rate limiter distributes permits at a configurable rate. Each
@@ -94,7 +94,6 @@
// would mean a maximum rate of "1MB/s", which might be small in some cases.
@Beta
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public abstract class RateLimiter {
/**
* Creates a {@code RateLimiter} with the specified stable throughput, given as "permits per
@@ -215,7 +214,7 @@
private final SleepingStopwatch stopwatch;
// Can't be initialized in the constructor because mocks don't call the constructor.
- @CheckForNull private volatile Object mutexDoNotUseDirectly;
+ private volatile @Nullable Object mutexDoNotUseDirectly;
private Object mutex() {
Object mutex = mutexDoNotUseDirectly;
diff --git a/guava/src/com/google/common/util/concurrent/Runnables.java b/guava/src/com/google/common/util/concurrent/Runnables.java
index 5503f68..e1ebd23 100644
--- a/guava/src/com/google/common/util/concurrent/Runnables.java
+++ b/guava/src/com/google/common/util/concurrent/Runnables.java
@@ -24,7 +24,6 @@
*/
@Beta
@GwtCompatible
-@ElementTypesAreNonnullByDefault
public final class Runnables {
private static final Runnable EMPTY_RUNNABLE =
diff --git a/guava/src/com/google/common/util/concurrent/SequentialExecutor.java b/guava/src/com/google/common/util/concurrent/SequentialExecutor.java
index 052c7e0..5604175 100644
--- a/guava/src/com/google/common/util/concurrent/SequentialExecutor.java
+++ b/guava/src/com/google/common/util/concurrent/SequentialExecutor.java
@@ -31,7 +31,6 @@
import java.util.concurrent.RejectedExecutionException;
import java.util.logging.Level;
import java.util.logging.Logger;
-import javax.annotation.CheckForNull;
/**
* Executor ensuring that all Runnables submitted are executed in order, using the provided
@@ -48,7 +47,6 @@
* restarted by a call to {@link #execute}.
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
final class SequentialExecutor implements Executor {
private static final Logger log = Logger.getLogger(SequentialExecutor.class.getName());
@@ -93,7 +91,7 @@
* Adds a task to the queue and makes sure a worker thread is running.
*
* <p>If this method throws, e.g. a {@code RejectedExecutionException} from the delegate executor,
- * execution of tasks will stop until a call to this method is made.
+ * execution of tasks will stop until a call to this method or to {@link #resume()} is made.
*/
@Override
public void execute(final Runnable task) {
@@ -172,7 +170,7 @@
/** Worker that runs tasks from {@link #queue} until it is empty. */
private final class QueueWorker implements Runnable {
- @CheckForNull Runnable task;
+ Runnable task;
@Override
public void run() {
diff --git a/guava/src/com/google/common/util/concurrent/Service.java b/guava/src/com/google/common/util/concurrent/Service.java
index dd0c7e6..3c4c476 100644
--- a/guava/src/com/google/common/util/concurrent/Service.java
+++ b/guava/src/com/google/common/util/concurrent/Service.java
@@ -56,7 +56,6 @@
*/
@DoNotMock("Create an AbstractIdleService")
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public interface Service {
/**
* If the service state is {@link State#NEW}, this initiates service startup and returns
@@ -207,28 +206,61 @@
*/
enum State {
/** A service in this state is inactive. It does minimal work and consumes minimal resources. */
- NEW,
+ NEW {
+ @Override
+ boolean isTerminal() {
+ return false;
+ }
+ },
/** A service in this state is transitioning to {@link #RUNNING}. */
- STARTING,
+ STARTING {
+ @Override
+ boolean isTerminal() {
+ return false;
+ }
+ },
/** A service in this state is operational. */
- RUNNING,
+ RUNNING {
+ @Override
+ boolean isTerminal() {
+ return false;
+ }
+ },
/** A service in this state is transitioning to {@link #TERMINATED}. */
- STOPPING,
+ STOPPING {
+ @Override
+ boolean isTerminal() {
+ return false;
+ }
+ },
/**
* A service in this state has completed execution normally. It does minimal work and consumes
* minimal resources.
*/
- TERMINATED,
+ TERMINATED {
+ @Override
+ boolean isTerminal() {
+ return true;
+ }
+ },
/**
* A service in this state has encountered a problem and may not be operational. It cannot be
* started nor stopped.
*/
- FAILED,
+ FAILED {
+ @Override
+ boolean isTerminal() {
+ return true;
+ }
+ };
+
+ /** Returns true if this state is terminal. */
+ abstract boolean isTerminal();
}
/**
diff --git a/guava/src/com/google/common/util/concurrent/ServiceManager.java b/guava/src/com/google/common/util/concurrent/ServiceManager.java
index d2dda7a..e5b468f 100644
--- a/guava/src/com/google/common/util/concurrent/ServiceManager.java
+++ b/guava/src/com/google/common/util/concurrent/ServiceManager.java
@@ -51,7 +51,6 @@
import com.google.common.util.concurrent.Service.State;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import com.google.errorprone.annotations.concurrent.GuardedBy;
-import com.google.j2objc.annotations.J2ObjCIncompatible;
import com.google.j2objc.annotations.WeakOuter;
import java.lang.ref.WeakReference;
import java.time.Duration;
@@ -121,7 +120,6 @@
* @since 14.0
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public final class ServiceManager implements ServiceManagerBridge {
private static final Logger logger = Logger.getLogger(ServiceManager.class.getName());
private static final ListenerCallQueue.Event<Listener> HEALTHY_EVENT =
@@ -415,20 +413,6 @@
return state.startupTimes();
}
- /**
- * Returns the service load times. This value will only return startup times for services that
- * have finished starting.
- *
- * @return Map of services and their corresponding startup time, the map entries will be ordered
- * by startup time.
- * @since 31.0
- */
- @J2ObjCIncompatible
- public ImmutableMap<Service, Duration> startupDurations() {
- return ImmutableMap.copyOf(
- Maps.<Service, Long, Duration>transformValues(startupTimes(), Duration::ofMillis));
- }
-
@Override
public String toString() {
return MoreObjects.toStringHelper(ServiceManager.class)
@@ -641,9 +625,9 @@
// N.B. There will only be an entry in the map if the service has started
for (Entry<Service, Stopwatch> entry : startupTimers.entrySet()) {
Service service = entry.getKey();
- Stopwatch stopwatch = entry.getValue();
- if (!stopwatch.isRunning() && !(service instanceof NoOpService)) {
- loadTimes.add(Maps.immutableEntry(service, stopwatch.elapsed(MILLISECONDS)));
+ Stopwatch stopWatch = entry.getValue();
+ if (!stopWatch.isRunning() && !(service instanceof NoOpService)) {
+ loadTimes.add(Maps.immutableEntry(service, stopWatch.elapsed(MILLISECONDS)));
}
}
} finally {
diff --git a/guava/src/com/google/common/util/concurrent/ServiceManagerBridge.java b/guava/src/com/google/common/util/concurrent/ServiceManagerBridge.java
index 7ae430e..a9300a6 100644
--- a/guava/src/com/google/common/util/concurrent/ServiceManagerBridge.java
+++ b/guava/src/com/google/common/util/concurrent/ServiceManagerBridge.java
@@ -26,7 +26,6 @@
* {@code servicesByState()} to return {@code ImmutableMultimap}.
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
interface ServiceManagerBridge {
ImmutableMultimap<State, Service> servicesByState();
}
diff --git a/guava/src/com/google/common/util/concurrent/SettableFuture.java b/guava/src/com/google/common/util/concurrent/SettableFuture.java
index 893161e..a0f4732 100644
--- a/guava/src/com/google/common/util/concurrent/SettableFuture.java
+++ b/guava/src/com/google/common/util/concurrent/SettableFuture.java
@@ -33,19 +33,17 @@
* @since 9.0 (in 1.0 as {@code ValueFuture})
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-public final class SettableFuture<V extends @Nullable Object>
- extends AbstractFuture.TrustedFuture<V> {
+public final class SettableFuture<V> extends AbstractFuture.TrustedFuture<V> {
/**
* Creates a new {@code SettableFuture} that can be completed or cancelled by a later method call.
*/
- public static <V extends @Nullable Object> SettableFuture<V> create() {
+ public static <V> SettableFuture<V> create() {
return new SettableFuture<V>();
}
@CanIgnoreReturnValue
@Override
- public boolean set(@ParametricNullness V value) {
+ public boolean set(@Nullable V value) {
return super.set(value);
}
diff --git a/guava/src/com/google/common/util/concurrent/SimpleTimeLimiter.java b/guava/src/com/google/common/util/concurrent/SimpleTimeLimiter.java
index 5a1969e..9d0b81b 100644
--- a/guava/src/com/google/common/util/concurrent/SimpleTimeLimiter.java
+++ b/guava/src/com/google/common/util/concurrent/SimpleTimeLimiter.java
@@ -34,8 +34,6 @@
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* A TimeLimiter that runs method calls in the background using an {@link ExecutorService}. If the
@@ -47,7 +45,6 @@
*/
@Beta
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public final class SimpleTimeLimiter implements TimeLimiter {
private final ExecutorService executor;
@@ -88,14 +85,11 @@
InvocationHandler handler =
new InvocationHandler() {
@Override
- @CheckForNull
- public Object invoke(
- Object obj, final Method method, @CheckForNull final @Nullable Object[] args)
+ public Object invoke(Object obj, final Method method, final Object[] args)
throws Throwable {
- Callable<@Nullable Object> callable =
- new Callable<@Nullable Object>() {
+ Callable<Object> callable =
+ new Callable<Object>() {
@Override
- @CheckForNull
public Object call() throws Exception {
try {
return method.invoke(target, args);
@@ -119,7 +113,7 @@
return interfaceType.cast(object);
}
- private <T extends @Nullable Object> T callWithTimeout(
+ private <T> T callWithTimeout(
Callable<T> callable, long timeoutDuration, TimeUnit timeoutUnit, boolean amInterruptible)
throws Exception {
checkNotNull(callable);
@@ -149,8 +143,7 @@
@CanIgnoreReturnValue
@Override
- public <T extends @Nullable Object> T callWithTimeout(
- Callable<T> callable, long timeoutDuration, TimeUnit timeoutUnit)
+ public <T> T callWithTimeout(Callable<T> callable, long timeoutDuration, TimeUnit timeoutUnit)
throws TimeoutException, InterruptedException, ExecutionException {
checkNotNull(callable);
checkNotNull(timeoutUnit);
@@ -171,7 +164,7 @@
@CanIgnoreReturnValue
@Override
- public <T extends @Nullable Object> T callUninterruptiblyWithTimeout(
+ public <T> T callUninterruptiblyWithTimeout(
Callable<T> callable, long timeoutDuration, TimeUnit timeoutUnit)
throws TimeoutException, ExecutionException {
checkNotNull(callable);
diff --git a/guava/src/com/google/common/util/concurrent/SmoothRateLimiter.java b/guava/src/com/google/common/util/concurrent/SmoothRateLimiter.java
index ca78905..d78d7da 100644
--- a/guava/src/com/google/common/util/concurrent/SmoothRateLimiter.java
+++ b/guava/src/com/google/common/util/concurrent/SmoothRateLimiter.java
@@ -22,15 +22,14 @@
import java.util.concurrent.TimeUnit;
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
abstract class SmoothRateLimiter extends RateLimiter {
/*
* How is the RateLimiter designed, and why?
*
- * The primary feature of a RateLimiter is its "stable rate", the maximum rate that it should
- * allow in normal conditions. This is enforced by "throttling" incoming requests as needed. For
- * example, we could compute the appropriate throttle time for an incoming request, and make the
- * calling thread wait for that time.
+ * The primary feature of a RateLimiter is its "stable rate", the maximum rate that is should
+ * allow at normal conditions. This is enforced by "throttling" incoming requests as needed, i.e.
+ * compute, for an incoming request, the appropriate throttle time, and make the calling thread
+ * wait as much.
*
* The simplest way to maintain a rate of QPS is to keep the timestamp of the last granted
* request, and ensure that (1/QPS) seconds have elapsed since then. For example, for a rate of
diff --git a/guava/src/com/google/common/util/concurrent/Striped.java b/guava/src/com/google/common/util/concurrent/Striped.java
index fc8bcd8..c9ba772 100644
--- a/guava/src/com/google/common/util/concurrent/Striped.java
+++ b/guava/src/com/google/common/util/concurrent/Striped.java
@@ -14,8 +14,6 @@
package com.google.common.util.concurrent;
-import static com.google.common.collect.Lists.newArrayList;
-
import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtIncompatible;
import com.google.common.annotations.VisibleForTesting;
@@ -23,6 +21,7 @@
import com.google.common.base.Preconditions;
import com.google.common.base.Supplier;
import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Iterables;
import com.google.common.collect.MapMaker;
import com.google.common.math.IntMath;
import com.google.common.primitives.Ints;
@@ -41,7 +40,6 @@
import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* A striped {@code Lock/Semaphore/ReadWriteLock}. This offers the underlying lock striping similar
@@ -84,7 +82,6 @@
*/
@Beta
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public abstract class Striped<L> {
/**
* If there are at least this many stripes, we assume the memory usage of a ConcurrentMap will be
@@ -139,26 +136,26 @@
* @return the stripes corresponding to the objects (one per each object, derived by delegating to
* {@link #get(Object)}; may contain duplicates), in an increasing index order.
*/
- public Iterable<L> bulkGet(Iterable<? extends Object> keys) {
- // Initially using the list to store the keys, then reusing it to store the respective L's
- List<Object> result = newArrayList(keys);
- if (result.isEmpty()) {
+ public Iterable<L> bulkGet(Iterable<?> keys) {
+ // Initially using the array to store the keys, then reusing it to store the respective L's
+ final Object[] array = Iterables.toArray(keys, Object.class);
+ if (array.length == 0) {
return ImmutableList.of();
}
- int[] stripes = new int[result.size()];
- for (int i = 0; i < result.size(); i++) {
- stripes[i] = indexFor(result.get(i));
+ int[] stripes = new int[array.length];
+ for (int i = 0; i < array.length; i++) {
+ stripes[i] = indexFor(array[i]);
}
Arrays.sort(stripes);
// optimize for runs of identical stripes
int previousStripe = stripes[0];
- result.set(0, getAt(previousStripe));
- for (int i = 1; i < result.size(); i++) {
+ array[0] = getAt(previousStripe);
+ for (int i = 1; i < array.length; i++) {
int currentStripe = stripes[i];
if (currentStripe == previousStripe) {
- result.set(i, result.get(i - 1));
+ array[i] = array[i - 1];
} else {
- result.set(i, getAt(currentStripe));
+ array[i] = getAt(currentStripe);
previousStripe = currentStripe;
}
}
@@ -180,8 +177,8 @@
* be garbage collected after locking them, ending up in a huge mess.
*/
@SuppressWarnings("unchecked") // we carefully replaced all keys with their respective L's
- List<L> asStripes = (List<L>) result;
- return Collections.unmodifiableList(asStripes);
+ List<L> asList = (List<L>) Arrays.asList(array);
+ return Collections.unmodifiableList(asList);
}
// Static factories
@@ -438,7 +435,7 @@
*/
@VisibleForTesting
static class SmallLazyStriped<L> extends PowerOfTwoStriped<L> {
- final AtomicReferenceArray<@Nullable ArrayReference<? extends L>> locks;
+ final AtomicReferenceArray<ArrayReference<? extends L>> locks;
final Supplier<L> supplier;
final int size;
final ReferenceQueue<L> queue = new ReferenceQueue<L>();
diff --git a/guava/src/com/google/common/util/concurrent/ThreadFactoryBuilder.java b/guava/src/com/google/common/util/concurrent/ThreadFactoryBuilder.java
index 1027f3c..f09ed4e 100644
--- a/guava/src/com/google/common/util/concurrent/ThreadFactoryBuilder.java
+++ b/guava/src/com/google/common/util/concurrent/ThreadFactoryBuilder.java
@@ -16,7 +16,6 @@
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
-import static java.util.Objects.requireNonNull;
import com.google.common.annotations.GwtIncompatible;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
@@ -26,7 +25,6 @@
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.atomic.AtomicLong;
-import javax.annotation.CheckForNull;
/**
* A ThreadFactory builder, providing any combination of these features:
@@ -47,13 +45,12 @@
*/
@CanIgnoreReturnValue
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public final class ThreadFactoryBuilder {
- @CheckForNull private String nameFormat = null;
- @CheckForNull private Boolean daemon = null;
- @CheckForNull private Integer priority = null;
- @CheckForNull private UncaughtExceptionHandler uncaughtExceptionHandler = null;
- @CheckForNull private ThreadFactory backingThreadFactory = null;
+ private String nameFormat = null;
+ private Boolean daemon = null;
+ private Integer priority = null;
+ private UncaughtExceptionHandler uncaughtExceptionHandler = null;
+ private ThreadFactory backingThreadFactory = null;
/** Creates a new {@link ThreadFactory} builder. */
public ThreadFactoryBuilder() {}
@@ -165,8 +162,7 @@
public Thread newThread(Runnable runnable) {
Thread thread = backingThreadFactory.newThread(runnable);
if (nameFormat != null) {
- // requireNonNull is safe because we create `count` if (and only if) we have a nameFormat.
- thread.setName(format(nameFormat, requireNonNull(count).getAndIncrement()));
+ thread.setName(format(nameFormat, count.getAndIncrement()));
}
if (daemon != null) {
thread.setDaemon(daemon);
diff --git a/guava/src/com/google/common/util/concurrent/TimeLimiter.java b/guava/src/com/google/common/util/concurrent/TimeLimiter.java
index 0245fec..600c6cf 100644
--- a/guava/src/com/google/common/util/concurrent/TimeLimiter.java
+++ b/guava/src/com/google/common/util/concurrent/TimeLimiter.java
@@ -25,7 +25,6 @@
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Imposes a time limit on method calls.
@@ -37,7 +36,6 @@
@Beta
@DoNotMock("Use FakeTimeLimiter")
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public interface TimeLimiter {
/**
@@ -146,8 +144,7 @@
*/
@SuppressWarnings("GoodTime") // should accept a java.time.Duration
@CanIgnoreReturnValue
- <T extends @Nullable Object> T callWithTimeout(
- Callable<T> callable, long timeoutDuration, TimeUnit timeoutUnit)
+ <T> T callWithTimeout(Callable<T> callable, long timeoutDuration, TimeUnit timeoutUnit)
throws TimeoutException, InterruptedException, ExecutionException;
/**
@@ -167,7 +164,7 @@
* @since 28.0
*/
@CanIgnoreReturnValue
- default <T extends @Nullable Object> T callWithTimeout(Callable<T> callable, Duration timeout)
+ default <T> T callWithTimeout(Callable<T> callable, Duration timeout)
throws TimeoutException, InterruptedException, ExecutionException {
return callWithTimeout(callable, toNanosSaturated(timeout), TimeUnit.NANOSECONDS);
}
@@ -193,7 +190,7 @@
*/
@SuppressWarnings("GoodTime") // should accept a java.time.Duration
@CanIgnoreReturnValue
- <T extends @Nullable Object> T callUninterruptiblyWithTimeout(
+ <T> T callUninterruptiblyWithTimeout(
Callable<T> callable, long timeoutDuration, TimeUnit timeoutUnit)
throws TimeoutException, ExecutionException;
@@ -216,8 +213,8 @@
* @since 28.0
*/
@CanIgnoreReturnValue
- default <T extends @Nullable Object> T callUninterruptiblyWithTimeout(
- Callable<T> callable, Duration timeout) throws TimeoutException, ExecutionException {
+ default <T> T callUninterruptiblyWithTimeout(Callable<T> callable, Duration timeout)
+ throws TimeoutException, ExecutionException {
return callUninterruptiblyWithTimeout(
callable, toNanosSaturated(timeout), TimeUnit.NANOSECONDS);
}
diff --git a/guava/src/com/google/common/util/concurrent/TimeoutFuture.java b/guava/src/com/google/common/util/concurrent/TimeoutFuture.java
index 219a098..af30d1f 100644
--- a/guava/src/com/google/common/util/concurrent/TimeoutFuture.java
+++ b/guava/src/com/google/common/util/concurrent/TimeoutFuture.java
@@ -24,7 +24,6 @@
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -35,9 +34,8 @@
* interrupted and cancelled if it times out.
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
-final class TimeoutFuture<V extends @Nullable Object> extends FluentFuture.TrustedFuture<V> {
- static <V extends @Nullable Object> ListenableFuture<V> create(
+final class TimeoutFuture<V> extends FluentFuture.TrustedFuture<V> {
+ static <V> ListenableFuture<V> create(
ListenableFuture<V> delegate,
long time,
TimeUnit unit,
@@ -73,16 +71,16 @@
* write-barriers).
*/
- @CheckForNull private ListenableFuture<V> delegateRef;
- @CheckForNull private ScheduledFuture<?> timer;
+ private @Nullable ListenableFuture<V> delegateRef;
+ private @Nullable ScheduledFuture<?> timer;
private TimeoutFuture(ListenableFuture<V> delegate) {
this.delegateRef = Preconditions.checkNotNull(delegate);
}
/** A runnable that is called when the delegate or the timer completes. */
- private static final class Fire<V extends @Nullable Object> implements Runnable {
- @CheckForNull TimeoutFuture<V> timeoutFutureRef;
+ private static final class Fire<V> implements Runnable {
+ @Nullable TimeoutFuture<V> timeoutFutureRef;
Fire(TimeoutFuture<V> timeoutFuture) {
this.timeoutFutureRef = timeoutFuture;
@@ -154,7 +152,6 @@
}
@Override
- @CheckForNull
protected String pendingToString() {
ListenableFuture<? extends V> localInputFuture = delegateRef;
ScheduledFuture<?> localTimer = timer;
diff --git a/guava/src/com/google/common/util/concurrent/TrustedListenableFutureTask.java b/guava/src/com/google/common/util/concurrent/TrustedListenableFutureTask.java
index a2c2115..3a607c5 100644
--- a/guava/src/com/google/common/util/concurrent/TrustedListenableFutureTask.java
+++ b/guava/src/com/google/common/util/concurrent/TrustedListenableFutureTask.java
@@ -21,7 +21,6 @@
import java.util.concurrent.Callable;
import java.util.concurrent.Executors;
import java.util.concurrent.RunnableFuture;
-import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -31,16 +30,14 @@
* performance reasons.
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
-class TrustedListenableFutureTask<V extends @Nullable Object> extends FluentFuture.TrustedFuture<V>
+class TrustedListenableFutureTask<V> extends FluentFuture.TrustedFuture<V>
implements RunnableFuture<V> {
- static <V extends @Nullable Object> TrustedListenableFutureTask<V> create(
- AsyncCallable<V> callable) {
+ static <V> TrustedListenableFutureTask<V> create(AsyncCallable<V> callable) {
return new TrustedListenableFutureTask<V>(callable);
}
- static <V extends @Nullable Object> TrustedListenableFutureTask<V> create(Callable<V> callable) {
+ static <V> TrustedListenableFutureTask<V> create(Callable<V> callable) {
return new TrustedListenableFutureTask<V>(callable);
}
@@ -53,8 +50,7 @@
* result, consider using constructions of the form: {@code ListenableFuture<?> f =
* ListenableFutureTask.create(runnable, null)}
*/
- static <V extends @Nullable Object> TrustedListenableFutureTask<V> create(
- Runnable runnable, @ParametricNullness V result) {
+ static <V> TrustedListenableFutureTask<V> create(Runnable runnable, @Nullable V result) {
return new TrustedListenableFutureTask<V>(Executors.callable(runnable, result));
}
@@ -65,7 +61,7 @@
* <p>{@code volatile} is required for j2objc transpiling:
* https://developers.google.com/j2objc/guides/j2objc-memory-model#atomicity
*/
- @CheckForNull private volatile InterruptibleTask<?> task;
+ private volatile InterruptibleTask<?> task;
TrustedListenableFutureTask(Callable<V> callable) {
this.task = new TrustedFutureInterruptibleTask(callable);
@@ -77,7 +73,7 @@
@Override
public void run() {
- InterruptibleTask<?> localTask = task;
+ InterruptibleTask localTask = task;
if (localTask != null) {
localTask.run();
}
@@ -93,7 +89,7 @@
super.afterDone();
if (wasInterrupted()) {
- InterruptibleTask<?> localTask = task;
+ InterruptibleTask localTask = task;
if (localTask != null) {
localTask.interruptTask();
}
@@ -103,9 +99,8 @@
}
@Override
- @CheckForNull
protected String pendingToString() {
- InterruptibleTask<?> localTask = task;
+ InterruptibleTask localTask = task;
if (localTask != null) {
return "task=[" + localTask + "]";
}
@@ -126,19 +121,17 @@
}
@Override
- @ParametricNullness
V runInterruptibly() throws Exception {
return callable.call();
}
@Override
- void afterRanInterruptiblySuccess(@ParametricNullness V result) {
- TrustedListenableFutureTask.this.set(result);
- }
-
- @Override
- void afterRanInterruptiblyFailure(Throwable error) {
- setException(error);
+ void afterRanInterruptibly(V result, Throwable error) {
+ if (error == null) {
+ TrustedListenableFutureTask.this.set(result);
+ } else {
+ setException(error);
+ }
}
@Override
@@ -171,13 +164,12 @@
}
@Override
- void afterRanInterruptiblySuccess(ListenableFuture<V> result) {
- setFuture(result);
- }
-
- @Override
- void afterRanInterruptiblyFailure(Throwable error) {
- setException(error);
+ void afterRanInterruptibly(ListenableFuture<V> result, Throwable error) {
+ if (error == null) {
+ setFuture(result);
+ } else {
+ setException(error);
+ }
}
@Override
diff --git a/guava/src/com/google/common/util/concurrent/UncaughtExceptionHandlers.java b/guava/src/com/google/common/util/concurrent/UncaughtExceptionHandlers.java
index a1add8b..c0c2600 100644
--- a/guava/src/com/google/common/util/concurrent/UncaughtExceptionHandlers.java
+++ b/guava/src/com/google/common/util/concurrent/UncaughtExceptionHandlers.java
@@ -29,7 +29,6 @@
* @since 8.0
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public final class UncaughtExceptionHandlers {
private UncaughtExceptionHandlers() {}
diff --git a/guava/src/com/google/common/util/concurrent/UncheckedExecutionException.java b/guava/src/com/google/common/util/concurrent/UncheckedExecutionException.java
index 713f4a6..c6c57d3 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 javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Unchecked variant of {@link java.util.concurrent.ExecutionException}. As with {@code
@@ -33,29 +33,22 @@
* @since 10.0
*/
@GwtCompatible
-@ElementTypesAreNonnullByDefault
public class UncheckedExecutionException extends RuntimeException {
- /*
- * Ideally, this class would have exposed only constructors that require a non-null cause. We
- * might try to move in that direction, but there are complications. See
- * https://github.com/jspecify/nullness-checker-for-checker-framework/blob/61aafa4ae52594830cfc2d61c8b113009dbdb045/src/main/java/com/google/jspecify/nullness/NullSpecTransfer.java#L789
- */
-
/** Creates a new instance with {@code null} as its detail message. */
protected UncheckedExecutionException() {}
/** Creates a new instance with the given detail message. */
- protected UncheckedExecutionException(@CheckForNull String message) {
+ protected UncheckedExecutionException(@Nullable String message) {
super(message);
}
/** Creates a new instance with the given detail message and cause. */
- public UncheckedExecutionException(@CheckForNull String message, @CheckForNull Throwable cause) {
+ public UncheckedExecutionException(@Nullable String message, @Nullable Throwable cause) {
super(message, cause);
}
/** Creates a new instance with the given cause. */
- public UncheckedExecutionException(@CheckForNull 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 8e30fca..04fddf4 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 javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Unchecked version of {@link java.util.concurrent.TimeoutException}.
@@ -24,19 +24,18 @@
* @since 1.0
*/
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
public class UncheckedTimeoutException extends RuntimeException {
public UncheckedTimeoutException() {}
- public UncheckedTimeoutException(@CheckForNull String message) {
+ public UncheckedTimeoutException(@Nullable String message) {
super(message);
}
- public UncheckedTimeoutException(@CheckForNull Throwable cause) {
+ public UncheckedTimeoutException(@Nullable Throwable cause) {
super(cause);
}
- public UncheckedTimeoutException(@CheckForNull String message, @CheckForNull Throwable cause) {
+ public UncheckedTimeoutException(@Nullable String message, @Nullable Throwable cause) {
super(message, cause);
}
diff --git a/guava/src/com/google/common/util/concurrent/Uninterruptibles.java b/guava/src/com/google/common/util/concurrent/Uninterruptibles.java
index 94678ec..0ce6f1a 100644
--- a/guava/src/com/google/common/util/concurrent/Uninterruptibles.java
+++ b/guava/src/com/google/common/util/concurrent/Uninterruptibles.java
@@ -35,7 +35,6 @@
import java.util.concurrent.TimeoutException;
import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.Lock;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Utilities for treating interruptible operations as uninterruptible. In all cases, if a thread is
@@ -46,7 +45,6 @@
* @since 10.0
*/
@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
public final class Uninterruptibles {
// Implementation Note: As of 3-7-11, the logic for each blocking/timeout
@@ -234,9 +232,7 @@
* @throws CancellationException if the computation was cancelled
*/
@CanIgnoreReturnValue
- @ParametricNullness
- public static <V extends @Nullable Object> V getUninterruptibly(Future<V> future)
- throws ExecutionException {
+ public static <V> V getUninterruptibly(Future<V> future) throws ExecutionException {
boolean interrupted = false;
try {
while (true) {
@@ -275,9 +271,8 @@
@CanIgnoreReturnValue
@GwtIncompatible // java.time.Duration
@Beta
- @ParametricNullness
- public static <V extends @Nullable Object> V getUninterruptibly(
- Future<V> future, Duration timeout) throws ExecutionException, TimeoutException {
+ public static <V> V getUninterruptibly(Future<V> future, Duration timeout)
+ throws ExecutionException, TimeoutException {
return getUninterruptibly(future, toNanosSaturated(timeout), TimeUnit.NANOSECONDS);
}
@@ -302,9 +297,8 @@
@CanIgnoreReturnValue
@GwtIncompatible // TODO
@SuppressWarnings("GoodTime") // should accept a java.time.Duration
- @ParametricNullness
- public static <V extends @Nullable Object> V getUninterruptibly(
- Future<V> future, long timeout, TimeUnit unit) throws ExecutionException, TimeoutException {
+ public static <V> V getUninterruptibly(Future<V> future, long timeout, TimeUnit unit)
+ throws ExecutionException, TimeoutException {
boolean interrupted = false;
try {
long remainingNanos = unit.toNanos(timeout);
diff --git a/guava/src/com/google/common/util/concurrent/WrappingExecutorService.java b/guava/src/com/google/common/util/concurrent/WrappingExecutorService.java
index 03c08cc..217e0a7 100644
--- a/guava/src/com/google/common/util/concurrent/WrappingExecutorService.java
+++ b/guava/src/com/google/common/util/concurrent/WrappingExecutorService.java
@@ -29,7 +29,6 @@
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* An abstract {@code ExecutorService} that allows subclasses to {@linkplain #wrapTask(Callable)
@@ -43,7 +42,6 @@
*/
@CanIgnoreReturnValue // TODO(cpovirk): Consider being more strict.
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
abstract class WrappingExecutorService implements ExecutorService {
private final ExecutorService delegate;
@@ -55,7 +53,7 @@
* Wraps a {@code Callable} for submission to the underlying executor. This method is also applied
* to any {@code Runnable} passed to the default implementation of {@link #wrapTask(Runnable)}.
*/
- protected abstract <T extends @Nullable Object> Callable<T> wrapTask(Callable<T> callable);
+ protected abstract <T> Callable<T> wrapTask(Callable<T> callable);
/**
* Wraps a {@code Runnable} for submission to the underlying executor. The default implementation
@@ -81,8 +79,7 @@
*
* @throws NullPointerException if any element of {@code tasks} is null
*/
- private <T extends @Nullable Object> ImmutableList<Callable<T>> wrapTasks(
- Collection<? extends Callable<T>> tasks) {
+ private <T> ImmutableList<Callable<T>> wrapTasks(Collection<? extends Callable<T>> tasks) {
ImmutableList.Builder<Callable<T>> builder = ImmutableList.builder();
for (Callable<T> task : tasks) {
builder.add(wrapTask(task));
@@ -97,7 +94,7 @@
}
@Override
- public final <T extends @Nullable Object> Future<T> submit(Callable<T> task) {
+ public final <T> Future<T> submit(Callable<T> task) {
return delegate.submit(wrapTask(checkNotNull(task)));
}
@@ -107,33 +104,31 @@
}
@Override
- public final <T extends @Nullable Object> Future<T> submit(
- Runnable task, @ParametricNullness T result) {
+ public final <T> Future<T> submit(Runnable task, T result) {
return delegate.submit(wrapTask(task), result);
}
@Override
- public final <T extends @Nullable Object> List<Future<T>> invokeAll(
- Collection<? extends Callable<T>> tasks) throws InterruptedException {
+ public final <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks)
+ throws InterruptedException {
return delegate.invokeAll(wrapTasks(tasks));
}
@Override
- public final <T extends @Nullable Object> List<Future<T>> invokeAll(
+ public final <T> List<Future<T>> invokeAll(
Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit)
throws InterruptedException {
return delegate.invokeAll(wrapTasks(tasks), timeout, unit);
}
@Override
- public final <T extends @Nullable Object> T invokeAny(Collection<? extends Callable<T>> tasks)
+ public final <T> T invokeAny(Collection<? extends Callable<T>> tasks)
throws InterruptedException, ExecutionException {
return delegate.invokeAny(wrapTasks(tasks));
}
@Override
- public final <T extends @Nullable Object> T invokeAny(
- Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit)
+ public final <T> T invokeAny(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit)
throws InterruptedException, ExecutionException, TimeoutException {
return delegate.invokeAny(wrapTasks(tasks), timeout, unit);
}
diff --git a/guava/src/com/google/common/util/concurrent/WrappingScheduledExecutorService.java b/guava/src/com/google/common/util/concurrent/WrappingScheduledExecutorService.java
index 48f23c1..4ab700f 100644
--- a/guava/src/com/google/common/util/concurrent/WrappingScheduledExecutorService.java
+++ b/guava/src/com/google/common/util/concurrent/WrappingScheduledExecutorService.java
@@ -20,7 +20,6 @@
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* An abstract {@code ScheduledExecutorService} that allows subclasses to {@linkplain
@@ -32,7 +31,6 @@
*/
@CanIgnoreReturnValue // TODO(cpovirk): Consider being more strict.
@GwtIncompatible
-@ElementTypesAreNonnullByDefault
abstract class WrappingScheduledExecutorService extends WrappingExecutorService
implements ScheduledExecutorService {
final ScheduledExecutorService delegate;
@@ -48,8 +46,7 @@
}
@Override
- public final <V extends @Nullable Object> ScheduledFuture<V> schedule(
- Callable<V> task, long delay, TimeUnit unit) {
+ public final <V> ScheduledFuture<V> schedule(Callable<V> task, long delay, TimeUnit unit) {
return delegate.schedule(wrapTask(task), delay, unit);
}
diff --git a/guava/src/com/google/common/xml/ElementTypesAreNonnullByDefault.java b/guava/src/com/google/common/xml/ElementTypesAreNonnullByDefault.java
deleted file mode 100644
index b4fb4e3..0000000
--- a/guava/src/com/google/common/xml/ElementTypesAreNonnullByDefault.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) 2021 The Guava Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.common.xml;
-
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.PARAMETER;
-import static java.lang.annotation.ElementType.TYPE;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-import com.google.common.annotations.GwtCompatible;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-import javax.annotation.Nonnull;
-import javax.annotation.meta.TypeQualifierDefault;
-
-/**
- * Marks all "top-level" types as non-null in a way that is recognized by Kotlin. Note that this
- * unfortunately includes type-variable usages, so we also provide {@link ParametricNullness} to
- * "undo" it as best we can.
- */
-@GwtCompatible
-@Retention(RUNTIME)
-@Target(TYPE)
-@TypeQualifierDefault({FIELD, METHOD, PARAMETER})
-@Nonnull
-@interface ElementTypesAreNonnullByDefault {}
diff --git a/guava/src/com/google/common/xml/ParametricNullness.java b/guava/src/com/google/common/xml/ParametricNullness.java
deleted file mode 100644
index a476558..0000000
--- a/guava/src/com/google/common/xml/ParametricNullness.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2021 The Guava Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.common.xml;
-
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.PARAMETER;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-import static javax.annotation.meta.When.UNKNOWN;
-
-import com.google.common.annotations.GwtCompatible;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-import javax.annotation.Nonnull;
-import javax.annotation.meta.TypeQualifierNickname;
-
-/**
- * Marks a "top-level" type-variable usage as (a) a Kotlin platform type when the type argument is
- * non-nullable and (b) nullable when the type argument is nullable. This is the closest we can get
- * to "non-nullable when non-nullable; nullable when nullable" (like the Android <a
- * href="https://android.googlesource.com/platform/libcore/+/master/luni/src/main/java/libcore/util/NullFromTypeParam.java">{@code
- * NullFromTypeParam}</a>). We use this to "undo" {@link ElementTypesAreNonnullByDefault}.
- */
-@GwtCompatible
-@Retention(RUNTIME)
-@Target({FIELD, METHOD, PARAMETER})
-@TypeQualifierNickname
-@Nonnull(when = UNKNOWN)
-@interface ParametricNullness {}
diff --git a/guava/src/com/google/common/xml/XmlEscapers.java b/guava/src/com/google/common/xml/XmlEscapers.java
index a1c637c..b25fcfc 100644
--- a/guava/src/com/google/common/xml/XmlEscapers.java
+++ b/guava/src/com/google/common/xml/XmlEscapers.java
@@ -30,6 +30,7 @@
* non-ASCII characters to their numeric entity replacements. These XML escapers provide the minimal
* level of escaping to ensure that the output can be safely included in a Unicode XML document.
*
+ *
* <p>For details on the behavior of the escapers in this class, see sections <a
* href="http://www.w3.org/TR/2008/REC-xml-20081126/#charsets">2.2</a> and <a
* href="http://www.w3.org/TR/2008/REC-xml-20081126/#syntax">2.4</a> of the XML specification.
@@ -40,7 +41,6 @@
*/
@Beta
@GwtCompatible
-@ElementTypesAreNonnullByDefault
public class XmlEscapers {
private XmlEscapers() {}
diff --git a/guava/src/com/google/thirdparty/publicsuffix/PublicSuffixPatterns.java b/guava/src/com/google/thirdparty/publicsuffix/PublicSuffixPatterns.java
index 9e5f173..475cabb 100644
--- a/guava/src/com/google/thirdparty/publicsuffix/PublicSuffixPatterns.java
+++ b/guava/src/com/google/thirdparty/publicsuffix/PublicSuffixPatterns.java
@@ -30,7 +30,7 @@
* determining whether a given domain name is an effective top-level domain (public suffix).
*
* <p>Because this class is used in GWT, the data members are stored in a space-efficient manner.
- * See {@link TrieParser}.
+ * {@see TrieParser}.
*
* @since 16.0
*/
@@ -42,7 +42,7 @@
/** If a hostname is contained as a key in this map, it is a public suffix. */
public static final ImmutableMap<String, PublicSuffixType> EXACT =
TrieParser.parseTrie(
- "a&0&0trk9--nx?27qjf--nx?e9ebgn--nx?nbb0c7abgm--nx??1&2oa08--nx?apg6qpcbgm--nx?hbbgm--nx?rdceqa08--nx??2&8ugbgm--nx?eyh3la2ckx--nx?qbd9--nx??3&2wqq1--nx?60a0y8--nx??4x1d77xrck--nx?6&1f4a3abgm--nx?2yqyn--nx?3np8lv81qo3--nx?5b06t--nx?axq--nx?ec7q--nx?lbgw--nx??883xnn--nx?9d2c24--nx?a&a?it??b!.&gro?lim?moc?sr,t&en?opsgolb,?ude?vog??abila?c?ihsot?m?n??c!.&b&a?m?n??c&b?g?q??ep?fn?k&s?y??ln?no?oc,p&i-on,ohsdaerpsym,?sn?t&n?opsgolb,?un?ysrab,?i&ma?r&emarp?fa??sroc??naiva?s??d&ats?n&eit?oh??om?sa?tl??eg?f&c?ob??g!emo?naripi?oy??hskihs?i&cnal?dem?hs?k!on??sa!.snduolc,??jnin?k&aso?dov?ede?usto??l!.&c,gro?moc?ofni?r&ep?nb,?t&en?ni??ude?vog??irgnahs?le&nisiuc?rbmuder???m!.&ca?gro?oc?sserp?ten?vog??ahokoy?e00sf7vqn--nx?m??n!.&ac?cc?eman?gro?ibom?loohcs?moc?ni?o&c?fni?rp??r&d?o??s&u?w??vt?xm??av?is?olecrab?tea??p!.&bog?ca?d&em?ls??g&ni?ro??mo&c?n??oba?ten?ude??c?g7hyabgm--nx?ra!.&461e?6pi?iru?nru?rdda-ni?siri???s??q!.&eman?gro?hcs?lim?moc?t&en?opsgolb,?ude?vog???r&az?emac?f4a3abgm--nx?n!d5uhf8le58r4w--nx??u&kas?tan???s!.&bup?dem?gro?hcs?moc?ten?ude?vog??ac!.uban.iu,?iv??t&ad?elhta?led?oyot??u!.&a&cinniv?emirc?i&hzhziropaz?stynniv??s&edo?sedo??tlay?vatlop??bs?cc,d&argovorik?o!roghzu??tl,?e&hzhziropaz?nvir?t??f&i?ni,?g&l?ro??hk?i&stvinrehc?ykstynlemhk??k&c?m?s&nagul?t&enod?ul??v&iknarf-onavi?orteporp&end?ind?????l&iponret?opotsa&bes?ves??p??m&k?oc?s?yrk??n&c?d?i?osrehk?v?ylov??o&c,nvor??p&d?p,z??r&c?imotihz?k?ymotyhz??sk?t&en?l?z??ude?v:c?e&alokin?ik??i&alokym?hinrehc?krahk?vl?yk??k?l?o&g!inrehc??krahk??r?,xc,y&ikstinlemhk?mus?s&akrehc?sakrehc?tvonrehc???z&ib,u????v!aj?bb?et?iv??waniko?x&a?iacal??yogan?z&.&bew?c&a?i&n?rga???gro?l&im?oohcs??m&on?t??o&c!.topsgolb,?gn??radnorg?sin?t&en?la??ude?vog?wal??zip???b&00ave5a9iabgm--nx?1&25qhx--nx?68quv--nx?e2kc1--nx??2xtbgm--nx?3&b2kcc--nx?jca1d--nx??4&6&1rfz--nx?qif--nx??96rzc--nx??7w9u16qlj--nx?88uvor--nx?a&0dc4xbgm--nx?c?her?n?ra?t??b!.&erots?gro?moc?o&c?fni??ten?ude?v&og?t??zib??a??c&j?s??d&hesa08--nx?mi??g?l!.&gro?moc?ten?ude?vog??m??s!.&gro?moc?ten?ude?vog???tc-retarebsnegmrev--nx?u&lc!.&elej,snduolc,y&nop,srab,??smas??p!.ysrab,??wp-gnutarebsnegmrev--nx??c&1&1q54--nx?hbgw--nx??2e9c2czf--nx?4&4ub1km--nx?a1e--nx?byj9q--nx?erd5a9b1kcb--nx??8&4xx2g--nx?c9jrb2h--nx??9jr&b&2h--nx?54--nx?9s--nx??c&eg--nx?h3--nx?s2--nx???a!.&gro?lim?moc?rrd,ten?ude?vog??3a09--nx!.&ca1o--nx?gva1c--nx?h&ca1o--nx?za09--nx??ta1d--nx?ua08--nx???da??b&a?b?ci?f76a0c7ylqbgm--nx?sh??c!.&eugaelysatnaf,gnipparcs,liamwt,revres-emag,s&nduolc,otohpym,seccaptf,?xsc,?0atf7b45--nx?a1l--nx??e!.&21k?bog?dem?gro?lim?moc?nif?o&fni?rp??ten?ude?vog??beuq?n?smoc??fdh?i&l&buperananab?ohtac??n&agro?ilc?osanap??sum?tic??l!.&gro?moc?oc?ten?ude?vog?yo,?l??m!.&mt?ossa??p1akcq--nx??n!.&mon?ossa??i?p??relcel?s!.&gro?moc?ten?ude?vog??c??t!.&e&m,w,?hc,?s?w??v!.&e0,gro?lim?moc?ten?ude?v&g:.d,,og???q??wp?yn??d&2urzc--nx?3&1wrpk--nx?c&4b11--nx?9jrcpf--nx???5xq55--nx?697uto--nx?75yrpk--nx?9ctdvkce--nx?a!.mon?d?er?olnwod??b2babgm--nx?c!.vog?g9a2g2b0ae0chclc--nx??e&m!bulc??r!k??sopxe?timil?w??fc?g!.&ude?vog???h&d3tbgm--nx?p?t??i!.&ased?bew?ca?etrof,golbw,hcs?lim?o&c!.topsgolb,?g??palf,r&egolb,o??sepnop?ten?ym?zib??ar?b?ordna?p?rdam??l&iub?og?row??m!.&ed,ot,pj,t&a,opsgolb,???n&a&b?l!.citats:.&setis,ved,?,raas???ob?uf??o&of?rp??r&a&c&tiderc?yalcrab??ugnav??ef506w4b--nx?k!.&oc,ude,?jh3a1habgm--nx??of??s!.&dem?gro?moc?ofni?ten?ude?v&og?t???m!kcrem???t!.topsgolb,excwkcc--nx?l??uolc!.&a&bura-vnej.&1ti,abura.rue.1ti,?tcepsrep,xo:.&ku,nt,?,?bewilek:.sc,,citsalej.piv,drayknil,elej,gnitsohdnert.&ed,hc,?letemirp:.ku,,m&edaid,ialcer.&ac,ku,su,??n&evueluk,woru,?r&epolroov,o&pav,tnemele,??tenraxa.1-se,ululetoj,xelpciffart,??za5cbgn--nx??e&1&53wlf--nx?7a1hbbgm--nx?ta3kg--nx??2a6a1b6b1i--nx?3ma0e1cvr--nx?418txh--nx?707b0e3--nx?a!.&ca?gro?hcs?lim?oc?t&en?opsgolb,?vog??09--nx??b!.&ca?gnitsohbew,nevueluk.yxorpze,pohsdaerpsym,snoitulostsohretni.duolc,topsgolb,?ortal?ut!uoy???c&0krbd4--nx?a&lp!.oc,?ps!.&lla4sx,rebu,tsafym,?artxe??sla??i!ffo??n&a&d?iler?nif?rusni!efil?srelevart???eics!.oby,??rofria??d!.&1sndnyd,42pi-nyd,7erauqs,amil4,b&ow-nrefeilgitsng--nx,rb-ni,vz-nelletsebgitsng--nx,?decalpb,e&daregtmueart,mohsnd,nihcamyek,?hcierebsnoissuksid,keegnietsi,lsd-ni,moc,n&-i-g-o-l,aw-ym,e&lletsebgitsnüg,sgnutiel,?i&emtsi,lreb-n&i,yd,??oitatsksid-ygolonys,pv&-n&i,yd,?nyd,?refeilgitsnüg,?orp-ytinummoc,p&h21,iog:ol,,ohsdaerpsym,?r&e&ntrapdeeps.remotsuc,su&-lautriv,lautriv,?t&adpusnd,tub-ni,uor-ym,?vres&-e&bucl,mohym,?bew-emoh:.nyd,,luhcs,??ogiv-&niem,ym,??s&d-&onys,ygolonys,?nd&-&dd,nufiat,sehcsimanyd,tenretni,yard,?isoc.nyd,ps,yard,?oper-&nvs,tig,?sndd:.&nyd,sndnyd,?,?topsgolb,vresi-&niem,tset,?xi2,y&awetag-&llawerif,ym,?srab,tic-amil,?zten&mitbel,sadtretteuf,??a&lg?rt!.oby,??i&sdoow?ug??nil?on--nx??e!.&bil?dem?eif?gro?irp?kiir?moc!.topsgolb,?pia?ude?vog??ei?ffoc?gg?r&f?ged???f&a&c?s??il??g!.&gro?lim?moc?t&en?vp??ude?vog??a&f?gtrom?p!.&3xlh,kselp,sndp,tengam,xlh,ycvrp,??rots?yov??elloc?na&hcxe?ro??roeg?ug??i!.&pohsdaerpsym,topsgolb,vog??tilop?v&bba?om???j!.&fo,gro?oc?ten???k!.&c&a?s??e&m?n??ibom?o&c!.topsgolb,?fni?g??ro??i&b?l?n???l&a&dmrif?s!.rof,rof???b&a?i&b?dua???c&aro?ric??dnik?g!oog??i&bom?ms??l&asal?erauqa??ppa?uhcs?yts!efil???m!.&4&32i,pct,?66c,ailisarb,b&dnevar,g-raegelif,?ca?duolcsd,e&d-raegelif,i&-raegelif,lpad:.tsohlacol,,?pcm,?g&ro?s-raegelif,?hctilg,k&catsegde,uoc,?noitatsksid,o&bmoy,c!ku,?t&nigol,poh,??p&ion,j-raegelif,ohbew,?qbw,r&aegelif,idcm,ofsnd,?s&dym,ndd,ti!bt,?umhol,?t&en?s&acdnuos,ohon,??u&a-raegelif,de?tcn,?v&irp?og??y&golonys,olpedew,srab,??a&g?n!.&reh.togrof,sih.togrof,???em?i&rp?twohs??orhc?w??n!goloc?i&lno!.&egats-oree,oree,ysrab,??w??o!.&derno:.gnigats,,ecivres,knilemoh,r&ednu,of,??hp?latipac?ts&der?e&gdirb?rif???z!.&66duolc,amil,sh,???ruoblem??om?p!.&bog?gro?lim?mo&c?n??t&en?opsgolb,?ude??irg?yks??r!.&mo&c?n??ossa?topsgolb,?a&c!htlaeh??pmoc?wtfos??bc?eh?if?ots!.&e&rawpohs,saberots,?yflles,??taeht?u&ces?sni?t&inruf?necca??za???s!.&a!bap.us,?b!ibnal?rofmok??c!a??d!b?n&arb?ubroflanummok???e?f!noc,?g!ro??h!f??i!trap??k!shf??l?m!oc,t??n!mygskurbrutan??o?p!ohsdaerpsym,p??r!owebdluocti,?s!serp?yspoi,?t!opsgolb,?u?vhf?w?x!uvmok??y?z??a&c?el?hc??i&er?urc??nesemoh?roh?uoh??t&a&d?ts&e!laer??lla???is!.&areduolc,e&lej,nilnigol,r&etnim,ocevon,?winmo,?k&rowtenoilof,wnf,?laicosnepo,n&eyb,oyc,?spvtsaf,thrs,xulel,ysrab,?bew??ov?ra?t&ioled?ol??utitsni??u&lb?qi&nilc?tuob???v!.&21e?b&ew?og??ce&r?t??erots?gro?lim?m&oc?rif??o&c?fni??stra?t&en?ni??ude?vog??as?e3gerb2h--nx?i&l!.xlh,?rd?ssergorp??ol??w&kct--nx?r??xul?y!.&gro?lim?moc?ten?ude?vog????f&0f3rkcg--nx?198xim--nx?280xim--nx?7vqn--nx?a!.&gro?moc?ten?ude?vog???b!.vog?wa9bgm--nx??c!.topsgolb,a1p--nx!.&a14--nx,b8lea1j--nx,c&avc0aaa08--nx,ma09--nx,?f&a1a09--nx,ea1j--nx,?gva1c--nx,nha1h--nx,pda1j--nx,zila1h--nx,??ns??ea1j--nx?fo?g?iam?l&a1d--nx?og??n!.&bew?cer?erots?m&oc?rif??ofni?re&hto?p??stra?ten???orp?p!.&gro?moc?ude???rus?t!w??vd7ckaabgm--nx?w??g&2&4wq55--nx?8zrf6--nx??3&44sd3--nx?91w6j--nx!.&a5wqmg--nx?d&22svcw--nx?5xq55--nx??gla0do--nx?m1qtxm--nx?vta0cu--nx????455ses--nx?5mzt5--nx?69vqhr--nx?7&8a4d5a4prebgm--nx?rb2c--nx??a!.&gro?mo&c?n??oc?ten??vd??b!.&0?1?2?3?4?5?6?7?8?9?a?b?c?d?e?f?g?h?i?j?k?l?m?n?o?p?q?r?s?t!opsgolb,?u?v?w?x?y!srab,?z???c!b?za9a0cbgm--nx??e!.&eman?gro?ics?lim?moc!.topsgolb,?nue?ten?ude?vog??a??g!.&ayc,gro?lenap:.nomead,,oc?saak,ten???i&a?v??k!.&g&olb,ro??ku,lim?moc?oi,pj,su,ten?ude?v&og?t,???m!.&drp?gro?lim?m&o&c?n??t??oc?ude?vog??pk??n!.&dtl,eman?gro?hcs?i!bom??l&im?oc,?m&oc!.topsgolb,?rif,?neg,ogn,ten?ude?vog??aw?i!b!mulp??car?d&art?dew??h&sif?tolc??k&iv?oo&b?c???ls?n&aelc?iart??p!pohs??re&enigne?tac??t&ad?ekram!.&htiw,morf,??hgil?lusnoc?neg?ov?soh!.tfarcnepo,??vi&g?l???o!s??u&rehcisrev?smas?tarebsnegömrev???o&d?lb?og!.&duolc,etalsnart,???r&2n084qlj--nx?ebmoolb?o!.&77ndc.c:sr,,a&remacytirucesym,t&neimip,sivretla,?z,?bew-llams,d&ab-yrev-si,e&sufnocsim,vas-si,?nuof-si,oog-yrev-si,uolc&arfniarodef,mw,??e&a,cin-yrev-si,grof&loot,peh,?l&as-4-ffuts,poeparodef,?m&-morf,agevres,ohruoyslles,?n&ozdop,uma.elet,?r&ehwongniogyldlob,iwym,uces-77ndc.nigiro.lss,?t&adidnac-a-si,is&-ybboh,golb,???fehc-a-si,golbymdaer,k&eeg-a&-si,si,?h,nut,?l&i&amwt,ve-yrev-si,?lawerif&-ym,ym,?sd-ni,?m&acssecca,edom-elbac,?n&af&blm,cfu,egelloc,lfn,s&citlec-a-si,niurb-a-si,tap-a-si,?xos-a-si,?ibptth,o&itatsksid,rviop,?pv-ni,?o&jodsnd,tp&az,oh,??p&i&-on,fles,?o&hbew,tksedeerf,?tf&e&moh,vres,?ym,??r&e&gatop,ppepteews,su-xunil-a-si,?gmtrec,vdmac,?s&a&ila&nyd,snd,?nymsd,?b&alfmw,bevres,?dylimaf,eirfotatophcuoc,j,koob-daer,ltbup,nd&-won,deerf,emoh,golb,kcud,mood,nyd:.&emoh,og,?,ps,rvd,tog,uolc,?s&a-skcik,ndd,?tnemhcattaomb,u,?t&ce&jorparodef.&duolc,gts.so.ppa,so.ppa,?riderbew,?e&ews-yrev-si,nretni&ehtfodne,fodne,??hgink-a-si,igude,oi-allizom,s&ixetn&od,seod,?o&h-emag,l-si,?rifyam,??ue:.&a&-q,c,?cm,dc,e&b,d,e,i,m,s,?g&b,n,?hc,i&f,s,?k&d,m,s,u,?l&a,i,n,p,?n&c,i,?o&n,r,ssa,?pj,r&f,g,h,k,t,?s&e,i:rap,,u,?t&a,en,i,l,m,ni,p,?u&a,de,h,l,r,?vl,y&c,m,?z&c,n,??,vresnyd,x&inuemoh,unilemoh,?y&limafxut,srab,???ub&mah?oj???s!.&delacsne,gro?moc?rep?t&en?opsgolb,?ude?vog??gb639j43us5--nx??t?u!.&c&a?s??en?gro?moc?o&c?g??ro?topsgolb,??v!.ta,a1c--nx??wsa08--nx??h&0ee5a3ld2ckx--nx?4wc3o--nx!.&a&2xyc3o--nx?3j0hc3m--nx?ve4b3c0oc21--nx??id1kzuc3h--nx?l8bxi8ifc21--nx?rb0ef1c21--nx???8&8yvfe--nx?a7maabgm--nx??b!.&gro?moc?ten?ude?vog??mg??c!.&7erauqs,amil4,duolc-drayknil,gniksnd,p&h21,ohsdaerpsym,?sndtog,topsgolb,wolf.e&a.1pla,nigneppa,?xi2,ytic-amil,?aoc?et?ir!euz??r&aes!errecnac??uhc??sob?taw!s???d0sbgp--nx?f&2lpbgm--nx?k??g!.&gro?lim?moc?ude?vog???m!a1j--nx??ocir?p!.&gro?i?lim?moc?ogn?ten?ude?vog???s!.&g&nabhsah,ro??l&im?xv,?m&oc?roftalp.&cb,su,tne,ue,??pib,ten?vog?won,yolpedew,?a&c?nom??i&d?f?ri???t!.&ca?enilno,im?ni?o&c?g??pohs,ro?ten??iaf!.oby,?laeh!.arh,?orxer?ra&ba?e???vo!.lopdren,?zb??i&3tupk--nx?7a0oi--nx?a!.&ffo?gro?moc?ten?uwu,?1p--nx?bud?dnuyh?tnihc??b!.&gro?moc?oc?ro?ude??ahduba?o!m!.&duolcsd,ysrab,???s??c!.&ayb-tropora--nx?ca?d&e?m??esserp?gro?ln,moc?nif,o&c?g?ssa??ro?t&en?ni?roporéa??ude?vuog??cug?t??d&dk?ua??e&bhf--nx?piat??f!.&aw5-nenikkh--nx,dnala?iki,mroftalpduolc.if,nenikkäh,pohsdaerpsym,retnecatad.&omed,saap,?topsgolb,yd,?onas??g!.&d&om?tl??gro?moc?ude?vog???h&c&atih?ra??s&abodoy?ibustim???juohs?k!.&gro?moc?ofni?ten?ude?vog?zib??b4gc--nx?iw?nisleh?s?uzus??l!.&aac,topsgolb,?drahcir?iamsi??maim?n!.&b&ew?og??ca?gro?lim?mo&c?n??ni?o&c?fni??pp?t&en?ni??ude?zib??airpic?i&hgrobmal?m??re??om?rarref?s!.&egaptig,ppatig,topsgolb,?ed??t&aresam?i&c?nifni??rahb?tagub??ut?v!.&21k?gro?moc?oc?ten???wik?xa&rp?t??yf??j&6pqgza9iabgm--nx?8da1tabbgl--nx?b!.&ossa?topsgolb,uaerrab?vuog???d?f!.&ca?eman?gro?lim?moc?o&fni?rp??ten?vog?zib???nj?s?t!.&bew?c&a?in??eman?gro?lim?moc?o&c?g??t&en?ni?set??ude?vog?zib???yqx94qit--nx??k&8uxp3--nx?924tcf--nx?arfel?c&a&bdeef?lb??ebdnul?ilc?reme?ud??d!.&erots,ger,mrif,oc,pohsdaerpsym,topsgolb,zib,?t??e&es?samet??h!.&a&4ya0cu--nx?5wqmg--nx??b3qa0do--nx?cni,d&2&2svcw--nx?3rvcl--nx??5xq55--nx?tl,?g&a0nt--nx?la0do--nx?ro??i&050qmg--nx?7a0oi--nx?xa0km--nx??m&1qtxm--nx?oc??npqic--nx?saaces,t&en?opsgolb,?ude?v&di?og?ta0cu--nx??xva0fz--nx?人&个?個?箇??司公?府政?絡&網?网??織&組?组??织&組?组??络&網?网??育&敎?教???n??i&tsob?vdnas??l!.&bew?c&a?os??dtl?gro?hcs?letoh?moc?nssa?ogn?prg?t&en?ni??ude?vog??at?cd?is??m!.&eman?fni?gro?moc?t&en?opsgolb,?ude?vog???n&ab!cfdh?etats?mmoc?t&en?fos??u??i!l!.&noyc,pepym,??p???oob?p!.&b&ew?og??gro?kog?m&af?oc??nog?ofni?pog?sog?ten?ude?vog?zib???row!.&morf,ot,?ten!.&htumiza,nolt,o&c,vra,??doof???s!.topsgolb,?t?u!.&c&a?lp??d&om?tl??e&cilop?m??gro!.&gul:g,,sgul,??nnoc,o&c!.&bunsorter.tsuc,e&lddiwg,n&ilnoysrab,ozgniebllew,??krametyb.&hd,mv,?omida,p&i-on,ohsdaerpsym,?t&fihsreyal.j,opsgolb,?vres-hn,ysrab,??rpoc,?psoh,shn?t&en?nmyp,?vog!.eci&ffoemoh,vres,??ysrab,???l&04sr4w--nx?a!.&gro?lim?moc?t&en?opsgolb,?ude?vog??bolg?c?ed?g!el??i&c&nanif!.oc,lpl??os??romem?tnedurp??n&if?oitanretni??t&i&gid!.sppaduolc:.nodnol,,?p&ac?soh???ned?ot??utum!nretsewhtron???c!.&bog?lim?oc?topsgolb,vog???dil?e&datic?n&ahc?nahc!gnikooc?levart?rehtaew???t!ria?tam??vart??f&8f&pbgo--nx?tbgm--nx??a?n??g!.&gro?moc?oc?ten?ude?xx,zib,??h&d?op??i!.&21k?ca?fdi?gro?inum?oc!.&egapvar,topsgolb,??ten?vog??a&f?m&e?g?toh???m?r?xil??l&a&b&esab?t&eksab!.&sua,zn,??oof???c?mt??e&d?hs??ihmailliw?j??m!.&esserp?gro?moc?ten?ude?v&og?uog????n!.&n&iemodleeutriv,o&med,rtsic,??oc,pohsdaerpsym,retsulc-gnitsoh,topsgolb,wsma,yalphk,?o??o&a?btuf?l!.gmo,?o&c!.&ed,rotnemele,??hcs??rit?u??p!.&a&cin&diws?gel??d&g,ortso?urawon??i&dem?mraw?nydg,?k&elo&guld?rtso??slopolam?tsu?ytsyrut??l&ip?o&kzs?w&-awolats?oksnok????n&erapohs,img?zcel,?rog&-ai&bab?nelej??j?z??syn?tsaim?w&a&l&eib?i?o??zsraw??o&namil?tainop,??z&eiwolaib?mol???c&e&iw&alselob?o&nsos?rtso???le&im?zrogz???orw,p??d&em,ia?ragrats?uolc&inu,sds,??e&c&i&lrog?w&ilg,o&hc&arats?orp??klop?tak????yzreibok??i&csjuoniws?ksromop?saldop??l&ahdop?opo??napokaz,tatselaer?z&romop?swozam???g&alble?ezrbo&lok?nrat??ro??hcyzrblaw?i&csomohcurein?grat?klawus??k&e&rut?walcolw??in&byr?diws,sark,?le?o&nas?tsylaib??rob&el?lam??s&als?jazel?nadg,puls?rowezrp???l&colw?e&r?vart??i&am?m???m&o&c?dar?n?tyb??s&g?iruot??t!a???n&a&gaz?nzop,?i&bul?cezczs?lbul,molow?nok?zd&eb?obeiws???uleiw?y&tzslo?z&rtek?seic????o&c,fni?k&celo?zdolk??lkan?n&leim?pek?t&uk?yzczs??z&copo?eing?rowaj???rga?tua?w&ejarg?ogarm???p&e&eb,lks??klwwortso?ohs!daerpsym,??romophcaz?sos?t&aiwop?en?opos,ra,sezc??ude?v&irp?og!.&a&p?s!w???bni&p?w??ci?dtiw?essp?fiw?g&imu?u??hiiw?m&igu?rio?u!o???nds?o&ks?p!pu??s?wtsorats??p&a?sp!mk?pk?wk??u&m?p??wk?z??r&ksw?s??s&i?oiw?u?zu??talusnok?w&gzr?i&p?rg?w??m?opu?u!imzw???zouw????w&a&l&corw?sizdow??w??o&golg?k&ark,ul?zsurp??r&az?gew??t&rabul,sugua??z&coks?sezr????xes?y&buzsak?d&azczseib?ikseb??hcyt?n&jes?lod-zreimizak??pal?r&ogt?uzam??walup?zutrak??z&am-awar?c&aprak?iwol?zsogdyb??dalezc?ib?s&i&lak?p??uklo????l??r&as?f?s??s!.&gro?moc?ten?ude?vog???t!.vog??ubnatsi?x3b689qq6--nx?yc5rb54--nx??m&00tsb3--nx?1qtxm--nx?981rvj--nx?a!.&aayn,enummoc?gro?moc?o&c?idar,ken,?t&en?opsgolb,??c!bew??dretsma?e&rts?t!.&citsalej,esruocsid,???fma?xq--nx??b!.&gro?moc?ten?ude?vog??i??c!.&moc?oc?ten?vog???d!.&gro?moc?ten?ude?vog???f!.&gro?moc?oidar,ten?ude??i??g!vu96d8syzf--nx??h?i!.&ca?gro?moc?o&c!.&clp?dtl???r,?t&en?t??vt??k?rbg4--nx??k!.&drp?e&rianiretev?sserp??gro?lim?m&o&c?n??t??nicedem?ossa?pooc?s&eriaton?neicamrahp?sa??ude?v&og?uog????l&if?ohkcots??o!.&dem?gro?m&oc?uesum??o&c?rp??ten?ude?vog??b?c!.&2aq,3pmevres,5sndd,a&c&-morf,ir&bafno,fa,??g&-morf,oy-sehcaet,?i-morf,m&-morf,all&-a-si,amai,??p&-morf,c-a-si,?r&emacytirucesym,odih,?s,tadtsudgniht,v-morf,w-morf,z,?b&dnevarym,ew&-sndnyd,draiw.segap,ottad,?g,ildts.ipa,?c&amytirucesemoh,d-morf,esyrcs,itsalej.omed,n&-morf,vym,?p&kroweht,ytirucesemoh,?q,rievres,s-morf,?d&aerotffuts,e&calpb,ifitrec-&si,ton-si,?llortnocduolc,rewopenignepw:.sj,,tsohecapsppa,?i&-morf,rgevissam.saap,?m-morf,n&-morf,abeht-htiw-si,?s-morf,uolc&-noitatsyalp,hr,iafaw.&d&ej,yr,?nol,?meaeboda,panqym:-&ahpla,ved,?,smetsystuo,tekcilc,ved&j,pw,??vreser,wetomer,?e&butuoyhtiw,ciffo-sndnyd,d:-morf,o&celgoog,n&il.srebmem,neve.&1-&su,ue,?2-&su,ue,?3-&su,ue,?4-&su,ue,????,erf&-sndnyd,sndd,?filflahevres,gnahcxeevres,i&hcet-a-si,p-sekil,?k&auqevres,irtsretnuocevres,?l&bitpa-no,googhtiw,?m&agevres,ina-otni-si,oh-&sndnyd,ta-sndnyd,??n&-morf,ilno&-evreser,ysrab,?og-si,?r&alfduolcyrt,ehwynanohtyp:.ue,,ihcec,?srun-a-si,t&i&nuarepo,s&-ybboh,aloy,tipohs,xiw,??omer-sndnyd,upmocsma,ysgolb,?v&als-elcibuc-a-si,i&lsndd,tavresnoc-a-si,??z&amkcar,eelg,iig,??fehc-a-si,g&ni&gats-&raeghtua,swennwot,?ksndd,robsikrow,?o&fgp,lb&-sndnyd,pawodni,sihtsetirw,???h&n-morf,o-morf,?i&fiwehtno,h-morf,kiw-sndnyd,m-morf,pdetsoh,r-morf,w-morf,z&ihcppa,nilppa,??jn-morf,k&a&-morf,erfocsic,?cils-si,eeg&-a&-si,si,?sndd,?h,latsnaebcitsale:.&1-&htuos-pa,lartnec-&ac,ue,?ts&ae&-&as,su,?ht&ron-pa,uos-pa,??ew-&su,ue,vog-su,???2-ts&ae&-su,ht&ron-pa,uos-pa,??ew-&su,ue,??3-ts&aehtron-pa,ew-ue,??,o-morf,r&adhtiwtliub,ow&-&sndnyd,ta-sndnyd,?ten-orehkcats,??u,?l&a&-morf,colottad,rebil-a-si,?f-morf,i&-morf,am&-sndnyd,detsohpw,??l&ecelffaw,uf-ytnuob:.a&hpla,teb,?,?ppmswa,ru-&elpmis,taen,?ssukoreh,xegap,?m&n-morf,pml.ppa,rofererac-htlaeh,sacrasevres,uirarret-yltsaf,?n&a&cilbuper-a-si,f&-sllub-a-si,racsan-a-si,?i&cisum-a-si,ratrebil-a-si,??c,dc&hsums,umpw,xirtrepmi,?eerg-a-si,i-morf,m-morf,o&ehtnaptog,isam-al-a-tse,r&italik,tap-el-tse,?s&iam-al-a-tse,replausunu,??pj,t-morf,?o&bordym,c,hce-namtsop,jodsnd,m&-morf,ed-baltlow,?n:iloxip,,ttadym,?p&2pevres,aelutym,i&-sndnyd,fles,ogol,ruoy&esol,hctid,?ym&eerf,teg,??ohsdaerpsym,pa&-rettalp,anis:piv,,esaberif,k1,lortnocduolc,oifilauq,r&aegyks,oetem:.ue,,?tnorfegap,ukoreh,?t&fevres,thevres,??r&a:-morf,tskcor-a-si,,b,e&d&iv&erp-yb-detsoh.saap,orpnwo,?ner&.ppa,no,??e&bevres,nigne-na-si,?ggolb&-a-si,ndi,?h&caet-a-si,pargotohp-a-si,?krow-drah-a-si,n&gised-a-si,ia&rtlanosrep-a-si,tretne-na-si,??p&acsdnal-a-si,eekkoob-a-si,?retac-a-si,subq,tn&ecysrab,iap-a-si,uh-a-si,?vres&-&ki.&cpj-rev-duolcj,duolcj,?s&ndnyd,pvtsaf,??inim,nmad,sak,?y&alp-a-si,wal-a-si,?zilibomdeepsegap,?g,ituob,k,mgrp.nex,o&-morf,sivdalaicnanif-a-si,t&areleccalabolgswa,c&a-na-si,od-a-si,?susaym,??p-morf,u&as-o-nyd,e&tsoh.&duolc-gar,hc-duolc-gar,?ugolb-nom-tse,?omuhevres,??s&a&apod,ila&nyd,snd,?nymsd,vnacremarf,?bbevres,ci&p&-sndnyd,evres,?tcatytiruces,?dylimaf,e&cived-anelab,itilitu3,lahw-eht-sevas,mag-otni-si,t&isro,yskciuq,??i&ht2tniop,pa&elgoog,tneltneg,??jfac,k&-morf,aerf-ten,colb&egrof,pohsym,??m&-morf,cxolb,?n&d&-pmet,dyard,golb,mood,tog,?kselp,nyd,ootrac-otni-si,?o&-xobeerf,xobeerf,?ppa&raeghtua,tneg,?r&ac-otni-si,e&ntrap-paelut,tsohmaerd,??s&e&l-rof-slles,rtca-na-si,?ibodym,?tsaeb-cihtym.&a&llicno,zno,?ilay,lacarac,re&gitnef,motsuc,?sv,toleco,x:n&ihps,yl,?,?u,wanozama.&1-&htuos-pa&-3s,.&3s,etisbew-3s,kcatslaud.3s,??la&nretxe-3s,rtnec-&ac&-3s,.&3s,etisbew-3s,kcatslaud.3s,??ue&-3s,.&3s,etisbew-3s,kcatslaud.3s,????ts&ae&-&as&-&3s,etisbew-3s,?.kcatslaud.3s,?su:-etisbew-3s,.kcatslaud.3s,,?ht&ron-pa&-&3s,etisbew-3s,?.kcatslaud.3s,?uos-pa&-&3s,etisbew-3s,?.kcatslaud.3s,???ew-&su-&3s,etisbew-3s,?ue&-&3s,etisbew-3s,?.kcatslaud.3s,?vog-su-&3s,spif-3s,????2-ts&ae&-su&-3s,.&3s,etisbew-3s,kcatslaud.3s,??ht&ron-pa&-3s,.&3s,etisbew-3s,kcatslaud.3s,??uos-pa&-&3s,etisbew-3s,?.kcatslaud.3s,???ew-&su-&3s,etisbew-3s,?ue&-3s,.&3s,etisbew-3s,kcatslaud.3s,????3&-tsew-ue&-3s,.&3s,etisbew-3s,kcatslaud.3s,??s,???t&arcomed-a-si,c&-morf,etedatad.&ecnatsni,omed,??eel&-si,rebu-si,?hgilfhtiwletoh,m-morf,n&atnuocca-na-si,e&duts-a-si,r-ot-ecaps,tnocresu&buhtig,e&capsppa,lbavresbo.citats,?pl,???ops&edoc,golb,ppa,?s&i&hcrana-&a-si,na-si,?laicos-a-si,pareht-a-si,tra-na-si,xetn&od,seod,??oh&piym,sfn,??u&-morf,nyekcoh-asi,?v-morf,?u&-rof-slles,4,e,h,oynahtretramssi,r:ug-a-si,,?v&n-morf,w-morf,?w&o&lpwons-yrt,zok,?ww100,?x&bsbf.sppa,em,i&nuemoh,rtrepmi,?obaniateb,t-morf,unilemoh,?y&a&bnx:.&2u,lacol-2u,?,l&erottad,pezam,?wetag-llawerif,?dnacsekil,fipohsym,k&-morf,niksisnd,?rotceridevitcaym,u:goo,,w-morf,x&alagkeeg,orphsilbup,???inu??m!.&dna,rof,??or?tsla??p!.nwo,?raf!.jrots,etats??s?t!.&gro?lim?mo&c?n??oc?ten?ude?vog???u&esum!.&a&92chg-seacinumocelet-e-soierroc--nx?atnav?c&i&aduj?rfatsae??rollam??d&anac?enomaledasac?irolf??e&raaihpledalihp?srednu??g&hannavas?oonattahc??hamo?i&auhsu?bmuloc!hsitirb??dem?groeg?hpledalihp?l&artsua?etalif??n&igriv?rofilac??ssur?tsonod??ksa&la?rben??l&lojal?q-snl--nx?uossim!trof???m&a&bala?nap??enic?o&m?r???n&a&cirema?idni??edasap?ilorachtuos?olecrab??r&abrabatnas?ezzivs??su?t&nalta?osennim??zalp??c&dnotgnihsaw?ebeuq?i&depolcycne?ficap?hpargonaeco?lbup?sum?t&carporihc?lec?naltadim??vu??yn??d&a&dhgab?etsmraf?m?orliar??i&rdam?ulegnedleeb??leif?n&a!l&gne?nif?ragyduj?t&ocs?rop??yram???u&brofsdgybmeh?osdnaegami???r&augria?ofxo???e&c&a&l&ap?phtrib??ps??n&a&lubma?tsiser??e&fedlatsaoc?gilletni?ics!foyrotsih????pein?rof??d&nukneklov?revasem??e&rt?tsurt??f&atnas?ildliw??g&a&lliv?tireh!lanoitan???dirbmac?rog??i&cnum?nollaw??koorbrehs?l&ab?bib?cycrotom?i&ssim?txet??oks?tsac??m&affollah?it!iram??utsoc??n&golos?ilno?recul??r&a&uqs?waled!foetats???i&hs&acnal?kroy?pmahwen??otsih??omitlab?ut&an?cetihcra?inruf?luc!irga?su???vuol??s&abatad?iacnarf?sius?uoh!lum???t&a&locohc?rak?ts!e!yrtnuoc!su?????imesoy?tevroc??u&qihpargonaeco?velleb??vit&caretni?omotua???f&iuj?ohgrub??g&n&i&dliub?ginerevmuesum?kiv?lahw?nim?peekemit?vil??ulmmastsnuk??orf?r&ebnrats?u&b&ierf?le?m&ah?uan??ram?s&mailliw!lainoloc??naitsirhc?retepts??zlas??ob&irf?mexul?????h&atu?c&raeser?sirotsih?uot??g&ea1h--nx?rubsttip??si&tirb?wej??t&laeh?ro&n?wtrof??uo&mnom?y????i&d6glbhbd9--nx?iawah?k&nisleh?s??lad!rodavlas??sissa?tannicnic??k&c&nivleeg?olc!-dna-hctaw?dnahctaw???fj?inebis?l&is?ofron??na&rfenna?t??oorbnarc?r&am&ned?reiets??oy!wen????l&a&ci&dem?golo&eahcra?meg?oz??natob?rotsih??ertnom?iromem?noita&cude?n??oc?rutluc?trop?utriv?van??e&nurb?s&ab?surb??utriv??i&artnogero?sarb??l&a&besab?hsnoegrus??e&hs?rdnevle??i&b?m!dniw????o&bup?ohcs?tsirb???m&a&dretsma?ets?h&netlehc?rud???ct?elas!urej??l&if?ohkcots?u??raf?silanruoj?u&esumyrotsihlarutan?ira&tenalp?uqa??terobra???n&a&c!irema!evitan???gihcim?i&dni?tpyge??mfoelsi?wehctaksas??e&d&alokohcs?ews?rag!cinatob?lacinatob?s&nerdlihc?u????gahnepoc?hcneum?laftsew?ppahcsnetewruutan?r&dlihc?ednaalv?hu!dnutamieh???sseig??gised!dn&atra?utsnuk???h&ab!nesie??ojts??i&lreb?tsua??l&eok?ocnil??n&ob?urbneohcs??o&dnol?gero?i&s&iv&dnadnuos?elet??nam??t&a&c&inummoc?ude!tra???dnuof?erc?i&cossa?va??kinummokelet?nissassa?r&belectsevrah?oproc?tsulli??silivic?t&nalp?s??vres&erp?noclatnemnorivne??zilivic??c&elloc?if-ecneics??ibihxe???ri?s&dnah?imaj?reffej?sral??t&erbepac?nilc?sob???r&e&b?dom?tsew?uab?zul??obredap??vahnebeok?wot??o&2a6v-seacinumoc--nx?ablib?c&edtra?ixemwen?sicnarfnas??elap?g&a&cihc?to??eidnas??i&cadnuf?diserp?ratno??llecitnom?mitiram?nirot?r&htna?ienajedoir???pohskrow?qari?r&aw!dloc?livic??dd?e&b&ma?yc??irrac?llimsiwel?naksiznarf?papswen?t&aeht?exe?nec!ecneics?larutluc?muesum?tra??s&ehc&nam?or??neum??upmoc???ia!nepo??obal?u&asonid?obal?takirak???s&a&l&g?l&ad?eh???xet??di&k?pardnarg??e&cneics!larutan??dnal?hcsi&deuj?rotsih!nizidem?rutan??selhcs??itinamuh?l&aw?egnasol?l&e&rutansecneics?xurb??iasrev???r&e&em?ugif??tsac??suohcirotsih?u&en?q&adac?itna!nacirema?su????õçacinumoc!elet-e-soierroc???gnirpsmlap?htab?i&lopanaidni?rap?uoltnias?xa??l&essurb?lod??mraeriflanoitan?n&a&blats?l??erdlihc?oi&snam?tacinummoc!elet-dna-stsop???äl??re&dnalf?lttes?mraf?nim?tnececneics??s&alg?erp??t&farc!dnastra??nalp?olip?ra!e&nif?vitaroced!su???su?xuaeb???u&b!muloc??cric???t&agilltrop?cejorp?dats?e&esum?kramnaidni??iorted?ne&m&elttes?norivne?piuqemraf??vnoc??oped?r&a!drib?enif?gttuts?hsiwej?kcor?n&acirema?ootrac??tamsa?yraropmetnoc??op&aes?snart?wen??ufknarf??s&a&cdaorb?octsae??ewhtuos?ilayol?nuk?r&ohnemled?uhlyram??urt???u&a&bgreb?etalpodaroloc??rmyc??w&ocsom?rn??x&esse?ineohp?nam?tas??y&a&bekaepasehc?w&etag?liar???camrahp?doc?e&hsub?l&ekreb?l&av!eniwydnarb??ort???n&dys?om??rrus?s&nreug?rejwen???golo&e&ahcra?g??motne?nh&cet?te??oz?po&rhtna?t??roh??hpargotohp?l&etalihp?imaf??m&edaca?onortsa??n&atob?yn??ps?r&a&ropmetnoc?tilim??e&diorbme?llag!tra??vocsid??lewej?nosameerf?otsih!dnaecneics?ecneics?gnivil!su??la&col?rutan??retupmoc?su??tsudnidnaecneics??spelipe?t&eicos!lacirotsih??i&nummoc?srevinu??nuoc???z&arg?iewhcs?nil?ojadab?urcatnas??моки?םילשורי???rof??z!.&ca?gro?hcs?lim?moc?o&c?fni??ten?ude?vog?zib????n&315rmi--nx?a&brud?cilbuper?f?grompj?hkaga?idraug?m?ol?ssin?u&hix?qna??varac?yalo??b!.&gro?moc?oc,ten?ude?vog??c??c!.&ah?bh?c&a?s??d&5xq55--nx?g?s?uolctnatsni,?eh?g&la0do--nx?ro??h&a?q?s??i&7a0oi--nx?h??j&b?f?t?x?z??kh?l&h?im?j??m&n?oc!.swanozama.&1-htron-nc.3s,be.1-&htron-nc,tsewhtron-nc,????n&h?l?s?y??om?qc?s&g?j??ten?ude?vog?wt?x&g?j?n?s??z&g?x??司公?絡網?络网??b??d&g!.ypnc,?ka??e&drag?erg?fuak?gawsklov?hctik?i&libommi?w??m!.r&iaper,of,??po?r!ednaalv??sier?ves??g!.&ca?gro?moc?ten?ude?vog??is&ed!.ssb,?irev???h!.&bog?cc,gro?lim?moc?ten?ude???i!.&bew,c&a?in??dni?esabapus,gro?lim?mrif?neg?oc?s&er?nduolc,?t&en?opsgolb,?ude?vog?ysrab,?elknivlac?griv?ks?lreb?p?v?w!.taht,?x??k!.&gro?ten?ude?vog???l&eok?ocnil??m!.&cyn,gro?ude?vog???o&dnol!.&fo,ni,??i&hsaf!.fo,?n&o?utiderc??siv!orue??t&a&cude!.oc,?dnuof?tsyalp??c&etorp?u&a?rtsnoc?????kin?las?mrom?nac?p&q?uoc??s&iam?nhojcs?pe?scire??t&ron?sob??zama??p!.&gro?oc?ten?ude?vog??k??r&e&c?yab??op!.eidni,??s!.&gro?moc?osrep?t&opsgolb,ra??ude?v&inu?uog????t!.&d&ni?uolcegnaro,?esnefed?gro?ltni?m&oc!nim??siruot??n&erut?if??o&fni?srep??sn&e?r??t&an?en!irga?ude??rnr??unr?vog??m??u&f?r!.&bdnevar,lper,sh,tnempoleved,??stad?xamay?y??v!.&ca?eman?gro?htlaeh?moc?o&fni?rp??t&en?ni?opsgolb,?ude?vog?zib???wo&rc?t!epac????o&76i4orfy--nx?a!.&bp?de?go?oc?ti?vg??boat??b!.&a&ci&sum?tilop??i&c&arcomed?neic??golo&ce?ncet??m&edaca?onoce??rt&ap?sudni??vilob??n&egidni?icidem??serpme?tsiver?vitarepooc??b&ew?og??dulas?e&rbmon?tr&a?op&ed?snart????g&olb?ro??ikiw?l&a&noi&canirulp?seforp??rutan??im??moc?o&fni?lbeup?rga?tneimivom??saiciton?t&askt?en?ni??ude?vt??h?iew?olg??c!.&bew?cer?dr&c,rac,?esabapus,gro?ipym,l&im?per:.di,,?m&o&c!.topsgolb,?n??rif?udon,?ofni?s&egap&dael,l,?tra??t&4n,en?ni??ude?vog??a?e?in?mara?s&edarb?ic???d!.&b&ew?og??dls?gro?lim?moc?t&en?ra??ude?vog??agoba?if?zd7acbgm--nx??e&c?d&iv?or??morafla??f!ni!.&e&g&delwonk-fo-l&errab,lerrab,?ellocevoli,?ht-skorg,rom-rof-ereh,tadpusn:d,,?llatiswonk,macrvd,ofni-v,p&i&-on,fles,?ohbew,?ruo-rof,s&iht-skorg,nd&-cimanyd,nyd,uolc,??tsrifyam,ysrab,zmurof,???g&el?n!am?ib???hwsohw?i!.&35nyd,8302,a&minifed,tad-b,?b&altig,uhtig,?c&inone:.remotsuc,,zh,?d&in,u&olc&iaznab.ppa,ropav,?rd,??e&c&apsinu.1rf-duolc,ivedniser,?donppad.sndnyd,egipa,lej,nilnigol,sufxob,t&i&beulb,snoehtnap,?newtu,ybeeb.saap,??gni&gatsniser.secived,tsohytsoh,?k&coregrof.di,orgn,ramytefasresworb,?m&oc?udon,?n&mtsp:.kcom,,yded,?ot&oq,pyrctfihs,?p&opilol,pa&-arusah,e&nalpkcab,tybeeb.1dkes,???r&e&tsneum-hf,vres&cisab,lautriv,??ial.sppa,?s&codehtdaer,gnihtbew,nemeis-om,pparevelc,tacdnas,?t&e&kcubtib,notorp,?i&belet,detfihs,kecaps,?raedon.egats,s&ohg,udgniht.&cersid.&dvreser,tsuc,?dorp.tsuc,gnitset.&dvreser,tsuc,?ved.&dvreser,tsuc,????vgib.0ku,whs,x&bslprbv.g,cq,rotide,?y&olpedew,srab,??b?d&ar?u&a?ts???j?r?syhp??j!.&eman?gro?hcs?lim?moc?ten?ude?vog???ll&ag?o??m!.&gro?moc?ten?ude?vog??g?il?mi?orp??n!.&a&0&b-ekhgnark--nx?c-iehsrgev--nx?g-lksedlig--nx?k-negnanvk--nx??1&p-nedragy--nx?q-&asierrs--nx?grebsnt--nx?lado-rs--nx?n&egnidl--nx?orf-rs--nx??regnayh--nx?ssofenh--nx??r-datsgrt--nx?s-ladrjts--nx?v-y&senner--nx?vrejks--nx???3g-datsobegh--nx?4&5-&dnaleprj--nx?goksnerl--nx?tednalyh--nx??6-neladnjm--nx?s-&antouvachb--nx?impouvtalm--nx??y-&agrjnevvad--nx?ikhvlaraeb--nx???7k-antouvacchb--nx?8&k-rekie-erv--nx?l-ladrua-rs--nx?m-darehsdrk--nx??a!.sg??bct-eimeuvejsemn--nx?d&do?iisevvad?lov?narts?uas??f&1-&l--nx?s--nx??2-h--nx??g&10aq0-ineve--nx?av?ev?lot?r&ajn&evvad?u??ájn&evvad?u????h?iz-lf--nx?j&ddadab?sel??k&el?hoj&sarak?šárák??iiv&ag&na&el?g??ŋ&ael?ág???ran???l&f?lahrevo?o&ms?s??sennev?t-&ilm--nx?tom--nx??u&-edr--nx?s??øms??muar?n&0-tsr--nx?2-dob--nx?5-&asir--nx?tals--nx??a&r!-i-om?f?t??t??douvsatvid?kiv?m&os?øs??n&od?ød??ra?sen?t&aouvatheig?ouv&a&c&ch&ab?áb??h&ab?áb???n??i&ag?ág??sa&mo?ttvid??án???z-rey--nx?ær&f?t???o&p-&ladr--nx?sens--nx??q-nagv--nx?r-asns--nx?s-kjks--nx?v-murb--nx?w-&anr&f--nx?t--nx??ublk--nx???ppol?q&0-t&baol--nx?soum--nx?veib--nx??x-&ipphl--nx?r&embh--nx?imph--nx???y-tinks--nx??r&f-atsr--nx?g-&an&ms--nx?nd--nx??e&drf--nx?ngs--nx??murs--nx?netl--nx?olmb--nx?sorr--nx??h-&a&lms--nx?yrf--nx??emjt--nx??i&-&lboh--nx?rsir--nx?y&d&ar--nx?na--nx??ksa--nx?lem--nx?r&ul--nx?yd--nx????stu??j-&drav--nx?rolf--nx?sdav--nx??kua?l-&drojf--nx?lares--nx??m-tlohr--nx?n-esans--nx?olf?p-sdnil--nx?s-ladrl--nx?tih?v-rvsyt--nx??s&a&ns?ons??i&ar?er&dron?r&os?øs???ár??la&g?h??mor!t??sir?uf?åns??t&koulo&nka?ŋká??la?p-raddjb--nx?r-agrjnu--nx?s&aefr&ammah?ámmáh??orf?r&o?ø???u-vreiks--nx??u&h-dnusel--nx?i-&drojfk--nx?vleslm--nx??j-ekerom--nx?k-rekrem--nx?u-&dnalr--nx?goksr--nx?sensk--nx??v-nekyr--nx?w-&k&abrd--nx?ivjg--nx??oryso--nx??y-y&dnas--nx?mrak--nx?n&art--nx?nif--nx??reva--nx??z-smort--nx??v!.sg?ledatskork?reiks??wh-antouvn--nx?x&9-dlofts--nx.aoq-relv--nx?d-nmaherk--nx?f-dnalnks--nx?h-neltloh--nx?i-drgeppo--nx?j-gve&gnal--nx?lreb--nx??m-negnilr--nx?n-drojfvk--nx??y&7-ujdaehal--nx?8-antouvig--nx?b-&dlofrs--nx?goksmr--nx?kivryr--nx?retslj--nx??e-nejsom--nx?f-y&krajb--nx?re&dni--nx?tso--nx??stivk--nx??g-regark--nx?orf?ørf??z9-drojfstb--nx??b&25-akiivagael--nx?53ay7-olousech--nx?a&iy-gv--nx?le-tl&b--nx?s--nx??n0-ydr--nx??c&0-dnal-erdns--nx?z-netot-erts--nx??g&g-regnarav-rs--nx?o-nejssendnas--nx??ju-erdils-ertsy--nx?nj-dnalh-goksrua--nx?q&q-ladsmor-go-erm--nx.&ari-yreh--nx?ednas??s-neslahsladrjts--nx???ca&4s-atsaefrmmh--nx?8m-dnusynnrb--nx?il-tl--nx?le-slg--nx?n5-rdib--nx?op-drgl--nx?uw-ynnrb--nx??d&a&qx-tggrv--nx?reh!nnivk?sd&ork?ørk??uas??ts&e&bi?kkar?llyh?nnan??g&ort?ørt??k&alf?irderf??levev?mirg?obeg&ah?æh??r&ah?ejg????barm-jdddb--nx?ie!rah?s&etivk?ladman???lof&r&os?øs??ts&ev.ednas?o.relav?ø.relåv???n&a&l&-erd&n&os?øs??ron??adroh.so?dron.&a&g5-b--nx?ri-yreh--nx??ob?y&oreh?øreh??øb??e&m!lejh??pr&oj?øj??vi??gyb?n&aks?åks??o&h-goksrua?rf??r&o?ua?ø??tros?øh-goksrua??rts!e&devt?lab?mloh???s&ellil?naitsirk?rof???u&l!os??s!d&im?lejt??e&guah?l&a?å???kkoh?lavk?naitsirk?r&af?eg&e?ie???tef?y&onnorb?ønnørb?????r&a&blavs!.sg??g&eppo?la???o&j&f&a!dniv?k?vk??die?e&dnas?kkelf??llins?r&iel?ots??s&lab?t&ab?åb??yt??å!k??ævk??les??ts??åg&eppo?lå???ureksub.sen??e&ayb-yrettn--nx?d&ar?lom?r&of?øf??år??g&gyr?nats??i&meuv&ejsem&aan?åån??sekaal??rjea??j&d&ef?oks??les??k&er&aom?åom??hgna&ark?årk??iregnir?kot!s??s&ig?uaf???l&bmab?kyb?l&av?ehtats??oh??m&it?ojt?øjt??n&arg?g&os?øs??meh?reil?te?ummok?yrb??r&dils-erts&ev?y&o?ø???ua?vod??sa&ans?åns??t&robraa?spaav??urg??f&62ats-ugsrop--nx?a&10-ujvrekkhr--nx?7k-tajjrv-attm--nx??o!.sg?h??s!.sg??v!.sg???g&5aly-yr&n--nx?v--nx??a&llor?ve&gnal?lreb???n&av!snellu??org??oks&die?m&or?ør??ner&ol?øl??r&o?ø???r&eb!adnar?edyps?s&die?elf?gnok?n&ot?øt????obspras??uahatsla?åve&gnal?lreb???h&0alu-ysm--nx?7&4ay8-akiivagg--nx?5ay7-atkoulok--nx??a!.sg???i&e&hsr&agev?ågev??rf??k&h&avlaraeb?ávlaraeb??s??lm&a?å??mpouvtal&am?ám??pph&al?ál??rrounaddleid?ssaneve?ššáneve??j&0aoq-ysgv--nx?94bawh-akhojrk--nx??k&a&b&ord?ørd??jks?lleis??iv!aklejps?l&am?evs?u??mag?nel?ojg?r&a&l?n??epok?iel?y&or?ør???s&ah?kel?om??øjg??kabene?ojsarak?ram&deh.&aoq-relv--nx?rel&av?åv??so??e&let.&ag5-b--nx?ob?øb??ra???åjks??l&a!d&anrus?d&numurb?ron??e&gnard?nte?s&meh?sin??ttin??g&is?nyl??kro?l&em?l&ejfttah?of??u&ag-ertdim?s???n&am?era?gos?i&b?nroh?r??kos?nus?oj??o-&dron?r&os?øs???ppo?r&a!l?nram??e&gne?l?v??is?o&jts?ts??u&a-&dron?r&os?øs???h??å?æl?øjts??s&e&jg?nivk?ryf??kav?mor-go-er&om.&ednas?yoreh??øm.&ednas?yøreh???uag??t&las?rajh?suan??v&l&a?e-rots??u-go-eron??yt??ksedlig?res&a?å???bib&eklof?seklyf??es!dah??h!.sg??i&m?syrt??l&ejf?ov&etsua?gnit?ksa?sdie???n!.sg??o!.sg?boh?g?h??r!.sg??å!ksedlig??øboh??m&a&rah?vk??f!.sg??h!.sg??i&e&h&dnort?rtsua?ssej??rkrejb??ksa??ol?t!.sg??u&dom?esum?r&ab?drejg?evle?os?uh?æb?øs??ttals???n&a&g&av?okssman?åv??jlis?or?r&g?rev???e&d&do&sen?ton??lah?r&agy&o?ø??ojfsam???g&iets?n&a&l&as?lab??n&avk?ævk??t&arg?ddosen??v&al?essov???i&d&ol?øl??l&ar?ær???yl??reb??iks?k&srot?y&or?ør???l&a&d&gnos?n&er?ojm?øjm??om??tloh??ug?åtloh??mmard?ojs&om?sendnas??ppolg?s&lahsladr&ojts?øjts??o??t&o&l?t-erts&ev?o?ø???roh?øl??vly&kkys?nav??yam-naj!.sg??øjs&om?sendnas???g&orf?ujb??i&dnaort?vnarg??kob?ladendua?maherk&a?å??n&it?urgsrop??orf-&dron?r&os?øs???r&aieb?evats??sfev?uaks?yrts??o&6axi-ygvtsev--nx?c,d&ob?rav??ievs?kssouf?l&m&ob?øb??ous&adna?ech&ac?áč???so!.sg???msdeks?niekotuak?r&egark?olf?y&oso?øso???s&dav?mort???p&ed?ohsdaerpsym,p&akdron?elk???r&a&d&dj&ab?áb??iab??jtif?luag?mah?vsyt??e&gn&a&k&iel?ro??merb?n&at?mas??rav-r&os?øs??srop?talf?v&ats?el??y&oh?øh???ivsgnok??il?jkniets?k&a&nvej?rem?s&gnir?nellu???ie-er&den?v&o?ø???ram?sa?årem??la&jf?vh??m&b&ah?áh??mahellil??nnul?ts&l&oj?øj??ul??y&o?ø???imp&ah?áh??m!.sg??osir?t!.sg??ádiáb?ævsyt?øsir??s&adnil?en&dnas?e&dga?k&ri&b?k??som??ve??me&h?jg??nroh-go-ejve?s&a?ednil?k&o?ø??of?yt?å??tsev??gv?hf?igaval?o&r&or?ør??sman??so&fen&oh?øh??m?v??uh&lem?sreka.sen??å!dnil???t&a&baol?g&aov?grav??jjr&av-attam?áv-attám??l&a&b?s??ás??soum?ts?v&eib?our???e&dnaly&oh?øh??f?s&nyt?rokomsdeks?sen??vtpiks??in&aks?áks??loh&ar?år??n!.sg??o&m&a?å??psgolb,?s!.sg?efremmah?or?ør??terdi?á&baol?ggráv?lá&b?s??soum?veib???u&b!.sg?alk?e&dna?gnir?nner??les?ælk??dra&b?eb??g&nasrop?vi?ŋásrop??j&daehal&a?á??jedub?v&arekkhar?árekkhár???ksiouf?n&diaegadvoug?taed???v&irp?lesl&am?åm???y&b&essen?nart?sebel?tsev??o&d&ar?na!s??or??gavtsev?k&rajb?sa??lem?mrak?n&art?n&if?orb???r&a&mah?n?v??e&dni?t&so?ton??va??ul?yd??s&am?enner?gav?lrak?tivk??vrejks??ø&d&ar?na!s??ør??gåvtsev?k&rajb?sa??lem?mrak?n&art?n&if?ørb???r&e&dni?t&so?tøn??va??ul?yd?æ&n?v???s&enner?gåv?tivk?åm??vrejks???á&slág?tlá?vreiks??å&gåv?h?jddådåb?lf??ø&d&ob?rav??r&egark?olf??s&dav?mort????aki?i&sac?tal??u??o&b?f?g?hay?o?ttat??r!.&cer?erots?gro?m&o&c?n??rif?t??o&c,fni??pohs,stra?t&n?opsgolb,?www??e&a!.&a&ac?cgd?idem??bulc!orea??ci&ffartria?taborea??e&cn&a&l&lievrus-ria?ubma??netniam?rusni??erefnoc??gnahcxe?mordorea?ni&gne?lria?zagam??rawtfos??gni&d&art?ilg!arap?gnah???l&dnahdnuorg?ledom??noollab?retac?sael?t&lusnoc?uhcarap??vidyks??hcraeser?l&anruoj?euf?icnuoc?ortnoc!-ciffart-ria???n&gised?oi&nu?t&a&cifitrec?ercer?gi&tsevni-tnedicca?van??i&cossa!-regnessap??valivic??redef??cudorp?neverp-tnedicca????ograc?p&ihsnoipmahc?uorg!gnikrow???r&e&dart?enigne?korb?niart?trahc??o&htua?tacude???s&citsigol?e&civres?r??krow?serp!xe??tnega??t&farcr&ia?otor??hgil&f?orcim??liubemoh?n&atlusnoc?e&duts?m&esuma?n&iatretne?revog??piuqe????olip?ropria?si&lanruoj?tneics???w&erc?ohs??y&cnegreme?dobper?tefas????rref?z??p!.&a&aa?ca?pc??dem?ecartsnd.icb,gne?r&ab?uj??snduolc,t&acova?cca?hcer??wal?ysrab,???s!.&em?gro?hcs,moc?ten?ude?vog???t!.&116,ayo,gro?lim?moc?nayn,sulpnpv,t&cennockciuq.tcerid,en??ude?v&dr,og???o&hp?m?v?yk??tol?ua??v&iv?lov??xas?ykot??p&a&ehc?g?m?s??eej?g!.&gro?ibom?moc?ossa?ppa,ten?ude???i&r!.nalc,?v?z??j!.&a&3&5xq6f--nx?xqi0ostn--nx??5wtb6--nx?85uwuu--nx?9xtlk--nx?bihc!.&a&bihciakoy?don?ma&him?ye&ragan?tat???r&a&bom?gan?hihci??u&agedos?kas?ustak???s&os?ufomihs??t&amihcay?iran??w&a&g&im&anah?o??omak??kihci?zustum??ihsak??y&agamak?imonihci???e&akas?nagot??i&azni?esohc?h&asa?s&abanuf?ohc???ka&to?zok??musi?orihs?r&akihabihsokoy?o&dim?tak??ukujuk??usihs??nano&hc?yk??o&d&iakustoy?ustam??hsonhot?k&a&rihs?t??iba??nihsaran?sobimanim?tas&arihsimao?imot??uhc?yihcay??u&kujno?s&ayaru?t&imik?tuf???zarasik????g&as!.&a&gas?m&a&tamah?yik??ihsak??rat?t&a&gatik?hatik??ira!ihsin????e&kaira?nimimak??i&akneg?g&aruyk?o??h&c&amo?uo??siorihs??kaznak?modukuf?ra&gonihsoy?mi???nezih?u&k&at?ohuok??s&ot?tarak?????ihs!.&a&kok?m&a&hagan?yirom??ihsakat??rabiam?wagoton??e&miharot?nokih??houyr?i&azaihsin?esok?kustakat?moihsagih??na&mihcahimo?nok??o&hsia?mag?t&asoyot?ok?tir???us&ay?t&asuk?o??????k&aso!.&a&d&awihsik?eki??k&a&noyot?s&akaayahihc?oihsagih???oadat?uziak??m&ayas!akaso??odak??r&a&bustam?wihsak??ediijuf??t&akarih?i&k?us???wag&ayen?odoyihsagih???e&son?tawanojihs??honim?i&akas?h&cugirom?s&ayabadnot?i&a&kat?t??n??oyimusihsagih???k&a&rabi?sim??ustakat??muzi?r&ijat?otamuk???nan&ak?n&ah?es???o&ay?n&a&ganihcawak?simuzi?tak??eba?ikibah?oyot??t&anim?iad?omamihs??uhc??ust&oimuzi?tes????ou&kuf!.&a&d&amay?eos??g&no?ok?usak??hiku?k&awayim?uzii??ma&kan?y&asih?im???rawak?t&a&gon?ka&h?num?t???umo??wa&g&a&kan?nay?t??ias??ko!rih???y&ihsa?usak???e&m&ay?uruk??taruk?us??i&a&nohs?raihcat??goruk?h&cukuf?s&a&gih?hukuy??in???k&a&gako?muzim??iust?o?ustani??m&anim?otihsoynihs?u??r&ogo?ugasas??usu??ne&siek?zu&b?kihc???o&gukihc?h&ak?ot?ukihc??j&ono?ukihc??kayim?nihsukihc?to?uhc??u&fiazad?gnihs?stoyot????zihs!.&a&bmetog?d&amihs?eijuf?ihsoy?omihs??kouzihs?mihsim?ra&biah?honikam??tawi?wa&g&ekak?ukik??kijuf??yimonijuf??i&a&ra?sok??hcamirom?juf?kaz&eamo?ustam??ma&nnak?ta??nukonuzi?orukuf??nohenawak?o&nosus?ti??u&stamamah?z&a&mun?wak??i!ay?i&hs&agih?in??manim??mihs????????m&a&tias!.&a&d&ihsoy?ot?usah??k&a&dih?sa??o&arihs?s???m&a&tias?y&as?o&rom?tah??ustamihsagih???i&hsagurust?jawak??uri??ni?wa&g&e&ko?man??ikot?o??k&ara?i&hsoy?mak???ru?zorokot??y&a&g&amuk?ihsok?otah??kuf??imo??ziin??e&bakusak?ogawak?sogo?ttas?zokoy??i&baraw?h&cugawak?s&oyim?ubustam???iroy?k&ato?ihs?u&k?stawi???m&akoyr?i&hsoy?juf??uziimak???naznar?o&dakas?ihsay?jnoh?n&a&go?nim??imijuf?nah?oy??r&ihsayim?otagan??t&asim!ak??igus?omatik??zak??u&bihcihc!ihsagih??sonuok?ynah????y&ak&aw!.&a&d&ira?notimak??kadih?ma&h&arihs?im??y&a&kaw?tik??oduk???ru&ustakihcan?y??sauy?wa&g&a&dira?zok??orih??konik??yok?zok??e&banat?dawi??i&garustak?jiat?mani??naniak?o&bog?nimik?t&asim?omihs&ah?uk????ugnihs???o!.&a&jos?koasak?m&ay&ako?ust??ihsayah??r&abi?ukawaihsin??wi&aka?nam???e&gakay?kaw??i&gan?h&cu&kasa?otes??sahakat??k&asim?ihsaruk??miin??n&anemuk?ezib??o&hsotas?jnihs?n&amat?imagak??ohs?uhcibik?????ot!.&a&damay?got?koakat?may&etat?ot??nahoj?riat?waki&inakan?reman???eb&ayo?oruk??i&h&asa?ciimak?sahanuf??kuzanu?m&an&i?ot??ih???nezuyn?otnan?u&hcuf?stimukuf?z&imi?ou???????ihs&o&gak!.&a&m&ayuok?ihsogak??si?yonak??e&banawak?n&at&akan?imanim??uka??tomoonihsin??i&adnesamustas?k&azarukam?oih??m&ama?uzi??usuy??nesi?o&knik?os?tomustam??uzimurat???rih!.&a&ka&n?s??m&ayukuf?i&hsorihihsagih?j&ate?imakikaso????r&a&bohs?h&ekat?im???es??tiak?wiad??e&kato?ruk??i&h&ci&akustah?mono?nihs??s&inares?oyim???manimasa?uk??negokikesnij?o&gnoh?namuk??uhcuf????uk&ot!.&a&bihci?mi&hsu&kot?stamok??m??wagakan??egihsustam?i&gum?h&coganas?soyim??kijaw?m&anim?uzia??ukihsihs??nan&a?iak??o&nati?turan????uf!.&a&batuf?m&a&to?y&enak?irok???ihs&im?ukuf??os?uko??r&aboihsatik?uganat??ta&katik?mawak?rih??w&a&g&akus?emas?uy??k&a&mat?rihs?sa??ihsi??nah??ohs???e&gnabuzia?iman?ta&d?tii???i&adnab?enet?hs&agih?iimagak??k&a&wi?zimuzi??ubay??minuk?r&ook?ustamay???nihsiat?o&g&etomo?ihsin?nan?omihs??no!duruf?rih??rihsawani?ta&may?simuzia???u&rahim?stamakawuzia?zia&ihsin?nay???????nug!.&a&bawak?doyihc?k&anna?oi&hsoy?juf?mot???m&ayakat?ustagaihsagih??n&ihsatak?nak??r&ahonagan?nak?o?u&kati?mamat???t&amun?inomihs?o??w&akubihs?iem?ohs???i&hsa&beam?yabetat??kas&akat?esi??m&akanim?uzio??ogamust?rodim??o&jonakan?n&eu?oyikust??tnihs??u&komnan?stasuk?yrik?????ran!.&a&bihsak?d&akatotamay?u!o???guraki?m&ay&atik&imak?omihs??irokotamay??oki??ra&hihsak?n??wa&geson?knet???e&kayim?ozamay?sog?ustim??i&a&rukas?wak??garustak?h&ciomihs?sinawak??jo?ka&mnak?toruk??makawak?nos?r&net?otakat?ugeh???o&d&na?oyo??gnas?jnihs?nihsoy!ihsagih??tomarawat?yrok????t&ag&amay!.&a&dihsio?k&atarihs?ourust??may&a&kan?rum??enak?onimak??rukho?ta&ga&may?nuf??hakat?kas??wa&g&ekas?orumam??ki&hsin?m??z&anabo?enoy?ot???zuy??e&agas?bonamay?dii?nihsagih?o??i&a&gan?nohs??h&asa?sinawak??nugo??o&dnet?jnihs?ynan??ukohak???iin!.&a&ga?k&ium?oagan??munou!imanim??t&a&bihs?giin??ioy??w&a&gioti?kikes?zuy??irak??yijo??e&kustim?mabust??i&aniat?hcamakot?kaz&awihsak?omuzi??m&a&gat?karum??o???n&anust?esog??o&das?ihcot?jnas?k&ihay?oym??mak?naga?ries??u&ories?steoj?????i&ka!.&a&go?k&asok?oimak??t&ago!rihcah??ika!atik???w&aki?oyk???e&mojog?natim?suranihsagih?t&ado?okoy???i&hsoyirom?magatak?naokimak??nesiad?o&hakin?jnoh!iruy??nuzak?rihson?tasi&juf?m??yjnoh??u&kobmes?oppah????o!.&a&dakatognub?m&asah?ihsemih??su?t&ekat?i&h?o????e&onokok?ustimak??i&jih?k&asinuk?ias?usu??mukust??onoognub?u&fuy?juk?ppeb?suk??????wa&ga&k!.&a&mihsoan?rihotok?waga&kihsagih?ya???emaguram?i&j&nonak?ustnez??kunas?monihcu??o&hsonot?nnam?yotim??u&st&amakat?odat??zatu????nak!.&a&dustam?kus&okoy?tarih??maz?nibe?r&a&gihsaimanim?h&esi?imagas??wa&do?guy???u&im?kamak???tikamay?wa&k&ia?oyik?umas??sijuf??yimonin??e&nokah?saya??i&akan?esiak?gusta?hsuz?kasagihc?o?ukust??o&nadah?sio?tamay?????kihsi!.&a&danihcu?gak?kihs?mijaw?t&abust?ikawak??wazanak??i&gurust?hcionon?mon?ukah??nasukah?o&anan?ton!akan???u&kohak?stamok?z&imana?us?????niko!.&a&han?m&arat?ijemuk?uru??n&e&dak?zi??no??ra&hihsin?rih??wa&kihsi?niko??yehi?zonig??e&osaru?seay??i&hsagih?jomihs?k&a&gihsi?not??ihsakot??m&a&ginuk?kihsug?maz??igo?otekat??nuga!noy???n&a&moti?timoy?wonig??i&jikan?k???o&gan?jnan?tiad&atik?imanim???u&botom?kusug&akan!atik??imot??rab&anoy?eah???????c&204ugv--nx?462a0t7--nx?678z7vq5d--nx?94ptr5--nx?a??d&17sql1--nx?3thr--nx?5&20xbz--nx?40sj5--nx??7&87tlk--nx?ptlk--nx??861ti4--nx?a?e??e&16thr--nx?5&1a4m2--nx?9ny7k--nx??im!.&a&bot?k&asustam?uzus??m&a&him?y&emak?im???ihs??nawuk?wi&em?k???e&bani?ogawak?si!imanim???i&arataw?gusim?h&asa?ciakkoy??k&a&mat?sosik?t??iat??raban??o&dat?hik?n&amuk?ihseru?o&du?mok????ust???mihe!.&a&m&a&h&ataway?iin??yustam??ij&awu?imak???taki!man???ebot?i&anoh?kasam?rabami??n&ania?egokamuk?oot??o&jias?kihcu?nustam?uhcukokihs?yi!es???u&kohik?zo????n!.&nriheg,teniesa.resu,?amihs!.&a&d&amah?ho?usam??kustay?m&a?ihsoni&hsin?ko???wakih??e&namihs?ustam??i&g&aka?usay??konikak?mikih??nannu?o&mu&kay?zi!ihsagih?uko???nawust?tasim??u&stog?yamat?????tawi!.&a&bahay?d&amay?on??koirom?t&a&honat?katnezukir??imus??w&as&ijuf?uzim??ihs???e&hon&i&hci?n??uk??tawi??i&a&duf?murak?wak??h&custo?si&amak?ukuzihs???j&oboj?uk??k&a&m&anah?uzuk??sagenak??esonihci??m&akatik?uzia&rih?wi????o&kayim?no&rih?t??tanufo??uhso????g&3zsiu--nx?71qstn--nx?l??h&03pv23--nx?13ynr--nx?22tsiu--nx?61qqle--nx??i&54urkm--nx?g&ayim!.&a&dukak?m&a&goihs?kihs??ihsustam!ihsagih??unawi??r&awago?iho??ta&bihs?rum??w&a&gano?kuruf??iat??y&imot?ukaw???e&mot?nimes??i&hsiorihs?ka&monihsi?s&awak?o???mak?r&ataw?o&muram?tan????o&az?jagat?t&asim?omamay???u&fir?k&irnasimanim?uhsakihcihs?????ihcot!.&a&g&a&h?kihsa??ust??kom?m&ay&o?usarak??unak??r&a&boihsusan?watho??iho?ukas??t&akihsin?iay??wa&konimak?zenakat??y&imonustu?oihs???e&iiju?kustomihs?nufawi??i&akihci?g&etom?ihcot?on???o&k&ihsam?kin??nas?sioruk?tab??u&bim?san?????h&c&ia!.&a&dnah?m&a!h&akat?im??yuni??ihs&ibot?ust???r&a&hat?tihs??ik?u&ihsagih?kawi???t&ihc?o&k?yot???wa&koyot?zani??yi&monihci?rak???e&inak?k&aoyot?usa??manokot?noyot??i&a&gusak?kot?sia??eot?h&asairawo?cugo?s&ahoyot?oyim???k&a&mok?zako??ihssi??motay?rogamag??n&an&ikeh?ok??ihssin??o&got?ihsin?jna?rihsnihs?suf?tes??u&bo?raho?s&oyik?takihs??yrihc?zah????ok!.&a&dusay?kadih?mayotom?r&ah&im?usuy??umakan??sot!ihsin??wa&g&atik?odoyin??k&as?o????i&esieg?hco!k??jamu?k&a!sus??usto??ma&gak?k??rahan??o&mukus?n&i?ust!ihsagih???torum?yot!o???u&koknan?zimihsasot????ugamay!.&a&m&ayukot?ihso??toyot??e&bu?subat??i&gah?kesonomihs?nukawi?rakih??nanuhs?otagan?u&ba?foh?otim?stamaduk?uy?????sanamay!.&a&dihsoyijuf?mayabat?r&ahoneu?ustakihsin??w&a&k&ayah?ijuf??suran??ohs???egusok?i&ak?h&cimakan?s&anamay?od???k&asarin?u&feuf?sto????o&k&akanamay?ihcugawakijuf??nihso?t&asimawakihci?ukoh??uhc??spla-imanim?u&b&nan?onim??fok?hsok?rust?????ka&rabi!.&a&bukust?gok?kan!ihcatih??m&a&sak?timo?wi??ihsak?ustomihs??ni?r&a&hihcu?way??u&agimusak?ihcust???t&ag&amay?eman??oihcatih??w&ag&arukas?o??os??yi&moihcatih?rom???e&bomot?dirot?not?tadomihs??i&a&k&as?ot??rao??esukihc?gahakat?h&asa?catih??k&a&rabi?saguyr??ihsani?uy??ma?rukustamat??o&dnab?giad?him?kati?rihsijuf?soj?t&asorihs?im??yihcay??u&fius?kihsu?simak????sagan!.&a&m&abo?ihsust??natawak?r&abamihs?u&mo?ustam???wijihc?yahasi??i&akias?hies?k&asagan?i??masah??neznu?o&besas?darih?t&eso?og!imaknihs????ust&igot?onihcuk?uf????zayim!.&a&biihs?guyh?k&oebon?ustorom??mihsuk?r&emihsin?uatik??ta&katik?mim??wag&atik?odak??ya??e&banakat?sakog??i&hsayabok?kaza&kat?yim??m&animawak?ot&inuk?nihs????nanihcin?o&j&ik?onokayim??n&ibe?ust??tias??urahakat????ro&moa!.&a&dawot?turust?wasim??e&hon&ihc&ah?ihs??nas?og?ukor??sario??i&anarih?ganayati?hsioruk?jehon?kasorih?makihsah?nawo?r&amodakan?omoa???o&gnihs?kkat??u&ragust?stum????ttot!.&a&r&ahawak?uotok??sa&kaw?sim???egok?irottot?nanihcin?o&ganoy?nih?tanimiakas??u&bnan?z&ay?ihc??????ukuf!.&a&deki?gurust?ma&bo?h&akat?im??yustak??sakaw??eabas?i&akas?ho?jiehie?ukuf??nezihce!imanim??ono????k&26rtl8--nx?4&3qtr5--nx?ytjd--nx??522tin--nx?797ti4--nx??l33ussp--nx?m&11tqqq--nx?41s3c--nx??n&30sql1--nx?65zqhe--nx?n7p7qrt0--nx??o&131rot--nx?7qrbk--nx?c?diakkoh!.&a&deki?gakihset?hcebihs?k&adih?u&fib?narihs???m&ayiruk?hot?ihs&orihatik?ukuf??oras?usta??r&ib&a!ka??o?uruf??ozo?u&gakihsagih?oyot???sakim?ta&gikust?mun??w&a&ga&k&an?uf??nus!imak???k&aru?i&h&asa?sagih??kat?mak??omihs?um??zimawi??ine?oyk??yot??e&a&mustam?nan??b&a&kihs?yak??o&noroh?to???ian?k&ihsam?ufoto??nakami?ppoko!ihsin??sotihc?tad!okah??uonikat??i&a&bib?mokamot?n&a&k&kaw?oroh??wi??eomak?ihsatu?okik?usta&moruk?sakan????eib?h&c&ioy?u&bmek?irihs???s&ase?ekka?oknar?uesom???jufirihsir?k&amamihs?i&at?n???m&atik?otoyot??oa&kihs?rihs??r&a&hs?kihsi?mot??ihs&aba?ir??otarib???n&a&hctuk?rorum?se?tokahs??uber??o&kayot?m&ire?ukay??naruf!ima&k?nim???orih?r&ih&ibo?suk??o&bah?h&i&b?hsimak??sa??pnan?yan??umen??t&asoyik?eko?ukoh???u&bassa?kotnihs?m&assaw?uo??pp&akiin?en&ioto?nuk??ip??rato?s&akat?t&eb&e?i&a?hs!a??robon??m&e?o&m?takan???no&h?tamah??o&mik?s?t??u&kir?ppihc?st???onihsnihs?ufuras??uaru??yru!koh??zimihs!ok?????g!oyh!.&a&bmat?dnas?gusak?k&at?o&oyot?y??uzarakat??m&ayasas?irah??wa&g&ani?okak??k&i&hci?mak??oy???yi&hsa?monihsin???i&asak?hs&aka?i&at?nawak???j&awa!imanim??emih??k&a&goa?s&agama?ukuf??wihsin??i&hsog?m???mati?oia?rogimak??n&annas?esnonihs??o&gasa!kat??ka?n&ikat?o?ustat??rihsay?sihs?tomus?yas??u&bay?gnihs?????nagan!.&a&bukah?d&a&w?yim??e&ki?u??ii??k&a&s&ay?uki??zus??ihsoo?ousay??m&ay&akat?ii??i&hsukufosik?jii??ukihc??n&i!hsetat??uzii??r&ah?ugot??saim?t&agamay?oyim??w&a&g&a&kan?n??o??kustam?ziurak??onim!imanim??u&koo?s!omihs????ya&ko?rih???e&akas?nagamok?subo??i&gakat?h&asa?c&a!mo!nanihs???uonamay??sukagot??k&a&kas?mimanim?to??ia&atik?imanim??oa?uzihcom??m&akawak?ijuf?o!t???r&ato?ijoihs?omakat???n&ana?esnoawazon??o&hukas?n&a&gan?kan??i&hc?muza??ustat??romok?si&gan?k??tomustam??u&k&as?ohukihc??stamega????to&mamuk!.&a&gamay?rahihsin?sukama!imak??tamanim??enufim?i&hcukik?k&ihsam?u??nugo!imanim??romakat??o&ara?rihsustay?sa?t&amay?om&amuk?us??u!koyg???yohc??u&sagan?zo????yk!.&a&bmatoyk?k&ies?oemak?uzaw??mayi&h&cukuf?sagih??muk??nihsamay?rawatiju?t&away?ik???e&ba&nat!oyk??ya??di?ni??i&ju?kazamayo?manim??natnan?o&gnatoyk?kum?mak?rihsamayimanim?y&gakan?ka&koagan?s??oj???u&ruziam?z&ayim?ik??????wtc1--nx?ykot!.&a&d&i&hcam?mus??oyihc??k&atim?ihsustak??m&a&t!uko??yarumihsa&gih?sum???i&hs&agoa?ika?o!t??uzuok??ren???r&a&honih?wasago??iadok?umah??ssuf?t&ik?o??wa&g&anihs?ode??k&ara?ihcat???y&agates?ubihs???e&amok?donih?m&o?urukihsagih??soyik??i&enagok?gani?h&ca&da?tinuk??sabati??j&nubukok?oihcah??manigus??o&huzim?jihcah?n&akan?ih!sasum??urika??rugem?t&a&mayihsagih?nim??iat?ok??uhc?yknub??u&fohc?hcuf?kujnihs?????r&2xro6--nx?g?o??s&9nvfe--nx?xvp4--nx??t&netnocresu,opsgolb,?u&4rvp8--nx?fig!.&a&d&eki?ih??kimot?m&ayakat?ihsah??ne?raha&gi&kes?makak??sak??taga&may?tik??wa&g&ibi?ustakan??karihs!ihsagih????e&katim?uawak??i&gohakas?hc&apna?uonaw??k&ago?es?ot??m&anuzim?ijat??nak?urat??nanig?o&dog?jug?makonim?nim?roy?sihcih??u&fig?s&otom?t&amasak?oay???????x5ytlk--nx?yu6d27srjd--nx?z72thr--nx?井福?京東?分大?取鳥?口山?城&宮?茨??媛愛?山&富?岡?歌和??岡&福?静??島&児鹿?広?徳?福??崎&宮?長??川&奈神?石?香??庫兵?形山?手岩?木栃?本熊?根島?梨山?森青?潟新?玉埼?田秋?知&愛?高??縄沖?良奈?葉千?賀&佐?滋??道海北?都京?重三?野長?阜岐?阪大?馬群???k!.&art?gro?moc?per?ude?vog???l&eh?l??m!.uj,ac?j??nd?o&g?h&pih?s!.ysrab,??lnud?oc?t!.&lldtn,snd-won,???pa!.&0mroftalp,arusah,bew:erif,,e&niln&igol,okoob,?tupmocegde,?lecrev,n&aecolatigidno,ur:.a,,?poon,remarf,t&ibelet,xenw,?yfilten,??ra&a?hs??u&ekam?llag?org!.esruocsid,cts?kouk?nayalo???vsr?xece4ibgm--nx??q&a!3a9y--nx??g?i!.&gro?lim?moc?ten?ude?vog???m?se??r&a!.&acisum?bog?gro?lim?moc!.topsgolb,?rut?t&en?ni??ude?vog??4d5a4prebgm--nx?b?c?eydoog?los?t&at?s!uen???ugaj??b!.&21g?a&b&a&coros?iuc??itiruc??cnogoas?dicerapa?gniram?i&naiog?ramatnas??n&erom?irdnol??op?p&acam?irolf?ma&j?s???rief?tsivaob??b!aj?ib?mi?sb??c&ba?e&r?t??js?sp?t!e???d&em?mb?n&f?i??rt??e&dnarganipmac?ficer?ht?llivnioj?rdnaotnas??f&dj?ed?gg?n&e?i???g&e&l!.&a&b,m,p,?bp,c&a,s,?e&c,p,s,?fd,gm,ip,jr,la,ma,nr,o&g,r,t,?p&a,s,?r&p,r,?s&e,m,r,?tm,??s??l&s?z??n&c?e?o??ol!b?f?v??pp?ro??hvp?i&du?kiw?nana?oretin?r&c?eurab??sp?te?xat??l&at&an?rof??el?im?sq??m&a?da?e&gatnoc?leb??f?ic?oc!.&duolclautriv.elacs.sresu,topsgolb,???nce?o&ariebir?c&e?narboir?saso??d&o?ranreboas??e&g?t??i&b?dar?ecam?r??rp?t&a?erpoir???p&er?m!e?t??ooc?pa?se??qra?r&af?ga?o&davlas?j??tn?ut??s&a&ixac?mlap?nipmac??ed?u&anam?j?m???t&am?e&d?n?v??nc?o&f?n??ra?sf??u&caug9?de?ja?rg??v&da?ed?og!.&a&b?m?p??bp?c&a?s??e&c?p?s??fd?gm?ip?jr?la?ma?nr?o&g?r?t??p&a?s??r&p?r??s&e?m?r??tm???rs?t??xiv?z&hb?ls?o&c?f?????c!.&as?ca?de?if?o&c?g??ro???e&bew?ccos?dnik?e&b?n&igne?oip??rac??gni&arg?rheob??h&cor?sok?t&aew?orb???itnorf?k&col?o&p?rb???l&aed?ffeahcs??mal?nes?pinuj?t&a&eht?rebsnegömrev??law?nec?s&acnal?nom?ubkcolb??upmoc??v&o&c&sid?tfiws??rdnal??resbo??wulksretlow?ywal?zifp??f!.&aterg?bew-no,drp?e&c&itsuj-reissiuh?narf-ne-setsitned-sneigrurihc,?lipuog,rianiretev??hny,i&cc?rgabmahc??m&o&c?n??t??n&eicamrahp?icedem??ossa?pohsdaerpsym,s&e&lbatpmoc-strepxe?riaton?tsitned-sneigrurihc?uova??o&-x&bf,obeerf,?x&bf,obeerf,???t&acova?o&or-ne,psgolb,?r&epxe-ertemoeg?op!orea????vuog??avc7ylqbgm--nx?s??g!.&gro?moc?t&en?opsgolb,?ude?vog???h!.&e&erf,man??mo&c?rf??topsgolb,zi??ur??i!.&a&61f4a3abgm--nx?rf4a3abgm--nx??ca?di?gro?hcs?oc?ten?vog?نار&يا?یا???a&h?per??ew?lf??k!.&c&a?s??e&n?p?r??gk?iggnoeyg?kub&gn&oeyg?uhc??noej??l&im?uoes??man&gn&oeyg?uhc??noej??n&as&lu?ub??o&e&hcni?jead??wgnag???o&c?g??ro?s&e?h?m??topsgolb,u&gead?j&ej?gnawg????cilf??l!.&gro?moc?ten?ude?vog???m!.&topsgolb,vog???n!.&gro?moc?ofni?ten?ude?vog?zib???o&htua?odtnorf?t&c&a?od??laer???p!.&alsi?ca?eman?forp?gro?moc?o&fni?rp??t&en?se??ude?vog?zib???s?t!.&21k?bew?cn!.vog??eman?gro?kst?l&e&b?t??im?op??moc!.topsgolb,?neg?ofni?pek?rd?sbb?ten?ude?v&a?og?t??zib??f?m??ubad?vd??s&8sqif--nx?9zqif--nx?a!.vog?birappnb?gev?lliv?mtsirhc?s??b!.&ew,gro?moc?ten?ude?vog??c?oj?s?u??c&i&hparg?p?t&sigolyrrek?ylana???od??d&a?d?l?n&iwriaf?omaid??oogemoh?rac??e!.&bog?gro?mo&c!.topsgolb,?n??pohsdaerpsym,ude??civres!.enilnigol,?d&d2bgm--nx?oc??h&ctaw?guh??i&lppus?rtsudni?treporp!yrrek???jaiv?l&aw?cycrotom?etoh?gnis?pats??m&ag?oh?reh??nut?ohs?picer?r&it?ut&cip!.7331,?nev???s!i&rpretne?urc??ruoc??taicossa?vig??g!nidloh??h5c822qif--nx?i!.&ekacpuc,gro?moc?t&en?ni?opsgolb,?ude?vog??a09--nx?nnet?rap?targ??k&c&or!.&ecapsbew,snddym,ytic-amil,??us??hxda08--nx?row??l!.&c&a?s??ed,gro?o&c?fni??ten?ude?vog?zib??a&ed?tner??e&ssurb?toh!yrrek???lahsram?m?oot??m!.&bal,etisinim,gro?moc?ten?ude?vog??b?etsys!.tniopthgink,?ialc??n&a&f?gorf?ol??egassap?i&a&grab?mod??giro??o&it&acav?cudorp?ulos??puoc???o&dnoc?geuj?leuv?ppaz?t&ohp?ua???p!.&ces?gro?moc?olp?ten?ude?vog??i&hsralohcs?lihp?t??u??r!.&au,ca?gro?ni?oc?topsgolb,ude?vog?xo,yldnerb.pohs,?a&c?p?tiug??c?e&dliub!.etisduolc,?erac?gor?levart?mraf?n&niw?trap??wolf??ot&cartnoc?omatat??pj?uot??s!.&em?gro?hcs?moc?ten?ude?vog?zib??alg?e&n&isub!.oc,?tif??rp!xe!nacirema???xnal??iws??t&a&e&b?ytic??ob??ek&cit?ram??fig?h&cay?gilf??n&atnuocca?e&mt&rapa?sevni??ve!.oc,???rap??u!.&a&c!.&21k?bil?cc???g!.&21k?bil?cc???i!.&21k?bil?cc???l!.&21k?bil?cc???m!.&21k!.&hcorap?rthc?tvp???bil?cc???p!.&21k?bil?cc???si?v!.&21k?bil?cc???w!.&21k?bil?cc????c&d!.&21k?bil?cc???n!.&21k?bil?cc???s!.&21k?bil?cc????d&e&f?lacsne.xhp,?i!.&21k?bil?cc???m!.&21k?bil?cc???n!.&bil?cc???s!.&bil?cc???u&olcrim,rd,??e&d!.&21k?bil,cc???las-4-&dnal,ffuts,?m!.&21k?bil?cc???n!.&21k?bil?cc????h&n!.&21k?bil?cc???o!.&21k?bil?cc????i&h!.&bil?cc???m!.&21k?bil?c&c?et??goc?n&eg?otae??robra-nna?sum?tsd?wanethsaw???nd?r!.&bil?cc???v!.&21k?bil?cc???w!.&21k?bil?cc????jn!.&21k?bil?cc???k&a!.&21k?bil?cc???o!.&21k?bil?cc????l&a!.&21k?bil?cc???f!.&21k?bil?cc???i!.&21k?bil?cc????mn!.&21k?bil?cc???n&afflog,i!.&21k?bil?cc???m!.&21k?bil?cc???sn?t!.&21k?bil?cc????o&c!.&21k?bil?cc???m!.&21k?bil?cc???ttniop,?p&ion,rettalp,?r&a!.&21k?bil?cc???o!.&21k?bil?cc???p!.&21k?bil?cc????s&a!.&21k?bil?cc???dik?k!.&21k?bil?cc???m!.&21k?bil?cc???nd&deerf,uolc,??t&c!.&21k?bil?cc???m!.&21k?bil?cc???u!.&21k?bil?cc???v!.&21k?bil?cc????ug!.&21k?bil?cc???v&n!.&21k?bil?cc???w!.cc???x&ohparg,t!.&21k?bil?cc????y&b-si,k!.&21k?bil?cc???n!.&21k?bil?cc???w!.&21k?bil?cc????za!.&21k?bil?cc????ah!uab??bria?col?e!.ytrap.resu,?ineserf?lp?xe&l?n???vt?w!.&66duolc,gro?moc?s&ndnyd,tepym,?ten?ude?vog??a?e&iver?n!.elbaeciton,??odniw??y&alcrab?cam?ot???t&0srzc--nx?a!.&amil4,ca!.hts??gni&liamerutuf,tsoherutuf,?o&c!.topsgolb,?fni,?p&h21,ohsdaerpsym,?r&euefknuf.neiw,o??v&g?irp,?xi2,ytic-amil,zib,?c?e!s??hc?if?l!asite??mami?rcomed??b!.&gro?moc?ten?ude?vog??b?gl??c&atnoc?e&les?rid!txen????dimhcs?e!.&eman?gro?moc?ofni?ten?ude?vog?zib??b?em?grat?id?k&circ?ram??n!.&0&002cilc,rab,?1rab,2rab,5inu,6vnyd,7&7ndc.r,erauqs,?a&l&-morf,moob,?minifed,remacytirucesym,tadsyawla,z,?b&boi,g,lyltsaf:.pam,,?c&inagro-gnitae,paidemym,?d&ecalpb,irgevissam.saap.&1-&gs,nol,rf,yn,?2-&nol,yn,??nab-eht-ni,uolc&meaeboda,nievas.c&di-etsedron,itsalej,?xednay:.e&garots,tisbew,?,??e&c&narusnihtlaehezitavirp,rofelacs.j,?gdirbtib,ht-no-eciffo,l&acsnoom,ibom-eruza,?m&ecnuob,ohtanyd,tcerider,?n&ilno-evreser,ozdop,?rehurht,s:abapus,,tis-repparcs,zamkcar,?f&aeletis,crs.&cos,resu,?ehc-a-si,?g&ni&reesnes,sirkcilc,tsohnnylf,?olb&evres,tsaf,??k&catsvano,eeg-a&-si,si,?u,?l&acolottad,iamwt,s&d-ni,s-77ndc,??m&ac&asac,ih,?urofniem,?n&a&f&agp,lhn,?i&bed,llerk,??dcduabkcalb,i,pv-ni,?o&c-morf,duppa,jodsnd,rp-ytinummoc,ttadym,?p&i&-&etsef,on,?emoh,fles,nwo,?j,mac-dnab-ta,o&-oidar-mah,h&bew,sdaerpsym,??pa&duolc,egde,?tfe&moh,vres,?usnd,?r&e&tsulcyduolc,vres-xnk,?vdslennahc:.u,,?s&a&ila&nyd,snd,?nymsd,?bbevres,dylimaf,e&gde-ndc,suohsyub,t&isbeweruza,ys,??k&catstsaf,ekokohcs,?n&d&-won,d,golb,npv,?oitcnufduolc,?ppacitatseruza:.&2suts&ae,ew,?aisatsae,eporuetsew,sulartnec,?,s&a-skcik,ecca&-citats,duolc,???t&adies,ce&ffeym,jorprot:.segap,,?e&nretnifodne,smem,?farcenimevres,i-&ekorb,s&eod,lles,teg,??n&essidym,orfduolc,?r0p3l3t,s&ixetnod,oh&-spv:.citsalej.&cir,lta,sjn,?,gnik,???u&h,nyd,r:eakust.citsalej,,?ved-naissalta.dorp.ndc,x&inuemoh,spym,tsale.&1ots-slj,2ots-slj,3ots-slj,?unilemoh,?y&awetag-llawerif,ffijduolc:.&ed-1arf,su-1tsew,?,ltsaf.&dorp.&a,labolg,?lss.&a,b,labolg,?pam,slteerf,?n&-morf,ofipi,?srab,?z&a-morf,tirfym,???p?tcip?v??f&ig?o&l?sorcim???g!.&bog?dni?ed,g&olb,ro??lim?moc?ot,ten?ude???h!.&dem?gro?l&er?op??m&oc?rif??o&fni?rp?s&rep?sa???po&hs?oc??t&en?luda?ra??ude?vuog???i!.&a&2n-loritds--nx?7e-etsoaellav--nx?8&c-aneseclrof--nx?i-lrofanesec--nx??at?b?c!cul??dv?i&blo&-oipmet?oipmet??cserb?drabmol?g&gof?urep??l&gup?i&cis?me&-oigger?oigger???uig&-&aizenev&-iluirf?iluirf??ev&-iluirf?iluirf??v&-iluirf?iluirf???aizenev&-iluirf?iluirf??ev&-iluirf?iluirf??v&-iluirf?iluirf????n&a&brev?cul?pmac?tac??idras?obrac&-saiselgi?saiselgi??resi??otsip?r&b&alac!-oigger?oigger??mu??dna&-&attelrab-inart?inart-attelrab??attelrabinart?inartattelrab?ssela??epmi?ugil??tnelav&-obiv?obiv??vap?z&e&nev?ps&-al?al???irog???l&iuqa!l??leib??m&or?rap??n!acsot?e&dom?is?sec&-&ilrof?ìlrof??ilrof?ìlrof???g&amor&-ailime?ailime??edras?olob??i&ssem?tal??ne!var??o&cna?merc?rev?vas???oneg?p?r!a&csep?rr&ac&-assam?assam??ef??von??etam?tsailgo!-lled?lled???s!ip?sam&-ararrac?ararrac??u&caris?gar???t!a&cilisab?recam??resac?soa!-&d&-&ellav?lav??ellav?lav??ellav??d&-&ellav?lav??ellav?lav??ellav??te&lrab&-&airdna-inart?inart-airdna??airdnainart?inartairdna??ssinatlac???udap?v!o&dap?neg?tnam???zn&airb&-a&lled-e-aznom?znom??a&lledeaznom?znom??eaznom??e&c&aip?iv??soc?top??om???b&-&23,46,61,?3c-lorit-ds-onitnert--nx?be-etsoa&-ellav--nx?dellav--nx??c!f-anesec-lrof--nx?m-lrof-anesec--nx??he-etsoa-d-ellav--nx?m!u??o2-loritds-nezob--nx?sn-loritds&-nasl&ab--nx?ub--nx??nitnert--nx??v!6-lorit-dsnitnert--nx?7-loritds&-nitnert--nx?onitnert--nx???z&r-lorit-ds&-nitnert--nx?onitnert--nx??s-loritds-onitnert--nx???c&f?is?l?m?p?r?v??d&p?u!olcnys,??e&c!cel?inev?nerolf??f?g!ida&-&a&-onitnert?onitnert??otla!-onitnert?onitnert???a&-onitnert?onitnert??otla!-on&azlob?itnert??onitnert????hcram?l?m!or??n&idu?o&n&edrop?isorf??torc???p?r?s&erav?ilom??t!nomeip?s&eirt?oa!-&d-e&ellav?éllav??e&ellav?éllav???de&ellav?éllav??e&ellav?éllav?????v?znerif??g&a?b?f?il?o?p?r?up?vf??hc?i&b?c?dol?f?l!lecrev?opan?rof&-anesec?anesec???m?n&a&part?rt&-attelrab-airdna?attelrabairdna???imir?ret??p?r!a&b?ilgac?ssas???s!idnirb??t&ei&hc?r??sa??v??l&a!c??b?c?o&m?rit&-&d&eus&-&nitnert?onitnert??nitnert?onitnert??us&-&nitnert?onitnert??nitnert?onitnert??üs&-&nitnert?onitnert??nitnert?onitnert???s&-onitnert?onitnert???d&eus!-&n&asl&ab?ub??ezob?itnert??onitnert??nitnert?onitnert??us&-&n&asl&ab?ub??ezob?itnert??onitnert??nitnert?onitnert??üs!-&n&asl&ab?ub??ezob?itnert??onitnert??nitnert?onitnert???s&-onitnert?onitnert?????m&ac?f?i!t.nepo.citsalej.duolc,?ol?r??n&a!lim?sl&ab?ub???b?c?e!en.cj,v?zob??irut?m!p??p?r?t??o&a!v??b!retiv??c!cel??enuc?g!ivor??i&dem&-onadipmac?onadipmac??pmet&-aiblo?aiblo??rdnos?zal??l?m!a&greb?ret??oc?re&f?lap???n!a&dipmac&-oidem?oidem??lim?tsiro?zlob??ecip&-ilocsa?ilocsa??i&bru&-orasep?orasep??lleva?rot?tnert??r&elas?ovil??ulleb??p?r!a&sep&-onibru?onibru??znatac??oun??s!ivert?sabopmac??t!arp?e&nev?ssorg??n&arat?e&girga?rt?veneb????zz&era?urba???p&a?ohsdaerpsym,s?t??qa?r&a!m?s??b!a??c?f?g?k?me?o?p?s?t?v??s&a&b?iselgi&-ainobrac?ainobrac???b?c?elpan?i?m?ot?s?t?v??t&a?b?c?l?m?nomdeip?o!psgolb,?p?v??u&de?l?n?p??v&a?og?p?s?t?v??y&drabmol?ellav&-atsoa?atsoa??licis?nacsut??z&al?b?c?p??ìlrof&-anesec?anesec???derc?er?f?m!r??utni??je3a3abgm--nx?kh?l!.&topsgolb,vog??uda??m!.&gro?moc!.topsgolb,?ten?ude???n&a&morockivdnas?ruatser?tnuocca??e&g?m&eganam!.retuor,?piuqe??r??i!.ue?m?opdlog??opud?uocsid??o&b?cs!.&ude,vog:.ecivres,,??d?g?h?j?oferab?p&edemoh?s???p!.&emon?gro?lbup?moc?t&en?ni?opsgolb,?ude?vog???r&a!m&law?s???epxe?op&er?pus!.ysrab,?s???s!.&adaxiabme?e&motoas?picnirp?rots??gro?lim?moc?o&c?dalusnoc?hon,?ten?ude??a&cmoc?f??e&b?padub?r?uq??i!rolf?tned??o&h!.&duolc&p,rim,?e&lej,tiseerf,?flah,lrupmet,s&pvtsaf,seccaduolc,?tsafym,vedumpw,??p!sua???urt??t!.&eman?gro?ibom?levart?m&oc?uesum??o&c?fni?r&ea?p???pooc?sboj?t&en?ni??ude?vog?zib??ayh?n?o!bba?irram???uognah?xen?y!.gro,?ztej??u&2&5te9--nx?yssp--nx??a!.&a&s?w??civ?d&i?lq??fnoc?gro?moc!.&pohsdaerpsym,stelduolc.lem,topsgolb,??nsa?ofni?sat?t&ca?en?n??ude!.&a&s?w??ci&lohtac?v??dlq?sat?t&ca?n??wsn!.sloohcs????vog!.&a&s?w??civ?dlq?sat???wsn?zo??ti??c!.&fni?gro?moc?ten?ude?vog??i??d&e!.tir.segap-tig,?iab??e!.&dcym,enozgniebllew,noitatsksid,odagod.citsalej,snd&ps,uolc,?ysrab,??g!.&bew?gro?m&aug?oc??ofni?ten?ude?vog???h!.&0002?a&citore?idem?kitore??edszot?gro?ilus?letoh?m&alker?lif?t?urof??naltagni?o&c?ediv?fni?levynok?nisac??pohs?rarga?s&a&kal?zatu??emag?wen??t&lob?opsgolb,rops??virp?xe&s?zs??ytic?zsagoj??os?sut??l!.topsgolb,?m!.&ca?gro?moc?oc?ro?ten?vog???n!.&duolcesirpretne,eni&esrem,m,?tenkcahs,?em!.ysrab,??o&ggnaw?y!c???r!.&3kl,a&i&kymlak,rikhsab,vodrom,?yegyda,?bps,ca,duolcrim,e&niram,rpcm,?g&bc,nitsohurger.citsalej,ro,?ianatsuk,k&ihclan,s&m,rogitayp,??li&amdlc.bh,m,?moc,natsegad,onijym,pp,ri&b,d&cm:.spv,,orue,?midalv,?s&ar,itym,?t&en,ni,opsgolb,set,?u&4an,de,?vo&g,n,?ynzorg,zakvakidalv,?myc?p?ug??s!.&a&d&golov,nagarak,?gulak,i&groeg,kymlak,lerak,nemra,rikhsab,ssakahk,vodrom,zahkba,?lut,rahkub,vut,yegyda,znep,?bps,da&baghsa,rgonilest,?gunel,i&anatsuk,hcos,ovan,ttailgot,?k&alhsygnam,ihclan,s&legnahkra,m,n&a&mrum,yrb,?i&buytka,nbo,??tiort,vorkop,??l&ocarak,ybmaj,?na&gruk,jiabreza,ts&egad,hkazak-&htron,tsae,???ovonavi,r&adonsark,imidalv,?t&enxe,nek&hsat,mihc,??vo&hsalab,n,?ynzorg,z&akvakidalv,emret,??t&amok?i&juf?masih????v!.&em,g&olb,ro??moc?nc,ten?ude?ved,??ykuyr??v&b?c!.topsgolb,?ed!.&enilnigol,gnigats-oned,hcetaidem,lecrev,o&ned,tpyrctfihs,?ppa-rettalp,s&egap,rekrow,?vr&esi,uc,?weiverpbuhtig,ylf,??ih?l!.&di?fnoc?gro?lim?moc?nsa?ten?ude?vog???m!.&eman?gro?lim?m&oc?uesum??o&fni?r&ea?p???pooc?t&en?ni??ude?vog?zib???o&g?m??rt?s!.&bog?der?gro?moc?ude???t!.&bew-eht-no,naht-&esrow,retteb,?sndnyd,?d?gh?i?won??uqhv--nx??w&a!.moc?hs?l??b!.&gro?oc???c!.&gro?moc?ten?ude??cp??e&iver!.oby,?n?s??g?k!.&bme?dni?gro?moc?ten?ude?vog???m!.&ca?gro?m&oc?uesum??oc?pooc?t&en?ni??ude?vog?zib??b??o&csom?h!s??n?w??p!.&344x,de?en?o&c?g??ro?snduolc,ualeb???r!.&ca?gro?lim?oc?pooc?ten?vog??n??t!.&a46oa0fz--nx?b&82wrzc--nx?ulc??emag?gro?l&im?ru,?moc!.reliamym,?t&en?opsgolb,?ude?v&di?og?ta0cu--nx??zibe?業商?織組?路網???z!.&ca?gro?lim?oc?vog????x&a!.&cm,eb,gg,s&e,u,?tac,ue,yx,?t??c!.&hta,ofni,vog???e&d&ef?nay??ma!nab??rof?s??ilften?jt?m!.&bog?gro?moc?t&en?opsgolb,?ude??g?ma2ibgy--nx??o&b!x??f?rex??rbgn--nx?s!.vog??x&am&jt?kt??x???y&4punu--nx?7rr03--nx?a&d!i&loh?rfkcalb??ot??g?lp?p!ila??rot?ssin?wdaorb??b!.&duolcym,fo?hcetaidem,lim?moc!.topsgolb,?vog??ab?gur??c!.&ca?dtl?eman?gro?m&oc!.&ecrofelacs.j,topsgolb,??t??orp?s&egolke?serp??t&en?nemailrap??vog?zib??amrahp?nega??d&dadog?uts??e&kcoh?ltneb?n&dys?om?rotta??snikcm??g!.&eb,gro?moc?oc?ten?ude?vog??olonhcet!.oc,?rene??hpargotohp?id?k!.&gro?moc?ten?ude?vog??s??l!.&clp?d&em?i??gro?hcs?moc?ten?ude?vog??f?imaf!nacirema??l&a?il??ppus??m!.&eman?gro?lim?moc?t&en?opsgolb,?ude?vog?zib??edaca!.laiciffo,?ra??n&a&ffit?pmoc!ylimafa???os??o&j?s??p!.&gro?lim?moc?pooc?ten?ude?vog???r&e&corg?grus?llag?viled??lewej?otcerid?tnuoc?uxul??s!.&gro?lim?moc?ten?ude?vog??pil??t&efas?i&c?ledif?n&ifx?ummoc!.&bdnevar,gon,murofym,???r&ahc?uces??srevinu??laer?r&ap!.oby,?eporp??uaeb??u!.&bug?gro?lim?moc!.topsgolb,?ten?ude??b!tseb???van!dlo??xes??z&a!.&eman?gro?lim?moc?o&fni?rp??pp?t&en?ni??ude?vog?zib???b!.&az,gro?jsg,moc?ten?ude?vog???c!.&4e,inum.duolc.&rsu,tlf,?m&laer,urtnecatem.motsuc,?oc,topsgolb,??d!.&cos?gro?lop?m&oc?t??ossa?t&en?ra??ude?vog???ib!.&duolcsd,e&ht-rof,mos-rof,rom-rof,?izoj,nafamm,p&i&-on,fles,?ohbew,tfym,?retteb-rof,snd&nyd,uolc,?xro,?g??k!.&duolcj,gro?lim?moc?t&en?ropeletzak.saapu,?ude?vog???m!.&ca?gro?lim?oc?ten?ude?v&da?og????n!.&asq-irom--nx?ca?gro?htlaeh?i&r&c?o&am?ām???wi!k???keeg?l&im?oohcs??neg?oc!.topsgolb,?t&en?nemailrap?vog???a!niflla???rawhcs?s!.&ca?gro?oc???t!.&c&a?s??e&m?n??ibom?l&etoh?im??o&c?fni?g??ro?vt???u!.&gro?moc?oc?ten??rwon??yx!.&e&nozlacol,tisgolb,?gnitfarc,otpaz,??zub??λε?υε?авксом?брс!.&гро?до?ка?р&бо?п!у?????г&б?ро??дкм?зақ?итед?килотак?леб?мок?н&йално?ом??рку?сур!.&арамас,бпс,гро,зиб,ичос,ксм,м&ок,ырк,?рим,я,??тйас?фр?юе?յահ?לארשי?םוק?اي&روس?سيلم?ناتيروم??بر&ع?غملا??ة&كبش?ي&دوعسلا?روس??یدوعسلا??ت&ا&راما?لاصتا??را&ب?ڀ?ھب???ر&ئازجلا?ازاب?صم?طق??سنوت?عقوم?قارع?ك&تيب?يلوثاك??موك?ن&ا&تس&كاپ?کاپ??دوس?ر&يا?یا??مع?يلعلا??درالا?ميلا?ي&رحبلا?طسلف???ه&ارمه?يدوعسلا??وكمارا?يبظوبا?ۃیدوعسلا?टेन?त&राभ?ोराभ??नठगंस?मॉक?्मतराभ?ত&রাভ?ৰাভ??ালংাব?ਤਰਾਭ?તરાભ?ତରାଭ?ாயித்நஇ?ைக்ஙலஇ?்ரூப்பக்ஙிச?్తరాభ?ತರಾಭ?ംതരാഭ?ාකංල?มอค?ยทไ!.&จิกรุธ?ต็นเ?ร&ก์คงอ?าหท??ลาบฐัร?าษกึศ???ວາລ?ეგ?なんみ?アトス?トンイポ?ドウラク?ムコ?ル&グーグ?ーセ??ン&ゾマア?ョシッァフ??业企?东广?乐娱?亚基诺?你爱我?信中?务政?动移?博微?卦八?厅餐?司公?品食?善慈?团集?国中?國中?址网?坡加新?城商?尚时?山佛?店&商?网?酒大里嘉??府政?康健?息信?戏游?拉里格香?拿大?教主天?机手?构机!织组??标商?歌谷?浦利飞?港香!.&人個?司公?府政?絡網?織組?育教???湾台?灣&台?臺??物购?界世?益公?看点?科盈訊電?站网?籍書?线在?络网?网文中?聘招?販通?车汽众大?逊马亚?通联?里嘉?锡马淡?門澳?门澳?闻新?電家?국한?넷닷?성삼?컴닷??");
+ "a&0&0trk9--nx?27qjf--nx?e9ebgn--nx?nbb0c7abgm--nx??1&2oa08--nx?apg6qpcbgm--nx?hbbgm--nx?rdceqa08--nx??2&8ugbgm--nx?eyh3la2ckx--nx?qbd9--nx??3&2wqq1--nx?60a0y8--nx??4x1d77xrck--nx?6&1f4a3abgm--nx?2yqyn--nx?3np8lv81qo3--nx?5b06t--nx?axq--nx?ec7q--nx?lbgw--nx??883xnn--nx?9d2c24--nx?a&a?it??b!.&gro?lim?moc?t&en?opsgolb,?ude?vog??abila?c?ihsot?m?n??c!.&b&a?m?n??c&b?g?q??ep?fn?k&s?y??ln?no?oc,pi-on,sn?t&n?opsgolb,?un?ysrab,?i&ma?r&emarp?fa??sroc??naiva?s??d&ats?n&eit?oh??om?sa?tl??eg?f&c?ob??g!emo?naripi?oy??hskihs?i&cnal?dem?hs?k!on??sa!.snduolc,??jnin?k&aso?dov?ede?usto??l!.&c,gro?m&oc?yn,?ofni?r&ep?nb,?t&en?ni??ude?vog??irgnahs?le&nisiuc?rbmuder???m!.&ca?gro?oc?sserp?ten?vog??ahokoy?e00sf7vqn--nx?m??n!.&ac?cc?eman?gro?ibom?loohcs?moc?ni?o&c?fni?rp??r&d?o??s&u?w??vt?xm??av?is?olecrab?tea??p!.&bog?ca?d&em?ls??g&ni?ro??mo&c?n??oba?ten?ude??c?g7hyabgm--nx?ra!.&461e?6pi?iru?nru?rdda-ni?siri???s??q!.&eman?gro?hcs?lim?mo&c?n,?t&en?opsgolb,?ude?vog???r&az?emac?f4a3abgm--nx?n!d5uhf8le58r4w--nx??u&kas?tan???s!.&bup?dem?gro?hcs?moc?ten?ude?vog??ac!.uban.iu,?iv??t&ad?elhta?led?oyot??u!.&a&cinniv?emirc?i&hzhziropaz?stynniv??s&edo?sedo??tlay?vatlop??bs?cc,d&argovorik?o!roghzu??tl,?e&hzhziropaz?nvir?t??f&i?ni,?g&l?ro??hk?i&stvinrehc?ykstynlemhk??k&c?m?s&nagul?t&enod?ul??v&iknarf-onavi?orteporp&end?ind?????l&iponret?opotsa&bes?ves??p??m&k?oc?s?yrk??n&c?d?i?osrehk?v?ylov??o&c,nvor??p&d?p,z??r&c?imotihz?k?ymotyhz??sk?t&en?l?z??ude?v:c?e&alokin?ik??i&alokym?hinrehc?krahk?vl?yk??k?l?o&g!inrehc??krahk??r?,y&ikstinlemhk?mus?s&akrehc?sakrehc?tvonrehc???z&ib,u????v!aj?bb?et?iv??waniko?x&a?iacal??yogan?z&.&bew?c&a?i&n?rga???gro?l&im?oohcs??m&on?t??o&c!.topsgolb,?gn??radnorg?sin?t&en?la??ude?vog?wal??zip???b&00ave5a9iabgm--nx?1&25qhx--nx?68quv--nx?e2kc1--nx??2xtbgm--nx?3&b2kcc--nx?jca1d--nx??4&6&1rfz--nx?qif--nx??96rzc--nx??7w9u16qlj--nx?88uvor--nx?a&0dc4xbgm--nx?c?her?n?ra?t??b!.&erots?gro?moc?o&c?fni??ten?ude?v&og?t??zib??a??c&j?s??d&hesa08--nx?mi??ec?g?l!.&gro?moc?ten?ude?vog??m??s!.&gro?moc?ten?ude?vog???tc-retarebsnegmrev--nx?u&lc!.&elej,snduolc,y&nop,srab,??smas??p!.ysrab,??wp-gnutarebsnegmrev--nx??c&1&1q54--nx?hbgw--nx??2e9c2czf--nx?4&4ub1km--nx?a1e--nx?byj9q--nx?erd5a9b1kcb--nx??8&4xx2g--nx?c9jrb2h--nx??9jr&b&2h--nx?54--nx?9s--nx??c&eg--nx?h3--nx?s2--nx???a!.&gro?lim?moc?ten?ude?vog??3a09--nx!.&ca1o--nx?gva1c--nx?h&ca1o--nx?za09--nx??ta1d--nx?ua08--nx???da??b&a?b?ci?f76a0c7ylqbgm--nx?sh??c!.&eugaelysatnaf,gnipparcs,liamwt,revres-emag,s&nduolc,otohpym,seccaptf,?xsc,?0atf7b45--nx?a1l--nx??e!.&21k?bog?dem?gro?lim?m&oc?yn,?nif?o&fni?rp??ten?ude?vog??beuq?n?smoc??fdh?i&l&buperananab?ohtac??n&agro?ilc?osanap??tic??l!.&gro?m&oc?yn,?oc?ten?ude?vog?yo,?l??m!.&mt?ossa??p1akcq--nx??n!.&mon?ossa??i?p??relcel?s!.&gro?moc?ten?ude?vog??c??t!.&e&m,w,?hc,?s?w??v!.&e0,gro?lim?mo&c?n,?ten?ude?v&g:.d,,og???q??wp?yn??d&2urzc--nx?3&1wrpk--nx?c&4b11--nx?9jrcpf--nx???5xq55--nx?697uto--nx?75yrpk--nx?9ctdvkce--nx?a!.mon?d?er?olnwod??b2babgm--nx?c!.vog?g9a2g2b0ae0chclc--nx??e&m!bulc??r!k??sopxe?timil?w??fc?g!.&mon,ude?vog???h&d3tbgm--nx?p?t??i!.&ased?bew?ca?etrof,hcs?lim?o&c!.topsgolb,?g??ro?sepnop?ten?ym?zib??ar?b?ordna?p?rdam??l&iub?og?row??m!.&ed,ot,pj,t&a,opsgolb,???n&a&b?l!.citats:.&setis,ved,?,lohwen?raas???ob?uf??o&of?rp??r&a&c&tiderc?yalcrab??ugnav??ef506w4b--nx?k!.&oc,ude,?jh3a1habgm--nx??of??s!.&dem?gro?moc?ofni?ten?ude?v&og?t???m!kcrem???t!.topsgolb,excwkcc--nx?l??uolc!.&atcepsrep,citsalej.piv,drayknil,elej,nworu,r&epolroov,opav,?xelpciffart,??za5cbgn--nx??e&1&53wlf--nx?7a1hbbgm--nx?ta3kg--nx??2a6a1b6b1i--nx?3ma0e1cvr--nx?418txh--nx?707b0e3--nx?a!.&ca?gro?hcs?lim?mon,oc?t&en?opsgolb,?vog??09--nx??b!.&ca?gnitsohbew,topsgolb,?ortal?ut!uoy???c&a&lp!.oc,?ps!.&lla4sx,rebu,slootiknil,tsafym,?artxe??sla??i!ffo??n&a&d?iler?nif?rusni!efil?srelevart???eics!.oby,??rofria??d!.&1sndnyd,42pi-nyd,7erauqs,amil4,brb-ni,decalpb,e&daregtmueart,mohsnd,nihcamyek,?hcierebsnoissuksid,keegnietsi,lsd-ni,moc,n&-i-g-o-l,aw-ym,esgnutiel,i&emtsi,lreb-n&i,yd,??oitatsksid-ygolonys,pv&-n&i,yd,?nyd,??orp-ytinummoc,p&h21,iog:ol,,?r&e&ntrapdeeps.remotsuc,su&-lautriv,lautriv,?t&adpusnd,tub-ni,uor-ym,?vres&-e&bucl,mohym,?bew-emoh:.nyd,,luhcs,??ogiv-&niem,ym,??s&d-&onys,ygolonys,?nd&-&dd,nufiat,sehcsimanyd,tenretni,yard,?isoc.nyd,ps,yard,?oper-&nvs,tig,?sndd:.&nyd,sndnyd,?,?topsgolb,vresi-&niem,tset,?xi2,y&awetag-&llawerif,ym,?srab,tic-amil,?zten&mitbel,sadtretteuf,??a&lg?rt!.oby,??i&s&doow?ruoyno??ug?wnoitan??nil?on--nx??e!.&bil?dem?eif?gro?irp?kiir?moc!.topsgolb,?pia?ude?vog??ei?ffoc?gg?r&f?ged???f&a&c?s??il!tem???g!.&gro?lim?mo&c?n,?t&en?vp??ude?vog??a&f?gtrom?p!.&kselp,sndp,ycvrp,??rots?yov??elloc?na&hcxe?ro??roeg?ug??i!.&myn,topsgolb,vog??tilop?v&bba?om???j!.&gro?oc?ten???k!.&c&a?s??e&m?n??ibom?mon,o&c!.topsgolb,?fni?g??ro??i&b?l?n???l&a&dmrif?s!.rof,rof???b&a?i&b?dua???c&aro?ric??dnik?g!oog??i&bom?ms??l&asal?erauqa??ppa?uhcs?yts!efil???m!.&4&32i,pct,?66c,ailisarb,b&dnevar,g-raegelif,?ca?duolcsd,e&d-raegelif,i&-raegelif,lpad:.tsohlacol,,?pcm,?g&ro?s-raegelif,?hctilg,k&catsegde,uoc,?myn,noitatsksid,o&bmoy,c!ku,?t&nigol,poh,??p&ion,j-raegelif,ohbew,?r&aegelif,ofsnd,?s&dym,ndd,ti??t&en?s&acdnuos,ohon,??u&a-raegelif,de?tcn,?v&irp?og??y&golonys,olpedew,srab,??a&g?n!.&reh.togrof,sih.togrof,???em?i&rp?twohs??orhc?w??n!goloc?i&lno!.ysrab,?w??o!.&derno:.gnigats,,knilemoh,rof,?hp?latipac?ts&der?e&gdirb?rif???z!.&66duolc,amil,sh,???ruoblem??om?p!.&bog?gro?lim?m&o&c?n??yn,?t&en?opsgolb,?ude??irg?yks??r!.&mo&c?n??ossa?topsgolb,?a&c!htlaeh??pmoc?wtfos??bc?eh?if?ots!.erawpohs,?taeht?u&ces?sni?t&inruf?necca??za???s!.&a?b!ibnal?rofmok??c!a??d!b?n&arb?ubroflanummok???e?f!noc,?g!ro??h!f??i!trap??k!shf??l?m!oc,t??n!mygskurbrutan??o?p!p??r?s!serp??t!opsgolb,?u?vhf?w?x!uvmok??y?z??a&c?el?hc??i&er?urc??nesemoh?roh?uoh??t&a&d?ts&e!laer??lla???is!.&areduolc,e&lej,nilnigol,retnim,winmo,?k&rowtenoilof,wnf,?laicosnepo,n&eyb,oyc,?spvtsaf,xulel,ysrab,?bew??ov?ra?t&ioled?ol??utitsni??u&lb?qi&nilc?tuob???v!.&21e?b&ew?og??ce&r?t??erots?gro?lim?m&oc?rif??o&c?fni??stra?t&en?ni??ude?vog??as?e3gerb2h--nx?i&l?rd?ssergorp??ol??w&kct--nx?r??xul??f&0f3rkcg--nx?198xim--nx?280xim--nx?7vqn--nx?a!.&gro?mo&c?n,?ten?ude?vog???b!.vog?wa9bgm--nx??c!.topsgolb,a1p--nx?ns??ea1j--nx?fo?g?iam?l&a1d--nx?og??n!.&bew?cer?erots?m&oc?rif??ofni?re&hto?p??stra?ten???orp?p!.&gro?moc?ude???rus?t!w??vd7ckaabgm--nx?w??g&2&4wq55--nx?8zrf6--nx??3&44sd3--nx?91w6j--nx!.&a5wqmg--nx?d&22svcw--nx?5xq55--nx??gla0do--nx?m1qtxm--nx?vta0cu--nx????455ses--nx?5mzt5--nx?69vqhr--nx?7&8a4d5a4prebgm--nx?rb2c--nx??a!.&gro?mo&c?n??oc?ten??vd??b!.&0?1?2?3?4?5?6?7?8?9?a?b?c?d?e?f?g?h?i?j?k?l?m?n?o?p?q?r?s?t!opsgolb,?u?v?w?x?y!srab,?z???c!b?za9a0cbgm--nx??e!.&eman?gro?ics?lim?moc!.topsgolb,?nue?ten?ude?vog??a??g!.&ayc,gro?lenap:.nomead,,oc?saak,ten???i&a?v??k!.&g&olb,ro??ku,lim?moc?oi,pj,su,ten?ude?v&og?t,???m!.&drp?gro?lim?m&o&c?n??t??oc?ude?vog??pk??n!.&dtl,eman?gro?hcs?i!bom??l&im?oc,?m&oc!.topsgolb,?rif,?neg,ogn,ten?ude?vog??aw?i!b!mulp??car?d&art?dew??h&sif?tolc??k&iv?oo&b?c???ls?n&aelc?iart??p!pohs??re&enigne?tac??t&ad?ekram?hgil?lusnoc?neg?ov?soh!.tfarcnepo,?tebdaerps??vi&g?l???o!s??u&rehcisrev?smas?tarebsnegömrev???o&d?lb?og!.duolc,??r&2n084qlj--nx?ebmoolb?o!.&77ndc.c:sr,,a&remacytirucesym,t&neimip,sivretla,?z,?bew-llams,d&ab-yrev-si,e&sufnocsim,vas-si,?nuof-si,oog-yrev-si,uolc&arfniarodef,mw,??e&a,cin-yrev-si,grof&loot,peh,?l&as-4-ffuts,poeparodef,?m&-morf,agevres,ohruoyslles,?n&ozdop,uma.elet,?r&ehwongniogyldlob,iwym,uces-77ndc.nigiro.lss,?t&adidnac-a-si,is&-ybboh,golb,???fehc-a-si,golbymdaer,k&eeg-a&-si,si,?h,nut,?l&i&amwt,ve-yrev-si,?lawerif&-ym,ym,?sd-ni,?m&acssecca,edom-elbac,?n&af&blm,cfu,egelloc,lfn,s&citlec-a-si,niurb-a-si,tap-a-si,?xos-a-si,?o&itatsksid,rviop,?pv-ni,?o&jodsnd,tp&az,oh,??p&i&-on,fles,?o&hbew,tksedeerf,?tf&e&moh,vres,?ym,??r&e&gatop,ppepteews,su-xunil-a-si,?gmtrec,vdmac,?s&a&ila&nyd,snd,?nymsd,?b&alfmw,bevres,?dylimaf,eirfotatophcuoc,gulku,j,koob-daer,ltbup,nd&-won,deerf,emoh,golb,kcud,mood,nyd:.&emoh,og,?,ps,rvd,tog,uolc,?s&a-skcik,ndd,?tnemhcattaomb,u,?t&ce&jorparodef.&duolc,gts.so.ppa,so.ppa,?riderbew,?e&ews-yrev-si,nretni&ehtfodne,fodne,??hgink-a-si,igude,oi-allizom,s&ixetn&od,seod,?o&h-emag,l-si,?rifyam,??ue:.&a&-q,c,?cm,dc,e&b,d,e,i,m,s,?g&b,n,?hc,i&f,s,?k&d,m,s,u,?l&a,i,n,p,?n&c,i,?o&n,r,ssa,?pj,r&f,g,h,k,t,?s&e,i:rap,,u,?t&a,en,i,l,m,ni,p,?u&a,de,h,l,r,?vl,y&c,m,?z&c,n,??,vresnyd,x&inuemoh,unilemoh,?y&limafxut,srab,???ub&mah?oj???s!.&gro?moc?rep?t&en?opsgolb,?ude?vog??gb639j43us5--nx??t?u!.&c&a?s??en?gro?mo&c?n,?o&c?g??ro?topsgolb,??v!.&mon,ta,?a1c--nx??wsa08--nx??h&0ee5a3ld2ckx--nx?4wc3o--nx!.&a&2xyc3o--nx?3j0hc3m--nx?ve4b3c0oc21--nx??id1kzuc3h--nx?l8bxi8ifc21--nx?rb0ef1c21--nx???8&8yvfe--nx?a7maabgm--nx??b!.&gro?moc?ten?ude?vog??mg??c!.&7erauqs,amil4,duolc-drayknil,gniksnd,ph21,sndtog,topsgolb,wolf.enigneppa,xi2,ytic-amil,?aoc?et?ir!euz??r&aes!errecnac??uhc??sob?taw!s???d0sbgp--nx?f&2lpbgm--nx?k??g!.&gro?lim?moc?ude?vog???iesac?m!a1j--nx??ocir?p!.&gro?i?lim?moc?ogn?ten?ude?vog???s!.&g&nabhsah,ro??l&im?xv,?m&oc?roftalp.&cb,su,tne,ue,??ten?vog?won,yolpedew,?a&c?nom??i&d?f?ri???t!.&ca?enilno,im?ni?o&c?g??pohs,ro?ten??iaf!.oby,?laeh?orxer?ra&ba?e???vo!.lopdren,?zb??i&3tupk--nx?7a0oi--nx?a!.&ffo?gro?mo&c?n,?ten?uwu,?1p--nx?bud?dnuyh?tnihc??b!.&gro?moc?oc?ro?ude??ahduba?o!m!.&duolcsd,ysrab,???s??c!.&ayb-tropora--nx?ca?d&e?m??esserp?gro?ln,moc?nif,o&c?g?ssa??ro?t&en?ni?roporéa??ude?vuog??cug?t??d&dk?ua??e&bhf--nx?piat??f!.&aw5-nenikkh--nx,dnala?iki,mroftalpduolc.if,nenikkäh,retnecatad.saap,topsgolb,yd,?onas??g!.&d&om?tl??gro?moc?ude?vog???h&c&atih?ra??s&abodoy?ibustim???juohs?k!.&gro?moc?ofni?ten?ude?vog?zib??b4gc--nx?iw?nisleh?s?uzus??l!.&aac,m&on,yn,?topsgolb,?drahcir?iamsi??maim?n!.&b&ew?og??ca?gro?lim?mo&c?n??ni?o&c?fni??pp?t&en?ni??ude?zib??airpic?i&hgrobmal?m??re??om?rarref?s!.&egaptig,mon,topsgolb,?ed??t&aresam?i&c?nifni??rahb?tagub??ut?v!.&21k?gro?moc?oc?ten???wik?xa&rp?t??yf??j&6pqgza9iabgm--nx?8da1tabbgl--nx?b!.&ossa?topsgolb,uaerrab?vuog???d?f!.&ca?eman?gro?lim?moc?o&fni?rp??ten?vog?zib???nj?s?t!.&bew?c&a?in??eman?gro?lim?mo&c?n,?o&c?g??t&en?ni?set??ude?vog?zib???yqx94qit--nx??k&8uxp3--nx?924tcf--nx?arfel?c&a&bdeef?lb??ebdnul?ilc?reme?ud??d!.&erots,ger,mrif,oc,topsgolb,zib,?t??e&es?samet??h!.&a&4ya0cu--nx?5wqmg--nx??b3qa0do--nx?cni,d&2&2svcw--nx?3rvcl--nx??5xq55--nx?tl,?g&a0nt--nx?la0do--nx?ro??i&050qmg--nx?7a0oi--nx?xa0km--nx??m&1qtxm--nx?oc?yn,?npqic--nx?t&en?opsgolb,?ude?v&di?og?ta0cu--nx??xva0fz--nx?人&个?個?箇??司公?府政?絡&網?网??織&組?组??织&組?组??络&網?网??育&敎?教???n??i&tsob?vdnas??l!.&bew?c&a?os??dtl?gro?hcs?letoh?moc?nssa?ogn?prg?t&en?ni??ude?vog??at?cd?is??m!.&eman?fni?gro?mo&c?n,?t&en?opsgolb,?ude?vog???n&ab!cfdh?etats?mmoc?t&en?fos??u??i!.gn,l!.&noyc,pepym,??p???oob?p!.&b&ew?og??gro?kog?m&af?oc??nog?ofni?pog?sog?ten?ude?vog?zib???row!.&fo,ot,?ten!.&htumiza,o&c,vra,??doof???s!.&myn,topsgolb,??t?u!.&c&a?lp??d&om?tl??e&cilop?m??gro!.&gul:g,,sgul,??nnoc,o&c!.&bunsorter.tsuc,e&lddiwg,n&ilnoysrab,ozgniebllew,??krametyb.&hd,mv,?pi-on,t&fihsreyal.j,opsgolb,?vres-hn,ysrab,??rpoc,?shn?t&en?nmyp,?vog!.eci&ffoemoh,vres,??ysrab,???l&04sr4w--nx?a!.&gro?lim?mo&c?n,?t&en?opsgolb,?ude?vog??bolg?c?ed?g!el??i&c&nanif!.oc,lpl??os??romem?tnedurp??n&if?oitanretni??t&i&gid!.sppaduolc:.nodnol,,?p&ac?soh???ned?ot??utum!nretsewhtron???c!.&bog?lim?mon,oc?samednerpa?topsgolb,vog???dil?e&datic?n&ahc?nahc!gnikooc?levart?rehtaew???t!ni?ria?tam??vart??f&8f&pbgo--nx?tbgm--nx??a?n??g!.&gro?mo&c?n,?oc?ten?ude?xx,zib,??h&d?op??i!.&21k?ca?fdi?gro?inum?oc!.topsgolb,?ten?vog??a&f?m&e?g?toh???m?r?xil??l&a&b&esab?t&eksab!.&sua,zn,??oof!.fo,???c?mt??e&d?hs??ihmailliw?j??m!.&esserp?gro?moc?ten?ude?v&og?uog????n!.&n&iemodleeutriv,o&med,rtsic,??oc,retsulc-gnitsoh,topsgolb,wsma,yalphk,?o??o&a?btuf?l!.gmo,?o&c!.ed,?hcs!.gn,??rit?u??p!.&a&cin&diws?gel??d&g,ortso?urawon??i&dem?mraw?nydg,?k&elo&guld?rtso??slopolam?tsu?ytsyrut??l&ip?o&kzs?w&-awolats?oksnok????n&img?zcel,?rog&-ai&bab?nelej??j?z??syn?tsaim?w&a&l&eib?i?o??zsraw??o&namil?tainop,??z&eiwolaib?mol???c&e&iw&alselob?o&nsos?rtso???le&im?zrogz???orw,p??d&em,ia?ragrats??e&c&i&lrog?w&ilg,o&hc&arats?orp??klop?tak????yzreibok??i&csjuoniws?ksromop?saldop??l&ahdop?opo??napokaz,tatselaer?z&romop?swozam???g&alble?ezrbo&lok?nrat??ro??hcyzrblaw?i&csomohcurein?grat?klawus??k&e&rut?walcolw??in&byr?diws,sark,?le?o&nas?tsylaib??rob&el?lam??s&als?jazel?nadg,puls?rowezrp???l&colw?e&r?vart??i&am?m???m&o&c?dar?n?tyb??s&g?iruot??t!a???n&a&gaz?nzop,?i&bul?cezczs?lbul,molow?nok?zd&eb?obeiws???uleiw?y&tzslo?z&rtek?seic????o&c,fni?k&celo?zdolk??lkan?n&leim?pek?t&uk?yzczs??z&copo?eing?rowaj???rga?tua?w&ejarg?ogarm???p&e&eb,lks??klwwortso?ohs??romophcaz?sos?t&aiwop?en?opos,ra,sezc??ude?v&irp?og!.&a&p?s!w???bni&p?w??ci?dtiw?essp?fiw?g&imu?u??hiiw?m&igu?rio?u!o???nds?o&ks?p!pu??s?wtsorats??p&a?sp!mk?pk?wk??u&m?p??wk?z??r&ksw?s??s&i?oiw?u?zu??talusnok?w&gzr?i&p?rg?w??m?opu?u!imzw???zouw????w&a&l&corw?sizdow??w??o&golg?k&ark,ul?zsurp??r&az?gew??t&rabul,sugua??z&coks?sezr????xes?y&buzsak?d&azczseib?ikseb??hcyt?n&jes?lod-zreimizak??pal?r&ogt?uzam??walup?zutrak??z&am-awar?c&aprak?iwol?zsogdyb??dalezc?ib?s&i&lak?p??uklo????l??r&as?f?s??s!.&gro?moc?ten?ude?vog???t!.vog??ubnatsi?x3b689qq6--nx?yc5rb54--nx??m&00tsb3--nx?1qtxm--nx?981rvj--nx?a!.&aayn,enummoc?gro?moc?o&c?idar,ken,?t&en?opsgolb,??c!bew??dretsma?e&rts?t!.&citsalej,esruocsid,???fma?rirhs?xq--nx??b!.&gro?moc?ten?ude?vog??i??c!.&moc?oc?ten?vog???d!.&gro?moc?ten?ude?vog???f!.&gro?moc?oidar,ten?ude??i??g!vu96d8syzf--nx??h?i!.&ca?gro?mo&c?n,?o&c!.&clp?dtl???r,?t&en?t??vt??k?rbg4--nx??k!.&drp?e&rianiretev?sserp??gro?lim?m&o&c?n??t??nicedem?ossa?pooc?s&eriaton?neicamrahp?sa??ude?v&og?uog????l&if?ohkcots??o!.&dem?gro?m&oc?uesum??o&c?rp??ten?ude?vog??b?c!.&2aq,3pmevres,a&c&-morf,ir&bafno,fa,??g&-morf,oy-sehcaet,?i-morf,m&-morf,all&-a-si,amai,??p&-morf,c-a-si,?r&emacytirucesym,odih,?s,tadtsudgniht,v-morf,w-morf,z,?b&dnevarym,ew&-sndnyd,draiw.segap,ottad,?g,ildts.ipa,?c&amytirucesemoh,d-morf,esyrcs,itsalej.omed,n&-morf,vym,?p&kroweht,ytirucesemoh,?q,rievres,s-morf,?d&aerotffuts,e&calpb,ifitrec-&si,ton-si,?llortnocduolc,rewopenignepw,?i&-morf,rgevissam.saap,?m-morf,n&-morf,abeht-htiw-si,?s-morf,uolc&-noitatsyalp,hr,meaeboda,panqym:-&ahpla,ved,?,smetsystuo,ved&j,pw,??wetomer,?e&butuoyhtiw,ciffo-sndnyd,d:-morf,o&celgoog,n&il.srebmem,neve.&1-&su,ue,?2-&su,ue,?3-&su,ue,?4-&su,ue,????,erf&-sndnyd,sndd,?filflahevres,gnahcxeevres,i&hcet-a-si,p-sekil,?k&auqevres,irtsretnuocevres,?l&bitpa-no,googhtiw,?m&agevres,ina-otni-si,oh-&sndnyd,ta-sndnyd,??n&-morf,ilnoysrab,og-si,?r&alfduolcyrt,ihcec,uzanoppanex,?srun-a-si,t&i&nuarepo,s&-ybboh,aloy,tipohs,??omer-sndnyd,ysgolb,?v&als-elcibuc-a-si,i&lsndd,tavresnoc-a-si,??z&amkcar,eelg,iig,??fehc-a-si,g&ni&gats-swennwot,ksndd,robsikrow,?o&fgp,lb&-sndnyd,sihtsetirw,???h&n-morf,o-morf,?i&fiwehtno,h-morf,kiw-sndnyd,m-morf,pdetsoh,r-morf,w-morf,z&ihcppa,nilppa,??jn-morf,k&a&-morf,erfocsic,?cils-si,eeg&-a&-si,si,?sndd,?h,latsnaebcitsale:.&1-&htuos-pa,lartnec-&ac,ue,?ts&ae&-&as,su,?ht&ron-pa,uos-pa,??ew-&su,ue,vog-su,???2-ts&ae&-su,ht&ron-pa,uos-pa,??ew-&su,ue,??3-ts&aehtron-pa,ew-ue,??,o-morf,r&adhtiwtliub,ow&-&sndnyd,ta-sndnyd,?ten-orehkcats,??u,?l&a&-morf,colottad,rebil-a-si,?f-morf,i&-morf,am-sndnyd,?l&ecelffaw,uf-ytnuob:.a&hpla,teb,?,?ppmswa,ru-&elpmis,taen,?ssukoreh,xegap,?m&n-morf,pml.ppa,rofererac-htlaeh,sacrasevres,uirarret-yltsaf,?n&a&cilbuper-a-si,f&-sllub-a-si,racsan-a-si,?i&cisum-a-si,ratrebil-a-si,??c,dcxirtrepmi,eerg-a-si,i-morf,m-morf,o&ehtnaptog,isam-al-a-tse,rtap-el-tse,s&iam-al-a-tse,replausunu,??pj,t-morf,?o&bordym,c,jodsnd,m-morf,n:iloxip,,ttadym,?p&2pevres,aelutym,i&-sndnyd,fles,ogol,ruoy&esol,hctid,?ymteg,?pa&-rettalp,anis:piv,,esaberif,k1,lortnocduolc,oifilauq,r&aegyks,oetem:.ue,,?tnorfegap,ukoreh,?t&fevres,thevres,??r&a:-morf,tskcor-a-si,,b,e&d&ivorpnwo,ner&.ppa,no,??e&bevres,nigne-na-si,?ggolb-a-si,h&caet-a-si,pargotohp-a-si,?krow-drah-a-si,n&gised-a-si,ia&rtlanosrep-a-si,tretne-na-si,??p&acsdnal-a-si,eekkoob-a-si,?retac-a-si,subq,tn&ecysrab,iap-a-si,uh-a-si,?vres&-&ki.duolcj,s&ndnyd,pvtsaf,??inim,nmad,sak,?y&alp-a-si,wal-a-si,?zilibomdeepsegap,?g,k,mgrp.nex,o&-morf,sivdalaicnanif-a-si,t&c&a-na-si,od-a-si,?susaym,??p-morf,u&as-o-nyd,eugolb-nom-tse,omuhevres,??s&a&apod,ila&nyd,snd,?nymsd,?bbevres,ci&p&-sndnyd,evres,?tcatytiruces,?dylimaf,e&cived-anelab,itilitu3,lahw-eht-sevas,mag-otni-si,tyskciuq,?i&ht2tniop,pa&elgoog,tneltneg,??k&-morf,aerf-ten,colbpohsym,?m&-morf,cxolb,?n&d&-pmet,dyard,golb,mood,tog,?kselp,nyd,ootrac-otni-si,?o&-xobeerf,xobeerf,?ppatneg,r&ac-otni-si,etsohmaerd,?s&e&l-rof-slles,rtca-na-si,?ibodym,?tsaeb-cihtym.&azno,ilay,remotsuc,sv,toleco,x:n&ihps,yl,?,?u,wanozama.&1-&htuos-pa&-3s,.&3s,etisbew-3s,kcatslaud.3s,??la&nretxe-3s,rtnec-&ac&-3s,.&3s,etisbew-3s,kcatslaud.3s,??ue&-3s,.&3s,etisbew-3s,kcatslaud.3s,????ts&ae&-&as&-&3s,etisbew-3s,?.kcatslaud.3s,?su:-etisbew-3s,.kcatslaud.3s,,?ht&ron-pa&-&3s,etisbew-3s,?.kcatslaud.3s,?uos-pa&-&3s,etisbew-3s,?.kcatslaud.3s,???ew-&su-&3s,etisbew-3s,?ue&-&3s,etisbew-3s,?.kcatslaud.3s,?vog-su-&3s,spif-3s,????2-ts&ae&-su&-3s,.&3s,etisbew-3s,kcatslaud.3s,??ht&ron-pa&-3s,.&3s,etisbew-3s,kcatslaud.3s,??uos-pa&-&3s,etisbew-3s,?.kcatslaud.3s,???ew-&su-&3s,etisbew-3s,?ue&-3s,.&3s,etisbew-3s,kcatslaud.3s,????3&-tsew-ue&-3s,.&3s,etisbew-3s,kcatslaud.3s,??s,???t&arcomed-a-si,c-morf,eel&-si,rebu-si,?m-morf,n&atnuocca-na-si,e&duts-a-si,r-ot-ecaps,tnocresu&buhtig,elbavresbo.citats,pl,???ops&edoc,golb,ppa,?s&i&hcrana-&a-si,na-si,?laicos-a-si,pareht-a-si,tra-na-si,xetn&od,seod,??oh&piym,sfn,??u&-morf,nyekcoh-asi,?v-morf,?u&-rof-slles,4,e,h,oynahtretramssi,r:ug-a-si,,?v&n-morf,w-morf,?w&ozok,ww100,?x&bsbf.sppa,em,i&nuemoh,rtrepmi,?obaniateb,t-morf,unilemoh,?y&a&bnx:.&2u,lacol-2u,?,lerottad,wetag-llawerif,?dnacsekil,k&-morf,niksisnd,?rotceridevitcaym,u:goo,,w-morf,x&alagkeeg,orphsilbup,???inu??m!.&dna,rof,??or?tsla??p!.nwo,?raf!.jrots,etats??s?t!.&gro?lim?mo&c?n??oc?ten?ude?vog???u&esum!.&a&92chg-seacinumocelet-e-soierroc--nx?atnav?c&i&aduj?rfatsae??rollam??d&anac?enomaledasac?irolf??e&raaihpledalihp?srednu??g&hannavas?oonattahc??hamo?i&auhsu?bmuloc!hsitirb??dem?groeg?hpledalihp?l&artsua?etalif??n&igriv?rofilac??ssur?tsonod??ksa&la?rben??l&lojal?q-snl--nx?uossim!trof???m&a&bala?nap??enic?o&m?r???n&a&cirema?idni??edasap?ilorachtuos?olecrab??r&abrabatnas?ezzivs??su?t&nalta?osennim??zalp??c&dnotgnihsaw?ebeuq?i&depolcycne?ficap?hpargonaeco?lbup?sum?t&carporihc?lec?naltadim??vu??yn??d&a&dhgab?etsmraf?m?orliar??i&rdam?ulegnedleeb??leif?n&a!l&gne?nif?ragyduj?t&ocs?rop??yram???u&brofsdgybmeh?osdnaegami???r&augria?ofxo???e&c&a&l&ap?phtrib??ps??n&a&lubma?tsiser??e&fedlatsaoc?gilletni?ics!foyrotsih????pein?rof??d&nukneklov?revasem??e&rt?tsurt??f&atnas?ildliw??g&a&lliv?tireh!lanoitan???dirbmac?rog??i&cnum?nollaw??koorbrehs?l&ab?bib?cycrotom?i&ssim?txet??oks?tsac??m&affollah?it!iram??utsoc??n&golos?ilno?recul??r&a&uqs?waled!foetats???i&hs&acnal?kroy?pmahwen??otsih??omitlab?ut&an?cetihcra?inruf?luc!irga?su???vuol??s&abatad?iacnarf?sius?uoh!lum???t&a&locohc?rak?ts!e!yrtnuoc!su?????imesoy?tevroc??u&qihpargonaeco?velleb??vit&caretni?omotua???f&iuj?ohgrub??g&n&i&dliub?ginerevmuesum?kiv?lahw?nim?peekemit?vil??ulmmastsnuk??orf?r&ebnrats?u&b&ierf?le?m&ah?uan??ram?s&mailliw!lainoloc??naitsirhc?retepts??zlas??ob&irf?mexul?????h&atu?c&raeser?sirotsih?uot??g&ea1h--nx?rubsttip??si&tirb?wej??t&laeh?ro&n?wtrof??uo&mnom?y????i&d6glbhbd9--nx?iawah?k&nisleh?s??lad!rodavlas??sissa?tannicnic??k&c&nivleeg?olc!-dna-hctaw?dnahctaw???fj?inebis?l&is?ofron??na&rfenna?t??oorbnarc?r&am&ned?reiets??oy!wen????l&a&ci&dem?golo&eahcra?meg?oz??natob?rotsih??ertnom?iromem?noita&cude?n??oc?rutluc?trop?utriv?van??e&nurb?s&ab?surb??utriv??i&artnogero?sarb??l&a&besab?hsnoegrus??e&hs?rdnevle??i&b?m!dniw????o&bup?ohcs?tsirb???m&a&dretsma?ets?h&netlehc?rud???ct?elas!urej??l&if?ohkcots?u??raf?silanruoj?u&esumyrotsihlarutan?ira&tenalp?uqa??terobra???n&a&c!irema!evitan???gihcim?i&dni?tpyge??mfoelsi?wehctaksas??e&d&alokohcs?ews?rag!cinatob?lacinatob?s&nerdlihc?u????gahnepoc?hcneum?laftsew?ppahcsnetewruutan?r&dlihc?ednaalv?hu!dnutamieh???sseig??gised!dn&atra?utsnuk???h&ab!nesie??ojts??i&lreb?tsua??l&eok?ocnil??n&ob?urbneohcs??o&dnol?gero?i&s&iv&dnadnuos?elet??nam??t&a&c&inummoc?ude!tra???dnuof?erc?i&cossa?va??kinummokelet?nissassa?r&belectsevrah?oproc?tsulli??silivic?t&nalp?s??vres&erp?noclatnemnorivne??zilivic??c&elloc?if-ecneics??ibihxe???ri?s&dnah?imaj?reffej?sral??t&erbepac?nilc?sob???r&e&b?dom?tsew?uab?zul??obredap??vahnebeok?wot??o&2a6v-seacinumoc--nx?ablib?c&edtra?ixemwen?sicnarfnas??elap?g&a&cihc?to??eidnas??i&cadnuf?diserp?ratno??llecitnom?mitiram?nirot?r&htna?ienajedoir???pohskrow?qari?r&aw!dloc?livic??dd?e&b&ma?yc??irrac?llimsiwel?naksiznarf?papswen?t&aeht?exe?nec!ecneics?larutluc?muesum?tra??s&ehc&nam?or??neum??upmoc???ia!nepo??obal?u&asonid?obal?takirak???s&a&l&g?l&ad?eh???xet??di&k?pardnarg??e&cneics!larutan??dnal?hcsi&deuj?rotsih!nizidem?rutan??selhcs??itinamuh?l&aw?egnasol?l&e&rutansecneics?xurb??iasrev???r&e&em?ugif??tsac??suohcirotsih?u&en?q&adac?itna!nacirema?su????õçacinumoc!elet-e-soierroc???gnirpsmlap?htab?i&lopanaidni?rap?uoltnias?xa??l&essurb?lod??mraeriflanoitan?n&a&blats?l??erdlihc?oi&snam?tacinummoc!elet-dna-stsop???äl??re&dnalf?lttes?mraf?nim?tnececneics??s&alg?erp??t&farc!dnastra??nalp?olip?ra!e&nif?vitaroced!su???su?xuaeb???u&b!muloc??cric???t&agilltrop?cejorp?dats?e&esum?kramnaidni??iorted?ne&m&elttes?norivne?piuqemraf??vnoc??oped?r&a!drib?enif?gttuts?hsiwej?kcor?n&acirema?ootrac??tamsa?yraropmetnoc??op&aes?snart?wen??ufknarf??s&a&cdaorb?octsae??ewhtuos?ilayol?nuk?r&ohnemled?uhlyram??urt???u&a&bgreb?etalpodaroloc??rmyc??w&ocsom?rn??x&esse?ineohp?nam?tas??y&a&bekaepasehc?w&etag?liar???camrahp?doc?e&hsub?l&ekreb?l&av!eniwydnarb??ort???n&dys?om??rrus?s&nreug?rejwen???golo&e&ahcra?g??motne?nh&cet?te??oz?po&rhtna?t??roh??hpargotohp?l&etalihp?imaf??m&edaca?onortsa??n&atob?yn??ps?r&a&ropmetnoc?tilim??e&diorbme?llag!tra??vocsid??lewej?nosameerf?otsih!dnaecneics?ecneics?gnivil!su??la&col?rutan??retupmoc?su??tsudnidnaecneics??spelipe?t&eicos!lacirotsih??i&nummoc?srevinu??nuoc???z&arg?iewhcs?nil?ojadab?urcatnas??моки?םילשורי???rof??z!.&ca?gro?hcs?lim?moc?o&c?fni??ten?ude?vog?zib????n&315rmi--nx?a&brud?cilbuper?f?grompj?hkaga?idraug?m?ol?ssin?u&hix?qna??varac?yalo??b!.&gro?moc?oc,ten?ude?vog??c??c!.&ah?bh?c&a?s??d&5xq55--nx?g?s?uolctnatsni,?eh?g&la0do--nx?ro??h&a?q?s??i&7a0oi--nx?h??j&b?f?t?x?z??kh?l&h?im?j??m&n?oc!.swanozama.&1-htron-nc.3s,be.1-&htron-nc,tsewhtron-nc,????n&h?l?s?y??om?qc?s&g?j??ten?ude?vog?wt?x&g?j?n?s??z&g?x??司公?絡網?络网??b??d&g!.ypnc,?ka??e&drag?erg?fuak?gawsklov?hctik?i&libommi?w??m!.rof,?po?r!ednaalv??sier?ves??g!.&ca?gro?moc?ten?ude?vog??is&ed!.ssb,?irev???h!.&bog?cc,gro?lim?mo&c?n,?ten?ude???i!.&bew,c&a?in??dni?gro?lim?mrif?neg?oc?s&er?nduolc,?t&en?opsgolb,?ude?vog?ysrab,?elknivlac?griv?ks?lreb?p!ul??v?w?x??k!.&gro?ten?ude?vog???l&eok?ocnil??m!.&cyn,gro?myn,ude?vog???o&dnol!.&fo,ni,??i&hsaf!.&fo,no,??n&o?utiderc??siv!orue??t&a&cude!.oc,?dnuof?tsyalp??c&etorp?u&a?rtsnoc?????kin?las?mrom?nac?p&q?uoc??s&iam?nhojcs?pe?scire??t&ron?sob??zama??p!.&gro?oc?ten?ude?vog??k??r&e&c?yab??op!.eidni,??s!.&gro?moc?osrep?t&opsgolb,ra??ude?v&inu?uog????t!.&dni?esnefed?gro?ltni?m&oc!nim??siruot??n&erut?if??o&fni?srep??sn&e?r??t&an?en!irga?ude??rnr??unr?vog??m??u&f?r!.&bdnevar,lper,sh,tnempoleved,??stad?xamay?y??v!.&ca?eman?gro?htlaeh?moc?o&fni?rp??t&en?ni?opsgolb,?ude?vog?zib???wo&rc?t!epac????o&76i4orfy--nx?a!.&bp?de?go?oc?ti?vg??boat??b!.&a&ci&sum?tilop??i&c&arcomed?neic??golo&ce?ncet??m&edaca?onoce??rt&ap?sudni??vilob??n&egidni?icidem??serpme?tsiver?vitarepooc??b&ew?og??dulas?e&rbmon?tr&a?op&ed?snart????g&olb?ro??ikiw?l&a&noi&canirulp?seforp??rutan??im??moc?o&fni?lbeup?rga?tneimivom??saiciton?t&askt?en?ni??ude?vt??h?iew?olg??c!.&bew?cer?dr&c,rac,?gro?ipym,l&im?per,?m&o&c!.topsgolb,?n??rif?udon,?ofni?s&egap&dael,l,?tra??t&4n,en?ni??ude?vog??a?e!vi??in?mara?s&edarb?ic???d!.&b&ew?og??dls?gro?lim?moc?t&en?ra??ude?vog??agoba?if?zd7acbgm--nx??e&c?d&iv?or??morafla??f!ni!.&e&g&delwonk-fo-l&errab,lerrab,?ellocevoli,?ht-skorg,rom-rof-ereh,tadpusn:d,,?llatiswonk,macrvd,ofni-v,p&i&-on,fles,?ohbew,?ruo-rof,s&iht-skorg,nd&-cimanyd,nyd,uolc,??tsrifyam,ysrab,zmurof,???g&el?n!am?ib???hwsohw?i!.&35nyd,8302,a&minifed,tad-b,?b&altig,uhtig,?c&inone:.remotsuc,,zh,?d&in,u&olc&iaznab.ppa,noitacilppa,ropav,?rd,??e&civedniser,donppad.sndnyd,egipa,lej,nilnigol,sufxob,t&isnoehtnap,newtu,??gni&gatsniser.secived,tsohytsoh,?k&orgn,ramytefasresworb,?m&oc?udon,?nyded,p&opilol,pa&-arusah,cs,enalpkcab,??r&evres&cisab,lautriv,?ial.sppa,?s&codehtdaer,nemeis-om,pparevelc,tacdnas,?t&enotorp,i&belet,detfihs,kecaps,?raedon.egats,sudgniht.&cersid.tsuc,dorp.tsuc,gnitset.tsuc,ved.tsuc,??vgib.0ku,whs,x&bslprbv.g,cq,?y&olpedew,srab,??b?d&ar?u&a?ts???j?r?syhp??j!.&eman?gro?hcs?lim?moc?ten?ude?vog???ll&ag?o??m!.&gro?moc?ten?ude?vog??g?il?mi?orp??n!.&a&0&b-ekhgnark--nx?c-iehsrgev--nx?g-lksedlig--nx?k-negnanvk--nx??1&p-nedragy--nx?q-&asierrs--nx?grebsnt--nx?lado-rs--nx?n&egnidl--nx?orf-rs--nx??regnayh--nx?ssofenh--nx??r-datsgrt--nx?s-ladrjts--nx?v-y&senner--nx?vrejks--nx???3g-datsobegh--nx?4&5-&dnaleprj--nx?goksnerl--nx?tednalyh--nx??6-neladnjm--nx?s-&antouvachb--nx?impouvtalm--nx??y-&agrjnevvad--nx?ikhvlaraeb--nx???7k-antouvacchb--nx?8&k-rekie-erv--nx?l-ladrua-rs--nx?m-darehsdrk--nx??a!.sg??bct-eimeuvejsemn--nx?d&do?iisevvad?lov?narts?uas??f&1-&l--nx?s--nx??2-h--nx??g&10aq0-ineve--nx?av?ev?lot?r&ajn&evvad?u??ájn&evvad?u????h?iz-lf--nx?j&ddadab?sel??k&el?hoj&sarak?šárák??iiv&ag&na&el?g??ŋ&ael?ág???ran???l&f?lahrevo?o&ms?s??sennev?t-&ilm--nx?tom--nx??u&-edr--nx?s??øms??muar?n&0-tsr--nx?2-dob--nx?5-&asir--nx?tals--nx??a&r!-i-om?f?t??t??douvsatvid?kiv?m&os?øs??n&od?ød??ra?sen?t&aouvatheig?ouv&a&c&ch&ab?áb??h&ab?áb???n??i&ag?ág??sa&mo?ttvid??án???z-rey--nx?ær&f?t???o&p-&ladr--nx?sens--nx??q-nagv--nx?r-asns--nx?s-kjks--nx?v-murb--nx?w-&anr&f--nx?t--nx??ublk--nx???ppol?q&0-t&baol--nx?soum--nx?veib--nx??x-&ipphl--nx?r&embh--nx?imph--nx???y-tinks--nx??r&f-atsr--nx?g-&an&ms--nx?nd--nx??e&drf--nx?ngs--nx??murs--nx?netl--nx?olmb--nx?sorr--nx??h-&a&lms--nx?yrf--nx??emjt--nx??i&-&lboh--nx?rsir--nx?y&d&ar--nx?na--nx??ksa--nx?lem--nx?r&ul--nx?yd--nx????stu??j-&drav--nx?rolf--nx?sdav--nx??kua?l-&drojf--nx?lares--nx??m-tlohr--nx?n-esans--nx?olf?p-sdnil--nx?s-ladrl--nx?tih?v-rvsyt--nx??s&a&ns?ons??i&ar?er&dron?r&os?øs???ár??la&g?h??mor!t??sir?uf?åns??t&koulo&nka?ŋká??la?p-raddjb--nx?r-agrjnu--nx?s&aefr&ammah?ámmáh??orf?r&o?ø???u-vreiks--nx??u&h-dnusel--nx?i-&drojfk--nx?vleslm--nx??j-ekerom--nx?k-rekrem--nx?u-&dnalr--nx?goksr--nx?sensk--nx??v-nekyr--nx?w-&k&abrd--nx?ivjg--nx??oryso--nx??y-y&dnas--nx?mrak--nx?n&art--nx?nif--nx??reva--nx??z-smort--nx??v!.sg?ledatskork?reiks??wh-antouvn--nx?x&9-dlofts--nx.aoq-relv--nx?d-nmaherk--nx?f-dnalnks--nx?h-neltloh--nx?i-drgeppo--nx?j-gve&gnal--nx?lreb--nx??m-negnilr--nx?n-drojfvk--nx??y&7-ujdaehal--nx?8-antouvig--nx?b-&dlofrs--nx?goksmr--nx?kivryr--nx?retslj--nx??e-nejsom--nx?f-y&krajb--nx?re&dni--nx?tso--nx??stivk--nx??g-regark--nx?orf?ørf??z9-drojfstb--nx??b&25-akiivagael--nx?53ay7-olousech--nx?a&iy-gv--nx?le-tl&b--nx?s--nx??n0-ydr--nx??c&0-dnal-erdns--nx?z-netot-erts--nx??g&g-regnarav-rs--nx?o-nejssendnas--nx??ju-erdils-ertsy--nx?nj-dnalh-goksrua--nx?q&q-ladsmor-go-erm--nx.&ari-yreh--nx?ednas??s-neslahsladrjts--nx???ca&4s-atsaefrmmh--nx?8m-dnusynnrb--nx?il-tl--nx?le-slg--nx?n5-rdib--nx?op-drgl--nx?uw-ynnrb--nx??d&a&qx-tggrv--nx?reh!nnivk?sd&ork?ørk??uas??ts&e&bi?kkar?llyh?nnan??g&ort?ørt??k&alf?irderf??levev?mirg?obeg&ah?æh??r&ah?ejg????barm-jdddb--nx?ie!rah?s&etivk?ladman???lof&r&os?øs??ts&ev.ednas?o.relav?ø.relåv???n&a&l&-erd&n&os?øs??ron??adroh.so?dron.&a&g5-b--nx?ri-yreh--nx??ob?y&oreh?øreh??øb??e&m!lejh??pr&oj?øj??vi??gyb?n&aks?åks??o&h-goksrua?rf??r&o?ua?ø??tros?øh-goksrua??rts!e&devt?lab?mloh???s&ellil?naitsirk?rof???u&l!os??s!d&im?lejt??e&guah?l&a?å???kkoh?lavk?naitsirk?r&af?eg&e?ie???tef?y&onnorb?ønnørb?????r&a&blavs!.sg??g&eppo?la???o&j&f&a!dniv?k?vk??die?e&dnas?kkelf??llins?r&iel?ots??s&lab?t&ab?åb??yt??å!k??ævk??les??ts??åg&eppo?lå???ureksub.sen??e&ayb-yrettn--nx?d&ar?lom?r&of?øf??år??g&gyr?nats??i&meuv&ejsem&aan?åån??sekaal??rjea??j&d&ef?oks??les??k&er&aom?åom??hgna&ark?årk??iregnir?kot!s??s&ig?uaf???l&bmab?kyb?l&av?ehtats??oh??m&it?ojt?øjt??n&arg?g&os?øs??meh?reil?te?ummok?yrb??r&dils-erts&ev?y&o?ø???ua?vod??sa&ans?åns??t&robraa?spaav??urg??f&62ats-ugsrop--nx?a&10-ujvrekkhr--nx?7k-tajjrv-attm--nx??o!.sg?h??s!.sg??v!.sg???g&5aly-yr&n--nx?v--nx??a&llor?ve&gnal?lreb???n&av!snellu??org??oks&die?m&or?ør??ner&ol?øl??r&o?ø???r&eb!adnar?edyps?s&die?elf?gnok?n&ot?øt????obspras??uahatsla?åve&gnal?lreb???h&0alu-ysm--nx?7&4ay8-akiivagg--nx?5ay7-atkoulok--nx??a!.sg???i&e&hsr&agev?ågev??rf??k&h&avlaraeb?ávlaraeb??s??lm&a?å??mpouvtal&am?ám??pph&al?ál??rrounaddleid?ssaneve?ššáneve??j&0aoq-ysgv--nx?94bawh-akhojrk--nx??k&a&b&ord?ørd??jks?lleis??iv!aklejps?l&am?evs?u??mag?nel?ojg?r&a&l?n??epok?iel?y&or?ør???s&ah?kel?om??øjg??kabene?ojsarak?ram&deh.&aoq-relv--nx?rel&av?åv??so??e&let.&ag5-b--nx?ob?øb??ra???åjks??l&a!d&anrus?d&numurb?ron??e&gnard?nte?s&meh?sin??ttin??g&is?nyl??kro?l&em?l&ejfttah?of??u&ag-ertdim?s???n&am?era?gos?i&b?nroh?r??kos?nus?oj??o-&dron?r&os?øs???ppo?r&a!l?nram??e&gne?l?v??is?o&jts?ts??u&a-&dron?r&os?øs???h??å?æl?øjts??s&e&jg?nivk?ryf??kav?mor-go-er&om.&ednas?yoreh??øm.&ednas?yøreh???uag??t&las?rajh?suan??v&l&a?e-rots??u-go-eron??yt??ksedlig?res&a?å???bib&eklof?seklyf??es!dah??h!.sg??i&m?syrt??l&ejf?ov&etsua?gnit?ksa?sdie???n!.sg??o!.sg?boh?g?h??r!.sg??å!ksedlig??øboh??m&a&rah?vk??f!.sg??h!.sg??i&e&h&dnort?rtsua?ssej??rkrejb??ksa??ol?t!.sg??u&dom?esum?r&ab?drejg?evle?os?uh?æb?øs??ttals???n&a&g&av?okssman?åv??jlis?or?r&g?rev???e&d&do&sen?ton??lah?r&agy&o?ø??ojfsam???g&iets?n&a&l&as?lab??n&avk?ævk??t&arg?ddosen??v&al?essov???i&d&ol?øl??l&ar?ær???yl??reb??iks?k&srot?y&or?ør???l&a&d&gnos?n&er?ojm?øjm??om??tloh??ug?åtloh??mmard?ojs&om?sendnas??ppolg?s&lahsladr&ojts?øjts??o??t&o&l?t-erts&ev?o?ø???roh?øl??vly&kkys?nav??yam-naj!.sg??øjs&om?sendnas???g&orf?ujb??i&dnaort?vnarg??kob?ladendua?maherk&a?å??n&it?urgsrop??orf-&dron?r&os?øs???r&aieb?evats??sfev?uaks?yrts??o&6axi-ygvtsev--nx?c,d&ob?rav??ievs?kssouf?l&m&ob?øb??ous&adna?ech&ac?áč???so!.sg???msdeks?niekotuak?r&egark?olf?y&oso?øso???s&dav?mort???p&ed?p&akdron?elk???r&a&d&dj&ab?áb??iab??jtif?luag?mah?vsyt??e&gn&a&k&iel?ro??merb?n&at?mas??rav-r&os?øs??srop?talf?v&ats?el??y&oh?øh???ivsgnok??il?jkniets?k&a&nvej?rem?s&gnir?nellu???ie-er&den?v&o?ø???ram?sa?årem??la&jf?vh??m&b&ah?áh??mahellil??nnul?ts&l&oj?øj??ul??y&o?ø???imp&ah?áh??m!.sg??osir?t!.sg??ádiáb?ævsyt?øsir??s&adnil?en&dnas?e&dga?k&ri&b?k??som??ve??me&h?jg??nroh-go-ejve?s&a?ednil?k&o?ø??of?yt?å??tsev??gv?hf?igaval?o&r&or?ør??sman??so&fen&oh?øh??m?v??uh&lem?sreka.sen??å!dnil???t&a&baol?g&aov?grav??jjr&av-attam?áv-attám??l&a&b?s??ás??soum?ts?v&eib?our???e&dnaly&oh?øh??f?s&nyt?rokomsdeks?sen??vtpiks??in&aks?áks??loh&ar?år??n!.sg??o&m&a?å??psgolb,?s!.sg?efremmah?or?ør??terdi?á&baol?ggráv?lá&b?s??soum?veib???u&b!.sg?alk?e&dna?gnir?nner??les?ælk??dra&b?eb??g&nasrop?vi?ŋásrop??j&daehal&a?á??jedub?v&arekkhar?árekkhár???ksiouf?n&diaegadvoug?taed???v&irp?lesl&am?åm???y&b&essen?nart?sebel?tsev??o&d&ar?na!s??or??gavtsev?k&rajb?sa??lem?mrak?n&art?n&if?orb???r&a&mah?n?v??e&dni?t&so?ton??va??ul?yd??s&am?enner?gav?lrak?tivk??vrejks??ø&d&ar?na!s??ør??gåvtsev?k&rajb?sa??lem?mrak?n&art?n&if?ørb???r&e&dni?t&so?tøn??va??ul?yd?æ&n?v???s&enner?gåv?tivk?åm??vrejks???á&slág?tlá?vreiks??å&gåv?h?jddådåb?lf??ø&d&ob?rav??r&egark?olf??s&dav?mort????aki?i&sac?tal??u??o&b?f?g?hay?o?ttat??r!.&cer?erots?gro?m&o&c?n??rif?t?yn,?o&c,fni??pohs,stra?t&n?opsgolb,?www??e&a!.&a&ac?cgd?idem??bulc!orea??ci&ffartria?taborea??e&cn&a&l&lievrus-ria?ubma??netniam?rusni??erefnoc??gnahcxe?mordorea?ni&gne?lria?zagam??rawtfos??gni&d&art?ilg!arap?gnah???l&dnahdnuorg?ledom??noollab?retac?sael?t&lusnoc?uhcarap??vidyks??hcraeser?l&anruoj?euf?icnuoc?ortnoc!-ciffart-ria???n&gised?oi&nu?t&a&cifitrec?ercer?gi&tsevni-tnedicca?van??i&cossa!-regnessap??valivic??redef??cudorp?neverp-tnedicca????ograc?p&ihsnoipmahc?uorg!gnikrow???r&e&dart?enigne?korb?niart?trahc??o&htua?tacude???s&citsigol?e&civres?r??krow?serp!xe??tnega??t&farcr&ia?otor??hgil&f?orcim??liubemoh?n&atlusnoc?e&duts?m&esuma?n&iatretne?revog??piuqe????olip?ropria?si&lanruoj?tneics???w&erc?ohs??y&cnegreme?dobper?tefas????rref?z??p!.&a&aa?ca?pc??dem?ecartsnd.icb,gne?r&ab?uj??snduolc,t&acova?cca?hcer??wal?ysrab,???s!.&em?gro?hcs,moc?ten?ude?vog???t!.&116,ayo,gro?lim?moc?nayn,sulpnpv,t&cennockciuq.tcerid,en??ude?v&dr,og???o&hp?m?v?yk??tol?ua??v&iv?lov??xas?ykot??p&a&ehc?g?m?s??cj?eej?g!.&gro?ibom?moc?ossa?ppa,ten?ude???i&r!.nalc,?v?z??j!.&a&3&5xq6f--nx?xqi0ostn--nx??5wtb6--nx?85uwuu--nx?9xtlk--nx?bihc!.&a&bihciakoy?don?ma&him?ye&ragan?tat???r&a&bom?gan?hihci??u&agedos?kas?ustak???s&os?ufomihs??t&amihcay?iran??w&a&g&im&anah?o??omak??kihci?zustum??ihsak??y&agamak?imonihci???e&akas?nagot??i&azni?esohc?h&asa?s&abanuf?ohc???ka&to?zok??musi?orihs?r&akihabihsokoy?o&dim?tak??ukujuk??usihs??nano&hc?yk??o&d&iakustoy?ustam??hsonhot?k&a&rihs?t??iba??nihsaran?sobimanim?tas&arihsimao?imot??uhc?yihcay??u&kujno?s&ayaru?t&imik?tuf???zarasik????g&as!.&a&gas?m&a&tamah?yik??ihsak??rat?t&a&gatik?hatik??ira!ihsin????e&kaira?nimimak??i&akneg?g&aruyk?o??h&c&amo?uo??siorihs??kaznak?modukuf?ra&gonihsoy?mi???nezih?u&k&at?ohuok??s&ot?tarak?????ihs!.&a&kok?m&a&hagan?yirom??ihsakat??rabiam?wagoton??e&miharot?nokih??houyr?i&azaihsin?esok?kustakat?moihsagih??na&mihcahimo?nok??o&hsia?mag?t&asoyot?ok?tir???us&ay?t&asuk?o??????k&aso!.&a&d&awihsik?eki??k&a&noyot?s&akaayahihc?oihsagih???oadat?uziak??m&ayas!akaso??odak??r&a&bustam?wihsak??ediijuf??t&akarih?i&k?us???wag&ayen?odoyihsagih???e&son?tawanojihs??honim?i&akas?h&cugirom?s&ayabadnot?i&a&kat?t??n??oyimusihsagih???k&a&rabi?sim??ustakat??muzi?r&ijat?otamuk???nan&ak?n&ah?es???o&ay?n&a&ganihcawak?simuzi?tak??eba?ikibah?oyot??t&anim?iad?omamihs??uhc??ust&oimuzi?tes????ou&kuf!.&a&d&amay?eos??g&no?ok?usak??hiku?k&awayim?uzii??ma&kan?y&asih?im???rawak?t&a&gon?ka&h?num?t???umo??wa&g&a&kan?nay?t??ias??ko!rih???y&ihsa?usak???e&m&ay?uruk??taruk?us??i&a&nohs?raihcat??goruk?h&cukuf?s&a&gih?hukuy??in???k&a&gako?muzim??iust?o?ustani??m&anim?otihsoynihs?u??r&ogo?ugasas??usu??ne&siek?zu&b?kihc???o&gukihc?h&ak?ot?ukihc??j&ono?ukihc??kayim?nihsukihc?to?uhc??u&fiazad?gnihs?stoyot????zihs!.&a&bmetog?d&amihs?eijuf?ihsoy?omihs??kouzihs?mihsim?ra&biah?honikam??tawi?wa&g&ekak?ukik??kijuf??yimonijuf??i&a&ra?sok??hcamirom?juf?kaz&eamo?ustam??ma&nnak?ta??nukonuzi?orukuf??nohenawak?o&nosus?ti??u&stamamah?z&a&mun?wak??i!ay?i&hs&agih?in??manim??mihs????????m&a&tias!.&a&d&ihsoy?ot?usah??k&a&dih?sa??o&arihs?s???m&a&tias?y&as?o&rom?tah??ustamihsagih???i&hsagurust?jawak??uri??ni?wa&g&e&ko?man??ikot?o??k&ara?i&hsoy?mak???ru?zorokot??y&a&g&amuk?ihsok?otah??kuf??imo??ziin??e&bakusak?ogawak?sogo?ttas?zokoy??i&baraw?h&cugawak?s&oyim?ubustam???iroy?k&ato?ihs?u&k?stawi???m&akoyr?i&hsoy?juf??uziimak???naznar?o&dakas?ihsay?jnoh?n&a&go?nim??imijuf?nah?oy??r&ihsayim?otagan??t&asim!ak??igus?omatik??zak??u&bihcihc!ihsagih??sonuok?ynah????y&ak&aw!.&a&d&ira?notimak??kadih?ma&h&arihs?im??y&a&kaw?tik??oduk???ru&ustakihcan?y??sauy?wa&g&a&dira?zok??orih??konik??yok?zok??e&banat?dawi??i&garustak?jiat?mani??naniak?o&bog?nimik?t&asim?omihs&ah?uk????ugnihs???o!.&a&jos?koasak?m&ay&ako?ust??ihsayah??r&abi?ukawaihsin??wi&aka?nam???e&gakay?kaw??i&gan?h&cu&kasa?otes??sahakat??k&asim?ihsaruk??miin??n&anemuk?ezib??o&hsotas?jnihs?n&amat?imagak??ohs?uhcibik?????ot!.&a&damay?got?koakat?may&etat?ot??nahoj?riat?waki&inakan?reman???eb&ayo?oruk??i&h&asa?ciimak?sahanuf??kuzanu?m&an&i?ot??ih???nezuyn?otnan?u&hcuf?stimukuf?z&imi?ou???????ihs&o&gak!.&a&m&ayuok?ihsogak??si?yonak??e&banawak?n&at&akan?imanim??uka??tomoonihsin??i&adnesamustas?k&azarukam?oih??m&ama?uzi??usuy??nesi?o&knik?os?tomustam??uzimurat???rih!.&a&ka&n?s??m&ayukuf?i&hsorihihsagih?j&ate?imakikaso????r&a&bohs?h&ekat?im???es??tiak?wiad??e&kato?ruk??i&h&ci&akustah?mono?nihs??s&inares?oyim???manimasa?uk??negokikesnij?o&gnoh?namuk??uhcuf????uk&ot!.&a&bihci?mi&hsu&kot?stamok??m??wagakan??egihsustam?i&gum?h&coganas?soyim??kijaw?m&anim?uzia??ukihsihs??nan&a?iak??o&nati?turan????uf!.&a&batuf?m&a&to?y&enak?irok???ihs&im?ukuf??os?uko??r&aboihsatik?uganat??ta&katik?mawak?rih??w&a&g&akus?emas?uy??k&a&mat?rihs?sa??ihsi??nah??ohs???e&gnabuzia?iman?ta&d?tii???i&adnab?enet?hs&agih?iimagak??k&a&wi?zimuzi??ubay??minuk?r&ook?ustamay???nihsiat?o&g&etomo?ihsin?nan?omihs??no!duruf?rih??rihsawani?ta&may?simuzia???u&rahim?stamakawuzia?zia&ihsin?nay???????nug!.&a&bawak?doyihc?k&anna?oi&hsoy?juf?mot???m&ayakat?ustagaihsagih??n&ihsatak?nak??r&ahonagan?nak?o?u&kati?mamat???t&amun?inomihs?o??w&akubihs?iem?ohs???i&hsa&beam?yabetat??kas&akat?esi??m&akanim?uzio??ogamust?rodim??o&jonakan?n&eu?oyikust??tnihs??u&komnan?stasuk?yrik?????ran!.&a&bihsak?d&akatotamay?u!o???guraki?m&ay&atik&imak?omihs??irokotamay??oki??ra&hihsak?n??wa&geson?knet???e&kayim?ozamay?sog?ustim??i&a&rukas?wak??garustak?h&ciomihs?sinawak??jo?ka&mnak?toruk??makawak?nos?r&net?otakat?ugeh???o&d&na?oyo??gnas?jnihs?nihsoy!ihsagih??tomarawat?yrok????t&ag&amay!.&a&dihsio?k&atarihs?ourust??may&a&kan?rum??enak?onimak??rukho?ta&ga&may?nuf??hakat?kas??wa&g&ekas?orumam??ki&hsin?m??z&anabo?enoy?ot???zuy??e&agas?bonamay?dii?nihsagih?o??i&a&gan?nohs??h&asa?sinawak??nugo??o&dnet?jnihs?ynan??ukohak???iin!.&a&ga?k&ium?oagan??munou!imanim??t&a&bihs?giin??ioy??w&a&gioti?kikes?zuy??irak??yijo??e&kustim?mabust??i&aniat?hcamakot?kaz&awihsak?omuzi??m&a&gat?karum??o???n&anust?esog??o&das?ihcot?jnas?k&ihay?oym??mak?naga?ries??u&ories?steoj?????i&ka!.&a&go?k&asok?oimak??t&ago!rihcah??ika!atik???w&aki?oyk???e&mojog?natim?suranihsagih?t&ado?okoy???i&hsoyirom?magatak?naokimak??nesiad?o&hakin?jnoh!iruy??nuzak?rihson?tasi&juf?m??yjnoh??u&kobmes?oppah????o!.&a&dakatognub?m&asah?ihsemih??su?t&ekat?i&h?o????e&onokok?ustimak??i&jih?k&asinuk?ias?usu??mukust??onoognub?u&fuy?juk?ppeb?suk??????wa&ga&k!.&a&mihsoan?rihotok?waga&kihsagih?ya???emaguram?i&j&nonak?ustnez??kunas?monihcu??o&hsonot?nnam?yotim??u&st&amakat?odat??zatu????nak!.&a&dustam?kus&okoy?tarih??maz?nibe?r&a&gihsaimanim?h&esi?imagas??wa&do?guy???u&im?kamak???tikamay?wa&k&ia?oyik?umas??sijuf??yimonin??e&nokah?saya??i&akan?esiak?gusta?hsuz?kasagihc?o?ukust??o&nadah?sio?tamay?????kihsi!.&a&danihcu?gak?kihs?mijaw?t&abust?ikawak??wazanak??i&gurust?hcionon?mon?ukah??nasukah?o&anan?ton!akan???u&kohak?stamok?z&imana?us?????niko!.&a&han?m&arat?ijemuk?uru??n&e&dak?zi??no??ra&hihsin?rih??wa&kihsi?niko??yehi?zonig??e&osaru?seay??i&hsagih?jomihs?k&a&gihsi?not??ihsakot??m&a&ginuk?kihsug?maz??igo?otekat??nuga!noy???n&a&moti?timoy?wonig??i&jikan?k???o&gan?jnan?tiad&atik?imanim???u&botom?kusug&akan!atik??imot??rab&anoy?eah???????c&204ugv--nx?462a0t7--nx?678z7vq5d--nx?94ptr5--nx?a??d&17sql1--nx?3thr--nx?5&20xbz--nx?40sj5--nx??7&87tlk--nx?ptlk--nx??861ti4--nx?a?e??e&16thr--nx?5&1a4m2--nx?9ny7k--nx??im!.&a&bot?k&asustam?uzus??m&a&him?y&emak?im???ihs??nawuk?wi&em?k???e&bani?ogawak?si!imanim???i&arataw?gusim?h&asa?ciakkoy??k&a&mat?sosik?t??iat??raban??o&dat?hik?n&amuk?ihseru?o&du?mok????ust???mihe!.&a&m&a&h&ataway?iin??yustam??ij&awu?imak???taki!man???ebot?i&anoh?kasam?rabami??n&ania?egokamuk?oot??o&jias?kihcu?nustam?uhcukokihs?yi!es???u&kohik?zo????n!.&nriheg,teniesa.resu,?amihs!.&a&d&amah?ho?usam??kustay?m&a?ihsoni&hsin?ko???wakih??e&namihs?ustam??i&g&aka?usay??konikak?mikih??nannu?o&mu&kay?zi!ihsagih?uko???nawust?tasim??u&stog?yamat?????tawi!.&a&bahay?d&amay?on??koirom?t&a&honat?katnezukir??imus??w&as&ijuf?uzim??ihs???e&hon&i&hci?n??uk??tawi??i&a&duf?murak?wak??h&custo?si&amak?ukuzihs???j&oboj?uk??k&a&m&anah?uzuk??sagenak??esonihci??m&akatik?uzia&rih?wi????o&kayim?no&rih?t??tanufo??uhso????g&3zsiu--nx?71qstn--nx?l??h&03pv23--nx?13ynr--nx?22tsiu--nx?61qqle--nx??i&54urkm--nx?g&ayim!.&a&dukak?m&a&goihs?kihs??ihsustam!ihsagih??unawi??r&awago?iho??ta&bihs?rum??w&a&gano?kuruf??iat??y&imot?ukaw???e&mot?nimes??i&hsiorihs?ka&monihsi?s&awak?o???mak?r&ataw?o&muram?tan????o&az?jagat?t&asim?omamay???u&fir?k&irnasimanim?uhsakihcihs?????ihcot!.&a&g&a&h?kihsa??ust??kom?m&ay&o?usarak??unak??r&a&boihsusan?watho??iho?ukas??t&akihsin?iay??wa&konimak?zenakat??y&imonustu?oihs???e&iiju?kustomihs?nufawi??i&akihci?g&etom?ihcot?on???o&k&ihsam?kin??nas?sioruk?tab??u&bim?san?????h&c&ia!.&a&dnah?m&a!h&akat?im??yuni??ihs&ibot?ust???r&a&hat?tihs??ik?u&ihsagih?kawi???t&ihc?o&k?yot???wa&koyot?zani??yi&monihci?rak???e&inak?k&aoyot?usa??manokot?noyot??i&a&gusak?kot?sia??eot?h&asairawo?cugo?s&ahoyot?oyim???k&a&mok?zako??ihssi??motay?rogamag??n&an&ikeh?ok??ihssin??o&got?ihsin?jna?rihsnihs?suf?tes??u&bo?raho?s&oyik?takihs??yrihc?zah????ok!.&a&dusay?kadih?mayotom?r&ah&im?usuy??umakan??sot!ihsin??wa&g&atik?odoyin??k&as?o????i&esieg?hco!k??jamu?k&a!sus??usto??ma&gak?k??rahan??o&mukus?n&i?ust!ihsagih???torum?yot!o???u&koknan?zimihsasot????ugamay!.&a&m&ayukot?ihso??toyot??e&bu?subat??i&gah?kesonomihs?nukawi?rakih??nanuhs?otagan?u&ba?foh?otim?stamaduk?uy?????sanamay!.&a&dihsoyijuf?mayabat?r&ahoneu?ustakihsin??w&a&k&ayah?ijuf??suran??ohs???egusok?i&ak?h&cimakan?s&anamay?od???k&asarin?u&feuf?sto????o&k&akanamay?ihcugawakijuf??nihso?t&asimawakihci?ukoh??uhc??spla-imanim?u&b&nan?onim??fok?hsok?rust?????ka&rabi!.&a&bukust?gok?kan!ihcatih??m&a&sak?timo?wi??ihsak?ustomihs??ni?r&a&hihcu?way??u&agimusak?ihcust???t&ag&amay?eman??oihcatih??w&ag&arukas?o??os??yi&moihcatih?rom???e&bomot?dirot?not?tadomihs??i&a&k&as?ot??rao??esukihc?gahakat?h&asa?catih??k&a&rabi?saguyr??ihsani?uy??ma?rukustamat??o&dnab?giad?him?kati?rihsijuf?soj?t&asorihs?im??yihcay??u&fius?kihsu?simak????sagan!.&a&m&abo?ihsust??natawak?r&abamihs?u&mo?ustam???wijihc?yahasi??i&akias?hies?k&asagan?i??masah??neznu?o&besas?darih?t&eso?og!imaknihs????ust&igot?onihcuk?uf????zayim!.&a&biihs?guyh?k&oebon?ustorom??mihsuk?r&emihsin?uatik??ta&katik?mim??wag&atik?odak??ya??e&banakat?sakog??i&hsayabok?kaza&kat?yim??m&animawak?ot&inuk?nihs????nanihcin?o&j&ik?onokayim??n&ibe?ust??tias??urahakat????ro&moa!.&a&dawot?turust?wasim??e&hon&ihc&ah?ihs??nas?og?ukor??sario??i&anarih?ganayati?hsioruk?jehon?kasorih?makihsah?nawo?r&amodakan?omoa???o&gnihs?kkat??u&ragust?stum????ttot!.&a&r&ahawak?uotok??sa&kaw?sim???egok?irottot?nanihcin?o&ganoy?nih?tanimiakas??u&bnan?z&ay?ihc??????ukuf!.&a&deki?gurust?ma&bo?h&akat?im??yustak??sakaw??eabas?i&akas?ho?jiehie?ukuf??nezihce!imanim??ono????k&26rtl8--nx?4&3qtr5--nx?ytjd--nx??522tin--nx?797ti4--nx??l33ussp--nx?m&11tqqq--nx?41s3c--nx??n&30sql1--nx?65zqhe--nx?n7p7qrt0--nx??o&131rot--nx?7qrbk--nx?c?diakkoh!.&a&deki?gakihset?hcebihs?k&adih?u&fib?narihs???m&ayiruk?hot?ihs&orihatik?ukuf??oras?usta??r&ib&a!ka??o?uruf??ozo?u&gakihsagih?oyot???sakim?ta&gikust?mun??w&a&ga&k&an?uf??nus!imak???k&aru?i&h&asa?sagih??kat?mak??omihs?um??zimawi??ine?oyk??yot??e&a&mustam?nan??b&a&kihs?yak??o&noroh?to???ian?k&ihsam?ufoto??nakami?ppoko!ihsin??sotihc?tad!okah??uonikat??i&a&bib?mokamot?n&a&k&kaw?oroh??wi??eomak?ihsatu?okik?usta&moruk?sakan????eib?h&c&ioy?u&bmek?irihs???s&ase?ekka?oknar?uesom???jufirihsir?k&amamihs?i&at?n???m&atik?otoyot??oa&kihs?rihs??r&a&hs?kihsi?mot??ihs&aba?ir??otarib???n&a&hctuk?rorum?se?tokahs??uber??o&kayot?m&ire?ukay??naruf!ima&k?nim???orih?r&ih&ibo?suk??o&bah?h&i&b?hsimak??sa??pnan?yan??umen??t&asoyik?eko?ukoh???u&bassa?kotnihs?m&assaw?uo??pp&akiin?en&ioto?nuk??ip??rato?s&akat?t&eb&e?i&a?hs!a??robon??m&e?o&m?takan???no&h?tamah??o&mik?s?t??u&kir?ppihc?st???onihsnihs?ufuras??uaru??yru!koh??zimihs!ok?????g!oyh!.&a&bmat?dnas?gusak?k&at?o&oyot?y??uzarakat??m&ayasas?irah??wa&g&ani?okak??k&i&hci?mak??oy???yi&hsa?monihsin???i&asak?hs&aka?i&at?nawak???j&awa!imanim??emih??k&a&goa?s&agama?ukuf??wihsin??i&hsog?m???mati?oia?rogimak??n&annas?esnonihs??o&gasa!kat??ka?n&ikat?o?ustat??rihsay?sihs?tomus?yas??u&bay?gnihs?????nagan!.&a&bukah?d&a&w?yim??e&ki?u??ii??k&a&s&ay?uki??zus??ihsoo?ousay??m&ay&akat?ii??i&hsukufosik?jii??ukihc??n&i!hsetat??uzii??r&ah?ugot??saim?t&agamay?oyim??w&a&g&a&kan?n??o??kustam?ziurak??onim!imanim??u&koo?s!omihs????ya&ko?rih???e&akas?nagamok?subo??i&gakat?h&asa?c&a!mo!nanihs???uonamay??sukagot??k&a&kas?mimanim?to??ia&atik?imanim??oa?uzihcom??m&akawak?ijuf?o!t???r&ato?ijoihs?omakat???n&ana?esnoawazon??o&hukas?n&a&gan?kan??i&hc?muza??ustat??romok?si&gan?k??tomustam??u&k&as?ohukihc??stamega????to&mamuk!.&a&gamay?rahihsin?sukama!imak??tamanim??enufim?i&hcukik?k&ihsam?u??nugo!imanim??romakat??o&ara?rihsustay?sa?t&amay?om&amuk?us??u!koyg???yohc??u&sagan?zo????yk!.&a&bmatoyk?k&ies?oemak?uzaw??mayi&h&cukuf?sagih??muk??nihsamay?rawatiju?t&away?ik???e&ba&nat!oyk??ya??di?ni??i&ju?kazamayo?manim??natnan?o&gnatoyk?kum?mak?rihsamayimanim?y&gakan?ka&koagan?s??oj???u&ruziam?z&ayim?ik??????wtc1--nx?ykot!.&a&d&i&hcam?mus??oyihc??k&atim?ihsustak??m&a&t!uko??yarumihsa&gih?sum???i&hs&agoa?ika?o!t??uzuok??ren???r&a&honih?wasago??iadok?umah??ssuf?t&ik?o??wa&g&anihs?ode??k&ara?ihcat???y&agates?ubihs???e&amok?donih?m&o?urukihsagih??soyik??i&enagok?gani?h&ca&da?tinuk??sabati??j&nubukok?oihcah??manigus??o&huzim?jihcah?n&akan?ih!sasum??urika??rugem?t&a&mayihsagih?nim??iat?ok??uhc?yknub??u&fohc?hcuf?kujnihs?????r&2xro6--nx?g?o??s&9nvfe--nx?xvp4--nx??t&netnocresu,opsgolb,?u&4rvp8--nx?fig!.&a&d&eki?ih??kimot?m&ayakat?ihsah??ne?raha&gi&kes?makak??sak??taga&may?tik??wa&g&ibi?ustakan??karihs!ihsagih????e&katim?uawak??i&gohakas?hc&apna?uonaw??k&ago?es?ot??m&anuzim?ijat??nak?urat??nanig?o&dog?jug?makonim?nim?roy?sihcih??u&fig?s&otom?t&amasak?oay???????x5ytlk--nx?yu6d27srjd--nx?z72thr--nx?井福?京東?分大?取鳥?口山?城&宮?茨??媛愛?山&富?岡?歌和??岡&福?静??島&児鹿?広?徳?福??崎&宮?長??川&奈神?石?香??庫兵?形山?手岩?木栃?本熊?根島?梨山?森青?潟新?玉埼?田秋?知&愛?高??縄沖?良奈?葉千?賀&佐?滋??道海北?都京?重三?野長?阜岐?阪大?馬群???k!.&art?gro?moc?per?ude?vog???l&eh?l??m!ac?j??nd?o&g?h&pih?s!.ysrab,??lnud?oc?t!.&lldtn,snd-won,???pa!.&0mroftalp,arusah,bew,enilnigol,lecrev,nur:.a,,t&ibelet,xenw,?yfilten,??ra&a?hs??u&ekam?llag?org!.esruocsid,cts?kouk?nayalo???vsr?xece4ibgm--nx??q&a!3a9y--nx??g?i!.&gro?lim?moc?ten?ude?vog???m?se??r&a!.&acisum?bog?gro?lim?moc!.topsgolb,?rut?t&en?ni??ude?vog??4d5a4prebgm--nx?b?c?eydoog?los?t&at?s!uen???ugaj??b!.&21g?a&b&a&coros?iuc??itiruc??cnogoas?dicerapa?gniram?i&naiog?ramatnas??n&erom?irdnol??op?p&acam?irolf?ma&j?s???rief?tsivaob??b!aj?ib?mi?sb??c&ba?e&r?t??js?sp?t!e???d&em?mb?n&f?i??rt??e&dnarganipmac?ficer?ht?llivnioj?rdnaotnas??f&dj?ed?gg?n&e?i???g&e&l!.&a&b,m,p,?bp,c&a,s,?e&c,p,s,?fd,gm,ip,jr,la,ma,nr,o&g,r,t,?p&a,s,?r&p,r,?s&e,m,r,?tm,??s??l&s?z??n&c?e?o??ol!b?f?v??pp?ro??hvp?i&du?kiw?nana?oretin?r&c?eurab??sp?te?xat??l&at&an?rof??el?im?sq??m&a?da?e&gatnoc?leb??f?ic?oc!.topsgolb,??nce?o&ariebir?c&e?narboir?saso??d&o?ranreboas??e&g?t??i&b?dar?ecam?r??rp?t&a?erpoir???p&er?m!e?t??ooc?pa?se??qra?r&af?ga?o&davlas?j??tn?ut??s&a&ixac?mlap?nipmac??ed?u&anam?j?m???t&am?e&d?n?v??nc?o&f?n??ra?sf??u&caug9?de?ja?rg??v&da?ed?og!.&a&b?m?p??bp?c&a?s??e&c?p?s??fd?gm?ip?jr?la?ma?nr?o&g?r?t??p&a?s??r&p?r??s&e?m?r??tm???rs?t??xiv?z&hb?ls?o&c?f?????c!.&as?ca?de?if?o&c?g??ro???e&bew?ccos?dnik?e&b?n&igne?oip??rac??gni&arg?rheob??h&cor?sok?t&aew?orb???itnorf?k&col?o&p?rb???l&aed?ffeahcs??mal?nes?pinuj?t&a&eht?rebsnegömrev??law?nec?s&acnal?nom?ubkcolb??upmoc??v&o&c&sid?tfiws??rdnal??resbo??wulksretlow?ywal?zifp??f!.&aterg?bew-no,drp?e&c&itsuj-reissiuh?narf-ne-setsitned-sneigrurihc,?rianiretev??i&cc?rgabmahc??m&o&c?n??t??n&eicamrahp?icedem??ossa?s&e&lbatpmoc-strepxe?riaton?tsitned-sneigrurihc?uova??o&-x&bf,obeerf,?x&bf,obeerf,???t&acova?o&or-ne,psgolb,?r&epxe-ertemoeg?op!orea????vuog??avc7ylqbgm--nx?s??g!.&gro?m&oc?yn,?t&en?opsgolb,?ude?vog???h!.&e&erf,man??mo&c?rf??topsgolb,zi??ur??i!.&a&61f4a3abgm--nx?rf4a3abgm--nx??ca?di?gro?hcs?oc?ten?vog?نار&يا?یا???a&h?per??ew?lf??k!.&c&a?s??e&n?p?r??gk?iggnoeyg?kub&gn&oeyg?uhc??noej??l&im?uoes??man&gn&oeyg?uhc??noej??n&as&lu?ub??o&e&hcni?jead??wgnag???o&c?g??ro?s&e?h?m??topsgolb,u&gead?j&ej?gnawg????cilf??l!.&gro?moc?ten?ude?vog???m!.&topsgolb,vog???n!.&gro?moc?ofni?ten?ude?vog?zib???o&htua?odtnorf?t&c&a?od??laer???p!.&alsi?ca?eman?forp?gro?moc?o&fni?rp??t&en?se??ude?vog?zib???s?t!.&21k?bew?cn!.vog??eman?gro?kst?l&e&b?t??im?op??moc!.topsgolb,?neg?ofni?pek?rd?sbb?ten?ude?v&a?og?t??zib??f?m??ubad?vd??s&8sqif--nx?9zqif--nx?a!.vog?birappnb?gev?lliv?mtsirhc?s??b!.&ew,gro?moc?ten?ude?vog??c?oj?s?u??c&i&hparg?p?t&sigolyrrek?ylana???od??d&a?d?l?n&iwriaf?omaid??oogemoh?rac??e!.&bog?gro?mo&c!.topsgolb,?n??ude??civres!.enilnigol,?d&d2bgm--nx?oc??h&ctaw?guh??i&lppus?rtsudni?treporp!yrrek???jaiv?l&aw?cycrotom?etoh?gnis?pats??m&ag?oh?reh??nut?ohs?picer?r&it?ut&cip!.7331,?nev???s!i&rpretne?urc??ruoc??taicossa?vig??g!nidloh??h5c822qif--nx?i!.&ekacpuc,gro?moc?t&en?ni?opsgolb,?ude?vog??a09--nx?nnet?rap?targ??k&c&or!.&ecapsbew,snddym,ytic-amil,??us??hxda08--nx?row??l!.&c&a?s??ed,gro?o&c?fni??ten?ude?vog?zib??a&ed?tner??e&ssurb?toh!yrrek???lahsram?m?oot??m!.&bal,gro?moc?ten?ude?vog??b?etsys!.tniopthgink,?ialc??n&a&f?gorf?ol??egassap?i&a&grab?mod??giro??o&it&acav?cudorp?ulos??puoc???o&dnoc?geuj?leuv?ppaz?t&ohp?ua???p!.&ces?gro?moc?olp?ten?ude?vog??i&hsralohcs?lihp?t??u??r!.&au,ca?gro?mon,ni?oc?topsgolb,ude?vog?xo,?a&c?p?tiug??c?e&dliub?erac?gor?levart?mraf?n&niw?trap??wolf??ot&cartnoc?omatat??pj?uot??s!.&gro?moc?ten?ude?vog?zib??alg?e&n&isub!.oc,?tif??rp!xe!nacirema???xnal??iws??t&a&e&b?ytic??ob??ek&cit?ram??fig?h&cay?gilf??n&atnuocca?e&mt&rapa?sevni??ve!.oc,???rap??u!.&a&c!.&21k?bil?cc???g!.&21k?bil?cc???i!.&21k?bil?cc???l!.&21k?bil?cc???m!.&21k!.&hcorap?rthc?tvp???bil?cc???p!.&21k?bil?cc???si?v!.&21k?bil?cc???w!.&21k?bil?cc????c&d!.&21k?bil?cc???n!.&21k?bil?cc???s!.&21k?bil?cc????d&ef?i!.&21k?bil?cc???m!.&21k?bil?cc???n!.&bil?cc???s!.&bil?cc???urd,?e&d!.&21k?bil,cc???las-4-&dnal,ffuts,?m!.&21k?bil?cc???n!.&21k?bil?cc????h&n!.&21k?bil?cc???o!.&21k?bil?cc????i&h!.&bil?cc???m!.&21k?bil?c&c?et??goc?n&eg?otae??robra-nna?sum?tsd?wanethsaw???nd?r!.&bil?cc???v!.&21k?bil?cc???w!.&21k?bil?cc????jn!.&21k?bil?cc???k&a!.&21k?bil?cc???o!.&21k?bil?cc????l&a!.&21k?bil?cc???f!.&21k?bil?cc???i!.&21k?bil?cc????mn!.&21k?bil?cc???n&afflog,i!.&21k?bil?cc???m!.&21k?bil?cc???sn?t!.&21k?bil?cc????o&c!.&21k?bil?cc???m!.&21k?bil?cc???ttniop,?p&ion,rettalp,?r&a!.&21k?bil?cc???o!.&21k?bil?cc???p!.&21k?bil?cc????s&a!.&21k?bil?cc???dik?k!.&21k?bil?cc???m!.&21k?bil?cc???nd&deerf,uolc,??t&c!.&21k?bil?cc???m!.&21k?bil?cc???u!.&21k?bil?cc???v!.&21k?bil?cc????ug!.&21k?bil?cc???v&n!.&21k?bil?cc???w!.cc???x&ohparg,t!.&21k?bil?cc????y&b-si,k!.&21k?bil?cc???n!.&21k?bil?cc???w!.&21k?bil?cc????za!.&21k?bil?cc????ah!uab??bria?col?e!.ytrap.resu,?ineserf?lp?xe&l?n???vt?w!.&66duolc,gro?moc?s&ndnyd,tepym,?ten?ude?vog??a?e&iver?n??odniw??y&alcrab?cam?ot???t&0srzc--nx?a!.&amil4,ca!.hts??gni&liamerutuf,tsoherutuf,?o&c!.topsgolb,?fni,?ph21,r&euefknuf.neiw,o??v&g?irp,?xi2,ytic-amil,zib,?c?e!s??hc?if?l!asite??mami?rcomed??b!.&gro?moc?ten?ude?vog??b?gl??c&atnoc?e&les?rid!txen????dimhcs?e!.&eman?gro?moc?ofni?ten?ude?vog?zib??b?em?grat?id?k&circ?ram??n!.&0&002cilc,rab,?1rab,2rab,5inu,6vnyd,7&7ndc.r,erauqs,?a&l&-morf,moob,?minifed,remacytirucesym,tadsyawla,z,?b&boi,g,lyltsaf:.pam,,?c&inagro-gnitae,paidemym,?d&ecalpb,nab-eht-ni,uolc&meaeboda,nievas.citsalej,xednay:.e&garots,tisbew,?,??e&cnarusnihtlaehezitavirp,gdirbtib,ht-no-eciffo,l&acsnoom,ibom-eruza,?m&ecnuob,ohtanyd,tcerider,?nozdop,rehurht,s,tis-repparcs,zamkcar,?f&aeletis,crs.&cos,resu,?ehc-a-si,?g&ni&reesnes,tsohnnylf,?olbevres,?k&eeg-a&-si,si,?u,?l&acolottad,iamwt,s&d-ni,s-77ndc,??m&ac&asac,ih,?urofniem,?n&a&f&agp,lhn,?ibed,?dcduabkcalb,i,pv-ni,?o&c-morf,jodsnd,rp-ytinummoc,ttadym,?p&i&-&etsef,on,?emoh,fles,nwo,?j,mac-dnab-ta,o&-oidar-mah,hbew,?pa&duolc,egde,?tfe&moh,vres,?usnd,?r&e&tsulcyduolc,vres-xnk,?vdslennahc:.u,,?s&a&ila&nyd,snd,?nymsd,?bbevres,dylimaf,e&suohsyub,t&isbeweruza,ys,??kekokohcs,n&d&-won,d,golb,npv,?oitcnufduolc,?s&a-skcik,ecca&-citats,duolc,???t&adies,ceffeym,e&nretnifodne,smem,?farcenimevres,i-&ekorb,s&eod,lles,teg,??n&essidym,orfduolc,?r0p3l3t,s&ixetnod,ohgnik,??u&h,nyd,r,?x&inuemoh,spym,tsale.1ots-slj,unilemoh,?y&awetag-llawerif,ffijduolc,ltsaf.&dorp.&a,labolg,?lss.&a,b,labolg,?pam,slteerf,?n&-morf,ofipi,?srab,tieduolc,?z&a-morf,tirfym,???p?tcip?v??f&ig?o&l?sorcim???g!.&bog?dni?ed,g&olb,ro??lim?mo&c?n,?ot,ten?ude???h!.&dem?gro?l&er?op??m&oc?rif??o&fni?rp?s&rep?sa???po&hs?oc??t&en?luda?ra??ude?vuog???i!.&a&2n-loritds--nx?7e-etsoaellav--nx?8&c-aneseclrof--nx?i-lrofanesec--nx??at?b?c!cul??dv?i&blo&-oipmet?oipmet??cserb?drabmol?g&gof?urep??l&gup?i&cis?me&-oigger?oigger???uig&-&aizenev&-iluirf?iluirf??ev&-iluirf?iluirf??v&-iluirf?iluirf???aizenev&-iluirf?iluirf??ev&-iluirf?iluirf??v&-iluirf?iluirf????n&a&brev?cul?pmac?tac??idras?obrac&-saiselgi?saiselgi??resi??otsip?r&b&alac!-oigger?oigger??mu??dna&-&attelrab-inart?inart-attelrab??attelrabinart?inartattelrab?ssela??epmi?ugil??tnelav&-obiv?obiv??vap?z&e&nev?ps&-al?al???irog???l&iuqa!l??leib??m&or?rap??n!acsot?e&dom?is?sec&-&ilrof?ìlrof??ilrof?ìlrof???g&amor&-ailime?ailime??edras?olob??i&ssem?tal??ne!var??o&cna?merc?rev?vas???oneg?p?r!a&csep?rr&ac&-assam?assam??ef??von??etam?tsailgo!-lled?lled???s!ip?sam&-ararrac?ararrac??u&caris?gar???t!a&cilisab?recam??resac?soa!-&d&-&ellav?lav??ellav?lav??ellav??d&-&ellav?lav??ellav?lav??ellav??te&lrab&-&airdna-inart?inart-airdna??airdnainart?inartairdna??ssinatlac???udap?v!o&dap?neg?tnam???zn&airb&-a&lled-e-aznom?znom??a&lledeaznom?znom??eaznom??e&c&aip?iv??soc?top??om???b&-&23,46,61,?3c-lorit-ds-onitnert--nx?be-etsoa&-ellav--nx?dellav--nx??c!f-anesec-lrof--nx?m-lrof-anesec--nx??he-etsoa-d-ellav--nx?m!u??o2-loritds-nezob--nx?sn-loritds&-nasl&ab--nx?ub--nx??nitnert--nx??v!6-lorit-dsnitnert--nx?7-loritds&-nitnert--nx?onitnert--nx???z&r-lorit-ds&-nitnert--nx?onitnert--nx??s-loritds-onitnert--nx???c&f?is?l?m?p?r?v??d&p?u!olcnys,??e&c!cel?inev?nerolf??f?g!ida&-&a&-onitnert?onitnert??otla!-onitnert?onitnert???a&-onitnert?onitnert??otla!-on&azlob?itnert??onitnert????hcram?l?m!or??n&idu?o&n&edrop?isorf??torc???p?r?s&erav?ilom??t!nomeip?s&eirt?oa!-&d-e&ellav?éllav??e&ellav?éllav???de&ellav?éllav??e&ellav?éllav?????v?znerif??g&a?b?f?il?o?p?r?up?vf??hc?i&b?c?dol?f?l!lecrev?opan?rof&-anesec?anesec???m?n&a&part?rt&-attelrab-airdna?attelrabairdna???imir?ret??p?r!a&b?ilgac?ssas???s!idnirb??t&ei&hc?r??sa??v??l&a!c??b?c?o&m?rit&-&d&eus&-&nitnert?onitnert??nitnert?onitnert??us&-&nitnert?onitnert??nitnert?onitnert??üs&-&nitnert?onitnert??nitnert?onitnert???s&-onitnert?onitnert???d&eus!-&n&asl&ab?ub??ezob?itnert??onitnert??nitnert?onitnert??us&-&n&asl&ab?ub??ezob?itnert??onitnert??nitnert?onitnert??üs!-&n&asl&ab?ub??ezob?itnert??onitnert??nitnert?onitnert???s&-onitnert?onitnert?????m&ac?f?i?ol?r??n&a!lim?sl&ab?ub???b?c?e!v?zob??irut?m!p??p?r?t??o&a!v??b!retiv??c!cel??enuc?g!ivor??i&dem&-onadipmac?onadipmac??pmet&-aiblo?aiblo??rdnos?zal??l?m!a&greb?ret??oc?re&f?lap???n!a&dipmac&-oidem?oidem??lim?tsiro?zlob??ecip&-ilocsa?ilocsa??i&bru&-orasep?orasep??lleva?rot?tnert??r&elas?ovil??ulleb??p?r!a&sep&-onibru?onibru??znatac??oun??s!ivert?sabopmac??t!arp?e&nev?ssorg??n&arat?e&girga?rt?veneb????zz&era?urba???p&a?s?t??qa?r&a!m?s??b!a??c?f?g?k?me?o?p?s?t?v??s&a&b?iselgi&-ainobrac?ainobrac???b?c?elpan?i?m?ot?s?t?v??t&a?b?c?l?m?nomdeip?o!psgolb,?p?v??u&de?l?n?p??v&a?og?p?s?t?v??y&drabmol?ellav&-atsoa?atsoa??licis?nacsut??z&al?b?c?p??ìlrof&-anesec?anesec???derc?er?f!.sulptp,?m!r??utni??je3a3abgm--nx?kh?l!.&myn,topsgolb,vog??uda??m!.&gro?moc!.topsgolb,?ten?ude???n&a&morockivdnas?ruatser?tnuocca??e&g?m&eganam!.retuor,?piuqe??r??i!.ue?m?opdlog??opud?uocsid??o&b?cs!.vog,?d?g?h?j?oferab?p&edemoh?s???p!.&emon?gro?lbup?m&oc?yn,?t&en?ni?opsgolb,?ude?vog???r&a!m&law?s???epxe?op&er?pus!.ysrab,?s???s!.&adaxiabme?e&motoas?picnirp?rots??gro?lim?mo&c?n,?o&c?dalusnoc?hon,?ten?ude?vog??a&cmoc?f??e&b?padub?r?uq??i!rolf?tned??o&h!.&duolc&p,rim,?e&lej,tiseerf,?flah,s&pvtsaf,seccaduolc,?tsafym,??p!sua???urt??t!.&eman?gro?ibom?levart?m&oc?uesum??o&c?fni?r&ea?p???pooc?sboj?t&en?ni??ude?vog?zib??ayh?n?o!bba?irram???uognah?xen?y?ztej??u&2&5te9--nx?yssp--nx??a!.&a&s?w??civ?d&i?lq??fnoc?gro?moc!.topsgolb,?nsa?ofni?sat?t&ca?en?n??ude!.&a&s?w??ci&lohtac?v??dlq?sat?t&ca?n??wsn!.sloohcs????vog!.&a&s?w??civ?dlq?sat???wsn?zo??ti??c!.&fni?gro?moc?ten?ude?vog??i??d&e!.tir.segap-tig,?iab??e!.&dcym,enozgniebllew,noitatsksid,odagod.citsalej,snd&ps,uolc,?ysrab,??g!.&bew?gro?m&aug?oc??ofni?ten?ude?vog???h!.&0002?a&citore?idem?kitore??edszot?gro?ilus?letoh?m&alker?lif?t?urof??naltagni?o&c?ediv?fni?levynok?nisac??pohs?rarga?s&a&kal?zatu??emag?wen??t&lob?opsgolb,rops??virp?xe&s?zs??ytic?zsagoj??os?sut??l!.&myn,topsgolb,??m!.&ca?gro?moc?oc?ro?ten?vog???n!.&duolcesirpretne,eni&esrem,m,?mon,tenkcahs,uwu,?em!.ysrab,??o&ggnaw?y!c???r!.&a&i&kymlak,rikhsab,vodrom,?yegyda,?bps,ca,eniram,g&bc,nitsohurger.citsalej,ro,?ianatsuk,k&ihclan,s&m,rogitayp,??li&amdlc.bh,m,?moc,natsegad,onijym,pp,ri&b,dcm:.spv,,midalv,?s&ar,itym,?t&en,ni,opsgolb,set,?u&4an,de,?vo&g,n,?ynzorg,zakvakidalv,?myc?p?ug??s!.&a&d&golov,nagarak,?gulak,i&groeg,kymlak,lerak,nemra,rikhsab,ssakahk,vodrom,zahkba,?lut,rahkub,vut,yegyda,znep,?bps,da&baghsa,rgonilest,?gunel,i&anatsuk,hcos,ovan,ttailgot,?k&alhsygnam,ihclan,s&legnahkra,m,n&a&mrum,yrb,?i&buytka,nbo,??tiort,vorkop,??l&ocarak,ybmaj,?myn,na&gruk,jiabreza,ts&egad,hkazak-&htron,tsae,???ovonavi,r&adonsark,imidalv,?t&enxe,nek&hsat,mihc,??vo&hsalab,n,?ynzorg,z&akvakidalv,emret,??t&amok?i&juf?masih????v!.&em,g&olb,ro??moc?nc,ten?ude?ved,??ykuyr??v&b?c!.topsgolb,?ed!.&enilnigol,lecrev,ppa-rettalp,srekrow,vr&esi,uc,?ylf,??ih?l!.&di?fnoc?gro?lim?mo&c?n,?nsa?ten?ude?vog???m!.&eman?gro?lim?m&oc?uesum??o&fni?r&ea?p???pooc?t&en?ni??ude?vog?zib???o&g?m??rt?s!.&bog?der?gro?moc?ude???t!.&bew-eht-no,naht-&esrow,retteb,?sndnyd,?d?gh?i?won??uqhv--nx??w&a!.moc?hs?l??b!.&gro?oc???c!.&gro?moc?ten?ude??cp??e&iver!.oby,?n?s??g?k!.&bme?dni?gro?moc?ten?ude?vog???m!.&ca?gro?m&oc?uesum??oc?pooc?t&en?ni??ude?vog?zib??b??o&csom?h!s??n?w??p!.&344x,de?en?mon,o&c?g??ro?snduolc,ualeb???r!.&ca?gro?lim?oc?pooc?ten?vog??n??t!.&a46oa0fz--nx?b&82wrzc--nx?ulc??emag?gro?l&im?ru,?m&oc!.reliamym,?yn,?t&en?opsgolb,?ude?v&di?og?ta0cu--nx??zibe?業商?織組?路網???z!.&ca?gro?lim?oc?vog????x&a!.&cm,eb,gg,s&e,u,?tac,ue,yx,?t??c!.&hta,ofni,vog???e&d&ef?nay??ma!nab??rof?s??ilften?jt?m!.&bog?gro?m&oc?yn,?t&en?opsgolb,?ude??g?ma2ibgy--nx??o&b!x??f?rex!ijuf???rbgn--nx?s!.&myn,vog???x&am&jt?kt??x???y&4punu--nx?7rr03--nx?a&d!i&loh?rfkcalb??ot??g?lp?p!ila??rot?ssin?wdaorb??b!.&fo?lim?m&oc!.topsgolb,?yn,?vog??ab?gur??c!.&ca?dtl?eman?gro?m&oc!.&ecrofelacs.j,topsgolb,??t??orp?s&egolke?serp??t&en?nemailrap??vog?zib??amrahp?nega??d&dadog?uts??e&kcoh?ltneb?n&dys?om?rotta??snikcm??g!.&eb,gro?m&oc?yn,?oc?ten?ude?vog??olonhcet!.oc,?rene??hpargotohp?id?k!.&gro?moc?ten?ude?vog??s??l!.&clp?d&em?i??gro?hcs?moc?ten?ude?vog??f?imaf!nacirema??l&a?il??ppus??m!.&eman?gro?lim?moc?t&en?opsgolb,?ude?vog??edaca!.laiciffo,?ra??n&a&ffit?pmoc!ylimafa???os??o&j?s??p!.&gro?lim?moc?pooc?ten?ude?vog???r&e&corg?grus?llag?viled??lewej?otcerid?tnuoc?uxul??s!.&gro?lim?moc?ten?ude?vog??pil??t&efas?i&c!.gn,?ledif?n&ifx?ummoc!.&bdnevar,murofym,???r&ahc?uces??srevinu??laer?r&ap!.oby,?eporp??uaeb??u!.&bug?gro?lim?mo&c!.topsgolb,?n,?ten?ude??b!tseb???van!dlo??xes??z&a!.&eman?gro?lim?moc?o&fni?rp??pp?t&en?ni??ude?vog?zib???b!.&az,gro?m&o&c?n,?yn,?ten?ude?vog???c!.&4e,inum.duolc.&rsu,tlf,?m&laer,urtnecatem.motsuc,?oc,topsgolb,??d!.&gro?lop?moc?ossa?t&en?ra??ude?vog???ib!.&duolcsd,e&ht-rof,mos-rof,rom-rof,?izoj,lpb,nafamm,p&i&-on,fles,?ohbew,tfym,?retteb-rof,snd&nyd,uolc,?xro,?g??k!.&gro?lim?m&oc?yn,?ten?ude?vog???m!.&ca?gro?lim?oc?ten?ude?v&da?og????n!.&asq-irom--nx?ca?gro?htlaeh?i&r&c?o&am?ām???wi!k???keeg?l&im?oohcs??myn,neg?oc!.topsgolb,?t&en?nemailrap?vog???a!niflla???rawhcs?s!.&ca?gro?oc???t!.&c&a?s??e&m?n??ibom?l&etoh?im??o&c?fni?g??ro?vt???u!.&gro?moc?oc?ten??rwon??yx!.&etisgolb,gnitfarc,otpaz,ppahf,??zub??λε?υε?авксом?брс!.&гро?до?ка?р&бо?п!у?????г&б?ро??дкм?зақ?итед?килотак?леб?мок?н&йално?ом??рку?сур?тйас?фр?юе?յահ?םוק?اي&روس?سيلم?ناتيروم??بر&ع?غملا??ة&كبش?ي&دوعسلا?روس??یدوعسلا??ت&ا&راما?لاصتا??را&ب?ڀ?ھب???ر&ئازجلا?ازاب?صم?طق??سنوت?عقوم?قارع?ك&تيب?يلوثاك??موك?ن&ا&تس&كاپ?کاپ??دوس?ر&يا?یا??مع?يلعلا??درالا?ميلا?ي&رحبلا?طسلف???ه&ارمه?يدوعسلا??وكمارا?يبظوبا?ۃیدوعسلا?टेन?त&राभ?ोराभ??नठगंस?मॉक?्मतराभ?ত&রাভ?ৰাভ??ালংাব?ਤਰਾਭ?તરાભ?ତରାଭ?ாயித்நஇ?ைக்ஙலஇ?்ரூப்பக்ஙிச?్తరాభ?ತರಾಭ?ംതരാഭ?ාකංල?มอค?ยทไ!.&จิกรุธ?ต็นเ?ร&ก์คงอ?าหท??ลาบฐัร?าษกึศ???ວາລ?ეგ?なんみ?アトス?トンイポ?ドウラク?ムコ?ル&グーグ?ーセ??ン&ゾマア?ョシッァフ??业企?东广?乐娱?亚基诺?你爱我?信中?务政?动移?博微?卦八?厅餐?司公?品食?善慈?团集?国中?國中?址网?坡加新?城商?尚时?山佛?店&商?网?酒大里嘉??府政?康健?息信?戏游?拉里格香?拿大?教主天?机手?构机!织组??标商?歌谷?浦利飞?港香!.&人個?司公?府政?絡網?織組?育教???湾台?灣&台?臺??物购?界世?益公?看点?科盈訊電?站网?籍書?线在?络网?网文中?聘招?販通?车汽众大?逊马亚?通联?里嘉?锡马淡?門澳?门澳?闻新?電家?국한?넷닷?성삼?컴닷??");
/**
* If a hostname is not a key in the EXCLUDE map, and if removing its leftmost component results
@@ -50,7 +50,7 @@
*/
public static final ImmutableMap<String, PublicSuffixType> UNDER =
TrieParser.parseTrie(
- "ac.vedwa,d&b?uolc.&etiso&isnes,tnegam,?iaznab,rehcnar-no,scitats,??e&b.lrusnart,d.&ecapsrebu,yksurf,?noz.notirt,t&atse.etupmoc,is.&hsmroftalp,tst,???gp?h&c.tenerif:.cvs,,k?trae.sppad:.zzb,,?k&c?f?nil.bewd,rowten.secla,u.hcs??ln.lrusnart,m&j?m?oc.&duolcmeaeboda.ved,edonil.recnalabedon,ico-remotsuc:.&ico,pco,sco,?,lrihwyap,mme0,osseccandcved,s&t&cejboedonil,nemelepiuq,?wanozama.&1-etupmoc,ble,etupmoc,??t&neyoj.snc,opsppa.r,???n&c.moc.swanozama.&ble,etupmoc,?ur.edoc,?o&c.pato,i.&duolciaznab.sdraykcab,elacsnoom,oir-no,reniatnoceruza,s&3k-no,olots,?xcq.sys,y5s,??p&j.&a&mahokoy?yogan??ebok?i&adnes?kasawak??oroppas?uhsuykatik??n?pa.&knalfhtron,repoleved,??r&b.mon?e??s&edoc.owo,w.rosivda,?t&a.&ofnistro.&nednuk,xe,?smcerutuf:.&ni,xe,?,?en.&cimonotpyrc,hvo.&gnitsoh,saapbew,???u&e.lrusnart,r.onijym.&gni&dnal,tsoh,?murtceps,spv,??ved.&e&gats>s,lcl,?rahbew,?gts,lcl,yawetag,?z&c.murtnecatem.duolc,yx.tibelet,??");
+ "ac.vedwa,d&b?uolc.&etiso&isnes,tnegam,?iaznab,rehcnar-no,scitats,??e&b.lrusnart,d.ecapsrebu,noz.notirt,t&atse.etupmoc,is.hsmroftalp,?y??gp?h&c.tenerif:.cvs,,k?trae.sppad:.zzb,,?k&c?f?nil.bewd,rowten.secla,u.hcs??ln.lrusnart,m&j?m?oc.&aimhtirogla,duolcmeaeboda.ved,edonil.recnalabedon,ico-remotsuc:.&ico,pco,sco,?,mme0,s&t&cejboedonil,nemelepiuq,?wanozama.&1-etupmoc,ble,etupmoc,??t&neyoj.snc,opsppa.r,???nc.moc.swanozama.&ble,etupmoc,?o&c.pato,i.&duolciaznab.sdraykcab,elacsnoom,oir-no,reniatnoceruza,s&3k-no,olots,?xcq.sys,y5s,??p&j.&a&mahokoy?yogan??ebok?i&adnes?kasawak??oroppas?uhsuykatik??n??r&b.mon?e??s&edoc.owo,w.rosivda,?t&a.&ofnistro.&nednuk,xe,?smcerutuf:.&ni,xe,?,?en.cimonotpyrc,?u&e.lrusnart,r.onijym.&gni&dnal,tsoh,?murtceps,spv,??ved.&erahbew,gts,lcl,?z&c.murtnecatem.duolc,yx.tibelet,??");
/**
* The elements in this map would pass the UNDER test, but are known not to be public suffixes and
@@ -59,5 +59,5 @@
*/
public static final ImmutableMap<String, PublicSuffixType> EXCLUDED =
TrieParser.parseTrie(
- "kc.www?pj.&a&mahokoy.ytic?yogan.ytic??ebok.ytic?i&adnes.ytic?kasawak.ytic??oroppas.ytic?uhsuykatik.ytic???");
+ "kc.www?moc.aimhtirogla.&smaet,tset,?pj.&a&mahokoy.ytic?yogan.ytic??ebok.ytic?i&adnes.ytic?kasawak.ytic??oroppas.ytic?uhsuykatik.ytic???");
}
diff --git a/guava/src/com/google/thirdparty/publicsuffix/PublicSuffixType.java b/guava/src/com/google/thirdparty/publicsuffix/PublicSuffixType.java
index be1d07f..f0c5292 100644
--- a/guava/src/com/google/thirdparty/publicsuffix/PublicSuffixType.java
+++ b/guava/src/com/google/thirdparty/publicsuffix/PublicSuffixType.java
@@ -62,4 +62,8 @@
}
throw new IllegalArgumentException("No enum corresponding to given code: " + code);
}
+
+ static PublicSuffixType fromIsPrivate(boolean isPrivate) {
+ return isPrivate ? PRIVATE : REGISTRY;
+ }
}
diff --git a/guava/src/com/google/thirdparty/publicsuffix/TrieParser.java b/guava/src/com/google/thirdparty/publicsuffix/TrieParser.java
index dd77780..9c387eb 100644
--- a/guava/src/com/google/thirdparty/publicsuffix/TrieParser.java
+++ b/guava/src/com/google/thirdparty/publicsuffix/TrieParser.java
@@ -17,8 +17,8 @@
import com.google.common.annotations.GwtCompatible;
import com.google.common.base.Joiner;
import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.Queues;
-import java.util.Deque;
+import com.google.common.collect.Lists;
+import java.util.List;
/** Parser for a map of reversed domain names stored as a serialized radix tree. */
@GwtCompatible
@@ -34,7 +34,7 @@
int encodedLen = encoded.length();
int idx = 0;
while (idx < encodedLen) {
- idx += doParseTrieToBuilder(Queues.<CharSequence>newArrayDeque(), encoded, idx, builder);
+ idx += doParseTrieToBuilder(Lists.<CharSequence>newLinkedList(), encoded, idx, builder);
}
return builder.build();
}
@@ -50,7 +50,7 @@
* @return The number of characters consumed from {@code encoded}.
*/
private static int doParseTrieToBuilder(
- Deque<CharSequence> stack,
+ List<CharSequence> stack,
CharSequence encoded,
int start,
ImmutableMap.Builder<String, PublicSuffixType> builder) {
@@ -67,7 +67,7 @@
}
}
- stack.push(reverse(encoded.subSequence(start, idx)));
+ stack.add(0, reverse(encoded.subSequence(start, idx)));
if (c == '!' || c == '?' || c == ':' || c == ',') {
// '!' represents an interior node that represents a REGISTRY entry in the map.
@@ -92,7 +92,7 @@
}
}
}
- stack.pop();
+ stack.remove(0);
return idx - start;
}
diff --git a/pom.xml b/pom.xml
index 3cecc43..df7f411 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.google.guava</groupId>
<artifactId>guava-parent</artifactId>
- <version>31.0.1-jre</version>
+ <version>30.0-jre</version>
<packaging>pom</packaging>
<name>Guava Maven Parent</name>
<description>Parent for guava artifacts</description>
@@ -14,11 +14,10 @@
<properties>
<!-- Override this with -Dtest.include="**/SomeTest.java" on the CLI -->
<test.include>%regex[.*.class]</test.include>
- <truth.version>1.1.2</truth.version>
- <checker-framework.version>3.12.0</checker-framework.version>
- <animal.sniffer.version>1.20</animal.sniffer.version>
+ <truth.version>1.0</truth.version>
+ <animal.sniffer.version>1.18</animal.sniffer.version>
<maven-javadoc-plugin.version>3.1.0</maven-javadoc-plugin.version>
- <maven-source-plugin.version>3.2.1</maven-source-plugin.version>
+ <maven-source-plugin.version>3.2.0</maven-source-plugin.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<issueManagement>
@@ -53,8 +52,8 @@
</developer>
</developers>
<ciManagement>
- <system>GitHub Actions</system>
- <url>https://github.com/google/guava/actions</url>
+ <system>Travis CI</system>
+ <url>https://travis-ci.org/google/guava</url>
</ciManagement>
<modules>
<module>guava</module>
@@ -120,16 +119,6 @@
<configuration>
<source>1.8</source>
<target>1.8</target>
- <compilerArgs>
- <!--
- Make includes/excludes fully work:
- https://issues.apache.org/jira/browse/MCOMPILER-174
-
- (Compare what guava-gwt has to do for maven-javadoc-plugin.)
- -->
- <arg>-sourcepath</arg>
- <arg>doesnotexist</arg>
- </compilerArgs>
</configuration>
</plugin>
<plugin>
@@ -152,7 +141,7 @@
<artifactId>animal-sniffer-maven-plugin</artifactId>
<version>${animal.sniffer.version}</version>
<configuration>
- <checkTestClasses>true</checkTestClasses>
+ <annotations>com.google.common.util.concurrent.IgnoreJRERequirement</annotations>
<signature>
<groupId>org.codehaus.mojo.signature</groupId>
<artifactId>java18</artifactId>
@@ -227,7 +216,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
- <version>3.0.0-M3</version>
+ <version>3.0.0-M2</version>
</plugin>
</plugins>
</pluginManagement>
@@ -259,18 +248,12 @@
<dependency>
<groupId>org.checkerframework</groupId>
<artifactId>checker-qual</artifactId>
- <version>${checker-framework.version}</version>
- </dependency>
- <dependency>
- <groupId>org.checkerframework</groupId>
- <artifactId>checker-qual</artifactId>
- <version>${checker-framework.version}</version>
- <classifier>sources</classifier>
+ <version>3.5.0</version>
</dependency>
<dependency>
<groupId>com.google.errorprone</groupId>
<artifactId>error_prone_annotations</artifactId>
- <version>2.7.1</version>
+ <version>2.3.4</version>
</dependency>
<dependency>
<groupId>com.google.j2objc</groupId>
@@ -280,25 +263,25 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
- <version>4.13.2</version>
+ <version>4.13</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.easymock</groupId>
<artifactId>easymock</artifactId>
- <version>4.3</version>
+ <version>3.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
- <version>3.9.0</version>
+ <version>2.19.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.jimfs</groupId>
<artifactId>jimfs</artifactId>
- <version>1.2</version>
+ <version>1.1</version>
<scope>test</scope>
</dependency>
<dependency>
diff --git a/util/deploy_snapshot.sh b/util/deploy_snapshot.sh
index d021318..2eaea17 100755
--- a/util/deploy_snapshot.sh
+++ b/util/deploy_snapshot.sh
@@ -5,12 +5,18 @@
set -e -u
function mvn_deploy() {
- mvn clean source:jar javadoc:jar deploy -DskipTests=true "$@"
+ mvn clean source:jar javadoc:jar deploy \
+ --settings="$(dirname $0)/settings.xml" -DskipTests=true "$@"
}
-echo "Publishing Maven snapshot..."
+if [ "$TRAVIS_REPO_SLUG" == "google/guava" ] && \
+ [ "$TRAVIS_JDK_VERSION" == "openjdk8" ] && \
+ [ "$TRAVIS_PULL_REQUEST" == "false" ] && \
+ [ "$TRAVIS_BRANCH" == "master" ]; then
+ echo "Publishing Maven snapshot..."
-mvn_deploy
-mvn_deploy -f android/pom.xml
+ mvn_deploy
+ mvn_deploy -f android/pom.xml
-echo "Maven snapshot published."
+ echo "Maven snapshot published."
+fi
diff --git a/util/settings.xml b/util/settings.xml
new file mode 100644
index 0000000..306d14a
--- /dev/null
+++ b/util/settings.xml
@@ -0,0 +1,11 @@
+<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
+ <servers>
+ <server>
+ <id>sonatype-nexus-snapshots</id>
+ <username>${env.CI_DEPLOY_USERNAME}</username>
+ <password>${env.CI_DEPLOY_PASSWORD}</password>
+ </server>
+ </servers>
+</settings>
diff --git a/util/update_snapshot_docs.sh b/util/update_snapshot_docs.sh
index 95e9429..14202e1 100755
--- a/util/update_snapshot_docs.sh
+++ b/util/update_snapshot_docs.sh
@@ -1,18 +1,25 @@
#!/bin/bash
+# see http://benlimmer.com/2013/12/26/automatically-publish-javadoc-to-gh-pages-with-travis-ci/ for details
+
set -e -u
-echo "Publishing Javadoc and JDiff..."
+if [ "$TRAVIS_REPO_SLUG" == "google/guava" ] && \
+ [ "$TRAVIS_JDK_VERSION" == "openjdk8" ] && \
+ [ "$TRAVIS_PULL_REQUEST" == "false" ] && \
+ [ "$TRAVIS_BRANCH" == "master" ]; then
+ echo "Publishing Javadoc and JDiff..."
-cd $HOME
-git clone -q -b gh-pages "https://x-access-token:${GITHUB_TOKEN}@github.com/google/guava.git" gh-pages > /dev/null
-cd gh-pages
+ cd $HOME
+ git clone -q -b gh-pages https://${GH_TOKEN}@github.com/google/guava gh-pages > /dev/null
+ cd gh-pages
-git config --global user.name "$GITHUB_ACTOR"
-git config --global user.email "$GITHUB_ACTOR@users.noreply.github.com"
+ git config --global user.email "travis@travis-ci.org"
+ git config --global user.name "travis-ci"
-./updaterelease.sh snapshot
+ ./updaterelease.sh snapshot
-git push -fq origin gh-pages > /dev/null
+ git push -fq origin gh-pages > /dev/null
-echo "Javadoc and JDiff published to gh-pages."
+ echo "Javadoc and JDiff published to gh-pages."
+fi