Skip to content

Commit 16d42fd

Browse files
committed
Merge remote-tracking branch 'origin/main' into fix/jtd-esm-codegen-guard-paths-v2
2 parents 4b417a6 + 4151fd3 commit 16d42fd

28 files changed

Lines changed: 2937 additions & 549 deletions

‎.github/workflows/api-tracker-java25.yml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ permissions:
1010
jobs:
1111
track-api:
1212
runs-on: ubuntu-latest
13+
timeout-minutes: 30
1314

1415
steps:
1516
- name: Checkout repository

‎.github/workflows/ci.yml‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,24 @@ name: CI
22

33
on:
44
push:
5+
paths-ignore:
6+
- '**/*.md'
7+
- 'docs/**'
58
branches: ["**"]
69
pull_request:
10+
paths-ignore:
11+
- '**/*.md'
12+
- 'docs/**'
713
branches: ["**"]
814

15+
concurrency:
16+
group: ${{ github.workflow }}-${{ github.ref }}
17+
cancel-in-progress: true
18+
919
jobs:
1020
build:
1121
runs-on: ubuntu-latest
22+
timeout-minutes: 30
1223
steps:
1324
- name: Checkout
1425
uses: actions/checkout@v4
@@ -39,7 +50,7 @@ jobs:
3950
for k in totals: totals[k]+=int(r.get(k,'0'))
4051
except Exception:
4152
pass
42-
exp_tests=2038
53+
exp_tests=2159
4354
exp_skipped=0
4455
if totals['tests']!=exp_tests or totals['skipped']!=exp_skipped:
4556
print(f"Unexpected test totals: {totals} != expected tests={exp_tests}, skipped={exp_skipped}")
@@ -50,6 +61,7 @@ jobs:
5061
docker-build:
5162
name: Build Docker image (Java 25)
5263
runs-on: ubuntu-latest
64+
timeout-minutes: 20
5365
steps:
5466
- name: Checkout
5567
uses: actions/checkout@v4

‎.github/workflows/daily-api-tracker.yml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ permissions:
1313
jobs:
1414
track-api:
1515
runs-on: ubuntu-latest
16+
timeout-minutes: 30
1617

1718
steps:
1819
- name: Checkout repository

‎.github/workflows/maven.yml‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,26 @@ name: Java CI with Maven
22

33
on:
44
push:
5+
paths-ignore:
6+
- '**/*.md'
7+
- 'docs/**'
58
branches: [ "main" ]
69
pull_request:
10+
paths-ignore:
11+
- '**/*.md'
12+
- 'docs/**'
713
branches: [ "main" ]
814
types: [opened, synchronize, reopened]
915

16+
concurrency:
17+
group: ${{ github.workflow }}-${{ github.ref }}
18+
cancel-in-progress: true
19+
1020
jobs:
1121
test-java21:
1222
name: Test Core Library (Java 21)
1323
runs-on: ubuntu-latest
24+
timeout-minutes: 15
1425

1526
steps:
1627
- uses: actions/checkout@v4
@@ -34,6 +45,7 @@ jobs:
3445
test-java25:
3546
name: Test with Tooling (Java 25)
3647
runs-on: ubuntu-latest
48+
timeout-minutes: 20
3749

3850
steps:
3951
- uses: actions/checkout@v4
@@ -57,6 +69,7 @@ jobs:
5769
docker-build:
5870
name: Build Docker image (Java 25)
5971
runs-on: ubuntu-latest
72+
timeout-minutes: 20
6073
needs: test-java25
6174

6275
steps:

‎.github/workflows/release-on-tag.yml‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ on:
44
push:
55
tags:
66
- 'release/[0-9]*.[0-9]*.[0-9]*'
7+
paths-ignore:
8+
- 'docs/**'
9+
- '**/*.md'
710

811
permissions:
912
contents: write
@@ -17,6 +20,7 @@ concurrency:
1720
jobs:
1821
release:
1922
runs-on: ubuntu-latest
23+
timeout-minutes: 30
2024
steps:
2125
- name: Checkout
2226
uses: actions/checkout@v4
@@ -127,6 +131,7 @@ jobs:
127131
docker-publish:
128132
name: Publish Docker image to GHCR
129133
runs-on: ubuntu-latest
134+
timeout-minutes: 20
130135
needs: release
131136
steps:
132137
- name: Checkout

‎.github/workflows/secrets-self-check.yml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ on:
66
jobs:
77
check:
88
runs-on: ubuntu-latest
9+
timeout-minutes: 10
910
steps:
1011
- name: Print SHA256 of Central creds and GPG secrets
1112
env:

