This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Integrate with Sarathy.
authorJarkko Hietaniemi <jhi@iki.fi>
Wed, 15 Sep 1999 06:57:51 +0000 (06:57 +0000)
committerJarkko Hietaniemi <jhi@iki.fi>
Wed, 15 Sep 1999 06:57:51 +0000 (06:57 +0000)
p4raw-id: //depot/cfgperl@4164

29 files changed:
Changes
MANIFEST
embed.h
embed.pl
jpl/JNI/Closer.java [new file with mode: 0755]
jpl/JNI/JNI.pm
jpl/JNI/JNI.xs
jpl/JNI/JNIConfig [new file with mode: 0644]
jpl/JNI/JNIConfig.Win32 [new file with mode: 0644]
jpl/JNI/JNIConfig.kaffe [new file with mode: 0644]
jpl/JNI/JNIConfig.noembed [new file with mode: 0644]
jpl/JNI/JNIConfig.standard [new file with mode: 0644]
jpl/JNI/Makefile.PL
jpl/JNI/test.pl
jpl/JNI/typemap
jpl/JNI/typemap.gcc [new file with mode: 0644]
jpl/JNI/typemap.win32 [new file with mode: 0644]
jpl/JPL/Makefile.PL
jpl/PerlInterpreter/Makefile.PL
jpl/PerlInterpreter/PerlInterpreter.c
jpl/PerlInterpreter/PerlInterpreter.h
jpl/README
jpl/SETVARS.PL [new file with mode: 0644]
jpl/Sample/Makefile.PL
jpl/install-jpl
lib/File/Spec/Functions.pm
pod/perlhist.pod
regexec.c
t/op/pat.t

diff --git a/Changes b/Changes
index 92c5765..8f0fb75 100644 (file)
--- a/Changes
+++ b/Changes
@@ -79,6 +79,168 @@ Version 5.005_62        Development release working toward 5.006
 ----------------
 
 ____________________________________________________________________________
+[  4161] By: gsar                                  on 1999/09/15  04:08:25
+        Log: missing perlhist dates from Jeff Okamoto
+     Branch: perl
+          ! pod/perlhist.pod
+____________________________________________________________________________
+[  4160] By: gsar                                  on 1999/09/15  03:13:08
+        Log: jpl tweak
+     Branch: perl
+          ! MANIFEST jpl/JNI/Makefile.PL
+____________________________________________________________________________
+[  4159] By: gsar                                  on 1999/09/15  02:57:08
+        Log: update to JPL snapshot v09141999, with minor tweaks (from Brian
+             Jepson <bjepson@home.com>)
+     Branch: perl
+          + jpl/JNI/Closer.java jpl/JNI/JNIConfig jpl/JNI/JNIConfig.Win32
+          + jpl/JNI/JNIConfig.kaffe jpl/JNI/JNIConfig.noembed
+          + jpl/JNI/JNIConfig.standard jpl/JNI/typemap.gcc
+          + jpl/JNI/typemap.win32 jpl/SETVARS.PL
+          ! jpl/JNI/JNI.pm jpl/JNI/JNI.xs jpl/JNI/Makefile.PL
+          ! jpl/JNI/test.pl jpl/JNI/typemap jpl/JPL/Makefile.PL
+          ! jpl/PerlInterpreter/Makefile.PL
+          ! jpl/PerlInterpreter/PerlInterpreter.c
+          ! jpl/PerlInterpreter/PerlInterpreter.h jpl/README
+          ! jpl/Sample/Makefile.PL jpl/install-jpl
+____________________________________________________________________________
+[  4158] By: gsar                                  on 1999/09/15  01:27:14
+        Log: From:    Ilya Zakharevich <ilya@math.ohio-state.edu>
+             Date:    Tue, 14 Sep 1999 21:26:15 EDT
+             Message-Id: <199909150126.VAA24720@monk.mps.ohio-state.edu>
+             Subject: [PATCH 5.005_58+] Re: [ID 19990914.001] Perl_re_intuit_start() hangs in a loop
+     Branch: perl
+          ! regexec.c t/op/pat.t
+____________________________________________________________________________
+[  4157] By: jhi                                   on 1999/09/14  21:18:09
+        Log: config.h will define USE_64_BITS if need be.
+     Branch: cfgperl
+          ! hints/irix_6.sh
+____________________________________________________________________________
+[  4156] By: jhi                                   on 1999/09/14  20:30:00
+        Log: Change #4149 necessitates also a small code change.
+     Branch: cfgperl
+          ! ext/B/defsubs_h.PL
+____________________________________________________________________________
+[  4155] By: jhi                                   on 1999/09/14  20:15:53
+        Log: Update EPOC libdir names.
+     Branch: cfgperl
+          ! epoc/config.h
+____________________________________________________________________________
+[  4154] By: jhi                                   on 1999/09/14  20:13:41
+        Log: Obsolete epoc/config.h caused #4153 to re-introduce already
+             deceased HAS.*DBM.*64 mumblings.
+     Branch: cfgperl
+          ! Configure config_h.SH epoc/config.h
+____________________________________________________________________________
+[  4153] By: jhi                                   on 1999/09/14  20:04:53
+        Log: Configure nits.
+     Branch: cfgperl
+          ! Configure config_h.SH
+     Branch: metaconfig
+          ! U/compline/d_sigaction.U U/threads/i_pthread.U
+____________________________________________________________________________
+[  4152] By: jhi                                   on 1999/09/14  19:30:22
+        Log: Integrate with Sarathy.
+     Branch: cfgperl
+         +> ext/B/defsubs_h.PL t/lib/bigfltpm.t
+          - ext/B/defsubs.h.PL t/lib/bigfloatpm.t
+         !> INSTALL MANIFEST ext/B/Makefile.PL pod/perldiag.pod
+         !> win32/config_sh.PL
+____________________________________________________________________________
+[  4151] By: jhi                                   on 1999/09/14  10:25:01
+        Log: Update Unicode database and recompute the tables.
+             Rename the .txt files to be more Unicode 3.0-like.
+             Unihan-3.0.txt not included because it is 16 MB.
+             syllables.txt is manually maintained.
+             See ReadMe.txt for description of the .txt files.
+             (not all of them are used yet)
+     Branch: cfgperl
+          + lib/unicode/ArabShap.txt lib/unicode/Blocks.txt
+          + lib/unicode/CompExcl.txt lib/unicode/EAWidth.txt
+          + lib/unicode/Index.txt lib/unicode/Jamo-2.txt
+          + lib/unicode/LineBrk.txt lib/unicode/Names.txt
+          + lib/unicode/Props.txt lib/unicode/ReadMe.txt
+          + lib/unicode/SpecCase.txt
+          - lib/unicode/arabshp.txt lib/unicode/blocks.txt
+          - lib/unicode/index2.txt lib/unicode/jamo2.txt
+          - lib/unicode/names2.txt lib/unicode/props2.txt
+          - lib/unicode/readme.txt
+          ! MANIFEST lib/unicode/ArabLink.pl lib/unicode/ArabLnkGrp.pl
+          ! lib/unicode/Bidirectional.pl lib/unicode/Block.pl
+          ! lib/unicode/Category.pl lib/unicode/CombiningClass.pl
+          ! lib/unicode/Decomposition.pl
+          ! lib/unicode/In/ArabicPresentationForms-B.pl
+          ! lib/unicode/In/Specials.pl lib/unicode/In/Tibetan.pl
+          ! lib/unicode/Is/Alnum.pl lib/unicode/Is/Alpha.pl
+          ! lib/unicode/Is/BidiCS.pl lib/unicode/Is/BidiL.pl
+          ! lib/unicode/Is/BidiON.pl lib/unicode/Is/BidiWS.pl
+          ! lib/unicode/Is/DCcompat.pl lib/unicode/Is/DecoCanon.pl
+          ! lib/unicode/Is/DecoCompat.pl lib/unicode/Is/L.pl
+          ! lib/unicode/Is/Ll.pl lib/unicode/Is/Lo.pl
+          ! lib/unicode/Is/Lower.pl lib/unicode/Is/Lu.pl
+          ! lib/unicode/Is/Pd.pl lib/unicode/Is/Po.pl lib/unicode/Is/S.pl
+          ! lib/unicode/Is/Sm.pl lib/unicode/Is/So.pl
+          ! lib/unicode/Is/Upper.pl lib/unicode/Is/Word.pl
+          ! lib/unicode/JamoShort.pl lib/unicode/UnicodeData-Latest.txt
+          ! lib/unicode/mktables.PL
+____________________________________________________________________________
+[  4150] By: gsar                                  on 1999/09/14  09:31:57
+        Log: INSTALL tweak
+     Branch: perl
+          ! INSTALL
+____________________________________________________________________________
+[  4149] By: gsar                                  on 1999/09/14  09:00:45
+        Log: change some filenames to be 8.3-friendly
+     Branch: perl
+         +> ext/B/defsubs_h.PL t/lib/bigfltpm.t
+          - ext/B/defsubs.h.PL t/lib/bigfloatpm.t
+          ! MANIFEST ext/B/Makefile.PL pod/perldiag.pod
+____________________________________________________________________________
+[  4148] By: gsar                                  on 1999/09/14  08:35:00
+        Log: win32 config tweak (suggested by Greg Chapman <glc@well.com>)
+     Branch: perl
+          ! win32/config_sh.PL
+____________________________________________________________________________
+[  4147] By: jhi                                   on 1999/09/14  08:07:49
+        Log: Not that UVSIZE normally differs that much from IVSIZE...
+     Branch: cfgperl
+          ! perl.h
+____________________________________________________________________________
+[  4146] By: jhi                                   on 1999/09/14  08:04:40
+        Log: Integrate with Sarathy.
+     Branch: cfgperl
+         !> Changes ext/DB_File/DB_File.xs
+____________________________________________________________________________
+[  4145] By: jhi                                   on 1999/09/14  07:10:02
+        Log: I_PTHREAD was PTHREADEAD.
+     Branch: cfgperl
+          ! Configure config_h.SH
+     Branch: metaconfig
+          ! U/threads/i_pthread.U
+____________________________________________________________________________
+[  4144] By: gsar                                  on 1999/09/14  06:46:47
+        Log: change#4113 was missing DB_File.xs changes
+     Branch: perl
+          ! ext/DB_File/DB_File.xs
+____________________________________________________________________________
+[  4143] By: jhi                                   on 1999/09/13  20:16:20
+        Log: Small doc and whitespace edits.
+     Branch: cfgperl
+          ! ext/DynaLoader/dl_aix.xs ext/DynaLoader/dl_beos.xs
+          ! ext/DynaLoader/dl_cygwin.xs ext/DynaLoader/dl_dld.xs
+          ! ext/DynaLoader/dl_hpux.xs ext/DynaLoader/dl_mpeix.xs
+          ! ext/DynaLoader/dl_next.xs ext/DynaLoader/dl_rhapsody.xs
+          ! ext/DynaLoader/dl_vmesa.xs ext/DynaLoader/dl_vms.xs
+          ! pod/perldelta.pod
+____________________________________________________________________________
+[  4142] By: gsar                                  on 1999/09/13  19:32:31
+        Log: integrate cfgperl contents into mainline, update Changes
+     Branch: perl
+         +> ext/DB_File/version.c
+          ! Changes
+         !> (integrate 44 files)
+____________________________________________________________________________
 [  4141] By: jhi                                   on 1999/09/13  16:16:56
         Log: Scan for <pthread.h> always.
      Branch: cfgperl
index a7125c7..06135b8 100644 (file)
--- a/MANIFEST
+++ b/MANIFEST
@@ -490,11 +490,19 @@ installperl               Perl script to do "make install" dirty work
 intrpvar.h             Variables held in each interpreter instance
 iperlsys.h             Perl's interface to the system
 jpl/JNI/Changes                Java Native Interface changes
+jpl/JNI/Closer.java    Java Native Interface example
 jpl/JNI/JNI.pm         Java Native Interface module
-jpl/JNI/JNI.xs         Java Native Interface external subroutines
+jpl/JNI/JNI.pm         Java Native Interface module
+jpl/JNI/JNIConfig      Java Native Interface config
+jpl/JNI/JNIConfig.Win32        Java Native Interface config
+jpl/JNI/JNIConfig.kaffe        Java Native Interface config
+jpl/JNI/JNIConfig.noembed      Java Native Interface config
+jpl/JNI/JNIConfig.standard     Java Native Interface config
 jpl/JNI/Makefile.PL    Java Native Interface makefile generator
 jpl/JNI/test.pl                Java Native Interface tests
 jpl/JNI/typemap                Java/Perl interface typemap
+jpl/JNI/typemap.gcc    Java/Perl interface typemap
+jpl/JNI/typemap.win32  Java/Perl interface typemap
 jpl/JPL/AutoLoader.pm  Java/Perl compiler module
 jpl/JPL/Class.pm       Java/Perl compiler module
 jpl/JPL/Compile.pm     Java/Perl compiler module
@@ -508,6 +516,7 @@ jpl/PerlInterpreter/PerlInterpreter.c               Perl interpreter abstraction
 jpl/PerlInterpreter/PerlInterpreter.h          Perl interpreter abstraction
 jpl/PerlInterpreter/PerlInterpreter.java       Perl interpreter abstraction
 jpl/README                                     JPL instructions
+jpl/SETVARS.PL                                 JPL setup
 jpl/Sample/Makefile.PL                         JPL sample makefile generator
 jpl/Sample/Sample.jpl                          JPL sample
 jpl/Test/Makefile.PL                           JPL tests makefile generator
diff --git a/embed.h b/embed.h
index ab68e0e..7cde885 100644 (file)
--- a/embed.h
+++ b/embed.h
  */
 
 #if !defined(PERL_CORE)
-#  define sv_setptrobj(rv,ptr,name)    sv_setref_iv(rv,name,(IV)ptr)
-#  define sv_setptrref(rv,ptr)         sv_setref_iv(rv,Nullch,(IV)ptr)
+#  define sv_setptrobj(rv,ptr,name)    sv_setref_iv(rv,name,PTR2IV(ptr))
+#  define sv_setptrref(rv,ptr)         sv_setref_iv(rv,Nullch,PTR2IV(ptr))
 #endif
 
 #if !defined(PERL_CORE) && !defined(PERL_NOCOMPAT) && !defined(PERL_BINCOMPAT_5005)
index eaee6f7..85e33dd 100755 (executable)
--- a/embed.pl
+++ b/embed.pl
@@ -452,8 +452,8 @@ print EM <<'END';
  */
 
 #if !defined(PERL_CORE)
-#  define sv_setptrobj(rv,ptr,name)    sv_setref_iv(rv,name,(IV)ptr)
-#  define sv_setptrref(rv,ptr)         sv_setref_iv(rv,Nullch,(IV)ptr)
+#  define sv_setptrobj(rv,ptr,name)    sv_setref_iv(rv,name,PTR2IV(ptr))
+#  define sv_setptrref(rv,ptr)         sv_setref_iv(rv,Nullch,PTR2IV(ptr))
 #endif
 
 #if !defined(PERL_CORE) && !defined(PERL_NOCOMPAT) && !defined(PERL_BINCOMPAT_5005)
diff --git a/jpl/JNI/Closer.java b/jpl/JNI/Closer.java
new file mode 100755 (executable)
index 0000000..9344055
--- /dev/null
@@ -0,0 +1,9 @@
+import java.awt.event.*;
+import java.awt.*;
+public class Closer extends WindowAdapter {
+
+    public void windowClosing(WindowEvent e) {
+        Window w = e.getWindow();
+        w.dispose();
+    }
+}
index ad28a9a..edbc1e6 100644 (file)
@@ -198,7 +198,7 @@ sub AUTOLOAD {
     ($constname = $AUTOLOAD) =~ s/.*:://;
     my $val = constant($constname, @_ ? $_[0] : 0);
     if ($! != 0) {
-       if ($! =~ /Invalid/ || $!{EINVAL}) {
+       if ($! =~ /Invalid/) {
            $AutoLoader::AUTOLOAD = $AUTOLOAD;
            goto &AutoLoader::AUTOLOAD;
        }
@@ -215,22 +215,45 @@ bootstrap JNI $VERSION;
 if (not $JPL::_env_) {
     $ENV{JAVA_HOME} ||= "/usr/local/java";
 
-    chop(my $arch = `uname -p`);
-    chop($arch = `uname -m`) unless -d "$ENV{JAVA_HOME}/lib/$arch";
+    my ($arch, @CLASSPATH);
+    if ($^O eq 'MSWin32') {
 
-    my @CLASSPATH = split(/:/, $ENV{CLASSPATH});
-    @CLASSPATH = "." unless @CLASSPATH;
-    push @CLASSPATH,
-       "$ENV{JAVA_HOME}/classes",
-       "$ENV{JAVA_HOME}/lib/classes.zip";
-    $ENV{CLASSPATH} = join(':', @CLASSPATH);
+        $arch = 'MSWin32' unless -d "$ENV{JAVA_HOME}/lib/$arch";
+        @CLASSPATH = split(/;/, $ENV{CLASSPATH});
+        @CLASSPATH = "." unless @CLASSPATH;
+        push @CLASSPATH,
+           "$ENV{JAVA_HOME}\\classes",
+           "$ENV{JAVA_HOME}\\lib\\classes.zip";
 
-    $ENV{THREADS_TYPE} ||= "green_threads";
+        $ENV{CLASSPATH} = join(';', @CLASSPATH);
+        $ENV{THREADS_TYPE} ||= "green_threads";
 
-    $JAVALIB = "$ENV{JAVA_HOME}/lib/$arch/$ENV{THREADS_TYPE}";
-    $ENV{$Config{ldlibpthname}} .= ":$JAVALIB";
+        $JAVALIB = "$ENV{JAVA_HOME}/lib/$arch/$ENV{THREADS_TYPE}";
+        $ENV{LD_LIBRARY_PATH} .= ":$JAVALIB";
 
-    $JVM = GetJavaVM("$JAVALIB/libjava.so",@JVM_ARGS);
+        push @JVM_ARGS, "classpath", $ENV{CLASSPATH};
+        print "JVM_ARGS=@JVM_ARGS!\n";
+        $JVM = GetJavaVM("$JAVALIB/javai.dll",@JVM_ARGS);
+
+    } else {
+        chop($arch = `uname -p`);
+        chop($arch = `uname -m`) unless -d "$ENV{JAVA_HOME}/lib/$arch";
+
+        @CLASSPATH = split(/:/, $ENV{CLASSPATH});
+        @CLASSPATH = "." unless @CLASSPATH;
+        push @CLASSPATH,
+           "$ENV{JAVA_HOME}/classes",
+           "$ENV{JAVA_HOME}/lib/classes.zip";
+        $ENV{CLASSPATH} = join(':', @CLASSPATH);
+
+        $ENV{THREADS_TYPE} ||= "green_threads";
+
+        $JAVALIB = "$ENV{JAVA_HOME}/lib/$arch/$ENV{THREADS_TYPE}";
+        $ENV{LD_LIBRARY_PATH} .= ":$JAVALIB";
+        push @JVM_ARGS, "classpath", $ENV{CLASSPATH};
+        print "JVM_ARGS=@JVM_ARGS!\n";
+        $JVM = GetJavaVM("$JAVALIB/libjava.so",@JVM_ARGS);
+    }
 }
 
 1;
index ee854c1..e5e0af3 100644 (file)
@@ -8,24 +8,64 @@
 #include "perl.h"
 #include "XSUB.h"
 
-#include <perl.h>
+#include <stdio.h>
 #include <jni.h>
-#include <dlfcn.h>
 
+#ifndef PERL_VERSION
+#  include <patchlevel.h>
+#  define PERL_REVISION                5
+#  define PERL_VERSION         PATCHLEVEL
+#  define PERL_SUBVERSION      SUBVERSION
+#endif
+
+#if PERL_REVISION == 5 && (PERL_VERSION < 4 || \
+                          (PERL_VERSION == 4 && PERL_SUBVERSION <= 75))
+#  define PL_na                na
+#  define PL_sv_no     sv_no
+#  define PL_sv_undef  sv_undef
+#  define PL_dowarn    dowarn
+#endif
+
+#ifndef newSVpvn
+#  define newSVpvn(a,b)        newSVpv(a,b)
+#endif
+
+#ifndef pTHX
+#  define pTHX         void
+#  define pTHX_
+#  define aTHX
+#  define aTHX_
+#  define dTHX         extern int JNI___notused
+#endif
+
+#ifndef WIN32
+#  include <dlfcn.h>
+#endif
+
+#ifdef EMBEDDEDPERL
 extern JNIEnv* jplcurenv;
 extern int jpldebug;
+#else
+JNIEnv* jplcurenv;
+int jpldebug = 1;
+#endif
 
 #define SysRet jint
 
-static void
-call_my_exit(jint status)
+#ifdef WIN32
+static void JNICALL call_my_exit(jint status)
+{
+    my_exit(status);
+}
+#else
+static void call_my_exit(jint status)
 {
-    dTHX;
     my_exit(status);
 }
+#endif
 
 jvalue*
-makeargs(pTHX_ char *sig, SV** svp, int items)
+makeargs(char *sig, SV** svp, int items)
 {
     jvalue* jv = (jvalue*)safemalloc(sizeof(jvalue) * items);
     int ix = 0;
@@ -80,10 +120,18 @@ makeargs(pTHX_ char *sig, SV** svp, int items)
                        int i;
                        SV** esv;
 
+#ifdef WIN32
+                       jbooleanArray ja = env->NewBooleanArray(len);
+#else
                        jbooleanArray ja = (*env)->NewBooleanArray(env, len);
+#endif
                        for (esv = AvARRAY((AV*)rv), i = 0; i < len; esv++, i++)
                            buf[i] = (jboolean)SvIV(*esv);
+#ifdef WIN32
+                       env->SetBooleanArrayRegion(ja, 0, len, buf);
+#else
                        (*env)->SetBooleanArrayRegion(env, ja, 0, len, buf);
+#endif
                        free((void*)buf);
                        jv[ix++].l = (jobject)ja;
                    }
@@ -93,8 +141,16 @@ makeargs(pTHX_ char *sig, SV** svp, int items)
                else if (SvPOK(sv)) {
                    jsize len = sv_len(sv) / sizeof(jboolean);
 
+#ifdef WIN32
+                   jbooleanArray ja = env->NewBooleanArray(len);
+#else
                    jbooleanArray ja = (*env)->NewBooleanArray(env, len);
+#endif
+#ifdef WIN32
+                   env->SetBooleanArrayRegion(ja, 0, len, (jboolean*)SvPV(sv,n_a));
+#else
                    (*env)->SetBooleanArrayRegion(env, ja, 0, len, (jboolean*)SvPV(sv,n_a));
+#endif
                    jv[ix++].l = (jobject)ja;
                }
                else
@@ -111,10 +167,18 @@ makeargs(pTHX_ char *sig, SV** svp, int items)
                        int i;
                        SV** esv;
 
+#ifdef WIN32
+                       jbyteArray ja = env->NewByteArray(len);
+#else
                        jbyteArray ja = (*env)->NewByteArray(env, len);
+#endif
                        for (esv = AvARRAY((AV*)rv), i = 0; i < len; esv++, i++)
                            buf[i] = (jbyte)SvIV(*esv);
+#ifdef WIN32
+                       env->SetByteArrayRegion(ja, 0, len, buf);
+#else
                        (*env)->SetByteArrayRegion(env, ja, 0, len, buf);
+#endif
                        free((void*)buf);
                        jv[ix++].l = (jobject)ja;
                    }
@@ -124,8 +188,16 @@ makeargs(pTHX_ char *sig, SV** svp, int items)
                else if (SvPOK(sv)) {
                    jsize len = sv_len(sv) / sizeof(jbyte);
 
+#ifdef WIN32
+                   jbyteArray ja = env->NewByteArray(len);
+#else
                    jbyteArray ja = (*env)->NewByteArray(env, len);
+#endif
+#ifdef WIN32
+                   env->SetByteArrayRegion(ja, 0, len, (jbyte*)SvPV(sv,n_a));
+#else
                    (*env)->SetByteArrayRegion(env, ja, 0, len, (jbyte*)SvPV(sv,n_a));
+#endif
                    jv[ix++].l = (jobject)ja;
                }
                else
@@ -142,10 +214,18 @@ makeargs(pTHX_ char *sig, SV** svp, int items)
                        int i;
                        SV** esv;
 
+#ifdef WIN32
+                       jcharArray ja = env->NewCharArray(len);
+#else
                        jcharArray ja = (*env)->NewCharArray(env, len);
+#endif
                        for (esv = AvARRAY((AV*)rv), i = 0; i < len; esv++, i++)
                            buf[i] = (jchar)SvIV(*esv);
+#ifdef WIN32
+                       env->SetCharArrayRegion(ja, 0, len, buf);
+#else
                        (*env)->SetCharArrayRegion(env, ja, 0, len, buf);
+#endif
                        free((void*)buf);
                        jv[ix++].l = (jobject)ja;
                    }
@@ -155,8 +235,16 @@ makeargs(pTHX_ char *sig, SV** svp, int items)
                else if (SvPOK(sv)) {
                    jsize len = sv_len(sv) / sizeof(jchar);
 
+#ifdef WIN32
+                   jcharArray ja = env->NewCharArray(len);
+#else
                    jcharArray ja = (*env)->NewCharArray(env, len);
+#endif
+#ifdef WIN32
+                   env->SetCharArrayRegion(ja, 0, len, (jchar*)SvPV(sv,n_a));
+#else
                    (*env)->SetCharArrayRegion(env, ja, 0, len, (jchar*)SvPV(sv,n_a));
+#endif
                    jv[ix++].l = (jobject)ja;
                }
                else
@@ -173,10 +261,18 @@ makeargs(pTHX_ char *sig, SV** svp, int items)
                        int i;
                        SV** esv;
 
+#ifdef WIN32
+                       jshortArray ja = env->NewShortArray(len);
+#else
                        jshortArray ja = (*env)->NewShortArray(env, len);
+#endif
                        for (esv = AvARRAY((AV*)rv), i = 0; i < len; esv++, i++)
                            buf[i] = (jshort)SvIV(*esv);
+#ifdef WIN32
+                       env->SetShortArrayRegion(ja, 0, len, buf);
+#else
                        (*env)->SetShortArrayRegion(env, ja, 0, len, buf);
+#endif
                        free((void*)buf);
                        jv[ix++].l = (jobject)ja;
                    }
@@ -186,8 +282,16 @@ makeargs(pTHX_ char *sig, SV** svp, int items)
                else if (SvPOK(sv)) {
                    jsize len = sv_len(sv) / sizeof(jshort);
 
+#ifdef WIN32
+                   jshortArray ja = env->NewShortArray(len);
+#else
                    jshortArray ja = (*env)->NewShortArray(env, len);
+#endif
+#ifdef WIN32
+                   env->SetShortArrayRegion(ja, 0, len, (jshort*)SvPV(sv,n_a));
+#else
                    (*env)->SetShortArrayRegion(env, ja, 0, len, (jshort*)SvPV(sv,n_a));
+#endif
                    jv[ix++].l = (jobject)ja;
                }
                else
@@ -204,10 +308,18 @@ makeargs(pTHX_ char *sig, SV** svp, int items)
                        int i;
                        SV** esv;
 
+#ifdef WIN32
+                       jintArray ja = env->NewIntArray(len);
+#else
                        jintArray ja = (*env)->NewIntArray(env, len);
+#endif
                        for (esv = AvARRAY((AV*)rv), i = 0; i < len; esv++, i++)
                            buf[i] = (jint)SvIV(*esv);
+#ifdef WIN32
+                       env->SetIntArrayRegion(ja, 0, len, buf);
+#else
                        (*env)->SetIntArrayRegion(env, ja, 0, len, buf);
+#endif
                        free((void*)buf);
                        jv[ix++].l = (jobject)ja;
                    }
@@ -217,8 +329,16 @@ makeargs(pTHX_ char *sig, SV** svp, int items)
                else if (SvPOK(sv)) {
                    jsize len = sv_len(sv) / sizeof(jint);
 
+#ifdef WIN32
+                   jintArray ja = env->NewIntArray(len);
+#else
                    jintArray ja = (*env)->NewIntArray(env, len);
+#endif
+#ifdef WIN32
+                   env->SetIntArrayRegion(ja, 0, len, (jint*)SvPV(sv,n_a));
+#else
                    (*env)->SetIntArrayRegion(env, ja, 0, len, (jint*)SvPV(sv,n_a));
+#endif
                    jv[ix++].l = (jobject)ja;
                }
                else
@@ -235,10 +355,18 @@ makeargs(pTHX_ char *sig, SV** svp, int items)
                        int i;
                        SV** esv;
 
+#ifdef WIN32
+                       jlongArray ja = env->NewLongArray(len);
+#else
                        jlongArray ja = (*env)->NewLongArray(env, len);
+#endif
                        for (esv = AvARRAY((AV*)rv), i = 0; i < len; esv++, i++)
                            buf[i] = (jlong)SvNV(*esv);
+#ifdef WIN32
+                       env->SetLongArrayRegion(ja, 0, len, buf);
+#else
                        (*env)->SetLongArrayRegion(env, ja, 0, len, buf);
+#endif
                        free((void*)buf);
                        jv[ix++].l = (jobject)ja;
                    }
@@ -248,8 +376,16 @@ makeargs(pTHX_ char *sig, SV** svp, int items)
                else if (SvPOK(sv)) {
                    jsize len = sv_len(sv) / sizeof(jlong);
 
+#ifdef WIN32
+                   jlongArray ja = env->NewLongArray(len);
+#else
                    jlongArray ja = (*env)->NewLongArray(env, len);
+#endif
+#ifdef WIN32
+                   env->SetLongArrayRegion(ja, 0, len, (jlong*)SvPV(sv,n_a));
+#else
                    (*env)->SetLongArrayRegion(env, ja, 0, len, (jlong*)SvPV(sv,n_a));
+#endif
                    jv[ix++].l = (jobject)ja;
                }
                else
@@ -266,10 +402,18 @@ makeargs(pTHX_ char *sig, SV** svp, int items)
                        int i;
                        SV** esv;
 
+#ifdef WIN32
+                       jfloatArray ja = env->NewFloatArray(len);
+#else
                        jfloatArray ja = (*env)->NewFloatArray(env, len);
+#endif
                        for (esv = AvARRAY((AV*)rv), i = 0; i < len; esv++, i++)
                            buf[i] = (jfloat)SvNV(*esv);
+#ifdef WIN32
+                       env->SetFloatArrayRegion(ja, 0, len, buf);
+#else
                        (*env)->SetFloatArrayRegion(env, ja, 0, len, buf);
+#endif
                        free((void*)buf);
                        jv[ix++].l = (jobject)ja;
                    }
@@ -279,8 +423,16 @@ makeargs(pTHX_ char *sig, SV** svp, int items)
                else if (SvPOK(sv)) {
                    jsize len = sv_len(sv) / sizeof(jfloat);
 
+#ifdef WIN32
+                   jfloatArray ja = env->NewFloatArray(len);
+#else
                    jfloatArray ja = (*env)->NewFloatArray(env, len);
+#endif
+#ifdef WIN32
+                   env->SetFloatArrayRegion(ja, 0, len, (jfloat*)SvPV(sv,n_a));
+#else
                    (*env)->SetFloatArrayRegion(env, ja, 0, len, (jfloat*)SvPV(sv,n_a));
+#endif
                    jv[ix++].l = (jobject)ja;
                }
                else
@@ -297,10 +449,18 @@ makeargs(pTHX_ char *sig, SV** svp, int items)
                        int i;
                        SV** esv;
 
+#ifdef WIN32
+                       jdoubleArray ja = env->NewDoubleArray(len);
+#else
                        jdoubleArray ja = (*env)->NewDoubleArray(env, len);
+#endif
                        for (esv = AvARRAY((AV*)rv), i = 0; i < len; esv++, i++)
                            buf[i] = (jdouble)SvNV(*esv);
+#ifdef WIN32
+                       env->SetDoubleArrayRegion(ja, 0, len, buf);
+#else
                        (*env)->SetDoubleArrayRegion(env, ja, 0, len, buf);
+#endif
                        free((void*)buf);
                        jv[ix++].l = (jobject)ja;
                    }
@@ -310,8 +470,16 @@ makeargs(pTHX_ char *sig, SV** svp, int items)
                else if (SvPOK(sv)) {
                    jsize len = sv_len(sv) / sizeof(jdouble);
 
+#ifdef WIN32
+                   jdoubleArray ja = env->NewDoubleArray(len);
+#else
                    jdoubleArray ja = (*env)->NewDoubleArray(env, len);
+#endif
+#ifdef WIN32
+                   env->SetDoubleArrayRegion(ja, 0, len, (jdouble*)SvPV(sv,n_a));
+#else
                    (*env)->SetDoubleArrayRegion(env, ja, 0, len, (jdouble*)SvPV(sv,n_a));
+#endif
                    jv[ix++].l = (jobject)ja;
                }
                else
@@ -330,14 +498,30 @@ makeargs(pTHX_ char *sig, SV** svp, int items)
                            int i;
                            SV** esv;
                            static jclass jcl = 0;
-                           jarray ja;
+                           jobjectArray ja;
 
                            if (!jcl)
+#ifdef WIN32
+                               jcl = env->FindClass("java/lang/String");
+#else
                                jcl = (*env)->FindClass(env, "java/lang/String");
+#endif
+#ifdef WIN32
+                           ja = env->NewObjectArray(len, jcl, 0);
+#else
                            ja = (*env)->NewObjectArray(env, len, jcl, 0);
+#endif
                            for (esv = AvARRAY((AV*)rv), i = 0; i < len; esv++, i++) {
+#ifdef WIN32
+                               jobject str = (jobject)env->NewStringUTF(SvPV(*esv,n_a));
+#else
                                jobject str = (jobject)(*env)->NewStringUTF(env, SvPV(*esv,n_a));
+#endif
+#ifdef WIN32
+                               env->SetObjectArrayElement(ja, i, str);
+#else
                                (*env)->SetObjectArrayElement(env, ja, i, str);
+#endif
                            }
                            jv[ix++].l = (jobject)ja;
                        }
@@ -359,20 +543,38 @@ makeargs(pTHX_ char *sig, SV** svp, int items)
                        int i;
                        SV** esv;
                       static jclass jcl = 0;
-                       jarray ja;
+                       jobjectArray ja;
 
                        if (!jcl)
+#ifdef WIN32
+                           jcl = env->FindClass("java/lang/Object");
+#else
                            jcl = (*env)->FindClass(env, "java/lang/Object");
+#endif
+#ifdef WIN32
+                       ja = env->NewObjectArray(len, jcl, 0);
+#else
                        ja = (*env)->NewObjectArray(env, len, jcl, 0);
+#endif
                        for (esv = AvARRAY((AV*)rv), i = 0; i < len; esv++, i++) {
                            if (SvROK(*esv) && (rv = SvRV(*esv)) && SvOBJECT(rv)) {
-                               (*env)->SetObjectArrayElement(env, ja, i,
-                                   (jobject)(void*)SvIV(rv));
+#ifdef WIN32
+                               env->SetObjectArrayElement(ja, i, (jobject)(void*)SvIV(rv));
+#else
+                               (*env)->SetObjectArrayElement(env, ja, i, (jobject)(void*)SvIV(rv));
+#endif
                            }
                            else {
-                               jobject str = (jobject)(*env)->NewStringUTF(env,
-                                   SvPV(*esv,n_a));
+#ifdef WIN32
+                               jobject str = (jobject)env->NewStringUTF(SvPV(*esv,n_a));
+#else
+                               jobject str = (jobject)(*env)->NewStringUTF(env, SvPV(*esv,n_a));
+#endif
+#ifdef WIN32
+                               env->SetObjectArrayElement(ja, i, str);
+#else
                                (*env)->SetObjectArrayElement(env, ja, i, str);
+#endif
                            }
                        }
                        jv[ix++].l = (jobject)ja;
@@ -388,8 +590,11 @@ makeargs(pTHX_ char *sig, SV** svp, int items)
        case 'L':
            if (!SvROK(sv) || strnEQ(s, "java/lang/String;", 17)) {
                s += 17;
-               jv[ix++].l = (jobject)(*env)->NewStringUTF(env,
-                               (char*) SvPV(sv,n_a));
+#ifdef WIN32
+               jv[ix++].l = (jobject)env->NewStringUTF((char*) SvPV(sv,n_a));
+#else
+               jv[ix++].l = (jobject)(*env)->NewStringUTF(env, (char*) SvPV(sv,n_a));
+#endif
                break;
            }
            while (*s != ';') s++;
@@ -400,16 +605,16 @@ makeargs(pTHX_ char *sig, SV** svp, int items)
            }
            break;
        case ')':
-           Perl_croak(aTHX_ "too many arguments, signature: %s", sig);
+           croak("too many arguments, signature: %s", sig);
            goto cleanup;
        default:
-           Perl_croak(aTHX_ "panic: malformed signature: %s", s-1);
+           croak("panic: malformed signature: %s", s-1);
            goto cleanup;
        }
 
     }
     if (*s != ')') {
-       Perl_croak(aTHX_ "not enough arguments, signature: %s", sig);
+       croak("not enough arguments, signature: %s", sig);
        goto cleanup;
     }
     return jv;
@@ -420,9 +625,9 @@ cleanup:
 }
 
 static int
-not_here(pTHX_ char *s)
+not_here(char *s)
 {
-    Perl_croak(aTHX_ "%s not implemented on this architecture", s);
+    croak("%s not implemented on this architecture", s);
     return -1;
 }
 
@@ -476,7 +681,11 @@ constant(char *name, int arg)
 #endif
        if (strEQ(name, "JNI_H"))
 #ifdef JNI_H
+#ifdef WIN32
+           return 1;
+#else
            return JNI_H;
+#endif
 #else
            goto not_there;
 #endif
@@ -551,7 +760,11 @@ GetVersion()
        JNIEnv *                env = FETCHENV;
     CODE:
        {
+#ifdef WIN32
+           RETVAL = env->GetVersion();
+#else
            RETVAL = (*env)->GetVersion(env);
+#endif
            RESTOREENV;
        }
     OUTPUT:
@@ -567,7 +780,19 @@ DefineClass(name, loader, buf)
        const jbyte *           buf
     CODE:
        {
-           RETVAL = (*env)->DefineClass(env,  name, loader, buf, (jsize)buf_len_);
+#ifdef KAFFE
+#ifdef WIN32
+           RETVAL = env->DefineClass( loader, buf, (jsize)buf_len_);
+#else
+           RETVAL = (*env)->DefineClass(env,  loader, buf, (jsize)buf_len_);
+#endif
+#else
+#ifdef WIN32
+           RETVAL = env->DefineClass( name, loader, buf, (jsize)buf_len_); 
+#else
+           RETVAL = (*env)->DefineClass(env,  name, loader, buf, (jsize)buf_len_); 
+#endif
+#endif
            RESTOREENV;
        }
     OUTPUT:
@@ -579,7 +804,11 @@ FindClass(name)
        const char *            name
     CODE:
        {
+#ifdef WIN32
+           RETVAL = env->FindClass( name);
+#else
            RETVAL = (*env)->FindClass(env,  name);
+#endif
            RESTOREENV;
        }
     OUTPUT:
@@ -591,7 +820,11 @@ GetSuperclass(sub)
        jclass                  sub
     CODE:
        {
+#ifdef WIN32
+           RETVAL = env->GetSuperclass( sub);
+#else
            RETVAL = (*env)->GetSuperclass(env,  sub);
+#endif
            RESTOREENV;
        }
     OUTPUT:
@@ -604,7 +837,11 @@ IsAssignableFrom(sub, sup)
        jclass                  sup
     CODE:
        {
+#ifdef WIN32
+           RETVAL = env->IsAssignableFrom( sub, sup);
+#else
            RETVAL = (*env)->IsAssignableFrom(env,  sub, sup);
+#endif
            RESTOREENV;
        }
     OUTPUT:
@@ -616,7 +853,11 @@ Throw(obj)
        jthrowable              obj
     CODE:
        {
+#ifdef WIN32
+           RETVAL = env->Throw( obj);
+#else
            RETVAL = (*env)->Throw(env,  obj);
+#endif
            RESTOREENV;
        }
     OUTPUT:
@@ -629,7 +870,11 @@ ThrowNew(clazz, msg)
        const char *            msg
     CODE:
        {
+#ifdef WIN32
+           RETVAL = env->ThrowNew( clazz, msg);
+#else
            RETVAL = (*env)->ThrowNew(env,  clazz, msg);
+#endif
            RESTOREENV;
        }
     OUTPUT:
@@ -640,7 +885,11 @@ ExceptionOccurred()
        JNIEnv *                env = FETCHENV;
     CODE:
        {
+#ifdef WIN32
+           RETVAL = env->ExceptionOccurred();
+#else
            RETVAL = (*env)->ExceptionOccurred(env);
+#endif
            RESTOREENV;
        }
     OUTPUT:
@@ -651,7 +900,11 @@ ExceptionDescribe()
        JNIEnv *                env = FETCHENV;
     CODE:
        {
+#ifdef WIN32
+           env->ExceptionDescribe();
+#else
            (*env)->ExceptionDescribe(env);
+#endif
            RESTOREENV;
        }
 
@@ -660,7 +913,11 @@ ExceptionClear()
        JNIEnv *                env = FETCHENV;
     CODE:
        {
+#ifdef WIN32
+           env->ExceptionClear();
+#else
            (*env)->ExceptionClear(env);
+#endif
            RESTOREENV;
        }
 
@@ -670,7 +927,11 @@ FatalError(msg)
        const char *            msg
     CODE:
        {
+#ifdef WIN32
+           env->FatalError( msg);
+#else
            (*env)->FatalError(env,  msg);
+#endif
            RESTOREENV;
        }
 
@@ -680,7 +941,11 @@ NewGlobalRef(lobj)
        jobject                 lobj
     CODE:
        {
+#ifdef WIN32
+           RETVAL = env->NewGlobalRef(lobj);
+#else
            RETVAL = (*env)->NewGlobalRef(env, lobj);
+#endif
            RESTOREENV;
        }
     OUTPUT:
@@ -692,7 +957,11 @@ DeleteGlobalRef(gref)
        jobject                 gref
     CODE:
        {
+#ifdef WIN32
+           env->DeleteGlobalRef(gref);
+#else
            (*env)->DeleteGlobalRef(env, gref);
+#endif
            RESTOREENV;
        }
 
@@ -702,7 +971,11 @@ DeleteLocalRef(obj)
        jobject                 obj
     CODE:
        {
+#ifdef WIN32
+           env->DeleteLocalRef( obj);
+#else
            (*env)->DeleteLocalRef(env,  obj);
+#endif
            RESTOREENV;
        }
 
@@ -713,7 +986,11 @@ IsSameObject(obj1,obj2)
        jobject                 obj2
     CODE:
        {
+#ifdef WIN32
+           RETVAL = env->IsSameObject(obj1,obj2);
+#else
            RETVAL = (*env)->IsSameObject(env, obj1,obj2);
+#endif
            RESTOREENV;
        }
     OUTPUT:
@@ -725,7 +1002,11 @@ AllocObject(clazz)
        jclass                  clazz
     CODE:
        {
+#ifdef WIN32
+           RETVAL = env->AllocObject(clazz);
+#else
            RETVAL = (*env)->AllocObject(env, clazz);
+#endif
            RESTOREENV;
        }
     OUTPUT:
@@ -740,8 +1021,12 @@ NewObject(clazz,methodID,...)
        int                     argoff = $min_args;
     CODE:
        {
-           jvalue * args = makeargs(aTHX_ sig, &ST(argoff), items - argoff);
+           jvalue * args = makeargs(sig, &ST(argoff), items - argoff);
+#ifdef WIN32
+           RETVAL = env->NewObjectA(clazz,methodID,args);
+#else
            RETVAL = (*env)->NewObjectA(env, clazz,methodID,args);
+#endif
            RESTOREENV;
        }
     OUTPUT:
@@ -756,7 +1041,11 @@ NewObjectA(clazz,methodID,args)
        jvalue *                args
     CODE:
        {
+#ifdef WIN32
+           RETVAL = env->NewObjectA(clazz,methodID,args);
+#else
            RETVAL = (*env)->NewObjectA(env, clazz,methodID,args);
+#endif
            RESTOREENV;
        }
     OUTPUT:
@@ -768,7 +1057,11 @@ GetObjectClass(obj)
        jobject                 obj
     CODE:
        {
+#ifdef WIN32
+           RETVAL = env->GetObjectClass(obj);
+#else
            RETVAL = (*env)->GetObjectClass(env, obj);
+#endif
            RESTOREENV;
        }
     OUTPUT:
@@ -781,7 +1074,11 @@ IsInstanceOf(obj,clazz)
        jclass                  clazz
     CODE:
        {
+#ifdef WIN32
+           RETVAL = env->IsInstanceOf(obj,clazz);
+#else
            RETVAL = (*env)->IsInstanceOf(env, obj,clazz);
+#endif
            RESTOREENV;
        }
     OUTPUT:
@@ -795,7 +1092,11 @@ GetMethodID(clazz,name,sig)
        const char *            sig
     CODE:
        {
+#ifdef WIN32
+           RETVAL = env->GetMethodID(clazz,name,sig);
+#else
            RETVAL = (*env)->GetMethodID(env, clazz,name,sig);
+#endif
            RESTOREENV;
        }
     OUTPUT:
@@ -810,8 +1111,12 @@ CallObjectMethod(obj,methodID,...)
        int                     argoff = $min_args;
     CODE:
        {
-           jvalue * args = makeargs(aTHX_ sig, &ST(argoff), items - argoff);
+           jvalue * args = makeargs(sig, &ST(argoff), items - argoff);
+#ifdef WIN32
+           RETVAL = env->CallObjectMethodA(obj,methodID,args);
+#else
            RETVAL = (*env)->CallObjectMethodA(env, obj,methodID,args);
+#endif
            RESTOREENV;
        }
     OUTPUT:
@@ -826,7 +1131,11 @@ CallObjectMethodA(obj,methodID,args)
        jvalue *                args
     CODE:
        {
+#ifdef WIN32
+           RETVAL = env->CallObjectMethodA(obj,methodID,args);
+#else
            RETVAL = (*env)->CallObjectMethodA(env, obj,methodID,args);
+#endif
            RESTOREENV;
        }
     OUTPUT:
@@ -841,8 +1150,12 @@ CallBooleanMethod(obj,methodID,...)
        int                     argoff = $min_args;
     CODE:
        {
-           jvalue * args = makeargs(aTHX_ sig, &ST(argoff), items - argoff);
+           jvalue * args = makeargs(sig, &ST(argoff), items - argoff);
+#ifdef WIN32
+           RETVAL = env->CallBooleanMethodA(obj,methodID,args);
+#else
            RETVAL = (*env)->CallBooleanMethodA(env, obj,methodID,args);
+#endif
            RESTOREENV;
        }
     OUTPUT:
@@ -857,7 +1170,11 @@ CallBooleanMethodA(obj,methodID, args)
        jvalue *                args
     CODE:
        {
+#ifdef WIN32
+           RETVAL = env->CallBooleanMethodA(obj,methodID, args);
+#else
            RETVAL = (*env)->CallBooleanMethodA(env, obj,methodID, args);
+#endif
            RESTOREENV;
        }
     OUTPUT:
@@ -872,8 +1189,12 @@ CallByteMethod(obj,methodID,...)
        int                     argoff = $min_args;
     CODE:
        {
-           jvalue * args = makeargs(aTHX_ sig, &ST(argoff), items - argoff);
+           jvalue * args = makeargs(sig, &ST(argoff), items - argoff);
+#ifdef WIN32
+           RETVAL = env->CallByteMethodA(obj,methodID,args);
+#else
            RETVAL = (*env)->CallByteMethodA(env, obj,methodID,args);
+#endif
            RESTOREENV;
        }
     OUTPUT:
@@ -888,7 +1209,11 @@ CallByteMethodA(obj,methodID,args)
        jvalue *                args
     CODE:
        {
+#ifdef WIN32
+           RETVAL = env->CallByteMethodA(obj,methodID,args);
+#else
            RETVAL = (*env)->CallByteMethodA(env, obj,methodID,args);
+#endif
            RESTOREENV;
        }
     OUTPUT:
@@ -903,8 +1228,12 @@ CallCharMethod(obj,methodID,...)
        int                     argoff = $min_args;
     CODE:
        {
-           jvalue * args = makeargs(aTHX_ sig, &ST(argoff), items - argoff);
+           jvalue * args = makeargs(sig, &ST(argoff), items - argoff);
+#ifdef WIN32
+           RETVAL = env->CallCharMethodA(obj,methodID,args);
+#else
            RETVAL = (*env)->CallCharMethodA(env, obj,methodID,args);
+#endif
            RESTOREENV;
        }
     OUTPUT:
@@ -919,7 +1248,11 @@ CallCharMethodA(obj,methodID,args)
        jvalue *                args
     CODE:
        {
+#ifdef WIN32
+           RETVAL = env->CallCharMethodA(obj,methodID,args);
+#else
            RETVAL = (*env)->CallCharMethodA(env, obj,methodID,args);
+#endif
            RESTOREENV;
        }
     OUTPUT:
@@ -934,8 +1267,12 @@ CallShortMethod(obj,methodID,...)
        int                     argoff = $min_args;
     CODE:
        {
-           jvalue * args = makeargs(aTHX_ sig, &ST(argoff), items - argoff);
+           jvalue * args = makeargs(sig, &ST(argoff), items - argoff);
+#ifdef WIN32
+           RETVAL = env->CallShortMethodA(obj,methodID,args);
+#else
            RETVAL = (*env)->CallShortMethodA(env, obj,methodID,args);
+#endif
            RESTOREENV;
        }
     OUTPUT:
@@ -950,7 +1287,11 @@ CallShortMethodA(obj,methodID,args)
        jvalue *                args
     CODE:
        {
+#ifdef WIN32
+           RETVAL = env->CallShortMethodA(obj,methodID,args);
+#else
            RETVAL = (*env)->CallShortMethodA(env, obj,methodID,args);
+#endif
            RESTOREENV;
        }
     OUTPUT:
@@ -965,8 +1306,12 @@ CallIntMethod(obj,methodID,...)
        int                     argoff = $min_args;
     CODE:
        {
-           jvalue * args = makeargs(aTHX_ sig, &ST(argoff), items - argoff);
+           jvalue * args = makeargs(sig, &ST(argoff), items - argoff);
+#ifdef WIN32
+           RETVAL = env->CallIntMethodA(obj,methodID,args);
+#else
            RETVAL = (*env)->CallIntMethodA(env, obj,methodID,args);
+#endif
            RESTOREENV;
        }
     OUTPUT:
@@ -981,7 +1326,11 @@ CallIntMethodA(obj,methodID,args)
        jvalue *                args
     CODE:
        {
+#ifdef WIN32
+           RETVAL = env->CallIntMethodA(obj,methodID,args);
+#else
            RETVAL = (*env)->CallIntMethodA(env, obj,methodID,args);
+#endif
            RESTOREENV;
        }
     OUTPUT:
@@ -996,8 +1345,12 @@ CallLongMethod(obj,methodID,...)
        int                     argoff = $min_args;
     CODE:
        {
-           jvalue * args = makeargs(aTHX_ sig, &ST(argoff), items - argoff);
+           jvalue * args = makeargs(sig, &ST(argoff), items - argoff);
+#ifdef WIN32
+           RETVAL = env->CallLongMethodA(obj,methodID,args);
+#else
            RETVAL = (*env)->CallLongMethodA(env, obj,methodID,args);
+#endif
            RESTOREENV;
        }
     OUTPUT:
@@ -1012,7 +1365,11 @@ CallLongMethodA(obj,methodID,args)
        jvalue *                args
     CODE:
        {
+#ifdef WIN32
+           RETVAL = env->CallLongMethodA(obj,methodID,args);
+#else
            RETVAL = (*env)->CallLongMethodA(env, obj,methodID,args);
+#endif
            RESTOREENV;
        }
     OUTPUT:
@@ -1027,8 +1384,12 @@ CallFloatMethod(obj,methodID,...)
        int                     argoff = $min_args;
     CODE:
        {
-           jvalue * args = makeargs(aTHX_ sig, &ST(argoff), items - argoff);
+           jvalue * args = makeargs(sig, &ST(argoff), items - argoff);
+#ifdef WIN32
+           RETVAL = env->CallFloatMethodA(obj,methodID,args);
+#else
            RETVAL = (*env)->CallFloatMethodA(env, obj,methodID,args);
+#endif
            RESTOREENV;
        }
     OUTPUT:
@@ -1043,7 +1404,11 @@ CallFloatMethodA(obj,methodID,args)
        jvalue *                args
     CODE:
        {
+#ifdef WIN32
+           RETVAL = env->CallFloatMethodA(obj,methodID,args);
+#else
            RETVAL = (*env)->CallFloatMethodA(env, obj,methodID,args);
+#endif
            RESTOREENV;
        }
     OUTPUT:
@@ -1058,8 +1423,12 @@ CallDoubleMethod(obj,methodID,...)
        int                     argoff = $min_args;
     CODE:
        {
-           jvalue * args = makeargs(aTHX_ sig, &ST(argoff), items - argoff);
+           jvalue * args = makeargs(sig, &ST(argoff), items - argoff);
+#ifdef WIN32
+           RETVAL = env->CallDoubleMethodA(obj,methodID,args);
+#else
            RETVAL = (*env)->CallDoubleMethodA(env, obj,methodID,args);
+#endif
            RESTOREENV;
        }
     OUTPUT:
@@ -1074,7 +1443,11 @@ CallDoubleMethodA(obj,methodID,args)
        jvalue *                args
     CODE:
        {
+#ifdef WIN32
+           RETVAL = env->CallDoubleMethodA(obj,methodID,args);
+#else
            RETVAL = (*env)->CallDoubleMethodA(env, obj,methodID,args);
+#endif
            RESTOREENV;
        }
     OUTPUT:
@@ -1089,8 +1462,12 @@ CallVoidMethod(obj,methodID,...)
        int                     argoff = $min_args;
     CODE:
        {
-           jvalue * args = makeargs(aTHX_ sig, &ST(argoff), items - argoff);
+           jvalue * args = makeargs(sig, &ST(argoff), items - argoff);
+#ifdef WIN32
+           env->CallVoidMethodA(obj,methodID,args);
+#else
            (*env)->CallVoidMethodA(env, obj,methodID,args);
+#endif
            RESTOREENV;
        }
 
@@ -1103,7 +1480,11 @@ CallVoidMethodA(obj,methodID,args)
        jvalue *                args
     CODE:
        {
+#ifdef WIN32
+           env->CallVoidMethodA(obj,methodID,args);
+#else
            (*env)->CallVoidMethodA(env, obj,methodID,args);
+#endif
            RESTOREENV;
        }
 
@@ -1117,8 +1498,12 @@ CallNonvirtualObjectMethod(obj,clazz,methodID,...)
        int                     argoff = $min_args;
     CODE:
        {
-           jvalue * args = makeargs(aTHX_ sig, &ST(argoff), items - argoff);
+           jvalue * args = makeargs(sig, &ST(argoff), items - argoff);
+#ifdef WIN32
+           RETVAL = env->CallNonvirtualObjectMethodA(obj,clazz,methodID,args);
+#else
            RETVAL = (*env)->CallNonvirtualObjectMethodA(env, obj,clazz,methodID,args);
+#endif
            RESTOREENV;
        }
     OUTPUT:
@@ -1134,7 +1519,11 @@ CallNonvirtualObjectMethodA(obj,clazz,methodID,args)
        jvalue *                args
     CODE:
        {
+#ifdef WIN32
+           RETVAL = env->CallNonvirtualObjectMethodA(obj,clazz,methodID,args);
+#else
            RETVAL = (*env)->CallNonvirtualObjectMethodA(env, obj,clazz,methodID,args);
+#endif
            RESTOREENV;
        }
     OUTPUT:
@@ -1150,8 +1539,12 @@ CallNonvirtualBooleanMethod(obj,clazz,methodID,...)
        int                     argoff = $min_args;
     CODE:
        {
-           jvalue * args = makeargs(aTHX_ sig, &ST(argoff), items - argoff);
+           jvalue * args = makeargs(sig, &ST(argoff), items - argoff);
+#ifdef WIN32
+           RETVAL = env->CallNonvirtualBooleanMethodA(obj,clazz,methodID,args);
+#else
            RETVAL = (*env)->CallNonvirtualBooleanMethodA(env, obj,clazz,methodID,args);
+#endif
            RESTOREENV;
        }
     OUTPUT:
@@ -1167,7 +1560,11 @@ CallNonvirtualBooleanMethodA(obj,clazz,methodID, args)
        jvalue *                args
     CODE:
        {
+#ifdef WIN32
+           RETVAL = env->CallNonvirtualBooleanMethodA(obj,clazz,methodID, args);
+#else
            RETVAL = (*env)->CallNonvirtualBooleanMethodA(env, obj,clazz,methodID, args);
+#endif
            RESTOREENV;
        }
     OUTPUT:
@@ -1183,8 +1580,12 @@ CallNonvirtualByteMethod(obj,clazz,methodID,...)
        int                     argoff = $min_args;
     CODE:
        {
-           jvalue * args = makeargs(aTHX_ sig, &ST(argoff), items - argoff);
+           jvalue * args = makeargs(sig, &ST(argoff), items - argoff);
+#ifdef WIN32
+           RETVAL = env->CallNonvirtualByteMethodA(obj,clazz,methodID,args);
+#else
            RETVAL = (*env)->CallNonvirtualByteMethodA(env, obj,clazz,methodID,args);
+#endif
            RESTOREENV;
        }
     OUTPUT:
@@ -1200,7 +1601,11 @@ CallNonvirtualByteMethodA(obj,clazz,methodID,args)
        jvalue *                args
     CODE:
        {
+#ifdef WIN32
+           RETVAL = env->CallNonvirtualByteMethodA(obj,clazz,methodID,args);
+#else
            RETVAL = (*env)->CallNonvirtualByteMethodA(env, obj,clazz,methodID,args);
+#endif
            RESTOREENV;
        }
     OUTPUT:
@@ -1216,8 +1621,12 @@ CallNonvirtualCharMethod(obj,clazz,methodID,...)
        int                     argoff = $min_args;
     CODE:
        {
-           jvalue * args = makeargs(aTHX_ sig, &ST(argoff), items - argoff);
+           jvalue * args = makeargs(sig, &ST(argoff), items - argoff);
+#ifdef WIN32
+           RETVAL = env->CallNonvirtualCharMethodA(obj,clazz,methodID,args);
+#else
            RETVAL = (*env)->CallNonvirtualCharMethodA(env, obj,clazz,methodID,args);
+#endif
            RESTOREENV;
        }
     OUTPUT:
@@ -1233,7 +1642,11 @@ CallNonvirtualCharMethodA(obj,clazz,methodID,args)
        jvalue *                args
     CODE:
        {
+#ifdef WIN32
+           RETVAL = env->CallNonvirtualCharMethodA(obj,clazz,methodID,args);
+#else
            RETVAL = (*env)->CallNonvirtualCharMethodA(env, obj,clazz,methodID,args);
+#endif
            RESTOREENV;
        }
     OUTPUT:
@@ -1249,8 +1662,12 @@ CallNonvirtualShortMethod(obj,clazz,methodID,...)
        int                     argoff = $min_args;
     CODE:
        {
-           jvalue * args = makeargs(aTHX_ sig, &ST(argoff), items - argoff);
+           jvalue * args = makeargs(sig, &ST(argoff), items - argoff);
+#ifdef WIN32
+           RETVAL = env->CallNonvirtualShortMethodA(obj,clazz,methodID,args);
+#else
            RETVAL = (*env)->CallNonvirtualShortMethodA(env, obj,clazz,methodID,args);
+#endif
            RESTOREENV;
        }
     OUTPUT:
@@ -1266,7 +1683,11 @@ CallNonvirtualShortMethodA(obj,clazz,methodID,args)
        jvalue *                args
     CODE:
        {
+#ifdef WIN32
+           RETVAL = env->CallNonvirtualShortMethodA(obj,clazz,methodID,args);
+#else
            RETVAL = (*env)->CallNonvirtualShortMethodA(env, obj,clazz,methodID,args);
+#endif
            RESTOREENV;
        }
     OUTPUT:
@@ -1282,8 +1703,12 @@ CallNonvirtualIntMethod(obj,clazz,methodID,...)
        int                     argoff = $min_args;
     CODE:
        {
-           jvalue * args = makeargs(aTHX_ sig, &ST(argoff), items - argoff);
+           jvalue * args = makeargs(sig, &ST(argoff), items - argoff);
+#ifdef WIN32
+           RETVAL = env->CallNonvirtualIntMethodA(obj,clazz,methodID,args);
+#else
            RETVAL = (*env)->CallNonvirtualIntMethodA(env, obj,clazz,methodID,args);
+#endif
            RESTOREENV;
        }
     OUTPUT:
@@ -1299,7 +1724,11 @@ CallNonvirtualIntMethodA(obj,clazz,methodID,args)
        jvalue *                args
     CODE:
        {
+#ifdef WIN32
+           RETVAL = env->CallNonvirtualIntMethodA(obj,clazz,methodID,args);
+#else
            RETVAL = (*env)->CallNonvirtualIntMethodA(env, obj,clazz,methodID,args);
+#endif
            RESTOREENV;
        }
     OUTPUT:
@@ -1315,8 +1744,12 @@ CallNonvirtualLongMethod(obj,clazz,methodID,...)
        int                     argoff = $min_args;
     CODE:
        {
-           jvalue * args = makeargs(aTHX_ sig, &ST(argoff), items - argoff);
+           jvalue * args = makeargs(sig, &ST(argoff), items - argoff);
+#ifdef WIN32
+           RETVAL = env->CallNonvirtualLongMethodA(obj,clazz,methodID,args);
+#else
            RETVAL = (*env)->CallNonvirtualLongMethodA(env, obj,clazz,methodID,args);
+#endif
            RESTOREENV;
        }
     OUTPUT:
@@ -1332,7 +1765,11 @@ CallNonvirtualLongMethodA(obj,clazz,methodID,args)
        jvalue *                args
     CODE:
        {
+#ifdef WIN32
+           RETVAL = env->CallNonvirtualLongMethodA(obj,clazz,methodID,args);
+#else
            RETVAL = (*env)->CallNonvirtualLongMethodA(env, obj,clazz,methodID,args);
+#endif
            RESTOREENV;
        }
     OUTPUT:
@@ -1348,8 +1785,12 @@ CallNonvirtualFloatMethod(obj,clazz,methodID,...)
        int                     argoff = $min_args;
     CODE:
        {
-           jvalue * args = makeargs(aTHX_ sig, &ST(argoff), items - argoff);
+           jvalue * args = makeargs(sig, &ST(argoff), items - argoff);
+#ifdef WIN32
+           RETVAL = env->CallNonvirtualFloatMethodA(obj,clazz,methodID,args);
+#else
            RETVAL = (*env)->CallNonvirtualFloatMethodA(env, obj,clazz,methodID,args);
+#endif
            RESTOREENV;
        }
     OUTPUT:
@@ -1365,7 +1806,11 @@ CallNonvirtualFloatMethodA(obj,clazz,methodID,args)
        jvalue *                args
     CODE:
        {
+#ifdef WIN32
+           RETVAL = env->CallNonvirtualFloatMethodA(obj,clazz,methodID,args);
+#else
            RETVAL = (*env)->CallNonvirtualFloatMethodA(env, obj,clazz,methodID,args);
+#endif
            RESTOREENV;
        }
     OUTPUT:
@@ -1381,8 +1826,12 @@ CallNonvirtualDoubleMethod(obj,clazz,methodID,...)
        int                     argoff = $min_args;
     CODE:
        {
-           jvalue * args = makeargs(aTHX_ sig, &ST(argoff), items - argoff);
+           jvalue * args = makeargs(sig, &ST(argoff), items - argoff);
+#ifdef WIN32
+           RETVAL = env->CallNonvirtualDoubleMethodA(obj,clazz,methodID,args);
+#else
            RETVAL = (*env)->CallNonvirtualDoubleMethodA(env, obj,clazz,methodID,args);
+#endif
            RESTOREENV;
        }
     OUTPUT:
@@ -1398,7 +1847,11 @@ CallNonvirtualDoubleMethodA(obj,clazz,methodID,args)
        jvalue *                args
     CODE:
        {
+#ifdef WIN32
+           RETVAL = env->CallNonvirtualDoubleMethodA(obj,clazz,methodID,args);
+#else
            RETVAL = (*env)->CallNonvirtualDoubleMethodA(env, obj,clazz,methodID,args);
+#endif
            RESTOREENV;
        }
     OUTPUT:
@@ -1414,8 +1867,12 @@ CallNonvirtualVoidMethod(obj,clazz,methodID,...)
        int                     argoff = $min_args;
     CODE:
        {
-           jvalue * args = makeargs(aTHX_ sig, &ST(argoff), items - argoff);
+           jvalue * args = makeargs(sig, &ST(argoff), items - argoff);
+#ifdef WIN32
+           env->CallNonvirtualVoidMethodA(obj,clazz,methodID,args);
+#else
            (*env)->CallNonvirtualVoidMethodA(env, obj,clazz,methodID,args);
+#endif
            RESTOREENV;
        }
 
@@ -1429,7 +1886,11 @@ CallNonvirtualVoidMethodA(obj,clazz,methodID,args)
        jvalue *                args
     CODE:
        {
+#ifdef WIN32
+           env->CallNonvirtualVoidMethodA(obj,clazz,methodID,args);
+#else
            (*env)->CallNonvirtualVoidMethodA(env, obj,clazz,methodID,args);
+#endif
            RESTOREENV;
        }
 
@@ -1441,7 +1902,11 @@ GetFieldID(clazz,name,sig)
        const char *            sig
     CODE:
        {
+#ifdef WIN32
+           RETVAL = env->GetFieldID(clazz,name,sig);
+#else
            RETVAL = (*env)->GetFieldID(env, clazz,name,sig);
+#endif
            RESTOREENV;
        }
     OUTPUT:
@@ -1455,7 +1920,11 @@ GetObjectField(obj,fieldID)
        char *                  sig = 0;
     CODE:
        {
+#ifdef WIN32
+           RETVAL = env->GetObjectField(obj,fieldID);
+#else
            RETVAL = (*env)->GetObjectField(env, obj,fieldID);
+#endif
            RESTOREENV;
        }
     OUTPUT:
@@ -1469,7 +1938,11 @@ GetBooleanField(obj,fieldID)
        char *                  sig = 0;
     CODE:
        {
+#ifdef WIN32
+           RETVAL = env->GetBooleanField(obj,fieldID);
+#else
            RETVAL = (*env)->GetBooleanField(env, obj,fieldID);
+#endif
            RESTOREENV;
        }
     OUTPUT:
@@ -1483,7 +1956,11 @@ GetByteField(obj,fieldID)
        char *                  sig = 0;
     CODE:
        {
+#ifdef WIN32
+           RETVAL = env->GetByteField(obj,fieldID);
+#else
            RETVAL = (*env)->GetByteField(env, obj,fieldID);
+#endif
            RESTOREENV;
        }
     OUTPUT:
@@ -1497,7 +1974,11 @@ GetCharField(obj,fieldID)
        char *                  sig = 0;
     CODE:
        {
+#ifdef WIN32
+           RETVAL = env->GetCharField(obj,fieldID);
+#else
            RETVAL = (*env)->GetCharField(env, obj,fieldID);
+#endif
            RESTOREENV;
        }
     OUTPUT:
@@ -1511,7 +1992,11 @@ GetShortField(obj,fieldID)
        char *                  sig = 0;
     CODE:
        {
+#ifdef WIN32
+           RETVAL = env->GetShortField(obj,fieldID);
+#else
            RETVAL = (*env)->GetShortField(env, obj,fieldID);
+#endif
            RESTOREENV;
        }
     OUTPUT:
@@ -1525,7 +2010,11 @@ GetIntField(obj,fieldID)
        char *                  sig = 0;
     CODE:
        {
+#ifdef WIN32
+           RETVAL = env->GetIntField(obj,fieldID);
+#else
            RETVAL = (*env)->GetIntField(env, obj,fieldID);
+#endif
            RESTOREENV;
        }
     OUTPUT:
@@ -1539,7 +2028,11 @@ GetLongField(obj,fieldID)
        char *                  sig = 0;
     CODE:
        {
+#ifdef WIN32
+           RETVAL = env->GetLongField(obj,fieldID);
+#else
            RETVAL = (*env)->GetLongField(env, obj,fieldID);
+#endif
            RESTOREENV;
        }
     OUTPUT:
@@ -1553,7 +2046,11 @@ GetFloatField(obj,fieldID)
        char *                  sig = 0;
     CODE:
        {
+#ifdef WIN32
+           RETVAL = env->GetFloatField(obj,fieldID);
+#else
            RETVAL = (*env)->GetFloatField(env, obj,fieldID);
+#endif
            RESTOREENV;
        }
     OUTPUT:
@@ -1567,7 +2064,11 @@ GetDoubleField(obj,fieldID)
        char *                  sig = 0;
     CODE:
        {
+#ifdef WIN32
+           RETVAL = env->GetDoubleField(obj,fieldID);
+#else
            RETVAL = (*env)->GetDoubleField(env, obj,fieldID);
+#endif
            RESTOREENV;
        }
     OUTPUT:
@@ -1582,7 +2083,11 @@ SetObjectField(obj,fieldID,val)
        jobject                 val
     CODE:
        {
+#ifdef WIN32
+           env->SetObjectField(obj,fieldID,val);
+#else
            (*env)->SetObjectField(env, obj,fieldID,val);
+#endif
            RESTOREENV;
        }
 
@@ -1595,7 +2100,11 @@ SetBooleanField(obj,fieldID,val)
        jboolean                val
     CODE:
        {
+#ifdef WIN32
+           env->SetBooleanField(obj,fieldID,val);
+#else
            (*env)->SetBooleanField(env, obj,fieldID,val);
+#endif
            RESTOREENV;
        }
 
@@ -1608,7 +2117,11 @@ SetByteField(obj,fieldID,val)
        jbyte                   val
     CODE:
        {
+#ifdef WIN32
+           env->SetByteField(obj,fieldID,val);
+#else
            (*env)->SetByteField(env, obj,fieldID,val);
+#endif
            RESTOREENV;
        }
 
@@ -1621,7 +2134,11 @@ SetCharField(obj,fieldID,val)
        jchar                   val
     CODE:
        {
+#ifdef WIN32
+           env->SetCharField(obj,fieldID,val);
+#else
            (*env)->SetCharField(env, obj,fieldID,val);
+#endif
            RESTOREENV;
        }
 
@@ -1634,7 +2151,11 @@ SetShortField(obj,fieldID,val)
        jshort                  val
     CODE:
        {
+#ifdef WIN32
+           env->SetShortField(obj,fieldID,val);
+#else
            (*env)->SetShortField(env, obj,fieldID,val);
+#endif
            RESTOREENV;
        }
 
@@ -1647,7 +2168,11 @@ SetIntField(obj,fieldID,val)
        jint                    val
     CODE:
        {
+#ifdef WIN32
+           env->SetIntField(obj,fieldID,val);
+#else
            (*env)->SetIntField(env, obj,fieldID,val);
+#endif
            RESTOREENV;
        }
 
@@ -1660,7 +2185,11 @@ SetLongField(obj,fieldID,val)
        jlong                   val
     CODE:
        {
+#ifdef WIN32
+           env->SetLongField(obj,fieldID,val);
+#else
            (*env)->SetLongField(env, obj,fieldID,val);
+#endif
            RESTOREENV;
        }
 
@@ -1673,7 +2202,11 @@ SetFloatField(obj,fieldID,val)
        jfloat                  val
     CODE:
        {
+#ifdef WIN32
+           env->SetFloatField(obj,fieldID,val);
+#else
            (*env)->SetFloatField(env, obj,fieldID,val);
+#endif
            RESTOREENV;
        }
 
@@ -1686,7 +2219,11 @@ SetDoubleField(obj,fieldID,val)
        jdouble                 val
     CODE:
        {
+#ifdef WIN32
+           env->SetDoubleField(obj,fieldID,val);
+#else
            (*env)->SetDoubleField(env, obj,fieldID,val);
+#endif
            RESTOREENV;
        }
 
@@ -1698,7 +2235,11 @@ GetStaticMethodID(clazz,name,sig)
        const char *            sig
     CODE:
        {
+#ifdef WIN32
+           RETVAL = env->GetStaticMethodID(clazz,name,sig);
+#else
            RETVAL = (*env)->GetStaticMethodID(env, clazz,name,sig);
+#endif
            RESTOREENV;
        }
     OUTPUT:
@@ -1713,8 +2254,12 @@ CallStaticObjectMethod(clazz,methodID,...)
        int                     argoff = $min_args;
     CODE:
        {
-           jvalue * args = makeargs(aTHX_ sig, &ST(argoff), items - argoff);
+           jvalue * args = makeargs(sig, &ST(argoff), items - argoff);
+#ifdef WIN32
+           RETVAL = env->CallStaticObjectMethodA(clazz,methodID,args);
+#else
            RETVAL = (*env)->CallStaticObjectMethodA(env, clazz,methodID,args);
+#endif
            RESTOREENV;
        }
     OUTPUT:
@@ -1729,7 +2274,11 @@ CallStaticObjectMethodA(clazz,methodID,args)
        jvalue *                args
     CODE:
        {
+#ifdef WIN32
+           RETVAL = env->CallStaticObjectMethodA(clazz,methodID,args);
+#else
            RETVAL = (*env)->CallStaticObjectMethodA(env, clazz,methodID,args);
+#endif
            RESTOREENV;
        }
     OUTPUT:
@@ -1744,8 +2293,12 @@ CallStaticBooleanMethod(clazz,methodID,...)
        int                     argoff = $min_args;
     CODE:
        {
-           jvalue * args = makeargs(aTHX_ sig, &ST(argoff), items - argoff);
+           jvalue * args = makeargs(sig, &ST(argoff), items - argoff);
+#ifdef WIN32
+           RETVAL = env->CallStaticBooleanMethodA(clazz,methodID,args);
+#else
            RETVAL = (*env)->CallStaticBooleanMethodA(env, clazz,methodID,args);
+#endif
            RESTOREENV;
        }
     OUTPUT:
@@ -1760,7 +2313,11 @@ CallStaticBooleanMethodA(clazz,methodID,args)
        jvalue *                args
     CODE:
        {
+#ifdef WIN32
+           RETVAL = env->CallStaticBooleanMethodA(clazz,methodID,args);
+#else
            RETVAL = (*env)->CallStaticBooleanMethodA(env, clazz,methodID,args);
+#endif
            RESTOREENV;
        }
     OUTPUT:
@@ -1775,8 +2332,12 @@ CallStaticByteMethod(clazz,methodID,...)
        int                     argoff = $min_args;
     CODE:
        {
-           jvalue * args = makeargs(aTHX_ sig, &ST(argoff), items - argoff);
+           jvalue * args = makeargs(sig, &ST(argoff), items - argoff);
+#ifdef WIN32
+           RETVAL = env->CallStaticByteMethodA(clazz,methodID,args);
+#else
            RETVAL = (*env)->CallStaticByteMethodA(env, clazz,methodID,args);
+#endif
            RESTOREENV;
        }
     OUTPUT:
@@ -1791,7 +2352,11 @@ CallStaticByteMethodA(clazz,methodID,args)
        jvalue *                args
     CODE:
        {
+#ifdef WIN32
+           RETVAL = env->CallStaticByteMethodA(clazz,methodID,args);
+#else
            RETVAL = (*env)->CallStaticByteMethodA(env, clazz,methodID,args);
+#endif
            RESTOREENV;
        }
     OUTPUT:
@@ -1806,8 +2371,12 @@ CallStaticCharMethod(clazz,methodID,...)
        int                     argoff = $min_args;
     CODE:
        {
-           jvalue * args = makeargs(aTHX_ sig, &ST(argoff), items - argoff);
+           jvalue * args = makeargs(sig, &ST(argoff), items - argoff);
+#ifdef WIN32
+           RETVAL = env->CallStaticCharMethodA(clazz,methodID,args);
+#else
            RETVAL = (*env)->CallStaticCharMethodA(env, clazz,methodID,args);
+#endif
            RESTOREENV;
        }
     OUTPUT:
@@ -1822,7 +2391,11 @@ CallStaticCharMethodA(clazz,methodID,args)
        jvalue *                args
     CODE:
        {
+#ifdef WIN32
+           RETVAL = env->CallStaticCharMethodA(clazz,methodID,args);
+#else
            RETVAL = (*env)->CallStaticCharMethodA(env, clazz,methodID,args);
+#endif
            RESTOREENV;
        }
     OUTPUT:
@@ -1837,8 +2410,12 @@ CallStaticShortMethod(clazz,methodID,...)
        int                     argoff = $min_args;
     CODE:
        {
-           jvalue * args = makeargs(aTHX_ sig, &ST(argoff), items - argoff);
+           jvalue * args = makeargs(sig, &ST(argoff), items - argoff);
+#ifdef WIN32
+           RETVAL = env->CallStaticShortMethodA(clazz,methodID,args);
+#else
            RETVAL = (*env)->CallStaticShortMethodA(env, clazz,methodID,args);
+#endif
            RESTOREENV;
        }
     OUTPUT:
@@ -1853,7 +2430,11 @@ CallStaticShortMethodA(clazz,methodID,args)
        jvalue *                args
     CODE:
        {
+#ifdef WIN32
+           RETVAL = env->CallStaticShortMethodA(clazz,methodID,args);
+#else
            RETVAL = (*env)->CallStaticShortMethodA(env, clazz,methodID,args);
+#endif
            RESTOREENV;
        }
     OUTPUT:
@@ -1868,8 +2449,12 @@ CallStaticIntMethod(clazz,methodID,...)
        int                     argoff = $min_args;
     CODE:
        {
-           jvalue * args = makeargs(aTHX_ sig, &ST(argoff), items - argoff);
+           jvalue * args = makeargs(sig, &ST(argoff), items - argoff);
+#ifdef WIN32
+           RETVAL = env->CallStaticIntMethodA(clazz,methodID,args);
+#else
            RETVAL = (*env)->CallStaticIntMethodA(env, clazz,methodID,args);
+#endif
            RESTOREENV;
        }
     OUTPUT:
@@ -1884,7 +2469,11 @@ CallStaticIntMethodA(clazz,methodID,args)
        jvalue *                args
     CODE:
        {
+#ifdef WIN32
+           RETVAL = env->CallStaticIntMethodA(clazz,methodID,args);
+#else
            RETVAL = (*env)->CallStaticIntMethodA(env, clazz,methodID,args);
+#endif
            RESTOREENV;
        }
     OUTPUT:
@@ -1899,8 +2488,12 @@ CallStaticLongMethod(clazz,methodID,...)
        int                     argoff = $min_args;
     CODE:
        {
-           jvalue * args = makeargs(aTHX_ sig, &ST(argoff), items - argoff);
+           jvalue * args = makeargs(sig, &ST(argoff), items - argoff);
+#ifdef WIN32
+           RETVAL = env->CallStaticLongMethodA(clazz,methodID,args);
+#else
            RETVAL = (*env)->CallStaticLongMethodA(env, clazz,methodID,args);
+#endif
            RESTOREENV;
        }
     OUTPUT:
@@ -1915,7 +2508,11 @@ CallStaticLongMethodA(clazz,methodID,args)
        jvalue *                args
     CODE:
        {
+#ifdef WIN32
+           RETVAL = env->CallStaticLongMethodA(clazz,methodID,args);
+#else
            RETVAL = (*env)->CallStaticLongMethodA(env, clazz,methodID,args);
+#endif
            RESTOREENV;
        }
     OUTPUT:
@@ -1930,8 +2527,12 @@ CallStaticFloatMethod(clazz,methodID,...)
        int                     argoff = $min_args;
     CODE:
        {
-           jvalue * args = makeargs(aTHX_ sig, &ST(argoff), items - argoff);
+           jvalue * args = makeargs(sig, &ST(argoff), items - argoff);
+#ifdef WIN32
+           RETVAL = env->CallStaticFloatMethodA(clazz,methodID,args);
+#else
            RETVAL = (*env)->CallStaticFloatMethodA(env, clazz,methodID,args);
+#endif
            RESTOREENV;
        }
     OUTPUT:
@@ -1946,7 +2547,11 @@ CallStaticFloatMethodA(clazz,methodID,args)
        jvalue *                args
     CODE:
        {
+#ifdef WIN32
+           RETVAL = env->CallStaticFloatMethodA(clazz,methodID,args);
+#else
            RETVAL = (*env)->CallStaticFloatMethodA(env, clazz,methodID,args);
+#endif
            RESTOREENV;
        }
     OUTPUT:
@@ -1961,8 +2566,12 @@ CallStaticDoubleMethod(clazz,methodID,...)
        int                     argoff = $min_args;
     CODE:
        {
-           jvalue * args = makeargs(aTHX_ sig, &ST(argoff), items - argoff);
+           jvalue * args = makeargs(sig, &ST(argoff), items - argoff);
+#ifdef WIN32
+           RETVAL = env->CallStaticDoubleMethodA(clazz,methodID,args);
+#else
            RETVAL = (*env)->CallStaticDoubleMethodA(env, clazz,methodID,args);
+#endif
            RESTOREENV;
        }
     OUTPUT:
@@ -1977,7 +2586,11 @@ CallStaticDoubleMethodA(clazz,methodID,args)
        jvalue *                args
     CODE:
        {
+#ifdef WIN32
+           RETVAL = env->CallStaticDoubleMethodA(clazz,methodID,args);
+#else
            RETVAL = (*env)->CallStaticDoubleMethodA(env, clazz,methodID,args);
+#endif
            RESTOREENV;
        }
     OUTPUT:
@@ -1992,8 +2605,12 @@ CallStaticVoidMethod(cls,methodID,...)
        int                     argoff = $min_args;
     CODE:
        {
-           jvalue * args = makeargs(aTHX_ sig, &ST(argoff), items - argoff);
+           jvalue * args = makeargs(sig, &ST(argoff), items - argoff);
+#ifdef WIN32
+           env->CallStaticVoidMethodA(cls,methodID,args);
+#else
            (*env)->CallStaticVoidMethodA(env, cls,methodID,args);
+#endif
            RESTOREENV;
        }
 
@@ -2006,7 +2623,11 @@ CallStaticVoidMethodA(cls,methodID,args)
        jvalue *                args
     CODE:
        {
+#ifdef WIN32
+           env->CallStaticVoidMethodA(cls,methodID,args);
+#else
            (*env)->CallStaticVoidMethodA(env, cls,methodID,args);
+#endif
            RESTOREENV;
        }
 
@@ -2018,7 +2639,11 @@ GetStaticFieldID(clazz,name,sig)
        const char *            sig
     CODE:
        {
+#ifdef WIN32
+           RETVAL = env->GetStaticFieldID(clazz,name,sig);
+#else
            RETVAL = (*env)->GetStaticFieldID(env, clazz,name,sig);
+#endif
            RESTOREENV;
        }
     OUTPUT:
@@ -2032,7 +2657,11 @@ GetStaticObjectField(clazz,fieldID)
        char *                  sig = 0;
     CODE:
        {
+#ifdef WIN32
+           RETVAL = env->GetStaticObjectField(clazz,fieldID);
+#else
            RETVAL = (*env)->GetStaticObjectField(env, clazz,fieldID);
+#endif
            RESTOREENV;
        }
     OUTPUT:
@@ -2046,7 +2675,11 @@ GetStaticBooleanField(clazz,fieldID)
        char *                  sig = 0;
     CODE:
        {
+#ifdef WIN32
+           RETVAL = env->GetStaticBooleanField(clazz,fieldID);
+#else
            RETVAL = (*env)->GetStaticBooleanField(env, clazz,fieldID);
+#endif
            RESTOREENV;
        }
     OUTPUT:
@@ -2060,7 +2693,11 @@ GetStaticByteField(clazz,fieldID)
        char *                  sig = 0;
     CODE:
        {
+#ifdef WIN32
+           RETVAL = env->GetStaticByteField(clazz,fieldID);
+#else
            RETVAL = (*env)->GetStaticByteField(env, clazz,fieldID);
+#endif
            RESTOREENV;
        }
     OUTPUT:
@@ -2074,7 +2711,11 @@ GetStaticCharField(clazz,fieldID)
        char *                  sig = 0;
     CODE:
        {
+#ifdef WIN32
+           RETVAL = env->GetStaticCharField(clazz,fieldID);
+#else
            RETVAL = (*env)->GetStaticCharField(env, clazz,fieldID);
+#endif
            RESTOREENV;
        }
     OUTPUT:
@@ -2088,7 +2729,11 @@ GetStaticShortField(clazz,fieldID)
        char *                  sig = 0;
     CODE:
        {
+#ifdef WIN32
+           RETVAL = env->GetStaticShortField(clazz,fieldID);
+#else
            RETVAL = (*env)->GetStaticShortField(env, clazz,fieldID);
+#endif
            RESTOREENV;
        }
     OUTPUT:
@@ -2102,7 +2747,11 @@ GetStaticIntField(clazz,fieldID)
        char *                  sig = 0;
     CODE:
        {
+#ifdef WIN32
+           RETVAL = env->GetStaticIntField(clazz,fieldID);
+#else
            RETVAL = (*env)->GetStaticIntField(env, clazz,fieldID);
+#endif
            RESTOREENV;
        }
     OUTPUT:
@@ -2116,7 +2765,11 @@ GetStaticLongField(clazz,fieldID)
        char *                  sig = 0;
     CODE:
        {
+#ifdef WIN32
+           RETVAL = env->GetStaticLongField(clazz,fieldID);
+#else
            RETVAL = (*env)->GetStaticLongField(env, clazz,fieldID);
+#endif
            RESTOREENV;
        }
     OUTPUT:
@@ -2130,7 +2783,11 @@ GetStaticFloatField(clazz,fieldID)
        char *                  sig = 0;
     CODE:
        {
+#ifdef WIN32
+           RETVAL = env->GetStaticFloatField(clazz,fieldID);
+#else
            RETVAL = (*env)->GetStaticFloatField(env, clazz,fieldID);
+#endif
            RESTOREENV;
        }
     OUTPUT:
@@ -2144,7 +2801,11 @@ GetStaticDoubleField(clazz,fieldID)
        char *                  sig = 0;
     CODE:
        {
+#ifdef WIN32
+           RETVAL = env->GetStaticDoubleField(clazz,fieldID);
+#else
            RETVAL = (*env)->GetStaticDoubleField(env, clazz,fieldID);
+#endif
            RESTOREENV;
        }
     OUTPUT:
@@ -2159,7 +2820,11 @@ SetStaticObjectField(clazz,fieldID,value)
        jobject                 value
     CODE:
        {
+#ifdef WIN32
+         env->SetStaticObjectField(clazz,fieldID,value);
+#else
          (*env)->SetStaticObjectField(env, clazz,fieldID,value);
+#endif
            RESTOREENV;
        }
 
@@ -2172,7 +2837,11 @@ SetStaticBooleanField(clazz,fieldID,value)
        jboolean                value
     CODE:
        {
+#ifdef WIN32
+         env->SetStaticBooleanField(clazz,fieldID,value);
+#else
          (*env)->SetStaticBooleanField(env, clazz,fieldID,value);
+#endif
            RESTOREENV;
        }
 
@@ -2185,7 +2854,11 @@ SetStaticByteField(clazz,fieldID,value)
        jbyte                   value
     CODE:
        {
+#ifdef WIN32
+         env->SetStaticByteField(clazz,fieldID,value);
+#else
          (*env)->SetStaticByteField(env, clazz,fieldID,value);
+#endif
            RESTOREENV;
        }
 
@@ -2198,7 +2871,11 @@ SetStaticCharField(clazz,fieldID,value)
        jchar                   value
     CODE:
        {
+#ifdef WIN32
+         env->SetStaticCharField(clazz,fieldID,value);
+#else
          (*env)->SetStaticCharField(env, clazz,fieldID,value);
+#endif
            RESTOREENV;
        }
 
@@ -2211,7 +2888,11 @@ SetStaticShortField(clazz,fieldID,value)
        jshort                  value
     CODE:
        {
+#ifdef WIN32
+         env->SetStaticShortField(clazz,fieldID,value);
+#else
          (*env)->SetStaticShortField(env, clazz,fieldID,value);
+#endif
            RESTOREENV;
        }
 
@@ -2224,7 +2905,11 @@ SetStaticIntField(clazz,fieldID,value)
        jint                    value
     CODE:
        {
+#ifdef WIN32
+         env->SetStaticIntField(clazz,fieldID,value);
+#else
          (*env)->SetStaticIntField(env, clazz,fieldID,value);
+#endif
            RESTOREENV;
        }
 
@@ -2237,7 +2922,11 @@ SetStaticLongField(clazz,fieldID,value)
        jlong                   value
     CODE:
        {
+#ifdef WIN32
+         env->SetStaticLongField(clazz,fieldID,value);
+#else
          (*env)->SetStaticLongField(env, clazz,fieldID,value);
+#endif
            RESTOREENV;
        }
 
@@ -2250,7 +2939,11 @@ SetStaticFloatField(clazz,fieldID,value)
        jfloat                  value
     CODE:
        {
+#ifdef WIN32
+         env->SetStaticFloatField(clazz,fieldID,value);
+#else
          (*env)->SetStaticFloatField(env, clazz,fieldID,value);
+#endif
            RESTOREENV;
        }
 
@@ -2263,7 +2956,11 @@ SetStaticDoubleField(clazz,fieldID,value)
        jdouble                 value
     CODE:
        {
+#ifdef WIN32
+         env->SetStaticDoubleField(clazz,fieldID,value);
+#else
          (*env)->SetStaticDoubleField(env, clazz,fieldID,value);
+#endif
            RESTOREENV;
        }
 
@@ -2275,7 +2972,11 @@ NewString(unicode)
        const jchar *           unicode
     CODE:
        {
+#ifdef WIN32
+           RETVAL = env->NewString(unicode, unicode_len_);
+#else
            RETVAL = (*env)->NewString(env, unicode, unicode_len_);
+#endif
            RESTOREENV;
        }
     OUTPUT:
@@ -2287,7 +2988,11 @@ GetStringLength(str)
        jstring                 str
     CODE:
        {
+#ifdef WIN32
+           RETVAL = env->GetStringLength(str);
+#else
            RETVAL = (*env)->GetStringLength(env, str);
+#endif
            RESTOREENV;
        }
     OUTPUT:
@@ -2301,14 +3006,26 @@ GetStringChars(str)
        jsize                   RETVAL_len_ = NO_INIT;
     CODE:
        {
+#ifdef WIN32
+           RETVAL = env->GetStringChars(str,&isCopy);
+#else
            RETVAL = (*env)->GetStringChars(env, str,&isCopy);
+#endif
+#ifdef WIN32
+           RETVAL_len_ = env->GetStringLength(str);
+#else
            RETVAL_len_ = (*env)->GetStringLength(env, str);
+#endif
            RESTOREENV;
        }
     OUTPUT:
        RETVAL
     CLEANUP:
+#ifdef WIN32
+           env->ReleaseStringChars(str,RETVAL);
+#else
            (*env)->ReleaseStringChars(env, str,RETVAL);
+#endif
 
 jstring
 NewStringUTF(utf)
@@ -2316,7 +3033,11 @@ NewStringUTF(utf)
        const char *            utf
     CODE:
        {
+#ifdef WIN32
+           RETVAL = env->NewStringUTF(utf);
+#else
            RETVAL = (*env)->NewStringUTF(env, utf);
+#endif
            RESTOREENV;
        }
     OUTPUT:
@@ -2328,7 +3049,11 @@ GetStringUTFLength(str)
        jstring                 str
     CODE:
        {
+#ifdef WIN32
+           RETVAL = env->GetStringUTFLength(str);
+#else
            RETVAL = (*env)->GetStringUTFLength(env, str);
+#endif
            RESTOREENV;
        }
     OUTPUT:
@@ -2341,13 +3066,21 @@ GetStringUTFChars(str)
        jboolean                isCopy = NO_INIT;
     CODE:
        {
+#ifdef WIN32
+           RETVAL = env->GetStringUTFChars(str,&isCopy);
+#else
            RETVAL = (*env)->GetStringUTFChars(env, str,&isCopy);
+#endif
            RESTOREENV;
        }
     OUTPUT:
        RETVAL
     CLEANUP:
+#ifdef WIN32
+       env->ReleaseStringUTFChars(str, RETVAL);
+#else
        (*env)->ReleaseStringUTFChars(env, str, RETVAL);
+#endif
 
 
 jsize
@@ -2356,7 +3089,11 @@ GetArrayLength(array)
        jarray                  array
     CODE:
        {
+#ifdef WIN32
+           RETVAL = env->GetArrayLength(array);
+#else
            RETVAL = (*env)->GetArrayLength(env, array);
+#endif
            RESTOREENV;
        }
     OUTPUT:
@@ -2370,7 +3107,11 @@ NewObjectArray(len,clazz,init)
        jobject                 init
     CODE:
        {
+#ifdef WIN32
+           RETVAL = env->NewObjectArray(len,clazz,init);
+#else
            RETVAL = (*env)->NewObjectArray(env, len,clazz,init);
+#endif
            RESTOREENV;
        }
     OUTPUT:
@@ -2383,7 +3124,11 @@ GetObjectArrayElement(array,index)
        jsize                   index
     CODE:
        {
+#ifdef WIN32
+           RETVAL = env->GetObjectArrayElement(array,index);
+#else
            RETVAL = (*env)->GetObjectArrayElement(env, array,index);
+#endif
            RESTOREENV;
        }
     OUTPUT:
@@ -2397,7 +3142,11 @@ SetObjectArrayElement(array,index,val)
        jobject                 val
     CODE:
        {
+#ifdef WIN32
+           env->SetObjectArrayElement(array,index,val);
+#else
            (*env)->SetObjectArrayElement(env, array,index,val);
+#endif
            RESTOREENV;
        }
 
@@ -2407,7 +3156,11 @@ NewBooleanArray(len)
        jsize                   len
     CODE:
        {
+#ifdef WIN32
+           RETVAL = env->NewBooleanArray(len);
+#else
            RETVAL = (*env)->NewBooleanArray(env, len);
+#endif
            RESTOREENV;
        }
     OUTPUT:
@@ -2419,7 +3172,11 @@ NewByteArray(len)
        jsize                   len
     CODE:
        {
+#ifdef WIN32
+           RETVAL = env->NewByteArray(len);
+#else
            RETVAL = (*env)->NewByteArray(env, len);
+#endif
            RESTOREENV;
        }
     OUTPUT:
@@ -2431,7 +3188,11 @@ NewCharArray(len)
        jsize                   len
     CODE:
        {
+#ifdef WIN32
+           RETVAL = env->NewCharArray(len);
+#else
            RETVAL = (*env)->NewCharArray(env, len);
+#endif
            RESTOREENV;
        }
     OUTPUT:
@@ -2443,7 +3204,11 @@ NewShortArray(len)
        jsize                   len
     CODE:
        {
+#ifdef WIN32
+           RETVAL = env->NewShortArray(len);
+#else
            RETVAL = (*env)->NewShortArray(env, len);
+#endif
            RESTOREENV;
        }
     OUTPUT:
@@ -2455,7 +3220,11 @@ NewIntArray(len)
        jsize                   len
     CODE:
        {
+#ifdef WIN32
+           RETVAL = env->NewIntArray(len);
+#else
            RETVAL = (*env)->NewIntArray(env, len);
+#endif
            RESTOREENV;
        }
     OUTPUT:
@@ -2467,7 +3236,11 @@ NewLongArray(len)
        jsize                   len
     CODE:
        {
+#ifdef WIN32
+           RETVAL = env->NewLongArray(len);
+#else
            RETVAL = (*env)->NewLongArray(env, len);
+#endif
            RESTOREENV;
        }
     OUTPUT:
@@ -2479,7 +3252,11 @@ NewFloatArray(len)
        jsize                   len
     CODE:
        {
+#ifdef WIN32
+           RETVAL = env->NewFloatArray(len);
+#else
            RETVAL = (*env)->NewFloatArray(env, len);
+#endif
            RESTOREENV;
        }
     OUTPUT:
@@ -2491,7 +3268,11 @@ NewDoubleArray(len)
        jsize                   len
     CODE:
        {
+#ifdef WIN32
+           RETVAL = env->NewDoubleArray(len);
+#else
            RETVAL = (*env)->NewDoubleArray(env, len);
+#endif
            RESTOREENV;
        }
     OUTPUT:
@@ -2505,8 +3286,16 @@ GetBooleanArrayElements(array)
        jboolean                isCopy = NO_INIT;
     PPCODE:
        {
+#ifdef WIN32
+           RETVAL = env->GetBooleanArrayElements(array,&isCopy);
+#else
            RETVAL = (*env)->GetBooleanArrayElements(env, array,&isCopy);
+#endif
+#ifdef WIN32
+           RETVAL_len_ = env->GetArrayLength(array);
+#else
            RETVAL_len_ = (*env)->GetArrayLength(env, array);
+#endif
            if (GIMME == G_ARRAY) {
                int i;
                jboolean* r = RETVAL;
@@ -2523,7 +3312,11 @@ GetBooleanArrayElements(array)
                else
                    PUSHs(&PL_sv_no);
            }
+#ifdef WIN32
+           env->ReleaseBooleanArrayElements(array,RETVAL,JNI_ABORT);
+#else
            (*env)->ReleaseBooleanArrayElements(env, array,RETVAL,JNI_ABORT);
+#endif
            RESTOREENV;
        }
 
@@ -2535,8 +3328,16 @@ GetByteArrayElements(array)
        jboolean                isCopy = NO_INIT;
     PPCODE:
        {
+#ifdef WIN32
+           RETVAL = env->GetByteArrayElements(array,&isCopy);
+#else
            RETVAL = (*env)->GetByteArrayElements(env, array,&isCopy);
+#endif
+#ifdef WIN32
+           RETVAL_len_ = env->GetArrayLength(array);
+#else
            RETVAL_len_ = (*env)->GetArrayLength(env, array);
+#endif
            if (GIMME == G_ARRAY) {
                int i;
                jbyte* r = RETVAL;
@@ -2553,7 +3354,11 @@ GetByteArrayElements(array)
                else
                    PUSHs(&PL_sv_no);
            }
+#ifdef WIN32
+           env->ReleaseByteArrayElements(array,RETVAL,JNI_ABORT);
+#else
            (*env)->ReleaseByteArrayElements(env, array,RETVAL,JNI_ABORT);
+#endif
            RESTOREENV;
        }
 
@@ -2565,8 +3370,16 @@ GetCharArrayElements(array)
        jboolean                isCopy = NO_INIT;
     PPCODE:
        {
+#ifdef WIN32
+           RETVAL = env->GetCharArrayElements(array,&isCopy);
+#else
            RETVAL = (*env)->GetCharArrayElements(env, array,&isCopy);
+#endif
+#ifdef WIN32
+           RETVAL_len_ = env->GetArrayLength(array);
+#else
            RETVAL_len_ = (*env)->GetArrayLength(env, array);
+#endif
            if (GIMME == G_ARRAY) {
                int i;
                jchar* r = RETVAL;
@@ -2583,7 +3396,11 @@ GetCharArrayElements(array)
                else
                    PUSHs(&PL_sv_no);
            }
+#ifdef WIN32
+           env->ReleaseCharArrayElements(array,RETVAL,JNI_ABORT);
+#else
            (*env)->ReleaseCharArrayElements(env, array,RETVAL,JNI_ABORT);
+#endif
            RESTOREENV;
        }
 
@@ -2595,8 +3412,16 @@ GetShortArrayElements(array)
        jboolean                isCopy = NO_INIT;
     PPCODE:
        {
+#ifdef WIN32
+           RETVAL = env->GetShortArrayElements(array,&isCopy);
+#else
            RETVAL = (*env)->GetShortArrayElements(env, array,&isCopy);
+#endif
+#ifdef WIN32
+           RETVAL_len_ = env->GetArrayLength(array);
+#else
            RETVAL_len_ = (*env)->GetArrayLength(env, array);
+#endif
            if (GIMME == G_ARRAY) {
                int i;
                jshort* r = RETVAL;
@@ -2613,7 +3438,11 @@ GetShortArrayElements(array)
                else
                    PUSHs(&PL_sv_no);
            }
+#ifdef WIN32
+           env->ReleaseShortArrayElements(array,RETVAL,JNI_ABORT);
+#else
            (*env)->ReleaseShortArrayElements(env, array,RETVAL,JNI_ABORT);
+#endif
            RESTOREENV;
        }
 
@@ -2625,8 +3454,16 @@ GetIntArrayElements(array)
        jboolean                isCopy = NO_INIT;
     PPCODE:
        {
+#ifdef WIN32
+           RETVAL = env->GetIntArrayElements(array,&isCopy);
+#else
            RETVAL = (*env)->GetIntArrayElements(env, array,&isCopy);
+#endif
+#ifdef WIN32
+           RETVAL_len_ = env->GetArrayLength(array);
+#else
            RETVAL_len_ = (*env)->GetArrayLength(env, array);
+#endif
            if (GIMME == G_ARRAY) {
                int i;
                jint* r = RETVAL;
@@ -2643,7 +3480,11 @@ GetIntArrayElements(array)
                else
                    PUSHs(&PL_sv_no);
            }
+#ifdef WIN32
+           env->ReleaseIntArrayElements(array,RETVAL,JNI_ABORT);
+#else
            (*env)->ReleaseIntArrayElements(env, array,RETVAL,JNI_ABORT);
+#endif
            RESTOREENV;
        }
 
@@ -2655,8 +3496,16 @@ GetLongArrayElements(array)
        jboolean                isCopy = NO_INIT;
     PPCODE:
        {
+#ifdef WIN32
+           RETVAL = env->GetLongArrayElements(array,&isCopy);
+#else
            RETVAL = (*env)->GetLongArrayElements(env, array,&isCopy);
+#endif
+#ifdef WIN32
+           RETVAL_len_ = env->GetArrayLength(array);
+#else
            RETVAL_len_ = (*env)->GetArrayLength(env, array);
+#endif
            if (GIMME == G_ARRAY) {
                int i;
                jlong* r = RETVAL;
@@ -2673,7 +3522,11 @@ GetLongArrayElements(array)
                else
                    PUSHs(&PL_sv_no);
            }
+#ifdef WIN32
+           env->ReleaseLongArrayElements(array,RETVAL,JNI_ABORT);
+#else
            (*env)->ReleaseLongArrayElements(env, array,RETVAL,JNI_ABORT);
+#endif
            RESTOREENV;
        }
 
@@ -2685,8 +3538,16 @@ GetFloatArrayElements(array)
        jboolean                isCopy = NO_INIT;
     PPCODE:
        {
+#ifdef WIN32
+           RETVAL = env->GetFloatArrayElements(array,&isCopy);
+#else
            RETVAL = (*env)->GetFloatArrayElements(env, array,&isCopy);
+#endif
+#ifdef WIN32
+           RETVAL_len_ = env->GetArrayLength(array);
+#else
            RETVAL_len_ = (*env)->GetArrayLength(env, array);
+#endif
            if (GIMME == G_ARRAY) {
                int i;
                jfloat* r = RETVAL;
@@ -2703,7 +3564,11 @@ GetFloatArrayElements(array)
                else
                    PUSHs(&PL_sv_no);
            }
+#ifdef WIN32
+           env->ReleaseFloatArrayElements(array,RETVAL,JNI_ABORT);
+#else
            (*env)->ReleaseFloatArrayElements(env, array,RETVAL,JNI_ABORT);
+#endif
            RESTOREENV;
        }
 
@@ -2715,8 +3580,16 @@ GetDoubleArrayElements(array)
        jboolean                isCopy = NO_INIT;
     PPCODE:
        {
+#ifdef WIN32
+           RETVAL = env->GetDoubleArrayElements(array,&isCopy);
+#else
            RETVAL = (*env)->GetDoubleArrayElements(env, array,&isCopy);
+#endif
+#ifdef WIN32
+           RETVAL_len_ = env->GetArrayLength(array);
+#else
            RETVAL_len_ = (*env)->GetArrayLength(env, array);
+#endif
            if (GIMME == G_ARRAY) {
                int i;
                jdouble* r = RETVAL;
@@ -2733,7 +3606,11 @@ GetDoubleArrayElements(array)
                else
                    PUSHs(&PL_sv_no);
            }
+#ifdef WIN32
+           env->ReleaseDoubleArrayElements(array,RETVAL,JNI_ABORT);
+#else
            (*env)->ReleaseDoubleArrayElements(env, array,RETVAL,JNI_ABORT);
+#endif
            RESTOREENV;
        }
 
