test/compiler/jvmci/compilerToVM/ConstantPoolTestsHelper.java
Index
Unified diffs
Context diffs
Sdiffs
Patch
New
Old
Previous File
Next File
*** old/test/compiler/jvmci/compilerToVM/ConstantPoolTestsHelper.java Thu Jun 2 12:26:09 2016
--- new/test/compiler/jvmci/compilerToVM/ConstantPoolTestsHelper.java Thu Jun 2 12:26:09 2016
*** 29,38 ****
--- 29,42 ----
import compiler.jvmci.compilerToVM.ConstantPoolTestCase.ConstantTypes;
import static compiler.jvmci.compilerToVM.ConstantPoolTestCase.ConstantTypes.*;
import compiler.jvmci.compilerToVM.ConstantPoolTestCase.TestedCPEntry;
import java.util.HashMap;
import java.util.Map;
+ import jdk.vm.ci.meta.MetaAccessProvider;
+ import jdk.vm.ci.meta.ResolvedJavaMethod;
+ import jdk.vm.ci.meta.ResolvedJavaType;
+ import jdk.vm.ci.runtime.JVMCI;
import jdk.internal.misc.SharedSecrets;
import jdk.internal.org.objectweb.asm.Opcodes;
import sun.hotspot.WhiteBox;
import jdk.internal.reflect.ConstantPool;
import jdk.internal.reflect.ConstantPool.Tag;
*** 42,51 ****
--- 46,56 ----
* jdk.vm.ci.hotspot.CompilerToVM constant pool methods
*/
public class ConstantPoolTestsHelper {
public static final int NO_CP_CACHE_PRESENT = Integer.MAX_VALUE;
+ private static final MetaAccessProvider metaAccess = JVMCI.getRuntime().getHostJVMCIBackend().getMetaAccess();
public enum DummyClasses {
DUMMY_CLASS(MultipleImplementer2.class, CP_MAP_FOR_CLASS),
DUMMY_ABS_CLASS(MultipleAbstractImplementer.class, CP_MAP_FOR_ABS_CLASS),
DUMMY_INTERFACE(MultipleImplementersInterface.class, CP_MAP_FOR_INTERFACE);
*** 74,83 ****
--- 79,127 ----
}
return NO_CP_CACHE_PRESENT;
}
}
+ /**
+ * Obtain a resolved Java method declared by a given type.
+ *
+ * @param type the declaring type
+ * @param the method's name
+ *
+ * Currently, the lookup is based only on the method's name
+ * but not on the method's signature (i.e., the first method
+ * with a matching name declared on {@code type} is returned).
+ */
+ private static ResolvedJavaMethod getMethod(ResolvedJavaType type, String methodName) {
+ if (methodName.equals("<clinit>")) {
+ return type.getClassInitializer();
+ }
+
+ if (methodName.equals("<init>")) {
+ ResolvedJavaMethod[] initializers = type.getDeclaredConstructors();
+ if (initializers.length >= 0) {
+ return initializers[0];
+ } else {
+ throw new IllegalArgumentException();
+ }
+ }
+
+ for (ResolvedJavaMethod method : type.getDeclaredMethods()) {
+ if (method.getName().equals(methodName)) {
+ return method;
+ }
+ }
+
+ throw new IllegalArgumentException();
+ }
+
+ private static ResolvedJavaType getType(Class<?> clazz) {
+ ResolvedJavaType type = metaAccess.lookupJavaType(clazz);
+ type.initialize();
+ return type;
+ }
+
private static final Map<ConstantTypes, TestedCPEntry[]> CP_MAP_FOR_CLASS = new HashMap<>();
static {
CP_MAP_FOR_CLASS.put(CONSTANT_CLASS,
new TestedCPEntry[] {
new TestedCPEntry("compiler/jvmci/common/testcases/MultipleImplementersInterface", null, null),
*** 139,148 ****
--- 183,193 ----
new byte[] {(byte) Opcodes.PUTFIELD | (byte) Opcodes.GETFIELD},
Opcodes.ACC_TRANSIENT),
new TestedCPEntry("compiler/jvmci/common/testcases/MultipleImplementer2",
"objectField",
"Ljava/lang/Object;",
+ new ResolvedJavaMethod[] { getMethod(getType(MultipleImplementer2.class), "<init>"), null },
new byte[] {(byte) Opcodes.PUTFIELD | (byte) Opcodes.GETFIELD},
Opcodes.ACC_FINAL),
new TestedCPEntry("compiler/jvmci/common/testcases/MultipleImplementer2",
"stringField",
"Ljava/lang/String;",
*** 294,303 ****
--- 339,349 ----
new byte[] {(byte) Opcodes.PUTFIELD | (byte) Opcodes.GETFIELD},
Opcodes.ACC_TRANSIENT),
new TestedCPEntry("compiler/jvmci/common/testcases/MultipleAbstractImplementer",
"objectField",
"Ljava/lang/Object;",
+ new ResolvedJavaMethod[] { getMethod(getType(MultipleAbstractImplementer.class), "<init>"), null },
new byte[] {(byte) Opcodes.PUTFIELD | (byte) Opcodes.GETFIELD},
Opcodes.ACC_FINAL),
new TestedCPEntry("compiler/jvmci/common/testcases/MultipleAbstractImplementer",
"stringField",
"Ljava/lang/String;",
*** 399,408 ****
--- 445,455 ----
CP_MAP_FOR_INTERFACE.put(CONSTANT_FIELDREF,
new TestedCPEntry[] {
new TestedCPEntry("compiler/jvmci/common/testcases/MultipleImplementersInterface",
"OBJECT_CONSTANT",
"Ljava/lang/Object;",
+ new ResolvedJavaMethod[] { getMethod(getType(MultipleImplementersInterface.class), "<clinit>"), null },
new byte[] {(byte) Opcodes.PUTSTATIC, (byte) Opcodes.GETSTATIC},
Opcodes.ACC_STATIC | Opcodes.ACC_FINAL | Opcodes.ACC_PUBLIC),
}
);
CP_MAP_FOR_INTERFACE.put(CONSTANT_METHODREF,
test/compiler/jvmci/compilerToVM/ConstantPoolTestsHelper.java
Index
Unified diffs
Context diffs
Sdiffs
Patch
New
Old
Previous File
Next File