Principal[] principals = (Principal[]) subject.getPrincipals().toArray (new Principal[0]);
Principal[] principals = null; if (subject != null) principals = (Principal[]) subject.getPrincipals().toArray (new Principal[0]);
  public ProtectionDomain[] combine (final ProtectionDomain[] current,                                     final ProtectionDomain[] assigned)  {    LinkedList domains = new LinkedList();    Principal[] principals =      (Principal[]) subject.getPrincipals().toArray (new Principal[0]);    if (current != null)      {        for (int i = 0; i < current.length; i++)          {            domains.add (new ProtectionDomain (current[i].getCodeSource(),                                               current[i].getPermissions(),                                               current[i].getClassLoader(),                                               principals));          }      }    if (assigned != null)      {        for (int i = 0; i < assigned.length; i++)          {            domains.add (assigned[i]);          }      }    return (ProtectionDomain[]) domains.toArray (new ProtectionDomain[domains.size()]);  }