jni-simple 0.1.0

Simple Rust wrapper around the JNI (Java Native Interface) API.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
//! # jni-simple
//! This crate contains a simple dumb handwritten rust wrapper around the JNI (Java Native Interface) API.
//! It does absolutely no magic around the JNI Calls and lets you just use it as you would in C.
//!
//! If you are looking to start a jvm from rust then the entrypoints in this create are
//! init_dynamic_link, load_jvm_from_library, JNI_CreateJavaVM and JNI_GetCreatedJavaVMs.
//!
//! If you are looking to write a jni library in rust then the types JNIEnv and jclass, etc.
//! should be sufficient.
//!
#![allow(non_snake_case)]
#![allow(non_camel_case_types)]
#![allow(dead_code)]

use std::ffi::{c_char, c_void, CStr, CString};
use std::mem;
use std::ptr::{null_mut};
#[cfg(feature = "asserts")]
use std::ptr::null;

use once_cell::sync::OnceCell;

pub const JNI_OK: jint = 0;

pub const JNI_COMMIT: jint = 1;

pub const JNI_ABORT: jint = 2;
pub const JNI_ERR: jint = -1;
pub const JNI_EDETACHED: jint = -2;
pub const JNI_EVERSION: jint = -3;
pub const JNI_ENOMEM: jint = -4;
pub const JNI_EEXIST: jint = -5;
pub const JNI_EINVAL: jint = -6;

pub const JNI_VERSION_1_1: jint = 0x00010001;
pub const JNI_VERSION_1_2: jint = 0x00010002;
pub const JNI_VERSION_1_4: jint = 0x00010004;
pub const JNI_VERSION_1_6: jint = 0x00010006;
pub const JNI_VERSION_1_8: jint = 0x00010008;
pub const JNI_VERSION_9: jint =   0x00090000;
pub const JNI_VERSION_10: jint =  0x000a0000;
pub const JNI_VERSION_19: jint =  0x00130000;
pub const JNI_VERSION_20: jint =  0x00140000;
pub const JNI_VERSION_21: jint = 0x00150000;

pub type jlong = i64;
pub type jint = i32;
pub type jsize = jint;
pub type jshort = i16;
pub type jchar = u16;
pub type jbyte = i8;
pub type jboolean = bool;

pub type jfloat = f32;

pub type jdouble = f64;

pub type jclass = *mut c_void;

pub type jobject = *mut c_void;

pub type jstring = jobject;

pub type jarray = jobject;

pub type jobjectArray = jarray;

pub type jbooleanArray = jarray;

pub type jbyteArray = jarray;

pub type jcharArray = jarray;

pub type jshortArray = jarray;

pub type jintArray = jarray;

pub type jlongArray = jarray;

pub type jfloatArray = jarray;

pub type jdoubleArray = jarray;

#[repr(C)]
pub enum jobjectRefType {
    JNIInvalidRefType = 0,
    JNILocalRefType = 1,
    JNIGlobalRefType = 2,
    JNIWeakGlobalRefType = 3
}

pub type jweak = jobject;

pub type jthrowable = jobject;

pub type jmethodID = jobject;
pub type jfieldID = jobject;

#[repr(C)]
pub union jtype {
    pub long: jlong,
    pub int: jint,
    pub short: jshort,
    pub char: jchar,
    pub byte: jbyte,
    pub boolean: jboolean,
    pub float: jfloat,
    pub double: jdouble,
    pub object: jobject,
    pub class: jclass,
    pub throwable: jthrowable
}

#[repr(C)]
#[derive(Debug)]
pub struct JNINativeMethod {
    name: *const c_char,
    signature: *const c_char,
    fnPtr: *const c_void
}

type JNIInvPtr = *mut *mut [*mut c_void; 10];

#[repr(C)]
#[derive(Debug, Clone, Copy)]
pub struct JavaVM {
    functions: JNIInvPtr
}

unsafe impl Send for JavaVM {}
unsafe impl Sync for JavaVM {}

#[repr(C)]
#[derive(Debug)]
pub struct JavaVMAttachArgs {
    version: jint,
    name: *const c_char,
    group: jobject
}

#[repr(C)]
#[derive(Debug, Clone)]
pub struct JavaVMOption {
    optionString: *mut c_char,
    extraInfo: *mut c_void,
}

impl JavaVMOption {
    pub fn new(option_string: *mut c_char, extra_info: *mut c_void) -> JavaVMOption {
        JavaVMOption {
            optionString: option_string,
            extraInfo: extra_info,
        }
    }

    pub fn optionString(&self) -> *mut c_char {
        self.optionString
    }

    pub fn extraInfo(&self) -> *mut c_void {
        self.extraInfo
    }
}


#[repr(C)]
#[derive(Debug, Clone)]
pub struct JavaVMInitArgs {
    version: i32,
    nOptions: i32,
    options: *mut JavaVMOption,
    ignoreUnrecognized: u8,
}

impl JavaVMInitArgs {
    pub fn new(version: i32, n_options: i32, options: *mut JavaVMOption, ignore_unrecognized: u8) -> JavaVMInitArgs {
        JavaVMInitArgs {
            version,
            nOptions: n_options,
            options,
            ignoreUnrecognized: ignore_unrecognized,
        }
    }

    pub fn version(&self) -> i32 {
        self.version
    }

    pub fn nOptions(&self) -> i32 {
        self.nOptions
    }

    pub fn options(&self) -> *mut JavaVMOption {
        self.options
    }

    pub fn ignoreUnrecognized(&self) -> u8 {
        self.ignoreUnrecognized
    }
}

#[repr(C)]
pub struct JNInvokerInternal {
    functions: [*mut c_void; 10],
}

type JNIEnvPtr = *mut *mut [*mut c_void; 235];

#[derive(Debug, Clone, Copy)]
#[repr(C)]
pub struct JNIEnv {
    functions: JNIEnvPtr,
}

impl JNINativeMethod {
    fn new(name: *const c_char, signature: *const c_char, function_pointer: *const c_void) -> JNINativeMethod {
        return JNINativeMethod {
            name,
            signature,
            fnPtr: function_pointer,
        };
    }

    fn name(&self) -> *const c_char {
        self.name
    }


    fn signature(&self) -> *const c_char {
        self.signature
    }


    fn fnPtr(&self) -> *const c_void {
        self.fnPtr
    }
}


impl JavaVMAttachArgs {
    pub fn new(version: jint, name: *const c_char, group: jobject) -> Self {
        Self { version, name, group }
    }


    pub fn version(&self) -> jint {
        self.version
    }
    pub fn name(&self) -> *const c_char {
        self.name
    }
    pub fn group(&self) -> jobject {
        self.group
    }
}


impl JNIEnv {

    #[inline(always)]
    unsafe fn jni<X>(&self, index: usize) -> X {
        return unsafe {mem::transmute_copy(&(**self.functions)[index])};
    }

    pub unsafe fn GetVersion(&self) -> jint {
        return self.jni::<fn(JNIEnvPtr) -> jint>(4)(self.functions);
    }

