kud1ing / rucaja

Calling the JVM from Rust via JNI
https://docs.rs/rucaja
Apache License 2.0
31 stars 7 forks source link

How to build a Java array of strings #13

Closed fpoli closed 7 years ago

fpoli commented 7 years ago

Is it possible to build a Java array from rucaja?

I would like to call a Java method that takes an array of strings (eg. void main(String[] args)), but I can't find how to build the `jvalue' of the array.

...

let java_string: JvmString = jvm.new_jvm_string("Hello").unwrap();

let args: Vec<jvalue> = vec![
    // ?
];

// Call the main
jvm.call_static_object_method(
    &main_class,
    &main_method,
    args.as_ptr()
);
kud1ing commented 7 years ago

No sorry. Such a function does not exist (yet).

You'd need to create a String array using the [type array specifier https://docs.oracle.com/javase/1.5.0/docs/guide/jni/spec/types.html Then Java strings would have to be created and set using the Java array method.

I don't have much time for this but i would be happy to merge such a function if provided.

There is also https://github.com/rawrasaur/rust-jvm

fpoli commented 7 years ago

Thanks