01: package org.python.core;
02:
03: import java.lang.reflect.*;
04:
05: /**
06: * Provides a means of using the Java 2
07: * {Field|Method|Constructor}.setAccessibility() methods.
08: *
09: * This class was formerly necessary for Java 1 compattibility.
10: * In the future, this class may be removed.
11: * @deprecated Java 1 no longer supported.
12: */
13:
14: class JavaAccessibility {
15: private static JavaAccessibility access = null;
16:
17: static void initialize() {
18: // If registry option
19: // python.security.respectJavaAccessibility is set, then we set the
20: // access object to an instance of the subclass Java2Accessibility
21: if (Options.respectJavaAccessibility)
22: return;
23: access = new Java2Accessibility();
24: }
25:
26: static boolean accessIsMutable() {
27: return access != null;
28: }
29:
30: /**
31: * These methods get overridden in the Java2Accessibility subclass
32: */
33: void setAccess(Field field, boolean flag) throws SecurityException {
34: }
35:
36: void setAccess(Method method, boolean flag)
37: throws SecurityException {
38: }
39:
40: void setAccess(Constructor constructor, boolean flag)
41: throws SecurityException {
42: }
43:
44: public static void setAccessible(Field field, boolean flag)
45: throws SecurityException {
46: if (access != null) {
47: access.setAccess(field, flag);
48: }
49: }
50:
51: public static void setAccessible(Method method, boolean flag)
52: throws SecurityException {
53: if (access != null) {
54: access.setAccess(method, flag);
55: }
56: }
57:
58: public static void setAccessible(Constructor constructor,
59: boolean flag) throws SecurityException {
60: if (access != null) {
61: access.setAccess(constructor, flag);
62: }
63: }
64: }
|