You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BUG][Java][okhttp-gson] JSON.java fails to compile with many model adapters #25532
Have you provided a full/minimal spec to reproduce the issue?
Have you validated the input using an OpenAPI validator?
Have you tested with the latest master to confirm the issue still exists?
Have you searched for related issues/PRs?
What's the actual output vs expected output?
Description
Java okhttp-gson clients generated from a specification with many object models can fail compilation. The generated JSON.java registers every model adapter in one static initializer, exceeding the JVM's per-method bytecode limit.
Actual: generation succeeds, but compilation reports JSON.java: code too large.
Expected: generated Java sources compile, with all model adapters registered in their original order.
openapi-generator version
Current master 0810b02db908ccb48c0d1ee480123fade431f21c (7.28.0-SNAPSHOT): reproduced using a public API specification with 5822 registered model adapters.
OpenAPI declaration file content or url
Create a standalone reproduction with 6000 simple object schemas:
python3 - <<'PY'with open('/tmp/many-models.yaml', 'w') as f: f.write("openapi: 3.0.3\ninfo: {title: Many models, version: '1'}\npaths: {}\ncomponents:\n schemas:\n") for i in range(6000): f.write(f" Model{i}:\n type: object\n properties:\n value: {{type: string}}\n")PY
Build the generator from master, create the synthetic specification above, then run the generation and compilation commands. The synthetic reproduction was verified with generator commit b54d497d44058592b22b96c9159e0e0a9d23927e; the relevant Java generator and template files are unchanged at the tested master commit above.
Related issues/PRs
No matching issue found for JSON.java and code too large.
Suggest a fix
Split model adapter registration into bounded helper methods while preserving registration order. Keep output for small specifications unchanged.
Activity