private static Permission[] grantablePermissions(Permission[] permissions){
  SecurityManager sm=System.getSecurityManager();
  if (sm == null || permissions.length == 0) {
    return permissions;
  }
  try {
    sm.checkPermission(new GrantPermission(permissions));
    return permissions;
  }
 catch (  SecurityException e) {
  }
  ArrayList list=new ArrayList(permissions.length);
  for (int i=0; i < permissions.length; i++) {
    try {
      Permission p=permissions[i];
      sm.checkPermission(new GrantPermission(p));
      list.add(p);
    }
 catch (    SecurityException e) {
    }
  }
  return (Permission[])list.toArray(new Permission[list.size()]);
}

private static Permission [ ] grantablePermissions ( Permission [ ] permissions ) { SecurityManager sm = System . getSecurityManager ( ) ; if ( sm == null || permissions . length == 0 ) { return permissions ; } try { sm . checkPermission ( new GrantPermission ( permissions ) ) ; return permissions ; } catch ( SecurityException e ) { } ArrayList list = new ArrayList ( permissions . length ) ; for ( int i = 0 ; i < permissions . length ; i ++ ) { try { Permission p = permissions [ i ] ; sm . checkPermission ( new GrantPermission ( p ) ) ; list . add ( p ) ; } catch ( SecurityException e ) { } } return ( Permission [ ] ) list . toArray ( new Permission [ list . size ( ) ] ) ; }
returns subset of given permissions that is grantable given the current calling context .
