From e01475fc1dd04c0c7b4ef25c1bed308bd24b0b98 Mon Sep 17 00:00:00 2001 From: Benshuai5D Date: Fri, 26 Jul 2024 16:32:35 +0800 Subject: [PATCH] The fast serialization function of sun.rmi.transport.ConnectionOutputStream is disabled by default --- ...zation-function-of-sun.rmi.transport.patch | 88 +++++++++++++++++++ openjdk-1.8.0.spec | 7 +- 2 files changed, 94 insertions(+), 1 deletion(-) create mode 100644 The-fast-serialization-function-of-sun.rmi.transport.patch diff --git a/The-fast-serialization-function-of-sun.rmi.transport.patch b/The-fast-serialization-function-of-sun.rmi.transport.patch new file mode 100644 index 0000000..b0417a0 --- /dev/null +++ b/The-fast-serialization-function-of-sun.rmi.transport.patch @@ -0,0 +1,88 @@ +Subject: [PATCH][Huawei] The fast serialization function of + sun.rmi.transport.ConnectionOutputStream is disabled by default + +--- + .../classes/java/io/ObjectOutputStream.java | 23 ++++++++++++++++--- + .../sun/rmi/server/MarshalOutputStream.java | 10 ++++++++ + 2 files changed, 30 insertions(+), 3 deletions(-) + +diff --git a/jdk/src/share/classes/java/io/ObjectOutputStream.java b/jdk/src/share/classes/java/io/ObjectOutputStream.java +index 328f47589..78dc3c5b2 100644 +--- a/jdk/src/share/classes/java/io/ObjectOutputStream.java ++++ b/jdk/src/share/classes/java/io/ObjectOutputStream.java +@@ -240,7 +240,7 @@ public class ObjectOutputStream + * Value of "UseFastSerializer" property. The fastSerializer is turned + * on when it is true. + */ +- private final boolean useFastSerializer = UNSAFE.getUseFastSerializer(); ++ private boolean useFastSerializer = UNSAFE.getUseFastSerializer(); + + /** + * value of "printFastSerializer" property, +@@ -254,7 +254,22 @@ public class ObjectOutputStream + * Magic number that is written to the stream header when using fastserilizer. + */ + private static final short STREAM_MAGIC_FAST = (short)0xdeca; ++ ++ /** ++ * The default value is true. If you want to disable the fast serialization function, please set it to false. ++ */ ++ protected boolean enableFastSerializerClass(){ ++ return true; ++ } + ++ /** ++ * Disable fast serialization functionality. ++ */ ++ private void disableFastSerializerStatusByClass() { ++ if ( this.useFastSerializer && !enableFastSerializerClass()){ ++ this.useFastSerializer = false; ++ } ++ } + /** + * Creates an ObjectOutputStream that writes to the specified OutputStream. + * This constructor writes the serialization stream header to the +@@ -279,7 +294,8 @@ public class ObjectOutputStream + * @see ObjectInputStream#ObjectInputStream(InputStream) + */ + public ObjectOutputStream(OutputStream out) throws IOException { +- verifySubclass(); ++ disableFastSerializerStatusByClass(); ++ verifySubclass(); + bout = new BlockDataOutputStream(out); + handles = new HandleTable(10, (float) 3.00); + subs = new ReplaceTable(10, (float) 3.00); +@@ -311,7 +327,8 @@ public class ObjectOutputStream + * @see java.io.SerializablePermission + */ + protected ObjectOutputStream() throws IOException, SecurityException { +- SecurityManager sm = System.getSecurityManager(); ++ disableFastSerializerStatusByClass(); ++ SecurityManager sm = System.getSecurityManager(); + if (sm != null) { + sm.checkPermission(SUBCLASS_IMPLEMENTATION_PERMISSION); + } +diff --git a/jdk/src/share/classes/sun/rmi/server/MarshalOutputStream.java b/jdk/src/share/classes/sun/rmi/server/MarshalOutputStream.java +index 699f11072..e113441f8 100644 +--- a/jdk/src/share/classes/sun/rmi/server/MarshalOutputStream.java ++++ b/jdk/src/share/classes/sun/rmi/server/MarshalOutputStream.java +@@ -48,6 +48,16 @@ import sun.rmi.transport.Target; + */ + public class MarshalOutputStream extends ObjectOutputStream + { ++ /** ++ * value of "enableRMIFastSerializerClass" property ++ */ ++ private static final boolean enableRMIFastSerializerClass = java.security.AccessController.doPrivileged( new sun.security.action.GetBooleanAction( "enableRMIFastSerializerClass")).booleanValue(); ++ ++ @Override ++ protected boolean enableFastSerializerClass() { ++ return this.enableRMIFastSerializerClass; ++ } ++ + /** + * Creates a marshal output stream with protocol version 1. + */ +-- +2.44.0 + diff --git a/openjdk-1.8.0.spec b/openjdk-1.8.0.spec index 9298a02..26ebd5e 100644 --- a/openjdk-1.8.0.spec +++ b/openjdk-1.8.0.spec @@ -943,7 +943,7 @@ Provides: java-%{javaver}-%{origin}-accessibility%{?1} = %{epoch}:%{version}-%{r Name: java-%{javaver}-%{origin} Version: %{javaver}.%{updatever}.%{buildver} -Release: 0 +Release: 1 # java-1.5.0-ibm from jpackage.org set Epoch to 1 for unknown reasons # and this change was brought into RHEL-4. java-1.5.0-ibm packages # also included the epoch in their virtual provides. This created a @@ -1340,6 +1340,7 @@ Patch439: Backport-8151845-Comment-in-globals.hpp-for-MetaspaceSize-is-.patch Patch440: Backport-8210706-G1-may-deadlock-when-starting-a-concurrent-c.patch Patch441: Backport-8318889-Backport-Important-Fixed-Issues-in-Later-Ver.patch Patch442: Huawei-Keep-objects-when-remove-unshareable-info.patch +Patch443: The-fast-serialization-function-of-sun.rmi.transport.patch ############################################# # # Upstreamable patches @@ -1995,6 +1996,7 @@ pushd %{top_level_dir_name} %patch440 -p1 %patch441 -p1 %patch442 -p1 +%patch443 -p1 %endif %ifarch loongarch64 @@ -2654,6 +2656,9 @@ cjc.mainProgram(args) -- the returns from copy_jdk_configs.lua should not affect %endif %changelog +* Fri Tue 26 2024 benshuai5D -1:1.8.0.422-b05.1 +- Add The-fast-serialization-function-of-sun.rmi.transport.patch + * Thu Tue 16 2024 Autistic_boyya -1:1.8.0.422-b05.rolling - modified 8014628-Support-AES-Encryption-with-HMAC-SHA2-for-Ke.patch - modified 8136577_Make_AbortVMOnException_available_in_product_builds.patch -- Gitee