Skip to content

Conversation

satvika-eda
Copy link
Contributor

@satvika-eda satvika-eda commented Jun 27, 2023

What's changed?

Remove deprecated invocations of Runtime.traceInstructions() and Runtime.traceMethodCalls() which have no alternatives needed.

What's your motivation?

To automate JDK migration to a greater extent

Checklist

  • I've added unit tests to cover both positive and negative cases
  • I've added the license header to any new files through ./gradlew licenseFormat
  • I've used the IntelliJ auto-formatter on affected files
  • I've updated the documentation (if applicable)

@timtebeek timtebeek added the recipe Recipe requested label Jun 27, 2023
@timtebeek timtebeek self-requested a review June 27, 2023 10:21
@timtebeek
Copy link
Member

timtebeek commented Jun 27, 2023

For context: this was removed in Java 13
https://bugs.openjdk.org/browse/JDK-8225330
As per https://javaalmanac.io/jdk/17/apidiff/11/

It's possible that some code out there has calls to these methods. Such calls will fail in the future with NoSuchMethodError. However, since these methods do nothing, any code that calls these methods cannot be depending on any actual functionality provided by these methods. The remediation is simply to remove calls to these methods.

Copy link
Member

@timtebeek timtebeek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some suggestions already, after checking out your branch locally and running through the changes.

In general I can say the code snippets in the tests were not yet valid for any version of Java; you can fix that through my code suggestions that you can apply all at once from this page: https://github.com/openrewrite/rewrite-migrate-java/pull/247/files

The recipe does not make the best use of the type system, possibly due to limitations with replacing methods formerly in the JDK. Not sure if there's a better way, as I struggled with forcing the test and replacements to use older versions of Java, and still did not get the method type to show. We can keep things as they are for now, as there's unlikely to arise any conflicts given that these methods are already on java.lang.Runtime.

And of course thanks a lot for these changes already! Good to get these removed for any upgrade to the Java runtime.

@satvika-eda satvika-eda mentioned this pull request Jul 11, 2023
4 tasks
@timtebeek timtebeek changed the title removing deprecated runtime methods recipe Removing deprecated Runtime trace methods in move to Java 17 Nov 20, 2023
Copy link
Member

@timtebeek timtebeek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Appreciate your patience in getting this through @satvika-eda ! I've pushed a polishing commit and included this in the migration to Java 17, accepting that we can not properly test this with the way our tests are set up. Thanks again!

@timtebeek timtebeek merged commit 010f7af into openrewrite:main Nov 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

recipe Recipe requested

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

3 participants