[prev in list] [next in list] [prev in thread] [next in thread]
List: groovy-scm
Subject: [groovy-scm] [jira] Updated: (GROOVY-1566) problems with if statements not
From: "Jochen Theodorou (JIRA)" <jira () codehaus ! org>
Date: 2006-11-29 10:00:40
Message-ID: 41586553.1164794440976.JavaMail.haus-jira () codehaus01 ! managed ! contegix ! com
[Download RAW message or body]
[ http://jira.codehaus.org/browse/GROOVY-1566?page=all ]
Jochen Theodorou updated GROOVY-1566:
-------------------------------------
Assignee: Jochen Theodorou (was: Guillaume Laforge)
Fix Version/s: 1.0-final
Component/s: bytecode
> problems with if statements not returning correctly
> ---------------------------------------------------
>
> Key: GROOVY-1566
> URL: http://jira.codehaus.org/browse/GROOVY-1566
> Project: groovy
> Issue Type: Bug
> Components: bytecode
> Reporter: Alex Shneyderman
> Assigned To: Jochen Theodorou
> Fix For: 1.0-final
>
>
> package groovy.runtime.metaclass.org.codehaus.groovy.antlr
> import groovy.formatter.DefaultTraverser
> import java.beans.IntrospectionException
> class GroovySourceASTMetaClass extends MetaClassImpl {
> public GroovySourceASTMetaClass(MetaClassRegistry mcr, Class clazz) throws \
> IntrospectionException { super(mcr, clazz)
> }
> // version that exhibits the bug
> Object getProperty(final Object object, final String property) {
> if (property == "children") {
> new ASTIterator(next:object.firstChild)
> } else {
> super.getProperty(object, property)
> }
> }
> /* version that works
> Object getProperty(final Object object, final String property) {
> def result = null
>
> if (property == "children") {
> result = new ASTIterator(next:object.firstChild)
> } else {
> result = super.getProperty(object, property)
> }
>
> return result
> }
> */
> }
> class ASTIterator implements Iterator {
> Object next = null
> boolean hasNext() {
> return next != null;
> }
> Object next() {
> def prevNext = next
> next = next.nextSibling
> prevNext
> }
> void remove() {
> throw new RuntimeException("Removal of AST nodes is not implemented.");
> }
>
> }
> // and here is some script that trips with an exception
> GroovyRecognizer parser = null
> UnicodeEscapingReader unicodeReader = new UnicodeEscapingReader(new StringReader \
> ("println 'Hello, there!'"), null) GroovyLexer lexer = new \
> GroovyLexer(unicodeReader) unicodeReader.setLexer(lexer)
> parser = GroovyRecognizer.make(lexer)
> parser.compilationUnit()
>
> GroovySourceAST ast = (GroovySourceAST) parser.getAST()
> ast.children.each { println it.text }
> // exception thrown is
> // Note: execution is not that of the snippet above.
> /*
> Exception in thread "main" java.lang.VerifyError: (class: \
> groovy/runtime/metaclass/org/codehaus/groovy/antlr/GroovySourceASTMetaClass, \
> method: getProperty signature: \
> (Ljava/lang/Object;Ljava/lang/String;)Ljava/lang/Object;) Inconsistent stack height \
> 1 != 0 at java.lang.Class.forName0(Native Method)
> at java.lang.Class.forName(Class.java:164)
> at groovy.lang.MetaClassRegistry.getMetaClassFor(MetaClassRegistry.java:218)
> at groovy.lang.MetaClassRegistry.getMetaClass(MetaClassRegistry.java:142)
> at org.codehaus.groovy.runtime.Invoker.getProperty(Invoker.java:247)
> at org.codehaus.groovy.runtime.InvokerHelper.getProperty(InvokerHelper.java:213)
> at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.getProperty(ScriptBytecodeAdapter.java:501)
> at groovy.formatter.GroovySourceFormatter.format(GroovySourceFormatter.groovy:44)
> at gjdk.groovy.formatter.GroovySourceFormatter_GroovyReflector.invoke(Unknown \
> Source) at groovy.lang.MetaMethod.invoke(MetaMethod.java:111)
> at org.codehaus.groovy.runtime.MetaClassHelper.doMethodInvoke(MetaClassHelper.java:659)
> at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:377)
> at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:344)
> at org.codehaus.groovy.runtime.Invoker.invokeMethod(Invoker.java:134)
> at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:111)
> at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnCurrentN(ScriptBytecodeAdapter.java:89)
> at groovy.formatter.GroovySourceFormatter$_run_closure2.doCall(GroovySourceFormatter.groovy:28)
> 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:585)
> at org.codehaus.groovy.runtime.ReflectionMetaMethod.invoke(ReflectionMetaMethod.java:67)
> at org.codehaus.groovy.runtime.MetaClassHelper.doMethodInvoke(MetaClassHelper.java:659)
> at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:377)
> at groovy.lang.Closure.call(Closure.java:176)
> at groovy.lang.Closure.call(Closure.java:189)
> at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:677)
> at gjdk.java.util.Collection_GroovyReflector.invoke(Unknown Source)
> at groovy.lang.MetaMethod.invoke(MetaMethod.java:111)
> at org.codehaus.groovy.runtime.NewInstanceMetaMethod.invoke(NewInstanceMetaMethod.java:99)
> at org.codehaus.groovy.runtime.MetaClassHelper.doMethodInvoke(MetaClassHelper.java:659)
> at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:377)
> at org.codehaus.groovy.runtime.Invoker.invokeMethod(Invoker.java:122)
> at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:111)
> at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN(ScriptBytecodeAdapter.java:165)
> at groovy.formatter.GroovySourceFormatter.run(GroovySourceFormatter.groovy:28)
> at gjdk.groovy.formatter.GroovySourceFormatter_GroovyReflector.invoke(Unknown \
> Source) at groovy.lang.MetaMethod.invoke(MetaMethod.java:111)
> at org.codehaus.groovy.runtime.MetaClassHelper.doMethodInvoke(MetaClassHelper.java:659)
> at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:377)
> at org.codehaus.groovy.runtime.Invoker.invokeMethod(Invoker.java:134)
> at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:111)
> at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN(ScriptBytecodeAdapter.java:165)
> at groovy.formatter.GroovySourceFormatter.main(GroovySourceFormatter.groovy:12)
> */
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: \
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
<hr/>
<p>
To unsubscribe from this list please visit:
</p>
<p>
<a href="http://xircles.codehaus.org/manage_email">http://xircles.codehaus.org/manage_email</a>
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic