Path: blob/master/test/hotspot/jtreg/compiler/arraycopy/stress/StressBooleanArrayCopy.java
64507 views
/*1* Copyright (c) 2021, Red Hat, Inc. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223package compiler.arraycopy.stress;2425import java.util.Arrays;26import java.util.Random;27import jdk.test.lib.Utils;2829public class StressBooleanArrayCopy extends AbstractStressArrayCopy {3031private static final boolean[] orig = new boolean[MAX_SIZE];32private static final boolean[] test = new boolean[MAX_SIZE];3334protected void testWith(int size, int l, int r, int len) {35// Seed the test from the original36System.arraycopy(orig, 0, test, 0, size);3738// Check the seed is correct39{40int m = Arrays.mismatch(test, 0, size,41orig, 0, size);42if (m != -1) {43throwSeedError(size, m);44}45}4647// Perform the tested copy48System.arraycopy(test, l, test, r, len);4950// Check the copy has proper contents51{52int m = Arrays.mismatch(test, r, r+len,53orig, l, l+len);54if (m != -1) {55throwContentsError(l, r, len, r+m);56}57}5859// Check anything else was not affected: head and tail60{61int m = Arrays.mismatch(test, 0, r,62orig, 0, r);63if (m != -1) {64throwHeadError(l, r, len, m);65}66}67{68int m = Arrays.mismatch(test, r + len, size,69orig, r + len, size);70if (m != -1) {71throwTailError(l, r, len, m);72}73}74}7576public static void main(String... args) {77Random rand = Utils.getRandomInstance();78for (int c = 0; c < orig.length; c++) {79orig[c] = rand.nextBoolean();80}81new StressBooleanArrayCopy().run(rand);82}8384}858687