@Override public FileObject getFileForInput(Location location, String packageName, String relativeName) throws IOException { if (!hasLocation(location)) { throw new IllegalArgumentException(String.valueOf(location)); } final File root = new File(outputRoot); final String path = FileObjects.resolveRelativePath(packageName, relativeName); final String[] names = FileObjects.getFolderAndBaseName(path, FileObjects.NBFS_SEPARATOR_CHAR); final javax.tools.FileObject jfo = tx.readFileObject(location, names[0], names[1]); if (jfo != null) { return (JavaFileObject) jfo; } final Archive archive = provider.getArchive(BaseUtilities.toURI(root).toURL(), false); return archive != null ? archive.getFile(path) : null; }
@NonNull static TypeCache newInstance(Iterable<? extends URL> bootClassPath) { Archive ctSym = null; final CachingArchiveProvider ap = CachingArchiveProvider.getDefault(); for (URL root : bootClassPath) { if (ap.hasCtSym(root)) { ctSym = ap.getArchive(root, true); break; } } if (ctSym == null) { throw new IllegalArgumentException( String.format( "No profile info for boot classpath: %s", //NOI18N bootClassPath)); } return new TypeCache(ctSym); }
for(ClassPath.Entry entry : this.cp.entries()) { try { Archive archive = provider.getArchive( entry.getURL(), cacheFile ); if (archive != null) { Iterable<JavaFileObject> entries = archive.getFiles( folderName, ignoreExcludes?null:entry, kinds, filter);
@Override public javax.tools.FileObject getFileForOutput( Location l, String pkgName, String relativeName, javax.tools.FileObject sibling ) throws IOException, UnsupportedOperationException, IllegalArgumentException { if (!allowOutput) { throw new UnsupportedOperationException("Output is unsupported."); //NOI18N } javax.tools.JavaFileObject file = findFile (pkgName, relativeName); if (file == null) { final List<ClassPath.Entry> entries = this.cp.entries(); if (!entries.isEmpty()) { final String resourceName = FileObjects.resolveRelativePath(pkgName, relativeName); file = provider.getArchive(entries.get(0).getURL(), cacheFile).create(resourceName, filter); } } return file; //todo: wrap to make read only }
@Override public JavaFileObject getJavaFileForInput(Location location, String className, JavaFileObject.Kind kind) throws IOException { if (!hasLocation(location)) { throw new IllegalArgumentException(String.valueOf(location)); } final String [] names = FileObjects.getParentRelativePathAndName(className); if (kind == JavaFileObject.Kind.CLASS) { javax.tools.FileObject fo = tx.readFileObject(location, names[0], names[1]); if (fo != null) { return (JavaFileObject)fo; } } names[1] = names[1] + kind.extension; try { final File root = new File (outputRoot); Archive archive = provider.getArchive (BaseUtilities.toURI(root).toURL(), false); if (archive != null) { Iterable<JavaFileObject> files = archive.getFiles(names[0], null, null, null); for (JavaFileObject e : files) { if (names[1].equals(e.getName())) { return e; } } } } catch (IOException e) { Exceptions.printStackTrace(e); } return null; }
private javax.tools.JavaFileObject findFile(final String pkgName, String relativeName) { assert pkgName != null; assert relativeName != null; final String resourceName = FileObjects.resolveRelativePath(pkgName,relativeName); for( ClassPath.Entry root : this.cp.entries()) { try { final Archive archive = provider.getArchive (root.getURL(), cacheFile); if (archive != null) { final JavaFileObject file = archive.getFile(resourceName); if (file != null) { return file; } } } catch (IOException e) { Exceptions.printStackTrace(e); } } return null; } }
@Override public JavaFileObject getJavaFileForInput (Location l, String className, JavaFileObject.Kind kind) { final String[] namePair = FileObjects.getParentRelativePathAndName(className); namePair[1] = namePair[1] + kind.extension; for( ClassPath.Entry root : this.cp.entries()) { try { Archive archive = provider.getArchive (root.getURL(), cacheFile); if (archive != null) { Iterable<JavaFileObject> files = archive.getFiles(namePair[0], ignoreExcludes?null:root, null, filter); for (JavaFileObject e : files) { if (namePair[1].equals(e.getName())) { return e; } } } } catch (IOException e) { Exceptions.printStackTrace(e); } } return null; }
public static ClassLoader forURLs( @NonNull final URL[] urls, @NullAllowed final ClassLoader parent, @NullAllowed final Consumer<? super URL> usedRoots) { Parameters.notNull("urls", urls); //NOI18N final List<Pair<URL,Archive>> archives = new ArrayList<>(urls.length); for (URL url : urls) { final Archive arch = CachingArchiveProvider.getDefault().getArchive(url, false); if (arch != null) { archives.add(Pair.of(url,arch)); } } return new CachingArchiveClassLoader( archives, parent, usedRoots); }