K
kartik
Currently, use of (JavaBeans) properties requires manual calls to
getter & setter methods. Wouldn't it be better to extend the language
so that an expression "object.foo" (without a '()'), in the absence of
a field named foo, is treated as equivalent to a call to a
getter/setter method (depending on whether the property is being read
or written).
I feel it would be better to do this *not* by a compile-time
transformation but by changing the spec of the getfield & putfield
instructions to invoke a getter/setter method when there is no
matching field. Then, classes can replace fields with properties (or
vice-versa) without hurting binary compatibility (for clients who
access the fields/properties using the "object.foo" syntax).
Maybe static properties should also be allowed.
Any comments? Thank you.
-kartik
getter & setter methods. Wouldn't it be better to extend the language
so that an expression "object.foo" (without a '()'), in the absence of
a field named foo, is treated as equivalent to a call to a
getter/setter method (depending on whether the property is being read
or written).
I feel it would be better to do this *not* by a compile-time
transformation but by changing the spec of the getfield & putfield
instructions to invoke a getter/setter method when there is no
matching field. Then, classes can replace fields with properties (or
vice-versa) without hurting binary compatibility (for clients who
access the fields/properties using the "object.foo" syntax).
Maybe static properties should also be allowed.
Any comments? Thank you.
-kartik