Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Critical
-
Resolution: Fixed
-
Affects Version/s: 1.8-rc-4
-
Fix Version/s: None
-
Component/s: class generator
-
Labels:None
-
Environment:Grails 1.4.0.BUILD-SNAPSHOT
-
Number of attachments :
Description
I'm afraid this happened with Grails 1.4.0.BUILD-SNAPSHOT and a Grails application. That means to reproduce, you will have to build Grails 1.4.0 from trunk or pick up a nightly snapshot. I have attached a sample application.
Here's the stacktrace when running grails compile:
Welcome to Grails 1.4.0.BUILD-SNAPSHOT - http://grails.org/
Licensed under Apache Standard License 2.0
Grails home is set to: /Users/pledbrook/dev/tools/git/grails-core
Base Directory: /Users/pledbrook/dev/projects/scratch/test-1.4-snap
Running script Compile.groovy
Environment set to development
[mkdir] Created dir: /Users/pledbrook/dev/projects/scratch/test-1.4-snap/target/plugin-classes
[groovyc] Compiling 46 source files to /Users/pledbrook/dev/projects/scratch/test-1.4-snap/target/plugin-classes
Error executing script Compile: : BUG! exception in phase 'class generation' in source unit '/Users/pledbrook/dev/projects/scratch/test-1.4-snap/target/plugins/fixtures-1.0.6/src/groovy/grails/plugin/fixtures/files/FixtureFileLoader.groovy' SpreadExpression should not be visited here
: BUG! exception in phase 'class generation' in source unit '/Users/pledbrook/dev/projects/scratch/test-1.4-snap/target/plugins/fixtures-1.0.6/src/groovy/grails/plugin/fixtures/files/FixtureFileLoader.groovy' SpreadExpression should not be visited here
at gant.Gant$_dispatch_closure5.doCall(Gant.groovy:391)
at gant.Gant$_dispatch_closure7.doCall(Gant.groovy:415)
at gant.Gant$_dispatch_closure7.doCall(Gant.groovy)
at java_util_concurrent_Callable$call.call(Unknown Source)
at gant.Gant.withBuildListeners(Gant.groovy:427)
at gant.Gant.this$2$withBuildListeners(Gant.groovy)
at gant.Gant$this$2$withBuildListeners.callCurrent(Unknown Source)
at gant.Gant.dispatch(Gant.groovy:415)
at gant.Gant.this$2$dispatch(Gant.groovy)
at gant.Gant.invokeMethod(Gant.groovy)
at gant.Gant.executeTargets(Gant.groovy:590)
at gant.Gant.executeTargets(Gant.groovy:589)
Caused by: : BUG! exception in phase 'class generation' in source unit '/Users/pledbrook/dev/projects/scratch/test-1.4-snap/target/plugins/fixtures-1.0.6/src/groovy/grails/plugin/fixtures/files/FixtureFileLoader.groovy' SpreadExpression should not be visited here
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:116)
at _GrailsCompile_groovy$_run_closure3_closure9.doCall(_GrailsCompile_groovy:119)
at _GrailsCompile_groovy$_run_closure3_closure9.doCall(_GrailsCompile_groovy)
at _GrailsCompile_groovy$_run_closure3.doCall(_GrailsCompile_groovy:106)
at java_util_concurrent_Callable$call.call(Unknown Source)
at _GrailsCompile_groovy$_run_closure2.doCall(_GrailsCompile_groovy:45)
at java_util_concurrent_Callable$call.call(Unknown Source)
at java_util_concurrent_Callable$call.call(Unknown Source)
at gant.Gant$_dispatch_closure5.doCall(Gant.groovy:381)
... 11 more
Caused by: BUG! exception in phase 'class generation' in source unit '/Users/pledbrook/dev/projects/scratch/test-1.4-snap/target/plugins/fixtures-1.0.6/src/groovy/grails/plugin/fixtures/files/FixtureFileLoader.groovy' SpreadExpression should not be visited here
at org.codehaus.groovy.classgen.AsmClassGenerator.visitSpreadExpression(AsmClassGenerator.java:575)
at org.codehaus.groovy.classgen.asm.InvocationWriter.writeDirectMethodCall(InvocationWriter.java:125)
at org.codehaus.groovy.classgen.asm.InvocationWriter.makeCall(InvocationWriter.java:166)
at org.codehaus.groovy.classgen.asm.InvocationWriter.makeCall(InvocationWriter.java:87)
at org.codehaus.groovy.classgen.asm.InvocationWriter.makeInvokeMethodCall(InvocationWriter.java:71)
at org.codehaus.groovy.classgen.asm.InvocationWriter.writeInvokeMethod(InvocationWriter.java:287)
at org.codehaus.groovy.classgen.AsmClassGenerator.visitMethodCallExpression(AsmClassGenerator.java:661)
at org.codehaus.groovy.classgen.asm.StatementWriter.writeExpressionStatement(StatementWriter.java:599)
at org.codehaus.groovy.classgen.asm.OptimizingStatementWriter.writeExpressionStatement(OptimizingStatementWriter.java:320)
at org.codehaus.groovy.classgen.AsmClassGenerator.visitExpressionStatement(AsmClassGenerator.java:460)
at org.codehaus.groovy.classgen.asm.StatementWriter.writeBlockStatement(StatementWriter.java:80)
at org.codehaus.groovy.classgen.asm.OptimizingStatementWriter.writeBlockStatement(OptimizingStatementWriter.java:151)
at org.codehaus.groovy.classgen.AsmClassGenerator.visitBlockStatement(AsmClassGenerator.java:406)
at org.codehaus.groovy.classgen.AsmClassGenerator.visitStdMethod(AsmClassGenerator.java:289)
at org.codehaus.groovy.classgen.AsmClassGenerator.visitConstructorOrMethod(AsmClassGenerator.java:268)
at org.codehaus.groovy.classgen.AsmClassGenerator.visitMethod(AsmClassGenerator.java:366)
at org.codehaus.groovy.classgen.AsmClassGenerator.visitClass(AsmClassGenerator.java:174)
at org.codehaus.groovy.control.CompilationUnit$13.call(CompilationUnit.java:763)
at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:957)
at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:542)
at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:520)
at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:497)
at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:476)
at org.codehaus.groovy.tools.FileSystemCompiler.compile(FileSystemCompiler.java:67)
at org.codehaus.groovy.tools.FileSystemCompiler.doCompilation(FileSystemCompiler.java:180)
at org.codehaus.groovy.ant.Groovyc.compile(Groovyc.java:903)
at org.codehaus.groovy.ant.Groovyc.execute(Groovyc.java:606)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
... 19 more
Error executing script Compile: : BUG! exception in phase 'class generation' in source unit '/Users/pledbrook/dev/projects/scratch/test-1.4-snap/target/plugins/fixtures-1.0.6/src/groovy/grails/plugin/fixtures/files/FixtureFileLoader.groovy' SpreadExpression should not be visited here
Activity
Peter Ledbrook
made changes -
| Field | Original Value | New Value |
|---|---|---|
| Attachment | groovy-compile-bug.zip [ 54775 ] |
Guillaume Laforge
made changes -
| Status | Open [ 1 ] | Resolved [ 5 ] |
| Assignee | Jochen Theodorou [ blackdrag ] | Guillaume Laforge [ guillaume ] |
| Resolution | Fixed [ 1 ] |
Paul King
made changes -
| Resolution | Fixed [ 1 ] | |
| Status | Resolved [ 5 ] | Reopened [ 4 ] |
blackdrag blackdrag
made changes -
| Status | Reopened [ 4 ] | Resolved [ 5 ] |
| Assignee | Guillaume Laforge [ guillaume ] | blackdrag blackdrag [ blackdrag ] |
| Resolution | Fixed [ 1 ] |
Paul King
made changes -
| Status | Resolved [ 5 ] | Closed [ 6 ] |
Groovy 1.7 was a bit more tolerant to such errors than Groovy 1.8 seems to be, but there is a bad usage of the spread operator in FixtureFileLoader.groovy.
To summarize what this class is doing (by trimming as much as possible):
class FixtureFileLoader { def load(String[] patterns) { doLoad(*patterns) } protected doLoad(String[] locationPatterns) {} } String[] arr = ['a', 'b', 'c'] def ffl = new FixtureFileLoader() ffl.load(arr)You are calling the doLoad() method from the load() method, by spreading the patterns array as arguments, but the doLoad() method actually takes the same array as parameters.
This is a bad usage of the spread operator, as the spread operator is not needed at all.
So just remove the 'star', and the code will work the same in 1.7 and 1.8.