test/tools/javac/processing/filer/TestGetResource2.java
Print this page
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
@@ -22,10 +22,11 @@
*/
/* @test
* @bug 6929404
* @summary Filer.getResource(SOURCE_PATH, ...) does not work when -sourcepath contains >1 entry
+ * @library ../../lib
*/
import java.io.*;
import java.security.*;
import java.util.*;
@@ -112,40 +113,35 @@
if (errors > 0)
throw new Exception(errors + " errors occurred");
}
- @SupportedAnnotationTypes("*")
- static class AnnoProc extends AbstractProcessor {
+ static class AnnoProc extends JavacTestingAbstractProcessor {
public @Override boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
if (roundEnv.processingOver()) {
return false;
}
try {
- FileObject resource = processingEnv.getFiler().getResource(StandardLocation.SOURCE_PATH, "resources", "file.txt");
+ FileObject resource = filer.getResource(StandardLocation.SOURCE_PATH, "resources", "file.txt");
try {
resource.openInputStream().close();
- processingEnv.getMessager().printMessage(Kind.NOTE, "found: " + resource.toUri());
+ messager.printMessage(Kind.NOTE, "found: " + resource.toUri());
return true;
} catch (IOException x) {
- processingEnv.getMessager().printMessage(Kind.ERROR, "could not read: " + resource.toUri());
+ messager.printMessage(Kind.ERROR, "could not read: " + resource.toUri());
x.printStackTrace();
}
} catch (IOException x) {
- processingEnv.getMessager().printMessage(Kind.ERROR, "did not find resource");
+ messager.printMessage(Kind.ERROR, "did not find resource");
x.printStackTrace();
}
return false;
}
- @Override
- public SourceVersion getSupportedSourceVersion() {
- return SourceVersion.latest();
- }
}
private File write(File dir, String path, String contents) throws IOException {
File f = new File(dir, path);
f.getParentFile().mkdirs();