Skip to content
Permalink
Browse files
8283715: Update ObjectStreamClass to be final
Reviewed-by: darcy, jpai, mchung, dfuchs
  • Loading branch information
Stuart Marks committed Mar 30, 2022
1 parent d9d19e9 commit ae57258b46b8b6953148cd8cf71faf75eef118da
Showing 2 changed files with 9 additions and 8 deletions.
@@ -80,7 +80,7 @@
* <cite>Java Object Serialization Specification,</cite> Section 4, "Class Descriptors"</a>
* @since 1.1
*/
public class ObjectStreamClass implements Serializable {
public final class ObjectStreamClass implements Serializable {

/** serialPersistentFields value indicating no serializable fields */
public static final ObjectStreamField[] NO_FIELDS =
@@ -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.
*
* 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.
private static Set<String> KNOWN_NON_FINAL_CSMS =
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#loadLibrary (Ljava/lang/String;)V",
"java/lang/Thread#getContextClassLoader ()Ljava/lang/ClassLoader;",
@@ -91,11 +90,13 @@ public static void main(String[] args) throws Exception {
CheckCSMs checkCSMs = new CheckCSMs();
Set<String> result = checkCSMs.run(getPlatformClasses());
if (!KNOWN_NON_FINAL_CSMS.equals(result)) {
Set<String> diff = new HashSet<>(result);
diff.removeAll(KNOWN_NON_FINAL_CSMS);
throw new RuntimeException("Unexpected non-final instance method: " +
result.stream().sorted()
.collect(Collectors.joining("\n", "\n", "")));
Set<String> extras = new HashSet<>(result);
extras.removeAll(KNOWN_NON_FINAL_CSMS);
Set<String> missing = new HashSet<>(KNOWN_NON_FINAL_CSMS);
missing.removeAll(result);
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

1 comment on commit ae57258

@openjdk-notifier
Copy link

@openjdk-notifier openjdk-notifier bot commented on ae57258 Mar 30, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.