public class CanAccessExample3 { public class Test { public Test() {} }
public static void main(String... args) throws NoSuchMethodException { //inner class has an implicit arg of outer class Constructor<Test> cons = Test.class.getDeclaredConstructor(CanAccessExample3.class); boolean b = cons.canAccess(null); System.out.println(b); } }