diff --git a/test/hotspot/jtreg/compiler/c2/Test8202414.java b/test/hotspot/jtreg/compiler/c2/Test8202414.java index e05b8dcb9db..ef54b0f3632 100644 --- a/test/hotspot/jtreg/compiler/c2/Test8202414.java +++ b/test/hotspot/jtreg/compiler/c2/Test8202414.java @@ -25,6 +25,8 @@ * @test * @bug 8202414 * @summary Unsafe write after primitive array creation may result in array length change + * @modules java.base/jdk.internal.misc + * @library /test/lib * @run main/othervm compiler.c2.Test8202414 */ @@ -34,10 +36,18 @@ import sun.misc.Unsafe; import java.lang.reflect.Field; import java.security.AccessController; import java.security.PrivilegedAction; +import jtreg.SkippedException; public class Test8202414 { public static void main(String[] args) { + // Some CPUs (for example, ARM) does not support unaligned + // memory accesses. This test may cause JVM crash due to + // alignment check failure on such CPUs. + if (!jdk.internal.misc.Unsafe.getUnsafe().unalignedAccess()) { + throw new SkippedException( + "Platform is missing unaligned memory accesses support."); + } System.err.close(); int count = 0; while (count++ < 120000) { diff --git a/test/hotspot/jtreg/compiler/unsafe/JdkInternalMiscUnsafeUnalignedAccess.java b/test/hotspot/jtreg/compiler/unsafe/JdkInternalMiscUnsafeUnalignedAccess.java index 53ccfd7c339..2b09b0c5a31 100644 --- a/test/hotspot/jtreg/compiler/unsafe/JdkInternalMiscUnsafeUnalignedAccess.java +++ b/test/hotspot/jtreg/compiler/unsafe/JdkInternalMiscUnsafeUnalignedAccess.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 SAP SE. All rights reserved. + * Copyright (c) 2016, 2020 SAP SE. 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 @@ -26,7 +26,7 @@ * @bug 8158260 * @summary Test unaligned Unsafe accesses * @modules java.base/jdk.internal.misc:+open - * + * @library /test/lib * @run main/othervm -Diters=20000 -XX:-UseOnStackReplacement -XX:-BackgroundCompilation * compiler.unsafe.JdkInternalMiscUnsafeUnalignedAccess * @author volker.simonis@gmail.com @@ -38,6 +38,7 @@ import jdk.internal.misc.Unsafe; import java.lang.reflect.Field; import java.nio.ByteOrder; +import jtreg.SkippedException; public class JdkInternalMiscUnsafeUnalignedAccess { static final int ITERS = Integer.getInteger("iters", 20_000); @@ -131,8 +132,7 @@ public class JdkInternalMiscUnsafeUnalignedAccess { public static void main(String[] args) throws Exception { if (!UNSAFE.unalignedAccess()) { - System.out.println("Platform is not supporting unaligned access - nothing to test."); - return; + throw new SkippedException("Platform is not supporting unaligned access - nothing to test."); } memory = UNSAFE.allocateMemory(SIZE);