All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.python.core.JavaAccessibility Maven / Gradle / Ivy

Go to download

Jython is an implementation of the high-level, dynamic, object-oriented language Python written in 100% Pure Java, and seamlessly integrated with the Java platform. It thus allows you to run Python on any Java platform.

There is a newer version: 2.7.4
Show newest version
package org.python.core;
import java.lang.reflect.*;

/**
 * Provides a means of using the Java 2
 * {Field|Method|Constructor}.setAccessibility() methods.
 *
 * This class was formerly necessary for Java 1 compattibility.
 * In the future, this class may be removed.
 * @deprecated Java 1 no longer supported.
 */

class JavaAccessibility
{
    private static JavaAccessibility access = null;

    static void initialize() {
        // If registry option
        // python.security.respectJavaAccessibility is set, then we set the
        // access object to an instance of the subclass Java2Accessibility
        if (Options.respectJavaAccessibility)
            return;
        access = new Java2Accessibility();
    }

    static boolean accessIsMutable() {
        return access != null;
    }

    /**
     * These methods get overridden in the Java2Accessibility subclass
     */
    void setAccess(Field field, boolean flag) throws SecurityException {
    }

    void setAccess(Method method, boolean flag) throws SecurityException {
    }

    void setAccess(Constructor constructor, boolean flag)
        throws SecurityException
    {}

    public static void setAccessible(Field field, boolean flag)
        throws SecurityException
    {
        if (access != null) {
            access.setAccess(field, flag);
        }
    }

    public static void setAccessible(Method method, boolean flag)
        throws SecurityException
    {
        if (access != null) {
            access.setAccess(method, flag);
        }
    }

    public static void setAccessible(Constructor constructor, boolean flag)
        throws SecurityException
    {
        if (access != null) {
            access.setAccess(constructor, flag);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy