@@ -71,13 +71,11 @@ fn connect(config: Config) -> Result<Client, ConnectionError> {
71
71
72
72
generates a matching expanded function invoking it:
73
73
74
- <details ><summary >Show macro expansion</summary >
75
-
76
74
``` rust
77
- #[doc = " Connect using the given credentials to the default server, and return a [Client] to interact with it." ]
78
75
fn connect (config : Config ) -> Result <Client , ConnectionError > {
79
76
super :: tokio (). block_on (Client :: connect (config ))
80
77
}
78
+
81
79
#[no_mangle]
82
80
#[allow(unused_unit)]
83
81
pub extern " system" fn Java_mp_code_Client_connect <'local >(
@@ -89,13 +87,7 @@ pub extern "system" fn Java_mp_code_Client_connect<'local>(
89
87
let config_new = match jni_toolbox :: from_java_static :: <Config >(& mut env , config ) {
90
88
Ok (x ) => x ,
91
89
Err (e ) => {
92
- let _ = env . throw_new (
93
- " java/lang/RuntimeException" ,
94
- $ crate :: __export :: must_use ({
95
- let res = $ crate :: fmt :: format ($ crate :: __export :: format_args! (" {e:?}" ));
96
- res
97
- }),
98
- );
90
+ let _ = env . throw_new (" java/lang/RuntimeException" , format! (" {e:?}" ));
99
91
return std :: ptr :: null_mut ();
100
92
}
101
93
};
@@ -104,36 +96,13 @@ pub extern "system" fn Java_mp_code_Client_connect<'local>(
104
96
let ret = match result {
105
97
Ok (x ) => x ,
106
98
Err (e ) => match env_copy . find_class (e . jclass ()) {
107
- Err (e ) => {
108
- $ crate :: panicking :: panic_fmt ($ crate :: const_format_args! (
109
- " error throwing Java exception -- failed resolving error class: {e}"
110
- ));
111
- }
112
- Ok (class ) => match env_copy . new_string ($ crate :: __export :: must_use ({
113
- let res = $ crate :: fmt :: format ($ crate :: __export :: format_args! (" {e:?}" ));
114
- res
115
- })) {
116
- Err (e ) => {
117
- $ crate :: panicking :: panic_fmt ($ crate :: const_format_args! (
118
- " error throwing Java exception -- failed creating error string: {e}"
119
- ));
120
- }
121
- Ok (msg ) => match env_copy . new_object (
122
- class ,
123
- " (Ljava/lang/String;)V" ,
124
- & [jni :: objects :: JValueGen :: Object (& msg )],
125
- ) {
126
- Err (e ) => {
127
- $ crate :: panicking :: panic_fmt ($ crate :: const_format_args! (
128
- " error throwing Java exception -- failed creating object: {e}"
129
- ));
130
- }
99
+ Err (e ) => panic! (" error throwing Java exception -- failed resolving error class: {e}" ),
100
+ Ok (class ) => match env_copy . new_string (format! (" {e:?}" )) {
101
+ Err (e ) => panic! (" error throwing Java exception -- failed creating error string: {e}" ),
102
+ Ok (msg ) => match env_copy . new_object (class , " (Ljava/lang/String;)V" , & [jni :: objects :: JValueGen :: Object (& msg )]) {
103
+ Err (e ) => panic! (" error throwing Java exception -- failed creating object: {e}" ));
131
104
Ok (obj ) => match env_copy . throw (jni :: objects :: JThrowable :: from (obj )) {
132
- Err (e ) => {
133
- $ crate :: panicking :: panic_fmt ($ crate :: const_format_args! (
134
- " error throwing Java exception -- failed throwing: {e}"
135
- ));
136
- }
105
+ Err (e ) => panic! (" error throwing Java exception -- failed throwing: {e}" ),
137
106
Ok (_ ) => return std :: ptr :: null_mut (),
138
107
},
139
108
},
@@ -143,20 +112,12 @@ pub extern "system" fn Java_mp_code_Client_connect<'local>(
143
112
match ret . into_java (& mut env_copy ) {
144
113
Ok (fin ) => fin ,
145
114
Err (e ) => {
146
- let _ = env_copy . throw_new (
147
- " java/lang/RuntimeException" ,
148
- $ crate :: __export :: must_use ({
149
- let res = $ crate :: fmt :: format ($ crate :: __export :: format_args! (" {e:?}" ));
150
- res
151
- }),
152
- );
115
+ let _ = env_copy . throw_new (" java/lang/RuntimeException" , format! (" {e:?}" ));
153
116
std :: ptr :: null_mut ()
154
117
}
155
118
}
156
119
}
157
120
```
158
- </details >
159
-
160
121
161
122
## Status
162
123
This crate is early and intended mostly to maintain [ ` codemp ` ] ( https://github.com/hexedtech/codemp ) 's Java bindings, so things not used
0 commit comments