1 # javacomp.m4 serial 18
2 dnl Copyright (C) 2001-2003, 2006-2007, 2009-2020 Free Software Foundation,
4 dnl This file is free software; the Free Software Foundation
5 dnl gives unlimited permission to copy and/or distribute it,
6 dnl with or without modifications, as long as this notice is preserved.
8 # Prerequisites of javacomp.sh.
9 # gt_JAVACOMP([source-version], [target-version])
10 # Sets HAVE_JAVACOMP to nonempty if javacomp.sh will allow Java source code
11 # according to source-version to be compiled to Java bytecode classes in the
12 # target-version format.
14 # source-version can be: support for
17 # 1.5 generic classes and methods
21 # 9 private interface methods
22 # 10 type inference for local variables
23 # 11 'var' in parameters of lambda expressions
24 # Instead of source-version 1.6, use 1.5, since Java 6 did not introduce any
25 # language changes. See
26 # https://docs.oracle.com/javase/8/docs/technotes/guides/language/enhancements.html
28 # target-version can be: classfile version:
40 # The classfile version of a .class file can be determined through the "file"
41 # command. More portably, the classfile major version can be determined through
42 # "od -A n -t d1 -j 7 -N 1 classfile".
43 # target-version can also be omitted. In this case, the required target-version
44 # is determined from the found JVM (see macro gt_JAVAEXEC):
45 # target-version for JVM
48 # 1.3 JDK/JRE 1.3, gij 3.3, 3.4
49 # 1.4 JDK/JRE 1.4, gij 4.0 ... 4.2
50 # 1.5 JDK/JRE 5, gij 4.3 ... 6
57 # Note: gij >= 3.3 can in some cases handle classes compiled with -target 1.4,
58 # and gij >= 4.1 can in some cases partially handle classes compiled with
59 # -target 1.5, but I have no idea how complete this support is. Similarly,
60 # gcj >= 4.3 supports -ftarget=1.6, and gij >= 4.3 can in some cases handle
61 # classes compiled with -target 1.6.
63 # Specifying target-version is useful when building a library (.jar) that is
64 # useful outside the given package. Omitting target-version is useful when
65 # building an application.
67 # It is unreasonable to ask for:
68 # - target-version < 1.4 with source-version >= 1.4, or
69 # - target-version < 1.5 with source-version >= 1.5, or
70 # - target_version < 1.6 with source_version >= 1.6, or
71 # - target_version < 1.7 with source_version >= 1.7, or
72 # - target_version < 1.8 with source_version >= 1.8, or
73 # - target_version < 9 with source_version >= 9, or
74 # - target_version < 10 with source_version >= 10, or
75 # - target_version < 11 with source_version >= 11,
76 # because even Sun's/Oracle's javac doesn't support these combinations.
78 # It is redundant to ask for a target-version > source-version, since the
79 # smaller target-version = source-version will also always work and newer JVMs
80 # support the older target-versions too. Except for the cases
81 # - target-version = 1.4, source-version = 1.3, which allows gcj versions 3.0
83 # - target-version = 1.6, source-version = 1.5, which allows gcj versions
86 AC_DEFUN([gt_JAVACOMP],
88 m4_if([$2], [], [AC_REQUIRE([gt_JAVAEXEC])], [])
90 #if defined _WIN32 || defined __CYGWIN__ || defined __EMX__ || defined __DJGPP__
93 ], CLASSPATH_SEPARATOR=';', CLASSPATH_SEPARATOR=':')
95 test -n "$source_version" || {
96 AC_MSG_ERROR([missing source-version argument to gt_@&t@JAVACOMP])
99 [if test -n "$HAVE_JAVAEXEC"; then
100 dnl Use $CONF_JAVA to determine the JVM's version.
102 cat > conftestver.java <<EOF
103 public class conftestver {
104 public static void main (String[] args) {
105 System.out.println(System.getProperty("java.specification.version"));
110 dnl A precompiled version of conftestver.java, compiled with
111 dnl "javac -target 1.1". This avoids having to compile conftestver.java
112 dnl during each test for a suitable Java compiler.
113 dnl For the conversion from binary to this ASCII encapsulation, avoiding
114 dnl to assume the presence of uudecode, use the command
115 dnl $ od -A n -t o1 < conftestver.class | tr ' ' '\012'| sort | uniq | sed -e '/^$/d' -e 's,^,\\,' | tr -d '\012'
116 dnl and the long tr command in opposite direction.
117 dnl Finally move the position corresponding to \055 to the last position,
118 dnl to work around a coreutils-5.x bug.
119 echo 'yzwx!$!I!D,!)!3+!4!5*!6,!4!7,!8!9)!:)!;"!(MeienN"!$FGW"!%Ojab"!2QeibRohZblVYZgb"!%hYei"!9FXQfYpYKgYidKUnleidLGW"!,Ujol_bPegb"!3_jicnbmnpblJfYpY/!*!+)!</!=!>"!=fYpYJmkb_ece_YnejiJpblmeji/!?!@)!A/!B!C"!._jicnbmnpbl"!3fYpYKgYidKSZfb_n"!3fYpYKgYidKUqmnbh"!$jon"!8QfYpYKejKTleinUnlbYhL"!.dbnTljkblnq"!EFQfYpYKgYidKUnleidLGQfYpYKgYidKUnleidL"!6fYpYKejKTleinUnlbYh"!)kleingi"!8FQfYpYKgYidKUnleidLGW!D!(!)!!!!!#!"!*!+!"!,!!!@!"!"!!!&Hu!"r!!!"!.!!!(!"!!!"!+!/!0!"!,!!!F!#!"!!!/s!#5$v!%t!&r!!!"!.!!!,!#!!!$!.!%!"!1!!!#!2' \
121 | tr '!"#$%&()*+,./0123456789:;<=>?@ABCDEFGHJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyzI' '\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\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\055' \
125 echo "$as_me:__oline__: CLASSPATH=.${CLASSPATH:+$CLASSPATH_SEPARATOR$CLASSPATH} $CONF_JAVA conftestver" >&AS_MESSAGE_LOG_FD
126 CLASSPATH=.${CLASSPATH:+$CLASSPATH_SEPARATOR$CLASSPATH} $CONF_JAVA conftestver 2>&AS_MESSAGE_LOG_FD
128 case "$target_version" in
129 1.1 | 1.2 | 1.3 | 1.4 | 1.5 | 1.6 | 1.7 | 1.8 | 9 | 10 | 11) ;;
130 12 | 13 | 14 | 15 | 16 | 17)
131 dnl Assume that these (not yet released) Java versions will behave
132 dnl like the preceding ones.
135 dnl JDK 1.1.X returns null.
136 target_version=1.1 ;;
137 *) AC_MSG_WARN([unknown target-version $target_version, please update gt_@&t@JAVACOMP macro])
138 target_version=1.1 ;;
145 case "$source_version" in
146 1.3) goodcode='class conftest {}'
147 failcode='class conftestfail { static { assert(true); } }' ;;
148 1.4) goodcode='class conftest { static { assert(true); } }'
149 failcode='class conftestfail<T> { T foo() { return null; } }' ;;
150 1.5) goodcode='class conftest<T> { T foo() { return null; } }'
151 failcode='class conftestfail { void foo () { switch ("A") {} } }' ;;
152 1.7) goodcode='class conftest { void foo () { switch ("A") {} } }'
153 failcode='class conftestfail { void foo () { Runnable r = () -> {}; } }' ;;
154 1.8) goodcode='class conftest { void foo () { Runnable r = () -> {}; } }'
155 failcode='interface conftestfail { private void foo () {} }' ;;
156 9) goodcode='interface conftest { private void foo () {} }'
157 failcode='class conftestfail { public void m() { var i = new Integer(0); } }' ;;
158 10) goodcode='class conftest { public void m() { var i = new Integer(0); } }'
159 failcode='class conftestfail { Readable r = (var b) -> 0; }' ;;
160 11) goodcode='class conftest { Readable r = (var b) -> 0; }'
161 failcode='class conftestfail syntax error' ;;
162 *) AC_MSG_ERROR([invalid source-version argument to gt_@&t@JAVACOMP: $source_version]) ;;
164 case "$target_version" in
176 *) AC_MSG_ERROR([invalid target-version argument to gt_@&t@JAVACOMP: $target_version]) ;;
178 # Function to output the classfile version of a file (8th byte) in decimal.
179 if od -A x < /dev/null >/dev/null 2>/dev/null; then
181 func_classfile_version ()
183 od -A n -t d1 -j 7 -N 1 "[$]1"
187 func_classfile_version ()
189 dd if="[$]1" bs=1 count=1 skip=7 2>/dev/null | hexdump -e '1/1 "%3d "'
193 AC_MSG_CHECKING([for Java compiler])
195 dnl The support of GNU gcj for target-version and source-version:
197 dnl gcj 3.0.4 to 4.2 does not have a way to specify the target-version.
198 dnl It always assumes target-version=1.4 but labels the class files as 1.1.
199 dnl One consequence of this is that gcj compiles GetURL.java to invalid
200 dnl bytecode, which crashes with a VerifyError when executed by Sun Java
201 dnl 1.3.1. The bug is registered as java/7066, see
202 dnl https://gcc.gnu.org/bugzilla/show_bug.cgi?id=7066
203 dnl gcj 4.3 and newer has an option -ftarget=1.X; the maximum supported
204 dnl target-version is 1.6.
206 dnl For gcj < 3.3, the source-version always is 1.3.
207 dnl For 3.3 <= gcj < 4.3, the source-version defaults to 1.4; option
208 dnl "-fno-assert" switches to source-version 1.3.
209 dnl gcj >= 4.3 has an option -fsource=1.X.
211 dnl The support of Sun/Oracle javac for target-version and source-version:
213 dnl javac 1.3: -target 1.1 1.2 1.3 default: 1.1
214 dnl source always: 1.3
216 dnl javac 1.4: -target 1.1 1.2 1.3 1.4 default: 1.2
217 dnl -source 1.3 1.4 default: 1.3
218 dnl -target 1.1/1.2/1.3 only possible with -source 1.3 or no -source
220 dnl javac 1.5: -target 1.1 1.2 1.3 1.4 1.5 default: 1.5
221 dnl -source 1.3 1.4 1.5 default: 1.5
222 dnl -target 1.1/1.2/1.3 only possible with -source 1.3
223 dnl -target 1.4 only possible with -source 1.3/1.4
225 dnl javac 1.6: -target 1.1 1.2 1.3 1.4 1.5 1.6 default: 1.6
226 dnl -source 1.3 1.4 1.5 1.6 default: 1.5
227 dnl -target 1.1/1.2/1.3 only possible with -source 1.3
228 dnl -target 1.4 only possible with -source 1.3/1.4
229 dnl -target 1.5 only possible with -source 1.3/1.4/1.5 or no -source
231 dnl javac 1.7: -target 1.1 1.2 1.3 1.4 1.5 1.6 1.7 default: 1.7
232 dnl -source 1.3 1.4 1.5 1.6 1.7 default: 1.7
233 dnl -target 1.1/1.2/1.3 only possible with -source 1.3
234 dnl -target 1.4 only possible with -source 1.3/1.4
235 dnl -target 1.5 only possible with -source 1.3/1.4/1.5
236 dnl -target 1.6 only possible with -source 1.3/1.4/1.5/1.6
238 dnl javac 1.8: -target 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 default: 1.8
239 dnl -source 1.3 1.4 1.5 1.6 1.7 1.8 default: 1.8
240 dnl -target 1.1/1.2/1.3 only possible with -source 1.3
241 dnl -target 1.4 only possible with -source 1.3/1.4
242 dnl -target 1.5 only possible with -source 1.3/1.4/1.5
243 dnl -target 1.6 only possible with -source 1.3/1.4/1.5/1.6
244 dnl -target 1.7 only possible with -source 1.3/1.4/1.5/1.6/1.7
246 dnl javac 9: -target 1.6 1.7 1.8 9 default: 9
247 dnl -source 1.6 1.7 1.8 9 default: 9
248 dnl -target 1.6 only possible with -source 1.6
249 dnl -target 1.7 only possible with -source 1.6/1.7
250 dnl -target 1.8 only possible with -source 1.6/1.7/1.8
252 dnl javac 10: -target 1.6 1.7 1.8 9 10 default: 10
253 dnl -source 1.6 1.7 1.8 9 10 default: 10
254 dnl -target 1.6 only possible with -source 1.6
255 dnl -target 1.7 only possible with -source 1.6/1.7
256 dnl -target 1.8 only possible with -source 1.6/1.7/1.8
257 dnl -target 9 only possible with -source 1.6/1.7/1.8/9
259 dnl javac 11: -target 1.6 1.7 1.8 9 10 11 default: 11
260 dnl -source 1.6 1.7 1.8 9 10 11 default: 11
261 dnl -target 1.6 only possible with -source 1.6
262 dnl -target 1.7 only possible with -source 1.6/1.7
263 dnl -target 1.8 only possible with -source 1.6/1.7/1.8
264 dnl -target 9 only possible with -source 1.6/1.7/1.8/9
265 dnl -target 10 only possible with -source 1.6/1.7/1.8/9/10
267 dnl The support of jikes for target-version and source-version:
269 dnl jikes 1.14 does not have a way to specify the target-version. It
270 dnl always assumes target-version=1.1.
272 dnl For jikes 1.14, the source-version always is 1.3.
281 cat > conftestlib.java <<EOF
282 public class conftestlib {
283 public static void main (String[] args) {
288 echo "$goodcode" > conftest.java
289 echo "$failcode" > conftestfail.java
290 dnl If the user has set the JAVAC environment variable, use that, if it
291 dnl satisfies the constraints (possibly after adding -target and -source
293 if test -n "$JAVAC"; then
294 dnl Try the original $JAVAC.
295 if $JAVAC --version 2>/dev/null | sed -e 1q | grep gcj > /dev/null; then
296 dnl It's a version of gcj.
298 if $JAVAC --version 2>/dev/null | sed -e 's,^[^0-9]*,,' -e 1q | sed -e '/^4\.[012]/d' | grep '^[4-9]' >/dev/null; then
300 dnl It's a version of gcj >= 4.3. Assume the classfile versions are correct.
303 if { echo "$as_me:__oline__: $JAVAC -d . conftest.java" >&AS_MESSAGE_LOG_FD
304 $JAVAC -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
306 && test -f conftest.class \
307 && expr `func_classfile_version conftest.class` '<=' $cfversion >/dev/null 2>&AS_MESSAGE_LOG_FD; then
308 dnl Try adding -fsource option if it is useful.
310 rm -f conftestfail.class
311 if { echo "$as_me:__oline__: $JAVAC -fsource=$source_version -d . conftest.java" >&AS_MESSAGE_LOG_FD
312 $JAVAC -fsource="$source_version" -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
314 && test -f conftest.class \
315 && expr `func_classfile_version conftest.class` '<=' $cfversion >/dev/null 2>&AS_MESSAGE_LOG_FD \
316 && { echo "$as_me:__oline__: $JAVAC -d . conftestfail.java" >&AS_MESSAGE_LOG_FD
317 $JAVAC -d . conftestfail.java >&AS_MESSAGE_LOG_FD 2>&1
319 && test -f conftestfail.class \
320 && ! { echo "$as_me:__oline__: $JAVAC -fsource=$source_version -d . conftestfail.java" >&AS_MESSAGE_LOG_FD
321 $JAVAC -fsource="$source_version" -d . conftestfail.java >&AS_MESSAGE_LOG_FD 2>&1
323 CONF_JAVAC="$JAVAC -fsource=$source_version"
332 dnl Try with -fsource and -ftarget options.
334 rm -f conftestfail.class
335 if { echo "$as_me:__oline__: $JAVAC -fsource=$source_version -ftarget=$target_version -d . conftest.java" >&AS_MESSAGE_LOG_FD
336 $JAVAC -fsource="$source_version" -ftarget="$target_version" -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
338 && test -f conftest.class \
339 && expr `func_classfile_version conftest.class` '<=' $cfversion >/dev/null 2>&AS_MESSAGE_LOG_FD; then
340 CONF_JAVAC="$JAVAC -fsource=$source_version -ftarget=$target_version"
346 dnl It's a version of gcj < 4.3. Ignore the version of conftest.class.
347 if test "$target_version" = 1.4 && test "$source_version" = 1.4; then
350 if { echo "$as_me:__oline__: $JAVAC -d . conftest.java" >&AS_MESSAGE_LOG_FD
351 $JAVAC -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
353 && test -f conftest.class; then
359 if test "$target_version" = 1.4 && test "$source_version" = 1.3; then
360 dnl Try $JAVAC and "$JAVAC -fno-assert". But add -fno-assert only if
361 dnl it makes a difference. (It could already be part of $JAVAC.)
364 if { echo "$as_me:__oline__: $JAVAC -d . conftest.java" >&AS_MESSAGE_LOG_FD
365 $JAVAC -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
367 && test -f conftest.class; then
370 javac_noassert_works=
372 if { echo "$as_me:__oline__: $JAVAC -fno-assert -d . conftest.java" >&AS_MESSAGE_LOG_FD
373 $JAVAC -fno-assert -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
375 && test -f conftest.class; then
376 javac_noassert_works=1
378 if test -n "$javac_works" && test -n "$javac_noassert_works"; then
379 rm -f conftestfail.class
380 if { echo "$as_me:__oline__: $JAVAC -d . conftestfail.java" >&AS_MESSAGE_LOG_FD
381 $JAVAC -d . conftestfail.java >&AS_MESSAGE_LOG_FD 2>&1
383 && test -f conftestfail.class \
384 && ! { echo "$as_me:__oline__: $JAVAC -fno-assert -d . conftestfail.java" >&AS_MESSAGE_LOG_FD
385 $JAVAC -fno-assert -d . conftestfail.java >&AS_MESSAGE_LOG_FD 2>&1
387 dnl "$JAVAC -fno-assert" works better than $JAVAC.
391 if test -n "$javac_works"; then
396 if test -n "$javac_noassert_works"; then
397 CONF_JAVAC="$JAVAC -fno-assert"
406 dnl It's not gcj. Assume the classfile versions are correct.
408 dnl The javac option '-source 1.5' has the same meaning as '-source 1.6',
409 dnl but since Java 9 supports only the latter, prefer the latter if a
410 dnl target_version >= 1.6 is requested.
411 if test "$source_version" = 1.5; then
412 case "$target_version" in
413 1.1 | 1.2 | 1.3 | 1.4 | 1.5) ;;
414 *) source_version='1.6' ;;
418 if { echo "$as_me:__oline__: $JAVAC -d . conftest.java" >&AS_MESSAGE_LOG_FD
419 $JAVAC -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
421 && test -f conftest.class \
422 && expr `func_classfile_version conftest.class` '<=' $cfversion >/dev/null 2>&AS_MESSAGE_LOG_FD; then
423 dnl Try adding -source option if it is useful.
425 rm -f conftestfail.class
426 if { echo "$as_me:__oline__: $JAVAC -source $source_version -d . conftest.java" >&AS_MESSAGE_LOG_FD
427 $JAVAC -source "$source_version" -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
429 && test -f conftest.class \
430 && expr `func_classfile_version conftest.class` '<=' $cfversion >/dev/null 2>&AS_MESSAGE_LOG_FD \
431 && { echo "$as_me:__oline__: $JAVAC -d . conftestfail.java" >&AS_MESSAGE_LOG_FD
432 $JAVAC -d . conftestfail.java >&AS_MESSAGE_LOG_FD 2>&1
434 && test -f conftestfail.class \
435 && ! { echo "$as_me:__oline__: $JAVAC -source $source_version -d . conftestfail.java" >&AS_MESSAGE_LOG_FD
436 $JAVAC -source "$source_version" -d . conftestfail.java >&AS_MESSAGE_LOG_FD 2>&1
438 CONF_JAVAC="$JAVAC -source $source_version"
447 dnl Try with -target option alone. (Sun javac 1.3.1 has the -target
448 dnl option but no -source option.)
450 if { echo "$as_me:__oline__: $JAVAC -target $target_version -d . conftest.java" >&AS_MESSAGE_LOG_FD
451 $JAVAC -target "$target_version" -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
453 && test -f conftest.class \
454 && expr `func_classfile_version conftest.class` '<=' $cfversion >/dev/null 2>&AS_MESSAGE_LOG_FD; then
455 dnl Try adding -source option if it is useful.
457 rm -f conftestfail.class
458 if { echo "$as_me:__oline__: $JAVAC -target $target_version -source $source_version -d . conftest.java" >&AS_MESSAGE_LOG_FD
459 $JAVAC -target "$target_version" -source "$source_version" -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
461 && test -f conftest.class \
462 && expr `func_classfile_version conftest.class` '<=' $cfversion >/dev/null 2>&AS_MESSAGE_LOG_FD \
463 && { echo "$as_me:__oline__: $JAVAC -target $target_version -d . conftestfail.java" >&AS_MESSAGE_LOG_FD
464 $JAVAC -target "$target_version" -d . conftestfail.java >&AS_MESSAGE_LOG_FD 2>&1
466 && test -f conftestfail.class \
467 && ! { echo "$as_me:__oline__: $JAVAC -target $target_version -source $source_version -d . conftestfail.java" >&AS_MESSAGE_LOG_FD
468 $JAVAC -target "$target_version" -source "$source_version" -d . conftestfail.java >&AS_MESSAGE_LOG_FD 2>&1
470 CONF_JAVAC="$JAVAC -target $target_version -source $source_version"
474 CONF_JAVAC="$JAVAC -target $target_version"
479 dnl Maybe this -target option requires a -source option? Try with
480 dnl -target and -source options. (Supported by Sun javac 1.4 and
483 if { echo "$as_me:__oline__: $JAVAC -target $target_version -source $source_version -d . conftest.java" >&AS_MESSAGE_LOG_FD
484 $JAVAC -target "$target_version" -source "$source_version" -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
486 && test -f conftest.class \
487 && expr `func_classfile_version conftest.class` '<=' $cfversion >/dev/null 2>&AS_MESSAGE_LOG_FD; then
488 CONF_JAVAC="$JAVAC -target $target_version -source $source_version"
496 if test -z "$HAVE_JAVACOMP"; then
497 pushdef([AC_MSG_CHECKING],[:])dnl
498 pushdef([AC_CHECKING],[:])dnl
499 pushdef([AC_MSG_RESULT],[:])dnl
500 AC_CHECK_PROG([HAVE_GCJ_IN_PATH], [gcj], [yes])
501 AC_CHECK_PROG([HAVE_JAVAC_IN_PATH], [javac], [yes])
502 AC_CHECK_PROG([HAVE_JIKES_IN_PATH], [jikes], [yes])
503 popdef([AC_MSG_RESULT])dnl
504 popdef([AC_CHECKING])dnl
505 popdef([AC_MSG_CHECKING])dnl
506 if test -z "$HAVE_JAVACOMP" && test -n "$HAVE_GCJ_IN_PATH"; then
507 dnl Test for a good gcj version (>= 3.0).
509 if gcj --version 2>/dev/null | sed -e 's,^[^0-9]*,,' -e 1q | sed -e '/^3\.[01]/d' | grep '^[3-9]' >/dev/null; then
511 dnl See if libgcj.jar is well installed.
512 if { echo "$as_me:__oline__: gcj -C -d . conftestlib.java" >&AS_MESSAGE_LOG_FD
513 gcj -C -d . conftestlib.java >&AS_MESSAGE_LOG_FD 2>&1
517 if gcj --version 2>/dev/null | sed -e 's,^[^0-9]*,,' -e 1q | sed -e '/^4\.[012]/d' | grep '^[4-9]' >/dev/null; then
519 dnl It's a version of gcj >= 4.3. Assume the classfile versions are correct.
522 if { echo "$as_me:__oline__: gcj -C -d . conftest.java" >&AS_MESSAGE_LOG_FD
523 gcj -C -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
525 && test -f conftest.class \
526 && expr `func_classfile_version conftest.class` '<=' $cfversion >/dev/null 2>&AS_MESSAGE_LOG_FD; then
527 dnl Try adding -fsource option if it is useful.
529 rm -f conftestfail.class
530 if { echo "$as_me:__oline__: gcj -C -fsource=$source_version -d . conftest.java" >&AS_MESSAGE_LOG_FD
531 gcj -C -fsource="$source_version" -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
533 && test -f conftest.class \
534 && expr `func_classfile_version conftest.class` '<=' $cfversion >/dev/null 2>&AS_MESSAGE_LOG_FD \
535 && { echo "$as_me:__oline__: gcj -C -d . conftestfail.java" >&AS_MESSAGE_LOG_FD
536 gcj -C -d . conftestfail.java >&AS_MESSAGE_LOG_FD 2>&1
538 && test -f conftestfail.class \
539 && ! { echo "$as_me:__oline__: gcj -C -fsource=$source_version -d . conftestfail.java" >&AS_MESSAGE_LOG_FD
540 gcj -C -fsource="$source_version" -d . conftestfail.java >&AS_MESSAGE_LOG_FD 2>&1
542 CONF_JAVAC="gcj -C -fsource=$source_version"
551 dnl Try with -fsource and -ftarget options.
553 rm -f conftestfail.class
554 if { echo "$as_me:__oline__: gcj -C -fsource=$source_version -ftarget=$target_version -d . conftest.java" >&AS_MESSAGE_LOG_FD
555 gcj -C -fsource="$source_version" -ftarget="$target_version" -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
557 && test -f conftest.class \
558 && expr `func_classfile_version conftest.class` '<=' $cfversion >/dev/null 2>&AS_MESSAGE_LOG_FD; then
559 CONF_JAVAC="gcj -C -fsource=$source_version -ftarget=$target_version"
565 dnl It's a version of gcj < 4.3. Ignore the version of conftest.class.
566 dnl Now test whether it supports the desired target-version and
568 if test "$target_version" = 1.4 && test "$source_version" = 1.4; then
570 if { echo "$as_me:__oline__: gcj -C -d . conftest.java" >&AS_MESSAGE_LOG_FD
571 gcj -C -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
573 && test -f conftest.class; then
579 if test "$target_version" = 1.4 && test "$source_version" = 1.3; then
580 dnl Try gcj and "gcj -fno-assert". But add -fno-assert only if
581 dnl it works (not gcj < 3.3).
583 if { echo "$as_me:__oline__: gcj -C -fno-assert -d . conftest.java" >&AS_MESSAGE_LOG_FD
584 gcj -C -fno-assert -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
586 && test -f conftest.class; then
587 CONF_JAVAC="gcj -C -fno-assert"
592 if { echo "$as_me:__oline__: gcj -C -d . conftest.java" >&AS_MESSAGE_LOG_FD
593 gcj -C -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
595 && test -f conftest.class; then
607 if test -z "$HAVE_JAVACOMP" && test -n "$HAVE_JAVAC_IN_PATH"; then
608 dnl Test whether javac is usable.
609 if { javac -version >/dev/null 2>/dev/null || test $? -le 2; } \
610 && ( 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
612 dnl The javac option '-source 1.5' has the same meaning as '-source 1.6',
613 dnl but since Java 9 supports only the latter, prefer the latter if a
614 dnl target_version >= 1.6 is requested.
615 if test "$source_version" = 1.5; then
616 case "$target_version" in
617 1.1 | 1.2 | 1.3 | 1.4 | 1.5) ;;
618 *) source_version='1.6' ;;
621 dnl Now test whether it supports the desired target-version and
624 if { echo "$as_me:__oline__: javac -d . conftest.java" >&AS_MESSAGE_LOG_FD
625 javac -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
627 && test -f conftest.class \
628 && expr `func_classfile_version conftest.class` '<=' $cfversion >/dev/null 2>&AS_MESSAGE_LOG_FD; then
629 dnl Try adding -source option if it is useful.
631 rm -f conftestfail.class
632 if { echo "$as_me:__oline__: javac -source $source_version -d . conftest.java" >&AS_MESSAGE_LOG_FD
633 javac -source "$source_version" -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
635 && test -f conftest.class \
636 && expr `func_classfile_version conftest.class` '<=' $cfversion >/dev/null 2>&AS_MESSAGE_LOG_FD \
637 && { echo "$as_me:__oline__: javac -d . conftestfail.java" >&AS_MESSAGE_LOG_FD
638 javac -d . conftestfail.java >&AS_MESSAGE_LOG_FD 2>&1
640 && test -f conftestfail.class \
641 && ! { echo "$as_me:__oline__: javac -source $source_version -d . conftestfail.java" >&AS_MESSAGE_LOG_FD
642 javac -source "$source_version" -d . conftestfail.java >&AS_MESSAGE_LOG_FD 2>&1
644 CONF_JAVAC="javac -source $source_version"
653 dnl Try with -target option alone. (Sun javac 1.3.1 has the -target
654 dnl option but no -source option.)
656 if { echo "$as_me:__oline__: javac -target $target_version -d . conftest.java" >&AS_MESSAGE_LOG_FD
657 javac -target "$target_version" -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
659 && test -f conftest.class \
660 && expr `func_classfile_version conftest.class` '<=' $cfversion >/dev/null 2>&AS_MESSAGE_LOG_FD; then
661 dnl Try adding -source option if it is useful.
663 rm -f conftestfail.class
664 if { echo "$as_me:__oline__: javac -target $target_version -source $source_version -d . conftest.java" >&AS_MESSAGE_LOG_FD
665 javac -target "$target_version" -source "$source_version" -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
667 && test -f conftest.class \
668 && expr `func_classfile_version conftest.class` '<=' $cfversion >/dev/null 2>&AS_MESSAGE_LOG_FD \
669 && { echo "$as_me:__oline__: javac -target $target_version -d . conftestfail.java" >&AS_MESSAGE_LOG_FD
670 javac -target "$target_version" -d . conftestfail.java >&AS_MESSAGE_LOG_FD 2>&1
672 && test -f conftestfail.class \
673 && ! { echo "$as_me:__oline__: javac -target $target_version -source $source_version -d . conftestfail.java" >&AS_MESSAGE_LOG_FD
674 javac -target "$target_version" -source "$source_version" -d . conftestfail.java >&AS_MESSAGE_LOG_FD 2>&1
676 CONF_JAVAC="javac -target $target_version -source $source_version"
680 CONF_JAVAC="javac -target $target_version"
685 dnl Maybe this -target option requires a -source option? Try with
686 dnl -target and -source options. (Supported by Sun javac 1.4 and
689 if { echo "$as_me:__oline__: javac -target $target_version -source $source_version -d . conftest.java" >&AS_MESSAGE_LOG_FD
690 javac -target "$target_version" -source "$source_version" -d . conftest.java >&AS_MESSAGE_LOG_FD 2>&1
692 && test -f conftest.class \
693 && expr `func_classfile_version conftest.class` '<=' $cfversion >/dev/null 2>&AS_MESSAGE_LOG_FD; then
694 CONF_JAVAC="javac -target $target_version -source $source_version"
702 if test -z "$HAVE_JAVACOMP" && test -n "$HAVE_JIKES_IN_PATH"; then
703 dnl Test whether jikes is usable.
704 if { jikes >/dev/null 2>/dev/null || test $? = 1; } \
706 # See if the existing CLASSPATH is sufficient to make jikes work.
708 jikes conftestlib.java >&AS_MESSAGE_LOG_FD 2>&1
710 rm -f conftestlib.class
714 dnl Now test whether it supports the desired target-version and
716 if test "$source_version" = 1.3; then
724 rm -f conftest*.java conftest*.class
725 if test -n "$HAVE_JAVACOMP"; then
726 ac_result="$CONF_JAVAC"
730 AC_MSG_RESULT([$ac_result])
731 AC_SUBST([CONF_JAVAC])
732 AC_SUBST([CLASSPATH])
733 AC_SUBST([CLASSPATH_SEPARATOR])
734 AC_SUBST([HAVE_JAVAC_ENVVAR])
735 AC_SUBST([HAVE_GCJ_C])
736 AC_SUBST([HAVE_JAVAC])
737 AC_SUBST([HAVE_JIKES])