RFR (XS) 8241462: StripNativeDebugSymbols jlink plugin allocates huge arrays

Aleksey Shipilev shade at redhat.com
Mon Mar 23 19:22:34 UTC 2020


RFE:
  https://bugs.openjdk.java.net/browse/JDK-8241462

In some of my testing pipelines that deal with huge .so-s due to specific build configuration, tests
that use the StripNativeDebugSymbols plugin fail with OOME. It can be fixed by using the method that
copies the InputStream straight to destination file without instantiating the huge array. The only
wrinkle is that we need to close the InputStream after we are done.

diff -r c456587e7ef4
src/jdk.jlink/linux/classes/jdk/tools/jlink/internal/plugins/StripNativeDebugSymbolsPlugin.java
---
a/src/jdk.jlink/linux/classes/jdk/tools/jlink/internal/plugins/StripNativeDebugSymbolsPlugin.java
Mon Mar 23 19:14:01 2020 +0100
+++
b/src/jdk.jlink/linux/classes/jdk/tools/jlink/internal/plugins/StripNativeDebugSymbolsPlugin.java
Mon Mar 23 20:13:15 2020 +0100
@@ -1,4 +1,4 @@
 /*
- * Copyright (c) 2019, Red Hat, Inc.
+ * Copyright (c) 2019, 2020, Red Hat, Inc.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
@@ -25,4 +25,5 @@
 package jdk.tools.jlink.internal.plugins;

+import java.io.InputStream;
 import java.io.IOException;
 import java.lang.ProcessBuilder.Redirect;
@@ -314,5 +315,8 @@
                 String relativeDbgFileName = relativeFileName + "." + debugExt;

-                Files.write(resourceFileBinary, resource.contentBytes());
+                try (InputStream in = resource.content()) {
+                    Files.copy(in, resourceFileBinary);
+                }
+
                 Path resourceFileDebugSymbols;
                 if (includeDebug) {


Testing: tools/jlink, tools/jpackage, jdk-submit (running)

-- 
Thanks,
-Aleksey



More information about the jigsaw-dev mailing list