Skip to content

feat: java.util.concurrent API with a core-api-java6 backport artifact (1.8.0) - #20

Merged
joalves merged 7 commits into
mainfrom
feat/java-util-concurrent
Nov 11, 2026
Merged

joalves merged 7 commits into
mainfrom
feat/java-util-concurrent

Conversation

@joalves

@joalves joalves commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Why

streamsupport-minifuture 1.7.4, the final release, breaks on JDK 24+: its TLR reads the removed Thread.inheritedAccessControlContext, and it relies on sun.misc.Unsafe, which JDK 25 already warns about. PR #19 works around this with an SDK-owned executor. This PR goes further and removes the backport from the main artifact.

One jar can't switch the type per JDK. Context.waitUntilReadyAsync(), ABSmartly.getContextData(), HTTPClient, ContextDataProvider and ContextEventHandler are compiled into customer code with the exact CompletableFuture type, and multi-release jars need an identical public API. So the SDK ships as two artifacts with the same version.

Design

Artifact Bytecode Async types animalsniffer
com.absmartly.sdk:core-api Java 8 (major 52) java.util.concurrent / java.util.function java18:1.0 and android-api-level-24:7.0_r2
com.absmartly.sdk:core-api-java6 Java 6 (major 50) java8.util.concurrent / java8.util.function (streamsupport-minifuture 1.7.4, api) java16:1.1
  • core-api is the source of truth. It is written against the JDK types but still in Java 6 syntax (sourceCompatibility 1.6, targetCompatibility 1.8), and no longer depends on streamsupport.
  • core-api-java6 has no hand-written sources. Two Sync tasks (generateMainSources, generateTestSources) copy core-api's src/main and src/test and rewrite only java.util.concurrent.{CompletableFuture,CompletionStage,CompletionException} and java.util.function.{Function,Consumer,Supplier,BiFunction} (imports and fully-qualified uses) to java8.util.*. Other java.util.concurrent classes are left alone. A wildcard java.util.function.* import, or a java.util.concurrent.* import in a file that uses Completable*/Completion*, fails the generation instead of silently compiling against the JDK type.
  • Per-variant files. A file in core-api/src/java6Main or core-api/src/java6Test replaces the file at the same path, or adds one, in core-api-java6 only.
  • Shared build logic. The build lives in gradle/sdk-module.gradle, applied by both modules: dependencies, jacoco rules (kept on both), test, testJdk25, and SdkVersion generation. Both modules are in the publishing list, so each gets a sources jar and a javadoc jar; core-api-java6 builds them from its generated sources. publish.yml already runs -x test -x testJdk25, which excludes those tasks in every project. I confirmed with ./gradlew -m clean build publish -x test -x testJdk25 that neither module runs a test task.
  • Renaming core-api-java6 means renaming the directory, plus one entry in build.gradle and one in gradle/compatibility.gradle.

SdkFuture / AsyncExecutor

SdkFuture is now variant-specific and lives in core-api/src/java6Main. The SDK creates futures through a small internal.Futures factory:

  • In core-api, Futures returns plain java.util.concurrent.CompletableFutures (new CompletableFuture<T>() / completedFuture).
  • The java6 override of Futures returns SdkFutures, so core-api-java6 behaves exactly as in PR fix: support JDK 24+ without breaking backwards compatibility #19, including the either-stage fix that was merged in.

Why not keep SdkFuture in core-api too:

  • On the JDK, defaultExecutor() and newIncompleteFuture() are Java 9 APIs, and minimalCompletionStage/copy don't exist on Java 8 / Android 24. Its behaviour would differ between Java 8 and Java 9+.
  • Its only purpose is to keep callers away from the backport's broken pool. The JDK common pool works on JDK 25.
  • The either-stage overrides only call super.*Either*, which are Java 8 APIs and would pass animalsniffer. Still, keeping a CompletableFuture subclass in the main artifact only adds surface.

PR #19's later commits are merged in:

  • 42ffc82's nine either-stage overrides live in the java6 SdkFuture.
  • 50b555d's copy() assertion is in the shared returned-futures test.
  • The README and CHANGELOG wording for core-api-java6 matches 50b555d: copy() is no longer listed.

Does the java.util variant need the either-stage overrides? On JDK 25, a CompletableFuture subclass that overrides newIncompleteFuture() gets a plain CompletableFuture back from pending.applyToEither(completedPlainFuture, fn), and its own type back when the other future is still pending. So the JDK allocates the dependent from whichever source is already complete, just as the backport does. core-api doesn't subclass CompletableFuture at all, though. Every future it returns is already plain and defaults to the JDK common pool, which works on every JDK. So there is nothing to keep, and core-api does not need the overrides.

