Skip to content

Commit c6cdf86

Browse files
committed
Add -proc:all to compilation by default.
JDK 22 does not do this by default anymore, so we should add this to remain consistent between compiler versions.
1 parent 87800fc commit c6cdf86

File tree

2 files changed

+14
-11
lines changed

2 files changed

+14
-11
lines changed

java-compiler-testing/src/main/java/io/github/ascopes/jct/compilers/impl/JavacJctFlagBuilderImpl.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ public final class JavacJctFlagBuilderImpl implements JctFlagBuilder {
4343
private static final String ANNOTATION_OPT = "-A";
4444
private static final String PROC_NONE = "-proc:none";
4545
private static final String PROC_ONLY = "-proc:only";
46+
private static final String PROC_ALL = "-proc:all";
4647

4748
private final List<String> craftedFlags;
4849

@@ -85,7 +86,9 @@ public JctFlagBuilder compilationMode(CompilationMode compilationMode) {
8586
break;
8687

8788
default:
88-
// Do nothing. The default behaviour is to allow this.
89+
// In Java 22, the default is to disable all annotation processing by default.
90+
// Prior to Java 22, the default was to enable all annotation processing by default.
91+
craftedFlags.add(PROC_ALL);
8992
break;
9093
}
9194

java-compiler-testing/src/test/java/io/github/ascopes/jct/tests/unit/compilers/impl/JavacJctFlagBuilderImplTest.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -189,16 +189,6 @@ void returnsFlagBuilder() {
189189
@Nested
190190
class CompilationModeFlagTest {
191191

192-
@DisplayName(".compilationMode(COMPILATION_AND_ANNOTATION_PROCESSING) adds no flags")
193-
@Test
194-
void compilationAndAnnotationProcessingAddsNoFlags() {
195-
// When
196-
flagBuilder.compilationMode(CompilationMode.COMPILATION_AND_ANNOTATION_PROCESSING);
197-
198-
// Then
199-
assertThat(flagBuilder.build()).isEmpty();
200-
}
201-
202192
@DisplayName(".compilationMode(COMPILATION_ONLY) adds -proc:none")
203193
@Test
204194
void compilationOnlyAddsProcNone() {
@@ -219,6 +209,16 @@ void annotationProcessingOnlyAddsProcOnly() {
219209
assertThat(flagBuilder.build()).containsExactly("-proc:only");
220210
}
221211

212+
@DisplayName(".compilationMode(COMPILATION_AND_ANNOTATION_PROCESSING) adds -proc:all")
213+
@Test
214+
void compilationAndAnnotationProcessingAddsProcAll() {
215+
// When
216+
flagBuilder.compilationMode(CompilationMode.COMPILATION_AND_ANNOTATION_PROCESSING);
217+
218+
// Then
219+
assertThat(flagBuilder.build()).containsExactly("-proc:all");
220+
}
221+
222222
@DisplayName(".compilationMode(...) returns the flag builder")
223223
@EnumSource(CompilationMode.class)
224224
@ParameterizedTest(name = "for compilationMode = {0}")

0 commit comments

Comments
 (0)