Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Java 21 toolchain for rewrite-migrate-java #595

Merged
merged 3 commits into from
Nov 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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")
}
Expand Down
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 @@ -43,7 +40,7 @@ void firstToGetFirst() {
java(
"""
import java.util.*;

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