You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by "Alexei Zakharov (JIRA)" <ji...@apache.org> on 2007/01/25 13:31:51 UTC
[jira] Closed: (HARMONY-1503) [classlib][beans] Harmony uses
standard introspection procedure for DefaultPersistenceDelegate constructor
[ https://issues.apache.org/jira/browse/HARMONY-1503?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Alexei Zakharov closed HARMONY-1503.
------------------------------------
Resolution: Won't Fix
> [classlib][beans] Harmony uses standard introspection procedure for DefaultPersistenceDelegate constructor
> ----------------------------------------------------------------------------------------------------------
>
> Key: HARMONY-1503
> URL: https://issues.apache.org/jira/browse/HARMONY-1503
> Project: Harmony
> Issue Type: Improvement
> Components: Non-bug differences from RI
> Environment: win
> Reporter: Alexei Zakharov
>
> The behavior of RI's implementations of java.beans.DefaultPersistenceDelegate#DefaultPersistenceDelegate(String[])
> violates 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 Harmony 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 (r447840):
> ---
> 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);
> It was decided in the mailing list [1] that we should ignore RI and follow the spec here.
> [1] http://mail-archives.apache.org/mod_mbox/incubator-harmony-dev/200609.mbox/%3c4510FACC.8080109@gmail.com%3e
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.