JDK-6358955 : javax.tools.JavaCompilerTool.getStandardFileManager().getFileForInput(directory) should throw IAE
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 6
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2005-12-05
  • Updated: 2010-04-03
  • Resolved: 2006-03-04
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 b75Fixed
Related Reports
Relates :  
Relates :  
Description
JavaFileObject of directory should throw IllegalArgumentException , If JavaFileObject is created on directory like   javax.tools.JavaCompilerTool.getStandardFileManager().getFileForInput(directory). The DiagnosticMessage is also too much confusing. 

<testcase>
import java.io.File;
import java.io.PrintWriter;
import javax.tools.*;
import static javax.tools.JavaFileObject.Kind.*;


class Foo {
    public static void main(String[] args) throws Exception {
        File dir = new File("temp" + args.hashCode());
	if (!dir.exists())
	    dir.mkdir();
	if (!dir.isDirectory())
	    throw new AssertionError("Not a directory " + dir);

	try {
	    JavaCompilerTool compiler = ToolProvider.defaultJavaCompiler();
	    JavaFileManager jfm = compiler.getStandardFileManager();
            JavaFileObject jfo = jfm.getFileForInput(dir.getName());
            for(DiagnosticMessage dm : 
                    compiler.run((PrintWriter)null, jfo).getDiagnostics())
                        System.out.println(dm);
        } catch(Exception ex) {
            ex.printStackTrace();
	} finally {
	    dir.delete(); // cleanup
	}        
    }
}
</testcase>

<java-version>
bash-3.00$ java -version
java version "1.6.0-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.6.0-beta-b59b)
Java HotSpot(TM) Client VM (build 1.6.0-beta-b59b, mixed mode)
</java-version>

Comments
EVALUATION Rather than producing a diagnostic message, the file manager should throw an illegal argument exception if the argument represents a directory.
14-02-2006

EVALUATION Please explain what is confusing about the error message, so that we can look at addressing your concern.
14-02-2006

EVALUATION Should be addressed in Mustang.
06-12-2005