You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -138,7 +138,7 @@ throw new IllegalArgumentException("invalid schema"); // Too vague
138
138
thrownewIllegalArgumentException("bad value"); // No specifics
139
139
```
140
140
141
-
Use `Json.toDisplayString(value, depth)` to render JSON fragments in error messages, and include relevant context like schema paths, actual vs expected values, and specific constraint violations.
141
+
Use `Json.toDisplayString(value, indent)` to render JSON fragments in error messages, and include relevant context like schema paths, actual vs expected values, and specific constraint violations.
142
142
143
143
## JSON Compatibility Suite
144
144
@@ -151,15 +151,15 @@ See `README.md` for user-facing commands. When running locally as an agent, use
151
151
-`json-java21-api-tracker`: API evolution tracking utilities.
152
152
-`json-compatibility-suite`: JSON Test Suite compatibility validation.
153
153
-`json-java21-jtd`: JSON Type Definition (JTD) validator based on RFC 8927.
154
-
-`json-java21-jsonpath`: JsonPath query engine over `jdk.sandbox.java.util.json` values.
154
+
-`json-java21-jsonpath`: JsonPath query engine over `jdk.incubator.java.util.json` values.
155
155
156
156
Only when you are asked to work on a specific module, start by reading that module's `README.md`, then its `AGENTS.md`.
157
157
158
158
These modules are treated as separate subsystems; do not read their docs unless you are actively working on them. They are not interlinked and each depends only on the core `json-java21` API.
159
159
160
160
### Core Components
161
161
162
-
#### Public API (`jdk.sandbox.java.util.json`)
162
+
#### Public API (`jdk.incubator.java.util.json`)
163
163
-`Json`: Static utilities for parsing, formatting, and conversion.
164
164
-`JsonValue`: Sealed root interface for all JSON types.
165
165
-`JsonObject`: JSON objects (key-value pairs).
@@ -169,14 +169,14 @@ These modules are treated as separate subsystems; do not read their docs unless
169
169
-`JsonBoolean`: JSON booleans.
170
170
-`JsonNull`: JSON null.
171
171
172
-
IMPORTANT: This API **MUST NOT** deviate from the upstream jdk.sandbox repo which is will track.
172
+
IMPORTANT: This API **MUST NOT** deviate from the upstream jdk.incubator repo which is will track.
-`Json*Impl`: Immutable implementations of `Json*` types.
177
177
-`Utils`: Internal utilities and factory methods.
178
178
179
-
IMPORTANT: Bugs in upstream-derived core logic MUST be fixed upstream. Do not patch `jdk.sandbox.*` sources in this repo unless the user explicitly agrees (for example, to carry a temporary local backport while the upstream fix is in progress).
179
+
IMPORTANT: Bugs in upstream-derived core logic MUST be fixed upstream. Do not patch `jdk.incubator.*` sources in this repo unless the user explicitly agrees (for example, to carry a temporary local backport while the upstream fix is in progress).
180
180
181
181
Only bugs in local, non-upstream code (for example, backporting shims/polyfills or other modules in this repo) should be fixed here using normal TDD.
This code is derived from the OpenJDK jdk-sandbox repository "json" branch at commit `c1a4f80` (2026-02-05), which was the last commit before the API was moved to `jdk.incubator.json`.
294
+
This code is derived from the OpenJDK jdk-sandbox repository "json" branch at commit `43325738c` (2026-08-27), which is the current frontier of the incubator-era `jdk.incubator.json`API. The incubator promotion itself happened at commit `b956ae0` (2026-02-05); this branch completed the migration from the sandbox-era `java.util.json` naming to the incubator packages — see the notice below and issue #145.
The upstream `java.util.json` API has been promoted to `jdk.incubator.json` (commit `b956ae0`, 2026-02-05). The incubator version introduces significant API changes including method renames (`bool()`→`asBoolean()`, `string()`→`asString()`, etc.) and new methods (`asInt()`). A separate branch tracks the incubator upgrade — see issue #145.
304
+
The upstream `java.util.json` API has been promoted to `jdk.incubator.json` (commit `b956ae0`, 2026-02-05). The incubator version introduces significant API changes including method renames (`bool()`→`asBoolean()`, `string()`→`asString()`, `toInt()`→`asInt()`, etc.), `tryGet()`/`tryValue()` navigation, and identity (non-value) `equals`/`hashCode`. **That migration is now DONE in this branch** (issue #145): the public API lives in `jdk.incubator.java.util.json` and the implementation in `jdk.incubator.internal.util.json`, matching upstream frontier `43325738c`.
303
305
304
306
The original proposal and design rationale can be found in the included PDF: [Towards a JSON API for the JDK.pdf](Towards%20a%20JSON%20API%20for%20the%20JDK.pdf)
305
307
306
308
The JSON compatibitlity tests in this repo suggest 99% conformance with a leading test suite when in "strict" mode. The two conformance expecatations that fail assume that duplicated keys in a JSON document are okay. The upstream code at this time appear to take a strict stance that it should not siliently ignore duplicate keys in a json object.
307
309
308
310
### CI: Upstream API Tracking
309
311
310
-
**Note**: The daily API tracker workflow currently targets the old `java.util.json` paths which no longer exist upstream. It needs to be updated to track `jdk.incubator.json` — see issue #145.
312
+
The `daily-api-tracker.yml` workflow runs daily at 02:00 UTC: it fetches the upstream `jdk.incubator.json` sources from the [jdk-sandbox `json` branch](https://github.com/openjdk/jdk-sandbox/tree/json) HEAD and compares public API signatures against the local `jdk.incubator.java.util.json` classes. When they differ it creates a fingerprint-deduplicated "API drift detected" issue; reports are uploaded as workflow artifacts (`target/api-tracker/`) with 90-day retention. The check can also be run locally:
This is a simplified backport with the following changes from the original:
315
323
- Replaced `LazyConstant` with a package-local polyfill using double-checked locking pattern.
316
324
- Added `Utils.powExact()` polyfill for `Math.powExact(long, int)` which is not available in Java 21.
317
-
- Replaced unnamed variables `_` with `ignored` for Java 21 compatibility.
325
+
- Replaced unnamed variables `_` with named variables (`e`, `v`, `k`) for Java 21 compatibility.
318
326
- Removed `@ValueBased` annotations.
319
327
- Removed `@PreviewFeature` annotations.
320
328
- Compatible with JDK 21.
321
329
322
330
### Upstream Bug Fixes
323
331
324
-
The following fixes have been applied to address bugs in the upstream OpenJDK jdk-sandbox code. These are upstream issues that should be reported to the [core-libs-dev@openjdk.org](mailto:core-libs-dev@openjdk.org) mailing list per OpenJDK process:
332
+
Historically this backport carried local fixes against the upstream OpenJDK jdk-sandbox code. With the uplift to upstream frontier `43325738c` their disposition is:
325
333
326
-
-**`JsonNumber.of(double)` offset bug** ([#118](https://github.com/simbo1905/java.util.json.Java21/issues/118)): The upstream implementation hardcodes `decimalOffset=0`and `exponentOffset=0`, causing `toLong()`to fail for integral doubles like `123.0`. Our fix delegates to `JsonNumber.of(String)` which correctly computes offsets via `Json.parse()`.
334
+
-**`JsonNumber.of(double)` offset bug** ([#118](https://github.com/simbo1905/java.util.json.Java21/issues/118)): **CLOSED BY UPSTREAM — no longer carried.** Upstream reworked the numeric logic: `of(double)` now computes the decimal/exponent offsets from `Double.toString` output via `indexOf`, and `JsonNumberImpl` was rewritten with `LazyConstant`-cached conversions, trailing-zero stripping and sign/scale handling. Verified equivalent to our historic `of(String)`delegation fix by `JsonNumberOfDoubleMatrixTest` (integral doubles such as `123.0` and `1.0E2`, fractions, negatives, zero variants, out-of-range `asInt`/`asLong` throwing `JsonValueException`, and very large/small magnitudes) plus the ported upstream `TestJsonNumber`. The historic delegation hack has been removed with the uplifted upstream source.
327
335
328
336
## Security Considerations
329
337
@@ -355,7 +363,7 @@ Per **RFC 8927 (JSON Typedef)**, the empty schema `{}` is the **empty form** and
0 commit comments