    pub unsafe fn DefineClass(&self, name: *const c_char, classloader: jobject, data: &[u8]) -> jclass {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("DefineClass");
            assert!(!name.is_null(), "DefineClass name is null");
        }
        return self.jni::<fn(JNIEnvPtr, *const c_char, jobject, *const u8, i32) -> jclass>(5)
            (self.functions, name, classloader, data.as_ptr(), data.len() as i32);
    }

    pub unsafe fn FindClass(&self, name: *const c_char) -> jclass {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("FindClass");
            assert!(!name.is_null(), "FindClass name is null");
        }
        return self.jni::<fn(JNIEnvPtr, *const c_char) -> jclass>(6)(self.functions, name);
    }

    pub unsafe fn FindClass_str(&self, name: &str) -> jclass {
        let str = CString::new(name).unwrap();
        let res = self.FindClass(str.as_ptr());
        return res;
    }

    pub unsafe fn GetSuperclass(&self, clazz: jclass) -> jclass {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("GetSuperclass");
            self.check_is_class("GetSuperclass", clazz);
        }
        return self.jni::<fn(JNIEnvPtr, jclass) -> jclass>(10)(self.functions, clazz);
    }

    pub unsafe fn IsAssignableFrom(&self, clazz1: jclass, clazz2: jclass) -> jboolean {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("IsAssignableFrom");
            self.check_is_class("IsAssignableFrom", clazz1);
            self.check_is_class("IsAssignableFrom", clazz2);
        }
        return self.jni::<fn(JNIEnvPtr, jclass, jclass) -> jboolean>(11)(self.functions, clazz1, clazz2);
    }

    pub unsafe fn Throw(&self, obj: jthrowable) -> jint {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("Throw");
            assert!(!obj.is_null(), "Throw throwable is null");
        }
        return self.jni::<fn(JNIEnvPtr, jthrowable) -> jint>(13)(self.functions, obj);
    }

    pub unsafe fn ThrowNew(&self, clazz: jclass, message: *const c_char) -> jint {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("ThrowNew");
            self.check_is_class("ThrowNew", clazz);
        }
        return self.jni::<fn(JNIEnvPtr, jclass, *const c_char) -> jint>(14)(self.functions, clazz, message);
    }

    pub unsafe fn ThrowNew_str(&self, clazz: jclass, message: &str) -> jint {
        let str = CString::new(message).unwrap();
        return self.ThrowNew(clazz, str.as_ptr());
    }

    pub unsafe fn ExceptionOccurred(&self) -> jthrowable {
        return self.jni::<fn(JNIEnvPtr) -> jthrowable>(15)(self.functions);
    }

    pub unsafe fn ExceptionDescribe(&self) {
        self.jni::<fn(JNIEnvPtr)>(16)(self.functions);
    }

    pub unsafe fn ExceptionClear(&self) {
        self.jni::<fn(JNIEnvPtr)>(17)(self.functions);
    }

    pub unsafe fn FatalError(&self, msg: *const c_char) {
        #[cfg(feature = "asserts")]
        {
            assert!(!msg.is_null(), "FatalError msg is null");
        }
        self.jni::<fn(JNIEnvPtr, *const c_char)>(18)(self.functions, msg);
    }

    pub unsafe fn FatalError_str(&self, message: &str) {
        let str = CString::new(message).unwrap().into_raw();
        self.FatalError(str);
        unreachable!("FatalError")
    }


    pub unsafe fn ExceptionCheck(&self) -> jboolean {
        return self.jni::<fn(JNIEnvPtr) -> jboolean>(228)(self.functions);
    }

    pub unsafe fn NewGlobalRef(&self, obj: jobject) -> jobject {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("NewGlobalRef");
            assert!(!obj.is_null(), "NewGlobalRef obj is null");
        }
        return self.jni::<fn(JNIEnvPtr, jobject) -> jobject>(21)(self.functions, obj);
    }

    pub unsafe fn DeleteGlobalRef(&self, obj: jobject) {
        #[cfg(feature = "asserts")]
        {
            assert!(!obj.is_null(), "DeleteGlobalRef obj is null");
        }
        return self.jni::<fn(JNIEnvPtr, jobject)>(22)(self.functions, obj);
    }

    pub unsafe fn DeleteLocalRef(&self, obj: jobject) {
        #[cfg(feature = "asserts")]
        {
            assert!(!obj.is_null(), "DeleteLocalRef obj is null");
        }
        return self.jni::<fn(JNIEnvPtr, jobject)>(23)(self.functions, obj);
    }

    pub unsafe fn EnsureLocalCapacity(&self, capacity: jint) -> jint {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("EnsureLocalCapacity");
            assert!(capacity >= 0, "EnsureLocalCapacity capacity is negative");
        }
        return self.jni::<fn(JNIEnvPtr, jint) -> jint>(26)(self.functions, capacity);
    }

    pub unsafe fn PushLocalFrame(&self, capacity: jint) -> jint {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("PushLocalFrame");
        }
        return self.jni::<fn(JNIEnvPtr, jint) -> jint>(19)(self.functions, capacity);
    }

    pub unsafe fn PopLocalFrame(&self, result: jobject) -> jobject {
        return self.jni::<fn(JNIEnvPtr, jobject) -> jobject>(20)(self.functions, result);
    }

    pub unsafe fn NewLocalRef(&self, obj: jobject) -> jobject {
        #[cfg(feature = "asserts")]
        {
            assert!(!obj.is_null(), "NewLocalRef obj is null");
        }
        return self.jni::<fn(JNIEnvPtr, jobject) -> jobject>(25)(self.functions, obj);
    }

    pub unsafe fn NewWeakGlobalRef(&self, obj: jobject) -> jweak {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("NewWeakGlobalRef");
            assert!(!obj.is_null(), "NewWeakGlobalRef obj is null");
        }
        return self.jni::<fn(JNIEnvPtr, jobject) -> jweak>(226)(self.functions, obj);
    }

    pub unsafe fn DeleteWeakGlobalRef(&self, obj: jweak) {
        #[cfg(feature = "asserts")]
        {
            assert!(!obj.is_null(), "DeleteWeakGlobalRef obj is null");
        }

        self.jni::<fn(JNIEnvPtr, jobject)>(227)(self.functions, obj);
    }

    pub unsafe fn AllocObject(&self, clazz: jclass) -> jobject {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("AllocObject");
            self.check_is_class("AllocObject", clazz);
        }
        return self.jni::<fn(JNIEnvPtr, jclass) -> jobject>(27)(self.functions, clazz);
    }

    pub unsafe fn NewObjectA(&self, clazz: jclass, constructor: jmethodID, args: *const jtype) -> jobject {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("NewObjectA");
            assert!(!constructor.is_null(), "NewObjectA constructor is null");
            self.check_is_class("NewObjectA", clazz);
        }
        return self.jni::<fn(JNIEnvPtr, jclass, jmethodID, *const jtype) -> jobject>(30)(self.functions, clazz, constructor, args);
    }

    pub unsafe fn GetObjectClass(&self, obj: jobject) -> jclass {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("GetObjectClass");
        }
        return self.jni::<fn(JNIEnvPtr, jobject) -> jobject>(31)(self.functions, obj);
    }

    pub unsafe fn GetObjectRefType(&self, obj: jobject) -> jobjectRefType {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("GetObjectRefType");
        }
        return self.jni::<fn(JNIEnvPtr, jobject) -> jobjectRefType>(232)(self.functions, obj);
    }

    pub unsafe fn IsInstanceOf(&self, obj: jobject, clazz: jclass) -> jboolean {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("IsInstanceOf");
            self.check_is_class("IsInstanceOf", clazz);
        }
        return self.jni::<fn(JNIEnvPtr, jobject, jclass) -> jboolean>(32)(self.functions, obj, clazz);
    }

    pub unsafe fn IsSameObject(&self, obj1: jobject, obj2: jobject) -> jboolean {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("IsSameObject");
        }
        return self.jni::<fn(JNIEnvPtr, jobject, jobject) -> jboolean>(24)(self.functions, obj1, obj2);
    }

    pub unsafe fn GetFieldID(&self, clazz: jclass, name: *const c_char, sig: *const c_char) -> jfieldID {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("GetFieldID");
            assert!(!name.is_null(), "GetFieldID name is null");
            assert!(!sig.is_null(), "GetFieldID sig is null");
            self.check_is_class("GetFieldID", clazz);
        }
        return self.jni::<fn(JNIEnvPtr, jclass, *const c_char, *const c_char) -> jfieldID>(94)(self.functions, clazz, name, sig);
    }

    pub unsafe fn GetFieldID_str(&self, class: jclass, name: &str, sig: &str) -> jfieldID {
        let nstr = CString::new(name).unwrap();
        let nsig = CString::new(sig).unwrap();
        return self.GetFieldID(class, nstr.as_ptr(), nsig.as_ptr());
    }

    pub unsafe fn GetObjectField(&self, obj: jobject, fieldID: jfieldID) -> jobject {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("GetObjectField");
            self.check_field_type_object("GetObjectField", obj, fieldID, "object");
        }
        return self.jni::<fn(JNIEnvPtr, jobject, jfieldID) -> jobject>(95)(self.functions, obj, fieldID);
    }

    pub unsafe fn GetBooleanField(&self, obj: jobject, fieldID: jfieldID) -> jboolean {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("GetBooleanField");
            self.check_field_type_object("GetBooleanField", obj, fieldID, "boolean");
        }
        return self.jni::<fn(JNIEnvPtr, jobject, jfieldID) -> jboolean>(96)(self.functions, obj, fieldID);
    }

    pub unsafe fn GetByteField(&self, obj: jobject, fieldID: jfieldID) -> jbyte {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("GetByteField");
            self.check_field_type_object("GetByteField", obj, fieldID, "byte");
        }
        return self.jni::<fn(JNIEnvPtr, jobject, jfieldID) -> jbyte>(97)(self.functions, obj, fieldID);
    }

    pub unsafe fn GetCharField(&self, obj: jobject, fieldID: jfieldID) -> jchar {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("GetCharField");
            self.check_field_type_object("GetCharField", obj, fieldID, "char");
        }
        return self.jni::<fn(JNIEnvPtr, jobject, jfieldID) -> jchar>(98)(self.functions, obj, fieldID);
    }

    pub unsafe fn GetShortField(&self, obj: jobject, fieldID: jfieldID) -> jshort {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("GetShortField");
            self.check_field_type_object("GetShortField", obj, fieldID, "short");
        }
        return self.jni::<fn(JNIEnvPtr, jobject, jfieldID) -> jshort>(99)(self.functions, obj, fieldID);
    }

    pub unsafe fn GetIntField(&self, obj: jobject, fieldID: jfieldID) -> jint {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("GetIntField");
            self.check_field_type_object("GetIntField", obj, fieldID, "int");
        }
        return self.jni::<fn(JNIEnvPtr, jobject, jfieldID) -> jint>(100)(self.functions, obj, fieldID);
    }

    pub unsafe fn GetLongField(&self, obj: jobject, fieldID: jfieldID) -> jlong {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("GetLongField");
            self.check_field_type_object("GetLongField", obj, fieldID, "long");
        }
        return self.jni::<fn(JNIEnvPtr, jobject, jfieldID) -> jlong>(101)(self.functions, obj, fieldID);
    }

    pub unsafe fn GetFloatField(&self, obj: jobject, fieldID: jfieldID) -> jfloat {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("GetFloatField");
            self.check_field_type_object("GetFloatField", obj, fieldID, "float");
        }
        return self.jni::<fn(JNIEnvPtr, jobject, jfieldID) -> jfloat>(102)(self.functions, obj, fieldID);
    }

    pub unsafe fn GetDoubleField(&self, obj: jobject, fieldID: jfieldID) -> jdouble {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("GetDoubleField");
            self.check_field_type_object("GetDoubleField", obj, fieldID, "double");
        }
        return self.jni::<fn(JNIEnvPtr, jobject, jfieldID) -> jdouble>(103)(self.functions, obj, fieldID);
    }

    pub unsafe fn SetObjectField(&self, obj: jobject, fieldID: jfieldID, value: jobject) {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("SetObjectField");
            self.check_field_type_object("SetObjectField", obj, fieldID, "object");
        }
        return self.jni::<fn(JNIEnvPtr, jobject, jfieldID, jobject)>(104)(self.functions, obj, fieldID, value);
    }

    pub unsafe fn SetBooleanField(&self, obj: jobject, fieldID: jfieldID, value: jboolean) {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("SetBooleanField");
            self.check_field_type_object("SetBooleanField", obj, fieldID, "boolean");
        }
        return self.jni::<fn(JNIEnvPtr, jobject, jfieldID, jboolean)>(105)(self.functions, obj, fieldID, value);
    }

    pub unsafe fn SetByteField(&self, obj: jobject, fieldID: jfieldID, value: jbyte) {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("SetByteField");
            self.check_field_type_object("SetByteField", obj, fieldID, "byte");
        }
        return self.jni::<fn(JNIEnvPtr, jobject, jfieldID, jbyte)>(106)(self.functions, obj, fieldID, value);
    }

    pub unsafe fn SetCharField(&self, obj: jobject, fieldID: jfieldID, value: jchar) {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("SetCharField");
            self.check_field_type_object("SetCharField", obj, fieldID, "char");
        }
        return self.jni::<fn(JNIEnvPtr, jobject, jfieldID, jchar)>(107)(self.functions, obj, fieldID, value);
    }

    pub unsafe fn SetShortField(&self, obj: jobject, fieldID: jfieldID, value: jshort) {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("SetShortField");
            self.check_field_type_object("SetShortField", obj, fieldID, "short");
        }
        return self.jni::<fn(JNIEnvPtr, jobject, jfieldID, jshort)>(108)(self.functions, obj, fieldID, value);
    }

    pub unsafe fn SetIntField(&self, obj: jobject, fieldID: jfieldID, value: jint) {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("SetIntField");
            self.check_field_type_object("SetIntField", obj, fieldID, "int");
        }
        return self.jni::<fn(JNIEnvPtr, jobject, jfieldID, jint)>(109)(self.functions, obj, fieldID, value);
    }

    pub unsafe fn SetLongField(&self, obj: jobject, fieldID: jfieldID, value: jlong) {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("SetLongField");
            self.check_field_type_object("SetLongField", obj, fieldID, "long");
        }
        return self.jni::<fn(JNIEnvPtr, jobject, jfieldID, jlong)>(110)(self.functions, obj, fieldID, value);
    }

    pub unsafe fn SetFloatField(&self, obj: jobject, fieldID: jfieldID, value: jfloat) {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("SetFloatField");
            self.check_field_type_object("SetFloatField", obj, fieldID, "float");
        }
        return self.jni::<fn(JNIEnvPtr, jobject, jfieldID, jfloat)>(111)(self.functions, obj, fieldID, value);
    }

    pub unsafe fn SetDoubleField(&self, obj: jobject, fieldID: jfieldID, value: jdouble) {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("SetDoubleField");
            self.check_field_type_object("SetDoubleField", obj, fieldID, "double");
        }
        return self.jni::<fn(JNIEnvPtr, jobject, jfieldID, jdouble)>(112)(self.functions, obj, fieldID, value);
    }



    pub unsafe fn GetMethodID(&self, class: jclass, name: *const c_char, sig: *const c_char) -> jmethodID {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("GetMethodID");
            assert!(!name.is_null(), "GetMethodID name is null");
            assert!(!sig.is_null(), "GetMethodID sig is null");
            self.check_is_class("GetMethodID", class);
        }
        return self.jni::<fn(JNIEnvPtr, jobject, *const c_char, *const c_char) -> jmethodID>(33)(self.functions, class, name, sig);
    }

    pub unsafe fn GetMethodID_str(&self, class: jclass, name: &str, sig: &str) -> jmethodID {
        let nstr = CString::new(name).unwrap();
        let nsig = CString::new(sig).unwrap();
        return self.GetMethodID(class, nstr.as_ptr(), nsig.as_ptr());
    }

    pub unsafe fn CallVoidMethodA(&self, obj: jobject, methodID: jmethodID, args: *const jtype) {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("CallVoidMethodA");
            self.check_return_type_object("CallVoidMethodA", obj, methodID, "void");
        }
        return self.jni::<fn(JNIEnvPtr, jobject, jmethodID, *const jtype)>(63)(self.functions, obj, methodID, args);
    }

    pub unsafe fn CallObjectMethodA(&self, obj: jobject, methodID: jmethodID, args: *const jtype) -> jobject {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("CallObjectMethodA");
            self.check_return_type_object("CallObjectMethodA", obj, methodID, "object");
        }
        return self.jni::<fn(JNIEnvPtr, jobject, jmethodID, *const jtype) -> jobject>(36)(self.functions, obj, methodID, args);
    }

    pub unsafe fn CallBooleanMethodA(&self, obj: jobject, methodID: jmethodID, args: *const jtype) -> jboolean {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("CallBooleanMethodA");
            self.check_return_type_object("CallBooleanMethodA", obj, methodID, "boolean");
        }
        return self.jni::<fn(JNIEnvPtr, jobject, jmethodID, *const jtype) -> jboolean>(39)(self.functions, obj, methodID, args);
    }

    pub unsafe fn CallByteMethodA(&self, obj: jobject, methodID: jmethodID, args: *const jtype) -> jbyte {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("CallByteMethodA");
            self.check_return_type_object("CallByteMethodA", obj, methodID, "byte");
        }
        return self.jni::<fn(JNIEnvPtr, jobject, jmethodID, *const jtype) -> jbyte>(42)(self.functions, obj, methodID, args);
    }

    pub unsafe fn CallCharMethodA(&self, obj: jobject, methodID: jmethodID, args: *const jtype) -> jchar {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("CallCharMethodA");
            self.check_return_type_object("CallCharMethodA", obj, methodID, "char");
        }
        return self.jni::<fn(JNIEnvPtr, jobject, jmethodID, *const jtype) -> jchar>(45)(self.functions, obj, methodID, args);
    }

    pub unsafe fn CallShortMethodA(&self, obj: jobject, methodID: jmethodID, args: *const jtype) -> jshort {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("CallShortMethodA");
            self.check_return_type_object("CallShortMethodA", obj, methodID, "short");
        }
        return self.jni::<fn(JNIEnvPtr, jobject, jmethodID, *const jtype) -> jshort>(48)(self.functions, obj, methodID, args);
    }

    pub unsafe fn CallIntMethodA(&self, obj: jobject, methodID: jmethodID, args: *const jtype) -> jint {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("CallIntMethodA");
            self.check_return_type_object("CallIntMethodA", obj, methodID, "int");
        }
        return self.jni::<fn(JNIEnvPtr, jobject, jmethodID, *const jtype) -> jint>(51)(self.functions, obj, methodID, args);
    }

    pub unsafe fn CallLongMethodA(&self, obj: jobject, methodID: jmethodID, args: *const jtype) -> jlong {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("CallLongMethodA");
            self.check_return_type_object("CallLongMethodA", obj, methodID, "long");
        }
        return self.jni::<fn(JNIEnvPtr, jobject, jmethodID, *const jtype) -> jlong>(54)(self.functions, obj, methodID, args);
    }

    pub unsafe fn CallFloatMethodA(&self, obj: jobject, methodID: jmethodID, args: *const jtype) -> jfloat {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("CallFloatMethodA");
            self.check_return_type_object("CallFloatMethodA", obj, methodID, "float");
        }
        return self.jni::<fn(JNIEnvPtr, jobject, jmethodID, *const jtype) -> jfloat>(57)(self.functions, obj, methodID, args);
    }

    pub unsafe fn CallDoubleMethodA(&self, obj: jobject, methodID: jmethodID, args: *const jtype) -> jdouble {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("CallDoubleMethodA");
            self.check_return_type_object("CallDoubleMethodA", obj, methodID, "double");
        }
        return self.jni::<fn(JNIEnvPtr, jobject, jmethodID, *const jtype) -> jdouble>(60)(self.functions, obj, methodID, args);
    }

    pub unsafe fn CallNonvirtualVoidMethodA(&self, obj: jobject, methodID: jmethodID, args: *const jtype) {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("CallNonvirtualVoidMethodA");
            self.check_return_type_object("CallNonvirtualVoidMethodA", obj, methodID, "void");
        }
        return self.jni::<fn(JNIEnvPtr, jobject, jmethodID, *const jtype)>(93)(self.functions, obj, methodID, args);
    }

    pub unsafe fn CallNonvirtualObjectMethodA(&self, obj: jobject, methodID: jmethodID, args: *const jtype) -> jobject {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("CallNonvirtualObjectMethodA");
            self.check_return_type_object("CallNonvirtualObjectMethodA", obj, methodID, "object");
        }
        return self.jni::<fn(JNIEnvPtr, jobject, jmethodID, *const jtype) -> jobject>(66)(self.functions, obj, methodID, args);
    }

    pub unsafe fn CallNonvirtualBooleanMethodA(&self, obj: jobject, methodID: jmethodID, args: *const jtype) -> jboolean {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("CallNonvirtualBooleanMethodA");
            self.check_return_type_object("CallNonvirtualBooleanMethodA", obj, methodID, "boolean");
        }
        return self.jni::<fn(JNIEnvPtr, jobject, jmethodID, *const jtype) -> jboolean>(69)(self.functions, obj, methodID, args);
    }

    pub unsafe fn CallNonvirtualByteMethodA(&self, obj: jobject, methodID: jmethodID, args: *const jtype) -> jbyte {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("CallNonvirtualByteMethodA");
            self.check_return_type_object("CallNonvirtualByteMethodA", obj, methodID, "byte");
        }
        return self.jni::<fn(JNIEnvPtr, jobject, jmethodID, *const jtype) -> jbyte>(72)(self.functions, obj, methodID, args);
    }

    pub unsafe fn CallNonvirtualCharMethodA(&self, obj: jobject, methodID: jmethodID, args: *const jtype) -> jchar {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("CallNonvirtualCharMethodA");
            self.check_return_type_object("CallNonvirtualCharMethodA", obj, methodID, "char");
        }
        return self.jni::<fn(JNIEnvPtr, jobject, jmethodID, *const jtype) -> jchar>(75)(self.functions, obj, methodID, args);
    }

    pub unsafe fn CallNonvirtualShortMethodA(&self, obj: jobject, methodID: jmethodID, args: *const jtype) -> jshort {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("CallNonvirtualShortMethodA");
            self.check_return_type_object("CallNonvirtualShortMethodA", obj, methodID, "short");
        }
        return self.jni::<fn(JNIEnvPtr, jobject, jmethodID, *const jtype) -> jshort>(78)(self.functions, obj, methodID, args);
    }

    pub unsafe fn CallNonvirtualIntMethodA(&self, obj: jobject, methodID: jmethodID, args: *const jtype) -> jint {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("CallNonvirtualIntMethodA");
            self.check_return_type_object("CallNonvirtualIntMethodA", obj, methodID, "int");
        }
        return self.jni::<fn(JNIEnvPtr, jobject, jmethodID, *const jtype) -> jint>(81)(self.functions, obj, methodID, args);
    }

    pub unsafe fn CallNonvirtualLongMethodA(&self, obj: jobject, methodID: jmethodID, args: *const jtype) -> jlong {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("CallNonvirtualLongMethodA");
            self.check_return_type_object("CallNonvirtualLongMethodA", obj, methodID, "long");
        }
        return self.jni::<fn(JNIEnvPtr, jobject, jmethodID, *const jtype) -> jlong>(84)(self.functions, obj, methodID, args);
    }

    pub unsafe fn CallNonvirtualFloatMethodA(&self, obj: jobject, methodID: jmethodID, args: *const jtype) -> jfloat {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("CallNonvirtualFloatMethodA");
            self.check_return_type_object("CallNonvirtualFloatMethodA", obj, methodID, "float");
        }
        return self.jni::<fn(JNIEnvPtr, jobject, jmethodID, *const jtype) -> jfloat>(87)(self.functions, obj, methodID, args);
    }

    pub unsafe fn CallNonvirtualDoubleMethodA(&self, obj: jobject, methodID: jmethodID, args: *const jtype) -> jdouble {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("CallNonvirtualDoubleMethodA");
            self.check_return_type_object("CallNonvirtualDoubleMethodA", obj, methodID, "double");
        }
        return self.jni::<fn(JNIEnvPtr, jobject, jmethodID, *const jtype) -> jdouble>(90)(self.functions, obj, methodID, args);
    }



    pub unsafe fn GetStaticFieldID(&self, clazz: jclass, name: *const c_char, sig: *const c_char) -> jfieldID {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("GetStaticFieldID");
            assert!(!name.is_null(), "GetStaticFieldID name is null");
            assert!(!sig.is_null(), "GetStaticFieldID sig is null");
            self.check_is_class("GetStaticFieldID", clazz);
        }
        return self.jni::<fn(JNIEnvPtr, jclass, *const c_char, *const c_char) -> jfieldID>(114)(self.functions, clazz, name, sig);
    }

    pub unsafe fn GetStaticFieldID_str(&self, class: jclass, name: &str, sig: &str) -> jfieldID {
        let nstr = CString::new(name).unwrap();
        let nsig = CString::new(sig).unwrap();
        return self.GetStaticFieldID(class, nstr.as_ptr(), nsig.as_ptr());

    }

    pub unsafe fn GetStaticObjectField(&self, obj: jclass, fieldID: jfieldID) -> jobject {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("GetStaticObjectField");
            self.check_field_type_static("GetStaticObjectField", obj, fieldID, "object");
        }
        return self.jni::<fn(JNIEnvPtr, jobject, jfieldID) -> jobject>(145)(self.functions, obj, fieldID);
    }

    pub unsafe fn GetStaticBooleanField(&self, obj: jclass, fieldID: jfieldID) -> jboolean {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("GetStaticBooleanField");
            self.check_field_type_static("GetStaticBooleanField", obj, fieldID, "boolean");
        }
        return self.jni::<fn(JNIEnvPtr, jobject, jfieldID) -> jboolean>(146)(self.functions, obj, fieldID);
    }

    pub unsafe fn GetStaticByteField(&self, obj: jclass, fieldID: jfieldID) -> jbyte {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("GetStaticByteField");
            self.check_field_type_static("GetStaticByteField", obj, fieldID, "byte");
        }
        return self.jni::<fn(JNIEnvPtr, jobject, jfieldID) -> jbyte>(147)(self.functions, obj, fieldID);
    }

    pub unsafe fn GetStaticCharField(&self, obj: jclass, fieldID: jfieldID) -> jchar {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("GetStaticCharField");
            self.check_field_type_static("GetStaticCharField", obj, fieldID, "char");
        }
        return self.jni::<fn(JNIEnvPtr, jobject, jfieldID) -> jchar>(148)(self.functions, obj, fieldID);
    }

    pub unsafe fn GetStaticShortField(&self, obj: jclass, fieldID: jfieldID) -> jshort {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("GetStaticShortField");
            self.check_field_type_static("GetStaticShortField", obj, fieldID, "short");
        }
        return self.jni::<fn(JNIEnvPtr, jobject, jfieldID) -> jshort>(149)(self.functions, obj, fieldID);
    }

    pub unsafe fn GetStaticIntField(&self, obj: jclass, fieldID: jfieldID) -> jint {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("GetStaticIntField");
            self.check_field_type_static("GetStaticIntField", obj, fieldID, "int");
        }
        return self.jni::<fn(JNIEnvPtr, jobject, jfieldID) -> jint>(150)(self.functions, obj, fieldID);
    }

    pub unsafe fn GetStaticLongField(&self, obj: jclass, fieldID: jfieldID) -> jlong {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("GetStaticLongField");
            self.check_field_type_static("GetStaticLongField", obj, fieldID, "long");
        }
        return self.jni::<fn(JNIEnvPtr, jobject, jfieldID) -> jlong>(151)(self.functions, obj, fieldID);
    }

    pub unsafe fn GetStaticFloatField(&self, obj: jclass, fieldID: jfieldID) -> jfloat {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("GetStaticFloatField");
            self.check_field_type_static("GetStaticFloatField", obj, fieldID, "float");
        }
        return self.jni::<fn(JNIEnvPtr, jobject, jfieldID) -> jfloat>(152)(self.functions, obj, fieldID);
    }

    pub unsafe fn GetStaticDoubleField(&self, obj: jclass, fieldID: jfieldID) -> jdouble {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("GetStaticDoubleField");
            self.check_field_type_static("GetStaticDoubleField", obj, fieldID, "double");
        }
        return self.jni::<fn(JNIEnvPtr, jobject, jfieldID) -> jdouble>(153)(self.functions, obj, fieldID);
    }

    pub unsafe fn SetStaticObjectField(&self, obj: jclass, fieldID: jfieldID, value: jobject) {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("SetStaticObjectField");
            self.check_field_type_static("SetStaticObjectField", obj, fieldID, "object");
        }
        return self.jni::<fn(JNIEnvPtr, jobject, jfieldID, jobject)>(154)(self.functions, obj, fieldID, value);
    }

    pub unsafe fn SetStaticBooleanField(&self, obj: jclass, fieldID: jfieldID, value: jboolean) {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("SetStaticBooleanField");
            self.check_field_type_static("SetStaticBooleanField", obj, fieldID, "boolean");
        }
        return self.jni::<fn(JNIEnvPtr, jobject, jfieldID, jboolean)>(155)(self.functions, obj, fieldID, value);
    }

    pub unsafe fn SetStaticByteField(&self, obj: jclass, fieldID: jfieldID, value: jbyte) {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("SetStaticByteField");
            self.check_field_type_static("SetStaticByteField", obj, fieldID, "byte");
        }
        return self.jni::<fn(JNIEnvPtr, jobject, jfieldID, jbyte)>(156)(self.functions, obj, fieldID, value);
    }

    pub unsafe fn SetStaticCharField(&self, obj: jclass, fieldID: jfieldID, value: jchar) {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("SetStaticCharField");
            self.check_field_type_static("SetStaticCharField", obj, fieldID, "char");
        }
        return self.jni::<fn(JNIEnvPtr, jobject, jfieldID, jchar)>(157)(self.functions, obj, fieldID, value);
    }

    pub unsafe fn SetStaticShortField(&self, obj: jclass, fieldID: jfieldID, value: jshort) {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("SetStaticShortField");
            self.check_field_type_static("SetStaticShortField", obj, fieldID, "short");
        }
        return self.jni::<fn(JNIEnvPtr, jobject, jfieldID, jshort)>(158)(self.functions, obj, fieldID, value);
    }

    pub unsafe fn SetStaticIntField(&self, obj: jclass, fieldID: jfieldID, value: jint) {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("SetStaticIntField");
            self.check_field_type_static("SetStaticIntField", obj, fieldID, "int");
        }
        return self.jni::<fn(JNIEnvPtr, jobject, jfieldID, jint)>(159)(self.functions, obj, fieldID, value);
    }

    pub unsafe fn SetStaticLongField(&self, obj: jclass, fieldID: jfieldID, value: jlong) {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("SetStaticLongField");
            self.check_field_type_static("SetStaticLongField", obj, fieldID, "long");
        }
        return self.jni::<fn(JNIEnvPtr, jobject, jfieldID, jlong)>(160)(self.functions, obj, fieldID, value);
    }

    pub unsafe fn SetStaticFloatField(&self, obj: jclass, fieldID: jfieldID, value: jfloat) {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("SetStaticFloatField");
            self.check_field_type_static("SetStaticFloatField", obj, fieldID, "float");
        }
        return self.jni::<fn(JNIEnvPtr, jobject, jfieldID, jfloat)>(161)(self.functions, obj, fieldID, value);
    }

    pub unsafe fn SetStaticDoubleField(&self, obj: jclass, fieldID: jfieldID, value: jdouble) {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("SetStaticDoubleField");
            self.check_field_type_static("SetStaticDoubleField", obj, fieldID, "double");
        }
        return self.jni::<fn(JNIEnvPtr, jobject, jfieldID, jdouble)>(162)(self.functions, obj, fieldID, value);
    }




    pub unsafe fn GetStaticMethodID(&self, class: jclass, name: *const c_char, sig: *const c_char) -> jmethodID {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("GetStaticMethodID");
            self.check_is_class("GetStaticMethodID", class);
            assert!(!name.is_null(), "GetStaticMethodID name is null");
            assert!(!sig.is_null(), "GetStaticMethodID sig is null");
        }


        return self.jni::<fn(JNIEnvPtr, jobject, *const c_char, *const c_char) -> jmethodID>(113)(self.functions, class, name, sig);
    }

    pub unsafe fn GetStaticMethodID_str(&self, class: jclass, name: &str, sig: &str) -> jmethodID {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("GetStaticMethodID_str");
            self.check_is_class("GetStaticMethodID_str", class);
        }
        let nstr = CString::new(name).unwrap();
        let nsig = CString::new(sig).unwrap();
        return self.GetStaticMethodID(class, nstr.as_ptr(), nsig.as_ptr());
    }


    pub unsafe fn CallStaticVoidMethodA(&self, obj: jclass, methodID: jmethodID, args: *const jtype) {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("CallStaticVoidMethodA");
            self.check_return_type_static("CallStaticVoidMethodA", obj, methodID, "void");
        }
        return self.jni::<fn(JNIEnvPtr, jobject, jmethodID, *const jtype)>(143)(self.functions, obj, methodID, args);
    }

    pub unsafe fn CallStaticObjectMethodA(&self, obj: jclass, methodID: jmethodID, args: *const jtype) -> jobject {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("CallStaticObjectMethodA");
            self.check_return_type_static("CallStaticBooleanMethodA", obj, methodID, "object");
        }
        return self.jni::<fn(JNIEnvPtr, jobject, jmethodID, *const jtype) -> jobject>(116)(self.functions, obj, methodID, args);
    }

    pub unsafe fn CallStaticBooleanMethodA(&self, obj: jclass, methodID: jmethodID, args: *const jtype) -> jboolean {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("CallStaticBooleanMethodA");
            self.check_return_type_static("CallStaticBooleanMethodA", obj, methodID, "boolean");
        }
        return self.jni::<fn(JNIEnvPtr, jobject, jmethodID, *const jtype) -> jboolean>(119)(self.functions, obj, methodID, args);
    }

    pub unsafe fn CallStaticByteMethodA(&self, obj: jclass, methodID: jmethodID, args: *const jtype) -> jbyte {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("CallStaticByteMethodA");
            self.check_return_type_static("CallStaticByteMethodA", obj, methodID, "byte");
        }
        return self.jni::<fn(JNIEnvPtr, jobject, jmethodID, *const jtype) -> jbyte>(122)(self.functions, obj, methodID, args);
    }

    pub unsafe fn CallStaticCharMethodA(&self, obj: jclass, methodID: jmethodID, args: *const jtype) -> jchar {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("CallStaticCharMethodA");
            self.check_return_type_static("CallStaticCharMethodA", obj, methodID, "char");
        }
        return self.jni::<fn(JNIEnvPtr, jobject, jmethodID, *const jtype) -> jchar>(125)(self.functions, obj, methodID, args);
    }

    pub unsafe fn CallStaticShortMethodA(&self, obj: jclass, methodID: jmethodID, args: *const jtype) -> jshort {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("CallStaticShortMethodA");
            self.check_return_type_static("CallStaticShortMethodA", obj, methodID, "short");
        }
        return self.jni::<fn(JNIEnvPtr, jobject, jmethodID, *const jtype) -> jshort>(128)(self.functions, obj, methodID, args);
    }

    pub unsafe fn CallStaticIntMethodA(&self, obj: jclass, methodID: jmethodID, args: *const jtype) -> jint {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("CallStaticIntMethodA");
            self.check_return_type_static("CallStaticIntMethodA", obj, methodID, "int");
        }
        return self.jni::<fn(JNIEnvPtr, jobject, jmethodID, *const jtype) -> jint>(131)(self.functions, obj, methodID, args);
    }

    pub unsafe fn CallStaticLongMethodA(&self, obj: jclass, methodID: jmethodID, args: *const jtype) -> jlong {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("CallStaticLongMethodA");
            self.check_return_type_static("CallStaticLongMethodA", obj, methodID, "long");
        }
        return self.jni::<fn(JNIEnvPtr, jobject, jmethodID, *const jtype) -> jlong>(134)(self.functions, obj, methodID, args);
    }

    pub unsafe fn CallStaticFloatMethodA(&self, obj: jclass, methodID: jmethodID, args: *const jtype) -> jfloat {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("CallStaticFloatMethodA");
            self.check_return_type_static("CallStaticFloatMethodA", obj, methodID, "float");
        }
        return self.jni::<fn(JNIEnvPtr, jobject, jmethodID, *const jtype) -> jfloat>(137)(self.functions, obj, methodID, args);
    }

    pub unsafe fn CallStaticDoubleMethodA(&self, obj: jclass, methodID: jmethodID, args: *const jtype) -> jdouble {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("CallStaticDoubleMethodA");
            self.check_return_type_static("CallStaticDoubleMethodA", obj, methodID, "double");
        }
        return self.jni::<fn(JNIEnvPtr, jobject, jmethodID, *const jtype) -> jdouble>(140)(self.functions, obj, methodID, args);
    }



    pub unsafe fn NewString(&self, unicodeChars: *const jchar, len: jsize) -> jstring {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("NewString");
            assert!(!unicodeChars.is_null(), "NewString string must not be null");
            assert!(len >= 0, "NewString len must not be negative");
        }
        return self.jni::<fn(JNIEnvPtr, *const jchar, jsize) -> jstring>(163)(self.functions, unicodeChars, len);
    }

    pub unsafe fn GetStringLength(&self, string: jstring) -> jsize {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("GetStringLength");
            assert!(!string.is_null(), "GetStringLength string must not be null");
            self.check_if_arg_is_string("GetStringLength", string);
        }
        return self.jni::<fn(JNIEnvPtr, jstring) -> jsize>(164)(self.functions, string);
    }

    pub unsafe fn GetStringChars(&self, string: jstring, isCopy: *mut jboolean) -> *const jchar {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("GetStringChars");
            assert!(!string.is_null(), "GetStringChars string must not be null");
            self.check_if_arg_is_string("GetStringChars", string);
        }
        return self.jni::<fn(JNIEnvPtr, jstring, *mut jboolean) -> *const jchar>(165)(self.functions, string, isCopy);
    }

    pub unsafe fn ReleaseStringChars(&self, string: jstring, chars: *const jchar) {
        #[cfg(feature = "asserts")]
        {
            assert!(!string.is_null(), "ReleaseStringChars string must not be null");
            assert!(!chars.is_null(), "ReleaseStringChars chars must not be null");
            self.check_if_arg_is_string("ReleaseStringChars", string);
        }
        return self.jni::<fn(JNIEnvPtr, jstring, *const jchar)>(166)(self.functions, string, chars);
    }

    pub unsafe fn NewStringUTF(&self, bytes: *const c_char) -> jstring {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("NewStringUTF");
            assert!(!bytes.is_null(), "NewStringUTF string must not be null");
        }
        return self.jni::<fn(JNIEnvPtr, *const c_char) -> jstring>(167)(self.functions, bytes);
    }

    pub unsafe fn NewStringUTF_str(&self, str: &str) -> jstring {
        let raw = CString::new(str).unwrap();
        let x =  self.NewStringUTF(raw.as_ptr());
        return x;
    }

    pub unsafe fn GetStringUTFLength(&self, string: jstring) -> jsize {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("GetStringUTFLength");
            assert!(!string.is_null(), "GetStringUTFLength string must not be null");
            self.check_if_arg_is_string("GetStringUTFLength", string);
        }

        return self.jni::<fn(JNIEnvPtr, jstring) -> jsize>(168)(self.functions, string);
    }

    pub unsafe fn GetStringUTFChars(&self, string: jstring, isCopy: *mut jboolean) -> *const c_char {
        #[cfg(feature = "asserts")]
        {
            assert!(!string.is_null(), "GetStringUTFChars string must not be null");
            self.check_if_arg_is_string("GetStringUTFChars", string);
        }

        return self.jni::<fn(JNIEnvPtr, jstring, *mut jboolean) -> *const c_char>(169)(self.functions, string, isCopy);
    }

    ///
    /// Convenience method that calls GetStringUTFChars, copies the result
    /// into a rust String and then calls ReleaseStringUTFChars.
    ///
    /// If GetStringUTFChars fails then None is returned and ExceptionCheck should be performed.
    /// If parsing the String as utf-8 fails (it shouldn't) then None is returned.
    ///
    pub unsafe fn GetStringUTFChars_as_string(&self, string: jstring) -> Option<String> {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("GetStringUTFChars_as_string");
            assert!(!string.is_null(), "GetStringUTFChars_as_string string must not be null");
            self.check_if_arg_is_string("GetStringUTFChars_as_string", string);
        }

        let str = self.GetStringUTFChars(string, null_mut());
        if str.is_null() {
            return None;
        }

        let parsed = CStr::from_ptr(str).to_str();
        if parsed.is_err() {
            self.ReleaseStringUTFChars(string, str);
            return None;
        }

        let copy = parsed.map_err(|_| {}).unwrap().to_string();
        self.ReleaseStringUTFChars(string, str);
        return Some(copy);
    }

    pub unsafe fn ReleaseStringUTFChars(&self, string: jstring, utf: *const c_char) {
        #[cfg(feature = "asserts")]
        {
            assert!(!string.is_null(), "ReleaseStringUTFChars string must not be null");
            assert!(!utf.is_null(), "ReleaseStringUTFChars utf must not be null");
            self.check_if_arg_is_string("ReleaseStringUTFChars", string);
        }

        return self.jni::<fn(JNIEnvPtr, jstring, *const c_char)>(170)(self.functions, string, utf);
    }

    pub unsafe fn GetStringRegion(&self, string: jstring, start: jsize, len: jsize, buffer: *mut jchar) {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("GetStringRegion");
            assert!(!string.is_null(), "GetStringRegion string must not be null");
            assert!(!buffer.is_null(), "GetStringRegion buffer must not be null");
            self.check_if_arg_is_string("GetStringRegion", string);
        }

        return self.jni::<fn(JNIEnvPtr, jstring, jsize, jsize, *mut jchar)>(220)(self.functions, string, start, len, buffer);
    }

    pub unsafe fn GetStringUTFRegion(&self, string: jstring, start: jsize, len: jsize, buffer: *mut c_char) {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("GetStringUTFRegion");
            assert!(!string.is_null(), "GetStringCritical string must not be null");
            self.check_if_arg_is_string("GetStringUTFRegion", string);
        }

        return self.jni::<fn(JNIEnvPtr, jstring, jsize, jsize, *mut c_char)>(221)(self.functions, string, start, len, buffer);
    }

    pub unsafe fn GetStringCritical(&self, string: jstring, isCopy: *mut jboolean) -> *const jchar {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("GetStringCritical");
            assert!(!string.is_null(), "GetStringCritical string must not be null");
            self.check_if_arg_is_string("GetStringCritical", string);
        }

        return self.jni::<fn(JNIEnvPtr, jstring, *mut jboolean) -> *const jchar>(224)(self.functions, string, isCopy);
    }



    pub unsafe fn ReleaseStringCritical(&self, string: jstring, cstring: *const jchar) {
        #[cfg(feature = "asserts")]
        {
            assert!(!string.is_null(), "ReleaseStringCritical string must not be null");
            assert!(!cstring.is_null(), "ReleaseStringCritical cstring must not be null");
            self.check_if_arg_is_string("GetStringCritical", string);
        }

        return self.jni::<fn(JNIEnvPtr, jstring, *const jchar)>(225)(self.functions, string, cstring);
    }


    pub unsafe fn GetArrayLength(&self, array: jarray) -> jsize {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("GetArrayLength");
            assert!(!array.is_null(), "GetArrayLength array must not be null");
        }

        return self.jni::<fn(JNIEnvPtr, jarray) -> jsize>(171)(self.functions, array);
    }

    pub unsafe fn NewObjectArray(&self, len: jsize, elementClass: jclass, initialElement: jobject) -> jobjectArray {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("NewObjectArray");
            assert!(!elementClass.is_null(), "NewObjectArray elementClass must not be null");
            assert!(len >= 0, "NewObjectArray len mot not be negative {}", len);
        }

        return self.jni::<fn(JNIEnvPtr, jsize, jclass, jobject) -> jobjectArray>(172)(self.functions, len, elementClass, initialElement);
    }

    pub unsafe fn GetObjectArrayElement(&self, array: jobjectArray, index: jsize) -> jobject {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("GetObjectArrayElement");
            assert!(!array.is_null(), "GetObjectArrayElement array must not be null");
        }

        return self.jni::<fn(JNIEnvPtr, jobjectArray, jsize) -> jobject>(173)(self.functions, array, index);
    }

    pub unsafe fn SetObjectArrayElement(&self, array: jobjectArray, index: jsize, value: jobject) {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("SetObjectArrayElement");
            assert!(!array.is_null(), "SetObjectArrayElement array must not be null");
        }

        self.jni::<fn(JNIEnvPtr, jobjectArray, jsize, jobject)>(174)(self.functions, array, index, value);
    }

    pub unsafe fn NewBooleanArray(&self, size: jsize) -> jbooleanArray {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("NewBooleanArray");
            assert!(size >= 0, "NewBooleanArray size must not be negative {}", size);
        }

        return self.jni::<fn(JNIEnvPtr, jsize) -> jobject>(175)(self.functions, size);
    }

    pub unsafe fn NewByteArray(&self, size: jsize) -> jbyteArray {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("NewByteArray");
            assert!(size >= 0, "NewByteArray size must not be negative {}", size);
        }

        return self.jni::<fn(JNIEnvPtr, jsize) -> jbyteArray>(176)(self.functions, size);
    }

    pub unsafe fn NewCharArray(&self, size: jsize) -> jcharArray {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("NewCharArray");
            assert!(size >= 0, "NewCharArray size must not be negative {}", size);
        }

        return self.jni::<fn(JNIEnvPtr, jsize) -> jcharArray>(177)(self.functions, size);
    }

    pub unsafe fn NewShortArray(&self, size: jsize) -> jshortArray {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("NewShortArray");
            assert!(size >= 0, "NewShortArray size must not be negative {}", size);
        }

        return self.jni::<fn(JNIEnvPtr, jsize) -> jshortArray>(178)(self.functions, size);
    }

    pub unsafe fn NewIntArray(&self, size: jsize) -> jintArray {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("NewIntArray");
            assert!(size >= 0, "NewIntArray size must not be negative {}", size);
        }

        return self.jni::<fn(JNIEnvPtr, jsize) -> jintArray>(179)(self.functions, size);
    }

    pub unsafe fn NewLongArray(&self, size: jsize) -> jlongArray {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("NewLongArray");
            assert!(size >= 0, "NewLongArray size must not be negative {}", size);
        }

        return self.jni::<fn(JNIEnvPtr, jsize) -> jlongArray>(180)(self.functions, size);
    }

    pub unsafe fn NewFloatArray(&self, size: jsize) -> jfloatArray {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("NewFloatArray");
            assert!(size >= 0, "NewFloatArray size must not be negative {}", size);
        }

        return self.jni::<fn(JNIEnvPtr, jsize) -> jfloatArray>(181)(self.functions, size);
    }

    pub unsafe fn NewDoubleArray(&self, size: jsize) -> jdoubleArray {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("NewDoubleArray");
            assert!(size >= 0, "NewDoubleArray size must not be negative {}", size);
        }

        return self.jni::<fn(JNIEnvPtr, jsize) -> jdoubleArray>(182)(self.functions, size);
    }

    pub unsafe fn GetBooleanArrayElements(&self, array: jbooleanArray) -> *mut jboolean {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("GetBooleanArrayElements");
            assert!(!array.is_null(), "GetBooleanArrayElements jarray must not be null");
        }

        return self.jni::<fn(JNIEnvPtr, jbooleanArray) -> *mut jboolean>(183)(self.functions, array);
    }

    pub unsafe fn GetByteArrayElements(&self, array: jbyteArray) -> *mut jbyte {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("GetByteArrayElements");
            assert!(!array.is_null(), "GetByteArrayElements jarray must not be null");
        }

        return self.jni::<fn(JNIEnvPtr, jbyteArray) -> *mut jbyte>(184)(self.functions, array);
    }

    pub unsafe fn GetCharArrayElements(&self, array: jcharArray) -> *mut jchar {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("GetCharArrayElements");
            assert!(!array.is_null(), "GetCharArrayElements jarray must not be null");
        }

        return self.jni::<fn(JNIEnvPtr, jcharArray) -> *mut jchar>(185)(self.functions, array);
    }

    pub unsafe fn GetShortArrayElements(&self, array: jshortArray) -> *mut jshort {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("GetShortArrayElements");
            assert!(!array.is_null(), "GetShortArrayElements jarray must not be null");
        }

        return self.jni::<fn(JNIEnvPtr, jshortArray) -> *mut jshort>(186)(self.functions, array);
    }

    pub unsafe fn GetIntArrayElements(&self, array: jintArray) -> *mut jint {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("GetIntArrayElements");
            assert!(!array.is_null(), "GetIntArrayElements jarray must not be null");
        }

        return self.jni::<fn(JNIEnvPtr, jintArray) -> *mut jint>(187)(self.functions, array);
    }

    pub unsafe fn GetLongArrayElements(&self, array: jlongArray) -> *mut jlong {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("GetLongArrayElements");
            assert!(!array.is_null(), "GetLongArrayElements jarray must not be null");
        }

        return self.jni::<fn(JNIEnvPtr, jlongArray) -> *mut jlong>(188)(self.functions, array);
    }

    pub unsafe fn GetFloatArrayElements(&self, array: jfloatArray) -> *mut jfloat {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("GetFloatArrayElements");
            assert!(!array.is_null(), "GetFloatArrayElements jarray must not be null");
        }

        return self.jni::<fn(JNIEnvPtr, jfloatArray) -> *mut jfloat>(189)(self.functions, array);
    }

    pub unsafe fn GetDoubleArrayElements(&self, array: jdoubleArray) -> *mut jdouble {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("GetDoubleArrayElements");
            assert!(!array.is_null(), "GetDoubleArrayElements jarray must not be null");
        }

        return self.jni::<fn(JNIEnvPtr, jdoubleArray) -> *mut jdouble>(190)(self.functions, array);
    }

    pub unsafe fn ReleaseBooleanArrayElements(&self, array: jbooleanArray, elems: *mut jboolean, mode: jint) {
        #[cfg(feature = "asserts")]
        {
            assert!(!array.is_null(), "ReleaseBooleanArrayElements jarray must not be null");
            assert!(!elems.is_null(), "ReleaseBooleanArrayElements elems must not be null");
            assert!(mode == JNI_OK || mode == JNI_COMMIT || mode == JNI_ABORT, "ReleaseBooleanArrayElements mode is invalid {}", mode);
        }

        self.jni::<fn(JNIEnvPtr, jbooleanArray, *mut jboolean, jint)>(191)(self.functions, array, elems, mode);
    }

    pub unsafe fn ReleaseByteArrayElements(&self, array: jbyteArray, elems: *mut jbyte, mode: jint) {
        #[cfg(feature = "asserts")]
        {
            assert!(!array.is_null(), "ReleaseByteArrayElements jarray must not be null");
            assert!(!elems.is_null(), "ReleaseByteArrayElements elems must not be null");
            assert!(mode == JNI_OK || mode == JNI_COMMIT || mode == JNI_ABORT, "ReleaseByteArrayElements mode is invalid {}", mode);
        }

        self.jni::<fn(JNIEnvPtr, jbyteArray, *mut jbyte, jint)>(192)(self.functions, array, elems, mode);
    }

    pub unsafe fn ReleaseCharArrayElements(&self, array: jcharArray, elems: *mut jchar, mode: jint) {
        #[cfg(feature = "asserts")]
        {
            assert!(!array.is_null(), "ReleaseCharArrayElements jarray must not be null");
            assert!(!elems.is_null(), "ReleaseCharArrayElements elems must not be null");
            assert!(mode == JNI_OK || mode == JNI_COMMIT || mode == JNI_ABORT, "ReleaseCharArrayElements mode is invalid {}", mode);
        }

        self.jni::<fn(JNIEnvPtr, jcharArray, *mut jchar, jint)>(193)(self.functions, array, elems, mode);
    }

    pub unsafe fn ReleaseShortArrayElements(&self, array: jshortArray, elems: *mut jshort, mode: jint) {
        #[cfg(feature = "asserts")]
        {
            assert!(!array.is_null(), "ReleaseShortArrayElements jarray must not be null");
            assert!(!elems.is_null(), "ReleaseShortArrayElements elems must not be null");
            assert!(mode == JNI_OK || mode == JNI_COMMIT || mode == JNI_ABORT, "ReleaseShortArrayElements mode is invalid {}", mode);
        }

        self.jni::<fn(JNIEnvPtr, jshortArray, *mut jshort, jint)>(194)(self.functions, array, elems, mode);
    }

    pub unsafe fn ReleaseIntArrayElements(&self, array: jintArray, elems: *mut jint, mode: jint) {
        #[cfg(feature = "asserts")]
        {
            assert!(!array.is_null(), "ReleaseIntArrayElements jarray must not be null");
            assert!(!elems.is_null(), "ReleaseIntArrayElements elems must not be null");
            assert!(mode == JNI_OK || mode == JNI_COMMIT || mode == JNI_ABORT, "ReleaseIntArrayElements mode is invalid {}", mode);
        }

        self.jni::<fn(JNIEnvPtr, jintArray, *mut jint, jint)>(195)(self.functions, array, elems, mode);
    }

    pub unsafe fn ReleaseLongArrayElements(&self, array: jlongArray, elems: *mut jlong, mode: jint) {
        #[cfg(feature = "asserts")]
        {
            assert!(!array.is_null(), "ReleaseLongArrayElements jarray must not be null");
            assert!(!elems.is_null(), "ReleaseLongArrayElements elems must not be null");
            assert!(mode == JNI_OK || mode == JNI_COMMIT || mode == JNI_ABORT, "ReleaseLongArrayElements mode is invalid {}", mode);
        }

        self.jni::<fn(JNIEnvPtr, jlongArray, *mut jlong, jint)>(196)(self.functions, array, elems, mode);
    }

    pub unsafe fn ReleaseFloatArrayElements(&self, array: jfloatArray, elems: *mut jfloat, mode: jint) {
        #[cfg(feature = "asserts")]
        {
            assert!(!array.is_null(), "ReleaseFloatArrayElements jarray must not be null");
            assert!(!elems.is_null(), "ReleaseFloatArrayElements elems must not be null");
            assert!(mode == JNI_OK || mode == JNI_COMMIT || mode == JNI_ABORT, "ReleaseFloatArrayElements mode is invalid {}", mode);
        }

        self.jni::<fn(JNIEnvPtr, jfloatArray, *mut jfloat, jint)>(197)(self.functions, array, elems, mode);
    }

    pub unsafe fn ReleaseDoubleArrayElements(&self, array: jdoubleArray, elems: *mut jdouble, mode: jint) {
        #[cfg(feature = "asserts")]
        {
            assert!(!array.is_null(), "ReleaseDoubleArrayElements jarray must not be null");
            assert!(!elems.is_null(), "ReleaseDoubleArrayElements elems must not be null");
            assert!(mode == JNI_OK || mode == JNI_COMMIT || mode == JNI_ABORT, "ReleaseDoubleArrayElements mode is invalid {}", mode);
        }

        self.jni::<fn(JNIEnvPtr, jdoubleArray, *mut jdouble, jint)>(198)(self.functions, array, elems, mode);
    }

    pub unsafe fn GetBooleanArrayRegion(&self, array: jbooleanArray, start: jsize, len: jsize, buf: *mut jboolean) {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("GetBooleanArrayRegion");
            assert!(!array.is_null(), "GetBooleanArrayRegion jarray must not be null");
            assert!(!buf.is_null(), "GetBooleanArrayRegion buf must not be null");
        }
        self.jni::<fn(JNIEnvPtr, jbooleanArray, jsize, jsize, *mut jboolean)>(199)(self.functions, array, start, len, buf);
    }

    pub unsafe fn GetByteArrayRegion(&self, array: jbyteArray, start: jsize, len: jsize, buf: *mut jbyte) {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("GetByteArrayRegion");
            assert!(!array.is_null(), "GetByteArrayRegion jarray must not be null");
            assert!(!buf.is_null(), "GetByteArrayRegion buf must not be null");
        }

        self.jni::<fn(JNIEnvPtr, jbooleanArray, jsize, jsize, *mut jbyte)>(200)(self.functions, array, start, len, buf);
    }

    pub unsafe fn GetCharArrayRegion(&self, array: jcharArray, start: jsize, len: jsize, buf: *mut jchar) {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("GetCharArrayRegion");
            assert!(!array.is_null(), "GetCharArrayRegion jarray must not be null");
            assert!(!buf.is_null(), "GetCharArrayRegion buf must not be null");
        }

        self.jni::<fn(JNIEnvPtr, jbooleanArray, jsize, jsize, *mut jchar)>(201)(self.functions, array, start, len, buf);
    }

    pub unsafe fn GetShortArrayRegion(&self, array: jshortArray, start: jsize, len: jsize, buf: *mut jshort) {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("GetShortArrayRegion");
            assert!(!array.is_null(), "GetShortArrayRegion jarray must not be null");
            assert!(!buf.is_null(), "GetShortArrayRegion buf must not be null");
        }

        self.jni::<fn(JNIEnvPtr, jbooleanArray, jsize, jsize, *mut jshort)>(202)(self.functions, array, start, len, buf);
    }

    pub unsafe fn GetIntArrayRegion(&self, array: jintArray, start: jsize, len: jsize, buf: *mut jint) {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("GetIntArrayRegion");
            assert!(!array.is_null(), "GetIntArrayRegion jarray must not be null");
            assert!(!buf.is_null(), "GetIntArrayRegion buf must not be null");
        }

        self.jni::<fn(JNIEnvPtr, jbooleanArray, jsize, jsize, *mut jint)>(203)(self.functions, array, start, len, buf);
    }

    pub unsafe fn GetLongArrayRegion(&self, array: jlongArray, start: jsize, len: jsize, buf: *mut jlong) {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("GetLongArrayRegion");
            assert!(!array.is_null(), "GetLongArrayRegion jarray must not be null");
            assert!(!buf.is_null(), "GetLongArrayRegion buf must not be null");
        }

        self.jni::<fn(JNIEnvPtr, jbooleanArray, jsize, jsize, *mut jlong)>(204)(self.functions, array, start, len, buf);
    }

    pub unsafe fn GetFloatArrayRegion(&self, array: jfloatArray, start: jsize, len: jsize, buf: *mut jfloat) {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("GetFloatArrayRegion");
            assert!(!array.is_null(), "GetFloatArrayRegion jarray must not be null");
            assert!(!buf.is_null(), "GetFloatArrayRegion buf must not be null");
        }

        self.jni::<fn(JNIEnvPtr, jbooleanArray, jsize, jsize, *mut jfloat)>(205)(self.functions, array, start, len, buf);
    }

    pub unsafe fn GetDoubleArrayRegion(&self, array: jdoubleArray, start: jsize, len: jsize, buf: *mut jdouble) {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("GetDoubleArrayRegion");
            assert!(!array.is_null(), "GetDoubleArrayRegion jarray must not be null");
            assert!(!buf.is_null(), "GetDoubleArrayRegion buf must not be null");
        }

        self.jni::<fn(JNIEnvPtr, jbooleanArray, jsize, jsize, *mut jdouble)>(206)(self.functions, array, start, len, buf);
    }

    pub unsafe fn SetBooleanArrayRegion(&self, array: jbooleanArray, start: jsize, len: jsize, buf: *const jboolean) {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("SetBooleanArrayRegion");
            assert!(!array.is_null(), "SetBooleanArrayRegion jarray must not be null");
            assert!(!buf.is_null(), "SetBooleanArrayRegion buf must not be null");
        }

        self.jni::<fn(JNIEnvPtr, jbooleanArray, jsize, jsize, *const jboolean)>(207)(self.functions, array, start, len, buf);
    }

    pub unsafe fn SetByteArrayRegion(&self, array: jbooleanArray, start: jsize, len: jsize, buf: *const jbyte) {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("SetByteArrayRegion");
            assert!(!array.is_null(), "SetByteArrayRegion jarray must not be null");
            assert!(!buf.is_null(), "SetByteArrayRegion buf must not be null");
        }

        self.jni::<fn(JNIEnvPtr, jbooleanArray, jsize, jsize, *const jbyte)>(208)(self.functions, array, start, len, buf);
    }

    pub unsafe fn SetCharArrayRegion(&self, array: jbooleanArray, start: jsize, len: jsize, buf: *const jchar) {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("SetCharArrayRegion");
            assert!(!array.is_null(), "SetCharArrayRegion jarray must not be null");
            assert!(!buf.is_null(), "SetCharArrayRegion buf must not be null");
        }

        self.jni::<fn(JNIEnvPtr, jbooleanArray, jsize, jsize, *const jchar)>(209)(self.functions, array, start, len, buf);
    }

    pub unsafe fn SetShortArrayRegion(&self, array: jbooleanArray, start: jsize, len: jsize, buf: *const jshort) {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("SetShortArrayRegion");
            assert!(!array.is_null(), "SetShortArrayRegion jarray must not be null");
            assert!(!buf.is_null(), "SetShortArrayRegion buf must not be null");
        }

        self.jni::<fn(JNIEnvPtr, jbooleanArray, jsize, jsize, *const jshort)>(210)(self.functions, array, start, len, buf);
    }

    pub unsafe fn SetIntArrayRegion(&self, array: jbooleanArray, start: jsize, len: jsize, buf: *const jint) {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("SetIntArrayRegion");
            assert!(!array.is_null(), "SetIntArrayRegion jarray must not be null");
            assert!(!buf.is_null(), "SetIntArrayRegion buf must not be null");
        }

        self.jni::<fn(JNIEnvPtr, jbooleanArray, jsize, jsize, *const jint)>(211)(self.functions, array, start, len, buf);
    }

    pub unsafe fn SetLongArrayRegion(&self, array: jbooleanArray, start: jsize, len: jsize, buf: *const jlong) {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("SetLongArrayRegion");
            assert!(!array.is_null(), "SetLongArrayRegion jarray must not be null");
            assert!(!buf.is_null(), "SetLongArrayRegion buf must not be null");
        }


        self.jni::<fn(JNIEnvPtr, jbooleanArray, jsize, jsize, *const jlong)>(212)(self.functions, array, start, len, buf);
    }

    pub unsafe fn SetFloatArrayRegion(&self, array: jbooleanArray, start: jsize, len: jsize, buf: *const jfloat) {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("SetFloatArrayRegion");
            assert!(!array.is_null(), "SetFloatArrayRegion jarray must not be null");
            assert!(!buf.is_null(), "SetFloatArrayRegion buf must not be null");
        }

        self.jni::<fn(JNIEnvPtr, jbooleanArray, jsize, jsize, *const jfloat)>(213)(self.functions, array, start, len, buf);
    }

    pub unsafe fn SetDoubleArrayRegion(&self, array: jbooleanArray, start: jsize, len: jsize, buf: *const jdouble) {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("SetDoubleArrayRegion");
            assert!(!array.is_null(), "SetDoubleArrayRegion jarray must not be null");
            assert!(!buf.is_null(), "SetDoubleArrayRegion buf must not be null");
        }

        self.jni::<fn(JNIEnvPtr, jbooleanArray, jsize, jsize, *const jdouble)>(214)(self.functions, array, start, len, buf);
    }

    pub unsafe fn GetPrimitiveArrayCritical(&self, array: jarray, isCopy: *mut jboolean) -> *mut c_void {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("GetPrimitiveArrayCritical");
            assert!(!array.is_null(), "GetPrimitiveArrayCritical jarray must not be null");
        }

        return self.jni::<fn(JNIEnvPtr, jarray, *mut jboolean) -> *mut c_void>(222)(self.functions, array, isCopy);
    }

    pub unsafe fn ReleasePrimitiveArrayCritical(&self, array: jarray, carray: *mut c_void, mode: jint) {
        #[cfg(feature = "asserts")]
        {
            assert!(!array.is_null(), "ReleasePrimitiveArrayCritical jarray must not be null");
            assert!(!carray.is_null(), "ReleasePrimitiveArrayCritical carray must not be null");
            assert!(mode == JNI_OK || mode == JNI_COMMIT || mode == JNI_ABORT, "ReleasePrimitiveArrayCritical mode is invalid {}", mode);
        }

        self.jni::<fn(JNIEnvPtr, jarray, *mut c_void, jint)>(223)(self.functions, array, carray, mode);
    }

    pub unsafe fn RegisterNatives(&self, clazz: jclass, methods : *const JNINativeMethod, size: jint) -> jint {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("RegisterNatives");
            assert!(!clazz.is_null(), "RegisterNatives class must not be null");
            assert!(size>0, "RegisterNatives size must be greater than 0");
            let sl = std::slice::from_raw_parts(methods, size as usize);
            for s in 0..sl.len() {
                let cur = &sl[s];
                assert!(!cur.name.is_null(), "RegisterNatives JNINativeMethod[{}],name is null", s);
                assert!(!cur.signature.is_null(), "RegisterNatives JNINativeMethod[{}].signature is null", s);
                assert!(!cur.fnPtr.is_null(), "RegisterNatives JNINativeMethod[{}].fnPtr is null", s);
            }
        }

        return self.jni::<fn(JNIEnvPtr, jclass, *const JNINativeMethod, jint) -> jint>(215)(self.functions, clazz, methods, size);
    }

    pub unsafe fn UnregisterNatives(&self, clazz: jclass) -> jint {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("UnregisterNatives");
            assert!(!clazz.is_null(), "UnregisterNatives class must not be null");
        }

        return self.jni::<fn(JNIEnvPtr, jclass) -> jint>(216)(self.functions, clazz);
    }

    pub unsafe fn MonitorEnter(&self, obj: jobject) -> jint {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("MonitorEnter");
            assert!(!obj.is_null(), "MonitorEnter object must not be null");
        }

        return self.jni::<fn(JNIEnvPtr, jobject) -> jint>(217)(self.functions, obj);
    }

    pub unsafe fn MonitorExit(&self, obj: jobject) -> jint {
        #[cfg(feature = "asserts")]
        {
            assert!(!obj.is_null(), "MonitorExit object must not be null");
        }

        return self.jni::<fn(JNIEnvPtr, jobject) -> jint>(218)(self.functions, obj);
    }

    pub unsafe fn NewDirectByteBuffer(&self, address: *mut c_void, capacity: jlong) -> jobject {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("NewDirectByteBuffer");
            assert!(!address.is_null(), "NewDirectByteBuffer address must not be null");
            assert!(capacity >= 0, "NewDirectByteBuffer capacity must not be negative {}", capacity);
            assert!(capacity <= jint::MAX as jlong, "NewDirectByteBuffer capacity is too big, its larger than Integer.MAX_VALUE {}", capacity);
        }

        return self.jni::<fn(JNIEnvPtr, *mut c_void, jlong) -> jobject>(229)(self.functions, address, capacity);
    }

    pub unsafe fn GetDirectBufferAddress(&self, buf: jobject) -> *mut c_void {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("GetDirectBufferAddress");
            assert!(!buf.is_null(), "GetDirectBufferAddress buffer must not be null");
        }
        return self.jni::<fn(JNIEnvPtr, jobject) -> *mut c_void>(230)(self.functions, buf);
    }

    pub unsafe fn GetDirectBufferCapacity(&self, buf: jobject) -> jlong {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("GetDirectBufferCapacity");
            assert!(!buf.is_null(), "GetDirectBufferCapacity buffer must not be null");
        }
        return self.jni::<fn(JNIEnvPtr, jobject) -> jlong>(231)(self.functions, buf);
    }

    pub unsafe fn FromReflectedMethod(&self, method: jobject) -> jmethodID {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("FromReflectedMethod");
            assert!(!method.is_null(), "FromReflectedMethod method must not be null");
        }
        return self.jni::<fn(JNIEnvPtr, jobject) -> jmethodID>(7)(self.functions, method);
    }

    pub unsafe fn ToReflectedMethod(&self, cls: jclass, jmethodID: jmethodID, isStatic: jboolean) -> jobject {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("ToReflectedMethod");
            assert!(!cls.is_null(), "ToReflectedMethod class must not be null");
            assert!(!jmethodID.is_null(), "ToReflectedMethod method must not be null");
        }
        return self.jni::<fn(JNIEnvPtr, jclass, jmethodID, jboolean) -> jobject>(9)(self.functions, cls, jmethodID, isStatic);
    }

    pub unsafe fn FromReflectedField(&self, field: jobject) -> jfieldID {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("FromReflectedField");
            assert!(!field.is_null(), "FromReflectedField field must not be null");
        }
        return self.jni::<fn(JNIEnvPtr, jobject) -> jfieldID>(8)(self.functions, field);
    }

    pub unsafe fn ToReflectedField(&self, cls: jclass, jfieldID: jfieldID, isStatic: jboolean) -> jobject {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("ToReflectedField");
            assert!(!cls.is_null(), "ToReflectedField class must not be null");
            assert!(!jfieldID.is_null(), "ToReflectedField field must not be null");
        }
        return self.jni::<fn(JNIEnvPtr, jclass, jfieldID, jboolean) -> jobject>(12)(self.functions, cls, jfieldID, isStatic);
    }

    pub unsafe fn GetJavaVM(&self) -> Result<JavaVM, jint> {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("GetJavaVM");
        }
        let mut r : JNIInvPtr = null_mut();
        let res = self.jni::<fn(JNIEnvPtr, *mut JNIInvPtr) -> jint>(219)(self.functions, &mut r);
        if res != 0 {
            return Err(res);
        }
        if r.is_null() {
            panic!("GetJavaVM returned 0 but did not set JVM pointer");
        }
        return Ok(JavaVM { functions: r});
    }

    pub unsafe fn GetModule(&self, cls: jclass) -> jobject {
        #[cfg(feature = "asserts")]
        {
            self.check_no_exception("GetModule");
            assert!(self.GetVersion() >= JNI_VERSION_9);
        }

        return self.jni::<fn(JNIEnvPtr, jclass) -> jobject>(233)(self.functions, cls);
    }

    pub unsafe fn IsVirtualThread(&self, thread: jobject) -> jboolean {
        #[cfg(feature = "asserts")]
        {
            assert!(self.GetVersion() >= JNI_VERSION_21);
        }
        return self.jni::<fn(JNIEnvPtr, jobject) -> jboolean>(234)(self.functions, thread);
    }

    #[cfg(feature = "asserts")]
    unsafe fn check_no_exception(&self, context: &str) {
        if !self.ExceptionCheck() {
            return;
        }

        self.ExceptionDescribe();
        panic!("{} exception is thrown and not handled", context);
    }


    #[cfg(feature = "asserts")]
    unsafe fn check_is_class(&self, context: &str, obj: jclass) {
        assert!(!obj.is_null(), "{} class is null", context);
        let class_cl = self.FindClass_str("java/lang/Class");
        assert!(!class_cl.is_null(), "{} java/lang/Class not found???", context);
        //GET OBJECT CLASS
        let tcl = self.jni::<fn(JNIEnvPtr, jobject) -> jobject>(31)(self.functions, obj);
        assert!(self.IsSameObject(tcl, class_cl), "{} not a class!", context);
        self.DeleteLocalRef(tcl);
        self.DeleteLocalRef(class_cl);
    }

    #[cfg(feature = "asserts")]
    unsafe fn check_if_arg_is_string(&self, src: &str, jobject: jobject) {
        if jobject.is_null() {
            return;
        }

        let clazz = self.GetObjectClass(jobject);
        assert!(!clazz.is_null(), "{} string.class is null?", src);
        let str_class = self.FindClass_str("java/lang/String");
        assert!(!str_class.is_null(), "{} java/lang/String not found?", src);
        assert!(self.IsSameObject(clazz, str_class), "{} Non string passed to GetStringCritical", src);
        self.DeleteLocalRef(clazz);
        self.DeleteLocalRef(str_class);
    }


    #[cfg(feature = "asserts")]
    unsafe fn check_field_type_static(&self, context: &str, obj: jclass, fieldID: jfieldID, ty: &str) {
        self.check_is_class(context, obj);
        assert!(!fieldID.is_null(), "{} fieldID is null", context);
        let f = self.ToReflectedField(obj, fieldID, true);
        assert!(!f.is_null(), "{} -> ToReflectedField returned null", context);
        let field_cl = self.FindClass_str("java/lang/reflect/Field");
        assert!(!f.is_null(), "{} java/lang/reflect/Method not found???", context);
        let field_rtyp = self.GetMethodID_str(field_cl, "getType", "()Ljava/lang/Class;");
        assert!(!field_rtyp.is_null(), "{} java/lang/reflect/Field#getType not found???", context);
        //CallObjectMethodA
        let rtc = self.jni::<fn(JNIEnvPtr, jobject, jmethodID, *const jtype) -> jobject>(36)(self.functions, f, field_rtyp, null());
        assert!(!rtc.is_null(), "{} java/lang/reflect/Field#getType returned null???", context);
        self.DeleteLocalRef(field_cl);
        self.DeleteLocalRef(f);
        let class_cl = self.FindClass_str("java/lang/Class");
        assert!(!class_cl.is_null(), "{} java/lang/Class not found???", context);
        let class_name = self.GetMethodID_str(class_cl, "getName", "()Ljava/lang/String;");
        assert!(!class_name.is_null(), "{} java/lang/Class#getName not found???", context);
        //CallObjectMethodA
        let name_str = self.jni::<fn(JNIEnvPtr, jobject, jmethodID, *const jtype) -> jobject>(36)(self.functions, rtc, class_name,  null());
        assert!(!name_str.is_null(), "{} java/lang/Class#getName returned null??? Class has no name???", context);
        self.DeleteLocalRef(rtc);
        let the_name = self.GetStringUTFChars_as_string(name_str).expect(format!("{} failed to get/parse classname???", context).as_str());
        self.DeleteLocalRef(class_cl);
        self.DeleteLocalRef(name_str);
        if the_name.as_str().eq(ty) {
            return;
        }

        if ty.eq("object") {
            match the_name.as_str() {
                "long" | "int" | "short" | "byte" | "char" | "float" | "double" | "boolean" => {
                    panic!("{} return type of method is {} but expected object", context, the_name);
                }
                _=> {
                    return;
                }
            }
        }

        panic!("{} return type of method is {} but expected {}", context, the_name, ty);
    }

    #[cfg(feature = "asserts")]
    unsafe fn check_return_type_static(&self, context: &str, obj: jclass, methodID: jmethodID, ty: &str) {
        self.check_is_class(context, obj);
        assert!(!methodID.is_null(), "{} methodID is null", context);
        let m = self.ToReflectedMethod(obj, methodID, true);
        assert!(!m.is_null(), "{} -> ToReflectedMethod returned null", context);
        let meth_cl = self.FindClass_str("java/lang/reflect/Method");
        assert!(!m.is_null(), "{} java/lang/reflect/Method not found???", context);
        let meth_rtyp = self.GetMethodID_str(meth_cl, "getReturnType", "()Ljava/lang/Class;");
        assert!(!meth_rtyp.is_null(), "{} java/lang/reflect/Method#getReturnType not found???", context);
        //CallObjectMethodA
        let rtc = self.jni::<fn(JNIEnvPtr, jobject, jmethodID, *const jtype) -> jobject>(36)(self.functions, m, meth_rtyp,  null());
        self.DeleteLocalRef(meth_cl);
        self.DeleteLocalRef(m);
        if rtc.is_null(){
            if ty.eq("void") {
                return;
            }

            panic!("{} return type of method is void but expected {}", context, ty);
        }
        let class_cl = self.FindClass_str("java/lang/Class");
        assert!(!class_cl.is_null(), "{} java/lang/Class not found???", context);
        let class_name = self.GetMethodID_str(class_cl, "getName", "()Ljava/lang/String;");
        assert!(!class_name.is_null(), "{} java/lang/Class#getName not found???", context);
        //CallObjectMethodA
        let name_str = self.jni::<fn(JNIEnvPtr, jobject, jmethodID, *const jtype) -> jobject>(36)(self.functions, rtc, class_name,  null());
        assert!(!name_str.is_null(), "{} java/lang/Class#getName returned null??? Class has no name???", context);
        self.DeleteLocalRef(rtc);
        let the_name = self.GetStringUTFChars_as_string(name_str).expect(format!("{} failed to get/parse classname???", context).as_str());
        self.DeleteLocalRef(class_cl);
        self.DeleteLocalRef(name_str);
        if the_name.as_str().eq(ty) {
            return;
        }

        if ty.eq("object") {
            match the_name.as_str() {
                "void" | "long" | "int" | "short" | "byte" | "char" | "float" | "double" | "boolean" => {
                    panic!("{} return type of method is {} but expected object", context, the_name);
                }
                _=> {
                    return;
                }
            }
        }

        panic!("{} return type of method is {} but expected {}", context, the_name, ty);
    }

    #[cfg(feature = "asserts")]
    unsafe fn check_return_type_object(&self, context: &str, obj: jobject, methodID: jmethodID, ty: &str) {
        assert!(!obj.is_null(), "{} obj is null", context);
        let clazz = self.GetObjectClass(obj);
        assert!(!clazz.is_null(), "{} obj.class is null??", context);
        assert!(!methodID.is_null(), "{} methodID is null", context);
        let m = self.ToReflectedMethod(clazz, methodID, false);
        assert!(!m.is_null(), "{} -> ToReflectedMethod returned null", context);
        let meth_cl = self.FindClass_str("java/lang/reflect/Method");
        assert!(!m.is_null(), "{} java/lang/reflect/Method not found???", context);
        let meth_rtyp = self.GetMethodID_str(meth_cl, "getReturnType", "()Ljava/lang/Class;");
        assert!(!meth_rtyp.is_null(), "{} java/lang/reflect/Method#getReturnType not found???", context);
        //CallObjectMethodA
        let rtc = self.jni::<fn(JNIEnvPtr, jobject, jmethodID, *const jtype) -> jobject>(36)(self.functions, m, meth_rtyp,  null());
        self.DeleteLocalRef(meth_cl);
        self.DeleteLocalRef(m);
        if rtc.is_null(){
            if ty.eq("void") {
                return;
            }

            panic!("{} return type of method is void but expected {}", context, ty);
        }
        let class_cl = self.FindClass_str("java/lang/Class");
        assert!(!class_cl.is_null(), "{} java/lang/Class not found???", context);
        let class_name = self.GetMethodID_str(class_cl, "getName", "()Ljava/lang/String;");
        assert!(!class_name.is_null(), "{} java/lang/Class#getName not found???", context);
        //CallObjectMethodA
        let name_str = self.jni::<fn(JNIEnvPtr, jobject, jmethodID, *const jtype) -> jobject>(36)(self.functions, rtc, class_name,  null());
        assert!(!name_str.is_null(), "{} java/lang/Class#getName returned null??? Class has no name???", context);
        self.DeleteLocalRef(rtc);
        let the_name = self.GetStringUTFChars_as_string(name_str).expect(format!("{} failed to get/parse classname???", context).as_str());
        self.DeleteLocalRef(class_cl);
        self.DeleteLocalRef(name_str);
        if the_name.as_str().eq(ty) {
            return;
        }

        if ty.eq("object") {
            match the_name.as_str() {
                "void" | "long" | "int" | "short" | "byte" | "char" | "float" | "double" | "boolean" => {
                    panic!("{} return type of method is {} but expected object", context, the_name);
                }
                _=> {
                    return;
                }
            }
        }

        panic!("{} return type of method is {} but expected {}", context, the_name, ty);
    }

    #[cfg(feature = "asserts")]
    unsafe fn check_field_type_object(&self, context: &str, obj: jclass, fieldID: jfieldID, ty: &str) {
        assert!(!obj.is_null(), "{} obj is null", context);
        let clazz = self.GetObjectClass(obj);
        assert!(!clazz.is_null(), "{} obj.class is null??", context);
        assert!(!fieldID.is_null(), "{} fieldID is null", context);
        let f = self.ToReflectedField(clazz, fieldID, false);
        assert!(!f.is_null(), "{} -> ToReflectedField returned null", context);
        let field_cl = self.FindClass_str("java/lang/reflect/Field");
        assert!(!f.is_null(), "{} java/lang/reflect/Method not found???", context);
        let field_rtyp = self.GetMethodID_str(field_cl, "getType", "()Ljava/lang/Class;");
        assert!(!field_rtyp.is_null(), "{} java/lang/reflect/Field#getType not found???", context);
        //CallObjectMethodA
        let rtc = self.jni::<fn(JNIEnvPtr, jobject, jmethodID, *const jtype) -> jobject>(36)(self.functions, f, field_rtyp, null());
        assert!(!rtc.is_null(), "{} java/lang/reflect/Field#getType returned null???", context);
        self.DeleteLocalRef(field_cl);
        self.DeleteLocalRef(f);
        let class_cl = self.FindClass_str("java/lang/Class");
        assert!(!class_cl.is_null(), "{} java/lang/Class not found???", context);
        let class_name = self.GetMethodID_str(class_cl, "getName", "()Ljava/lang/String;");
        assert!(!class_name.is_null(), "{} java/lang/Class#getName not found???", context);
        //CallObjectMethodA
        let name_str = self.jni::<fn(JNIEnvPtr, jobject, jmethodID, *const jtype) -> jobject>(36)(self.functions, rtc, class_name,  null());
        assert!(!name_str.is_null(), "{} java/lang/Class#getName returned null??? Class has no name???", context);
        self.DeleteLocalRef(rtc);
        let the_name = self.GetStringUTFChars_as_string(name_str).expect(format!("{} failed to get/parse classname???", context).as_str());
        self.DeleteLocalRef(class_cl);
        self.DeleteLocalRef(name_str);
        if the_name.as_str().eq(ty) {
            return;
        }

        if ty.eq("object") {
            match the_name.as_str() {
                "long" | "int" | "short" | "byte" | "char" | "float" | "double" | "boolean" => {
                    panic!("{} return type of method is {} but expected object", context, the_name);
                }
                _=> {
                    return;
                }
            }
        }

        panic!("{} return type of method is {} but expected {}", context, the_name, ty);
    }

}

