Skip to content
This repository has been archived by the owner on Aug 27, 2022. It is now read-only.

Commit

Permalink
8248233: Avoid superfluous Class::isRecord invocations during deseria…
Browse files Browse the repository at this point in the history
…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 42d3bad
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 13 deletions.
7 changes: 1 addition & 6 deletions src/java.base/share/classes/java/io/ObjectInputStream.java
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down
12 changes: 5 additions & 7 deletions src/java.base/share/classes/java/io/ObjectStreamClass.java
Expand Up @@ -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;
Expand All @@ -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;
Expand Down

0 comments on commit 42d3bad

Please sign in to comment.