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.
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.