< prev index next >
src/java.logging/share/classes/java/util/logging/Level.java
Print this page
@@ -1,7 +1,7 @@
/*
- * 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
@@ -23,10 +23,11 @@
* questions.
*/
package java.util.logging;
+import java.io.Serial;
import java.lang.ref.Reference;
import java.lang.ref.ReferenceQueue;
import java.lang.ref.WeakReference;
import java.security.AccessController;
import java.security.PrivilegedAction;
@@ -430,15 +431,29 @@
*/
public final int intValue() {
return value;
}
+ @Serial
private static final long serialVersionUID = -8176160795706313070L;
+ /**
+ * 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.
- private Object readResolve() {
Optional<Level> level = KnownLevel.matches(this);
if (level.isPresent()) {
return level.get();
}
// Woops. Whoever sent us this object knows
< prev index next >