Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
8248233: Avoid superfluous Class::isRecord invocations during deseria…
…lization

Co-authored-by: Peter Levart <peter.levart@gmail.com>
Reviewed-by: redestad, plevart
  • Loading branch information
ChrisHegarty and plevart committed Jun 25, 2020
1 parent 34755c3 commit 42d3bad0b1c596b845fbfbd16be00ca44b967d30
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 13 deletions.
@@ -2139,11 +2139,6 @@ private Enum<?> readEnum(boolean unshared) throws IOException {
return result;
}

@SuppressWarnings("preview")
private static boolean isRecord(Class<?> cls) {
return cls.isRecord();
}

/**
* Reads and returns "ordinary" (i.e., not a String, Class,
* ObjectStreamClass, array, or enum constant) object, or null if object's
@@ -2182,7 +2177,7 @@ private Object readOrdinaryObject(boolean unshared)
handles.markException(passHandle, resolveEx);
}

final boolean isRecord = cl != null && isRecord(cl);
final boolean isRecord = desc.isRecord();
if (isRecord) {
assert obj == null;
obj = readRecord(desc);
@@ -747,13 +747,6 @@ void initNonProxy(ObjectStreamClass model,
}

this.cl = cl;
if (cl != null) {
this.isRecord = isRecord(cl);
// canonical record constructor is shared
this.canonicalCtr = osc.canonicalCtr;
// cache of deserialization constructors is shared
this.deserializationCtrs = osc.deserializationCtrs;
}
this.resolveEx = resolveEx;
this.superDesc = superDesc;
name = model.name;
@@ -770,6 +763,11 @@ void initNonProxy(ObjectStreamClass model,

if (osc != null) {
localDesc = osc;
isRecord = localDesc.isRecord;
// canonical record constructor is shared
canonicalCtr = localDesc.canonicalCtr;
// cache of deserialization constructors is shared
deserializationCtrs = localDesc.deserializationCtrs;
writeObjectMethod = localDesc.writeObjectMethod;
readObjectMethod = localDesc.readObjectMethod;
readObjectNoDataMethod = localDesc.readObjectNoDataMethod;

0 comments on commit 42d3bad

Please sign in to comment.