Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] How i can register java static methods in V8 runtime #582

Open
ghost opened this issue May 8, 2022 · 0 comments
Open

[Question] How i can register java static methods in V8 runtime #582

ghost opened this issue May 8, 2022 · 0 comments

Comments

@ghost
Copy link

ghost commented May 8, 2022

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

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<Class> and will give an NoSuchMethodException because the method name that i give doesn't exists on the Class<Class> class.

Is there a way to register java static methods with J2V8?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants