Skip to content

Add json-java21-jdt module for JSON Document Transforms#142

Open
simbo1905 wants to merge 24 commits intomainfrom
jdt-transforms2
Open

Add json-java21-jdt module for JSON Document Transforms#142
simbo1905 wants to merge 24 commits intomainfrom
jdt-transforms2

Conversation

@simbo1905
Copy link
Owner

@simbo1905 simbo1905 commented Feb 9, 2026

Summary

  • Rename module from json-java21-transforms to json-java21-jdt (JSON Document Transforms)
  • New package json.java21.jdt with Jdt engine and JdtException
  • Implement core JDT operations: @jdt.replace, @jdt.remove, @jdt.rename, @jdt.merge
  • Execution order: Rename → Remove → Merge → Replace
  • 33 tests passing (18 unit tests + 15 Microsoft fixture tests)

Features Implemented

  • Default transformation: Recursive merge of objects, array append, primitive replacement
  • @jdt.replace: Wholesale node replacement (primitives, objects, arrays with double-bracket syntax)
  • @jdt.remove: Remove keys by name, array of names, or boolean true to null
  • @jdt.rename: Rename keys using object mapping
  • @jdt.merge: Explicit merge operation

Deferred

Path-based operations using @jdt.path attribute moved to Skipped/ folders for future implementation.

Verification

mvn test -pl json-java21-jdt -Djava.util.logging.ConsoleHandler.level=INFO

Note

Medium Risk
Large net-new functionality across multiple modules plus new code generation paths and CI/release automation; main risk is build/test pipeline changes and correctness of the new transform/codegen implementations.

Overview
Adds a new json-java21-jdt module implementing JSON Document Transforms with @jdt.rename/remove/merge/replace (fixed execution order) plus an AST parser (parseToAst) and an experimental ES2020 ESM renderer for emitting a transform(source) module.

Introduces bytecode/codegen tooling modules for JsonPath (json-java21-jsonpath-codegen) and JTD (json-java21-jtd-codegen), exposes JsonPath.ast() and makes JsonPathAst public to support codegen, and adds an ES2020 JsonPathEsmRenderer with tests.

CI is updated to exclude the Java 24-only codegen modules from the JDK 21 workflow and to assert the new overall test count; a new nightly GitHub Action builds and publishes jtd-esm-codegen uber-jar + GraalVM native binaries. Minor docs/ignore updates add the new submodule to README.md and ignore .DS_Store.

Written by Cursor Bugbot for commit 8f0032e. This will update automatically on new commits. Configure here.

cursoragent and others added 23 commits February 5, 2026 14:13
Co-authored-by: Simon Massey <simbo1905@users.noreply.github.com>
Co-authored-by: Simon Massey <simbo1905@users.noreply.github.com>
Co-authored-by: Simon Massey <simbo1905@users.noreply.github.com>
Co-authored-by: Simon Massey <simbo1905@users.noreply.github.com>
Co-authored-by: Simon Massey <simbo1905@users.noreply.github.com>
…on bug (#31)

- Add junit-js 2.0.0 dependency with GraalVM exclusions to avoid version conflicts
- Add JUnit Vintage engine to run JUnit 4 tests under JUnit 5 Platform
- Configure Surefire to discover *TestSuite.java files
- Delete bun-based src/test/js/ directory (replaced by junit-js)
- Add JtdEsmJsTestSuite.java to run JS tests via @RunWith(JSRunner.class)
- Add boolean-schema.test.js and nested-elements-empty-focused.test.js
  - Tests run in GraalVM polyglot, no external JS runtime needed
- Fix EsmRenderer bug where inline validator functions were never emitted:
  - Add generateInlineFunctions() method to emit collected inline validators
  - Fix collision issue by using counter instead of hashCode for function names
  - Support nested elements/schemas that require multiple inline validators

Test results: 29 tests pass in jtd-esm-codegen (17 Java + 2 property + 10 JS)
- Remove all bun-specific code (ProcessBuilder runners, isBunAvailable checks)
- Replace with GraalVM Polyglot JS in-process execution via jsContext()/evalModule()
- Add GraalVM helper methods: jsContext(), evalModule(), errCount()
- Simplify test schemas (inline them instead of separate variables)
- Add generatedDiscriminatorValidatorWorks test
- Add JTD_CODEGEN_SPEC.md documentation
- All 17 tests pass, no external JS runtime required
Adds json-java21-jtd-codegen module (JDK 24+, --release 24) that
compiles JTD schemas into bytecode validators targeting Java 21.
Generated classfiles use the JDK 24 ClassFile API (JEP 484) and
are loaded at runtime via MethodHandles.Lookup.defineClass().

Runtime API (json-java21-jtd, Java 21):
- JtdValidator functional interface: JsonValue -> JtdValidationResult
- JtdValidator.compile(schema) -- interpreter path, always available
- JtdValidator.compileGenerated(schema) -- codegen path via reflection
- JtdValidationResult record with RFC 8927 (instancePath, schemaPath)
- InterpreterValidator wraps the existing stack machine

Codegen module (json-java21-jtd-codegen, JDK 24+):
- Modular emitter architecture: EmitNode dispatches to per-form
  emitters (EmitType, EmitEnum, EmitElements, EmitProperties,
  EmitValues, EmitDiscriminator)
- Lazy instance path construction: deferred concat only on error
- Average 9.4x faster than interpreter on valid documents

RFC 8927 conformance:
- Schema path corrections per official validation suite:
  Elements/Values/Properties/Discriminator type guards,
  Properties conditional guard (/properties vs /optionalProperties),
  Ref paths use /definitions/<name>/...
- 316/316 official json-typedef-spec validation.json cases pass
  (interpreter); 314/316 codegen (2 recursive schemas skipped)

Verification:
- json-java21-jtd: 452 tests (136 unit + 316 spec conformance)
- json-java21-jtd-codegen: 398 tests (82 cross-validation + 316 spec)
- Total: 850 tests, all passing
…forms)

- Rename module from json-java21-transforms to json-java21-jdt
- New package: json.java21.jdt with Jdt engine and JdtException
- Implement core JDT operations: replace, remove, rename, merge
- Execution order: Rename → Remove → Merge → Replace
- 18 unit tests + 15 Microsoft fixture tests (33 total)
- Path-based operations deferred to Skipped/ folders for future work

To verify: mvn test -pl json-java21-jdt
…on-java21-jdt

To verify: mvn test -pl json-java21-jdt -am -Djava.util.logging.ConsoleHandler.level=INFO
…queries

Compiles JsonPath expressions into Java 21 classfiles via the JDK 24+
ClassFile API. Generated code eliminates interpretation overhead by
inlining all segment dispatch at codegen time.

Supports all 8 segment types: PropertyAccess, ArrayIndex, ArraySlice,
Wildcard, RecursiveDescent, Filter, Union, ScriptExpression.

Uses runtime helpers for recursive descent (DFS traversal) and filter
comparison (value extraction and comparison logic).

29 cross-validation tests verify codegen produces identical results
to the interpreter for all supported JsonPath expressions.

