package com.logicbig.example.method;
import java.lang.reflect.Method;
public class CanAccessExample {
private static class Test {
private void doSomething() {
}
}
public static void main(String... args) throws NoSuchMethodException {
Method m = Test.class.getDeclaredMethod("doSomething");
Test test = new Test();
System.out.println(m.canAccess(test));
boolean b = m.trySetAccessible();
System.out.println(b);
System.out.println(m.canAccess(test));
}
}