eclipsesource / eclipsesource/J2V8
[Question] How i can register java static methods in V8 runtime
- Dominant language
- Java
- Stars
- 2.6k
- Forks
- 387
- PR merge metrics
- No merged PRs in 30d
Description
Hi! this is only a question, i'm writing a tool to run JS Code from a JS File, but i can't see a way to make an java static method accessible via JavaScript, i saw the V8Object source code and i don't see anything about, and i tried using Class.getMethod, but this 3 lines blocked me:
`J2V8/src/main/java/com/eclipsesource/v8/V8Obiect.java at line 633`
```java
Method method = object.getClass().getMethod(methodName, parameterTypes);
method.setAccessible(true);
v8.registerCallback(object, method, getHandle(), jsFunctionName, includeReceiver);
```
At that moment, the variable `object` is an `Class` object, and the methodName is obtained by `class.getDeclaredMethods() -> .getName()` inside a for loop, the problem is: Because of the variable `object` is a `Class`, when the code call `.getClass()`, the code will access `Class` and will give an NoSuchMethodException because the method name that i give doesn't exists on the `Class` class.
Is there a way to register java static methods with J2V8?
Contributor guide
Assessment
This issue has not been assessed yet.