Skip to content

Commit bee0211

Browse files
authored
Merge pull request #908 from ascopes/task/deprecate-java-17
Deprecate Java 17 support now it is at end of life.
2 parents 85ba349 + 4e0b291 commit bee0211

13 files changed

Lines changed: 116 additions & 249 deletions

File tree

‎.github/workflows/build.yml‎

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -23,38 +23,14 @@ jobs:
2323
uses: actions/checkout@v7
2424

2525
###
26-
### Lint scripts and configuration files.
26+
### Lint configuration files.
2727
###
2828

29-
#- name: Validate shell scripts
30-
# uses: ludeeus/action-shellcheck@master
31-
# if: ${{ ! cancelled() }}
32-
# with:
33-
# check_together: 'yes'
34-
# scandir: ./scripts
35-
3629
- name: Validate codecov.yml
3730
shell: bash
3831
if: ${{ ! cancelled() }}
3932
run: curl -si --fail-with-body --data-binary @codecov.yml https://codecov.io/validate
4033

41-
###
42-
### Lint GitHub Actions for issues.
43-
###
44-
45-
- name: Lint GitHub Actions
46-
shell: bash
47-
if: ${{ ! cancelled() }}
48-
run: >-
49-
docker run
50-
--rm
51-
--user "$(id -u "${USER}"):$(id -g "${USER}")"
52-
--volume "$(pwd):/repo"
53-
--workdir /repo
54-
rhysd/actionlint:latest
55-
-color
56-
-verbose
57-
5834
###
5935
### Lint Java, export information about current environment for
6036
### the next jobs to utilise.
@@ -86,14 +62,13 @@ jobs:
8662
matrix:
8763
os-name: [ubuntu-latest]
8864
java-version:
89-
- 17 # LTS
9065
- 21 # LTS
9166
- 25 # LTS
9267
include:
9368
- os-name: windows-11-arm
9469
java-version: 23 # Latest Temurin for ARM
9570
- os-name: macos-latest
96-
java-version: 25 # LTS
71+
java-version: 21
9772

9873
steps:
9974
- name: Checkout repository

‎.github/workflows/codeql.yml‎

Lines changed: 0 additions & 41 deletions
This file was deleted.

‎java-compiler-testing/pom.xml‎

Lines changed: 37 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<parent>
2323
<groupId>io.github.ascopes.jct</groupId>
2424
<artifactId>java-compiler-testing-parent</artifactId>
25-
<version>6.0.2-SNAPSHOT</version>
25+
<version>7.0.0-SNAPSHOT</version>
2626
<relativePath>../pom.xml</relativePath>
2727
</parent>
2828

@@ -115,13 +115,47 @@
115115
<groupId>org.apache.maven.plugins</groupId>
116116
<artifactId>maven-compiler-plugin</artifactId>
117117
<configuration>
118-
<annotationProcessorPaths combine.children="append" />
119-
<compilerArgs combine.children="append">
118+
<annotationProcessorPaths>
119+
<annotationProcessorPath>
120+
<groupId>com.google.errorprone</groupId>
121+
<artifactId>error_prone_core</artifactId>
122+
<version>${errorprone.version}</version>
123+
</annotationProcessorPath>
124+
<annotationProcessorPath>
125+
<!-- Override what Maven is pulling in. This is fine during compilation as our
126+
code doesn't use Guava at all. This is needed for ErrorProne to not crash
127+
on startup. -->
128+
<groupId>com.google.guava</groupId>
129+
<artifactId>guava</artifactId>
130+
<version>[33,)</version>
131+
</annotationProcessorPath>
132+
<annotationProcessorPath>
133+
<groupId>com.uber.nullaway</groupId>
134+
<artifactId>nullaway</artifactId>
135+
<version>${nullaway.version}</version>
136+
</annotationProcessorPath>
137+
</annotationProcessorPaths>
138+
139+
<compilerArgs>
120140
<!--
121141
Disable warnings about modules. We cannot do much about some of these due to how Maven
122142
works with modules with Surefire.
123143
-->
124144
<arg>-Xlint:-module</arg>
145+
<!-- ErrorProne configuration -->
146+
<compilerArg>--should-stop=ifError=FLOW</compilerArg>
147+
<compilerArg>
148+
-Xplugin:ErrorProne
149+
-XepDisableWarningsInGeneratedCode
150+
-XepExcludedPaths:.*/target/generated.*?/.*
151+
-XepOpt:NullAway:AnnotatedPackages=io.github.ascopes.jct
152+
<!-- See https://github.com/uber/NullAway/issues/1319 -->
153+
-XepOpt:NullAway:ExcludedFieldAnnotations=org.junit.jupiter.*,org.mockito.*
154+
-XepOpt:NullAway:KnownInitializers=io.github.ascopes.jct.annotations.Initializer,io.github.ascopes.jct.junit.Managed
155+
</compilerArg>
156+
<!-- Needed for ErrorProne to be able to run -->
157+
<compilerArg>-XDaddTypeAnnotationsToSymbol=true</compilerArg>
158+
<compilerArg>-XDcompilePolicy=simple</compilerArg>
125159
</compilerArgs>
126160
</configuration>
127161
</plugin>
@@ -232,48 +266,6 @@
232266
<artifactId>maven-compiler-plugin</artifactId>
233267

234268
<configuration>
235-
<annotationProcessorPaths>
236-
<annotationProcessorPath>
237-
<groupId>com.google.errorprone</groupId>
238-
<artifactId>error_prone_core</artifactId>
239-
<version>${errorprone.version}</version>
240-
</annotationProcessorPath>
241-
<annotationProcessorPath>
242-
<!-- Override what Maven is pulling in. This is fine during compilation as our
243-
code doesn't use Guava at all. This is needed for ErrorProne to not crash
244-
on startup. -->
245-
<groupId>com.google.guava</groupId>
246-
<artifactId>guava</artifactId>
247-
<version>[33,)</version>
248-
</annotationProcessorPath>
249-
<annotationProcessorPath>
250-
<groupId>com.uber.nullaway</groupId>
251-
<artifactId>nullaway</artifactId>
252-
<version>${nullaway.version}</version>
253-
</annotationProcessorPath>
254-
</annotationProcessorPaths>
255-
256-
<compilerArgs>
257-
<!--
258-
Disable warnings about modules. We cannot do much about some of these due to how Maven
259-
works with modules with Surefire.
260-
-->
261-
<arg>-Xlint:-module</arg>
262-
<!-- ErrorProne configuration -->
263-
<compilerArg>--should-stop=ifError=FLOW</compilerArg>
264-
<compilerArg>
265-
-Xplugin:ErrorProne
266-
-XepDisableWarningsInGeneratedCode
267-
-XepExcludedPaths:.*/target/generated.*?/.*
268-
-XepOpt:NullAway:AnnotatedPackages=io.github.ascopes.jct
269-
<!-- See https://github.com/uber/NullAway/issues/1319 -->
270-
-XepOpt:NullAway:ExcludedFieldAnnotations=org.junit.jupiter.*,org.mockito.*
271-
-XepOpt:NullAway:KnownInitializers=io.github.ascopes.jct.annotations.Initializer,io.github.ascopes.jct.junit.Managed
272-
</compilerArg>
273-
<!-- Needed for ErrorProne to be able to run -->
274-
<compilerArg>-XDaddTypeAnnotationsToSymbol=true</compilerArg>
275-
<compilerArg>-XDcompilePolicy=simple</compilerArg>
276-
</compilerArgs>
277269
</configuration>
278270
</plugin>
279271
</plugins>

