开发者

How can I instantiate a Java generic with JNI?

If I want to instantiate a D开发者_StackOverflow中文版ate, I can use:

jclass cls = (*env)->FindClass(env, "java/util/Date");
jmethodID ctr = (*env)->GetMethodID(env, cls, "<init>", "()V");
jobject obj = (*env)->NewObject(env, cls, ctr);

But how do I instantiate an ArrayList<String>?


In the same way. On VM level, there are no generics.


@noise is correct. Generics are used simply to ensure type safety. When compiled, the compiler does "type erasure". Check out this more detailed explanation of type erasure: Type Erasure

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