test/tools/javac/processing/filer/TestGetResource2.java

changeset 699
d2aaaec153e8
parent 655
f3323b1c65ee
child 1466
b52a38d4536c
     1.1 --- a/test/tools/javac/processing/filer/TestGetResource2.java	Wed Sep 29 14:01:37 2010 -0700
     1.2 +++ b/test/tools/javac/processing/filer/TestGetResource2.java	Wed Sep 29 23:27:57 2010 -0700
     1.3 @@ -1,5 +1,5 @@
     1.4  /*
     1.5 - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
     1.6 + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
     1.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.8   *
     1.9   * This code is free software; you can redistribute it and/or modify it
    1.10 @@ -24,6 +24,7 @@
    1.11  /* @test
    1.12   * @bug 6929404
    1.13   * @summary Filer.getResource(SOURCE_PATH, ...) does not work when -sourcepath contains >1 entry
    1.14 + * @library ../../lib
    1.15   */
    1.16  
    1.17  import java.io.*;
    1.18 @@ -114,8 +115,7 @@
    1.19              throw new Exception(errors + " errors occurred");
    1.20      }
    1.21  
    1.22 -    @SupportedAnnotationTypes("*")
    1.23 -    static class AnnoProc extends AbstractProcessor {
    1.24 +    static class AnnoProc extends JavacTestingAbstractProcessor {
    1.25  
    1.26          public @Override boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
    1.27              if (roundEnv.processingOver()) {
    1.28 @@ -123,27 +123,23 @@
    1.29              }
    1.30  
    1.31              try {
    1.32 -                FileObject resource = processingEnv.getFiler().getResource(StandardLocation.SOURCE_PATH, "resources", "file.txt");
    1.33 +                FileObject resource = filer.getResource(StandardLocation.SOURCE_PATH, "resources", "file.txt");
    1.34                  try {
    1.35                      resource.openInputStream().close();
    1.36 -                    processingEnv.getMessager().printMessage(Kind.NOTE, "found: " + resource.toUri());
    1.37 +                    messager.printMessage(Kind.NOTE, "found: " + resource.toUri());
    1.38                      return true;
    1.39                  } catch (IOException x) {
    1.40 -                    processingEnv.getMessager().printMessage(Kind.ERROR, "could not read: " + resource.toUri());
    1.41 +                    messager.printMessage(Kind.ERROR, "could not read: " + resource.toUri());
    1.42                      x.printStackTrace();
    1.43                  }
    1.44              } catch (IOException x) {
    1.45 -                processingEnv.getMessager().printMessage(Kind.ERROR, "did not find resource");
    1.46 +                messager.printMessage(Kind.ERROR, "did not find resource");
    1.47                  x.printStackTrace();
    1.48              }
    1.49  
    1.50              return false;
    1.51          }
    1.52  
    1.53 -        @Override
    1.54 -        public SourceVersion getSupportedSourceVersion() {
    1.55 -            return SourceVersion.latest();
    1.56 -        }
    1.57      }
    1.58  
    1.59      private File write(File dir, String path, String contents) throws IOException {

mercurial