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

ChangePackage doesn't handle classes with GWT JNSI methods #4995

Open
auke- opened this issue Feb 6, 2025 · 7 comments
Open

ChangePackage doesn't handle classes with GWT JNSI methods #4995

auke- opened this issue Feb 6, 2025 · 7 comments
Labels
bug Something isn't working

Comments

@auke-
Copy link

auke- commented Feb 6, 2025

What version of OpenRewrite are you using?

I am using OpenRewrite v8.44.2 with the ChangePackage recipe.

What is the smallest, simplest way to reproduce the problem?

type: specs.openrewrite.org/v1beta/recipe
name: com.yourorg.ChangePackageExample
displayName: Rename package name example
recipeList:
  - org.openrewrite.java.ChangePackage:
      oldPackageName: old_package_name
      newPackageName: new_package_name
package old_package_name;
class A {
  native void alert(String msg) /*-{ $wnd.alert(msg); }-*/;
}

What did you expect to see?

package new_package_name;
class A {
  native void alert(String msg) /*-{ $wnd.alert(msg); }-*/;
}

What did you see instead?

OpenRewrite didn't touch the file. It seems like it ignores Java classes with native methods and/or trailing comment.

See reproducer

@auke- auke- added the bug Something isn't working label Feb 6, 2025
@timtebeek
Copy link
Contributor

Thanks for the runnable report! Feel free to open up a draft PR; that makes it easier to pull into an IDEA and explore. We're not too strict on requiring an issue or working fix first.

@auke-
Copy link
Author

auke- commented Feb 6, 2025

Hmm... looks i've made some errror on my side, the reproducer isn't correct.

@auke- auke- closed this as completed Feb 6, 2025
@auke-
Copy link
Author

auke- commented Feb 6, 2025

We did encounter issues with the ChangePackage recipe and it looked like is had to to with native methods. Will try to create a proper reproducer tomorrow. Do you have another channel for quick questions, besides issues and discussions in Github?

@timtebeek
Copy link
Contributor

Sure, always welcome on our Slack! :)

@auke- auke- reopened this Feb 7, 2025
@github-project-automation github-project-automation bot moved this from Done to In Progress in OpenRewrite Feb 7, 2025
@auke- auke- changed the title ChangePackage doesn't handle classes with native methods ChangePackage doesn't handle classes with GWT JNSI methods Feb 7, 2025
@auke-
Copy link
Author

auke- commented Feb 7, 2025

An even smaller reproducer shows that the trailing comment is causing the issue:

import org.openrewrite.Foo;
interface Test {
  void foo() /* */;
}

@timtebeek
Copy link
Contributor

Thanks for the helpful reproducer! Indeed something to fix in the parser then it seems. Did you already explore that side?

@auke-
Copy link
Author

auke- commented Feb 7, 2025

No, i didn't look into the parser side yet and i probably don't have time until after the weekend.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: In Progress
Development

No branches or pull requests

2 participants