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] Large oneOf adapter fails to load with too many constructor arguments #25538
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
A Java okhttp-gson client with a large oneOf can compile successfully but fail when the generated Gson adapter is loaded. The anonymous adapter captures each variant adapter as a separate constructor argument, exceeding the JVM method parameter limit.
Actual: java.lang.ClassFormatError: Too many arguments in method signature when loading the generated adapter.
Expected: the generated adapter loads and serializes/deserializes the variants.
openapi-generator version
Reproduced on master d80e6fc9d26b1205c84a0a822684f0ef7f3f6ef2 with the focused runtime regression test. The standalone generated-client reproduction was also verified on b54d497d44058592b22b96c9159e0e0a9d23927e.
OpenAPI declaration file content or url
Generate a self-contained specification with 260 variants:
python3 - <<'PY'with open('/tmp/large-oneof.yaml', 'w') as f: f.write("openapi: 3.0.3\ninfo: {title: Large oneOf, version: '1'}\npaths: {}\ncomponents:\n schemas:\n Union:\n oneOf:\n") for i in range(260): f.write(f" - $ref: '#/components/schemas/Variant{i}'\n") for i in range(260): f.write(f" Variant{i}:\n type: object\n required: [kind]\n properties:\n kind: {{type: string, enum: [v{i}]}}\n")PY
Build the generator, create the specification, and run the commands above. Compilation succeeds, but loading the anonymous adapter fails on Java 11, 21, and 27.
Related issues/PRs
Related to, but independent of, #25532 / #25533, which address the size of the model registration initializer in JSON.java.
Suggest a fix
For large oneOf schemas, store variant adapters as fields of the generated anonymous adapter rather than capturing them as constructor arguments.
Activity