1 2 import director_protected.*; 3 import java.lang.reflect.*; 4 5 public class director_protected_runme { 6 7 static { 8 try { 9 System.loadLibrary("director_protected"); 10 } catch (UnsatisfiedLinkError e) { 11 System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e); 12 System.exit(1); 13 } 14 } 15 main(String argv[])16 public static void main(String argv[]) { 17 18 Bar b = new Bar(); 19 Foo f = b.create(); 20 director_protected_FooBar fb = new director_protected_FooBar(); 21 director_protected_FooBar2 fb2 = new director_protected_FooBar2(); 22 director_protected_FooBar3 fb3 = new director_protected_FooBar3(); 23 24 { 25 String s = fb.used(); 26 if (!s.equals("Foo::pang();Bar::pong();Foo::pong();director_protected_FooBar::ping();")) 27 throw new RuntimeException( "bad director_protected_FooBar::used" ); 28 } 29 30 { 31 String s = fb2.used(); 32 if (!s.equals("director_protected_FooBar2::pang();Bar::pong();Foo::pong();director_protected_FooBar2::ping();")) 33 throw new RuntimeException( "bad director_protected_FooBar2::used" ); 34 } 35 36 { 37 String s = b.pong(); 38 if (!s.equals("Bar::pong();Foo::pong();Bar::ping();")) 39 throw new RuntimeException( "bad Bar::pong" ); 40 } 41 42 { 43 String s = f.pong(); 44 if (!s.equals("Bar::pong();Foo::pong();Bar::ping();")) 45 throw new RuntimeException(" bad Foo::pong" ); 46 } 47 48 { 49 String s3 = fb.pong(); 50 if (!s3.equals("Bar::pong();Foo::pong();director_protected_FooBar::ping();")) 51 throw new RuntimeException(" bad director_protected_FooBar::pong" ); 52 } 53 54 try { 55 56 Method method = b.getClass().getDeclaredMethod("ping", (java.lang.Class[])null); 57 if ( !Modifier.isProtected(method.getModifiers()) ) 58 throw new RuntimeException("Bar::ping should be protected" ); 59 60 method = f.getClass().getDeclaredMethod("ping", (java.lang.Class[])null); 61 if ( !Modifier.isProtected(method.getModifiers()) ) 62 throw new RuntimeException("Foo::ping should be protected" ); 63 64 method = b.getClass().getDeclaredMethod("cheer", (java.lang.Class[])null); 65 if ( !Modifier.isProtected(method.getModifiers()) ) 66 throw new RuntimeException("Bar::cheer should be protected" ); 67 68 method = f.getClass().getDeclaredMethod("cheer", (java.lang.Class[])null); 69 if ( !Modifier.isProtected(method.getModifiers()) ) 70 throw new RuntimeException("Foo::cheer should be protected" ); 71 72 } catch (NoSuchMethodException n) { 73 throw new RuntimeException(n); 74 } catch (SecurityException s) { 75 throw new RuntimeException("SecurityException caught. Test failed."); 76 } 77 78 if (!fb3.cheer().equals("director_protected_FooBar3::cheer();")) 79 throw new RuntimeException("bad fb3::cheer"); 80 81 if (!fb2.callping().equals("director_protected_FooBar2::ping();")) 82 throw new RuntimeException("bad fb2.callping"); 83 84 if (!fb2.callcheer().equals("director_protected_FooBar2::pang();Bar::pong();Foo::pong();director_protected_FooBar2::ping();")) 85 throw new RuntimeException("bad fb2.callcheer"); 86 87 if (!fb3.callping().equals("Bar::ping();")) 88 throw new RuntimeException("bad fb3.callping"); 89 90 if (!fb3.callcheer().equals("director_protected_FooBar3::cheer();")) 91 throw new RuntimeException("bad fb3.callcheer"); 92 } 93 } 94 95 class director_protected_FooBar extends Bar { ping()96 public String ping() { 97 return "director_protected_FooBar::ping();"; 98 } 99 } 100 101 class director_protected_FooBar2 extends Bar { ping()102 public String ping() { 103 return "director_protected_FooBar2::ping();"; 104 } pang()105 public String pang() { 106 return "director_protected_FooBar2::pang();"; 107 } 108 } 109 110 class director_protected_FooBar3 extends Bar { cheer()111 public String cheer() { 112 return "director_protected_FooBar3::cheer();"; 113 } 114 } 115 116