@Test public void testGetResource_location_classpath() throws Exception { EclipseFileManager fileManager = new EclipseFileManager(null, Charsets.UTF_8); List<File> classpath = new ArrayList<>(); classpath.add(new File("src/test/projects/compile-jdt-proc/getresource-location-classpath/classes")); classpath.add(new File("src/test/projects/compile-jdt-proc/getresource-location-classpath/dependency.zip")); fileManager.setLocation(StandardLocation.CLASS_PATH, classpath); FilerImpl filer = new FilerImpl(null , fileManager, null , null ); Assert.assertEquals("dir resource", toString(filer.getResource(StandardLocation.CLASS_PATH, "", "dirresource.txt"))); Assert.assertEquals("pkg jar resource", toString(filer.getResource(StandardLocation.CLASS_PATH, "pkg", "jarresource.txt"))); }
@Override public FileObject getResource(Location location, CharSequence pkg, CharSequence relativeName) throws IOException { FileObject file = fileManager.getFileForInput(location, pkg.toString(), relativeName.toString()); if (file == null) { throw new FileNotFoundException("Resource does not exist " + location + '/' + pkg + '/' + relativeName); } if (createdResources.contains(file.toUri())) { throw new FilerException("Resource already created " + pkg + "." + relativeName); } return file; }
FilerImpl implements Filer { @Override public FileObject getResource(Location location, CharSequence pkg, CharSequence relativeName) throws IOException { FileObject file = fileManager.getFileForInput(location, pkg.toString(), relativeName.toString()); if (file == null) { throw new FileNotFoundException("Resource does not exist " + location + '/' + pkg + '/' + relativeName); } if (createdResources.contains(file.toUri())) { throw new FilerException("Resource already created " + pkg + "." + relativeName); } return file; } }
FilerImpl implements Filer { @Override public FileObject getResource(Location location, CharSequence pkg, CharSequence relativeName) throws IOException { FileObject file = fileManager.getFileForInput(location, pkg.toString(), relativeName.toString()); if (file == null) { throw new FileNotFoundException("Resource does not exist " + location + '/' + pkg + '/' + relativeName); } if (createdResources.contains(file.toUri())) { throw new FilerException("Resource already created " + pkg + "." + relativeName); } return file; } FilerImpl(CompilerBuildContext context, StandardJavaFileManager fileManager, CompilerJdt incrementalCompiler, ProcessingEnvImpl processingEnv); }
FilerImpl implements Filer { @Override public FileObject getResource(Location location, CharSequence pkg, CharSequence relativeName) throws IOException { FileObject file = fileManager.getFileForInput(location, pkg.toString(), relativeName.toString()); if (file == null) { throw new FileNotFoundException("Resource does not exist " + location + '/' + pkg + '/' + relativeName); } if (createdResources.contains(file.toUri())) { throw new FilerException("Resource already created " + pkg + "." + relativeName); } return file; } FilerImpl(CompilerBuildContext context, StandardJavaFileManager fileManager, CompilerJdt incrementalCompiler, ProcessingEnvImpl processingEnv); @Override JavaFileObject createSourceFile(CharSequence name, Element... originatingElements); @Override JavaFileObject createClassFile(CharSequence name, Element... originatingElements); @Override FileObject createResource(Location location, CharSequence pkg, CharSequence relativeName, Element... originatingElements); @Override FileObject getResource(Location location, CharSequence pkg, CharSequence relativeName); void incrementalIterationReset(); Set<File> getWrittenFiles(); }
FilerImpl implements Filer { @Override public FileObject getResource(Location location, CharSequence pkg, CharSequence relativeName) throws IOException { FileObject file = fileManager.getFileForInput(location, pkg.toString(), relativeName.toString()); if (file == null) { throw new FileNotFoundException("Resource does not exist " + location + '/' + pkg + '/' + relativeName); } if (createdResources.contains(file.toUri())) { throw new FilerException("Resource already created " + pkg + "." + relativeName); } return file; } FilerImpl(CompilerBuildContext context, StandardJavaFileManager fileManager, CompilerJdt incrementalCompiler, ProcessingEnvImpl processingEnv); @Override JavaFileObject createSourceFile(CharSequence name, Element... originatingElements); @Override JavaFileObject createClassFile(CharSequence name, Element... originatingElements); @Override FileObject createResource(Location location, CharSequence pkg, CharSequence relativeName, Element... originatingElements); @Override FileObject getResource(Location location, CharSequence pkg, CharSequence relativeName); void incrementalIterationReset(); Set<File> getWrittenFiles();  }