code: @SuppressFBWarnings("DP_CREATE_CLASSLOADER_INSIDE_DO_PRIVILEGED") // TODO: clarify and use service loader instead
      public static TerminalFactory loadTerminalFactory(String jar, String classname, String type, String arg) throws NoSuchAlgorithmException {
          try {
              // To support things like host:port pairs, urldecode the arguments component if provided
              if (arg != null) {
                  arg = URLDecoder.decode(arg, "UTF-8");
              }
              final TerminalFactory tf;
              final Class<?> cls; // XXX: stricter type
              if (jar != null) {
                  // Specify class loader
                  URLClassLoader loader = new URLClassLoader(new URL[]{new File(jar).toURI().toURL()}, TerminalManager.class.getClassLoader());
                  // Load custom provider
                  cls = Class.forName(classname, true, loader);
              } else {
                  // Load provider
                  cls = Class.forName(classname);
              }
              Provider p = (Provider) cls.getConstructor().newInstance();
              tf = TerminalFactory.getInstance(type == null ? "PC/SC" : type, arg, p);
              return tf;
          } catch (UnsupportedEncodingException | MalformedURLException | ClassNotFoundException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) {
              throw new NoSuchAlgorithmException("Could not load " + classname + ": " + e.getMessage());
          } catch (NoSuchAlgorithmException e) {
              if (e.getCause() != null) {
                  Class<?> cause = e.getCause().getClass();
                  if (cause.equals(java.lang.UnsupportedOperationException.class)) {
                      throw new NoSuchAlgorithmException(e.getCause().getMessage());
                  }
                  if (cause.equals(java.lang.UnsatisfiedLinkError.class)) {
                      throw new NoSuchAlgorithmException(e.getCause().getMessage());
                  }
              }
              throw e;
          }
      }
docs: Load the TerminalFactory, possibly from a JAR and with arguments