lime
lime copied to clipboard
Is there a way to call constructor from java class via jni
i was making a lib that have some of java android classes ported to haxe via jni, but i need to call constructor, could it be called via jni?
It seems there is, though it isn't documented and the code is somewhat confusing. Short version is try this:
var processConstructor = JNI.createStaticMethod("android/os/Process", "<init>", "()V");
var process = processConstructor();
Where I got this information:
- From Oracle's documentation, you must use
<init>
as the function name andV
as the return type. - From Lime's source code, you must treat it as a static function, but internally it treats it as an instance function. (Thus
createMemberMethod()
won't throw an error, but the function it returns will fail.)