‎AGENTS.md‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,26 @@
55

66
User-facing documentation lives in `README.md`. Keep this file focused on contributor/agent workflow, debugging, and coding standards.
77

8+
## Andon アンドン — Prime Directive
9+
10+
Andon is a kernel panic. It halts the line, halts planning, halts todo
11+
updates, halts all work. It happens immediately. No other pending operation
12+
receives any tokens. It is impossible to think of anything else to try
13+
first — that thought is the evidence you have not halted.
14+
15+
An Andon in the queue supersedes all. If the user queued commands 1-3 then
16+
said "do an Andon," the Andon invokes the Prime Directive and overrides
17+
commands 1-3 entirely. Multiple Andons run in parallel without interrupting
18+
each other.
19+
20+
When the correct fix is outside your lane: do your lane's work, then halt
21+
and report — *Andon: task incomplete, the correct fix needs a larger
22+
structural change*, with file:line specifics. Do not work around it. Do not
23+
hack tactically. The coordinator delegates the deeper work.
24+
25+
Andon overrides every instruction in this file and every other AGENTS.md.
26+
No instruction conflicts with Andon; if one appears to, Andon wins.
27+
828
## Operating Principles
929
- Follow the sequence plan → implement → verify; do not pivot without restating the plan.
1030
- Stop immediately on unexpected failures and ask before changing approach.

