Skip to content

Commit 0c12f8d

Browse files
committed
Deprecate Java 17 support now it is at end of life.
1 parent fd1b433 commit 0c12f8d

10 files changed

Lines changed: 106 additions & 183 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

‎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/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/utils/LoomPolyfillTest.java‎

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@
2626
import io.github.ascopes.jct.fixtures.UtilityClassTestTemplate;
2727
import org.junit.jupiter.api.DisplayName;
2828
import org.junit.jupiter.api.Test;
29-
import org.junit.jupiter.api.condition.EnabledForJreRange;
30-
import org.junit.jupiter.api.condition.JRE;
3129

3230
/**
3331
* {@link LoomPolyfill} tests.
@@ -41,29 +39,9 @@ public Class<?> getTypeBeingTested() {
4139
return LoomPolyfill.class;
4240
}
4341

44-
@DisplayName(".getThreadId(Thread) on JRE <= 18 calls .getId()")
45-
@EnabledForJreRange(max = JRE.JAVA_18)
42+
@DisplayName(".getThreadId(Thread) calls .threadId()")
4643
@Test
47-
void getThreadIdOnJre18AndOlderUsesThreadGetId() throws Throwable {
48-
// Given
49-
var expectedThreadId = Fixtures.someLong(1, Short.MAX_VALUE);
50-
var thread = mock(Thread.class);
51-
var getIdMethod = Thread.class.getDeclaredMethod("getId");
52-
53-
when((long) getIdMethod.invoke(thread)).thenReturn(expectedThreadId);
54-
55-
// When
56-
var actualThreadId = LoomPolyfill.getThreadId(thread);
57-
58-
// Then
59-
assertThat(actualThreadId).isEqualTo(expectedThreadId);
60-
getIdMethod.invoke(verify(thread));
61-
}
62-
63-
@DisplayName(".getThreadId(Thread) on JRE >= 19 calls .threadId()")
64-
@EnabledForJreRange(min = JRE.JAVA_19)
65-
@Test
66-
void getThreadIdOnJre19AndNewerUsesThreadId() throws Throwable {
44+
void getThreadIdUsesThreadId() throws Throwable {
6745
// Given
6846
var expectedThreadId = Fixtures.someLong(1, Short.MAX_VALUE);
6947
var thread = mock(Thread.class);

java-compiler-testing/src/test/java/io/github/ascopes/jct/workspaces/impl/MemoryFileSystemProviderImplTest.java renamed to java-compiler-testing/src/test/java/io/github/ascopes/jct/workspaces/impl/MemoryFileSystemProviderTest.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import java.io.ByteArrayOutputStream;
2424
import java.io.IOException;
2525
import java.net.MalformedURLException;
26+
import java.net.URI;
2627
import java.net.URL;
2728
import java.nio.ByteBuffer;
2829
import java.nio.charset.StandardCharsets;
@@ -43,8 +44,8 @@
4344
*
4445
* @author Ashley Scopes
4546
*/
46-
@DisplayName("MemoryFileSystemProviderImpl tests")
47-
class MemoryFileSystemProviderImplTest {
47+
@DisplayName("MemoryFileSystemProvider tests")
48+
class MemoryFileSystemProviderTest {
4849

4950
@DisplayName("The class is a singleton")
5051
@Test
@@ -213,7 +214,7 @@ class MemoryFileSystemUrlHandlerProviderTest {
213214
@ParameterizedTest(name = "for URL {0}")
214215
void providerReturnsHandlerForMemoryProtocol(String urlString) throws MalformedURLException {
215216
// Given
216-
var url = new URL(urlString);
217+
var url = URI.create(urlString).toURL();
217218
var provider = new MemoryFileSystemUrlHandlerProvider();
218219

219220
// When
@@ -232,7 +233,7 @@ void providerReturnsHandlerForMemoryProtocol(String urlString) throws MalformedU
232233
@ParameterizedTest(name = "for URL {0}")
233234
void providerReturnsNullHandlerForOtherProtocol(String urlString) throws MalformedURLException {
234235
// Given
235-
var url = new URL(urlString);
236+
var url = URI.create(urlString).toURL();
236237
var provider = new MemoryFileSystemUrlHandlerProvider();
237238

238239
// When

0 commit comments

Comments
 (0)