RFR: 8341735: Rewrite the build/AbsPathsInImage.java test to not load the entire file at once [v6]
Daniel Hu
duke at openjdk.org
Wed Oct 22 17:56:15 UTC 2025
On Tue, 14 Oct 2025 21:53:41 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.
>
> Daniel Hu has updated the pull request incrementally with two additional commits since the last revision:
>
> - fix incorrect use of inputstream
> - remove extraneous variables/imports
test/jdk/build/AbsPathsInImage.java line 313:
> 311: }
> 312: System.out.println();
> 313: }
I wanted to keep the debug output as close to the original as possible. But the original method backtracks to a non-ascii value, and that gets really complicated with the new buffered solution as probably a 2nd buffer would need to be kept while not being able to guarantee a static space complexity requirement (as who knows how much bytes are between each pair of ascii bytes). Moreover, when the test passes, a 2nd buffer kept for debug output isn't even used, meaning a pointless space penalty for the common case.
Instead, I added a secondary function that simply re-scans the file when the test fails. That does mean the test might take twice as long during failure (and all the associated additional space requirements), but I think that's an acceptable tradeoff, as vast majority of runs won't receive this penalty.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/26030#discussion_r2452876592
More information about the build-dev
mailing list