mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-26 14:24:46 +02:00
8331224: ClassCastException in ObjectInputStream hides ClassNotFoundException
Reviewed-by: smarks
This commit is contained in:
parent
42e3c842ae
commit
8291c94bcd
2 changed files with 199 additions and 4 deletions
|
@ -2358,7 +2358,13 @@ public class ObjectInputStream
|
|||
*/
|
||||
}
|
||||
|
||||
/** Reads a record. */
|
||||
/**
|
||||
* Reads and returns a record.
|
||||
* If an exception is marked for any of the fields, the dependency
|
||||
* mechanism marks the record as having an exception.
|
||||
* Null is returned from readRecord and later the exception is thrown at
|
||||
* the exit of {@link #readObject(Class)}.
|
||||
**/
|
||||
private Object readRecord(ObjectStreamClass desc) throws IOException {
|
||||
ObjectStreamClass.ClassDataSlot[] slots = desc.getClassDataLayout();
|
||||
if (slots.length != 1) {
|
||||
|
@ -2371,6 +2377,9 @@ public class ObjectInputStream
|
|||
}
|
||||
|
||||
FieldValues fieldValues = new FieldValues(desc, true);
|
||||
if (handles.lookupException(passHandle) != null) {
|
||||
return null; // slot marked with exception, don't create record
|
||||
}
|
||||
|
||||
// get canonical record constructor adapted to take two arguments:
|
||||
// - byte[] primValues
|
||||
|
@ -2464,8 +2473,11 @@ public class ObjectInputStream
|
|||
if (slotValues != null) {
|
||||
slotValues[i] = values;
|
||||
} else if (obj != null) {
|
||||
values.defaultCheckFieldValues(obj);
|
||||
values.defaultSetFieldValues(obj);
|
||||
if (handles.lookupException(passHandle) == null) {
|
||||
// passHandle NOT marked with an exception; set field values
|
||||
values.defaultCheckFieldValues(obj);
|
||||
values.defaultSetFieldValues(obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2484,7 +2496,8 @@ public class ObjectInputStream
|
|||
}
|
||||
}
|
||||
|
||||
if (obj != null && slotValues != null) {
|
||||
if (obj != null && slotValues != null && handles.lookupException(passHandle) == null) {
|
||||
// passHandle NOT marked with an exception
|
||||
// Check that the non-primitive types are assignable for all slots
|
||||
// before assigning.
|
||||
for (int i = 0; i < slots.length; i++) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue