1 #![cfg(feature = "invocation")]
2 
3 use std::thread::spawn;
4 
5 mod util;
6 use util::{attach_current_thread_permanently, call_java_abs, jvm};
7 
8 #[test]
thread_detaches_when_finished()9 fn thread_detaches_when_finished() {
10     let thread = spawn(|| {
11         let mut env = attach_current_thread_permanently();
12         let val = call_java_abs(&mut env, -2);
13         assert_eq!(val, 2);
14         assert_eq!(jvm().threads_attached(), 1);
15     });
16 
17     thread.join().unwrap();
18     assert_eq!(jvm().threads_attached(), 0);
19 }
20