Allow relative paths by getting the absolute file (seriously Java)

This commit is contained in:
Daniel Holle 2023-11-06 12:30:42 +01:00
parent f588ece7c3
commit ec04f01a10

View File

@ -75,7 +75,7 @@ public class CompilationEnvironment {
ClassLoader classLoader = compiler.getClassLoader(); ClassLoader classLoader = compiler.getClassLoader();
List<Class> ret = new ArrayList<>(); List<Class> ret = new ArrayList<>();
// Set classLoader to include default package for this specific source file // Set classLoader to include default package for this specific source file
File dir = sourceFile.getParentFile(); File dir = sourceFile.getAbsoluteFile().getParentFile();
String dirPath = dir.toString() + "/"; String dirPath = dir.toString() + "/";
if (packageName.length() > 0) if (packageName.length() > 0)
dirPath = dirPath.substring(0, dirPath.length() - packageName.length() - 1); dirPath = dirPath.substring(0, dirPath.length() - packageName.length() - 1);