Open AsyncProxy opened 3 days ago
Please follow the doc strictly and try again. The JS code should look like the following.
{
add: (a, b) => a + b,
}
请严格按照文档进行操作,然后重试。JS 代码应如下所示。
{ add: (a, b) => a + b, }
Please ask me what I did wrong, give a reasonable explanation, I have done it strictly according to the example of the document.
请严格按照文档进行操作,然后重试。JS 代码应如下所示。
{ add: (a, b) => a + b, }
I tried java.io.File at the beginning, he reported an error with multiple constructors, which was thrown by ByteBuddy internally, and I later opened the DynamicObjectAutoCloseableInvocationHandler class from your source code to try to generate bytecode, but it didn't work, the same error was thrown, Android architecture.
It only works for classes with default constructor. New features are not planned.
它仅适用于具有 default 构造函数的类。新功能未计划。
But I wrote TestJava according to your example, which is the same as your example, why is it also wrong, if it says java.io.File, then it is very reasonable, but TestJava I came according to your documentation, what is going on?
它仅适用于具有 default 构造函数的类。新功能未计划。
It's the same as the default constructor class, but it doesn't work, and I see from your anonymous implementation, it seems that you need to pass a class object instead of V8Object, when I pass a specified class object in the test function, he doesn't report an error, but the function is completely inconsistent.
@AsyncProxy net.bytebuddy.ByteBuddy please check this! Maybe it cannot fit Android!
Well, it seems JavetBuddy needs to adapt to Android in the future.
好吧,看来 JavetBuddy 将来需要适应 Android。
I've also used ByteBuddy before, it seems to be stuck in the getLoaded place, when I tried to generate class before, it can only work on generating empty shell classes, r8 compiles to dex loading, so I think ByteBuddy may not be compatible with android, but I don't know if there is any other way to quickly generate bytecode.
1.Follow your example and write an anonymous class.
public class TestJava {
}
javetProxyConverter.getConfig().setReflectionObjectFactory(JavetReflectionObjectFactory.getInstance()); IJavetAnonymous anonymous = new IJavetAnonymous() { @V8Function public void JavaAptder(TestJava testJava) throws Exception { testJava.add(); } };
JS: Java.JavaAptder({
})
3.Error: failed with error message Attempt to invoke virtual method 'int com.editor.async.script.TestJava.add()' on a null object reference.