damnhandy / Handy-URI-Templates

A Java URI Template processor implementing RFC6570
https://damnhandy.github.io/Handy-URI-Templates/
Other
202 stars 37 forks source link

Not working on android, java 1.8 sdk #48

Closed sebastianmacarescu closed 8 years ago

sebastianmacarescu commented 8 years ago

Running the provided example: UriTemplate template = UriTemplate.buildFromTemplate("http://example.com") .literal("/foo") .path(var("thing1"),var("explodedThing", true)) .fragment(var("prefix", 2)) .build();

Give FATAL EXCEPTION:

Caused by: java.util.regex.PatternSyntaxException: Syntax error in regexp pattern near index 4: (?[^\/]+)(?[^\/]+) ^ at java.util.regex.Pattern.compileImpl(Native Method) at java.util.regex.Pattern.compile(Pattern.java:411) at java.util.regex.Pattern.(Pattern.java:394) at java.util.regex.Pattern.compile(Pattern.java:381) at com.damnhandy.uri.template.Expression.buildMatchingPattern(Expression.java:390) at com.damnhandy.uri.template.Expression.(Expression.java:288) at com.damnhandy.uri.template.Expression$Builder.build(Expression.java:570) at com.damnhandy.uri.template.UriTemplateBuilder.path(UriTemplateBuilder.java:473) at ro.assist.bookingbugandroid.LoginActivity.onCreate(LoginActivity.java:66) at android.app.Activity.performCreate(Activity.java:6221) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2614) ... 10 more

damnhandy commented 8 years ago

What version of the Android SDK are you using? Also, how are you using JDK 8 with Android? The current release only supports Java 7 features. Are you referring to running Android Studio under Java 8? More importantly, what version of Handy URI Templates are you using?

sebastianmacarescu commented 8 years ago

You can use jdk8 with retro-lambda in Android Studio. I have upgraded to the last version of damnhandy library and now it works.

I was using 2.1.0

damnhandy commented 8 years ago

Okay. This sounded like it was an issue that was fixed in 2.1.1 as a result of PR #38 since this was happening in Expression.buildMatchingPattern(), which now no longer pre-calculates the regex.