Merge pull request #1207 from marco-c/test_class_forname_in_static

Test calling Class.forName in a static initializer
This commit is contained in:
Myk Melez 2015-03-06 18:23:10 -08:00
Родитель bb43dfb8cf aab7eff3f8
Коммит 97c641cb04
1 изменённых файлов: 28 добавлений и 0 удалений

Просмотреть файл

@ -0,0 +1,28 @@
package gnu.testlet.vm;
import gnu.testlet.TestHarness;
import gnu.testlet.Testlet;
public class ClassForNameInStaticInitializerTest implements Testlet {
public int getExpectedPass() { return 2; }
public int getExpectedFail() { return 0; }
public int getExpectedKnownFail() { return 0; }
private static boolean test1 = ClassForNameInStaticInitializerTest.canLoad("java.lang.Object");
private static boolean test2 = ClassForNameInStaticInitializerTest.canLoad("java.lang.DoesntExist");
public static boolean canLoad(String className) {
try {
Class.forName(className);
return true;
} catch (ClassNotFoundException e) {
}
return false;
}
public void test(TestHarness th) {
th.check(test1, "java.lang.Object exists");
th.check(!test2, "java.lang.DoesntExist doesn't exist");
}
}