cailin186 / reflections

Automatically exported from code.google.com/p/reflections
Do What The F*ck You Want To Public License
0 stars 0 forks source link

Vfs.normalizePath does not always detect Windows drive letter #60

Closed GoogleCodeExporter closed 9 years ago

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

1. Use Reflections 0.9.5-RC1 under Windows.
2. Search the classpath for classes annotated with a certain annotation, having 
at least one thus annotated class in a directory that is on the classpath.

What is the expected output? What do you see instead?

I would expect the code block that handles Windows drive letters in the method 
normalizePath to detect the letter and keep it, as it was intended in the code 
(which I gather from the inline comments).

However, in the Debugger I see that the local String variable maybeDrive ends 
up being on length 2, containing a back-slash and the drive letter. The 
following if-statement means that a Windows drive letter is only detected if 
maybeDrive contains only the letter itself, and thus in my case the letter is 
not detected.

What version of the product are you using? On what operating system?

0.9.5-RC1

Additional Information.

Note that in my case the URL to be normalized contained the protocol "file:" as 
well as the drive letter "D:". Furthermore, I use cygwin which means that my 
URLs come with slashes. The URL String (path) to be normalized was like 
"file:/D:/dir0/dir1/dir2/".

Original issue reported on code.google.com by post.at....@googlemail.com on 15 Nov 2010 at 2:41

GoogleCodeExporter commented 9 years ago
upgrade to rc2

Original comment by ronm...@gmail.com on 15 Nov 2010 at 2:46

GoogleCodeExporter commented 9 years ago
Okay, done. Another point though, in rc1 I definitely needed a trick to make it 
work under Windows regarding the System File-Separator, the Back-Shash. On a 
package prefix I called packagePrefix.replace(".", ".?\\\\?"); so that the 
Regular Expression would also cover paths with Back-Slashes. I am not quite 
sure if this has been fixed in rc2 already. Example:

String packagePrefix = ...; // something like com.company
FilterBuilder predicate = new FilterBuilder();
String preparedPackagePrefix = packagePrefix.replace(".", ".?\\\\?")
predicate.include(FilterBuilder.prefix(preparedPackagePrefix));

Original comment by post.at....@googlemail.com on 4 Jan 2011 at 4:23

GoogleCodeExporter commented 9 years ago
fixed on trunk

Original comment by ronm...@gmail.com on 12 May 2011 at 7:49