Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
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
-
GROOVY-754
scoping
-
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.