JDK-2210060 : regression: NPE in CloseableURLClassLoader
  • Type: Backport
  • Backport of: JDK-6881317
  • Component: tools
  • Sub-Component: javac
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • Submitted: 2011-05-23
  • Updated: 2011-06-08
  • Resolved: 2011-06-08
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
6u27 b03Fixed 7Fixed
When running bigApp application, the following Exception was thrown:

java.io.IOException: cannot close class loader
        at com.sun.tools.javac.util.CloseableURLClassLoader.close(CloseableURLClassLoader.java:60)
        at com.sun.tools.javac.processing.JavacProcessingEnvironment.close(JavacProcessingEnvironment.java:916)
        at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:738)
        at com.sun.tools.javac.main.Main.compile(Main.java:353)
        at com.sun.tools.javac.main.Main.compile(Main.java:279)
        at com.sun.tools.javac.main.Main.compile(Main.java:270)
        at com.sun.tools.javac.Main.compile(Main.java:69)
        at com.sun.tools.javac.Main.main(Main.java:54)
Caused by: java.lang.NullPointerException
        at com.sun.tools.javac.util.CloseableURLClassLoader.close(CloseableURLClassLoader.java:56)
        ... 7 more
Approximately 1500 Libraries tests fails due to this bug.

EVALUATION Caused by the fix for 6558476 com/sun/tools/javac/Main.compile don't release file handles on return

SUGGESTED FIX Fix is same as it was for JDK 7 - add a null test.

EVALUATION null check is missing in CloseableURLClassLoader.close(): public void close() throws IOException { try { for (Object l: getLoaders()) { if (l.getClass().getName().equals("sun.misc.URLClassPath$JarLoader")) { Field jarField = l.getClass().getDeclaredField("jar"); JarFile jar = (JarFile) getField(l, jarField); //System.err.println("CloseableURLClassLoader: closing " + jar); jar.close(); //jar can be null here!!! } } } catch (Throwable t) { IOException e = new IOException("cannot close class loader"); e.initCause(t); throw e; } }