AsyncExecutor stays shared: core-api still runs its internal async steps on it when no ClientConfig.setExecutor is set, the same as before.

Tests:

Breaking change (1.8.0)

VERSION is 1.8.0, and the CHANGELOG has a ## 1.8.0 (unreleased) section with a Breaking change entry. The README has a compatibility table, Gradle and Maven snippets for both artifacts, and a revised "Java 24 and later" section: core-api has no executor restriction, and PR #19's restrictions apply only to core-api-java6.

Who is affected and what to do:

  • Code that names java8.util.concurrent.* or java8.util.function.* from the SDK API, or that implements HTTPClient, ContextDataProvider or ContextEventHandler: switch the imports to java.util.concurrent / java.util.function.
  • Java 6/7, and Android below API 24: switch the dependency to core-api-java6. No code changes are needed.
  • Code that only uses the blocking API: recompile.

Verification

./gradlew clean build with Gradle on Temurin 11.0.33 and Temurin 25.0.5 as the testJdk25 toolchain ran with -x spotlessCheck (see below). Result: BUILD SUCCESSFUL.

  • :core-api:animalsnifferMain (java18 + android-24), :core-api-java6:animalsnifferMain (java16)
  • :core-api:test 584 passed, :core-api:testJdk25 584 passed
  • :core-api-java6:test 585 passed, :core-api-java6:testJdk25 585 passed (the extra test is the java6-only SdkFutureTest)
  • jacocoTestCoverageVerification passed for both modules
  • I checked that animalsniffer actually enforces both new signatures with a throwaway probe class. CompletableFuture.defaultExecutor() was flagged by java18 and android-24, and java.util.Base64 by android-24.

javap on the built jars:

core-api:       133 classes, all "major version: 52"; 41 classes reference java/util/concurrent/Complet* or java/util/function, 0 reference java8/util
core-api-java6: 135 classes, all "major version: 50"; 0 reference java/util/concurrent/Complet* or java/util/function, 43 reference java8/util

core-api        HTTPClient.get(...)               -> java.util.concurrent.CompletableFuture<HTTPClient$Response>
core-api        Context.waitUntilReadyAsync()     -> java.util.concurrent.CompletableFuture<Context>
core-api        ABSmartly.getContextData()        -> java.util.concurrent.CompletableFuture<ContextData>
core-api-java6  HTTPClient.get(...)               -> java8.util.concurrent.CompletableFuture<HTTPClient$Response>
core-api-java6  Context.waitUntilReadyAsync()     -> java8.util.concurrent.CompletableFuture<Context>
core-api-java6  ABSmartly.getContextData()        -> java8.util.concurrent.CompletableFuture<ContextData>

ContextDataProvider.getContextData() and ContextEventHandler.publish(...) follow the same pattern. The generated POMs: core-api has no streamsupport dependency, and core-api-java6 has streamsupport-minifuture:1.7.4 with compile scope.

Diff between generated and original sources, with the 7 type names normalised:

main: 11 rewritten files, 0 lines differing beyond the 7 type names; overrides: internal/Futures.java, internal/SdkFuture.java
test: 17 rewritten files, 0 lines differing beyond the 7 type names; overrides: ReturnedFutures.java, internal/SdkFutureTest.java

The grep over main and test sources, including fully-qualified uses, found exactly the 7 types. The only other java8. mention was a comment about TLR.

Spotless was not run locally. After a first baseline build succeeded, archive.eclipse.org stopped resolving in my environment, and both the JDT and Groovy formatters download from it. CI's spotlessCheck flagged import order and one Gradle indentation. I applied exactly the diffs CI printed, in the two style: commits.

Open points

  • The artifact name core-api-java6 can be revisited.
  • The example module now compiles for 1.8 because it consumes core-api.

🤖 Generated with Claude Code

lux worker and others added 5 commits November 10, 2026 22:15
core-api's public API (Context, ABSmartly, HTTPClient, ContextDataProvider,
ContextEventHandler) now uses java.util.concurrent.CompletableFuture and the
java.util.function interfaces instead of the streamsupport backport, whose
final release fails on JDK 24+ and relies on sun.misc.Unsafe. The
streamsupport dependency is dropped from core-api.

The sources keep Java 6 syntax so core-api-java6 can be generated from them,
but compile to Java 8 bytecode and are checked by animalsniffer against the
Java 8 and Android API level 24 signatures.

SdkFuture only exists to keep the backport's default pool out of reach, and
CompletableFuture.defaultExecutor()/newIncompleteFuture() are Java 9 APIs, so
core-api hands out plain JDK futures through internal.Futures. The
returned-futures test asserts the default executor through a per-variant
ReturnedFutures helper.

BREAKING CHANGE: code that names java8.util.concurrent or java8.util.function
types from the SDK API, or implements HTTPClient, ContextDataProvider or
ContextEventHandler, must import the java.util.concurrent and
java.util.function types instead.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ort types

core-api-java6 has no sources of its own. generateMainSources and
generateTestSources copy core-api's sources and switch only
java.util.concurrent.{CompletableFuture,CompletionStage,CompletionException}
and java.util.function.{Function,Consumer,Supplier,BiFunction} to their
java8.util twins; a file in core-api's src/java6Main or src/java6Test replaces
the one at the same path. Wildcard imports that would hide one of those types
fail the generation instead of compiling against the wrong one.

The java6 overrides restore PR #19's behavior: Futures hands out SdkFutures,
whose *Async stages default to the SDK executor, and ReturnedFutures asserts
that. The module compiles to Java 6 bytecode, depends on
streamsupport-minifuture 1.7.4 (api), keeps the java16 animalsniffer
signature and runs the full suite on test and testJdk25. It is published with
sources and javadoc jars built from the generated sources.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
The README explains which artifact to use, with Gradle and Maven snippets for
both, and limits the Java 24+ executor restrictions to core-api-java6. The
CHANGELOG describes who is affected by the move to java.util.concurrent and
how to migrate. CONTRIBUTING explains how core-api-java6 is generated.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
PR #19's either-stage fix lands in core-api/src/java6Main/.../SdkFuture.java,
which only core-api-java6 compiles. Its test exercises the backport SdkFuture
directly, so it moves to the java6-only SdkFutureTest; the copy() assertion
stays in the shared returned-futures test.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@coderabbitai

coderabbitai Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

  • Ask an admin to enable usage-based reviews

Open in CodeRabbit

Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing.

Next included review available in 56 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available. Your 75 included PR review attempts over the past 7 days set your current allowance at 1 review per hour.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Essentials
  • Run ID: 792248c3-002b-41cb-ae0b-370ff623e44a
Commits

Reviewing files that changed from the base of the PR and between 25f5835 and ff3d289.

Files selected for processing: 44

  • CHANGELOG.md
  • CONTRIBUTING.md
  • README.md
  • build.gradle
  • core-api-java6/build.gradle
  • core-api/build.gradle
  • core-api/src/java6Main/java/com/absmartly/sdk/internal/Futures.java
  • core-api/src/java6Main/java/com/absmartly/sdk/internal/SdkFuture.java
  • core-api/src/java6Test/java/com/absmartly/sdk/ReturnedFutures.java
  • core-api/src/java6Test/java/com/absmartly/sdk/internal/SdkFutureTest.java
  • core-api/src/main/java/com/absmartly/sdk/ABSmartly.java
  • core-api/src/main/java/com/absmartly/sdk/Client.java
  • core-api/src/main/java/com/absmartly/sdk/Context.java
  • core-api/src/main/java/com/absmartly/sdk/ContextDataProvider.java
  • core-api/src/main/java/com/absmartly/sdk/ContextEventHandler.java
  • core-api/src/main/java/com/absmartly/sdk/DefaultContextDataProvider.java
  • core-api/src/main/java/com/absmartly/sdk/DefaultContextEventHandler.java
  • core-api/src/main/java/com/absmartly/sdk/DefaultHTTPClient.java
  • core-api/src/main/java/com/absmartly/sdk/HTTPClient.java
  • core-api/src/main/java/com/absmartly/sdk/internal/Algorithm.java
  • core-api/src/main/java/com/absmartly/sdk/internal/AsyncExecutor.java
  • core-api/src/main/java/com/absmartly/sdk/internal/Concurrency.java
  • core-api/src/main/java/com/absmartly/sdk/internal/Futures.java
  • core-api/src/test/java/com/absmartly/sdk/ABSmartlyCompatTest.java
  • core-api/src/test/java/com/absmartly/sdk/ABSmartlyFixTest.java
  • core-api/src/test/java/com/absmartly/sdk/ABSmartlyTest.java
  • core-api/src/test/java/com/absmartly/sdk/AsyncExecutorCompatibilityTest.java
  • core-api/src/test/java/com/absmartly/sdk/ClientFixTest.java
  • core-api/src/test/java/com/absmartly/sdk/ClientTest.java
  • core-api/src/test/java/com/absmartly/sdk/ContextAssignmentRulesTest.java
  • core-api/src/test/java/com/absmartly/sdk/ContextFixTest.java
  • core-api/src/test/java/com/absmartly/sdk/ContextHoldoutTest.java
  • core-api/src/test/java/com/absmartly/sdk/ContextSystemAttributesTest.java
  • core-api/src/test/java/com/absmartly/sdk/ContextTest.java
  • core-api/src/test/java/com/absmartly/sdk/DefaultContextDataProviderTest.java
  • core-api/src/test/java/com/absmartly/sdk/DefaultContextEventHandlerTest.java
  • core-api/src/test/java/com/absmartly/sdk/DefaultHTTPClientTest.java
  • core-api/src/test/java/com/absmartly/sdk/ReturnedFutures.java
  • core-api/src/test/java/com/absmartly/sdk/TestUtils.java
  • core-api/src/test/java/com/absmartly/sdk/internal/AlgorithmTest.java
  • core-api/src/test/java/com/absmartly/sdk/internal/ConcurrencyTest.java
  • example/build.gradle
  • gradle/compatibility.gradle
  • gradle/sdk-module.gradle
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@jervasion-absmartly

jervasion-absmartly commented Nov 10, 2026 •

Copy link
Copy Markdown

Review submitted

The automated review has been submitted. See the review for the verdict and any findings.

Head: ff3d28972c14 | Updated: 2026-11-10 22:36 UTC

@jervasion-absmartly jervasion-absmartly left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Approved with suggestions

The two-artifact split implements the documented breaking change while preserving the legacy future API in core-api-java6. No blocking issues found. The formatting-only commits pushed during review are covered, and latest-head CI passes.

Next step: None — ready to merge.

Suggestions (optional)

  • Two redundant build-script comment blocks could be trimmed; see details.

What I checked

  • ✅ Full suites pass on JDK 11 and JDK 25: 584 tests per runtime for core-api, 585 for core-api-java6, no failures or skips. Includes real HTTP fetch/publish, async lifecycle, failure recovery and caller cancellation.
  • ✅ Both API-floor and coverage gates pass. Built classes and publication metadata target Java 8 and Java 6; only the legacy artifact exposes streamsupport.
  • ✅ Source/Javadoc packaging and generated POMs pass. Generated legacy sources match the rewriting/override specification.
  • ✅ Latest exact-head Java-SDK build passes, including formatting. Local formatters could not download because the Eclipse host did not resolve; CI supplies this evidence.
Review details

Head: ff3d28972c14626f05a04c30499a3cbcebaec723. Base/merge-base: 50b555d194a25e6206d0922acd0fb52b744457af. Round 1. Reviewed supplied head 890a2b2df69aed07bbf93700333bc706d21e3d56 in full, then inspected both subsequent commits (only import sorting and indentation) and revalidated the latest head.

Intent: Primary artifact adopts JDK future/function types and removes streamsupport; generated legacy artifact preserves the prior types and SDK-owned default executor. Version 1.8.0 intentionally changes the public contract; README/changelog explain migration, compatibility floors and selecting only one artifact. No feature flag is involved.

Validation:

  • Verified JDK 11; ./gradlew clean build stopped loading the Eclipse Groovy formatter because download.eclipse.org did not resolve. Direct :core-api:spotlessJavaCheck encountered the same DNS limit for JDT.
  • ./gradlew clean build -x spotlessCheck plus both modules' sourcesJar, javadocJar, generatePomFileForReleasePublication, and generateMetadataFileForReleasePublication: successful. All four test tasks, both coverage gates and Animal Sniffer tasks executed successfully.
  • After the formatting-only push: ./gradlew build -x spotlessCheck plus both POM tasks succeeded; generation/compilation reran, Gradle reused unchanged test outputs and the built JARs remained unchanged. XML totals: 584/584/585/585 tests, zero failures/errors/skips. The relocated either-stage test executes in the legacy suite.
  • Class inspection: primary artifact has 133 classes, all major 52, no java8/util references; legacy has 135 classes, all major 50, no JDK future/function references. Gradle JVM attributes are 8 and 6. Only legacy POM exposes streamsupport-minifuture:1.7.4 with compile scope.
  • Independently compared all 78 generated main files and 59 generated test files against exact rewriting/override rules: matched. Source JARs include the proper variant-specific implementation.
  • Traced readiness, refresh, publish, HTTP, close, cancellation and exceptional completion. Independent error specialist completed; no PR-caused defect survived. Legacy SdkFuture is unchanged from base.
  • git diff --check passed. Pinned introduced-blob helper completed; inspected 50 content writes through the supplied head and 18 later formatting-only writes, including intermediate content. No secrets or stray artifacts found.
  • CI run 42914477014, job 130173214498, exact latest head: successful. Earlier-head run 42913699722 failed and is not latest-head evidence; its downloadable logs were inaccessible here.
  • No oldest-JVM or Android emulator execution: repository-declared API signatures and bytecode inspection check compatibility floors; runtime behavior was exercised on JDK 11/25.

