英文:
Android JNI DefineClass Equivelent (Loading Classes)
问题
I am in JNI code, and I have a .class
file, which I want to dynamically load and use as a jclass
. This is normally done by calling env->DefineClass(...)
, but that appears to be removed in the Android JNI, as it prompts me with:
JNI DefineClass is not supported
Which makes sense based on the implementation: https://android.googlesource.com/platform/art/+/master/runtime/jni/jni_internal.cc#665
I don't see anything online discussing how to actually get this functionality from the JNI, though. What mechanism can I use to dynamically load Java classes from the JNI?
英文:
I am in JNI code, and I have a .class
file, which I want to dynamically load and use as a jclass
. This is normally done by calling env->DefineClass(...)
but that appears to be removed in the Android JNI, as it prompts me with:
JNI DefineClass is not supported
Which makes sense based on the implementation: https://android.googlesource.com/platform/art/+/master/runtime/jni/jni_internal.cc#665
I don't see anything online discussing how to actually get this functionality from the JNI, though. What mechanism can I use to dynamically load Java classes from the JNI?
答案1
得分: 1
这是根本不可能的。
Android应用程序的编译过程将Java .class文件转换为一种称为“DEX”的格式,该格式嵌入到APK中。
没有用于加载额外DEX文件的运行时功能。
英文:
This is fundamentally impossible.
The compilation process for Android applications turns Java .class files into a format called "DEX", which is baked into the APK.
There is no runtime functionality for loading additional DEX files.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论