commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Steve Downey <steve.dow...@netfolio.com>
Subject Re: [lang] Reflection - how accurate
Date Fri, 11 Oct 2002 22:59:26 GMT
We should work according to spec. If that's not possible without bizzareness, 
we should work the way the JDK works. Or we run the risk of it not working 
again when a point release of the JDK comes out.

On Friday 11 October 2002 04:35 pm, Stephen Colebourne wrote:
> I've been coding up the new reflection handling code (low level) for
> [lang]. And I've discovered that the Sun implementation (1.3.1) is screwed.
> Consider:
>
> Class A. Defines _public_ field named 'number' value 1
> Class B. Subclass of A. Defines _private_ field named 'number' value 2
> Interface I. Defines _public static final_ field named 'number' value 3
> Class C. Subclass of B, implements I.
>
> What value does 'number' have if you reference it from C ???
>
> Testing shows it is 3, because the private field in B hides the public
> field in A.
>
> However, Java reflection will give you the field on A if you request it
> passing in C. In other words Java 1.3.1 Sun reflection is screwed. I've
> just tested it on Sun's 1.4.0 however and it gives the correct answer.
>
> Now, I can work around this, doing lots of searches and the like, but it
> will slow things down a lot.
> - So how accurate do we need to be??
> - Should I code the workaround just for 1.3 java??
> - What about non-Sun implementations??
> - What about 1.2??
> - Do we care anyway, as its such a peculiar case??
>
> Stephen


--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message