private static final Class<?>[] getVisibleClasses(Map<String, String> options) { // --Variables List<Class<?>> classes = new ArrayList<Class<?>>(); // (get classpath) String pathSep = System.getProperty("path.separator"); String[] cp = System.getProperties().getProperty("java.class.path", null).split(pathSep); // --Configuration ensureScalaPath(options, cp); // --Fill Options // (get classes) for (String entry : cp) { // (should skip?) if (entry.equals(".") || entry.trim().length() == 0) { continue; } boolean isIgnored = false; for (String pattern : ignoredClasspath) { if (entry.matches(pattern)) { log.debug(LOG_TAG, "Ignoring options in classpath element: " + entry); isIgnored = true; break; } } if (isIgnored) { continue; } // (no, don't skip) File f = new File(entry); if (f.isDirectory()) { // --Case: Files LazyFileIterator iter = new LazyFileIterator(f, ".*class$"); while (iter.hasNext()) { // (get the associated class) Class<?> clazz = filePathToClass(entry, iter.next().getPath()); if (clazz != null) { // (add the class if it's valid) classes.add(clazz); } } } else if (!isIgnored(entry)) { // --Case: Jar try { JarFile jar = new JarFile(f); Enumeration<JarEntry> e = jar.entries(); while (e.hasMoreElements()) { // (for each jar file element) JarEntry jarEntry = e.nextElement(); String clazz = jarEntry.getName(); if (clazz.matches(".*class$")) { // (if it's a class) clazz = clazz.substring(0, clazz.length() - 6).replaceAll("/", "."); // (add it) try { classes.add(Class.forName(clazz, false, ClassLoader.getSystemClassLoader())); } catch (ClassNotFoundException ex) { throw Log.internal("Could not load class in jar: " + f + " at path: " + clazz); } catch (NoClassDefFoundError ex) { log.debug(LOG_TAG, "Could not scan class: " + clazz + " (in jar: " + f + ")"); } } } } catch (IOException e) { throw log.fail("Could not open jar file: " + f + "(are you sure the file exists?)"); } } else { // case: ignored jar } } return classes.toArray(new Class<?>[classes.size()]); }