United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-2210060 regression: NPE in CloseableURLClassLoader
JDK-2210060 : regression: NPE in CloseableURLClassLoader

Details
Type:
Backport
Submit Date:
2011-05-23
Status:
Closed
Updated Date:
2011-06-08
Project Name:
JDK
Resolved Date:
2011-06-08
Component:
tools
OS:
Sub-Component:
javac
CPU:
Priority:
P2
Resolution:
Fixed
Affected Versions:
Fixed Versions:
6u27 (b03)

Related Reports
Backport:
Relates:

Sub Tasks

Description
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.

                                    

Comments
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;
        }
    }
                                     
2011-05-23
SUGGESTED FIX

Fix is same as it was for JDK 7 - add a null test.
                                     
2011-05-23
EVALUATION

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



Hardware and Software, Engineered to Work Together