5 use vars qw($VERSION @ISA @EXPORT @EXPORT_OK $AUTOLOAD $JVM @JVM_ARGS $JAVALIB);
11 @ISA = qw(Exporter DynaLoader);
62 CallNonvirtualObjectMethod
63 CallNonvirtualObjectMethodA
64 CallNonvirtualBooleanMethod
65 CallNonvirtualBooleanMethodA
66 CallNonvirtualByteMethod
67 CallNonvirtualByteMethodA
68 CallNonvirtualCharMethod
69 CallNonvirtualCharMethodA
70 CallNonvirtualShortMethod
71 CallNonvirtualShortMethodA
72 CallNonvirtualIntMethod
73 CallNonvirtualIntMethodA
74 CallNonvirtualLongMethod
75 CallNonvirtualLongMethodA
76 CallNonvirtualFloatMethod
77 CallNonvirtualFloatMethodA
78 CallNonvirtualDoubleMethod
79 CallNonvirtualDoubleMethodA
80 CallNonvirtualVoidMethod
81 CallNonvirtualVoidMethodA
102 CallStaticObjectMethod
103 CallStaticObjectMethodA
104 CallStaticBooleanMethod
105 CallStaticBooleanMethodA
107 CallStaticByteMethodA
109 CallStaticCharMethodA
110 CallStaticShortMethod
111 CallStaticShortMethodA
115 CallStaticLongMethodA
116 CallStaticFloatMethod
117 CallStaticFloatMethodA
118 CallStaticDoubleMethod
119 CallStaticDoubleMethodA
121 CallStaticVoidMethodA
124 GetStaticBooleanField
133 SetStaticBooleanField
149 GetObjectArrayElement
150 SetObjectArrayElement
159 GetBooleanArrayElements
162 GetShortArrayElements
165 GetFloatArrayElements
166 GetDoubleArrayElements
167 GetBooleanArrayRegion
175 SetBooleanArrayRegion
193 # This AUTOLOAD is used to 'autoload' constants from the constant()
194 # XS function. If a constant is not found then control is passed
195 # to the AUTOLOAD in AutoLoader.
198 ($constname = $AUTOLOAD) =~ s/.*:://;
199 my $val = constant($constname, @_ ? $_[0] : 0);
201 if ($! =~ /Invalid/ || $!{EINVAL}) {
202 $AutoLoader::AUTOLOAD = $AUTOLOAD;
203 goto &AutoLoader::AUTOLOAD;
206 croak "Your vendor has not defined JNI macro $constname";
209 eval "sub $AUTOLOAD { $val }";
213 bootstrap JNI $VERSION;
215 if (not $JPL::_env_) {
216 # Note that only Kaffe support only cares about what JNI::Config says
217 use JNI::Config qw($KAFFE $LD_LIBRARY_PATH $CLASS_HOME $LIB_HOME $JAVA_LIB);
219 # Win32 and Sun JDK pay attention to $ENV{JAVA_HOME}; Kaffe doesn't
220 $ENV{JAVA_HOME} ||= "/usr/local/java";
222 my ($arch, @CLASSPATH);
223 if ($^O eq 'MSWin32' and (! $JNI::Config::KAFFE) ) {
225 $arch = 'MSWin32' unless -d "$ENV{JAVA_HOME}/lib/$arch";
226 @CLASSPATH = split(/;/, $ENV{CLASSPATH});
227 @CLASSPATH = "." unless @CLASSPATH;
229 "$ENV{JAVA_HOME}\\classes",
230 "$ENV{JAVA_HOME}\\lib\\classes.zip",
231 # MSR - added for JDK 1.3
232 "$ENV{JAVA_HOME}\\jre\\lib\\rt.jar",
233 # MSR - added to find Closer.class
236 $ENV{CLASSPATH} = join(';', @CLASSPATH);
237 $ENV{THREADS_TYPE} ||= "green_threads";
239 #$JAVALIB = "$ENV{JAVA_HOME}/lib/$arch/$ENV{THREADS_TYPE}";
240 # MSR - changed above for JDK 1.3
241 $JAVALIB = "$ENV{JAVA_HOME}/lib/";
243 $ENV{LD_LIBRARY_PATH} .= ":$JAVALIB";
245 push @JVM_ARGS, "classpath", $ENV{CLASSPATH};
246 print "JVM_ARGS=@JVM_ARGS!\n" if $JPL::DEBUG;
247 $JVM = GetJavaVM("$JAVALIB/javai.dll",@JVM_ARGS);
248 } elsif ($^O eq 'MSWin32' and $JNI::Config::KAFFE) {
249 croak "Kaffe is not yet supported on MSWin32 platform!";
250 } elsif ($JNI::Config::KAFFE) {
251 # The following code has to build a classpath for us. It would be
252 # better if we could have *both* a classpath and a classhome, and
253 # not have to "guess" at the classpath like this. We should be able
254 # to send in, say, a classpath of ".", and classhome of
255 # ".../share/kaffe", and have it build the right classpath. That
256 # doesn't work. The function initClasspath() in findInJar.c in the
257 # Kaffe source says: "Oh, you have a classpath, well forget
258 # classhome!" This seems brain-dead to me. But, anyway, that's why
259 # I don't use the classhome option on GetJavaVM. I have to build
260 # the classpath by hand. *sigh*
263 my $classpath = $ENV{CLASSPATH} || ".";
265 @classCheck{split(/\s*:\s*/, $classpath)} = 1;
266 foreach my $jarFile (qw(Klasses.jar comm.jar pjava.jar
267 tools.jar microsoft.jar rmi.jar)) {
268 $classpath .= ":$JNI::Config::CLASS_HOME/$jarFile"
269 unless defined $classCheck{"$JNI::Config::CLASS_HOME/$jarFile"};
270 # Assume that if someone else already put these here, they knew
271 # what they were doing and have the order right.
273 $classpath = ".:$classpath" unless defined $classCheck{"."};
275 $ENV{CLASSPATH} = $classpath; # Not needed for GetJavaVM(), since
276 # we pass it in as a JVM option, but
277 # something else might expect it.
278 # (also see comment above)
279 print STDERR "bkuhn: JNI classpath=$classpath\n";
280 unshift(@JVM_ARGS, "classpath", $classpath,
281 "libraryhome", $JNI::Config::LIB_HOME);
283 # The following line is useless; see comment above.
284 # "classhome", $JNI::Config::CLASS_HOME);
286 $JVM = GetJavaVM($JNI::Config::JAVA_LIB, @JVM_ARGS);
288 chop($arch = `uname -p`);
289 chop($arch = `uname -m`) unless -d "$ENV{JAVA_HOME}/lib/$arch";
291 @CLASSPATH = split(/:/, $ENV{CLASSPATH});
292 @CLASSPATH = "." unless @CLASSPATH;
294 "$ENV{JAVA_HOME}/classes",
295 "$ENV{JAVA_HOME}/lib/classes.zip";
296 $ENV{CLASSPATH} = join(':', @CLASSPATH);
298 $ENV{THREADS_TYPE} ||= "green_threads";
300 $JAVALIB = "$ENV{JAVA_HOME}/lib/$arch/$ENV{THREADS_TYPE}";
301 $ENV{LD_LIBRARY_PATH} .= ":$JAVALIB";
302 push @JVM_ARGS, "classpath", $ENV{CLASSPATH};
303 print "JVM_ARGS=@JVM_ARGS!\n" if $JPL::DEBUG;
304 $JVM = GetJavaVM("$JAVALIB/libjava.so",@JVM_ARGS);
313 JNI - Perl encapsulation of the Java Native Interface
321 This module provides an encapsulation in Perl of the Java Native Interface.
323 =head1 Exported constants
336 Copyright 1998, O'Reilly & Associates, Inc.
338 This package may be copied under the same terms as Perl itself.