1 /* 2 * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 25 package org.graalvm.compiler.jtt.lang; 26 27 import java.net.URL; 28 import java.net.URLClassLoader; 29 30 import org.junit.Test; 31 32 import org.graalvm.compiler.jtt.JTTTest; 33 34 /* 35 */ 36 public final class Class_forName03 extends JTTTest { 37 test(int i)38 public static String test(int i) throws ClassNotFoundException { 39 String clname = null; 40 Class<?> cl = null; 41 if (i == 0) { 42 clname = "java.lang.Object[]"; 43 cl = Object.class; 44 } else if (i == 1) { 45 clname = "[Ljava.lang.String;"; 46 cl = String.class; 47 } else if (i == 2) { 48 clname = "[Ljava/lang/String;"; 49 cl = String.class; 50 } else if (i == 3) { 51 clname = "[I"; 52 cl = Class_forName03.class; 53 } else if (i == 4) { 54 clname = "[java.lang.Object;"; 55 cl = Class_forName03.class; 56 } 57 if (clname != null) { 58 return Class.forName(clname, false, new URLClassLoader(new URL[0], cl.getClassLoader())).toString(); 59 } 60 return null; 61 } 62 63 @Test run0()64 public void run0() throws Throwable { 65 runTest("test", 0); 66 } 67 68 @Test run1()69 public void run1() throws Throwable { 70 runTest("test", 1); 71 } 72 73 @Test run2()74 public void run2() throws Throwable { 75 runTest("test", 2); 76 } 77 78 @Test run3()79 public void run3() throws Throwable { 80 runTest("test", 3); 81 } 82 83 @Test run4()84 public void run4() throws Throwable { 85 runTest("test", 4); 86 } 87 88 @Test run5()89 public void run5() throws Throwable { 90 runTest("test", 5); 91 } 92 93 } 94