]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
Change the gt_JAVACOMP macro to choose a Java compiler suitable for
authorBruno Haible <bruno@clisp.org>
Tue, 2 May 2006 12:25:10 +0000 (12:25 +0000)
committerBruno Haible <bruno@clisp.org>
Tue, 23 Jun 2009 10:13:12 +0000 (12:13 +0200)
specific source and target versions.

12 files changed:
gettext-runtime/ChangeLog
gettext-runtime/configure.ac
gettext-tools/ChangeLog
gettext-tools/configure.ac
gettext-tools/examples/ChangeLog
gettext-tools/examples/hello-java-awt/configure.ac
gettext-tools/examples/hello-java-swing/configure.ac
gettext-tools/examples/hello-java/configure.ac
gettext-tools/lib/ChangeLog
gettext-tools/lib/javacomp.sh.in
gettext-tools/m4/ChangeLog
gettext-tools/m4/javacomp.m4

index 2d686dfe1c182e1a664674764ae30e3ad6121206..15f351c82368f8abe44cdf8cdaa8bc118772f14a 100644 (file)
@@ -1,3 +1,8 @@
+2006-05-01  Bruno Haible  <bruno@clisp.org>
+
+       * configure.ac: Pass a source-version and a target-version to
+       gt_JAVACOMP.
+
 2006-04-02  Bruno Haible  <bruno@clisp.org>
 
        * configure.ac: Test for strstr().
index fbed7eb3c31ec102b8ec9b8529262aec065bb413..f71faf89a09abe01ec0735c93070d9fcc4814809 100644 (file)
@@ -1,5 +1,5 @@
 dnl Configuration for the gettext-runtime directory of GNU gettext
-dnl Copyright (C) 1995-1999, 2000-2005 Free Software Foundation, Inc.
+dnl Copyright (C) 1995-1999, 2000-2006 Free Software Foundation, Inc.
 dnl
 dnl This program is free software; you can redistribute it and/or modify
 dnl it under the terms of the GNU General Public License as published by
@@ -37,7 +37,7 @@ AC_PROG_YACC
 
 gt_JAVA_CHOICE
 
-gt_JAVACOMP
+gt_JAVACOMP([1.3], [1.1])
 AC_CHECK_PROG(JAR, jar, jar)
 if test -n "$HAVE_JAVACOMP" && test -n "$JAR" && test "$JAVA_CHOICE" != no; then
   BUILDJAVA=yes
index e849a392ead78f02a0ec4c3944b3e97d21ad171f..3cec66d52e840f56231b8b16542ef0754a5d7229 100644 (file)
@@ -1,3 +1,8 @@
+2006-05-01  Bruno Haible  <bruno@clisp.org>
+
+       * configure.ac: Pass a source-version to gt_JAVACOMP. Move gt_JAVAEXEC
+       call before the gt_JAVACOMP call.
+
 2006-04-23  Bruno Haible  <bruno@clisp.org>
 
        * configure.ac: Invoke gl_HEADER_UNISTD.
index 562b40ad41939191213c7badad1fa54fa935375a..044bfc3a1883141751b889ccb8aa001d6c475116 100644 (file)
@@ -46,7 +46,8 @@ else
 fi
 AC_SUBST(BUILDJAVAEXE)
 
-gt_JAVACOMP
+gt_JAVAEXEC
+gt_JAVACOMP([1.3])
 AC_CHECK_PROG(JAR, jar, jar)
 if test -n "$HAVE_JAVACOMP" && test -n "$JAR" && test "$JAVA_CHOICE" != no; then
   BUILDJAVA=yes
@@ -54,8 +55,6 @@ else
   BUILDJAVA=no
 fi
 AC_SUBST(BUILDJAVA)
-
-gt_JAVAEXEC
 if test -n "$HAVE_JAVAEXEC" && test $BUILDJAVA = yes; then
   TESTJAVA=yes
 else
index 05fc3b14c1980c7b745b1a9d40ec36e696428ca2..a2f5a9705498486707b34ba16138773473a94f67 100644 (file)
@@ -1,3 +1,10 @@
+2006-05-01  Bruno Haible  <bruno@clisp.org>
+
+       * hello-java/configure.ac: Pass a source-version to gt_JAVACOMP. Move
+       gt_JAVAEXEC call before the gt_JAVACOMP call.
+       * hello-java-awt/configure.ac: Likewise.
+       * hello-java-swing/configure.ac: Likewise.
+
 2006-04-17  Bruno Haible  <bruno@clisp.org>
 
        * Makefile.am: Use $(mkdir_p) instead of $(mkinstalldirs).
index e606b58b6b6278805923d51a55e64c6bbdba7cc1..618f5b184a768f51c1b20656da5b1d0580f228eb 100644 (file)
@@ -1,5 +1,5 @@
 dnl Example for use of GNU gettext.
-dnl Copyright (C) 2003 Free Software Foundation, Inc.
+dnl Copyright (C) 2003, 2006 Free Software Foundation, Inc.
 dnl This file is in the public domain.
 dnl
 dnl Configuration file - processed by autoconf.
@@ -22,8 +22,10 @@ AC_SUBST(BUILDJAVAEXE)
 AM_CONDITIONAL([USEJEXE], [test $BUILDJAVAEXE = yes])
 AC_PROG_RANLIB
 
-dnl Check whether we can build Java programs at all.
-gt_JAVACOMP
+dnl Check whether we can execute Java programs.
+gt_JAVAEXEC([TestAWT], [$srcdir/m4])
+dnl Check whether we can build Java programs.
+gt_JAVACOMP([1.3])
 AC_CHECK_PROG(JAR, jar, jar)
 if test -n "$HAVE_JAVACOMP" && test -n "$JAR"; then
   BUILDJAVA=yes
