Skip to content

Commit 2fe392a

Browse files
MBoegerstimtebeek
andauthored
Remove and cleanup System.getSecurityManager() (#716)
* set `System.getSecurityManager()`` calls to `null` and run cleanups afterwards. * Update java-version-25.yml --------- Co-authored-by: Tim te Beek <[email protected]>
1 parent 57d4c64 commit 2fe392a

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/main/resources/META-INF/rewrite/java-version-25.yml

+22
Original file line numberDiff line numberDiff line change
@@ -88,3 +88,25 @@ recipeList:
8888
methodPattern: java.lang.SecurityManager#check*(..)
8989
- org.openrewrite.staticanalysis.UnnecessaryCatch
9090
- org.openrewrite.staticanalysis.UnnecessaryThrows
91+
92+
---
93+
type: specs.openrewrite.org/v1beta/recipe
94+
name: org.openrewrite.java.migrate.SystemGetSecurityManagerToNull
95+
displayName: Replace `System.getSecurityManager()` with `null`
96+
description: >-
97+
The Security Manager API is unsupported in Java 24. This recipe will replace `System.getSecurityManager()` with `null`
98+
to make its behavior more obvious and try to simplify execution paths afterwards.
99+
tags:
100+
- java25
101+
- security
102+
- deprecation
103+
preconditions:
104+
- org.openrewrite.java.migrate.search.FindJavaVersion:
105+
version: 24
106+
- org.openrewrite.java.search.FindMethods:
107+
methodPattern: java.lang.System#getSecurityManager()
108+
recipeList:
109+
- org.openrewrite.java.ReplaceMethodInvocationWithConstant:
110+
methodPattern: java.lang.System#getSecurityManager()
111+
constant: "null"
112+
- org.openrewrite.staticanalysis.SimplifyConstantIfBranchExecution

0 commit comments

Comments
 (0)