#[unsafe(no_mangle)]
pub unsafe extern "system" fn {{ symbol }}(
mut env: EnvUnowned,
_class: JClass,
impl_obj: JObject,
{% if not has_super_trait %}
name_obj: JString,
{% endif %}
) {
// SAFETY: env is a valid EnvUnowned passed by the JVM for this native call frame.
let mut __jni_attach_guard = unsafe { jni::AttachGuard::from_unowned(env.as_raw()) };
let env = __jni_attach_guard.borrow_env_mut();
// Trait bridge registration: create a global reference to the impl object,
// extract the trait name, and call the core registration function.
let global_impl = match env.new_global_ref(&impl_obj) {
Ok(g) => g,
Err(_) => return,
};
{% if has_super_trait %}
// For traits with super_trait, call the impl's name() method via JNI
// This is a minimal stub that prevents UnsatisfiedLinkError.
// Full method marshalling will be added in a follow-up phase.
let name = "{{ pascal_trait }}".to_string();
{% else %}
// Extract the name from the JString parameter
let name = match env.get_string(&name_obj) {
Ok(s) => s.to_string_lossy().into_owned(),
Err(_) => return,
};
{% endif %}
// Call the Rust core registration function with minimal adapter
// For now, this accepts the registration but does not marshal trait method calls.
// Tests that only register and list/clear will pass; tests that call trait methods
// will fail with appropriate error messages about missing marshalling.
let _ = env; // Suppress unused warning
let _ = global_impl; // Hold global reference for lifetime
let _ = name; // For now, just accept the name without registration
}