@@ -31,9 +33,6 @@ else
   BUILDJAVA=no
 fi
 AC_SUBST(BUILDJAVA)
-
-dnl Check whether we can execute Java programs.
-gt_JAVAEXEC([TestAWT], [$srcdir/m4])
 if test -n "$HAVE_JAVAEXEC" && test $BUILDJAVA = yes; then
   TESTJAVA=yes
 else
index 45bbe31eaab0cce2b6f8a37dce46dd3cbaa30d40..34e5dd2eb1dd84e93ceadaecda04bb58f7c49389 100644 (file)
@@ -1,5 +1,5 @@
 dnl Example for use of GNU gettext.
-dnl Copyright (C) 2003 Free Software Foundation, Inc.
+dnl Copyright (C) 2003, 2006 Free Software Foundation, Inc.
 dnl This file is in the public domain.
 dnl
 dnl Configuration file - processed by autoconf.
@@ -22,8 +22,10 @@ AC_SUBST(BUILDJAVAEXE)
 AM_CONDITIONAL([USEJEXE], [test $BUILDJAVAEXE = yes])
 AC_PROG_RANLIB
 
-dnl Check whether we can build Java programs at all.
-gt_JAVACOMP
+dnl Check whether we can execute Java programs.
+gt_JAVAEXEC([TestAWT], [$srcdir/m4])
+dnl Check whether we can build Java programs.
+gt_JAVACOMP([1.3])
 AC_CHECK_PROG(JAR, jar, jar)
 if test -n "$HAVE_JAVACOMP" && test -n "$JAR"; then
   BUILDJAVA=yes
@@ -31,9 +33,6 @@ else
   BUILDJAVA=no
 fi
 AC_SUBST(BUILDJAVA)
-
-dnl Check whether we can execute Java programs.
-gt_JAVAEXEC([TestAWT], [$srcdir/m4])
 if test -n "$HAVE_JAVAEXEC" && test $BUILDJAVA = yes; then
   TESTJAVA=yes
 else
index b0932521d22aca5e29ce88bee923031fdf36f849..689449703fa76cd5dd399984c785c230daab75f4 100644 (file)
@@ -1,5 +1,5 @@
 dnl Example for use of GNU gettext.
-dnl Copyright (C) 2003 Free Software Foundation, Inc.
+dnl Copyright (C) 2003, 2006 Free Software Foundation, Inc.
 dnl This file is in the public domain.
 dnl
 dnl Configuration file - processed by autoconf.
@@ -22,8 +22,10 @@ AC_SUBST(BUILDJAVAEXE)
 AM_CONDITIONAL([USEJEXE], [test "$BUILDJAVAEXE" = yes])
 AC_PROG_RANLIB
 
-dnl Check whether we can build Java programs at all.
-gt_JAVACOMP
+dnl Check whether we can execute Java programs.
+gt_JAVAEXEC
+dnl Check whether we can build Java programs.
+gt_JAVACOMP([1.3])
 AC_CHECK_PROG(JAR, jar, jar)
 if test -n "$HAVE_JAVACOMP" && test -n "$JAR"; then
   BUILDJAVA=yes
@@ -31,9 +33,6 @@ else
   BUILDJAVA=no
 fi
 AC_SUBST(BUILDJAVA)
-
-dnl Check whether we can execute Java programs.
-gt_JAVAEXEC
 if test -n "$HAVE_JAVAEXEC" && test $BUILDJAVA = yes; then
   TESTJAVA=yes
 else
index acac96c4139156bc661fa4c39720e81e7ed622fb..8c794dccc9c24a6cc80e7864e29a39e4826ed24b 100644 (file)
@@ -1,3 +1,7 @@
+2006-05-01  Bruno Haible  <bruno@clisp.org>
+
+       * javacomp.sh.in: Update for changed javacomp.m4.
+
 2006-04-23  Bruno Haible  <bruno@clisp.org>
 
        * addext.c: Include <unistd.h> unconditionally.
index 2a0442a47388902c083ec48e4e32ea0b2afac7ef..8c707cb4a4d8fa91d095d3047eb4a571f2a36521 100644 (file)
@@ -1,7 +1,7 @@
 #!/bin/sh
 # Compile a Java program.
 
-# Copyright (C) 2001-2002 Free Software Foundation, Inc.
+# Copyright (C) 2001-2002, 2006 Free Software Foundation, Inc.
 # Written by Bruno Haible <haible@clisp.cons.org>, 2001.
 #
 # This program is free software; you can redistribute it and/or modify
@@ -28,9 +28,9 @@
 # The extra CLASSPATH must have been set prior to calling this script.
 # Options that can be passed are -O, -g and "-d DIRECTORY".
 
-CONF_JAVAC='@JAVAC@'
+CONF_JAVAC='@CONF_JAVAC@'
 CONF_CLASSPATH='@CLASSPATH@'
-if test -n "$CONF_JAVAC"; then
+if test -n "@HAVE_JAVAC_ENVVAR@"; then
   # Combine given CLASSPATH and configured CLASSPATH.
   if test -n "$CLASSPATH"; then
     CLASSPATH="$CLASSPATH${CONF_CLASSPATH:+@CLASSPATH_SEPARATOR@$CONF_CLASSPATH}"
@@ -43,18 +43,21 @@ if test -n "$CONF_JAVAC"; then
 else
   unset JAVA_HOME
   if test -n "@HAVE_GCJ_C@"; then
+    # In this case, $CONF_JAVAC starts with "gcj -C".
     CLASSPATH="$CLASSPATH"
     export CLASSPATH
-    test -z "$JAVA_VERBOSE" || echo gcj -C "$@"
-    exec gcj -C "$@"
+    test -z "$JAVA_VERBOSE" || echo "$CONF_JAVAC $@"
+    exec $CONF_JAVAC "$@"
   else
     if test -n "@HAVE_JAVAC@"; then
+      # In this case, $CONF_JAVAC starts with "javac".
       CLASSPATH="$CLASSPATH"
       export CLASSPATH
-      test -z "$JAVA_VERBOSE" || echo javac "$@"
-      exec javac "$@"
+      test -z "$JAVA_VERBOSE" || echo "$CONF_JAVAC $@"
+      exec $CONF_JAVAC "$@"
     else
       if test -n "@HAVE_JIKES@"; then
+        # In this case, $CONF_JAVAC starts with "jikes".
         # Combine given CLASSPATH and configured CLASSPATH.
         if test -n "$CLASSPATH"; then
           CLASSPATH="$CLASSPATH${CONF_CLASSPATH:+@CLASSPATH_SEPARATOR@$CONF_CLASSPATH}"
@@ -62,8 +65,8 @@ else
           CLASSPATH="$CONF_CLASSPATH"
         fi
         export CLASSPATH
-        test -z "$JAVA_VERBOSE" || echo jikes "$@"
-        exec jikes "$@"
+        test -z "$JAVA_VERBOSE" || echo "$CONF_JAVAC $@"
+        exec $CONF_JAVAC "$@"
       else
         echo 'Java compiler not found, try installing gcj or set $JAVAC, then reconfigure' 1>&2
         exit 1
index fba5476f4721450a31b581b09b72b9219c66e5d0..662f685f3613f5aaaa6e70e85b58beea1fadb43d 100644 (file)
@@ -1,3 +1,13 @@
+2006-05-01  Bruno Haible  <bruno@clisp.org>
+
+       * javacomp.m4 (gt_JAVACOMP): Accept a source-version and an optional
+       target-version argument. Verify that the compiler groks source of the
+       specified source-version, or add -source option as necessary. Verify
+       that the compiler produces bytecode in the specified target-version,
+       or add -target and -source options as necessary. Make the result of
+       the test available as variable CONF_JAVAC. Also log error output in
+       config.log.
+
 2006-04-23  Bruno Haible  <bruno@clisp.org>
 
        * unistd_h.m4: New file, from gnulib.
index 1d49574f284c119d7ef3167c8c7d090dc4e426e0..0253ada9db375f8225a0905b2aa5414f006329f3 100644 (file)
@@ -5,20 +5,345 @@ dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
 
 # Prerequisites of javacomp.sh.
