code: public static MessageDigest getInstance(String algorithm)
      throws NoSuchAlgorithmException {
          try {
              MessageDigest md;
              Object[] objs = Security.getImpl(algorithm, "MessageDigest",
                                               (String)null);
              if (objs[0] instanceof MessageDigest) {
                  md = (MessageDigest)objs[0];
              } else {
                  md = new Delegate((MessageDigestSpi)objs[0], algorithm);
              }
              md.provider = (Provider)objs[1];
  
              /*
              Android-removed: this debugging mechanism is not available in Android.
              if (!skipDebug && pdebug != null) {
                  pdebug.println("MessageDigest." + algorithm +
                      " algorithm from: " + md.provider.getName());
              }
              */
  
              return md;
  
          } catch(NoSuchProviderException e) {
              throw new NoSuchAlgorithmException(algorithm + " not found");
          }
      }
docs: Returns a MessageDigest object that implements the specified digest
  algorithm.
  
  <p> This method traverses the list of registered security Providers,
  starting with the most preferred Provider.
  A new MessageDigest object encapsulating the
  MessageDigestSpi implementation from the first
  Provider that supports the specified algorithm is returned.
  
  <p> Note that the list of registered providers may be retrieved via
  the {@link Security#getProviders() Security.getProviders()} method.
  
  @param algorithm the name of the algorithm requested.
  See the MessageDigest section in the <a href=
  "{@docRoot}openjdk-redirect.html?v=8&path=/technotes/guides/security/StandardNames.html#MessageDigest">
  Java Cryptography Architecture Standard Algorithm Name Documentation</a>
  for information about standard algorithm names.
  
  @return a Message Digest object that implements the specified algorithm.
  
  @exception NoSuchAlgorithmException if no Provider supports a
  MessageDigestSpi implementation for the
  specified algorithm.
  
  @see Provider