private ResourceFile checkScript(String scriptName) {

		// Check for pre-compiled GhidraScript (e.g., my.package.Impl.class)
		String classExtension = ".class";

		if (scriptName.endsWith(classExtension)) {
			String className =
				scriptName.substring(0, scriptName.length() - classExtension.length());
			try {

				// Create a classloader that contains all the ghidra_script paths (especially the one
				// specified in -scriptPath!)
				List<ResourceFile> dirs = GhidraScriptUtil.getScriptSourceDirectories();
				List<URL> urls = new ArrayList<>();

				for (ResourceFile dir : dirs) {
					try {
						urls.add(dir.toURL());
					}
					catch (MalformedURLException e) {
						// Do nothing. If can't make a URL out of the dir, don't add it.
					}
				}

				classLoaderForDotClassScripts =
					URLClassLoader.newInstance(urls.toArray(new URL[0]));

				Class<?> c = Class.forName(className, true, classLoaderForDotClassScripts);

				if (GhidraScript.class.isAssignableFrom(c)) {
					// No issues, but return null, which signifies we don't actually have a
					// ResourceFile to associate with the script name
					return null;
				}

				Msg.error(this,
					"REPORT SCRIPT ERROR: java class '" + className + "' is not a GhidraScript");
			}
			catch (ClassNotFoundException e) {
				Msg.error(this,
					"REPORT SCRIPT ERROR: java class not found for '" + className + "'");
			}
			throw new IllegalArgumentException("Invalid script: " + scriptName);
		}

		try {
			ResourceFile scriptSource = findScript(scriptName);
			GhidraScriptProvider provider = GhidraScriptUtil.getProvider(scriptSource);

			if (provider == null) {
				throw new IOException("Missing plugin needed to run scripts of this type. Please " +
					"ensure you have installed the necessary plugin.");
			}

			return scriptSource;
		}
		catch (Exception | NoClassDefFoundError exc) {
			String logErrorMsg = "REPORT SCRIPT ERROR: " + scriptName + " : " + exc.getMessage();
			Msg.error(this, logErrorMsg);
		}
		throw new IllegalArgumentException("Invalid script: " + scriptName);
	}
Checks the script name to ensure it exists. If the script type has a GhidraScriptProvider
(any type of script but .class), then return the ResourceFile that represents that script.

If the script is a class file, return null (one class loader is stored to allow the
Headless Analyzer to find all the class files).

GhidraScript is not instantiated here, because it is important that each script be
instantiated at the time it's used. If a GhidraScript object is re-used, this causes
problems where GhidraScript variables aren't being re-initialized at each use of the script.

@param scriptName The name of the script to check
@return ResourceFile representing the source file, or null (if script is a .class file)
Ghidra/Features/Base/src/main/java/ghidra/app/util/headless/HeadlessAnalyzer.java