Utils.java Source code

Java tutorial

Introduction

Here is the source code for Utils.java

Source

import java.lang.reflect.AccessibleObject;
import java.security.AccessController;
import java.security.PrivilegedAction;

public class Utils {

    public static void makeAccessible(final AccessibleObject object) {
        if (!object.isAccessible()) {
            if (System.getSecurityManager() == null) {
                object.setAccessible(true);
            } else {
                AccessController.doPrivileged(new PrivilegedAction<Object>() {

                    public Object run() {
                        object.setAccessible(true);
                        return null;
                    }
                });
            }
        }
    }

}