Hans Muller just convinced me that I didn't want a short hand syntax for declaring properties after all. Hope it isn't too late.
Posted by Stephen Colebourne on January 10, 2007 at 08:28 AM PST #
Posted by Mike on January 10, 2007 at 09:11 AM PST #
Posted by Fatih Coskun on January 10, 2007 at 09:53 AM PST #
Posted by Jonathan Gibbons on January 10, 2007 at 10:51 AM PST #
Posted by Eugene Vigdorchik on January 10, 2007 at 12:52 PM PST #
Posted by Ben on January 10, 2007 at 05:27 PM PST #
Posted by 84.52.111.196 on January 10, 2007 at 11:43 PM PST #
Dear peter,
i 've written my answer
here.
Santa
Posted by Rémi Forax on January 11, 2007 at 08:26 AM PST #
interface base { public abstract property int val; }
class derived implements base {
private int val;
public int getVal(){ return val; }
public void setVal(int v){ val = v; }
}
public class test {
public static void main(String[] args){
derived d = new derived();
d.val = 0; //compile time error
}
}
property is hidden by field declaration in remi's current prototype implementation. I think that is necessary to source level compatibility(new compiler can compile old class that implements interface which has property). However, this behavior is feeling bad to me. I worry whether property becomes the mass of such little bad feelings.
Posted by Michel Ishizuka on January 11, 2007 at 11:00 AM PST #
Michel, you are right.
There is really a bad interaction.
The compiler could generate a warning in
derived for that case. But that doesn't satisfy me.
It's perhaps time to change dot to another symbol :(
Posted by Rémi Forax on January 12, 2007 at 05:57 AM PST #
Michel, to be clear, this kind of shadowing exists since jdk1.0 but you are right that we can't retrofit property access that use gettter/setter to use qualified access without introducing this shadowing bug.
class base { public int val; }
class derived extends base {
private int val;
}
public class ShadowingTest {
public static void main(String[] args){
derived d = new derived();
d.val = 0; //compile time error
}
}
Rémi
Posted by Rémi Forax on January 12, 2007 at 06:56 AM PST #
Posted by Peter von der Ahe on January 12, 2007 at 07:15 AM PST #