Return-Path: Delivered-To: apmail-jakarta-commons-dev-archive@apache.org Received: (qmail 79898 invoked from network); 12 Oct 2002 07:13:28 -0000 Received: from unknown (HELO nagoya.betaversion.org) (192.18.49.131) by daedalus.apache.org with SMTP; 12 Oct 2002 07:13:28 -0000 Received: (qmail 7417 invoked by uid 97); 12 Oct 2002 07:13:43 -0000 Delivered-To: qmlist-jakarta-archive-commons-dev@jakarta.apache.org Received: (qmail 7390 invoked by uid 97); 12 Oct 2002 07:13:42 -0000 Mailing-List: contact commons-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Jakarta Commons Developers List" Reply-To: "Jakarta Commons Developers List" Delivered-To: mailing list commons-dev@jakarta.apache.org Received: (qmail 7372 invoked by uid 98); 12 Oct 2002 07:13:41 -0000 X-Antivirus: nagoya (v4218 created Aug 14 2002) X-Qmail-Scanner-Mail-From: baliuka@centras.lt via jim.skynet.vl X-Qmail-Scanner: 1.03 (Clean. Processed in 3.315877 secs) Message-ID: <041c01c271be$bd19e130$0111010a@user> From: "Juozas Baliuka" To: "Jakarta Commons Developers List" References: <005701c27165$d5406d00$d03529d9@oemcomputer> <008301c27175$78bc16a0$d03529d9@oemcomputer> Subject: Re: [lang] Reflection - how accurate Date: Sat, 12 Oct 2002 09:12:34 +0200 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2600.0000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N Hi, It is possible using java.lang.reflect.Modifier, see Method[] Class.getDeclaredMethods() and Method[] getMethods() it is not the same. And it seems "getMethods" has some bugs on sun's 1.3. > OK, Its even worse, because there is no easy way to find out if a > method/field can be called without actually calling it. What I mean is that > there is no method that says can I call this method/field without getting an > IllegalAccessException. > > (The method isAccessible() is badly named, and should be called > isIgnoreScope().) > > This adds even more complexity to the code. I know about the MethodUtils > from [beanutils], but has anyone else come up against these kinds of issues > with reflection. > > Stephen > > ----- Original Message ----- > From: "Stephen Colebourne" > To: "Jakarta Commons Developers List" > Sent: Friday, October 11, 2002 9:35 PM > Subject: [lang] Reflection - how accurate > > > > 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: > > > For additional commands, e-mail: > > > > > > -- > To unsubscribe, e-mail: > For additional commands, e-mail: > -- To unsubscribe, e-mail: For additional commands, e-mail: