Path: blob/master/test/hotspot/jtreg/gc/epsilon/TestObjects.java
66644 views
/*1* Copyright (c) 2017, 2018, 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 gc.epsilon;2425/**26* @test TestObjects27* @key randomness28* @requires vm.gc.Epsilon29* @summary Epsilon is able to allocate objects, and does not corrupt their state30* @library /test/lib31*32* @run main/othervm -XX:+UseTLAB -Xmx256m33* -XX:+UnlockExperimentalVMOptions -XX:+UseEpsilonGC34* gc.epsilon.TestObjects35*36* @run main/othervm -XX:+UseTLAB -Xmx256m37* -Xint38* -XX:+UnlockExperimentalVMOptions -XX:+UseEpsilonGC39* gc.epsilon.TestObjects40*41* @run main/othervm -XX:+UseTLAB -Xmx256m42* -Xbatch -Xcomp -XX:TieredStopAtLevel=143* -XX:+UnlockExperimentalVMOptions -XX:+UseEpsilonGC44* gc.epsilon.TestObjects45*46* @run main/othervm -XX:+UseTLAB -Xmx256m47* -Xbatch -Xcomp -XX:-TieredCompilation48* -XX:+UnlockExperimentalVMOptions -XX:+UseEpsilonGC49* gc.epsilon.TestObjects50*51* @run main/othervm -XX:-UseTLAB -Xmx256m52* -XX:+UnlockExperimentalVMOptions -XX:+UseEpsilonGC53* gc.epsilon.TestObjects54*55* @run main/othervm -XX:-UseTLAB -Xmx256m56* -Xint57* -XX:+UnlockExperimentalVMOptions -XX:+UseEpsilonGC58* gc.epsilon.TestObjects59*60* @run main/othervm -XX:-UseTLAB -Xmx256m61* -Xbatch -Xcomp -XX:TieredStopAtLevel=162* -XX:+UnlockExperimentalVMOptions -XX:+UseEpsilonGC63* gc.epsilon.TestObjects64*65* @run main/othervm -XX:-UseTLAB -Xmx256m66* -Xbatch -Xcomp -XX:-TieredCompilation67* -XX:+UnlockExperimentalVMOptions -XX:+UseEpsilonGC68* gc.epsilon.TestObjects69*/7071import java.util.Random;72import jdk.test.lib.Utils;7374public class TestObjects {75static int COUNT = Integer.getInteger("count", 1_000_000); // ~24 MB allocation7677static MyObject[] arr;7879public static void main(String[] args) throws Exception {80Random r = Utils.getRandomInstance();8182arr = new MyObject[COUNT];83for (int c = 0; c < COUNT; c++) {84arr[c] = new MyObject(r.nextInt());85}8687r = new Random(Utils.SEED);88for (int c = 0; c < COUNT; c++) {89int expected = r.nextInt();90int actual = arr[c].id();91if (expected != actual) {92throw new IllegalStateException("Failure: expected = " + expected + ", actual = " + actual);93}94}95}9697public static class MyObject {98int id;99public MyObject(int id) {100this.id = id;101}102public int id() {103return id;104}105}106}107108109