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

org.perfectable.introspection.PrivilegedActions Maven / Gradle / Ivy

There is a newer version: 5.1.0
Show newest version
package org.perfectable.introspection;

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

/**
 * Helper class that allows executing code that requires {@link AccessController#doPrivileged}.
 */
public final class PrivilegedActions {
	/**
	 * Marks object as accessible with {@link AccessibleObject#setAccessible}.
	 *
	 * @param accessibleObject object to be marked as accessible
	 */
	public static void markAccessible(AccessibleObject accessibleObject) {
		AccessController.doPrivileged((PrivilegedAction) () -> {
			accessibleObject.setAccessible(true);
			return null;
		});
	}

	private PrivilegedActions() {
		// utility class
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy