在我的代码我打开我的file.java和解析他JavaParser类.
FileInputStream in = new FileInputStream(".../file.java");
CompilationUnit cu;
try {
// parse the file
cu = JavaParser.parse(in);
} finally {
in.close();
}
........
Run Code Online (Sandbox Code Playgroud)
file.java:
public class File{
public void ownMethod(){...}
public static void main(String[] args){
ownMethod(5); //Note the extra parameter
}
}
Run Code Online (Sandbox Code Playgroud)
在file.java中有一个错误:该main方法ownMethod使用一个参数调用该方法,但ownMethod需要0个参数.JavaParser未检测到此错误,并使用此错误解析file.java.我怎么知道(在我的代码中)file.java是否没有错误?没有使用java编译器它是否可行?