Skip to content

Commit 0a281eb

Browse files
authored
Merge pull request #1677 from uhafner/java21
Bump baseline to Java 21
2 parents baf492e + 044e8fa commit 0a281eb

File tree

8 files changed

+31
-32
lines changed

8 files changed

+31
-32
lines changed

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ http://creativecommons.org/licenses/by/4.0/
66

77
MIT License
88

9-
Copyright (c) 2014-2023 Dr. Ullrich Hafner
9+
Copyright (c) 2014-2026 Dr. Ullrich Hafner
1010

1111
Permission is hereby granted, free of charge, to any person
1212
obtaining a copy of this software and associated documentation

LIESMICH.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ entsprechenden IntelliJ Plugins). Zusätzlich sind die
2525
[IntelliJ Code Inspections](https://www.jetbrains.com/help/idea/code-inspection.html) gemäß meiner Richtlinien konfiguriert.
2626
Aktuell können diese allerdings noch nicht automatisch im Build überprüft werden
2727
(siehe [#7](https://github.com/uhafner/codingstyle/issues/7)). Insgesamt ist damit sichergestellt,
28-
dass immer die gleichen Warnungen angezeigt werden - egal wie und wo die Java Dateien weiterverarbeitet werden.
28+
dass immer die gleichen Warnungen angezeigt werden - egal wie und wo die Java-Dateien weiterverarbeitet werden.
2929
Für SpotBugs und PMD ist der Umweg über das Build Management Tool [Maven](http://maven.apache.org/) erforderlich
3030
(die entsprechenden IntelliJ Plugins sind leider aus meiner Sicht noch nicht ausgereift genug bzw. verwenden eine separate Konfiguration).
3131
Die Verwendung von Maven hat zudem den Vorteil, dass die Ergebnisse hinterher leicht in den Continuous Integration Server

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ It provides all necessary resources for a Java project to enforce this coding st
1717
- [SpotBugs](https://spotbugs.github.io)
1818
- [Error Prone](https://errorprone.info)
1919

20-
❗This project requires a JDK version of 17 or higher.❗
20+
❗This project requires a JDK version of 21 or higher.❗
2121

2222
Moreover, this project provides some sample classes that already use this style guide.
2323
These classes can be used as such but are not required in this project.
@@ -54,4 +54,4 @@ Source code (snippets, examples, and classes) are using the [MIT license](https:
5454

5555
[![License: MIT](https://img.shields.io/badge/license-MIT-yellow.svg)](https://en.wikipedia.org/wiki/MIT_License)
5656
[![License: CC BY 4.0](https://img.shields.io/badge/License-CC%20BY%204.0-lightgrey.svg)](https://creativecommons.org/licenses/by/4.0/)
57-
![JDK17](https://img.shields.io/badge/jdk-17-blue.svg)
57+
![JDK21](https://img.shields.io/badge/jdk-21-blue.svg)

pom.xml

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<groupId>edu.hm.hafner</groupId>
66
<artifactId>codingstyle</artifactId>
7-
<version>5.28.0-SNAPSHOT</version>
7+
<version>6.0.0-SNAPSHOT</version>
88
<packaging>jar</packaging>
99

1010
<name>Java coding style</name>
@@ -47,7 +47,7 @@
4747
<properties>
4848
<source.encoding>UTF-8</source.encoding>
4949
<project.build.sourceEncoding>${source.encoding}</project.build.sourceEncoding>
50-
<java.version>17</java.version>
50+
<java.version>21</java.version>
5151
<java.jdk.version>21</java.jdk.version>
5252

5353
<module.name>${project.groupId}.codingstyle</module.name>
@@ -357,19 +357,19 @@
357357
<recipe>org.openrewrite.maven.BestPractices</recipe>
358358
<recipe>org.openrewrite.maven.RemoveRedundantDependencyVersions</recipe>
359359
<recipe>org.openrewrite.staticanalysis.AddSerialAnnotationToSerialVersionUID</recipe>
360-
<recipe>org.openrewrite.staticanalysis.MissingOverrideAnnotation</recipe>
361360
<recipe>org.openrewrite.staticanalysis.CodeCleanup</recipe>
362361
<recipe>org.openrewrite.staticanalysis.CommonStaticAnalysis</recipe>
362+
<recipe>org.openrewrite.staticanalysis.MissingOverrideAnnotation</recipe>
363363
<recipe>org.openrewrite.staticanalysis.RemoveExtraSemicolons</recipe>
364-
<recipe>org.openrewrite.java.migrate.UpgradeToJava17</recipe>
364+
<recipe>org.openrewrite.java.migrate.UpgradeToJava21</recipe>
365+
<recipe>org.openrewrite.java.migrate.util.JavaUtilAPIs</recipe>
365366
<recipe>org.openrewrite.java.migrate.util.SequencedCollection</recipe>
367+
<recipe>org.openrewrite.java.migrate.lang.StringRulesRecipes</recipe>
366368
<recipe>org.openrewrite.java.migrate.lang.var.UseVarForObject</recipe>
367369
<recipe>org.openrewrite.java.migrate.net.JavaNetAPIs</recipe>
368-
<recipe>org.openrewrite.java.migrate.util.JavaUtilAPIs</recipe>
369-
<recipe>org.openrewrite.java.migrate.lang.StringRulesRecipes</recipe>
370-
<recipe>org.openrewrite.java.format.RemoveTrailingWhitespace</recipe>
371370
<recipe>org.openrewrite.java.format.BlankLines</recipe>
372371
<recipe>org.openrewrite.java.format.EmptyNewlineAtEndOfFile</recipe>
372+
<recipe>org.openrewrite.java.format.RemoveTrailingWhitespace</recipe>
373373
<recipe>org.openrewrite.java.testing.assertj.SimplifyChainedAssertJAssertions</recipe>
374374
</activeRecipes>
375375
</configuration>
@@ -719,7 +719,8 @@
719719
<configuration>
720720
<rules>
721721
<requireJavaVersion>
722-
<version>${java.jdk.version}</version>
722+
<version>[21,22),[25,26)</version>
723+
<message>Java LTS 21 or 25 is required to build this project.</message>
723724
</requireJavaVersion>
724725
</rules>
725726
</configuration>

src/main/java/edu/hm/hafner/util/FilteredLog.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,18 @@
2323
*/
2424
public class FilteredLog implements Serializable {
2525
@Serial
26-
private static final long serialVersionUID = -8552323621953159904L;
26+
private static final long serialVersionUID = 6956036398485594488L;
2727

2828
private static final int DEFAULT_MAX_LINES = 20;
2929

3030
private final String title;
3131
private final int maxLines;
3232
private int lines;
3333

34-
@SuppressWarnings("serial")
35-
private final List<String> infoMessages = new ArrayList<>();
36-
@SuppressWarnings("serial")
37-
private final List<String> errorMessages = new ArrayList<>();
34+
@SuppressWarnings("PMD.LooseCoupling")
35+
private final ArrayList<String> infoMessages = new ArrayList<>();
36+
@SuppressWarnings("PMD.LooseCoupling")
37+
private final ArrayList<String> errorMessages = new ArrayList<>();
3838

3939
private transient ReentrantLock lock = new ReentrantLock();
4040

src/main/java/edu/hm/hafner/util/Generated.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,11 @@
88

99
/**
1010
* This annotation is used to mark source code that has been generated or is somehow not relevant for style checking or
11-
* code coverage analysis. It is quite similar to the JSR305 annotation. The
12-
* main difference is that it has class retention, so it is available for tools that work on bytecode (like JaCoCo,
13-
* PIT, or SpotBugs).
11+
* code coverage analysis. It is quite similar to the annotation of the abandoned JSR305 project. The main difference is
12+
* that it has class retention, so it is available for tools that work on bytecode (like JaCoCo, PIT, or SpotBugs).
1413
*/
1514
@Retention(CLASS)
16-
@Target({PACKAGE, TYPE, ANNOTATION_TYPE, METHOD, CONSTRUCTOR, FIELD,
17-
LOCAL_VARIABLE, PARAMETER})
15+
@Target({PACKAGE, TYPE, ANNOTATION_TYPE, METHOD, CONSTRUCTOR, FIELD, LOCAL_VARIABLE, PARAMETER})
1816
public @interface Generated {
1917
/**
2018
* An optional property that identifies the code generator.

src/test/java/edu/hm/hafner/util/EnsureTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ void shouldNotThrowExceptionIfContractIsValid() {
2929
Ensure.that("").isNotNull();
3030
Ensure.that("", "").isNotNull();
3131
Ensure.that(null, (Object) null).isNull();
32-
Ensure.that(new String[] {""}).isNotEmpty();
32+
Ensure.that(new String[]{""}).isNotEmpty();
3333
Ensure.that(SOME_STRING).isNotEmpty();
3434
Ensure.that(SOME_STRING).isNotBlank();
3535
Ensure.that("").isInstanceOf(String.class);
@@ -116,7 +116,7 @@ void shouldThrowExceptionIfEmpty() {
116116
Ensure.that(Lists.newArrayList("", null, "")).isNotEmpty(ERROR_MESSAGE)).isInstanceOf(
117117
AssertionError.class);
118118
assertThatThrownBy(() ->
119-
Ensure.that(new String[] {"", null, ""}).isNotEmpty(ERROR_MESSAGE)).isInstanceOf(AssertionError.class);
119+
Ensure.that(new String[]{"", null, ""}).isNotEmpty(ERROR_MESSAGE)).isInstanceOf(AssertionError.class);
120120
assertThatThrownBy(() ->
121121
Ensure.that("").isNotEmpty(ERROR_MESSAGE)).isInstanceOf(AssertionError.class);
122122
assertThatThrownBy(() ->
@@ -128,7 +128,7 @@ void shouldThrowExceptionIfEmpty() {
128128
assertThatThrownBy(() ->
129129
Ensure.that(Lists.newArrayList("", null, "")).isNotEmpty()).isInstanceOf(AssertionError.class);
130130
assertThatThrownBy(() ->
131-
Ensure.that(new String[] {"", null, ""}).isNotEmpty()).isInstanceOf(AssertionError.class);
131+
Ensure.that(new String[]{"", null, ""}).isNotEmpty()).isInstanceOf(AssertionError.class);
132132
assertThatThrownBy(() ->
133133
Ensure.that("").isNotEmpty()).isInstanceOf(AssertionError.class);
134134
assertThatThrownBy(() ->

src/test/java/edu/hm/hafner/util/LineRangeListTest.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package edu.hm.hafner.util;
22

3-
import java.util.List;
4-
53
import org.junit.jupiter.api.Test;
64

5+
import java.util.List;
6+
77
import static org.assertj.core.api.Assertions.*;
88

99
/**
@@ -43,17 +43,17 @@ void shouldSupportSetOperations() {
4343
var range = new LineRange(1, 2);
4444
list.add(range);
4545

46-
assertThat(list.get(0)).isEqualTo(range);
47-
assertThat(list.get(0)).isNotSameAs(range);
46+
assertThat(list.getFirst()).isEqualTo(range);
47+
assertThat(list.getFirst()).isNotSameAs(range);
4848
assertThat(list).hasSize(1);
4949

5050
var other = new LineRange(3, 4);
5151
assertThat(list.set(0, other)).isEqualTo(range);
52-
assertThat(list.get(0)).isEqualTo(other);
53-
assertThat(list.get(0)).isNotSameAs(other);
52+
assertThat(list.getFirst()).isEqualTo(other);
53+
assertThat(list.getFirst()).isNotSameAs(other);
5454
assertThat(list).hasSize(1);
5555

56-
assertThat(list.remove(0)).isEqualTo(other);
56+
assertThat(list.removeFirst()).isEqualTo(other);
5757
assertThat(list).hasSize(0);
5858
}
5959

0 commit comments

Comments
 (0)