18 |
# Find all methods in the JNI C source files. |
# Find all methods in the JNI C source files. |
19 |
find native/jni -name \*.c | \ |
find native/jni -name \*.c | \ |
20 |
xargs grep -h '^Java_' | \ |
xargs grep -h '^Java_' | \ |
21 |
LC_ALL=C sed -e 's,^\(Java_[a-z_A-Z0-9]*\) *(.*$,\1,' | \ |
LC_ALL=C sed -e 's,^\(Java_[a-z_A-Z0-9]*\) *(.*$,\1,' > $TMPFILE2 |
22 |
sort > $TMPFILE2 |
# 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_' | \ |
29 |
|
cut -f4 -d\ | \ |
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 |
33 |
|
rm $TMPFILE3 |
34 |
|
|
35 |
# Write temporary ignore file. |
# Write temporary ignore file. |
36 |
cat > $TMPFILE3 << EOF |
cat > $TMPFILE3 << EOF |
40 |
EOF |
EOF |
41 |
|
|
42 |
# Compare again silently. |
# Compare again silently. |
43 |
if diff -ub -0 $TMPFILE $TMPFILE2 | grep '^[+-]Java' | grep -q -v -f $TMPFILE3; |
if diff -b -U 0 $TMPFILE $TMPFILE2 | grep '^[+-]Java' | grep -q -v -f $TMPFILE3; |
44 |
then |
then |
45 |
PROBLEM=1 |
PROBLEM=1 |
46 |
echo "Found a problem with the JNI methods declared and implemented." |
echo "Found a problem with the JNI methods declared and implemented." |
47 |
echo "(-) missing in implementation, (+) missing in header files" |
echo "(-) missing in implementation, (+) missing in header files" |
48 |
|
|
49 |
# Compare the found method lists. |
# Compare the found method lists. |
50 |
diff -ub -0 $TMPFILE $TMPFILE2 | grep '^[+-]Java' | grep -v -f $TMPFILE3 |
diff -b -U 0 $TMPFILE $TMPFILE2 | grep '^[+-]Java' | grep -v -f $TMPFILE3 |
51 |
fi |
fi |
52 |
|
|
53 |
# Cleanup. |
# Cleanup. |