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 JavaCalls::call_static(&boxed_value, klass_handle, vmSymbols::valueOf_name(), valueOf_signature, &args, THREAD); But maybe I misunderstood the implementation of JavaCalls. Best regards, Andrej Golovnin