diff --git a/.github/workflows/ci.build.yml b/.github/workflows/ci.build.yml new file mode 100644 index 000000000000..f1d33b1f556d --- /dev/null +++ b/.github/workflows/ci.build.yml @@ -0,0 +1,215 @@ +# Guava GitHub CI +# --------------------------------------------------------------------------------------------------------------------- +# This is the main CI build on GitHub for the Google Guava project. This workflow is not invoked directly; instead, the +# `on.pr.yml` and `on.push.yml` workflows kick in on PR and push events, respectively, and call this workflow as a +# Reusable Workflow. +# +# This workflow can be tested independently of the entrypoint flow through the `workflow_dispatch` hook, which adds a +# button within the UI of the GitHub repository. You can trigger the workflow from here: +# +# https://github.com/google/guava/actions/workflows/ci.build.yml +# +# ## Inputs +# +# See the set of input parameters underneath the `workflow_call` and `workflow_dispatch` hooks for ways this workflow +# can be controlled when called. +# +# ## SLSA Provenance +# +# After building Guava in both JRE and Android variants, this workflow will (if enabled) generate provenance material +# and upload it to an associated release. Learn more about SLSA here: https://slsa.dev. + +name: Build + +on: + workflow_call: + inputs: + provenance: + type: boolean + description: "Provenance" + default: false + provenance_publish: + type: boolean + description: "Publish: Provenance" + default: true + snapshot: + type: boolean + description: "Publish: Snapshot" + default: false + repository: + type: string + description: "Publish Repository" + default: "sonatype-nexus-snapshots" + + workflow_dispatch: + inputs: + provenance: + type: boolean + description: "Provenance" + default: false + provenance_publish: + type: boolean + description: "Publish: Provenance" + default: false + snapshot: + type: boolean + description: "Publish: Snapshot" + default: true + repository: + type: string + description: "Publish Repository" + default: "sonatype-nexus-snapshots" + +permissions: + contents: read + +jobs: + build: + strategy: + fail-fast: false + matrix: + mode: ["JRE", "Android"] + name: "Build Guava (${{ matrix.mode }})" + runs-on: ubuntu-latest + permissions: + contents: read # for actions/checkout to fetch code + outputs: + hashes: ${{ steps.hash.outputs.hashes }} + env: + ROOT_POM: ${{ matrix.mode == 'Android' && 'android/pom.xml' || 'pom.xml' }} + steps: + - name: Harden Runner + uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0 + with: + disable-sudo: true + egress-policy: block + allowed-endpoints: > + api.azul.com:443 + api.github.com:443 + cdn.azul.com:443 + dl.google.com:443 + docs.oracle.com:443 + errorprone.info:443 + github.com:443 + objects.githubusercontent.com:443 + oss.sonatype.org:443 + repo.maven.apache.org:443 + services.gradle.org:443 + - name: 'Check out repository' + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + with: + persist-credentials: false + - name: 'Set up JDK 21' + uses: actions/setup-java@9704b39bf258b59bc04b50fa2dd55e9ed76b47a8 # v4.1.0 + with: + java-version: 21 + distribution: 'zulu' + cache: 'maven' + - name: 'Install' + shell: bash + run: | + ./mvnw \ + --strict-checksums \ + -B \ + -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn \ + install \ + -U \ + -DskipTests=true \ + -Dmaven.javadoc.skip=false \ + -Dguava.build.spdx=true \ + -Dgpg.skip \ + -f $ROOT_POM + - name: Generate hashes + shell: bash + id: hash + if: matrix.mode == 'JRE' + run: | + echo "Building SLSA provenance material..." + ls guava/target/*.jar guava-gwt/target/*.jar guava-testlib/target/*.jar + echo "hashes=$(sha256sum guava/target/*.jar guava-gwt/target/*.jar guava-testlib/target/*.jar | base64 -w0)" >> ./provenance-hashes.txt + cat ./provenance-hashes.txt >> "$GITHUB_OUTPUT" + echo "Gathered provenance hashes:" + cat ./provenance-hashes.txt + - name: 'Upload artifacts' + uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 + if: matrix.mode == 'JRE' + with: + name: guava-artifacts-${{ matrix.mode == 'Android' && 'android' || 'jre' }}-${{ github.sha }} + path: | + guava/target/*.jar + guava-gwt/target/*.jar + guava-testlib/target/*.jar + ./provenance-hashes.txt + if-no-files-found: warn + retention-days: 7 + + # Generate SLSA provenance + provenance: + needs: [build] + if: inputs.provenance + name: "SLSA Provenance" + uses: slsa-framework/slsa-github-generator/.github/workflows/generator_generic_slsa3.yml@v1.9.0 + permissions: + actions: read + id-token: write + contents: write + with: + base64-subjects: "${{ needs.build.outputs.hashes }}" + upload-assets: ${{ inputs.provenance_publish }} + + # Publish snapshot JAR + publish_snapshot: + name: 'Publish Snapshot' + needs: [build, provenance] + if: inputs.snapshot + runs-on: ubuntu-latest + steps: + - name: Harden Runner + uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0 + with: + egress-policy: audit + - name: 'Check out repository' + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + - name: 'Set up JDK 21' + uses: actions/setup-java@9704b39bf258b59bc04b50fa2dd55e9ed76b47a8 # v4.1.0 + with: + java-version: 21 + distribution: 'zulu' + server-id: ${{ inputs.repository }} + server-username: CI_DEPLOY_USERNAME + server-password: CI_DEPLOY_PASSWORD + cache: 'maven' + - name: "Download artifacts" + uses: actions/download-artifact@c850b930e6ba138125429b7e5c93fc707a7f8427 # v4.1.4 + with: + name: guava-artifacts-jre-${{ github.sha }} + - name: 'Publish' + env: + CI_DEPLOY_USERNAME: ${{ secrets.CI_DEPLOY_USERNAME }} + CI_DEPLOY_PASSWORD: ${{ secrets.CI_DEPLOY_PASSWORD }} + run: ./util/deploy_snapshot.sh + + generate_docs: + permissions: + contents: write + name: 'Generate Docs' + needs: build + if: github.event_name == 'push' && github.repository == 'google/guava' + runs-on: ubuntu-latest + steps: + - name: Harden Runner + uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0 + with: + egress-policy: audit + - name: 'Check out repository' + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + - name: 'Set up JDK 21' + uses: actions/setup-java@9704b39bf258b59bc04b50fa2dd55e9ed76b47a8 # v4.1.0 + with: + java-version: 21 + distribution: 'zulu' + cache: 'maven' + - name: 'Generate latest docs' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: ./util/update_snapshot_docs.sh diff --git a/.github/workflows/ci.test.yml b/.github/workflows/ci.test.yml new file mode 100644 index 000000000000..cee2d16edfb9 --- /dev/null +++ b/.github/workflows/ci.test.yml @@ -0,0 +1,116 @@ +# Guava GitHub CI +# --------------------------------------------------------------------------------------------------------------------- +# This is the main CI testsuite on GitHub for the Google Guava project. This workflow is not invoked directly; instead, +# the `on.pr.yml` and `on.push.yml` workflows kick in on PR and push events, respectively, and call this workflow as a +# Reusable Workflow. +# +# This workflow can be tested independently of the entrypoint flow through the `workflow_dispatch` hook, which adds a +# button within the UI of the GitHub repository. You can trigger the workflow from here: +# +# https://github.com/google/guava/actions/workflows/ci.test.yml +# +# ## Inputs +# +# See the set of input parameters underneath the `workflow_call` and `workflow_dispatch` hooks for ways this workflow +# can be controlled when called. +# +# ## Multi-OS and Multi-JVM Testing +# +# Guava is tested against each LTS release at JDK 8 through JDK 21, on Linux and on Windows (starting at JDK 17), and +# in Android and JRE flavors. + +name: Tests + +on: + workflow_call: {} + workflow_dispatch: {} + +permissions: + contents: read + +jobs: + test: + permissions: + contents: read # for actions/checkout to fetch code + name: "JDK ${{ matrix.java }} ${{ matrix.mode }} (${{ matrix.os }})" + strategy: + matrix: + os: [ ubuntu-latest ] + java: [ 8, 11, 17, 21 ] + mode: [ 'JRE', 'Android' ] + include: + - os: windows-latest + java: 21 + mode: JRE + - os: windows-latest + java: 21 + mode: Android + runs-on: ${{ matrix.os }} + outputs: + hashes: ${{ steps.hash.outputs.hashes }} + env: + ROOT_POM: ${{ matrix.mode == 'Android' && 'android/pom.xml' || 'pom.xml' }} + steps: + - name: Harden Runner + uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0 + with: + disable-sudo: true + egress-policy: block + allowed-endpoints: > + api.azul.com:443 + api.github.com:443 + cdn.azul.com:443 + dl.google.com:443 + docs.oracle.com:443 + errorprone.info:443 + github.com:443 + objects.githubusercontent.com:443 + oss.sonatype.org:443 + repo.maven.apache.org:443 + services.gradle.org:443 + - name: 'Check out repository' + uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 + with: + persist-credentials: false + - name: 'Set up JDK ${{ matrix.java }}' + uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1 + with: + java-version: ${{ matrix.java }} + distribution: 'zulu' + cache: 'maven' + - name: 'Install' + shell: bash + run: | + ./mvnw \ + --strict-checksums \ + -B \ + -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn \ + install \ + -U \ + -DskipTests=true \ + -Dgpg.skip \ + -Dguava.build.spdx=false \ + -Dmaven.javadoc.skip=true \ + -f $ROOT_POM + - name: 'Test' + shell: bash + run: | + ./mvnw \ + --strict-checksums \ + -B \ + -P!standard-with-extra-repos \ + verify \ + -U \ + -Dgpg.skip \ + -Dguava.build.spdx=false \ + -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 + - name: 'Integration Test' + if: matrix.java == 11 + shell: bash + run: util/gradle_integration_tests.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index d1b4e5a3b10b..000000000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,105 +0,0 @@ -name: CI - -on: - push: - branches: - - master - pull_request: - branches: - - master - -permissions: - contents: read - -jobs: - test: - permissions: - actions: write # for styfle/cancel-workflow-action to cancel/stop running workflows - contents: read # for actions/checkout to fetch code - name: "${{ matrix.root-pom }} on JDK ${{ matrix.java }} on ${{ matrix.os }}" - strategy: - matrix: - os: [ ubuntu-latest ] - java: [ 8, 11, 17, 21 ] - root-pom: [ 'pom.xml', 'android/pom.xml' ] - include: - - os: windows-latest - java: 21 - root-pom: pom.xml - runs-on: ${{ matrix.os }} - 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@85880fa0301c86cca9da44039ee3bb12d3bedbfa # 0.12.1 - with: - access_token: ${{ github.token }} - - name: 'Check out repository' - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 - - name: 'Set up JDK ${{ matrix.java }}' - uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1 - - with: - java-version: ${{ matrix.java }} - distribution: 'zulu' - cache: 'maven' - - name: 'Install' - shell: bash - run: ./mvnw -B -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn install -U -DskipTests=true -f $ROOT_POM - - name: 'Test' - shell: bash - run: ./mvnw -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 - - name: 'Integration Test' - if: matrix.java == 11 - shell: bash - run: util/gradle_integration_tests.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@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 - - name: 'Set up JDK 21' - uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1 - with: - java-version: 21 - distribution: 'zulu' - server-id: sonatype-nexus-snapshots - server-username: CI_DEPLOY_USERNAME - server-password: CI_DEPLOY_PASSWORD - cache: 'maven' - - name: 'Publish' - env: - CI_DEPLOY_USERNAME: ${{ secrets.CI_DEPLOY_USERNAME }} - CI_DEPLOY_PASSWORD: ${{ secrets.CI_DEPLOY_PASSWORD }} - run: ./util/deploy_snapshot.sh - - generate_docs: - permissions: - contents: write - 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@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 - - name: 'Set up JDK 11' - uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1 - with: - java-version: 11 - distribution: 'zulu' - cache: 'maven' - - name: 'Generate latest docs' - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: ./util/update_snapshot_docs.sh diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml new file mode 100644 index 000000000000..bdc2e9cd1d09 --- /dev/null +++ b/.github/workflows/codeql.yml @@ -0,0 +1,85 @@ +name: "CodeQL" + +on: + workflow_call: + inputs: + publish: + type: boolean + description: "Publish SARIF" + default: true + + workflow_dispatch: {} + push: + branches: ["master"] + schedule: + - cron: "0 0 * * 1" + +permissions: + contents: read + +jobs: + analyze: + name: CodeQL Analysis + runs-on: ubuntu-latest + permissions: + actions: read + contents: read + security-events: write + + strategy: + fail-fast: false + matrix: + language: ["java"] + # CodeQL supports [ $supported-codeql-languages ] + # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support + + steps: + - name: Harden Runner + uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0 + with: + disable-sudo: true + egress-policy: block + allowed-endpoints: > + api.azul.com:443 + api.github.com:443 + cdn.azul.com:443 + dl.google.com:443 + docs.oracle.com:443 + errorprone.info:443 + github.com:443 + objects.githubusercontent.com:443 + oss.sonatype.org:443 + repo.maven.apache.org:443 + services.gradle.org:443 + - name: Checkout repository + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + with: + persist-credentials: false + - name: 'Set up JDK 21' + uses: actions/setup-java@9704b39bf258b59bc04b50fa2dd55e9ed76b47a8 # v4.1.0 + with: + java-version: 21 + distribution: 'zulu' + cache: 'maven' + - name: Initialize CodeQL + uses: github/codeql-action/init@8a470fddafa5cbb6266ee11b37ef4d8aae19c571 # v3.24.6 + continue-on-error: true + with: + languages: ${{ matrix.language }} + - name: Build Package + run: | + ./mvnw \ + --strict-checksums \ + -B \ + -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn \ + install \ + -U \ + -DskipTests=true \ + -Dmaven.javadoc.skip=true \ + -Dgpg.skip \ + -f pom.xml + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@8a470fddafa5cbb6266ee11b37ef4d8aae19c571 # v3.24.6 + continue-on-error: true + with: + category: "/language:${{matrix.language}}" diff --git a/.github/workflows/dependency-review.yml b/.github/workflows/dependency-review.yml new file mode 100644 index 000000000000..abc802dae2ac --- /dev/null +++ b/.github/workflows/dependency-review.yml @@ -0,0 +1,59 @@ +# Guava GitHub CI +# --------------------------------------------------------------------------------------------------------------------- +# This workflow is called from `on.push.yml` and `on.pr.yml` to operate on Guava's dependency graph: +# +# - The dependency graph is calculated from pom.xml files +# - The graph is then published to GitHub, and associated with the Guava repository +# - When operating on a PR, Dependency Review can be invoked to check dependency changes +# +# ## Inputs +# +# See the set of input parameters underneath the `workflow_call` and `workflow_dispatch` hooks for ways this workflow +# can be controlled when called. + +name: 'Dependency Graph' +on: + workflow_call: + inputs: + review: + type: boolean + description: "Dependency Review" + default: false + workflow_dispatch: + inputs: + review: + type: boolean + description: "Dependency Review" + default: false + +permissions: + contents: read + +jobs: + dependency-review: + name: 'Dependency Graph' + runs-on: ubuntu-latest + permissions: + contents: write # needed to post a dependency graph + id-token: write # needed to exchange the graph publish token for an access token + steps: + - name: Harden Runner + uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0 + with: + disable-sudo: true + egress-policy: block + allowed-endpoints: > + api.github.com:443 + github.com:443 + oss.sonatype.org:443 + repo.maven.apache.org:443 + - name: 'Checkout Repository' + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + - name: Maven Dependency Tree Dependency Submission + continue-on-error: true + uses: advanced-security/maven-dependency-submission-action@bfd2106013da0957cdede0b6c39fb5ca25ae375e # v4.0.2 + - name: 'Dependency Review' + uses: actions/dependency-review-action@9129d7d40b8c12c1ed0f60400d00c92d437adcce # v4.1.3 + continue-on-error: true + with: + retry-on-snapshot-warnings: true diff --git a/.github/workflows/gradle-wrapper-validation.yml b/.github/workflows/gradle-wrapper-validation.yml index 2d2d5245d398..4b905305a8dd 100644 --- a/.github/workflows/gradle-wrapper-validation.yml +++ b/.github/workflows/gradle-wrapper-validation.yml @@ -1,13 +1,25 @@ name: "Validate Gradle Wrapper" -on: [push, pull_request] +on: + workflow_call: {} + workflow_dispatch: {} permissions: contents: read jobs: validation: - name: "Validation" + name: "Gradle Wrapper Validate" runs-on: ubuntu-latest steps: + - name: Harden Runner + uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0 + with: + disable-sudo: true + egress-policy: block + allowed-endpoints: > + github.com:443 - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 - uses: gradle/wrapper-validation-action@b5418f5a58f5fd2eb486dd7efb368fe7be7eae45 # v2.1.3 + with: + persist-credentials: false + - uses: gradle/wrapper-validation-action@699bb18358f12c5b78b37bb0111d3a0e2276e0e2 # v2.1.1 diff --git a/.github/workflows/on.pr.yml b/.github/workflows/on.pr.yml new file mode 100644 index 000000000000..df88ff841bd9 --- /dev/null +++ b/.github/workflows/on.pr.yml @@ -0,0 +1,70 @@ +# Guava GitHub CI +# --------------------------------------------------------------------------------------------------------------------- +# This is an entrypoint workflow which operates on pull requests; this workflow doesn't do much on its own. Its job is +# to dispatch `on.build.yml` and check workflows, which can be found in this same directory. +# +# PR workflows are slightly different from push workflows (for example, they do not publish snapshots). See the +# `on.push.yml` workflow. PR and push flows are designed to be invoked separately. + +name: PR + +on: + pull_request: + branches: + - master + +concurrency: + group: guava-pr-${{ github.event.number }} + cancel-in-progress: true + +permissions: + contents: read + +jobs: + ## Build the library and provenance material, but don't publish + build: + name: "Build" + uses: ./.github/workflows/ci.build.yml + permissions: + actions: write + contents: write + id-token: write + with: + provenance: ${{ github.event.pull_request.head.repo.full_name == 'google/guava' }} + provenance_publish: false + snapshot: false + + ## Run main CI build and tests. + test: + name: "Tests" + uses: ./.github/workflows/ci.test.yml + permissions: + actions: write + contents: write + id-token: write + + ## Validate the Gradle Wrapper binary + checks-gradle-wrapper: + name: "Checks" + uses: ./.github/workflows/gradle-wrapper-validation.yml + + ## Publish and check the dependency graph. + checks-dependency-graph: + name: "Checks" + uses: ./.github/workflows/dependency-review.yml + permissions: + contents: write + id-token: write + with: + review: true + + ## Run CodeQL checks + checks-codeql: + name: "Checks" + uses: ./.github/workflows/codeql.yml + permissions: + actions: read + contents: read + security-events: write + with: + publish: ${{ github.event.pull_request.head.repo.full_name == 'google/guava' }} diff --git a/.github/workflows/on.push.yml b/.github/workflows/on.push.yml new file mode 100644 index 000000000000..91e567b6d569 --- /dev/null +++ b/.github/workflows/on.push.yml @@ -0,0 +1,47 @@ +# Guava GitHub CI +# --------------------------------------------------------------------------------------------------------------------- +# This is an entrypoint workflow which operates on pushed revisions to Guava; this workflow doesn't do much on its own. +# Its job is to dispatch `on.build.yml` and check workflows, which can be found in this same directory. +# +# PR workflows are slightly different from push workflows (for example, the push workflow publishes snapshots). See the +# `on.pr.yml` workflow. PR and push flows are designed to be invoked separately. + +name: Push + +on: + push: + branches: + - master + +concurrency: + group: guava-push-${{ github.sha }} + cancel-in-progress: true + +permissions: + contents: read + +jobs: + ## Run main CI build and tests. + run-ci: + name: "Build" + uses: ./.github/workflows/ci.build.yml + permissions: + actions: write + contents: write + id-token: write + with: + snapshot: github.repository == 'google/guava' + provenance: true + + ## Publish and check the dependency graph. + checks-dependency-graph: + name: "Checks" + uses: ./.github/workflows/dependency-review.yml + permissions: + contents: write + id-token: write + + ## Validate the Gradle Wrapper binary + checks-gradle-wrapper: + name: "Checks" + uses: ./.github/workflows/gradle-wrapper-validation.yml diff --git a/.github/workflows/scorecard.yml b/.github/workflows/scorecard.yml index 68407139f3e3..8741c776bd9a 100644 --- a/.github/workflows/scorecard.yml +++ b/.github/workflows/scorecard.yml @@ -31,6 +31,10 @@ jobs: # actions: read steps: + - name: Harden Runner + uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0 + with: + egress-policy: audit - name: "Checkout code" uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 with: diff --git a/.mvn/jvm.config b/.mvn/jvm.config new file mode 100644 index 000000000000..8fc30111dd55 --- /dev/null +++ b/.mvn/jvm.config @@ -0,0 +1 @@ +-XX:-TieredCompilation -XX:TieredStopAtLevel=1 -XX:+UseParallelGC -Djava.awt.headless=true \ No newline at end of file diff --git a/.mvn/maven.config b/.mvn/maven.config new file mode 100644 index 000000000000..cc57db8375d4 --- /dev/null +++ b/.mvn/maven.config @@ -0,0 +1,2 @@ +-T2C +--strict-checksums diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties index e1c4b83d0115..f84935b09cd1 100644 --- a/.mvn/wrapper/maven-wrapper.properties +++ b/.mvn/wrapper/maven-wrapper.properties @@ -14,8 +14,6 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. -distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.5/apache-maven-3.9.5-bin.zip -distributionSha256Sum=7822eb593d29558d8edf87845a2c47e36e2a89d17a84cd2390824633214ed423 +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.6/apache-maven-3.9.6-bin.zip wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar -# TODO: Does not work properly on Windows, see https://issues.apache.org/jira/browse/MWRAPPER-103 -# wrapperSha256Sum=e63a53cfb9c4d291ebe3c2b0edacb7622bbc480326beaa5a0456e412f52f066a +distributionSha256Sum=83aaf914c785c9faed661f223000a92d1de9553f5c82d3b4362e66d9c031625f diff --git a/README.md b/README.md index 6582d18b6cc5..5fad074bfe39 100644 --- a/README.md +++ b/README.md @@ -71,7 +71,7 @@ consult the ## Snapshots and Documentation Snapshots of Guava built from the `master` branch are available through Maven -using version `HEAD-jre-SNAPSHOT`, or `HEAD-android-SNAPSHOT` for the Android +using version `1.0-HEAD-jre-SNAPSHOT`, or `1.0-HEAD-android-SNAPSHOT` for the Android flavor. - Snapshot API Docs: [guava][guava-snapshot-api-docs] diff --git a/android/guava-bom/pom.xml b/android/guava-bom/pom.xml index 8fde93d1a75a..e6a5d9f132ac 100644 --- a/android/guava-bom/pom.xml +++ b/android/guava-bom/pom.xml @@ -8,7 +8,7 @@ com.google.guava guava-bom - HEAD-android-SNAPSHOT + 1.0-HEAD-android-SNAPSHOT pom diff --git a/android/guava-testlib/pom.xml b/android/guava-testlib/pom.xml index 33dc15799d00..8dc3771c6e0c 100644 --- a/android/guava-testlib/pom.xml +++ b/android/guava-testlib/pom.xml @@ -5,7 +5,7 @@ com.google.guava guava-parent - HEAD-android-SNAPSHOT + 1.0-HEAD-android-SNAPSHOT guava-testlib Guava Testing Library diff --git a/android/guava-tests/pom.xml b/android/guava-tests/pom.xml index bf9bec45c651..f9b485f5e2cf 100644 --- a/android/guava-tests/pom.xml +++ b/android/guava-tests/pom.xml @@ -5,7 +5,7 @@ com.google.guava guava-parent - HEAD-android-SNAPSHOT + 1.0-HEAD-android-SNAPSHOT guava-tests Guava Unit Tests diff --git a/android/guava/pom.xml b/android/guava/pom.xml index 501b3967264c..cbeac5470b9b 100644 --- a/android/guava/pom.xml +++ b/android/guava/pom.xml @@ -6,7 +6,7 @@ com.google.guava guava-parent - HEAD-android-SNAPSHOT + 1.0-HEAD-android-SNAPSHOT guava bundle @@ -161,8 +161,8 @@ - https://docs.oracle.com/javase/9/docs/api/ - https://docs.oracle.com/javase/9/docs/api/ + https://docs.oracle.com/javase/21/docs/api/ + https://docs.oracle.com/en/java/javase/21/docs/api/ diff --git a/android/guava/src/com/google/common/base/Strings.java b/android/guava/src/com/google/common/base/Strings.java index fa3626648d10..a7df5a0d77de 100644 --- a/android/guava/src/com/google/common/base/Strings.java +++ b/android/guava/src/com/google/common/base/Strings.java @@ -235,7 +235,7 @@ static boolean validSurrogatePairAt(CharSequence string, int index) { *

