fix: use args map instead of method args in generated java code #9711
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 #9353
When generating java from ksql, all arguments are passed as individual method arguments. The java compiler only allows up to 255 method arguments. After a ksql statement reaches a certain size, this limit is nolonger sufficient resulting in the following ClassFormatError:
Exception in thread "main" java.lang.ClassFormatError: Too many arguments in method signature in class file SC at java.base/java.lang.ClassLoader.defineClass1(Native Method) at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1017) at org.codehaus.janino.ByteArrayClassLoader.findClass(ByteArrayClassLoader.java:74) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:589) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522) at org.codehaus.janino.ClassBodyEvaluator.compileToClass(ClassBodyEvaluator.java:317) at org.codehaus.janino.ScriptEvaluator.cook2(ScriptEvaluator.java:608) at org.codehaus.janino.ScriptEvaluator.cook(ScriptEvaluator.java:597) at org.codehaus.janino.ScriptEvaluator.cook(ScriptEvaluator.java:534) at org.codehaus.janino.ScriptEvaluator.cook(ScriptEvaluator.java:503) at org.codehaus.janino.SimpleCompiler.cook(SimpleCompiler.java:204) at org.codehaus.commons.compiler.Cookable.cook(Cookable.java:80) at org.codehaus.commons.compiler.Cookable.cook(Cookable.java:75) at io.confluent.ksql.execution.codegen.CodeGenRunner.cook(CodeGenRunner.java:195) ...
This change puts all those arguments in one map. This map is then passed as one method argument.
Testing done
Unit tests have been changed to reflect the changes made in this PR.
A new test 'shouldHandleManyArguments' has been added to SqlToJavaVisitorTest.
Reviewer checklist