xtclang / xvm

Ecstasy and XVM
Other
195 stars 15 forks source link

Exception in thread "main" java.lang.NullPointerException: Cannot read the array length because "<local4>" is null #198

Closed dimitrirakitine closed 3 months ago

dimitrirakitine commented 3 months ago

Compiler fails when xec file is already there

to reproduce - vi Test.x

module Test { @Inject Console console;

void run() {
    console.print("Hello, world\n");
}

}

compile 1st time -

dima@macbook /tmp % vi Test.x dima@macbook /tmp % ./xcc Test.x

without changing anything compile 2nd time -

dima@macbook /tmp % ./xcc Test.x Exception in thread "main" java.lang.NullPointerException: Cannot read the array length because "" is null at org.xvm.tool.ResourceDir.calcTimestamp(ResourceDir.java:304) at org.xvm.tool.ResourceDir.calcTimestamp(ResourceDir.java:306) at org.xvm.tool.ResourceDir.getTimestamp(ResourceDir.java:294) at org.xvm.tool.ModuleInfo.getResourceTimestamp(ModuleInfo.java:600) at org.xvm.tool.ModuleInfo.isUpToDate(ModuleInfo.java:432) at org.xvm.tool.Compiler.process(Compiler.java:257) at org.xvm.tool.Launcher.run(Launcher.java:147) at org.xvm.tool.Compiler.launch(Compiler.java:121) at org.xvm.tool.Compiler.main(Compiler.java:112) at org.xvm.tool.Launcher.main(Launcher.java:95)

ggleyzer commented 3 months ago

I could not reproduce it, but since there is a path in which File.listFiles() returns null, it makes perfect sense to protect against it regardless.

Fixed by https://github.com/xtclang/xvm/commit/240f6313f71204f0eb75e5defbcc50667d722623