1 /*
2  * Test failure to resolve classes.
3  */
4 class UnresTest2 {
5     /*
6      * Try check-cast and instance-of.
7      */
checkCasts(Object obj)8     static boolean checkCasts(Object obj) {
9         boolean foo = false;
10 
11         try {
12             UnresClass un = (UnresClass) obj;
13             Main.assertTrue(false);
14         } catch (NoClassDefFoundError ncdfe) {
15             // good
16         }
17         try {
18             foo = obj instanceof UnresClass;
19             Main.assertTrue(false);
20         } catch (NoClassDefFoundError ncdfe) {
21             // good
22         }
23 
24         return foo;
25     }
26 
run()27     public static void run() {
28         System.out.println("UnresTest2...");
29         UnresClass un;
30         UnresStuff stuff = new UnresStuff();
31 
32         try {
33             un = new UnresClass();
34             Main.assertTrue(false);
35         } catch (NoClassDefFoundError ncdfe) {
36             Main.assertTrue(ncdfe.getCause() instanceof ClassNotFoundException);
37             // good
38         }
39 
40         try {
41             new UnresClassSubclass();
42             Main.assertTrue(false);
43         } catch (NoClassDefFoundError ncdfe) {
44             // TODO b/22080519
45             // Main.assertTrue(ncdfe.getCause() instanceof ClassNotFoundException);
46             // good
47         }
48 
49         try {
50             UnresClass[] uar = new UnresClass[3];
51             Main.assertTrue(false);
52         } catch (NoClassDefFoundError ncdfe) {
53             // good
54         }
55 
56         checkCasts(stuff);
57         System.out.println("UnresTest2 done");
58     }
59 }
60