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

Fix PatternSyntaxException on Android 5 & 6 #343

Closed
wants to merge 3 commits into from

Conversation

vonox7
Copy link
Contributor

@vonox7 vonox7 commented Oct 18, 2021

Exception message: Syntax error in regexp pattern near index 38: ^simplejavamail\.extraproperties\.(?<actualProperty>.*)

Please note that Android 5 doesn't support named capturing groups, see https://github.com/tony19/named-regexp or https://stackoverflow.com/questions/32776168/regex-pattern-in-android-studio-throws-error-this-named-group-syntax-is-not-su.
Changing this Regex to an unnamed capture group creates no functional change, except that there are no RuntimeCrashes when using simple-java-mail with old Android versions.

Note: group 0 is "whole regex", group 1 is "first group".

Exception message: `Syntax error in regexp pattern near index 38: ^simplejavamail\.extraproperties\.(?<actualProperty>.*)`

Please note that Android 5 doesn't support named capturing groups, see https://github.com/tony19/named-regexp or https://stackoverflow.com/questions/32776168/regex-pattern-in-android-studio-throws-error-this-named-group-syntax-is-not-su.
Changing this to an unnamed capture group creates no functional change, except that there are no RuntimeCrashes when using simple-java-mail with old Android versions.
@bbottema
Copy link
Owner

I used named groups in a few more places, are those not problematic?

@vonox7
Copy link
Contributor Author

vonox7 commented Oct 21, 2021

Ok yeah, this could then be problematic too. Probably depends on the usage of simple-java-mail.

@vonox7
Copy link
Contributor Author

vonox7 commented Nov 15, 2021

For everyone else who is also struggling with crashes on Android due to newer simple-java-mail versions: https://github.com/bbottema/simple-java-mail/releases/tag/6.1.0 is the last version that doesn't use named capturing groups, so use this version in case you use simple-java-mail on Android.

@vonox7
Copy link
Contributor Author

vonox7 commented Nov 15, 2021

This PR removes now all named regex groups except the one used in StringUtil.replaceNestedTokens(), but this function is only used in the cli-modules (and the testcases), so there should not be any further Android crashes.

@bbottema sadly i was not able to compile the project locally, so please run the tests on your machine when merging this PR.

@vonox7 vonox7 changed the title Fix PatternSyntaxException on Android 5 Fix PatternSyntaxException on Android 5 & 6 Nov 15, 2021
@bbottema
Copy link
Owner

Closing in favor of solution 2 in #352 (integrate named-regexp instead, which adds named regex group support Android)

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

Successfully merging this pull request may close these issues.

Bug: names regex groups are not supported in Android JVM
2 participants