You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@polygene.apache.org by Paul Merlin <pa...@apache.org> on 2017/04/08 16:03:53 UTC

setAccessible( true )

Gang,

We use accessibleObject.setAccessible( true ) a bit too agressively.
This is a performance killer because of the JVM security checks it implies.
Some profiling showed me that's it's often on the critical path, Well
that's because I profiled the bootstrap phase for most of the cases.

BTW, the new serialization subsystem is way faster than the previous one \o/
JSONEntityState still is a hotspot, but that's another topic.

There are places where setAccessible( true ) is simply not needed and I
will remove them.

Unfortunately, o.isAccessible() does not check if it is actually
accessible but simply if setAccessible( true ) was called on it to
forcibly make it accessible. We have some of these checks here and
there, I'll verify if they are legitimate.

There are places where it supports e.g. using private classes as mixins,
and injection to private fields. For some types of
composites/fragments/etc.. calls to setAccessible() are made when
creating the model, for some others they are made during runtime
repeatedly. I'll move all these at bootstrap time so we don't pay that
cost at runtime.

/Paul


Re: setAccessible( true )

Posted by Niclas Hedhman <ni...@hedhman.org>.
Yeah, already pre-1.0 we were fighting to move all setAccessible() to model
creation where they belong and ensure none were executed in runtime. IF
they have snuck back into runtime, then yes they should be pushed back. IF
they are simply called too many times in bootstrap, then I don't worry too
much about it and wouldn't spend time locate them.

Cheers
Niclas

On Sun, Apr 9, 2017 at 12:03 AM, Paul Merlin <pa...@apache.org> wrote:

> Gang,
>
> We use accessibleObject.setAccessible( true ) a bit too agressively.
> This is a performance killer because of the JVM security checks it implies.
> Some profiling showed me that's it's often on the critical path, Well
> that's because I profiled the bootstrap phase for most of the cases.
>
> BTW, the new serialization subsystem is way faster than the previous one
> \o/
> JSONEntityState still is a hotspot, but that's another topic.
>
> There are places where setAccessible( true ) is simply not needed and I
> will remove them.
>
> Unfortunately, o.isAccessible() does not check if it is actually
> accessible but simply if setAccessible( true ) was called on it to
> forcibly make it accessible. We have some of these checks here and
> there, I'll verify if they are legitimate.
>
> There are places where it supports e.g. using private classes as mixins,
> and injection to private fields. For some types of
> composites/fragments/etc.. calls to setAccessible() are made when
> creating the model, for some others they are made during runtime
> repeatedly. I'll move all these at bootstrap time so we don't pay that
> cost at runtime.
>
> /Paul
>
>


-- 
Niclas Hedhman, Software Developer
http://polygene.apache.org - New Energy for Java