StampFactoryTest.java revision 12651:6ef01bd40ce2
1228753Smm/* 2228753Smm * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved. 3248616Smm * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4228753Smm * 5228753Smm * This code is free software; you can redistribute it and/or modify it 6228753Smm * under the terms of the GNU General Public License version 2 only, as 7228753Smm * published by the Free Software Foundation. 8228753Smm * 9228753Smm * This code is distributed in the hope that it will be useful, but WITHOUT 10228753Smm * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11228753Smm * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12228753Smm * version 2 for more details (a copy is included in the LICENSE file that 13228753Smm * accompanied this code). 14228753Smm * 15228753Smm * You should have received a copy of the GNU General Public License version 16228753Smm * 2 along with this work; if not, write to the Free Software Foundation, 17228753Smm * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18228753Smm * 19228753Smm * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20228753Smm * or visit www.oracle.com if you need additional information or have any 21228753Smm * questions. 22228753Smm */ 23228753Smmpackage org.graalvm.compiler.phases.common.test; 24228753Smm 25228753Smmimport java.lang.reflect.Method; 26228753Smm 27228753Smmimport jdk.vm.ci.meta.JavaKind; 28228753Smmimport jdk.vm.ci.meta.MetaAccessProvider; 29228753Smm 30228753Smmimport org.junit.Assert; 31228753Smmimport org.junit.Test; 32228753Smm 33228753Smmimport org.graalvm.compiler.api.test.Graal; 34228753Smmimport org.graalvm.compiler.core.common.type.Stamp; 35228753Smmimport org.graalvm.compiler.core.common.type.StampFactory; 36228753Smmimport org.graalvm.compiler.core.common.type.TypeReference; 37228753Smmimport org.graalvm.compiler.runtime.RuntimeProvider; 38228753Smm 39228753Smmpublic class StampFactoryTest { 40228753Smm 41228753Smm @SuppressWarnings("unused") 42228753Smm public void test(int a, Object b, double c) { 43228753Smm } 44228753Smm 45228753Smm @Test 46228753Smm public void testParameters() throws NoSuchMethodException, SecurityException { 47228753Smm Method method = StampFactoryTest.class.getMethod("test", Integer.TYPE, Object.class, Double.TYPE); 48248616Smm MetaAccessProvider metaAccess = Graal.getRequiredCapability(RuntimeProvider.class).getHostBackend().getProviders().getMetaAccess(); 49228753Smm Stamp[] parameterStamps = StampFactory.createParameterStamps(null, metaAccess.lookupJavaMethod(method)); 50248616Smm Stamp[] expected = {StampFactory.objectNonNull(TypeReference.createWithoutAssumptions(metaAccess.lookupJavaType(StampFactoryTest.class))), StampFactory.forKind(JavaKind.Int), 51228753Smm StampFactory.object(TypeReference.createWithoutAssumptions(metaAccess.lookupJavaType(Object.class))), StampFactory.forKind(JavaKind.Double)}; 52231200Smm Assert.assertArrayEquals(expected, parameterStamps); 53231200Smm } 54231200Smm} 55231200Smm