@@ -2748,7 +3625,11 @@ GetBooleanArrayRegion(array,start,len,buf)
        jboolean *              buf = (jboolean*)sv_grow(ST(3),len * sizeof(jboolean)+1);
     CODE:
        {
+#ifdef WIN32
+           env->GetBooleanArrayRegion(array,start,len,buf);
+#else
            (*env)->GetBooleanArrayRegion(env, array,start,len,buf);
+#endif
            SvCUR_set(ST(3), len * sizeof(jboolean));
            *SvEND(ST(3)) = '\0';
            RESTOREENV;
@@ -2765,7 +3646,11 @@ GetByteArrayRegion(array,start,len,buf)
        jbyte *                 buf = (jbyte*)sv_grow(ST(3),len * sizeof(jbyte)+1);
     CODE:
        {
+#ifdef WIN32
+           env->GetByteArrayRegion(array,start,len,buf);
+#else
            (*env)->GetByteArrayRegion(env, array,start,len,buf);
+#endif
            SvCUR_set(ST(3), len * sizeof(jbyte));
            *SvEND(ST(3)) = '\0';
            RESTOREENV;
@@ -2782,7 +3667,11 @@ GetCharArrayRegion(array,start,len,buf)
        jchar *                 buf = (jchar*)sv_grow(ST(3),len * sizeof(jchar)+1);
     CODE:
        {
+#ifdef WIN32
+           env->GetCharArrayRegion(array,start,len,buf);
+#else
            (*env)->GetCharArrayRegion(env, array,start,len,buf);
+#endif
            SvCUR_set(ST(3), len * sizeof(jchar));
            *SvEND(ST(3)) = '\0';
            RESTOREENV;
@@ -2799,7 +3688,11 @@ GetShortArrayRegion(array,start,len,buf)
        jshort *                buf = (jshort*)sv_grow(ST(3),len * sizeof(jshort)+1);
     CODE:
        {
+#ifdef WIN32
+           env->GetShortArrayRegion(array,start,len,buf);
+#else
            (*env)->GetShortArrayRegion(env, array,start,len,buf);
+#endif
            SvCUR_set(ST(3), len * sizeof(jshort));
            *SvEND(ST(3)) = '\0';
            RESTOREENV;
@@ -2816,7 +3709,11 @@ GetIntArrayRegion(array,start,len,buf)
        jint *                  buf = (jint*)sv_grow(ST(3),len * sizeof(jint)+1);
     CODE:
        {
+#ifdef WIN32
+           env->GetIntArrayRegion(array,start,len,buf);
+#else
            (*env)->GetIntArrayRegion(env, array,start,len,buf);
+#endif
            SvCUR_set(ST(3), len * sizeof(jint));
            *SvEND(ST(3)) = '\0';
            RESTOREENV;
@@ -2833,7 +3730,11 @@ GetLongArrayRegion(array,start,len,buf)
        jlong *                 buf = (jlong*)sv_grow(ST(3),len * sizeof(jlong)+1);
     CODE:
        {
+#ifdef WIN32
+           env->GetLongArrayRegion(array,start,len,buf);
+#else
            (*env)->GetLongArrayRegion(env, array,start,len,buf);
+#endif
            SvCUR_set(ST(3), len * sizeof(jlong));
            *SvEND(ST(3)) = '\0';
            RESTOREENV;
@@ -2850,7 +3751,11 @@ GetFloatArrayRegion(array,start,len,buf)
        jfloat *                buf = (jfloat*)sv_grow(ST(3),len * sizeof(jfloat)+1);
     CODE:
        {
+#ifdef WIN32
+           env->GetFloatArrayRegion(array,start,len,buf);
+#else
            (*env)->GetFloatArrayRegion(env, array,start,len,buf);
+#endif
            SvCUR_set(ST(3), len * sizeof(jfloat));
            *SvEND(ST(3)) = '\0';
            RESTOREENV;
@@ -2867,7 +3772,11 @@ GetDoubleArrayRegion(array,start,len,buf)
        jdouble *               buf = (jdouble*)sv_grow(ST(3),len * sizeof(jdouble)+1);
     CODE:
        {
+#ifdef WIN32
+           env->GetDoubleArrayRegion(array,start,len,buf);
+#else
            (*env)->GetDoubleArrayRegion(env, array,start,len,buf);
+#endif
            SvCUR_set(ST(3), len * sizeof(jdouble));
            *SvEND(ST(3)) = '\0';
            RESTOREENV;
@@ -2885,10 +3794,14 @@ SetBooleanArrayRegion(array,start,len,buf)
     CODE:
        {
            if (buf_len_ < len)
-               Perl_croak(aTHX_ "string is too short");
-           else if (buf_len_ > len && ckWARN(WARN_UNSAFE))
-               Perl_warner(aTHX_ WARN_UNSAFE, "string is too long");
+               croak("string is too short");
+           else if (buf_len_ > len && PL_dowarn)
+               warn("string is too long");
+#ifdef WIN32
+           env->SetBooleanArrayRegion(array,start,len,buf);
+#else
            (*env)->SetBooleanArrayRegion(env, array,start,len,buf);
+#endif
            RESTOREENV;
        }
 
@@ -2904,10 +3817,14 @@ SetByteArrayRegion(array,start,len,buf)
     CODE:
        {
            if (buf_len_ < len)
-               Perl_croak(aTHX_ "string is too short");
-           else if (buf_len_ > len && ckWARN(WARN_UNSAFE))
-               Perl_warner(aTHX_ WARN_UNSAFE, "string is too long");
+               croak("string is too short");
+           else if (buf_len_ > len && PL_dowarn)
+               warn("string is too long");
+#ifdef WIN32
+           env->SetByteArrayRegion(array,start,len,buf);
+#else
            (*env)->SetByteArrayRegion(env, array,start,len,buf);
+#endif
            RESTOREENV;
        }
 
@@ -2923,10 +3840,14 @@ SetCharArrayRegion(array,start,len,buf)
     CODE:
        {
            if (buf_len_ < len)
-               Perl_croak(aTHX_ "string is too short");
-           else if (buf_len_ > len && ckWARN(WARN_UNSAFE))
-               Perl_warner(aTHX_ WARN_UNSAFE, "string is too long");
+               croak("string is too short");
+           else if (buf_len_ > len && PL_dowarn)
+               warn("string is too long");
+#ifdef WIN32
+           env->SetCharArrayRegion(array,start,len,buf);
+#else
            (*env)->SetCharArrayRegion(env, array,start,len,buf);
+#endif
            RESTOREENV;
        }
 
@@ -2942,10 +3863,14 @@ SetShortArrayRegion(array,start,len,buf)
     CODE:
        {
            if (buf_len_ < len)
-               Perl_croak(aTHX_ "string is too short");
-           else if (buf_len_ > len && ckWARN(WARN_UNSAFE))
-               Perl_warner(aTHX_ WARN_UNSAFE, "string is too long");
+               croak("string is too short");
+           else if (buf_len_ > len && PL_dowarn)
+               warn("string is too long");
+#ifdef WIN32
+           env->SetShortArrayRegion(array,start,len,buf);
+#else
            (*env)->SetShortArrayRegion(env, array,start,len,buf);
+#endif
            RESTOREENV;
        }
 
@@ -2961,10 +3886,14 @@ SetIntArrayRegion(array,start,len,buf)
     CODE:
        {
            if (buf_len_ < len)
-               Perl_croak(aTHX_ "string is too short");
-           else if (buf_len_ > len && ckWARN(WARN_UNSAFE))
-               Perl_warner(aTHX_ WARN_UNSAFE, "string is too long");
+               croak("string is too short");
+           else if (buf_len_ > len && PL_dowarn)
+               warn("string is too long");
+#ifdef WIN32
+           env->SetIntArrayRegion(array,start,len,buf);
+#else
            (*env)->SetIntArrayRegion(env, array,start,len,buf);
+#endif
            RESTOREENV;
        }
 
@@ -2980,10 +3909,14 @@ SetLongArrayRegion(array,start,len,buf)
     CODE:
        {
            if (buf_len_ < len)
-               Perl_croak(aTHX_ "string is too short");
-           else if (buf_len_ > len && ckWARN(WARN_UNSAFE))
-               Perl_warner(aTHX_ WARN_UNSAFE, "string is too long");
+               croak("string is too short");
+           else if (buf_len_ > len && PL_dowarn)
+               warn("string is too long");
+#ifdef WIN32
+           env->SetLongArrayRegion(array,start,len,buf);
+#else
            (*env)->SetLongArrayRegion(env, array,start,len,buf);
+#endif
            RESTOREENV;
        }
 
@@ -2999,10 +3932,14 @@ SetFloatArrayRegion(array,start,len,buf)
     CODE:
        {
            if (buf_len_ < len)
-               Perl_croak(aTHX_ "string is too short");
-           else if (buf_len_ > len && ckWARN(WARN_UNSAFE))
-               Perl_warner(aTHX_ WARN_UNSAFE, "string is too long");
+               croak("string is too short");
+           else if (buf_len_ > len && PL_dowarn)
+               warn("string is too long");
+#ifdef WIN32
+           env->SetFloatArrayRegion(array,start,len,buf);
+#else
            (*env)->SetFloatArrayRegion(env, array,start,len,buf);
+#endif
            RESTOREENV;
        }
 
@@ -3018,10 +3955,14 @@ SetDoubleArrayRegion(array,start,len,buf)
     CODE:
        {
            if (buf_len_ < len)
-               Perl_croak(aTHX_ "string is too short");
-           else if (buf_len_ > len && ckWARN(WARN_UNSAFE))
-               Perl_warner(aTHX_ WARN_UNSAFE, "string is too long");
+               croak("string is too short");
+           else if (buf_len_ > len && PL_dowarn)
+               warn("string is too long");
+#ifdef WIN32
+           env->SetDoubleArrayRegion(array,start,len,buf);
+#else
            (*env)->SetDoubleArrayRegion(env, array,start,len,buf);
+#endif
            RESTOREENV;
        }
 
@@ -3033,7 +3974,11 @@ RegisterNatives(clazz,methods,nMethods)
        jint                    nMethods
     CODE:
        {
+#ifdef WIN32
+           RETVAL = env->RegisterNatives(clazz,methods,nMethods);
+#else
            RETVAL = (*env)->RegisterNatives(env, clazz,methods,nMethods);
+#endif
        }
 
 SysRet
@@ -3042,7 +3987,11 @@ UnregisterNatives(clazz)
        jclass                  clazz
     CODE:
        {
+#ifdef WIN32
+           RETVAL = env->UnregisterNatives(clazz);
+#else
            RETVAL = (*env)->UnregisterNatives(env, clazz);
+#endif
        }
     OUTPUT:
        RETVAL  
@@ -3053,7 +4002,11 @@ MonitorEnter(obj)
        jobject                 obj
     CODE:
        {
+#ifdef WIN32
+           RETVAL = env->MonitorEnter(obj);
+#else
            RETVAL = (*env)->MonitorEnter(env, obj);
+#endif
            RESTOREENV;
        }
     OUTPUT:
@@ -3065,7 +4018,11 @@ MonitorExit(obj)
        jobject                 obj
     CODE:
        {
+#ifdef WIN32
+           RETVAL = env->MonitorExit(obj);
+#else
            RETVAL = (*env)->MonitorExit(env, obj);
+#endif
            RESTOREENV;
        }
     OUTPUT:
@@ -3077,12 +4034,23 @@ GetJavaVM(...)
     CODE:
        {
            if (env) {  /* We're embedded. */
+#ifdef WIN32
+               if (env->GetJavaVM(&RETVAL) < 0)
+#else
                if ((*env)->GetJavaVM(env, &RETVAL) < 0)
+#endif
                    RETVAL = 0;
            }
            else {      /* We're embedding. */
-               JDK1_1InitArgs vm_args;
+#ifdef KAFFE
+                JavaVMInitArgs vm_args;
+#else
+                JDK1_1InitArgs vm_args;
+#endif
                char *lib;
+               if (jpldebug) {
+                   fprintf(stderr, "We're embedding Java in Perl.\n");
+               }
 
                if (items--) {
                    ++mark;
@@ -3090,47 +4058,84 @@ GetJavaVM(...)
                }
                else
                    lib = 0;
-
+               if (jpldebug) {
+                   fprintf(stderr, "lib is %s.\n", lib);
+               }
+#ifdef WIN32
+               if (!LoadLibrary("javai.dll")) {
+                   if (lib && !LoadLibrary(lib))
+                       croak("Can't load javai.dll");
+               }
+#else
+               if (jpldebug) {
+                   fprintf(stderr, "Opening Java shared library.\n");
+                }
+#ifdef KAFFE
+               if (!dlopen("libkaffevm.so", RTLD_LAZY|RTLD_GLOBAL)) {
+#else
                if (!dlopen("libjava.so", RTLD_LAZY|RTLD_GLOBAL)) {
+#endif
                    if (lib && !dlopen(lib, RTLD_LAZY|RTLD_GLOBAL))
-                       Perl_croak(aTHX_ "Can't load libjava.so");
+                       croak("Can't load Java shared library.");
                }
+#endif
 
                JNI_GetDefaultJavaVMInitArgs(&vm_args);
                vm_args.exit = &call_my_exit;
+               if (jpldebug) {
+            fprintf(stderr, "items = %d\n", items);
+            fprintf(stderr, "mark = %s\n", SvPV(*mark, PL_na));
+        }
+               ++mark;
                while (items > 1) {
-                   char *s = SvPV(*++mark,PL_na);
+                   char *s = SvPV(*mark,PL_na);
+                   ++mark;
+                   if (jpldebug) {
+                fprintf(stderr, "*s = %s\n", s);
+                fprintf(stderr, "val = %s\n", SvPV(*mark, PL_na));
+            }
                    items -= 2;
                    if (strEQ(s, "checkSource"))
-                       vm_args.checkSource = (jint)SvIV(*++mark);
+                       vm_args.checkSource = (jint)SvIV(*mark);
                    else if (strEQ(s, "nativeStackSize"))
-                       vm_args.nativeStackSize = (jint)SvIV(*++mark);
+                       vm_args.nativeStackSize = (jint)SvIV(*mark);
                    else if (strEQ(s, "javaStackSize"))
-                       vm_args.javaStackSize = (jint)SvIV(*++mark);
+                       vm_args.javaStackSize = (jint)SvIV(*mark);
                    else if (strEQ(s, "minHeapSize"))
-                       vm_args.minHeapSize = (jint)SvIV(*++mark);
+                       vm_args.minHeapSize = (jint)SvIV(*mark);
                    else if (strEQ(s, "maxHeapSize"))
-                       vm_args.maxHeapSize = (jint)SvIV(*++mark);
+                       vm_args.maxHeapSize = (jint)SvIV(*mark);
                    else if (strEQ(s, "verifyMode"))
-                       vm_args.verifyMode = (jint)SvIV(*++mark);
+                       vm_args.verifyMode = (jint)SvIV(*mark);
                    else if (strEQ(s, "classpath"))
-                       vm_args.classpath = savepv(SvPV(*++mark,PL_na));
+                       vm_args.classpath = savepv(SvPV(*mark,PL_na));
                    else if (strEQ(s, "enableClassGC"))
-                       vm_args.enableClassGC = (jint)SvIV(*++mark);
+                       vm_args.enableClassGC = (jint)SvIV(*mark);
                    else if (strEQ(s, "enableVerboseGC"))
-                       vm_args.enableVerboseGC = (jint)SvIV(*++mark);
+                       vm_args.enableVerboseGC = (jint)SvIV(*mark);
                    else if (strEQ(s, "disableAsyncGC"))
-                       vm_args.disableAsyncGC = (jint)SvIV(*++mark);
+                       vm_args.disableAsyncGC = (jint)SvIV(*mark);
+#ifndef KAFFE
                    else if (strEQ(s, "verbose"))
-                       vm_args.verbose = (jint)SvIV(*++mark);
+                       vm_args.verbose = (jint)SvIV(*mark); 
                    else if (strEQ(s, "debugging"))
-                       vm_args.debugging = (jboolean)SvIV(*++mark);
+                       vm_args.debugging = (jboolean)SvIV(*mark);
                    else if (strEQ(s, "debugPort"))
-                       vm_args.debugPort = (jint)SvIV(*++mark);
+                       vm_args.debugPort = (jint)SvIV(*mark); 
+#endif
                    else
-                       Perl_croak(aTHX_ "unrecognized option: %s", s);
+                       croak("unrecognized option: %s", s);
+               }
+
+               if (jpldebug) {
+                   fprintf(stderr, "Creating Java VM...\n");
+                   fprintf(stderr, "Working CLASSPATH: %s\n", 
+                       vm_args.classpath);
                }
                JNI_CreateJavaVM(&RETVAL, &jplcurenv, &vm_args);
+               if (jpldebug) {
+                   fprintf(stderr, "Created Java VM.\n");
+               }
            }
        }
 
diff --git a/jpl/JNI/JNIConfig b/jpl/JNI/JNIConfig
new file mode 100644 (file)
index 0000000..494de13
--- /dev/null
@@ -0,0 +1,13 @@
+eval `$JPL_SRC/setvars -perl`;
+$java = $ENV{JAVA_HOME};
+$jpl = $ENV{JPL_HOME};
+
+# Where are the Java includes?
+#
+@INCLUDE = ("$java/include", "$java/include/$^O", "$java/include/genunix");
+
+# Are we embedding Perl in Java?
+#
+$EMBEDDEDPERL = 1;
+
+1;
diff --git a/jpl/JNI/JNIConfig.Win32 b/jpl/JNI/JNIConfig.Win32
new file mode 100644 (file)
index 0000000..000566a
--- /dev/null
@@ -0,0 +1,21 @@
+# Are we using Kaffe?
+#
+$KAFFE = 0;
+
+# Where are the Java includes?
+#
+@INCLUDE = ("C:\\jdk1.1.8\\include", "C:\\jdk1.1.8\\include\\win32");
+
+# Are we embedding Perl in Java?
+#
+$EMBEDDEDPERL = 0;
+
+# Extra C flags
+#
+$CCFLAGS=" -Z7 -D_DEBUG";
+
+$MYEXTLIB = "C:\\jdk1.1.8\\lib\\javai.lib " .
+            "$Config{installarchlib}\\CORE\\perlcore.lib " .
+            "$Config{installarchlib}\\CORE\\perlcapi.lib";
+
+1;
diff --git a/jpl/JNI/JNIConfig.kaffe b/jpl/JNI/JNIConfig.kaffe
new file mode 100644 (file)
index 0000000..9b2fa87
--- /dev/null
@@ -0,0 +1,26 @@
+eval `$JPL_SRC/setvars -perl`;
+$java = $ENV{JAVA_HOME};
+$jpl = $ENV{JPL_HOME};
+
+# Are we using Kaffe?
+#
+$KAFFE = 1;
+
+# What is the name of the JVM library?
+#
+$LIBJVM="kaffevm";
+
+# Where is the JVM library?
+#
+$LIBLOC="/usr/local/lib";
+
+# Where are the Java includes?
+#
+#@INCLUDE = ('$java/include', '$java/include/$^O' '$java/include/genunix');
+@INCLUDE = ( '/usr/local/include/kaffe');
+
+# Are we embedding Perl in Java?
+#
+$EMBEDDEDPERL = 0;
+
+1;
diff --git a/jpl/JNI/JNIConfig.noembed b/jpl/JNI/JNIConfig.noembed
new file mode 100644 (file)
index 0000000..ae03b2c
--- /dev/null
@@ -0,0 +1,25 @@
+eval `$JPL_SRC/setvars -perl`;
+$java = $ENV{JAVA_HOME};
+$jpl = $ENV{JPL_HOME};
+
+# Are we using Kaffe?
+#
+$KAFFE = 0;
+
+# What is the name of the JVM library?
+#
+$LIBJVM="java";
+
+# Where is the JVM library?
+#
+$LIBLOC="/usr/local/java/lib/i686/green_threads/";
+
+# Where are the Java includes?
+#
+@INCLUDE = ("$java/include", "$java/include/$^O", "$java/include/genunix");
+
+# Are we embedding Perl in Java?
+#
+$EMBEDDEDPERL = 0;
+
+1;
diff --git a/jpl/JNI/JNIConfig.standard b/jpl/JNI/JNIConfig.standard
new file mode 100644 (file)
index 0000000..494de13
--- /dev/null
@@ -0,0 +1,13 @@
+eval `$JPL_SRC/setvars -perl`;
+$java = $ENV{JAVA_HOME};
+$jpl = $ENV{JPL_HOME};
+
+# Where are the Java includes?
+#
+@INCLUDE = ("$java/include", "$java/include/$^O", "$java/include/genunix");
+
+# Are we embedding Perl in Java?
+#
+$EMBEDDEDPERL = 1;
+
+1;
index 2611ff1..1a54b9d 100644 (file)
 #!/usr/bin/perl
-
-$JPL_SRC = "..";
-
 use ExtUtils::MakeMaker;
+use Getopt::Std;
 use Config;
+$ARCHNAME = $Config{archname};
+use File::Basename;
 
-eval `$JPL_SRC/setvars -perl`;
+getopts('e'); # embedding?
 
-$java = $ENV{JAVA_HOME};
-$jpl = $ENV{JPL_HOME};
+#require "JNIConfig";
 
-$ARCHNAME = $Config{archname};
+if ($^O eq 'solaris') {
+    $LIBPATH = " -R$Config{archlib}/CORE -L$Config{archlib}/CORE";
+} elsif ($^O eq 'MSWin32') {
+    $LIBPATH = " -L$Config{archlib}\\CORE";
+} else {
+    $LIBPATH = " -L$Config{archlib}/CORE";
+}
+#$LIBS = " -lperl";
 
-# See lib/ExtUtils/MakeMaker.pm for details of how to influence
-# the contents of the Makefile that is written.
-WriteMakefile(
-    NAME       => 'JNI',
+# Figure out where Java might live
+#
+my @JAVA_HOME_GUESSES = qw(/usr/local/java /usr/java /usr/local/jdk117_v3
+                           /usr/local/lib/kaffe C:\\JDK1.1.8
+                           C:\\JDK1.2.1 );
+if (! defined $ENV{JAVA_HOME}) {
+        print "You didn't define JAVA_HOME, so I'm trying a few guesses.\n";
+        print "If this fails, you might want to try setting JAVA_HOME and\n";
+        print "running me again.\n";
+} else {
+        @JAVA_HOME_GUESSES = ( $ENV{JAVA_HOME} );
+}
+
+# Let's find out where jni.h lives
+#
+my @INCLUDE = find_includes();
+$INC = join(" -I", ("", @INCLUDE));
+
+# Let's find out the name of the Java shared library
+#
+my @JAVALIBS = find_libs();
+
+# Find out some defines based on the library we are linking to
+#
+foreach (@JAVALIBS) {
+    if ( /javai.lib$/ or /jvm.lib$/) { # We're on Win32
+        $INC =~ s#/#\\#g;
+        $INC =~ s#\\$##;
+        $CCFLAGS .= "-DWIN32 -Z7 -D_DEBUG";
+        $MYEXTLIB = $libjava;
+    } elsif (/libkaffevm.so$/) {
+        $CCFLAGS .= "-DKAFFE";
+    }
+}
+
+# Let's find out the path of the library we need to link against.
+#
+foreach (@JAVALIBS) {
+    if ( /javai.lib$/ or /jvm.lib$/) { # We're on Win32
+        $_ =~ s#/#\\\\#g;
+    }
+    my ($libname, $libpath, $libsuffix) = fileparse($_, ("\.so", "\.lib"));
+    $libname =~ s/^lib//;
+    if ($^O eq 'solaris') {
+        $LIBPATH .= " -R$libpath -L$libpath"
+    } else {
+        $LIBPATH .= " -L$libpath"
+    }
+    $LIBS .= " -l$libname";
+}
+
+# Do we need -D_REENTRANT?
+if ($LIBPATH =~ /native/) {
+    print "Looks like native threads...\n";
+    $CCFLAGS .= " -D_REENTRANT";
+}
+
+if ($opt_e) {
+    print "We're embedding Perl in Java via libPerlInterpreter.so.\n";
+    eval `../setvars -perl`;
+    $CCFLAGS .= " -DEMBEDDEDPERL";
+    $LIBPATH .= " -R$ENV{JPL_HOME}/lib/$ARCHNAME -L$ENV{JPL_HOME}/lib/$ARCHNAME";
+    $LIBS    .= " -lPerlInterpreter";
+}
+
+# Needed for JNI.
+if ($^O eq 'solaris') {
+    $LIBS = " -lthread -lc $LIBS"; #-lthread must be first!!!
+    $CCFLAGS .= " -D_REENTRANT";
+}
+
+my %Makefile = (
+    NAME        => 'JNI',
     VERSION_FROM => 'JNI.pm',
-    LIBS       => ["-R$Config{archlib}/CORE -L$Config{archlib}/CORE -R$jpl/lib/$ARCHNAME -L$jpl/lib/$ARCHNAME -lperl -lPerlInterpreter"],
-    DEFINE     => '',
+    DEFINE        => '',
     LINKTYPE => 'dynamic',
-    INC        => "-I$java/include -I$java/include/$^O -I$java/include/genunix",
+    INC        => $INC,
+    CCFLAGS => "$Config{ccflags} $CCFLAGS", 
+    ($Config{archname} =~ /mswin32.*-object/i ? ('CAPI' => 'TRUE') : ()),
 );
+
+$Makefile{LIBS} = ["$LIBPATH $LIBS"];
+if ($MYEXTLIB) {
+    $Makefile{MYEXTLIB} = $MYEXTLIB;
+}
+
+# See lib/ExtUtils/MakeMaker.pm for details of how to influence
+# the contents of the Makefile that is written.
+#
+WriteMakefile(%Makefile);
+
+# subroutine to find a library
+#
+sub find_stuff {
+
+    my ($candidates, $locations) = @_;
+
+    my $lib;
+    $wanted = sub {
+        foreach my $name (@$candidates) {
+            if (/$name$/ and ! /green_threads/ and !/include-old/) {
+                    $lib = $File::Find::name;
+            }
+        }
+    };
+    
+    use File::Find;
+    foreach my $guess (@$locations) {
+        next unless -d $guess;
+        find (\&$wanted, $guess);
+    }
+    if (! $lib) {
+        print "Could not find @$candidates\n";
+    } else {
+        print "Found @$candidates as $lib\n\n";
+    }
+    return $lib;
+}
+
+# Extra lib for Java 1.2
+#
+sub find_libs {
+
+    my $libjava = find_stuff(['libjava.so', 'libkaffevm.so', 'javai.lib', 'jvm.lib'],
+                        \@JAVA_HOME_GUESSES);
+    my $libjvm  = find_stuff(['libjvm.so'],  \@JAVA_HOME_GUESSES);
+    if ($libjvm) { # JDK 1.2
+        my $libhpi  = find_stuff(['libhpi.so'], \@JAVA_HOME_GUESSES);
+        my $libawt  = find_stuff(['libawt.so'], \@JAVA_HOME_GUESSES);
+        return($libjava, $libjvm, $libhpi, $libawt);
+    } else {
+        return($libjava);
+    }
+
+}
+
+# We need to find jni.h and jni_md.h
+#
+sub find_includes {
+
+    my @CANDIDATES = qw(jni.h jni_md.h);
+    my @includes;
+
+    sub find_inc {
+        foreach my $name (@CANDIDATES) {
+            if (/$name$/) {
+                my ($hname, $hpath, $hsuffix) = 
+                    fileparse($File::Find::name, ("\.h", "\.H"));
+                unless ($hpath =~ /include-old/) {
+                    print "Found $hname$hsuffix in $hpath\n";
+                    push @includes, $hpath;
+                }
+            }
+        }
+    }
+    
+    use File::Find;
+    foreach my $guess (@JAVA_HOME_GUESSES) {
+        next unless -d $guess;
+        find (\&find_inc, $guess);
+    }
+    if (! @includes) {
+        die "Could not find Java includes!";
+    } else {
+        print join("\n", @includes), "\n";
+    }
+    return @includes;
+}
+
index 816e28b..9c5238e 100644 (file)
@@ -6,7 +6,7 @@
 # Change 1..1 below to 1..last_test_to_print .
 # (It may become useful if the test is moved to ./t subdirectory.)
 
-BEGIN { $| = 1; print "1..1\n"; }
+BEGIN { $| = 1; print "1..3\n"; }
 END {print "not ok 1\n" unless $loaded;}
 use JNI;
 $loaded = 1;
@@ -18,3 +18,41 @@ print "ok 1\n";
 # (correspondingly "not ok 13") depending on the success of chunk 13
 # of the test code):
 
+# Simple StringBuffer test.
+#
+use JPL::AutoLoader;
+use JPL::Class 'java::lang::StringBuffer';
+$sb = java::lang::StringBuffer->new__s("TEST");
+if ($sb->toString____s() eq "TEST") {
+    print "ok 2\n";
+} else {
+    print "not ok 2\n";
+}
+
+# Put up a frame and let the user close it.
+#
+use JPL::AutoLoader;
+use JPL::Class 'java::awt::Frame';
+use JPL::Class 'Closer';
+
+$f = java::awt::Frame->new__s("Close Me, Please!");
+my $setSize = getmeth("setSize", ["int", "int"], []);
+my $addWindowListener = getmeth("addWindowListener",
+            ["java.awt.event.WindowListener"], []);
+
+$f->$addWindowListener( new Closer );
+$f->$setSize(200,200);
+$f->show();
+
+while (1) {
+
+    if (!$f->isVisible____Z) {
+        last;
+    }
+
+    # Sleep a bit.
+    #
+    sleep 1;
+}
+
+print "ok 3\n";
index 6b97cf4..9bd0691 100644 (file)
@@ -55,13 +55,13 @@ T_JVALUELIST
            AV* av = (AV*)SvRV($arg);
            if (SvTYPE(av) == SVt_PVAV) {
                I32 maxarg = AvFILL(av) + 1;
-               $var = makeargs(aTHX_ sig, AvARRAY(av), maxarg);
+               $var = makeargs(sig, AvARRAY(av), maxarg);
            }
            else
-               Perl_croak(aTHX_ \"$var is not an array reference\");
+               croak(\"$var is not an array reference\");
        }
        else
-           Perl_croak(aTHX_ \"$var is not a reference\")
+           croak(\"$var is not a reference\")
 T_JIDSIG
        {
            $var = ($type)SvIV($arg);
@@ -73,7 +73,7 @@ T_JPTROBJ
            $var = ($type) tmp;
        }
        else
-           Perl_croak(aTHX_ \"$var is not of type ${ntype}\")
+           croak(\"$var is not of type ${ntype}\")
 
 OUTPUT
 T_JMEM
@@ -152,22 +152,22 @@ T_JPTROBJ
 #              if (sv_isa($arg, \"${ntype}\"))
 #                  $var = (SV*)SvRV($arg);
 #              else
-#                  Perl_croak(aTHX_ \"$var is not of type ${ntype}\")
+#                  croak(\"$var is not of type ${ntype}\")
 #      T_AVREF
 #              if (sv_isa($arg, \"${ntype}\"))
 #                  $var = (AV*)SvRV($arg);
 #              else
-#                  Perl_croak(aTHX_ \"$var is not of type ${ntype}\")
+#                  croak(\"$var is not of type ${ntype}\")
 #      T_HVREF
 #              if (sv_isa($arg, \"${ntype}\"))
 #                  $var = (HV*)SvRV($arg);
 #              else
-#                  Perl_croak(aTHX_ \"$var is not of type ${ntype}\")
+#                  croak(\"$var is not of type ${ntype}\")
 #      T_CVREF
 #              if (sv_isa($arg, \"${ntype}\"))
 #                  $var = (CV*)SvRV($arg);
 #              else
-#                  Perl_croak(aTHX_ \"$var is not of type ${ntype}\")
+#                  croak(\"$var is not of type ${ntype}\")
 #      T_SYSRET
 #              $var NOT IMPLEMENTED
 #      T_IV
@@ -208,28 +208,28 @@ T_JPTROBJ
 #                  $var = ($type) tmp;
 #              }
 #              else
-#                  Perl_croak(aTHX_ \"$var is not a reference\")
+#                  croak(\"$var is not a reference\")
 #      T_REF_IV_REF
 #              if (sv_isa($arg, \"${type}\")) {
 #                  IV tmp = SvIV((SV*)SvRV($arg));
 #                  $var = *($type *) tmp;
 #              }
 #              else
-#                  Perl_croak(aTHX_ \"$var is not of type ${ntype}\")
+#                  croak(\"$var is not of type ${ntype}\")
 #      T_REF_IV_PTR
 #              if (sv_isa($arg, \"${type}\")) {
 #                  IV tmp = SvIV((SV*)SvRV($arg));
 #                  $var = ($type) tmp;
 #              }
 #              else
-#                  Perl_croak(aTHX_ \"$var is not of type ${ntype}\")
+#                  croak(\"$var is not of type ${ntype}\")
 #      T_PTROBJ
 #              if (sv_derived_from($arg, \"${ntype}\")) {
 #                  IV tmp = SvIV((SV*)SvRV($arg));
 #                  $var = ($type) tmp;
 #              }
 #              else
-#                  Perl_croak(aTHX_ \"$var is not of type ${ntype}\")
+#                  croak(\"$var is not of type ${ntype}\")
 #      T_PTRDESC
 #              if (sv_isa($arg, \"${ntype}\")) {
 #                  IV tmp = SvIV((SV*)SvRV($arg));
@@ -237,21 +237,21 @@ T_JPTROBJ
 #                  $var = ${type}_desc->ptr;
 #              }
 #              else
-#                  Perl_croak(aTHX_ \"$var is not of type ${ntype}\")
+#                  croak(\"$var is not of type ${ntype}\")
 #      T_REFREF
 #              if (SvROK($arg)) {
 #                  IV tmp = SvIV((SV*)SvRV($arg));
 #                  $var = *($type) tmp;
 #              }
 #              else
-#                  Perl_croak(aTHX_ \"$var is not a reference\")
+#                  croak(\"$var is not a reference\")
 #      T_REFOBJ
 #              if (sv_isa($arg, \"${ntype}\")) {
 #                  IV tmp = SvIV((SV*)SvRV($arg));
 #                  $var = *($type) tmp;
 #              }
 #              else
-#                  Perl_croak(aTHX_ \"$var is not of type ${ntype}\")
+#                  croak(\"$var is not of type ${ntype}\")
 #      T_OPAQUE
 #              $var NOT IMPLEMENTED
 #      T_OPAQUEPTR
diff --git a/jpl/JNI/typemap.gcc b/jpl/JNI/typemap.gcc
new file mode 100644 (file)
index 0000000..9bd0691
--- /dev/null
@@ -0,0 +1,386 @@
+JavaVM *               T_JPTROBJ
+JNINativeMethod *      T_JPTROBJ
+const char *           T_PV
+const jbyte *          T_JMEM
+const jchar *          T_JMEM
+jarray                 T_JPTROBJ
+jboolean               T_IV
+jboolean *             T_JMEM
+jbooleanArray          T_JPTROBJ
+jbyte                  T_IV
+jbyte *                        T_JMEM
+jbyteArray             T_JPTROBJ
+jchar                  T_IV
+jchar *                        T_JMEM
+jcharArray             T_JPTROBJ
+jclass                 T_JPTROBJ
+jdouble                        T_NV
+jdouble *              T_JMEM
+jdoubleArray           T_JPTROBJ
+jfieldID               T_JIDSIG
+jfloat                 T_NV
+jfloat *               T_JMEM
+jfloatArray            T_JPTROBJ
+jint                   T_IV
+jint *                 T_JMEM
+jintArray              T_JPTROBJ
+jlong                  T_NV
+jlong *                        T_JMEM
+jlongArray             T_JPTROBJ
+jmethodID              T_JIDSIG
+jobject                        T_JPTROBJ
+jobjectArray           T_JPTROBJ
+jshort                 T_IV
+jshort *               T_JMEM
+jshortArray            T_JPTROBJ
+jsize                  T_IV
+jstring                        T_JSTRING
+jthrowable             T_JPTROBJ
+jvalue *               T_JVALUELIST
+
+INPUT
+T_JMEM
+       {
+           $var = ($type)SvPV($arg,tmplen);
+           ${var}_len_ = (jsize) tmplen / sizeof(${subtype});
+       }
+T_JSTRING
+       if (SvROK($arg)) {
+           $var = ($type)(void*)SvIV(SvRV($arg));
+       }
+       else
+           $var = ($type)(*env)->NewStringUTF(env, (char *) SvPV($arg,PL_na))
+T_JVALUELIST
+       if (SvROK($arg)) {
+           AV* av = (AV*)SvRV($arg);
+           if (SvTYPE(av) == SVt_PVAV) {
+               I32 maxarg = AvFILL(av) + 1;
+               $var = makeargs(sig, AvARRAY(av), maxarg);
+           }
+           else
+               croak(\"$var is not an array reference\");
+       }
+       else
+           croak(\"$var is not a reference\")
+T_JIDSIG
+       {
+           $var = ($type)SvIV($arg);
+           sig = (char*)SvPV($arg,PL_na);
+       }
+T_JPTROBJ
+       if (SvROK($arg) && SvOBJECT(SvRV($arg))) {
+           IV tmp = SvIV((SV*)SvRV($arg));
+           $var = ($type) tmp;
+       }
+       else
+           croak(\"$var is not of type ${ntype}\")
+
+OUTPUT
+T_JMEM
+       sv_setpvn((SV*)$arg, (char*)$var, (STRLEN)${var}_len_ * sizeof(${subtype}));
+T_JSTRING
+       {
+           static HV* ${var}_stashhv_ = 0;
+           if (!${var}_stashhv_)
+               ${var}_stashhv_ = gv_stashpv("java::lang::String", TRUE);
+        
+           sv_bless(
+               sv_setref_iv($arg, Nullch, (IV)(void*)${var}),
+               ${var}_stashhv_);
+       }
+T_JIDSIG
+       sv_setiv($arg, (IV)(void*)$var);
+       sv_setpv($arg, (char*)sig);
+       SvIOK_on($arg);
+T_JPTROBJ
+       sv_setref_pv($arg, \"${ntype}\", (void*)$var);
+
+# basic C types
+#      int                     T_IV
+#      unsigned                T_IV
+#      unsigned int            T_IV
+#      long                    T_IV
+#      unsigned long           T_IV
+#      short                   T_IV
+#      unsigned short          T_IV
+#      char                    T_CHAR
+#      unsigned char           T_U_CHAR
+#      char *                  T_PV
+#      unsigned char *         T_PV
+#      caddr_t                 T_PV
+#      wchar_t *               T_PV
+#      wchar_t                 T_IV
+#      bool_t                  T_IV
+#      size_t                  T_IV
+#      ssize_t                 T_IV
+#      time_t                  T_NV
+#      unsigned long *         T_OPAQUEPTR
+#      char **                 T_PACKED
+#      void *                  T_PTR
+#      Time_t *                T_PV
+#      SV *                    T_SV
+#      SVREF                   T_SVREF
+#      AV *                    T_AVREF
+#      HV *                    T_HVREF
+#      CV *                    T_CVREF
+#      
+#      IV                      T_IV
+#      I32                     T_IV
+#      I16                     T_IV
+#      I8                      T_IV
+#      U32                     T_U_LONG
+#      U16                     T_U_SHORT
+#      U8                      T_IV
+#      Result                  T_U_CHAR
+#      Boolean                 T_IV
+#      double                  T_DOUBLE
+#      SysRet                  T_SYSRET
+#      SysRetLong              T_SYSRET
+#      FILE *                  T_IN
+#      FileHandle              T_PTROBJ
+#      InputStream             T_IN
+#      InOutStream             T_INOUT
+#      OutputStream            T_OUT
+#      bool                    T_BOOL
+#
+#############################################################################
+#      INPUT
+#      T_SV
+#              $var = $arg
+#      T_SVREF
+#              if (sv_isa($arg, \"${ntype}\"))
+#                  $var = (SV*)SvRV($arg);
+#              else
+#                  croak(\"$var is not of type ${ntype}\")
+#      T_AVREF
+#              if (sv_isa($arg, \"${ntype}\"))
+#                  $var = (AV*)SvRV($arg);
+#              else
+#                  croak(\"$var is not of type ${ntype}\")
+#      T_HVREF
+#              if (sv_isa($arg, \"${ntype}\"))
+#                  $var = (HV*)SvRV($arg);
+#              else
+#                  croak(\"$var is not of type ${ntype}\")
+#      T_CVREF
+#              if (sv_isa($arg, \"${ntype}\"))
+#                  $var = (CV*)SvRV($arg);
+#              else
+#                  croak(\"$var is not of type ${ntype}\")
+#      T_SYSRET
+#              $var NOT IMPLEMENTED
+#      T_IV
+#              $var = ($type)SvIV($arg)
+#      T_INT
+#              $var = (int)SvIV($arg)
+#      T_ENUM
+#              $var = ($type)SvIV($arg)
+#      T_BOOL
+#              $var = (int)SvIV($arg)
+#      T_U_INT
+#              $var = (unsigned int)SvIV($arg)
+#      T_SHORT
+#              $var = (short)SvIV($arg)
+#      T_U_SHORT
+#              $var = (unsigned short)SvIV($arg)
+#      T_LONG
+#              $var = (long)SvIV($arg)
+#      T_U_LONG
+#              $var = (unsigned long)SvIV($arg)
+#      T_CHAR
+#              $var = (char)*SvPV($arg,PL_na)
+#      T_U_CHAR
+#              $var = (unsigned char)SvIV($arg)
+#      T_FLOAT
+#              $var = (float)SvNV($arg)
+#      T_NV
+#              $var = ($type)SvNV($arg)
+#      T_DOUBLE
+#              $var = (double)SvNV($arg)
+#      T_PV
+#              $var = ($type)SvPV($arg,PL_na)
+#      T_PTR
+#              $var = ($type)SvIV($arg)
+#      T_PTRREF
+#              if (SvROK($arg)) {
+#                  IV tmp = SvIV((SV*)SvRV($arg));
+#                  $var = ($type) tmp;
+#              }
+#              else
+#                  croak(\"$var is not a reference\")
+#      T_REF_IV_REF
+#              if (sv_isa($arg, \"${type}\")) {
+#                  IV tmp = SvIV((SV*)SvRV($arg));
+#                  $var = *($type *) tmp;
+#              }
+#              else
+#                  croak(\"$var is not of type ${ntype}\")
+#      T_REF_IV_PTR
+#              if (sv_isa($arg, \"${type}\")) {
+#                  IV tmp = SvIV((SV*)SvRV($arg));
+#                  $var = ($type) tmp;
+#              }
+#              else
+#                  croak(\"$var is not of type ${ntype}\")
+#      T_PTROBJ
+#              if (sv_derived_from($arg, \"${ntype}\")) {
+#                  IV tmp = SvIV((SV*)SvRV($arg));
+#                  $var = ($type) tmp;
+#              }
+#              else
+#                  croak(\"$var is not of type ${ntype}\")
+#      T_PTRDESC
+#              if (sv_isa($arg, \"${ntype}\")) {
+#                  IV tmp = SvIV((SV*)SvRV($arg));
+#                  ${type}_desc = (\U${type}_DESC\E*) tmp; 
+#                  $var = ${type}_desc->ptr;
+#              }
+#              else
+#                  croak(\"$var is not of type ${ntype}\")
+#      T_REFREF
+#              if (SvROK($arg)) {
+#                  IV tmp = SvIV((SV*)SvRV($arg));
+#                  $var = *($type) tmp;
+#              }
+#              else
+#                  croak(\"$var is not a reference\")
+#      T_REFOBJ
+#              if (sv_isa($arg, \"${ntype}\")) {
+#                  IV tmp = SvIV((SV*)SvRV($arg));
+#                  $var = *($type) tmp;
+#              }
+#              else
+#                  croak(\"$var is not of type ${ntype}\")
+#      T_OPAQUE
+#              $var NOT IMPLEMENTED
+#      T_OPAQUEPTR
+#              $var = ($type)SvPV($arg,PL_na)
+#      T_PACKED
+#              $var = XS_unpack_$ntype($arg)
+#      T_PACKEDARRAY
+#              $var = XS_unpack_$ntype($arg)
+#      T_CALLBACK
+#              $var = make_perl_cb_$type($arg)
+#      T_ARRAY
+#              $var = $ntype(items -= $argoff);
+#              U32 ix_$var = $argoff;
+#              while (items--) {
+#                  DO_ARRAY_ELEM;
+#              }
+#      T_IN
+#              $var = IoIFP(sv_2io($arg))
+#      T_INOUT
+#              $var = IoIFP(sv_2io($arg))
+#      T_OUT
+#              $var = IoOFP(sv_2io($arg))
+##############################################################################
+#      OUTPUT
+#      T_SV
+#              $arg = $var;
+#      T_SVREF
+#              $arg = newRV((SV*)$var);
+#      T_AVREF
+#              $arg = newRV((SV*)$var);
+#      T_HVREF
+#              $arg = newRV((SV*)$var);
+#      T_CVREF
+#              $arg = newRV((SV*)$var);
+#      T_IV
+#              sv_setiv($arg, (IV)$var);
+#      T_INT
+#              sv_setiv($arg, (IV)$var);
+#      T_SYSRET
+#              if ($var != -1) {
+#                  if ($var == 0)
+#                      sv_setpvn($arg, "0 but true", 10);
+#                  else
+#                      sv_setiv($arg, (IV)$var);
+#              }
+#      T_ENUM
+#              sv_setiv($arg, (IV)$var);
+#      T_BOOL
+#              $arg = boolSV($var);
+#      T_U_INT
+#              sv_setiv($arg, (IV)$var);
+#      T_SHORT
+#              sv_setiv($arg, (IV)$var);
+#      T_U_SHORT
+#              sv_setiv($arg, (IV)$var);
+#      T_LONG
+#              sv_setiv($arg, (IV)$var);
+#      T_U_LONG
+#              sv_setiv($arg, (IV)$var);
+#      T_CHAR
+#              sv_setpvn($arg, (char *)&$var, 1);
+#      T_U_CHAR
+#              sv_setiv($arg, (IV)$var);
+#      T_FLOAT
+#              sv_setnv($arg, (double)$var);
+#      T_NV
+#              sv_setnv($arg, (double)$var);
+#      T_DOUBLE
+#              sv_setnv($arg, (double)$var);
+#      T_PV
+#              sv_setpv((SV*)$arg, $var);
+#      T_PTR
+#              sv_setiv($arg, (IV)$var);
+#      T_PTRREF
+#              sv_setref_pv($arg, Nullch, (void*)$var);
+#      T_REF_IV_REF
+#              sv_setref_pv($arg, \"${ntype}\", (void*)new $ntype($var));
+#      T_REF_IV_PTR
+#              sv_setref_pv($arg, \"${ntype}\", (void*)$var);
+#      T_PTROBJ
+#              sv_setref_pv($arg, \"${ntype}\", (void*)$var);
+#      T_PTRDESC
+#              sv_setref_pv($arg, \"${ntype}\", (void*)new\U${type}_DESC\E($var));
+#      T_REFREF
+#              sv_setrefref($arg, \"${ntype}\", XS_service_$ntype,
+#                          ($var ? (void*)new $ntype($var) : 0));
+#      T_REFOBJ
+#              NOT IMPLEMENTED
+#      T_OPAQUE
+#              sv_setpvn($arg, (char *)&$var, sizeof($var));
+#      T_OPAQUEPTR
+#              sv_setpvn($arg, (char *)$var, sizeof(*$var)), XFree((char *)$var);
+#      T_PACKED
+#              XS_pack_$ntype($arg, $var);
+#      T_PACKEDARRAY
+#              XS_pack_$ntype($arg, $var, count_$ntype);
+#      T_DATAUNIT      
+#              sv_setpvn($arg, $var.chp(), $var.size());
+#      T_CALLBACK
+#              sv_setpvn($arg, $var.context.value().chp(),
+#                      $var.context.value().size());
+#      T_ARRAY
+#              ST_EXTEND($var.size);
+#              for (U32 ix_$var = 0; ix_$var < $var.size; ix_$var++) {
+#                      ST(ix_$var) = sv_newmortal();
+#              DO_ARRAY_ELEM
+#              }
+#              sp += $var.size - 1;
+#      T_IN
+#              {
+#                  GV *gv = newGVgen("$Package");
+#                  if ( do_open(gv, "<&", 2, FALSE, 0, 0, $var) )
+#                      sv_setsv($arg, sv_bless(newRV((SV*)gv), gv_stashpv("$Package",1)));
+#                  else
+#                      $arg = &PL_sv_undef;
+#              }
+#      T_INOUT
+#              {
+#                  GV *gv = newGVgen("$Package");
+#                  if ( do_open(gv, "+<&", 3, FALSE, 0, 0, $var) )
+#                      sv_setsv($arg, sv_bless(newRV((SV*)gv), gv_stashpv("$Package",1)));
+#                  else
+#                      $arg = &PL_sv_undef;
+#              }
+#      T_OUT
+#              {
+#                  GV *gv = newGVgen("$Package");
+#                  if ( do_open(gv, "+>&", 3, FALSE, 0, 0, $var) )
+#                      sv_setsv($arg, sv_bless(newRV((SV*)gv), gv_stashpv("$Package",1)));
+#                  else
+#                      $arg = &PL_sv_undef;
+#              }
diff --git a/jpl/JNI/typemap.win32 b/jpl/JNI/typemap.win32
new file mode 100644 (file)
index 0000000..89eb8df
--- /dev/null
@@ -0,0 +1,386 @@
+JavaVM *               T_JPTROBJ
+JNINativeMethod *      T_JPTROBJ
+const char *           T_PV
+const jbyte *          T_JMEM
+const jchar *          T_JMEM
+jarray                 T_JPTROBJ
+jboolean               T_IV
+jboolean *             T_JMEM
+jbooleanArray          T_JPTROBJ
+jbyte                  T_IV
+jbyte *                        T_JMEM
+jbyteArray             T_JPTROBJ
+jchar                  T_IV
+jchar *                        T_JMEM
+jcharArray             T_JPTROBJ
+jclass                 T_JPTROBJ
+jdouble                        T_NV
+jdouble *              T_JMEM
+jdoubleArray           T_JPTROBJ
+jfieldID               T_JIDSIG
+jfloat                 T_NV
+jfloat *               T_JMEM
+jfloatArray            T_JPTROBJ
+jint                   T_IV
+jint *                 T_JMEM
+jintArray              T_JPTROBJ
+jlong                  T_NV
+jlong *                        T_JMEM
+jlongArray             T_JPTROBJ
+jmethodID              T_JIDSIG
+jobject                        T_JPTROBJ
+jobjectArray           T_JPTROBJ
+jshort                 T_IV
+jshort *               T_JMEM
+jshortArray            T_JPTROBJ
+jsize                  T_IV
+jstring                        T_JSTRING
+jthrowable             T_JPTROBJ
+jvalue *               T_JVALUELIST
+
+INPUT
+T_JMEM
+       {
+           $var = ($type)SvPV($arg,tmplen);
+           ${var}_len_ = (jsize) tmplen / sizeof(${subtype});
+       }
+T_JSTRING
+       if (SvROK($arg)) {
+           $var = ($type)(void*)SvIV(SvRV($arg));
+       }
+       else
+           $var = ($type)env->NewStringUTF((char *) SvPV($arg,PL_na))
+T_JVALUELIST
+       if (SvROK($arg)) {
+           AV* av = (AV*)SvRV($arg);
+           if (SvTYPE(av) == SVt_PVAV) {
+               I32 maxarg = AvFILL(av) + 1;
+               $var = makeargs(sig, AvARRAY(av), maxarg);
+           }
+           else
+               croak(\"$var is not an array reference\");
+       }
+       else
+           croak(\"$var is not a reference\")
+T_JIDSIG
+       {
+           $var = ($type)SvIV($arg);
+           sig = (char*)SvPV($arg,PL_na);
+       }
+T_JPTROBJ
+       if (SvROK($arg) && SvOBJECT(SvRV($arg))) {
+           IV tmp = SvIV((SV*)SvRV($arg));
+           $var = ($type) tmp;
+       }
+       else
+           croak(\"$var is not of type ${ntype}\")
+
+OUTPUT
+T_JMEM
+       sv_setpvn((SV*)$arg, (char*)$var, (STRLEN)${var}_len_ * sizeof(${subtype}));
+T_JSTRING
+       {
+           static HV* ${var}_stashhv_ = 0;
+           if (!${var}_stashhv_)
+               ${var}_stashhv_ = gv_stashpv("java::lang::String", TRUE);
+        
+           sv_bless(
+               sv_setref_iv($arg, Nullch, (IV)(void*)${var}),
+               ${var}_stashhv_);
+       }
+T_JIDSIG
+       sv_setiv($arg, (IV)(void*)$var);
+       sv_setpv($arg, (char*)sig);
+       SvIOK_on($arg);
+T_JPTROBJ
+       sv_setref_pv($arg, \"${ntype}\", (void*)$var);
+
+# basic C types
+#      int                     T_IV
+#      unsigned                T_IV
+#      unsigned int            T_IV
+#      long                    T_IV
+#      unsigned long           T_IV
+#      short                   T_IV
+#      unsigned short          T_IV
+#      char                    T_CHAR
+#      unsigned char           T_U_CHAR
+#      char *                  T_PV
+#      unsigned char *         T_PV
+#      caddr_t                 T_PV
+#      wchar_t *               T_PV
+#      wchar_t                 T_IV
+#      bool_t                  T_IV
+#      size_t                  T_IV
+#      ssize_t                 T_IV
+#      time_t                  T_NV
+#      unsigned long *         T_OPAQUEPTR
+#      char **                 T_PACKED
+#      void *                  T_PTR
+#      Time_t *                T_PV
+#      SV *                    T_SV
+#      SVREF                   T_SVREF
+#      AV *                    T_AVREF
+#      HV *                    T_HVREF
+#      CV *                    T_CVREF
+#      
+#      IV                      T_IV
+#      I32                     T_IV
+#      I16                     T_IV
+#      I8                      T_IV
+#      U32                     T_U_LONG
+#      U16                     T_U_SHORT
+#      U8                      T_IV
+#      Result                  T_U_CHAR
+#      Boolean                 T_IV
+#      double                  T_DOUBLE
+#      SysRet                  T_SYSRET
+#      SysRetLong              T_SYSRET
+#      FILE *                  T_IN
+#      FileHandle              T_PTROBJ
+#      InputStream             T_IN
+#      InOutStream             T_INOUT
+#      OutputStream            T_OUT
+#      bool                    T_BOOL
+#
+#############################################################################
+#      INPUT
+#      T_SV
+#              $var = $arg
+#      T_SVREF
+#              if (sv_isa($arg, \"${ntype}\"))
+#                  $var = (SV*)SvRV($arg);
+#              else
+#                  croak(\"$var is not of type ${ntype}\")
+#      T_AVREF
+#              if (sv_isa($arg, \"${ntype}\"))
+#                  $var = (AV*)SvRV($arg);
+#              else
+#                  croak(\"$var is not of type ${ntype}\")
+#      T_HVREF
+#              if (sv_isa($arg, \"${ntype}\"))
+#                  $var = (HV*)SvRV($arg);
+#              else
+#                  croak(\"$var is not of type ${ntype}\")
+#      T_CVREF
+#              if (sv_isa($arg, \"${ntype}\"))
+#                  $var = (CV*)SvRV($arg);
+#              else
+#                  croak(\"$var is not of type ${ntype}\")
+#      T_SYSRET
+#              $var NOT IMPLEMENTED
+#      T_IV
+#              $var = ($type)SvIV($arg)
+#      T_INT
+#              $var = (int)SvIV($arg)
+#      T_ENUM
+#              $var = ($type)SvIV($arg)
+#      T_BOOL
+#              $var = (int)SvIV($arg)
+#      T_U_INT
+#              $var = (unsigned int)SvIV($arg)
+#      T_SHORT
+#              $var = (short)SvIV($arg)
+#      T_U_SHORT
+#              $var = (unsigned short)SvIV($arg)
+#      T_LONG
+#              $var = (long)SvIV($arg)
+#      T_U_LONG
+#              $var = (unsigned long)SvIV($arg)
+#      T_CHAR
+#              $var = (char)*SvPV($arg,PL_na)
+#      T_U_CHAR
+#              $var = (unsigned char)SvIV($arg)
+#      T_FLOAT
+#              $var = (float)SvNV($arg)
+#      T_NV
+#              $var = ($type)SvNV($arg)
+#      T_DOUBLE
+#              $var = (double)SvNV($arg)
+#      T_PV
+#              $var = ($type)SvPV($arg,PL_na)
+#      T_PTR
+#              $var = ($type)SvIV($arg)
+#      T_PTRREF
+#              if (SvROK($arg)) {
+#                  IV tmp = SvIV((SV*)SvRV($arg));
+#                  $var = ($type) tmp;
+#              }
+#              else
+#                  croak(\"$var is not a reference\")
+#      T_REF_IV_REF
+#              if (sv_isa($arg, \"${type}\")) {
+#                  IV tmp = SvIV((SV*)SvRV($arg));
+#                  $var = *($type *) tmp;
+#              }
+#              else
+#                  croak(\"$var is not of type ${ntype}\")
+#      T_REF_IV_PTR
+#              if (sv_isa($arg, \"${type}\")) {
+#                  IV tmp = SvIV((SV*)SvRV($arg));
+#                  $var = ($type) tmp;
+#              }
+#              else
+#                  croak(\"$var is not of type ${ntype}\")
+#      T_PTROBJ
+#              if (sv_derived_from($arg, \"${ntype}\")) {
+#                  IV tmp = SvIV((SV*)SvRV($arg));
+#                  $var = ($type) tmp;
+#              }
+#              else
+#                  croak(\"$var is not of type ${ntype}\")
+#      T_PTRDESC
+#              if (sv_isa($arg, \"${ntype}\")) {
+#                  IV tmp = SvIV((SV*)SvRV($arg));
+#                  ${type}_desc = (\U${type}_DESC\E*) tmp; 
+#                  $var = ${type}_desc->ptr;
+#              }
+#              else
+#                  croak(\"$var is not of type ${ntype}\")
+#      T_REFREF
+#              if (SvROK($arg)) {
+#                  IV tmp = SvIV((SV*)SvRV($arg));
+#                  $var = *($type) tmp;
+#              }
+#              else
+#                  croak(\"$var is not a reference\")
+#      T_REFOBJ
+#              if (sv_isa($arg, \"${ntype}\")) {
+#                  IV tmp = SvIV((SV*)SvRV($arg));
+#                  $var = *($type) tmp;
+#              }
+#              else
+#                  croak(\"$var is not of type ${ntype}\")
+#      T_OPAQUE
+#              $var NOT IMPLEMENTED
+#      T_OPAQUEPTR
+#              $var = ($type)SvPV($arg,PL_na)
+#      T_PACKED
+#              $var = XS_unpack_$ntype($arg)
+#      T_PACKEDARRAY
+#              $var = XS_unpack_$ntype($arg)
+#      T_CALLBACK
+#              $var = make_perl_cb_$type($arg)
+#      T_ARRAY
+#              $var = $ntype(items -= $argoff);
+#              U32 ix_$var = $argoff;
+#              while (items--) {
+#                  DO_ARRAY_ELEM;
+#              }
+#      T_IN
+#              $var = IoIFP(sv_2io($arg))
+#      T_INOUT
+#              $var = IoIFP(sv_2io($arg))
+#      T_OUT
+#              $var = IoOFP(sv_2io($arg))
+##############################################################################
+#      OUTPUT
+#      T_SV
+#              $arg = $var;
+#      T_SVREF
+#              $arg = newRV((SV*)$var);
+#      T_AVREF
+#              $arg = newRV((SV*)$var);
+#      T_HVREF
+#              $arg = newRV((SV*)$var);
+#      T_CVREF
+#              $arg = newRV((SV*)$var);
+#      T_IV
+#              sv_setiv($arg, (IV)$var);
+#      T_INT
+#              sv_setiv($arg, (IV)$var);
+#      T_SYSRET
+#              if ($var != -1) {
+#                  if ($var == 0)
+#                      sv_setpvn($arg, "0 but true", 10);
+#                  else
+#                      sv_setiv($arg, (IV)$var);
+#              }
+#      T_ENUM
+#              sv_setiv($arg, (IV)$var);
+#      T_BOOL
+#              $arg = boolSV($var);
+#      T_U_INT
+#              sv_setiv($arg, (IV)$var);
+#      T_SHORT
+#              sv_setiv($arg, (IV)$var);
+#      T_U_SHORT
+#              sv_setiv($arg, (IV)$var);
+#      T_LONG
+#              sv_setiv($arg, (IV)$var);
+#      T_U_LONG
+#              sv_setiv($arg, (IV)$var);
+#      T_CHAR
+#              sv_setpvn($arg, (char *)&$var, 1);
+#      T_U_CHAR
+#              sv_setiv($arg, (IV)$var);
+#      T_FLOAT
+#              sv_setnv($arg, (double)$var);
+#      T_NV
+#              sv_setnv($arg, (double)$var);
+#      T_DOUBLE
+#              sv_setnv($arg, (double)$var);
+#      T_PV
+#              sv_setpv((SV*)$arg, $var);
+#      T_PTR
+#              sv_setiv($arg, (IV)$var);
+#      T_PTRREF
+#              sv_setref_pv($arg, Nullch, (void*)$var);
+#      T_REF_IV_REF
+#              sv_setref_pv($arg, \"${ntype}\", (void*)new $ntype($var));
+#      T_REF_IV_PTR
+#              sv_setref_pv($arg, \"${ntype}\", (void*)$var);
+#      T_PTROBJ
+#              sv_setref_pv($arg, \"${ntype}\", (void*)$var);
+#      T_PTRDESC
+#              sv_setref_pv($arg, \"${ntype}\", (void*)new\U${type}_DESC\E($var));
+#      T_REFREF
+#              sv_setrefref($arg, \"${ntype}\", XS_service_$ntype,
+#                          ($var ? (void*)new $ntype($var) : 0));
+#      T_REFOBJ
+#              NOT IMPLEMENTED
+#      T_OPAQUE
+#              sv_setpvn($arg, (char *)&$var, sizeof($var));
+#      T_OPAQUEPTR
+#              sv_setpvn($arg, (char *)$var, sizeof(*$var)), XFree((char *)$var);
+#      T_PACKED
+#              XS_pack_$ntype($arg, $var);
+#      T_PACKEDARRAY
+#              XS_pack_$ntype($arg, $var, count_$ntype);
+#      T_DATAUNIT      
+#              sv_setpvn($arg, $var.chp(), $var.size());
+#      T_CALLBACK
+#              sv_setpvn($arg, $var.context.value().chp(),
+#                      $var.context.value().size());
+#      T_ARRAY
+#              ST_EXTEND($var.size);
+#              for (U32 ix_$var = 0; ix_$var < $var.size; ix_$var++) {
+#                      ST(ix_$var) = sv_newmortal();
+#              DO_ARRAY_ELEM
+#              }
+#              sp += $var.size - 1;
+#      T_IN
+#              {
+#                  GV *gv = newGVgen("$Package");
+#                  if ( do_open(gv, "<&", 2, FALSE, 0, 0, $var) )
+#                      sv_setsv($arg, sv_bless(newRV((SV*)gv), gv_stashpv("$Package",1)));
+#                  else
+#                      $arg = &PL_sv_undef;
+#              }
+#      T_INOUT
+#              {
+#                  GV *gv = newGVgen("$Package");
+#                  if ( do_open(gv, "+<&", 3, FALSE, 0, 0, $var) )
+#                      sv_setsv($arg, sv_bless(newRV((SV*)gv), gv_stashpv("$Package",1)));
+#                  else
+#                      $arg = &PL_sv_undef;
+#              }
+#      T_OUT
+#              {
+#                  GV *gv = newGVgen("$Package");
+#                  if ( do_open(gv, "+>&", 3, FALSE, 0, 0, $var) )
+#                      sv_setsv($arg, sv_bless(newRV((SV*)gv), gv_stashpv("$Package",1)));
+#                  else
+#                      $arg = &PL_sv_undef;
+#              }
index efb606d..02e5b45 100644 (file)
@@ -1,36 +1,6 @@
-#!/usr/bin/perl
-
-$JPL_SRC = "..";
-
-use Config;
-
-eval `$JPL_SRC/setvars -perl`;
-
-open(MAKEFILE, ">Makefile");
-
-print MAKEFILE <<"SUBS";
-PERL = perl$]
-ARCHNAME = $Config{archname}
-JAVA_HOME = $ENV{JAVA_HOME}
-JPL_HOME = $ENV{JPL_HOME}
-PERLARCHDIR = $Config{archlib}
-
-SUBS
-
-print MAKEFILE <<'NOSUBS';
-
-all:
-
-debug:
-
-test:
-
-install:
-       mkdir -p $(JPL_HOME)/perl/JPL
-       cp *.p[ml] $(JPL_HOME)/perl/JPL
-
-clean:
-
-NOSUBS
-
-close MAKEFILE;
+use ExtUtils::MakeMaker;
+# See lib/ExtUtils/MakeMaker.pm for details of how to influence
+# the contents of the Makefile that is written.
+WriteMakefile(
+    'NAME'     => 'JPL::Class',
+);
index 76852c6..b8b20f1 100644 (file)
@@ -9,12 +9,16 @@ eval `$JPL_SRC/setvars -perl`;
 if ($^O eq 'linux') {
     $flags = "-Dbool=char";    # avoid builtin bool altogether
     $libs = "-lc -lm -ldl";
-}
-else {
+} else {
     $flags = "";
     $libs = "-lc -lm -ldl";
 }
 
+# Needed for JNI.
+if ($^O eq 'solaris') {
+    $libs .= " -lthread";
+}
+
 open(MAKEFILE, ">Makefile");
 
 print MAKEFILE <<"SUBS";
index b229d13..8134f0c 100644 (file)
@@ -8,6 +8,37 @@
 #include "EXTERN.h"
 #include "perl.h"
 
+#ifndef PERL_VERSION
+#  include <patchlevel.h>
+#  define PERL_REVISION                5
+#  define PERL_VERSION         PATCHLEVEL
+#  define PERL_SUBVERSION      SUBVERSION
+#endif
+
+#if PERL_REVISION == 5 && (PERL_VERSION < 4 || \
+                          (PERL_VERSION == 4 && PERL_SUBVERSION <= 75))
+#  define PL_na                                na
+#  define PL_sv_no                     sv_no
+#  define PL_sv_undef                  sv_undef
+#  define PL_dowarn                    dowarn
+#  define PL_curinterp                 curinterp
+#  define PL_do_undump                 do_undump
+#  define PL_perl_destruct_level       perl_destruct_level
+#  define ERRSV                                GvSV(errgv)
+#endif
+
+#ifndef newSVpvn
+#  define newSVpvn(a,b)        newSVpv(a,b)
+#endif
+
+#ifndef pTHX
+#  define pTHX         void
+#  define pTHX_
+#  define aTHX
+#  define aTHX_
+#  define dTHX         extern int JNI___notused
+#endif
+
 #ifndef EXTERN_C
 #  ifdef __cplusplus
 #    define EXTERN_C extern "C"
@@ -46,6 +77,8 @@ Java_PerlInterpreter_init(JNIEnv *env, jobject obj, jstring js)
     if (PL_curinterp)
        return;
 
+    perl_init_i18nl10n(1);
+
     if (!PL_do_undump) {
        my_perl = perl_alloc();
        if (!my_perl)
@@ -62,21 +95,20 @@ Java_PerlInterpreter_init(JNIEnv *env, jobject obj, jstring js)
 }
 
 JNIEXPORT void JNICALL
-Java_PerlInterpreter_eval(void *perl, JNIEnv *env, jobject obj, jstring js)
+Java_PerlInterpreter_eval(JNIEnv *env, jobject obj, jstring js)
 {
     SV* envsv;
     SV* objsv;
     dSP;
     jbyte* jb;
-    dTHXa(perl);
 
     ENTER;
     SAVETMPS;
 
     jplcurenv = env;
-    envsv = get_sv("JPL::_env_", 1);
+    envsv = perl_get_sv("JPL::_env_", 1);
     sv_setiv(envsv, (IV)(void*)env);
-    objsv = get_sv("JPL::_obj_", 1);
+    objsv = perl_get_sv("JPL::_obj_", 1);
     sv_setiv(objsv, (IV)(void*)obj);
 
     jb = (jbyte*)(*env)->GetStringUTFChars(env,js,0);
@@ -84,7 +116,7 @@ Java_PerlInterpreter_eval(void *perl, JNIEnv *env, jobject obj, jstring js)
     if (jpldebug)
        fprintf(stderr, "eval %s\n", (char*)jb);
 
-    eval_pv( (char*)jb, 0 );
+    perl_eval_pv( (char*)jb, 0 );
 
     if (SvTRUE(ERRSV)) {
        jthrowable newExcCls;
@@ -105,9 +137,8 @@ Java_PerlInterpreter_eval(void *perl, JNIEnv *env, jobject obj, jstring js)
 
 /*
 JNIEXPORT jint JNICALL
-Java_PerlInterpreter_eval(void *perl, JNIEnv *env, jobject obj, jint ji)
+Java_PerlInterpreter_eval(JNIEnv *env, jobject obj, jint ji)
 {
-    dTHXa(perl);
     op = (OP*)(void*)ji;
     op = (*op->op_ppaddr)(pTHX);
     return (jint)(void*)op;
index 4927a5f..22fdf52 100644 (file)
@@ -21,7 +21,7 @@ JNIEXPORT void JNICALL Java_PerlInterpreter_init
  * Signature: (Ljava/lang/String;)V
  */
 JNIEXPORT void JNICALL Java_PerlInterpreter_eval
-  (void *perl, JNIEnv *, jobject, jstring);
+  (JNIEnv *, jobject, jstring);
 
 #ifdef __cplusplus
 }
index eb900f0..57f52c4 100644 (file)
@@ -9,12 +9,13 @@ from the network.  Don't expect not to be surprised occasionally.
 
 Requirements
 ------------
-Perl 5.005_02 (or later) must be compiled and installed as a shared library
-(libperl.so).  I had to use the system's malloc.  JPL was originally built
-and tested with 5.004_04 and early Java 1.1 development kits.  This version
-has not been well tested under 5.005_02, so you can expect some rough edges.
+Under Solaris and Linux (and other Unix-like systems), Perl 5.005 (or later)
+must be compiled and installed as a shared library (libperl.so).  I had to use
+the system's malloc.  JPL was originally built and tested with 5.004_04 and
+early Java 1.1 development kits.  This version has not been well tested under
+other versions, so you can expect some rough edges.
 
-You need JDK 1.1.  On Solaris 1.1.5 has been verified to work.  Linux
+You need JDK 1.1.  On Solaris, 1.1.5 has been verified to work.  Linux
 users can try the latest version (1.1.3 or later) available from (for
 example):
 
@@ -28,6 +29,21 @@ You may need to ensure that all files under the ../jpl directory are writable.
 install-jpl expects to be run with super-user privileges so that it can
 put things in the right places.
 
+Microsoft Windows
+-----------------
+Only a subset of JPL works under Microsoft Windows.  This subset includes
+the JNI extension and the JPL module.  This is enough for you to embed
+Java in Perl, but not Perl in Java.
+
+This has only been tested with the Sun JDK 1.1.8. I haven't tested it
+with JDK 1.2 (aka Java 2) or any Microsoft implementation of Java.
+
+Kaffe
+-----
+You might notice some mention of Kaffe (www.kaffe.org) in the source files. 
+This is because some preliminary work is being done in this area, but JPL
+doesn't yet work with Kaffe.
+
 What the heck is JPL?
 ---------------------
 JPL is a hybrid (to use the polite term) language.  It's basically Java
@@ -58,6 +74,25 @@ file it generates.
 
 Installation
 ------------
+There are two ways to install JPL.
+
+The first way gives you the ability to embed Perl in Java programs. You
+can also call back into Java from your embedded Perl programs. This should
+work well with most JDKs, and is the only option for people using a JDK
+that uses green threads (see your JDK documentation). 
+
+The second way lets you embed Java in Perl, but doesn't provide support
+for the other direction. This is good, in theory, if you need to work with
+a lot of Java classes from within Perl.  I say "in theory," because this 
+doesn't actually work a lot of the time.  To use this second way, you
+must be using a JDK with native threads.
+
+At this point, the second way is the only way to use JPL under Microsoft 
+Windows. Oddly enough, this is the only platform under which the second 
+way works!
+
+Installation the First Way (All of JPL)
+---------------------------------------
 Run "install-jpl".  You have to tell it whether you want to use the
 current directory for JPL_HOME or some other directory.  Everything
 else should take care of itself, except that after install-jpl
@@ -68,6 +103,124 @@ before any JPL applications can be compiled under the current shell.
     csh:  eval `setvars -csh`
     perl: eval `setvars -perl`;
 
+install-jpl has been tested under:
+
+    Solaris 2.5.1 SPARC, GCC 2.8.0, Perl 5.005_03, JDK 1.1.7
+    Debian 2.1 x86, Perl 5.005_60, JDK 1.1.7v3
+
+********************
+Solaris 2.5.1 Users:
+********************
+
+NOTE: Under Solaris 2.5.1, you may get an error message when install-jpl
+builds Sample.jpl:
+
+    You must install a Solaris patch to run this version of the Java 
+    runtime.  Please see the README and release notes for more 
+    information.
+    Exiting.
+
+  This is apparently a spurious message, and it has been reported to 
+  Sun.  Although this message aborts the installation, all of JPL is 
+  installed by the time this message is reached. To recover and continue, 
+  run setvars as described above, cd to the Sample directory, and type
+  'make' to continue building. You can then run 'java Sample' to test the 
+  example.
+
+  Unfortunately, each time you use 'make' to build a JPL application,
+  it will abort when it tries to run 'perl -c' on the generated .pl
+  file.  However, you can continue building by typing 'make' again.
+
+Just-JNI (call into Java from Perl only)
+----------------------------------------
+
+This has been tested with:
+
+    Debian 2.1 SPARC, Perl 5.005_60, JDK 1.2 beta (crashes with AWT, though)
+    Windows NT 4.0 SP4, ActivePerl 519, JDK 1.1.8, Visual C++
+    Solaris 7, Perl 5.005_03, JDK 1.1.6, GCC 2.8.1
+
+Solaris 7 Note (this probably applies to all native thread situations):
+
+    Native threads were tricky. I had to build my own Perl, configured with:
+
+    sh Configure -Dprefix=/opt/perl5.005 -Duseshrplib -Doptimize=-g \
+                 -Uusemymalloc -D cc=gcc -Dusethreads -d
+
+    When Configure let me edit config.sh, I changed libs to:
+
+    libs='-lthread -lsocket -lnsl -ldl -lm -lposix4 -lpthread -lc -lcrypt'
+
+    The leading -lthread is the only thing I had to add.
+
+How do I do this crazy thing?
+
+1) Cd into the JPL directory. Type the following:
+
+    perl Makefile.PL
+    make
+    make install
+
+   Under windows, that's:
+
+    perl Makefile.PL
+    nmake
+    nmake install
+
+3) cd into the JNI directory (cd ../JNI or cd ..\JNI)   
+
+4) We now need to compile and make the Closer.class available to your 
+   JPL program.  Closer is a WindowListener that closes the Frame we 
+   make in the test program.
+
+   It seems that we've managed to fix the problem with CLASSPATH not
+   getting propagated to the JVM, so if '.' is in your CLASSPATH, you
+   should be able to compile Closer.java and leave it in the current
+   directory:
+
+       javac Closer.java
+
+5) Make the demo:
+
+    a) If you are on Windows, copy typemap.win32:
+
+        copy typemap.win32 typemap
+
+       (this step will probably go away when we clean up some of the
+        WIN32 #defines)
+
+    b) type the following:
+
+        perl Makefile.PL
+        make
+        make test
+
+       Under Windows:
+
+        perl Makefile.PL
+        nmake
+        nmake test
+
+
+    c) if all went well, type:
+
+        make install
+
+       or, under Windows:
+
+        nmake install
+
+Mailing List
+------------
+To subscribe to the jpl mailing list, send an email message to 
+jpl-subscribe@perl.org.
+
+CVS Access
+----------
+Information on accessing the bleeding edge JPL via CVS can be found at:
+
+    http://users.ids.net/~bjepson/jpl/cvs.html
+
 More Info
 ---------
 
diff --git a/jpl/SETVARS.PL b/jpl/SETVARS.PL
new file mode 100644 (file)
index 0000000..d3d85b4
--- /dev/null
@@ -0,0 +1,11 @@
+# Your JDK top-level directory.
+#
+$ENV{JAVA_HOME} = 'c:\jdk1.1.8';
+
+# The location where you extracted JPL.
+#
+$ENV{JPL_HOME} = 'D:\jpl';
+
+# The executeable name of Perl
+#
+$ENV{JPLPERL} = 'perl';
index 944c7e1..cd6b093 100644 (file)
@@ -14,11 +14,16 @@ $WHAT =~ s#.*/##;
 if ($^O eq 'linux') {
     $flags = "-Dbool=char";    # avoid builtin bool altogether
     $libs = "-lc -lm -ldl";
-}
-else {
+} else {
     $flags = "";
     $libs = "-lc -lm -ldl";
 }
+
+# Needed for JNI
+if ($^O eq 'solaris') {
+    $libs .= " -lthread";
+}
+
 chop($cwd = `pwd`);
 ($jpldir = $cwd) =~ s#/[^/]*$##;
 
@@ -65,7 +70,8 @@ lib$(WHAT)_g.so: $(WHAT).c $(JPL_HOME)/lib/$(ARCHNAME)/libPerlInterpreter_g.so
        $(LIBS) \
        -o lib$(WHAT)_g.so
 
-test:
+test: all
+       java $(WHAT)
 
 install: all
        cp *.class              $(JPL_HOME)/lib
index c1ef0b4..f19e226 100755 (executable)
@@ -116,9 +116,9 @@ print "\nInstalling JNI module\n";
 system <<'END' and die "Couldn't install JNI\n";
 set -x
 cd JNI
-perl Makefile.PL
+perl Makefile.PL -e
 make clean
-perl Makefile.PL
+perl Makefile.PL -e
 make
 echo 'Attempting to install JNI as root'
 su root -c "make install"
@@ -187,14 +187,8 @@ archname=`$JPLPERL -MConfig -e 'print $Config{archname}'`
 CLASSPATH=".:$JPL_HOME/lib${CLASSPATH:+:$CLASSPATH}"
 export CLASSPATH
 
-ldlibpthname=`$JPLPERL -MConfig -e 'print $Config{ldlibpthname}'`
-case "$ldlibpthname" in
-'') ldlibpthname=LD_LIBRARY_PATH ;;
-esac
-eval "ldlibpth=\$$ldlibpthname"
-
-$ldlibpthname=".:$JPL_HOME/lib/$archname:$archlib/CORE$ldlibpth"
-export $ldlibpthname
+LD_LIBRARY_PATH=".:$JPL_HOME/lib/$archname:$archlib/CORE${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
+export LD_LIBRARY_PATH
 
 PERL5LIB="$JPL_HOME/perl${PERL5LIB:+:$PERL5LIB}"
 export PERL5LIB
@@ -211,13 +205,13 @@ case "$1" in
 \$ENV{JPL_HOME} = '$JPL_HOME';
 \$ENV{JPLPERL} = '$JPLPERL';
 \$ENV{CLASSPATH} = '$CLASSPATH';
-\$ENV{$ldlibpthname} = '$ldlibpth';
+\$ENV{LD_LIBRARY_PATH} = '$LD_LIBRARY_PATH';
 \$ENV{PERL5LIB} = '$PERL5LIB';
 END
     ;;
 -sh)
     cat <<END
- PATH='$PATH';export PATH;JAVA_HOME='$JAVA_HOME';export JAVA_HOME;JPL_HOME='$JPL_HOME';export JPL_HOME;JPLPERL='$JPLPERL';export JPLPERL;CLASSPATH='$CLASSPATH';export CLASSPATH;$ldlibpthname='$ldlibpth';export $ldlibpthname;PERL5LIB='$PERL5LIB';export PERL5LIB
+ PATH='$PATH';export PATH;JAVA_HOME='$JAVA_HOME';export JAVA_HOME;JPL_HOME='$JPL_HOME';export JPL_HOME;JPLPERL='$JPLPERL';export JPLPERL;CLASSPATH='$CLASSPATH';export CLASSPATH;LD_LIBRARY_PATH='$LD_LIBRARY_PATH';export LD_LIBRARY_PATH;PERL5LIB='$PERL5LIB';export PERL5LIB
 END
     ;;
 -csh)
@@ -227,7 +221,7 @@ setenv JAVA_HOME '$JAVA_HOME';
 setenv JPL_HOME '$JPL_HOME';
 setenv JPLPERL '$JPLPERL';
 setenv CLASSPATH '$CLASSPATH';
-setenv $ldlibpthname '$ldlibpth';
+setenv LD_LIBRARY_PATH '$LD_LIBRARY_PATH';
 setenv PERL5LIB '$PERL5LIB';
 END
     ;;
index ffc1199..140738f 100644 (file)
@@ -3,7 +3,7 @@ package File::Spec::Functions;
 use File::Spec;
 use strict;
 
-use vars qw(@ISA @EXPORT @EXPORT_OK);
+use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
 
 require Exporter;
 
@@ -31,6 +31,8 @@ require Exporter;
        rel2abs
 );
 
+%EXPORT_TAGS = ( ALL => [ @EXPORT_OK, @EXPORT ] );
+
 foreach my $meth (@EXPORT, @EXPORT_OK) {
     my $sub = File::Spec->can($meth);
     no strict 'refs';
@@ -85,6 +87,8 @@ The following functions are exported only by request.
        abs2rel
        rel2abs
 
+All the functions may be imported using the C<:ALL> tag.
+
 =head1 SEE ALSO
 
 File::Spec, File::Spec::Unix, File::Spec::Mac, File::Spec::OS2,
index 6a171d3..adc0212 100644 (file)
@@ -122,13 +122,13 @@ the strings?).
           5.003alpha7   1994-Mar-25
  Andy     5.000alpha8   1994-Apr-04
  Larry    5.000alpha9   1994-May-05     ext appears.
-          5.000alpha10  1994-???-??
-          5.000alpha11  1994-???-??
+          5.000alpha10  1994-Jun-11
+          5.000alpha11  1994-Jul-01
  Andy     5.000a11a     1994-Jul-07     To fit 14.
           5.000a11b     1994-Jul-14
           5.000a11c     1994-Jul-19
           5.000a11d     1994-Jul-22
- Larry    5.000alpha12  1994-???-??
+ Larry    5.000alpha12  1994-Aug-04
  Andy     5.000a12a     1994-Aug-08
           5.000a12b     1994-Aug-15
           5.000a12c     1994-Aug-22
@@ -137,8 +137,8 @@ the strings?).
           5.000a12f     1994-Aug-24
           5.000a12g     1994-Aug-24
           5.000a12h     1994-Aug-24
- Larry    5.000beta1    1994-???-??
- Andy     5.000b1a      1994-???-??
+ Larry    5.000beta1    1994-Aug-30
+ Andy     5.000b1a      1994-Sep-06
  Larry    5.000beta2    1994-Sep-14     Core slushified.
  Andy     5.000b2a      1994-Sep-14
           5.000b2b      1994-Sep-17
@@ -167,7 +167,7 @@ the strings?).
           5.000j        1995-Feb-07
           5.000k        1995-Feb-11
           5.000l        1995-Feb-21
-          5.000m        1995-???-??
+          5.000m        1995-Feb-28
           5.000n        1995-Mar-07
 
  Larry   5.001          1995-Mar-13
@@ -187,7 +187,7 @@ the strings?).
           5.001m        1995-Jul-02     Very stable.
           5.001n        1995-Oct-31     Very unstable.
           5.002beta1    1995-Nov-21
-          5.002b1a      1995-Nov-??
+          5.002b1a      1995-Dec-04
           5.002b1b      1995-Dec-04
           5.002b1c      1995-Dec-04
           5.002b1d      1995-Dec-04
@@ -549,7 +549,7 @@ Jarkko Hietaniemi <F<jhi@iki.fi>>.
 
 Thanks to the collective memory of the Perlfolk.  In addition to the
 Keepers of the Pumpkin also Alan Champion, Andreas K├Ânig, John
-Macdonald, Matthias Neeracher, Michael Peppler, Randal Schwartz, and
-Paul D. Smith sent corrections and additions.
+Macdonald, Matthias Neeracher, Jeff Okamoto, Michael Peppler,
+Randal Schwartz, and Paul D. Smith sent corrections and additions.
 
 =cut
index 8361145..d55c5be 100644 (file)
--- a/regexec.c
+++ b/regexec.c
@@ -278,7 +278,16 @@ S_cache_re(pTHX_ regexp *prog)
 /* A failure to find a constant substring means that there is no need to make
    an expensive call to REx engine, thus we celebrate a failure.  Similarly,
    finding a substring too deep into the string means that less calls to
-   regtry() should be needed. */
+   regtry() should be needed.
+
+   REx compiler's optimizer found 4 possible hints:
+       a) Anchored substring;
+       b) Fixed substring;
+       c) Whether we are anchored (beginning-of-line or \G);
+       d) First node (of those at offset 0) which may distingush positions;
+   We use 'a', 'b', multiline-part of 'c', and try to find a position in the
+   string which does not contradict any of them.
+ */
 
 char *
 Perl_re_intuit_start(pTHX_ regexp *prog, SV *sv, char *strpos,
@@ -293,6 +302,9 @@ Perl_re_intuit_start(pTHX_ regexp *prog, SV *sv, char *strpos,
     I32 ml_anch;
     char *tmp;
     register char *other_last = Nullch;
+#ifdef DEBUGGING
+    char *i_strpos = strpos;
+#endif
 
     DEBUG_r( if (!PL_colorset) reginitcolors() );
     DEBUG_r(PerlIO_printf(Perl_debug_log,
@@ -420,7 +432,7 @@ Perl_re_intuit_start(pTHX_ regexp *prog, SV *sv, char *strpos,
        goto fail_finish;
 
     /* Finish the diagnostic message */
-    DEBUG_r(PerlIO_printf(Perl_debug_log, "%ld...\n", (long)(s - strpos)) );
+    DEBUG_r(PerlIO_printf(Perl_debug_log, "%ld...\n", (long)(s - i_strpos)) );
 
     /* Got a candidate.  Check MBOL anchoring, and the *other* substr.
        Start with the other substr.
@@ -431,11 +443,13 @@ Perl_re_intuit_start(pTHX_ regexp *prog, SV *sv, char *strpos,
      */
 
     if (prog->float_substr && prog->anchored_substr) {
-       /* Take into account the anchored substring. */
+       /* Take into account the "other" substring. */
        /* XXXX May be hopelessly wrong for UTF... */
        if (!other_last)
            other_last = strpos - 1;
        if (check == prog->float_substr) {
+         do_other_anchored:
+           {
                char *last = s - start_shift, *last1, *last2;
                char *s1 = s;
 
@@ -446,7 +460,7 @@ Perl_re_intuit_start(pTHX_ regexp *prog, SV *sv, char *strpos,
                        || (PL_bostr = strpos, /* Used in regcopmaybe() */
                            (t = reghopmaybe_c(s, -(prog->check_offset_max)))
                            && t > strpos)))
-                   ;
+                   /* EMPTY */;
                else
                    t = strpos;
                t += prog->anchored_offset;
@@ -478,7 +492,7 @@ Perl_re_intuit_start(pTHX_ regexp *prog, SV *sv, char *strpos,
                    }
                    DEBUG_r(PerlIO_printf(Perl_debug_log,
                        ", trying floating at offset %ld...\n",
-                       (long)(s1 + 1 - strpos)));
+                       (long)(s1 + 1 - i_strpos)));
                    PL_regeol = strend;                 /* Used in HOP() */
                    other_last = last1 + prog->anchored_offset;
                    s = HOPc(last, 1);
@@ -486,14 +500,15 @@ Perl_re_intuit_start(pTHX_ regexp *prog, SV *sv, char *strpos,
                }
                else {
                    DEBUG_r(PerlIO_printf(Perl_debug_log, " at offset %ld...\n",
-                         (long)(s - strpos)));
+                         (long)(s - i_strpos)));
                    t = s - prog->anchored_offset;
                    other_last = s - 1;
+                   s = s1;
                    if (t == strpos)
                        goto try_at_start;
-                   s = s1;
                    goto try_at_offset;
                }
+           }
        }
        else {          /* Take into account the floating substring. */
                char *last, *last1;
@@ -529,7 +544,7 @@ Perl_re_intuit_start(pTHX_ regexp *prog, SV *sv, char *strpos,
                    }
                    DEBUG_r(PerlIO_printf(Perl_debug_log,
                        ", trying anchored starting at offset %ld...\n",
-                       (long)(s1 + 1 - strpos)));
+                       (long)(s1 + 1 - i_strpos)));
                    other_last = last;
                    PL_regeol = strend;                 /* Used in HOP() */
                    s = HOPc(t, 1);
@@ -537,11 +552,11 @@ Perl_re_intuit_start(pTHX_ regexp *prog, SV *sv, char *strpos,
                }
                else {
                    DEBUG_r(PerlIO_printf(Perl_debug_log, " at offset %ld...\n",
-                         (long)(s - strpos)));
+                         (long)(s - i_strpos)));
                    other_last = s - 1;
+                   s = s1;
                    if (t == strpos)
                        goto try_at_start;
-                   s = s1;
                    goto try_at_offset;
                }
        }
@@ -559,18 +574,36 @@ Perl_re_intuit_start(pTHX_ regexp *prog, SV *sv, char *strpos,
           cannot start at strpos. */
       try_at_offset:
        if (ml_anch && t[-1] != '\n') {
-         find_anchor:          /* Eventually fbm_*() should handle this */
+           /* Eventually fbm_*() should handle this, but often
+              anchored_offset is not 0, so this check will not be wasted. */
+           /* XXXX In the code below we prefer to look for "^" even in
+              presence of anchored substrings.  And we search even
+              beyond the found float position.  These pessimizations
+              are historical artefacts only.  */
+         find_anchor:
            while (t < strend - prog->minlen) {
                if (*t == '\n') {
                    if (t < s - prog->check_offset_min) {
+                       if (prog->anchored_substr) {
+                           /* We definitely contradict the found anchored
+                              substr.  Due to the above check we do not
+                              contradict "check" substr.
+                              Thus we can arrive here only if check substr
+                              is float.  Redo checking for "other"=="fixed".
+                            */
+                           strpos = t + 1;                         
+                           DEBUG_r(PerlIO_printf(Perl_debug_log, "Found /%s^%s/m at offset %ld, rescanning for anchored from offset %ld...\n",
+                               PL_colors[0],PL_colors[1], (long)(strpos - i_strpos), (long)(strpos - i_strpos + prog->anchored_offset)));
+                           goto do_other_anchored;
+                       }
                        s = t + 1;
                        DEBUG_r(PerlIO_printf(Perl_debug_log, "Found /%s^%s/m at offset %ld...\n",
-                           PL_colors[0],PL_colors[1], (long)(s - strpos)));
+                           PL_colors[0],PL_colors[1], (long)(s - i_strpos)));
                        goto set_useful;
                    }
                    DEBUG_r(PerlIO_printf(Perl_debug_log, "Found /%s^%s/m, restarting at offset %ld...\n",
-                       PL_colors[0],PL_colors[1], (long)(t + 1 - strpos)));
-                   s = t + 1;
+                       PL_colors[0],PL_colors[1], (long)(t + 1 - i_strpos)));
+                   strpos = s = t + 1;
                    goto restart;
                }
                t++;
@@ -596,8 +629,12 @@ Perl_re_intuit_start(pTHX_ regexp *prog, SV *sv, char *strpos,
            t = strpos;
            goto find_anchor;
        }
+       DEBUG_r( if (ml_anch)
+           PerlIO_printf(Perl_debug_log, "Does not contradict /%s^%s/m...\n",
+                       PL_colors[0],PL_colors[1]);
+       );
       success_at_start:
-       if (!(prog->reganch & ROPT_NAUGHTY)
+       if (!(prog->reganch & ROPT_NAUGHTY)     /* XXXX If strpos moved? */
            && --BmUSEFUL(prog->check_substr) < 0
            && prog->check_substr == prog->float_substr) { /* boo */
            /* If flags & SOMETHING - do not do it many times on the same match */
@@ -612,7 +649,7 @@ Perl_re_intuit_start(pTHX_ regexp *prog, SV *sv, char *strpos,
     }
 
     DEBUG_r(PerlIO_printf(Perl_debug_log, "%sGuessed:%s match at offset %ld\n",
-                         PL_colors[4], PL_colors[5], (long)(s - strpos)) );
+                         PL_colors[4], PL_colors[5], (long)(s - i_strpos)) );
     return s;
 
   fail_finish:                         /* Substring not found */
@@ -755,9 +792,12 @@ Perl_regexec_flags(pTHX_ register regexp *prog, char *stringarg, register char *
            end = HOPc(strend, -dontbother) - 1;
            /* for multiline we only have to try after newlines */
            if (prog->check_substr) {
+               if (s == startpos)
+                   goto after_try;
                while (1) {
                    if (regtry(prog, s))
                        goto got_it;
+                 after_try:
                    if (s >= end)
                        goto phooey;
                    s = re_intuit_start(prog, sv, s + 1, strend, flags, NULL);
index 768d1b9..89cc2bb 100755 (executable)
@@ -4,7 +4,7 @@
 # the format supported by op/regexp.t.  If you want to add a test
 # that does fit that format, add it to op/re_tests, not here.
 
-print "1..191\n";
+print "1..192\n";
 
 BEGIN {
     chdir 't' if -d 't';
@@ -882,3 +882,8 @@ print "not " unless $1 eq "{ and }";
 print "ok $test\n";
 $test++;
 
+$_ = "a-a\nxbb";
+pos=1;
+m/^-.*bb/mg and print "not ";
+print "ok $test\n";
+$test++;