‎java-compiler-testing/src/it/dogfood/src/test/java/io/github/ascopes/jct/acceptancetests/dogfood/JctDogfoodTest.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class JctDogfoodTest {
5252
.resolve("classes");
5353

5454
@DisplayName("JCT can compile itself as a legacy module source")
55-
@JavacCompilerTest(minVersion = 17, configurers = JctCompilationConfigurer.class)
55+
@JavacCompilerTest(minVersion = 21, configurers = JctCompilationConfigurer.class)
5656
void jctCanCompileItselfAsLegacyModule(JctCompiler compiler) throws IOException {
5757
// Given
5858
try (var workspace = Workspaces.newWorkspace()) {

‎java-compiler-testing/src/main/java/io/github/ascopes/jct/compilers/JctCompiler.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -632,7 +632,7 @@ default JctCompiler release(SourceVersion release) {
632632
* Request that the compiler uses a language version that corresponds to the runtime language
633633
* version in use on the current JVM.
634634
*
635-
* <p>For example, running this on JRE 19 would set the release to "19".
635+
* <p>For example, running this on JRE 25 would set the release to "25".
636636
*
637637
* <p>This calls {@link #release(int)} internally.
638638
*

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

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,7 @@
3434
*/
3535
public final class JavacJctCompilerImpl extends AbstractJctCompiler {
3636

37-
private static final int JAVA_8 = 8;
3837
private static final int JAVA_9 = 9;
39-
private static final int JAVA_20 = 20;
4038
private static final String NAME = "JDK Compiler";
4139

4240
/**
@@ -60,7 +58,7 @@ public JctFlagBuilderFactory getFlagBuilderFactory() {
6058
public Jsr199CompilerFactory getCompilerFactory() {
6159
// RequireNonNull to ensure the return result is non-null, since the ToolProvider
6260
// method is not annotated.
63-
return () -> requireNonNull(ToolProvider.getSystemJavaCompiler(),
61+
return () -> requireNonNull(ToolProvider.getSystemJavaCompiler(),
6462
"ToolProvider.getSystemJavaCompiler()");
6563
}
6664

@@ -76,21 +74,10 @@ public JctFileManagerFactory getFileManagerFactory() {
7674
* @since 1.0.0
7775
*/
7876
public static int getEarliestSupportedVersionInt() {
79-
// Purposely do not hardcode members of the SourceVersion enum here other
80-
// than utility methods, as this prevents compilation problems on various
81-
// versions of the JDK when certain members are unavailable.
82-
83-
@SuppressWarnings("EnumOrdinal")
84-
var latestSupported = SourceVersion.latestSupported().ordinal();
85-
86-
if (latestSupported >= JAVA_20) {
87-
// JDK 20 marks source-version 8 as obsolete, and emits compilation
88-
// warnings that may break tests using "fail on warnings". To avoid this,
89-
// disallow compiling Java 8 sources under Javac in JDK 20 or newer
90-
return JAVA_9;
91-
}
92-
93-
return JAVA_8;
77+
// JDK 20 marks source-version 8 as obsolete, and emits compilation
78+
// warnings that may break tests using "fail on warnings". To avoid this,
79+
// disallow compiling Java 8 sources under Javac in JDK 20 or newer
80+
return JAVA_9;
9481
}
9582

9683
/**

‎java-compiler-testing/src/main/java/io/github/ascopes/jct/utils/LoomPolyfill.java‎

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,15 @@
1515
*/
1616
package io.github.ascopes.jct.utils;
1717

18-
import io.github.ascopes.jct.annotations.DeadCodeGenerated;
19-
2018
/**
2119
* Polyfill to enable supporting using the newer Thread APIs on newer platforms.
2220
*
2321
* <p>This specifically targets the new APIs introduced as part of Project Loom
2422
* in Java 19.
2523
*
24+
* <p><strong>This class is now suitable to be removed as we only target Java 21 and
25+
* newer.</strong>
26+
*
2627
* @author Ashley Scopes
2728
* @since 0.0.1
2829
*/
@@ -40,18 +41,9 @@ private LoomPolyfill() {
4041
* @param thread the thread to use.
4142
* @return the thread ID.
4243
*/
43-
@DeadCodeGenerated
4444
public static long getThreadId(Thread thread) {
45-
// Note: this test will never get 100% coverage on one JDK, because it totally depends on the
46-
// JDK in use as to which code path runs.
47-
try {
48-
// Where possible, use the newer Loom API to fetch the thread ID.
49-
var method = Thread.class.getDeclaredMethod("threadId");
50-
return (long) method.invoke(thread);
51-
} catch (Exception ex) {
52-
// Fall back to the old API (which is the only method prior to Java 19).
53-
return thread.getId();
54-
}
45+
// Now we baseline to Java 21, we don't have to use reflection to invoke this Java 19 API.
46+
return thread.threadId();
5547
}
5648

5749
/**

‎java-compiler-testing/src/main/java/module-info.java‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@
2424
* <p><strong>For Java 11 support, please use version 4 of this library, which is still kept up to date.
2525
* Version 5 of this library only supports Java 17 onwards.</strong>
2626
*
27+
* <p><strong>For Java 17 support, please use version 6 of this library, which is still kept up to date.
28+
* Version 7 of this library only supports Java 17 onwards.</strong>
29+
*
2730
* <p>The <em>Java Compiler Testing</em> API has a number of facilities for assisting in testing
2831
* anything related to the Java compiler. This includes Javac plugins and JSR-199 annotation
2932
* processors.

‎java-compiler-testing/src/test/java/io/github/ascopes/jct/compilers/AbstractJctCompilerTest.java‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,6 @@ void configureInvokesConfigurerOnTheCompiler() throws Throwable {
552552
IllegalThreadStateException.class,
553553
NoClassDefFoundError.class,
554554
ClassNotFoundException.class,
555-
ThreadDeath.class,
556555
})
557556
@ParameterizedTest(name = "for exception of type {0}")
558557
void configurePropagatesAnyException(Class<? extends Exception> exceptionCls) throws Throwable {

‎java-compiler-testing/src/test/java/io/github/ascopes/jct/compilers/impl/JavacJctCompilerImplTest.java‎

Lines changed: 13 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -130,21 +130,13 @@ void compilersHaveNoDefaultAnnotationProcessorsSet() {
130130
@DisplayName("the earliest supported version int has the expected value")
131131
@CsvSource(useHeadersInDisplayName = true, value = {
132132
"SourceVersion.latest(), expectedResult",
133-
" 9, 8",
134-
" 10, 8",
135-
" 11, 8",
136-
" 12, 8",
137-
" 13, 8",
138-
" 14, 8",
139-
" 15, 8",
140-
" 16, 8",
141-
" 17, 8",
142-
" 18, 8",
143-
" 19, 8",
144-
// JDK-20 marks Java 8 as obsolete, so we do not support it.
145-
// We default to Java 9 regardless in this case.
146-
" 20, 9",
147133
" 21, 9",
134+
" 22, 9",
135+
" 23, 9",
136+
" 24, 9",
137+
" 25, 9",
138+
" 26, 9",
139+
" 27, 9",
148140
})
149141
@ParameterizedTest(name = "expect {1} when using Javac for JDK {0}")
150142
@SuppressWarnings({"EnumOrdinal", "ResultOfMethodCallIgnored"})
@@ -166,22 +158,16 @@ void earliestSupportedVersionReturnsTheExpectedValue(int latest, int expectedRes
166158
}
167159
}
168160

169-
@DisplayName("the earliest supported version int has the expected value")
161+
@DisplayName("the latest supported version int has the expected value")
170162
@CsvSource(useHeadersInDisplayName = true, value = {
171163
"SourceVersion.latest(), expectedResult",
172-
" 9, 9",
173-
" 10, 10",
174-
" 11, 11",
175-
" 12, 12",
176-
" 13, 13",
177-
" 14, 14",
178-
" 15, 15",
179-
" 16, 16",
180-
" 17, 17",
181-
" 18, 18",
182-
" 19, 19",
183-
" 20, 20",
184164
" 21, 21",
165+
" 22, 22",
166+
" 23, 23",
167+
" 24, 24",
168+
" 25, 25",
169+
" 26, 26",
170+
" 27, 27",
185171
})
186172
@ParameterizedTest(name = "expect {1} when using Javac for JDK {0}")
187173
@SuppressWarnings({"EnumOrdinal", "ResultOfMethodCallIgnored"})

0 commit comments

Comments
 (0)