type JNI_CreateJavaVM = extern "C" fn(*mut JNIInvPtr, *mut JNIEnv, *mut JavaVMInitArgs) -> jint;
type JNI_GetCreatedJavaVMs = extern "C" fn(*mut JNIInvPtr, jsize, *mut jsize) -> jint;

#[derive(Debug, Copy, Clone)]
struct JNIDynamicLink {
    JNI_CreateJavaVM: JNI_CreateJavaVM,
    JNI_GetCreatedJavaVMs: JNI_GetCreatedJavaVMs,
}

impl JNIDynamicLink {
    pub fn new(JNI_CreateJavaVM: *const c_void, JNI_GetCreatedJavaVMs: *const c_void) -> Self {
        if JNI_GetCreatedJavaVMs.is_null() {
            panic!("JNI_GetCreatedJavaVMs is null");
        }

        if JNI_CreateJavaVM.is_null() {
            panic!("JNI_CreateJavaVM is null");
        }

        unsafe {
            Self {
                JNI_CreateJavaVM: mem::transmute_copy(&JNI_CreateJavaVM),
                JNI_GetCreatedJavaVMs: mem::transmute_copy(&JNI_GetCreatedJavaVMs)
            }
        }
    }

    pub fn JNI_CreateJavaVM(&self) -> JNI_CreateJavaVM {
        self.JNI_CreateJavaVM
    }
    pub fn JNI_GetCreatedJavaVMs(&self) -> JNI_GetCreatedJavaVMs {
        self.JNI_GetCreatedJavaVMs
    }
}

unsafe impl Sync for JNIDynamicLink {

}

unsafe impl Send for JNIDynamicLink {

}


static LINK: OnceCell<JNIDynamicLink> = OnceCell::new();

///
/// Call this function to initialize the dynamic linking to the jvm to use the provided function pointers to
/// create the jvm. If this function is called more than once then it is a noop, since it is not possible to create
/// more than one jvm per process.
///
pub fn init_dynamic_link(JNI_CreateJavaVM: *const c_void, JNI_GetCreatedJavaVMs: *const c_void) {
    _= LINK.set(JNIDynamicLink::new(JNI_CreateJavaVM, JNI_GetCreatedJavaVMs));
}

///
/// Returns true if the jvm was loaded by either calling load_jvm_from_library or init_dynamic_link.
///
pub fn is_jvm_loaded() -> bool {
    return LINK.get().is_some();
}


#[cfg(feature = "loadjvm")]
use std::sync::atomic::{AtomicBool, Ordering};

#[cfg(feature = "loadjvm")]
unsafe fn symbol_to_ptr<T>(symbol: libloading::Symbol<T>) -> *mut c_void {
    //Why the library doesn't have a function for this is not really clear to me, this is the
    //primary use case. Sad I have to do this myself...

    #[cfg(target_os = "windows")]
    {
        return symbol.into_raw().into_raw().unwrap() as *mut c_void;
    }

    #[cfg(not(target_os = "windows"))]
    {
        return symbol.into_raw().into_raw();
    }
}

///
/// Convenience method to load the jvm from a path to libjvm.so or jvm.dll.
/// On success this method does NOT close the handle to the shared object.
/// This is usually fine because unloading the jvm is not supported anyway.
/// If you do not desire this then use init_dynamic_link.
///
#[cfg(feature = "loadjvm")]
pub unsafe fn load_jvm_from_library(path: &str) -> Result<(), String> {
    let latch = AtomicBool::new(false);

    LINK.get_or_try_init(|| {
        latch.store(true, Ordering::SeqCst);
        let lib = libloading::Library::new(path)
            .map_err(|e| format!("Failed to load jvm from {} reason: {}", path, e))?;

        let JNI_CreateJavaVM_ptr = lib.get::<JNI_CreateJavaVM>(b"JNI_CreateJavaVM\0")
            .map_err(|e| format!("Failed to load jvm from {} reason: JNI_CreateJavaVM -> {}", path, e))?;

        let JNI_CreateJavaVM_ptr = symbol_to_ptr(JNI_CreateJavaVM_ptr);

        if JNI_CreateJavaVM_ptr.is_null() {
            return Err(format!("Failed to load jvm from {} reason: JNI_CreateJavaVM not found", path))
        }

        let JNI_GetCreatedJavaVMs_ptr = lib.get::<JNI_GetCreatedJavaVMs>(b"JNI_GetCreatedJavaVMs\0")
            .map_err(|e| format!("Failed to load jvm from {} reason: JNI_GetCreatedJavaVMs -> {}", path, e))?;

        let JNI_GetCreatedJavaVMs_ptr = symbol_to_ptr(JNI_GetCreatedJavaVMs_ptr);

        if JNI_GetCreatedJavaVMs_ptr.is_null() {
            return Err(format!("Failed to load jvm from {} reason: JNI_GetCreatedJavaVMs not found", path))
        }

        //We are good to go!
        mem::forget(lib);
        Ok(JNIDynamicLink::new(JNI_CreateJavaVM_ptr, JNI_GetCreatedJavaVMs_ptr))
    })?;

    if !latch.load(Ordering::SeqCst) {
        return Err("JVM already loaded".to_string());
    }

    return Ok(());
}

fn get_link() -> &'static JNIDynamicLink {
    return LINK.get().expect("jni_simple::init_dynamic_link not called");
}

///
/// Returns the created JavaVMs.
/// This will only ever return 1 (or 0) JavaVM according to Oracle Documentation.
///
pub unsafe fn JNI_GetCreatedJavaVMs() -> Result<Vec<JavaVM>, jint> {
    let link = get_link();

    //NOTE: Oracle spec says this will only ever yield 1 JVM.
    //I will worry about this when it actually becomes a problem
    let mut buf : [JNIInvPtr; 64] = [null_mut(); 64];
    let mut count : jint = 0;
    let res = link.JNI_GetCreatedJavaVMs()(buf.as_mut_ptr(), 64, &mut count);
    if res != JNI_OK {
        return Err(res);
    }

    if count < 0 {
        panic!("JNI_GetCreatedJavaVMs did set count to < 0 : {}", count);
    }

    let mut result_vec : Vec<JavaVM> = Vec::with_capacity(count as usize);
    for i in 0 .. count as usize {
        let ptr = buf[i];
        if ptr.is_null() {
            panic!("JNI_GetCreatedJavaVMs VM #{} is null! count is {}", i, count);
        }

        result_vec.push(JavaVM { functions: ptr});
    }

    return Ok(result_vec);
}

