This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
ee854c13b5b4b1b0602e0d9fa57a2bdf730717fa
[perl5.git] / jpl / JNI / JNI.xs
1 /*
2  * Copyright 1997, O'Reilly & Associate, Inc.
3  *
4  * This package may be copied under the same terms as Perl itself.
5  */
6
7 #include "EXTERN.h"
8 #include "perl.h"
9 #include "XSUB.h"
10
11 #include <perl.h>
12 #include <jni.h>
13 #include <dlfcn.h>
14
15 extern JNIEnv* jplcurenv;
16 extern int jpldebug;
17
18 #define SysRet jint
19
20 static void
21 call_my_exit(jint status)
22 {
23     dTHX;
24     my_exit(status);
25 }
26
27 jvalue*
28 makeargs(pTHX_ char *sig, SV** svp, int items)
29 {
30     jvalue* jv = (jvalue*)safemalloc(sizeof(jvalue) * items);
31     int ix = 0;
32     char *s = sig;
33     JNIEnv* env = jplcurenv;
34     char *start;
35     STRLEN n_a;
36
37     if (jpldebug)
38         fprintf(stderr, "sig = %s, items = %d\n", sig, items);
39     if (*s++ != '(')
40         goto cleanup;
41
42     while (items--) {
43         SV *sv = *svp++;
44         start = s;
45         switch (*s++) {
46         case 'Z':
47             jv[ix++].z = (jboolean)(SvIV(sv) != 0);
48             break;
49         case 'B':
50             jv[ix++].b = (jbyte)SvIV(sv);
51             break;
52         case 'C':
53             jv[ix++].c = (jchar)SvIV(sv);
54             break;
55         case 'S':
56             jv[ix++].s = (jshort)SvIV(sv);
57             break;
58         case 'I':
59             jv[ix++].i = (jint)SvIV(sv);
60             break;
61         case 'J':
62             jv[ix++].j = (jlong)SvNV(sv);
63             break;
64         case 'F':
65             jv[ix++].f = (jfloat)SvNV(sv);
66             break;
67         case 'D':
68             jv[ix++].d = (jdouble)SvNV(sv);
69             break;
70         case '[':
71             switch (*s++) {
72             case 'Z':
73                 if (SvROK(sv)) {
74                     SV* rv = (SV*)SvRV(sv);
75                     if (SvOBJECT(rv))
76                         jv[ix++].l = (jobject)(void*)SvIV(rv);
77                     else if (SvTYPE(rv) == SVt_PVAV) {
78                         jsize len = av_len((AV*)rv) + 1;
79                         jboolean* buf = (jboolean*)malloc(len * sizeof(jboolean));
80                         int i;
81                         SV** esv;
82
83                         jbooleanArray ja = (*env)->NewBooleanArray(env, len);
84                         for (esv = AvARRAY((AV*)rv), i = 0; i < len; esv++, i++)
85                             buf[i] = (jboolean)SvIV(*esv);
86                         (*env)->SetBooleanArrayRegion(env, ja, 0, len, buf);
87                         free((void*)buf);
88                         jv[ix++].l = (jobject)ja;
89                     }
90                     else
91                         jv[ix++].l = (jobject)(void*)0;
92                 }
93                 else if (SvPOK(sv)) {
94                     jsize len = sv_len(sv) / sizeof(jboolean);
95
96                     jbooleanArray ja = (*env)->NewBooleanArray(env, len);
97                     (*env)->SetBooleanArrayRegion(env, ja, 0, len, (jboolean*)SvPV(sv,n_a));
98                     jv[ix++].l = (jobject)ja;
99                 }
100                 else
101                     jv[ix++].l = (jobject)(void*)0;
102                 break;
103             case 'B':
104                 if (SvROK(sv)) {
105                     SV* rv = (SV*)SvRV(sv);
106                     if (SvOBJECT(rv))
107                         jv[ix++].l = (jobject)(void*)SvIV(rv);
108                     else if (SvTYPE(rv) == SVt_PVAV) {
109                         jsize len = av_len((AV*)rv) + 1;
110                         jbyte* buf = (jbyte*)malloc(len * sizeof(jbyte));
111                         int i;
112                         SV** esv;
113
114                         jbyteArray ja = (*env)->NewByteArray(env, len);
115                         for (esv = AvARRAY((AV*)rv), i = 0; i < len; esv++, i++)
116                             buf[i] = (jbyte)SvIV(*esv);
117                         (*env)->SetByteArrayRegion(env, ja, 0, len, buf);
118                         free((void*)buf);
119                         jv[ix++].l = (jobject)ja;
120                     }
121                     else
122                         jv[ix++].l = (jobject)(void*)0;
123                 }
124                 else if (SvPOK(sv)) {
125                     jsize len = sv_len(sv) / sizeof(jbyte);
126
127                     jbyteArray ja = (*env)->NewByteArray(env, len);
128                     (*env)->SetByteArrayRegion(env, ja, 0, len, (jbyte*)SvPV(sv,n_a));
129                     jv[ix++].l = (jobject)ja;
130                 }
131                 else
132                     jv[ix++].l = (jobject)(void*)0;
133                 break;
134             case 'C':
135                 if (SvROK(sv)) {
136                     SV* rv = (SV*)SvRV(sv);
137                     if (SvOBJECT(rv))
138                         jv[ix++].l = (jobject)(void*)SvIV(rv);
139                     else if (SvTYPE(rv) == SVt_PVAV) {
140                         jsize len = av_len((AV*)rv) + 1;
141                         jchar* buf = (jchar*)malloc(len * sizeof(jchar));
142                         int i;
143                         SV** esv;
144
145                         jcharArray ja = (*env)->NewCharArray(env, len);
146                         for (esv = AvARRAY((AV*)rv), i = 0; i < len; esv++, i++)
147                             buf[i] = (jchar)SvIV(*esv);
148                         (*env)->SetCharArrayRegion(env, ja, 0, len, buf);
149                         free((void*)buf);
150                         jv[ix++].l = (jobject)ja;
151                     }
152                     else
153                         jv[ix++].l = (jobject)(void*)0;
154                 }
155                 else if (SvPOK(sv)) {
156                     jsize len = sv_len(sv) / sizeof(jchar);
157
158                     jcharArray ja = (*env)->NewCharArray(env, len);
159                     (*env)->SetCharArrayRegion(env, ja, 0, len, (jchar*)SvPV(sv,n_a));
160                     jv[ix++].l = (jobject)ja;
161                 }
162                 else
163                     jv[ix++].l = (jobject)(void*)0;
164                 break;
165             case 'S':
166                 if (SvROK(sv)) {
167                     SV* rv = (SV*)SvRV(sv);
168                     if (SvOBJECT(rv))
169                         jv[ix++].l = (jobject)(void*)SvIV(rv);
170                     else if (SvTYPE(rv) == SVt_PVAV) {
171                         jsize len = av_len((AV*)rv) + 1;
172                         jshort* buf = (jshort*)malloc(len * sizeof(jshort));
173                         int i;
174                         SV** esv;
175
176                         jshortArray ja = (*env)->NewShortArray(env, len);
177                         for (esv = AvARRAY((AV*)rv), i = 0; i < len; esv++, i++)
178                             buf[i] = (jshort)SvIV(*esv);
179                         (*env)->SetShortArrayRegion(env, ja, 0, len, buf);
180                         free((void*)buf);
181                         jv[ix++].l = (jobject)ja;
182                     }
183                     else
184                         jv[ix++].l = (jobject)(void*)0;
185                 }
186                 else if (SvPOK(sv)) {
187                     jsize len = sv_len(sv) / sizeof(jshort);
188
189                     jshortArray ja = (*env)->NewShortArray(env, len);
190                     (*env)->SetShortArrayRegion(env, ja, 0, len, (jshort*)SvPV(sv,n_a));
191                     jv[ix++].l = (jobject)ja;
192                 }
193                 else
194                     jv[ix++].l = (jobject)(void*)0;
195                 break;
196             case 'I':
197                 if (SvROK(sv)) {
198                     SV* rv = (SV*)SvRV(sv);
199                     if (SvOBJECT(rv))
200                         jv[ix++].l = (jobject)(void*)SvIV(rv);
201                     else if (SvTYPE(rv) == SVt_PVAV) {
202                         jsize len = av_len((AV*)rv) + 1;
203                         jint* buf = (jint*)malloc(len * sizeof(jint));
204                         int i;
205                         SV** esv;
206
207                         jintArray ja = (*env)->NewIntArray(env, len);
208                         for (esv = AvARRAY((AV*)rv), i = 0; i < len; esv++, i++)
209                             buf[i] = (jint)SvIV(*esv);
210                         (*env)->SetIntArrayRegion(env, ja, 0, len, buf);
211                         free((void*)buf);
212                         jv[ix++].l = (jobject)ja;
213                     }
214                     else
215                         jv[ix++].l = (jobject)(void*)0;
216                 }
217                 else if (SvPOK(sv)) {
218                     jsize len = sv_len(sv) / sizeof(jint);
219
220                     jintArray ja = (*env)->NewIntArray(env, len);
221                     (*env)->SetIntArrayRegion(env, ja, 0, len, (jint*)SvPV(sv,n_a));
222                     jv[ix++].l = (jobject)ja;
223                 }
224                 else
225                     jv[ix++].l = (jobject)(void*)0;
226                 break;
227             case 'J':
228                 if (SvROK(sv)) {
229                     SV* rv = (SV*)SvRV(sv);
230                     if (SvOBJECT(rv))
231                         jv[ix++].l = (jobject)(void*)SvIV(rv);
232                     else if (SvTYPE(rv) == SVt_PVAV) {
233                         jsize len = av_len((AV*)rv) + 1;
234                         jlong* buf = (jlong*)malloc(len * sizeof(jlong));
235                         int i;
236                         SV** esv;
237
238                         jlongArray ja = (*env)->NewLongArray(env, len);
239                         for (esv = AvARRAY((AV*)rv), i = 0; i < len; esv++, i++)
240                             buf[i] = (jlong)SvNV(*esv);
241                         (*env)->SetLongArrayRegion(env, ja, 0, len, buf);
242                         free((void*)buf);
243                         jv[ix++].l = (jobject)ja;
244                     }
245                     else
246                         jv[ix++].l = (jobject)(void*)0;
247                 }
248                 else if (SvPOK(sv)) {
249                     jsize len = sv_len(sv) / sizeof(jlong);
250
251                     jlongArray ja = (*env)->NewLongArray(env, len);
252                     (*env)->SetLongArrayRegion(env, ja, 0, len, (jlong*)SvPV(sv,n_a));
253                     jv[ix++].l = (jobject)ja;
254                 }
255                 else
256                     jv[ix++].l = (jobject)(void*)0;
257                 break;
258             case 'F':
259                 if (SvROK(sv)) {
260                     SV* rv = (SV*)SvRV(sv);
261                     if (SvOBJECT(rv))
262                         jv[ix++].l = (jobject)(void*)SvIV(rv);
263                     else if (SvTYPE(rv) == SVt_PVAV) {
264                         jsize len = av_len((AV*)rv) + 1;
265                         jfloat* buf = (jfloat*)malloc(len * sizeof(jfloat));
266                         int i;
267                         SV** esv;
268
269                         jfloatArray ja = (*env)->NewFloatArray(env, len);
270                         for (esv = AvARRAY((AV*)rv), i = 0; i < len; esv++, i++)
271                             buf[i] = (jfloat)SvNV(*esv);
272                         (*env)->SetFloatArrayRegion(env, ja, 0, len, buf);
273                         free((void*)buf);
274                         jv[ix++].l = (jobject)ja;
275                     }
276                     else
277                         jv[ix++].l = (jobject)(void*)0;
278                 }
279                 else if (SvPOK(sv)) {
280                     jsize len = sv_len(sv) / sizeof(jfloat);
281
282                     jfloatArray ja = (*env)->NewFloatArray(env, len);
283                     (*env)->SetFloatArrayRegion(env, ja, 0, len, (jfloat*)SvPV(sv,n_a));
284                     jv[ix++].l = (jobject)ja;
285                 }
286                 else
287                     jv[ix++].l = (jobject)(void*)0;
288                 break;
289             case 'D':
290                 if (SvROK(sv)) {
291                     SV* rv = (SV*)SvRV(sv);
292                     if (SvOBJECT(rv))
293                         jv[ix++].l = (jobject)(void*)SvIV(rv);
294                     else if (SvTYPE(rv) == SVt_PVAV) {
295                         jsize len = av_len((AV*)rv) + 1;
296                         jdouble* buf = (jdouble*)malloc(len * sizeof(jdouble));
297                         int i;
298                         SV** esv;
299
300                         jdoubleArray ja = (*env)->NewDoubleArray(env, len);
301                         for (esv = AvARRAY((AV*)rv), i = 0; i < len; esv++, i++)
302                             buf[i] = (jdouble)SvNV(*esv);
303                         (*env)->SetDoubleArrayRegion(env, ja, 0, len, buf);
304                         free((void*)buf);
305                         jv[ix++].l = (jobject)ja;
306                     }
307                     else
308                         jv[ix++].l = (jobject)(void*)0;
309                 }
310                 else if (SvPOK(sv)) {
311                     jsize len = sv_len(sv) / sizeof(jdouble);
312
313                     jdoubleArray ja = (*env)->NewDoubleArray(env, len);
314                     (*env)->SetDoubleArrayRegion(env, ja, 0, len, (jdouble*)SvPV(sv,n_a));
315                     jv[ix++].l = (jobject)ja;
316                 }
317                 else
318                     jv[ix++].l = (jobject)(void*)0;
319                 break;
320             case 'L':
321                 while (*s != ';') s++;
322                 s++;
323                 if (strnEQ(start, "[Ljava/lang/String;", 19)) {
324                     if (SvROK(sv)) {
325                         SV* rv = (SV*)SvRV(sv);
326                         if (SvOBJECT(rv))
327                             jv[ix++].l = (jobject)(void*)SvIV(rv);
328                         else if (SvTYPE(rv) == SVt_PVAV) {
329                             jsize len = av_len((AV*)rv) + 1;
330                             int i;
331                             SV** esv;
332                             static jclass jcl = 0;
333                             jarray ja;
334
335                             if (!jcl)
336                                 jcl = (*env)->FindClass(env, "java/lang/String");
337                             ja = (*env)->NewObjectArray(env, len, jcl, 0);
338                             for (esv = AvARRAY((AV*)rv), i = 0; i < len; esv++, i++) {
339                                 jobject str = (jobject)(*env)->NewStringUTF(env, SvPV(*esv,n_a));
340                                 (*env)->SetObjectArrayElement(env, ja, i, str);
341                             }
342                             jv[ix++].l = (jobject)ja;
343                         }
344                         else
345                             jv[ix++].l = (jobject)(void*)0;
346                     }
347                     else
348                         jv[ix++].l = (jobject)(void*)0;
349                     break;
350                 }
351                 /* FALL THROUGH */
352             default:
353                 if (SvROK(sv)) {
354                     SV* rv = (SV*)SvRV(sv);
355                     if (SvOBJECT(rv))
356                         jv[ix++].l = (jobject)(void*)SvIV(rv);
357                     else if (SvTYPE(rv) == SVt_PVAV) {
358                         jsize len = av_len((AV*)rv) + 1;
359                         int i;
360                         SV** esv;
361                        static jclass jcl = 0;
362                         jarray ja;
363
364                         if (!jcl)
365                             jcl = (*env)->FindClass(env, "java/lang/Object");
366                         ja = (*env)->NewObjectArray(env, len, jcl, 0);
367                         for (esv = AvARRAY((AV*)rv), i = 0; i < len; esv++, i++) {
368                             if (SvROK(*esv) && (rv = SvRV(*esv)) && SvOBJECT(rv)) {
369                                 (*env)->SetObjectArrayElement(env, ja, i,
370                                     (jobject)(void*)SvIV(rv));
371                             }
372                             else {
373                                 jobject str = (jobject)(*env)->NewStringUTF(env,
374                                     SvPV(*esv,n_a));
375                                 (*env)->SetObjectArrayElement(env, ja, i, str);
376                             }
377                         }
378                         jv[ix++].l = (jobject)ja;
379                     }
380                     else
381                         jv[ix++].l = (jobject)(void*)0;
382                 }
383                 else
384                     jv[ix++].l = (jobject)(void*)0;
385                 break;
386             }
387             break;
388         case 'L':
389             if (!SvROK(sv) || strnEQ(s, "java/lang/String;", 17)) {
390                 s += 17;
391                 jv[ix++].l = (jobject)(*env)->NewStringUTF(env,
392                                 (char*) SvPV(sv,n_a));
393                 break;
394             }
395             while (*s != ';') s++;
396             s++;
397             if (SvROK(sv)) {
398                 SV* rv = SvRV(sv);
399                 jv[ix++].l = (jobject)(void*)SvIV(rv);
400             }
401             break;
402         case ')':
403             Perl_croak(aTHX_ "too many arguments, signature: %s", sig);
404             goto cleanup;
405         default:
406             Perl_croak(aTHX_ "panic: malformed signature: %s", s-1);
407             goto cleanup;
408         }
409
410     }
411     if (*s != ')') {
412         Perl_croak(aTHX_ "not enough arguments, signature: %s", sig);
413         goto cleanup;
414     }
415     return jv;
416
417 cleanup:
418     safefree((char*)jv);
419     return 0;
420 }
421
422 static int
423 not_here(pTHX_ char *s)
424 {
425     Perl_croak(aTHX_ "%s not implemented on this architecture", s);
426     return -1;
427 }
428
429 static double
430 constant(char *name, int arg)
431 {
432     errno = 0;
433     switch (*name) {
434     case 'A':
435         break;
436     case 'B':
437         break;
438     case 'C':
439         break;
440     case 'D':
441         break;
442     case 'E':
443         break;
444     case 'F':
445         break;
446     case 'G':
447         break;
448     case 'H':
449         break;
450     case 'I':
451         break;
452     case 'J':
453         if (strEQ(name, "JNI_ABORT"))
454 #ifdef JNI_ABORT
455             return JNI_ABORT;
456 #else
457             goto not_there;
458 #endif
459         if (strEQ(name, "JNI_COMMIT"))
460 #ifdef JNI_COMMIT
461             return JNI_COMMIT;
462 #else
463             goto not_there;
464 #endif
465         if (strEQ(name, "JNI_ERR"))
466 #ifdef JNI_ERR
467             return JNI_ERR;
468 #else
469             goto not_there;
470 #endif
471         if (strEQ(name, "JNI_FALSE"))
472 #ifdef JNI_FALSE
473             return JNI_FALSE;
474 #else
475             goto not_there;
476 #endif
477         if (strEQ(name, "JNI_H"))
478 #ifdef JNI_H
479             return JNI_H;
480 #else
481             goto not_there;
482 #endif
483         if (strEQ(name, "JNI_OK"))
484 #ifdef JNI_OK
485             return JNI_OK;
486 #else
487             goto not_there;
488 #endif
489         if (strEQ(name, "JNI_TRUE"))
490 #ifdef JNI_TRUE
491             return JNI_TRUE;
492 #else
493             goto not_there;
494 #endif
495         break;
496     case 'K':
497         break;
498     case 'L':
499         break;
500     case 'M':
501         break;
502     case 'N':
503         break;
504     case 'O':
505         break;
506     case 'P':
507         break;
508     case 'Q':
509         break;
510     case 'R':
511         break;
512     case 'S':
513         break;
514     case 'T':
515         break;
516     case 'U':
517         break;
518     case 'V':
519         break;
520     case 'W':
521         break;
522     case 'X':
523         break;
524     case 'Y':
525         break;
526     case 'Z':
527         break;
528     }
529     errno = EINVAL;
530     return 0;
531
532 not_there:
533     errno = ENOENT;
534     return 0;
535 }
536
537 #define FETCHENV jplcurenv
538 #define RESTOREENV jplcurenv = env
539
540 MODULE = JNI            PACKAGE = JNI           
541
542 PROTOTYPES: ENABLE
543
544 double
545 constant(name,arg)
546         char *          name
547         int             arg
548
549 jint
550 GetVersion()
551         JNIEnv *                env = FETCHENV;
552     CODE:
553         {
554             RETVAL = (*env)->GetVersion(env);
555             RESTOREENV;
556         }
557     OUTPUT:
558         RETVAL
559
560 jclass
561 DefineClass(name, loader, buf)
562         JNIEnv *                env = FETCHENV;
563         STRLEN                  tmplen = NO_INIT;
564         jsize                   buf_len_ = NO_INIT;
565         const char *            name
566         jobject                 loader
567         const jbyte *           buf
568     CODE:
569         {
570             RETVAL = (*env)->DefineClass(env,  name, loader, buf, (jsize)buf_len_);
571             RESTOREENV;
572         }
573     OUTPUT:
574         RETVAL
575
576 jclass
577 FindClass(name)
578         JNIEnv *                env = FETCHENV;
579         const char *            name
580     CODE:
581         {
582             RETVAL = (*env)->FindClass(env,  name);
583             RESTOREENV;
584         }
585     OUTPUT:
586         RETVAL
587
588 jclass
589 GetSuperclass(sub)
590         JNIEnv *                env = FETCHENV;
591         jclass                  sub
592     CODE:
593         {
594             RETVAL = (*env)->GetSuperclass(env,  sub);
595             RESTOREENV;
596         }
597     OUTPUT:
598         RETVAL
599
600 jboolean
601 IsAssignableFrom(sub, sup)
602         JNIEnv *                env = FETCHENV;
603         jclass                  sub
604         jclass                  sup
605     CODE:
606         {
607             RETVAL = (*env)->IsAssignableFrom(env,  sub, sup);
608             RESTOREENV;
609         }
610     OUTPUT:
611         RETVAL
612
613 SysRet
614 Throw(obj)
615         JNIEnv *                env = FETCHENV;
616         jthrowable              obj
617     CODE:
618         {
619             RETVAL = (*env)->Throw(env,  obj);
620             RESTOREENV;
621         }
622     OUTPUT:
623         RETVAL    
624
625 SysRet
626 ThrowNew(clazz, msg)
627         JNIEnv *                env = FETCHENV;
628         jclass                  clazz
629         const char *            msg
630     CODE:
631         {
632             RETVAL = (*env)->ThrowNew(env,  clazz, msg);
633             RESTOREENV;
634         }
635     OUTPUT:
636         RETVAL
637
638 jthrowable
639 ExceptionOccurred()
640         JNIEnv *                env = FETCHENV;
641     CODE:
642         {
643             RETVAL = (*env)->ExceptionOccurred(env);
644             RESTOREENV;
645         }
646     OUTPUT:
647         RETVAL
648
649 void
650 ExceptionDescribe()
651         JNIEnv *                env = FETCHENV;
652     CODE:
653         {
654             (*env)->ExceptionDescribe(env);
655             RESTOREENV;
656         }
657
658 void
659 ExceptionClear()
660         JNIEnv *                env = FETCHENV;
661     CODE:
662         {
663             (*env)->ExceptionClear(env);
664             RESTOREENV;
665         }
666
667 void
668 FatalError(msg)
669         JNIEnv *                env = FETCHENV;
670         const char *            msg
671     CODE:
672         {
673             (*env)->FatalError(env,  msg);
674             RESTOREENV;
675         }
676
677 jobject
678 NewGlobalRef(lobj)
679         JNIEnv *                env = FETCHENV;
680         jobject                 lobj
681     CODE:
682         {
683             RETVAL = (*env)->NewGlobalRef(env, lobj);
684             RESTOREENV;
685         }
686     OUTPUT:
687         RETVAL
688
689 void
690 DeleteGlobalRef(gref)
691         JNIEnv *                env = FETCHENV;
692         jobject                 gref
693     CODE:
694         {
695             (*env)->DeleteGlobalRef(env, gref);
696             RESTOREENV;
697         }
698
699 void
700 DeleteLocalRef(obj)
701         JNIEnv *                env = FETCHENV;
702         jobject                 obj
703     CODE:
704         {
705             (*env)->DeleteLocalRef(env,  obj);
706             RESTOREENV;
707         }
708
709 jboolean
710 IsSameObject(obj1,obj2)
711         JNIEnv *                env = FETCHENV;
712         jobject                 obj1
713         jobject                 obj2
714     CODE:
715         {
716             RETVAL = (*env)->IsSameObject(env, obj1,obj2);
717             RESTOREENV;
718         }
719     OUTPUT:
720         RETVAL
721
722 jobject
723 AllocObject(clazz)
724         JNIEnv *                env = FETCHENV;
725         jclass                  clazz
726     CODE:
727         {
728             RETVAL = (*env)->AllocObject(env, clazz);
729             RESTOREENV;
730         }
731     OUTPUT:
732         RETVAL
733
734 jobject
735 NewObject(clazz,methodID,...)
736         JNIEnv *                env = FETCHENV;
737         jclass                  clazz
738         jmethodID               methodID
739         char *                  sig = 0;
740         int                     argoff = $min_args;
741     CODE:
742         {
743             jvalue * args = makeargs(aTHX_ sig, &ST(argoff), items - argoff);
744             RETVAL = (*env)->NewObjectA(env, clazz,methodID,args);
745             RESTOREENV;
746         }
747     OUTPUT:
748         RETVAL
749
750 jobject
751 NewObjectA(clazz,methodID,args)
752         JNIEnv *                env = FETCHENV;
753         jclass                  clazz
754         jmethodID               methodID
755         char *                  sig = 0;
756         jvalue *                args
757     CODE:
758         {
759             RETVAL = (*env)->NewObjectA(env, clazz,methodID,args);
760             RESTOREENV;
761         }
762     OUTPUT:
763         RETVAL
764
765 jclass
766 GetObjectClass(obj)
767         JNIEnv *                env = FETCHENV;
768         jobject                 obj
769     CODE:
770         {
771             RETVAL = (*env)->GetObjectClass(env, obj);
772             RESTOREENV;
773         }
774     OUTPUT:
775         RETVAL
776
777 jboolean
778 IsInstanceOf(obj,clazz)
779         JNIEnv *                env = FETCHENV;
780         jobject                 obj
781         jclass                  clazz
782     CODE:
783         {
784             RETVAL = (*env)->IsInstanceOf(env, obj,clazz);
785             RESTOREENV;
786         }
787     OUTPUT:
788         RETVAL
789
790 jmethodID
791 GetMethodID(clazz,name,sig)
792         JNIEnv *                env = FETCHENV;
793         jclass                  clazz
794         const char *            name
795         const char *            sig
796     CODE:
797         {
798             RETVAL = (*env)->GetMethodID(env, clazz,name,sig);
799             RESTOREENV;
800         }
801     OUTPUT:
802         RETVAL
803
804 jobject
805 CallObjectMethod(obj,methodID,...)
806         JNIEnv *                env = FETCHENV;
807         jobject                 obj
808         jmethodID               methodID
809         char *                  sig = 0;
810         int                     argoff = $min_args;
811     CODE:
812         {
813             jvalue * args = makeargs(aTHX_ sig, &ST(argoff), items - argoff);
814             RETVAL = (*env)->CallObjectMethodA(env, obj,methodID,args);
815             RESTOREENV;
816         }
817     OUTPUT:
818         RETVAL
819
820 jobject
821 CallObjectMethodA(obj,methodID,args)
822         JNIEnv *                env = FETCHENV;
823         jobject                 obj
824         jmethodID               methodID
825         char *                  sig = 0;
826         jvalue *                args
827     CODE:
828         {
829             RETVAL = (*env)->CallObjectMethodA(env, obj,methodID,args);
830             RESTOREENV;
831         }
832     OUTPUT:
833         RETVAL
834
835 jboolean
836 CallBooleanMethod(obj,methodID,...)
837         JNIEnv *                env = FETCHENV;
838         jobject                 obj
839         jmethodID               methodID
840         char *                  sig = 0;
841         int                     argoff = $min_args;
842     CODE:
843         {
844             jvalue * args = makeargs(aTHX_ sig, &ST(argoff), items - argoff);
845             RETVAL = (*env)->CallBooleanMethodA(env, obj,methodID,args);
846             RESTOREENV;
847         }
848     OUTPUT:
849         RETVAL
850
851 jboolean
852 CallBooleanMethodA(obj,methodID, args)
853         JNIEnv *                env = FETCHENV;
854         jobject                 obj
855         jmethodID               methodID
856         char *                  sig = 0;
857         jvalue *                args
858     CODE:
859         {
860             RETVAL = (*env)->CallBooleanMethodA(env, obj,methodID, args);
861             RESTOREENV;
862         }
863     OUTPUT:
864         RETVAL
865
866 jbyte
867 CallByteMethod(obj,methodID,...)
868         JNIEnv *                env = FETCHENV;
869         jobject                 obj
870         jmethodID               methodID
871         char *                  sig = 0;
872         int                     argoff = $min_args;
873     CODE:
874         {
875             jvalue * args = makeargs(aTHX_ sig, &ST(argoff), items - argoff);
876             RETVAL = (*env)->CallByteMethodA(env, obj,methodID,args);
877             RESTOREENV;
878         }
879     OUTPUT:
880         RETVAL
881
882 jbyte
883 CallByteMethodA(obj,methodID,args)
884         JNIEnv *                env = FETCHENV;
885         jobject                 obj
886         jmethodID               methodID
887         char *                  sig = 0;
888         jvalue *                args
889     CODE:
890         {
891             RETVAL = (*env)->CallByteMethodA(env, obj,methodID,args);
892             RESTOREENV;
893         }
894     OUTPUT:
895         RETVAL
896
897 jchar
898 CallCharMethod(obj,methodID,...)
899         JNIEnv *                env = FETCHENV;
900         jobject                 obj
901         jmethodID               methodID
902         char *                  sig = 0;
903         int                     argoff = $min_args;
904     CODE:
905         {
906             jvalue * args = makeargs(aTHX_ sig, &ST(argoff), items - argoff);
907             RETVAL = (*env)->CallCharMethodA(env, obj,methodID,args);
908             RESTOREENV;
909         }
910     OUTPUT:
911         RETVAL
912
913 jchar
914 CallCharMethodA(obj,methodID,args)
915         JNIEnv *                env = FETCHENV;
916         jobject                 obj
917         jmethodID               methodID
918         char *                  sig = 0;
919         jvalue *                args
920     CODE:
921         {
922             RETVAL = (*env)->CallCharMethodA(env, obj,methodID,args);
923             RESTOREENV;
924         }
925     OUTPUT:
926         RETVAL
927
928 jshort
929 CallShortMethod(obj,methodID,...)
930         JNIEnv *                env = FETCHENV;
931         jobject                 obj
932         jmethodID               methodID
933         char *                  sig = 0;
934         int                     argoff = $min_args;
935     CODE:
936         {
937             jvalue * args = makeargs(aTHX_ sig, &ST(argoff), items - argoff);
938             RETVAL = (*env)->CallShortMethodA(env, obj,methodID,args);
939             RESTOREENV;
940         }
941     OUTPUT:
942         RETVAL
943
944 jshort
945 CallShortMethodA(obj,methodID,args)
946         JNIEnv *                env = FETCHENV;
947         jobject                 obj
948         jmethodID               methodID
949         char *                  sig = 0;
950         jvalue *                args
951     CODE:
952         {
953             RETVAL = (*env)->CallShortMethodA(env, obj,methodID,args);
954             RESTOREENV;
955         }
956     OUTPUT:
957         RETVAL
958
959 jint
960 CallIntMethod(obj,methodID,...)
961         JNIEnv *                env = FETCHENV;
962         jobject                 obj
963         jmethodID               methodID
964         char *                  sig = 0;
965         int                     argoff = $min_args;
966     CODE:
967         {
968             jvalue * args = makeargs(aTHX_ sig, &ST(argoff), items - argoff);
969             RETVAL = (*env)->CallIntMethodA(env, obj,methodID,args);
970             RESTOREENV;
971         }
972     OUTPUT:
973         RETVAL
974
975 jint
976 CallIntMethodA(obj,methodID,args)
977         JNIEnv *                env = FETCHENV;
978         jobject                 obj
979         jmethodID               methodID
980         char *                  sig = 0;
981         jvalue *                args
982     CODE:
983         {
984             RETVAL = (*env)->CallIntMethodA(env, obj,methodID,args);
985             RESTOREENV;
986         }
987     OUTPUT:
988         RETVAL
989
990 jlong
991 CallLongMethod(obj,methodID,...)
992         JNIEnv *                env = FETCHENV;
993         jobject                 obj
994         jmethodID               methodID
995         char *                  sig = 0;
996         int                     argoff = $min_args;
997     CODE:
998         {
999             jvalue * args = makeargs(aTHX_ sig, &ST(argoff), items - argoff);
1000             RETVAL = (*env)->CallLongMethodA(env, obj,methodID,args);
1001             RESTOREENV;
1002         }
1003     OUTPUT:
1004         RETVAL
1005
1006 jlong
1007 CallLongMethodA(obj,methodID,args)
1008         JNIEnv *                env = FETCHENV;
1009         jobject                 obj
1010         jmethodID               methodID
1011         char *                  sig = 0;
1012         jvalue *                args
1013     CODE:
1014         {
1015             RETVAL = (*env)->CallLongMethodA(env, obj,methodID,args);
1016             RESTOREENV;
1017         }
1018     OUTPUT:
1019         RETVAL
1020
1021 jfloat
1022 CallFloatMethod(obj,methodID,...)
1023         JNIEnv *                env = FETCHENV;
1024         jobject                 obj
1025         jmethodID               methodID
1026         char *                  sig = 0;
1027         int                     argoff = $min_args;
1028     CODE:
1029         {
1030             jvalue * args = makeargs(aTHX_ sig, &ST(argoff), items - argoff);
1031             RETVAL = (*env)->CallFloatMethodA(env, obj,methodID,args);
1032             RESTOREENV;
1033         }
1034     OUTPUT:
1035         RETVAL
1036
1037 jfloat
1038 CallFloatMethodA(obj,methodID,args)
1039         JNIEnv *                env = FETCHENV;
1040         jobject                 obj
1041         jmethodID               methodID
1042         char *                  sig = 0;
1043         jvalue *                args
1044     CODE:
1045         {
1046             RETVAL = (*env)->CallFloatMethodA(env, obj,methodID,args);
1047             RESTOREENV;
1048         }
1049     OUTPUT:
1050         RETVAL
1051
1052 jdouble
1053 CallDoubleMethod(obj,methodID,...)
1054         JNIEnv *                env = FETCHENV;
1055         jobject                 obj
1056         jmethodID               methodID
1057         char *                  sig = 0;
1058         int                     argoff = $min_args;
1059     CODE:
1060         {
1061             jvalue * args = makeargs(aTHX_ sig, &ST(argoff), items - argoff);
1062             RETVAL = (*env)->CallDoubleMethodA(env, obj,methodID,args);
1063             RESTOREENV;
1064         }
1065     OUTPUT:
1066         RETVAL
1067
1068 jdouble
1069 CallDoubleMethodA(obj,methodID,args)
1070         JNIEnv *                env = FETCHENV;
1071         jobject                 obj
1072         jmethodID               methodID
1073         char *                  sig = 0;
1074         jvalue *                args
1075     CODE:
1076         {
1077             RETVAL = (*env)->CallDoubleMethodA(env, obj,methodID,args);
1078             RESTOREENV;
1079         }
1080     OUTPUT:
1081         RETVAL
1082
1083 void
1084 CallVoidMethod(obj,methodID,...)
1085         JNIEnv *                env = FETCHENV;
1086         jobject                 obj
1087         jmethodID               methodID
1088         char *                  sig = 0;
1089         int                     argoff = $min_args;
1090     CODE:
1091         {
1092             jvalue * args = makeargs(aTHX_ sig, &ST(argoff), items - argoff);
1093             (*env)->CallVoidMethodA(env, obj,methodID,args);
1094             RESTOREENV;
1095         }
1096
1097 void
1098 CallVoidMethodA(obj,methodID,args)
1099         JNIEnv *                env = FETCHENV;
1100         jobject                 obj
1101         jmethodID               methodID
1102         char *                  sig = 0;
1103         jvalue *                args
1104     CODE:
1105         {
1106             (*env)->CallVoidMethodA(env, obj,methodID,args);
1107             RESTOREENV;
1108         }
1109
1110 jobject
1111 CallNonvirtualObjectMethod(obj,clazz,methodID,...)
1112         JNIEnv *                env = FETCHENV;
1113         jobject                 obj
1114         jclass                  clazz
1115         jmethodID               methodID
1116         char *                  sig = 0;
1117         int                     argoff = $min_args;
1118     CODE:
1119         {
1120             jvalue * args = makeargs(aTHX_ sig, &ST(argoff), items - argoff);
1121             RETVAL = (*env)->CallNonvirtualObjectMethodA(env, obj,clazz,methodID,args);
1122             RESTOREENV;
1123         }
1124     OUTPUT:
1125         RETVAL
1126
1127 jobject
1128 CallNonvirtualObjectMethodA(obj,clazz,methodID,args)
1129         JNIEnv *                env = FETCHENV;
1130         jobject                 obj
1131         jclass                  clazz
1132         jmethodID               methodID
1133         char *                  sig = 0;
1134         jvalue *                args
1135     CODE:
1136         {
1137             RETVAL = (*env)->CallNonvirtualObjectMethodA(env, obj,clazz,methodID,args);
1138             RESTOREENV;
1139         }
1140     OUTPUT:
1141         RETVAL
1142
1143 jboolean
1144 CallNonvirtualBooleanMethod(obj,clazz,methodID,...)
1145         JNIEnv *                env = FETCHENV;
1146         jobject                 obj
1147         jclass                  clazz
1148         jmethodID               methodID
1149         char *                  sig = 0;
1150         int                     argoff = $min_args;
1151     CODE:
1152         {
1153             jvalue * args = makeargs(aTHX_ sig, &ST(argoff), items - argoff);
1154             RETVAL = (*env)->CallNonvirtualBooleanMethodA(env, obj,clazz,methodID,args);
1155             RESTOREENV;
1156         }
1157     OUTPUT:
1158         RETVAL
1159
1160 jboolean
1161 CallNonvirtualBooleanMethodA(obj,clazz,methodID, args)
1162         JNIEnv *                env = FETCHENV;
1163         jobject                 obj
1164         jclass                  clazz
1165         jmethodID               methodID
1166         char *                  sig = 0;
1167         jvalue *                args
1168     CODE:
1169         {
1170             RETVAL = (*env)->CallNonvirtualBooleanMethodA(env, obj,clazz,methodID, args);
1171             RESTOREENV;
1172         }
1173     OUTPUT:
1174         RETVAL
1175
1176 jbyte
1177 CallNonvirtualByteMethod(obj,clazz,methodID,...)
1178         JNIEnv *                env = FETCHENV;
1179         jobject                 obj
1180         jclass                  clazz
1181         jmethodID               methodID
1182         char *                  sig = 0;
1183         int                     argoff = $min_args;
1184     CODE:
1185         {
1186             jvalue * args = makeargs(aTHX_ sig, &ST(argoff), items - argoff);
1187             RETVAL = (*env)->CallNonvirtualByteMethodA(env, obj,clazz,methodID,args);
1188             RESTOREENV;
1189         }
1190     OUTPUT:
1191         RETVAL
1192
1193 jbyte
1194 CallNonvirtualByteMethodA(obj,clazz,methodID,args)
1195         JNIEnv *                env = FETCHENV;
1196         jobject                 obj
1197         jclass                  clazz
1198         jmethodID               methodID
1199         char *                  sig = 0;
1200         jvalue *                args
1201     CODE:
1202         {
1203             RETVAL = (*env)->CallNonvirtualByteMethodA(env, obj,clazz,methodID,args);
1204             RESTOREENV;
1205         }
1206     OUTPUT:
1207         RETVAL
1208
1209 jchar
1210 CallNonvirtualCharMethod(obj,clazz,methodID,...)
1211         JNIEnv *                env = FETCHENV;
1212         jobject                 obj
1213         jclass                  clazz
1214         jmethodID               methodID
1215         char *                  sig = 0;
1216         int                     argoff = $min_args;
1217     CODE:
1218         {
1219             jvalue * args = makeargs(aTHX_ sig, &ST(argoff), items - argoff);
1220             RETVAL = (*env)->CallNonvirtualCharMethodA(env, obj,clazz,methodID,args);
1221             RESTOREENV;
1222         }
1223     OUTPUT:
1224         RETVAL
1225
1226 jchar
1227 CallNonvirtualCharMethodA(obj,clazz,methodID,args)
1228         JNIEnv *                env = FETCHENV;
1229         jobject                 obj
1230         jclass                  clazz
1231         jmethodID               methodID
1232         char *                  sig = 0;
1233         jvalue *                args
1234     CODE:
1235         {
1236             RETVAL = (*env)->CallNonvirtualCharMethodA(env, obj,clazz,methodID,args);
1237             RESTOREENV;
1238         }
1239     OUTPUT:
1240         RETVAL
1241
1242 jshort
1243 CallNonvirtualShortMethod(obj,clazz,methodID,...)
1244         JNIEnv *                env = FETCHENV;
1245         jobject                 obj
1246         jclass                  clazz
1247         jmethodID               methodID
1248         char *                  sig = 0;
1249         int                     argoff = $min_args;
1250     CODE:
1251         {
1252             jvalue * args = makeargs(aTHX_ sig, &ST(argoff), items - argoff);
1253             RETVAL = (*env)->CallNonvirtualShortMethodA(env, obj,clazz,methodID,args);
1254             RESTOREENV;
1255         }
1256     OUTPUT:
1257         RETVAL
1258
1259 jshort
1260 CallNonvirtualShortMethodA(obj,clazz,methodID,args)
1261         JNIEnv *                env = FETCHENV;
1262         jobject                 obj
1263         jclass                  clazz
1264         jmethodID               methodID
1265         char *                  sig = 0;
1266         jvalue *                args
1267     CODE:
1268         {
1269             RETVAL = (*env)->CallNonvirtualShortMethodA(env, obj,clazz,methodID,args);
1270             RESTOREENV;
1271         }
1272     OUTPUT:
1273         RETVAL
1274
1275 jint
1276 CallNonvirtualIntMethod(obj,clazz,methodID,...)
1277         JNIEnv *                env = FETCHENV;
1278         jobject                 obj
1279         jclass                  clazz
1280         jmethodID               methodID
1281         char *                  sig = 0;
1282         int                     argoff = $min_args;
1283     CODE:
1284         {
1285             jvalue * args = makeargs(aTHX_ sig, &ST(argoff), items - argoff);
1286             RETVAL = (*env)->CallNonvirtualIntMethodA(env, obj,clazz,methodID,args);
1287             RESTOREENV;
1288         }
1289     OUTPUT:
1290         RETVAL
1291
1292 jint
1293 CallNonvirtualIntMethodA(obj,clazz,methodID,args)
1294         JNIEnv *                env = FETCHENV;
1295         jobject                 obj
1296         jclass                  clazz
1297         jmethodID               methodID
1298         char *                  sig = 0;
1299         jvalue *                args
1300     CODE:
1301         {
1302             RETVAL = (*env)->CallNonvirtualIntMethodA(env, obj,clazz,methodID,args);
1303             RESTOREENV;
1304         }
1305     OUTPUT:
1306         RETVAL
1307
1308 jlong
1309 CallNonvirtualLongMethod(obj,clazz,methodID,...)
1310         JNIEnv *                env = FETCHENV;
1311         jobject                 obj
1312         jclass                  clazz
1313         jmethodID               methodID
1314         char *                  sig = 0;
1315         int                     argoff = $min_args;
1316     CODE:
1317         {
1318             jvalue * args = makeargs(aTHX_ sig, &ST(argoff), items - argoff);
1319             RETVAL = (*env)->CallNonvirtualLongMethodA(env, obj,clazz,methodID,args);
1320             RESTOREENV;
1321         }
1322     OUTPUT:
1323         RETVAL
1324
1325 jlong
1326 CallNonvirtualLongMethodA(obj,clazz,methodID,args)
1327         JNIEnv *                env = FETCHENV;
1328         jobject                 obj
1329         jclass                  clazz
1330         jmethodID               methodID
1331         char *                  sig = 0;
1332         jvalue *                args
1333     CODE:
1334         {
1335             RETVAL = (*env)->CallNonvirtualLongMethodA(env, obj,clazz,methodID,args);
1336             RESTOREENV;
1337         }
1338     OUTPUT:
1339         RETVAL
1340
1341 jfloat
1342 CallNonvirtualFloatMethod(obj,clazz,methodID,...)
1343         JNIEnv *                env = FETCHENV;
1344         jobject                 obj
1345         jclass                  clazz
1346         jmethodID               methodID
1347         char *                  sig = 0;
1348         int                     argoff = $min_args;
1349     CODE:
1350         {
1351             jvalue * args = makeargs(aTHX_ sig, &ST(argoff), items - argoff);
1352             RETVAL = (*env)->CallNonvirtualFloatMethodA(env, obj,clazz,methodID,args);
1353             RESTOREENV;
1354         }
1355     OUTPUT:
1356         RETVAL
1357
1358 jfloat
1359 CallNonvirtualFloatMethodA(obj,clazz,methodID,args)
1360         JNIEnv *                env = FETCHENV;
1361         jobject                 obj
1362         jclass                  clazz
1363         jmethodID               methodID
1364         char *                  sig = 0;
1365         jvalue *                args
1366     CODE:
1367         {
1368             RETVAL = (*env)->CallNonvirtualFloatMethodA(env, obj,clazz,methodID,args);
1369             RESTOREENV;
1370         }
1371     OUTPUT:
1372         RETVAL
1373
1374 jdouble
1375 CallNonvirtualDoubleMethod(obj,clazz,methodID,...)
1376         JNIEnv *                env = FETCHENV;
1377         jobject                 obj
1378         jclass                  clazz
1379         jmethodID               methodID
1380         char *                  sig = 0;
1381         int                     argoff = $min_args;
1382     CODE:
1383         {
1384             jvalue * args = makeargs(aTHX_ sig, &ST(argoff), items - argoff);
1385             RETVAL = (*env)->CallNonvirtualDoubleMethodA(env, obj,clazz,methodID,args);
1386             RESTOREENV;
1387         }
1388     OUTPUT:
1389         RETVAL
1390
1391 jdouble
1392 CallNonvirtualDoubleMethodA(obj,clazz,methodID,args)
1393         JNIEnv *                env = FETCHENV;
1394         jobject                 obj
1395         jclass                  clazz
1396         jmethodID               methodID
1397         char *                  sig = 0;
1398         jvalue *                args
1399     CODE:
1400         {
1401             RETVAL = (*env)->CallNonvirtualDoubleMethodA(env, obj,clazz,methodID,args);
1402             RESTOREENV;
1403         }
1404     OUTPUT:
1405         RETVAL
1406
1407 void
1408 CallNonvirtualVoidMethod(obj,clazz,methodID,...)
1409         JNIEnv *                env = FETCHENV;
1410         jobject                 obj
1411         jclass                  clazz
1412         jmethodID               methodID
1413         char *                  sig = 0;
1414         int                     argoff = $min_args;
1415     CODE:
1416         {
1417             jvalue * args = makeargs(aTHX_ sig, &ST(argoff), items - argoff);
1418             (*env)->CallNonvirtualVoidMethodA(env, obj,clazz,methodID,args);
1419             RESTOREENV;
1420         }
1421
1422 void
1423 CallNonvirtualVoidMethodA(obj,clazz,methodID,args)
1424         JNIEnv *                env = FETCHENV;
1425         jobject                 obj
1426         jclass                  clazz
1427         jmethodID               methodID
1428         char *                  sig = 0;
1429         jvalue *                args
1430     CODE:
1431         {
1432             (*env)->CallNonvirtualVoidMethodA(env, obj,clazz,methodID,args);
1433             RESTOREENV;
1434         }
1435
1436 jfieldID
1437 GetFieldID(clazz,name,sig)
1438         JNIEnv *                env = FETCHENV;
1439         jclass                  clazz
1440         const char *            name
1441         const char *            sig
1442     CODE:
1443         {
1444             RETVAL = (*env)->GetFieldID(env, clazz,name,sig);
1445             RESTOREENV;
1446         }
1447     OUTPUT:
1448         RETVAL
1449
1450 jobject
1451 GetObjectField(obj,fieldID)
1452         JNIEnv *                env = FETCHENV;
1453         jobject                 obj
1454         jfieldID                fieldID
1455         char *                  sig = 0;
1456     CODE:
1457         {
1458             RETVAL = (*env)->GetObjectField(env, obj,fieldID);
1459             RESTOREENV;
1460         }
1461     OUTPUT:
1462         RETVAL
1463
1464 jboolean
1465 GetBooleanField(obj,fieldID)
1466         JNIEnv *                env = FETCHENV;
1467         jobject                 obj
1468         jfieldID                fieldID
1469         char *                  sig = 0;
1470     CODE:
1471         {
1472             RETVAL = (*env)->GetBooleanField(env, obj,fieldID);
1473             RESTOREENV;
1474         }
1475     OUTPUT:
1476         RETVAL
1477
1478 jbyte
1479 GetByteField(obj,fieldID)
1480         JNIEnv *                env = FETCHENV;
1481         jobject                 obj
1482         jfieldID                fieldID
1483         char *                  sig = 0;
1484     CODE:
1485         {
1486             RETVAL = (*env)->GetByteField(env, obj,fieldID);
1487             RESTOREENV;
1488         }
1489     OUTPUT:
1490         RETVAL
1491
1492 jchar
1493 GetCharField(obj,fieldID)
1494         JNIEnv *                env = FETCHENV;
1495         jobject                 obj
1496         jfieldID                fieldID
1497         char *                  sig = 0;
1498     CODE:
1499         {
1500             RETVAL = (*env)->GetCharField(env, obj,fieldID);
1501             RESTOREENV;
1502         }
1503     OUTPUT:
1504         RETVAL
1505
1506 jshort
1507 GetShortField(obj,fieldID)
1508         JNIEnv *                env = FETCHENV;
1509         jobject                 obj
1510         jfieldID                fieldID
1511         char *                  sig = 0;
1512     CODE:
1513         {
1514             RETVAL = (*env)->GetShortField(env, obj,fieldID);
1515             RESTOREENV;
1516         }
1517     OUTPUT:
1518         RETVAL
1519
1520 jint
1521 GetIntField(obj,fieldID)
1522         JNIEnv *                env = FETCHENV;
1523         jobject                 obj
1524         jfieldID                fieldID
1525         char *                  sig = 0;
1526     CODE:
1527         {
1528             RETVAL = (*env)->GetIntField(env, obj,fieldID);
1529             RESTOREENV;
1530         }
1531     OUTPUT:
1532         RETVAL
1533
1534 jlong
1535 GetLongField(obj,fieldID)
1536         JNIEnv *                env = FETCHENV;
1537         jobject                 obj
1538         jfieldID                fieldID
1539         char *                  sig = 0;
1540     CODE:
1541         {
1542             RETVAL = (*env)->GetLongField(env, obj,fieldID);
1543             RESTOREENV;
1544         }
1545     OUTPUT:
1546         RETVAL
1547
1548 jfloat
1549 GetFloatField(obj,fieldID)
1550         JNIEnv *                env = FETCHENV;
1551         jobject                 obj
1552         jfieldID                fieldID
1553         char *                  sig = 0;
1554     CODE:
1555         {
1556             RETVAL = (*env)->GetFloatField(env, obj,fieldID);
1557             RESTOREENV;
1558         }
1559     OUTPUT:
1560         RETVAL
1561
1562 jdouble
1563 GetDoubleField(obj,fieldID)
1564         JNIEnv *                env = FETCHENV;
1565         jobject                 obj
1566         jfieldID                fieldID
1567         char *                  sig = 0;
1568     CODE:
1569         {
1570             RETVAL = (*env)->GetDoubleField(env, obj,fieldID);
1571             RESTOREENV;
1572         }
1573     OUTPUT:
1574         RETVAL
1575
1576 void
1577 SetObjectField(obj,fieldID,val)
1578         JNIEnv *                env = FETCHENV;
1579         jobject                 obj
1580         jfieldID                fieldID
1581         char *                  sig = 0;
1582         jobject                 val
1583     CODE:
1584         {
1585             (*env)->SetObjectField(env, obj,fieldID,val);
1586             RESTOREENV;
1587         }
1588
1589 void
1590 SetBooleanField(obj,fieldID,val)
1591         JNIEnv *                env = FETCHENV;
1592         jobject                 obj
1593         jfieldID                fieldID
1594         char *                  sig = 0;
1595         jboolean                val
1596     CODE:
1597         {
1598             (*env)->SetBooleanField(env, obj,fieldID,val);
1599             RESTOREENV;
1600         }
1601
1602 void
1603 SetByteField(obj,fieldID,val)
1604         JNIEnv *                env = FETCHENV;
1605         jobject                 obj
1606         jfieldID                fieldID
1607         char *                  sig = 0;
1608         jbyte                   val
1609     CODE:
1610         {
1611             (*env)->SetByteField(env, obj,fieldID,val);
1612             RESTOREENV;
1613         }
1614
1615 void
1616 SetCharField(obj,fieldID,val)
1617         JNIEnv *                env = FETCHENV;
1618         jobject                 obj
1619         jfieldID                fieldID
1620         char *                  sig = 0;
1621         jchar                   val
1622     CODE:
1623         {
1624             (*env)->SetCharField(env, obj,fieldID,val);
1625             RESTOREENV;
1626         }
1627
1628 void
1629 SetShortField(obj,fieldID,val)
1630         JNIEnv *                env = FETCHENV;
1631         jobject                 obj
1632         jfieldID                fieldID
1633         char *                  sig = 0;
1634         jshort                  val
1635     CODE:
1636         {
1637             (*env)->SetShortField(env, obj,fieldID,val);
1638             RESTOREENV;
1639         }
1640
1641 void
1642 SetIntField(obj,fieldID,val)
1643         JNIEnv *                env = FETCHENV;
1644         jobject                 obj
1645         jfieldID                fieldID
1646         char *                  sig = 0;
1647         jint                    val
1648     CODE:
1649         {
1650             (*env)->SetIntField(env, obj,fieldID,val);
1651             RESTOREENV;
1652         }
1653
1654 void
1655 SetLongField(obj,fieldID,val)
1656         JNIEnv *                env = FETCHENV;
1657         jobject                 obj
1658         jfieldID                fieldID
1659         char *                  sig = 0;
1660         jlong                   val
1661     CODE:
1662         {
1663             (*env)->SetLongField(env, obj,fieldID,val);
1664             RESTOREENV;
1665         }
1666
1667 void
1668 SetFloatField(obj,fieldID,val)
1669         JNIEnv *                env = FETCHENV;
1670         jobject                 obj
1671         jfieldID                fieldID
1672         char *                  sig = 0;
1673         jfloat                  val
1674     CODE:
1675         {
1676             (*env)->SetFloatField(env, obj,fieldID,val);
1677             RESTOREENV;
1678         }
1679
1680 void
1681 SetDoubleField(obj,fieldID,val)
1682         JNIEnv *                env = FETCHENV;
1683         jobject                 obj
1684         jfieldID                fieldID
1685         char *                  sig = 0;
1686         jdouble                 val
1687     CODE:
1688         {
1689             (*env)->SetDoubleField(env, obj,fieldID,val);
1690             RESTOREENV;
1691         }
1692
1693 jmethodID
1694 GetStaticMethodID(clazz,name,sig)
1695         JNIEnv *                env = FETCHENV;
1696         jclass                  clazz
1697         const char *            name
1698         const char *            sig
1699     CODE:
1700         {
1701             RETVAL = (*env)->GetStaticMethodID(env, clazz,name,sig);
1702             RESTOREENV;
1703         }
1704     OUTPUT:
1705         RETVAL
1706
1707 jobject
1708 CallStaticObjectMethod(clazz,methodID,...)
1709         JNIEnv *                env = FETCHENV;
1710         jclass                  clazz
1711         jmethodID               methodID
1712         char *                  sig = 0;
1713         int                     argoff = $min_args;
1714     CODE:
1715         {
1716             jvalue * args = makeargs(aTHX_ sig, &ST(argoff), items - argoff);
1717             RETVAL = (*env)->CallStaticObjectMethodA(env, clazz,methodID,args);
1718             RESTOREENV;
1719         }
1720     OUTPUT:
1721         RETVAL
1722
1723 jobject
1724 CallStaticObjectMethodA(clazz,methodID,args)
1725         JNIEnv *                env = FETCHENV;
1726         jclass                  clazz
1727         jmethodID               methodID
1728         char *                  sig = 0;
1729         jvalue *                args
1730     CODE:
1731         {
1732             RETVAL = (*env)->CallStaticObjectMethodA(env, clazz,methodID,args);
1733             RESTOREENV;
1734         }
1735     OUTPUT:
1736         RETVAL
1737
1738 jboolean
1739 CallStaticBooleanMethod(clazz,methodID,...)
1740         JNIEnv *                env = FETCHENV;
1741         jclass                  clazz
1742         jmethodID               methodID
1743         char *                  sig = 0;
1744         int                     argoff = $min_args;
1745     CODE:
1746         {
1747             jvalue * args = makeargs(aTHX_ sig, &ST(argoff), items - argoff);
1748             RETVAL = (*env)->CallStaticBooleanMethodA(env, clazz,methodID,args);
1749             RESTOREENV;
1750         }
1751     OUTPUT:
1752         RETVAL
1753
1754 jboolean
1755 CallStaticBooleanMethodA(clazz,methodID,args)
1756         JNIEnv *                env = FETCHENV;
1757         jclass                  clazz
1758         jmethodID               methodID
1759         char *                  sig = 0;
1760         jvalue *                args
1761     CODE:
1762         {
1763             RETVAL = (*env)->CallStaticBooleanMethodA(env, clazz,methodID,args);
1764             RESTOREENV;
1765         }
1766     OUTPUT:
1767         RETVAL
1768
1769 jbyte
1770 CallStaticByteMethod(clazz,methodID,...)
1771         JNIEnv *                env = FETCHENV;
1772         jclass                  clazz
1773         jmethodID               methodID
1774         char *                  sig = 0;
1775         int                     argoff = $min_args;
1776     CODE:
1777         {
1778             jvalue * args = makeargs(aTHX_ sig, &ST(argoff), items - argoff);
1779             RETVAL = (*env)->CallStaticByteMethodA(env, clazz,methodID,args);
1780             RESTOREENV;
1781         }
1782     OUTPUT:
1783         RETVAL
1784
1785 jbyte
1786 CallStaticByteMethodA(clazz,methodID,args)
1787         JNIEnv *                env = FETCHENV;
1788         jclass                  clazz
1789         jmethodID               methodID
1790         char *                  sig = 0;
1791         jvalue *                args
1792     CODE:
1793         {
1794             RETVAL = (*env)->CallStaticByteMethodA(env, clazz,methodID,args);
1795             RESTOREENV;
1796         }
1797     OUTPUT:
1798         RETVAL
1799
1800 jchar
1801 CallStaticCharMethod(clazz,methodID,...)
1802         JNIEnv *                env = FETCHENV;
1803         jclass                  clazz
1804         jmethodID               methodID
1805         char *                  sig = 0;
1806         int                     argoff = $min_args;
1807     CODE:
1808         {
1809             jvalue * args = makeargs(aTHX_ sig, &ST(argoff), items - argoff);
1810             RETVAL = (*env)->CallStaticCharMethodA(env, clazz,methodID,args);
1811             RESTOREENV;
1812         }
1813     OUTPUT:
1814         RETVAL
1815
1816 jchar
1817 CallStaticCharMethodA(clazz,methodID,args)
1818         JNIEnv *                env = FETCHENV;
1819         jclass                  clazz
1820         jmethodID               methodID
1821         char *                  sig = 0;
1822         jvalue *                args
1823     CODE:
1824         {
1825             RETVAL = (*env)->CallStaticCharMethodA(env, clazz,methodID,args);
1826             RESTOREENV;
1827         }
1828     OUTPUT:
1829         RETVAL
1830
1831 jshort
1832 CallStaticShortMethod(clazz,methodID,...)
1833         JNIEnv *                env = FETCHENV;
1834         jclass                  clazz
1835         jmethodID               methodID
1836         char *                  sig = 0;
1837         int                     argoff = $min_args;
1838     CODE:
1839         {
1840             jvalue * args = makeargs(aTHX_ sig, &ST(argoff), items - argoff);
1841             RETVAL = (*env)->CallStaticShortMethodA(env, clazz,methodID,args);
1842             RESTOREENV;
1843         }
1844     OUTPUT:
1845         RETVAL
1846
1847 jshort
1848 CallStaticShortMethodA(clazz,methodID,args)
1849         JNIEnv *                env = FETCHENV;
1850         jclass                  clazz
1851         jmethodID               methodID
1852         char *                  sig = 0;
1853         jvalue *                args
1854     CODE:
1855         {
1856             RETVAL = (*env)->CallStaticShortMethodA(env, clazz,methodID,args);
1857             RESTOREENV;
1858         }
1859     OUTPUT:
1860         RETVAL
1861
1862 jint
1863 CallStaticIntMethod(clazz,methodID,...)
1864         JNIEnv *                env = FETCHENV;
1865         jclass                  clazz
1866         jmethodID               methodID
1867         char *                  sig = 0;
1868         int                     argoff = $min_args;
1869     CODE:
1870         {
1871             jvalue * args = makeargs(aTHX_ sig, &ST(argoff), items - argoff);
1872             RETVAL = (*env)->CallStaticIntMethodA(env, clazz,methodID,args);
1873             RESTOREENV;
1874         }
1875     OUTPUT:
1876         RETVAL
1877
1878 jint
1879 CallStaticIntMethodA(clazz,methodID,args)
1880         JNIEnv *                env = FETCHENV;
1881         jclass                  clazz
1882         jmethodID               methodID
1883         char *                  sig = 0;
1884         jvalue *                args
1885     CODE:
1886         {
1887             RETVAL = (*env)->CallStaticIntMethodA(env, clazz,methodID,args);
1888             RESTOREENV;
1889         }
1890     OUTPUT:
1891         RETVAL
1892
1893 jlong
1894 CallStaticLongMethod(clazz,methodID,...)
1895         JNIEnv *                env = FETCHENV;
1896         jclass                  clazz
1897         jmethodID               methodID
1898         char *                  sig = 0;
1899         int                     argoff = $min_args;
1900     CODE:
1901         {
1902             jvalue * args = makeargs(aTHX_ sig, &ST(argoff), items - argoff);
1903             RETVAL = (*env)->CallStaticLongMethodA(env, clazz,methodID,args);
1904             RESTOREENV;
1905         }
1906     OUTPUT:
1907         RETVAL
1908
1909 jlong
1910 CallStaticLongMethodA(clazz,methodID,args)
1911         JNIEnv *                env = FETCHENV;
1912         jclass                  clazz
1913         jmethodID               methodID
1914         char *                  sig = 0;
1915         jvalue *                args
1916     CODE:
1917         {
1918             RETVAL = (*env)->CallStaticLongMethodA(env, clazz,methodID,args);
1919             RESTOREENV;
1920         }
1921     OUTPUT:
1922         RETVAL
1923
1924 jfloat
1925 CallStaticFloatMethod(clazz,methodID,...)
1926         JNIEnv *                env = FETCHENV;
1927         jclass                  clazz
1928         jmethodID               methodID
1929         char *                  sig = 0;
1930         int                     argoff = $min_args;
1931     CODE:
1932         {
1933             jvalue * args = makeargs(aTHX_ sig, &ST(argoff), items - argoff);
1934             RETVAL = (*env)->CallStaticFloatMethodA(env, clazz,methodID,args);
1935             RESTOREENV;
1936         }
1937     OUTPUT:
1938         RETVAL
1939
1940 jfloat
1941 CallStaticFloatMethodA(clazz,methodID,args)
1942         JNIEnv *                env = FETCHENV;
1943         jclass                  clazz
1944         jmethodID               methodID
1945         char *                  sig = 0;
1946         jvalue *                args
1947     CODE:
1948         {
1949             RETVAL = (*env)->CallStaticFloatMethodA(env, clazz,methodID,args);
1950             RESTOREENV;
1951         }
1952     OUTPUT:
1953         RETVAL
1954
1955 jdouble
1956 CallStaticDoubleMethod(clazz,methodID,...)
1957         JNIEnv *                env = FETCHENV;
1958         jclass                  clazz
1959         jmethodID               methodID
1960         char *                  sig = 0;
1961         int                     argoff = $min_args;
1962     CODE:
1963         {
1964             jvalue * args = makeargs(aTHX_ sig, &ST(argoff), items - argoff);
1965             RETVAL = (*env)->CallStaticDoubleMethodA(env, clazz,methodID,args);
1966             RESTOREENV;
1967         }
1968     OUTPUT:
1969         RETVAL
1970
1971 jdouble
1972 CallStaticDoubleMethodA(clazz,methodID,args)
1973         JNIEnv *                env = FETCHENV;
1974         jclass                  clazz
1975         jmethodID               methodID
1976         char *                  sig = 0;
1977         jvalue *                args
1978     CODE:
1979         {
1980             RETVAL = (*env)->CallStaticDoubleMethodA(env, clazz,methodID,args);
1981             RESTOREENV;
1982         }
1983     OUTPUT:
1984         RETVAL
1985
1986 void
1987 CallStaticVoidMethod(cls,methodID,...)
1988         JNIEnv *                env = FETCHENV;
1989         jclass                  cls
1990         jmethodID               methodID
1991         char *                  sig = 0;
1992         int                     argoff = $min_args;
1993     CODE:
1994         {
1995             jvalue * args = makeargs(aTHX_ sig, &ST(argoff), items - argoff);
1996             (*env)->CallStaticVoidMethodA(env, cls,methodID,args);
1997             RESTOREENV;
1998         }
1999
2000 void
2001 CallStaticVoidMethodA(cls,methodID,args)
2002         JNIEnv *                env = FETCHENV;
2003         jclass                  cls
2004         jmethodID               methodID
2005         char *                  sig = 0;
2006         jvalue *                args
2007     CODE:
2008         {
2009             (*env)->CallStaticVoidMethodA(env, cls,methodID,args);
2010             RESTOREENV;
2011         }
2012
2013 jfieldID
2014 GetStaticFieldID(clazz,name,sig)
2015         JNIEnv *                env = FETCHENV;
2016         jclass                  clazz
2017         const char *            name
2018         const char *            sig
2019     CODE:
2020         {
2021             RETVAL = (*env)->GetStaticFieldID(env, clazz,name,sig);
2022             RESTOREENV;
2023         }
2024     OUTPUT:
2025         RETVAL
2026
2027 jobject
2028 GetStaticObjectField(clazz,fieldID)
2029         JNIEnv *                env = FETCHENV;
2030         jclass                  clazz
2031         jfieldID                fieldID
2032         char *                  sig = 0;
2033     CODE:
2034         {
2035             RETVAL = (*env)->GetStaticObjectField(env, clazz,fieldID);
2036             RESTOREENV;
2037         }
2038     OUTPUT:
2039         RETVAL
2040
2041 jboolean
2042 GetStaticBooleanField(clazz,fieldID)
2043         JNIEnv *                env = FETCHENV;
2044         jclass                  clazz
2045         jfieldID                fieldID
2046         char *                  sig = 0;
2047     CODE:
2048         {
2049             RETVAL = (*env)->GetStaticBooleanField(env, clazz,fieldID);
2050             RESTOREENV;
2051         }
2052     OUTPUT:
2053         RETVAL
2054
2055 jbyte
2056 GetStaticByteField(clazz,fieldID)
2057         JNIEnv *                env = FETCHENV;
2058         jclass                  clazz
2059         jfieldID                fieldID
2060         char *                  sig = 0;
2061     CODE:
2062         {
2063             RETVAL = (*env)->GetStaticByteField(env, clazz,fieldID);
2064             RESTOREENV;
2065         }
2066     OUTPUT:
2067         RETVAL
2068
2069 jchar
2070 GetStaticCharField(clazz,fieldID)
2071         JNIEnv *                env = FETCHENV;
2072         jclass                  clazz
2073         jfieldID                fieldID
2074         char *                  sig = 0;
2075     CODE:
2076         {
2077             RETVAL = (*env)->GetStaticCharField(env, clazz,fieldID);
2078             RESTOREENV;
2079         }
2080     OUTPUT:
2081         RETVAL
2082
2083 jshort
2084 GetStaticShortField(clazz,fieldID)
2085         JNIEnv *                env = FETCHENV;
2086         jclass                  clazz
2087         jfieldID                fieldID
2088         char *                  sig = 0;
2089     CODE:
2090         {
2091             RETVAL = (*env)->GetStaticShortField(env, clazz,fieldID);
2092             RESTOREENV;
2093         }
2094     OUTPUT:
2095         RETVAL
2096
2097 jint
2098 GetStaticIntField(clazz,fieldID)
2099         JNIEnv *                env = FETCHENV;
2100         jclass                  clazz
2101         jfieldID                fieldID
2102         char *                  sig = 0;
2103     CODE:
2104         {
2105             RETVAL = (*env)->GetStaticIntField(env, clazz,fieldID);
2106             RESTOREENV;
2107         }
2108     OUTPUT:
2109         RETVAL
2110
2111 jlong
2112 GetStaticLongField(clazz,fieldID)
2113         JNIEnv *                env = FETCHENV;
2114         jclass                  clazz
2115         jfieldID                fieldID
2116         char *                  sig = 0;
2117     CODE:
2118         {
2119             RETVAL = (*env)->GetStaticLongField(env, clazz,fieldID);
2120             RESTOREENV;
2121         }
2122     OUTPUT:
2123         RETVAL
2124
2125 jfloat
2126 GetStaticFloatField(clazz,fieldID)
2127         JNIEnv *                env = FETCHENV;
2128         jclass                  clazz
2129         jfieldID                fieldID
2130         char *                  sig = 0;
2131     CODE:
2132         {
2133             RETVAL = (*env)->GetStaticFloatField(env, clazz,fieldID);
2134             RESTOREENV;
2135         }
2136     OUTPUT:
2137         RETVAL
2138
2139 jdouble
2140 GetStaticDoubleField(clazz,fieldID)
2141         JNIEnv *                env = FETCHENV;
2142         jclass                  clazz
2143         jfieldID                fieldID
2144         char *                  sig = 0;
2145     CODE:
2146         {
2147             RETVAL = (*env)->GetStaticDoubleField(env, clazz,fieldID);
2148             RESTOREENV;
2149         }
2150     OUTPUT:
2151         RETVAL
2152
2153 void
2154 SetStaticObjectField(clazz,fieldID,value)
2155         JNIEnv *                env = FETCHENV;
2156         jclass                  clazz
2157         jfieldID                fieldID
2158         char *                  sig = 0;
2159         jobject                 value
2160     CODE:
2161         {
2162           (*env)->SetStaticObjectField(env, clazz,fieldID,value);
2163             RESTOREENV;
2164         }
2165
2166 void
2167 SetStaticBooleanField(clazz,fieldID,value)
2168         JNIEnv *                env = FETCHENV;
2169         jclass                  clazz
2170         jfieldID                fieldID
2171         char *                  sig = 0;
2172         jboolean                value
2173     CODE:
2174         {
2175           (*env)->SetStaticBooleanField(env, clazz,fieldID,value);
2176             RESTOREENV;
2177         }
2178
2179 void
2180 SetStaticByteField(clazz,fieldID,value)
2181         JNIEnv *                env = FETCHENV;
2182         jclass                  clazz
2183         jfieldID                fieldID
2184         char *                  sig = 0;
2185         jbyte                   value
2186     CODE:
2187         {
2188           (*env)->SetStaticByteField(env, clazz,fieldID,value);
2189             RESTOREENV;
2190         }
2191
2192 void
2193 SetStaticCharField(clazz,fieldID,value)
2194         JNIEnv *                env = FETCHENV;
2195         jclass                  clazz
2196         jfieldID                fieldID
2197         char *                  sig = 0;
2198         jchar                   value
2199     CODE:
2200         {
2201           (*env)->SetStaticCharField(env, clazz,fieldID,value);
2202             RESTOREENV;
2203         }
2204
2205 void
2206 SetStaticShortField(clazz,fieldID,value)
2207         JNIEnv *                env = FETCHENV;
2208         jclass                  clazz
2209         jfieldID                fieldID
2210         char *                  sig = 0;
2211         jshort                  value
2212     CODE:
2213         {
2214           (*env)->SetStaticShortField(env, clazz,fieldID,value);
2215             RESTOREENV;
2216         }
2217
2218 void
2219 SetStaticIntField(clazz,fieldID,value)
2220         JNIEnv *                env = FETCHENV;
2221         jclass                  clazz
2222         jfieldID                fieldID
2223         char *                  sig = 0;
2224         jint                    value
2225     CODE:
2226         {
2227           (*env)->SetStaticIntField(env, clazz,fieldID,value);
2228             RESTOREENV;
2229         }
2230
2231 void
2232 SetStaticLongField(clazz,fieldID,value)
2233         JNIEnv *                env = FETCHENV;
2234         jclass                  clazz
2235         jfieldID                fieldID
2236         char *                  sig = 0;
2237         jlong                   value
2238     CODE:
2239         {
2240           (*env)->SetStaticLongField(env, clazz,fieldID,value);
2241             RESTOREENV;
2242         }
2243
2244 void
2245 SetStaticFloatField(clazz,fieldID,value)
2246         JNIEnv *                env = FETCHENV;
2247         jclass                  clazz
2248         jfieldID                fieldID
2249         char *                  sig = 0;
2250         jfloat                  value
2251     CODE:
2252         {
2253           (*env)->SetStaticFloatField(env, clazz,fieldID,value);
2254             RESTOREENV;
2255         }
2256
2257 void
2258 SetStaticDoubleField(clazz,fieldID,value)
2259         JNIEnv *                env = FETCHENV;
2260         jclass                  clazz
2261         jfieldID                fieldID
2262         char *                  sig = 0;
2263         jdouble                 value
2264     CODE:
2265         {
2266           (*env)->SetStaticDoubleField(env, clazz,fieldID,value);
2267             RESTOREENV;
2268         }
2269
2270 jstring
2271 NewString(unicode)
2272         JNIEnv *                env = FETCHENV;
2273         STRLEN                  tmplen = NO_INIT;
2274         jsize                   unicode_len_ = NO_INIT;
2275         const jchar *           unicode
2276     CODE:
2277         {
2278             RETVAL = (*env)->NewString(env, unicode, unicode_len_);
2279             RESTOREENV;
2280         }
2281     OUTPUT:
2282         RETVAL
2283
2284 jsize
2285 GetStringLength(str)
2286         JNIEnv *                env = FETCHENV;
2287         jstring                 str
2288     CODE:
2289         {
2290             RETVAL = (*env)->GetStringLength(env, str);
2291             RESTOREENV;
2292         }
2293     OUTPUT:
2294         RETVAL
2295
2296 const jchar *
2297 GetStringChars(str)
2298         JNIEnv *                env = FETCHENV;
2299         jstring                 str
2300         jboolean                isCopy = NO_INIT;
2301         jsize                   RETVAL_len_ = NO_INIT;
2302     CODE:
2303         {
2304             RETVAL = (*env)->GetStringChars(env, str,&isCopy);
2305             RETVAL_len_ = (*env)->GetStringLength(env, str);
2306             RESTOREENV;
2307         }
2308     OUTPUT:
2309         RETVAL
2310     CLEANUP:
2311             (*env)->ReleaseStringChars(env, str,RETVAL);
2312
2313 jstring
2314 NewStringUTF(utf)
2315         JNIEnv *                env = FETCHENV;
2316         const char *            utf
2317     CODE:
2318         {
2319             RETVAL = (*env)->NewStringUTF(env, utf);
2320             RESTOREENV;
2321         }
2322     OUTPUT:
2323         RETVAL
2324
2325 jsize
2326 GetStringUTFLength(str)
2327         JNIEnv *                env = FETCHENV;
2328         jstring                 str
2329     CODE:
2330         {
2331             RETVAL = (*env)->GetStringUTFLength(env, str);
2332             RESTOREENV;
2333         }
2334     OUTPUT:
2335         RETVAL
2336
2337 const char *
2338 GetStringUTFChars(str)
2339         JNIEnv *                env = FETCHENV;
2340         jstring                 str
2341         jboolean                isCopy = NO_INIT;
2342     CODE:
2343         {
2344             RETVAL = (*env)->GetStringUTFChars(env, str,&isCopy);
2345             RESTOREENV;
2346         }
2347     OUTPUT:
2348         RETVAL
2349     CLEANUP:
2350         (*env)->ReleaseStringUTFChars(env, str, RETVAL);
2351
2352
2353 jsize
2354 GetArrayLength(array)
2355         JNIEnv *                env = FETCHENV;
2356         jarray                  array
2357     CODE:
2358         {
2359             RETVAL = (*env)->GetArrayLength(env, array);
2360             RESTOREENV;
2361         }
2362     OUTPUT:
2363         RETVAL
2364
2365 jobjectArray
2366 NewObjectArray(len,clazz,init)
2367         JNIEnv *                env = FETCHENV;
2368         jsize                   len
2369         jclass                  clazz
2370         jobject                 init
2371     CODE:
2372         {
2373             RETVAL = (*env)->NewObjectArray(env, len,clazz,init);
2374             RESTOREENV;
2375         }
2376     OUTPUT:
2377         RETVAL
2378
2379 jobject
2380 GetObjectArrayElement(array,index)
2381         JNIEnv *                env = FETCHENV;
2382         jobjectArray            array
2383         jsize                   index
2384     CODE:
2385         {
2386             RETVAL = (*env)->GetObjectArrayElement(env, array,index);
2387             RESTOREENV;
2388         }
2389     OUTPUT:
2390         RETVAL
2391
2392 void
2393 SetObjectArrayElement(array,index,val)
2394         JNIEnv *                env = FETCHENV;
2395         jobjectArray            array
2396         jsize                   index
2397         jobject                 val
2398     CODE:
2399         {
2400             (*env)->SetObjectArrayElement(env, array,index,val);
2401             RESTOREENV;
2402         }
2403
2404 jbooleanArray
2405 NewBooleanArray(len)
2406         JNIEnv *                env = FETCHENV;
2407         jsize                   len
2408     CODE:
2409         {
2410             RETVAL = (*env)->NewBooleanArray(env, len);
2411             RESTOREENV;
2412         }
2413     OUTPUT:
2414         RETVAL
2415
2416 jbyteArray
2417 NewByteArray(len)
2418         JNIEnv *                env = FETCHENV;
2419         jsize                   len
2420     CODE:
2421         {
2422             RETVAL = (*env)->NewByteArray(env, len);
2423             RESTOREENV;
2424         }
2425     OUTPUT:
2426         RETVAL
2427
2428 jcharArray
2429 NewCharArray(len)
2430         JNIEnv *                env = FETCHENV;
2431         jsize                   len
2432     CODE:
2433         {
2434             RETVAL = (*env)->NewCharArray(env, len);
2435             RESTOREENV;
2436         }
2437     OUTPUT:
2438         RETVAL
2439
2440 jshortArray
2441 NewShortArray(len)
2442         JNIEnv *                env = FETCHENV;
2443         jsize                   len
2444     CODE:
2445         {
2446             RETVAL = (*env)->NewShortArray(env, len);
2447             RESTOREENV;
2448         }
2449     OUTPUT:
2450         RETVAL
2451
2452 jintArray
2453 NewIntArray(len)
2454         JNIEnv *                env = FETCHENV;
2455         jsize                   len
2456     CODE:
2457         {
2458             RETVAL = (*env)->NewIntArray(env, len);
2459             RESTOREENV;
2460         }
2461     OUTPUT:
2462         RETVAL
2463
2464 jlongArray
2465 NewLongArray(len)
2466         JNIEnv *                env = FETCHENV;
2467         jsize                   len
2468     CODE:
2469         {
2470             RETVAL = (*env)->NewLongArray(env, len);
2471             RESTOREENV;
2472         }
2473     OUTPUT:
2474         RETVAL
2475
2476 jfloatArray
2477 NewFloatArray(len)
2478         JNIEnv *                env = FETCHENV;
2479         jsize                   len
2480     CODE:
2481         {
2482             RETVAL = (*env)->NewFloatArray(env, len);
2483             RESTOREENV;
2484         }
2485     OUTPUT:
2486         RETVAL
2487
2488 jdoubleArray
2489 NewDoubleArray(len)
2490         JNIEnv *                env = FETCHENV;
2491         jsize                   len
2492     CODE:
2493         {
2494             RETVAL = (*env)->NewDoubleArray(env, len);
2495             RESTOREENV;
2496         }
2497     OUTPUT:
2498         RETVAL
2499
2500 jboolean *
2501 GetBooleanArrayElements(array)
2502         JNIEnv *                env = FETCHENV;
2503         jsize                   RETVAL_len_ = NO_INIT;
2504         jbooleanArray           array
2505         jboolean                isCopy = NO_INIT;
2506     PPCODE:
2507         {
2508             RETVAL = (*env)->GetBooleanArrayElements(env, array,&isCopy);
2509             RETVAL_len_ = (*env)->GetArrayLength(env, array);
2510             if (GIMME == G_ARRAY) {
2511                 int i;
2512                 jboolean* r = RETVAL;
2513                 EXTEND(sp, RETVAL_len_);
2514                 for (i = RETVAL_len_; i; --i) {
2515                     PUSHs(sv_2mortal(newSViv(*r++)));
2516                 }
2517             }
2518             else {
2519                 if (RETVAL_len_) {
2520                     PUSHs(sv_2mortal(newSVpvn((char*)RETVAL,
2521                         (STRLEN)RETVAL_len_ * sizeof(jboolean))));
2522                 }
2523                 else
2524                     PUSHs(&PL_sv_no);
2525             }
2526             (*env)->ReleaseBooleanArrayElements(env, array,RETVAL,JNI_ABORT);
2527             RESTOREENV;
2528         }
2529
2530 jbyte *
2531 GetByteArrayElements(array)
2532         JNIEnv *                env = FETCHENV;
2533         jsize                   RETVAL_len_ = NO_INIT;
2534         jbyteArray              array
2535         jboolean                isCopy = NO_INIT;
2536     PPCODE:
2537         {
2538             RETVAL = (*env)->GetByteArrayElements(env, array,&isCopy);
2539             RETVAL_len_ = (*env)->GetArrayLength(env, array);
2540             if (GIMME == G_ARRAY) {
2541                 int i;
2542                 jbyte* r = RETVAL;
2543                 EXTEND(sp, RETVAL_len_);
2544                 for (i = RETVAL_len_; i; --i) {
2545                     PUSHs(sv_2mortal(newSViv(*r++)));
2546                 }
2547             }
2548             else {
2549                 if (RETVAL_len_) {
2550                     PUSHs(sv_2mortal(newSVpvn((char*)RETVAL,
2551                         (STRLEN)RETVAL_len_ * sizeof(jbyte))));
2552                 }
2553                 else
2554                     PUSHs(&PL_sv_no);
2555             }
2556             (*env)->ReleaseByteArrayElements(env, array,RETVAL,JNI_ABORT);
2557             RESTOREENV;
2558         }
2559
2560 jchar *
2561 GetCharArrayElements(array)
2562         JNIEnv *                env = FETCHENV;
2563         jsize                   RETVAL_len_ = NO_INIT;
2564         jcharArray              array
2565         jboolean                isCopy = NO_INIT;
2566     PPCODE:
2567         {
2568             RETVAL = (*env)->GetCharArrayElements(env, array,&isCopy);
2569             RETVAL_len_ = (*env)->GetArrayLength(env, array);
2570             if (GIMME == G_ARRAY) {
2571                 int i;
2572                 jchar* r = RETVAL;
2573                 EXTEND(sp, RETVAL_len_);
2574                 for (i = RETVAL_len_; i; --i) {
2575                     PUSHs(sv_2mortal(newSViv(*r++)));
2576                 }
2577             }
2578             else {
2579                 if (RETVAL_len_) {
2580                     PUSHs(sv_2mortal(newSVpvn((char*)RETVAL,
2581                         (STRLEN)RETVAL_len_ * sizeof(jchar))));
2582                 }
2583                 else
2584                     PUSHs(&PL_sv_no);
2585             }
2586             (*env)->ReleaseCharArrayElements(env, array,RETVAL,JNI_ABORT);
2587             RESTOREENV;
2588         }
2589
2590 jshort *
2591 GetShortArrayElements(array)
2592         JNIEnv *                env = FETCHENV;
2593         jsize                   RETVAL_len_ = NO_INIT;
2594         jshortArray             array
2595         jboolean                isCopy = NO_INIT;
2596     PPCODE:
2597         {
2598             RETVAL = (*env)->GetShortArrayElements(env, array,&isCopy);
2599             RETVAL_len_ = (*env)->GetArrayLength(env, array);
2600             if (GIMME == G_ARRAY) {
2601                 int i;
2602                 jshort* r = RETVAL;
2603                 EXTEND(sp, RETVAL_len_);
2604                 for (i = RETVAL_len_; i; --i) {
2605                     PUSHs(sv_2mortal(newSViv(*r++)));
2606                 }
2607             }
2608             else {
2609                 if (RETVAL_len_) {
2610                     PUSHs(sv_2mortal(newSVpvn((char*)RETVAL,
2611                         (STRLEN)RETVAL_len_ * sizeof(jshort))));
2612                 }
2613                 else
2614                     PUSHs(&PL_sv_no);
2615             }
2616             (*env)->ReleaseShortArrayElements(env, array,RETVAL,JNI_ABORT);
2617             RESTOREENV;
2618         }
2619
2620 jint *
2621 GetIntArrayElements(array)
2622         JNIEnv *                env = FETCHENV;
2623         jsize                   RETVAL_len_ = NO_INIT;
2624         jintArray               array
2625         jboolean                isCopy = NO_INIT;
2626     PPCODE:
2627         {
2628             RETVAL = (*env)->GetIntArrayElements(env, array,&isCopy);
2629             RETVAL_len_ = (*env)->GetArrayLength(env, array);
2630             if (GIMME == G_ARRAY) {
2631                 int i;
2632                 jint* r = RETVAL;
2633                 EXTEND(sp, RETVAL_len_);
2634                 for (i = RETVAL_len_; i; --i) {
2635                     PUSHs(sv_2mortal(newSViv(*r++)));
2636                 }
2637             }
2638             else {
2639                 if (RETVAL_len_) {
2640                     PUSHs(sv_2mortal(newSVpvn((char*)RETVAL,
2641                         (STRLEN)RETVAL_len_ * sizeof(jint))));
2642                 }
2643                 else
2644                     PUSHs(&PL_sv_no);
2645             }
2646             (*env)->ReleaseIntArrayElements(env, array,RETVAL,JNI_ABORT);
2647             RESTOREENV;
2648         }
2649
2650 jlong *
2651 GetLongArrayElements(array)
2652         JNIEnv *                env = FETCHENV;
2653         jsize                   RETVAL_len_ = NO_INIT;
2654         jlongArray              array
2655         jboolean                isCopy = NO_INIT;
2656     PPCODE:
2657         {
2658             RETVAL = (*env)->GetLongArrayElements(env, array,&isCopy);
2659             RETVAL_len_ = (*env)->GetArrayLength(env, array);
2660             if (GIMME == G_ARRAY) {
2661                 int i;
2662                 jlong* r = RETVAL;
2663                 EXTEND(sp, RETVAL_len_);
2664                 for (i = RETVAL_len_; i; --i) {
2665                     PUSHs(sv_2mortal(newSViv(*r++)));
2666                 }
2667             }
2668             else {
2669                 if (RETVAL_len_) {
2670                     PUSHs(sv_2mortal(newSVpvn((char*)RETVAL,
2671                         (STRLEN)RETVAL_len_ * sizeof(jlong))));
2672                 }
2673                 else
2674                     PUSHs(&PL_sv_no);
2675             }
2676             (*env)->ReleaseLongArrayElements(env, array,RETVAL,JNI_ABORT);
2677             RESTOREENV;
2678         }
2679
2680 jfloat *
2681 GetFloatArrayElements(array)
2682         JNIEnv *                env = FETCHENV;
2683         jsize                   RETVAL_len_ = NO_INIT;
2684         jfloatArray             array
2685         jboolean                isCopy = NO_INIT;
2686     PPCODE:
2687         {
2688             RETVAL = (*env)->GetFloatArrayElements(env, array,&isCopy);
2689             RETVAL_len_ = (*env)->GetArrayLength(env, array);
2690             if (GIMME == G_ARRAY) {
2691                 int i;
2692                 jfloat* r = RETVAL;
2693                 EXTEND(sp, RETVAL_len_);
2694                 for (i = RETVAL_len_; i; --i) {
2695                     PUSHs(sv_2mortal(newSVnv(*r++)));
2696                 }
2697             }
2698             else {
2699                 if (RETVAL_len_) {
2700                     PUSHs(sv_2mortal(newSVpvn((char*)RETVAL,
2701                         (STRLEN)RETVAL_len_ * sizeof(jfloat))));
2702                 }
2703                 else
2704                     PUSHs(&PL_sv_no);
2705             }
2706             (*env)->ReleaseFloatArrayElements(env, array,RETVAL,JNI_ABORT);
2707             RESTOREENV;
2708         }
2709
2710 jdouble *
2711 GetDoubleArrayElements(array)
2712         JNIEnv *                env = FETCHENV;
2713         jsize                   RETVAL_len_ = NO_INIT;
2714         jdoubleArray            array
2715         jboolean                isCopy = NO_INIT;
2716     PPCODE:
2717         {
2718             RETVAL = (*env)->GetDoubleArrayElements(env, array,&isCopy);
2719             RETVAL_len_ = (*env)->GetArrayLength(env, array);
2720             if (GIMME == G_ARRAY) {
2721                 int i;
2722                 jdouble* r = RETVAL;
2723                 EXTEND(sp, RETVAL_len_);
2724                 for (i = RETVAL_len_; i; --i) {
2725                     PUSHs(sv_2mortal(newSVnv(*r++)));
2726                 }
2727             }
2728             else {
2729                 if (RETVAL_len_) {
2730                     PUSHs(sv_2mortal(newSVpvn((char*)RETVAL,
2731                         (STRLEN)RETVAL_len_ * sizeof(jdouble))));
2732                 }
2733                 else
2734                     PUSHs(&PL_sv_no);
2735             }
2736             (*env)->ReleaseDoubleArrayElements(env, array,RETVAL,JNI_ABORT);
2737             RESTOREENV;
2738         }
2739
2740 void
2741 GetBooleanArrayRegion(array,start,len,buf)
2742         JNIEnv *                env = FETCHENV;
2743         jbooleanArray           array
2744         jsize                   start
2745         jsize                   len
2746         STRLEN                  tmplen = len * sizeof(jboolean) + 1;
2747         char *                  tmpbuf = (char*)sv_pvn_force(ST(3), &tmplen);
2748         jboolean *              buf = (jboolean*)sv_grow(ST(3),len * sizeof(jboolean)+1);
2749     CODE:
2750         {
2751             (*env)->GetBooleanArrayRegion(env, array,start,len,buf);
2752             SvCUR_set(ST(3), len * sizeof(jboolean));
2753             *SvEND(ST(3)) = '\0';
2754             RESTOREENV;
2755         }
2756
2757 void
2758 GetByteArrayRegion(array,start,len,buf)
2759         JNIEnv *                env = FETCHENV;
2760         jbyteArray              array
2761         jsize                   start
2762         jsize                   len
2763         STRLEN                  tmplen = len * sizeof(jboolean) + 1;
2764         char *                  tmpbuf = (char*)sv_pvn_force(ST(3), &tmplen);
2765         jbyte *                 buf = (jbyte*)sv_grow(ST(3),len * sizeof(jbyte)+1);
2766     CODE:
2767         {
2768             (*env)->GetByteArrayRegion(env, array,start,len,buf);
2769             SvCUR_set(ST(3), len * sizeof(jbyte));
2770             *SvEND(ST(3)) = '\0';
2771             RESTOREENV;
2772         }
2773
2774 void
2775 GetCharArrayRegion(array,start,len,buf)
2776         JNIEnv *                env = FETCHENV;
2777         jcharArray              array
2778         jsize                   start
2779         jsize                   len
2780         STRLEN                  tmplen = len * sizeof(jboolean) + 1;
2781         char *                  tmpbuf = (char*)sv_pvn_force(ST(3), &tmplen);
2782         jchar *                 buf = (jchar*)sv_grow(ST(3),len * sizeof(jchar)+1);
2783     CODE:
2784         {
2785             (*env)->GetCharArrayRegion(env, array,start,len,buf);
2786             SvCUR_set(ST(3), len * sizeof(jchar));
2787             *SvEND(ST(3)) = '\0';
2788             RESTOREENV;
2789         }
2790
2791 void
2792 GetShortArrayRegion(array,start,len,buf)
2793         JNIEnv *                env = FETCHENV;
2794         jshortArray             array
2795         jsize                   start
2796         jsize                   len
2797         STRLEN                  tmplen = len * sizeof(jboolean) + 1;
2798         char *                  tmpbuf = (char*)sv_pvn_force(ST(3), &tmplen);
2799         jshort *                buf = (jshort*)sv_grow(ST(3),len * sizeof(jshort)+1);
2800     CODE:
2801         {
2802             (*env)->GetShortArrayRegion(env, array,start,len,buf);
2803             SvCUR_set(ST(3), len * sizeof(jshort));
2804             *SvEND(ST(3)) = '\0';
2805             RESTOREENV;
2806         }
2807
2808 void
2809 GetIntArrayRegion(array,start,len,buf)
2810         JNIEnv *                env = FETCHENV;
2811         jintArray               array
2812         jsize                   start
2813         jsize                   len
2814         STRLEN                  tmplen = len * sizeof(jboolean) + 1;
2815         char *                  tmpbuf = (char*)sv_pvn_force(ST(3), &tmplen);
2816         jint *                  buf = (jint*)sv_grow(ST(3),len * sizeof(jint)+1);
2817     CODE:
2818         {
2819             (*env)->GetIntArrayRegion(env, array,start,len,buf);
2820             SvCUR_set(ST(3), len * sizeof(jint));
2821             *SvEND(ST(3)) = '\0';
2822             RESTOREENV;
2823         }
2824
2825 void
2826 GetLongArrayRegion(array,start,len,buf)
2827         JNIEnv *                env = FETCHENV;
2828         jlongArray              array
2829         jsize                   start
2830         jsize                   len
2831         STRLEN                  tmplen = len * sizeof(jboolean) + 1;
2832         char *                  tmpbuf = (char*)sv_pvn_force(ST(3), &tmplen);
2833         jlong *                 buf = (jlong*)sv_grow(ST(3),len * sizeof(jlong)+1);
2834     CODE:
2835         {
2836             (*env)->GetLongArrayRegion(env, array,start,len,buf);
2837             SvCUR_set(ST(3), len * sizeof(jlong));
2838             *SvEND(ST(3)) = '\0';
2839             RESTOREENV;
2840         }
2841
2842 void
2843 GetFloatArrayRegion(array,start,len,buf)
2844         JNIEnv *                env = FETCHENV;
2845         jfloatArray             array
2846         jsize                   start
2847         jsize                   len
2848         STRLEN                  tmplen = len * sizeof(jboolean) + 1;
2849         char *                  tmpbuf = (char*)sv_pvn_force(ST(3), &tmplen);
2850         jfloat *                buf = (jfloat*)sv_grow(ST(3),len * sizeof(jfloat)+1);
2851     CODE:
2852         {
2853             (*env)->GetFloatArrayRegion(env, array,start,len,buf);
2854             SvCUR_set(ST(3), len * sizeof(jfloat));
2855             *SvEND(ST(3)) = '\0';
2856             RESTOREENV;
2857         }
2858
2859 void
2860 GetDoubleArrayRegion(array,start,len,buf)
2861         JNIEnv *                env = FETCHENV;
2862         jdoubleArray            array
2863         jsize                   start
2864         jsize                   len
2865         STRLEN                  tmplen = len * sizeof(jboolean) + 1;
2866         char *                  tmpbuf = (char*)sv_pvn_force(ST(3), &tmplen);
2867         jdouble *               buf = (jdouble*)sv_grow(ST(3),len * sizeof(jdouble)+1);
2868     CODE:
2869         {
2870             (*env)->GetDoubleArrayRegion(env, array,start,len,buf);
2871             SvCUR_set(ST(3), len * sizeof(jdouble));
2872             *SvEND(ST(3)) = '\0';
2873             RESTOREENV;
2874         }
2875
2876 void
2877 SetBooleanArrayRegion(array,start,len,buf)
2878         JNIEnv *                env = FETCHENV;
2879         STRLEN                  tmplen = NO_INIT;
2880         jbooleanArray           array
2881         jsize                   start
2882         jsize                   len
2883         jsize                   buf_len_ = NO_INIT;
2884         jboolean *              buf
2885     CODE:
2886         {
2887             if (buf_len_ < len)
2888                 Perl_croak(aTHX_ "string is too short");
2889             else if (buf_len_ > len && ckWARN(WARN_UNSAFE))
2890                 Perl_warner(aTHX_ WARN_UNSAFE, "string is too long");
2891             (*env)->SetBooleanArrayRegion(env, array,start,len,buf);
2892             RESTOREENV;
2893         }
2894
2895 void
2896 SetByteArrayRegion(array,start,len,buf)
2897         JNIEnv *                env = FETCHENV;
2898         STRLEN                  tmplen = NO_INIT;
2899         jbyteArray              array
2900         jsize                   start
2901         jsize                   len
2902         jsize                   buf_len_ = NO_INIT;
2903         jbyte *                 buf
2904     CODE:
2905         {
2906             if (buf_len_ < len)
2907                 Perl_croak(aTHX_ "string is too short");
2908             else if (buf_len_ > len && ckWARN(WARN_UNSAFE))
2909                 Perl_warner(aTHX_ WARN_UNSAFE, "string is too long");
2910             (*env)->SetByteArrayRegion(env, array,start,len,buf);
2911             RESTOREENV;
2912         }
2913
2914 void
2915 SetCharArrayRegion(array,start,len,buf)
2916         JNIEnv *                env = FETCHENV;
2917         STRLEN                  tmplen = NO_INIT;
2918         jcharArray              array
2919         jsize                   start
2920         jsize                   len
2921         jsize                   buf_len_ = NO_INIT;
2922         jchar *                 buf
2923     CODE:
2924         {
2925             if (buf_len_ < len)
2926                 Perl_croak(aTHX_ "string is too short");
2927             else if (buf_len_ > len && ckWARN(WARN_UNSAFE))
2928                 Perl_warner(aTHX_ WARN_UNSAFE, "string is too long");
2929             (*env)->SetCharArrayRegion(env, array,start,len,buf);
2930             RESTOREENV;
2931         }
2932
2933 void
2934 SetShortArrayRegion(array,start,len,buf)
2935         JNIEnv *                env = FETCHENV;
2936         STRLEN                  tmplen = NO_INIT;
2937         jshortArray             array
2938         jsize                   start
2939         jsize                   len
2940         jsize                   buf_len_ = NO_INIT;
2941         jshort *                buf
2942     CODE:
2943         {
2944             if (buf_len_ < len)
2945                 Perl_croak(aTHX_ "string is too short");
2946             else if (buf_len_ > len && ckWARN(WARN_UNSAFE))
2947                 Perl_warner(aTHX_ WARN_UNSAFE, "string is too long");
2948             (*env)->SetShortArrayRegion(env, array,start,len,buf);
2949             RESTOREENV;
2950         }
2951
2952 void
2953 SetIntArrayRegion(array,start,len,buf)
2954         JNIEnv *                env = FETCHENV;
2955         STRLEN                  tmplen = NO_INIT;
2956         jintArray               array
2957         jsize                   start
2958         jsize                   len
2959         jsize                   buf_len_ = NO_INIT;
2960         jint *                  buf
2961     CODE:
2962         {
2963             if (buf_len_ < len)
2964                 Perl_croak(aTHX_ "string is too short");
2965             else if (buf_len_ > len && ckWARN(WARN_UNSAFE))
2966                 Perl_warner(aTHX_ WARN_UNSAFE, "string is too long");
2967             (*env)->SetIntArrayRegion(env, array,start,len,buf);
2968             RESTOREENV;
2969         }
2970
2971 void
2972 SetLongArrayRegion(array,start,len,buf)
2973         JNIEnv *                env = FETCHENV;
2974         STRLEN                  tmplen = NO_INIT;
2975         jlongArray              array
2976         jsize                   start
2977         jsize                   len
2978         jsize                   buf_len_ = NO_INIT;
2979         jlong *                 buf
2980     CODE:
2981         {
2982             if (buf_len_ < len)
2983                 Perl_croak(aTHX_ "string is too short");
2984             else if (buf_len_ > len && ckWARN(WARN_UNSAFE))
2985                 Perl_warner(aTHX_ WARN_UNSAFE, "string is too long");
2986             (*env)->SetLongArrayRegion(env, array,start,len,buf);
2987             RESTOREENV;
2988         }
2989
2990 void
2991 SetFloatArrayRegion(array,start,len,buf)
2992         JNIEnv *                env = FETCHENV;
2993         STRLEN                  tmplen = NO_INIT;
2994         jfloatArray             array
2995         jsize                   start
2996         jsize                   len
2997         jsize                   buf_len_ = NO_INIT;
2998         jfloat *                buf
2999     CODE:
3000         {
3001             if (buf_len_ < len)
3002                 Perl_croak(aTHX_ "string is too short");
3003             else if (buf_len_ > len && ckWARN(WARN_UNSAFE))
3004                 Perl_warner(aTHX_ WARN_UNSAFE, "string is too long");
3005             (*env)->SetFloatArrayRegion(env, array,start,len,buf);
3006             RESTOREENV;
3007         }
3008
3009 void
3010 SetDoubleArrayRegion(array,start,len,buf)
3011         JNIEnv *                env = FETCHENV;
3012         STRLEN                  tmplen = NO_INIT;
3013         jdoubleArray            array
3014         jsize                   start
3015         jsize                   len
3016         jsize                   buf_len_ = NO_INIT;
3017         jdouble *               buf
3018     CODE:
3019         {
3020             if (buf_len_ < len)
3021                 Perl_croak(aTHX_ "string is too short");
3022             else if (buf_len_ > len && ckWARN(WARN_UNSAFE))
3023                 Perl_warner(aTHX_ WARN_UNSAFE, "string is too long");
3024             (*env)->SetDoubleArrayRegion(env, array,start,len,buf);
3025             RESTOREENV;
3026         }
3027
3028 SysRet
3029 RegisterNatives(clazz,methods,nMethods)
3030         JNIEnv *                env = FETCHENV;
3031         jclass                  clazz
3032         JNINativeMethod *       methods
3033         jint                    nMethods
3034     CODE:
3035         {
3036             RETVAL = (*env)->RegisterNatives(env, clazz,methods,nMethods);
3037         }
3038
3039 SysRet
3040 UnregisterNatives(clazz)
3041         JNIEnv *                env = FETCHENV;
3042         jclass                  clazz
3043     CODE:
3044         {
3045             RETVAL = (*env)->UnregisterNatives(env, clazz);
3046         }
3047     OUTPUT:
3048         RETVAL  
3049    
3050 SysRet
3051 MonitorEnter(obj)
3052         JNIEnv *                env = FETCHENV;
3053         jobject                 obj
3054     CODE:
3055         {
3056             RETVAL = (*env)->MonitorEnter(env, obj);
3057             RESTOREENV;
3058         }
3059     OUTPUT:
3060         RETVAL
3061
3062 SysRet
3063 MonitorExit(obj)
3064         JNIEnv *                env = FETCHENV;
3065         jobject                 obj
3066     CODE:
3067         {
3068             RETVAL = (*env)->MonitorExit(env, obj);
3069             RESTOREENV;
3070         }
3071     OUTPUT:
3072         RETVAL
3073
3074 JavaVM *
3075 GetJavaVM(...)
3076         JNIEnv *                env = FETCHENV;
3077     CODE:
3078         {
3079             if (env) {  /* We're embedded. */
3080                 if ((*env)->GetJavaVM(env, &RETVAL) < 0)
3081                     RETVAL = 0;
3082             }
3083             else {      /* We're embedding. */
3084                 JDK1_1InitArgs vm_args;
3085                 char *lib;
3086
3087                 if (items--) {
3088                     ++mark;
3089                     lib = SvPV(*mark, PL_na);
3090                 }
3091                 else
3092                     lib = 0;
3093
3094                 if (!dlopen("libjava.so", RTLD_LAZY|RTLD_GLOBAL)) {
3095                     if (lib && !dlopen(lib, RTLD_LAZY|RTLD_GLOBAL))
3096                         Perl_croak(aTHX_ "Can't load libjava.so");
3097                 }
3098
3099                 JNI_GetDefaultJavaVMInitArgs(&vm_args);
3100                 vm_args.exit = &call_my_exit;
3101                 while (items > 1) {
3102                     char *s = SvPV(*++mark,PL_na);
3103                     items -= 2;
3104                     if (strEQ(s, "checkSource"))
3105                         vm_args.checkSource = (jint)SvIV(*++mark);
3106                     else if (strEQ(s, "nativeStackSize"))
3107                         vm_args.nativeStackSize = (jint)SvIV(*++mark);
3108                     else if (strEQ(s, "javaStackSize"))
3109                         vm_args.javaStackSize = (jint)SvIV(*++mark);
3110                     else if (strEQ(s, "minHeapSize"))
3111                         vm_args.minHeapSize = (jint)SvIV(*++mark);
3112                     else if (strEQ(s, "maxHeapSize"))
3113                         vm_args.maxHeapSize = (jint)SvIV(*++mark);
3114                     else if (strEQ(s, "verifyMode"))
3115                         vm_args.verifyMode = (jint)SvIV(*++mark);
3116                     else if (strEQ(s, "classpath"))
3117                         vm_args.classpath = savepv(SvPV(*++mark,PL_na));
3118                     else if (strEQ(s, "enableClassGC"))
3119                         vm_args.enableClassGC = (jint)SvIV(*++mark);
3120                     else if (strEQ(s, "enableVerboseGC"))
3121                         vm_args.enableVerboseGC = (jint)SvIV(*++mark);
3122                     else if (strEQ(s, "disableAsyncGC"))
3123                         vm_args.disableAsyncGC = (jint)SvIV(*++mark);
3124                     else if (strEQ(s, "verbose"))
3125                         vm_args.verbose = (jint)SvIV(*++mark);
3126                     else if (strEQ(s, "debugging"))
3127                         vm_args.debugging = (jboolean)SvIV(*++mark);
3128                     else if (strEQ(s, "debugPort"))
3129                         vm_args.debugPort = (jint)SvIV(*++mark);
3130                     else
3131                         Perl_croak(aTHX_ "unrecognized option: %s", s);
3132                 }
3133                 JNI_CreateJavaVM(&RETVAL, &jplcurenv, &vm_args);
3134             }
3135         }
3136