Passes (non-blocking): run: core runtime/API/security/data (executable Java); error handling/messages (future and generator failure paths; delegated specialist completed); tests/CI/packaging (new artifact and modified tests/build); behaviour-bearing configuration (Gradle generation/compatibility); cross-cutting simplicity (independent pass); comment hygiene and diff composition (primary). Not run: deployment/operations/observability (no deployment or emission changes); shared frontend blast radius (no frontend source).

Comment hygiene (non-blocking): 23 comment / 322 code lines, ratio ~1:14, 2 blocks flagged.

threshold T=5; restatements counted: no (10 × C < E)

  • core-api-java6/build.gradle:11–13: restates the source generation/override code immediately below; optional deletion.
  • gradle/sdk-module.gradle:1: restates which modules apply the shared build; optional deletion.

Other comments preserve compatibility constraints, backport quirks or variant rationale. No qualifying always-counted lines; no promotion.

Diff composition (non-blocking): every file is required for the change; none flagged.

Simplifications (non-blocking): none. Shared build logic, generated legacy sources and small factory/test overrides carry distinct requirements; no equivalent construct-removing simplification established.

@jervasion-absmartly jervasion-absmartly left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Approved with suggestions

Reconfirmed approval of the requested head. The move from 890a2b2 to ff3d289 consists only of import sorting and Gradle indentation; these changes were already incorporated into my previous review. No new blocking issues or unresolved author questions.

Next step: None — ready to merge.

Suggestions (optional)

  • The two optional build-comment cleanup suggestions in the previous review remain unchanged.

What I checked

  • ✅ Current head/base match the requested revisions; no code delta exists from the commit already approved.
  • ✅ Verified all 18 files changed since the originally supplied head retain identical nonblank, whitespace-normalized line multisets. The inspected changes only reorder imports or adjust indentation; git diff --check passes.
  • ✅ Exact-head Java-SDK CI remains successful: run 42914477014, build job 130173214498. No commit statuses are posted.
  • ✅ Reused the completed same-session validation: 584 primary-artifact and 585 legacy-artifact tests on each of JDK 11/25, API-floor and coverage gates, generation equivalence, bytecode/publication metadata and source/Javadoc packaging.
Review details

Head: ff3d28972c14626f05a04c30499a3cbcebaec723. Base/merge-base: 50b555d194a25e6206d0922acd0fb52b744457af. Round 1 continuation. Previous review 5850547793 already recorded this exact head as APPROVED. Re-read current PR description, top-level discussion, reviews, inline comments and exact-head CI. The author now explicitly describes applying the formatter output in the two style commits; that matches the inspected delta. No additional source changes or review threads were present.

The full runtime, compatibility and packaging evidence, exact build commands and introduced-content audit are preserved in the linked previous review and remain applicable to this identical head. No test suite was rerun in this confirmation turn. Local formatting downloads were previously blocked by Eclipse-host DNS; passing exact-head CI supplies formatting evidence. Oldest JVMs and Android emulators were not executed; compatibility-floor evidence is bytecode inspection plus the repository's Animal Sniffer signatures.

Passes (non-blocking): run this continuation: formatting/import delta correctness, CI selection/build evidence, comment hygiene, diff composition and simplicity. Reused completed full-scope independent runtime/API, tests/packaging, behaviour-bearing Gradle configuration and delegated error-specialist passes from the previous review; no changed failure/message behavior requires a specialist rerun. Not run anew: runtime/error/packaging execution passes (same already-reviewed head, formatting-only movement); deployment/operations/observability (no related changes); shared frontend blast radius (no frontend source).

Comment hygiene (non-blocking): cumulative base-to-head census unchanged: 23 comment / 322 code lines, ratio ~1:14, 2 blocks flagged.

threshold T=5; restatements counted: no (10 × C < E)

  • core-api-java6/build.gradle:11–13: restates generation/override code; optional deletion.
  • gradle/sdk-module.gradle:1: restates which modules apply the shared build; optional deletion.

No qualifying always-counted lines and no promotion. The formatting delta adds no comment content.

Diff composition (non-blocking): every file is required for the change; none flagged. The previous completed audit covered all 68 content writes through this head, including both style commits; no new content writes since that audit.

Simplifications (non-blocking): none. The formatting delta introduces no new construct; full-scope simplicity result remains unchanged.

@joalves
joalves merged commit 86aa9ea into main Nov 11, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants