public MemoryFileManager(ClassLoader classLoader, JavaFileManager fileManager) { super(fileManager); helper = new PackageHelper(classLoader); }
public List<JavaFileObject> find(String packageName) throws IOException { String javaPackageName = packageName.replaceAll("\\.", "/"); List<JavaFileObject> result = new ArrayList<>(); Enumeration<URL> urlEnumeration = classLoader.getResources(javaPackageName); while (urlEnumeration.hasMoreElements()) { URL resource = urlEnumeration.nextElement(); //Need to urldecode it too, since bug in JDK URL class which does not url decode it, so if it contains spaces you are screwed final File directory = new File(decodeURIComponent(resource.getFile(), false)); if (directory.isDirectory()) { result.addAll(browseDir(packageName, directory)); } else { result.addAll(browseJar(resource)); } } return result; }
@Override public Iterable<JavaFileObject> list(Location location, String packageName, Set<JavaFileObject.Kind> kinds, boolean recurse) throws IOException { if (location == StandardLocation.CLASS_PATH && kinds.contains(JavaFileObject.Kind.CLASS)) { return helper.find(packageName); } return super.list(location, packageName, kinds, recurse); } }
public List<JavaFileObject> find(String packageName) throws IOException { String javaPackageName = packageName.replaceAll("\\.", "/"); List<JavaFileObject> result = new ArrayList<>(); Enumeration<URL> urlEnumeration = classLoader.getResources(javaPackageName); while (urlEnumeration.hasMoreElements()) { URL resource = urlEnumeration.nextElement(); //Need to urldecode it too, since bug in JDK URL class which does not url decode it, so if it contains spaces you are screwed final File directory = new File(decodeURIComponent(resource.getFile(), false)); if (directory.isDirectory()) { result.addAll(browseDir(packageName, directory)); } else { result.addAll(browseJar(resource)); } } return result; }
@Override public Iterable<JavaFileObject> list(Location location, String packageName, Set<JavaFileObject.Kind> kinds, boolean recurse) throws IOException { if (location == StandardLocation.CLASS_PATH && kinds.contains(JavaFileObject.Kind.CLASS)) { return helper.find(packageName); } return super.list(location, packageName, kinds, recurse); } }
public MemoryFileManager(ClassLoader classLoader, JavaFileManager fileManager) { super(fileManager); helper = new PackageHelper(classLoader); }