[m-rev.] for review: improvements to the Java launcher scripts

Julien Fischer jfischer at opturion.com
Mon Jul 18 15:42:47 AEST 2022

Hi Peter,

On Mon, 18 Jul 2022, Peter Wang wrote:

> On Sun, 17 Jul 2022 17:04:37 +1000 Julien Fischer <jfischer at opturion.com> wrote:
>> For review by anyone.
>> Question: should the new variable in the launcher scripts be named
>> JAVA_OPTS or JAVA_FLAGS (or something else)?

I've seen all three suffixes in the wild.

> I see that the java launcher from JDK 9+ supports the JDK_JAVA_OPTIONS
> variable so perhaps we can use that?

We still support Java 8 (and that's not going anywhere soon). I would
like to avoid the same names as the variables supported by the Java
tools themselves.  How about we change all of the variables in the
Mercury launchers that can be overridden to have a MERCURY_ prefix,


(There's some precedent for doing this since the shell scripts we use
in the C grades have MERCURY_C_COMPILER etc.)

That should reduce the risk of clashes with (a) Java itself and (b)
other stuff written in Java.


>> @@ -924,7 +928,8 @@ write_java_shell_script(Globals, MainModuleName, JarFileName, Stream, !IO) :-
>>           "CLASSPATH=", ClassPath, "\n",
>>           "export CLASSPATH\n",
>>           "JAVA=${JAVA:-", Java, "}\n",
>> -        "exec \"$JAVA\" jmercury.", ClassName, " \"$@\"\n"
>> +        "JAVA_OPTS=${JAVA_OPTS:-", RuntimeOpts, "}\n",
>> +        "exec \"$JAVA\" $JAVA_OPTS jmercury.", ClassName, " \"$@\"\n"
>>       ], !IO).
> RuntimeOpts should be quoted/escaped (here and elsewhere).
> If options.quote_arg doesn't do it, I think the simplest method is to
> wrap the value in single quotes, and replace any internal single quote
> char with '\'' (i.e. close string, backslash escaped single quote,
> open new string).



More information about the reviews mailing list