You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@harmony.apache.org by Sean Qiu <se...@gmail.com> on 2009/01/04 09:34:28 UTC

Re: Using PriviAction instead of PrivilegedAction

"find . -name *.java -exec grep  'doPrivileged' {} \; | wc -l"   in
<trunk>/modules/luni/src/main
We get the fact that AccessController.doPrivileged* is called 53 times.
I think it may be worth refacting it.

Is there any comments about Nathan's suggestion code sample?

2008/12/25 Nathan Beyer <nd...@apache.org>

> Agreed. The value is just eliminating some redundant code and if there
> is a lot of calls in a single module, that's why I suggested a util
> class for each module, as appropriate.
>
> -Nathan
>
> On Wed, Dec 24, 2008 at 5:44 AM, Tim Ellison <t....@gmail.com>
> wrote:
> > Pavel Pervov wrote:
> >> As I see it this class only solves the problem of "the more anonymous
> >> classes - the larger disribution is" problem. That is all. I assume we
> >> want to move toward solving that problem, but I'm not quite sure if we
> >> want to achieve it by using _single_ helper class for all the class
> >> library.
> >
> > So how is this use of PriviAction:
> >  new PriviAction<String>("line.separator")
> >
> >
> > producing fewer anonymous classes than this use of PrivilegedAction:
> >
> >  new PrivilegedAction<String>() {
> >    public String run() {
> >      return System.getProperty("line.separator");
> >    }
> >  }
> >
> >
> > It is more compact in source code, but...<shrug/>
> >
> > Regards,
> > Tim
> >
> >
> >> On Wed, Dec 24, 2008 at 2:10 PM, Tim Ellison <t....@gmail.com>
> wrote:
> >>> I didn't see a good answer to Alexei's question...
> >>>
> >>> Alexei Fedotov wrote:
> >>>> Pavel,
> >>>> Kevin didn't mention performance, did he?
> >>>>
> >>>> I believe it is always a trade off between modularity and speed. The
> >>>> performance measurement might be a part of Kevin's arguments if his
> >>>> intentions are to improve the performance. That is why I asked him to
> >>>> elaborate both approaches uncovering intentions.
> >>>>
> >>>> If our internal security interfaces are much quicker on real
> >>>> applications I would wonder why our public interfaces are so slow.
> >>> What problem is the PriviAction solving?  I see the class comment [1]
> says:
> >>>
> >>> "Helper class to avoid multiple anonymous inner class for
> >>> java.security.AccessController#doPrivileged(PrivilegedAction) calls."
> >>>
> >>> Is that really a problem?  For readability or performance?
> >>>
> >>> [1]
> >>>
> http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/util/PriviAction.java?revision=486600
> >>>
> >>> Regards,
> >>> Tim
> >>>
> >>
> >
>



-- 
Best Regards
Sean, Xiao Xia Qiu

China Software Development Lab, IBM