Path: blob/master/test/hotspot/jtreg/compiler/compilercontrol/share/pool/SubMethodHolder.java
41161 views
package compiler.compilercontrol.share.pool;12import jdk.test.lib.util.Pair;34import java.lang.reflect.Constructor;5import java.lang.reflect.Executable;6import java.lang.reflect.Method;7import java.util.ArrayList;8import java.util.List;9import java.util.concurrent.Callable;1011/**12* A helper class that creates executables and callables for internal classes13* It's necessary to have this class to make all helper lambdas not contain14* any of class names that could be used as a pattern (Internal*, *Klass*)15*/16public abstract class SubMethodHolder extends MethodHolder {17@Override18public List<Pair<Executable, Callable<?>>> getAllMethods() {19List<Pair<Executable, Callable<?>>> pairs = new ArrayList<>();20{21Method method = getMethod(this, "method", Float.class);22Pair<Executable, Callable<?>> pair = new Pair<>(method,23() -> method.invoke(this, 3.141592f));24pairs.add(pair);25}26{27Method method = getMethod(this, "methodDup");28Pair<Executable, Callable<?>> pair = new Pair<>(method,29() -> method.invoke(this));30pairs.add(pair);31}32{33Method method = getMethod(this, "smethod", Integer.class);34Pair<Executable, Callable<?>> pair = new Pair<>(method,35() -> method.invoke(this, 1024));36pairs.add(pair);37}38try {39Constructor constructor = this.getClass().getConstructor();40Pair<Executable, Callable<?>> pair = new Pair<>(constructor,41constructor::newInstance);42pairs.add(pair);43} catch (NoSuchMethodException e) {44throw new Error("TESTBUG: unable to get constructor");45}46return pairs;47}48}495051