Also makes JsonPathAst public and adds JsonPath.ast() accessor
for cross-module codegen access.

To verify: mvn test -pl json-java21-jsonpath-codegen -am
…ing init

- Exclude json-java21-jtd-codegen and json-java21-jsonpath-codegen from
  the Java 21 CI build (they require JDK 24+ ClassFile API)
- Update test count to 653 (excluding codegen modules)
- Fix CodegenTestBase to handle empty logging level property in CI

To verify: mvn test -pl '!json-java21-jtd-codegen,!json-java21-jsonpath-codegen'
Thread a pathResolver function through the JDT engine so callers can
plug in bytecode-compiled JsonPath queries instead of the interpreter.

The new overload Jdt.transform(source, transform, pathResolver) accepts
a Function<String, Function<JsonValue, List<JsonValue>>> that compiles
a JsonPath expression into a query function.

Default behavior unchanged: uses JsonPath.parse(expr)::query.

Example with compiled JsonPath:
  Jdt.transform(source, transform, expr -> JsonPathCodegen.compile(expr)::query);

All 33 existing tests pass unchanged.

To verify: mvn test -pl json-java21-jdt -am
Create JdtAst with three sealed node types:
- DirectiveNode: contains @jdt.rename/remove/merge/replace + children
- MergeNode: default object-to-object deep merge
- ReplacementNode: direct value replacement

JdtAstParser builds the AST from a JsonValue transform document.
Jdt.parseToAst() public API for codegen modules to access the AST.

4 new AST parser tests (22 total JDT unit tests).

To verify: mvn test -pl json-java21-jdt -am
Walk the JsonPath AST with exhaustive switch to emit JavaScript that
evaluates the expression without interpretation overhead.

Generated modules export a query(root) function that returns an array
of matched values. Supports all segment types: property access, array
index, slice, wildcard, recursive descent, filter, union, script.

18 tests verify structural validity and correct rendering for each
segment type.

To verify: mvn test -pl json-java21-jsonpath -Dtest=JsonPathEsmRendererTest
Walk the JDT AST with exhaustive switch to emit JavaScript that
applies the transform without interpretation overhead. Generated
modules export a transform(source) function with inlined directive
logic and a deepMerge helper.

Supports all JDT directives: rename, remove, merge, replace, plus
default recursive merge for non-directive keys.

7 tests verify correct rendering for each directive type and
structural validity.