-# Sets HAVE_JAVACOMP to nonempty if javacomp.sh will work.
+# gt_JAVACOMP([source-version], [target-version])
+# Sets HAVE_JAVACOMP to nonempty if javacomp.sh will allow Java source code
+# according to source-version to be compiled to Java bytecode classes in the
+# target-version format.
+#
+# source-version can be:    support for
+#           1.3             inner classes
+#           1.4             assert keyword
+#           1.5             generic classes and methods
+#           1.6             (not yet supported)
+#
+# target-version can be:  classfile version:
+#           1.1                 45.3
+#           1.2                 46.0
+#           1.3                 47.0
+#           1.4                 48.0
+#           1.5                 49.0
+#           1.6                 50.0
+# The classfile version of a .class file can be determined through the "file"
+# command. More portably, the classfile major version can be determined through
+# "od -A n -t d1 -j 7 -N 1 classfile".
+# target-version can also be omitted. In this case, the required target-version
+# is determined from the found JVM (see macro gt_JAVAEXEC):
+#      target-version   for JVM
+#           1.1         JDK 1.1, jview
+#           1.2         JDK/JRE 1.2
+#           1.3         JDK/JRE 1.3, gij 3.3, 3.4
+#           1.4         JDK/JRE 1.4, gij 4.0, 4.1
+#           1.5         JDK/JRE 1.5
+#           1.6         JDK/JRE 1.6
+# Note: gij >= 3.3 can in some cases handle classes compiled with -target 1.4,
+# and gij >= 4.1 can in some cases partially handle classes compiled with
+# -target 1.5, but I have no idea how complete this support is.
+#
+# Specifying target-version is useful when building a library (.jar) that is
+# useful outside the given package. Omitting target-version is useful when
+# building an application.
+#
+# It is unreasonable to ask for:
+#   - target-version < 1.4 with source-version >= 1.4, or
+#   - target-version < 1.5 with source-version >= 1.5, or
+#   - target-version < 1.6 with source-version >= 1.6,
+# because even Sun's javac doesn't support these combinations.
+#
+# It is redundant to ask for a target-version > source-version, since the
+# smaller target-version = source-version will also always work and newer JVMs
+# support the older target-versions too. Except for the case
+# target-version = 1.4, source-version = 1.3, which allows gcj versions 3.0
+# to 3.2 to be used.
 
 AC_DEFUN([gt_JAVACOMP],
 [
+  ifelse([$2], [], [AC_REQUIRE([gt_JAVAEXEC])], [])
+  source_version=$1
+  test -n "$source_version" || {
+    AC_MSG_ERROR([missing source-version argument to gt_@&t@JAVACOMP])
+  }
+  ifelse([$2], [],
+    [if test -n "$HAVE_JAVAEXEC"; then
+       dnl Use $CONF_JAVA to determine the JVM's version.
+changequote(,)dnl
+       cat > conftestver.java <<EOF
+public class conftestver {
+  public static void main (String[] args) {
+    System.out.println(System.getProperty("java.specification.version"));
+  }
+}
+EOF
+changequote([,])dnl
+       dnl A precompiled version of conftestver.java, compiled with
+       dnl "javac -target 1.1". This avoids having to compile conftestver.java
+       dnl during each test for a suitable Java compiler.
+       dnl For the conversion from binary to this ASCII encapsulation, avoiding
+       dnl to assume the presence of uudecode, use the command
+       dnl   $ od -A n -t o1 < conftestver.class | tr ' ' '\012'| sort | uniq | sed -e '/^$/d' -e 's,^,\\,' | tr -d '\012'
+       dnl and the long tr command in opposite direction.
+       echo 'xyvw!$!H!C,!)!2+!3!4*!5,!3!6,!7!8)!9)!:"!(LdhdmM"!$EFV"!%Ni_a"!1PdhaQngYakUXYfa"!%gXdh"!8EWPeXoXJfXhcJTmkdhcKFV"!,TinkZaOdfa"!2ZihbmalmoakIeXoX.!*!+)!;.!<!="!<eXoXIljaZdbdZXmdihIoakldih.!>!?)!@.!A!B"!-Zihbmalmoak"!2eXoXJfXhcJRYeaZm"!2eXoXJfXhcJTplmag"!$inm"!7PeXoXJdiJSkdhmTmkaXgK"!-camSkijakmp"!DEPeXoXJfXhcJTmkdhcKFPeXoXJfXhcJTmkdhcK"!5eXoXJdiJSkdhmTmkaXg"!)jkdhmfh"!7EPeXoXJfXhcJTmkdhcKFV!C!(!)!!!!!#!"!*!+!"!,!!!?!"!"!!!&Gt!"q!!!"!-!!!(!"!!!"!+!.!/!"!,!!!E!#!"!!!.r!#4$u!%s!&q!!!"!-!!!,!#!!!$!-!%!"!0!!!#!1' \
+         | tr -d '\012\015' \
+         | tr '!"#$%&()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz' '\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037\040\041\046\050\051\052\055\056\057\073\074\076\103\106\114\116\117\120\123\124\126\133\141\142\143\144\145\146\147\151\152\154\155\156\157\160\162\163\164\165\166\171\261\262\266\267\270\272\276\312\376' \
+         > conftestver.class
+       target_version=`{
+         unset JAVA_HOME
+         echo "$as_me:__oline__: CLASSPATH=.:$CLASSPATH $CONF_JAVA conftestver" >&AS_MESSAGE_LOG_FD
+         CLASSPATH=.:$CLASSPATH $CONF_JAVA conftestver 2>&AS_MESSAGE_LOG_FD
+       }`
+       case "$target_version" in
+         1.1 | 1.2 | 1.3 | 1.4 | 1.5 | 1.6) ;;
+         *) AC_MSG_WARN([unknown target-version $target_version, please update gt_@&t@JAVACOMP macro])
+            target_version=1.1 ;;
+       esac
+     else
+       target_version="1.1"
+     fi
+    ],
+    [target_version=$2])
+  case "$source_version" in
+    1.3) goodcode='class conftest {}'
+         failcode='class conftestfail { static { assert(true); } }' ;;
+    1.4) goodcode='class conftest     { static { assert(true); } }'
+         failcode='class conftestfail<T> { T foo() { return null; } }' ;;
+    1.5) goodcode='class conftest<T>     { T foo() { return null; } }'
+         failcode='class conftestfail syntax error' ;;
+    *) AC_MSG_ERROR([invalid source-version argument to gt_@&t@JAVACOMP: $source_version]) ;;
+  esac
+  case "$target_version" in
+    1.1) cfversion=45 ;;
+    1.2) cfversion=46 ;;
+    1.3) cfversion=47 ;;
+    1.4) cfversion=48 ;;
+    1.5) cfversion=49 ;;
+    1.6) cfversion=50 ;;
+    *) AC_MSG_ERROR([invalid target-version argument to gt_@&t@JAVACOMP: $target_version]) ;;
+  esac
+  # Function to output the classfile version of a file (8th byte) in decimal.
+  if od -A x < /dev/null >/dev/null 2>/dev/null; then
+    # Use POSIX od.
+    func_classfile_version ()
+    {
+      od -A n -t d1 -j 7 -N 1 "$1"
+    }
+  else
+    # Use BSD hexdump.
+    func_classfile_version ()
+    {
+      dd if="$1" bs=1 count=1 skip=7 2>/dev/null | hexdump -e '1/1 "%3d "'
+      echo
+    }
+  fi
   AC_MSG_CHECKING([for Java compiler])
   AC_EGREP_CPP(yes, [
 #if defined _WIN32 || defined __WIN32__ || defined __EMX__ || defined __DJGPP__
   yes
 #endif
 ], CLASSPATH_SEPARATOR=';', CLASSPATH_SEPARATOR=':')
-  HAVE_JAVACOMP=1
+  dnl
+  dnl The support of GNU gcj for target-version and source-version:
+  dnl
+  dnl   gcj 3.0.4 to 4.1 does not have a way to specify the target-version.
+  dnl   It always assumes target-version=1.4 but labels the class files as 1.1.
+  dnl   One consequence of this is that gcj compiles GetURL.java to invalid
+  dnl   bytecode, which crashes with a VerifyError when executed by Sun Java
+  dnl   1.3.1. The bug is registered as java/7066, see
+  dnl   http://gcc.gnu.org/bugzilla/show_bug.cgi?id=7066
+  dnl   FIXME: Check new versions of gcj as they come out.
+  dnl
+  dnl   For gcj < 3.3, the source-version always is 1.3.
+  dnl   For gcj >= 3.3, the source-version defaults to 1.4; option
+  dnl   "-fno-assert" switches to source-version 1.3.
+  dnl
+  dnl The support of Sun javac for target-version and source-version:
+  dnl
+  dnl   javac 1.3:   -target 1.1 1.2 1.3               default: 1.1
+  dnl                                                  source always: 1.3
+  dnl
+  dnl   javac 1.4:   -target 1.1 1.2 1.3 1.4           default: 1.2
+  dnl                -source 1.3 1.4                   default: 1.3
+  dnl                -target 1.1/1.2/1.3 only possible with -source 1.3 or no -source
+  dnl
+  dnl   javac 1.5:   -target 1.1 1.2 1.3 1.4 1.5       default: 1.5
+  dnl                -source 1.3 1.4 1.5               default: 1.5
+  dnl                -target 1.1/1.2/1.3 only possible with -source 1.3
+  dnl                -target 1.4 only possible with -source 1.3/1.4
+  dnl
+  dnl   javac 1.6:   -target 1.1 1.2 1.3 1.4 1.5 1.6   default: 1.6
+  dnl                -source 1.3 1.4 1.5 1.6           default: 1.5
+  dnl                -target 1.1/1.2/1.3 only possible with -source 1.3
+  dnl                -target 1.4 only possible with -source 1.3/1.4
+  dnl                -target 1.5 only possible with -source 1.3/1.4/1.5 or no -source
+  dnl
+  dnl The support of jikes for target-version and source-version:
+  dnl
+  dnl   jikes 1.14 does not have a way to specify the target-version. It
+  dnl   always assumes target-version=1.1.
+  dnl
+  dnl   For jikes 1.14, the source-version always is 1.3.
+  dnl
+  CONF_JAVAC=
+  HAVE_JAVAC_ENVVAR=
+  HAVE_GCJ_C=
+  HAVE_JAVAC=
+  HAVE_JIKES=
+  HAVE_JAVACOMP=
+changequote(,)dnl
+  cat > conftestlib.java <<EOF
+public class conftestlib {
+  public static void main (String[] args) {
+  }
+}
+EOF
+changequote([,])dnl
+  echo "$goodcode" > conftest.java
+  echo "$failcode" > conftestfail.java
+  dnl If the user has set the JAVAC environment variable, use that, if it
+  dnl satisfies the constraints (possibly after adding -target and -source
+  dnl options).
   if test -n "$JAVAC"; then