Note: For most string-formatting needs, use {@link String#format String.format}, * {@link java.io.PrintWriter#format PrintWriter.format}, and related methods. These support the * full range of format + * href="https://docs.oracle.com/javase/21/docs/api/java/util/Formatter.html#syntax">format * specifiers, and alert you to usage errors by throwing {@link * java.util.IllegalFormatException}. * diff --git a/android/guava/src/com/google/common/collect/ImmutableCollection.java b/android/guava/src/com/google/common/collect/ImmutableCollection.java index 25d3336eadae..ab533379ee02 100644 --- a/android/guava/src/com/google/common/collect/ImmutableCollection.java +++ b/android/guava/src/com/google/common/collect/ImmutableCollection.java @@ -96,7 +96,7 @@ *

Expressing the immutability guarantee directly in the type that user code references is a * powerful advantage. Although Java offers certain immutable collection factory methods, such as * {@link Collections#singleton(Object)} and {@code Set.of}, + * href="https://docs.oracle.com/javase/21/docs/api/java/util/Set.html#immutable">{@code Set.of}, * we recommend using these classes instead for this reason (as well as for consistency). * *

Creation

diff --git a/android/guava/src/com/google/common/primitives/package-info.java b/android/guava/src/com/google/common/primitives/package-info.java index ad38c111393c..af077e2cc43c 100644 --- a/android/guava/src/com/google/common/primitives/package-info.java +++ b/android/guava/src/com/google/common/primitives/package-info.java @@ -29,7 +29,7 @@ * diff --git a/android/pom.xml b/android/pom.xml index 96ea9fa41df5..9678adcdbfc0 100644 --- a/android/pom.xml +++ b/android/pom.xml @@ -6,7 +6,7 @@ 4.0.0 com.google.guava guava-parent - HEAD-android-SNAPSHOT + 1.0-HEAD-android-SNAPSHOT pom Guava Maven Parent Parent for guava artifacts @@ -29,7 +29,7 @@ integration android android - HEAD-jre-SNAPSHOT + 1.0-HEAD-jre-SNAPSHOT standard-jvm jre @@ -122,7 +122,7 @@ maven-compiler-plugin - 3.8.1 + 3.12.1 1.8 1.8 @@ -159,7 +159,7 @@ maven-jar-plugin - 3.2.0 + 3.3.0 maven-source-plugin @@ -211,7 +211,7 @@ maven-javadoc-plugin - 3.5.0 + 3.6.3 true true diff --git a/futures/failureaccess/pom.xml b/futures/failureaccess/pom.xml index 8886a4b2f7de..5eefbe1e87c4 100644 --- a/futures/failureaccess/pom.xml +++ b/futures/failureaccess/pom.xml @@ -5,11 +5,12 @@ com.google.guava guava-parent - 26.0-android + 1.0-HEAD-jre-SNAPSHOT + ../../pom.xml failureaccess - 1.0.2 - bundle + 1.0.3-jpms + jar Guava InternalFutureFailureAccess and InternalFutures Contains @@ -22,14 +23,44 @@ + + maven-compiler-plugin + + + default-compile + + 1.8 + 1.8 + + module-info.java + + + + + compile-java9 + + compile + + + 9 + true + + + + maven-jar-plugin + ${project.build.outputDirectory}/META-INF/MANIFEST.MF - com.google.common.util.concurrent.internal + true + + /module-info.class + META-INF/versions/9/com/google/common/util/concurrent/internal/*.class + @@ -55,7 +86,8 @@ - com.google.common.util.concurrent.internal + <_fixupmessages>^Classes found in the wrong directory: .* + com.google.common.util.concurrent.internal,!META-INF.* https://github.com/google/guava/ diff --git a/futures/failureaccess/src/module-info.java b/futures/failureaccess/src/module-info.java new file mode 100644 index 000000000000..71ea64d24570 --- /dev/null +++ b/futures/failureaccess/src/module-info.java @@ -0,0 +1,20 @@ +/* + * Copyright (C) 2024 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. + */ + +/** + * Guava: Future Internals. + */ +module com.google.common.util.concurrent.internal { + exports com.google.common.util.concurrent.internal; +} diff --git a/guava-bench/pom.xml b/guava-bench/pom.xml new file mode 100644 index 000000000000..7e3508de40ec --- /dev/null +++ b/guava-bench/pom.xml @@ -0,0 +1,134 @@ + + + 4.0.0 + + com.google.guava + guava-parent + 1.0-HEAD-jre-SNAPSHOT + + guava-bench + Guava Benchmarks + + Benchmarks for Guava, on JMH. + + + + ${project.groupId} + guava-testlib + ${project.version} + test + + + com.google.code.findbugs + jsr305 + test + + + org.checkerframework + checker-qual + test + + + com.google.errorprone + error_prone_annotations + test + + + ${project.groupId} + guava + ${project.version} + test + + + com.google.truth + truth + ${truth.version} + test + + + com.google.truth.extensions + truth-java8-extension + ${truth.version} + test + + + com.google.jimfs + jimfs + 1.3.0 + test + + + junit + junit + 4.13.2 + test + + + com.google.caliper + caliper + 1.0-beta-3 + test + + + org.openjdk.jmh + jmh-core + 1.37 + test + + + + + + maven-compiler-plugin + + + maven-jar-plugin + + + create-test-jar + test-jar + + + + + org.codehaus.mojo + exec-maven-plugin + + com.google.guava.benchmarks.Benchmarks + test + + + + run-bench + test + + java + + + + + + + + + jvm11plus + + [11,] + + + + + maven-compiler-plugin + + + -Xlint:-removal + -Xlint:-options + + + + + + + + diff --git a/guava-tests/benchmark/com/google/common/base/AsciiBenchmark.java b/guava-bench/test/com/google/common/base/AsciiBenchmark.java similarity index 100% rename from guava-tests/benchmark/com/google/common/base/AsciiBenchmark.java rename to guava-bench/test/com/google/common/base/AsciiBenchmark.java diff --git a/guava-tests/test/com/google/common/base/BenchmarkHelpers.java b/guava-bench/test/com/google/common/base/BenchmarkHelpers.java similarity index 100% rename from guava-tests/test/com/google/common/base/BenchmarkHelpers.java rename to guava-bench/test/com/google/common/base/BenchmarkHelpers.java diff --git a/guava-tests/benchmark/com/google/common/base/CharMatcherBenchmark.java b/guava-bench/test/com/google/common/base/CharMatcherBenchmark.java similarity index 100% rename from guava-tests/benchmark/com/google/common/base/CharMatcherBenchmark.java rename to guava-bench/test/com/google/common/base/CharMatcherBenchmark.java diff --git a/guava-tests/benchmark/com/google/common/base/EnumsBenchmark.java b/guava-bench/test/com/google/common/base/EnumsBenchmark.java similarity index 100% rename from guava-tests/benchmark/com/google/common/base/EnumsBenchmark.java rename to guava-bench/test/com/google/common/base/EnumsBenchmark.java diff --git a/guava-tests/benchmark/com/google/common/base/JoinerBenchmark.java b/guava-bench/test/com/google/common/base/JoinerBenchmark.java similarity index 100% rename from guava-tests/benchmark/com/google/common/base/JoinerBenchmark.java rename to guava-bench/test/com/google/common/base/JoinerBenchmark.java diff --git a/guava-tests/benchmark/com/google/common/base/LazyStackTraceBenchmark.java b/guava-bench/test/com/google/common/base/LazyStackTraceBenchmark.java similarity index 100% rename from guava-tests/benchmark/com/google/common/base/LazyStackTraceBenchmark.java rename to guava-bench/test/com/google/common/base/LazyStackTraceBenchmark.java diff --git a/guava-tests/benchmark/com/google/common/base/ObjectsBenchmark.java b/guava-bench/test/com/google/common/base/ObjectsBenchmark.java similarity index 96% rename from guava-tests/benchmark/com/google/common/base/ObjectsBenchmark.java rename to guava-bench/test/com/google/common/base/ObjectsBenchmark.java index 561f76dca98b..d26e192077ff 100644 --- a/guava-tests/benchmark/com/google/common/base/ObjectsBenchmark.java +++ b/guava-bench/test/com/google/common/base/ObjectsBenchmark.java @@ -19,7 +19,7 @@ import com.google.caliper.Benchmark; /** - * Some microbenchmarks for the {@link com.google.common.base.Objects} class. + * Some microbenchmarks for the {@link Objects} class. * * @author Ben L. Titzer */ diff --git a/guava-tests/benchmark/com/google/common/base/SplitterBenchmark.java b/guava-bench/test/com/google/common/base/SplitterBenchmark.java similarity index 100% rename from guava-tests/benchmark/com/google/common/base/SplitterBenchmark.java rename to guava-bench/test/com/google/common/base/SplitterBenchmark.java diff --git a/guava-tests/benchmark/com/google/common/base/StopwatchBenchmark.java b/guava-bench/test/com/google/common/base/StopwatchBenchmark.java similarity index 100% rename from guava-tests/benchmark/com/google/common/base/StopwatchBenchmark.java rename to guava-bench/test/com/google/common/base/StopwatchBenchmark.java diff --git a/guava-tests/benchmark/com/google/common/base/StringsRepeatBenchmark.java b/guava-bench/test/com/google/common/base/StringsRepeatBenchmark.java similarity index 97% rename from guava-tests/benchmark/com/google/common/base/StringsRepeatBenchmark.java rename to guava-bench/test/com/google/common/base/StringsRepeatBenchmark.java index 16e00ef3d2e2..b20d33dff0b0 100644 --- a/guava-tests/benchmark/com/google/common/base/StringsRepeatBenchmark.java +++ b/guava-bench/test/com/google/common/base/StringsRepeatBenchmark.java @@ -21,7 +21,7 @@ import com.google.caliper.Param; /** - * Microbenchmark for {@link com.google.common.base.Strings#repeat} + * Microbenchmark for {@link Strings#repeat} * * @author Mike Cripps */ diff --git a/guava-tests/benchmark/com/google/common/base/ToStringHelperBenchmark.java b/guava-bench/test/com/google/common/base/ToStringHelperBenchmark.java similarity index 100% rename from guava-tests/benchmark/com/google/common/base/ToStringHelperBenchmark.java rename to guava-bench/test/com/google/common/base/ToStringHelperBenchmark.java diff --git a/guava-tests/benchmark/com/google/common/base/WhitespaceMatcherBenchmark.java b/guava-bench/test/com/google/common/base/WhitespaceMatcherBenchmark.java similarity index 100% rename from guava-tests/benchmark/com/google/common/base/WhitespaceMatcherBenchmark.java rename to guava-bench/test/com/google/common/base/WhitespaceMatcherBenchmark.java diff --git a/guava-tests/benchmark/com/google/common/cache/ChainBenchmark.java b/guava-bench/test/com/google/common/cache/ChainBenchmark.java similarity index 100% rename from guava-tests/benchmark/com/google/common/cache/ChainBenchmark.java rename to guava-bench/test/com/google/common/cache/ChainBenchmark.java diff --git a/guava-tests/benchmark/com/google/common/cache/LoadingCacheSingleThreadBenchmark.java b/guava-bench/test/com/google/common/cache/LoadingCacheSingleThreadBenchmark.java similarity index 100% rename from guava-tests/benchmark/com/google/common/cache/LoadingCacheSingleThreadBenchmark.java rename to guava-bench/test/com/google/common/cache/LoadingCacheSingleThreadBenchmark.java diff --git a/guava-tests/benchmark/com/google/common/cache/MapMakerComparisonBenchmark.java b/guava-bench/test/com/google/common/cache/MapMakerComparisonBenchmark.java similarity index 100% rename from guava-tests/benchmark/com/google/common/cache/MapMakerComparisonBenchmark.java rename to guava-bench/test/com/google/common/cache/MapMakerComparisonBenchmark.java diff --git a/guava-tests/benchmark/com/google/common/cache/SegmentBenchmark.java b/guava-bench/test/com/google/common/cache/SegmentBenchmark.java similarity index 100% rename from guava-tests/benchmark/com/google/common/cache/SegmentBenchmark.java rename to guava-bench/test/com/google/common/cache/SegmentBenchmark.java diff --git a/guava-bench/test/com/google/common/collect/BenchmarkHelpers.java b/guava-bench/test/com/google/common/collect/BenchmarkHelpers.java new file mode 100644 index 000000000000..5a5bdad7addd --- /dev/null +++ b/guava-bench/test/com/google/common/collect/BenchmarkHelpers.java @@ -0,0 +1,420 @@ +/* + * 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.collect; + +import com.google.common.base.Equivalence; + +import java.util.*; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; +import java.util.concurrent.ConcurrentSkipListMap; + +import static com.google.common.base.Preconditions.checkState; + +/** + * Helper classes for various benchmarks. + * + * @author Christopher Swenson + */ +final class BenchmarkHelpers { + /** So far, this is the best way to test various implementations of {@link Set} subclasses. */ + public interface CollectionsImplEnum { + > Collection create(Collection contents); + + String name(); + } + + public interface MapsImplEnum { + , V> Map create(Map contents); + + String name(); + } + + public interface InternerImplEnum { + Interner create(Collection contents); + + String name(); + } + + public enum SetImpl implements CollectionsImplEnum { + HashSetImpl { + @Override + public > Set create(Collection contents) { + return new HashSet(contents); + } + }, + LinkedHashSetImpl { + @Override + public > Set create(Collection contents) { + return new LinkedHashSet(contents); + } + }, + TreeSetImpl { + @Override + public > Set create(Collection contents) { + return new TreeSet(contents); + } + }, + UnmodifiableSetImpl { + @Override + public > Set create(Collection contents) { + return Collections.unmodifiableSet(new HashSet(contents)); + } + }, + SynchronizedSetImpl { + @Override + public > Set create(Collection contents) { + return Collections.synchronizedSet(new HashSet(contents)); + } + }, + ImmutableSetImpl { + @Override + public > Set create(Collection contents) { + return ImmutableSet.copyOf(contents); + } + }, + ImmutableSortedSetImpl { + @Override + public > Set create(Collection contents) { + return ImmutableSortedSet.copyOf(contents); + } + }, + ContiguousSetImpl { + @Override + public > Set create(Collection contents) { + return ContiguousSet.copyOf(contents); + } + }, + ; + } + + public enum ListMultimapImpl { + ArrayListMultimapImpl { + @Override + ListMultimap create(Multimap contents) { + return ArrayListMultimap.create(contents); + } + }, + LinkedListMultimapImpl { + @Override + ListMultimap create(Multimap contents) { + return LinkedListMultimap.create(contents); + } + }, + ImmutableListMultimapImpl { + @Override + ListMultimap create(Multimap contents) { + return ImmutableListMultimap.copyOf(contents); + } + }; + + abstract ListMultimap create(Multimap contents); + } + + public enum RangeSetImpl { + TreeRangeSetImpl { + @Override + > RangeSet create(RangeSet contents) { + return TreeRangeSet.create(contents); + } + }, + ImmutableRangeSetImpl { + @Override + > RangeSet create(RangeSet contents) { + return ImmutableRangeSet.copyOf(contents); + } + }; + + abstract > RangeSet create(RangeSet contents); + } + + public enum SetMultimapImpl { + HashMultimapImpl { + @Override + , V extends Comparable> SetMultimap create( + Multimap contents) { + return HashMultimap.create(contents); + } + }, + LinkedHashMultimapImpl { + @Override + , V extends Comparable> SetMultimap create( + Multimap contents) { + return LinkedHashMultimap.create(contents); + } + }, + TreeMultimapImpl { + @Override + , V extends Comparable> SetMultimap create( + Multimap contents) { + return TreeMultimap.create(contents); + } + }, + ImmutableSetMultimapImpl { + @Override + , V extends Comparable> SetMultimap create( + Multimap contents) { + return ImmutableSetMultimap.copyOf(contents); + } + }; + + abstract , V extends Comparable> SetMultimap create( + Multimap contents); + } + + public enum MapImpl implements MapsImplEnum { + HashMapImpl { + @Override + public , V> Map create(Map map) { + return Maps.newHashMap(map); + } + }, + LinkedHashMapImpl { + @Override + public , V> Map create(Map map) { + return Maps.newLinkedHashMap(map); + } + }, + ConcurrentHashMapImpl { + @Override + public , V> Map create(Map map) { + return new ConcurrentHashMap<>(map); + } + }, + ImmutableMapImpl { + @Override + public , V> Map create(Map map) { + return ImmutableMap.copyOf(map); + } + }, + MapMakerStrongKeysStrongValues { + @Override + public , V> Map create(Map map) { + // We use a "custom" equivalence to force MapMaker to make a MapMakerInternalMap. + ConcurrentMap newMap = new MapMaker().keyEquivalence(Equivalence.equals()).makeMap(); + checkState(newMap instanceof MapMakerInternalMap); + newMap.putAll(map); + return newMap; + } + }, + MapMakerStrongKeysWeakValues { + @Override + public , V> Map create(Map map) { + ConcurrentMap newMap = new MapMaker().weakValues().makeMap(); + checkState(newMap instanceof MapMakerInternalMap); + newMap.putAll(map); + return newMap; + } + }, + MapMakerWeakKeysStrongValues { + @Override + public , V> Map create(Map map) { + ConcurrentMap newMap = new MapMaker().weakKeys().makeMap(); + checkState(newMap instanceof MapMakerInternalMap); + newMap.putAll(map); + return newMap; + } + }, + MapMakerWeakKeysWeakValues { + @Override + public , V> Map create(Map map) { + ConcurrentMap newMap = new MapMaker().weakKeys().weakValues().makeMap(); + checkState(newMap instanceof MapMakerInternalMap); + newMap.putAll(map); + return newMap; + } + }; + } + + enum SortedMapImpl implements MapsImplEnum { + TreeMapImpl { + @Override + public , V> SortedMap create(Map map) { + SortedMap result = Maps.newTreeMap(); + result.putAll(map); + return result; + } + }, + ConcurrentSkipListImpl { + @Override + public , V> SortedMap create(Map map) { + return new ConcurrentSkipListMap<>(map); + } + }, + ImmutableSortedMapImpl { + @Override + public , V> SortedMap create(Map map) { + return ImmutableSortedMap.copyOf(map); + } + }; + } + + enum BiMapImpl implements MapsImplEnum { + HashBiMapImpl { + @Override + public , V> BiMap create(Map map) { + return HashBiMap.create(map); + } + }, + ImmutableBiMapImpl { + @Override + public , V> BiMap create(Map map) { + return ImmutableBiMap.copyOf(map); + } + }; + + @Override + public abstract , V> BiMap create(Map map); + } + + enum MultisetImpl implements CollectionsImplEnum { + HashMultisetImpl { + @Override + public > Multiset create(Collection contents) { + return HashMultiset.create(contents); + } + }, + LinkedHashMultisetImpl { + @Override + public > Multiset create(Collection contents) { + return LinkedHashMultiset.create(contents); + } + }, + ConcurrentHashMultisetImpl { + @Override + public > Multiset create(Collection contents) { + return ConcurrentHashMultiset.create(contents); + } + }, + ImmutableMultisetImpl { + @Override + public > Multiset create(Collection contents) { + return ImmutableMultiset.copyOf(contents); + } + }; + } + + enum SortedMultisetImpl implements CollectionsImplEnum { + TreeMultisetImpl { + @Override + public > SortedMultiset create(Collection contents) { + return TreeMultiset.create(contents); + } + }, + ImmutableSortedMultisetImpl { + @Override + public > SortedMultiset create(Collection contents) { + return ImmutableSortedMultiset.copyOf(contents); + } + }; + } + + enum QueueImpl implements CollectionsImplEnum { + MinMaxPriorityQueueImpl { + @Override + public > Queue create(Collection contents) { + return MinMaxPriorityQueue.create(contents); + } + }; + } + + enum TableImpl { + HashBasedTableImpl { + @Override + , C extends Comparable, V> Table create( + Table contents) { + return HashBasedTable.create(contents); + } + }, + TreeBasedTableImpl { + @Override + , C extends Comparable, V> Table create( + Table contents) { + Table table = TreeBasedTable.create(); + table.putAll(contents); + return table; + } + }, + ArrayTableImpl { + @Override + , C extends Comparable, V> Table create( + Table contents) { + if (contents.isEmpty()) { + return ImmutableTable.of(); + } else { + return ArrayTable.create(contents); + } + } + }, + ImmutableTableImpl { + @Override + , C extends Comparable, V> Table create( + Table contents) { + return ImmutableTable.copyOf(contents); + } + }; + + abstract , C extends Comparable, V> Table create( + Table contents); + } + + public enum InternerImpl implements InternerImplEnum { + WeakInternerImpl { + @Override + public Interner create(Collection contents) { + Interner interner = Interners.newWeakInterner(); + for (E e : contents) { + E unused = interner.intern(e); + } + return interner; + } + }, + StrongInternerImpl { + @Override + public Interner create(Collection contents) { + Interner interner = Interners.newStrongInterner(); + for (E e : contents) { + E unused = interner.intern(e); + } + return interner; + } + }; + } + + public enum Value { + INSTANCE; + } + + public enum ListSizeDistribution { + UNIFORM_0_TO_2(0, 2), + UNIFORM_0_TO_9(0, 9), + ALWAYS_0(0, 0), + ALWAYS_10(10, 10); + + final int min; + final int max; + + private ListSizeDistribution(int min, int max) { + this.min = min; + this.max = max; + } + + public int chooseSize(Random random) { + return random.nextInt(max - min + 1) + min; + } + } +} diff --git a/guava-tests/benchmark/com/google/common/collect/BinaryTreeTraverserBenchmark.java b/guava-bench/test/com/google/common/collect/BinaryTreeTraverserBenchmark.java similarity index 100% rename from guava-tests/benchmark/com/google/common/collect/BinaryTreeTraverserBenchmark.java rename to guava-bench/test/com/google/common/collect/BinaryTreeTraverserBenchmark.java diff --git a/guava-tests/test/com/google/common/collect/CollectionBenchmarkSampleData.java b/guava-bench/test/com/google/common/collect/CollectionBenchmarkSampleData.java similarity index 99% rename from guava-tests/test/com/google/common/collect/CollectionBenchmarkSampleData.java rename to guava-bench/test/com/google/common/collect/CollectionBenchmarkSampleData.java index 0504e6a745f6..9cd8386adeb2 100644 --- a/guava-tests/test/com/google/common/collect/CollectionBenchmarkSampleData.java +++ b/guava-bench/test/com/google/common/collect/CollectionBenchmarkSampleData.java @@ -16,13 +16,14 @@ package com.google.common.collect; -import static com.google.common.base.Preconditions.checkNotNull; - import com.google.common.primitives.Ints; +import org.checkerframework.checker.nullness.qual.Nullable; + import java.util.Collections; import java.util.List; import java.util.Set; -import org.checkerframework.checker.nullness.qual.Nullable; + +import static com.google.common.base.Preconditions.checkNotNull; /** * Package up sample data for common collections benchmarking. diff --git a/guava-tests/benchmark/com/google/common/collect/ComparatorDelegationOverheadBenchmark.java b/guava-bench/test/com/google/common/collect/ComparatorDelegationOverheadBenchmark.java similarity index 100% rename from guava-tests/benchmark/com/google/common/collect/ComparatorDelegationOverheadBenchmark.java rename to guava-bench/test/com/google/common/collect/ComparatorDelegationOverheadBenchmark.java diff --git a/guava-tests/benchmark/com/google/common/collect/ConcurrentHashMultisetBenchmark.java b/guava-bench/test/com/google/common/collect/ConcurrentHashMultisetBenchmark.java similarity index 98% rename from guava-tests/benchmark/com/google/common/collect/ConcurrentHashMultisetBenchmark.java rename to guava-bench/test/com/google/common/collect/ConcurrentHashMultisetBenchmark.java index 322dd547f6d1..9975ba6e3335 100644 --- a/guava-tests/benchmark/com/google/common/collect/ConcurrentHashMultisetBenchmark.java +++ b/guava-bench/test/com/google/common/collect/ConcurrentHashMultisetBenchmark.java @@ -236,7 +236,7 @@ public T[] toArray(T[] array) { */ private List snapshot() { List list = Lists.newArrayListWithExpectedSize(size()); - for (Multiset.Entry entry : entrySet()) { + for (Entry entry : entrySet()) { E element = entry.getElement(); for (int i = entry.getCount(); i > 0; i--) { list.add(element); @@ -446,7 +446,7 @@ Iterator elementIterator() { private transient EntrySet entrySet; @Override - public Set> entrySet() { + public Set> entrySet() { EntrySet result = entrySet; if (result == null) { entrySet = result = new EntrySet(); @@ -474,7 +474,7 @@ public boolean hasNext() { } @Override - public Multiset.Entry next() { + public Entry next() { Map.Entry backingEntry = backingIterator.next(); return Multisets.immutableEntry(backingEntry.getKey(), backingEntry.getValue()); } @@ -517,8 +517,8 @@ public T[] toArray(T[] array) { return snapshot().toArray(array); } - private List> snapshot() { - List> list = Lists.newArrayListWithExpectedSize(size()); + private List> snapshot() { + List> list = Lists.newArrayListWithExpectedSize(size()); // not Iterables.addAll(list, this), because that'll forward back here Iterators.addAll(list, iterator()); return list; @@ -527,7 +527,7 @@ private List> snapshot() { @Override public boolean remove(Object object) { if (object instanceof Multiset.Entry) { - Multiset.Entry entry = (Multiset.Entry) object; + Entry entry = (Entry) object; Object element = entry.getElement(); int entryCount = entry.getCount(); return countMap.remove(element, entryCount); diff --git a/guava-tests/benchmark/com/google/common/collect/HashMultisetAddPresentBenchmark.java b/guava-bench/test/com/google/common/collect/HashMultisetAddPresentBenchmark.java similarity index 100% rename from guava-tests/benchmark/com/google/common/collect/HashMultisetAddPresentBenchmark.java rename to guava-bench/test/com/google/common/collect/HashMultisetAddPresentBenchmark.java diff --git a/guava-tests/benchmark/com/google/common/collect/ImmutableListCreationBenchmark.java b/guava-bench/test/com/google/common/collect/ImmutableListCreationBenchmark.java similarity index 100% rename from guava-tests/benchmark/com/google/common/collect/ImmutableListCreationBenchmark.java rename to guava-bench/test/com/google/common/collect/ImmutableListCreationBenchmark.java diff --git a/guava-tests/benchmark/com/google/common/collect/ImmutableSetHashFloodingDetectionBenchmark.java b/guava-bench/test/com/google/common/collect/ImmutableSetHashFloodingDetectionBenchmark.java similarity index 100% rename from guava-tests/benchmark/com/google/common/collect/ImmutableSetHashFloodingDetectionBenchmark.java rename to guava-bench/test/com/google/common/collect/ImmutableSetHashFloodingDetectionBenchmark.java diff --git a/guava-tests/benchmark/com/google/common/collect/InternersBenchmark.java b/guava-bench/test/com/google/common/collect/InternersBenchmark.java similarity index 100% rename from guava-tests/benchmark/com/google/common/collect/InternersBenchmark.java rename to guava-bench/test/com/google/common/collect/InternersBenchmark.java diff --git a/guava-tests/benchmark/com/google/common/collect/IteratorBenchmark.java b/guava-bench/test/com/google/common/collect/IteratorBenchmark.java similarity index 100% rename from guava-tests/benchmark/com/google/common/collect/IteratorBenchmark.java rename to guava-bench/test/com/google/common/collect/IteratorBenchmark.java diff --git a/guava-tests/benchmark/com/google/common/collect/MapBenchmark.java b/guava-bench/test/com/google/common/collect/MapBenchmark.java similarity index 100% rename from guava-tests/benchmark/com/google/common/collect/MapBenchmark.java rename to guava-bench/test/com/google/common/collect/MapBenchmark.java diff --git a/guava-tests/benchmark/com/google/common/collect/MinMaxPriorityQueueBenchmark.java b/guava-bench/test/com/google/common/collect/MinMaxPriorityQueueBenchmark.java similarity index 100% rename from guava-tests/benchmark/com/google/common/collect/MinMaxPriorityQueueBenchmark.java rename to guava-bench/test/com/google/common/collect/MinMaxPriorityQueueBenchmark.java diff --git a/guava-tests/benchmark/com/google/common/collect/MultipleSetContainsBenchmark.java b/guava-bench/test/com/google/common/collect/MultipleSetContainsBenchmark.java similarity index 100% rename from guava-tests/benchmark/com/google/common/collect/MultipleSetContainsBenchmark.java rename to guava-bench/test/com/google/common/collect/MultipleSetContainsBenchmark.java diff --git a/guava-tests/benchmark/com/google/common/collect/MultisetIteratorBenchmark.java b/guava-bench/test/com/google/common/collect/MultisetIteratorBenchmark.java similarity index 100% rename from guava-tests/benchmark/com/google/common/collect/MultisetIteratorBenchmark.java rename to guava-bench/test/com/google/common/collect/MultisetIteratorBenchmark.java diff --git a/guava-tests/benchmark/com/google/common/collect/PowerSetBenchmark.java b/guava-bench/test/com/google/common/collect/PowerSetBenchmark.java similarity index 100% rename from guava-tests/benchmark/com/google/common/collect/PowerSetBenchmark.java rename to guava-bench/test/com/google/common/collect/PowerSetBenchmark.java diff --git a/guava-tests/benchmark/com/google/common/collect/SetContainsBenchmark.java b/guava-bench/test/com/google/common/collect/SetContainsBenchmark.java similarity index 100% rename from guava-tests/benchmark/com/google/common/collect/SetContainsBenchmark.java rename to guava-bench/test/com/google/common/collect/SetContainsBenchmark.java diff --git a/guava-tests/benchmark/com/google/common/collect/SetCreationBenchmark.java b/guava-bench/test/com/google/common/collect/SetCreationBenchmark.java similarity index 100% rename from guava-tests/benchmark/com/google/common/collect/SetCreationBenchmark.java rename to guava-bench/test/com/google/common/collect/SetCreationBenchmark.java diff --git a/guava-tests/benchmark/com/google/common/collect/SetIterationBenchmark.java b/guava-bench/test/com/google/common/collect/SetIterationBenchmark.java similarity index 100% rename from guava-tests/benchmark/com/google/common/collect/SetIterationBenchmark.java rename to guava-bench/test/com/google/common/collect/SetIterationBenchmark.java diff --git a/guava-tests/benchmark/com/google/common/collect/SortedCopyBenchmark.java b/guava-bench/test/com/google/common/collect/SortedCopyBenchmark.java similarity index 100% rename from guava-tests/benchmark/com/google/common/collect/SortedCopyBenchmark.java rename to guava-bench/test/com/google/common/collect/SortedCopyBenchmark.java diff --git a/guava-tests/test/com/google/common/collect/SpecialRandom.java b/guava-bench/test/com/google/common/collect/SpecialRandom.java similarity index 100% rename from guava-tests/test/com/google/common/collect/SpecialRandom.java rename to guava-bench/test/com/google/common/collect/SpecialRandom.java diff --git a/guava-tests/benchmark/com/google/common/collect/StreamsBenchmark.java b/guava-bench/test/com/google/common/collect/StreamsBenchmark.java similarity index 100% rename from guava-tests/benchmark/com/google/common/collect/StreamsBenchmark.java rename to guava-bench/test/com/google/common/collect/StreamsBenchmark.java diff --git a/guava-tests/benchmark/com/google/common/eventbus/EventBusBenchmark.java b/guava-bench/test/com/google/common/eventbus/EventBusBenchmark.java similarity index 100% rename from guava-tests/benchmark/com/google/common/eventbus/EventBusBenchmark.java rename to guava-bench/test/com/google/common/eventbus/EventBusBenchmark.java diff --git a/guava-tests/benchmark/com/google/common/hash/ChecksumBenchmark.java b/guava-bench/test/com/google/common/hash/ChecksumBenchmark.java similarity index 100% rename from guava-tests/benchmark/com/google/common/hash/ChecksumBenchmark.java rename to guava-bench/test/com/google/common/hash/ChecksumBenchmark.java diff --git a/guava-tests/benchmark/com/google/common/hash/HashCodeBenchmark.java b/guava-bench/test/com/google/common/hash/HashCodeBenchmark.java similarity index 100% rename from guava-tests/benchmark/com/google/common/hash/HashCodeBenchmark.java rename to guava-bench/test/com/google/common/hash/HashCodeBenchmark.java diff --git a/guava-tests/benchmark/com/google/common/hash/HashFunctionBenchmark.java b/guava-bench/test/com/google/common/hash/HashFunctionBenchmark.java similarity index 100% rename from guava-tests/benchmark/com/google/common/hash/HashFunctionBenchmark.java rename to guava-bench/test/com/google/common/hash/HashFunctionBenchmark.java diff --git a/guava-tests/test/com/google/common/hash/HashFunctionEnum.java b/guava-bench/test/com/google/common/hash/HashFunctionEnum.java similarity index 100% rename from guava-tests/test/com/google/common/hash/HashFunctionEnum.java rename to guava-bench/test/com/google/common/hash/HashFunctionEnum.java diff --git a/guava-tests/benchmark/com/google/common/hash/HashStringBenchmark.java b/guava-bench/test/com/google/common/hash/HashStringBenchmark.java similarity index 100% rename from guava-tests/benchmark/com/google/common/hash/HashStringBenchmark.java rename to guava-bench/test/com/google/common/hash/HashStringBenchmark.java diff --git a/guava-tests/benchmark/com/google/common/hash/MessageDigestAlgorithmBenchmark.java b/guava-bench/test/com/google/common/hash/MessageDigestAlgorithmBenchmark.java similarity index 97% rename from guava-tests/benchmark/com/google/common/hash/MessageDigestAlgorithmBenchmark.java rename to guava-bench/test/com/google/common/hash/MessageDigestAlgorithmBenchmark.java index 2e252d127b68..e245dd14b45e 100644 --- a/guava-tests/benchmark/com/google/common/hash/MessageDigestAlgorithmBenchmark.java +++ b/guava-bench/test/com/google/common/hash/MessageDigestAlgorithmBenchmark.java @@ -24,7 +24,7 @@ import java.util.Random; /** - * Benchmarks for comparing {@link MessageDigest}s and {@link com.google.common.hash.HashFunction}s + * Benchmarks for comparing {@link MessageDigest}s and {@link HashFunction}s * that wrap {@link MessageDigest}s. * *

Parameters for the benchmark are: diff --git a/guava-tests/benchmark/com/google/common/hash/MessageDigestCreationBenchmark.java b/guava-bench/test/com/google/common/hash/MessageDigestCreationBenchmark.java similarity index 100% rename from guava-tests/benchmark/com/google/common/hash/MessageDigestCreationBenchmark.java rename to guava-bench/test/com/google/common/hash/MessageDigestCreationBenchmark.java diff --git a/guava-tests/benchmark/com/google/common/io/BaseEncodingBenchmark.java b/guava-bench/test/com/google/common/io/BaseEncodingBenchmark.java similarity index 100% rename from guava-tests/benchmark/com/google/common/io/BaseEncodingBenchmark.java rename to guava-bench/test/com/google/common/io/BaseEncodingBenchmark.java diff --git a/guava-tests/benchmark/com/google/common/io/ByteSourceAsCharSourceReadBenchmark.java b/guava-bench/test/com/google/common/io/ByteSourceAsCharSourceReadBenchmark.java similarity index 100% rename from guava-tests/benchmark/com/google/common/io/ByteSourceAsCharSourceReadBenchmark.java rename to guava-bench/test/com/google/common/io/ByteSourceAsCharSourceReadBenchmark.java diff --git a/guava-tests/benchmark/com/google/common/io/CharStreamsCopyBenchmark.java b/guava-bench/test/com/google/common/io/CharStreamsCopyBenchmark.java similarity index 100% rename from guava-tests/benchmark/com/google/common/io/CharStreamsCopyBenchmark.java rename to guava-bench/test/com/google/common/io/CharStreamsCopyBenchmark.java diff --git a/guava-tests/benchmark/com/google/common/math/ApacheBenchmark.java b/guava-bench/test/com/google/common/math/ApacheBenchmark.java similarity index 100% rename from guava-tests/benchmark/com/google/common/math/ApacheBenchmark.java rename to guava-bench/test/com/google/common/math/ApacheBenchmark.java diff --git a/guava-tests/benchmark/com/google/common/math/BigIntegerMathBenchmark.java b/guava-bench/test/com/google/common/math/BigIntegerMathBenchmark.java similarity index 100% rename from guava-tests/benchmark/com/google/common/math/BigIntegerMathBenchmark.java rename to guava-bench/test/com/google/common/math/BigIntegerMathBenchmark.java diff --git a/guava-tests/benchmark/com/google/common/math/BigIntegerMathRoundingBenchmark.java b/guava-bench/test/com/google/common/math/BigIntegerMathRoundingBenchmark.java similarity index 100% rename from guava-tests/benchmark/com/google/common/math/BigIntegerMathRoundingBenchmark.java rename to guava-bench/test/com/google/common/math/BigIntegerMathRoundingBenchmark.java diff --git a/guava-tests/benchmark/com/google/common/math/DoubleMathBenchmark.java b/guava-bench/test/com/google/common/math/DoubleMathBenchmark.java similarity index 100% rename from guava-tests/benchmark/com/google/common/math/DoubleMathBenchmark.java rename to guava-bench/test/com/google/common/math/DoubleMathBenchmark.java diff --git a/guava-tests/benchmark/com/google/common/math/DoubleMathRoundingBenchmark.java b/guava-bench/test/com/google/common/math/DoubleMathRoundingBenchmark.java similarity index 100% rename from guava-tests/benchmark/com/google/common/math/DoubleMathRoundingBenchmark.java rename to guava-bench/test/com/google/common/math/DoubleMathRoundingBenchmark.java diff --git a/guava-tests/benchmark/com/google/common/math/IntMathBenchmark.java b/guava-bench/test/com/google/common/math/IntMathBenchmark.java similarity index 100% rename from guava-tests/benchmark/com/google/common/math/IntMathBenchmark.java rename to guava-bench/test/com/google/common/math/IntMathBenchmark.java diff --git a/guava-tests/benchmark/com/google/common/math/IntMathRoundingBenchmark.java b/guava-bench/test/com/google/common/math/IntMathRoundingBenchmark.java similarity index 100% rename from guava-tests/benchmark/com/google/common/math/IntMathRoundingBenchmark.java rename to guava-bench/test/com/google/common/math/IntMathRoundingBenchmark.java diff --git a/guava-tests/benchmark/com/google/common/math/LessThanBenchmark.java b/guava-bench/test/com/google/common/math/LessThanBenchmark.java similarity index 100% rename from guava-tests/benchmark/com/google/common/math/LessThanBenchmark.java rename to guava-bench/test/com/google/common/math/LessThanBenchmark.java diff --git a/guava-tests/benchmark/com/google/common/math/LongMathBenchmark.java b/guava-bench/test/com/google/common/math/LongMathBenchmark.java similarity index 100% rename from guava-tests/benchmark/com/google/common/math/LongMathBenchmark.java rename to guava-bench/test/com/google/common/math/LongMathBenchmark.java diff --git a/guava-tests/benchmark/com/google/common/math/LongMathRoundingBenchmark.java b/guava-bench/test/com/google/common/math/LongMathRoundingBenchmark.java similarity index 100% rename from guava-tests/benchmark/com/google/common/math/LongMathRoundingBenchmark.java rename to guava-bench/test/com/google/common/math/LongMathRoundingBenchmark.java diff --git a/guava-tests/test/com/google/common/math/MathBenchmarking.java b/guava-bench/test/com/google/common/math/MathBenchmarking.java similarity index 100% rename from guava-tests/test/com/google/common/math/MathBenchmarking.java rename to guava-bench/test/com/google/common/math/MathBenchmarking.java diff --git a/guava-tests/benchmark/com/google/common/math/QuantilesBenchmark.java b/guava-bench/test/com/google/common/math/QuantilesBenchmark.java similarity index 98% rename from guava-tests/benchmark/com/google/common/math/QuantilesBenchmark.java rename to guava-bench/test/com/google/common/math/QuantilesBenchmark.java index d97c2d56d642..7cf7e312bbcd 100644 --- a/guava-tests/benchmark/com/google/common/math/QuantilesBenchmark.java +++ b/guava-bench/test/com/google/common/math/QuantilesBenchmark.java @@ -23,6 +23,7 @@ import com.google.common.collect.DiscreteDomain; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Range; +import com.google.common.testing.math.QuantilesAlgorithm; import java.util.Random; /** Benchmarks some algorithms providing the same functionality as {@link Quantiles}. */ diff --git a/guava-tests/benchmark/com/google/common/math/StatsBenchmark.java b/guava-bench/test/com/google/common/math/StatsBenchmark.java similarity index 100% rename from guava-tests/benchmark/com/google/common/math/StatsBenchmark.java rename to guava-bench/test/com/google/common/math/StatsBenchmark.java diff --git a/guava-tests/benchmark/com/google/common/primitives/UnsignedBytesBenchmark.java b/guava-bench/test/com/google/common/primitives/UnsignedBytesBenchmark.java similarity index 100% rename from guava-tests/benchmark/com/google/common/primitives/UnsignedBytesBenchmark.java rename to guava-bench/test/com/google/common/primitives/UnsignedBytesBenchmark.java diff --git a/guava-tests/benchmark/com/google/common/primitives/UnsignedLongsBenchmark.java b/guava-bench/test/com/google/common/primitives/UnsignedLongsBenchmark.java similarity index 100% rename from guava-tests/benchmark/com/google/common/primitives/UnsignedLongsBenchmark.java rename to guava-bench/test/com/google/common/primitives/UnsignedLongsBenchmark.java diff --git a/guava-tests/test/com/google/common/util/concurrent/AbstractFutureBenchmarks.java b/guava-bench/test/com/google/common/util/concurrent/AbstractFutureBenchmarks.java similarity index 97% rename from guava-tests/test/com/google/common/util/concurrent/AbstractFutureBenchmarks.java rename to guava-bench/test/com/google/common/util/concurrent/AbstractFutureBenchmarks.java index d90c5bbe807d..9321eb05272a 100644 --- a/guava-tests/test/com/google/common/util/concurrent/AbstractFutureBenchmarks.java +++ b/guava-bench/test/com/google/common/util/concurrent/AbstractFutureBenchmarks.java @@ -16,17 +16,14 @@ package com.google.common.util.concurrent; -import static com.google.common.base.Preconditions.checkNotNull; - import com.google.errorprone.annotations.CanIgnoreReturnValue; -import java.util.concurrent.CancellationException; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.Executor; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.TimeoutException; -import java.util.concurrent.locks.AbstractQueuedSynchronizer; import org.checkerframework.checker.nullness.qual.Nullable; +import java.util.concurrent.*; +import java.util.concurrent.locks.AbstractQueuedSynchronizer; + +import static com.google.common.base.Preconditions.checkNotNull; + /** Utilities for the AbstractFutureBenchmarks */ final class AbstractFutureBenchmarks { private AbstractFutureBenchmarks() {} @@ -211,7 +208,7 @@ public void addListener(Runnable listener, Executor exec) { /** * Subclasses should invoke this method to set the result of the computation to {@code value}. - * This will set the state of the future to {@link OldAbstractFuture.Sync#COMPLETED} and invoke + * This will set the state of the future to {@link Sync#COMPLETED} and invoke * the listeners if the state was successfully changed. * * @param value the value that was the result of the task. @@ -228,7 +225,7 @@ protected boolean set(@Nullable V value) { /** * Subclasses should invoke this method to set the result of the computation to an error, {@code - * throwable}. This will set the state of the future to {@link OldAbstractFuture.Sync#COMPLETED} + * throwable}. This will set the state of the future to {@link Sync#COMPLETED} * and invoke the listeners if the state was successfully changed. * * @param throwable the exception that the task failed with. diff --git a/guava-tests/benchmark/com/google/common/util/concurrent/AbstractFutureFootprintBenchmark.java b/guava-bench/test/com/google/common/util/concurrent/AbstractFutureFootprintBenchmark.java similarity index 100% rename from guava-tests/benchmark/com/google/common/util/concurrent/AbstractFutureFootprintBenchmark.java rename to guava-bench/test/com/google/common/util/concurrent/AbstractFutureFootprintBenchmark.java diff --git a/guava-tests/benchmark/com/google/common/util/concurrent/CycleDetectingLockFactoryBenchmark.java b/guava-bench/test/com/google/common/util/concurrent/CycleDetectingLockFactoryBenchmark.java similarity index 100% rename from guava-tests/benchmark/com/google/common/util/concurrent/CycleDetectingLockFactoryBenchmark.java rename to guava-bench/test/com/google/common/util/concurrent/CycleDetectingLockFactoryBenchmark.java diff --git a/guava-tests/benchmark/com/google/common/util/concurrent/ExecutionListBenchmark.java b/guava-bench/test/com/google/common/util/concurrent/ExecutionListBenchmark.java similarity index 99% rename from guava-tests/benchmark/com/google/common/util/concurrent/ExecutionListBenchmark.java rename to guava-bench/test/com/google/common/util/concurrent/ExecutionListBenchmark.java index 946b85109cb8..def54109f0e4 100644 --- a/guava-tests/benchmark/com/google/common/util/concurrent/ExecutionListBenchmark.java +++ b/guava-bench/test/com/google/common/util/concurrent/ExecutionListBenchmark.java @@ -42,6 +42,7 @@ /** Benchmarks for {@link ExecutionList}. */ @VmOptions({"-Xms8g", "-Xmx8g"}) +@SuppressWarnings({"removal", "deprecation"}) public class ExecutionListBenchmark { private static final int NUM_THREADS = 10; // make a param? @@ -375,7 +376,7 @@ public void run() { // This is the old implementation of ExecutionList using a LinkedList. private static final class OldExecutionList { static final Logger log = Logger.getLogger(OldExecutionList.class.getName()); - final Queue runnables = Lists.newLinkedList(); + final Queue runnables = Lists.newLinkedList(); boolean executed = false; public void add(Runnable runnable, Executor executor) { diff --git a/guava-tests/benchmark/com/google/common/util/concurrent/FuturesGetCheckedBenchmark.java b/guava-bench/test/com/google/common/util/concurrent/FuturesGetCheckedBenchmark.java similarity index 100% rename from guava-tests/benchmark/com/google/common/util/concurrent/FuturesGetCheckedBenchmark.java rename to guava-bench/test/com/google/common/util/concurrent/FuturesGetCheckedBenchmark.java diff --git a/guava-tests/benchmark/com/google/common/util/concurrent/MonitorBasedArrayBlockingQueue.java b/guava-bench/test/com/google/common/util/concurrent/MonitorBasedArrayBlockingQueue.java similarity index 100% rename from guava-tests/benchmark/com/google/common/util/concurrent/MonitorBasedArrayBlockingQueue.java rename to guava-bench/test/com/google/common/util/concurrent/MonitorBasedArrayBlockingQueue.java diff --git a/guava-tests/benchmark/com/google/common/util/concurrent/MonitorBasedPriorityBlockingQueue.java b/guava-bench/test/com/google/common/util/concurrent/MonitorBasedPriorityBlockingQueue.java similarity index 100% rename from guava-tests/benchmark/com/google/common/util/concurrent/MonitorBasedPriorityBlockingQueue.java rename to guava-bench/test/com/google/common/util/concurrent/MonitorBasedPriorityBlockingQueue.java diff --git a/guava-tests/benchmark/com/google/common/util/concurrent/MonitorBenchmark.java b/guava-bench/test/com/google/common/util/concurrent/MonitorBenchmark.java similarity index 100% rename from guava-tests/benchmark/com/google/common/util/concurrent/MonitorBenchmark.java rename to guava-bench/test/com/google/common/util/concurrent/MonitorBenchmark.java diff --git a/guava-tests/benchmark/com/google/common/util/concurrent/MoreExecutorsDirectExecutorBenchmark.java b/guava-bench/test/com/google/common/util/concurrent/MoreExecutorsDirectExecutorBenchmark.java similarity index 100% rename from guava-tests/benchmark/com/google/common/util/concurrent/MoreExecutorsDirectExecutorBenchmark.java rename to guava-bench/test/com/google/common/util/concurrent/MoreExecutorsDirectExecutorBenchmark.java diff --git a/guava-tests/benchmark/com/google/common/util/concurrent/SingleThreadAbstractFutureBenchmark.java b/guava-bench/test/com/google/common/util/concurrent/SingleThreadAbstractFutureBenchmark.java similarity index 100% rename from guava-tests/benchmark/com/google/common/util/concurrent/SingleThreadAbstractFutureBenchmark.java rename to guava-bench/test/com/google/common/util/concurrent/SingleThreadAbstractFutureBenchmark.java diff --git a/guava-tests/benchmark/com/google/common/util/concurrent/StripedBenchmark.java b/guava-bench/test/com/google/common/util/concurrent/StripedBenchmark.java similarity index 100% rename from guava-tests/benchmark/com/google/common/util/concurrent/StripedBenchmark.java rename to guava-bench/test/com/google/common/util/concurrent/StripedBenchmark.java diff --git a/guava-bench/test/com/google/guava/benchmarks/Benchmarks.java b/guava-bench/test/com/google/guava/benchmarks/Benchmarks.java new file mode 100644 index 000000000000..8f1596df3797 --- /dev/null +++ b/guava-bench/test/com/google/guava/benchmarks/Benchmarks.java @@ -0,0 +1,7 @@ +package com.google.guava.benchmarks; + +public class Benchmarks { + public static void main(String[] args) { + System.out.println("Hello, Guava Benchmarks!"); + } +} diff --git a/guava-bom/pom.xml b/guava-bom/pom.xml index 8c5ea2ec035f..af7c956adbaa 100644 --- a/guava-bom/pom.xml +++ b/guava-bom/pom.xml @@ -8,7 +8,7 @@ com.google.guava guava-bom - HEAD-jre-SNAPSHOT + 1.0-HEAD-jre-SNAPSHOT pom diff --git a/guava-gwt/pom.xml b/guava-gwt/pom.xml index 9d207424387b..daef88890ce0 100644 --- a/guava-gwt/pom.xml +++ b/guava-gwt/pom.xml @@ -5,7 +5,7 @@ com.google.guava guava-parent - HEAD-jre-SNAPSHOT + 1.0-HEAD-jre-SNAPSHOT guava-gwt Guava GWT compatible libs diff --git a/guava-testlib/pom.xml b/guava-testlib/pom.xml index f60890e78e7a..03034270da0c 100644 --- a/guava-testlib/pom.xml +++ b/guava-testlib/pom.xml @@ -5,7 +5,7 @@ com.google.guava guava-parent - HEAD-jre-SNAPSHOT + 1.0-HEAD-jre-SNAPSHOT guava-testlib Guava Testing Library @@ -60,9 +60,6 @@ - - maven-compiler-plugin - maven-source-plugin @@ -88,10 +85,97 @@ maven-javadoc-plugin + + ${javadoc.specification.version} + + --add-reads=com.google.common.testlib=ALL-UNNAMED + + maven-surefire-plugin + + org.apache.maven.plugins + maven-compiler-plugin + + + default-compile + + 1.8 + 1.8 + + module-info.java + + + -XDignore.symbol.file + + + + + + + + compile-jpms + + [9,] + + + + + maven-compiler-plugin + + + compile-java9 + compile + + compile + + + 9 + + ${project.basedir}/src + + + + + -sourcepath + ${project.basedir}/src + --add-reads=com.google.common=ALL-UNNAMED + --add-reads=com.google.common.testlib=ALL-UNNAMED + + -XDcompilePolicy=simple + -Xlint:-removal + -Xlint:-options + + true + true + + + + + + org.apache.maven.plugins + maven-jar-plugin + + + /module-info.class + META-INF/versions/9/com/**/*.class + + + + true + + + + + + + + diff --git a/guava-testlib/src/com/google/common/testing/math/QuantilesAlgorithm.java b/guava-testlib/src/com/google/common/testing/math/QuantilesAlgorithm.java new file mode 100644 index 000000000000..3ac861bd1bbf --- /dev/null +++ b/guava-testlib/src/com/google/common/testing/math/QuantilesAlgorithm.java @@ -0,0 +1,219 @@ +/* + * Copyright (C) 2014 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.testing.math; + +import com.google.common.collect.ImmutableMap; +import com.google.common.math.LongMath; +import com.google.common.math.Quantiles; + +import java.math.RoundingMode; +import java.util.Arrays; +import java.util.Collection; +import java.util.Map; + +/** + * Enumerates several algorithms providing equivalent functionality to {@link Quantiles}, for use in + * quantiles tests and benchmarks. These algorithms each calculate either a single quantile or + * multiple quantiles. All algorithms modify the dataset they are given (the cost of a copy to avoid + * this will be constant across algorithms). + * + * @author Pete Gillin + * @since 20.0 + */ +public enum QuantilesAlgorithm { + + /** + * Sorts the dataset, and picks values from it. When computing multiple quantiles, we sort once + * and pick multiple values. + */ + SORTING { + + @Override + public double singleQuantile(int index, int scale, double[] dataset) { + Arrays.sort(dataset); + return singleQuantileFromSorted(index, scale, dataset); + } + + @Override + public Map multipleQuantiles( + Collection indexes, int scale, double[] dataset) { + Arrays.sort(dataset); + ImmutableMap.Builder builder = ImmutableMap.builder(); + for (int index : indexes) { + builder.put(index, singleQuantileFromSorted(index, scale, dataset)); + } + return builder.buildOrThrow(); + } + + private double singleQuantileFromSorted(int index, int scale, double[] dataset) { + long numerator = (long) index * (dataset.length - 1); + int positionFloor = (int) LongMath.divide(numerator, scale, RoundingMode.DOWN); + int remainder = (int) (numerator - positionFloor * scale); + if (remainder == 0) { + return dataset[positionFloor]; + } else { + double positionFrac = (double) remainder / scale; + return dataset[positionFloor] + + positionFrac * (dataset[positionFloor + 1] - dataset[positionFloor]); + } + } + }, + + /** + * Uses quickselect. When calculating multiple quantiles, each quickselect starts from scratch. + */ + QUICKSELECT { + + @Override + public double singleQuantile(int index, int scale, double[] dataset) { + long numerator = (long) index * (dataset.length - 1); + int positionFloor = (int) LongMath.divide(numerator, scale, RoundingMode.DOWN); + int remainder = (int) (numerator - positionFloor * scale); + double percentileFloor = select(positionFloor, dataset); + if (remainder == 0) { + return percentileFloor; + } else { + double percentileCeiling = getMinValue(dataset, positionFloor + 1); + double positionFrac = (double) remainder / scale; + return percentileFloor + positionFrac * (percentileCeiling - percentileFloor); + } + } + + @Override + public Map multipleQuantiles( + Collection indexes, int scale, double[] dataset) { + ImmutableMap.Builder builder = ImmutableMap.builder(); + for (int index : indexes) { + builder.put(index, singleQuantile(index, scale, dataset)); + } + return builder.buildOrThrow(); + } + }, + + /** Uses {@link Quantiles}. */ + TARGET { + + @Override + public double singleQuantile(int index, int scale, double[] dataset) { + return Quantiles.scale(scale).index(index).computeInPlace(dataset); + } + + @Override + public Map multipleQuantiles( + Collection indexes, int scale, double[] dataset) { + return Quantiles.scale(scale).indexes(indexes).computeInPlace(dataset); + } + }, + ; + + /** + * Calculates a single quantile. Equivalent to {@code + * Quantiles.scale(scale).index(index).computeInPlace(dataset)}. + */ + public abstract double singleQuantile(int index, int scale, double[] dataset); + + /** + * Calculates multiple quantiles. Equivalent to {@code + * Quantiles.scale(scale).indexes(indexes).computeInPlace(dataset)}. + */ + public abstract Map multipleQuantiles( + Collection indexes, int scale, double[] dataset); + + static double getMinValue(double[] array, int from) { + // This is basically a copy of com.google.math.Rank#getMinValue, with a small change in the + // method signature: we always search to the end of the array. + int min = from; + for (int i = from + 1; i < array.length; i++) { + if (array[min] > array[i]) { + min = i; + } + } + return array[min]; + } + + static double select(int k, double[] array) { + // This is basically a copy of com.google.math.Rank#select, with a small change in the method + // signature: we make k 0-based rather than 1-based; and we drop from and to, and always work on + // the whole array. + int from = 0; + int to = array.length - 1; + + while (true) { + if (to <= from + 1) { + // Two or less elements left. + if (to == from + 1 && array[to] < array[from]) { + // Exactly two elements left. + swap(array, from, to); + } + return array[k]; + } else { + int midIndex = (from + to) >>> 1; + // Choose the median of the elements at the from, to and mid indexes, + // and rearrange so that array[from]<=array[from+1], and + // array[to] => array[from + 1]. + + swap(array, midIndex, from + 1); + + if (array[from] > array[to]) { + swap(array, from, to); + } + if (array[from + 1] > array[to]) { + swap(array, from + 1, to); + } + if (array[from] > array[from + 1]) { + swap(array, from, from + 1); + } + + // Perform a partition with the selected median. + int low = from + 1, high = to; // Indexes for partitioning. + double partition = array[from + 1]; // Choose partitioning element. + while (true) { + // Skip the elements smaller than the partition. + do { + low++; + } while (array[low] < partition); + + // Skip the elements larger than the partition. + do { + high--; + } while (array[high] > partition); + if (high < low) { + break; // Pointers crossed. Partitioning complete. + } + swap(array, low, high); // End of innermost loop. + } + array[from + 1] = array[high]; // Insert partitioning element. + array[high] = partition; + + // Continue the partition that contains the kth element. + if (high >= k) { + to = high - 1; + } + if (high <= k) { + from = low; + } + } + } + } + + private static void swap(double[] array, int i, int j) { + // This is a copy of com.google.math.Rank#swap. + double temp = array[i]; + array[i] = array[j]; + array[j] = temp; + } +} diff --git a/guava-testlib/src/module-info.java b/guava-testlib/src/module-info.java new file mode 100644 index 000000000000..e7ee724db36d --- /dev/null +++ b/guava-testlib/src/module-info.java @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2024 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. + */ + +/** + * Guava Testlib + */ +open module com.google.common.testlib { + requires java.logging; + requires com.google.common; + requires com.google.common.util.concurrent.internal; + + exports com.google.common.collect.testing; + exports com.google.common.collect.testing.features; + exports com.google.common.collect.testing.google; + exports com.google.common.collect.testing.testers; + exports com.google.common.escape.testing; + exports com.google.common.testing; + exports com.google.common.testing.math; + exports com.google.common.util.concurrent.testing; +} diff --git a/guava-tests/pom.xml b/guava-tests/pom.xml index 8596221d8316..7010a508a4bb 100644 --- a/guava-tests/pom.xml +++ b/guava-tests/pom.xml @@ -5,7 +5,7 @@ com.google.guava guava-parent - HEAD-jre-SNAPSHOT + 1.0-HEAD-jre-SNAPSHOT guava-tests Guava Unit Tests @@ -111,23 +111,27 @@ false - - org.codehaus.mojo - build-helper-maven-plugin - 1.7 - - - add-benchmark-sources - generate-test-sources - add-test-source - - - benchmark - - - - - + + + jvm11plus + + [11,] + + + + + maven-compiler-plugin + + + -Xlint:-removal + -Xlint:-options + + + + + + + diff --git a/guava-tests/test/com/google/common/math/QuantilesAlgorithm.java b/guava-tests/test/com/google/common/math/QuantilesAlgorithm.java index ddb2064e20b6..f81d3fdf0e17 100644 --- a/guava-tests/test/com/google/common/math/QuantilesAlgorithm.java +++ b/guava-tests/test/com/google/common/math/QuantilesAlgorithm.java @@ -24,7 +24,7 @@ /** * Enumerates several algorithms providing equivalent functionality to {@link Quantiles}, for use in - * {@link QuantilesBenchmark}. These algorithms each calculate either a single quantile or multiple + * the Quantiles Benchmark. These algorithms each calculate either a single quantile or multiple * quantiles. All algorithms modify the dataset they are given (the cost of a copy to avoid this * will be constant across algorithms). * diff --git a/guava-tests/test/com/google/common/math/QuantilesAlgorithmTest.java b/guava-tests/test/com/google/common/math/QuantilesAlgorithmTest.java index 87a962a61299..49b972cd0659 100644 --- a/guava-tests/test/com/google/common/math/QuantilesAlgorithmTest.java +++ b/guava-tests/test/com/google/common/math/QuantilesAlgorithmTest.java @@ -27,7 +27,7 @@ import junit.framework.TestCase; /** - * Tests that the different algorithms benchmarked in {@link QuantilesBenchmark} are actually all + * Tests that the different algorithms benchmarked in the Quantiles Benchmark are actually all * returning more-or-less the same answers. */ public class QuantilesAlgorithmTest extends TestCase { diff --git a/guava/pom.xml b/guava/pom.xml index be0bab174e16..987e3cfe7ef2 100644 --- a/guava/pom.xml +++ b/guava/pom.xml @@ -6,10 +6,10 @@ com.google.guava guava-parent - HEAD-jre-SNAPSHOT + 1.0-HEAD-jre-SNAPSHOT guava - bundle + jar Guava: Google Core Libraries for Java https://github.com/google/guava @@ -21,7 +21,7 @@ com.google.guava failureaccess - 1.0.2 + ${failureaccess.version} com.google.guava @@ -31,18 +31,22 @@ com.google.code.findbugs jsr305 + ${jsr305.version} org.checkerframework checker-qual + ${checker.version} com.google.errorprone error_prone_annotations + ${errorprone.version} com.google.j2objc j2objc-annotations + ${j2objc.version} @@ -59,19 +63,12 @@ maven-jar-plugin - - - - com.google.common - - - true org.apache.felix maven-bundle-plugin - 5.1.8 + 5.1.9 bundle-manifest @@ -83,9 +80,12 @@ + <_fixupmessages>^Classes found in the wrong directory: .* + <_jpms-module-info>com.google.common !com.google.common.base.internal, !com.google.common.util.concurrent.internal, + !META-INF.*, com.google.common.* @@ -100,6 +100,47 @@ maven-compiler-plugin + + + default-compile + + 1.8 + 1.8 + + module-info.java + + + -XDignore.symbol.file + + + + + compile-java-9 + compile + + compile + + + 9 + + ${project.basedir}/src + + + + + -sourcepath + ${project.basedir}/src + --add-reads=com.google.common=ALL-UNNAMED + + -XDcompilePolicy=simple + + true + + + maven-source-plugin @@ -111,6 +152,7 @@ maven-javadoc-plugin + 9 @@ -161,8 +203,12 @@ - https://docs.oracle.com/javase/9/docs/api/ - https://docs.oracle.com/javase/9/docs/api/ + https://docs.oracle.com/javase/21/docs/api/ + https://docs.oracle.com/en/java/javase/21/docs/api/ + + + https://docs.oracle.com/en/java/javase/21/docs/api/ + https://docs.oracle.com/en/java/javase/21/docs/api/ @@ -173,6 +219,7 @@ https://errorprone.info/api/latest/ + all,-missing,-html,-accessibility ../overview.html @@ -222,4 +269,146 @@ + + + spdx + + [11, + + + + + maven-compiler-plugin + + + compile-java-9 + compile + + 9 + + ${project.basedir}/src + + + + + -sourcepath + ${project.basedir}/src + --add-reads=com.google.common=ALL-UNNAMED + + -XDcompilePolicy=simple + -Xlint:-removal + -Xlint:-options + + true + + + + + + org.apache.maven.plugins + maven-jar-plugin + + + /module-info.class + META-INF/versions/9/com/**/*.class + + + + true + ALL-UNNAMED + + + + + + + + + spdx-sign + + [11,] + + guava.build.spdx + true + + + + + + + org.spdx + spdx-maven-plugin + + + build-spdx + install + + createSPDX + + + + + true + true + Organization: Google, LLC + Copyright (c) 2012-2024, The Guava Authors + Copyright (c) 2012-2024, The Guava Authors + Apache-2.0 + Organization: Google, LLC + + SHA256 + + + + + + org.apache.maven.plugins + maven-antrun-plugin + + + repack-spdx + install + + run + + + + + + + + + + + + + + + + + + maven-gpg-plugin + + + default-gpg + install + + sign + + + + + + + + diff --git a/guava/src/com/google/common/base/Strings.java b/guava/src/com/google/common/base/Strings.java index e56bf1c48196..619c61d26542 100644 --- a/guava/src/com/google/common/base/Strings.java +++ b/guava/src/com/google/common/base/Strings.java @@ -241,7 +241,7 @@ static boolean validSurrogatePairAt(CharSequence string, int index) { *

Note: For most string-formatting needs, use {@link String#format String.format}, * {@link java.io.PrintWriter#format PrintWriter.format}, and related methods. These support the * full range of format + * href="https://docs.oracle.com/javase/21/docs/api/java/util/Formatter.html#syntax">format * specifiers, and alert you to usage errors by throwing {@link * java.util.IllegalFormatException}. * diff --git a/guava/src/com/google/common/cache/CacheBuilder.java b/guava/src/com/google/common/cache/CacheBuilder.java index ca0754c83f92..ff54bfd2ff7c 100644 --- a/guava/src/com/google/common/cache/CacheBuilder.java +++ b/guava/src/com/google/common/cache/CacheBuilder.java @@ -967,7 +967,6 @@ Ticker getTicker(boolean recordsTime) { * * @return the cache builder reference that should be used instead of {@code this} for any * remaining configuration and cache building - * @return this {@code CacheBuilder} instance (for chaining) * @throws IllegalStateException if a removal listener was already set */ public CacheBuilder removalListener( diff --git a/guava/src/com/google/common/cache/Striped64.java b/guava/src/com/google/common/cache/Striped64.java index aca34b8c8c2b..6b5ac005c920 100644 --- a/guava/src/com/google/common/cache/Striped64.java +++ b/guava/src/com/google/common/cache/Striped64.java @@ -94,6 +94,7 @@ abstract class Striped64 extends Number { *

JVM intrinsics note: It would be possible to use a release-only form of CAS here, if it were * provided. */ + @SuppressWarnings({"deprecation", "removal", "unused"}) static final class Cell { volatile long p0, p1, p2, p3, p4, p5, p6; volatile long value; @@ -103,7 +104,7 @@ static final class Cell { value = x; } - final boolean cas(long cmp, long val) { + boolean cas(long cmp, long val) { return UNSAFE.compareAndSwapLong(this, valueOffset, cmp, val); } diff --git a/guava/src/com/google/common/collect/ImmutableCollection.java b/guava/src/com/google/common/collect/ImmutableCollection.java index 80987788cda7..40d3b9b4a5c9 100644 --- a/guava/src/com/google/common/collect/ImmutableCollection.java +++ b/guava/src/com/google/common/collect/ImmutableCollection.java @@ -94,9 +94,9 @@ *

Expressing the immutability guarantee directly in the type that user code references is a * powerful advantage. Although Java offers certain immutable collection factory methods, such as * {@link Collections#singleton(Object)} and {@code Set.of}, - * we recommend using these classes instead for this reason (as well as for consistency). - * + * href="https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/util/Set.html#of()"> + * {@code Set.of}, we recommend using these classes instead for this reason (as well + * as for consistency). *

Creation

* *

Except for logically "abstract" types like {@code ImmutableCollection} itself, each {@code diff --git a/guava/src/com/google/common/graph/ValueGraph.java b/guava/src/com/google/common/graph/ValueGraph.java index 6495e2d4d0ba..089c712a9020 100644 --- a/guava/src/com/google/common/graph/ValueGraph.java +++ b/guava/src/com/google/common/graph/ValueGraph.java @@ -308,9 +308,9 @@ public interface ValueGraph extends BaseGraph { * *

Unlike the other {@code EndpointPair}-accepting methods, this method does not throw if the * endpoints are unordered and the graph is directed; it simply returns {@code false}. This is for - * consistency with the behavior of {@link Collection#contains(Object)} (which does not generally - * throw if the object cannot be present in the collection), and the desire to have this method's - * behavior be compatible with {@code edges().contains(endpoints)}. + * consistency with the behavior of {@link java.util.Collection#contains(Object)} (which does not + * generally throw if the object cannot be present in the collection), and the desire to have this + * method's behavior be compatible with {@code edges().contains(endpoints)}. * * @since 27.1 */ diff --git a/guava/src/com/google/common/primitives/package-info.java b/guava/src/com/google/common/primitives/package-info.java index ad38c111393c..af077e2cc43c 100644 --- a/guava/src/com/google/common/primitives/package-info.java +++ b/guava/src/com/google/common/primitives/package-info.java @@ -29,7 +29,7 @@ *

    *
  • {@link ImmutableDoubleArray} *
  • {@link ImmutableIntArray} - *
  • {@link ImmutableLongrray} + *
  • {@link ImmutableLongArray} *
  • {@link UnsignedInteger} *
  • {@link UnsignedLong} *
diff --git a/guava/src/com/google/common/util/concurrent/AbstractFuture.java b/guava/src/com/google/common/util/concurrent/AbstractFuture.java index 96ecda5f5168..6ae282d241af 100644 --- a/guava/src/com/google/common/util/concurrent/AbstractFuture.java +++ b/guava/src/com/google/common/util/concurrent/AbstractFuture.java @@ -65,6 +65,7 @@ * @since 1.0 */ @SuppressWarnings({ + "removal", // `AccessController` removal "ShortCircuitBoolean", // we use non-short circuiting comparisons intentionally "nullness", // TODO(b/147136275): Remove once our checker understands & and |. }) @@ -426,7 +427,7 @@ protected AbstractFuture() {} *

The default {@link AbstractFuture} implementation throws {@code InterruptedException} if the * current thread is interrupted during the call, even if the value is already available. * - * @throws CancellationException {@inheritDoc} + * @throws CancellationException if the computation was cancelled */ @CanIgnoreReturnValue @Override @@ -539,7 +540,7 @@ public V get(long timeout, TimeUnit unit) *

The default {@link AbstractFuture} implementation throws {@code InterruptedException} if the * current thread is interrupted during the call, even if the value is already available. * - * @throws CancellationException {@inheritDoc} + * @throws CancellationException if the computation was cancelled */ @CanIgnoreReturnValue @Override diff --git a/guava/src/com/google/common/util/concurrent/ExecutionSequencer.java b/guava/src/com/google/common/util/concurrent/ExecutionSequencer.java index 4e13a9d0b315..fd1ceac0408f 100644 --- a/guava/src/com/google/common/util/concurrent/ExecutionSequencer.java +++ b/guava/src/com/google/common/util/concurrent/ExecutionSequencer.java @@ -29,6 +29,7 @@ import com.google.errorprone.annotations.concurrent.LazyInit; import java.util.concurrent.Callable; import java.util.concurrent.Executor; +import java.util.concurrent.Future; import java.util.concurrent.atomic.AtomicReference; import javax.annotation.CheckForNull; import org.checkerframework.checker.nullness.qual.Nullable; @@ -37,7 +38,7 @@ * Serializes execution of tasks, somewhat like an "asynchronous {@code synchronized} block." Each * {@linkplain #submit enqueued} callable will not be submitted to its associated executor until the * previous callable has returned -- and, if the previous callable was an {@link AsyncCallable}, not - * until the {@code Future} it returned is {@linkplain Future#isDone done} (successful, failed, or + * until the {@code Future} it returned is {@linkplain Future#isDone()} (successful, failed, or * cancelled). * *

This class serializes execution of submitted tasks but not any listeners of diff --git a/guava/src/com/google/common/util/concurrent/ListeningExecutorService.java b/guava/src/com/google/common/util/concurrent/ListeningExecutorService.java index b870e34fef59..ade3e6c44992 100644 --- a/guava/src/com/google/common/util/concurrent/ListeningExecutorService.java +++ b/guava/src/com/google/common/util/concurrent/ListeningExecutorService.java @@ -47,21 +47,21 @@ public interface ListeningExecutorService extends ExecutorService { /** * @return a {@code ListenableFuture} representing pending completion of the task - * @throws RejectedExecutionException {@inheritDoc} + * @throws RejectedExecutionException if the task cannot be scheduled for execution */ @Override ListenableFuture submit(Callable task); /** * @return a {@code ListenableFuture} representing pending completion of the task - * @throws RejectedExecutionException {@inheritDoc} + * @throws RejectedExecutionException if the task cannot be scheduled for execution */ @Override ListenableFuture submit(Runnable task); /** * @return a {@code ListenableFuture} representing pending completion of the task - * @throws RejectedExecutionException {@inheritDoc} + * @throws RejectedExecutionException if the task cannot be scheduled for execution */ @Override ListenableFuture submit( @@ -82,7 +82,7 @@ public interface ListeningExecutorService extends ExecutorService { * @return A list of {@code ListenableFuture} instances representing the tasks, in the same * sequential order as produced by the iterator for the given task list, each of which has * completed. - * @throws RejectedExecutionException {@inheritDoc} + * @throws RejectedExecutionException if the task cannot be scheduled for execution * @throws NullPointerException if any task is null */ @Override @@ -105,7 +105,7 @@ public interface ListeningExecutorService extends ExecutorService { * sequential order as produced by the iterator for the given task list. If the operation did * not time out, each task will have completed. If it did time out, some of these tasks will * not have completed. - * @throws RejectedExecutionException {@inheritDoc} + * @throws RejectedExecutionException if the task cannot be scheduled for execution * @throws NullPointerException if any task is null */ @Override diff --git a/guava/src/module-info.java b/guava/src/module-info.java new file mode 100644 index 000000000000..e800e4d8538b --- /dev/null +++ b/guava/src/module-info.java @@ -0,0 +1,43 @@ +// GENERATED FILE - DO NOT EDIT + +/* + * 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. + */ + +/** + * Google Guava + */ +module com.google.common { + requires static jdk.unsupported; + requires java.logging; + requires com.google.common.util.concurrent.internal; + + exports com.google.common.annotations; + exports com.google.common.base; + exports com.google.common.cache; + exports com.google.common.collect; + exports com.google.common.escape; + exports com.google.common.eventbus; + exports com.google.common.graph; + exports com.google.common.hash; + exports com.google.common.html; + exports com.google.common.io; + exports com.google.common.math; + exports com.google.common.net; + exports com.google.common.primitives; + exports com.google.common.reflect; + exports com.google.common.util.concurrent; + exports com.google.common.xml; +} diff --git a/pom.xml b/pom.xml index f92855fb4ef8..235a23d31916 100644 --- a/pom.xml +++ b/pom.xml @@ -6,12 +6,18 @@ 4.0.0 com.google.guava guava-parent - HEAD-jre-SNAPSHOT + 1.0-HEAD-jre-SNAPSHOT pom Guava Maven Parent Parent for guava artifacts https://github.com/google/guava + + all + false + 48 + + true %regex[.*.class] 1.4.2 @@ -19,7 +25,10 @@ 3.42.0 2.26.1 3.0.0 + 1.0.2 9+181-r4173-1 + + 21 2024-01-02T00:00:00Z @@ -29,9 +38,17 @@ integration standard-jvm jre - HEAD-android-SNAPSHOT + 1.0-HEAD-android-SNAPSHOT android android + https://oss.sonatype.org/content/repositories/snapshots/ + https://oss.sonatype.org/service/local/staging/deploy/maven2/ + + true + + 3 GitHub Issues @@ -41,7 +58,7 @@ Apache License, Version 2.0 - http://www.apache.org/licenses/LICENSE-2.0.txt + https://www.apache.org/licenses/LICENSE-2.0.txt repo @@ -56,7 +73,7 @@ Kevin Bourrillion kevinb@google.com Google - http://www.google.com + https://www.google.com owner developer @@ -74,6 +91,7 @@ guava-gwt guava-testlib guava-tests + guava-bench @@ -123,21 +141,13 @@ maven-compiler-plugin - 3.8.1 + 3.12.1 1.8 1.8 UTF-8 true - - - -sourcepath - doesnotexist + -XDcompilePolicy=simple @@ -160,7 +170,7 @@ maven-jar-plugin - 3.2.0 + 3.3.0 maven-source-plugin @@ -206,7 +216,7 @@ maven-javadoc-plugin - 3.5.0 + 3.6.3 true true @@ -218,7 +228,7 @@ -Xdoclint:-html true - ${java.specification.version} + ${javadoc.specification.version} ${maven-javadoc-plugin.additionalJOptions} @@ -238,7 +248,7 @@ maven-surefire-plugin - 2.7.2 + 3.2.5 ${test.include} @@ -257,6 +267,8 @@ -Xmx1536M -Duser.language=hi -Duser.country=IN ${test.add.args} ${test.add.opens} + true + 2C @@ -272,6 +284,33 @@ build-helper-maven-plugin 3.4.0 + + maven-gpg-plugin + 3.0.1 + + + dev.sigstore + sigstore-maven-plugin + 0.4.0 + + + org.spdx + spdx-maven-plugin + 0.7.3 + + + maven-jmod-plugin + 3.0.0-alpha-1 + + + maven-jacoco-plugin + 0.8.11 + + + org.codehaus.mojo + exec-maven-plugin + 3.2.0 + @@ -279,12 +318,12 @@ sonatype-nexus-snapshots Sonatype Nexus Snapshots - https://oss.sonatype.org/content/repositories/snapshots/ + ${publishing.repository.snapshots} sonatype-nexus-staging Nexus Release Repository - https://oss.sonatype.org/service/local/staging/deploy/maven2/ + ${publishing.repository.releases} guava-site @@ -326,9 +365,20 @@ sonatype-oss-release + + dev.sigstore + sigstore-maven-plugin + + + sign + + sign + + + + maven-gpg-plugin - 3.0.1 sign-artifacts @@ -340,8 +390,58 @@ - - + + + + sigstore + + + + dev.sigstore + sigstore-maven-plugin + + + sign + + sign + + + + + + + + + sign + true + + + + + signing + + + + maven-gpg-plugin + + + sign-artifacts + verify + + sign + + + + + + + + + sign + true + + +