Mercurial > hg > release > icedtea7-forest-2.6 > jdk
changeset 9921:c39602abdf2f
8224541: Better mapping of serial ENUMs
Reviewed-by: mschoene, rhalade, robm, rriggs, smarks, andrew
author | bchristi |
---|---|
date | Tue, 21 Jan 2020 10:56:30 -0800 |
parents | ab30e7ec1875 |
children | 1a95d48e5ff1 |
files | src/share/classes/java/io/ObjectInputStream.java src/share/classes/java/io/ObjectStreamClass.java |
diffstat | 2 files changed, 15 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/src/share/classes/java/io/ObjectInputStream.java Tue Apr 07 18:30:25 2020 +0100 +++ b/src/share/classes/java/io/ObjectInputStream.java Tue Jan 21 10:56:30 2020 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -1796,6 +1796,8 @@ break; case TC_REFERENCE: descriptor = (ObjectStreamClass) readHandle(unshared); + // Should only reference initialized class descriptors + descriptor.checkInitialized(); break; case TC_PROXYCLASSDESC: descriptor = readProxyDesc(unshared);
--- a/src/share/classes/java/io/ObjectStreamClass.java Tue Apr 07 18:30:25 2020 +0100 +++ b/src/share/classes/java/io/ObjectStreamClass.java Tue Jan 21 10:56:30 2020 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -864,6 +864,17 @@ } /** + * Throws InvalidClassException if not initialized. + * To be called in cases where an uninitialized class descriptor indicates + * a problem in the serialization stream. + */ + final void checkInitialized() throws InvalidClassException { + if (!initialized) { + throw new InvalidClassException("Class descriptor should be initialized"); + } + } + + /** * Throws an InvalidClassException if object instances referencing this * class descriptor should not be allowed to deserialize. This method does * not apply to deserialization of enum constants.