Skip to content

Commit 1f9e430

Browse files
authored
Use Java 21 toolchain for rewrite-migrate-java (#595)
* Use Java 21 toolchain for rewrite-migrate-java Replaces #337 * Restore original import
1 parent 312cf90 commit 1f9e430

File tree

4 files changed

+28
-22
lines changed

4 files changed

+28
-22
lines changed

.sdkmanrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# Enable auto-env through the sdkman_auto_env config
22
# Add key=value pairs of SDKs to use below
3-
java=21.0.2-tem
3+
java=21.0.5-tem

build.gradle.kts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,12 @@ dependencies {
6262
testRuntimeOnly(gradleApi())
6363
}
6464

65+
java {
66+
toolchain {
67+
languageVersion.set(JavaLanguageVersion.of(21))
68+
}
69+
}
70+
6571
tasks.withType(Javadoc::class.java) {
6672
exclude("**/PlanJavaMigration.java")
6773
}

src/test/java/org/openrewrite/java/migrate/DeleteDeprecatedFinalizeTest.java

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,15 @@
1616
package org.openrewrite.java.migrate;
1717

1818
import org.junit.jupiter.api.Test;
19+
import org.junit.jupiter.api.condition.EnabledForJreRange;
20+
import org.junit.jupiter.api.condition.JRE;
1921
import org.openrewrite.DocumentExample;
2022
import org.openrewrite.test.RecipeSpec;
2123
import org.openrewrite.test.RewriteTest;
2224

2325
import static org.openrewrite.java.Assertions.java;
2426

27+
@EnabledForJreRange(max = JRE.JAVA_17)
2528
class DeleteDeprecatedFinalizeTest implements RewriteTest {
2629

2730
@Override
@@ -38,54 +41,54 @@ void deleteDeprecatedFinalize() {
3841
java(
3942
"""
4043
package java.awt.color;
41-
44+
4245
import java.awt.color.ICC_Profile;
4346
import java.awt.image.ColorModel;
4447
import java.awt.image.IndexColorModel;
45-
48+
4649
public class Test {
4750
public static void main(String[] args) {
4851
byte ff = (byte) 0xff;
4952
byte[] r = { ff, 0, 0, ff, 0 };
5053
byte[] g = { 0, ff, 0, ff, 0 };
5154
byte[] b = { 0, 0, ff, ff, 0 };
52-
55+
5356
ICC_Profile profile = ICC_Profile.getInstance(ICC_Profile.CLASS_COLORSPACECONVERSION);
5457
// flag
5558
profile.finalize();
56-
59+
5760
ColorModel cm = new IndexColorModel(3, 5, r, g, b);
58-
61+
5962
// flag
6063
cm.finalize();
61-
64+
6265
IndexColorModel icm = new IndexColorModel(3, 5, r, g, b);
6366
// flag
6467
icm.finalize();
65-
68+
6669
}
6770
}
6871
""",
6972
"""
7073
package java.awt.color;
71-
74+
7275
import java.awt.color.ICC_Profile;
7376
import java.awt.image.ColorModel;
7477
import java.awt.image.IndexColorModel;
75-
78+
7679
public class Test {
7780
public static void main(String[] args) {
7881
byte ff = (byte) 0xff;
7982
byte[] r = { ff, 0, 0, ff, 0 };
8083
byte[] g = { 0, ff, 0, ff, 0 };
8184
byte[] b = { 0, 0, ff, ff, 0 };
82-
85+
8386
ICC_Profile profile = ICC_Profile.getInstance(ICC_Profile.CLASS_COLORSPACECONVERSION);
84-
87+
8588
ColorModel cm = new IndexColorModel(3, 5, r, g, b);
86-
89+
8790
IndexColorModel icm = new IndexColorModel(3, 5, r, g, b);
88-
91+
8992
}
9093
}
9194
"""

src/test/java/org/openrewrite/java/migrate/util/SequencedCollectionTest.java

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,15 @@
1717

1818
import org.junit.jupiter.api.Nested;
1919
import org.junit.jupiter.api.Test;
20-
import org.junit.jupiter.api.condition.EnabledForJreRange;
21-
import org.junit.jupiter.api.condition.JRE;
2220
import org.openrewrite.Issue;
2321
import org.openrewrite.test.RecipeSpec;
2422
import org.openrewrite.test.RewriteTest;
2523

2624
import static org.openrewrite.java.Assertions.java;
2725

28-
2926
@Issue("https://github.com/openrewrite/rewrite-migrate-java/issues/243")
30-
@EnabledForJreRange(min = JRE.JAVA_21)
3127
class SequencedCollectionTest implements RewriteTest {
28+
3229
@Override
3330
public void defaults(RecipeSpec spec) {
3431
spec.recipeFromResource("/META-INF/rewrite/java-version-21.yml", "org.openrewrite.java.migrate.util.SequencedCollection");
@@ -43,7 +40,7 @@ void firstToGetFirst() {
4340
java(
4441
"""
4542
import java.util.*;
46-
43+
4744
class Foo {
4845
void bar(SortedSet<String> collection) {
4946
String first = collection.first();
@@ -53,7 +50,7 @@ void bar(SortedSet<String> collection) {
5350
""",
5451
"""
5552
import java.util.*;
56-
53+
5754
class Foo {
5855
void bar(SortedSet<String> collection) {
5956
String first = collection.getFirst();
@@ -75,7 +72,7 @@ void descendingSetToReversed() {
7572
java(
7673
"""
7774
import java.util.*;
78-
75+
7976
class Foo {
8077
void bar(NavigableSet<String> collection) {
8178
NavigableSet<String> reversed = collection.descendingSet();
@@ -84,7 +81,7 @@ void bar(NavigableSet<String> collection) {
8481
""",
8582
"""
8683
import java.util.*;
87-
84+
8885
class Foo {
8986
void bar(NavigableSet<String> collection) {
9087
NavigableSet<String> reversed = collection.reversed();

0 commit comments

Comments
 (0)