diff --git a/src/main/java/haflow/utility/ClassHelper.java b/src/main/java/haflow/utility/ClassHelper.java index 4ee9163..6ae48e0 100644 --- a/src/main/java/haflow/utility/ClassHelper.java +++ b/src/main/java/haflow/utility/ClassHelper.java @@ -25,7 +25,7 @@ public class ClassHelper { for (URL url : urls) { if (url.getProtocol().equals("file")) { File file = new File(url.getFile()); - String root = file.getPath(); + String root = file.getPath().replace("\\", "/"); if (file.isDirectory()) { classNames.addAll(this.getClassNamesFromDirectory(root, packageName, searchInChildPackage, file, true)); @@ -48,10 +48,11 @@ public class ClassHelper { List classNames = new ArrayList(); File[] files = directory.listFiles(); for (File file : files) { + String filePath = file.getPath().replace("\\", "/"); if (file.isDirectory()) { if (searchInChildPackage || continueSearch) { boolean needToContinue = continueSearch; - if (file.getPath().endsWith(packageName.replace(".", "/"))) { + if (filePath.endsWith(packageName.replace(".", "/"))) { needToContinue = needToContinue & false; } classNames.addAll(this.getClassNamesFromDirectory(root, @@ -59,9 +60,8 @@ public class ClassHelper { needToContinue)); } } else { - if (file.getPath().endsWith(".class")) { - String classFileName = file.getPath().replace(root + "/", - ""); + if (filePath.endsWith(".class")) { + String classFileName = filePath.replace(root + "/", ""); if (classFileName.startsWith(packageName.replace(".", "/"))) { String className = classFileName.substring(0, classFileName.length() - ".class".length()) diff --git a/src/test/java/haflow/test/ClassHelperTest.java b/src/test/java/haflow/test/ClassHelperTest.java index 70d64f1..dfa374c 100644 --- a/src/test/java/haflow/test/ClassHelperTest.java +++ b/src/test/java/haflow/test/ClassHelperTest.java @@ -10,7 +10,7 @@ public class ClassHelperTest { @Test public void test() { ClassHelper classHelper = new ClassHelper(); - List classes = classHelper.getClassNames("haflow.module", true); + List classes = classHelper.getClassNames("haflow", true); if (classes != null) { for (String c : classes) { System.out.println(c);