[m-rev.] For review: Fix a Java CLASSPATH-related bug

Fergus Henderson fjh at cs.mu.OZ.AU
Thu Feb 19 15:56:14 AEDT 2004


On 19-Feb-2004, James Goddard <goddardjames at yahoo.com> wrote:
> +++ compile_target_code.m	19 Feb 2004 01:32:32 -0000
> @@ -670,17 +670,15 @@
>  	{ join_string_list(JavaFlagsList, "", "", " ", JAVAFLAGS) },
>  
>  	globals__io_lookup_accumulating_option(java_classpath,
> -	 	Java_Incl_Dirs),
> -	( { Java_Incl_Dirs = [] } ->
> -		{ InclOpt = "" }
> -	;
> -		% XXX PathSeparator should be ";" on Windows
> -		{ PathSeparator = ":" },
> -		{ join_string_list(Java_Incl_Dirs, "", "",
> +		 	Java_Incl_Dirs),
> +	% XXX PathSeparator should be ";" on Windows
> +	{ PathSeparator = ":" },
> +	% We prepend the current CLASSPATH to preserve the accumulating
> +	% nature of this variable.
> +	{ join_string_list(["$CLASSPATH"|Java_Incl_Dirs], "", "",
>  			PathSeparator, ClassPath) },
> -		{ InclOpt = string__append_list([
> -			"-classpath ", quote_arg(ClassPath), " "]) }
> -	),
> +	{ SetCP = string__append_list(["CLASSPATH=", ClassPath, " "]) },
...
> +	{ string__append_list([SetCP, JavaCompiler, " ", DestDir,
>  		Target_DebugOpt, JAVAFLAGS, " ", JavaFile], Command) },
>  	invoke_system_command(ErrorStream, verbose_commands,
>  		Command, Succeeded).

Here you are relying on Bourne shell syntax for invoke_system_command.
That won't work if the compiler is compiled with the .NET back-end
and I think it won't work with the Java back-end either (does
java.lang.Runtime.exec() use the shell to invoke the command,
or does it use the exec() system call directly?).

It would be better to use io__get_environment_variable to get the previous
value.  (Only a little better, since io__get_environment_variable is itself
not completely portable, but still...)

Otherwise that looks fine.

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
The University of Melbourne         |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list