///
/// Directly calls JNI_CreateJavaVM with the provided arguments.
/// Will panic if the JVM shared library has not been loaded yet.
///
pub unsafe fn JNI_CreateJavaVM(arguments: *mut JavaVMInitArgs) -> Result<(JavaVM, JNIEnv), jint> {
    let link = get_link();

    let mut jvm : JNIInvPtr = null_mut();
    let mut env : JNIEnv = JNIEnv {
        functions: null_mut(),
    };

    let res = link.JNI_CreateJavaVM()(&mut jvm, &mut env, arguments);
    if res != JNI_OK {
        return Err(res);
    }

    if jvm.is_null() {
        panic!("JNI_CreateJavaVM returned JNI_OK but the JavaVM pointer is null");
    }

    if env.functions.is_null() {
        panic!("JNI_CreateJavaVM returned JNI_OK but the JNIEnv pointer is null");
    }

    return Ok((JavaVM{ functions: jvm }, env));
}

///
/// Convenience function to call JNI_CreateJavaVM with a simple list of String arguments.
/// These arguments are almost identical to the command line arguments used to start the jvm with the java binary.
/// Some options differ slightly. Consult the JNI Invocation API documentation for more information.
///
/// Will panic if the JVM shared library has not been loaded yet.
///
pub unsafe fn JNI_CreateJavaVM_with_string_args(version: jint, arguments: &Vec<String>) -> Result<(JavaVM, JNIEnv), jint> {
    let link = get_link();

    let mut vm_args: Vec<JavaVMOption> = Vec::with_capacity(arguments.len());
    let mut dealloc_list = Vec::with_capacity(arguments.len());
    for arg in arguments {
        let jvm_arg = CString::new(arg.as_str()).unwrap().into_raw();

        vm_args.push(JavaVMOption{
            optionString: jvm_arg,
            extraInfo: null_mut(),
        });

        dealloc_list.push(jvm_arg);
    }

    let mut args = JavaVMInitArgs {
        version,
        nOptions: vm_args.len() as i32,
        options: vm_args.as_mut_ptr(),
        ignoreUnrecognized: 1,
    };

    let mut jvm : JNIInvPtr = null_mut();
    let mut env : JNIEnv = JNIEnv {
        functions: null_mut(),
    };


    let err = link.JNI_CreateJavaVM()(&mut jvm, &mut env, &mut args);

    for x in dealloc_list {
        _=CString::from_raw(x);
    }

    if err != JNI_OK {
        return Err(err);
    }

    if jvm.is_null() {
        panic!("JNI_CreateJavaVM returned JNI_OK but the JavaVM pointer is null");
    }

    if env.functions.is_null() {
        panic!("JNI_CreateJavaVM returned JNI_OK but the JNIEnv pointer is null");
    }

    return Ok((JavaVM{ functions: jvm }, env));
}



