Repository navigation
fix(java): batch Gson model adapter registration - #25533
Open
AndreyVMarkelov wants to merge 3 commits into
Open
AndreyVMarkelov wants to merge 3 commits into
AndreyVMarkelov wants to merge 3 commits into
Conversation
wing328
reviewed
Nov 3, 2026
| public Map<String, Object> postProcessSupportingFileData(Map<String, Object> objs) { | ||
| generateYAMLSpecFile(objs); | ||
| if (isLibrary(OKHTTP_GSON)) { | ||
| @SuppressWarnings("unchecked") |
Member
There was a problem hiding this comment.
please add comments explaining what this new block code does. thank you.
Contributor
Author
There was a problem hiding this comment.
Added a comment explaining that adapter registrations are split into batches to avoid exceeding the JVM method size limit. The original registration order is preserved.
This was referenced Nov 3, 2026
…rator into andreymarkelov/fix-java-gson-adapter-batching
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes #25532
Java
okhttp-gsonclients with thousands of models can fail compilation because the generatedJSON.javastatic initializer exceeds the JVM method-size limit.Group model adapter registrations into helper methods of at most 200 registrations, preserving their original order. Specifications with at most 200 registered models retain the existing output.
Tests
JavaClientCodegenTest#testOkHttpGsonBatchesModelAdapterRegistrationsverifies both batches and every generated registration for 201 models.FilesMetadatavariants and JSON header serialization.git diff --check.A separate local runtime observation: Homebrew OpenJDK 21.0.12.1 crashed while loading a very large generated model during the header probe. The probe passed with Java 11, Java 27, and Java 21 with
-Xint. The cause of that JVM crash has not been determined; it is outside the compilation fix in this PR.PR checklist
Summary by cubic
Fixes #25532. Java
okhttp-gsonclients with thousands of models previously failed compilation because the generatedJSON.javastatic initializer exceeded the JVM method-size limit. Model adapter registrations are now grouped into helper methods of at most 200 registrations each, preserving their original order. Specifications with at most 200 registered models keep the existing output, and the batching behavior is documented in the generator docs.Written for commit 0ad1d5a. Summary will update on new commits.