1 /* 2 * Test failure to resolve classes. 3 */ 4 class UnresTest2 { 5 /* 6 * Try check-cast and instance-of. 7 */ 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 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 Main.assertTrue(ncdfe.getCause() instanceof ClassNotFoundException); 45 // good 46 } 47 48 try { 49 UnresClass[] uar = new UnresClass[3]; 50 Main.assertTrue(false); 51 } catch (NoClassDefFoundError ncdfe) { 52 Main.assertTrue(ncdfe.getCause() instanceof ClassNotFoundException); 53 // good 54 } 55 56 checkCasts(stuff); 57 System.out.println("UnresTest2 done"); 58 } 59 } 60