harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mikhail Loenko" <mloe...@gmail.com>
Subject Re: [classlib][beans] RI violates the spec in the Statement class
Date Thu, 03 Aug 2006 14:08:01 GMT
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 <alexei.zakharov@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 <mloenko@gmail.com>:
> > How does RI behave if there are three methods? does it alway selects less
> > specific?
> >
> > Thanks,
> > Mikhail
> >
> > 2006/8/3, Alexei Zakharov <alexei.zakharov@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


Mime
View raw message