Fix #87 - normalize to forward slashes
On windows when walking through jar contents some files use forward slashes and some backslashes. With this change we switch to a consistent usage of forward slashes throughout (converting backslashes to forward when necessary). With these changes the testsuites work on windows.
This commit is contained in:
@@ -46,7 +46,8 @@ public abstract class CloseableFilterableJavaFileObjectIterable implements Itera
|
|||||||
if (packageNameFilter!=null && packageNameFilter.contains(File.separator)) {
|
if (packageNameFilter!=null && packageNameFilter.contains(File.separator)) {
|
||||||
throw new IllegalArgumentException("Package name filters should use dots to separate components: "+packageNameFilter);
|
throw new IllegalArgumentException("Package name filters should use dots to separate components: "+packageNameFilter);
|
||||||
}
|
}
|
||||||
this.packageNameFilter = packageNameFilter==null?null:packageNameFilter.replace('.', File.separatorChar) + "/";
|
// Normalize filter to forward slashes
|
||||||
|
this.packageNameFilter = packageNameFilter==null?null:packageNameFilter.replace('.', '/') + '/';
|
||||||
this.includeSubpackages = includeSubpackages;
|
this.includeSubpackages = includeSubpackages;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -65,6 +66,8 @@ public abstract class CloseableFilterableJavaFileObjectIterable implements Itera
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
boolean accept;
|
boolean accept;
|
||||||
|
// Normalize to forward slashes (some jars are producing paths with forward slashes, some with backward slashes)
|
||||||
|
name = name.replace('\\', '/');
|
||||||
if (includeSubpackages == true) {
|
if (includeSubpackages == true) {
|
||||||
accept = name.startsWith(packageNameFilter);
|
accept = name.startsWith(packageNameFilter);
|
||||||
if (!accept && BOOT_PACKAGING_AWARE) {
|
if (!accept && BOOT_PACKAGING_AWARE) {
|
||||||
|
|||||||
@@ -33,10 +33,10 @@ public class CompiledClassDefinition {
|
|||||||
this.filename = filename;
|
this.filename = filename;
|
||||||
this.bytes = bytes;
|
this.bytes = bytes;
|
||||||
this.classname = filename;
|
this.classname = filename;
|
||||||
if (classname.startsWith(File.separator)) {
|
if (classname.startsWith("/")) {
|
||||||
classname = classname.substring(1);
|
classname = classname.substring(1);
|
||||||
}
|
}
|
||||||
classname = classname.replace(File.separatorChar, '.').substring(0, classname.length()-6);//strip off .class
|
classname = classname.replace('/', '.').substring(0, classname.length()-6); //strip off .class
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
|
|||||||
@@ -147,7 +147,7 @@ public class MemoryBasedJavaFileManager implements JavaFileManager {
|
|||||||
}
|
}
|
||||||
// Kind of ignoring location here... assuming we want basically the FQ type name
|
// Kind of ignoring location here... assuming we want basically the FQ type name
|
||||||
// Example value from getName(): javax/validation/bootstrap/GenericBootstrap.class
|
// Example value from getName(): javax/validation/bootstrap/GenericBootstrap.class
|
||||||
String classname = file.getName().replace('/', '.');
|
String classname = file.getName().replace('/', '.').replace('\\', '.');
|
||||||
return classname.substring(0, classname.lastIndexOf(".class"));
|
return classname.substring(0, classname.lastIndexOf(".class"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user