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

javap, method com.sun.tools.javap.Main.run returns 0 even in case of class not found error

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P4
    • 8
    • 8
    • tools
    • None
    • b96
    • Verified

    Description

      Having the following java class:

      import java.io.File;
      import java.io.PrintWriter;
      import java.io.StringWriter;
      import com.sun.tools.javap.Main;

      public class TestJavap {

          public static void main(String args[])
                  throws Exception {
              String[] params = new String[]{"-v", "eeTestJavap.class"};
              StringWriter sw = null;
              int result = 0;
              try (PrintWriter pw = new PrintWriter(sw = new StringWriter())) {
                  result = Main.run(params, pw);
              }
              System.out.println("result " + result);
              System.out.println(sw.toString());
          }

      }

      and compiling and executing it with the following commands:

      javac -classpath /path/to/jdk1.8.0/lib/tools.jar:. TestJavap.java
      java -classpath /path/to/jdk1.8.0/lib/tools.jar:. TestJavap

      The output is:

      result 0
      Error: class not found: eeTestJavap.class

      Not sure if this is the intended behavior but it could be expected that in the case of a class not found or similar errors, the method should return an exit code different from 0.

      Attachments

        Activity

          People

            vromero Vicente Arturo Romero Zaldivar
            vromero Vicente Arturo Romero Zaldivar
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: