JDK-6259897 : No output from JavacTool when trying to compile a file without '.java' extension
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 6
  • Priority: P3
  • Status: Closed
  • Resolution: Not an Issue
  • OS: generic
  • CPU: generic
  • Submitted: 2005-04-22
  • Updated: 2010-08-18
  • Resolved: 2005-04-22
Related Reports
Relates :  
Description
No output from JavacTool when trying to compile a file without .java extension

Please see the following test case:
<code>
import java.io.*;
import javax.tools.*;

public class Test7 {
    public static void test(String... args) {
        JavacTool javac = com.sun.tools.javac.Tool.create();
        DiagnosticListener dl =  new DiagnosticListener() {
                public void problemFound(DiagnosticMessage message) {
                    System.out.println(new File(message.getSourceName().toString()).getName()+":"+
                            message.getStartPosition()+":"+message.getStartPosition()
                            +":"+message.getPosition());
                    System.out.println(message.toString());
                    System.out.format("Found problem: %s%n", message.getKey());
                    System.out.flush();
                }
        };
        PrintWriter writer = new PrintWriter(new OutputStream(){
                public void write(int b) {}
        });
        javac.run((InputLocator)null, null, dl, writer, args);
    }
    public static void main(String... arg){
        Test3 test = new Test3();
        test.test("/home/sa151881/javatrails/SWarnings/unchecked/noExtFile");
        test.test("/home/sa151881/javatrails/SWarnings/unchecked/test.html");
    }
}
</code>
Output of the code:

<output>
bash-2.05b$ $b/java Test7
bash-2.05b$
</output>


###@###.### 2005-04-22 05:43:36 GMT

Comments
EVALUATION The output is passed to the writer object which ignores it. ###@###.### 2005-04-22 18:37:13 GMT
22-04-2005