code: Method findSparkSubmit() throws IOException {
      ClassLoader cl = Thread.currentThread().getContextClassLoader();
      if (cl == null) {
        cl = getClass().getClassLoader();
      }
  
      Class<?> sparkSubmit;
      // SPARK-22941: first try the new SparkSubmit interface that has better error handling,
      // but fall back to the old interface in case someone is mixing & matching launcher and
      // Spark versions.
      try {
        sparkSubmit = cl.loadClass("org.apache.spark.deploy.InProcessSparkSubmit");
      } catch (Exception e1) {
        try {
          sparkSubmit = cl.loadClass("org.apache.spark.deploy.SparkSubmit");
        } catch (Exception e2) {
          throw new IOException("Cannot find SparkSubmit; make sure necessary jars are available.",
            e2);
        }
      }
  
      Method main;
      try {
        main = sparkSubmit.getMethod("main", String[].class);
      } catch (Exception e) {
        throw new IOException("Cannot find SparkSubmit main method.", e);
      }
  
      CommandBuilderUtils.checkState(Modifier.isStatic(main.getModifiers()),
        "main method is not static.");
      return main;
    }
docs: Visible for testing.