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

James Goddard goddardjames at yahoo.com
Thu Feb 19 13:30:43 AEDT 2004


Estimated hours taken: 1
Branches: main

Fix a Java CLASSPATH-related bug.

compiler/compile_target_code.m:
	Prepend the current CLASSPATH when setting the new classpath, so as to
	preserve the accumulating nature of the variable.  Otherwise, setting
	the CLASSPATH environmental variable will be overridden by the mercury
	classpath, if it is present.


Index: compile_target_code.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/compile_target_code.m,v
retrieving revision 1.53
diff -u -d -r1.53 compile_target_code.m
--- compile_target_code.m	19 Feb 2004 00:58:28 -0000	1.53
+++ 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, " "]) },
+
 	globals__io_lookup_bool_option(target_debug, Target_Debug),
 	{ Target_Debug = yes ->
 		Target_DebugOpt = "-g "
@@ -710,7 +708,7 @@
 
 	% Be careful with the order here!  Some options may override others.
 	% Also be careful that each option is separated by spaces.
-	{ string__append_list([JavaCompiler, " ", InclOpt, DestDir,
+	{ string__append_list([SetCP, JavaCompiler, " ", DestDir,
 		Target_DebugOpt, JAVAFLAGS, " ", JavaFile], Command) },
 	invoke_system_command(ErrorStream, verbose_commands,
 		Command, Succeeded).
--------------------------------------------------------------------------
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