Commit | Line | Data |
---|---|---|
35ef589f JH |
1 | Just-JNI (call into Java from Perl only) |
2 | ---------------------------------------- | |
3 | ||
4 | This has been tested with: | |
5 | ||
6 | Debian GNU/Linux 2.2 i386, perl 5.6.0, Kaffe (CVS, 2000-12-05 or later) | |
7 | RedHat 6.1, perl-5.00503-6 (RedHat RPM), IBM JDK 1.1.8 | |
8 | Debian 2.1 SPARC, Perl 5.005_60, JDK 1.2 beta (crashes with AWT, though) | |
9 | Windows NT 4.0 SP4, ActivePerl 519, JDK 1.1.8, Visual C++ | |
10 | Solaris 7, Perl 5.005_03, JDK 1.1.6, GCC 2.8.1 | |
11 | ||
12 | Solaris 7 Note (this probably applies to all native thread situations): | |
13 | ||
14 | Native threads were tricky. I had to build my own Perl, configured with: | |
15 | ||
16 | sh Configure -Dprefix=/opt/perl5.005 -Duseshrplib -Doptimize=-g \ | |
17 | -Uusemymalloc -D cc=gcc -Dusethreads -d | |
18 | ||
19 | When Configure let me edit config.sh, I changed libs to: | |
20 | ||
21 | libs='-lthread -lsocket -lnsl -ldl -lm -lposix4 -lpthread -lc -lcrypt' | |
22 | ||
23 | The leading -lthread is the only thing I had to add. | |
24 | ||
25 | Kaffe Note: | |
26 | ||
27 | I believe that Kaffe with JIT enabled will likely be problematic. I had a | |
28 | lot of trouble with it, that simply went away with interpreter-based Kaffe. | |
29 | FWIW, here's how I configured Kaffe: | |
30 | ||
31 | env AM_CPPFLAGS=-DDEBUG CFLAGS="-O0 -ggdb" ./configure --disable-gcj \ | |
32 | --with-engine=intrp | |
33 | ||
34 | Likely you don't need all that debugging stuff. | |
35 | ||
36 | Also, when I build perl, I do this, to be on the safe side. I was worried | |
37 | about thread interaction, but realized there was no need to build threaded | |
38 | perl, but I thought that the perl code should probably be reentrant, so, I | |
39 | did this: | |
40 | ||
41 | sh ./Configure -Dcc=gcc -Doptimize='-D_REENTRANT -DDEBUGGING -ggdb' \ | |
42 | -Dlibperl='libperl.so' -Duseshrplib='true' | |
43 | ||
44 | Again, you likely don't need the debugging flags. | |
45 | ||
46 | ||
47 | How do I do this crazy thing? | |
48 | ----------------------------- | |
49 | ||
50 | 1) Cd into the JPL directory. Type the following: | |
51 | ||
52 | perl Makefile.PL | |
53 | make | |
54 | make install | |
55 | ||
56 | Under windows, that's: | |
57 | ||
58 | perl Makefile.PL | |
59 | nmake | |
60 | nmake install | |
61 | ||
62 | 3) cd into the JNI directory (cd ../JNI or cd ..\JNI) | |
63 | ||
64 | 4) We now need to compile and make the Closer.class available to your | |
65 | JPL program. Closer is a WindowListener that closes the Frame we | |
66 | make in the test program. | |
67 | ||
68 | It seems that we've managed to fix the problem with CLASSPATH not | |
69 | getting propagated to the JVM, so if '.' is in your CLASSPATH, you | |
70 | should be able to compile Closer.java and leave it in the current | |
71 | directory: | |
72 | ||
73 | javac Closer.java | |
74 | ||
75 | or perhaps | |
76 | ||
77 | jikes Closer.java | |
78 | ||
79 | 5) Make the demo: | |
80 | ||
81 | a) type the following: | |
82 | ||
83 | for SUN's proprietary software Java: | |
84 | ||
85 | env JAVA_HOME=/path/to/java perl Makefile.PL | |
86 | # setting the JAVA_HOME enviornment variable might not be needed | |
87 | # if Java is in installed in a canonical location | |
88 | make | |
89 | make test | |
90 | ||
91 | for Kaffe: | |
92 | ||
93 | env KAFFE_PREFIX=/kaffe/installation/prefix perl Makefile.PL | |
94 | # setting the KAFFE_PREFIX enviornment variable might not be needed | |
95 | # if Kaffe is in a canonical location | |
96 | make | |
97 | make test | |
98 | ||
99 | Under Windows: | |
100 | ||
101 | perl Makefile.PL | |
102 | nmake | |
103 | nmake test | |
104 | ||
105 | ||
106 | b) if all went well, type: | |
107 | ||
108 | make install | |
109 | ||
110 | or, under Windows: | |
111 | ||
112 | nmake install | |
113 |