8283715: Update ObjectStreamClass to be final

Reviewed-by: darcy, jpai, mchung, dfuchs
This commit is contained in:
Stuart Marks 2022-03-30 15:50:31 +00:00
parent d9d19e96b1
commit ae57258b46
2 changed files with 9 additions and 8 deletions

View file

@ -80,7 +80,7 @@ import static java.io.ObjectStreamField.*;
* <cite>Java Object Serialization Specification,</cite> Section 4, "Class Descriptors"</a> * <cite>Java Object Serialization Specification,</cite> Section 4, "Class Descriptors"</a>
* @since 1.1 * @since 1.1
*/ */
public class ObjectStreamClass implements Serializable { public final class ObjectStreamClass implements Serializable {
/** serialPersistentFields value indicating no serializable fields */ /** serialPersistentFields value indicating no serializable fields */
public static final ObjectStreamField[] NO_FIELDS = public static final ObjectStreamField[] NO_FIELDS =

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -68,7 +68,6 @@ public class CheckCSMs {
// over time. Do not add any new one to this list. // over time. Do not add any new one to this list.
private static Set<String> KNOWN_NON_FINAL_CSMS = private static Set<String> KNOWN_NON_FINAL_CSMS =
Set.of("java/io/ObjectStreamField#getType ()Ljava/lang/Class;", Set.of("java/io/ObjectStreamField#getType ()Ljava/lang/Class;",
"java/io/ObjectStreamClass#forClass ()Ljava/lang/Class;",
"java/lang/Runtime#load (Ljava/lang/String;)V", "java/lang/Runtime#load (Ljava/lang/String;)V",
"java/lang/Runtime#loadLibrary (Ljava/lang/String;)V", "java/lang/Runtime#loadLibrary (Ljava/lang/String;)V",
"java/lang/Thread#getContextClassLoader ()Ljava/lang/ClassLoader;", "java/lang/Thread#getContextClassLoader ()Ljava/lang/ClassLoader;",
@ -91,11 +90,13 @@ public class CheckCSMs {
CheckCSMs checkCSMs = new CheckCSMs(); CheckCSMs checkCSMs = new CheckCSMs();
Set<String> result = checkCSMs.run(getPlatformClasses()); Set<String> result = checkCSMs.run(getPlatformClasses());
if (!KNOWN_NON_FINAL_CSMS.equals(result)) { if (!KNOWN_NON_FINAL_CSMS.equals(result)) {
Set<String> diff = new HashSet<>(result); Set<String> extras = new HashSet<>(result);
diff.removeAll(KNOWN_NON_FINAL_CSMS); extras.removeAll(KNOWN_NON_FINAL_CSMS);
throw new RuntimeException("Unexpected non-final instance method: " + Set<String> missing = new HashSet<>(KNOWN_NON_FINAL_CSMS);
result.stream().sorted() missing.removeAll(result);
.collect(Collectors.joining("\n", "\n", ""))); throw new RuntimeException("Mismatch in non-final instance methods.\n" +
"Extra methods:\n" + String.join("\n", extras) + "\n" +
"Missing methods:\n" + String.join("\n", missing) + "\n");
} }
// check if all csm methods with a trailing Class parameter are supported // check if all csm methods with a trailing Class parameter are supported