Skip to content

Commit

Permalink
8327180: Failed: java/io/ObjectStreamClass/ObjectStreamClassCaching.j…
Browse files Browse the repository at this point in the history
…ava#G1

Reviewed-by: iris, stefank
  • Loading branch information
Roger Riggs committed Mar 18, 2024
1 parent 569b05a commit 85fc47c
Showing 1 changed file with 8 additions and 32 deletions.
40 changes: 8 additions & 32 deletions test/jdk/java/io/ObjectStreamClass/ObjectStreamClassCaching.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -49,8 +49,12 @@
*/

/*
* Disabled for ZGC Generational.
* TODO: Find correct appropriate solution to the flakiness of this test.
* @test id=ZGenerational
* @requires vm.gc.ZGenerational
* @bug 8277072 8327180
* @library /test/lib/
* @summary ObjectStreamClass caches keep ClassLoaders alive (ZGC)
* @run testng/othervm -Xmx64m -XX:+UseZGC -XX:+ZGenerational ObjectStreamClassCaching
*/

/*
Expand All @@ -65,41 +69,13 @@
/*
* @test id=Serial
* @requires vm.gc.Serial
* @bug 8277072
* @bug 8277072 8327180
* @library /test/lib/
* @summary ObjectStreamClass caches keep ClassLoaders alive (Serial GC)
* @run testng/othervm -Xmx64m -XX:+UseSerialGC ObjectStreamClassCaching
*/
public class ObjectStreamClassCaching {

/**
* Test methods execute in same VM and are ordered by name.
* We test effectiveness 1st which is sensitive to previous allocations when ZGC is used.
*/
@Test
public void test1CacheEffectiveness() throws Exception {
var list = new ArrayList<>();
var ref1 = lookupObjectStreamClass(TestClass1.class);
var ref2 = newWeakRef();
boolean oome = false;
try {
while (!ref2.refersTo(null)) {
list.add(new byte[1024 * 1024 * 1]); // 1 MiB chunks
System.out.println("1MiB allocated...");
Thread.sleep(5L);
}
} catch (OutOfMemoryError e) {
// release
list = null;
oome = true;
}
assertFalse(oome, "WeakReference was not cleared although memory was pressed hard");
assertFalse(ref1.refersTo(null),
"Cache lost entry together with WeakReference being cleared although memory was not under pressure");
System.gc();
Thread.sleep(100L);
}

@Test
public void test2CacheReleaseUnderMemoryPressure() throws Exception {
var list = new ArrayList<>();
Expand Down

5 comments on commit 85fc47c

@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 85fc47c Apr 19, 2024

Choose a reason for hiding this comment

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

/backport jdk12u-dev

@openjdk
Copy link

@openjdk openjdk bot commented on 85fc47c Apr 19, 2024

Choose a reason for hiding this comment

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

@GoeLin The target repository jdk12u-dev is not a valid target for backports.
List of valid target repositories: openjdk/jdk, openjdk/jdk11u, openjdk/jdk11u-dev, openjdk/jdk17u, openjdk/jdk17u-dev, openjdk/jdk21u, openjdk/jdk21u-dev, openjdk/jdk22u, openjdk/jdk7u, openjdk/jdk8u, openjdk/jdk8u-dev, openjdk/jfx, openjdk/jfx17u, openjdk/jfx21u, openjdk/jfx22u, openjdk/lilliput-jdk17u, openjdk/lilliput-jdk21u, openjdk/shenandoah-jdk21u, openjdk/shenandoah-jdk8u.
Supplying the organization/group prefix is optional.

@GoeLin
Copy link
Member

@GoeLin GoeLin commented on 85fc47c Apr 19, 2024

Choose a reason for hiding this comment

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

/backport jdk21u-dev

@openjdk
Copy link

@openjdk openjdk bot commented on 85fc47c Apr 19, 2024

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 backport-GoeLin-85fc47c8 in my personal fork of openjdk/jdk21u-dev. To create a pull request with this backport targeting openjdk/jdk21u-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 85fc47c8 from the openjdk/jdk repository.

The commit being backported was authored by Roger Riggs on 18 Mar 2024 and was reviewed by Iris Clark and Stefan Karlsson.

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/jdk21u-dev:

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

Please sign in to comment.