RFR: 8341735: Rewrite the build/AbsPathsInImage.java test to not load the entire file at once

Cesar Soares Lucas cslucas at openjdk.org
Mon Jul 7 18:27:39 UTC 2025


On Fri, 27 Jun 2025 23:29:15 GMT, Daniel Hu <duke at openjdk.org> wrote:

> These changes should prevent entire binary files from being loaded into memory for build/AbsPathsInImage.java test. I chose a default buffer size of 8KB since BufferedInputStream uses that, but open to alternative solutions. GHA passes and test passes on linux x64.

test/jdk/build/AbsPathsInImage.java line 186:

> 184:         byte[] buffer = new byte[8192];
> 185:         List<String> matches = new ArrayList<>();
> 186:         try(InputStream inputStream = Files.newInputStream(file)) {

NIT: space after `try`?

test/jdk/build/AbsPathsInImage.java line 204:

> 202:         ZipEntry zipEntry;
> 203:         int bytesRead;
> 204:         byte[] buffer = new byte[8192];

NIT: would be cleaner if the `8192` were a constant in the test class itself.

test/jdk/build/AbsPathsInImage.java line 208:

> 206:             while ((zipEntry = zipInputStream.getNextEntry()) != null) {
> 207:                 List<String> matches = new ArrayList<>();
> 208:                 while((bytesRead = zipInputStream.read(buffer)) != -1) {

NIT: space after `while`.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/26030#discussion_r2190773742
PR Review Comment: https://git.openjdk.org/jdk/pull/26030#discussion_r2190773440
PR Review Comment: https://git.openjdk.org/jdk/pull/26030#discussion_r2190771622


More information about the build-dev mailing list