diff options
author | upstream source tree <ports@midipix.org> | 2015-03-15 20:14:05 -0400 |
---|---|---|
committer | upstream source tree <ports@midipix.org> | 2015-03-15 20:14:05 -0400 |
commit | 554fd8c5195424bdbcabf5de30fdc183aba391bd (patch) | |
tree | 976dc5ab7fddf506dadce60ae936f43f58787092 /libjava/classpath/scripts/check_jni_methods.sh.in | |
download | cbb-gcc-4.6.4-upstream.tar.bz2 cbb-gcc-4.6.4-upstream.tar.xz |
obtained gcc-4.6.4.tar.bz2 from upstream website;upstream
verified gcc-4.6.4.tar.bz2.sig;
imported gcc-4.6.4 source tree from verified upstream tarball.
downloading a git-generated archive based on the 'upstream' tag
should provide you with a source tree that is binary identical
to the one extracted from the above tarball.
if you have obtained the source via the command 'git clone',
however, do note that line-endings of files in your working
directory might differ from line-endings of the respective
files in the upstream repository.
Diffstat (limited to 'libjava/classpath/scripts/check_jni_methods.sh.in')
-rw-r--r-- | libjava/classpath/scripts/check_jni_methods.sh.in | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/libjava/classpath/scripts/check_jni_methods.sh.in b/libjava/classpath/scripts/check_jni_methods.sh.in new file mode 100644 index 000000000..facf34b34 --- /dev/null +++ b/libjava/classpath/scripts/check_jni_methods.sh.in @@ -0,0 +1,65 @@ +#!/bin/sh + +# Fail if any command fails +set -e + +TMPFILE=/tmp/check-jni-methods.$$.1 +TMPFILE2=/tmp/check-jni-methods.$$.2 +TMPFILE3=/tmp/check-jni-methods.$$.3 +TMPFILE4=/tmp/check-jni-methods.$$.4 + +# Find all methods defined in the header files generated +# from the java source files. +grep -h '^JNIEXPORT .* Java_' @abs_top_srcdir@/include/*.h | \ + LC_ALL=C sed -e 's,.*JNICALL \(Java_[a-z_A-Z0-9]*\).*$,\1,' > $TMPFILE +grep -h '^JNIEXPORT .* Java_' @abs_top_builddir@/include/*.h | \ + LC_ALL=C sed -e 's,.*JNICALL \(Java_[a-z_A-Z0-9]*\).*$,\1,' >> $TMPFILE +sort -u $TMPFILE > $TMPFILE4 +mv $TMPFILE4 $TMPFILE + +# Find all methods in the JNI C source files. +find @abs_top_srcdir@/native/jni -name \*.c | \ + xargs grep -h '^Java_' | \ + LC_ALL=C sed -e 's,^\(Java_[a-z_A-Z0-9]*\).*$,\1,' > $TMPFILE2 +# Or in the the C++ files. (Note that cpp doesn't follow gnu conventions atm) +# So we try to match both GNU style and some other style. +find @abs_top_srcdir@/native/jni -name \*.cpp | \ + xargs grep -h '^Java_' | \ + LC_ALL=C sed -e 's,^\(Java_[a-z_A-Z0-9]*\).*$,\1,' >> $TMPFILE2 +find @abs_top_srcdir@/native/jni -name \*.cpp | \ + xargs egrep -h '^(JNIEXPORT .* JNICALL )?Java_' | \ + cut -f4 -d\ | \ + LC_ALL=C sed -e 's,^\JNIEXPORT .* JNICALL \(Java_[a-z_A-Z0-9]*\).*$,\1,' >> $TMPFILE2 +mv $TMPFILE2 $TMPFILE3 +sort $TMPFILE3 | uniq > $TMPFILE2 +rm $TMPFILE3 + +# Write temporary ignore file. +cat > $TMPFILE3 << EOF +< Java_gnu_java_awt_peer_gtk_GtkMenuComponentPeer_dispose +< Java_java_lang_VMSystem_arraycopy +< Java_java_lang_VMSystem_identityHashCode +EOF + +# Compare again silently. +# Use fgrep and direct the output to /dev/null for compatibility with older +# grep instead of using the non portable -q. +if diff $TMPFILE $TMPFILE2 | grep '^[<>] Java' | \ + fgrep -v -f $TMPFILE3 > /dev/null; +then + PROBLEM=1 + echo "Found a problem with the JNI methods declared and implemented." + echo "(<) missing in implementation, (>) missing in header files" + + # Compare the found method lists. + diff $TMPFILE $TMPFILE2 | grep '^[<>] Java' | fgrep -v -f $TMPFILE3 +fi + +# Cleanup. +rm -f $TMPFILE $TMPFILE2 $TMPFILE3 + +if test "$PROBLEM" = "1" ; then + exit 1 +fi + +exit 0 |