|
Jochen Theodorou made changes - 24/Apr/08 06:25 AM
a I commented elsewhere.... the field is final, thus the change should not happen. If it where a property it would not happen. It only happens because it is a field and there is a check missing. that's nothing crazy
Jochen Theodorou made changes - 24/Apr/08 07:23 AM
That test case does not demonstrate modification of a final field and that is not what is happening. It reads a final field which returns a [C (array of char) then updates the element values in the array. That is completely valid from a 'final' aspect (that the field is private and should never have been readable in the first place is the bug as I reported using this test case). Groovy does not modify final fields, but if you think it can, then submit a suitable test. you should check that with a test. See my comment at GROOVY-1875 As you said, the test belongs here. The test I tried earlier was this: class MyBean {
final String foo = '123'
}
def b = new MyBean()
b.foo = 'ABC'
==>
groovy.lang.ReadOnlyPropertyException: Cannot set readonly property: foo for class: MyBean
My new version that should fail, but does not: String s = "123" def x = s.value s.value = "ABC" assert !x.is(s.value) The reason I put it in "should fail" form is because it should really fail before the assertion.
Jochen Theodorou made changes - 24/Apr/08 12:29 PM
Jochen Theodorou made changes - 24/Apr/08 01:57 PM
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
It's crazy world that it's come to this point. I wonder if the fact that this would be possible occurred to any of the groovy developers as groovy was being written, or if this is an innocent mistake. If it occurred to someone pre-release... I'd love to see the discussion on the matter on why on earth this should be permitted.