Adds a jar file to be scanned

@param jars
jars to be added to the scanner

@return this scanner
960302
public JarScanner addJar(Collection<URL> jars) {
        this.jars.addAll(jars.stream().map(JarScanner::toUri).collect(Collectors.toList()));
        return this;
    }
844390
public Weld addPackages(boolean scanRecursively, Class<?>... packageClasses) {
        for (Class<?> packageClass : packageClasses) {
            addPackage(scanRecursively, packageClass);
        }
        return this;
    }
997957
public Jar setJarPrefix(Path file) {
        verifyNotSealed();
        if (jos != null)
            throw new IllegalStateException("Really executable cannot be set after entries are added.");
        if (file != null && jarPrefixStr != null)
            throw new IllegalStateException("A prefix has already been set (" + jarPrefixStr + ")");
        this.jarPrefixFile = file;
        return this;
    }
961565
public static List<Class<?>> getComponentClasses(URL jar) throws IOException {
        JarInputStream jarFile = new JarInputStream(jar.openStream());
        URLClassLoader cl = new URLClassLoader(new URL[]{jar}, Thread.currentThread().getContextClassLoader());
        List<Class<?>> idx = new ArrayList<Class<?>>();

        JarEntry jarEntry = jarFile.getNextJarEntry();
        while (jarEntry != null) {
            String classname = jarEntry.getName();
//            System.out.println(classname);
            if (classname.endsWith(".class")) {
                classname = classname.substring(0, classname.indexOf(".class")).replace('/', '.');
                try {
                    Class<?> c = Class.forName(classname, false, cl);
                    for (Method method : c.getMethods()) {
                        if ((method.getAnnotation(Execute.class)) != null) {
                            idx.add(c);
                            break;
                        }
                    }
                } catch (ClassNotFoundException ex) {
                    ex.printStackTrace();
                }
            }
            jarEntry = jarFile.getNextJarEntry();
        }
        jarFile.close();
        return idx;
    }
445840
public static Set<Class<?>> scanForClasses(final File directory, final String packagePath)
		throws ClassNotFoundException
	{
		return AnnotationExtensions.scanForAnnotatedClasses(directory, packagePath, null);
	}
1224659
private static void addClasspathEntries(final Object owner, final ClassLoader classLoader,
            final ClasspathOrder classpathOrderOut, final ScanSpec scanSpec, final LogNode log) {
        // type ClasspathEntry[]
        final Object entries = ReflectionUtils.getFieldVal(owner, "entries", false);
        if (entries != null) {
            for (int i = 0, n = Array.getLength(entries); i < n; i++) {
                // type ClasspathEntry
                final Object entry = Array.get(entries, i);
                // type BundleFile
                final Object bundlefile = ReflectionUtils.getFieldVal(entry, "bundlefile", false);
                addBundleFile(bundlefile, new HashSet<>(), classLoader, classpathOrderOut, scanSpec, log);
            }
        }
    }
127793
public List<String> selectJars(String targetPath) {
        List<String> jarPaths = new ArrayList<String>();

        if (targetPath == null) {
            return jarPaths;
        }

        File targetDir = new File(targetPath);
        if (!UtilImpl_FileUtils.exists(targetDir)) {
            return jarPaths;
        }

        File[] targetFiles = UtilImpl_FileUtils.listFiles(targetDir);
        if (targetFiles != null) {
            for (File nextTargetFile : targetFiles) {
                String nextTargetName = nextTargetFile.getName();
                if (nextTargetName.toUpperCase().endsWith(".JAR")) {
                    String nextTargetPath = targetPath + "/" + nextTargetName;
                    jarPaths.add(nextTargetPath);
                }
            }
        }

        return jarPaths;
    }
624223
@Override
    public List<File> scan() {

        File baseDirFile = new File(baseDir);

        List<File> includedFiles = walkDirectory(baseDirFile);
        return includedFiles;
    }
895053
private void fillJars()
  {
    synchronized (_pathList) {
      _pathList.clear();
    //_jarList.clear();

      loadPaths(_pathList);
      
      Collections.sort(_pathList);

      for (PathImpl jar : _pathList) {
        addJar(jar);
      }
    }
  }
110362
public Jar addEntry(Path path, String file) throws IOException {
        return addEntry(path, Paths.get(file));
    }
