1 package org.python.core; 2 import java.lang.reflect.*; 3 4 13 14 class JavaAccessibility 15 { 16 private static JavaAccessibility access = null; 17 18 static void initialize() { 19 if (Options.respectJavaAccessibility) 23 return; 24 try { 25 Class c = Class.forName("org.python.core.Java2Accessibility"); 26 Class.forName("java.lang.reflect.AccessibleObject"); 27 access = (JavaAccessibility)c.newInstance(); 28 } 29 catch (InstantiationException e) {} 30 catch (IllegalAccessException e) {} 31 catch (ClassNotFoundException e) {} 32 } 33 34 static boolean accessIsMutable() { 35 return access != null; 36 } 37 38 41 void setAccess(Field field, boolean flag) throws SecurityException { 42 } 43 44 void setAccess(Method method, boolean flag) throws SecurityException { 45 } 46 47 void setAccess(Constructor constructor, boolean flag) 48 throws SecurityException 49 {} 50 51 public static void setAccessible(Field field, boolean flag) 52 throws SecurityException 53 { 54 if (access != null) 55 access.setAccess(field, flag); 56 } 57 58 public static void setAccessible(Method method, boolean flag) 59 throws SecurityException 60 { 61 if (access != null) 62 access.setAccess(method, flag); 63 } 64 65 public static void setAccessible(Constructor constructor, boolean flag) 66 throws SecurityException 67 { 68 if (access != null) 69 access.setAccess(constructor, flag); 70 } 71 } 72 | Popular Tags |