RFR: 5043030 (reflect) unnecessary object creation in reflection

Andrej Golovnin andrej.golovnin at gmail.com
Thu May 29 12:24:09 UTC 2014

Hi David,

>> The valueOf calls may also allocate a new object so you can't just
>> delete the JvmtiExport::post_vm_object_alloc call. Unfortunately you
>> can't tell whether a new object was allocated or not. It is only for the
>> smaller primitive types that any kind of Object caching is mandated.
> It is only for the smaller values (-128 to +127) of the integer primitives types (plus boolean) that caching is mandated. Float.valueOf and Double.valueOf always create objects.

You are right, that #valueOf call may allocate an object.
But as far as I understand currently the JvmtiExport::post_vm_object_alloc call
is only needed, because today the native code itself allocates an object
by calling java_lang_boxing_object::create(type, value, CHECK_NULL);.

My code changes this behavior and delegates object allocation back to Java
by calling 


But maybe I misunderstood the implementation of JavaCalls.

Best regards,
Andrej Golovnin

More information about the hotspot-runtime-dev mailing list