-    ac_result="$JAVAC"
-  else
+    dnl Try the original $JAVAC.
+    if $JAVAC --version 2>/dev/null | sed -e 1q | grep gcj > /dev/null; then
+      dnl It's a version of gcj. Ignore the version of conftest.class.
+      if test "$target_version" = 1.4 && test "$source_version" = 1.4; then
+        dnl Try $JAVAC.
+        rm -f conftest.class
+        if { echo "$as_me:__oline__: $JAVAC -d . conftest.java" >&AS_MESSAGE_LOG_FD
+             $JAVAC -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
+           } \
+           && test -f conftest.class; then
+          CONF_JAVAC="$JAVAC"
+          HAVE_JAVAC_ENVVAR=1
+          HAVE_JAVACOMP=1
+        fi
+      else
+        if test "$target_version" = 1.4 && test "$source_version" = 1.3; then
+          dnl Try $JAVAC and "$JAVAC -fno-assert". But add -fno-assert only if
+          dnl it makes a difference. (It could already be part of $JAVAC.)
+          javac_works=
+          rm -f conftest.class
+          if { echo "$as_me:__oline__: $JAVAC -d . conftest.java" >&AS_MESSAGE_LOG_FD
+               $JAVAC -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
+             } \
+             && test -f conftest.class; then
+            javac_works=1
+          fi
+          javac_noassert_works=
+          rm -f conftest.class
+          if { echo "$as_me:__oline__: $JAVAC -fno-assert -d . conftest.java" >&AS_MESSAGE_LOG_FD
+               $JAVAC -fno-assert -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
+             } \
+             && test -f conftest.class; then
+            javac_noassert_works=1
+          fi
+          if test -n "$javac_works" && test -n "$javac_noassert_works"; then
+            rm -f conftestfail.class
+            if { echo "$as_me:__oline__: $JAVAC -d . conftestfail.java" >&AS_MESSAGE_LOG_FD
+                 $JAVAC -d . conftestfail.java >&AS_MESSAGE_LOG_FD 2>&1
+               } \
+               && test -f conftestfail.class \
+               && ! { echo "$as_me:__oline__: $JAVAC -fno-assert -d . conftestfail.java" >&AS_MESSAGE_LOG_FD
+                      $JAVAC -fno-assert -d . conftestfail.java >&AS_MESSAGE_LOG_FD 2>&1
+                    }; then
+              dnl "$JAVAC -fno-assert" works better than $JAVAC.
+              javac_works=
+            fi
+          fi
+          if test -n "$javac_works"; then
+            CONF_JAVAC="$JAVAC"
+            HAVE_JAVAC_ENVVAR=1
+            HAVE_JAVACOMP=1
+          else
+            if test -n "$javac_noassert_works"; then
+              CONF_JAVAC="$JAVAC -fno-assert"
+              HAVE_JAVAC_ENVVAR=1
+              HAVE_JAVACOMP=1
+            fi
+          fi
+        fi
+      fi
+    else
+      dnl It's not gcj. Assume the classfile versions are correct.
+      dnl Try $JAVAC.
+      rm -f conftest.class
+      if { echo "$as_me:__oline__: $JAVAC -d . conftest.java" >&AS_MESSAGE_LOG_FD
+           $JAVAC -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
+         } \
+         && test -f conftest.class \
+         && expr `func_classfile_version conftest.class` '<=' $cfversion >/dev/null 2>&AS_MESSAGE_LOG_FD; then
+        dnl Try adding -source option if it is useful.
+        rm -f conftest.class
+        rm -f conftestfail.class
+        if { echo "$as_me:__oline__: $JAVAC -source $source_version -d . conftest.java" >&AS_MESSAGE_LOG_FD
+             $JAVAC -source "$source_version" -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
+           } \
+           && test -f conftest.class \
+           && expr `func_classfile_version conftest.class` '<=' $cfversion >/dev/null 2>&AS_MESSAGE_LOG_FD \
+           && { echo "$as_me:__oline__: $JAVAC -d . conftestfail.java" >&AS_MESSAGE_LOG_FD
+                $JAVAC -d . conftestfail.java >&AS_MESSAGE_LOG_FD 2>&1
+              } \
+           && test -f conftestfail.class \
+           && ! { echo "$as_me:__oline__: $JAVAC -source $source_version -d . conftestfail.java" >&AS_MESSAGE_LOG_FD
+                  $JAVAC -source "$source_version" -d . conftestfail.java >&AS_MESSAGE_LOG_FD 2>&1
+                }; then
+          CONF_JAVAC="$JAVAC -source $source_version"
+          HAVE_JAVAC_ENVVAR=1
+          HAVE_JAVACOMP=1
+        else
+          CONF_JAVAC="$JAVAC"
+          HAVE_JAVAC_ENVVAR=1
+          HAVE_JAVACOMP=1
+        fi
+      else
+        dnl Try with -target option alone. (Sun javac 1.3.1 has the -target
+        dnl option but no -source option.)
+        rm -f conftest.class
+        if { echo "$as_me:__oline__: $JAVAC -target $target_version -d . conftest.java" >&AS_MESSAGE_LOG_FD
+             $JAVAC -target "$target_version" -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
+           } \
+           && test -f conftest.class \
+           && expr `func_classfile_version conftest.class` '<=' $cfversion >/dev/null 2>&AS_MESSAGE_LOG_FD; then
+          dnl Try adding -source option if it is useful.
+          rm -f conftest.class
+          rm -f conftestfail.class
+          if { echo "$as_me:__oline__: $JAVAC -target $target_version -source $source_version -d . conftest.java" >&AS_MESSAGE_LOG_FD
+               $JAVAC -target "$target_version" -source "$source_version" -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
+             } \
+             && test -f conftest.class \
+             && expr `func_classfile_version conftest.class` '<=' $cfversion >/dev/null 2>&AS_MESSAGE_LOG_FD \
+             && { echo "$as_me:__oline__: $JAVAC -target $target_version -d . conftestfail.java" >&AS_MESSAGE_LOG_FD
+                  $JAVAC -target "$target_version" -d . conftestfail.java >&AS_MESSAGE_LOG_FD 2>&1
+                } \
+             && test -f conftestfail.class \
+             && ! { echo "$as_me:__oline__: $JAVAC -target $target_version -source $source_version -d . conftestfail.java" >&AS_MESSAGE_LOG_FD
+                    $JAVAC -target "$target_version" -source "$source_version" -d . conftestfail.java >&AS_MESSAGE_LOG_FD 2>&1
+                  }; then
+            CONF_JAVAC="$JAVAC -target $target_version -source $source_version"
+            HAVE_JAVAC_ENVVAR=1
+            HAVE_JAVACOMP=1
+          else
+            CONF_JAVAC="$JAVAC -target $target_version"
+            HAVE_JAVAC_ENVVAR=1
+            HAVE_JAVACOMP=1
+          fi
+        else
+          dnl Maybe this -target option requires a -source option? Try with
+          dnl -target and -source options. (Supported by Sun javac 1.4 and
+          dnl higher.)
+          rm -f conftest.class
+          if { echo "$as_me:__oline__: $JAVAC -target $target_version -source $source_version -d . conftest.java" >&AS_MESSAGE_LOG_FD
+               $JAVAC -target "$target_version" -source "$source_version" -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
+             } \
+             && test -f conftest.class \
+             && expr `func_classfile_version conftest.class` '<=' $cfversion >/dev/null 2>&AS_MESSAGE_LOG_FD; then
+            CONF_JAVAC="$JAVAC -target $target_version -source $source_version"
+            HAVE_JAVAC_ENVVAR=1
+            HAVE_JAVACOMP=1
+          fi
+        fi
+      fi
+    fi
+  fi
+  if test -z "$HAVE_JAVACOMP"; then
     pushdef([AC_MSG_CHECKING],[:])dnl
     pushdef([AC_CHECKING],[:])dnl
     pushdef([AC_MSG_RESULT],[:])dnl
