Graal: InvalidPathException on Windows when trying to eval js

Created on 13 Jun 2018  路  3Comments  路  Source: oracle/graal

Despite Windows support not being fully available yet, I was told on gitter that Graal in its interpreted mode should already work on Windows on a stock JDK8 as long as the following .jars are on the classpath:

  • graal-sdk-jar
  • truffle-api.jar
  • tregex.jar
  • graaljs.jar
  • graaljs-scriptengine.jar

However there seems to be a bug causing an InvalidPathException when the context is being created so I was asked to report here as a bug. Here's the code:

import javax.script.ScriptException;
import org.graalvm.polyglot.Context;

public class NewMain {

    public static void main(String[] args) throws ScriptException {
        org.graalvm.polyglot.Context context = Context.create(); //error here
        context.eval("js", "console.log('hello');");
    }

}

Stacktrace:

Exception in thread "main" java.nio.file.InvalidPathException: Illegal char <:> at index 2: /C:/libs/graaljs.jar
    at sun.nio.fs.WindowsPathParser.normalize(WindowsPathParser.java:182)
    at sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:153)
    at sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:77)
    at sun.nio.fs.WindowsPath.parse(WindowsPath.java:94)
    at sun.nio.fs.WindowsFileSystem.getPath(WindowsFileSystem.java:255)
    at java.nio.file.Paths.get(Paths.java:84)
    at com.oracle.truffle.api.vm.LanguageCache.collectLanguages(LanguageCache.java:199)
    at com.oracle.truffle.api.vm.LanguageCache.createLanguages(LanguageCache.java:145)
    at com.oracle.truffle.api.vm.LanguageCache.languages(LanguageCache.java:135)
    at com.oracle.truffle.api.vm.PolyglotEngineImpl.initializeLanguages(PolyglotEngineImpl.java:403)
    at com.oracle.truffle.api.vm.PolyglotEngineImpl.<init>(PolyglotEngineImpl.java:153)
    at com.oracle.truffle.api.vm.PolyglotEngineImpl.<init>(PolyglotEngineImpl.java:135)
    at com.oracle.truffle.api.vm.PolyglotImpl.buildEngine(PolyglotImpl.java:177)
    at org.graalvm.polyglot.Engine$Builder.build(Engine.java:366)
    at org.graalvm.polyglot.Context$Builder.build(Context.java:976)
    at org.graalvm.polyglot.Context.create(Context.java:640)
    at NewMain.main(NewMain.java:9)

I'm on Windows 10 Pro Version 1803, running JDK1.8.0_111

bug javascript truffle

Most helpful comment

And the same error occurs for tregex.jar:
Exception in thread "main" java.nio.file.InvalidPathException: Illegal char <:> at index 2: /C:/dev/temp/graal/tregex.jar

Current code doesn't like the semicolon in a windows path..
Workaround is to set systemprops:

  static {
    // 2 temporary workarounds for running truffle on windows - unsupported yet
    System.getProperties().put("js.home", "x");
    System.getProperties().put("regex.home", "x");
  }

or pass in
-Djs.home=x -Dregex.home=x

All 3 comments

And the same error occurs for tregex.jar:
Exception in thread "main" java.nio.file.InvalidPathException: Illegal char <:> at index 2: /C:/dev/temp/graal/tregex.jar

Current code doesn't like the semicolon in a windows path..
Workaround is to set systemprops:

  static {
    // 2 temporary workarounds for running truffle on windows - unsupported yet
    System.getProperties().put("js.home", "x");
    System.getProperties().put("regex.home", "x");
  }

or pass in
-Djs.home=x -Dregex.home=x

This is a major bug for Windows.

Half of the test suite fails on this, so we don't need any additional tests.

Still can't gate it on Windows because of multiple other bugs, but it breaks nothing on Mac. And it allows Windows people to do at least something on an application level, without checking out Truffle sources.

Fixed by https://github.com/oracle/graal/pull/567

Was this page helpful?
0 / 5 - 0 ratings