public static void checkAccess(int modifiers){
  if (System.getSecurityManager() != null && !Modifier.isPublic(modifiers)) {
    throw new SecurityException("Resource is not accessible");
  }
}

public static void checkAccess ( int modifiers ) { if ( System . getSecurityManager ( ) != null && ! Modifier . isPublic ( modifiers ) ) { throw new SecurityException ( "Resource is not accessible" ) ; } }
utility method that throws securityexception if securitymanager is set and modifiers are not public
