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

Escape $ in patterns #64

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

szeiger
Copy link

@szeiger szeiger commented Jan 27, 2025

$ is a valid character in an identifier (Character.isJavaIdentifierPart) and thus it is (correctly) accepted by jarjar in rule patterns, but it is not escaped when building the regex (which is not necessary for other identifier characters). This makes it impossible to match inner classes (which always contain a $) and other synthetic classes directly (which is necessary to rename classes instead of simply moving them to other packages). Escaping it as \$ makes these matches work correctly.

`$` is a valid character in an identifier (`Character.isJavaIdentifierPart`) and thus it is (correctly) accepted by jarjar in rule patterns, but it is not escaped when building the regex (which is not necessary for other identifier characters). This makes it impossible to match inner classes (which always contain a `$`) and other synthetic classes directly (which is necessary to rename classes instead of simply moving them to other packages). Escaping it as `\$` makes these matches work correctly.
@johnynek
Copy link
Collaborator

can we add a test for this case?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants