mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 06:45:07 +02:00
8247532: Records deserialization is slow
8248135: Build microbenchmarks with --enable-preview Test contributed by Chris Hegarty <chris.hegarty@oracle.com> Reviewed-by: chegar, psandoz, redestad, ihse
This commit is contained in:
parent
4bcd70acc0
commit
2f09989ec0
5 changed files with 972 additions and 70 deletions
|
@ -2182,7 +2182,7 @@ public class ObjectInputStream
|
|||
handles.markException(passHandle, resolveEx);
|
||||
}
|
||||
|
||||
final boolean isRecord = cl != null && isRecord(cl) ? true : false;
|
||||
final boolean isRecord = cl != null && isRecord(cl);
|
||||
if (isRecord) {
|
||||
assert obj == null;
|
||||
obj = readRecord(desc);
|
||||
|
@ -2289,14 +2289,14 @@ public class ObjectInputStream
|
|||
|
||||
FieldValues fieldValues = defaultReadFields(null, desc);
|
||||
|
||||
// retrieve the canonical constructor
|
||||
MethodHandle ctrMH = desc.getRecordConstructor();
|
||||
|
||||
// bind the stream field values
|
||||
ctrMH = RecordSupport.bindCtrValues(ctrMH, desc, fieldValues);
|
||||
// get canonical record constructor adapted to take two arguments:
|
||||
// - byte[] primValues
|
||||
// - Object[] objValues
|
||||
// and return Object
|
||||
MethodHandle ctrMH = RecordSupport.deserializationCtr(desc);
|
||||
|
||||
try {
|
||||
return ctrMH.invoke();
|
||||
return (Object) ctrMH.invokeExact(fieldValues.primValues, fieldValues.objValues);
|
||||
} catch (Exception e) {
|
||||
InvalidObjectException ioe = new InvalidObjectException(e.getMessage());
|
||||
ioe.initCause(e);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue