Details
-
Bug
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
1.0-JSR-3
-
None
-
None
-
Java 1.5.0_03 on Windows XP
Description
When accessing a private static field, you get a "NoSuchFieldException" instead of an "IllegalPropertyAccessException:"
groovy> class A
{ static x }groovy> A.x = new Integer(10)
groovy> go
Caught: java.lang.NoSuchFieldException: x
at CommandLine.run(CommandLine.groovy:2)
With non-static fields, you get a more informative message:
groovy> class A
{ def x }groovy> a = new A()
groovy> a.x = new Integer(10)
groovy> go
Caught: groovy.lang.IllegalPropertyAccessException: Can not access the private field x in class A
at gjdk.groovy.lang.MetaClass_GroovyReflector.invoke(Unknown Source)
at A.setProperty(CommandLine.groovy)
at CommandLine.run(CommandLine.groovy:1)
Attachments
Activity
Field | Original Value | New Value |
---|---|---|
Comment |
[ a.@x = new Integer(10) // This ia a workaround. ] |
Fix Version/s | 1.0-JSR-4 [ 11905 ] | |
Assignee | Jochen Theodorou [ blackdrag ] | |
Resolution | Fixed [ 1 ] | |
Status | Open [ 1 ] | Closed [ 6 ] |
Project Import | Sun Apr 05 13:32:57 UTC 2015 [ 1428240777691 ] |
Workflow | jira [ 12730184 ] | Default workflow, editable Closed status [ 12742172 ] |
Project Import | Mon Apr 06 02:11:23 UTC 2015 [ 1428286283443 ] |
Workflow | jira [ 12972002 ] | Default workflow, editable Closed status [ 12979768 ] |
a.@x = new Integer(10) // This ia a workaround since jsr-04
X---------------------------------------------------------
Lets get Groovy!
================
Version: 1.0-jsr-04-SNAPSHOT JVM: 1.4.2_08-b03
Type 'exit' to terminate the shell
Type 'help' for command help
Type 'go' to execute the statements
groovy> class A
{ static x }groovy> A.@x = new Integer(10)
groovy> go
groovy> class A
{ def x }groovy> a = new A()
groovy> a.@x = new Integer(10)
groovy> go
X---------------------------------------------------------