From harmony-dev-return-13804-apmail-incubator-harmony-dev-archive=incubator.apache.org@incubator.apache.org Wed Sep 20 11:19:33 2006 Return-Path: Delivered-To: apmail-incubator-harmony-dev-archive@www.apache.org Received: (qmail 8176 invoked from network); 20 Sep 2006 11:19:33 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 20 Sep 2006 11:19:33 -0000 Received: (qmail 20771 invoked by uid 500); 20 Sep 2006 11:19:28 -0000 Delivered-To: apmail-incubator-harmony-dev-archive@incubator.apache.org Received: (qmail 20741 invoked by uid 500); 20 Sep 2006 11:19:28 -0000 Mailing-List: contact harmony-dev-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: harmony-dev@incubator.apache.org Delivered-To: mailing list harmony-dev@incubator.apache.org Received: (qmail 20723 invoked by uid 99); 20 Sep 2006 11:19:28 -0000 Received: from idunn.apache.osuosl.org (HELO idunn.apache.osuosl.org) (140.211.166.84) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 20 Sep 2006 04:19:28 -0700 Authentication-Results: idunn.apache.osuosl.org header.from=alexei.zakharov@gmail.com; domainkeys=good X-ASF-Spam-Status: No, hits=0.4 required=5.0 tests=DNS_FROM_RFC_ABUSE,RCVD_BY_IP DomainKey-Status: good X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 Received: from ([66.249.82.227:42304] helo=wx-out-0506.google.com) by idunn.apache.osuosl.org (ecelerity 2.1 r(10620)) with ESMTP id 24/15-00532-DB321154 for ; Wed, 20 Sep 2006 04:19:25 -0700 Received: by wx-out-0506.google.com with SMTP id s13so216258wxc for ; Wed, 20 Sep 2006 04:19:23 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=e1EtXCPqLm3gaxMofALq7y7pJVBOCBZXAZ4VN3o+QtoMR8m3lxpKW7ZVEKCfShfW5YSb+2yyfScII78YJntGkvYwaN+gtha64O4Ep+XFY1CoHSYpgHDMz+RBY5ZQ+l6as/6eyuh8IVYD58+ssexuWJMF9cnTBSRXd1ITOEVpPEQ= Received: by 10.90.94.2 with SMTP id r2mr6252893agb; Wed, 20 Sep 2006 04:19:22 -0700 (PDT) Received: by 10.90.68.10 with HTTP; Wed, 20 Sep 2006 04:19:22 -0700 (PDT) Message-ID: <2c9597b90609200419w7e9adf73h55aa9e2f5e054fc6@mail.gmail.com> Date: Wed, 20 Sep 2006 15:19:22 +0400 From: "Alexei Zakharov" To: harmony-dev@incubator.apache.org Subject: Re: [classlib][beans] RI violates the spec in DefaultPersistenceDelegate In-Reply-To: <4510FACC.8080109@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <2c9597b90609191108l6f36cb95m4eaa6677b701d349@mail.gmail.com> <4510FACC.8080109@gmail.com> X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Thanks for the feedback Tim. HARMONY-1503 has been rised. Regards, 2006/9/20, Tim Ellison : > I agree that it should use the BeanInfo. Leave Harmony code as-is and > file a non-bug difference JIRA. > > Regards, > Tim > > Alexei Zakharov wrote: > > > > Greetings to Harmony java beans experts. > > > > It seems I found another place where RI fails. The behavior of its > > java.beans.DefaultPersistenceDelegate#DefaultPersistenceDelegate(String[]) > > IMHO violates at least the following part of the spec (JavaBeans spec > > v1.01 page 57): > > > > <-- > > 8.7. Analyzing a Bean > > > > We allow both explicit specification of a bean's exposed > > properties/methods/events and also implicit analysis using design > > patterns. > > To simplify access to this information, and to make sure that all > > tools apply the same analysis rules, we provide a class > > java.beans.Introspector that should be used to analyze a bean class. > > It allows you to obtain a BeanInfo object that comprehensively > > describes a target bean class. > > The Introspector class walks over the class/superclass chain of the > > target class. At each level it checks if there is a matching BeanInfo > > class which provides explicit information about the bean, and if so > > uses that explicit information. Otherwise it uses the low level > > reflection APIs to study the target class and uses design patterns to > > analyze its behaviour and then proceeds to continue the introspection > > with its baseclass. (See the Introspector class definition for a full > > description of the analysis rules.) > > <-- > > > > The test below illustrates that RI does not care about explicitly > > specified BeanInfo class and uses the reflection API instead. Please > > note that our implementation behaves correctly in this situation. This > > is the reason why some tests from DefaultPersistenceDelegateTest fail > > - they are "optimized" for this RI behavior. > > The test case: > > --- > > import java.beans.*; > > > > public class DefaultPDtest { > > > > public static class MyFoo { > > String ugh; > > > > public MyFoo(String str) { > > ugh = str; > > } > > > > public String myget() { > > return ugh; > > } > > > > public void myset(String val) { > > ugh = val; > > } > > } > > > > public static class MyFooBeanInfo extends SimpleBeanInfo { > > public PropertyDescriptor[] getPropertyDescriptors() { > > PropertyDescriptor pd; > > > > try { > > pd = new PropertyDescriptor("prop1", > > MyFoo.class, "myget", "myset"); > > } catch (IntrospectionException e) { > > throw new RuntimeException(e); > > } > > return new PropertyDescriptor[] { pd }; > > } > > } > > > > public static class MyPersistenceDelegate > > extends DefaultPersistenceDelegate { > > public MyPersistenceDelegate(String[] propNames) { > > super(propNames); > > } > > > > protected Expression instantiate(Object oldInstance, Encoder out) { > > return super.instantiate(oldInstance, out); > > } > > } > > > > public static void main(String argv[]) { > > Encoder enc = new Encoder(); > > MyPersistenceDelegate pd; > > MyFoo oldBean = new MyFoo("harmony"); > > Expression expr; > > > > System.out.println("Test1: arg should be \"harmony\""); > > pd = new MyPersistenceDelegate(new String[] {"prop1"}); > > expr = pd.instantiate(oldBean, enc); > > System.out.println("Constructor to call: " + expr); > > > > System.out.println("Test2: arg should be null"); > > pd = new MyPersistenceDelegate(new String[] {"ugh"}); > > expr = pd.instantiate(oldBean, enc); > > System.out.println("Constructor to call: " + expr); > > > > } > > > > } > > > > Output on RI (Sun 1.5.0_06): > > --- > > Test1: arg should be "harmony" > > java.lang.NoSuchMethodException: DefaultPDtest$MyFoo.getProp1 > > Continuing ... > > Constructor to call: DefaultPDtest$MyFoo=Class.new(null); > > Test2: arg should be null > > Constructor to call: DefaultPDtest$MyFoo=Class.new("harmony"); > > > > Output on Harmony (current): > > --- > > Test1: arg should be "harmony" > > Constructor to call: DefaultPDtest$MyFoo=Class.new("harmony"); > > Test2: arg should be null > > class java.lang.NoSuchMethodException: no property for name ugh is found > > Constructor to call: DefaultPDtest$MyFoo=Class.new(null); > > > > I vote for ignoring RI and following the spec here. > > Thanks for your attention, > > > > > > -- > > Tim Ellison (t.p.ellison@gmail.com) > IBM Java technology centre, UK. -- Alexei Zakharov, Intel Middleware Product Division --------------------------------------------------------------------- Terms of use : http://incubator.apache.org/harmony/mailing.html To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org For additional commands, e-mail: harmony-dev-help@incubator.apache.org