Replacing Unsafe.allocateInstance
Paul Sandoz
paul.sandoz at oracle.com
Tue Jun 30 14:28:35 UTC 2015
On Jun 30, 2015, at 4:10 PM, Henri Tremblay <henri at tremblay.pro> wrote:
> I indeed noticed that having a constant class seems indeed to constant fold.
>
> So far, I was also suspecting that having a Constructor was allowing to cache part of the work.
>
Certainly the class spinning can be viewed as part of that, since the type to construct is placed in the constant pool.
> Then, if we want to keep things simple, we can just get rid of Unsafe.allocateInstance and keep ReflectionFactory.newConstructorForSerialization.
>
Yes, perhaps, but obviously not in it's current internal form. It does allow for calling a super constructor. A variant returning method handle might actually be more optimal in terms of handling any constructor parameters to avoid boxing and packing.
Paul.
More information about the jdk9-dev
mailing list