--- old/src/java.logging/share/classes/java/util/logging/Level.java 2020-08-13 11:48:45.000000000 +0100 +++ new/src/java.logging/share/classes/java/util/logging/Level.java 2020-08-13 11:48:45.000000000 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -25,6 +25,7 @@ package java.util.logging; +import java.io.Serial; import java.lang.ref.Reference; import java.lang.ref.ReferenceQueue; import java.lang.ref.WeakReference; @@ -432,11 +433,25 @@ return value; } + @Serial private static final long serialVersionUID = -8176160795706313070L; - // Serialization magic to prevent "doppelgangers". - // This is a performance optimization. + /** + * This method prevents creating two different instances of + * {@code Level} with the same characteristics. + * If a matching level is found in the local system that corresponds + * to the deserialized object, the deserialized object is replaced + * by the existing instance. Otherwise, a new instance of {@code Level} + * is created and substituted to the deserialized object. + * The returned {@code Level} instance will have the same {@code name}, + * {@code value}, and {@code resourceBundleName} as the deserialized + * object, but no further guarantee is made. + * @return A {@code Level} instance with equivalent characteristics. + */ + @Serial private Object readResolve() { + // Serialization magic to prevent "doppelgangers". + // This is a performance optimization. Optional level = KnownLevel.matches(this); if (level.isPresent()) { return level.get();