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-1039

VerifyError: returning local variable outside of scope

  • Log In
  • Views
    • XML
    • Word
    • Printable

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Fixed
  • Affects Version/s: 1.0-JSR-3
  • Fix Version/s: 1.0-JSR-5
  • Component/s: None
  • Labels:
    None

Description

test()

def test() {
try { def y = 1; } catch (NullPointerException ex) {
}

return y;
}

java.lang.VerifyError: (class: testScript, method: test signature: ()Ljava/lang/Object Accessing value from uninitialized register 3
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:2328)
at java.lang.Class.getConstructor0(Class.java:2640)
at java.lang.Class.newInstance0(Class.java:321)
at java.lang.Class.newInstance(Class.java:303)
at org.codehaus.groovy.runtime.InvokerHelper.createScript(InvokerHelper.java:517)

Issue Links

is depended upon by

Task - A task that needs to be done. GROOVY-754 scoping

  • Major - Major loss of function.
  • Closed - The issue is considered finished, the resolution is correct. Issues which are not closed can be reopened.

Activity

Ascending order - Click to sort in descending order
  • All
  • Comments
  • Work Log
  • History
  • Activity
Hide
Permalink
blackdrag blackdrag added a comment - 06/Sep/05 5:24 AM

the reason is that you are trying to access an undefined variable. y is only defined in the scope of the try-block. This is checked if you put these methods inside a class, but not in scripts.

Show
blackdrag blackdrag added a comment - 06/Sep/05 5:24 AM the reason is that you are trying to access an undefined variable. y is only defined in the scope of the try-block. This is checked if you put these methods inside a class, but not in scripts.
Hide
Permalink
blackdrag blackdrag added a comment - 19/Jan/06 6:59 PM

the program will noe throw a MissingPropertyException since you defined a local variable y which is only visible inside the try block. The return uses a y, but this is from the binding. Removing the def means, the return will succeed.

Show
blackdrag blackdrag added a comment - 19/Jan/06 6:59 PM the program will noe throw a MissingPropertyException since you defined a local variable y which is only visible inside the try block. The return uses a y, but this is from the binding. Removing the def means, the return will succeed.

People

  • Assignee:
    blackdrag blackdrag
    Reporter:
    Igor Nuzhnov
Vote (0)
Watch (0)

Dates

  • Created:
    02/Sep/05 8:29 AM
    Updated:
    19/Jan/06 6:59 PM
    Resolved:
    19/Jan/06 6:59 PM
  • 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.