3 # Fail if any command fails
5 # Don't override existing files
8 TMPFILE
=/tmp
/check-jni-methods.$$
.1
9 TMPFILE2
=/tmp
/check-jni-methods.$$
.2
10 TMPFILE3
=/tmp
/check-jni-methods.$$
.3
12 # Find all methods defined in the header files generated
13 # from the java source files.
14 grep -h '^JNIEXPORT .* Java_' include
/*.h | \
15 LC_ALL
=C
sed -e 's,.*JNICALL \(Java_[a-z_A-Z0-9]*\).*$,\1,' | \
18 # Find all methods in the JNI C source files.
19 find native
/jni
-name \
*.c | \
20 xargs grep -h '^Java_' | \
21 LC_ALL
=C
sed -e 's,^\(Java_[a-z_A-Z0-9]*\) *(.*$,\1,' > $TMPFILE2
22 # Or in the the C++ files. (Note that cpp doesn't follow gnu conventions atm)
23 # So we try to match both GNU style and some other style.
24 find native
/jni
-name \
*.cpp | \
25 xargs grep -h '^Java_' | \
26 LC_ALL
=C
sed -e 's,^\(Java_[a-z_A-Z0-9]*\) *(.*$,\1,' >> $TMPFILE2
27 find native
/jni
-name \
*.cpp | \
28 xargs egrep -h '^(JNIEXPORT .* JNICALL )?Java_' | \
30 LC_ALL
=C
sed -e 's,^\JNIEXPORT .* JNICALL \(Java_[a-z_A-Z0-9]*\) *(.*$,\1,' >> $TMPFILE2
31 mv $TMPFILE2 $TMPFILE3
32 sort $TMPFILE3 > $TMPFILE2
35 # Write temporary ignore file.
36 cat > $TMPFILE3 << EOF
37 -Java_gnu_java_awt_peer_gtk_GtkMenuComponentPeer_dispose
38 -Java_java_lang_VMSystem_arraycopy
39 -Java_java_lang_VMSystem_identityHashCode
42 # Compare again silently.
43 # Use fgrep and direct the output to /dev/null for compatibility with older
44 # grep instead of using the non portable -q.
45 if diff -b -U 0 $TMPFILE $TMPFILE2 |
grep '^[+-]Java' | \
46 fgrep
-v -f $TMPFILE3 > /dev
/null
;
49 echo "Found a problem with the JNI methods declared and implemented."
50 echo "(-) missing in implementation, (+) missing in header files"
52 # Compare the found method lists.
53 diff -b -U 0 $TMPFILE $TMPFILE2 |
grep '^[+-]Java' | fgrep
-v -f $TMPFILE3
57 rm -f $TMPFILE $TMPFILE2 $TMPFILE3
59 if test "$PROBLEM" = "1" ; then