Fix byte array memory leak from MemoryBasedClassLoader

40 Mb of bytes of preloaded compiler classes during the compilation become 16
Mb after this change

This is a slightly reworked version of 58b033d (reverted in 3f05419). The
problem in that commit was that URLClassLoader did not work in the fashion
MemoryBasedClassLoader was designed to work (child first, parent last). So some
resource was found in an incorrect jar which was causing the compiler to break
This commit is contained in:
Alexander Udalov
2015-03-24 16:40:42 +03:00
parent 45da9555de
commit 485dce987c
3 changed files with 39 additions and 5 deletions
@@ -135,7 +135,11 @@ public class PathUtil {
@NotNull
public static File getResourcePathForClass(@NotNull Class aClass) {
String resourceRoot = PathManager.getResourceRoot(aClass, "/" + aClass.getName().replace('.', '/') + ".class");
String path = "/" + aClass.getName().replace('.', '/') + ".class";
String resourceRoot = PathManager.getResourceRoot(aClass, path);
if (resourceRoot == null) {
throw new IllegalStateException("Resource not found: " + path);
}
return new File(resourceRoot).getAbsoluteFile();
}