1313 */
1414package org .joor .test ;
1515
16- import java .io .Serializable ;
1716import java .util .Collections ;
1817
19-
20-
21- import java .util .HashSet ;
18+ import java .util .Locale ;
2219import java .util .Set ;
23- import java .util .function . Supplier ;
20+ import java .util .concurrent . atomic . AtomicReference ;
2421
2522import javax .annotation .processing .Completion ;
2623import javax .annotation .processing .ProcessingEnvironment ;
3128import javax .lang .model .element .Element ;
3229import javax .lang .model .element .ExecutableElement ;
3330import javax .lang .model .element .TypeElement ;
31+ import javax .tools .Diagnostic ;
3432
3533import org .joor .CompileOptions ;
3634import org .joor .Reflect ;
3735import org .joor .ReflectException ;
38- import org .junit .Assert ;
3936import org .junit .Test ;
4037
4138import static org .junit .Assert .*;
@@ -159,6 +156,7 @@ public SourceVersion getSupportedSourceVersion() {
159156
160157 @ Override
161158 public void init (ProcessingEnvironment processingEnv ) {
159+ processingEnv .getMessager ().printMessage (Diagnostic .Kind .NOTE , "running " + getClass ().getName ());
162160 }
163161
164162 @ Override
@@ -178,6 +176,24 @@ public Iterable<? extends Completion> getCompletions(Element element, Annotation
178176 return Collections .emptyList ();
179177 }
180178 }
179+
180+ /**
181+ * -proc:only is a standard option and should be supported.
182+ * see https://docs.oracle.com/javase/7/docs/technotes/tools/windows/javac.html
183+ */
184+ @ Test
185+ public void testProcOnlyWithDiagnostics () {
186+ AtomicReference <String > diagMessage = new AtomicReference <>();
187+ Object result = Reflect .compile ("p.D" , "package p; public class D extends B {} class B {}" ,
188+ new CompileOptions ().options ("-proc:only" )
189+ .processors (new AProcessor ())
190+ .withDiagnosticListener (diagnostic -> {
191+ diagMessage .set (diagnostic .getMessage (Locale .ENGLISH ));
192+ }));
193+ assertNull (result );
194+ assertNotNull (diagMessage .get ());
195+ }
196+
181197}
182198
183199@interface A {}
0 commit comments