Closed xiaoye-2018 closed 2 months ago
And I found that another project j2v8 has a higher execution speed than your project. Why is this? Is it because too many things are introduced in the design?
And I found that another project j2v8 has a higher execution speed than your project. Why is this? Is it because too many things are introduced in the design?
What is "User"? From your code
IV8Executor executor = v8Runtime.getExecutor("user;");
end with ";", output "null" is right!!
J2V8 hasnot been maintained for years!
Please go over the tutorials. There are a couple of things you've missed.
Please go over the tutorials. There are a couple of things you've missed.
Although I solved my problem using JavetProxyConverter, I think the official documentation examples are not clear and not practical. Only part of the content can be seen in the source code
Why does the following code prompt that the object is not recycled?
try (V8Runtime v8Runtime = V8Host.getV8Instance().createV8Runtime()) {
// JavetBridgeConverter javetBridgeConverter = new JavetBridgeConverter();
JavetProxyConverter converter = new JavetProxyConverter();
v8Runtime.setConverter(converter);
V8Locker v8Locker = v8Runtime.getV8Locker();
V8ValueGlobalObject globalObject = v8Runtime.getGlobalObject();
User user = new User(1, "user", 22);
HashMap<String, Object> map = new HashMap<>();
map.put("p1", user);
// map.put("p2", "p2");
// globalObject.setProperty("user2", user);
globalObject.set("map", map);
String s = v8Runtime.getExecutor("map.p1;").executeString();
System.out.println(s);
v8Locker.close();
globalObject.close();
} catch (JavetException e) {
throw new RuntimeException(e);
}
Obviously, you haven't fully understood the tutorial. Run the code in the tutorial and find out why it doesn't have any leaks.
I just performed a small case, which is a bit difficult for novices
beacuase my project use large js config, and alway use JDK Noshorn engine, recently I found this project, its use v8 as js engine, its significant improvement in performance。but I found some problem, please help.
eg: I want to inject a java pojo to javascript ,but it not work. But able to work in noshorn code:
output: user // noshorn null // v8
Is it possible to provide similar support? I also want to know how V8Locker in this project improves performance. I looked through the code but didn't find any results.