@CallerSensitive
public Constructor<?> getEnclosingConstructor () throws SecurityException

If this Class object represents a local or anonymous class within a constructor, returns a Constructor object representing the immediately enclosing constructor of the underlying class. Returns null otherwise. In particular, this method returns null if the underlying class is a local or anonymous class immediately enclosed by a type declaration, instance initializer or static initializer.

Returns:  the immediately enclosing constructor of the underlying class, if that class is a local or anonymous class; otherwise null.

Exceptions:
SecurityException     If a security manager, s, is present and any of the following conditions is met:
  • the caller's class loader is not the same as the class loader of the enclosing class and invocation of s.checkPermission method with RuntimePermission("accessDeclaredMembers") denies access to the constructors within the enclosing class
  • the caller's class loader is not the same as or an ancestor of the class loader for the enclosing class and invocation of s.checkPackageAccess() denies access to the package of the enclosing class

Since:  1.5