JDK-6415780 : JSR 199: javax.tools.JavaFileManager.getClassLoader always fails
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 6
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2006-04-20
  • Updated: 2011-01-19
  • Resolved: 2006-05-13
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.
JDK 6
6 b85Fixed
Related Reports
Duplicate :  
Relates :  
Description
javax.tools.JavaFileManager.getClassLoader always fails

test:
------------------------------
import javax.tools.*;
import java.io.File;
import java.util.Collections;

public class test3 {

    static public void main(String[] args){
        File dir = new File( new File(".").toURI() );

        StandardJavaFileManager sfm = 
            ToolProvider.getSystemJavaCompilerTool().
                getStandardFileManager( new DiagnosticCollector<JavaFileObject>() );

        JavaFileManager.Location location = StandardJavaFileManager.StandardLocation.SOURCE_PATH;
        sfm.setLocation( location, Collections.singleton(dir) );

        try {
            sfm.getClassLoader(location);
            System.out.println("OK");
        } catch( Exception x ){
            x.printStackTrace( System.out );
        }
    }
}
------------------------------
result:
------------------------------
java.lang.UnsupportedOperationException
    at com.sun.tools.javac.util.ListBuffer.add(ListBuffer.java:205)
    at com.sun.tools.javac.util.DefaultFileManager.getClassLoader(DefaultFileManager.java:664)
    at test3.main(test3.java:18)
tests failed
> api/javax_tools/FileManager/index.html#All[getClassLoader0001]
> api/javax_tools/FileManager/index.html#All[getClassLoader0002]
> api/javax_tools/FileManager/index.html#All[getClassLoader0003]
> api/javax_tools/FileManager/index.html#All[getClassLoader0004]
> api/javax_tools/FileManager/index.html#All[getClassLoader0005]

Comments
EVALUATION A silly bug: we should use append, not add.
21-04-2006