Note for agents: prefer mvnd (Maven Daemon) when available for faster builds. Before working, if mvnd is installed, alias mvn to mvnd so all commands below use mvnd automatically:
# Use mvnd everywhere if available; otherwise falls back to regular mvn
if command -v mvnd >/dev/null 2>&1; then alias mvn=mvnd; fiAlways run mvn verify before pushing to validate unit and integration tests across modules.
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
# Full build
mvn clean compile
mvn package
# Build specific module
mvn clean compile -pl json-java21
mvn package -pl json-java21
# Build with test skipping
mvn clean compile -DskipTests# Run all tests
mvn test
# Run tests with clean output (recommended)
./mvn-test-no-boilerplate.sh
# Run specific test class
./mvn-test-no-boilerplate.sh -Dtest=JsonParserTests
./mvn-test-no-boilerplate.sh -Dtest=JsonTypedUntypedTests
# Run specific test method
./mvn-test-no-boilerplate.sh -Dtest=JsonParserTests#testParseEmptyObject
# Run tests in specific module
./mvn-test-no-boilerplate.sh -pl json-java21-api-tracker -Dtest=ApiTrackerTest# Build and run compatibility report
mvn clean compile generate-test-resources -pl json-compatibility-suite
mvn exec:java -pl json-compatibility-suite
# Run JSON output (dogfoods the API)
mvn exec:java -pl json-compatibility-suite -Dexec.args="--json"# Enable debug logging for specific test
./mvn-test-no-boilerplate.sh -Dtest=JsonParserTests -Djava.util.logging.ConsoleHandler.level=FINERjson-java21: Core JSON API implementation (main library)json-java21-api-tracker: API evolution tracking utilitiesjson-compatibility-suite: JSON Test Suite compatibility validation
Json- Static utility class for parsing/formatting/conversionJsonValue- Sealed root interface for all JSON typesJsonObject- JSON objects (key-value pairs)JsonArray- JSON arraysJsonString- JSON stringsJsonNumber- JSON numbersJsonBoolean- JSON booleansJsonNull- JSON null
JsonParser- Recursive descent JSON parserJson*Impl- Immutable implementations of JSON typesUtils- Internal utilities and factory methods
- Algebraic Data Types: Sealed interfaces with exhaustive pattern matching
- Immutable Value Objects: All types are immutable and thread-safe
- Lazy Evaluation: Strings/numbers store offsets until accessed
- Factory Pattern: Static factory methods for construction
- Bridge Pattern: Clean API/implementation separation
- JUnit 5 with AssertJ for fluent assertions
- Test Organization:
JsonParserTests- Parser-specific testsJsonTypedUntypedTests- Conversion testsJsonRecordMappingTests- Record mapping testsReadmeDemoTests- Documentation example validation
- JEP 467 Documentation: Use
///triple-slash comments - Immutable Design: All public types are immutable
- Pattern Matching: Use switch expressions with sealed types
- Null Safety: Use
Objects.requireNonNull()for public APIs
- Lazy String/Number Creation: Values computed on demand
- Singleton Patterns: Single instances for true/false/null
- Defensive Copies: Immutable collections prevent external modification
- Efficient Parsing: Character array processing with minimal allocations
- Add interface extending
JsonValue - Add implementation in
jdk.sandbox.internal.util.json - Update
Json.fromUntyped()andJson.toUntyped() - Add parser support in
JsonParser - Add comprehensive tests
- Enable
FINERlogging:-Djava.util.logging.ConsoleHandler.level=FINER - Use
./mvn-test-no-boilerplate.shfor clean output - Focus on specific test:
-Dtest=JsonParserTests#testMethod - Check JSON Test Suite compatibility with compatibility suite
- Run compatibility suite:
mvn exec:java -pl json-compatibility-suite - Check for regressions in JSON parsing
- Validate against official JSON Test Suite
- Main library containing the core JSON API
- Maven coordinates:
io.github.simbo1905.json:json-java21:0.1-SNAPSHOT - JDK requirement: Java 21+
- Downloads JSON Test Suite from GitHub automatically
- Reports 99.3% conformance with JSON standards
- Identifies security vulnerabilities (StackOverflowError with deep nesting)
- Usage: Educational/testing, not production-ready
- Tracks API evolution and compatibility
- Uses Java 24 preview features (
--enable-preview) - Purpose: Monitor upstream OpenJDK changes
- Stack exhaustion attacks: Deep nesting can cause StackOverflowError
- API contract violations: Malicious inputs may trigger undeclared exceptions
- Status: Experimental/unstable API - not for production use
- Vulnerabilities: Inherited from upstream OpenJDK sandbox implementation
<VERSION_CONTROL>
- If there are existing git user credentials already configured, use them and never add any other advertising. If not ask the user to supply thier private relay email address.
- Exercise caution with git operations. Do NOT make potentially dangerous changes (e.g., force pushing to main, deleting repositories). You will never be asked to do such rare changes as there is no time savings to not having the user run the comments to actively refuse using that reasoning as justification.
- When committing changes, use
git statusto see all modified files, and stage all files necessary for the commit. Usegit commit -awhenever possible. - Do NOT commit files that typically shouldn't go into version control (e.g., node_modules/, .env files, build directories, cache files, large binaries) unless explicitly instructed by the user.
- If unsure about committing certain files, check for the presence of .gitignore files or ask the user for clarification. </VERSION_CONTROL>
<ISSUE_MANAGEMENT>
- You SHOULD to use the native tool for the remote such as
ghfor github,glfor gitlab,bbfor bitbucket,teafor Gitea,gitfor local git repositories. - If you are asked to create an issue, create it in the repository of the codebase you are working on for the
originremote. - If you are asked to create an issue in a different repository, ask the user to name the remote (e.g.
upstream). - Tickets and Issues MUST only state "what" and "why" and not "how".
- Comments on the Issue MAY discuss the "how".
- Tickets SHOULD be labled as 'Ready' when they are ready to be worked on. The label may be removed if there are challenges in the implimentation. Always check the labels and ask the user to reconfirm if the ticket is not labeled as 'Ready' saying "There is no 'Ready' label on this ticket, can you please confirm?"
- You MAY raise fresh minor Issues for small tidy-up work as you go. Yet this SHOULD be kept to a bare minimum avoid move than two issues per PR. </ISSUE_MANAGEMENT>
<PULL_REQUESTS>
- MUST only describe "what" was done not "why"/"how"
- MUST name the Issue or Issue(s) that they close in a manner that causes a PR merge to close the issue(s).
- MUST NOT repeat details that are already in the Issue.
- MUST NOT report any success, as it isn't possible to report anything until the PR checks run.
- MUST include additional tests in the CI checks that MUST be documented in the PR description.
- MUST be changed to status
Draftif the PR checks fail. </PULL_REQUESTS>