code: private static char[] toCharArray(String password) {
          char[] result = password.toCharArray();
          if (result.length == 0) {
              result = new char[]{0};
          }
          return result;
      }
docs: Converts the given password to a char array.
  <p>
  NB: an empty char array can cause errors when passed to
  {@link javax.crypto.SecretKeyFactory#generateSecret(java.security.spec.KeySpec)}
  in {@link Keys#generateSecretKey(String, String)}, so if the
  password is an empty String, the return value is a char array containing
  a single element of value 0.
  
  @param password The password to be converted.
  @return {@link String#toCharArray()} or, if the password is an empty
  string <code>new char[] {0}</code>