< prev index next >

test/tools/javac/processing/loader/testClose/TestClose2.java

Print this page




  75             protected ClassLoader getClassLoader(URL[] urls) {
  76                 return new URLClassLoader(urls, cl) {
  77                     @Override
  78                     public void close() throws IOException {
  79                         System.err.println(getClass().getName() + " closing");
  80                         TestClose2.this.closedCount++;
  81                         TestClose2.this.closedIsLast = true;
  82                         super.close();
  83                     }
  84                 };
  85             }
  86         };
  87 
  88         fm.setLocation(StandardLocation.CLASS_OUTPUT,
  89                 Collections.singleton(new File(".")));
  90         fm.setLocation(StandardLocation.ANNOTATION_PROCESSOR_PATH,
  91                 Collections.singleton(testClasses));
  92         Iterable<? extends JavaFileObject> files =
  93                 fm.getJavaFileObjects(new File(testSrc, TestClose2.class.getName() + ".java"));
  94         List<String> options = Arrays.asList(
  95                 "-XaddExports:jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED",
  96                 "-XaddExports:jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED",
  97                 "-XaddExports:jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED",
  98                 "-processor", TestClose2.class.getName());
  99 
 100         JavacTask task = tool.getTask(null, fm, null, options, null, files);
 101         task.setTaskListener(this);
 102 
 103         if (!task.call())
 104             throw new Error("compilation failed");
 105 
 106         if (closedCount == 0)
 107             throw new Error("no closing message");
 108         else if (closedCount > 1)
 109             throw new Error(closedCount + " closed messages");
 110 
 111         if (!closedIsLast)
 112             throw new Error("closing message not last");
 113     }
 114 
 115     // AbstractProcessor methods
 116 
 117     @Override




  75             protected ClassLoader getClassLoader(URL[] urls) {
  76                 return new URLClassLoader(urls, cl) {
  77                     @Override
  78                     public void close() throws IOException {
  79                         System.err.println(getClass().getName() + " closing");
  80                         TestClose2.this.closedCount++;
  81                         TestClose2.this.closedIsLast = true;
  82                         super.close();
  83                     }
  84                 };
  85             }
  86         };
  87 
  88         fm.setLocation(StandardLocation.CLASS_OUTPUT,
  89                 Collections.singleton(new File(".")));
  90         fm.setLocation(StandardLocation.ANNOTATION_PROCESSOR_PATH,
  91                 Collections.singleton(testClasses));
  92         Iterable<? extends JavaFileObject> files =
  93                 fm.getJavaFileObjects(new File(testSrc, TestClose2.class.getName() + ".java"));
  94         List<String> options = Arrays.asList(
  95                 "--add-exports", "jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED",
  96                 "--add-exports", "jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED",
  97                 "--add-exports", "jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED",
  98                 "-processor", TestClose2.class.getName());
  99 
 100         JavacTask task = tool.getTask(null, fm, null, options, null, files);
 101         task.setTaskListener(this);
 102 
 103         if (!task.call())
 104             throw new Error("compilation failed");
 105 
 106         if (closedCount == 0)
 107             throw new Error("no closing message");
 108         else if (closedCount > 1)
 109             throw new Error(closedCount + " closed messages");
 110 
 111         if (!closedIsLast)
 112             throw new Error("closing message not last");
 113     }
 114 
 115     // AbstractProcessor methods
 116 
 117     @Override


< prev index next >