To verify: mvn test -pl json-java21-jdt -Dtest=JdtEsmRendererTest
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b96335a950

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +334 to +337
for (final var entry : source.members().entrySet()) {
final var value = entry.getValue();
if (!toRemove.contains(value)) {
if (value instanceof JsonObject childObj) {

Choose a reason for hiding this comment

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

P2 Badge Match removals by identity to avoid deleting equal values

The path-based remove uses toRemove.contains(value), which relies on JsonValue.equals (value-based in JsonArrayImpl/JsonObjectImpl). That means if the matched node’s value is equal to other nodes elsewhere, those unrelated nodes will also be removed even though they were not selected by the JSONPath. For example, a path that matches a single 1 in $.items[0] will remove every other 1 in the document. To preserve path semantics, track matches by identity (e.g., IdentityHashMap/Set) and compare with == when deciding what to remove.

Useful? React with 👍 / 👎.

@gemini-code-assist
Copy link

Summary of Changes

Hello @simbo1905, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly expands the project's JSON processing capabilities by introducing a new module for declarative JSON document transformations (JDT). It also establishes a robust framework for generating highly optimized, bytecode-based validators for both JsonPath queries and JTD schemas, alongside an experimental ES2020 module generator for JTD. These additions aim to enhance performance and provide flexible, standards-compliant JSON manipulation and validation tools.

Highlights

  • New JSON Document Transforms (JDT) Module: Introduced a new module json-java21-jdt for declarative JSON document transformations, inspired by Microsoft's JDT specification. This module implements core operations like replace, remove, rename, and merge, with a fixed execution order.
  • Advanced Code Generation Capabilities: Added new modules json-java21-jsonpath-codegen and json-java21-jtd-codegen to enable bytecode-generated JsonPath queries and JTD validators, respectively. This aims to improve performance by compiling validation logic directly into Java bytecode, eliminating runtime interpretation overhead.
  • ESM Validator Code Generator (Experimental): Included an experimental jtd-esm-codegen module that generates vanilla ES2020 JavaScript modules from JTD schemas, intended for browser-side validation without a build step.
  • Enhanced JTD Validator API: The json-java21-jtd module now offers a functional JtdValidator interface with both interpreter-based and optional bytecode-generated (compileGenerated) paths, providing RFC 8927 compliant error reporting.
  • Comprehensive Testing and Documentation: Added extensive probe tests, spec conformance tests, and detailed specification documents (JTD_CODEGEN_SPEC.md, JTD_STACK_MACHINE_SPEC.md) to formalize and verify the JTD implementation and code generation logic.
Changelog
  • .gitignore
    • Added macOS metadata entries (.DS_Store) to ignore list.
  • README.md
    • Updated the table of contents to include the new jtd-esm-codegen module.
    • Added a new section detailing the 'JTD to ESM Validator Codegen (Experimental)' tool, its features, supported JTD subset, and build/run instructions.
  • json-java21-jdt/AGENTS.md
    • Added a new file providing operational notes for contributors, clarifying the meaning of 'JDT' in this project (JSON Document Transforms vs. Eclipse JDT).
    • Documented stable code entry points, dependencies, current architecture (static walker), incomplete features (path-based rename), transform verb processing, test fixtures, and future directions (AST and code generation).
  • json-java21-jdt/README.md
    • Added a new comprehensive README for the json-java21-jdt module, detailing its features, quick start guide, default transformation behavior, explicit transform verbs (@jdt.rename, @jdt.remove, @jdt.merge, @jdt.replace), fixed execution order, path-based operations, error handling, building/testing instructions, architecture, source/test files, and Microsoft JDT fixture status.
  • json-java21-jdt/pom.xml
    • Added a new Maven POM file for the json-java21-jdt module, defining its artifact ID, packaging, name, SCM details, and description.
    • Declared dependencies on java.util.json and java.util.json.jsonpath, along with JUnit Jupiter and AssertJ for testing.
  • json-java21-jdt/src/main/java/json/java21/jdt/Jdt.java
    • Added the core Jdt class, implementing the transform methods for applying JSON document transformations.
    • Implemented logic for applying JDT directives (@jdt.rename, @jdt.remove, @jdt.merge, @jdt.replace) with a defined execution order.
    • Included helper methods for merging objects, appending arrays, and applying transformations to matched nodes using JsonPath.
  • json-java21-jdt/src/main/java/json/java21/jdt/JdtAst.java
    • Added a new sealed interface JdtAst.JdtNode to represent the Abstract Syntax Tree (AST) for JDT transform specifications, including DirectiveNode, MergeNode, and ReplacementNode records.
  • json-java21-jdt/src/main/java/json/java21/jdt/JdtAstParser.java
    • Added the JdtAstParser class responsible for parsing JSON transform documents into the JdtAst.JdtNode tree structure.
  • json-java21-jdt/src/main/java/json/java21/jdt/JdtEsmRenderer.java
    • Added the JdtEsmRenderer class, which renders a JDT AST into an ES2020 module exporting a transform(source) function for JavaScript environments.
  • json-java21-jdt/src/main/java/json/java21/jdt/JdtException.java
    • Added a new custom runtime exception JdtException for invalid JDT transform specifications.
  • json-java21-jdt/src/test/java/json/java21/jdt/JdtEsmRendererTest.java
    • Added unit tests for JdtEsmRenderer, verifying the correct generation of ES2020 modules for various JDT directives and primitive replacements.
  • json-java21-jdt/src/test/java/json/java21/jdt/JdtLoggingConfig.java
    • Added a new base class JdtLoggingConfig for JDT tests to standardize JUL logging configuration.
  • json-java21-jdt/src/test/java/json/java21/jdt/JdtTest.java
    • Added comprehensive unit tests for the Jdt engine, covering default transformations, specific @jdt.replace, @jdt.remove, @jdt.rename, @jdt.merge directives, combined transformations, edge cases, and AST parsing.
  • json-java21-jdt/src/test/java/json/java21/jdt/MicrosoftJdtFixturesTest.java
    • Added a parameterized test class MicrosoftJdtFixturesTest to run the official Microsoft JSON Document Transforms test fixtures against the Java implementation, ensuring compatibility and correctness.
  • json-java21-jdt/src/test/resources/microsoft-json-document-transforms/Inputs/Default/Array.Merge.Expected.json
    • Added expected JSON output for array merge default transformation.
  • json-java21-jdt/src/test/resources/microsoft-json-document-transforms/Inputs/Default/Array.Merge.Transform.json
    • Added transform JSON for array merge default transformation.
  • json-java21-jdt/src/test/resources/microsoft-json-document-transforms/Inputs/Default/Array.Replace.Expected.json
    • Added expected JSON output for array replace default transformation.
  • json-java21-jdt/src/test/resources/microsoft-json-document-transforms/Inputs/Default/Array.Replace.Transform.json
    • Added transform JSON for array replace default transformation.
  • json-java21-jdt/src/test/resources/microsoft-json-document-transforms/Inputs/Default/Array.Source.json
    • Added source JSON for array default transformations.
  • json-java21-jdt/src/test/resources/microsoft-json-document-transforms/Inputs/Default/Object.Merge.Expected.json
    • Added expected JSON output for object merge default transformation.
  • json-java21-jdt/src/test/resources/microsoft-json-document-transforms/Inputs/Default/Object.Merge.Transform.json
    • Added transform JSON for object merge default transformation.
  • json-java21-jdt/src/test/resources/microsoft-json-document-transforms/Inputs/Default/Object.Replace.Expected.json
    • Added expected JSON output for object replace default transformation.
  • json-java21-jdt/src/test/resources/microsoft-json-document-transforms/Inputs/Default/Object.Replace.Transform.json
    • Added transform JSON for object replace default transformation.
  • json-java21-jdt/src/test/resources/microsoft-json-document-transforms/Inputs/Default/Object.Source.json
    • Added source JSON for object default transformations.
  • json-java21-jdt/src/test/resources/microsoft-json-document-transforms/Inputs/Default/Primitive.AddArray.Expected.json
    • Added expected JSON output for primitive add array default transformation.
  • json-java21-jdt/src/test/resources/microsoft-json-document-transforms/Inputs/Default/Primitive.AddArray.Transform.json
    • Added transform JSON for primitive add array default transformation.
  • json-java21-jdt/src/test/resources/microsoft-json-document-transforms/Inputs/Default/Primitive.AddObject.Expected.json
    • Added expected JSON output for primitive add object default transformation.
  • json-java21-jdt/src/test/resources/microsoft-json-document-transforms/Inputs/Default/Primitive.AddObject.Transform.json
    • Added transform JSON for primitive add object default transformation.
  • json-java21-jdt/src/test/resources/microsoft-json-document-transforms/Inputs/Default/Primitive.AddPrimitive.Expected.json
    • Added expected JSON output for primitive add primitive default transformation.
  • json-java21-jdt/src/test/resources/microsoft-json-document-transforms/Inputs/Default/Primitive.AddPrimitive.Transform.json
    • Added transform JSON for primitive add primitive default transformation.
  • json-java21-jdt/src/test/resources/microsoft-json-document-transforms/Inputs/Default/Primitive.Replace.Expected.json
    • Added expected JSON output for primitive replace default transformation.
  • json-java21-jdt/src/test/resources/microsoft-json-document-transforms/Inputs/Default/Primitive.Replace.Transform.json
    • Added transform JSON for primitive replace default transformation.
  • json-java21-jdt/src/test/resources/microsoft-json-document-transforms/Inputs/Default/Primitive.Source.json
    • Added source JSON for primitive default transformations.
  • json-java21-jdt/src/test/resources/microsoft-json-document-transforms/Inputs/Merge/Object.Source.json
    • Added source JSON for merge object transformations.
  • json-java21-jdt/src/test/resources/microsoft-json-document-transforms/Inputs/Merge/Primitive.MergeObjects.Expected.json
    • Added expected JSON output for primitive merge objects transformation.
  • json-java21-jdt/src/test/resources/microsoft-json-document-transforms/Inputs/Merge/Primitive.MergeObjects.Transform.json
    • Added transform JSON for primitive merge objects transformation.
  • json-java21-jdt/src/test/resources/microsoft-json-document-transforms/Inputs/Merge/Primitive.MergePrimitives.Expected.json
    • Added expected JSON output for primitive merge primitives transformation.
  • json-java21-jdt/src/test/resources/microsoft-json-document-transforms/Inputs/Merge/Primitive.MergePrimitives.Transform.json
    • Added transform JSON for primitive merge primitives transformation.
  • json-java21-jdt/src/test/resources/microsoft-json-document-transforms/Inputs/Merge/Primitive.Source.json
    • Added source JSON for primitive merge transformations.
  • json-java21-jdt/src/test/resources/microsoft-json-document-transforms/Inputs/Merge/Skipped/Object.MergeObjects.Expected.json
    • Added expected JSON output for skipped object merge objects transformation.
  • json-java21-jdt/src/test/resources/microsoft-json-document-transforms/Inputs/Merge/Skipped/Object.MergeObjects.Transform.json
    • Added transform JSON for skipped object merge objects transformation.
  • json-java21-jdt/src/test/resources/microsoft-json-document-transforms/Inputs/Merge/Skipped/Object.UsingDirectPath.Expected.json
    • Added expected JSON output for skipped object using direct path merge transformation.
  • json-java21-jdt/src/test/resources/microsoft-json-document-transforms/Inputs/Merge/Skipped/Object.UsingDirectPath.Transform.json
    • Added transform JSON for skipped object using direct path merge transformation.
  • json-java21-jdt/src/test/resources/microsoft-json-document-transforms/Inputs/Merge/Skipped/Primitive.UsingSimplePath.Expected.json
    • Added expected JSON output for skipped primitive using simple path merge transformation.
  • json-java21-jdt/src/test/resources/microsoft-json-document-transforms/Inputs/Merge/Skipped/Primitive.UsingSimplePath.Transform.json
    • Added transform JSON for skipped primitive using simple path merge transformation.
  • json-java21-jdt/src/test/resources/microsoft-json-document-transforms/Inputs/Remove/Array.Source.json
    • Added source JSON for array remove transformations.
  • json-java21-jdt/src/test/resources/microsoft-json-document-transforms/Inputs/Remove/Object.Source.json
    • Added source JSON for object remove transformations.
  • json-java21-jdt/src/test/resources/microsoft-json-document-transforms/Inputs/Remove/Object.WithBool.Expected.json
    • Added expected JSON output for object with boolean remove transformation.
  • json-java21-jdt/src/test/resources/microsoft-json-document-transforms/Inputs/Remove/Object.WithBool.Transform.json
    • Added transform JSON for object with boolean remove transformation.
  • json-java21-jdt/src/test/resources/microsoft-json-document-transforms/Inputs/Remove/Primitive.FromRoot.Expected.json
    • Added expected JSON output for primitive from root remove transformation.
  • json-java21-jdt/src/test/resources/microsoft-json-document-transforms/Inputs/Remove/Primitive.FromRoot.Transform.json
    • Added transform JSON for primitive from root remove transformation.
  • json-java21-jdt/src/test/resources/microsoft-json-document-transforms/Inputs/Remove/Primitive.Source.json
    • Added source JSON for primitive remove transformations.
  • json-java21-jdt/src/test/resources/microsoft-json-document-transforms/Inputs/Remove/Skipped/Array.DirectPath.Expected.json
    • Added expected JSON output for skipped array direct path remove transformation.
  • json-java21-jdt/src/test/resources/microsoft-json-document-transforms/Inputs/Remove/Skipped/Array.DirectPath.Transform.json
    • Added transform JSON for skipped array direct path remove transformation.
  • json-java21-jdt/src/test/resources/microsoft-json-document-transforms/Inputs/Remove/Skipped/Array.ScriptPath.Expected.json
    • Added expected JSON output for skipped array script path remove transformation.
  • json-java21-jdt/src/test/resources/microsoft-json-document-transforms/Inputs/Remove/Skipped/Array.ScriptPath.Transform.json
    • Added transform JSON for skipped array script path remove transformation.
  • json-java21-jdt/src/test/resources/microsoft-json-document-transforms/Inputs/Remove/Skipped/Object.DirectPath.Expected.json
    • Added expected JSON output for skipped object direct path remove transformation.
  • json-java21-jdt/src/test/resources/microsoft-json-document-transforms/Inputs/Remove/Skipped/Object.DirectPath.Transform.json
    • Added transform JSON for skipped object direct path remove transformation.
  • json-java21-jdt/src/test/resources/microsoft-json-document-transforms/Inputs/Remove/Skipped/Object.InObject.Expected.json
    • Added expected JSON output for skipped object in object remove transformation.
  • json-java21-jdt/src/test/resources/microsoft-json-document-transforms/Inputs/Remove/Skipped/Object.InObject.Transform.json
    • Added transform JSON for skipped object in object remove transformation.
  • json-java21-jdt/src/test/resources/microsoft-json-document-transforms/Inputs/Remove/Skipped/Object.PathToItself.Expected.json
    • Added expected JSON output for skipped object path to itself remove transformation.
  • json-java21-jdt/src/test/resources/microsoft-json-document-transforms/Inputs/Remove/Skipped/Object.PathToItself.Transform.json
    • Added transform JSON for skipped object path to itself remove transformation.
  • json-java21-jdt/src/test/resources/microsoft-json-document-transforms/Inputs/Remove/Skipped/Object.ScriptPath.Expected.json
    • Added expected JSON output for skipped object script path remove transformation.
  • json-java21-jdt/src/test/resources/microsoft-json-document-transforms/Inputs/Remove/Skipped/Object.ScriptPath.Transform.json
    • Added transform JSON for skipped object script path remove transformation.
  • json-java21-jdt/src/test/resources/microsoft-json-document-transforms/Inputs/Remove/Skipped/Primitive.UsingPathArray.Expected.json
    • Added expected JSON output for skipped primitive using path array remove transformation.
  • json-java21-jdt/src/test/resources/microsoft-json-document-transforms/Inputs/Remove/Skipped/Primitive.UsingPathArray.Transform.json
    • Added transform JSON for skipped primitive using path array remove transformation.
  • json-java21-jdt/src/test/resources/microsoft-json-document-transforms/Inputs/Remove/Skipped/Primitive.UsingSimpleArray.Expected.json
    • Added expected JSON output for skipped primitive using simple array remove transformation.
  • json-java21-jdt/src/test/resources/microsoft-json-document-transforms/Inputs/Remove/Skipped/Primitive.UsingSimpleArray.Transform.json
    • Added transform JSON for skipped primitive using simple array remove transformation.
  • json-java21-jdt/src/test/resources/microsoft-json-document-transforms/Inputs/Remove/Skipped/Primitive.UsingSimplePath.Expected.json
    • Added expected JSON output for skipped primitive using simple path remove transformation.
  • json-java21-jdt/src/test/resources/microsoft-json-document-transforms/Inputs/Remove/Skipped/Primitive.UsingSimplePath.Transform.json
    • Added transform JSON for skipped primitive using simple path remove transformation.
  • json-java21-jdt/src/test/resources/microsoft-json-document-transforms/Inputs/Rename/Array.Source.json
    • Added source JSON for array rename transformations.
  • json-java21-jdt/src/test/resources/microsoft-json-document-transforms/Inputs/Rename/Object.Source.json
    • Added source JSON for object rename transformations.
  • json-java21-jdt/src/test/resources/microsoft-json-document-transforms/Inputs/Rename/Primitive.FromRoot.Expected.json
    • Added expected JSON output for primitive from root rename transformation.
  • json-java21-jdt/src/test/resources/microsoft-json-document-transforms/Inputs/Rename/Primitive.FromRoot.Transform.json
    • Added transform JSON for primitive from root rename transformation.
  • json-java21-jdt/src/test/resources/microsoft-json-document-transforms/Inputs/Rename/Primitive.Source.json
    • Added source JSON for primitive rename transformations.
  • json-java21-jdt/src/test/resources/microsoft-json-document-transforms/Inputs/Rename/Skipped/Array.DirectPath.Expected.json
    • Added expected JSON output for skipped array direct path rename transformation.
  • json-java21-jdt/src/test/resources/microsoft-json-document-transforms/Inputs/Rename/Skipped/Array.DirectPath.Transform.json
    • Added transform JSON for skipped array direct path rename transformation.
  • json-java21-jdt/src/test/resources/microsoft-json-document-transforms/Inputs/Rename/Skipped/Array.ScriptPath.Expected.json
    • Added expected JSON output for skipped array script path rename transformation.
  • json-java21-jdt/src/test/resources/microsoft-json-document-transforms/Inputs/Rename/Skipped/Array.ScriptPath.Transform .json
    • Added transform JSON for skipped array script path rename transformation.
  • json-java21-jdt/src/test/resources/microsoft-json-document-transforms/Inputs/Rename/Skipped/Object.InObject.Expected.json
    • Added expected JSON output for skipped object in object rename transformation.
  • json-java21-jdt/src/test/resources/microsoft-json-document-transforms/Inputs/Rename/Skipped/Object.InObject.Transform.json
    • Added transform JSON for skipped object in object rename transformation.
  • json-java21-jdt/src/test/resources/microsoft-json-document-transforms/Inputs/Rename/Skipped/Object.UsingSimplePath.Expected.json
    • Added expected JSON output for skipped object using simple path rename transformation.
  • json-java21-jdt/src/test/resources/microsoft-json-document-transforms/Inputs/Rename/Skipped/Object.UsingSimplePath.Transform.json
    • Added transform JSON for skipped object using simple path rename transformation.
  • json-java21-jdt/src/test/resources/microsoft-json-document-transforms/Inputs/Rename/Skipped/Object.WithChangingNames.Expected.json
    • Added expected JSON output for skipped object with changing names rename transformation.
  • json-java21-jdt/src/test/resources/microsoft-json-document-transforms/Inputs/Rename/Skipped/Object.WithChangingNames.Transform.json
    • Added transform JSON for skipped object with changing names rename transformation.
  • json-java21-jdt/src/test/resources/microsoft-json-document-transforms/Inputs/Rename/Skipped/Primitive.UsingSimpleArray.Expected.json
    • Added expected JSON output for skipped primitive using simple array rename transformation.
  • json-java21-jdt/src/test/resources/microsoft-json-document-transforms/Inputs/Rename/Skipped/Primitive.UsingSimpleArray.Transform.json
    • Added transform JSON for skipped primitive using simple array rename transformation.
  • json-java21-jdt/src/test/resources/microsoft-json-document-transforms/Inputs/Rename/Skipped/Primitive.UsingSimplePath.Expected.json
    • Added expected JSON output for skipped primitive using simple path rename transformation.
  • json-java21-jdt/src/test/resources/microsoft-json-document-transforms/Inputs/Rename/Skipped/Primitive.UsingSimplePath.Transform.json
    • Added transform JSON for skipped primitive using simple path rename transformation.
  • json-java21-jdt/src/test/resources/microsoft-json-document-transforms/Inputs/Replace/Array.Source.json
    • Added source JSON for array replace transformations.
  • json-java21-jdt/src/test/resources/microsoft-json-document-transforms/Inputs/Replace/Object.Source.json
    • Added source JSON for object replace transformations.
  • json-java21-jdt/src/test/resources/microsoft-json-document-transforms/Inputs/Replace/Object.WithObject.Expected.json
    • Added expected JSON output for object with object replace transformation.
  • json-java21-jdt/src/test/resources/microsoft-json-document-transforms/Inputs/Replace/Object.WithObject.Transform.json
    • Added transform JSON for object with object replace transformation.
  • json-java21-jdt/src/test/resources/microsoft-json-document-transforms/Inputs/Replace/Object.WithPrimitive.Expected.json
    • Added expected JSON output for object with primitive replace transformation.
  • json-java21-jdt/src/test/resources/microsoft-json-document-transforms/Inputs/Replace/Object.WithPrimitive.Transform.json
    • Added transform JSON for object with primitive replace transformation.
  • json-java21-jdt/src/test/resources/microsoft-json-document-transforms/Inputs/Replace/Skipped/Array.DirectPath.Expected.json
    • Added expected JSON output for skipped array direct path replace transformation.
  • json-java21-jdt/src/test/resources/microsoft-json-document-transforms/Inputs/Replace/Skipped/Array.DirectPath.Transform.json
    • Added transform JSON for skipped array direct path replace transformation.
  • json-java21-jdt/src/test/resources/microsoft-json-document-transforms/Inputs/Replace/Skipped/Array.ScriptPath.Expected.json
    • Added expected JSON output for skipped array script path replace transformation.
  • json-java21-jdt/src/test/resources/microsoft-json-document-transforms/Inputs/Replace/Skipped/Array.ScriptPath.Transform.json
    • Added transform JSON for skipped array script path replace transformation.
  • json-java21-jdt/src/test/resources/microsoft-json-document-transforms/Inputs/Replace/Skipped/Object.WithArray.Expected.json
    • Added expected JSON output for skipped object with array replace transformation.
  • json-java21-jdt/src/test/resources/microsoft-json-document-transforms/Inputs/Replace/Skipped/Object.WithArray.Transform.json
    • Added transform JSON for skipped object with array replace transformation.
  • json-java21-jsonpath-codegen/pom.xml
    • Added a new Maven POM file for the java.util.json.jsonpath.codegen module, defining its artifact ID, packaging, name, SCM details, and description.
    • Declared dependencies on java.util.json and java.util.json.jsonpath, along with JUnit Jupiter and AssertJ for testing.
  • json-java21-jsonpath-codegen/src/main/java/json/java21/jsonpath/codegen/CompiledJsonPath.java
    • Added a new interface CompiledJsonPath for bytecode-generated JsonPath queries, defining the query method and toString.
  • json-java21-jsonpath-codegen/src/main/java/json/java21/jsonpath/codegen/Descriptors.java
    • Added the Descriptors class, providing shared ClassDesc and MethodTypeDesc constants for JsonPath bytecode emission, covering JDK types, collections, and JSON API types.
  • json-java21-jsonpath-codegen/src/main/java/json/java21/jsonpath/codegen/EmitFilter.java
    • Added the EmitFilter class, responsible for emitting bytecode for JsonPath filter expressions, including existence, comparison, and logical filters.
  • json-java21-jsonpath-codegen/src/main/java/json/java21/jsonpath/codegen/EmitScaffold.java
    • Added the EmitScaffold class, which emits the basic class structure for generated JsonPath queries, including the constructor, toString method, and the query method shell.
  • json-java21-jsonpath-codegen/src/main/java/json/java21/jsonpath/codegen/EmitSegments.java
    • Added the EmitSegments class, which emits bytecode for the JsonPath segment evaluation chain, covering property access, array indexing, slicing, wildcards, recursive descent, filters, unions, and script expressions.
  • json-java21-jsonpath-codegen/src/main/java/json/java21/jsonpath/codegen/FilterHelper.java
    • Added the FilterHelper class, providing runtime helper methods invoked by generated bytecode for complex filter evaluation logic, such as value extraction and comparison.
  • json-java21-jsonpath-codegen/src/main/java/json/java21/jsonpath/codegen/JsonPathCodegen.java
    • Added the JsonPathCodegen class, the main entry point for compiling JsonPath expressions into bytecode-generated CompiledJsonPath instances.
  • json-java21-jsonpath-codegen/src/main/java/json/java21/jsonpath/codegen/RecursiveDescentHelper.java
    • Added the RecursiveDescentHelper class, a runtime helper for recursive descent operations in generated JsonPath bytecode, handling DFS traversal for ..property and ..*.
  • json-java21-jsonpath-codegen/src/test/java/json/java21/jsonpath/codegen/CodegenTestBase.java
    • Added a base class CodegenTestBase for JsonPath codegen tests to configure JUL logging.
  • json-java21-jsonpath-codegen/src/test/java/json/java21/jsonpath/codegen/CrossValidationTest.java
    • Added CrossValidationTest to cross-validate the bytecode-generated JsonPath implementation against the interpreter-based one, ensuring identical results for various expressions and documents.
  • json-java21-jsonpath/src/main/java/json/java21/jsonpath/JsonPath.java
    • Modified the JsonPath class to expose the parsed Abstract Syntax Tree (AST) via a new ast() method, enabling external codegen modules to access the parsed structure.
  • json-java21-jsonpath/src/main/java/json/java21/jsonpath/JsonPathAst.java
    • Modified the JsonPathAst interface to be public sealed, allowing external modules to implement and extend it.
  • json-java21-jsonpath/src/main/java/json/java21/jsonpath/JsonPathEsmRenderer.java
    • Added the JsonPathEsmRenderer class, which renders a JsonPath AST into an ES2020 module exporting a query(document) function for JavaScript environments.
  • json-java21-jsonpath/src/test/java/json/java21/jsonpath/JsonPathEsmRendererTest.java
    • Added unit tests for JsonPathEsmRenderer, verifying the structural validity and correctness of generated JavaScript for various JsonPath expressions.
  • json-java21-jtd-codegen/pom.xml
    • Added a new Maven POM file for the java.util.json.jtd.codegen module, defining its artifact ID, packaging, name, SCM details, and description.
    • Declared dependencies on java.util.json and java.util.json.jtd, along with JUnit Jupiter and AssertJ for testing.
  • json-java21-jtd-codegen/src/main/java/json/java21/jtd/codegen/Descriptors.java
    • Added the Descriptors class, providing shared ClassDesc and MethodTypeDesc constants for JTD bytecode emission, covering JDK types, collections, JSON API types, and JTD validation result types.
  • json-java21-jtd-codegen/src/main/java/json/java21/jtd/codegen/EmitDiscriminator.java
    • Added the EmitDiscriminator class, responsible for emitting bytecode for JTD Discriminator schemas, including type checks, tag existence, string validation, mapping dispatch, and error reporting.
  • json-java21-jtd-codegen/src/main/java/json/java21/jtd/codegen/EmitElements.java
    • Added the EmitElements class, responsible for emitting bytecode for JTD Elements schemas, including array type checks and looping through elements for validation.
  • json-java21-jtd-codegen/src/main/java/json/java21/jtd/codegen/EmitEnum.java
    • Added the EmitEnum class, responsible for emitting bytecode for JTD Enum schemas, checking if an instance is a string and its value is within the defined enum set.
  • json-java21-jtd-codegen/src/main/java/json/java21/jtd/codegen/EmitError.java
    • Added the EmitError class, providing static methods to emit bytecode for adding JtdValidationError instances to the errors list, with variants for compile-time and dynamic instance paths.
  • json-java21-jtd-codegen/src/main/java/json/java21/jtd/codegen/EmitNode.java
    • Added the EmitNode class, a central dispatcher for emitting bytecode for various JTD AST nodes, handling both static and dynamic instance path construction.
  • json-java21-jtd-codegen/src/main/java/json/java21/jtd/codegen/EmitProperties.java
    • Added the EmitProperties class, responsible for emitting bytecode for JTD Properties schemas, including object type checks, required property presence, additional properties validation, and child property validation.
  • json-java21-jtd-codegen/src/main/java/json/java21/jtd/codegen/EmitScaffold.java
    • Added the EmitScaffold class, which emits the basic class structure for generated JTD validators, including the constructor, toString method, and the validate method shell.
  • json-java21-jtd-codegen/src/main/java/json/java21/jtd/codegen/EmitType.java
    • Added the EmitType class, responsible for emitting bytecode for JTD Type schemas, covering boolean, string, float, integer types (int8 to uint32), and timestamp validation.
  • json-java21-jtd-codegen/src/main/java/json/java21/jtd/codegen/EmitValues.java
    • Added the EmitValues class, responsible for emitting bytecode for JTD Values schemas, including object type checks and looping through values for validation.
  • json-java21-jtd-codegen/src/main/java/json/java21/jtd/codegen/JtdCodegen.java
    • Added the JtdCodegen class, the main entry point for compiling JTD schemas into bytecode-generated JtdValidator instances, including a CompileResult record for statistics.
  • json-java21-jtd-codegen/src/test/java/json/java21/jtd/codegen/BenchmarkTest.java
    • Added BenchmarkTest to compare the performance of bytecode-generated JTD validators against the interpreter path across various schema complexities, reporting classfile size and throughput.
  • json-java21-jtd-codegen/src/test/java/json/java21/jtd/codegen/CodegenSpecConformanceTest.java
    • Added CodegenSpecConformanceTest to run the official json-typedef-spec validation test suite against the bytecode-generated JTD implementation, ensuring RFC 8927 conformance.
  • json-java21-jtd-codegen/src/test/java/json/java21/jtd/codegen/CodegenTestBase.java
    • Added a base class CodegenTestBase for JTD codegen tests to configure JUL logging consistently.
  • json-java21-jtd-codegen/src/test/java/json/java21/jtd/codegen/CrossValidationTest.java
    • Added CrossValidationTest to cross-validate that both the interpreter and bytecode-generated JTD validators produce identical RFC 8927 error sets for the same schema/instance pairs.
  • json-java21-jtd/JTD_CODEGEN_SPEC.md
    • Added a new Markdown file detailing the JTD Code Generation Specification, outlining the AST, compilation algorithm, emission rules, error format, and conformance criteria for generating target-language validators.
  • json-java21-jtd/JTD_STACK_MACHINE_SPEC.md
    • Added a new Markdown file detailing the JTD Stack-Machine Interpreter Specification, describing the AST, compilation, runtime work stack, step functions, type checking, multi-root support, and error format for the interpreter-based validator.
  • json-java21-jtd/PROBE_TESTS_SUMMARY.md
    • Added a new Markdown file summarizing all probe tests for the JTD implementation, categorizing them by schema form and detailing their purpose and expected outcomes.
  • json-java21-jtd/README.md
    • Updated the README to include a new 'Functional Validator API' section, introducing the JtdValidator interface and its compile and compileGenerated (optional) factory methods.
    • Added links to the new JTD_STACK_MACHINE_SPEC.md and JTD_CODEGEN_SPEC.md documents for detailed architectural information.
    • Updated the RFC 8927 Compliance section to mention the optional codegen path.
  • json-java21-jtd/src/main/java/json/java21/jtd/Frame.java
    • Modified the Frame record to include schemaPath and updated constructors to align with RFC 8927 error reporting requirements, clarifying its role in tracking instance and schema pointers.
  • json-java21-jtd/src/main/java/json/java21/jtd/InterpreterValidator.java
    • Added the InterpreterValidator class, implementing the JtdValidator interface using a stack-machine interpreter to produce RFC 8927 error pairs by walking the compiled JtdSchema AST.
  • json-java21-jtd/src/main/java/json/java21/jtd/Jtd.java
    • Modified the Jtd class to expose a compileToSchema method, returning the immutable JtdSchema AST.
    • Updated the pushChildFrames method to correctly pass schemaPath and discriminatorKey within Frame instances for accurate error reporting.
  • json-java21-jtd/src/main/java/json/java21/jtd/JtdSchema.java
    • Modified the JtdSchema interface to be public sealed, allowing broader access and extensibility.
    • Made RefSchema.target() public and TypeSchema.RFC3339 pattern static for external use and consistency.
  • json-java21-jtd/src/main/java/json/java21/jtd/JtdValidationError.java
    • Added a new record JtdValidationError to represent RFC 8927 validation error indicators, consisting of instancePath and schemaPath JSON Pointers.
  • json-java21-jtd/src/main/java/json/java21/jtd/JtdValidationResult.java
    • Added a new record JtdValidationResult to encapsulate the outcome of a JTD validation, including a boolean isValid flag and a list of JtdValidationError objects.
  • json-java21-jtd/src/main/java/json/java21/jtd/JtdValidator.java
    • Added a new functional interface JtdValidator, providing static factory methods compile (interpreter-based) and compileGenerated (bytecode-generated, optional) for creating reusable validators.
  • json-java21-jtd/src/test/java/json/java21/jtd/DiscriminatorEdgeCaseProbe.java
    • Added a new probe test class DiscriminatorEdgeCaseProbe to thoroughly test various edge cases and compliance aspects of JTD Discriminator schemas, including missing/non-string fields, additional properties exemption, key redefinition, and nested discriminators.
  • json-java21-jtd/src/test/java/json/java21/jtd/ElementsEdgeCaseProbe.java
    • Added a new probe test class ElementsEdgeCaseProbe to cover edge cases for JTD Elements schemas, such as empty arrays, nested elements, complex child schemas, large arrays, and detailed error reporting.
  • json-java21-jtd/src/test/java/json/java21/jtd/ErrorFormatComplianceProbe.java
    • Added a new probe test class ErrorFormatComplianceProbe to verify strict RFC 8927 error format compliance, checking for correct instancePath and schemaPath JSON Pointers and comprehensive error collection.
  • json-java21-jtd/src/test/java/json/java21/jtd/JtdSpecConformanceTest.java
    • Added JtdSpecConformanceTest to run the official json-typedef-spec validation test suite against the interpreter path, serving as the authoritative conformance test for the JTD implementation.
  • json-java21-jtd/src/test/java/json/java21/jtd/JtdValidatorTest.java
    • Added JtdValidatorTest to test the JtdValidator functional interface and InterpreterValidator, focusing on RFC 8927 error pair format, various schema forms, and functional usage in stream pipelines.
  • json-java21-jtd/src/test/java/json/java21/jtd/NullableEdgeCaseProbe.java
    • Added a new probe test class NullableEdgeCaseProbe to examine edge cases for the JTD Nullable modifier, including its application to all schema forms, nested nullable schemas, and compilation checks for invalid nullable values.
  • json-java21-jtd/src/test/java/json/java21/jtd/PropertiesEdgeCaseProbe.java
    • Added a new probe test class PropertiesEdgeCaseProbe to investigate edge cases for JTD Properties schemas, such as empty properties, special characters in keys, multiple additional properties, required/optional property behavior, and deep nesting.
  • json-java21-jtd/src/test/java/json/java21/jtd/RefEdgeCaseProbe.java
    • Added a new probe test class RefEdgeCaseProbe to test edge cases for JTD Ref schemas, including forward references, mutual recursion, deeply nested refs, and refs in various schema contexts.
  • json-java21-jtd/src/test/java/json/java21/jtd/TypeValidationEdgeCaseProbe.java
    • Added a new probe test class TypeValidationEdgeCaseProbe to cover edge cases for JTD Type validation, such as integer boundary values, fractional detection, scientific notation, timestamp formats, and strictness of boolean/string types.
  • jtd-esm-codegen/JTD_CODEGEN_SPEC.md
    • Added a new Markdown file detailing the JTD Code Generation Specification for ESM, outlining the AST, compilation algorithm, emission rules, error format, and conformance criteria for generating ES2020 validators.
  • jtd-esm-codegen/pom.xml
    • Added a new Maven POM file for the jtd-esm-codegen module, defining its artifact ID, packaging, name, SCM details, and description.
    • Declared dependencies on java.util.json, JUnit Jupiter, AssertJ, jqwik, and GraalVM Polyglot JS for testing, along with the maven-shade-plugin for creating an uber JAR.
  • jtd-esm-codegen/src/main/java/io/github/simbo1905/json/jtd/codegen/EsmRenderer.java
    • Added the EsmRenderer class, responsible for generating ES2020 ESM validators from a JTD AST, adhering to principles of no runtime stack, no helper functions, and minimal code emission.
  • jtd-esm-codegen/src/main/java/io/github/simbo1905/json/jtd/codegen/JtdAst.java
    • Added the JtdAst class, defining the complete AST for RFC 8927 JTD code generation, including sealed interfaces and records for all schema forms.
  • jtd-esm-codegen/src/main/java/io/github/simbo1905/json/jtd/codegen/JtdParser.java
    • Added the JtdParser class, which parses JTD (RFC 8927) schemas into the JtdAst for code generation, supporting all schema forms and performing validation checks during parsing.
  • jtd-esm-codegen/src/main/java/io/github/simbo1905/json/jtd/codegen/JtdToEsmCli.java
    • Added the JtdToEsmCli class, providing the CLI entry point for the JTD to ESM code generator, allowing users to generate validators from schema files.
  • jtd-esm-codegen/src/main/java/io/github/simbo1905/json/jtd/codegen/Sha256.java
    • Added the Sha256 helper class for generating SHA-256 digests and hexadecimal representations, used for deterministic output naming of generated ESM files.
  • jtd-esm-codegen/src/test/java/io/github/simbo1905/json/jtd/codegen/GraalJsRunner.java
    • Added the GraalJsRunner class, which executes generated ES2020 validators in-process using GraalVM Polyglot JS, providing methods to load modules and validate JSON instances.
  • jtd-esm-codegen/src/test/java/io/github/simbo1905/json/jtd/codegen/JtdEsmCodegenLoggingConfig.java
    • Added a base class JtdEsmCodegenLoggingConfig for JTD ESM codegen tests to configure JUL logging consistently.
  • jtd-esm-codegen/src/test/java/io/github/simbo1905/json/jtd/codegen/JtdEsmJsTestSuite.java
    • Added JtdEsmJsTestSuite, a JUnit test suite that runs JavaScript tests via GraalVM polyglot using junit-js JSRunner, replacing external JavaScript runtime dependencies.
  • jtd-esm-codegen/src/test/java/io/github/simbo1905/json/jtd/codegen/JtdEsmPropertyTest.java
    • Added JtdEsmPropertyTest, a property-based testing class for the JTD to ESM code generator, which generates comprehensive schema/document permutations and validates generated JavaScript validators using GraalVM Polyglot JS.
  • jtd-esm-codegen/src/test/java/io/github/simbo1905/json/jtd/codegen/JtdToEsmCodegenTest.java
    • Added JtdToEsmCodegenTest to test the stack-based JTD to ESM code generator, covering parser functionality, generated code content, and GraalVM Polyglot JS execution for various schema types.
  • jtd-esm-codegen/src/test/resources/boolean-schema.test.js
    • Added a JavaScript test file for the boolean schema, verifying the generated validator's behavior using junit-js.
  • jtd-esm-codegen/src/test/resources/expected/boolean-schema.js
    • Added the expected generated JavaScript output for a simple boolean schema, used as a fixture for testing.
  • jtd-esm-codegen/src/test/resources/jtd/boolean-schema.jtd.json
    • Added a JTD schema file defining a simple boolean type, used as input for code generation tests.
  • jtd-esm-codegen/src/test/resources/nested-elements-empty-focused.test.js
    • Added a focused JavaScript test file for nested elements with an empty schema, verifying the generation of inline validators and fixing a previous issue.
  • jtd-esm-codegen/src/test/resources/odc-chart-event-v1.jtd.json
    • Added a JTD schema file for an ODC chart event payload, used as a realistic example for code generation.
  • pom.xml
    • Added new modules to the project's pom.xml: json-java21-jdt, jtd-esm-codegen, json-java21-jtd-codegen, and json-java21-jsonpath-codegen.
Ignored Files
  • Ignored by pattern: .github/workflows/** (2)
    • .github/workflows/ci.yml
    • .github/workflows/jtd-esm-codegen-release.yml
Activity
  • The pull request introduces a new module json-java21-jdt for JSON Document Transforms, along with extensive documentation and tests.
  • It adds new code generation modules for JsonPath and JTD, aiming to improve performance by compiling validation logic.
  • An experimental JTD to ES2020 module generator is included, demonstrating cross-language code generation.
  • Numerous probe tests and conformance tests have been added to ensure the correctness and RFC 8927 compliance of the JTD implementation.
  • Detailed specification documents for both the JTD interpreter and code generator have been added, formalizing the design.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This is a massive and impressive pull request that introduces a new json-java21-jdt module for JSON Document Transforms, complete with extensive documentation and tests. It also adds experimental code generation capabilities for JTD and JsonPath to both Java bytecode (for JDK 24+) and ES2020 JavaScript modules. The changes are well-structured, and the new APIs, like JtdValidator, are a significant improvement. I have found one potential issue in the new JDT ESM renderer that I've commented on.

Comment on lines +146 to +151
default ->
sb.append(indent).append("if (typeof _r === 'object' && _r !== null && _r[")
.append(jsString(key)).append("] !== undefined) _r[").append(jsString(key))
.append("] = deepMerge(_r[").append(jsString(key)).append("], ")
.append(jsonToJs(child)).append(");\n");
}

Choose a reason for hiding this comment

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

high

The default case in this switch statement for processing child nodes appears to be incorrect. It handles MergeNode and DirectiveNode children.

default ->
    sb.append(indent).append("if (typeof _r === 'object' && _r !== null && _r[")
      .append(jsString(key)).append("] !== undefined) _r[").append(jsString(key))
      .append("] = deepMerge(_r[").append(jsString(key)).append("], ")
      .append(jsonToJs(child)).append(");\n");

When child is a MergeNode or DirectiveNode, jsonToJs(child) returns {}, as per the implementation of jsonToJs:

private static String jsonToJs(Object value) {
    if (value instanceof JdtNode) return "{}"; // Fallback for AST nodes in children
    // ...
}

This results in deepMerge(..., {}), which does not apply the child's transformation. This is likely a bug as it will cause incorrect behavior for nested transforms within a directive node.

To fix this, the switch should handle MergeNode and DirectiveNode explicitly by generating recursive transformation logic for them, similar to how emitMergeNode handles its children by creating inline functions.

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 4 potential issues.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

This is the final PR Bugbot will review for you during this billing cycle

Your free Bugbot reviews will reset on March 9

Details

You are on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle.

To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

sb.append(indent).append("if (typeof _r === 'object' && _r !== null && _r[")
.append(jsString(key)).append("] !== undefined) _r[").append(jsString(key))
.append("] = deepMerge(_r[").append(jsString(key)).append("], ")
.append(jsonToJs(child)).append(");\n");
Copy link

Choose a reason for hiding this comment

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

ESM renderer loses nested transform logic in directive children

Medium Severity

In emitDirectiveNode, the default branch for processing children calls jsonToJs(child) where child is a MergeNode or DirectiveNode. The jsonToJs method returns "{}" for any JdtNode, so all nested transform content is silently lost. For example, a child MergeNode carrying {"A": 10, "C": 3} would generate deepMerge(_r["key"], {}) instead of the actual values. Compare with emitMergeNode, which correctly generates local functions for nested MergeNode/DirectiveNode children.

Additional Locations (1)

Fix in Cursor Fix in Web

return transformObj;
} else {
return transformObj;
}
Copy link

Choose a reason for hiding this comment

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

Redundant identical branches in default transform dispatch

Low Severity

The else if (source instanceof JsonArray) branch and the else branch in applyTransform both return transformObj identically. The JsonArray check is redundant since it produces the same result as the fallback. This could also mask a missing behavior — the README specifies arrays append by default, but when a non-directive object transform is applied to an array source, it replaces rather than appends.

Fix in Cursor Fix in Web


for (final var entry : source.members().entrySet()) {
final var value = entry.getValue();
if (!toRemove.contains(value)) {
Copy link

Choose a reason for hiding this comment

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

Path-based removal uses value equality instead of reference identity

Medium Severity

removeMatchedNodes and removeMatchedNodesFromArray use toRemove.contains(value) which relies on .equals() (structural equality), while the sibling method transformMatchingNodes uses node == match (reference identity). The AGENTS.md explicitly documents that the design uses reference identity because JsonPath returns the same object instances from the source tree. Using .equals() causes over-removal — if a document has multiple nodes with identical values at different paths, removing one path-matched node would incorrectly remove all value-equal nodes.

Additional Locations (2)

Fix in Cursor Fix in Web


private static void emitReplace(StringBuilder sb, JsonValue replaceSpec, String indent) {
sb.append(indent).append("_r = ").append(jsonToJs(replaceSpec)).append(";\n");
}
Copy link

Choose a reason for hiding this comment

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

ESM renderer omits double-bracket array unwrapping for merge/replace

Medium Severity

emitMerge and emitReplace pass the raw JsonValue spec through jsonToJs() without handling the double-bracket array syntax [[...]]. The Java interpreter's applyMerge and applyReplace both call isDoubleBracketArray() to unwrap [[1,2,3]] into [1,2,3], but the ESM renderer has no equivalent logic. A transform like {"@jdt.replace": [[1,2,3]]} would generate _r = [[1,2,3]] instead of the correct _r = [1,2,3].

Fix in Cursor Fix in Web

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.

2 participants

Comments