Community
Participate
Working Groups
APT uses URLClassLoader, which opens streams on its resources and does not ensure they are closed until URLClassLoader.close() is called. When APT clears its cached classloaders (org.eclipse.jdt.apt.core.internal.AnnotationProcessorFactoryLoader.uncacheProject(IJavaProject), org.eclipse.jdt.apt.core.internal.AnnotationProcessorFactoryLoader.resetAll(), org.eclipse.jdt.apt.core.internal.AnnotationProcessorFactoryLoader.resetBatchProcessors(IJavaProject)), it only calls close() on the classloader if it is a JarClassLoader (a class which is actually not used anywhere). This means that resources opened by URLClassLoader are never closed. I propose that the code is changed to check if the classloader is a URLClassLoader instead of JarClassLoader.
(In reply to Harry Terkelsen from comment #0) > it only calls close() on the > classloader if it is a JarClassLoader (a class which is actually not used > anywhere). I am surprised, but you are right. The only place where we seem to refer to JarClassLoader is in those instanceof checks. > I propose that the code is changed to check if the classloader is a > URLClassLoader instead of JarClassLoader. I will look into this.
(In reply to Jayaprakash Arthanareeswaran from comment #1) > I will look into this. Hmm... URLClassLoader#close() is a 1.7 method and the apt.core project is still at 1.5. More importantly, eclipse needs to run with a 1.6 JRE :(
(In reply to Jayaprakash Arthanareeswaran from comment #2) > Hmm... URLClassLoader#close() is a 1.7 method and the apt.core project is > still at 1.5. More importantly, eclipse needs to run with a 1.6 JRE :( You can do something like: if (classLoader instanceof Closeable) ((Closeable) classLoader).close(); This would not eliminate the resource leak under JRE 1.6, but under JRE 1.7 the problem would be fixed.
A proposed fix is in https://git.eclipse.org/r/#/c/30473/.
Thanks Harry. Released in master for M1.
The code is verified by inspection. The class JarClassLoader (functions and constructors) is not referred at all. Verified for 4.5 M1 using I20140804-2000 build. Thanks