impl JavaVM {

    fn jnx<X>(&self, index: usize) -> X {
        return unsafe {std::mem::transmute_copy(&(**self.functions)[index])};
    }

    pub fn AttachCurrentThread(&self, args: *mut JavaVMAttachArgs) -> Result<JNIEnv, jint> {
        let mut envptr : JNIEnvPtr = null_mut();

        let result = self.jnx::<fn(JNIInvPtr, *mut JNIEnvPtr, *mut JavaVMAttachArgs) -> jint>(4)
            (self.functions, &mut envptr, args);
        if result != JNI_OK {
            return Err(result);
        }

        if envptr.is_null() {
            panic!("AttachCurrentThread returned JNI_OK but did not set the JNIEnv pointer!");
        }

        return Ok(JNIEnv{functions: envptr});
    }

    pub fn AttachCurrentThreadAsDaemon(&self, args: *mut JavaVMAttachArgs) -> Result<JNIEnv, jint> {
        let mut envptr : JNIEnvPtr = null_mut();

        let result = self.jnx::<fn(JNIInvPtr, *mut JNIEnvPtr, *mut JavaVMAttachArgs) -> jint>(7)
            (self.functions, &mut envptr, args);
        if result != JNI_OK {
            return Err(result);
        }

        if envptr.is_null() {
            panic!("AttachCurrentThreadAsDaemon returned JNI_OK but did not set the JNIEnv pointer!");
        }

        return Ok(JNIEnv{functions: envptr});
    }

    pub fn GetEnv(&self, jni_version: jint) -> Result<JNIEnv, jint> {
        let mut envptr : JNIEnvPtr = null_mut();

        let result = self.jnx::<fn(JNIInvPtr, *mut JNIEnvPtr, jint) -> jint>(6)
            (self.functions, &mut envptr, jni_version);
        if result != JNI_OK {
            return Err(result);
        }

        if envptr.is_null() {
            panic!("GetEnv returned JNI_OK but did not set the JNIEnv pointer!");
        }

        return Ok(JNIEnv{functions: envptr});
    }

    pub fn DetachCurrentThread(&self) -> jint {
        return self.jnx::<fn(JNIInvPtr) -> jint>(5)(self.functions);
    }


    pub fn DestroyJavaVM(&self) {
        self.jnx::<fn(JNIInvPtr) -> ()>(3)(self.functions);
    }


}