Skip to content

Commit

Permalink
8299075: TestStringDeduplicationInterned.java fails because extra ded…
Browse files Browse the repository at this point in the history
…uplication

Reviewed-by: kbarrett, tschatzl
  • Loading branch information
stefank committed May 16, 2023
1 parent 9d5bab1 commit 682359c
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions test/hotspot/jtreg/gc/stringdedup/TestStringDeduplicationTools.java
Expand Up @@ -348,9 +348,8 @@ public static void main(String[] args) {
// Create duplicate of baseString
StringBuilder sb1 = new StringBuilder(baseString);
String dupString1 = sb1.toString();
if (getValue(dupString1) == getValue(baseString)) {
throw new RuntimeException("Values should not match");
}

checkNotDeduplicated(getValue(dupString1), getValue(baseString));

// Force baseString to be inspected for deduplication
// and be inserted into the deduplication hashtable.
Expand All @@ -363,9 +362,8 @@ public static void main(String[] args) {
// Create a new duplicate of baseString
StringBuilder sb2 = new StringBuilder(baseString);
String dupString2 = sb2.toString();
if (getValue(dupString2) == getValue(baseString)) {
throw new RuntimeException("Values should not match");
}

checkNotDeduplicated(getValue(dupString2), getValue(baseString));

// Intern the new duplicate
Object beforeInternedValue = getValue(dupString2);
Expand All @@ -384,16 +382,13 @@ public static void main(String[] args) {
// Check original value of interned string, to make sure
// deduplication happened on the interned string and not
// on the base string
if (beforeInternedValue == getValue(baseString)) {
throw new RuntimeException("Values should not match");
}
checkNotDeduplicated(beforeInternedValue, getValue(baseString));

// Create duplicate of baseString
StringBuilder sb3 = new StringBuilder(baseString);
String dupString3 = sb3.toString();
if (getValue(dupString3) == getValue(baseString)) {
throw new RuntimeException("Values should not match");
}

checkNotDeduplicated(dupString3, getValue(baseString));

forceDeduplication(ageThreshold, FullGC);

Expand All @@ -410,6 +405,15 @@ public static void main(String[] args) {
System.out.println("End: InternedTest");
}

private static void checkNotDeduplicated(Object value1, Object value2) {
// Note that the following check is invalid since a GC
// can run and actually deduplicate the strings.
//
// if (value1 == value2) {
// throw new RuntimeException("Values should not match");
// }
}

public static OutputAnalyzer run() throws Exception {
return runTest("-Xlog:gc=debug,stringdedup*=debug",
"-XX:+UseStringDeduplication",
Expand Down

3 comments on commit 682359c

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@GoeLin
Copy link
Member

@GoeLin GoeLin commented on 682359c Oct 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/backport jdk17u-dev

@openjdk
Copy link

@openjdk openjdk bot commented on 682359c Oct 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@GoeLin the backport was successfully created on the branch GoeLin-backport-682359cb in my personal fork of openjdk/jdk17u-dev. To create a pull request with this backport targeting openjdk/jdk17u-dev:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit 682359cb from the openjdk/jdk repository.

The commit being backported was authored by Stefan Karlsson on 16 May 2023 and was reviewed by Kim Barrett and Thomas Schatzl.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk17u-dev:

$ git fetch https://github.com/openjdk-bots/jdk17u-dev.git GoeLin-backport-682359cb:GoeLin-backport-682359cb
$ git checkout GoeLin-backport-682359cb
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk17u-dev.git GoeLin-backport-682359cb

Please sign in to comment.