From ac7c5c7265ac1ebb88f4b6ebf9e7010ff4c5e8ad Mon Sep 17 00:00:00 2001 From: StepSecurity Bot Date: Thu, 7 Mar 2024 19:18:20 -0800 Subject: [PATCH 01/40] chore(ci): apply hardening to ci jobs - chore: apply 'Harden Runner' auditing to all ci tasks - chore: apply `persist-credentials: false` to checkout tasks - chore: publish dependency graph and add dependency review check - chore: add codeql scan job (temp) Bumps [actions/checkout](https://github.com/actions/checkout) from 3.6.0 to 4.1.1. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/v3.6.0...b4ffde65f46336ab88eb53be808477a3936bae11) Bumps [actions/dependency-review-action](https://github.com/actions/dependency-review-action) from 2.5.1 to 4.1.3. - [Release notes](https://github.com/actions/dependency-review-action/releases) - [Commits](https://github.com/actions/dependency-review-action/compare/0efb1d1d84fc9633afcdaad14c485cbbc90ef46c...9129d7d40b8c12c1ed0f60400d00c92d437adcce) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-major - dependency-name: actions/dependency-review-action dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: StepSecurity Bot Signed-off-by: Sam Gammon Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/ci.yml | 15 +++- .github/workflows/codeql.yml | 68 +++++++++++++++++++ .github/workflows/dependency-review.yml | 33 +++++++++ .../workflows/gradle-wrapper-validation.yml | 15 +++- .github/workflows/scorecard.yml | 4 ++ 5 files changed, 133 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/codeql.yml create mode 100644 .github/workflows/dependency-review.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d1b4e5a3b10b..1be878db054a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -30,6 +30,10 @@ jobs: env: ROOT_POM: ${{ matrix.root-pom }} steps: + - name: Harden Runner + uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0 + with: + egress-policy: audit # 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 @@ -37,9 +41,10 @@ jobs: access_token: ${{ github.token }} - 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' @@ -66,6 +71,10 @@ jobs: 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@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 - name: 'Set up JDK 21' @@ -91,6 +100,10 @@ jobs: 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@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 - name: 'Set up JDK 11' diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml new file mode 100644 index 000000000000..df4d4495e2d7 --- /dev/null +++ b/.github/workflows/codeql.yml @@ -0,0 +1,68 @@ +name: "CodeQL" + +on: + push: + branches: ["master"] + pull_request: + # The branches below must be a subset of the branches above + branches: ["master"] + schedule: + - cron: "0 0 * * 1" + +permissions: + contents: read + +jobs: + analyze: + name: Analyze + 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: + egress-policy: audit + - name: Checkout repository + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + with: + persist-credentials: false + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@928ff8c822d966a999092a6a35e32177899afb7c # v2.24.6 + with: + languages: ${{ matrix.language }} + # If you wish to specify custom queries, you can do so here or in a config file. + # By default, queries listed here will override any specified in a config file. + # Prefix the list here with "+" to use these queries and those in the config file. + + # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). + # If this step fails, then you should remove it and run the build manually (see below) + - name: Autobuild + uses: github/codeql-action/autobuild@928ff8c822d966a999092a6a35e32177899afb7c # v2.24.6 + + # ℹī¸ Command-line programs to run using the OS shell. + # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun + + # If the Autobuild fails above, remove it and uncomment the following three lines. + # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance. + + # - run: | + # echo "Run, Build Application using script" + # ./location_of_script_within_repo/buildscript.sh + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@928ff8c822d966a999092a6a35e32177899afb7c # v2.24.6 + 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..8b419a6a39ad --- /dev/null +++ b/.github/workflows/dependency-review.yml @@ -0,0 +1,33 @@ +name: 'Dependency Graph' +on: + pull_request: {} + push: + branches: + - master + +permissions: + contents: read + +jobs: + dependency-review: + name: 'Dependency Graph' + runs-on: ubuntu-latest + permissions: + contents: read # needed to check out the repository + 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: + egress-policy: audit + - name: 'Checkout Repository' + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + - name: Maven Dependency Tree Dependency Submission + uses: advanced-security/maven-dependency-submission-action@bfd2106013da0957cdede0b6c39fb5ca25ae375e # v4.0.2 + with: + token: ${{ secrets.GH_GRAPH_PUBLISH_TOKEN }} + - 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..df713e9f2889 100644 --- a/.github/workflows/gradle-wrapper-validation.yml +++ b/.github/workflows/gradle-wrapper-validation.yml @@ -1,5 +1,11 @@ name: "Validate Gradle Wrapper" -on: [push, pull_request] +on: + push: + branches: + - master + pull_request: + branches: + - master permissions: contents: read @@ -9,5 +15,12 @@ jobs: name: "Validation" runs-on: ubuntu-latest steps: + - name: Harden Runner + uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0 + with: + egress-policy: audit - 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/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: From 2bee2a2c86694ab4fda42c2c7dc83952970a49ea Mon Sep 17 00:00:00 2001 From: Sam Gammon Date: Thu, 7 Mar 2024 20:29:57 -0800 Subject: [PATCH 02/40] chore(ci): refactor into reusable workflows This change refactors the main CI workflow into two new workflows, `on.pr.yml` and `on.push.yml`, which each call into the exiting CI job as a reusable workflow. This has the nice benefit of putting all tests, checks, builds, etc., on one screen during development on GitHub, allows customization of the PR vs. push flow, and yet keeps behavior fully consistent between the two. - chore: move ci jobs to `workflow_call` trigger - chore: add entrypoint jobs for PR and Push events - chore: cleanup permissions and dispatch checks/tests Signed-off-by: Sam Gammon --- .github/workflows/ci.yml | 17 ++++--- .github/workflows/codeql.yml | 15 +++--- .github/workflows/dependency-review.yml | 23 ++++++---- .../workflows/gradle-wrapper-validation.yml | 10 ++-- .github/workflows/on.pr.yml | 46 +++++++++++++++++++ .github/workflows/on.push.yml | 35 ++++++++++++++ 6 files changed, 113 insertions(+), 33 deletions(-) create mode 100644 .github/workflows/on.pr.yml create mode 100644 .github/workflows/on.push.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1be878db054a..1c443c6a84be 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,12 +1,8 @@ name: CI on: - push: - branches: - - master - pull_request: - branches: - - master + workflow_call: {} + workflow_dispatch: {} permissions: contents: read @@ -21,14 +17,17 @@ jobs: matrix: os: [ ubuntu-latest ] java: [ 8, 11, 17, 21 ] - root-pom: [ 'pom.xml', 'android/pom.xml' ] + mode: [ 'JRE', 'Android' ] include: - os: windows-latest java: 21 - root-pom: pom.xml + mode: JRE + - os: windows-latest + java: 21 + mode: Android runs-on: ${{ matrix.os }} env: - ROOT_POM: ${{ matrix.root-pom }} + ROOT_POM: ${{ matrix.mode == 'Android' && 'android/pom.xml' || 'pom.xml' }} steps: - name: Harden Runner uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0 diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index df4d4495e2d7..15d155c0e0f7 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -1,11 +1,10 @@ name: "CodeQL" on: + workflow_call: {} + workflow_dispatch: {} push: branches: ["master"] - pull_request: - # The branches below must be a subset of the branches above - branches: ["master"] schedule: - cron: "0 0 * * 1" @@ -14,7 +13,7 @@ permissions: jobs: analyze: - name: Analyze + name: CodeQL Analysis runs-on: ubuntu-latest permissions: actions: read @@ -37,10 +36,8 @@ jobs: uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 with: persist-credentials: false - - # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@928ff8c822d966a999092a6a35e32177899afb7c # v2.24.6 + uses: github/codeql-action/init@8a470fddafa5cbb6266ee11b37ef4d8aae19c571 # v3.24.6 with: languages: ${{ matrix.language }} # If you wish to specify custom queries, you can do so here or in a config file. @@ -50,7 +47,7 @@ jobs: # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). # If this step fails, then you should remove it and run the build manually (see below) - name: Autobuild - uses: github/codeql-action/autobuild@928ff8c822d966a999092a6a35e32177899afb7c # v2.24.6 + uses: github/codeql-action/autobuild@8a470fddafa5cbb6266ee11b37ef4d8aae19c571 # v3.24.6 # ℹī¸ Command-line programs to run using the OS shell. # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun @@ -63,6 +60,6 @@ jobs: # ./location_of_script_within_repo/buildscript.sh - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@928ff8c822d966a999092a6a35e32177899afb7c # v2.24.6 + uses: github/codeql-action/analyze@8a470fddafa5cbb6266ee11b37ef4d8aae19c571 # v3.24.6 with: category: "/language:${{matrix.language}}" diff --git a/.github/workflows/dependency-review.yml b/.github/workflows/dependency-review.yml index 8b419a6a39ad..ea5d4df36afa 100644 --- a/.github/workflows/dependency-review.yml +++ b/.github/workflows/dependency-review.yml @@ -1,9 +1,17 @@ name: 'Dependency Graph' on: - pull_request: {} - push: - branches: - - master + 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 @@ -13,8 +21,8 @@ jobs: name: 'Dependency Graph' runs-on: ubuntu-latest permissions: - contents: read # needed to check out the repository - id-token: write # needed to exchange the graph publish token for an access token + 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 @@ -23,9 +31,8 @@ jobs: - 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 - with: - token: ${{ secrets.GH_GRAPH_PUBLISH_TOKEN }} - name: 'Dependency Review' uses: actions/dependency-review-action@9129d7d40b8c12c1ed0f60400d00c92d437adcce # v4.1.3 continue-on-error: true diff --git a/.github/workflows/gradle-wrapper-validation.yml b/.github/workflows/gradle-wrapper-validation.yml index df713e9f2889..55069fbc58e2 100644 --- a/.github/workflows/gradle-wrapper-validation.yml +++ b/.github/workflows/gradle-wrapper-validation.yml @@ -1,18 +1,14 @@ name: "Validate Gradle Wrapper" on: - push: - branches: - - master - pull_request: - branches: - - master + workflow_call: {} + workflow_dispatch: {} permissions: contents: read jobs: validation: - name: "Validation" + name: "Gradle Wrapper Validate" runs-on: ubuntu-latest steps: - name: Harden Runner diff --git a/.github/workflows/on.pr.yml b/.github/workflows/on.pr.yml new file mode 100644 index 000000000000..a530d42a17a6 --- /dev/null +++ b/.github/workflows/on.pr.yml @@ -0,0 +1,46 @@ +name: PR + +on: + pull_request: + branches: + - master + +concurrency: + group: guava-pr-${{ github.event.number }} + cancel-in-progress: true + +permissions: + contents: read + +jobs: + ## Run main CI build and tests. + run-ci: + name: "Build & Test" + uses: ./.github/workflows/ci.yml + permissions: + actions: write + contents: 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 diff --git a/.github/workflows/on.push.yml b/.github/workflows/on.push.yml new file mode 100644 index 000000000000..08706b14f87c --- /dev/null +++ b/.github/workflows/on.push.yml @@ -0,0 +1,35 @@ +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 & Test" + uses: ./.github/workflows/ci.yml + permissions: + actions: write + contents: write + + ## 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 From 57d61149165bd1a3db64a921c53a5b38b22eb283 Mon Sep 17 00:00:00 2001 From: Sam Gammon Date: Thu, 7 Mar 2024 20:52:41 -0800 Subject: [PATCH 03/40] chore(ci): switch to enforced hardening mode This changeset switches the StepSecurity hardening action to enforced mode, where previously it was running in `audit` mode. Now, audit logs have been gathered and it is time to seal off the list of accessible network endpoints for a given job. - chore: gather and apply network endpoints for each job - chore: move to `block` mode for `egress-policy` in `step-security/harden-runner` Signed-off-by: Sam Gammon --- .github/workflows/ci.yml | 23 +++++--- .github/workflows/codeql.yml | 53 ++++++++++++------- .github/workflows/dependency-review.yml | 8 ++- .../workflows/gradle-wrapper-validation.yml | 5 +- 4 files changed, 59 insertions(+), 30 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1c443c6a84be..1118b157d46c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,9 +10,8 @@ permissions: 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 }}" + name: "JDK ${{ matrix.java }} / ${{ matrix.mode }} (${{ matrix.os }})" strategy: matrix: os: [ ubuntu-latest ] @@ -32,12 +31,20 @@ jobs: - name: Harden Runner uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0 with: - egress-policy: audit - # 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 }} + 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: diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 15d155c0e0f7..621e59148d6c 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -31,35 +31,48 @@ jobs: - name: Harden Runner uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0 with: - egress-policy: audit + 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 }} - # If you wish to specify custom queries, you can do so here or in a config file. - # By default, queries listed here will override any specified in a config file. - # Prefix the list here with "+" to use these queries and those in the config file. - - # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). - # If this step fails, then you should remove it and run the build manually (see below) - - name: Autobuild - uses: github/codeql-action/autobuild@8a470fddafa5cbb6266ee11b37ef4d8aae19c571 # v3.24.6 - - # ℹī¸ Command-line programs to run using the OS shell. - # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun - - # If the Autobuild fails above, remove it and uncomment the following three lines. - # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance. - - # - run: | - # echo "Run, Build Application using script" - # ./location_of_script_within_repo/buildscript.sh - + - 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 \ + -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 index ea5d4df36afa..f302b07d983b 100644 --- a/.github/workflows/dependency-review.yml +++ b/.github/workflows/dependency-review.yml @@ -27,7 +27,13 @@ jobs: - name: Harden Runner uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0 with: - egress-policy: audit + 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 diff --git a/.github/workflows/gradle-wrapper-validation.yml b/.github/workflows/gradle-wrapper-validation.yml index 55069fbc58e2..4b905305a8dd 100644 --- a/.github/workflows/gradle-wrapper-validation.yml +++ b/.github/workflows/gradle-wrapper-validation.yml @@ -14,7 +14,10 @@ jobs: - name: Harden Runner uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0 with: - egress-policy: audit + 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: From 9c737bffac719487c682f6f959152361f2403ea7 Mon Sep 17 00:00:00 2001 From: Sam Gammon Date: Thu, 7 Mar 2024 21:08:32 -0800 Subject: [PATCH 04/40] feat(ci): slsa provenance support This changeset adds SLSA 3+ provenance support to the workflow. The main CI run has now been split into two: `ci.build.yml`, which only builds the library and is provenance-capable, and `ci.test.yml`, which is the previous CI logic. The regular build logic is applied only on push, and can be applied on PRs too, with publish of provenance material turned off. The test suite is invoked from PRs. The workflows have been split into build/test phases to avoid publishing provenance data and GitHub artifacts for build matrix outputs. JARs are uniform across OS targets, so there is no need to gather and publish for more than Ubuntu. - feat: add slsa support to build workflow - chore: split `test` into `build` and `test` workflows - chore: use new workflows (build/test) from push/pr triggers Signed-off-by: Sam Gammon --- .github/workflows/ci.build.yml | 183 ++++++++++++++++++++++ .github/workflows/{ci.yml => ci.test.yml} | 58 +------ .github/workflows/codeql.yml | 8 +- .github/workflows/on.pr.yml | 22 ++- .github/workflows/on.push.yml | 8 +- 5 files changed, 219 insertions(+), 60 deletions(-) create mode 100644 .github/workflows/ci.build.yml rename .github/workflows/{ci.yml => ci.test.yml} (53%) diff --git a/.github/workflows/ci.build.yml b/.github/workflows/ci.build.yml new file mode 100644 index 000000000000..79448d235219 --- /dev/null +++ b/.github/workflows/ci.build.yml @@ -0,0 +1,183 @@ +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 11' + uses: actions/setup-java@9704b39bf258b59bc04b50fa2dd55e9ed76b47a8 # v4.1.0 + with: + java-version: 11 + 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: 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 11' + uses: actions/setup-java@9704b39bf258b59bc04b50fa2dd55e9ed76b47a8 # v4.1.0 + with: + java-version: 11 + 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 11' + uses: actions/setup-java@9704b39bf258b59bc04b50fa2dd55e9ed76b47a8 # v4.1.0 + 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/ci.yml b/.github/workflows/ci.test.yml similarity index 53% rename from .github/workflows/ci.yml rename to .github/workflows/ci.test.yml index 1118b157d46c..124ce4adbfd2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.test.yml @@ -1,4 +1,4 @@ -name: CI +name: Tests on: workflow_call: {} @@ -11,7 +11,7 @@ jobs: test: permissions: contents: read # for actions/checkout to fetch code - name: "JDK ${{ matrix.java }} / ${{ matrix.mode }} (${{ matrix.os }})" + name: "JDK ${{ matrix.java }} ${{ matrix.mode }} (${{ matrix.os }})" strategy: matrix: os: [ ubuntu-latest ] @@ -25,6 +25,8 @@ jobs: 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: @@ -70,55 +72,3 @@ jobs: 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: Harden Runner - uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0 - with: - egress-policy: audit - - 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: Harden Runner - uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0 - with: - egress-policy: audit - - 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 index 621e59148d6c..d2d37a273117 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -1,7 +1,13 @@ name: "CodeQL" on: - workflow_call: {} + workflow_call: + inputs: + publish: + type: boolean + description: "Publish SARIF" + default: true + workflow_dispatch: {} push: branches: ["master"] diff --git a/.github/workflows/on.pr.yml b/.github/workflows/on.pr.yml index a530d42a17a6..7c8f965fd95c 100644 --- a/.github/workflows/on.pr.yml +++ b/.github/workflows/on.pr.yml @@ -13,13 +13,27 @@ 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. - run-ci: - name: "Build & Test" - uses: ./.github/workflows/ci.yml + 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: @@ -44,3 +58,5 @@ jobs: 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 index 08706b14f87c..f6aedfa8ea1c 100644 --- a/.github/workflows/on.push.yml +++ b/.github/workflows/on.push.yml @@ -15,11 +15,15 @@ permissions: jobs: ## Run main CI build and tests. run-ci: - name: "Build & Test" - uses: ./.github/workflows/ci.yml + 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: From a785edfc3359a77852400c5869a2b60d3f6af869 Mon Sep 17 00:00:00 2001 From: Sam Gammon Date: Thu, 7 Mar 2024 22:56:44 -0800 Subject: [PATCH 05/40] chore(ci): build with `--strict-checksums` Fails the build if any downloaded dependencies fail their checksum verification. - chore: add `--strict-checksums` flag to `mvnw` calls in ci --- .github/workflows/ci.build.yml | 2 +- .github/workflows/ci.test.yml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.build.yml b/.github/workflows/ci.build.yml index 79448d235219..7a13f13c9caa 100644 --- a/.github/workflows/ci.build.yml +++ b/.github/workflows/ci.build.yml @@ -86,7 +86,7 @@ jobs: 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 + run: ./mvnw --strict-checksums -B -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn install -U -DskipTests=true -f $ROOT_POM - name: Generate hashes shell: bash id: hash diff --git a/.github/workflows/ci.test.yml b/.github/workflows/ci.test.yml index 124ce4adbfd2..5830a086870e 100644 --- a/.github/workflows/ci.test.yml +++ b/.github/workflows/ci.test.yml @@ -59,10 +59,10 @@ jobs: 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 + run: ./mvnw --strict-checksums -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 + run: ./mvnw --strict-checksums -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() }} From b7fd83cade112bb8f6529b02670ffcbce86646eb Mon Sep 17 00:00:00 2001 From: Sam Gammon Date: Fri, 8 Mar 2024 13:50:30 -0800 Subject: [PATCH 06/40] chore(ci): build avoidance (javadoc, gpg) - chore: don't rebuild javadoc during tests in ci - chore: don't run with gpg enabled in ci Signed-off-by: Sam Gammon --- .github/workflows/ci.build.yml | 24 +++++++++++++++++------- .github/workflows/ci.test.yml | 22 ++++++++++++++++++++-- .github/workflows/codeql.yml | 1 + 3 files changed, 38 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.build.yml b/.github/workflows/ci.build.yml index 7a13f13c9caa..52690da38308 100644 --- a/.github/workflows/ci.build.yml +++ b/.github/workflows/ci.build.yml @@ -78,15 +78,25 @@ jobs: uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 with: persist-credentials: false - - name: 'Set up JDK 11' + - name: 'Set up JDK 21' uses: actions/setup-java@9704b39bf258b59bc04b50fa2dd55e9ed76b47a8 # v4.1.0 with: - java-version: 11 + 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 -f $ROOT_POM + run: | + ./mvnw \ + --strict-checksums \ + -B \ + -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn \ + install \ + -U \ + -DskipTests=true \ + -Dmaven.javadoc.skip=false \ + -Dgpg.skip \ + -f $ROOT_POM - name: Generate hashes shell: bash id: hash @@ -138,10 +148,10 @@ jobs: egress-policy: audit - name: 'Check out repository' uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - - name: 'Set up JDK 11' + - name: 'Set up JDK 21' uses: actions/setup-java@9704b39bf258b59bc04b50fa2dd55e9ed76b47a8 # v4.1.0 with: - java-version: 11 + java-version: 21 distribution: 'zulu' server-id: ${{ inputs.repository }} server-username: CI_DEPLOY_USERNAME @@ -171,10 +181,10 @@ jobs: egress-policy: audit - name: 'Check out repository' uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - - name: 'Set up JDK 11' + - name: 'Set up JDK 21' uses: actions/setup-java@9704b39bf258b59bc04b50fa2dd55e9ed76b47a8 # v4.1.0 with: - java-version: 11 + java-version: 21 distribution: 'zulu' cache: 'maven' - name: 'Generate latest docs' diff --git a/.github/workflows/ci.test.yml b/.github/workflows/ci.test.yml index 5830a086870e..24cd3f30f965 100644 --- a/.github/workflows/ci.test.yml +++ b/.github/workflows/ci.test.yml @@ -59,10 +59,28 @@ jobs: 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 -f $ROOT_POM + run: | + ./mvnw \ + --strict-checksums \ + -B \ + -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn \ + install \ + -U \ + -DskipTests=true \ + -Dgpg.skip \ + -Dmaven.javadoc.skip=true \ + -f $ROOT_POM - name: 'Test' shell: bash - run: ./mvnw --strict-checksums -B -P!standard-with-extra-repos verify -U -Dmaven.javadoc.skip=true -f $ROOT_POM + run: | + ./mvnw \ + --strict-checksums \ + -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() }} diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index d2d37a273117..bdc2e9cd1d09 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -76,6 +76,7 @@ jobs: -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 From 0c3ea61936ad1a06de4ef945c47eb14d48ebd652 Mon Sep 17 00:00:00 2001 From: Sam Gammon Date: Thu, 7 Mar 2024 22:05:03 -0800 Subject: [PATCH 07/40] chore(build): parameterize deploy repositories Adds two build parameters - `publishing.repository.snapshots`: Snapshot repo to deploy to - `publishing.repository.releases`: Releases repo to deploy to Both default to their current values, Sonatype. This small inert change allows a fork to easily publish to a different repository without resorting to a code change. Signed-off-by: Sam Gammon --- pom.xml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index f92855fb4ef8..a7704a6e6e31 100644 --- a/pom.xml +++ b/pom.xml @@ -32,6 +32,8 @@ HEAD-android-SNAPSHOT android android + https://oss.sonatype.org/content/repositories/snapshots/ + https://oss.sonatype.org/service/local/staging/deploy/maven2/ GitHub Issues @@ -279,12 +281,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 From 9bb5597c73236b8e0fa928a79d586923cb1ce819 Mon Sep 17 00:00:00 2001 From: Sam Gammon Date: Thu, 7 Mar 2024 22:10:45 -0800 Subject: [PATCH 08/40] feat(build): sigstore publishing plugin This changeset adds the Maven Sigstore plugin for use during publishing to Sonatype and other public repositories. - chore: add sigstore plugin to build Signed-off-by: Sam Gammon --- pom.xml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/pom.xml b/pom.xml index a7704a6e6e31..6df3c36166e0 100644 --- a/pom.xml +++ b/pom.xml @@ -328,6 +328,19 @@ sonatype-oss-release + + dev.sigstore + sigstore-maven-plugin + 0.4.0 + + + sign + + sign + + + + maven-gpg-plugin 3.0.1 From 8beadb87ca4ab5837e1bfbf5d3260d36f433397f Mon Sep 17 00:00:00 2001 From: Sam Gammon Date: Thu, 7 Mar 2024 23:17:57 -0800 Subject: [PATCH 09/40] chore(ci): document gha workflows Signed-off-by: Sam Gammon --- .github/workflows/ci.build.yml | 21 +++++++++++++++++++++ .github/workflows/ci.test.yml | 21 +++++++++++++++++++++ .github/workflows/dependency-review.yml | 13 +++++++++++++ .github/workflows/on.pr.yml | 8 ++++++++ .github/workflows/on.push.yml | 8 ++++++++ 5 files changed, 71 insertions(+) diff --git a/.github/workflows/ci.build.yml b/.github/workflows/ci.build.yml index 52690da38308..86c378599e2e 100644 --- a/.github/workflows/ci.build.yml +++ b/.github/workflows/ci.build.yml @@ -1,3 +1,24 @@ +# 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: diff --git a/.github/workflows/ci.test.yml b/.github/workflows/ci.test.yml index 24cd3f30f965..a12e8a2d9b1e 100644 --- a/.github/workflows/ci.test.yml +++ b/.github/workflows/ci.test.yml @@ -1,3 +1,24 @@ +# 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: diff --git a/.github/workflows/dependency-review.yml b/.github/workflows/dependency-review.yml index f302b07d983b..abc802dae2ac 100644 --- a/.github/workflows/dependency-review.yml +++ b/.github/workflows/dependency-review.yml @@ -1,3 +1,16 @@ +# 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: diff --git a/.github/workflows/on.pr.yml b/.github/workflows/on.pr.yml index 7c8f965fd95c..df88ff841bd9 100644 --- a/.github/workflows/on.pr.yml +++ b/.github/workflows/on.pr.yml @@ -1,3 +1,11 @@ +# 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: diff --git a/.github/workflows/on.push.yml b/.github/workflows/on.push.yml index f6aedfa8ea1c..91e567b6d569 100644 --- a/.github/workflows/on.push.yml +++ b/.github/workflows/on.push.yml @@ -1,3 +1,11 @@ +# 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: From 35d8a1da065d3cd7715c95003c00b5b33ab72ca5 Mon Sep 17 00:00:00 2001 From: Sam Gammon Date: Fri, 8 Mar 2024 00:05:11 -0800 Subject: [PATCH 10/40] chore(ci): add spdx plugin Signed-off-by: Sam Gammon --- guava/pom.xml | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++- pom.xml | 16 ++++++++-- 2 files changed, 97 insertions(+), 3 deletions(-) diff --git a/guava/pom.xml b/guava/pom.xml index be0bab174e16..f0e50c58bb00 100644 --- a/guava/pom.xml +++ b/guava/pom.xml @@ -9,7 +9,7 @@ HEAD-jre-SNAPSHOT guava - bundle + jar Guava: Google Core Libraries for Java https://github.com/google/guava @@ -222,4 +222,86 @@ + + + spdx + + [11, + + + + + + 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/pom.xml b/pom.xml index 6df3c36166e0..e22e87011064 100644 --- a/pom.xml +++ b/pom.xml @@ -274,6 +274,20 @@ 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 + @@ -331,7 +345,6 @@ dev.sigstore sigstore-maven-plugin - 0.4.0 sign @@ -343,7 +356,6 @@ maven-gpg-plugin - 3.0.1 sign-artifacts From 7fe72774b50b97c67686f88c26257b49fb2a9d39 Mon Sep 17 00:00:00 2001 From: Sam Gammon Date: Fri, 8 Mar 2024 12:43:34 -0800 Subject: [PATCH 11/40] feat(jpms): add `module-info` definition for guava MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This changeset adds full support for modular Java builds in Guava, and in libraries which depend on Guava. The Guava JAR for JRE now structures as a Multi-Release JAR, with a module definition situated in `META-INF/versions/9/`. Guava remains compatible with JDK 8. - feat: add `module-info.java` to `guava` module - chore: update `guava` to build MRJAR - chore: adjust dev version → `1.0-HEAD-[jre|android]-SNAPSHOT` - chore: upgrade maven compiler plugin → `3.12.1` Fixes and closes google/guava#2970 Relates-To: elide-dev/jpms#1 Signed-off-by: Sam Gammon --- android/guava-bom/pom.xml | 2 +- android/guava-testlib/pom.xml | 2 +- android/guava-tests/pom.xml | 2 +- android/guava/pom.xml | 2 +- android/pom.xml | 2 +- guava-bom/pom.xml | 2 +- guava-gwt/pom.xml | 2 +- guava-testlib/pom.xml | 2 +- guava-tests/pom.xml | 2 +- guava/pom.xml | 44 +++++++++++++++++++++++++++++++++-- guava/src/module-info.java | 44 +++++++++++++++++++++++++++++++++++ pom.xml | 14 +++-------- 12 files changed, 98 insertions(+), 22 deletions(-) create mode 100644 guava/src/module-info.java 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..ca267e58ef52 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 diff --git a/android/pom.xml b/android/pom.xml index 96ea9fa41df5..c8e3e357322f 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 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..cd2bc969833b 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 diff --git a/guava-tests/pom.xml b/guava-tests/pom.xml index 8596221d8316..ca74eb2e2814 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 diff --git a/guava/pom.xml b/guava/pom.xml index f0e50c58bb00..413f15f767ce 100644 --- a/guava/pom.xml +++ b/guava/pom.xml @@ -6,7 +6,7 @@ com.google.guava guava-parent - HEAD-jre-SNAPSHOT + 1.0-HEAD-jre-SNAPSHOT guava jar @@ -62,9 +62,11 @@ - com.google.common + true + + /module-info.class @@ -100,6 +102,44 @@ maven-compiler-plugin + + + default-compile + + 1.8 + 1.8 + + module-info.java + + + + + 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 diff --git a/guava/src/module-info.java b/guava/src/module-info.java new file mode 100644 index 000000000000..e459eb9d9e8e --- /dev/null +++ b/guava/src/module-info.java @@ -0,0 +1,44 @@ +// 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 java.base; + requires java.logging; + requires jdk.unsupported; + + 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; + exports com.google.thirdparty.publicsuffix; +} diff --git a/pom.xml b/pom.xml index e22e87011064..10654cd216c3 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ 4.0.0 com.google.guava guava-parent - HEAD-jre-SNAPSHOT + 1.0-HEAD-jre-SNAPSHOT pom Guava Maven Parent Parent for guava artifacts @@ -125,21 +125,13 @@ maven-compiler-plugin - 3.8.1 + 3.12.1 1.8 1.8 UTF-8 true - - - -sourcepath - doesnotexist + -XDcompilePolicy=simple From 7178b96861e51a23eb786be157a0a711b5f7ee73 Mon Sep 17 00:00:00 2001 From: Sam Gammon Date: Fri, 8 Mar 2024 15:17:29 -0800 Subject: [PATCH 12/40] fixup! version update misalignment Signed-off-by: Sam Gammon --- README.md | 2 +- android/pom.xml | 2 +- pom.xml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) 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/pom.xml b/android/pom.xml index c8e3e357322f..e94e0f9ae12a 100644 --- a/android/pom.xml +++ b/android/pom.xml @@ -29,7 +29,7 @@ integration android android - HEAD-jre-SNAPSHOT + 1.0-HEAD-jre-SNAPSHOT standard-jvm jre diff --git a/pom.xml b/pom.xml index 10654cd216c3..9f102f7c4ce7 100644 --- a/pom.xml +++ b/pom.xml @@ -29,7 +29,7 @@ integration standard-jvm jre - HEAD-android-SNAPSHOT + 1.0-HEAD-android-SNAPSHOT android android https://oss.sonatype.org/content/repositories/snapshots/ From 813a8a0f358282a14161f0d41e40b5965ca85896 Mon Sep 17 00:00:00 2001 From: Sam Gammon Date: Fri, 8 Mar 2024 15:03:07 -0800 Subject: [PATCH 13/40] fixup! working bundle without duplicated classes Signed-off-by: Sam Gammon --- android/pom.xml | 4 ++-- guava/pom.xml | 61 +++++++++++++++++++++++++++++++++++++++++-------- pom.xml | 3 ++- 3 files changed, 55 insertions(+), 13 deletions(-) diff --git a/android/pom.xml b/android/pom.xml index e94e0f9ae12a..375d9d5590b1 100644 --- a/android/pom.xml +++ b/android/pom.xml @@ -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 diff --git a/guava/pom.xml b/guava/pom.xml index 413f15f767ce..b371e96e96ef 100644 --- a/guava/pom.xml +++ b/guava/pom.xml @@ -59,21 +59,12 @@ maven-jar-plugin - - - - true - - - - /module-info.class - true org.apache.felix maven-bundle-plugin - 5.1.8 + 5.1.9 bundle-manifest @@ -88,6 +79,7 @@ !com.google.common.base.internal, !com.google.common.util.concurrent.internal, + !META-INF.*, com.google.common.* @@ -111,6 +103,10 @@ module-info.java + + -Xlint:-removal,-options + -XDignore.symbol.file + @@ -270,6 +266,51 @@ + + 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,-options + + true + + + + + + org.apache.maven.plugins + maven-jar-plugin + + + /module-info.class + META-INF/versions/9/com/**/*.class + + + + true + ALL-UNNAMED + + + + diff --git a/pom.xml b/pom.xml index 9f102f7c4ce7..3b13769c9cbc 100644 --- a/pom.xml +++ b/pom.xml @@ -135,6 +135,7 @@ -XDcompilePolicy=simple + -Xlint:-removal,-options @@ -154,7 +155,7 @@ maven-jar-plugin - 3.2.0 + 3.3.0 maven-source-plugin From 27b60d05441579a481e1a3c34aa67775940af109 Mon Sep 17 00:00:00 2001 From: Sam Gammon Date: Fri, 8 Mar 2024 15:23:48 -0800 Subject: [PATCH 14/40] fixup! compile Xlint Signed-off-by: Sam Gammon --- guava/pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/guava/pom.xml b/guava/pom.xml index b371e96e96ef..2cd51c2de033 100644 --- a/guava/pom.xml +++ b/guava/pom.xml @@ -104,7 +104,6 @@ module-info.java - -Xlint:-removal,-options -XDignore.symbol.file @@ -288,7 +287,8 @@ --add-reads=com.google.common=ALL-UNNAMED -XDcompilePolicy=simple - -Xlint:-removal,-options + -Xlint:-removal + -Xlint:-options true From 0dfe0f85257f4e4ec6507ca3c74eb8a71c992ac0 Mon Sep 17 00:00:00 2001 From: Sam Gammon Date: Fri, 8 Mar 2024 15:26:59 -0800 Subject: [PATCH 15/40] fixup! compiler args for jdk11+ Signed-off-by: Sam Gammon --- pom.xml | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 3b13769c9cbc..32d28d04d5da 100644 --- a/pom.xml +++ b/pom.xml @@ -135,7 +135,6 @@ -XDcompilePolicy=simple - -Xlint:-removal,-options @@ -486,7 +485,26 @@ - javac-for-jvm18plus + jvm11plus + + [11,] + + + + + maven-compiler-plugin + + + -Xlint:-removal + -Xlint:-options + + + + + + + + jvm18plus + true GitHub Issues From f098e630149a539e13f7ab6f8df42b5be3bc9b26 Mon Sep 17 00:00:00 2001 From: Sam Gammon Date: Fri, 8 Mar 2024 15:03:20 -0800 Subject: [PATCH 17/40] chore: cleanup suppressions in `Striped64.java` Signed-off-by: Sam Gammon --- guava/src/com/google/common/cache/Striped64.java | 3 ++- .../src/com/google/common/util/concurrent/AbstractFuture.java | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) 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/util/concurrent/AbstractFuture.java b/guava/src/com/google/common/util/concurrent/AbstractFuture.java index 96ecda5f5168..18d49d43516e 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 |. }) From ee711e17141badfc4c5b9b1d206474f897f638de Mon Sep 17 00:00:00 2001 From: Sam Gammon Date: Fri, 8 Mar 2024 16:58:13 -0800 Subject: [PATCH 18/40] chore(labs): improve build and test speed This changeset optimizes the Guava build significantly by enabling parallel build and test features supported by Maven. With these flags enabled, only a few tests exhibit flaky behavior; applying a sensible count of test retries (3) solves the problem. As a result, the testsuite can now be executed often, because it takes about 2 minutes to run. Building is also much faster. After benchmarking different configurations, 2-threads-per-core and 2-test-forks-per-core seems optimal: ``` [INFO] Guava Maven Parent ..................... SUCCESS [ 0.121 s] [INFO] Guava: Google Core Libraries for Java .. SUCCESS [ 9.681 s] [INFO] Guava BOM .............................. SUCCESS [ 0.120 s] [INFO] Guava Testing Library .................. SUCCESS [ 47.883 s] [INFO] Guava Unit Tests ....................... SUCCESS [01:57 min] <-- [INFO] Guava GWT compatible libs .............. SUCCESS [ 6.909 s] ``` When built and executed serially: ``` [INFO] Guava Maven Parent ..................... SUCCESS [ 0.129 s] [INFO] Guava: Google Core Libraries for Java .. SUCCESS [ 15.653 s] [INFO] Guava BOM .............................. SUCCESS [ 0.064 s] [INFO] Guava Testing Library .................. SUCCESS [01:26 min] [INFO] Guava Unit Tests ....................... SUCCESS [06:26 min] <-- [INFO] Guava GWT compatible libs .............. SUCCESS [ 11.092 s] ``` Benchmark hardware: - Apple M2 Max, 96GB RAM - macOS Sonoma 14.3.1 - GraalVM CE JVM 21.0.2 ``` openjdk version "21.0.2" 2024-01-16 OpenJDK Runtime Environment GraalVM CE 21.0.2+13.1 (build 21.0.2+13-jvmci-23.1-b30) OpenJDK 64-Bit Server VM GraalVM CE 21.0.2+13.1 (build 21.0.2+13-jvmci-23.1-b30, mixed mode, sharing) ``` - chore: enable parallel build - chore: enable parallel test execution - chore: enable parallel gc for maven - chore: tune tiered compilation for maven - chore: tune thread count for maven - fix: enable test retries (max = 3) for parallel-flaky tests Signed-off-by: Sam Gammon --- .mvn/jvm.config | 1 + .mvn/maven.config | 2 ++ guava-tests/pom.xml | 4 ++++ pom.xml | 10 +++++++++- 4 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 .mvn/jvm.config create mode 100644 .mvn/maven.config 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/guava-tests/pom.xml b/guava-tests/pom.xml index ca74eb2e2814..c32525203bbc 100644 --- a/guava-tests/pom.xml +++ b/guava-tests/pom.xml @@ -87,6 +87,10 @@ maven-surefire-plugin + + true + 2.5C + maven-jar-plugin diff --git a/pom.xml b/pom.xml index 9730c4a113a7..2bc7e48ca610 100644 --- a/pom.xml +++ b/pom.xml @@ -12,6 +12,10 @@ Parent for guava artifacts https://github.com/google/guava + + all + false + 48 %regex[.*.class] 1.4.2 @@ -38,6 +42,8 @@ https://maven.apache.org/plugins-archives/maven-install-plugin-2.4/examples/installing-checksums.html --> true + + 3 GitHub Issues @@ -236,7 +242,7 @@ maven-surefire-plugin - 2.7.2 + 3.2.5 ${test.include} @@ -255,6 +261,8 @@ -Xmx1536M -Duser.language=hi -Duser.country=IN ${test.add.args} ${test.add.opens} + true + 2C From 9fc86489fefa1630f5579129a7ebd8e591bad13d Mon Sep 17 00:00:00 2001 From: Sam Gammon Date: Fri, 8 Mar 2024 17:45:52 -0800 Subject: [PATCH 19/40] =?UTF-8?q?chore:=20upgrade=20maven=20=E2=86=92=20`3?= =?UTF-8?q?.9.6`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Sam Gammon --- .mvn/wrapper/maven-wrapper.properties | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties index e1c4b83d0115..0a4095a73e29 100644 --- a/.mvn/wrapper/maven-wrapper.properties +++ b/.mvn/wrapper/maven-wrapper.properties @@ -14,8 +14,7 @@ # 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 +wrapperSha256Sum=e63a53cfb9c4d291ebe3c2b0edacb7622bbc480326beaa5a0456e412f52f066a From a51c9be164449383b51ef8b5f8bea5edf434c6ba Mon Sep 17 00:00:00 2001 From: Sam Gammon Date: Fri, 8 Mar 2024 17:50:17 -0800 Subject: [PATCH 20/40] fixup! conditional spdx, suppress spdx for irrelevant ci jobs Signed-off-by: Sam Gammon --- .github/workflows/ci.build.yml | 1 + .github/workflows/ci.test.yml | 2 ++ guava/pom.xml | 14 ++++++++++++++ pom.xml | 2 ++ 4 files changed, 19 insertions(+) diff --git a/.github/workflows/ci.build.yml b/.github/workflows/ci.build.yml index 86c378599e2e..f1d33b1f556d 100644 --- a/.github/workflows/ci.build.yml +++ b/.github/workflows/ci.build.yml @@ -116,6 +116,7 @@ jobs: -U \ -DskipTests=true \ -Dmaven.javadoc.skip=false \ + -Dguava.build.spdx=true \ -Dgpg.skip \ -f $ROOT_POM - name: Generate hashes diff --git a/.github/workflows/ci.test.yml b/.github/workflows/ci.test.yml index a12e8a2d9b1e..8eb4a9e25e73 100644 --- a/.github/workflows/ci.test.yml +++ b/.github/workflows/ci.test.yml @@ -89,6 +89,7 @@ jobs: -U \ -DskipTests=true \ -Dgpg.skip \ + -Dguava.build.spdx=false \ -Dmaven.javadoc.skip=true \ -f $ROOT_POM - name: 'Test' @@ -100,6 +101,7 @@ jobs: -P!standard-with-extra-repos \ verify \ -U \ + -Dguava.build.spdx=false \ -Dmaven.javadoc.skip=true \ -f $ROOT_POM - name: 'Print Surefire reports' diff --git a/guava/pom.xml b/guava/pom.xml index 2cd51c2de033..7e3ffe9f2138 100644 --- a/guava/pom.xml +++ b/guava/pom.xml @@ -311,6 +311,20 @@ + + + + + spdx-sign + + [11,] + + guava.build.spdx + true + + + + diff --git a/pom.xml b/pom.xml index 2bc7e48ca610..3bb635a37a21 100644 --- a/pom.xml +++ b/pom.xml @@ -16,6 +16,8 @@ all false 48 + + true %regex[.*.class] 1.4.2 From 672070c92fcb20eb1e96d18bed4f60d20c0a2b06 Mon Sep 17 00:00:00 2001 From: Sam Gammon Date: Fri, 8 Mar 2024 17:56:05 -0800 Subject: [PATCH 21/40] fixup! skip gpg in test (another) Signed-off-by: Sam Gammon --- .github/workflows/ci.test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.test.yml b/.github/workflows/ci.test.yml index 8eb4a9e25e73..cee2d16edfb9 100644 --- a/.github/workflows/ci.test.yml +++ b/.github/workflows/ci.test.yml @@ -101,6 +101,7 @@ jobs: -P!standard-with-extra-repos \ verify \ -U \ + -Dgpg.skip \ -Dguava.build.spdx=false \ -Dmaven.javadoc.skip=true \ -f $ROOT_POM From 5f2d9a09cac1ccf63e4222ff4e7edee4e5bfc300 Mon Sep 17 00:00:00 2001 From: Sam Gammon Date: Fri, 8 Mar 2024 17:56:15 -0800 Subject: [PATCH 22/40] fixup! osgi and mrjars/jpms Signed-off-by: Sam Gammon --- guava/pom.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/guava/pom.xml b/guava/pom.xml index 7e3ffe9f2138..2a22aa9f089d 100644 --- a/guava/pom.xml +++ b/guava/pom.xml @@ -76,6 +76,8 @@ + <_fixupmessages>^Classes found in the wrong directory: .* + <_jpms-module-info>com.google.common !com.google.common.base.internal, !com.google.common.util.concurrent.internal, From 0850496b8a679aae4f6d1baad39292fb8f5a2b0c Mon Sep 17 00:00:00 2001 From: Sam Gammon Date: Fri, 8 Mar 2024 19:31:10 -0800 Subject: [PATCH 23/40] feat(jpms): modularize `failureaccess` + `testlib` This change adds a `module-info.java` definition for the ancillary `failureaccess` and `testlib` libraries. Test Lib is kept as an `open module` so that it can be reflectively introspected. - feat(jpms): add `module-info.java` to `failureaccess` - feat(jpms): add `module-info.java` to `testlib` - fix: necessary fixes to get testsuite running on modular java Signed-off-by: Sam Gammon --- futures/failureaccess/pom.xml | 27 ++++++++++++++++++- futures/failureaccess/src/module-info.java | 21 +++++++++++++++ guava-testlib/pom.xml | 14 +++++++--- guava-testlib/src/module-info.java | 31 ++++++++++++++++++++++ guava-tests/pom.xml | 10 +++++++ guava/src/module-info.java | 1 + 6 files changed, 100 insertions(+), 4 deletions(-) create mode 100644 futures/failureaccess/src/module-info.java create mode 100644 guava-testlib/src/module-info.java diff --git a/futures/failureaccess/pom.xml b/futures/failureaccess/pom.xml index 8886a4b2f7de..bef7819f8968 100644 --- a/futures/failureaccess/pom.xml +++ b/futures/failureaccess/pom.xml @@ -22,14 +22,39 @@ + + maven-compiler-plugin + + + default-compile + + 1.8 + 1.8 + + module-info.java + + + + + compile-java9 + + 9 + true + + + + maven-jar-plugin - com.google.common.util.concurrent.internal + true + + META-INF/versions/9/com/**/*.java + diff --git a/futures/failureaccess/src/module-info.java b/futures/failureaccess/src/module-info.java new file mode 100644 index 000000000000..3c4edf52c69c --- /dev/null +++ b/futures/failureaccess/src/module-info.java @@ -0,0 +1,21 @@ +/* + * 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 { + requires java.base; + exports com.google.common.util.concurrent.internal; +} diff --git a/guava-testlib/pom.xml b/guava-testlib/pom.xml index cd2bc969833b..24548b0b7726 100644 --- a/guava-testlib/pom.xml +++ b/guava-testlib/pom.xml @@ -60,9 +60,6 @@ - - maven-compiler-plugin - maven-source-plugin @@ -92,6 +89,17 @@ maven-surefire-plugin + + org.apache.maven.plugins + maven-compiler-plugin + + 9 + 9 + + --add-reads=com.google.common.testlib=ALL-UNNAMED + + + diff --git a/guava-testlib/src/module-info.java b/guava-testlib/src/module-info.java new file mode 100644 index 000000000000..ee0cf879b3e8 --- /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.base; + 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.util.concurrent.testing; +} diff --git a/guava-tests/pom.xml b/guava-tests/pom.xml index c32525203bbc..94dc29026dcd 100644 --- a/guava-tests/pom.xml +++ b/guava-tests/pom.xml @@ -74,6 +74,16 @@ maven-compiler-plugin + + + default-testCompile + + + -Xlint:-removal + + + + maven-source-plugin diff --git a/guava/src/module-info.java b/guava/src/module-info.java index e459eb9d9e8e..ee63fe41df73 100644 --- a/guava/src/module-info.java +++ b/guava/src/module-info.java @@ -23,6 +23,7 @@ requires java.base; requires java.logging; requires jdk.unsupported; + requires com.google.common.util.concurrent.internal; exports com.google.common.annotations; exports com.google.common.base; From f305713ec9f98945ba7b0ea4867120188e9fa939 Mon Sep 17 00:00:00 2001 From: Sam Gammon Date: Fri, 8 Mar 2024 19:33:16 -0800 Subject: [PATCH 24/40] fix: javadoc warning fixes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This changeset generally fixes all Javadoc warnings at JVM 21, and upgrades the LTS Javadoc release to 21. Slight code changes have been made to fix Javadoc issues; no logic has changed. - fix: various javadoc flag fixes - fix: deprecations and other javadoc warnings - chore: upgrade javadoc plugin to latest - chore: upgrade javadoc java spec version → 21 Signed-off-by: Sam Gammon --- android/guava/pom.xml | 4 ++-- android/guava/src/com/google/common/base/Strings.java | 2 +- .../com/google/common/collect/ImmutableCollection.java | 2 +- .../src/com/google/common/primitives/package-info.java | 2 +- android/pom.xml | 2 +- guava-testlib/pom.xml | 6 ++++++ guava/pom.xml | 10 ++++++++-- guava/src/com/google/common/base/Strings.java | 2 +- guava/src/com/google/common/cache/CacheBuilder.java | 1 - .../com/google/common/collect/ImmutableCollection.java | 6 +++--- guava/src/com/google/common/graph/ValueGraph.java | 6 +++--- .../src/com/google/common/primitives/package-info.java | 2 +- .../google/common/util/concurrent/AbstractFuture.java | 4 ++-- .../common/util/concurrent/ExecutionSequencer.java | 3 ++- .../util/concurrent/ListeningExecutorService.java | 10 +++++----- pom.xml | 10 ++++++---- 16 files changed, 43 insertions(+), 29 deletions(-) diff --git a/android/guava/pom.xml b/android/guava/pom.xml index ca267e58ef52..cbeac5470b9b 100644 --- a/android/guava/pom.xml +++ b/android/guava/pom.xml @@ -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 @@ *
    *
  • {@link ImmutableDoubleArray} *
  • {@link ImmutableIntArray} - *
  • {@link ImmutableLongrray} + *
  • {@link ImmutableLongArray} *
  • {@link UnsignedInteger} *
  • {@link UnsignedLong} *
diff --git a/android/pom.xml b/android/pom.xml index 375d9d5590b1..9678adcdbfc0 100644 --- a/android/pom.xml +++ b/android/pom.xml @@ -211,7 +211,7 @@
maven-javadoc-plugin - 3.5.0 + 3.6.3 true true diff --git a/guava-testlib/pom.xml b/guava-testlib/pom.xml index 24548b0b7726..d87761c5545a 100644 --- a/guava-testlib/pom.xml +++ b/guava-testlib/pom.xml @@ -85,6 +85,12 @@ maven-javadoc-plugin + + ${javadoc.specification.version} + + --add-reads=com.google.common.testlib=ALL-UNNAMED + + maven-surefire-plugin diff --git a/guava/pom.xml b/guava/pom.xml index 2a22aa9f089d..d274c1582f37 100644 --- a/guava/pom.xml +++ b/guava/pom.xml @@ -148,6 +148,7 @@ maven-javadoc-plugin + 9 @@ -198,8 +199,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/ @@ -210,6 +215,7 @@ https://errorprone.info/api/latest/ + all,-missing,-html,-accessibility ../overview.html 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/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 18d49d43516e..6ae282d241af 100644 --- a/guava/src/com/google/common/util/concurrent/AbstractFuture.java +++ b/guava/src/com/google/common/util/concurrent/AbstractFuture.java @@ -427,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 @@ -540,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/pom.xml b/pom.xml index 3bb635a37a21..af520fdb2f76 100644 --- a/pom.xml +++ b/pom.xml @@ -26,6 +26,8 @@ 2.26.1 3.0.0 9+181-r4173-1 + + 21 2024-01-02T00:00:00Z @@ -55,7 +57,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 @@ -70,7 +72,7 @@ Kevin Bourrillion kevinb@google.com Google - http://www.google.com + https://www.google.com owner developer @@ -212,7 +214,7 @@ maven-javadoc-plugin - 3.5.0 + 3.6.3 true true @@ -224,7 +226,7 @@ -Xdoclint:-html true - ${java.specification.version} + ${javadoc.specification.version} ${maven-javadoc-plugin.additionalJOptions} From 1164e151923a5c815be7d2bcbb46d6c8768ba048 Mon Sep 17 00:00:00 2001 From: Sam Gammon Date: Fri, 8 Mar 2024 19:34:49 -0800 Subject: [PATCH 25/40] fixup! cleanup of redundant test args Signed-off-by: Sam Gammon --- guava-tests/pom.xml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/guava-tests/pom.xml b/guava-tests/pom.xml index 94dc29026dcd..0891bd86484e 100644 --- a/guava-tests/pom.xml +++ b/guava-tests/pom.xml @@ -97,10 +97,6 @@ maven-surefire-plugin - - true - 2.5C - maven-jar-plugin From 5ec3d51c0c2d4ace93f94fcf3d528579d75b4a03 Mon Sep 17 00:00:00 2001 From: Sam Gammon Date: Fri, 8 Mar 2024 19:34:58 -0800 Subject: [PATCH 26/40] chore: add coverage via `maven-jacoco-plugin` Signed-off-by: Sam Gammon --- pom.xml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pom.xml b/pom.xml index af520fdb2f76..e7c33e811c82 100644 --- a/pom.xml +++ b/pom.xml @@ -296,6 +296,14 @@ spdx-maven-plugin 0.7.3 + + maven-jmod-plugin + 3.0.0-alpha-1 + + + maven-jacoco-plugin + 0.8.11 + From ea03b94a57e628fe36999e3e6e3aef080559fa6c Mon Sep 17 00:00:00 2001 From: Sam Gammon Date: Fri, 8 Mar 2024 19:37:01 -0800 Subject: [PATCH 27/40] fixup! wrapper sha256 breaks windows build Signed-off-by: Sam Gammon --- .mvn/wrapper/maven-wrapper.properties | 1 - 1 file changed, 1 deletion(-) diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties index 0a4095a73e29..f84935b09cd1 100644 --- a/.mvn/wrapper/maven-wrapper.properties +++ b/.mvn/wrapper/maven-wrapper.properties @@ -17,4 +17,3 @@ 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 distributionSha256Sum=83aaf914c785c9faed661f223000a92d1de9553f5c82d3b4362e66d9c031625f -wrapperSha256Sum=e63a53cfb9c4d291ebe3c2b0edacb7622bbc480326beaa5a0456e412f52f066a From 8f170132d1107563aac92942093e8439d4364e76 Mon Sep 17 00:00:00 2001 From: Sam Gammon Date: Fri, 8 Mar 2024 19:48:56 -0800 Subject: [PATCH 28/40] fixup! testlib mrjar Signed-off-by: Sam Gammon --- guava-testlib/pom.xml | 84 +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 77 insertions(+), 7 deletions(-) diff --git a/guava-testlib/pom.xml b/guava-testlib/pom.xml index d87761c5545a..03034270da0c 100644 --- a/guava-testlib/pom.xml +++ b/guava-testlib/pom.xml @@ -98,14 +98,84 @@ org.apache.maven.plugins maven-compiler-plugin - - 9 - 9 - - --add-reads=com.google.common.testlib=ALL-UNNAMED - - + + + 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 + + + + + + + + From 7b8b21dfc9d694699ce1496821f665864560b4c6 Mon Sep 17 00:00:00 2001 From: Sam Gammon Date: Fri, 8 Mar 2024 19:54:51 -0800 Subject: [PATCH 29/40] fixup! `-Xlint:-removal` on jdk8 Signed-off-by: Sam Gammon --- guava-tests/pom.xml | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/guava-tests/pom.xml b/guava-tests/pom.xml index 0891bd86484e..50a5a9ffe2eb 100644 --- a/guava-tests/pom.xml +++ b/guava-tests/pom.xml @@ -74,16 +74,6 @@ maven-compiler-plugin - - - default-testCompile - - - -Xlint:-removal - - - - maven-source-plugin @@ -140,4 +130,25 @@ + + + jvm11plus + + [11,] + + + + + maven-compiler-plugin + + + -Xlint:-removal + -Xlint:-options + + + + + + + From f903cd5941e3e1f57a47c66a7dece2bd928cf309 Mon Sep 17 00:00:00 2001 From: Sam Gammon Date: Sun, 10 Mar 2024 00:19:31 -0800 Subject: [PATCH 30/40] fixup! version mappings in guava module Signed-off-by: Sam Gammon --- guava/pom.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/guava/pom.xml b/guava/pom.xml index d274c1582f37..df67435a2d93 100644 --- a/guava/pom.xml +++ b/guava/pom.xml @@ -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} From a5e2c92e3fdcce766ad132aa5c540faebeb2e0fb Mon Sep 17 00:00:00 2001 From: Sam Gammon Date: Sun, 10 Mar 2024 12:51:38 -0700 Subject: [PATCH 31/40] chore: move benchmarks to dedicated module Signed-off-by: Sam Gammon --- guava-bench/pom.xml | 134 ++++++ .../google/common/base/AsciiBenchmark.java | 0 .../google/common/base/BenchmarkHelpers.java | 0 .../common/base/CharMatcherBenchmark.java | 0 .../google/common/base/EnumsBenchmark.java | 0 .../google/common/base/JoinerBenchmark.java | 0 .../common/base/LazyStackTraceBenchmark.java | 0 .../google/common/base/ObjectsBenchmark.java | 2 +- .../google/common/base/SplitterBenchmark.java | 0 .../common/base/StopwatchBenchmark.java | 0 .../common/base/StringsRepeatBenchmark.java | 2 +- .../common/base/ToStringHelperBenchmark.java | 0 .../base/WhitespaceMatcherBenchmark.java | 0 .../google/common/cache/ChainBenchmark.java | 0 .../LoadingCacheSingleThreadBenchmark.java | 0 .../cache/MapMakerComparisonBenchmark.java | 0 .../google/common/cache/SegmentBenchmark.java | 0 .../common/collect/BenchmarkHelpers.java | 420 ++++++++++++++++++ .../collect/BinaryTreeTraverserBenchmark.java | 0 .../CollectionBenchmarkSampleData.java | 7 +- ...ComparatorDelegationOverheadBenchmark.java | 0 .../ConcurrentHashMultisetBenchmark.java | 12 +- .../HashMultisetAddPresentBenchmark.java | 0 .../ImmutableListCreationBenchmark.java | 0 ...ableSetHashFloodingDetectionBenchmark.java | 0 .../common/collect/InternersBenchmark.java | 0 .../common/collect/IteratorBenchmark.java | 0 .../google/common/collect/MapBenchmark.java | 0 .../collect/MinMaxPriorityQueueBenchmark.java | 0 .../collect/MultipleSetContainsBenchmark.java | 0 .../collect/MultisetIteratorBenchmark.java | 0 .../common/collect/PowerSetBenchmark.java | 0 .../common/collect/SetContainsBenchmark.java | 0 .../common/collect/SetCreationBenchmark.java | 0 .../common/collect/SetIterationBenchmark.java | 0 .../common/collect/SortedCopyBenchmark.java | 0 .../google/common/collect/SpecialRandom.java | 0 .../common/collect/StreamsBenchmark.java | 0 .../common/eventbus/EventBusBenchmark.java | 0 .../google/common/hash/ChecksumBenchmark.java | 0 .../google/common/hash/HashCodeBenchmark.java | 0 .../common/hash/HashFunctionBenchmark.java | 0 .../google/common/hash/HashFunctionEnum.java | 0 .../common/hash/HashStringBenchmark.java | 0 .../hash/MessageDigestAlgorithmBenchmark.java | 2 +- .../hash/MessageDigestCreationBenchmark.java | 0 .../common/io/BaseEncodingBenchmark.java | 0 .../ByteSourceAsCharSourceReadBenchmark.java | 0 .../common/io/CharStreamsCopyBenchmark.java | 0 .../google/common/math/ApacheBenchmark.java | 0 .../common/math/BigIntegerMathBenchmark.java | 0 .../math/BigIntegerMathRoundingBenchmark.java | 0 .../common/math/DoubleMathBenchmark.java | 0 .../math/DoubleMathRoundingBenchmark.java | 0 .../google/common/math/IntMathBenchmark.java | 0 .../common/math/IntMathRoundingBenchmark.java | 0 .../google/common/math/LessThanBenchmark.java | 0 .../google/common/math/LongMathBenchmark.java | 0 .../math/LongMathRoundingBenchmark.java | 0 .../google/common/math/MathBenchmarking.java | 0 .../common/math/QuantilesBenchmark.java | 1 + .../google/common/math/StatsBenchmark.java | 0 .../primitives/UnsignedBytesBenchmark.java | 0 .../primitives/UnsignedLongsBenchmark.java | 0 .../concurrent/AbstractFutureBenchmarks.java | 17 +- .../AbstractFutureFootprintBenchmark.java | 0 .../CycleDetectingLockFactoryBenchmark.java | 0 .../concurrent/ExecutionListBenchmark.java | 3 +- .../FuturesGetCheckedBenchmark.java | 0 .../MonitorBasedArrayBlockingQueue.java | 0 .../MonitorBasedPriorityBlockingQueue.java | 0 .../util/concurrent/MonitorBenchmark.java | 0 .../MoreExecutorsDirectExecutorBenchmark.java | 0 .../SingleThreadAbstractFutureBenchmark.java | 0 .../util/concurrent/StripedBenchmark.java | 0 .../google/guava/benchmarks/Benchmarks.java | 7 + .../testing/math/QuantilesAlgorithm.java | 219 +++++++++ guava-testlib/src/module-info.java | 1 + guava-tests/pom.xml | 17 - .../common/math/QuantilesAlgorithm.java | 2 +- .../common/math/QuantilesAlgorithmTest.java | 2 +- pom.xml | 6 + 82 files changed, 812 insertions(+), 42 deletions(-) create mode 100644 guava-bench/pom.xml rename {guava-tests/benchmark => guava-bench/test}/com/google/common/base/AsciiBenchmark.java (100%) rename {guava-tests => guava-bench}/test/com/google/common/base/BenchmarkHelpers.java (100%) rename {guava-tests/benchmark => guava-bench/test}/com/google/common/base/CharMatcherBenchmark.java (100%) rename {guava-tests/benchmark => guava-bench/test}/com/google/common/base/EnumsBenchmark.java (100%) rename {guava-tests/benchmark => guava-bench/test}/com/google/common/base/JoinerBenchmark.java (100%) rename {guava-tests/benchmark => guava-bench/test}/com/google/common/base/LazyStackTraceBenchmark.java (100%) rename {guava-tests/benchmark => guava-bench/test}/com/google/common/base/ObjectsBenchmark.java (96%) rename {guava-tests/benchmark => guava-bench/test}/com/google/common/base/SplitterBenchmark.java (100%) rename {guava-tests/benchmark => guava-bench/test}/com/google/common/base/StopwatchBenchmark.java (100%) rename {guava-tests/benchmark => guava-bench/test}/com/google/common/base/StringsRepeatBenchmark.java (97%) rename {guava-tests/benchmark => guava-bench/test}/com/google/common/base/ToStringHelperBenchmark.java (100%) rename {guava-tests/benchmark => guava-bench/test}/com/google/common/base/WhitespaceMatcherBenchmark.java (100%) rename {guava-tests/benchmark => guava-bench/test}/com/google/common/cache/ChainBenchmark.java (100%) rename {guava-tests/benchmark => guava-bench/test}/com/google/common/cache/LoadingCacheSingleThreadBenchmark.java (100%) rename {guava-tests/benchmark => guava-bench/test}/com/google/common/cache/MapMakerComparisonBenchmark.java (100%) rename {guava-tests/benchmark => guava-bench/test}/com/google/common/cache/SegmentBenchmark.java (100%) create mode 100644 guava-bench/test/com/google/common/collect/BenchmarkHelpers.java rename {guava-tests/benchmark => guava-bench/test}/com/google/common/collect/BinaryTreeTraverserBenchmark.java (100%) rename {guava-tests => guava-bench}/test/com/google/common/collect/CollectionBenchmarkSampleData.java (99%) rename {guava-tests/benchmark => guava-bench/test}/com/google/common/collect/ComparatorDelegationOverheadBenchmark.java (100%) rename {guava-tests/benchmark => guava-bench/test}/com/google/common/collect/ConcurrentHashMultisetBenchmark.java (98%) rename {guava-tests/benchmark => guava-bench/test}/com/google/common/collect/HashMultisetAddPresentBenchmark.java (100%) rename {guava-tests/benchmark => guava-bench/test}/com/google/common/collect/ImmutableListCreationBenchmark.java (100%) rename {guava-tests/benchmark => guava-bench/test}/com/google/common/collect/ImmutableSetHashFloodingDetectionBenchmark.java (100%) rename {guava-tests/benchmark => guava-bench/test}/com/google/common/collect/InternersBenchmark.java (100%) rename {guava-tests/benchmark => guava-bench/test}/com/google/common/collect/IteratorBenchmark.java (100%) rename {guava-tests/benchmark => guava-bench/test}/com/google/common/collect/MapBenchmark.java (100%) rename {guava-tests/benchmark => guava-bench/test}/com/google/common/collect/MinMaxPriorityQueueBenchmark.java (100%) rename {guava-tests/benchmark => guava-bench/test}/com/google/common/collect/MultipleSetContainsBenchmark.java (100%) rename {guava-tests/benchmark => guava-bench/test}/com/google/common/collect/MultisetIteratorBenchmark.java (100%) rename {guava-tests/benchmark => guava-bench/test}/com/google/common/collect/PowerSetBenchmark.java (100%) rename {guava-tests/benchmark => guava-bench/test}/com/google/common/collect/SetContainsBenchmark.java (100%) rename {guava-tests/benchmark => guava-bench/test}/com/google/common/collect/SetCreationBenchmark.java (100%) rename {guava-tests/benchmark => guava-bench/test}/com/google/common/collect/SetIterationBenchmark.java (100%) rename {guava-tests/benchmark => guava-bench/test}/com/google/common/collect/SortedCopyBenchmark.java (100%) rename {guava-tests => guava-bench}/test/com/google/common/collect/SpecialRandom.java (100%) rename {guava-tests/benchmark => guava-bench/test}/com/google/common/collect/StreamsBenchmark.java (100%) rename {guava-tests/benchmark => guava-bench/test}/com/google/common/eventbus/EventBusBenchmark.java (100%) rename {guava-tests/benchmark => guava-bench/test}/com/google/common/hash/ChecksumBenchmark.java (100%) rename {guava-tests/benchmark => guava-bench/test}/com/google/common/hash/HashCodeBenchmark.java (100%) rename {guava-tests/benchmark => guava-bench/test}/com/google/common/hash/HashFunctionBenchmark.java (100%) rename {guava-tests => guava-bench}/test/com/google/common/hash/HashFunctionEnum.java (100%) rename {guava-tests/benchmark => guava-bench/test}/com/google/common/hash/HashStringBenchmark.java (100%) rename {guava-tests/benchmark => guava-bench/test}/com/google/common/hash/MessageDigestAlgorithmBenchmark.java (97%) rename {guava-tests/benchmark => guava-bench/test}/com/google/common/hash/MessageDigestCreationBenchmark.java (100%) rename {guava-tests/benchmark => guava-bench/test}/com/google/common/io/BaseEncodingBenchmark.java (100%) rename {guava-tests/benchmark => guava-bench/test}/com/google/common/io/ByteSourceAsCharSourceReadBenchmark.java (100%) rename {guava-tests/benchmark => guava-bench/test}/com/google/common/io/CharStreamsCopyBenchmark.java (100%) rename {guava-tests/benchmark => guava-bench/test}/com/google/common/math/ApacheBenchmark.java (100%) rename {guava-tests/benchmark => guava-bench/test}/com/google/common/math/BigIntegerMathBenchmark.java (100%) rename {guava-tests/benchmark => guava-bench/test}/com/google/common/math/BigIntegerMathRoundingBenchmark.java (100%) rename {guava-tests/benchmark => guava-bench/test}/com/google/common/math/DoubleMathBenchmark.java (100%) rename {guava-tests/benchmark => guava-bench/test}/com/google/common/math/DoubleMathRoundingBenchmark.java (100%) rename {guava-tests/benchmark => guava-bench/test}/com/google/common/math/IntMathBenchmark.java (100%) rename {guava-tests/benchmark => guava-bench/test}/com/google/common/math/IntMathRoundingBenchmark.java (100%) rename {guava-tests/benchmark => guava-bench/test}/com/google/common/math/LessThanBenchmark.java (100%) rename {guava-tests/benchmark => guava-bench/test}/com/google/common/math/LongMathBenchmark.java (100%) rename {guava-tests/benchmark => guava-bench/test}/com/google/common/math/LongMathRoundingBenchmark.java (100%) rename {guava-tests => guava-bench}/test/com/google/common/math/MathBenchmarking.java (100%) rename {guava-tests/benchmark => guava-bench/test}/com/google/common/math/QuantilesBenchmark.java (98%) rename {guava-tests/benchmark => guava-bench/test}/com/google/common/math/StatsBenchmark.java (100%) rename {guava-tests/benchmark => guava-bench/test}/com/google/common/primitives/UnsignedBytesBenchmark.java (100%) rename {guava-tests/benchmark => guava-bench/test}/com/google/common/primitives/UnsignedLongsBenchmark.java (100%) rename {guava-tests => guava-bench}/test/com/google/common/util/concurrent/AbstractFutureBenchmarks.java (97%) rename {guava-tests/benchmark => guava-bench/test}/com/google/common/util/concurrent/AbstractFutureFootprintBenchmark.java (100%) rename {guava-tests/benchmark => guava-bench/test}/com/google/common/util/concurrent/CycleDetectingLockFactoryBenchmark.java (100%) rename {guava-tests/benchmark => guava-bench/test}/com/google/common/util/concurrent/ExecutionListBenchmark.java (99%) rename {guava-tests/benchmark => guava-bench/test}/com/google/common/util/concurrent/FuturesGetCheckedBenchmark.java (100%) rename {guava-tests/benchmark => guava-bench/test}/com/google/common/util/concurrent/MonitorBasedArrayBlockingQueue.java (100%) rename {guava-tests/benchmark => guava-bench/test}/com/google/common/util/concurrent/MonitorBasedPriorityBlockingQueue.java (100%) rename {guava-tests/benchmark => guava-bench/test}/com/google/common/util/concurrent/MonitorBenchmark.java (100%) rename {guava-tests/benchmark => guava-bench/test}/com/google/common/util/concurrent/MoreExecutorsDirectExecutorBenchmark.java (100%) rename {guava-tests/benchmark => guava-bench/test}/com/google/common/util/concurrent/SingleThreadAbstractFutureBenchmark.java (100%) rename {guava-tests/benchmark => guava-bench/test}/com/google/common/util/concurrent/StripedBenchmark.java (100%) create mode 100644 guava-bench/test/com/google/guava/benchmarks/Benchmarks.java create mode 100644 guava-testlib/src/com/google/common/testing/math/QuantilesAlgorithm.java 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-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 index ee0cf879b3e8..51437a19dea7 100644 --- a/guava-testlib/src/module-info.java +++ b/guava-testlib/src/module-info.java @@ -27,5 +27,6 @@ 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 50a5a9ffe2eb..7010a508a4bb 100644 --- a/guava-tests/pom.xml +++ b/guava-tests/pom.xml @@ -111,23 +111,6 @@ false - - org.codehaus.mojo - build-helper-maven-plugin - 1.7 - - - add-benchmark-sources - generate-test-sources - add-test-source - - - benchmark - - - - - 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/pom.xml b/pom.xml index e7c33e811c82..3e608028388b 100644 --- a/pom.xml +++ b/pom.xml @@ -90,6 +90,7 @@ guava-gwt guava-testlib guava-tests + guava-bench @@ -304,6 +305,11 @@ maven-jacoco-plugin 0.8.11 + + org.codehaus.mojo + exec-maven-plugin + 3.2.0 + From 474b0c76ddd1314e7000f3a9dd50cc6123ddfc47 Mon Sep 17 00:00:00 2001 From: Sam Gammon Date: Mon, 11 Mar 2024 11:33:16 -0700 Subject: [PATCH 32/40] fixup! drop `requires java.base` Signed-off-by: Sam Gammon --- futures/failureaccess/src/module-info.java | 1 - guava-testlib/src/module-info.java | 1 - guava/src/module-info.java | 1 - 3 files changed, 3 deletions(-) diff --git a/futures/failureaccess/src/module-info.java b/futures/failureaccess/src/module-info.java index 3c4edf52c69c..71ea64d24570 100644 --- a/futures/failureaccess/src/module-info.java +++ b/futures/failureaccess/src/module-info.java @@ -16,6 +16,5 @@ * Guava: Future Internals. */ module com.google.common.util.concurrent.internal { - requires java.base; exports com.google.common.util.concurrent.internal; } diff --git a/guava-testlib/src/module-info.java b/guava-testlib/src/module-info.java index 51437a19dea7..e7ee724db36d 100644 --- a/guava-testlib/src/module-info.java +++ b/guava-testlib/src/module-info.java @@ -16,7 +16,6 @@ * Guava Testlib */ open module com.google.common.testlib { - requires java.base; requires java.logging; requires com.google.common; requires com.google.common.util.concurrent.internal; diff --git a/guava/src/module-info.java b/guava/src/module-info.java index ee63fe41df73..daf517fe61c6 100644 --- a/guava/src/module-info.java +++ b/guava/src/module-info.java @@ -20,7 +20,6 @@ * Google Guava */ module com.google.common { - requires java.base; requires java.logging; requires jdk.unsupported; requires com.google.common.util.concurrent.internal; From 4c46bdbb79c998f0f4dbfb684ce5edcce1bf24c7 Mon Sep 17 00:00:00 2001 From: Sam Gammon Date: Mon, 11 Mar 2024 11:33:28 -0700 Subject: [PATCH 33/40] fixup! don't export `.thirdparty.publicsuffix` Signed-off-by: Sam Gammon --- guava/src/module-info.java | 1 - 1 file changed, 1 deletion(-) diff --git a/guava/src/module-info.java b/guava/src/module-info.java index daf517fe61c6..050b082df9c2 100644 --- a/guava/src/module-info.java +++ b/guava/src/module-info.java @@ -40,5 +40,4 @@ exports com.google.common.reflect; exports com.google.common.util.concurrent; exports com.google.common.xml; - exports com.google.thirdparty.publicsuffix; } From 531a5833364ea096fa29d1db9d798c9ec5a26d97 Mon Sep 17 00:00:00 2001 From: Sam Gammon Date: Mon, 11 Mar 2024 16:07:08 -0700 Subject: [PATCH 34/40] fixup! move to `requires static jdk.unsupported` Signed-off-by: Sam Gammon --- guava/src/module-info.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/guava/src/module-info.java b/guava/src/module-info.java index 050b082df9c2..e800e4d8538b 100644 --- a/guava/src/module-info.java +++ b/guava/src/module-info.java @@ -20,8 +20,8 @@ * Google Guava */ module com.google.common { + requires static jdk.unsupported; requires java.logging; - requires jdk.unsupported; requires com.google.common.util.concurrent.internal; exports com.google.common.annotations; From b076a308a20b36653347fda88668a25d0b6fa444 Mon Sep 17 00:00:00 2001 From: Sam Gammon Date: Mon, 11 Mar 2024 16:07:18 -0700 Subject: [PATCH 35/40] fixup! release version for `failureaccess` Signed-off-by: Sam Gammon --- futures/failureaccess/pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/futures/failureaccess/pom.xml b/futures/failureaccess/pom.xml index bef7819f8968..6d0a669a4773 100644 --- a/futures/failureaccess/pom.xml +++ b/futures/failureaccess/pom.xml @@ -5,10 +5,10 @@ com.google.guava guava-parent - 26.0-android + 1.0-HEAD-jre-SNAPSHOT failureaccess - 1.0.2 + 1.0.3-jpms bundle Guava InternalFutureFailureAccess and InternalFutures From 8ad65d9118422c18bb30d4be75961db3ceecdeb5 Mon Sep 17 00:00:00 2001 From: Sam Gammon Date: Mon, 11 Mar 2024 16:09:46 -0700 Subject: [PATCH 36/40] fixup! property for `failureaccess.version` Signed-off-by: Sam Gammon --- guava/pom.xml | 2 +- pom.xml | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/guava/pom.xml b/guava/pom.xml index df67435a2d93..987e3cfe7ef2 100644 --- a/guava/pom.xml +++ b/guava/pom.xml @@ -21,7 +21,7 @@ com.google.guava failureaccess - 1.0.2 + ${failureaccess.version} com.google.guava diff --git a/pom.xml b/pom.xml index 3e608028388b..bcb7535943fc 100644 --- a/pom.xml +++ b/pom.xml @@ -25,6 +25,7 @@ 3.42.0 2.26.1 3.0.0 + 1.0.2 9+181-r4173-1 21 From d24b5f9f406585fbe78a74c9ae3f7f4e8ba8d817 Mon Sep 17 00:00:00 2001 From: Sam Gammon Date: Mon, 11 Mar 2024 16:14:07 -0700 Subject: [PATCH 37/40] fixup! `failureaccess` needs relative path to parent pom Signed-off-by: Sam Gammon --- futures/failureaccess/pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/futures/failureaccess/pom.xml b/futures/failureaccess/pom.xml index 6d0a669a4773..ae1be2f876df 100644 --- a/futures/failureaccess/pom.xml +++ b/futures/failureaccess/pom.xml @@ -6,6 +6,7 @@ com.google.guava guava-parent 1.0-HEAD-jre-SNAPSHOT + ../../pom.xml failureaccess 1.0.3-jpms From 49e26a75bcb05ac822abbd865aafad2e7e7e4e8d Mon Sep 17 00:00:00 2001 From: Sam Gammon Date: Mon, 11 Mar 2024 16:25:05 -0700 Subject: [PATCH 38/40] fixup! failureaccess mrjar structure, bundle plugin Signed-off-by: Sam Gammon --- futures/failureaccess/pom.xml | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/futures/failureaccess/pom.xml b/futures/failureaccess/pom.xml index ae1be2f876df..5eefbe1e87c4 100644 --- a/futures/failureaccess/pom.xml +++ b/futures/failureaccess/pom.xml @@ -10,7 +10,7 @@ failureaccess 1.0.3-jpms - bundle + jar Guava InternalFutureFailureAccess and InternalFutures Contains @@ -38,6 +38,9 @@ compile-java9 + + compile + 9 true @@ -49,12 +52,14 @@ maven-jar-plugin + ${project.build.outputDirectory}/META-INF/MANIFEST.MF true - META-INF/versions/9/com/**/*.java + /module-info.class + META-INF/versions/9/com/google/common/util/concurrent/internal/*.class @@ -81,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/ From b9897a4a3bc1e39fe4a2a84467691bb51d598bfa Mon Sep 17 00:00:00 2001 From: Sam Gammon Date: Sun, 14 Apr 2024 19:35:01 -0700 Subject: [PATCH 39/40] chore: profile for signing Signed-off-by: Sam Gammon --- pom.xml | 41 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index bcb7535943fc..469d63bad0f8 100644 --- a/pom.xml +++ b/pom.xml @@ -390,8 +390,45 @@ - - + + + + signing + + + + dev.sigstore + sigstore-maven-plugin + + + sign + + sign + + + + + + maven-gpg-plugin + + + sign-artifacts + verify + + sign + + + + + + + + + sign + true + + +