diff --git a/microbat/src/main/microbat/util/MicroBatUtil.java b/microbat/src/main/microbat/util/MicroBatUtil.java index 29399e105..28cddf2b9 100644 --- a/microbat/src/main/microbat/util/MicroBatUtil.java +++ b/microbat/src/main/microbat/util/MicroBatUtil.java @@ -219,7 +219,10 @@ public static String getSourceFolder(String cName, String projectName) { ICompilationUnit unit = JavaUtil.findICompilationUnitInProject(cName, projectName); IPath uri = unit.getResource().getFullPath(); String sourceFolderPath = IResourceUtils.getAbsolutePathOsStr(uri); - cName = cName.substring(0, cName.lastIndexOf(".")).replace(".", File.separator); + int lastIndexOfDot = cName.lastIndexOf("."); + if (lastIndexOfDot != -1) { + cName = cName.substring(0, lastIndexOfDot).replace(".", File.separator); + } sourceFolderPath = sourceFolderPath.substring(0, sourceFolderPath.indexOf(cName) - 1); return sourceFolderPath; }