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

Remove Runtime.runFinalizersOnExit() in upgrade to Java 11 #244

Merged
merged 8 commits into from
Nov 20, 2023
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* Copyright 2023 the original author or authors.
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* https://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.openrewrite.java.migrate;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.openrewrite.ExecutionContext;
import org.openrewrite.Option;
import org.openrewrite.Recipe;
import org.openrewrite.TreeVisitor;
import org.openrewrite.internal.lang.NonNull;
import org.openrewrite.java.MethodMatcher;
import org.openrewrite.staticanalysis.RemoveMethodCallVisitor;

public class RemoveMethodInvocation extends Recipe {
@Option(displayName = "Method Pattern",
description = "A method pattern for matching required method definition.",
example = "*..* hello(..)")
@NonNull
private String methodPattern;

@JsonCreator
public RemoveMethodInvocation(@JsonProperty("methodPattern") String methodPattern) {
this.methodPattern = methodPattern;
}

@Override
public String getDisplayName() {
return "Remove methods calls";
}

@Override
public String getDescription() {
return "Checks for a method patterns and removes the method call from the class.";
}

@Override
public TreeVisitor<?, ExecutionContext> getVisitor() {
return new RemoveMethodCallVisitor<>(new MethodMatcher(methodPattern), (n, it) -> true);
}
}

This file was deleted.

This file was deleted.

This file was deleted.

12 changes: 6 additions & 6 deletions src/main/resources/META-INF/rewrite/jakarta-ee-10.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,17 @@ description: >
In addition, the behavior of these methods has been changed so the setters no longer have any effect, the getComment methods return null, and the getVersion method returns 0.
The deprecated methods are removed.
recipeList:
- org.openrewrite.java.migrate.jakarta.RemoveMethods:
- org.openrewrite.java.migrate.RemoveMethodInvocation:
methodPattern: jakarta.servlet.http.Cookie getComment()
- org.openrewrite.java.migrate.jakarta.RemoveMethods:
- org.openrewrite.java.migrate.RemoveMethodInvocation:
methodPattern: jakarta.servlet.http.Cookie getVersion()
- org.openrewrite.java.migrate.jakarta.RemoveMethods:
- org.openrewrite.java.migrate.RemoveMethodInvocation:
methodPattern: jakarta.servlet.http.Cookie setComment(String)
- org.openrewrite.java.migrate.jakarta.RemoveMethods:
- org.openrewrite.java.migrate.RemoveMethodInvocation:
methodPattern: jakarta.servlet.http.Cookie setVersion(int)
- org.openrewrite.java.migrate.jakarta.RemoveMethods:
- org.openrewrite.java.migrate.RemoveMethodInvocation:
methodPattern: jakarta.servlet.SessionCookieConfig getComment()
- org.openrewrite.java.migrate.jakarta.RemoveMethods:
- org.openrewrite.java.migrate.RemoveMethodInvocation:
methodPattern: jakarta.servlet.SessionCookieConfig setComment(String)
---
type: specs.openrewrite.org/v1beta/recipe
Expand Down
4 changes: 4 additions & 0 deletions src/main/resources/META-INF/rewrite/java-version-11.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ recipeList:
- org.openrewrite.staticanalysis.PrimitiveWrapperClassConstructorToValueOf
- org.openrewrite.java.migrate.concurrent.JavaConcurrentAPIs
- org.openrewrite.java.migrate.lang.JavaLangAPIs
- org.openrewrite.java.migrate.RemoveMethodInvocation:
methodPattern: java.lang.Runtime runFinalizersOnExit(boolean)
- org.openrewrite.java.migrate.RemoveMethodInvocation:
methodPattern: java.lang.System runFinalizersOnExit(boolean)
- org.openrewrite.java.migrate.logging.JavaLoggingAPIs
- org.openrewrite.java.migrate.lombok.UpdateLombokToJava11
- org.openrewrite.java.migrate.net.JavaNetAPIs
Expand Down
5 changes: 4 additions & 1 deletion src/main/resources/META-INF/rewrite/java-version-17.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ recipeList:
- org.openrewrite.github.SetupJavaUpgradeJavaVersion:
minimumJavaMajorVersion: 17
- org.openrewrite.staticanalysis.InstanceOfPatternMatch
- org.openrewrite.java.migrate.lang.RemoveRuntimeTraceMethods
- org.openrewrite.java.migrate.RemoveMethodInvocation:
methodPattern: java.lang.Runtime traceInstructions(boolean)
- org.openrewrite.java.migrate.RemoveMethodInvocation:
methodPattern: java.lang.System traceMethodCalls(boolean)
- org.openrewrite.java.migrate.lang.UseTextBlocks
- org.openrewrite.java.migrate.lombok.LombokValueToRecord
- org.openrewrite.java.migrate.DeprecatedJavaxSecurityCert
Expand Down
4 changes: 3 additions & 1 deletion src/main/resources/META-INF/rewrite/java-version-8.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,6 @@ description: >
tags:
- java8
recipeList:
- org.openrewrite.java.migrate.MXBeanNonPublic
- org.openrewrite.java.migrate.MXBeanNonPublic
- org.openrewrite.java.migrate.RemoveMethodInvocation:
methodPattern: java.lang.Thread destroy()
Loading
Loading