Skip to content

Commit

Permalink
JDK-8333144
Browse files Browse the repository at this point in the history
  • Loading branch information
MBaesken committed Jun 26, 2024
1 parent b2ac725 commit 35163ff
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
13 changes: 11 additions & 2 deletions src/hotspot/share/prims/whitebox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,15 @@ WB_ENTRY(void, WB_PrintHeapSizes(JNIEnv* env, jobject o)) {
}
WB_END

WB_ENTRY(jboolean, WB_isUbsanEnabled(JNIEnv* env, jobject o)) {
#if defined(UNDEFINED_BEHAVIOR_SANITIZER)
return true;
#else
return false;
#endif
}
WB_END

WB_ENTRY(void, WB_ReadFromNoaccessArea(JNIEnv* env, jobject o))
size_t granularity = os::vm_allocation_granularity();
ReservedHeapSpace rhs(100 * granularity, granularity, os::vm_page_size());
Expand Down Expand Up @@ -2684,8 +2693,8 @@ static JNINativeMethod methods[] = {
(void*)&WB_AddToBootstrapClassLoaderSearch},
{CC"addToSystemClassLoaderSearch0", CC"(Ljava/lang/String;)V",
(void*)&WB_AddToSystemClassLoaderSearch},
{CC"getCompressedOopsMaxHeapSize", CC"()J",
(void*)&WB_GetCompressedOopsMaxHeapSize},
{CC"getCompressedOopsMaxHeapSize", CC"()J", (void*)&WB_GetCompressedOopsMaxHeapSize},
{CC"isUbsanEnabled", CC"()Z", (void*)&WB_isUbsanEnabled},
{CC"printHeapSizes", CC"()V", (void*)&WB_PrintHeapSizes },
{CC"readFromNoaccessArea",CC"()V", (void*)&WB_ReadFromNoaccessArea},
{CC"stressVirtualSpaceResize",CC"(JJJ)I", (void*)&WB_StressVirtualSpaceResize},
Expand Down
13 changes: 11 additions & 2 deletions test/hotspot/jtreg/containers/docker/DockerBasicTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,29 @@
* @modules java.base/jdk.internal.misc
* java.management
* jdk.jartool/sun.tools.jar
* @build HelloDocker
* @run driver DockerBasicTest
* @build HelloDocker jdk.test.whitebox.WhiteBox
*
* @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI DockerBasicTest
*/
import jdk.test.lib.containers.docker.Common;
import jdk.test.lib.containers.docker.DockerRunOptions;
import jdk.test.lib.containers.docker.DockerTestUtils;
import jdk.test.lib.Platform;
import jdk.test.lib.Utils;
import jdk.test.whitebox.WhiteBox;


public class DockerBasicTest {
private static final String imageNameAndTag = Common.imageName("basic");

public static void main(String[] args) throws Exception {
WhiteBox wb = WhiteBox.getWhiteBox();
if (wb.isUbsanEnabled()) {
System.out.println("ubsan is enabled, avoid docker tests");
return;
}

if (!DockerTestUtils.canTestDocker()) {
return;
}
Expand Down
2 changes: 2 additions & 0 deletions test/lib/jdk/test/whitebox/WhiteBox.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ public synchronized static WhiteBox getWhiteBox() {
// Arguments
public native void printHeapSizes();

public native boolean isUbsanEnabled();

// Memory
private native long getObjectAddress0(Object o);
public long getObjectAddress(Object o) {
Expand Down

0 comments on commit 35163ff

Please sign in to comment.