Path: blob/master/test/hotspot/jtreg/compiler/compilercontrol/share/AbstractTestBase.java
41155 views
/*1* Copyright (c) 2015, 2016, Oracle and/or its affiliates. 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.compilercontrol.share;2425import compiler.compilercontrol.share.method.MethodDescriptor;26import compiler.compilercontrol.share.method.MethodGenerator;27import compiler.compilercontrol.share.pool.PoolHelper;28import jdk.test.lib.util.Pair;2930import java.lang.reflect.Executable;31import java.util.List;32import java.util.concurrent.Callable;3334public abstract class AbstractTestBase {35protected static final MethodGenerator METHOD_GEN = new MethodGenerator();36protected static final int ATTEMPTS = 25;37protected static final List<Pair<Executable, Callable<?>>> METHODS38= new PoolHelper().getAllMethods(PoolHelper.METHOD_FILTER);3940public abstract void test();4142/**43* Generate random valid method descriptor44*45* @param exec method to make descriptor for46* @return a valid {@link MethodDescriptor#isValid()} descriptor instance47*/48public static MethodDescriptor getValidMethodDescriptor(Executable exec) {49MethodDescriptor md = METHOD_GEN.generateRandomDescriptor(exec);50for (int i = 0; !md.isValid() && i < ATTEMPTS; i++) {51md = METHOD_GEN.generateRandomDescriptor(exec);52}53if (!md.isValid() || "any.method()".matches(md.getRegexp())) {54/* if we haven't got a valid pattern or it matches any method55leading to timeouts, then use plain standard descriptor */56md = MethodGenerator.commandDescriptor(exec);57}58return md;59}60}616263