1308601
protected List<File> findJarFile(String scriptLibDir) {
		List<File> files = new ArrayList<File>();
		try {
			File file = new File(scriptLibDir);
			if (file.isDirectory()) {
				for (File f : file.listFiles()) {
					if (f.isFile() && f.getName().endsWith(".jar")) {
						files.add(f);
					}
				}
			}
		} catch (Exception e) {
			_log.error(e.getMessage(), e);
		}
		return files;
	}
1117640
static String readFileFromJarfile(String fulljarpath) throws IOException {
        assert (fulljarpath.contains(".jar!"));

        String[] paths = fulljarpath.split("!");
        if (paths[0].startsWith("file:"))
            paths[0] = paths[0].substring("file:".length());
        paths[1] = paths[1].substring(1);

        return readFileFromJarfile(paths[0], paths[1]);
    }
1177441
public List<String> scan() {
        try {
            JarFile jar = new JarFile(jarURL.getFile());
            try {
                List<String> result = new ArrayList<>();
                Enumeration<JarEntry> en = jar.entries();
                while (en.hasMoreElements()) {
                    JarEntry entry = en.nextElement();
                    String path = entry.getName();
                    boolean match = includes.size() == 0;
                    if (!match) {
                        for (String pattern : includes) {
                            if ( patternMatches(pattern, path)) {
                                match = true;
                                break;
                            }
                        }
                    }
                    if (match) {
                        for (String pattern : excludes) {
                            if ( patternMatches(pattern, path)) {
                                match = false;
                                break;
                            }
                        }
                    }
                    if (match) {
                        result.add(path);
                    }
                }
                return result;
            } finally {
                jar.close();
            }
        } catch (IOException e) {
            throw new IllegalStateException(e);
        }
    }
1038306
public static Set<Path> getDirectoriesFromJar(Path pathToJarFile) throws IOException {
        Set<Path> result = new HashSet<Path>();
        ZipFile jarfile = new ZipFile(pathToJarFile.toFile());
        try {
            final Enumeration<? extends ZipEntry> entries = jarfile.entries();
            while (entries.hasMoreElements()) {
                ZipEntry entry = entries.nextElement();
                if (entry.isDirectory()) {
                    result.add(Paths.get(entry.getName()));
                }
            }
            jarfile.close();
        } finally {
            IOUtils.closeQuietly(jarfile);
        }
        return result;
    }
267185
private void addClassByJar(ClassLoader classLoader, URL url, String packageName, String packageDirName) {
        // 从url中获取jar，然后从此jar包得到一个枚举类，然后进行迭代.
        JarFile jar;
        try {
            jar = ((JarURLConnection) url.openConnection()).getJarFile();
            Enumeration<JarEntry> entries = jar.entries();
            while (entries.hasMoreElements()) {
                // 获取jar里的一个实体 可以是目录 和一些jar包里的其他文件 如META-INF等文件
                JarEntry entry = entries.nextElement();
                String name = entry.getName();
                // 如果是以/开头的,则获取后面的字符串
                if (name.charAt(0) == '/') {
                    name = name.substring(1);
                }

                // 如果前半部分和定义的包名相同.
                if (name.startsWith(packageDirName)) {
                    int index = name.lastIndexOf('/');
                    // 如果以"/"结尾，则是一个包，获取包名并把"/"替换成"."
                    if (index != -1) {
                        packageName = name.substring(0, index).replace('/', '.');
                    }
                    // 如果可以迭代下去 并且是一个包,如果是一个.class文件 而且不是目录
                    if (index != -1 && name.endsWith(".class") && !entry.isDirectory()) {
                        // 去掉后面的".class" 获取真正的类名
                        String className = name.substring(packageName.length() + 1, name.length() - 6);
                        this.addClassByName(classLoader, packageName + '.' + className);
                    }
                }
            }
        } catch (IOException expected) {
            // 此处不打印堆栈信息.
            log.warn("从jar文件中读取class出错.");
        }
    }
805771
def add_jars(jars):
    

    #if the parameter is a string, convert to a single element list
    if isinstance(jars,str):
        jars = [jars]

    _add_to_submit_args("--jars "+ ",".join(jars)  +" pyspark-shell")
205184
public Set<Class<?>> scan() {
		for (URL url : ResourceUtil.getResourceIter(this.packagePath)) {
			switch (url.getProtocol()) {
			case "file":
				scanFile(new File(URLUtil.decode(url.getFile(), this.charset.name())), null);
				break;
			case "jar":
				scanJar(URLUtil.getJarFile(url));
				break;
			}
		}
		
		if(CollUtil.isEmpty(this.classes)) {
			scanJavaClassPaths();
		}
		
		return Collections.unmodifiableSet(this.classes);
	}