[ 
https://issues.apache.org/jira/browse/GROOVY-7367?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14636322#comment-14636322
 ] 

Jochen Theodorou commented on GROOVY-7367:
------------------------------------------

There is a 255 parameters limit in the JVM (254 for non-static methods), this 
implies a 255 arguments limit, unless the call is to a vargs method, in which 
case there could be a call with more arguments. The right thing to do then 
would be, to not use ArrayUtil in this case. At least for standard Groovy. In 
the invokedynamic version this will need special handling, since MethodHandles 
have such a limit as well. In total it would be best to add a compile time error

> ArrayIndexOutOfBoundsException in getCreateArraySignature on too many 
> function parameters
> -----------------------------------------------------------------------------------------
>
>                 Key: GROOVY-7367
>                 URL: https://issues.apache.org/jira/browse/GROOVY-7367
>             Project: Groovy
>          Issue Type: Bug
>          Components: class generator
>    Affects Versions: 2.3.9
>         Environment: OSX 10.10.2
> Groovy Version: 2.3.9 JVM: 1.7.0_75 Vendor: Oracle Corporation OS: Mac OS X
>            Reporter: Artur Matuszewski
>            Priority: Critical
>              Labels: exception
>         Attachments: params.groovy
>
>
> When trying to pass too many arguments to a function Groovy crashes. This 
> crashes even if the code is never called.
> Discovered when trying to automatically generate a Gradle project 
> configuration from a different build system. Ended up listing over 280 
> directories in a single argument list.
> Tested only against 2.3.9.
> Setting priority to Critical only because it's the suggested priority for 
> crashes.
> {code}$ groovy params.groovy 
> org.codehaus.groovy.control.MultipleCompilationErrorsException: startup 
> failed:
> General error during class generation: 255
> java.lang.ArrayIndexOutOfBoundsException: 255
>       at 
> org.codehaus.groovy.classgen.asm.CallSiteWriter.getCreateArraySignature(CallSiteWriter.java:55)
>       at 
> org.codehaus.groovy.classgen.asm.CallSiteWriter.makeCallSite(CallSiteWriter.java:314)
>       at 
> org.codehaus.groovy.classgen.asm.InvocationWriter.makeCachedCall(InvocationWriter.java:281)
>       at 
> org.codehaus.groovy.classgen.asm.InvocationWriter.makeCall(InvocationWriter.java:366)
>       at 
> org.codehaus.groovy.classgen.asm.InvocationWriter.makeCall(InvocationWriter.java:99)
>       at 
> org.codehaus.groovy.classgen.asm.InvocationWriter.makeInvokeMethodCall(InvocationWriter.java:83)
>       at 
> org.codehaus.groovy.classgen.asm.InvocationWriter.writeInvokeMethod(InvocationWriter.java:433)
>       at 
> org.codehaus.groovy.classgen.AsmClassGenerator.visitMethodCallExpression(AsmClassGenerator.java:749)
>       at 
> org.codehaus.groovy.ast.expr.MethodCallExpression.visit(MethodCallExpression.java:64)
>       at 
> org.codehaus.groovy.classgen.asm.StatementWriter.writeReturn(StatementWriter.java:582)
>       at 
> org.codehaus.groovy.classgen.asm.OptimizingStatementWriter.writeReturn(OptimizingStatementWriter.java:316)
>       at 
> org.codehaus.groovy.classgen.AsmClassGenerator.visitReturnStatement(AsmClassGenerator.java:606)
>       at 
> org.codehaus.groovy.ast.stmt.ReturnStatement.visit(ReturnStatement.java:47)
>       at 
> org.codehaus.groovy.classgen.asm.StatementWriter.writeBlockStatement(StatementWriter.java:81)
>       at 
> org.codehaus.groovy.classgen.asm.OptimizingStatementWriter.writeBlockStatement(OptimizingStatementWriter.java:155)
>       at 
> org.codehaus.groovy.classgen.AsmClassGenerator.visitBlockStatement(AsmClassGenerator.java:556)
>       at 
> org.codehaus.groovy.ast.stmt.BlockStatement.visit(BlockStatement.java:69)
>       at 
> org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClassCodeContainer(ClassCodeVisitorSupport.java:101)
>       at 
> org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitConstructorOrMethod(ClassCodeVisitorSupport.java:112)
>       at 
> org.codehaus.groovy.classgen.AsmClassGenerator.visitStdMethod(AsmClassGenerator.java:420)
>       at 
> org.codehaus.groovy.classgen.AsmClassGenerator.visitConstructorOrMethod(AsmClassGenerator.java:377)
>       at 
> org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitMethod(ClassCodeVisitorSupport.java:123)
>       at 
> org.codehaus.groovy.classgen.AsmClassGenerator.visitMethod(AsmClassGenerator.java:497)
>       at org.codehaus.groovy.ast.ClassNode.visitContents(ClassNode.java:1064)
>       at 
> org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClass(ClassCodeVisitorSupport.java:50)
>       at 
> org.codehaus.groovy.classgen.AsmClassGenerator.visitClass(AsmClassGenerator.java:231)
>       at 
> org.codehaus.groovy.control.CompilationUnit$16.call(CompilationUnit.java:805)
>       at 
> org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1047)
>       at 
> org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:583)
>       at 
> org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:561)
>       at 
> org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:538)
>       at 
> groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:286)
>       at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:259)
>       at groovy.lang.GroovyShell.parseClass(GroovyShell.java:674)
>       at groovy.lang.GroovyShell.run(GroovyShell.java:501)
>       at groovy.lang.GroovyShell.run(GroovyShell.java:491)
>       at groovy.ui.GroovyMain.processOnce(GroovyMain.java:650)
>       at groovy.ui.GroovyMain.run(GroovyMain.java:381)
>       at groovy.ui.GroovyMain.process(GroovyMain.java:367)
>       at groovy.ui.GroovyMain.processArgs(GroovyMain.java:126)
>       at groovy.ui.GroovyMain.main(GroovyMain.java:106)
>       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>       at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
>       at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>       at java.lang.reflect.Method.invoke(Method.java:606)
>       at 
> org.codehaus.groovy.tools.GroovyStarter.rootLoader(GroovyStarter.java:106)
>       at org.codehaus.groovy.tools.GroovyStarter.main(GroovyStarter.java:128)
> 1 error
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to