@@ -5,13 +5,43 @@ This file is for contributor/agent operational notes. Read `json-java21-jsonpath
55- User docs MUST recommend only ` ./mvnw ` .
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
8- Stable code entry points:
9- - ` json-java21-jsonpath/src/main/java/json/java21/jsonpath/JsonPath.java `
10- - ` json-java21-jsonpath/src/main/java/json/java21/jsonpath/JsonPathParser.java `
11- - ` json-java21-jsonpath/src/main/java/json/java21/jsonpath/JsonPathAst.java `
12- - ` json-java21-jsonpath/src/main/java/json/java21/jsonpath/JsonPathParseException.java `
13- - ` json-java21-jsonpath/src/main/java/json/java21/jsonpath/JsonPathStreams.java `
14-
15- When changing syntax/behavior:
16- - Update ` JsonPathAst ` + ` JsonPathParser ` + ` JsonPath ` together.
8+ ## Architecture
9+
10+ JsonPath is a sealed interface with two implementations:
11+ - ` JsonPathInterpreted ` : AST-walking interpreter (default from ` JsonPath.parse() ` )
12+ - ` JsonPathCompiled ` : Bytecode-compiled version (from ` JsonPath.compile() ` )
13+
14+ The compilation flow:
15+ 1 . ` JsonPath.parse() ` -> ` JsonPathInterpreted ` (fast parsing, AST-based evaluation)
16+ 2 . ` JsonPath.compile() ` -> ` JsonPathCompiled ` (generates Java source, compiles with JDK ToolProvider)
17+
18+ ## Stable Code Entry Points
19+
20+ - ` json-java21-jsonpath/src/main/java/json/java21/jsonpath/JsonPath.java ` - Public sealed interface
21+ - ` json-java21-jsonpath/src/main/java/json/java21/jsonpath/JsonPathParser.java ` - Parses expressions to AST
22+ - ` json-java21-jsonpath/src/main/java/json/java21/jsonpath/JsonPathAst.java ` - AST node definitions
23+ - ` json-java21-jsonpath/src/main/java/json/java21/jsonpath/JsonPathInterpreted.java ` - AST-walking evaluator
24+ - ` json-java21-jsonpath/src/main/java/json/java21/jsonpath/JsonPathCompiler.java ` - Code generator and compiler
25+ - ` json-java21-jsonpath/src/main/java/json/java21/jsonpath/JsonPathCompiled.java ` - Compiled executor wrapper
26+ - ` json-java21-jsonpath/src/main/java/json/java21/jsonpath/JsonPathExecutor.java ` - Public interface for generated executors
27+ - ` json-java21-jsonpath/src/main/java/json/java21/jsonpath/JsonPathHelpers.java ` - Helpers for generated code
28+ - ` json-java21-jsonpath/src/main/java/json/java21/jsonpath/JsonPathStreams.java ` - Stream processing utilities
29+
30+ ## When Changing Syntax/Behavior
31+
32+ - Update ` JsonPathAst ` + ` JsonPathParser ` + ` JsonPathInterpreted ` together.
33+ - Update ` JsonPathCompiler ` code generation to match any AST changes.
1734- Add parser + evaluation tests; new tests should extend ` JsonPathLoggingConfig ` .
35+ - Add compiler tests in ` JsonPathCompilerTest ` to verify compiled and interpreted produce identical results.
36+
37+ ## Code Generation Notes
38+
39+ The ` JsonPathCompiler ` generates Java source code that:
40+ - Imports from ` jdk.sandbox.java.util.json.* ` and ` json.java21.jsonpath.* `
41+ - Implements ` JsonPathExecutor ` functional interface
42+ - Uses ` JsonPathHelpers ` for complex operations (recursive descent, comparisons)
43+ - Is compiled in-memory using ` javax.tools.ToolProvider `
44+
45+ When adding new AST node types:
46+ 1 . Add the case to ` generateSegmentEvaluation() ` in ` JsonPathCompiler `
47+ 2 . Consider if a helper method in ` JsonPathHelpers ` would simplify the generated code
0 commit comments