How to inject the File class?
Closed this issue · 2 comments
newk5 commented
Hello, is it possible to inject the File class using the V8JavaAdapter?
I've tried the following:
public static void main(String[] args) {
V8 v8 = V8.createV8Runtime();
V8JavaAdapter.injectClass(File.class, v8);
v8.executeVoidScript("var f = new File( \"test.txt\" );");
}
This results in:
Exception in thread "main" undefined:1: Constructor received invalid arguments!
this.File = function() {v8ConstructJavaClassjava_io_File.apply(this, arguments);
^
com.eclipsesource.v8.V8ScriptExecutionException
at com.eclipsesource.v8.V8._executeVoidScript(Native Method)
at com.eclipsesource.v8.V8.executeVoidScript(V8.java:944)
at com.eclipsesource.v8.V8.executeVoidScript(V8.java:652)
at com.eclipsesource.v8.V8.executeVoidScript(V8.java:638)
at vcmp.NewMain1.main(NewMain1.java:22)
Caused by: java.lang.IllegalArgumentException: Constructor received invalid arguments!
at io.alicorn.v8.V8JavaClassProxy.invoke(V8JavaClassProxy.java:455)
at com.eclipsesource.v8.V8.callObjectJavaMethod(V8.java:739)
... 5 more
caer commented
newk5 commented
Wow that was fast! Thank you, I cloned the branch, built it and ran the test, all working now 😃