blob: d43f807e157eea594ccf2fdc776a23ef6502048a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
#![cfg(feature = "invocation")]
mod util;
use util::{attach_current_thread, call_java_abs, jvm};
#[test]
fn thread_attach_guard_detaches_on_drop() {
assert_eq!(jvm().threads_attached(), 0);
{
let guard = attach_current_thread();
assert_eq!(jvm().threads_attached(), 1);
let val = call_java_abs(&guard, -1);
assert_eq!(val, 1);
}
assert_eq!(jvm().threads_attached(), 0);
// Verify that this thread is really detached.
assert!(jvm().get_env().is_err());
}
|