groovy-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Paul King (JIRA)" <j...@apache.org>
Subject [jira] [Resolved] (GROOVY-4787) BUG! exception in phase 'class generation' generating class from map in closure
Date Mon, 01 Jun 2015 13:01:17 GMT

     [ https://issues.apache.org/jira/browse/GROOVY-4787?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Paul King resolved GROOVY-4787.
-------------------------------
       Resolution: Fixed
    Fix Version/s: 2.5.0-beta-1
         Assignee: Paul King

> BUG! exception in phase 'class generation' generating class from map in closure
> -------------------------------------------------------------------------------
>
>                 Key: GROOVY-4787
>                 URL: https://issues.apache.org/jira/browse/GROOVY-4787
>             Project: Groovy
>          Issue Type: Bug
>          Components: class generator
>    Affects Versions: 1.7.10, 1.8-rc-4, 2.4.0-rc-1
>            Reporter: Tim Yates
>            Assignee: Paul King
>            Priority: Minor
>             Fix For: 2.5.0-beta-1
>
>
> If I have a class like so:
> {code}
> class Person {
>   String name
>   int age
> }
> {code}
> Then it is possible to create an instance of {{Person}} using the little known construct:
> {code}
> def tim = Person [ name:'tim', age:49 ]
> {code}
> This works fine.
> However, if I try to do the following:
> {code}
> def ppl = [ [ name:'Tim', age:49 ], [ name:'Dave', age:32 ], [ name:'Steve', age:28 ]
]
> ppl.collect { Person [ *it ] }
> {code}
> I get the class generation error
> {code}
> BUG! exception in phase 'class generation' in source unit 'ConsoleScript10' SpreadExpression
should not be visited here
> 	at org.codehaus.groovy.classgen.AsmClassGenerator.visitSpreadExpression(AsmClassGenerator.java:1871)
> 	at org.codehaus.groovy.ast.expr.SpreadExpression.visit(SpreadExpression.java:39)
> 	at org.codehaus.groovy.classgen.AsmClassGenerator.visitAndAutoboxBoolean(AsmClassGenerator.java:4122)
> 	at org.codehaus.groovy.classgen.AsmClassGenerator.makeBinopCallSite(AsmClassGenerator.java:2268)
> 	at org.codehaus.groovy.classgen.AsmClassGenerator.evaluateBinaryExpression(AsmClassGenerator.java:3902)
> 	at org.codehaus.groovy.classgen.AsmClassGenerator.visitBinaryExpression(AsmClassGenerator.java:1662)
> 	at org.codehaus.groovy.ast.expr.BinaryExpression.visit(BinaryExpression.java:49)
> 	at org.codehaus.groovy.classgen.AsmClassGenerator.visitAndAutoboxBoolean(AsmClassGenerator.java:4122)
> 	at org.codehaus.groovy.classgen.AsmClassGenerator.evaluateExpression(AsmClassGenerator.java:1447)
> 	at org.codehaus.groovy.classgen.AsmClassGenerator.visitReturnStatement(AsmClassGenerator.java:1408)
> 	at org.codehaus.groovy.ast.stmt.ReturnStatement.visit(ReturnStatement.java:47)
> 	at org.codehaus.groovy.ast.CodeVisitorSupport.visitBlockStatement(CodeVisitorSupport.java:35)
> 	at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitBlockStatement(ClassCodeVisitorSupport.java:165)
> 	at org.codehaus.groovy.classgen.AsmClassGenerator.visitBlockStatement(AsmClassGenerator.java:738)
> 	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:626)
> 	at org.codehaus.groovy.classgen.AsmClassGenerator.visitConstructorOrMethod(AsmClassGenerator.java:601)
> 	at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitMethod(ClassCodeVisitorSupport.java:123)
> 	at org.codehaus.groovy.classgen.AsmClassGenerator.visitMethod(AsmClassGenerator.java:696)
> 	at org.codehaus.groovy.ast.ClassNode.visitContents(ClassNode.java:1039)
> 	at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClass(ClassCodeVisitorSupport.java:50)
> 	at org.codehaus.groovy.classgen.AsmClassGenerator.visitClass(AsmClassGenerator.java:276)
> 	at org.codehaus.groovy.control.CompilationUnit$12.call(CompilationUnit.java:748)
> 	at org.codehaus.groovy.control.CompilationUnit$12.call(CompilationUnit.java:765)
> 	at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:942)
> 	at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:519)
> 	at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:497)
> 	at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:474)
> 	at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:306)
> 	at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:287)
> 	at groovy.lang.GroovyShell.parseClass(GroovyShell.java:731)
> 	at groovy.lang.GroovyShell.run(GroovyShell.java:516)
> 	at groovy.lang.GroovyShell.run(GroovyShell.java:172)
> 	at groovy.lang.GroovyShell$run.call(Unknown Source)
> 	at groovy.ui.Console$_runScriptImpl_closure16.doCall(Console.groovy:904)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> 	at java.lang.reflect.Method.invoke(Method.java:597)
> 	at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
> 	at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)
> 	at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:273)
> 	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:886)
> 	at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:66)
> 	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:149)
> 	at groovy.ui.Console$_runScriptImpl_closure16.doCall(Console.groovy)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> 	at java.lang.reflect.Method.invoke(Method.java:597)
> 	at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
> 	at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)
> 	at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:273)
> 	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:886)
> 	at groovy.lang.Closure.call(Closure.java:282)
> 	at groovy.lang.Closure.call(Closure.java:277)
> 	at groovy.lang.Closure.run(Closure.java:360)
> 	at java.lang.Thread.run(Thread.java:680)
> {code}
> I know I should be doing:
> {code}
> ppl.collect { new Person( *:it ) }
> {code}
> (which works fine), but I just thought you should know about this {{BUG!}} exception



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

Mime
View raw message