Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
2.4.7
-
None
-
None
-
mac os x 10.10.5
jdk 1.8.0_51
Description
when I executed this code in GroovyConsole
@Category(Integer) class IntegerEx { def reset(int value) { this = value this } } use(IntegerEx){ println (1 + 2).reset(1) }
Then, I get this exception log
Exception thrown BUG! exception in phase 'semantic analysis' in source unit 'ConsoleScript17' null at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:935) at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:593) at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:542) at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:298) at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:268) at groovy.lang.GroovyShell.parseClass(GroovyShell.java:688) at groovy.lang.GroovyShell.run(GroovyShell.java:517) at groovy.lang.GroovyShell.run(GroovyShell.java:497) at groovy.lang.GroovyShell.run(GroovyShell.java:170) at groovy.lang.GroovyShell$run$1.call(Unknown Source) at groovy.ui.Console$_runScriptImpl_closure16.doCall(Console.groovy:1005) at groovy.ui.Console$_runScriptImpl_closure16.doCall(Console.groovy) at sun.reflect.GeneratedMethodAccessor218.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93) at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325) at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:294) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1024) at groovy.lang.Closure.call(Closure.java:414) at groovy.lang.Closure.call(Closure.java:408) at groovy.lang.Closure.run(Closure.java:495) at java.lang.Thread.run(Thread.java:745) Caused by: java.lang.NullPointerException at org.codehaus.groovy.classgen.VariableScopeVisitor.checkForFinal(VariableScopeVisitor.java:388) at org.codehaus.groovy.classgen.VariableScopeVisitor.checkFinalFieldAccess(VariableScopeVisitor.java:381) at org.codehaus.groovy.classgen.VariableScopeVisitor.visitBinaryExpression(VariableScopeVisitor.java:365) at org.codehaus.groovy.ast.expr.BinaryExpression.visit(BinaryExpression.java:51) at org.codehaus.groovy.ast.CodeVisitorSupport.visitExpressionStatement(CodeVisitorSupport.java:71) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitExpressionStatement(ClassCodeVisitorSupport.java:196) at org.codehaus.groovy.ast.stmt.ExpressionStatement.visit(ExpressionStatement.java:42) at org.codehaus.groovy.ast.CodeVisitorSupport.visitBlockStatement(CodeVisitorSupport.java:37) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitBlockStatement(ClassCodeVisitorSupport.java:166) at org.codehaus.groovy.classgen.VariableScopeVisitor.visitBlockStatement(VariableScopeVisitor.java:308) at org.codehaus.groovy.ast.stmt.BlockStatement.visit(BlockStatement.java:71) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClassCodeContainer(ClassCodeVisitorSupport.java:104) at org.codehaus.groovy.classgen.VariableScopeVisitor.visitConstructorOrMethod(VariableScopeVisitor.java:505) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitMethod(ClassCodeVisitorSupport.java:126) at org.codehaus.groovy.ast.ClassNode.visitContents(ClassNode.java:1078) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClass(ClassCodeVisitorSupport.java:53) at org.codehaus.groovy.classgen.VariableScopeVisitor.visitClass(VariableScopeVisitor.java:473) at org.codehaus.groovy.control.CompilationUnit$11.call(CompilationUnit.java:648) at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:931) ... 22 more
Is this behavior groovy-language specification ?
Attachments
Issue Links
- relates to
-
GROOVY-6947 NPE in compilation when assigning a value to 'this'
- Closed
- links to