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