RFR: 8271419: Refactor test code for modifying CDS archive contents

Calvin Cheung ccheung at openjdk.java.net
Fri Jul 30 21:07:33 UTC 2021


On Fri, 30 Jul 2021 15:33:14 GMT, Yumin Qi <minqi at openjdk.org> wrote:

> The code for modifying CDS archive content could be used by other tests so the common code is refactored into a util class CDSArchiveUtils.
> 
> Tests: tier1,tier4
> 
> Thanks
> Yumin

I have 2 comments.

test/hotspot/jtreg/runtime/cds/appcds/SharedArchiveConsistency.java line 159:

> 157:     public static void modifyHeaderIntField(File jsaFile, long offset, int value) throws Exception {
> 158:         System.out.println("    offset " + offset);
> 159:         byte[] buf = { (byte)(value >> 24), (byte)(value >> 16), (byte)(value >> 8), (byte)(value)};

Isn't this the same as the original code which does a `ByteBuffer.wrap()`?
If so, why changing it.

test/hotspot/jtreg/runtime/cds/appcds/SharedArchiveConsistency.java line 214:

> 212:         shareAuto = args[0].equals("auto");
> 213:         WhiteBox box = WhiteBox.getWhiteBox();
> 214:         CDSArchiveUtils.initialize(box);  // all offsets available

After this refactoring, I don't think WhiteBox is required in this file.
So I think CDSArchiveUtils could create a WhiteBox instance instead of requiring the caller to supply one.

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

PR: https://git.openjdk.java.net/jdk/pull/4945


More information about the hotspot-runtime-dev mailing list