Array_newInstance06.java revision 12657:6ef01bd40ce2
1135549Sdes/* 2135549Sdes * Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved. 3135549Sdes * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4234010Sdougb * 5135549Sdes * This code is free software; you can redistribute it and/or modify it 6135549Sdes * under the terms of the GNU General Public License version 2 only, as 7135549Sdes * published by the Free Software Foundation. 8135549Sdes * 9135549Sdes * This code is distributed in the hope that it will be useful, but WITHOUT 10135549Sdes * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11135549Sdes * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12135549Sdes * version 2 for more details (a copy is included in the LICENSE file that 13135549Sdes * accompanied this code). 14135549Sdes * 15135549Sdes * You should have received a copy of the GNU General Public License version 16135549Sdes * 2 along with this work; if not, write to the Free Software Foundation, 17135549Sdes * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18135549Sdes * 19135549Sdes * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20135549Sdes * or visit www.oracle.com if you need additional information or have any 21135549Sdes * questions. 22135549Sdes */ 23135549Sdes/* 24135549Sdes */ 25135549Sdespackage org.graalvm.compiler.jtt.reflect; 26135549Sdes 27170224Sdougbimport java.lang.reflect.Array; 28170224Sdougb 29135549Sdesimport org.junit.Test; 30135549Sdes 31135549Sdesimport org.graalvm.compiler.jtt.JTTTest; 32135549Sdes 33135549Sdespublic class Array_newInstance06 extends JTTTest { 34135549Sdes 35135549Sdes public static boolean test(int i) { 36135549Sdes final int[] dims = {i, 3}; 37135549Sdes Class<?> javaClass; 38135549Sdes if (i == 2) { 39135549Sdes javaClass = int.class; 40135549Sdes } else if (i == 3) { 41135549Sdes javaClass = Object.class; 42135549Sdes } else { 43135549Sdes javaClass = Array_newInstance06.class; 44135549Sdes } 45135549Sdes return Array.newInstance(javaClass, dims).getClass().getComponentType().getComponentType() == javaClass; 46135549Sdes } 47135549Sdes 48135549Sdes @Test 49135549Sdes public void run0() throws Throwable { 50135549Sdes runTest("test", 1); 51135549Sdes } 52135549Sdes 53135549Sdes @Test 54135549Sdes public void run1() throws Throwable { 55135549Sdes runTest("test", 2); 56135549Sdes } 57135549Sdes 58135549Sdes @Test 59135549Sdes public void run2() throws Throwable { 60135549Sdes runTest("test", 3); 61135549Sdes } 62135549Sdes 63135549Sdes} 64135549Sdes