< prev index next >

test/tools/javac/T6406771.java

Print this page




  33         "line:33", "line:33",
  34 //       1         2         3         4         5         6
  35 //3456789012345678901234567890123456789012345678901234567890
  36       "col:7", "col:16", "col:26",                 // this line uses spaces
  37         "col:9",        "col:25",       "col:41",  // this line uses tabs
  38                    "col:20",              "col:43" // this line uses a mixture
  39     };
  40 
  41     // White-space after this point does not matter
  42 
  43     public static void main(String[] args) throws IOException {
  44         String self = T6406771.class.getName();
  45         String testSrc = System.getProperty("test.src");
  46         String testClasses = System.getProperty("test.classes");
  47 
  48         JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
  49         try (StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null)) {
  50             JavaFileObject f = fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrc, self+".java"))).iterator().next();
  51 
  52             List<String> opts = Arrays.asList(
  53                 "-XaddExports:jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED",
  54                 "-XaddExports:jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED",
  55                 "-XDaccessInternalAPI",
  56                 "-d", ".",
  57                 "-processorpath", testClasses,
  58                 "-processor", self,
  59                 "-proc:only");
  60 
  61             JavacTask task = (JavacTask)tool.getTask(null, fm, null, opts, null, Arrays.asList(f));
  62 
  63             if (!task.call())
  64                 throw new AssertionError("failed");
  65         }
  66     }
  67 
  68     public boolean process(Set<? extends TypeElement> elems, RoundEnvironment rEnv) {
  69         final String LINE = "line" + ':';   // avoid matching this string
  70         final String COLUMN  = "col" + ':';
  71         final Messager messager = processingEnv.getMessager();
  72         final Trees trees = Trees.instance(processingEnv);
  73 
  74         TreeScanner<Void,LineMap> s = new  TreeScanner<Void,LineMap>() {




  33         "line:33", "line:33",
  34 //       1         2         3         4         5         6
  35 //3456789012345678901234567890123456789012345678901234567890
  36       "col:7", "col:16", "col:26",                 // this line uses spaces
  37         "col:9",        "col:25",       "col:41",  // this line uses tabs
  38                    "col:20",              "col:43" // this line uses a mixture
  39     };
  40 
  41     // White-space after this point does not matter
  42 
  43     public static void main(String[] args) throws IOException {
  44         String self = T6406771.class.getName();
  45         String testSrc = System.getProperty("test.src");
  46         String testClasses = System.getProperty("test.classes");
  47 
  48         JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
  49         try (StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null)) {
  50             JavaFileObject f = fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrc, self+".java"))).iterator().next();
  51 
  52             List<String> opts = Arrays.asList(
  53                 "--add-exports", "jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED",
  54                 "--add-exports", "jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED",
  55                 "-XDaccessInternalAPI",
  56                 "-d", ".",
  57                 "-processorpath", testClasses,
  58                 "-processor", self,
  59                 "-proc:only");
  60 
  61             JavacTask task = (JavacTask)tool.getTask(null, fm, null, opts, null, Arrays.asList(f));
  62 
  63             if (!task.call())
  64                 throw new AssertionError("failed");
  65         }
  66     }
  67 
  68     public boolean process(Set<? extends TypeElement> elems, RoundEnvironment rEnv) {
  69         final String LINE = "line" + ':';   // avoid matching this string
  70         final String COLUMN  = "col" + ':';
  71         final Messager messager = processingEnv.getMessager();
  72         final Trees trees = Trees.instance(processingEnv);
  73 
  74         TreeScanner<Void,LineMap> s = new  TreeScanner<Void,LineMap>() {


< prev index next >