Skip to content

Commit db6ae61

Browse files
committed
Updates to Java 24
1 parent 86c58f5 commit db6ae61

File tree

9 files changed

+555
-23
lines changed

9 files changed

+555
-23
lines changed
Lines changed: 280 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,280 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!-- ====================================================================== -->
3+
<!-- -->
4+
<!-- Generated by Maven Help Plugin -->
5+
<!-- See: https://maven.apache.org/plugins/maven-help-plugin/ -->
6+
<!-- -->
7+
<!-- ====================================================================== -->
8+
<!-- ====================================================================== -->
9+
<!-- -->
10+
<!-- Effective POM for project 'org.acme:java-migration:jar:1.0-SNAPSHOT' -->
11+
<!-- -->
12+
<!-- ====================================================================== -->
13+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
14+
<modelVersion>4.0.0</modelVersion>
15+
<groupId>org.acme</groupId>
16+
<artifactId>java-migration</artifactId>
17+
<version>1.0-SNAPSHOT</version>
18+
<name>java-migration</name>
19+
<url>http://www.example.com</url>
20+
<properties>
21+
<maven.compiler.source>24</maven.compiler.source>
22+
<maven.compiler.target>24</maven.compiler.target>
23+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
24+
</properties>
25+
<repositories>
26+
<repository>
27+
<snapshots>
28+
<enabled>false</enabled>
29+
</snapshots>
30+
<id>central</id>
31+
<name>Central Repository</name>
32+
<url>https://repo.maven.apache.org/maven2</url>
33+
</repository>
34+
</repositories>
35+
<pluginRepositories>
36+
<pluginRepository>
37+
<releases>
38+
<updatePolicy>never</updatePolicy>
39+
</releases>
40+
<snapshots>
41+
<enabled>false</enabled>
42+
</snapshots>
43+
<id>central</id>
44+
<name>Central Repository</name>
45+
<url>https://repo.maven.apache.org/maven2</url>
46+
</pluginRepository>
47+
</pluginRepositories>
48+
<build>
49+
<sourceDirectory>/Users/asotobu/git/java-migration/apps/java-migration/src/main/java</sourceDirectory>
50+
<scriptSourceDirectory>/Users/asotobu/git/java-migration/apps/java-migration/src/main/scripts</scriptSourceDirectory>
51+
<testSourceDirectory>/Users/asotobu/git/java-migration/apps/java-migration/src/test/java</testSourceDirectory>
52+
<outputDirectory>/Users/asotobu/git/java-migration/apps/java-migration/target/classes</outputDirectory>
53+
<testOutputDirectory>/Users/asotobu/git/java-migration/apps/java-migration/target/test-classes</testOutputDirectory>
54+
<resources>
55+
<resource>
56+
<directory>/Users/asotobu/git/java-migration/apps/java-migration/src/main/resources</directory>
57+
</resource>
58+
</resources>
59+
<testResources>
60+
<testResource>
61+
<directory>/Users/asotobu/git/java-migration/apps/java-migration/src/test/resources</directory>
62+
</testResource>
63+
</testResources>
64+
<directory>/Users/asotobu/git/java-migration/apps/java-migration/target</directory>
65+
<finalName>java-migration-1.0-SNAPSHOT</finalName>
66+
<pluginManagement>
67+
<plugins>
68+
<plugin>
69+
<artifactId>maven-antrun-plugin</artifactId>
70+
<version>3.1.0</version>
71+
</plugin>
72+
<plugin>
73+
<artifactId>maven-assembly-plugin</artifactId>
74+
<version>3.6.0</version>
75+
</plugin>
76+
<plugin>
77+
<artifactId>maven-dependency-plugin</artifactId>
78+
<version>3.6.1</version>
79+
</plugin>
80+
<plugin>
81+
<artifactId>maven-release-plugin</artifactId>
82+
<version>3.0.1</version>
83+
</plugin>
84+
<plugin>
85+
<artifactId>maven-clean-plugin</artifactId>
86+
<version>3.1.0</version>
87+
</plugin>
88+
<plugin>
89+
<artifactId>maven-resources-plugin</artifactId>
90+
<version>3.0.2</version>
91+
</plugin>
92+
<plugin>
93+
<artifactId>maven-compiler-plugin</artifactId>
94+
<version>3.8.0</version>
95+
</plugin>
96+
<plugin>
97+
<artifactId>maven-surefire-plugin</artifactId>
98+
<version>2.22.1</version>
99+
</plugin>
100+
<plugin>
101+
<artifactId>maven-jar-plugin</artifactId>
102+
<version>3.0.2</version>
103+
</plugin>
104+
<plugin>
105+
<artifactId>maven-install-plugin</artifactId>
106+
<version>2.5.2</version>
107+
</plugin>
108+
<plugin>
109+
<artifactId>maven-deploy-plugin</artifactId>
110+
<version>2.8.2</version>
111+
</plugin>
112+
<plugin>
113+
<artifactId>maven-site-plugin</artifactId>
114+
<version>3.7.1</version>
115+
</plugin>
116+
<plugin>
117+
<artifactId>maven-project-info-reports-plugin</artifactId>
118+
<version>3.0.0</version>
119+
</plugin>
120+
</plugins>
121+
</pluginManagement>
122+
<plugins>
123+
<plugin>
124+
<artifactId>maven-clean-plugin</artifactId>
125+
<version>3.1.0</version>
126+
<executions>
127+
<execution>
128+
<id>default-clean</id>
129+
<phase>clean</phase>
130+
<goals>
131+
<goal>clean</goal>
132+
</goals>
133+
</execution>
134+
</executions>
135+
</plugin>
136+
<plugin>
137+
<artifactId>maven-resources-plugin</artifactId>
138+
<version>3.0.2</version>
139+
<executions>
140+
<execution>
141+
<id>default-testResources</id>
142+
<phase>process-test-resources</phase>
143+
<goals>
144+
<goal>testResources</goal>
145+
</goals>
146+
</execution>
147+
<execution>
148+
<id>default-resources</id>
149+
<phase>process-resources</phase>
150+
<goals>
151+
<goal>resources</goal>
152+
</goals>
153+
</execution>
154+
</executions>
155+
</plugin>
156+
<plugin>
157+
<artifactId>maven-jar-plugin</artifactId>
158+
<version>3.0.2</version>
159+
<executions>
160+
<execution>
161+
<id>default-jar</id>
162+
<phase>package</phase>
163+
<goals>
164+
<goal>jar</goal>
165+
</goals>
166+
</execution>
167+
</executions>
168+
</plugin>
169+
<plugin>
170+
<artifactId>maven-compiler-plugin</artifactId>
171+
<version>3.8.0</version>
172+
<executions>
173+
<execution>
174+
<id>default-compile</id>
175+
<phase>compile</phase>
176+
<goals>
177+
<goal>compile</goal>
178+
</goals>
179+
</execution>
180+
<execution>
181+
<id>default-testCompile</id>
182+
<phase>test-compile</phase>
183+
<goals>
184+
<goal>testCompile</goal>
185+
</goals>
186+
</execution>
187+
</executions>
188+
</plugin>
189+
<plugin>
190+
<artifactId>maven-surefire-plugin</artifactId>
191+
<version>2.22.1</version>
192+
<executions>
193+
<execution>
194+
<id>default-test</id>
195+
<phase>test</phase>
196+
<goals>
197+
<goal>test</goal>
198+
</goals>
199+
</execution>
200+
</executions>
201+
</plugin>
202+
<plugin>
203+
<artifactId>maven-install-plugin</artifactId>
204+
<version>2.5.2</version>
205+
<executions>
206+
<execution>
207+
<id>default-install</id>
208+
<phase>install</phase>
209+
<goals>
210+
<goal>install</goal>
211+
</goals>
212+
</execution>
213+
</executions>
214+
</plugin>
215+
<plugin>
216+
<artifactId>maven-deploy-plugin</artifactId>
217+
<version>2.8.2</version>
218+
<executions>
219+
<execution>
220+
<id>default-deploy</id>
221+
<phase>deploy</phase>
222+
<goals>
223+
<goal>deploy</goal>
224+
</goals>
225+
</execution>
226+
</executions>
227+
</plugin>
228+
<plugin>
229+
<artifactId>maven-site-plugin</artifactId>
230+
<version>3.7.1</version>
231+
<executions>
232+
<execution>
233+
<id>default-site</id>
234+
<phase>site</phase>
235+
<goals>
236+
<goal>site</goal>
237+
</goals>
238+
<configuration>
239+
<outputDirectory>/Users/asotobu/git/java-migration/apps/java-migration/target/site</outputDirectory>
240+
<reportPlugins>
241+
<reportPlugin>
242+
<groupId>org.apache.maven.plugins</groupId>
243+
<artifactId>maven-project-info-reports-plugin</artifactId>
244+
</reportPlugin>
245+
</reportPlugins>
246+
</configuration>
247+
</execution>
248+
<execution>
249+
<id>default-deploy</id>
250+
<phase>site-deploy</phase>
251+
<goals>
252+
<goal>deploy</goal>
253+
</goals>
254+
<configuration>
255+
<outputDirectory>/Users/asotobu/git/java-migration/apps/java-migration/target/site</outputDirectory>
256+
<reportPlugins>
257+
<reportPlugin>
258+
<groupId>org.apache.maven.plugins</groupId>
259+
<artifactId>maven-project-info-reports-plugin</artifactId>
260+
</reportPlugin>
261+
</reportPlugins>
262+
</configuration>
263+
</execution>
264+
</executions>
265+
<configuration>
266+
<outputDirectory>/Users/asotobu/git/java-migration/apps/java-migration/target/site</outputDirectory>
267+
<reportPlugins>
268+
<reportPlugin>
269+
<groupId>org.apache.maven.plugins</groupId>
270+
<artifactId>maven-project-info-reports-plugin</artifactId>
271+
</reportPlugin>
272+
</reportPlugins>
273+
</configuration>
274+
</plugin>
275+
</plugins>
276+
</build>
277+
<reporting>
278+
<outputDirectory>/Users/asotobu/git/java-migration/apps/java-migration/target/site</outputDirectory>
279+
</reporting>
280+
</project>

