Info
This post is auto-generated from RSS feed The Rust Programming Language Forum - Latest topics. Source: How to create an ArrayList and add element with Rust JNI?
Hello,
Is it possible to create an collection ArrayList and append object?
I tried to do smth like a:
let cls_array_list = jenv.find_class("java/util/ArrayList").unwrap();
let items_list = jenv.new_object(cls_array_list, "()V", &[]).unwrap();
then add item
let cls_item = jenv.find_class("Item").unwrap();
let obj_item = jenv.new_object(cls_item, "()V", &[]).unwrap();
jenv.call_method(
&items_list,
"add",
"(Ljava/lang/Object;)V",
&[JValue::Object(&item1)],
)
.unwrap();
But got exception:
Exception in thread "Thread-0" java.lang.NoSuchMethodError: Ljava/util/ArrayList;.add(Ljava/lang/Object;)V
Any ideas how can I create collection of Items?
Thanks!
5 posts - 2 participants
🏷️ rust_feed