Extend ax_javac_and_java.m4 to test for specific classes

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@774130 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/aclocal/ax_javac_and_java.m4 b/aclocal/ax_javac_and_java.m4
index 3c8577f..03ab08e 100644
--- a/aclocal/ax_javac_and_java.m4
+++ b/aclocal/ax_javac_and_java.m4
@@ -1,20 +1,24 @@
 dnl @synopsis AX_JAVAC_AND_JAVA
+dnl @synopsis AX_CHECK_JAVA_CLASS(CLASSNAME)
 dnl
-dnl Test for the presence of a JDK.
+dnl Test for the presence of a JDK, and (optionally) specific classes.
 dnl
 dnl If "JAVA" is defined in the environment, that will be the only
 dnl java command tested.  Otherwise, a hard-coded list will be used.
 dnl Similarly for "JAVAC".
 dnl
-dnl This macro does not currenly support testing for a particular
-dnl Java version, the presence of a particular class, testing for
-dnl only one of "java" and "javac", or compiling or running
-dnl user-provided Java code.
+dnl AX_JAVAC_AND_JAVA does not currenly support testing for a particular
+dnl Java version, testing for only one of "java" and "javac", or
+dnl compiling or running user-provided Java code.
 dnl
 dnl After AX_JAVAC_AND_JAVA runs, the shell variables "success" and
 dnl "ax_javac_and_java" are set to "yes" or "no", and "JAVAC" and
 dnl "JAVA" are set to the appropriate commands.
 dnl
+dnl AX_CHECK_JAVA_CLASS must be run after AX_JAVAC_AND_JAVA.
+dnl It tests for the presence of a class based on a fully-qualified name.
+dnl It sets the shell variable "success" to "yes" or "no".
+dnl
 dnl @category Java
 dnl @version 2009-02-09
 dnl @license AllPermissive
@@ -82,3 +86,22 @@
           ax_javac_and_java="$success"
 
           ])
+
+
+AC_DEFUN([AX_CHECK_JAVA_CLASS],
+         [
+          AC_MSG_CHECKING(for Java class [$1])
+
+          echo "import $1; public class configtest_ax_javac_and_java { public static void main(String args@<:@@:>@) { } }" > configtest_ax_javac_and_java.java
+
+          echo "Running \"$JAVAC configtest_ax_javac_and_java.java\"" >&AS_MESSAGE_LOG_FD
+          if $JAVAC configtest_ax_javac_and_java.java >&AS_MESSAGE_LOG_FD 2>&1 ; then
+            AC_MSG_RESULT(yes)
+            success=yes
+          else
+            AC_MSG_RESULT(no)
+            success=no
+          fi
+
+          rm -f configtest_ax_javac_and_java.java configtest_ax_javac_and_java.class
+          ])