Skip to content

PatternSyntaxException when use on Android. #23

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

Closed
jxzhung opened this issue Aug 16, 2018 · 2 comments
Closed

PatternSyntaxException when use on Android. #23

jxzhung opened this issue Aug 16, 2018 · 2 comments
Assignees
Labels
Milestone

Comments

@jxzhung
Copy link

jxzhung commented Aug 16, 2018

Hi, raydac:

When I use this lib on my personal Android App with version '1.4.0', I got an error like below.

Process: com.demo.netsniffer, PID: 1646 java.lang.ExceptionInInitializerError at com.igormaznitsa.jbbp.compiler.JBBPCompiler.compile(JBBPCompiler.java:214) at com.igormaznitsa.jbbp.JBBPParser.<init>(JBBPParser.java:132) at com.igormaznitsa.jbbp.JBBPParser.prepare(JBBPParser.java:160) at com.igormaznitsa.jbbp.JBBPParser.prepare(JBBPParser.java:206) at com.demo.netsniffer.core.SnifferVpnService.<init>(SnifferVpnService.java:38) at java.lang.Class.newInstance(Native Method) at android.app.ActivityThread.handleCreateService(ActivityThread.java:3173) at android.app.ActivityThread.-wrap5(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1567) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6119) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776) Caused by: java.util.regex.PatternSyntaxException: Syntax error in regexp pattern near index 14 \s*//.*$|\s*(})|\s*([^\s;\[\]}{]+)?\s*(?:\[\s*([^\[\]{};]+)\s*])?\s*([^\d\s;\[\]}{/][^\s;\[\]}{/]*)?\s*([{;]) ^ at java.util.regex.Pattern.compileImpl(Native Method) at java.util.regex.Pattern.compile(Pattern.java:1340) at java.util.regex.Pattern.<init>(Pattern.java:1324) at java.util.regex.Pattern.compile(Pattern.java:971) at com.igormaznitsa.jbbp.compiler.tokenizer.JBBPTokenizer.<clinit>(JBBPTokenizer.java:46) ... 15 more

It seems that the regex pattern in "JBBPTokenizer.java" can not be complied on Android.
field:
private static final Pattern PATTERN = Pattern.compile("\\s*//.*$|\\s*(})|\\s*([^\\s;\\[\\]}{]+)?\\s*(?:\\[\\s*([^\\[\\]{};]+)\\s*])?\\s*([^\\d\\s;\\[\\]}{/][^\\s;\\[\\]}{/]*)?\\s*([{;])", Pattern.MULTILINE);

Could you fix it?

@raydac raydac self-assigned this Aug 16, 2018
@raydac raydac added the bug label Aug 16, 2018
@raydac raydac added this to the 1.4.1 milestone Aug 16, 2018
@raydac
Copy link
Owner

raydac commented Aug 16, 2018

which version of Android API do you use?

@jxzhung
Copy link
Author

jxzhung commented Aug 17, 2018

My Android phone is 8.1.0 and I have tested on Genymotion Android Emulator with Android 7.0 but got the same exception.

Update:
your fix worked well on Android now.

@raydac raydac closed this as completed Aug 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants