You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@harmony.apache.org by Alexei Zakharov <al...@gmail.com> on 2006/08/03 15:16:44 UTC

[classlib][beans] RI violates the spec in the Statement class

Hi community,

I'd like to attract everyone's attention to another RI inconsistence.
It seems RI has a bug in the implementation of execute() method of the
java.beans.Statement class. The spec states:

1. "When the target's class defines many methods with the given name
the implementation should choose the most specific method using the
algorithm specified in the Java Language Specification (15.11)."
2. "The reserved method name "new" may be used to call a class's
constructor as if all classes defined static "new" methods."

But the following test shows that RI does not follow these rules –
does not choose the most specific method:

import java.beans.*;

public class StatementTest {

    public static class MyBean {
        static String calledM = null;

        public MyBean(Object arg) {
            calledM = "new1";
        }

        public MyBean(Integer arg) {
            calledM = "new2";
        }

    }

    public static void main(String argv[]) throws Exception {
        Statement stmt = new Statement(MyBean.class, "new",
                new Object[] { new Integer(17) });

        stmt.execute();
        if (!MyBean.calledM.equals("new2")) {
            System.out.println("FAIL");
        } else {
            System.out.println("PASS");
        }
    }

}

The result is "FAIL" on RI. However, it behaves correctly for regular
methods (that aren't constructors). I think I should post "Non-bug
differences from RI" JIRA. I am also going to correct our
implementation of Statement since it is now "compatible" with RI. Any
objections?

Thanks,

-- 
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


Re: [classlib][beans] RI violates the spec in the Statement class

Posted by Alexey Petrenko <al...@gmail.com>.
I've moved public MyBean(Integer arg) to the top and test passed after
that. Both on Harmony and RI.

It seems that we just take the first compatible constructor.

SY, Alexey

2006/8/3, Alexei Zakharov <al...@gmail.com>:
> Hi community,
>
> I'd like to attract everyone's attention to another RI inconsistence.
> It seems RI has a bug in the implementation of execute() method of the
> java.beans.Statement class. The spec states:
>
> 1. "When the target's class defines many methods with the given name
> the implementation should choose the most specific method using the
> algorithm specified in the Java Language Specification (15.11)."
> 2. "The reserved method name "new" may be used to call a class's
> constructor as if all classes defined static "new" methods."
>
> But the following test shows that RI does not follow these rules –
> does not choose the most specific method:
>
> import java.beans.*;
>
> public class StatementTest {
>
>    public static class MyBean {
>        static String calledM = null;
>
>        public MyBean(Object arg) {
>            calledM = "new1";
>        }
>
>        public MyBean(Integer arg) {
>            calledM = "new2";
>        }
>
>    }
>
>    public static void main(String argv[]) throws Exception {
>        Statement stmt = new Statement(MyBean.class, "new",
>                new Object[] { new Integer(17) });
>
>        stmt.execute();
>        if (!MyBean.calledM.equals("new2")) {
>            System.out.println("FAIL");
>        } else {
>            System.out.println("PASS");
>        }
>    }
>
> }
>
> The result is "FAIL" on RI. However, it behaves correctly for regular
> methods (that aren't constructors). I think I should post "Non-bug
> differences from RI" JIRA. I am also going to correct our
> implementation of Statement since it is now "compatible" with RI. Any
> objections?
>
> Thanks,
>
> --
> 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
>
>


-- 
Alexey A. Petrenko
Intel Middleware Products Division

Re: [classlib][beans] RI violates the spec in the Statement class

Posted by Alexei Zakharov <al...@gmail.com>.
Mikhail, please pay attention on the second quotation from my first
message. It states that while calling Statement#execute() we should
think about construtors as about regular static methods with the
special name "new", and all other regular rules should be applicable
to them. This quote is from the java.beans.Statement.execute()
method's description - you may read the whole text there if you like.

Thanks,

2006/8/3, Mikhail Loenko <ml...@gmail.com>:
> Well constructor is not a method :)
> so RI and Harmony are not necessary violate the spec
>
> I'd probably stick to the current behavior
>
> Thanks,
> Mikhail
>
> 2006/8/3, Alexei Zakharov <al...@gmail.com>:
> > As far as I understand RI simply take the first declared method. In
> > other words, if we swap constructors in the above example like this
> >
> > public static class MyBean {
> >       static String calledM = null;
> >
> >       public MyBean(Integer arg) {
> >           calledM = "new2";
> >       }
> >
> >       public MyBean(Object arg) {
> >           calledM = "new1";
> >       }
> >
> >   }
> >
> > the result will be "PASS".
> > :-/
> >
> >
> > Thanks,
> >
> > 2006/8/3, Mikhail Loenko <ml...@gmail.com>:
> > > How does RI behave if there are three methods? does it alway selects less
> > > specific?
> > >
> > > Thanks,
> > > Mikhail
> > >
> > > 2006/8/3, Alexei Zakharov <al...@gmail.com>:
> > > > Hi community,
> > > >
> > > > I'd like to attract everyone's attention to another RI inconsistence.
> > > > It seems RI has a bug in the implementation of execute() method of the
> > > > java.beans.Statement class. The spec states:
> > > >
> > > > 1. "When the target's class defines many methods with the given name
> > > > the implementation should choose the most specific method using the
> > > > algorithm specified in the Java Language Specification (15.11)."
> > > > 2. "The reserved method name "new" may be used to call a class's
> > > > constructor as if all classes defined static "new" methods."
> > > >
> > > > But the following test shows that RI does not follow these rules –
> > > > does not choose the most specific method:
> > > >
> > > > import java.beans.*;
> > > >
> > > > public class StatementTest {
> > > >
> > > >    public static class MyBean {
> > > >        static String calledM = null;
> > > >
> > > >        public MyBean(Object arg) {
> > > >            calledM = "new1";
> > > >        }
> > > >
> > > >        public MyBean(Integer arg) {
> > > >            calledM = "new2";
> > > >        }
> > > >
> > > >    }
> > > >
> > > >    public static void main(String argv[]) throws Exception {
> > > >        Statement stmt = new Statement(MyBean.class, "new",
> > > >                new Object[] { new Integer(17) });
> > > >
> > > >        stmt.execute();
> > > >        if (!MyBean.calledM.equals("new2")) {
> > > >            System.out.println("FAIL");
> > > >        } else {
> > > >            System.out.println("PASS");
> > > >        }
> > > >    }
> > > >
> > > > }
> > > >
> > > > The result is "FAIL" on RI. However, it behaves correctly for regular
> > > > methods (that aren't constructors). I think I should post "Non-bug
> > > > differences from RI" JIRA. I am also going to correct our
> > > > implementation of Statement since it is now "compatible" with RI. Any
> > > > objections?
> > > >
> > > > Thanks,
> > > >
> > > > --
> > > > 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
> > > >
> > > >
> > >
> > > ---------------------------------------------------------------------
> > > 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
> > >
> > >
> >
> >
> > --
> > 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
> >
> >
>
> ---------------------------------------------------------------------
> 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
>
>


-- 
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


Re: [classlib][beans] RI violates the spec in the Statement class

Posted by Alexei Zakharov <al...@gmail.com>.
Exactly.

2006/8/3, Oleg Khaschansky <ol...@gmail.com>:
> According to "15.9.3 Choosing the Constructor and its Arguments":
>
> Once the actual arguments have been determined, they are used to
> select a constructor of C, using the same rules as for method
> invocations (§15.12).
>
> On 8/3/06, Mikhail Loenko <ml...@gmail.com> wrote:
> > Well constructor is not a method :)
> > so RI and Harmony are not necessary violate the spec
> >
> > I'd probably stick to the current behavior
> >
> > Thanks,
> > Mikhail
> >
> > 2006/8/3, Alexei Zakharov <al...@gmail.com>:
> > > As far as I understand RI simply take the first declared method. In
> > > other words, if we swap constructors in the above example like this
> > >
> > > public static class MyBean {
> > >       static String calledM = null;
> > >
> > >       public MyBean(Integer arg) {
> > >           calledM = "new2";
> > >       }
> > >
> > >       public MyBean(Object arg) {
> > >           calledM = "new1";
> > >       }
> > >
> > >   }
> > >
> > > the result will be "PASS".
> > > :-/
> > >
> > >
> > > Thanks,
> > >
> > > 2006/8/3, Mikhail Loenko <ml...@gmail.com>:
> > > > How does RI behave if there are three methods? does it alway selects less
> > > > specific?
> > > >
> > > > Thanks,
> > > > Mikhail
> > > >
> > > > 2006/8/3, Alexei Zakharov <al...@gmail.com>:
> > > > > Hi community,
> > > > >
> > > > > I'd like to attract everyone's attention to another RI inconsistence.
> > > > > It seems RI has a bug in the implementation of execute() method of the
> > > > > java.beans.Statement class. The spec states:
> > > > >
> > > > > 1. "When the target's class defines many methods with the given name
> > > > > the implementation should choose the most specific method using the
> > > > > algorithm specified in the Java Language Specification (15.11)."
> > > > > 2. "The reserved method name "new" may be used to call a class's
> > > > > constructor as if all classes defined static "new" methods."
> > > > >
> > > > > But the following test shows that RI does not follow these rules –
> > > > > does not choose the most specific method:
> > > > >
> > > > > import java.beans.*;
> > > > >
> > > > > public class StatementTest {
> > > > >
> > > > >    public static class MyBean {
> > > > >        static String calledM = null;
> > > > >
> > > > >        public MyBean(Object arg) {
> > > > >            calledM = "new1";
> > > > >        }
> > > > >
> > > > >        public MyBean(Integer arg) {
> > > > >            calledM = "new2";
> > > > >        }
> > > > >
> > > > >    }
> > > > >
> > > > >    public static void main(String argv[]) throws Exception {
> > > > >        Statement stmt = new Statement(MyBean.class, "new",
> > > > >                new Object[] { new Integer(17) });
> > > > >
> > > > >        stmt.execute();
> > > > >        if (!MyBean.calledM.equals("new2")) {
> > > > >            System.out.println("FAIL");
> > > > >        } else {
> > > > >            System.out.println("PASS");
> > > > >        }
> > > > >    }
> > > > >
> > > > > }
> > > > >
> > > > > The result is "FAIL" on RI. However, it behaves correctly for regular
> > > > > methods (that aren't constructors). I think I should post "Non-bug
> > > > > differences from RI" JIRA. I am also going to correct our
> > > > > implementation of Statement since it is now "compatible" with RI. Any
> > > > > objections?
> > > > >
> > > > > Thanks,
> > > > >
> > > > > --
> > >
> > > --
> > > Alexei Zakharov,
> > > Intel Middleware Product Division

-- 
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


Re: [classlib][beans] RI violates the spec in the Statement class

Posted by Oleg Khaschansky <ol...@gmail.com>.
According to "15.9.3 Choosing the Constructor and its Arguments":

Once the actual arguments have been determined, they are used to
select a constructor of C, using the same rules as for method
invocations (§15.12).

On 8/3/06, Mikhail Loenko <ml...@gmail.com> wrote:
> Well constructor is not a method :)
> so RI and Harmony are not necessary violate the spec
>
> I'd probably stick to the current behavior
>
> Thanks,
> Mikhail
>
> 2006/8/3, Alexei Zakharov <al...@gmail.com>:
> > As far as I understand RI simply take the first declared method. In
> > other words, if we swap constructors in the above example like this
> >
> > public static class MyBean {
> >       static String calledM = null;
> >
> >       public MyBean(Integer arg) {
> >           calledM = "new2";
> >       }
> >
> >       public MyBean(Object arg) {
> >           calledM = "new1";
> >       }
> >
> >   }
> >
> > the result will be "PASS".
> > :-/
> >
> >
> > Thanks,
> >
> > 2006/8/3, Mikhail Loenko <ml...@gmail.com>:
> > > How does RI behave if there are three methods? does it alway selects less
> > > specific?
> > >
> > > Thanks,
> > > Mikhail
> > >
> > > 2006/8/3, Alexei Zakharov <al...@gmail.com>:
> > > > Hi community,
> > > >
> > > > I'd like to attract everyone's attention to another RI inconsistence.
> > > > It seems RI has a bug in the implementation of execute() method of the
> > > > java.beans.Statement class. The spec states:
> > > >
> > > > 1. "When the target's class defines many methods with the given name
> > > > the implementation should choose the most specific method using the
> > > > algorithm specified in the Java Language Specification (15.11)."
> > > > 2. "The reserved method name "new" may be used to call a class's
> > > > constructor as if all classes defined static "new" methods."
> > > >
> > > > But the following test shows that RI does not follow these rules –
> > > > does not choose the most specific method:
> > > >
> > > > import java.beans.*;
> > > >
> > > > public class StatementTest {
> > > >
> > > >    public static class MyBean {
> > > >        static String calledM = null;
> > > >
> > > >        public MyBean(Object arg) {
> > > >            calledM = "new1";
> > > >        }
> > > >
> > > >        public MyBean(Integer arg) {
> > > >            calledM = "new2";
> > > >        }
> > > >
> > > >    }
> > > >
> > > >    public static void main(String argv[]) throws Exception {
> > > >        Statement stmt = new Statement(MyBean.class, "new",
> > > >                new Object[] { new Integer(17) });
> > > >
> > > >        stmt.execute();
> > > >        if (!MyBean.calledM.equals("new2")) {
> > > >            System.out.println("FAIL");
> > > >        } else {
> > > >            System.out.println("PASS");
> > > >        }
> > > >    }
> > > >
> > > > }
> > > >
> > > > The result is "FAIL" on RI. However, it behaves correctly for regular
> > > > methods (that aren't constructors). I think I should post "Non-bug
> > > > differences from RI" JIRA. I am also going to correct our
> > > > implementation of Statement since it is now "compatible" with RI. Any
> > > > objections?
> > > >
> > > > Thanks,
> > > >
> > > > --
> > > > 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
> > > >
> > > >
> > >
> > > ---------------------------------------------------------------------
> > > 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
> > >
> > >
> >
> >
> > --
> > 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
> >
> >
>
> ---------------------------------------------------------------------
> 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
>
>

---------------------------------------------------------------------
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


Re: [classlib][beans] RI violates the spec in the Statement class

Posted by Mikhail Loenko <ml...@gmail.com>.
Well constructor is not a method :)
so RI and Harmony are not necessary violate the spec

I'd probably stick to the current behavior

Thanks,
Mikhail

2006/8/3, Alexei Zakharov <al...@gmail.com>:
> As far as I understand RI simply take the first declared method. In
> other words, if we swap constructors in the above example like this
>
> public static class MyBean {
>       static String calledM = null;
>
>       public MyBean(Integer arg) {
>           calledM = "new2";
>       }
>
>       public MyBean(Object arg) {
>           calledM = "new1";
>       }
>
>   }
>
> the result will be "PASS".
> :-/
>
>
> Thanks,
>
> 2006/8/3, Mikhail Loenko <ml...@gmail.com>:
> > How does RI behave if there are three methods? does it alway selects less
> > specific?
> >
> > Thanks,
> > Mikhail
> >
> > 2006/8/3, Alexei Zakharov <al...@gmail.com>:
> > > Hi community,
> > >
> > > I'd like to attract everyone's attention to another RI inconsistence.
> > > It seems RI has a bug in the implementation of execute() method of the
> > > java.beans.Statement class. The spec states:
> > >
> > > 1. "When the target's class defines many methods with the given name
> > > the implementation should choose the most specific method using the
> > > algorithm specified in the Java Language Specification (15.11)."
> > > 2. "The reserved method name "new" may be used to call a class's
> > > constructor as if all classes defined static "new" methods."
> > >
> > > But the following test shows that RI does not follow these rules –
> > > does not choose the most specific method:
> > >
> > > import java.beans.*;
> > >
> > > public class StatementTest {
> > >
> > >    public static class MyBean {
> > >        static String calledM = null;
> > >
> > >        public MyBean(Object arg) {
> > >            calledM = "new1";
> > >        }
> > >
> > >        public MyBean(Integer arg) {
> > >            calledM = "new2";
> > >        }
> > >
> > >    }
> > >
> > >    public static void main(String argv[]) throws Exception {
> > >        Statement stmt = new Statement(MyBean.class, "new",
> > >                new Object[] { new Integer(17) });
> > >
> > >        stmt.execute();
> > >        if (!MyBean.calledM.equals("new2")) {
> > >            System.out.println("FAIL");
> > >        } else {
> > >            System.out.println("PASS");
> > >        }
> > >    }
> > >
> > > }
> > >
> > > The result is "FAIL" on RI. However, it behaves correctly for regular
> > > methods (that aren't constructors). I think I should post "Non-bug
> > > differences from RI" JIRA. I am also going to correct our
> > > implementation of Statement since it is now "compatible" with RI. Any
> > > objections?
> > >
> > > Thanks,
> > >
> > > --
> > > 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
> > >
> > >
> >
> > ---------------------------------------------------------------------
> > 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
> >
> >
>
>
> --
> 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
>
>

---------------------------------------------------------------------
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


Re: [classlib][beans] RI violates the spec in the Statement class

Posted by Alexei Zakharov <al...@gmail.com>.
As far as I understand RI simply take the first declared method. In
other words, if we swap constructors in the above example like this

public static class MyBean {
       static String calledM = null;

       public MyBean(Integer arg) {
           calledM = "new2";
       }

       public MyBean(Object arg) {
           calledM = "new1";
       }

   }

the result will be "PASS".
:-/


Thanks,

2006/8/3, Mikhail Loenko <ml...@gmail.com>:
> How does RI behave if there are three methods? does it alway selects less
> specific?
>
> Thanks,
> Mikhail
>
> 2006/8/3, Alexei Zakharov <al...@gmail.com>:
> > Hi community,
> >
> > I'd like to attract everyone's attention to another RI inconsistence.
> > It seems RI has a bug in the implementation of execute() method of the
> > java.beans.Statement class. The spec states:
> >
> > 1. "When the target's class defines many methods with the given name
> > the implementation should choose the most specific method using the
> > algorithm specified in the Java Language Specification (15.11)."
> > 2. "The reserved method name "new" may be used to call a class's
> > constructor as if all classes defined static "new" methods."
> >
> > But the following test shows that RI does not follow these rules –
> > does not choose the most specific method:
> >
> > import java.beans.*;
> >
> > public class StatementTest {
> >
> >    public static class MyBean {
> >        static String calledM = null;
> >
> >        public MyBean(Object arg) {
> >            calledM = "new1";
> >        }
> >
> >        public MyBean(Integer arg) {
> >            calledM = "new2";
> >        }
> >
> >    }
> >
> >    public static void main(String argv[]) throws Exception {
> >        Statement stmt = new Statement(MyBean.class, "new",
> >                new Object[] { new Integer(17) });
> >
> >        stmt.execute();
> >        if (!MyBean.calledM.equals("new2")) {
> >            System.out.println("FAIL");
> >        } else {
> >            System.out.println("PASS");
> >        }
> >    }
> >
> > }
> >
> > The result is "FAIL" on RI. However, it behaves correctly for regular
> > methods (that aren't constructors). I think I should post "Non-bug
> > differences from RI" JIRA. I am also going to correct our
> > implementation of Statement since it is now "compatible" with RI. Any
> > objections?
> >
> > Thanks,
> >
> > --
> > 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
> >
> >
>
> ---------------------------------------------------------------------
> 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
>
>


-- 
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


Re: [classlib][beans] RI violates the spec in the Statement class

Posted by Mikhail Loenko <ml...@gmail.com>.
How does RI behave if there are three methods? does it alway selects less
specific?

Thanks,
Mikhail

2006/8/3, Alexei Zakharov <al...@gmail.com>:
> Hi community,
>
> I'd like to attract everyone's attention to another RI inconsistence.
> It seems RI has a bug in the implementation of execute() method of the
> java.beans.Statement class. The spec states:
>
> 1. "When the target's class defines many methods with the given name
> the implementation should choose the most specific method using the
> algorithm specified in the Java Language Specification (15.11)."
> 2. "The reserved method name "new" may be used to call a class's
> constructor as if all classes defined static "new" methods."
>
> But the following test shows that RI does not follow these rules –
> does not choose the most specific method:
>
> import java.beans.*;
>
> public class StatementTest {
>
>    public static class MyBean {
>        static String calledM = null;
>
>        public MyBean(Object arg) {
>            calledM = "new1";
>        }
>
>        public MyBean(Integer arg) {
>            calledM = "new2";
>        }
>
>    }
>
>    public static void main(String argv[]) throws Exception {
>        Statement stmt = new Statement(MyBean.class, "new",
>                new Object[] { new Integer(17) });
>
>        stmt.execute();
>        if (!MyBean.calledM.equals("new2")) {
>            System.out.println("FAIL");
>        } else {
>            System.out.println("PASS");
>        }
>    }
>
> }
>
> The result is "FAIL" on RI. However, it behaves correctly for regular
> methods (that aren't constructors). I think I should post "Non-bug
> differences from RI" JIRA. I am also going to correct our
> implementation of Statement since it is now "compatible" with RI. Any
> objections?
>
> Thanks,
>
> --
> 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
>
>

---------------------------------------------------------------------
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