Small test tweaks.
[p5sagit/p5-mst-13.2.git] / jpl / JNI / JNI.pm
CommitLineData
d50cb536 1package JNI;
2
3use strict;
4use Carp;
5use vars qw($VERSION @ISA @EXPORT @EXPORT_OK $AUTOLOAD $JVM @JVM_ARGS $JAVALIB);
6
7require Exporter;
8require DynaLoader;
9require AutoLoader;
10
11@ISA = qw(Exporter DynaLoader);
12
13@EXPORT = qw(
14 JNI_ABORT
15 JNI_COMMIT
16 JNI_ERR
17 JNI_FALSE
18 JNI_H
19 JNI_OK
20 JNI_TRUE
21 GetVersion
22 DefineClass
23 FindClass
24 GetSuperclass
25 IsAssignableFrom
26 Throw
27 ThrowNew
28 ExceptionOccurred
29 ExceptionDescribe
30 ExceptionClear
31 FatalError
32 NewGlobalRef
33 DeleteGlobalRef
34 DeleteLocalRef
35 IsSameObject
36 AllocObject
37 NewObject
38 NewObjectA
39 GetObjectClass
40 IsInstanceOf
41 GetMethodID
42 CallObjectMethod
43 CallObjectMethodA
44 CallBooleanMethod
45 CallBooleanMethodA
46 CallByteMethod
47 CallByteMethodA
48 CallCharMethod
49 CallCharMethodA
50 CallShortMethod
51 CallShortMethodA
52 CallIntMethod
53 CallIntMethodA
54 CallLongMethod
55 CallLongMethodA
56 CallFloatMethod
57 CallFloatMethodA
58 CallDoubleMethod
59 CallDoubleMethodA
60 CallVoidMethod
61 CallVoidMethodA
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
82 GetFieldID
83 GetObjectField
84 GetBooleanField
85 GetByteField
86 GetCharField
87 GetShortField
88 GetIntField
89 GetLongField
90 GetFloatField
91 GetDoubleField
92 SetObjectField
93 SetBooleanField
94 SetByteField
95 SetCharField
96 SetShortField
97 SetIntField
98 SetLongField
99 SetFloatField
100 SetDoubleField
101 GetStaticMethodID
102 CallStaticObjectMethod
103 CallStaticObjectMethodA
104 CallStaticBooleanMethod
105 CallStaticBooleanMethodA
106 CallStaticByteMethod
107 CallStaticByteMethodA
108 CallStaticCharMethod
109 CallStaticCharMethodA
110 CallStaticShortMethod
111 CallStaticShortMethodA
112 CallStaticIntMethod
113 CallStaticIntMethodA
114 CallStaticLongMethod
115 CallStaticLongMethodA
116 CallStaticFloatMethod
117 CallStaticFloatMethodA
118 CallStaticDoubleMethod
119 CallStaticDoubleMethodA
120 CallStaticVoidMethod
121 CallStaticVoidMethodA
122 GetStaticFieldID
123 GetStaticObjectField
124 GetStaticBooleanField
125 GetStaticByteField
126 GetStaticCharField
127 GetStaticShortField
128 GetStaticIntField
129 GetStaticLongField
130 GetStaticFloatField
131 GetStaticDoubleField
132 SetStaticObjectField
133 SetStaticBooleanField
134 SetStaticByteField
135 SetStaticCharField
136 SetStaticShortField
137 SetStaticIntField
138 SetStaticLongField
139 SetStaticFloatField
140 SetStaticDoubleField
141 NewString
142 GetStringLength
143 GetStringChars
144 NewStringUTF
145 GetStringUTFLength
146 GetStringUTFChars
147 GetArrayLength
148 NewObjectArray
149 GetObjectArrayElement
150 SetObjectArrayElement
151 NewBooleanArray
152 NewByteArray
153 NewCharArray
154 NewShortArray
155 NewIntArray
156 NewLongArray
157 NewFloatArray
158 NewDoubleArray
159 GetBooleanArrayElements
160 GetByteArrayElements
161 GetCharArrayElements
162 GetShortArrayElements
163 GetIntArrayElements
164 GetLongArrayElements
165 GetFloatArrayElements
166 GetDoubleArrayElements
167 GetBooleanArrayRegion
168 GetByteArrayRegion
169 GetCharArrayRegion
170 GetShortArrayRegion
171 GetIntArrayRegion
172 GetLongArrayRegion
173 GetFloatArrayRegion
174 GetDoubleArrayRegion
175 SetBooleanArrayRegion
176 SetByteArrayRegion
177 SetCharArrayRegion
178 SetShortArrayRegion
179 SetIntArrayRegion
180 SetLongArrayRegion
181 SetFloatArrayRegion
182 SetDoubleArrayRegion
183 RegisterNatives
184 UnregisterNatives
185 MonitorEnter
186 MonitorExit
187 GetJavaVM
188);
189
190$VERSION = '0.01';
191
192sub AUTOLOAD {
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.
196
197 my $constname;
198 ($constname = $AUTOLOAD) =~ s/.*:://;
199 my $val = constant($constname, @_ ? $_[0] : 0);
200 if ($! != 0) {
265f5c4a 201 if ($! =~ /Invalid/ || $!{EINVAL}) {
d50cb536 202 $AutoLoader::AUTOLOAD = $AUTOLOAD;
203 goto &AutoLoader::AUTOLOAD;
204 }
205 else {
206 croak "Your vendor has not defined JNI macro $constname";
207 }
208 }
209 eval "sub $AUTOLOAD { $val }";
210 goto &$AUTOLOAD;
211}
212
213bootstrap JNI $VERSION;
214
215if (not $JPL::_env_) {
216 $ENV{JAVA_HOME} ||= "/usr/local/java";
217
218 chop(my $arch = `uname -p`);
219 chop($arch = `uname -m`) unless -d "$ENV{JAVA_HOME}/lib/$arch";
220
221 my @CLASSPATH = split(/:/, $ENV{CLASSPATH});
222 @CLASSPATH = "." unless @CLASSPATH;
223 push @CLASSPATH,
224 "$ENV{JAVA_HOME}/classes",
225 "$ENV{JAVA_HOME}/lib/classes.zip";
226 $ENV{CLASSPATH} = join(':', @CLASSPATH);
227
228 $ENV{THREADS_TYPE} ||= "green_threads";
229
230 $JAVALIB = "$ENV{JAVA_HOME}/lib/$arch/$ENV{THREADS_TYPE}";
c99d408a 231 $ENV{$Config{ldlibpthname}} .= ":$JAVALIB";
d50cb536 232
233 $JVM = GetJavaVM("$JAVALIB/libjava.so",@JVM_ARGS);
234}
235
d50cb536 2361;
237__END__
d50cb536 238
239=head1 NAME
240
db4a4bfe 241JNI - Perl encapsulation of the Java Native Interface
d50cb536 242
243=head1 SYNOPSIS
244
245 use JNI;
d50cb536 246
247=head1 DESCRIPTION
248
d50cb536 249=head1 Exported constants
250
251 JNI_ABORT
252 JNI_COMMIT
253 JNI_ERR
254 JNI_FALSE
255 JNI_H
256 JNI_OK
257 JNI_TRUE
258
259
260=head1 AUTHOR
261
db4a4bfe 262Copyright 1998, O'Reilly & Associates, Inc.
263
264This package may be copied under the same terms as Perl itself.
d50cb536 265
266=head1 SEE ALSO
267
268perl(1).
269
270=cut