001/*
002 * Copyright (C) 2022 - 2023, the original author or authors.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *    http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016package io.github.ascopes.jct.compilers;
017
018import io.github.ascopes.jct.ex.JctCompilerException;
019import io.github.ascopes.jct.filemanagers.AnnotationProcessorDiscovery;
020import io.github.ascopes.jct.filemanagers.LoggingMode;
021import io.github.ascopes.jct.utils.IterableUtils;
022import io.github.ascopes.jct.workspaces.Workspace;
023import java.io.UncheckedIOException;
024import java.nio.charset.Charset;
025import java.nio.charset.StandardCharsets;
026import java.util.Collection;
027import java.util.List;
028import java.util.Locale;
029import javax.annotation.processing.Processor;
030import javax.lang.model.SourceVersion;
031import org.apiguardian.api.API;
032import org.apiguardian.api.API.Status;
033
034/**
035 * Base definition of a compiler that can be configured to perform a compilation run against
036 * sources. This is designed to provide functionality that {@code javac} does by default, for JDK
037 * 17.
038 *
039 * @param <C> the implementation type. This is provided to allow call-chaining the implementation.
040 * @param <R> the compilation type that gets returned once compilation completes.
041 * @author Ashley Scopes
042 * @since 0.0.1
043 */
044@API(since = "0.0.1", status = Status.STABLE)
045public interface JctCompiler<C extends JctCompiler<C, R>, R extends JctCompilation> {
046
047  /**
048   * Default setting for deprecation warnings ({@code true}).
049   */
050  boolean DEFAULT_SHOW_DEPRECATION_WARNINGS = true;
051
052  /**
053   * Default setting for locale ({@link Locale#ROOT}).
054   */
055  Locale DEFAULT_LOCALE = Locale.ROOT;
056
057  /**
058   * Default setting for preview features ({@code false}).
059   */
060  boolean DEFAULT_PREVIEW_FEATURES = false;
061
062  /**
063   * Default setting for verbose logging ({@code false}).
064   */
065  boolean DEFAULT_VERBOSE = false;
066
067  /**
068   * Default setting for displaying warnings ({@code true}).
069   */
070  boolean DEFAULT_SHOW_WARNINGS = true;
071
072  /**
073   * Default setting for displaying warnings as errors ({@code false}).
074   */
075  boolean DEFAULT_FAIL_ON_WARNINGS = false;
076
077  /**
078   * Default setting for fixing modules being placed on the classpath by mistake ({@code true}).
079   */
080  boolean DEFAULT_FIX_JVM_MODULE_PATH_MISMATCH = true;
081
082  /**
083   * Default setting for inclusion of the current class path ({@code true}).
084   */
085  boolean DEFAULT_INHERIT_CLASS_PATH = true;
086
087  /**
088   * Default setting for inclusion of the current module path ({@code true}).
089   */
090  boolean DEFAULT_INHERIT_MODULE_PATH = true;
091
092  /**
093   * Default setting for inclusion of the current platform class path ({@code true}).
094   */
095  boolean DEFAULT_INHERIT_PLATFORM_CLASS_PATH = true;
096
097  /**
098   * Default setting for inclusion of the system module path ({@code true}).
099   */
100  boolean DEFAULT_INHERIT_SYSTEM_MODULE_PATH = true;
101
102  /**
103   * Default setting for logging file manager operations ({@link LoggingMode#DISABLED}).
104   */
105  LoggingMode DEFAULT_FILE_MANAGER_LOGGING_MODE = LoggingMode.DISABLED;
106
107  /**
108   * Default setting for logging diagnostics ({@link LoggingMode#ENABLED}).
109   */
110  LoggingMode DEFAULT_DIAGNOSTIC_LOGGING_MODE = LoggingMode.ENABLED;
111
112  /**
113   * Default setting for the compilation mode to use
114   * ({@link CompilationMode#COMPILATION_AND_ANNOTATION_PROCESSING}).
115   */
116  CompilationMode DEFAULT_COMPILATION_MODE = CompilationMode.COMPILATION_AND_ANNOTATION_PROCESSING;
117
118  /**
119   * Default setting for how to apply annotation processor discovery when no processors are
120   * explicitly defined ({@link AnnotationProcessorDiscovery#INCLUDE_DEPENDENCIES}).
121   */
122  AnnotationProcessorDiscovery DEFAULT_ANNOTATION_PROCESSOR_DISCOVERY =
123      AnnotationProcessorDiscovery.INCLUDE_DEPENDENCIES;
124
125  /**
126   * Default charset to use for compiler logs ({@link StandardCharsets#UTF_8}).
127   */
128  Charset DEFAULT_LOG_CHARSET = StandardCharsets.UTF_8;
129
130  /**
131   * Invoke the compilation and return the compilation result.
132   *
133   * <p>The actual classes to compile will be dynamically discovered. If you wish to
134   * specify the specific classes to compile, see {@link #compile(Workspace, String, String...)} or
135   * {@link #compile(Workspace, Collection)}.
136   *
137   * @param workspace the workspace to compile.
138   * @return the compilation result.
139   * @throws JctCompilerException  if the compiler threw an unhandled exception. This should not
140   *                               occur for compilation failures generally.
141   * @throws IllegalStateException if no compilation units were found.
142   * @throws UncheckedIOException  if an IO error occurs.
143   * @see #compile(Workspace, String, String...)
144   * @see #compile(Workspace, Collection)
145   */
146  R compile(Workspace workspace);
147
148  /**
149   * Invoke the compilation and return the compilation result.
150   *
151   * <p>Only classes matching the given class names will be compiled.
152   *
153   * <p>If you wish to let JCT determine which classes to compile dynamically, see
154   * {@link #compile(Workspace)} instead.
155   *
156   * @param workspace            the workspace to compile.
157   * @param firstClassName       the first class name to compile.
158   * @param additionalClassNames any additional class names to compile.
159   * @return the compilation result.
160   * @throws JctCompilerException  if the compiler threw an unhandled exception. This should not
161   *                               occur for compilation failures generally.
162   * @throws IllegalStateException if no compilation units were found.
163   * @throws UncheckedIOException  if an IO error occurs.
164   * @see #compile(Workspace)
165   * @see #compile(Workspace, Collection)
166   */
167  default R compile(Workspace workspace, String firstClassName, String... additionalClassNames) {
168    return compile(workspace, IterableUtils.combineOneOrMore(firstClassName, additionalClassNames));
169  }
170
171  /**
172   * Invoke the compilation and return the compilation result.
173   *
174   * <p>Only classes matching the given class names will be compiled.
175   *
176   * <p>If you wish to let JCT determine which classes to compile dynamically, see
177   * {@link #compile(Workspace)} instead.
178   *
179   * @param workspace  the workspace to compile.
180   * @param classNames the class names to compile.
181   * @return the compilation result.
182   * @throws JctCompilerException     if the compiler threw an unhandled exception. This should not
183   *                                  occur for compilation failures generally.
184   * @throws IllegalArgumentException if the collection is empty.
185   * @throws IllegalStateException    if no compilation units were found.
186   * @throws UncheckedIOException     if an IO error occurs.
187   * @see #compile(Workspace)
188   * @see #compile(Workspace, String, String...)
189   */
190  R compile(Workspace workspace, Collection<String> classNames);
191
192  /**
193   * Apply a given configurer to this compiler that can throw a checked exception.
194   *
195   * @param <E>        any exception that may be thrown.
196   * @param configurer the configurer to invoke.
197   * @return this compiler object for further call chaining.
198   * @throws E any exception that may be thrown by the configurer.
199   */
200  <E extends Exception> C configure(JctCompilerConfigurer<E> configurer) throws E;
201
202  /**
203   * Get the friendly printable name of this compiler object.
204   *
205   * @return the name of the compiler.
206   */
207  String getName();
208
209  /**
210   * Set the friendly name of this compiler.
211   *
212   * @param name the name to set.
213   * @return this compiler object for further call chaining.
214   */
215  C name(String name);
216
217  /**
218   * Get an <strong>immutable snapshot view</strong> of the current annotation processor options
219   * that are set.
220   *
221   * @return the current annotation processor options that are set.
222   */
223  List<String> getAnnotationProcessorOptions();
224
225  /**
226   * Add options to pass to any annotation processors.
227   *
228   * @param annotationProcessorOptions the options to pass.
229   * @return this compiler object for further call chaining.
230   */
231  C addAnnotationProcessorOptions(Iterable<String> annotationProcessorOptions);
232
233  /**
234   * Add options to pass to any annotation processors.
235   *
236   * @param annotationProcessorOption  the first option to pass.
237   * @param annotationProcessorOptions additional options to pass.
238   * @return this compiler object for further call chaining.
239   */
240  default C addAnnotationProcessorOptions(
241      String annotationProcessorOption,
242      String... annotationProcessorOptions
243  ) {
244    return addAnnotationProcessorOptions(
245        IterableUtils.combineOneOrMore(annotationProcessorOption, annotationProcessorOptions)
246    );
247  }
248
249  /**
250   * Get an <strong>immutable snapshot view</strong> of the current annotation processors that are
251   * explicitly set to be run, in the order that they were provided to the compiler.
252   *
253   * @return the current annotation processors that are set.
254   */
255  List<Processor> getAnnotationProcessors();
256
257  /**
258   * Add annotation processors to invoke.
259   *
260   * <p>This bypasses the discovery process of annotation processors provided in the annotation
261   * processor path.
262   *
263   * @param annotationProcessors the processors to invoke.
264   * @return this compiler object for further call chaining.
265   */
266  C addAnnotationProcessors(Iterable<? extends Processor> annotationProcessors);
267
268  /**
269   * Add annotation processors to invoke.
270   *
271   * <p>This bypasses the discovery process of annotation processors provided in the annotation
272   * processor path.
273   *
274   * @param annotationProcessor  the first processor to invoke.
275   * @param annotationProcessors additional processors to invoke.
276   * @return this compiler object for further call chaining.
277   */
278  default C addAnnotationProcessors(
279      Processor annotationProcessor,
280      Processor... annotationProcessors
281  ) {
282    return addAnnotationProcessors(
283        IterableUtils.combineOneOrMore(annotationProcessor, annotationProcessors));
284  }
285
286  /**
287   * Get an <strong>immutable snapshot view</strong> of the current compiler options that are set.
288   *
289   * @return the current compiler  options that are set.
290   */
291  List<String> getCompilerOptions();
292
293  /**
294   * Add command line options to pass to {@code javac}.
295   *
296   * @param compilerOptions the options to add.
297   * @return this compiler object for further call chaining.
298   */
299  C addCompilerOptions(Iterable<String> compilerOptions);
300
301  /**
302   * Add command line options to pass to {@code javac}.
303   *
304   * @param compilerOption  the first option to add.
305   * @param compilerOptions additional options to add.
306   * @return this compiler object for further call chaining.
307   */
308  default C addCompilerOptions(String compilerOption, String... compilerOptions) {
309    return addCompilerOptions(IterableUtils.combineOneOrMore(compilerOption, compilerOptions));
310  }
311
312  /**
313   * Determine whether verbose logging is enabled or not.
314   *
315   * <p>Unless otherwise changed or specified, implementations should default to
316   * {@link #DEFAULT_VERBOSE}.
317   *
318   * <p>Note that enabling this is compiler-specific behaviour. There is no guarantee that the
319   * output target or the format or verbosity of output will be consistent between different
320   * compiler implementations.
321   *
322   * @return whether verbose logging is enabled or not.
323   */
324  boolean isVerbose();
325
326  /**
327   * Set whether to use verbose output or not.
328   *
329   * <p>Unless otherwise changed or specified, implementations should default to
330   * {@link #DEFAULT_VERBOSE}.
331   *
332   * <p>Note that enabling this is compiler-specific behaviour. There is no guarantee that the
333   * output target or the format or verbosity of output will be consistent between different
334   * compiler implementations.
335   *
336   * @param enabled {@code true} for verbose output, {@code false} for normal output.
337   * @return this compiler for further call chaining.
338   */
339  C verbose(boolean enabled);
340
341  /**
342   * Determine whether preview features are enabled or not.
343   *
344   * <p>Unless otherwise changed or specified, implementations should default to
345   * {@link #DEFAULT_PREVIEW_FEATURES}.
346   *
347   * @return whether preview features are enabled or not.
348   */
349  boolean isPreviewFeatures();
350
351  /**
352   * Set whether to enable preview features or not.
353   *
354   * <p>Unless otherwise changed or specified, implementations should default to
355   * {@link #DEFAULT_PREVIEW_FEATURES}.
356   *
357   * @param enabled {@code true} to enable preview features, or {@code false} to disable them.
358   * @return this compiler object for further call chaining.
359   */
360  C previewFeatures(boolean enabled);
361
362  /**
363   * Determine whether warnings are enabled or not.
364   *
365   * <p>Unless otherwise changed or specified, implementations should default to
366   * {@link #DEFAULT_SHOW_WARNINGS}.
367   *
368   * @return whether warnings are enabled or not.
369   */
370  boolean isShowWarnings();
371
372  /**
373   * Set whether to enable displaying warnings or not.
374   *
375   * <p>Unless otherwise changed or specified, implementations should default to
376   * {@link #DEFAULT_SHOW_WARNINGS}.
377   *
378   * @param enabled {@code true} to enable warnings. {@code false} to disable them.
379   * @return this compiler object for further call chaining.
380   */
381  C showWarnings(boolean enabled);
382
383  /**
384   * Determine whether deprecation warnings are enabled or not.
385   *
386   * <p>Unless otherwise changed or specified, implementations should default to
387   * {@link #DEFAULT_SHOW_DEPRECATION_WARNINGS}.
388   *
389   * @return whether deprecation warnings are enabled or not.
390   */
391  boolean isShowDeprecationWarnings();
392
393  /**
394   * Set whether to enable deprecation warnings or not.
395   *
396   * <p>This is ignored if {@link #showWarnings(boolean)} is disabled.
397   *
398   * <p>Unless otherwise changed or specified, implementations should default to
399   * {@link #DEFAULT_SHOW_DEPRECATION_WARNINGS}.
400   *
401   * @param enabled {@code true} to enable deprecation warnings. {@code false} to disable them.
402   * @return this compiler object for further call chaining.
403   */
404  C showDeprecationWarnings(boolean enabled);
405
406  /**
407   * Determine whether warnings are being treated as errors or not.
408   *
409   * <p>Unless otherwise changed or specified, implementations should default to
410   * {@link #DEFAULT_FAIL_ON_WARNINGS}.
411   *
412   * @return whether warnings are being treated as errors or not.
413   */
414  boolean isFailOnWarnings();
415
416  /**
417   * Set whether to enable treating warnings as errors or not.
418   *
419   * <p>This is ignored if {@link #showWarnings(boolean)} is disabled.
420   *
421   * <p>Unless otherwise changed or specified, implementations should default to
422   * {@link #DEFAULT_FAIL_ON_WARNINGS}.
423   *
424   * @param enabled {@code true} to enable treating warnings as errors. {@code false} to disable
425   *                them.
426   * @return this compiler object for further call chaining.
427   */
428  C failOnWarnings(boolean enabled);
429
430  /**
431   * Get the compilation mode that is in use.
432   *
433   * <p>Unless otherwise changed or specified, implementations should default to
434   * {@link #DEFAULT_COMPILATION_MODE}.
435   *
436   * @return the compilation mode.
437   */
438  CompilationMode getCompilationMode();
439
440  /**
441   * Set the compilation mode to use for this compiler.
442   *
443   * <p>Unless otherwise changed or specified, implementations should default to
444   * {@link #DEFAULT_COMPILATION_MODE}.
445   *
446   * @param compilationMode the compilation mode to use.
447   * @return this compiler object for further call chaining.
448   */
449  C compilationMode(CompilationMode compilationMode);
450
451  /**
452   * Get the default release to use if no release or target version is specified.
453   *
454   * <p>This can <strong>not</strong> be configured.
455   *
456   * @return the default release version to use.
457   */
458  String getDefaultRelease();
459
460  /**
461   * Get the effective release to use for the actual compilation.
462   *
463   * <p>This may be determined from the {@link #getSource() source},
464   * {@link #getTarget() target}, {@link #getRelease() release}, and
465   * {@link #getDefaultRelease() default release.}
466   *
467   * @return the effective release.
468   */
469  String getEffectiveRelease();
470
471  /**
472   * Get the current release version that is set, or {@code null} if left to the compiler to decide.
473   * default.
474   *
475   * <p>Unless explicitly defined, the default setting is expected to be a sane compiler-specific
476   * default.
477   *
478   * @return the release version string, if set.
479   */
480  String getRelease();
481
482  /**
483   * Set the release version.
484   *
485   * <p>This will clear any source and target version that is set.
486   *
487   * <p>Unless explicitly defined, the default setting is expected to be a sane compiler-specific
488   * default.
489   *
490   * @param release the version to set.
491   * @return this compiler object for further call chaining.
492   */
493  C release(String release);
494
495  /**
496   * Set the release version.
497   *
498   * <p>This will clear any source and target version that is set.
499   *
500   * <p>Unless explicitly defined, the default setting is expected to be a sane compiler-specific
501   * default.
502   *
503   * @param release the version to set.
504   * @return this compiler object for further call chaining.
505   */
506  default C release(int release) {
507    if (release < 0) {
508      throw new IllegalArgumentException("Cannot provide a release version less than 0");
509    }
510
511    return release(Integer.toString(release));
512  }
513
514  /**
515   * Set the release version.
516   *
517   * <p>This will clear any source and target version that is set.
518   *
519   * <p>Unless explicitly defined, the default setting is expected to be a sane compiler-specific
520   * default.
521   *
522   * @param release the version to set.
523   * @return this compiler object for further call chaining.
524   */
525  default C release(SourceVersion release) {
526    return release(Integer.toString(release.ordinal()));
527  }
528
529  /**
530   * Get the current source version that is set, or {@code null} if left to the compiler to decide.
531   * default.
532   *
533   * <p>Unless explicitly defined, the default setting is expected to be a sane compiler-specific
534   * default.
535   *
536   * @return the source version string, if set.
537   */
538  String getSource();
539
540  /**
541   * Set the source version.
542   *
543   * <p>This will clear any release version that is set.
544   *
545   * <p>Unless explicitly defined, the default setting is expected to be a sane compiler-specific
546   * default.
547   *
548   * @param source the version to set.
549   * @return this compiler object for further call chaining.
550   */
551  C source(String source);
552
553  /**
554   * Set the source version.
555   *
556   * <p>This will clear any release version that is set.
557   *
558   * <p>Unless explicitly defined, the default setting is expected to be a sane compiler-specific
559   * default.
560   *
561   * @param source the version to set.
562   * @return this compiler object for further call chaining.
563   */
564  default C source(int source) {
565    if (source < 0) {
566      throw new IllegalArgumentException("Cannot provide a source version less than 0");
567    }
568
569    return source(Integer.toString(source));
570  }
571
572  /**
573   * Set the source version.
574   *
575   * <p>This will clear any release version that is set.
576   *
577   * <p>Unless explicitly defined, the default setting is expected to be a sane compiler-specific
578   * default.
579   *
580   * @param source the version to set.
581   * @return this compiler object for further call chaining.
582   */
583  default C source(SourceVersion source) {
584    return source(Integer.toString(source.ordinal()));
585  }
586
587  /**
588   * Get the current target version that is set, or {@code null} if left to the compiler default.
589   *
590   * <p>Unless explicitly defined, the default setting is expected to be a sane compiler-specific
591   * default.
592   *
593   * @return the target version string, if set.
594   */
595  String getTarget();
596
597  /**
598   * Set the target version.
599   *
600   * <p>This will clear any release version that is set.
601   *
602   * <p>Unless explicitly defined, the default setting is expected to be a sane compiler-specific
603   * default.
604   *
605   * @param target the version to set.
606   * @return this compiler object for further call chaining.
607   */
608  C target(String target);
609
610  /**
611   * Set the target version.
612   *
613   * <p>This will clear any release version that is set.
614   *
615   * <p>Unless explicitly defined, the default setting is expected to be a sane compiler-specific
616   * default.
617   *
618   * @param target the version to set.
619   * @return this compiler object for further call chaining.
620   */
621  default C target(int target) {
622    if (target < 0) {
623      throw new IllegalArgumentException("Cannot provide a target version less than 0");
624    }
625
626    return target(Integer.toString(target));
627  }
628
629  /**
630   * Set the target version.
631   *
632   * <p>This will clear any release version that is set.
633   *
634   * <p>Unless explicitly defined, the default setting is expected to be a sane compiler-specific
635   * default.
636   *
637   * @param target the version to set.
638   * @return this compiler object for further call chaining.
639   */
640  default C target(SourceVersion target) {
641    return target(Integer.toString(target.ordinal()));
642  }
643
644  /**
645   * Get whether we will attempt to fix modules appearing on the classpath, or non-modules appearing
646   * on the module path.
647   *
648   * <p>This enables correct classpath and module path detection when the test pack is a module but
649   * the code being compiled in the test is not, and vice versa. We need this because many build
650   * systems decide whether to populate the {@code --module-path} flat or the {@code --classpath}
651   * with JPMS-enabled dependencies based on whether the project under compilation is a JPMS module
652   * itself.
653   *
654   * <p>This only applies if {@link #isInheritModulePath()} or {@link #isInheritClassPath()} is
655   * enabled, and only applies to the current JVM classpath and module path.
656   *
657   * <p>Unless otherwise changed or specified, implementations should default to
658   * {@link #DEFAULT_FIX_JVM_MODULE_PATH_MISMATCH}.
659   *
660   * @return {@code true} if enabled, or {@code false} if disabled.
661   */
662  boolean isFixJvmModulePathMismatch();
663
664  /**
665   * Get whether we will attempt to fix modules appearing on the classpath, or non-modules appearing
666   * on the module path.
667   *
668   * <p>Unless otherwise changed or specified, implementations should default to
669   * {@link #DEFAULT_FIX_JVM_MODULE_PATH_MISMATCH}.
670   *
671   * @param fixJvmModulePathMismatch whether to enable the mismatch fixing or not.
672   * @return this compiler object for further call chaining.
673   */
674  C fixJvmModulePathMismatch(boolean fixJvmModulePathMismatch);
675
676  /**
677   * Get whether the class path is inherited from the caller JVM or not.
678   *
679   * <p>Unless otherwise changed or specified, implementations should default to
680   * {@link #DEFAULT_INHERIT_CLASS_PATH}.
681   *
682   * @return whether the current class path is being inherited or not.
683   */
684  boolean isInheritClassPath();
685
686  /**
687   * Set whether the class path is inherited from the caller JVM or not.
688   *
689   * <p>Unless otherwise changed or specified, implementations should default to
690   * {@link #DEFAULT_INHERIT_CLASS_PATH}.
691   *
692   * @param inheritClassPath {@code true} to include it, or {@code false} to exclude it.
693   * @return this compiler object for further call chaining.
694   */
695  C inheritClassPath(boolean inheritClassPath);
696
697  /**
698   * Get whether the module path is inherited from the caller JVM or not.
699   *
700   * <p>Unless otherwise changed or specified, implementations should default to
701   * {@link #DEFAULT_INHERIT_MODULE_PATH}.
702   *
703   * @return whether the module path is being inherited or not.
704   */
705  boolean isInheritModulePath();
706
707  /**
708   * Set whether the module path is inherited from the caller JVM or not.
709   *
710   * <p>Unless otherwise changed or specified, implementations should default to
711   * {@link #DEFAULT_INHERIT_MODULE_PATH}.
712   *
713   * @param inheritModulePath {@code true} to include it, or {@code false} to exclude it.
714   * @return this compiler object for further call chaining.
715   */
716  C inheritModulePath(boolean inheritModulePath);
717
718  /**
719   * Get whether the current platform class path is being inherited from the caller JVM or not.
720   *
721   * <p>This may also be known as the "bootstrap class path".
722   *
723   * <p>Default environments probably will not provide this functionality, in which case it will be
724   * ignored.
725   *
726   * <p>Unless otherwise changed or specified, implementations should default to
727   * {@link #DEFAULT_INHERIT_PLATFORM_CLASS_PATH}.
728   *
729   * @return whether the platform class path is being inherited or not.
730   */
731  boolean isInheritPlatformClassPath();
732
733  /**
734   * Set whether the current platform class path is being inherited from the caller JVM or not.
735   *
736   * <p>This may also be known as the "bootstrap class path".
737   *
738   * <p>Default environments probably will not provide this functionality, in which case it will be
739   * ignored.
740   *
741   * @param inheritPlatformClassPath {@code true} to include it, or {@code false} to exclude it.
742   * @return this compiler object for further call chaining.
743   */
744  C inheritPlatformClassPath(boolean inheritPlatformClassPath);
745
746  /**
747   * Get whether the system module path is inherited from the caller JVM or not.
748   *
749   * <p>Unless otherwise changed or specified, implementations should default to
750   * {@link #DEFAULT_INHERIT_SYSTEM_MODULE_PATH}.
751   *
752   * @return whether the system module path is being inherited or not.
753   */
754  boolean isInheritSystemModulePath();
755
756  /**
757   * Set whether the system module path is inherited from the caller JVM or not.
758   *
759   * <p>Unless otherwise changed or specified, implementations should default to
760   * {@link #DEFAULT_INHERIT_SYSTEM_MODULE_PATH}.
761   *
762   * @param inheritSystemModulePath {@code true} to include it, or {@code false} to exclude it.
763   * @return this compiler object for further call chaining.
764   */
765  C inheritSystemModulePath(boolean inheritSystemModulePath);
766
767  /**
768   * Get the output locale.
769   *
770   * <p>Unless otherwise changed or specified, implementations should default to
771   * {@link #DEFAULT_LOCALE}.
772   *
773   * @return the output locale to use.
774   */
775  Locale getLocale();
776
777  /**
778   * Set the output locale.
779   *
780   * <p>Unless otherwise changed or specified, implementations should default to
781   * {@link #DEFAULT_LOCALE}.
782   *
783   * @param locale the locale to use.
784   * @return this compiler for further call chaining.
785   */
786  C locale(Locale locale);
787
788  /**
789   * Get the charset being used to write compiler logs with.
790   *
791   * <p>Unless otherwise changed or specified, implementations should default to
792   * {@link #DEFAULT_LOG_CHARSET}.
793   *
794   * @return the charset.
795   */
796  Charset getLogCharset();
797
798  /**
799   * Set the charset being used to write compiler logs with.
800   *
801   * <p>Unless otherwise changed or specified, implementations should default to
802   * {@link #DEFAULT_LOG_CHARSET}.
803   *
804   * @param logCharset the charset to use.
805   * @return this compiler for further call chaining.
806   */
807  C logCharset(Charset logCharset);
808
809  /**
810   * Get the current file manager logging mode.
811   *
812   * <p>Unless otherwise changed or specified, implementations should default to
813   * {@link #DEFAULT_FILE_MANAGER_LOGGING_MODE}.
814   *
815   * @return the current file manager logging mode.
816   */
817  LoggingMode getFileManagerLoggingMode();
818
819  /**
820   * Set how to handle logging calls to underlying file managers.
821   *
822   * <p>Unless otherwise changed or specified, implementations should default to
823   * {@link #DEFAULT_FILE_MANAGER_LOGGING_MODE}.
824   *
825   * @param fileManagerLoggingMode the mode to use for file manager logging.
826   * @return this compiler for further call chaining.
827   */
828  C fileManagerLoggingMode(LoggingMode fileManagerLoggingMode);
829
830  /**
831   * Get the current diagnostic logging mode.
832   *
833   * <p>Unless otherwise changed or specified, implementations should default to
834   * {@link #DEFAULT_DIAGNOSTIC_LOGGING_MODE}.
835   *
836   * @return the current diagnostic logging mode.
837   */
838  LoggingMode getDiagnosticLoggingMode();
839
840  /**
841   * Set how to handle diagnostic capture.
842   *
843   * <p>Unless otherwise changed or specified, implementations should default to
844   * {@link #DEFAULT_DIAGNOSTIC_LOGGING_MODE}.
845   *
846   * @param diagnosticLoggingMode the mode to use for diagnostic capture.
847   * @return this compiler for further call chaining.
848   */
849  C diagnosticLoggingMode(LoggingMode diagnosticLoggingMode);
850
851  /**
852   * Get how to perform annotation processor discovery.
853   *
854   * <p>Unless otherwise changed or specified, implementations should default to
855   * {@link #DEFAULT_ANNOTATION_PROCESSOR_DISCOVERY}.
856   *
857   * <p>Specifying any annotation processors explicitly with
858   * {@link #addAnnotationProcessors(Iterable)} or
859   * {@link #addAnnotationProcessors(Processor, Processor...)} will bypass this setting, treating it
860   * as being disabled.
861   *
862   * @return the processor discovery mode to use.
863   */
864  AnnotationProcessorDiscovery getAnnotationProcessorDiscovery();
865
866  /**
867   * Set how to perform annotation processor discovery.
868   *
869   * <p>Unless otherwise changed or specified, implementations should default to
870   * {@link #DEFAULT_ANNOTATION_PROCESSOR_DISCOVERY}.
871   *
872   * <p>Specifying any annotation processors explicitly with
873   * {@link #addAnnotationProcessors(Iterable)} or
874   * {@link #addAnnotationProcessors(Processor, Processor...)} will bypass this setting, treating it
875   * as being disabled.
876   *
877   * @param annotationProcessorDiscovery the processor discovery mode to use.
878   * @return this compiler for further call chaining.
879   */
880  C annotationProcessorDiscovery(AnnotationProcessorDiscovery annotationProcessorDiscovery);
881}