code: private static Collection<List<?>> makeAltNames(GeneralNames names) {
          if (names.isEmpty()) {
              return Collections.<List<?>>emptySet();
          }
          List<List<?>> newNames = new ArrayList<>();
          for (GeneralName gname : names.names()) {
              GeneralNameInterface name = gname.getName();
              List<Object> nameEntry = new ArrayList<>(2);
              nameEntry.add(Integer.valueOf(name.getType()));
              switch (name.getType()) {
              case GeneralNameInterface.NAME_RFC822:
                  nameEntry.add(((RFC822Name) name).getName());
                  break;
              case GeneralNameInterface.NAME_DNS:
                  nameEntry.add(((DNSName) name).getName());
                  break;
              case GeneralNameInterface.NAME_DIRECTORY:
                  nameEntry.add(((X500Name) name).getRFC2253Name());
                  break;
              case GeneralNameInterface.NAME_URI:
                  nameEntry.add(((URIName) name).getName());
                  break;
              case GeneralNameInterface.NAME_IP:
                  try {
                      nameEntry.add(((IPAddressName) name).getName());
                  } catch (IOException ioe) {
                      // IPAddressName in cert is bogus
                      throw new RuntimeException("IPAddress cannot be parsed",
                          ioe);
                  }
                  break;
              case GeneralNameInterface.NAME_OID:
                  nameEntry.add(((OIDName) name).getOID().toString());
                  break;
              default:
                  // add DER encoded form
                  DerOutputStream derOut = new DerOutputStream();
                  try {
                      name.encode(derOut);
                  } catch (IOException ioe) {
                      // should not occur since name has already been decoded
                      // from cert (this would indicate a bug in our code)
                      throw new RuntimeException("name cannot be encoded", ioe);
                  }
                  nameEntry.add(derOut.toByteArray());
                  break;
              }
              newNames.add(Collections.unmodifiableList(nameEntry));
          }
          return Collections.unmodifiableCollection(newNames);
      }
docs: Converts a GeneralNames structure into an immutable Collection of
  alternative names (subject or issuer) in the form required by
  {@link #getSubjectAlternativeNames} or
  {@link #getIssuerAlternativeNames}.
  
  @param names the GeneralNames to be converted
  @return an immutable Collection of alternative names