In Java, a package-private method (no private, protected or public keyword) can only be called from code in the same package. I assume your JNI code is not somehow in the same package -- I haven't used JNI but I assume this is not possible.
Nevermind. I see now that the method signature is from the javadoc, and the method is therefore public. I don't know why you can't call it.
I believe the Ljava/util/HashMap; parameter in your method signature needs to be Ljava/util/Map; to match the erased type of the actual static method parameter. For a simpler reproduction:
use jni::objects::{JObject, JValue};
use jni::{InitArgsBuilder, JNIVersion, JavaVM};
fn main() -> jni::errors::Result<()> {
let jvm_args = InitArgsBuilder::new()
.version(JNIVersion::V8)
.option("-Xcheck:jni")
.build()
.unwrap();
let jvm = JavaVM::new(jvm_args).unwrap();
let mut env = jvm.attach_current_thread()?;
let cls = env.find_class("java/util/Map")?;
env.call_static_method(
cls,
"copyOf",
"(Ljava/util/HashMap;)Ljava/util/Map;",
&[JValue::Object(&JObject::null())],
)?;
Ok(())
}
fails with a NoSuchMethodError, but with Ljava/util/Map; it fails with the expected NullPointerException instead.