Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6258271

DiagnosticMessage exposes internal name __input

XMLWordPrintable

    • b47
    • generic
    • generic
    • Verified

      JavacTool will fail to work when trying to the compile the file which is not there.

      Please see the following code:
      <code>
      import java.io.*;
      import javax.tools.*;
      public class Test2 {
          public static void test(String... args) {
              try{
                  JavacTool javac = com.sun.tools.javac.Tool.create();
                  DiagnosticListener dl = new DiagnosticListener() {
                      public void problemFound(DiagnosticMessage message) {
                          System.out.println("Source Name :" + new File(message.getSourceName().toString()));
                          System.out.println("Start position :" + message.getStartPosition());
                          System.out.println("Position :" + message.getStartPosition());
                          System.out.println("End position :" + message.getEndPosition());
                          System.out.flush();
                      }
                  };
                  PrintWriter writer = null;
                  javac.run((InputLocator)null, null, dl, writer, args);
              }catch(Exception ex){
                  ex.printStackTrace();
              }
          }
          public static void main(String... arg){
              try{
                  Test1 test = new Test1();
                  test.test("nofile.java");
              }catch(Exception ex){
                  ex.printStackTrace();
              }
          }
      }
      <\code>

      Ouput of the code :

      <output>
      bash-2.05b$ $b/java Test2
      __input:-1:-1:-1
      error: cannot read: nofile.java
      <\output>


      ###@###.### 2005-04-20 09:32:42 GMT

            jjg Jonathan Gibbons
            savadhansunw Seetharama Avadhanam (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: