weikipeng / javacpp

Automatically exported from code.google.com/p/javacpp
GNU General Public License v2.0
0 stars 0 forks source link

Current snapshot immediately crashes in Windows #41

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

1. calling Loader.java -> loadProperties(String name) in Windows
-> Regex exception on line 118 
-> s.split(File.separator, -1)

Why ?

String.split works on Regex, but File.separator returns "\" which is an escape 
character in both Regex and Java. This causes an immediate crash. This fix 
should make it work on all platforms.

-> s.split(Pattern.quote(File.separator), -1)

Pattern.quote(...) takes an arbitrary String and escapes it. For Windows it 
will return "\\\".

Florian

Original issue reported on code.google.com by Florian....@gmail.com on 16 Dec 2013 at 3:41

GoogleCodeExporter commented 9 years ago
Whoopsie, I only thought about using it because it's a character that can't be 
part of a filename. I did not try it on Windows before pushing that change. 
Maybe hardcoding '/' would be a better idea. What do you think?

Original comment by samuel.a...@gmail.com on 16 Dec 2013 at 3:43

GoogleCodeExporter commented 9 years ago
added patch

Original comment by Florian....@gmail.com on 16 Dec 2013 at 3:47

Attachments:

GoogleCodeExporter commented 9 years ago
I think hardcoding '/' would probably make the intention a bit more clear than 
using Delimiter

Original comment by Florian....@gmail.com on 16 Dec 2013 at 5:22

GoogleCodeExporter commented 9 years ago
Ok, and let's get rid of the regex while we're at it. I've made the changes in 
the repo:
https://code.google.com/p/javacpp/source/detail?r=e192b1eacc824bd2fef5ca8bf8e5f3
2578b61d6b

Thanks for reporting!

Original comment by samuel.a...@gmail.com on 17 Dec 2013 at 1:07

GoogleCodeExporter commented 9 years ago
Tested and it works like a charm :) Thanks

Original comment by Florian....@gmail.com on 17 Dec 2013 at 4:45

GoogleCodeExporter commented 9 years ago
Fix included in JavaCPP 0.7! Thanks for reporting, and let me know that 
everything works OK.

Original comment by samuel.a...@gmail.com on 8 Jan 2014 at 1:25