chaokunyang opened a new pull request, #3909:
URL: https://github.com/apache/fory/pull/3909

   ## Why?
   
   Untrusted JSON can materialize a retained Java object graph that is 
substantially larger than the
   input, and object invariants sometimes need validation immediately after 
complete deserialization.
   This change adds an explicit graph-memory gate for composite owners and a 
generated-code-aware
   post-deserialization validator contract.
   
   ## What does this PR do?
   
   - Adds a fixed per-root `maxGraphMemoryBytes` limit with a 128 MiB default. 
Object, reference-array,
     collection, map, and composite-wrapper owners are charged by the codec 
that materializes them.
     Dedicated leaf codecs remain uncharged and contain no budget branch.
   - Adds public method annotation `JsonValidator`. Effective public instance 
no-argument void methods
     run after the complete mapped object is constructed and populated. 
Multiple validators have no
     ordering contract, and `JsonCreator` validation remains an alternative.
   - Supports validator add/remove overlays through exact `JsonMixin` method 
matching.
   - Completes interpreted, runtime-codegen, annotation-processor, GraalVM 
Native Image, Android, and
     release-minified R8 paths, with focused and platform integration coverage.
   - Documents the public configuration, accounting scope, custom-codec 
ownership, validator contract,
     Mixin behavior, and Android/GraalVM setup.
   
   ## Related issues
   
   N/A
   
   ## AI Contribution Checklist
   
   - [x] Substantial AI assistance was used in this PR: `yes`
   - [x] The standardized AI Usage Disclosure is included below.
   - [ ] The submitter can explain and defend all important changes without AI 
help.
   - [ ] The submitter reviewed the AI-assisted code changes line by line 
before submission.
   - [x] Line-by-line agent self-review and the required two-reviewer AI loop 
completed on the current
     HEAD.
   - [x] One fresh Fory-guided reviewer and one fresh independent general 
reviewer reported no
     actionable findings on the current 47-path diff.
   - [x] Final clean AI review artifacts are linked below.
   - [x] Local JVM, processor, GraalVM native-image, and Android API 26 
debug/release-R8 verification
     completed.
   - [x] Tests and documentation were added or updated for the changed behavior.
   - [x] Protocol compatibility is unchanged; this is a Java JSON runtime-local 
feature.
   - [ ] The submitter verified licensing and provenance compliance.
   
   AI Usage Disclosure
   
   - substantial_ai_assistance: yes
   - scope: design drafting, implementation, tests, documentation, review 
fixes, and verification
   - affected_files_or_subsystems: Java Fory JSON runtime/codegen, annotation 
processor, GraalVM
     Native Image, Android/R8 integration, security and user guides
   - ai_review: Full main-agent self-review completed. The final current-HEAD 
reruns by a fresh
     Fory-guided reviewer and a separate fresh independent general reviewer 
both reported no
     actionable findings.
   - ai_review_artifacts: Pending PR comment links.
   - human_verification: Automated/local checks and results are recorded below; 
submitter line-by-line
     review and accountability confirmation remain pending while this PR is a 
draft.
   - performance_verification: Benchmarks were intentionally not run for this 
task. The implementation
     keeps dedicated leaf codecs and ordinary unannotated object paths free of 
new budget/validator
     branches or allocations; hot-path allocation/control-flow risks were 
inspected in both final AI
     reviews.
   - provenance_license_confirmation: Submitter confirmation pending; no 
third-party code or new
     dependency was introduced.
   
   ## Validation
   
   - Full Java module tests: 904 passed (`fory-json` 819, annotation processor 
85).
   - Focused graph-budget/validator/Mixin/async/Android host tests: 113 passed.
   - GraalVM JDK 21: 9/9 Java reactor modules, native-image build, and native 
binary passed.
   - Android 8.0/API 26 arm64: debug 18/18 and release-minified/R8 18/18 
instrumented tests passed.
   - Spotless and Checkstyle passed; changed Android Java files are Google Java 
Format clean; changed
     Markdown is Prettier clean.
   
   ## Does this PR introduce any user-facing change?
   
   - [x] Does this PR introduce any public API change?
   - [ ] Does this PR introduce any binary protocol compatibility change?
   
   ## Benchmark
   
   Not run, as explicitly scoped for this security feature. No benchmark code 
or benchmark artifacts
   were changed.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to