[PATCH] Use #valueOf()-methods in Unsafe-based FieldAccessors

Rémi Forax forax at univ-mlv.fr
Tue May 1 21:54:43 UTC 2012

On 05/01/2012 09:33 PM, Andrej Golovnin wrote:
> Hi all,

Hi Andrej,
your far from Swing :)
(I remember you from the glorious appframework time)

> Is there some reason for not using #valueOf-methods from wrapper classes
> in Unsafe-based FieldAccessors in sun.reflect-package (see the attached patch)?

The main reason, I think, is that these code was written during 1.4 time 
and not updated for 1.5.
And the mailer deamon (or mailer imp ?) remove attachment, so you have 
to repost it inlined.

> The main motivation for this patch is to reduce memory consumption in applications
> which make heavy use of reflection API (e.g. apps which use ORM solutions).

and your ORM doesn't use neither field.getInt() (and variants) instead 
of field.get()
nor do bytecode enhancement ?

Also, because currently the escape analysis done by Hotspot is a little 
bit broken
you may introduce a slowdown/more memory consumption because the JIT
may be able to remove new Integer()/Integer.intValue() pair but not
Integer.valueOf()/Integer.intValue() pair.

But I know that someone is working on this :)

> The patch does not modify Unsafe-based FieldAccessors for double and float
> fields as the wrapper classes does not provide caching for fields of this types.
> Best regards
> Andrej Golovnin


More information about the core-libs-dev mailing list