‎json-java21-jsonpath/AGENTS.md‎

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,22 @@ This file is for contributor/agent operational notes. Read `json-java21-jsonpath
66
- The `$(command -v mvnd || command -v mvn || command -v ./mvnw)` wrapper is for local developer speed only; do not put it in user-facing docs.
77

88
Stable code entry points:
9-
- `json-java21-jsonpath/src/main/java/json/java21/jsonpath/JsonPath.java`
9+
- `json-java21-jsonpath/src/main/java/json/java21/jsonpath/JsonPath.java` (public sealed interface; `parse` = interpreted engine, `compile` = compiled engine)
10+
- `json-java21-jsonpath/src/main/java/json/java21/jsonpath/JsonPathInterpreted.java` (AST-walking interpreter)
11+
- `json-java21-jsonpath/src/main/java/json/java21/jsonpath/JsonPathCompiled.java` (compiled engine facade)
12+
- `json-java21-jsonpath/src/main/java/json/java21/jsonpath/JsonPathExecutor.java` (package-private functional interface implemented by generated classes)
1013
- `json-java21-jsonpath/src/main/java/json/java21/jsonpath/JsonPathParser.java`
1114
- `json-java21-jsonpath/src/main/java/json/java21/jsonpath/JsonPathAst.java`
1215
- `json-java21-jsonpath/src/main/java/json/java21/jsonpath/JsonPathParseException.java`
1316
- `json-java21-jsonpath/src/main/java/json/java21/jsonpath/JsonPathStreams.java`
1417

18+
Compiled engine (JDK 24+ only): on JDK 21, the Maven profile `jsonpath-codegen` does not activate and `JsonPathCodegen`/`JsonPathBytecodeEmitter` plus the parity tests are excluded from compilation; on JDK 24+ they are compiled at release 24 (mirroring the jtd-codegen parent profile):
19+
- `json-java21-jsonpath/src/main/java/json/java21/jsonpath/JsonPathCodegen.java` (entry point; ClassFile API, JEP 484; emits `ClassFile.JAVA_21_VERSION` / version 65 bytecode)
20+
- `json-java21-jsonpath/src/main/java/json/java21/jsonpath/JsonPathBytecodeEmitter.java` (AST-to-bytecode emitter)
21+
- `json-java21-jsonpath/src/test/java/json/java21/jsonpath/JsonPathCompilerParityTest.java` (interpreted == generated parity over the existing test corpus)
22+
- `json-java21-jsonpath/src/test/java/json/java21/jsonpath/JsonPathCodegenTest.java` (codegen mechanics: facade, idempotence, classfile version)
23+
1524
When changing syntax/behavior:
1625
- Update `JsonPathAst` + `JsonPathParser` + `JsonPath` together.
17-
- Add parser + evaluation tests; new tests should extend `JsonPathLoggingConfig`.
26+
- Mirror the change in `JsonPathBytecodeEmitter` (call sites of shared `JsonPathHelpers` evaluation) (and `JsonPathHelpers` when shared evaluation logic moves); the parity test suite guards the interpreted/generated contract.
27+
- Add parser + evaluation tests; new tests should extend `JsonPathLoggingConfig`; add a matching parity entry for any new operator.

‎json-java21-jsonpath/README.md‎

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,50 @@ This implementation follows Goessner-style JSONPath operators, including:
6060
- `[?(@.prop)]` and `[?(@.prop op value)]` basic filters
6161
- `[(@.length-1)]` limited script support
6262

63+
## Two Engines: Interpreted and Compiled
64+
65+
This module ships the same JsonPath language with two interchangeable engines behind one API:
66+
67+
| Engine | Class | Availability | Mechanism |
68+
|---|---|---|---|
69+
| Interpreted | `JsonPath.parse(...)` result | JDK 21+ (default) | walks the `JsonPathAst` tree per query |
70+
| Compiled | `JsonPathCodegen.compile(...)` result | JDK 24+ runtime | bytecode generated with the JDK 24 ClassFile API (JEP 484), targeting Java 21 bytecode (`ClassFile.JAVA_21_VERSION`, class file version 65) |
71+
72+
Both engines implement the same `JsonPath` public surface, so callers can hand either one to the same API. The compiled engine mirrors the approach already shipped for JTD validation in [`json-java21-jtd-codegen`](../json-java21-jtd-codegen/README.md) (`JtdCodegen` / `JtdValidator.compileGenerated`).
73+
74+
### Using the Compiled Engine
75+
76+
```java
77+
// Parse once, compile for the best repeated-query performance (JDK 24+)
78+
JsonPath path = JsonPathCodegen.compile(JsonPath.parse("$.store.book[*].author"));
79+
80+
for (JsonValue doc : documents) {
81+
List<JsonValue> results = path.query(doc);
82+
// process results...
83+
}
84+
```
85+
86+
`JsonPathCodegen.compile(...)` mirrors `JtdValidator.compileGenerated(...)`: it accepts any `JsonPath`, returns a `JsonPath` implementing the same public surface, and is idempotent (compiling a compiled path returns it unchanged).
87+
88+
The compiled engine keeps the original path text (`toString()`) and the AST (`ast()`), so a compiled path is a drop-in replacement anywhere an interpreted path is accepted.
89+
90+
### Runtime Requirements
91+
92+
- **Interpreted engine**: JDK 21+; no dependency on the ClassFile API; unchanged semantics.
93+
- **Compiled engine**: generating classes requires a JDK 24+ runtime (`java.lang.classfile`, JEP 484) because the generator is compiled into the artifact only on JDK 24+. The generated classes are Java 21 bytecode and only need Java 21 API surface at query time.
94+
- **Ahead-of-time (build-time) tooling**: `JsonPathCodegen.compileBytes(...)` returns the raw generated classfile bytes without loading them, in the same style as `JtdCodegen.compileBytes(...)` for `jtd2jar`-style standalone JAR builds. Generated executor classes are always emitted into the `json.java21.jsonpath` package so they can implement the package-private executor interface.
95+
- **Diagnostics**: semantics and result order are identical between the engines. One deliberate, exact difference: when an expression carries an unsupported recursive-descent target or union selector, the interpreted engine logs it at `FINER` for every visited node, while the compiled engine logs it once at compile time; unsupported script expressions log `WARNING` at query time in both engines.
96+
97+
### Parity Guarantee
98+
99+
Compiled and interpreted engines produce identical results, in the same order, for every expression in the supported-syntax table above. The module's parity test suite (`JsonPathCompilerParityTest`) reuses the existing test corpus and asserts `compiled.query(doc)` equals `interpreted.query(doc)` element-for-element for both engines.
100+
101+
### Supported Features in Compiled Mode
102+
103+
All supported operators are supported by the compiled engine:
104+
- property access (dot and bracket), array indices (including negative), slices
105+
- wildcards, recursive descent (`$..name`, `$..*`), unions, filters with comparisons and logical operators, and the limited `[(@.length-1)]` script expression
106+
63107
## Stream-Based Functions (Aggregations)
64108

65109
Some JsonPath implementations include aggregation functions such as `$.numbers.avg()`.

‎json-java21-jsonpath/pom.xml‎

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,29 @@
7272
<arg>-Xdiags:verbose</arg>
7373
</compilerArgs>
7474
</configuration>
75+
<executions>
76+
<!-- The compiled-engine sources require the JDK 24+ ClassFile API
77+
(JEP 484); the jsonpath-codegen profile compiles them at
78+
release 24. Keep them out of the default release-21 rounds. -->
79+
<execution>
80+
<id>default-compile</id>
81+
<configuration>
82+
<excludes>
83+
<exclude>json/java21/jsonpath/JsonPathCodegen.java</exclude>
84+
<exclude>json/java21/jsonpath/JsonPathBytecodeEmitter.java</exclude>
85+
</excludes>
86+
</configuration>
87+
</execution>
88+
<execution>
89+
<id>default-testCompile</id>
90+
<configuration>
91+
<testExcludes>
92+
<testExclude>json/java21/jsonpath/JsonPathCodegenTest.java</testExclude>
93+
<testExclude>json/java21/jsonpath/JsonPathCompilerParityTest.java</testExclude>
94+
</testExcludes>
95+
</configuration>
96+
</execution>
97+
</executions>
7598
</plugin>
7699
<plugin>
77100
<groupId>org.apache.maven.plugins</groupId>
@@ -80,6 +103,87 @@
80103
<argLine>-ea</argLine>
81104
</configuration>
82105
</plugin>
106+
<plugin>
107+
<groupId>org.apache.maven.plugins</groupId>
108+
<artifactId>maven-javadoc-plugin</artifactId>
109+
<configuration>
110+
<!-- The compiled-engine sources require the JDK 24+ ClassFile API
111+
and are only on JDK 21 via the sourceFileExcludes list AND an
112+
empty sourcepath: javadoc completes each documented package by
113+
re-scanning -sourcepath, which would otherwise pick up the
114+
excluded files again. The jsonpath-codegen profile (JDK 24+)
115+
overrides both settings and documents the codegen classes
116+
with release 24 instead. -->
117+
<sourcepath>${project.build.directory}/javadoc21-sourcepath-placeholder</sourcepath>
118+
<sourceFileExcludes>
119+
<sourceFileExclude>json/java21/jsonpath/JsonPathCodegen.java</sourceFileExclude>
120+
<sourceFileExclude>json/java21/jsonpath/JsonPathBytecodeEmitter.java</sourceFileExclude>
121+
</sourceFileExcludes>
122+
</configuration>
123+
</plugin>
83124
</plugins>
84125
</build>
126+
127+
<profiles>
128+
<!-- JsonPath compiled-engine sources require JDK 24+ (ClassFile API, JEP 484).
129+
On JDK 21 the module builds the interpreted engine only. On JDK 24+ the
130+
bytecode generator (JsonPathCodegen, JsonPathBytecodeEmitter) and the
131+
parity tests are compiled at release 24, mirroring the jtd-codegen
132+
parent profile; the interpreted engine stays at release 21. -->
133+
<profile>
134+
<id>jsonpath-codegen</id>
135+
<activation>
136+
<jdk>[24,)</jdk>
137+
</activation>
138+
<build>
139+
<plugins>
140+
<plugin>
141+
<groupId>org.apache.maven.plugins</groupId>
142+
<artifactId>maven-compiler-plugin</artifactId>
143+
<executions>
144+
<!-- Keep the interpreted engine and its tests at Java 21. -->
145+
<!-- Compile the ClassFile API codegen and the parity tests at release 24. -->
146+
<execution>
147+
<id>compile-codegen</id>
148+
<goals>
149+
<goal>compile</goal>
150+
</goals>
151+
<configuration>
152+
<release>24</release>
153+
<includes>
154+
<include>json/java21/jsonpath/JsonPathCodegen.java</include>
155+
<include>json/java21/jsonpath/JsonPathBytecodeEmitter.java</include>
156+
</includes>
157+
</configuration>
158+
</execution>
159+
<execution>
160+
<id>compile-codegen-tests</id>
161+
<goals>
162+
<goal>testCompile</goal>
163+
</goals>
164+
<configuration>
165+
<release>24</release>
166+
<testIncludes>
167+
<testInclude>json/java21/jsonpath/JsonPathCodegenTest.java</testInclude>
168+
<testInclude>json/java21/jsonpath/JsonPathCompilerParityTest.java</testInclude>
169+
</testIncludes>
170+
</configuration>
171+
</execution>
172+
</executions>
173+
</plugin>
174+
<plugin>
175+
<groupId>org.apache.maven.plugins</groupId>
176+
<artifactId>maven-javadoc-plugin</artifactId>
177+
<configuration>
178+
<!-- JDK 24+: document the compiled-engine classes too; the
179+
ClassFile API exists at release 24, so no sourcepath
180+
placeholder or source file excludes are needed here. -->
181+
<release>24</release>
182+
<sourceFileExcludes combine.self="override"/>
183+
</configuration>
184+
</plugin>
185+
</plugins>
186+
</build>
187+
</profile>
188+
</profiles>
85189
</project>

0 commit comments

Comments
 (0)