apps/java-migration/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414

1515
<properties>
1616
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
17-
<maven.compiler.source>17</maven.compiler.source>
18-
<maven.compiler.target>17</maven.compiler.target>
17+
<maven.compiler.source>24</maven.compiler.source>
18+
<maven.compiler.target>24</maven.compiler.target>
1919
</properties>
2020

2121
<dependencies>

documentation/modules/ROOT/examples/java-migration/pom.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212

1313
<properties>
1414
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
15-
<maven.compiler.source>21</maven.compiler.source>
16-
<maven.compiler.target>21</maven.compiler.target>
15+
<maven.compiler.source>24</maven.compiler.source>
16+
<maven.compiler.target>24</maven.compiler.target>
1717
</properties>
1818

1919
<build>
@@ -65,8 +65,8 @@
6565
<groupId>org.apache.maven.plugins</groupId>
6666
<artifactId>maven-compiler-plugin</artifactId>
6767
<configuration>
68-
<source>21</source>
69-
<target>21</target>
68+
<source>24</source>
69+
<target>24</target>
7070
<compilerArgs>--enable-preview</compilerArgs>
7171
</configuration>
7272
</plugin>
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
package org.acme;
2+
3+
import java.nio.charset.StandardCharsets;
4+
import java.security.InvalidAlgorithmParameterException;
5+
import java.security.NoSuchAlgorithmException;
6+
import java.security.spec.AlgorithmParameterSpec;
7+
import java.time.Instant;
8+
import java.util.Arrays;
9+
import java.util.HexFormat;
10+
import java.util.List;
11+
import java.util.stream.Gatherers;
12+
import javax.crypto.KDF;
13+
import javax.crypto.SecretKey;
14+
import javax.crypto.spec.HKDFParameterSpec;
15+
16+
public class Gatherings {
17+
18+
public static List<String> titles = Arrays.asList("1", "2", "3", "4", "5", "6","7", "8","9");
19+
20+
public static void main(String args[]) throws NoSuchAlgorithmException, InvalidAlgorithmParameterException {
21+
22+
titles.stream()
23+
.gather(Gatherers.windowFixed(3))
24+
.forEach(System.out::println);
25+
26+
titles.stream()
27+
.gather(Gatherers.windowSliding(2))
28+
.forEach(System.out::println);
29+
30+
titles.stream()
31+
.gather(Gatherers.fold(
32+
() -> "List of numbers: ",
33+
(result, num) -> result + num + ", "))
34+
.forEach(System.out::println);
35+
36+
titles.stream()
37+
.gather(Gatherers.scan(
38+
() -> "List of numbers: ",
39+
(result, num) -> result + num + ", "))
40+
.forEach(System.out::println);
41+
42+
titles.stream()
43+
.gather(Gatherers.mapConcurrent(2,
44+
word -> "- " + word
45+
)
46+
)
47+
.forEach(System.out::println);
48+
49+
final Instant now = Instant.now();
50+
final Instant plusSeconds = now.plusSeconds(50);
51+
System.out.println(now.until(plusSeconds));
52+
53+
KDF hkdf = KDF.getInstance("HKDF-SHA256");
54+
AlgorithmParameterSpec params =
55+
HKDFParameterSpec.ofExtract()
56+
.addIKM("the super secret passphrase".getBytes(StandardCharsets.UTF_8))
57+
.addSalt("the salt".getBytes(StandardCharsets.UTF_8))
58+
.thenExpand("my derived key description".getBytes(StandardCharsets.UTF_8), 32);
59+
60+
SecretKey key = hkdf.deriveKey("AES", params);
61+
62+
System.out.println("key = " + HexFormat.of().formatHex(key.getEncoded()));
63+
64+
}
65+
66+
}

0 commit comments

Comments
 (0)