jira.codehaus.org

  • Log In Access more options
    • Online Help
    • Keyboard Shortcuts
    • About JIRA
    • JIRA Credits
    • What?s New
  • Dashboards Access more options (Alt+d)
  • Projects Access more options (Alt+p)
  • Issues Access more options (Alt+i)
  • groovy
  • GROOVY-3128

VerifyError for class definition in script edge case

  • Log In
  • Views
    • XML
    • Word
    • Printable

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Fixed
  • Affects Version/s: 1.5.7, 1.6-beta-2
  • Fix Version/s: 1.6.3, 1.7-beta-1
  • Component/s: bytecode
  • Labels:
    None

Description

This script runs fine:

class MyClosure extends Closure {
    MyClosure(owner) {
        super(owner)
    }
    void run() { println 'running' }
}
new MyClosure(this).run()

But when I run this script:

class MyClosure extends Closure {
    MyClosure() {
        super(this)
    }
    void run() { println 'running' }
}
new MyClosure().run()

I receive:

java.lang.VerifyError: (class: MyClosure, method: <init> signature: ()V)
Expecting to find object/array on stack

Perhaps accessing the this variable inside the class definintion isn't supported by current scoping rules but in any case we should get a nice error not VerifyError.

Activity

Ascending order - Click to sort in descending order
  • All
  • Comments
  • Work Log
  • History
  • Activity
Hide
Permalink
blackdrag blackdrag added a comment - 01/Nov/08 5:16 PM

that is strange... I thought we already have a check for the usage of "this" in a case like above... yes, GROOVY-500 sounds very much like that bug... hmm. let me look at Verifier... in fact line 392 is expected to report this as an compilation error. .. but when I look at this code now, I have the feeling this nether really worked right, because the code looks as if it has some obvious bugs.

Show
blackdrag blackdrag added a comment - 01/Nov/08 5:16 PM that is strange... I thought we already have a check for the usage of "this" in a case like above... yes, GROOVY-500 sounds very much like that bug... hmm. let me look at Verifier... in fact line 392 is expected to report this as an compilation error. .. but when I look at this code now, I have the feeling this nether really worked right, because the code looks as if it has some obvious bugs.
Hide
Permalink
Roshan Dawrani added a comment - 25/Apr/09 9:53 AM

Fixed.

In Constructor body, if "this" or "super" was found referred in arguments list of a ConstructorCallExpression, a compiler error is thrown as in the case of MethodCallExpression.

Show
Roshan Dawrani added a comment - 25/Apr/09 9:53 AM Fixed. In Constructor body, if "this" or "super" was found referred in arguments list of a ConstructorCallExpression, a compiler error is thrown as in the case of MethodCallExpression.

People

  • Assignee:
    Roshan Dawrani
    Reporter:
    Paul King
Vote (0)
Watch (0)

Dates

  • Created:
    01/Nov/08 10:40 AM
    Updated:
    14/May/09 10:47 AM
    Resolved:
    25/Apr/09 9:53 AM
  • Atlassian JIRA (v5.0.4#731-sha1:3aa7374)
  • Report a problem
  • Powered by a free Atlassian JIRA open source license for Codehaus. Try JIRA - bug tracking software for your team.