Class_forName02.java revision 12657:6ef01bd40ce2
1114402Sru/* 2114402Sru * Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved. 3114402Sru * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4114402Sru * 5114402Sru * This code is free software; you can redistribute it and/or modify it 6114402Sru * under the terms of the GNU General Public License version 2 only, as 7114402Sru * published by the Free Software Foundation. 8114402Sru * 9114402Sru * This code is distributed in the hope that it will be useful, but WITHOUT 10114402Sru * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11114402Sru * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12114402Sru * version 2 for more details (a copy is included in the LICENSE file that 13114402Sru * accompanied this code). 14114402Sru * 15114402Sru * You should have received a copy of the GNU General Public License version 16114402Sru * 2 along with this work; if not, write to the Free Software Foundation, 17114402Sru * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18114402Sru * 19151497Sru * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20114402Sru * or visit www.oracle.com if you need additional information or have any 21114402Sru * questions. 22114402Sru */ 23114402Sru/* 24114402Sru */ 25114402Srupackage org.graalvm.compiler.jtt.lang; 26114402Sru 27114402Sruimport org.junit.Test; 28114402Sru 29114402Sruimport org.graalvm.compiler.jtt.JTTTest; 30114402Sru 31114402Srupublic final class Class_forName02 extends JTTTest { 32114402Sru 33114402Sru public static String test(int i) throws ClassNotFoundException { 34114402Sru String clname = null; 35114402Sru Class<?> cl = null; 36114402Sru if (i == 0) { 37114402Sru clname = "java.lang.Object"; 38114402Sru cl = Object.class; 39114402Sru } else if (i == 1) { 40114402Sru clname = "java.lang.String"; 41114402Sru cl = String.class; 42114402Sru } else if (i == 2) { 43114402Sru clname = "org.graalvm.compiler.jtt.lang.Class_forName02"; 44114402Sru cl = Class_forName02.class; 45114402Sru } else if (i == 3) { 46114402Sru clname = "xyzz.zyxy.XYXY"; 47114402Sru cl = Class_forName02.class; 48114402Sru } 49114402Sru if (clname != null) { 50114402Sru return Class.forName(clname, false, cl.getClassLoader()).toString(); 51114402Sru } 52114402Sru return null; 53114402Sru } 54114402Sru 55114402Sru @Test 56114402Sru public void run0() throws Throwable { 57114402Sru runTest("test", 0); 58114402Sru } 59114402Sru 60114402Sru @Test 61114402Sru public void run1() throws Throwable { 62114402Sru runTest("test", 1); 63114402Sru } 64114402Sru 65114402Sru @Test 66114402Sru public void run2() throws Throwable { 67114402Sru runTest("test", 2); 68114402Sru } 69114402Sru 70114402Sru @Test 71114402Sru public void run3() throws Throwable { 72114402Sru runTest("test", 3); 73114402Sru } 74114402Sru 75114402Sru @Test 76114402Sru public void run4() throws Throwable { 77114402Sru runTest("test", 4); 78114402Sru } 79114402Sru 80114402Sru} 81114402Sru