harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mikhail Loenko" <mloe...@gmail.com>
Subject Re: [website] harmony-dev agreements and recommendations
Date Thu, 25 May 2006 15:43:37 GMT
Hi Mikhail

2006/5/25, Mikhail Fursov <mike.fursov@gmail.com>:
> On 5/25/06, Mikhail Loenko <mloenko@gmail.com> wrote:
> >
> > > 2) Try to make all objects used for synchronization 'final'  (we have a
> > lot
> > > of non-final monitors in API, so we give a chance to bugs)
> >
> > Could you please explain with details and an example?
>
>
> This is not a bug (E.g. ExemptionMechanism:47, BeanContextSupport:149) but
> such code may lead (in theory or in future) to deadlock because it allows
> different threads to use different locks in the same object instance. Also
> when you analyse 'synchronized' pattern the 'final' modifier for a lock
> really helps in understanding code and locks logic.

Agreed that in some cases in theory it might lead to problems. So if it is
a recommendation rather than a strict law, then +1 from me.

>
>
> > 3) Never call to Boolean of Integer contructors (performance issue, there
> > > are a lot of such calls in our API)
> >
> > Again, an example would be useful.
>
>
> grep "new Boolean" or "new Integer" over the sources. You fill find > 100
> samples. New object creation when it's possible to use static and cached
> instances is a bad practice from the performance point of view.

The first grep result is:
    private PropertyChangeEvent createPropertyChangeEvent(
            String propertyName, int oldValue, int newValue) {
        return new PropertyChangeEvent(sourceBean, propertyName,
                new Integer(oldValue), new Integer(newValue));
    }
How do you suggest to make it better?

>
> > 4) Never do manual array copying (our crypto API does )
> >
> > What do you mean by 'manual array copying'? How it should be done and why?
>
>
> This is manual copying of arrays in loop instead of System.arraycopy() call
> (System.arraycopy() can be implemented as performance primitive in VM or
> JIT)
> Check this code as example: ExemptionMechanism:249, Statement:164

Agreed here. BTW, if array has a lenght of 5 what is the best copying way?

Thanks,
Mikhail

>
>
> Thanks,
> > Mikhail
> >
>
>
>
> --
> Mikhail Fursov
> Intel Middleware Products 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


Mime
View raw message