Skip to content

Commit

Permalink
Use Java 21 toolchain for rewrite-migrate-java
Browse files Browse the repository at this point in the history
Replaces #337
  • Loading branch information
timtebeek committed Nov 1, 2024
1 parent 88cf8f5 commit 3987a73
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .sdkmanrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Enable auto-env through the sdkman_auto_env config
# Add key=value pairs of SDKs to use below
java=21.0.2-tem
java=21.0.5-tem
6 changes: 6 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ dependencies {
testRuntimeOnly(gradleApi())
}

java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(21))
}
}

tasks.withType(Javadoc::class.java) {
exclude("**/PlanJavaMigration.java")
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,15 @@
package org.openrewrite.java.migrate;

import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledForJreRange;
import org.junit.jupiter.api.condition.JRE;
import org.openrewrite.DocumentExample;
import org.openrewrite.test.RecipeSpec;
import org.openrewrite.test.RewriteTest;

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

@EnabledForJreRange(max = JRE.JAVA_17)
class DeleteDeprecatedFinalizeTest implements RewriteTest {

@Override
Expand All @@ -38,54 +41,54 @@ void deleteDeprecatedFinalize() {
java(
"""
package java.awt.color;
import java.awt.color.ICC_Profile;
import java.awt.image.ColorModel;
import java.awt.image.IndexColorModel;
public class Test {
public static void main(String[] args) {
byte ff = (byte) 0xff;
byte[] r = { ff, 0, 0, ff, 0 };
byte[] g = { 0, ff, 0, ff, 0 };
byte[] b = { 0, 0, ff, ff, 0 };
ICC_Profile profile = ICC_Profile.getInstance(ICC_Profile.CLASS_COLORSPACECONVERSION);
// flag
profile.finalize();
ColorModel cm = new IndexColorModel(3, 5, r, g, b);
// flag
cm.finalize();
IndexColorModel icm = new IndexColorModel(3, 5, r, g, b);
// flag
icm.finalize();
}
}
""",
"""
package java.awt.color;
import java.awt.color.ICC_Profile;
import java.awt.image.ColorModel;
import java.awt.image.IndexColorModel;
public class Test {
public static void main(String[] args) {
byte ff = (byte) 0xff;
byte[] r = { ff, 0, 0, ff, 0 };
byte[] g = { 0, ff, 0, ff, 0 };
byte[] b = { 0, 0, ff, ff, 0 };
ICC_Profile profile = ICC_Profile.getInstance(ICC_Profile.CLASS_COLORSPACECONVERSION);
ColorModel cm = new IndexColorModel(3, 5, r, g, b);
IndexColorModel icm = new IndexColorModel(3, 5, r, g, b);
}
}
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,15 @@

import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledForJreRange;
import org.junit.jupiter.api.condition.JRE;
import org.openrewrite.Issue;
import org.openrewrite.test.RecipeSpec;
import org.openrewrite.test.RewriteTest;

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


@Issue("https://github.com/openrewrite/rewrite-migrate-java/issues/243")
@EnabledForJreRange(min = JRE.JAVA_21)
class SequencedCollectionTest implements RewriteTest {

@Override
public void defaults(RecipeSpec spec) {
spec.recipeFromResource("/META-INF/rewrite/java-version-21.yml", "org.openrewrite.java.migrate.util.SequencedCollection");
Expand All @@ -42,8 +39,8 @@ void firstToGetFirst() {
//language=java
java(
"""
import java.util.*;
import java.util.SortedSet;
class Foo {
void bar(SortedSet<String> collection) {
String first = collection.first();
Expand All @@ -53,7 +50,7 @@ void bar(SortedSet<String> collection) {
""",
"""
import java.util.*;
class Foo {
void bar(SortedSet<String> collection) {
String first = collection.getFirst();
Expand All @@ -75,7 +72,7 @@ void descendingSetToReversed() {
java(
"""
import java.util.*;
class Foo {
void bar(NavigableSet<String> collection) {
NavigableSet<String> reversed = collection.descendingSet();
Expand All @@ -84,7 +81,7 @@ void bar(NavigableSet<String> collection) {
""",
"""
import java.util.*;
class Foo {
void bar(NavigableSet<String> collection) {
NavigableSet<String> reversed = collection.reversed();
Expand Down

0 comments on commit 3987a73

Please sign in to comment.