Skip to content

Commit 1d31a91

Browse files
committed
Issue #154 refresh sync tooling for the incubator module layout
RefreshFromUpstream.java now fetches the impl package from src/jdk.incubator.json/.../jdk/incubator/json/impl/, snapshots it under upstream/jdk.incubator.json.impl and skips the local-only LazyConstant polyfill. transform_upstream.py maps the upstream incubator packages to our jdk.incubator.* packages, drops the obsolete StableValue skip and reminds the operator to re-append the Utils.powExact polyfill. Transform regexes dry-run verified against fetched upstream sources. Verify: python3 dry-run of transform() on JsonStringImpl.java (5/5 mapping checks pass); no source-tree changes made by the dry run.
1 parent 52bd016 commit 1d31a91

2 files changed

Lines changed: 16 additions & 12 deletions

File tree

‎updates/2025-09-04/RefreshFromUpstream.java‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// Compact single-file Java 25 script to refresh and compare impl sources
22
// Run: java RefreshFromUpstream.java
3+
// Refreshed 2026-08-30 for the upstream jdk.incubator.json module layout (issue #154).
34

45
import java.io.*;
56
import java.net.URI;
@@ -37,19 +38,20 @@ void main() throws Exception {
3738

3839
// Work dirs (not checked in)
3940
Path updatesDir = repoRoot.resolve("updates/2025-09-04");
40-
Path upstreamDir = updatesDir.resolve("upstream/jdk.internal.util.json");
41+
Path upstreamDir = updatesDir.resolve("upstream/jdk.incubator.json.impl");
4142
Path reportDir = updatesDir.resolve("reports");
4243
Files.createDirectories(upstreamDir);
4344
Files.createDirectories(reportDir);
4445

45-
// Upstream raw base for impl package
46-
String upstreamBase = "https://raw.githubusercontent.com/openjdk/jdk-sandbox/refs/heads/json/src/java.base/share/classes/jdk/internal/util/json/";
46+
// Upstream raw base for the incubator module impl package
47+
String upstreamBase = "https://raw.githubusercontent.com/openjdk/jdk-sandbox/refs/heads/json/src/jdk.incubator.json/share/classes/jdk/incubator/json/impl/";
4748

48-
// Discover local impl files
49+
// Discover local impl files (LazyConstant.java is a local-only polyfill with no upstream counterpart)
4950
List<Path> localFiles;
5051
try (var stream = Files.list(localImplDir)) {
5152
localFiles = stream
5253
.filter(p -> p.getFileName().toString().endsWith(".java"))
54+
.filter(p -> !p.getFileName().toString().equals("LazyConstant.java"))
5355
.sorted()
5456
.toList();
5557
}

‎updates/2025-09-04/transform_upstream.py‎

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import os, sys, re, shutil
22

3-
SRC = 'updates/2025-09-04/upstream/jdk.internal.util.json'
3+
# Refreshed 2026-08-30 for the upstream jdk.incubator.json module layout (issue #154).
4+
# Scope: impl files fetched into the snapshot dir (see RefreshFromUpstream.java).
5+
# Public API files follow the manual process in json-java21/AGENTS.md.
6+
SRC = 'updates/2025-09-04/upstream/jdk.incubator.json.impl'
47
DST = 'json-java21/src/main/java/jdk/incubator/internal/util/json'
58

69
def read(path):
@@ -27,10 +30,11 @@ def write_safe(path, text):
2730
return True
2831

2932
def transform(text, name):
30-
# package
31-
text = re.sub(r'^package\s+jdk\.internal\.util\.json;', 'package jdk.incubator.internal.util.json;', text, flags=re.M)
32-
# imports for public API
33-
text = re.sub(r'^(\s*import\s+)java\.util\.json\.', r'\1jdk.incubator.java.util.json.', text, flags=re.M)
33+
# package: upstream impl package -> our internal package
34+
text = re.sub(r'^package\s+jdk\.incubator\.json\.impl;', 'package jdk.incubator.internal.util.json;', text, flags=re.M)
35+
# imports: impl-internal first (defensive; upstream impl rarely imports itself), then public API
36+
text = re.sub(r'^(\s*import\s+)jdk\.incubator\.json\.impl\.', r'\1jdk.incubator.internal.util.json.', text, flags=re.M)
37+
text = re.sub(r'^(\s*import\s+)jdk\.incubator\.json\.', r'\1jdk.incubator.java.util.json.', text, flags=re.M)
3438
# annotations (single-line)
3539
text = re.sub(r'^\s*@(?:jdk\.internal\..*|ValueBased|StableValue).*\n', '', text, flags=re.M)
3640
# remove import of ValueBased if present
@@ -57,9 +61,6 @@ def main():
5761
for name in os.listdir(SRC):
5862
if not name.endswith('.java'):
5963
continue
60-
if name in ('StableValue.java', 'Utils.java'):
61-
# Keep local backport helper and existing Utils for now
62-
continue
6364
src_path = os.path.join(SRC, name)
6465
dst_path = os.path.join(DST, name)
6566
data = read(src_path)
@@ -69,6 +70,7 @@ def main():
6970
if not ok:
7071
sys.exit(2)
7172
print('Transform complete')
73+
print('Reminder: after transforming, re-append the Utils.powExact polyfill (Java 21 lacks Math.powExact) and keep LazyConstant.java untouched (local polyfill).')
7274

7375
if __name__ == '__main__':
7476
main()

0 commit comments

Comments
 (0)