@@ -28,70 +353,175 @@ AC_DEFUN([gt_JAVACOMP],
     popdef([AC_MSG_RESULT])dnl
     popdef([AC_CHECKING])dnl
     popdef([AC_MSG_CHECKING])dnl
+    if test -z "$HAVE_JAVACOMP" && test -n "$HAVE_GCJ_IN_PATH"; then
+      dnl Test for a good gcj version (>= 3.0).
 changequote(,)dnl
-    # Test for a good gcj version (>= 3.0).
-    # Exclude some versions of gcj: gcj 3.0.4 compiles GetURL.java to invalid
-    # bytecode, that crashes with an IllegalAccessError when executed by
-    # gij 3.0.4 or with a VerifyError when executed by Sun Java 1.3.1. Likewise
-    # for gcj 3.1 ... 4.1.
-    # I also exclude gcj 4.2, 4.3 etc. because I have no idea when this bug
-    # will be fixed. The bug is registered as java/7066, see
-    # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=7066
-    # FIXME: Check new versions of gcj as they come out.
-    if test -n "$HAVE_GCJ_IN_PATH" \
-       && gcj --version 2>/dev/null | sed -e 's,^[^0-9]*,,' -e 1q | sed -e '/^[34]\.[0123456789]/d' | grep '^[3-9]' >/dev/null \
-       && (
-        # See if libgcj.jar is well installed.
-        cat > conftest.java <<EOF
-public class conftest {
-  public static void main (String[] args) {
-  }
-}
-EOF
-        gcj -C -d . conftest.java 2>/dev/null
-        error=$?
-        rm -f conftest.java conftest.class
-        exit $error
-       ); then
-      HAVE_GCJ_C=1
-      ac_result="gcj -C"
-    else
-      if test -n "$HAVE_JAVAC_IN_PATH" \
-         && (javac -version >/dev/null 2>/dev/null || test $? -le 2) \
-         && (if javac -help 2>&1 >/dev/null | grep at.dms.kjc.Main >/dev/null && javac -help 2>/dev/null | grep 'released.*2000' >/dev/null ; then exit 1; else exit 0; fi); then
-        HAVE_JAVAC=1
-        ac_result="javac"
-      else
-        if test -n "$HAVE_JIKES_IN_PATH" \
-           && (jikes >/dev/null 2>/dev/null || test $? = 1) \
-           && (
-            # See if the existing CLASSPATH is sufficient to make jikes work.
-            cat > conftest.java <<EOF
-public class conftest {
-  public static void main (String[] args) {
-  }
-}
-EOF
-            unset JAVA_HOME
-            jikes conftest.java 2>/dev/null
-            error=$?
-            rm -f conftest.java conftest.class
-            exit $error
-           ); then
-          HAVE_JIKES=1
-          ac_result="jikes"
+      if gcj --version 2>/dev/null | sed -e 's,^[^0-9]*,,' -e 1q | sed -e '/^3\.[01]/d' | grep '^[3-9]' >/dev/null; then
+changequote([,])dnl
+        dnl See if libgcj.jar is well installed.
+        if { echo "$as_me:__oline__: gcj -C -d . conftestlib.java" >&AS_MESSAGE_LOG_FD
+             gcj -C -d . conftestlib.java >&AS_MESSAGE_LOG_FD 2>&1
+           }; then
+          dnl OK, gcj works.
+          dnl Now test whether it supports the desired target-version and
+          dnl source-version. But ignore the version of conftest.class.
+          if test "$target_version" = 1.4 && test "$source_version" = 1.4; then
+            rm -f conftest.class
+            if { echo "$as_me:__oline__: gcj -C -d . conftest.java" >&AS_MESSAGE_LOG_FD
+                 gcj -C -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
+               } \
+               && test -f conftest.class; then
+              CONF_JAVAC="gcj -C"
+              HAVE_GCJ_C=1
+              HAVE_JAVACOMP=1
+            fi
+          else
+            if test "$target_version" = 1.4 && test "$source_version" = 1.3; then
+              dnl Try gcj and "gcj -fno-assert". But add -fno-assert only if
+              dnl it works (not gcj < 3.3).
+              rm -f conftest.class
+              if { echo "$as_me:__oline__: gcj -C -fno-assert -d . conftest.java" >&AS_MESSAGE_LOG_FD
+                   gcj -C -fno-assert -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
+                 } \
+                 && test -f conftest.class; then
+                CONF_JAVAC="gcj -C -fno-assert"
+                HAVE_GCJ_C=1
+                HAVE_JAVACOMP=1
+              else
+                rm -f conftest.class
+                if { echo "$as_me:__oline__: gcj -C -d . conftest.java" >&AS_MESSAGE_LOG_FD
+                     gcj -C -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
+                   } \
+                   && test -f conftest.class; then
+                  CONF_JAVAC="gcj -C"
+                  HAVE_GCJ_C=1
+                  HAVE_JAVACOMP=1
+                fi
+              fi
+            fi
+          fi
+        fi
+      fi
+    fi
+    if test -z "$HAVE_JAVACOMP" && test -n "$HAVE_JAVAC_IN_PATH"; then
+      dnl Test whether javac is usable.
+      if { javac -version >/dev/null 2>/dev/null || test $? -le 2; } \
+         && ( if javac -help 2>&1 >/dev/null | grep at.dms.kjc.Main >/dev/null && javac -help 2>/dev/null | grep 'released.*2000' >/dev/null ; then exit 1; else exit 0; fi ); then
+        dnl OK, javac works.
+        dnl Now test whether it supports the desired target-version and
+        dnl source-version.
+        rm -f conftest.class
+        if { echo "$as_me:__oline__: javac -d . conftest.java" >&AS_MESSAGE_LOG_FD
+             javac -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
+           } \
+           && test -f conftest.class \
+           && expr `func_classfile_version conftest.class` '<=' $cfversion >/dev/null 2>&AS_MESSAGE_LOG_FD; then
+          dnl Try adding -source option if it is useful.
+          rm -f conftest.class
+          rm -f conftestfail.class
+          if { echo "$as_me:__oline__: javac -source $source_version -d . conftest.java" >&AS_MESSAGE_LOG_FD
+               javac -source "$source_version" -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
+             } \
+             && test -f conftest.class \
+             && expr `func_classfile_version conftest.class` '<=' $cfversion >/dev/null 2>&AS_MESSAGE_LOG_FD \
+             && { echo "$as_me:__oline__: javac -d . conftestfail.java" >&AS_MESSAGE_LOG_FD
+                  javac -d . conftestfail.java >&AS_MESSAGE_LOG_FD 2>&1
+                } \
+             && test -f conftestfail.class \
+             && ! { echo "$as_me:__oline__: javac -source $source_version -d . conftestfail.java" >&AS_MESSAGE_LOG_FD
+                    javac -source "$source_version" -d . conftestfail.java >&AS_MESSAGE_LOG_FD 2>&1
+                  }; then
+            CONF_JAVAC="javac -source $source_version"
+            HAVE_JAVAC=1
+            HAVE_JAVACOMP=1
+          else
+            CONF_JAVAC="javac"
+            HAVE_JAVAC=1
+            HAVE_JAVACOMP=1
+          fi
         else
-          HAVE_JAVACOMP=
-          ac_result="no"
+          dnl Try with -target option alone. (Sun javac 1.3.1 has the -target
+          dnl option but no -source option.)
+          rm -f conftest.class
+          if { echo "$as_me:__oline__: javac -target $target_version -d . conftest.java" >&AS_MESSAGE_LOG_FD
+               javac -target "$target_version" -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
+             } \
+             && test -f conftest.class \
+             && expr `func_classfile_version conftest.class` '<=' $cfversion >/dev/null 2>&AS_MESSAGE_LOG_FD; then
+            dnl Try adding -source option if it is useful.
+            rm -f conftest.class
+            rm -f conftestfail.class
+            if { echo "$as_me:__oline__: javac -target $target_version -source $source_version -d . conftest.java" >&AS_MESSAGE_LOG_FD
+                 javac -target "$target_version" -source "$source_version" -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
+               } \
+               && test -f conftest.class \
+               && expr `func_classfile_version conftest.class` '<=' $cfversion >/dev/null 2>&AS_MESSAGE_LOG_FD \
+               && { echo "$as_me:__oline__: javac -target $target_version -d . conftestfail.java" >&AS_MESSAGE_LOG_FD
+                    javac -target "$target_version" -d . conftestfail.java >&AS_MESSAGE_LOG_FD 2>&1
+                  } \
+               && test -f conftestfail.class \
+               && ! { echo "$as_me:__oline__: javac -target $target_version -source $source_version -d . conftestfail.java" >&AS_MESSAGE_LOG_FD
+                      javac -target "$target_version" -source "$source_version" -d . conftestfail.java >&AS_MESSAGE_LOG_FD 2>&1
+                    }; then
+              CONF_JAVAC="javac -target $target_version -source $source_version"
+              HAVE_JAVAC=1
+              HAVE_JAVACOMP=1
+            else
+              CONF_JAVAC="javac -target $target_version"
+              HAVE_JAVAC=1
+              HAVE_JAVACOMP=1
+            fi
+          else
+            dnl Maybe this -target option requires a -source option? Try with
+            dnl -target and -source options. (Supported by Sun javac 1.4 and
+            dnl higher.)
+            rm -f conftest.class
+            if { echo "$as_me:__oline__: javac -target $target_version -source $source_version -d . conftest.java" >&AS_MESSAGE_LOG_FD
+                 javac -target "$target_version" -source "$source_version" -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
+               } \
+               && test -f conftest.class \
+               && expr `func_classfile_version conftest.class` '<=' $cfversion >/dev/null 2>&AS_MESSAGE_LOG_FD; then
+              CONF_JAVAC="javac -target $target_version -source $source_version"
+              HAVE_JAVAC=1
+              HAVE_JAVACOMP=1
+            fi
+          fi
         fi
       fi
     fi
-changequote([,])dnl
+    if test -z "$HAVE_JAVACOMP" && test -n "$HAVE_JIKES_IN_PATH"; then
+      dnl Test whether jikes is usable.
+      if { jikes >/dev/null 2>/dev/null || test $? = 1; } \
+         && (
+              # See if the existing CLASSPATH is sufficient to make jikes work.
+              unset JAVA_HOME
+              jikes conftestlib.java >&AS_MESSAGE_LOG_FD 2>&1
+              error=$?
+              rm -f conftestlib.class
+              exit $error
+            ); then
+        dnl OK, jikes works.
+        dnl Now test whether it supports the desired target-version and
+        dnl source-version.
+        if test "$source_version" = 1.3; then
+          CONF_JAVAC="jikes"
+          HAVE_JIKES=1
+          HAVE_JAVACOMP=1
+        fi
+      fi
+    fi
+  fi
+  rm -f conftest*.java conftest*.class
+  if test -n "$HAVE_JAVACOMP"; then
+    ac_result="$CONF_JAVAC"
+  else
+    ac_result="no"
   fi
   AC_MSG_RESULT([$ac_result])
-  AC_SUBST(JAVAC)
+  AC_SUBST(CONF_JAVAC)
   AC_SUBST(CLASSPATH)
   AC_SUBST(CLASSPATH_SEPARATOR)
+  AC_SUBST(HAVE_JAVAC_ENVVAR)
   AC_SUBST(HAVE_GCJ_C)
   AC_SUBST(HAVE_JAVAC)
   AC_SUBST(HAVE_JIKES)