/* Determine the version from the found JVM. */
java_version_cache = javaexec_version ();
if (java_version_cache == NULL)
- java_version_cache = "1.1";
+ java_version_cache = "1.6";
+ else if (java_version_cache[0] == '1'
+ && java_version_cache[1] == '.'
+ && java_version_cache[2] >= '1' && java_version_cache[2] <= '5'
+ && java_version_cache[3] == '\0')
+ {
+ error (0, 0, _("The java program is too old. Cannot compile Java code for this old version any more."));
+ java_version_cache = "1.6";
+ }
else if ((java_version_cache[0] == '1'
&& java_version_cache[1] == '.'
- && java_version_cache[2] >= '1' && java_version_cache[2] <= '8'
+ && java_version_cache[2] >= '6' && java_version_cache[2] <= '8'
&& java_version_cache[3] == '\0')
|| (java_version_cache[0] == '9'
&& java_version_cache[1] == '\0')
like the preceding ones. */
java_version_cache = "11";
else
- java_version_cache = "1.1";
+ java_version_cache = "1.6";
}
return java_version_cache;
}
/* ======================= Source version dependent ======================= */
/* Convert a source version to an index. */
-#define SOURCE_VERSION_BOUND 8 /* exclusive upper bound */
+#define SOURCE_VERSION_BOUND 6 /* exclusive upper bound */
static unsigned int
source_version_index (const char *source_version)
{
if (source_version[0] == '1' && source_version[1] == '.')
{
- if ((source_version[2] >= '3' && source_version[2] <= '5')
+ if ((source_version[2] >= '6' && source_version[2] <= '8')
&& source_version[3] == '\0')
- return source_version[2] - '3';
- if ((source_version[2] >= '7' && source_version[2] <= '8')
- && source_version[3] == '\0')
- return source_version[2] - '4';
+ return source_version[2] - '6';
}
else if (source_version[0] == '9' && source_version[1] == '\0')
- return 5;
+ return 3;
else if (source_version[0] == '1'
&& (source_version[1] >= '0' && source_version[1] <= '1')
&& source_version[2] == '\0')
- return source_version[1] - '0' + 6;
+ return source_version[1] - '0' + 4;
error (EXIT_FAILURE, 0, _("invalid source_version argument to compile_java_class"));
return 0;
}
static const char *
get_goodcode_snippet (const char *source_version)
{
- if (strcmp (source_version, "1.3") == 0)
- return "class conftest {}\n";
- if (strcmp (source_version, "1.4") == 0)
- return "class conftest { static { assert(true); } }\n";
- if (strcmp (source_version, "1.5") == 0)
+ if (strcmp (source_version, "1.6") == 0)
return "class conftest<T> { T foo() { return null; } }\n";
if (strcmp (source_version, "1.7") == 0)
return "class conftest { void foo () { switch (\"A\") {} } }\n";
static const char *
get_failcode_snippet (const char *source_version)
{
- if (strcmp (source_version, "1.3") == 0)
- return "class conftestfail { static { assert(true); } }\n";
- if (strcmp (source_version, "1.4") == 0)
- return "class conftestfail<T> { T foo() { return null; } }\n";
- if (strcmp (source_version, "1.5") == 0)
+ if (strcmp (source_version, "1.6") == 0)
return "class conftestfail { void foo () { switch (\"A\") {} } }\n";
if (strcmp (source_version, "1.7") == 0)
return "class conftestfail { void foo () { Runnable r = () -> {}; } }\n";
/* ======================= Target version dependent ======================= */
/* Convert a target version to an index. */
-#define TARGET_VERSION_BOUND 11 /* exclusive upper bound */
+#define TARGET_VERSION_BOUND 6 /* exclusive upper bound */
static unsigned int
target_version_index (const char *target_version)
{
if (target_version[0] == '1' && target_version[1] == '.'
- && (target_version[2] >= '1' && target_version[2] <= '8')
+ && (target_version[2] >= '6' && target_version[2] <= '8')
&& target_version[3] == '\0')
- return target_version[2] - '1';
+ return target_version[2] - '6';
else if (target_version[0] == '9' && target_version[1] == '\0')
- return 8;
+ return 3;
else if (target_version[0] == '1'
&& (target_version[1] >= '0' && target_version[1] <= '1')
&& target_version[2] == '\0')
- return target_version[1] - '0' + 9;
+ return target_version[1] - '0' + 4;
error (EXIT_FAILURE, 0, _("invalid target_version argument to compile_java_class"));
return 0;
}
static int
corresponding_classfile_version (const char *target_version)
{
- if (strcmp (target_version, "1.1") == 0)
- return 45;
- if (strcmp (target_version, "1.2") == 0)
- return 46;
- if (strcmp (target_version, "1.3") == 0)
- return 47;
- if (strcmp (target_version, "1.4") == 0)
- return 48;
- if (strcmp (target_version, "1.5") == 0)
- return 49;
if (strcmp (target_version, "1.6") == 0)
return 50;
if (strcmp (target_version, "1.7") == 0)
return 0;
}
-/* Return the source version to pass to javac. */
-static const char *
-get_source_version_for_javac (const char *source_version,
- const char *target_version)
-{
- /* The javac option '-source 1.5' has the same meaning as '-source 1.6',
- but since Java 9 supports only the latter, prefer the latter if a
- target_version >= 1.6 is requested. */
- if (strcmp (source_version, "1.5") == 0
- && !(target_version[0] == '1' && target_version[1] == '.'
- && (target_version[2] >= '1' && target_version[2] <= '5')
- && target_version[3] == '\0'))
- return "1.6";
- return source_version;
-}
-
/* ======================== Compilation subroutines ======================== */
/* Try to compile a set of Java sources with $JAVAC.
Return a failure indicator (true upon error). */
static bool
is_envjavac_usable (const char *javac,
- const char *source_version,
- const char *source_version_for_javac,
- const char *target_version,
+ const char *source_version, const char *target_version,
bool *usablep,
bool *source_option_p, bool *target_option_p)
{
/* $JAVAC compiled conftest.java successfully. */
/* Try adding -source option if it is useful. */
char *javac_source =
- xasprintf ("%s -source %s", javac, source_version_for_javac);
+ xasprintf ("%s -source %s", javac, source_version);
assume (javac_source != NULL);
unlink (compiled_file_name);
tmpdir->dir_name,
false, false, false, true))
/* $JAVAC compiled conftestfail.java successfully, and
- "$JAVAC -source $source_version_for_javac" rejects it.
+ "$JAVAC -source $source_version" rejects it.
So the -source option is useful. */
resultp->source_option = true;
}
}
else
{
- /* Try with -target option alone. (Sun javac 1.3.1 has the -target
- option but no -source option.) */
- char *javac_target =
- xasprintf ("%s -target %s", javac, target_version);
- assume (javac_target != NULL);
+ /* Try with -target and -source options. (All supported javac
+ versions support both, see the table in javacomp.m4.) */
+ char *javac_target_source =
+ xasprintf ("%s -target %s -source %s", javac,
+ target_version, source_version);
+ assume (javac_target_source != NULL);
unlink (compiled_file_name);
java_sources[0] = conftest_file_name;
- if (!compile_using_envjavac (javac_target,
+ if (!compile_using_envjavac (javac_target_source,
java_sources, 1, tmpdir->dir_name,
false, false, false, true)
&& stat (compiled_file_name, &statbuf) >= 0
&& get_classfile_version (compiled_file_name)
<= corresponding_classfile_version (target_version))
{
- /* "$JAVAC -target $target_version" compiled conftest.java
- successfully. */
- /* Try adding -source option if it is useful. */
- char *javac_target_source =
- xasprintf ("%s -source %s", javac_target, source_version_for_javac);
- assume (javac_target_source != NULL);
-
- unlink (compiled_file_name);
-
- java_sources[0] = conftest_file_name;
- if (!compile_using_envjavac (javac_target_source,
- java_sources, 1, tmpdir->dir_name,
- false, false, false, true)
- && stat (compiled_file_name, &statbuf) >= 0
- && get_classfile_version (compiled_file_name)
- <= corresponding_classfile_version (target_version))
- {
- const char *failcode = get_failcode_snippet (source_version);
-
- if (failcode != NULL)
- {
- free (compiled_file_name);
- free (conftest_file_name);
-
- conftest_file_name =
- xconcatenated_filename (tmpdir->dir_name,
- "conftestfail.java",
- NULL);
- if (write_temp_file (tmpdir, conftest_file_name,
- failcode))
- {
- free (conftest_file_name);
- free (javac_target_source);
- free (javac_target);
- cleanup_temp_dir (tmpdir);
- return true;
- }
-
- compiled_file_name =
- xconcatenated_filename (tmpdir->dir_name,
- "conftestfail.class",
- NULL);
- register_temp_file (tmpdir, compiled_file_name);
-
- java_sources[0] = conftest_file_name;
- if (!compile_using_envjavac (javac_target,
- java_sources, 1,
- tmpdir->dir_name,
- false, false, false, true)
- && stat (compiled_file_name, &statbuf) >= 0)
- {
- unlink (compiled_file_name);
-
- java_sources[0] = conftest_file_name;
- if (compile_using_envjavac (javac_target_source,
- java_sources, 1,
- tmpdir->dir_name,
- false, false, false,
- true))
- /* "$JAVAC -target $target_version" compiled
- conftestfail.java successfully, and
- "$JAVAC -target $target_version -source $source_version_for_javac"
- rejects it. So the -source option is useful. */
- resultp->source_option = true;
- }
- }
- }
-
- free (javac_target_source);
-
+ /* "$JAVAC -target $target_version -source $source_version"
+ compiled conftest.java successfully. */
+ resultp->source_option = true;
resultp->target_option = true;
resultp->usable = true;
}
- else
- {
- /* Maybe this -target option requires a -source option? Try with
- -target and -source options. (Supported by Sun javac 1.4 and
- higher.) */
- char *javac_target_source =
- xasprintf ("%s -source %s", javac_target, source_version_for_javac);
- assume (javac_target_source != NULL);
-
- unlink (compiled_file_name);
-
- java_sources[0] = conftest_file_name;
- if (!compile_using_envjavac (javac_target_source,
- java_sources, 1, tmpdir->dir_name,
- false, false, false, true)
- && stat (compiled_file_name, &statbuf) >= 0
- && get_classfile_version (compiled_file_name)
- <= corresponding_classfile_version (target_version))
- {
- /* "$JAVAC -target $target_version -source $source_version_for_javac"
- compiled conftest.java successfully. */
- resultp->source_option = true;
- resultp->target_option = true;
- resultp->usable = true;
- }
-
- free (javac_target_source);
- }
- free (javac_target);
+ free (javac_target_source);
}
free (compiled_file_name);
-target option.
Return a failure indicator (true upon error). */
static bool
-is_javac_usable (const char *source_version,
- const char *source_version_for_javac,
- const char *target_version,
+is_javac_usable (const char *source_version, const char *target_version,
bool *usablep, bool *source_option_p, bool *target_option_p)
{
/* The cache depends on the source_version and target_version. */
java_sources[0] = conftest_file_name;
if (!compile_using_javac (java_sources, 1,
- false, source_version_for_javac,
+ false, source_version,
false, target_version,
tmpdir->dir_name, false, false, false, true)
&& stat (compiled_file_name, &statbuf) >= 0
java_sources[0] = conftest_file_name;
if (!compile_using_javac (java_sources, 1,
- true, source_version_for_javac,
+ true, source_version,
false, target_version,
tmpdir->dir_name, false, false, false, true)
&& stat (compiled_file_name, &statbuf) >= 0
java_sources[0] = conftest_file_name;
if (!compile_using_javac (java_sources, 1,
- false, source_version_for_javac,
+ false, source_version,
false, target_version,
tmpdir->dir_name,
false, false, false, true)
java_sources[0] = conftest_file_name;
if (compile_using_javac (java_sources, 1,
- true, source_version_for_javac,
+ true, source_version,
false, target_version,
tmpdir->dir_name,
false, false, false, true))
/* javac compiled conftestfail.java successfully, and
- "javac -source $source_version_for_javac" rejects it.
+ "javac -source $source_version" rejects it.
So the -source option is useful. */
resultp->source_option = true;
}
}
else
{
- /* Try with -target option alone. (Sun javac 1.3.1 has the -target
- option but no -source option.) */
+ /* Try with -target and -source options. (All supported javac
+ versions support both, see the table in javacomp.m4.) */
unlink (compiled_file_name);
java_sources[0] = conftest_file_name;
if (!compile_using_javac (java_sources, 1,
- false, source_version_for_javac,
+ true, source_version,
true, target_version,
tmpdir->dir_name,
false, false, false, true)
&& get_classfile_version (compiled_file_name)
<= corresponding_classfile_version (target_version))
{
- /* "javac -target $target_version" compiled conftest.java
- successfully. */
- /* Try adding -source option if it is useful. */
- unlink (compiled_file_name);
-
- java_sources[0] = conftest_file_name;
- if (!compile_using_javac (java_sources, 1,
- true, source_version_for_javac,
- true, target_version,
- tmpdir->dir_name,
- false, false, false, true)
- && stat (compiled_file_name, &statbuf) >= 0
- && get_classfile_version (compiled_file_name)
- <= corresponding_classfile_version (target_version))
- {
- const char *failcode = get_failcode_snippet (source_version);
-
- if (failcode != NULL)
- {
- free (compiled_file_name);
- free (conftest_file_name);
-
- conftest_file_name =
- xconcatenated_filename (tmpdir->dir_name,
- "conftestfail.java",
- NULL);
- if (write_temp_file (tmpdir, conftest_file_name,
- failcode))
- {
- free (conftest_file_name);
- cleanup_temp_dir (tmpdir);
- return true;
- }
-
- compiled_file_name =
- xconcatenated_filename (tmpdir->dir_name,
- "conftestfail.class",
- NULL);
- register_temp_file (tmpdir, compiled_file_name);
-
- java_sources[0] = conftest_file_name;
- if (!compile_using_javac (java_sources, 1,
- false, source_version_for_javac,
- true, target_version,
- tmpdir->dir_name,
- false, false, false, true)
- && stat (compiled_file_name, &statbuf) >= 0)
- {
- unlink (compiled_file_name);
-
- java_sources[0] = conftest_file_name;
- if (compile_using_javac (java_sources, 1,
- true, source_version_for_javac,
- true, target_version,
- tmpdir->dir_name,
- false, false, false, true))
- /* "javac -target $target_version" compiled
- conftestfail.java successfully, and
- "javac -target $target_version -source $source_version_for_javac"
- rejects it. So the -source option is useful. */
- resultp->source_option = true;
- }
- }
- }
-
+ /* "javac -target $target_version -source $source_version"
+ compiled conftest.java successfully. */
+ resultp->source_option = true;
resultp->target_option = true;
resultp->usable = true;
}
- else
- {
- /* Maybe this -target option requires a -source option? Try with
- -target and -source options. (Supported by Sun javac 1.4 and
- higher.) */
- unlink (compiled_file_name);
-
- java_sources[0] = conftest_file_name;
- if (!compile_using_javac (java_sources, 1,
- true, source_version_for_javac,
- true, target_version,
- tmpdir->dir_name,
- false, false, false, true)
- && stat (compiled_file_name, &statbuf) >= 0
- && get_classfile_version (compiled_file_name)
- <= corresponding_classfile_version (target_version))
- {
- /* "javac -target $target_version -source $source_version_for_javac"
- compiled conftest.java successfully. */
- resultp->source_option = true;
- resultp->target_option = true;
- resultp->usable = true;
- }
- }
}
free (compiled_file_name);
bool err = false;
char *old_JAVA_HOME;
+ /* Map source_version 1.1 ... 1.5 to 1.6. */
+ if (source_version[0] == '1' && source_version[1] == '.'
+ && (source_version[2] >= '1' && source_version[2] <= '5')
+ && source_version[3] == '\0')
+ source_version = "1.6";
+
+ /* Map target_version 1.1 ... 1.5 to 1.6. */
+ if (target_version != NULL
+ && target_version[0] == '1' && target_version[1] == '.'
+ && (target_version[2] >= '1' && target_version[2] <= '5')
+ && target_version[3] == '\0')
+ target_version = "1.6";
+
{
const char *javac = getenv ("JAVAC");
if (javac != NULL && javac[0] != '\0')
bool usable = false;
bool source_option = false;
bool target_option = false;
- const char *source_version_for_javac;
if (target_version == NULL)
target_version = default_target_version ();
- source_version_for_javac =
- get_source_version_for_javac (source_version, target_version);
-
if (is_envjavac_usable (javac,
- source_version,
- source_version_for_javac,
- target_version,
+ source_version, target_version,
&usable,
&source_option, &target_option))
{
xasprintf ("%s%s%s%s%s",
javac,
source_option ? " -source " : "",
- source_option ? source_version_for_javac : "",
+ source_option ? source_version : "",
target_option ? " -target " : "",
target_option ? target_version : "");
assume (javac_with_options != NULL);
bool usable = false;
bool source_option = false;
bool target_option = false;
- const char *source_version_for_javac;
if (target_version == NULL)
target_version = default_target_version ();
- source_version_for_javac =
- get_source_version_for_javac (source_version, target_version);
-
- if (is_javac_usable (source_version, source_version_for_javac,
- target_version,
+ if (is_javac_usable (source_version, target_version,
&usable, &source_option, &target_option))
{
err = true;
verbose);
err = compile_using_javac (java_sources, java_sources_count,
- source_option, source_version_for_javac,
+ source_option, source_version,
target_option, target_version,
directory, optimize, debug, verbose,
false);
-# javacomp.m4 serial 23
+# javacomp.m4 serial 24
dnl Copyright (C) 2001-2003, 2006-2007, 2009-2023 Free Software Foundation,
dnl Inc.
dnl This file is free software; the Free Software Foundation
# 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 supported)
+# 1.6 assert keyword (1.4), generic classes and methods (1.5)
# 1.7 switch(string)
# 1.8 lambdas
# 9 private interface methods
# 10 type inference for local variables
# 11 'var' in parameters of lambda expressions
-# Instead of source-version 1.6, use 1.5, since Java 6 did not introduce any
-# language changes. See
-# https://docs.oracle.com/javase/8/docs/technotes/guides/language/enhancements.html
+# If source-version 1.3 or 1.4 or 1.5 is requested, it gets mapped to 1.6, for
+# backward compatibility. (Currently the minimum Java and javac version we need
+# to support is Java 1.6, since that's the default Java version on Solaris 10.)
#
# 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
# 1.7 51.0
# 1.8 52.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".
+# If a target-version below 1.6 is requested, it gets mapped to 1.6, for
+# backward compatibility. (Currently the minimum Java and javac version we need
+# to support is Java 1.6, since that's the default Java version on Solaris 10.)
+#
# 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
-# 1.2 JDK/JRE 1.2
-# 1.3 JDK/JRE 1.3
-# 1.4 JDK/JRE 1.4
-# 1.5 JDK/JRE 5
# 1.6 JDK/JRE 6
# 1.7 JDK/JRE 7
# 1.8 JDK/JRE 8
# useful outside the given package. Omitting target-version is useful when
# building an application.
#
-# It is unreasonable to ask for:
+# It is unreasonable to ask for a target-version < source-version, such as
# - 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, or
# - target_version < 1.8 with source_version >= 1.8, or
# - target_version < 9 with source_version >= 9, or
# - target_version < 10 with source_version >= 10, or
-# - target_version < 11 with source_version >= 11,
+# - target_version < 11 with source_version >= 11, or
+# - ...
# because even Sun's/Oracle's javac doesn't support these combinations.
#
# It is redundant to ask for a target-version > source-version, since the
test -n "$source_version" || {
AC_MSG_ERROR([missing source-version argument to gt_@&t@JAVACOMP])
}
+ case "$source_version" in
+ 1.1 | 1.2 | 1.3 | 1.4 | 1.5) source_version='1.6' ;;
+ esac
m4_if([$2], [],
[if test -n "$HAVE_JAVAEXEC"; then
dnl Use $CONF_JAVA to determine the JVM's version.
CLASSPATH=.${CLASSPATH:+$CLASSPATH_SEPARATOR$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 | 1.7 | 1.8 | 9 | 10 | 11) ;;
+ null)
+ dnl JDK 1.1.X returns null.
+ target_version=1.1 ;;
+ esac
+ case "$target_version" in
+ 1.1 | 1.2 | 1.3 | 1.4 | 1.5)
+ AC_MSG_WARN([$CONF_JAVA is too old, cannot compile Java code for this old version any more])
+ target_version=1.6 ;;
+ 1.6 | 1.7 | 1.8 | 9 | 10 | 11) ;;
12 | 13 | 14 | 15 | 16 | 17)
dnl Assume that these (not yet released) Java versions will behave
dnl like the preceding ones.
target_version=11 ;;
- null)
- dnl JDK 1.1.X returns null.
- target_version=1.1 ;;
*) AC_MSG_WARN([unknown target-version $target_version, please update gt_@&t@JAVACOMP macro])
- target_version=1.1 ;;
+ target_version=1.6 ;;
esac
else
- target_version="1.1"
+ target_version="1.6"
fi
],
- [target_version=$2])
+ [target_version=$2
+ case "$target_version" in
+ 1.1 | 1.2 | 1.3 | 1.4 | 1.5) target_version='1.6' ;;
+ esac
+ ])
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; } }'
+ 1.6) goodcode='class conftest<T> { T foo() { return null; } }'
failcode='class conftestfail { void foo () { switch ("A") {} } }' ;;
1.7) goodcode='class conftest { void foo () { switch ("A") {} } }'
failcode='class conftestfail { void foo () { Runnable r = () -> {}; } }' ;;
*) 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 ;;
1.7) cfversion=51 ;;
1.8) cfversion=52 ;;
dnl
dnl The support of Sun/Oracle 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 options).
if test -n "$JAVAC"; then
dnl Try $JAVAC.
- dnl The javac option '-source 1.5' has the same meaning as '-source 1.6',
- dnl but since Java 9 supports only the latter, prefer the latter if a
- dnl target_version >= 1.6 is requested.
- if test "$source_version" = 1.5; then
- case "$target_version" in
- 1.1 | 1.2 | 1.3 | 1.4 | 1.5) ;;
- *) source_version='1.6' ;;
- esac
- fi
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
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.)
+ dnl Try with -target and -source options. (All supported javac
+ dnl versions support both, see the table above.)
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
+ 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
- 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
+ CONF_JAVAC="$JAVAC -target $target_version -source $source_version"
+ HAVE_JAVAC_ENVVAR=1
+ HAVE_JAVACOMP=1
fi
fi
fi
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 The javac option '-source 1.5' has the same meaning as '-source 1.6',
- dnl but since Java 9 supports only the latter, prefer the latter if a
- dnl target_version >= 1.6 is requested.
- if test "$source_version" = 1.5; then
- case "$target_version" in
- 1.1 | 1.2 | 1.3 | 1.4 | 1.5) ;;
- *) source_version='1.6' ;;
- esac
- fi
dnl Now test whether it supports the desired target-version and
dnl source-version.
rm -f conftest.class
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.)
+ dnl Try with -target and -source options. (All supported javac
+ dnl versions support both, see the table above.)
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
+ 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
- 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
+ CONF_JAVAC="javac -target $target_version -source $source_version"
+ HAVE_JAVAC=1
+ HAVE_JAVACOMP=1
fi
fi
fi