New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
8271419: Refactor test code for modifying CDS archive contents #4945
Conversation
|
/label add hotspot-runtime |
@yminqi |
Webrevs
|
alignment = wb.metaspaceSharedRegionAlignment(); | ||
// fileHeaderSize may not be available | ||
// fileHeaderSize = (int)alignUpWithPageSize(wb.getOffsetForName("file_header_size")); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should always be available. file_header_size
is a constant value (sizeof(FileMapHeader)
) stored inside cdsoffsets.cpp. It doesn't depend on the contents of the archive file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is same as original code, I will investigate more of this part. Thanks.
if (fc.isOpen()) { | ||
fc.close(); | ||
} | ||
System.out.println(" offset_jvm_ident " + CDSArchiveUtils.offsetJvmIdent); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the modifyXXX functions should also be moved to CDSArchiveUtils so that they can be called by other test cases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let me double check this part.
if (fc.isOpen()) { | ||
fc.close(); | ||
} | ||
byte[] buf = { (byte)(value >> 24), (byte)(value >> 16), (byte)(value >> 8), (byte)(value)}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this the same as the original code which does a ByteBuffer.wrap()
?
If so, why changing it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I make CDSARchiveUtils take byte[] as input, not ByteBuffer. Here just simply convert int to byte[].
WhiteBox box = WhiteBox.getWhiteBox(); | ||
CDSArchiveUtils.initialize(box); // all offsets available |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The util class is just a utility class, I have no idea if we can do this, let me try --- it might work.
@@ -89,261 +62,21 @@ | |||
public static int num_regions = shared_region_name.length; | |||
public static String[] matchMessages = { | |||
"Unable to use shared archive", | |||
"The shared archive file has a bad magic number", | |||
"Unable to map shared spaces", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are these new errors needed? Did you change any behavior of the tests?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for mentioning this. There is an issue to use FileChannel:
outputChannel.transferFrom(inputChannel, 0, offset);
+ outputChannel.position(offset); // <---- need explicitly positioned or the following write to overwrite from offset 0.
outputChannel.write(ByteBuffer.wrap(bytes));
outputChannel.transferFrom(inputChannel, offset + bytes.length, orgSize - bytes.length);
The added lines should be removed.
public static int num_regions = shared_region_name.length; | ||
|
||
public static void initialize() throws Exception { | ||
WhiteBox wb = WhiteBox.getWhiteBox(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method can be changed to a static { ....}
block, so that you don't need to explicitly call CDSArchiveUtils.initialize()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will move to static block.
@@ -34,42 +34,15 @@ | |||
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI SharedArchiveConsistency on | |||
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI SharedArchiveConsistency auto | |||
*/ | |||
import jdk.test.lib.cds.CDSArchiveUtils; | |||
import jdk.test.lib.process.OutputAnalyzer; | |||
import jdk.test.lib.Utils; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The above import of Utils is no longer needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one is new added util class, it is needed here. Do you think it is CDSTestUtils ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was referring to import jdk.test.lib.Utils;
. It was for Utils.getRandomInstance();
and the code has been moved to the new class CDSArchiveUtils
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, thanks. Will remove.
import java.util.Random; | ||
import sun.hotspot.WhiteBox; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The import of Random is no longer needed.
I think the import of WhiteBox can also be removed since it is not used in this file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, they no longer needed. thanks.
@yminqi This change now passes all automated pre-integration checks. After integration, the commit message for the final commit will be:
You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 28 new commits pushed to the
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.
|
@calvinccheung @iklam Thanks for review! |
Going to push as commit 84f0231.
Your commit was automatically rebased without conflicts. |
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
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/4945/head:pull/4945
$ git checkout pull/4945
Update a local copy of the PR:
$ git checkout pull/4945
$ git pull https://git.openjdk.java.net/jdk pull/4945/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 4945
View PR using the GUI difftool:
$ git pr show -t 4945
Using diff file
Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/4945.diff