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