Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions test/hotspot/jtreg/compiler/c2/Test8202414.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/

Expand All @@ -34,10 +36,18 @@
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(
Copy link
Member

Choose a reason for hiding this comment

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

nit: I don't think we need a line break here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Previously, all lines within this file were no longer than 80 chars, so I decided to follow the same restriction.

"Platform is missing unaligned memory accesses support.");
}
System.err.close();
int count = 0;
while (count++ < 120000) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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 [email protected]
Expand All @@ -38,6 +38,7 @@

import java.lang.reflect.Field;
import java.nio.ByteOrder;
import jtreg.SkippedException;

public class JdkInternalMiscUnsafeUnalignedAccess {
static final int ITERS = Integer.getInteger("iters", 20_000);
Expand Down Expand Up @@ -131,8 +132,7 @@ static void putLong_17(long l) {
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);
Expand Down