Simon Baars
Simon Baars

Reputation: 2289

Rascal outputs "Got NPE for node ..." to console when calling "createAstsFromDirectory"

I have the following code snippet:

println("bll1");
createAstsFromDirectory(location, false);
println("bll2");

When I run this for any valid location that denotes a Java project, I get the following output (varying per project):

bll1
Got NPE for node String[] args
Got NPE for node String[] args
Got NPE for node blah=6
Got NPE for node String[] args
Got NPE for node String[] args
bll2

This is an issue, as I'm using an external program to read the shell output. Also, for big projects this spams the console a lot (the above output is for a project with two small (<30sloc) classes). Smallsql yields at least 1000 of these Got NPE for node ... lines.

Furthermore:

Upvotes: 0

Views: 135

Answers (1)

Jurgen Vinju
Jurgen Vinju

Reputation: 6696

The cause of the problem is that types can not be resolved properly on your commandline by the Eclipse Java compiler. This triggers an internal bug which triggers a null pointer exception which should actually never happen. The ASTs produced are still valid, but the resolved types are going to be missing completely.

In this case the type resolver already fails on java.lang.String[], so the java run-time library is not even on the compiler's classpath.

This should fix it: include the JRE jar into the classPath keyword parameter:

createAstFromFile(..., classPath=[|file:///path/to/your/rt.jar|, ...possibly some other jars...])

Upvotes: 1

Related Questions