code: private static int[] computeFailure(byte[] pattern) {
          int[] failure = new int[pattern.length];
          int j = 0;
          for (int i = 1; i < pattern.length; i++) {
              while (j > 0 && pattern[j] != pattern[i])
                  j = failure[j - 1];
              if (pattern[j] == pattern[i])
                  j++;
              failure[i] = j;
          }
          return failure;
      }
docs: Computes the failure function using a boot-strapping process,
  where the pattern is matched against itself.