You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
private val constructor = JavaCallback { receiver, parameters ->
val name = parameters.getString(0)
val shadow = MyJavaClass(name)
//=========================================
//TODO:attach the shadow java object to receiver
}
private val test= JavaVoidCallback { receiver, _ ->
//=========================================
//TODO::get java object back from receiver
shadow.doSomething()
}
val c = V8Function(v8, constructor)
val cp = c.getObject("prototype")
cp.registerJavaMethod(test, "__test__")
cp.release()
v8.add("MyJavaClass", c)
v8.executeVoideScript("new MyJavaClass().__test__()")
I can not find a way to make a shadow java object to the js object, including let Java GC not release my shadow when js object lives.
any suggestion how to attach NON-STATIC java method to js object?
The text was updated successfully, but these errors were encountered:
PR #201 most likely addresses the problem you are trying to solve. I am in the process of making it into a stand-alone GitHub project so that users can use it on top of J2V8 without having to incorporate it into the main J2V8 repository; let me know if you have any questions about how it works!
Just let any looking solution know, I currently use this code and works if you use them carefully
//static MyJavaClass curInstance=null;
receiver.registerVCB("__java_back__"){_,_->
curInstance=shadow
}
//whenever you need java instance
receiver.executeVoidFunction("__java_back__")
//and now the receiver's java shadow object in curInstance
I have a js class implement in j2v8(kotlin).
I can not find a way to make a shadow java object to the js object, including let Java GC not release my shadow when js object lives.
any suggestion how to attach NON-STATIC java method to js object?
The text was updated successfully, but these errors were encountered: