[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
RE: [aspectj-users] One target for intertype declarations
|
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Nicholas Lesiecki wrote:
>> Whoops, sorry, missed the modifier. Of course you are right. I
>> also consider that as a possible place for improvement.
>
> Actually, there would be two copies of the field even if the
> modifier were "public". Variables, unlike methods, are not
> overridden. They can be shadowed, but you can still access both
> copies on a given
> object.
Interesting. That's really new to me. I always thought inheritance
would work the normal way for fields as well. So how would one access
a field that is declared in a superclass when you have the very same
declaration in the subclass as well (a shadow)? By a cast?
class Super { public Type field; }
class Sub extends super { public Type field; }
class Foo {
void someMethod {
Super s = new Sub();
//is s.field here the field of Sub or Super?
Sub sub = (Sub) s;
//is s.field here the field of Sub or Super?
}
}
Now *I* am confused ;-)
Eric
- --
Eric Bodden
Chair I2 for Programming Languages and Program Analysis
RWTH Aachen University
-----BEGIN PGP SIGNATURE-----
Version: PGP 8.0.3
iQA/AwUBQaQxZswiFCm7RlWCEQJCQgCeP6BpBQucceA4Q0w3ztf4RfzzFhQAnRTI
dYZmicZ8dhZuyLroWLGUWETV
=uEXG
-----END PGP SIGNATURE-----