summaryrefslogtreecommitdiff
path: root/sources
diff options
context:
space:
mode:
authorpaltherr <paltherr@epfl.ch>2004-09-15 16:03:54 +0000
committerpaltherr <paltherr@epfl.ch>2004-09-15 16:03:54 +0000
commiteed5ff3582546afc17f2f7ed0c5ec99a0f642c6d (patch)
tree175f1447c32026da7e768db1f16d219bed6ba66d /sources
parent2cbdc0ba3b93ed6dc7ed85758ce34ee8e020fb74 (diff)
downloadscala-eed5ff3582546afc17f2f7ed0c5ec99a0f642c6d.tar.gz
scala-eed5ff3582546afc17f2f7ed0c5ec99a0f642c6d.tar.bz2
scala-eed5ff3582546afc17f2f7ed0c5ec99a0f642c6d.zip
- Changed scala_wrapper so that tools are run a...
- Changed scala_wrapper so that tools are run as normal scala programs - Added support for SCALA_SOURCEPATH & SCALA_EXTDIRS Added properties - "scala.library.source.path" & "scala.library.class.path" Improved - computation of default bootclasspath Changed scalap to used ClassPath - from scala.tools.util
Diffstat (limited to 'sources')
-rw-r--r--sources/bin/.scala_wrapper.tmpl585
-rw-r--r--sources/scala/tools/scaladoc/HTMLGeneratorCommand.java2
-rw-r--r--sources/scala/tools/scalap/AbstractFile.scala270
-rw-r--r--sources/scala/tools/scalap/ClassPath.scala185
-rw-r--r--sources/scala/tools/scalap/FileCache.scala42
-rw-r--r--sources/scala/tools/scalap/Main.scala17
-rw-r--r--sources/scala/tools/util/ClassPath.java65
-rw-r--r--sources/scalac/CompilerCommand.java8
8 files changed, 371 insertions, 803 deletions
diff --git a/sources/bin/.scala_wrapper.tmpl b/sources/bin/.scala_wrapper.tmpl
index 0769dda3a9..7bf24be40d 100644
--- a/sources/bin/.scala_wrapper.tmpl
+++ b/sources/bin/.scala_wrapper.tmpl
@@ -14,63 +14,71 @@
# Configuration
# The configure function contains all the configurable variables of
-# this script. The content of these variables may be overridden by
-# defining an environment variable with the same name prefixed by
-# SCALA_. For example, to run socos with a big initial heap size, one
-# may run the command "env SCALA_JAVA_ARGS=-Xms1024m socos".
+# this script. Each of these variables may be overridden by defining
+# an environment variable with the same but where the "default_" has
+# been replaced by "SCALA_". For example, to start scalaint with a big
+# initial heap size, one may run the following command:
+#
+# env SCALA_SCALA_ARGS=-Xms1024m scalaint".
+#
+# These variables must use the Unix form for paths and path lists
+# (i.e. use '/' as file separator and ':' as path separator). There
+# are two exceptions: JAVA_ARGS and SCALA_ARGS which must use the
+# paltform-specific form.
#
# The following environment variables are also read by this script:
-# - SCALA_BOOTCLASSPATH: if defined, it is used as the default
-# bootclasspath by the Scala compiler.
#
# - SCALA_CLASSPATH: if defined, it is used as the default classpath
-# by the scala compiler.
+# by all Scala tools.
+#
+# - CLASSPATH: if defined and SCALA_CLASSPATH is undefined, it is used
+# as the default classpath by all Scala tools.
+#
+# - SCALA_SOURCEPATH: if defined, it is used as the default sourcepath
+# by all Scala tools.
+#
+# - SCALA_BOOTCLASSPATH: if defined, it is used as the default
+# bootclasspath by all Scala tools.
#
-# - CLASSPATH: if defined and if SCALA_CLASSPATH is undefined, it is
-# used as the default classpath by the Scala compiler.
+# - SCALA_EXTDIRS: if defined, it is used as the default extdirs by
+# all Scala tools.
#
-# All paths and path lists must be in Unix form (i.e. use '/' as file
-# separator and ':' as path separator). There is only one exception to
-# this rule: CLASSPATH must be in Windows form (i.e. use '\' and ';')
-# on Windows platforms.
+# These variables must use the platform-specific form for paths and
+# path lists.
configure() {
- # Location of the Scala library sources. These sources are
- # included in the Scala distribution.
- # This variable must refer a directory.
- RUNTIME_SOURCES={#RUNTIME_SOURCES#};
+ # Location of the Scala library sources.
+ default_LIBRARY_SOURCES={#LIBRARY_SOURCES#};
- # Location of the compiled Scala library. This library is included
- # in the Scala distribution.
- # This variable must refer a directory or a zip or jar file.
- RUNTIME_CLASSES={#RUNTIME_CLASSES#};
+ # Location of the Scala library.
+ default_LIBRARY_CLASSES={#LIBRARY_CLASSES#};
- # Location of the compiled Scala tools. These tools are included
- # in the Scala distribution.
- # This variable must refer a directory or a zip or jar file.
- TOOLS_CLASSES={#TOOLS_CLASSES#};
+ # Location of the Scala tools library.
+ default_TOOLS_CLASSES={#TOOLS_CLASSES#};
- # Location of the compiled fjbg library. This library is included
- # in the Scala distribution.
- # This variable must refer a directory or a zip or jar file.
- FJBG_CLASSES={#FJBG_CLASSES#};
+ # Location of the FJBG library.
+ default_FJBG_CLASSES={#FJBG_CLASSES#};
- # Location of the compiled msil library. This library is included
- # in the Scala distribution.
- # This variable must refer a directory or a zip or jar file.
- MSIL_CLASSES={#MSIL_CLASSES#};
+ # Location of the MSIL library.
+ default_MSIL_CLASSES={#MSIL_CLASSES#};
# Command to start the Java VM.
- JAVA_EXEC="java";
+ default_JAVA_CMD={#JAVA_CMD#};
# Additional arguments to pass to the Java VM.
- JAVA_ARGS={#JAVA_ARGS#};
+ default_JAVA_ARGS={#JAVA_ARGS#};
+
+ # Command to start the Scala VM.
+ default_SCALA_CMD={#SCALA_CMD#};
+
+ # Additional arguments to pass to the Scala VM.
+ default_SCALA_ARGS={#SCALA_ARGS#};
# Command to start subprocesses. This is mainly for debugging
- # purposes. One may, for example, display the Java command that is
- # started by "socos", by running "env SCALA_EXEC=echo socos".
- EXEC="exec";
+ # purposes. For example, one may display the Java command that is
+ # started by "scala", by running "env SCALA_EXEC=echo scala".
+ default_EXEC="exec";
}
@@ -96,7 +104,7 @@ abort() {
##############################################################################
# File name and path list conversion functions
-# Prints the OS specific form of the given Unix form file name.
+# Prints the OS-specific form of the specified Unix form file name.
get_os_filename() {
[ $# = 1 ] || abort "internal error";
case "$UNAME" in
@@ -105,7 +113,7 @@ get_os_filename() {
esac;
}
-# Prints the OS specific form of the given Unix form path list.
+# Prints the Unix form of the specified OS-specific form file name.
get_unix_filename() {
[ $# = 1 ] || abort "internal error";
case "$UNAME" in
@@ -114,7 +122,7 @@ get_unix_filename() {
esac;
}
-# Prints the Unix form of the given OS specific form file name.
+# Prints the OS-specific form of the specified Unix form path list.
get_os_pathlist() {
[ $# = 1 ] || abort "internal error";
case "$UNAME" in
@@ -123,7 +131,7 @@ get_os_pathlist() {
esac;
}
-# Prints the Unix form of the given OS specific form path list.
+# Prints the Unix form of the specified OS-specific form path list.
get_unix_pathlist() {
[ $# = 1 ] || abort "internal error";
case "$UNAME" in
@@ -133,331 +141,354 @@ get_unix_pathlist() {
}
##############################################################################
-# Variable configuration functions
+# Path list construction functions
-# Configures the variable with the given name. If a variable named
-# SCALA_$1 is defined, assigns its value to the variable named $1,
-# otherwise does nothing.
-configure_variable() {
- [ $# = 1 ] || abort "internal error";
+# Prints the concatenation of two path lists.
+append_pathlists() {
+ [ $# = 2 ] || abort "internal error";
- if set | grep "^SCALA_$1=" > /dev/null; then
- eval $1=\$SCALA_$1;
+ if [ -z "$1" ]; then
+ echo "$2";
+ elif [ -z "$2" ]; then
+ echo "$1";
+ else
+ echo "$1:$2";
fi;
}
-# Configures and tests the path variable with the given name. If a
-# variable named SCALA_$1 is defined and refers an existing directory
-# or file, assigns its value to the variable named $1. If, after that,
-# the variable $1 refers a non-existing path, exits with an error.
-configure_path_variable() {
+##############################################################################
+# Value computation functions
+
+# Computes and stores the value "$1" in the variable "current_$1". If
+# the variable "SCALA_$1" is defined, its content is used. Otherwise,
+# the content of the variable "default_$1" is used.
+compute_value() {
[ $# = 1 ] || abort "internal error";
- if set | grep "^SCALA_$1=" > /dev/null; then
- path=`eval echo \\\$SCALA_\$1`;
- if [ -f "$path" -o -d "$path" ]; then
- eval $1=\$SCALA_$1;
- else
- warning "File refered by SCALA_$1 ($path) does not exist.";
- unset SCALA_$1;
- fi;
- fi;
+ eval current_$1=\"\$default_$1\";
+ case "$1" in
+
+ LIBRARY_SOURCES | \
+ LIBRARY_CLASSES | \
+ TOOLS_CLASSES | \
+ FJBG_CLASSES | \
+ MSIL_CLASSES )
+ if eval [ -n \"\$SCALA_$1\" ]; then
+ if eval [ -f \"\$SCALA_$1\" -o -d \"\$SCALA_$1\" ]; then
+ eval current_$1=\"\$SCALA_$1\";
+ else
+ eval warning \""File referred by SCALA_$1 (\$SCALA_$1)" \
+ "does not exist, using default value instead."\";
+ unset SCALA_$1;
+ fi;
+ fi;
+ if ! eval [ -f \"\$current_$1\" -o -d \"\$current_$1\" ]; then
+ eval abort \""File referred by default_$1 (\$default_$1)" \
+ "does not exist. Please, fix definition of default_$1 in" \
+ "file $SOURCE or define environment variable SCALA_$1."\";
+ fi;
+ ;;
+
+ JAVA_CMD | \
+ JAVA_ARGS | \
+ SCALA_CMD | \
+ SCALA_ARGS | \
+ EXEC )
+ if eval [ -n \"\$SCALA_$1\" ]; then
+ eval current_$1=\"\$SCALA_$1\";
+ fi;
+ ;;
+
+ * )
+ abort "internal error: $1";
+ ;;
- path=`eval echo \\\$\$1`;
- if [ ! -f "$path" -a ! -d "$path" ]; then
- abort "File referred by $1 ($path) does not exist." \
- "Please, fix the definition of $1 in file $SOURCE." \
- "Alternatively you may also define the environment" \
- "variable SCALA_$1.";
- fi
+ esac;
}
##############################################################################
-# Path list construction functions
+# Default paths
+
+# Prints the default scala classpath or nothing if it's unspecified.
+get_scala_classpath() {
+ if [ -n "$SCALA_CLASSPATH" ]; then
+ get_unix_pathlist "$SCALA_CLASSPATH";
+ elif [ -n "$CLASSPATH" ]; then
+ get_unix_pathlist "$CLASSPATH";
+ fi;
+}
-# Prepends a named path to a named path list. First, computes variable
-# $2 and then updates the path list in variable $1 by appending the
-# path from variable $2.
-prepend_path() {
- [ $# = 2 ] || abort "internal error";
+# Prints the default scala sourcepath or nothing if it's unspecified.
+get_scala_sourcepath() {
+ if [ -n "$SCALA_SOURCEPATH" ]; then
+ get_unix_pathlist "$SCALA_SOURCEPATH";
+ fi;
+}
- compute_variable "$2";
+# Prints the default scala bootclasspath or nothing if it's unspecified.
+get_scala_bootclasspath() {
+ if [ -n "$SCALA_BOOTCLASSPATH" ]; then
+ get_unix_pathlist "$SCALA_BOOTCLASSPATH";
+ fi;
+}
- if [ -z "`eval echo \\\$\$1`" ]; then
- eval $1=\$$2;
- else
- eval $1=\$$2:\$$1;
+# Prints the default scala extdirs or nothing if it's unspecified.
+get_scala_extdirs() {
+ if [ -n "$SCALA_EXTDIRS" ]; then
+ get_unix_pathlist "$SCALA_EXTDIRS";
fi;
}
##############################################################################
-# Variable computation functions
+# VM invocation functions
-# Sets SCALA_CLASSPATH to its default value.
-compute_default_scala_classpath() {
- SCALA_CLASSPATH=".";
+# Prints the VM script-suffix-specific arguments.
+vm_get_script_suffix_args() {
+ case "$SCRIPT" in
+ *-debug* ) echo "-Djava.compiler=NONE -ea";;
+ esac;
}
-# Computes SCALA_CLASSPATH.
-compute_scala_classpath() {
- if [ -z "$SCALA_CLASSPATH" ]; then
- if [ -n "$CLASSPATH" ]; then
- SCALA_CLASSPATH=`get_unix_pathlist "$CLASSPATH"`;
- else
- compute_default_scala_classpath;
- fi;
- fi;
-}
+# Starts a Java VM with the specified arguments.
+vm_start_java() {
+ # compute values
+ compute_value EXEC;
+ compute_value JAVA_CMD;
+ compute_value JAVA_ARGS;
-# Sets SCALA_BOOTCLASSPATH to its default value.
-compute_default_scala_bootclasspath() {
- eval SCALA_BOOTCLASSPATH="";
- prepend_path SCALA_BOOTCLASSPATH RUNTIME_SOURCES;
- prepend_path SCALA_BOOTCLASSPATH RUNTIME_CLASSES;
+ # start Java VM
+ $current_EXEC $current_JAVA_CMD $current_JAVA_ARGS \
+ `vm_get_script_suffix_args` "$@";
}
+# Starts a Scala VM with the specified arguments.
+vm_start_scala() {
+ # compute values
+ compute_value EXEC;
+ compute_value SCALA_CMD;
+ compute_value SCALA_ARGS;
-# Computes SCALA_BOOTCLASSPATH.
-compute_scala_bootclasspath() {
- if [ -z "$SCALA_BOOTCLASSPATH" ]; then
- compute_default_scala_bootclasspath;
- fi;
+ # start Java VM
+ $current_EXEC $current_SCALA_CMD $current_SCALA_ARGS \
+ `vm_get_script_suffix_args` "$@";
}
-# Computes variable $1.
-compute_variable() {
- [ $# = 1 ] || abort "internal error";
+##############################################################################
+# Scala invocation functions
- case "$1" in
- SCALA_CLASSPATH ) compute_scala_classpath;;
- SCALA_BOOTCLASSPATH ) compute_scala_bootclasspath;;
- RUNTIME_SOURCES ) configure_path_variable "$1";;
- RUNTIME_CLASSES ) configure_path_variable "$1";;
- TOOLS_CLASSES ) configure_path_variable "$1";;
- FJBG_CLASSES ) configure_path_variable "$1";;
- MSIL_CLASSES ) configure_path_variable "$1";;
- JAVA_EXEC ) configure_variable "$1";;
- JAVA_ARGS ) configure_variable "$1";;
- EXEC ) configure_variable "$1";;
- esac;
+# Returns true if the given arguments contain a flag -Xbootclasspath.
+scala_has_bootclasspath() {
+ while [ $# != 0 ]; do
+ case "$1" in
+ -Xbootclasspath:* ) return 0;;
+ -cp | -classpath ) shift 2;;
+ -jar ) return 1;;
+ -* ) shift 1;;
+ * ) return 1;;
+ esac;
+ done;
+ return 1;
+}
+
+# Implements the command "scala".
+scala() {
+ if scala_has_bootclasspath "$@"; then
+ vm_start_java "$@";
+ else
+ compute_value LIBRARY_CLASSES;
+ classes="$current_LIBRARY_CLASSES";
+ vm_start_java "-Xbootclasspath/a:`get_os_filename "$classes"`" "$@";
+ fi;
}
##############################################################################
-# Java invocation functions
+# Tool invocation functions
-# Starts a Java program with the given arguments and the following
-# additional ones:
-# - arguments specified by the variable JAVA_ARGS
-# - script-suffix-specific arguments
-exec_java() {
- [ $# -gt 0 ] || abort "internal error";
+# Starts a Scala tool. The first argument is added to the runtime
+# classpath. The following ones are passed to vm_start_scala. They
+# must, at least, contain the name of the main class.
+tool_start() {
+ [ $# -gt 1 ] || abort "internal error";
+ classpath="$1"; shift 1;
- # configure variables
- compute_variable EXEC;
- compute_variable JAVA_EXEC;
- compute_variable JAVA_ARGS;
+ # compute value
+ compute_value LIBRARY_SOURCES;
+ compute_value LIBRARY_CLASSES;
+ compute_value TOOLS_CLASSES;
- # append script-suffix-specific arguments
- case "$SCRIPT" in
- *-debug* ) JAVA_ARGS="$JAVA_ARGS -Djava.compiler=NONE -ea";;
- esac;
+ # append tools library to classpath
+ classpath=`append_pathlists "$classpath" "$current_TOOLS_CLASSES"`;
- # invoke Java
- $EXEC $JAVA_EXEC $JAVA_ARGS "$@";
+ # start Scala VM
+ tool_start0 -classpath "`get_os_pathlist "$classpath"`" "$@";
}
-# Starts a Scala tool. The first argument must be either "java" or
-# "scala". It tells whether the tool is written in Java or Scala. The
-# following arguments are passed to exec_java. They must, at least,
-# contain the name of the main class.
-exec_tool() {
- [ $# -gt 1 ] || abort "internal error";
- language="$1"; shift 1;
-
- # augment Java classpath
- prepend_path JAVA_CLASSPATH TOOLS_CLASSES;
- case "$language" in
- java ) true;;
- scala ) prepend_path JAVA_CLASSPATH RUNTIME_CLASSES;;
- * ) abort "internal error: found language='$language'";;
- esac;
+tool_start0() {
+ if [ -n "`get_scala_extdirs`" ]; then
+ tool_start1 -Dscala.ext.dirs="`get_scala_extdirs`" "$@";
+ else
+ tool_start1 "$@";
+ fi;
+}
- # invoke Java
- exec_java \
- -classpath "`get_os_pathlist "$JAVA_CLASSPATH"`" \
- -Dscala.home="$PREFIX" \
- -Dscala.product="$SCRIPT" \
- -Dscala.version="$VERSION" \
- "$@";
+tool_start1() {
+ if [ -n "`get_scala_bootclasspath`" ]; then
+ tool_start2 -Dscala.boot.class.path="`get_scala_bootclasspath`" "$@";
+ else
+ tool_start2 "$@";
+ fi;
}
-# Starts a Scala compile tool (one that uses properties
-# scala.class.path and scala.boot.class.path). The first argument must
-# be either "java" or "scala". It tells whether the tool is written in
-# Java or Scala. The following arguments are passed to exec_java. They
-# must, at least, contain the name of the main class.
-exec_compile_tool() {
- [ $# -gt 1 ] || abort "internal error";
- language="$1"; shift 1;
+tool_start2() {
+ if [ -n "`get_scala_sourcepath`" ]; then
+ tool_start3 -Dscala.source.path="`get_scala_sourcepath`" "$@";
+ else
+ tool_start3 "$@";
+ fi;
+}
- # compute Scala classpath and bootclasspath
- compute_scala_classpath;
- compute_scala_bootclasspath;
+tool_start3() {
+ if [ -n "`get_scala_classpath`" ]; then
+ tool_start4 -Dscala.class.path="`get_scala_classpath`" "$@";
+ else
+ tool_start4 "$@";
+ fi;
+}
- # invoke Java
- exec_tool "$language" \
- -Dscala.class.path=`get_os_pathlist "$SCALA_CLASSPATH"` \
- -Dscala.boot.class.path=`get_os_pathlist "$SCALA_BOOTCLASSPATH"` \
+tool_start4() {
+ sources="$current_LIBRARY_SOURCES";
+ classes="$current_LIBRARY_CLASSES";
+ vm_start_scala \
+ -Dscala.product="$SCRIPT" \
+ -Dscala.version="$VERSION" \
+ -Dscala.home="$PREFIX" \
+ -Dscala.library.source.path="`get_os_filename "$sources"`" \
+ -Dscala.library.class.path="`get_os_filename "$classes"`" \
"$@";
}
-# Starts a Scala compiler. The first argument must be either "java" or
-# "scala". It tells whether the tool is written in Java or Scala. The
-# following arguments are passed to exec_java. They must, at least,
-# contain the name of the main class.
-exec_compiler() {
+##############################################################################
+# Compiler invocation functions
+
+# Starts a Scala compiler. The first argument is added to the runtime
+# classpath. The following ones are passed to vm_start_scala. They
+# must, at least, contain the name of the main class.
+compiler_start() {
[ $# -gt 1 ] || abort "internal error";
- language="$1"; shift 1;
+ classpath="$1"; shift 1;
- # augment Java classpath
- prepend_path JAVA_CLASSPATH MSIL_CLASSES;
- prepend_path JAVA_CLASSPATH FJBG_CLASSES;
+ # compute values
+ compute_value FJBG_CLASSES;
+ compute_value MSIL_CLASSES;
- exec_compile_tool "$language" "$@";
+ # append FJBG and MSIL libraries to classpath
+ classpath=`append_pathlists "$classpath" "$current_FJBG_CLASSES"`;
+ classpath=`append_pathlists "$classpath" "$current_MSIL_CLASSES"`;
+
+ # start tool
+ tool_start "$classpath" "$@";
}
##############################################################################
# Implementation of scala-info
# Prints given error message, prints usage and exits with error code 1.
-scala_info_abort() {
+info_abort() {
error "$@";
- scala_info_print_usage 1>&2;
+ info_print_usage 1>&2;
exit 1;
}
-# Prints value of $1.
-scala_info_print_variable() {
+# Prints value of variable $1.
+info_print_variable() {
[ $# = 1 ] || abort "internal error";
eval echo \"\$$1\";
}
-# Prints default value of $1.
-scala_info_print_variable_default() {
+# Prints default value of value $1.
+info_print_default_value() {
[ $# = 1 ] || abort "internal error";
- case "$1" in
- SCALA_CLASSPATH ) compute_default_scala_classpath;;
- SCALA_BOOTCLASSPATH ) compute_default_scala_bootclasspath;;
- esac;
- scala_info_print_variable "$1";
+ info_print_variable "default_$1";
}
-# Prints current value of $1.
-scala_info_print_variable_current() {
+# Prints current value of value $1.
+info_print_current_value() {
[ $# = 1 ] || abort "internal error";
- compute_variable "$1";
- scala_info_print_variable "$1";
+ compute_value "$1";
+ info_print_variable "current_$1";
}
# Implements "scala-info --home".
-scala_info_option_home() {
+info_option_home() {
[ $# -gt 0 ] && abort "too many arguments";
echo "$PREFIX";
}
# Implements "scala-info --version".
-scala_info_option_version() {
+info_option_version() {
[ $# -gt 0 ] && abort "too many arguments";
echo "$VERSION";
}
-# Implements "scala-info --$1 <variable>"
-scala_info_option_x_variable() {
- [ $# -lt 2 ] && abort "missing variable name";
+# Implements "scala-info --$1 <value>"
+info_option_x_value() {
+ [ $# -lt 2 ] && abort "missing value name";
[ $# -gt 2 ] && abort "too many arguments";
case "$2" in
- CLASSPATH ) variable=SCALA_$2;;
- BOOTCLASSPATH ) variable=SCALA_$2;;
- RUNTIME_SOURCES ) variable=$2;;
- RUNTIME_CLASSES ) variable=$2;;
- TOOLS_CLASSES ) variable=$2;;
- FJBG_CLASSES ) variable=$2;;
- MSIL_CLASSES ) variable=$2;;
- JAVA_EXEC ) variable=$2;;
- JAVA_ARGS ) variable=$2;;
- EXEC ) variable=$2;;
- * ) abort "Unknown variable \`$2'";;
+ LIBRARY_SOURCES ) value=$2;;
+ LIBRARY_CLASSES ) value=$2;;
+ TOOLS_CLASSES ) value=$2;;
+ FJBG_CLASSES ) value=$2;;
+ MSIL_CLASSES ) value=$2;;
+ JAVA_CMD ) value=$2;;
+ JAVA_ARGS ) value=$2;;
+ SCALA_CMD ) value=$2;;
+ SCALA_ARGS ) value=$2;;
+ EXEC ) value=$2;;
+ * ) abort "Unknown value \`$2'";;
esac;
- scala_info_print_variable_$1 $variable;
+ info_print_$1_value $value;
}
# Implements "scala-info --help".
-scala_info_option_help() {
+info_option_help() {
echo "usage: $0 <option>";
echo "where possible options include:";
- echo " --home Print Scala home directory";
- echo " --version Print Scala version";
- echo " --default <variable> Print default value of variable";
- echo " --current <variable> Print current value of variable";
- echo " -? --help Print this help message";
+ echo " --home Print Scala home directory";
+ echo " --version Print Scala version";
+ echo " --default <name> Print default value of value <name>";
+ echo " --current <name> Print current value of value <name>";
+ echo " -? --help Print this help message";
echo "";
- echo "valid variables include:";
- echo " CLASSPATH Default classpath";
- echo " BOOTCLASSPATH Default bootclasspath";
- echo " RUNTIME_SOURCES Location of the Scala library sources";
- echo " RUNTIME_CLASSES Location of the Scala library";
- echo " TOOLS_CLASSES Location of the Scala tools";
- echo " FJBG_CLASSES Location of the fjbg library";
- echo " MSIL_CLASSES Location of the msil library";
- echo " JAVA_EXEC Command to start the Java VM";
- echo " JAVA_ARGS Additional arguments to pass to the Java VM";
- echo " EXEC Command to start subprocesses";
+ echo "valid value names include:";
+ echo " LIBRARY_SOURCES Location of the Scala library sources";
+ echo " LIBRARY_CLASSES Location of the Scala library";
+ echo " TOOLS_CLASSES Location of the Scala tools";
+ echo " FJBG_CLASSES Location of the fjbg library";
+ echo " MSIL_CLASSES Location of the msil library";
+ echo " JAVA_CMD Command to start the Java VM";
+ echo " JAVA_ARGS Additional arguments to pass to the Java VM";
+ echo " SCALA_CMD Command to start the Scala VM";
+ echo " SCALA_ARGS Additional arguments to pass to the Scala VM";
+ echo " EXEC Command to start subprocesses";
}
# Entry point of scala-info.
-scala_info() {
+info() {
[ $# = 0 ] && abort "missing option";
case "$1" in
- --home ) shift 1; scala_info_option_home "$@";;
- --version ) shift 1; scala_info_option_version "$@";;
- --default ) shift 1; scala_info_option_x_variable default "$@";;
- --current ) shift 1; scala_info_option_x_variable current "$@";;
- -? | --help ) shift 1; scala_info_option_help "$@";;
+ --home ) shift 1; info_option_home "$@";;
+ --version ) shift 1; info_option_version "$@";;
+ --default ) shift 1; info_option_x_value default "$@";;
+ --current ) shift 1; info_option_x_value current "$@";;
+ -? | --help ) shift 1; info_option_help "$@";;
-* ) abort "unrecognised option \`$1'";;
* ) abort "illegal argument \`$1'";;
esac;
}
##############################################################################
-# Implementation of scala
-
-# Returns true if the given arguments contain a Xbootclasspath: flag.
-scala_has_bootclasspath() {
- while [ $# != 0 ]; do
- case "$1" in
- -Xbootclasspath:* ) return 0;;
- -cp | -classpath ) shift 2;;
- -jar ) return 1;;
- -* ) shift 1;;
- * ) return 1;;
- esac;
- done;
- return 1;
-}
-
-# Entry point of scala-info.
-scala() {
- compute_variable EXEC;
- if scala_has_bootclasspath "$@"; then
- exec_java "$@";
- else
- compute_variable RUNTIME_CLASSES;
- exec_java "-Xbootclasspath/a:$RUNTIME_CLASSES" "$@";
- fi;
-}
-
-##############################################################################
# Definition of UNAME, SOURCE, SCRIPT, PREFIX and VERSION
unset SCRIPT;
@@ -490,19 +521,19 @@ fi;
##############################################################################
# Configuration and invocation of $SCRIPT
-unset JAVA_CLASSPATH;
configure;
case "$SCRIPT" in
+ scala-info ) info "$@";;
scala ) scala "$@";;
- scala-info ) scala_info "$@";;
- scalac* ) exec_compiler scala scala.tools.scalac.Main "$@";;
- scalarun* ) exec_compiler scala scala.tools.scalai.Main "$@";;
- scalaint* ) exec_compiler scala scala.tools.scalai.Main -interactive "$@";;
- scaladoc* ) exec_compile_tool scala scala.tools.scaladoc.Main "$@";;
- scalap* ) exec_compile_tool scala scala.tools.scalap.Main "$@";;
- dtd2scala* ) exec_tool scala scala.tools.dtd2scala.Main "$@";;
- scalatest* ) exec_tool java scala.tools.scalatest.Main "$@";;
+ scala-* ) scala "$@";;
+ scalac* ) compiler_start "" scala.tools.scalac.Main "$@";;
+ scalarun* ) compiler_start "" scala.tools.scalai.Main "$@";;
+ scalaint* ) compiler_start "" scala.tools.scalai.Main -interactive "$@";;
+ scaladoc* ) tool_start "" scala.tools.scaladoc.Main "$@";;
+ scalap* ) tool_start "" scala.tools.scalap.Main "$@";;
+ dtd2scala* ) tool_start "" scala.tools.dtd2scala.Main "$@";;
+ scalatest* ) tool_start "" scala.tools.scalatest.Main "$@";;
* ) abort "Don't know what to do for $SCRIPT.";;
esac;
diff --git a/sources/scala/tools/scaladoc/HTMLGeneratorCommand.java b/sources/scala/tools/scaladoc/HTMLGeneratorCommand.java
index bdf6b672da..dc4fab3015 100644
--- a/sources/scala/tools/scaladoc/HTMLGeneratorCommand.java
+++ b/sources/scala/tools/scaladoc/HTMLGeneratorCommand.java
@@ -96,7 +96,7 @@ public class HTMLGeneratorCommand extends CompilerCommand {
"docmodulepath",
"Specify where to find doc module class files",
"path",
- ClassPath.CLASSPATH);
+ ClassPath.DEFAULT_CLASSPATH);
this.doctitle = new StringOptionParser(this,
"doctitle",
diff --git a/sources/scala/tools/scalap/AbstractFile.scala b/sources/scala/tools/scalap/AbstractFile.scala
deleted file mode 100644
index bf959ee2af..0000000000
--- a/sources/scala/tools/scalap/AbstractFile.scala
+++ /dev/null
@@ -1,270 +0,0 @@
-/* ___ ____ ___ __ ___ ___
-** / _// __// _ | / / / _ | / _ \ Scala classfile decoder
-** __\ \/ /__/ __ |/ /__/ __ |/ ___/ (c) 2003, LAMP/EPFL
-** /____/\___/_/ |_/____/_/ |_/_/
-**
-** $Id$
-*/
-
-package scala.tools.scalap;
-
-import scala.collection._;
-import java.io._;
-import java.util.jar._;
-
-
-trait AbstractFile {
-
- /** separator
- */
- protected val separator: Char = File.separatorChar;
-
- /** get name of the file
- */
- def getName: String;
-
- /** get path of the file
- */
- def getPath: String;
-
- /** does the file exist?
- */
- def exists: Boolean;
-
- /** is the file a directory?
- */
- def isDirectory: Boolean;
-
- /** read content of the file into a byte[] buffer
- */
- def content: Array[Byte];
-
- /** list contents of a directory
- */
- def elements: Iterator[String];
-
- /** open a new file
- */
- def open(name: String): AbstractFile;
-
- /** return an input stream for the file
- */
- def getInputStream: InputStream = new ByteArrayInputStream(content);
-}
-
-class PlainFile(f: File) with AbstractFile {
-
- def getName = f.getName();
-
- def getPath = f.getPath();
-
- def exists = f.exists();
-
- def isDirectory = f.isDirectory();
-
- def content = {
- val in = new FileInputStream(f);
- var rest = f.length().asInstanceOf[Int];
- val buf = new Array[Byte](rest);
- do {
- val res = in.read(buf, buf.length - rest, rest);
- if (res == -1)
- error("read error");
- rest = rest - res;
- } while (rest > 0);
- in.close();
- buf;
- }
-
- def elements = {
- val fs = f.listFiles();
- if (fs == null)
- Iterator.empty[String]
- else
- new Iterator[String] {
- var i = 0;
- def hasNext = (i < fs.length);
- def next = {
- val res = fs(i).getName();
- i = i + 1;
- if (fs(i - 1).isDirectory() &&
- !res.endsWith("/")) res + "/" else res;
- }
- }
- }
-
- def open(name: String) = new PlainFile(new File(f, name));
-}
-
-class JarArchive(f: File) with AbstractFile {
- val jarFile = try { new JarFile(f) } catch { case e => null };
- var entries: mutable.Map[String, JarArchiveEntry] = _;
-
- def getName = f.getName();
-
- def getPath = f.getPath();
-
- def exists = (jarFile != null);
-
- def isDirectory = (jarFile != null);
-
- def content: Array[Byte] = error("cannot read archive");
-
- private def load = {
- //entries = new mutable.HashMap[String, JarArchiveEntry];
- entries = new mutable.JavaMapAdaptor(new java.util.HashMap());
- if (jarFile != null) {
- val enum = jarFile.entries();
- while (enum.hasMoreElements()) {
- val candidate = enum.nextElement().asInstanceOf[JarEntry].getName();
- var i = candidate.indexOf('/');
- var j = 0;
- var files = entries;
- while (i >= 0) {
- val dirname = candidate.substring(j, i + 1);
- j = i + 1;
- if (!files.isDefinedAt(dirname))
- files(dirname) = new JarDirEntry(candidate.substring(0, j));
- files = files(dirname).entries;
- i = candidate.indexOf('/', j);
- }
- if (j < (candidate.length() - 1)) {
- val filename = candidate.substring(j);
- if (!files.isDefinedAt(filename))
- files(filename) = new JarFileEntry(candidate);
- }
- }
- }
- }
-
- def list(prefix: String) = {
- val pref = prefix.replace(File.separatorChar, '/');
- if (entries == null)
- load;
- var i = pref.indexOf('/');
- var j = 0;
- var files = entries;
- var continue = true;
- while (continue && (i >= 0)) {
- val dirname = pref.substring(j, i + 1);
- j = i + 1;
- continue = files.isDefinedAt(dirname);
- if (continue) {
- files = files(dirname).entries;
- i = pref.indexOf('/', j);
- }
- }
- if (!continue)
- Iterator.empty;
- else if (j < (pref.length() - 1)) {
- if (files.isDefinedAt(pref.substring(j)))
- List(pref).elements;
- else
- Iterator.empty;
- } else
- files.keys;
- }
-
- def elements = list("");
-
- def open(fname: String) = {
- if (entries == null)
- load;
- val name = fname.replace(File.separatorChar, '/');
- var i = name.indexOf('/');
- var j = 0;
- var namelen = name.length();
- var files = entries;
- var res: AbstractFile = null;
- while ((res == null) && (i >= 0)) {
- val dirname = name.substring(j, i + 1);
- j = i + 1;
- if (files != null) {
- if (files.isDefinedAt(dirname)) {
- if (j == namelen)
- res = files(dirname);
- else
- files = files(dirname).entries;
- } else
- files = null;
- }
- i = name.indexOf('/', j);
- }
- if (res != null)
- res
- else if (j < (namelen - 1)) {
- if (files == null)
- new JarArchiveEntry(name, false);
- else {
- val filename = name.substring(j);
- if (files.isDefinedAt(filename))
- files(filename)
- else
- new JarArchiveEntry(name, false)
- }
- } else
- new JarArchiveEntry(name, true);
- }
-
- class JarArchiveEntry(name: String, dir: Boolean) with AbstractFile {
-
- def getName = name.substring(
- name.lastIndexOf('/', name.length() - (if (dir) 2 else 1)) + 1);
-
- def getPath = name;
-
- def getFullName = name;
-
- def exists = false;
-
- def isDirectory = dir;
-
- def elements: Iterator[String] = error("nothing to iterate over");
-
- def content: Array[Byte] = error("cannot read archive");
-
- def open(n: String): AbstractFile = error("cannot open archive entry");
-
- def entries: mutable.Map[String, JarArchiveEntry] = error("no entries");
- }
-
- final class JarDirEntry(name: String) extends JarArchiveEntry(name, true) {
- //val entr = new mutable.HashMap[String, JarArchiveEntry];
- val entr = new mutable.JavaMapAdaptor[String, JarArchiveEntry](new java.util.HashMap());
-
- override def getPath = JarArchive.this.getPath + "(" + name + ")";
-
- override def exists = true;
-
- override def elements = JarArchive.this.list(name);
-
- override def open(fname: String) = JarArchive.this.open(
- name + fname.replace(File.separatorChar, '/'));
-
- override def entries: mutable.Map[String, JarArchiveEntry] = entr;
- }
-
- final class JarFileEntry(name: String) extends JarArchiveEntry(name, false) {
-
- override def getPath = JarArchive.this.getPath + "(" + name + ")";
-
- override def exists = true;
-
- override def content: Array[Byte] = {
- val jarEntry = jarFile.getJarEntry(name);
- if (jarEntry == null)
- error("unable to read " + name);
- val in = jarFile.getInputStream(jarEntry);
- var rest = jarEntry.getSize().asInstanceOf[Int];
- val buf = new Array[Byte](rest);
- do {
- val res = in.read(buf, buf.length - rest, rest);
- if (res == -1)
- error("read error");
- rest = rest - res;
- } while (rest > 0);
- in.close();
- buf;
- }
- }
-}
diff --git a/sources/scala/tools/scalap/ClassPath.scala b/sources/scala/tools/scalap/ClassPath.scala
deleted file mode 100644
index b6999b97e9..0000000000
--- a/sources/scala/tools/scalap/ClassPath.scala
+++ /dev/null
@@ -1,185 +0,0 @@
-/* ___ ____ ___ __ ___ ___
-** / _// __// _ | / / / _ | / _ \ Scala classfile decoder
-** __\ \/ /__/ __ |/ /__/ __ |/ ___/ (c) 2003, LAMP/EPFL
-** /____/\___/_/ |_/____/_/ |_/_/
-**
-** $Id$
-*/
-
-package scala.tools.scalap;
-
-import java.io._;
-import scala.collection._;
-
-
-class ClassPath {
-
- /** the character separating files
- */
- protected val FILE_SEP = File.separator;
-
- /** the separator in class path specifications
- */
- protected val PATH_SEP = System.getProperty("path.separator");
-
- /** the default class path
- */
- val classPath = System.getProperty("scala.class.path");
-
- /** the default boot class path
- */
- val bootPath = System.getProperty("sun.boot.class.path");
-
- /** the default boot class path
- */
- val scalaBootPath = System.getProperty("scala.boot.class.path");
-
- /** the default extension path
- */
- val extensionPath = System.getProperty("java.ext.dirs");
-
- /** the corresponding file cache (for not reading .jar files over
- * and over again)
- */
- val cache = new FileCache;
-
- /** the various class path roots
- */
- protected var root: List[String] = decompose(bootPath) :::
- decompose(scalaBootPath) :::
- expand(extensionPath) :::
- decompose(classPath);
-
-
- /** append files from the extension directories
- */
- protected def expand(edirs: String): List[String] =
- if (edirs == null)
- Nil
- else {
- val extdirs = edirs + PATH_SEP;
- val length = extdirs.length();
- var i = 0;
- var path: List[String] = Nil;
- while (i < length) {
- val k = extdirs.indexOf(PATH_SEP, i);
- val dirname = extdirs.substring(i, k);
- if ((dirname != null) && (dirname.length() > 0)) {
- val iter = Iterator.fromArray(new File(dirname).list());
- val dname = if (dirname.endsWith(FILE_SEP)) dirname else dirname + FILE_SEP;
- while (iter.hasNext) {
- val entry = iter.next;
- if (entry.endsWith(".jar"))
- path = (dname + entry) :: path;
- }
- }
- i = k + 1;
- }
- path
- };
-
- /** parse a class path specification and return an array
- * of existing class file locations
- */
- protected def decompose(p: String): List[String] = {
- val path = if (p.endsWith(PATH_SEP)) p else p + PATH_SEP;
- var components: List[String] = Nil;
- var i = 0;
- while (i < path.length()) {
- val j = path.indexOf(PATH_SEP, i);
- val subpath = path.substring(i, j);
- if (new File(subpath).exists())
- components = subpath :: components;
- i = j + 1;
- }
- components.reverse;
- }
-
- /** find file with given name in class path and return an abstract
- * file representation together with the originating class path
- * component.
- */
- def findFile(name: String): Pair[AbstractFile, String] = {
- val iter = root.elements;
- var entry: AbstractFile = null;
- var continue: Boolean = true;
- var origin: String = null;
- while (continue && iter.hasNext) {
- origin = iter.next;
- entry = cache.open(origin, name);
- if (entry.exists)
- continue = false;
- }
- Pair(entry, origin)
- }
-
- /** find file with given name in class path and return an abstract
- * file representation.
- */
- def openFile(name: String): AbstractFile = findFile(name)._1;
-
- /** find class with given name in class path and return an abstract
- * file representation.
- */
- def openClass(name: String): AbstractFile =
- openFile(name.replace('.', File.separatorChar) + ".class");
-
- def elements: Iterator[String] = root.elements;
-
- def classes: Iterator[String] = new Iterator[String] {
- val todo: mutable.Stack[Pair[AbstractFile, String]] = new mutable.Stack;
- var iter: Iterator[String] = Iterator.empty;
- var file: AbstractFile = null;
- var path: String = null;
- var clazz: String = null;
- root.foreach { component => {
- val f = cache.open(component, null);
- if (f.exists && f.isDirectory)
- todo.push(Pair(f, null));
- }};
- scan;
- def hasNext = (clazz != null);
- def next =
- if (clazz == null)
- error("no next element");
- else {
- val res = clazz; scan; res
- };
- def scan: Unit = {
- if (!iter.hasNext) {
- if (todo.isEmpty)
- clazz = null;
- else {
- val Pair(f, p) = todo.top;
- todo.pop;
- iter = f.elements;
- file = f;
- path = if ((p != null) && p.endsWith("/"))
- p.substring(0, p.length() - 1) else p;
- scan;
- }
- } else {
- var continue = true;
- while (continue && iter.hasNext) {
- val g = file.open(iter.next);
- clazz = if (path == null) g.getName else path + "." + g.getName;
- if (clazz.endsWith(".class")) {
- clazz = clazz.substring(0, clazz.length() - 6);
- continue = false;
- } else if (g.exists && g.isDirectory)
- todo.push(Pair(g, clazz));
- }
- if (continue)
- scan;
- }
- }
- }
-
- /** return a textual representation of this class path
- */
- override def toString() = root match {
- case Nil => ""
- case x :: Nil => x
- case x :: xs => xs.foldLeft(x)((s, e) => s + PATH_SEP + e);
- }
-}
diff --git a/sources/scala/tools/scalap/FileCache.scala b/sources/scala/tools/scalap/FileCache.scala
deleted file mode 100644
index b0cd172447..0000000000
--- a/sources/scala/tools/scalap/FileCache.scala
+++ /dev/null
@@ -1,42 +0,0 @@
-/* ___ ____ ___ __ ___ ___
-** / _// __// _ | / / / _ | / _ \ Scala classfile decoder
-** __\ \/ /__/ __ |/ /__/ __ |/ ___/ (c) 2003, LAMP/EPFL
-** /____/\___/_/ |_/____/_/ |_/_/
-**
-** $Id$
-*/
-
-package scala.tools.scalap;
-
-import scala.collection._;
-import java.io._;
-import java.util.jar._;
-
-
-class FileCache {
-
- /** table of all opened jar-files
- */
- protected val opened: mutable.Map[String, AbstractFile] =
- //new mutable.HashMap[String, AbstractFile];
- new mutable.JavaMapAdaptor(new java.util.HashMap());
-
- def open(name: String): AbstractFile = open(null, name);
-
- /** open file 'name' in directory 'dirname'; 'name' is a path
- * relative to 'dirname'; 'dirname' might also refer to a .zip
- * or .jar file
- */
- def open(dirname: String, name: String): AbstractFile = {
- if (dirname == null)
- new PlainFile(new File(name))
- else if (dirname.endsWith(".jar")) {
- if (!opened.isDefinedAt(dirname))
- opened(dirname) = new JarArchive(new File(dirname));
- if (name == null) opened(dirname) else opened(dirname).open(name)
- } else if (name == null)
- new PlainFile(new File(dirname))
- else
- new PlainFile(new File(dirname, name))
- }
-}
diff --git a/sources/scala/tools/scalap/Main.scala b/sources/scala/tools/scalap/Main.scala
index baf675f417..347cd5d3e3 100644
--- a/sources/scala/tools/scalap/Main.scala
+++ b/sources/scala/tools/scalap/Main.scala
@@ -10,6 +10,8 @@ package scala.tools.scalap;
import java.io._;
+import scala.tools.util.ClassPath;
+
/** The main object used to execute scalap on the command-line.
*
@@ -44,16 +46,17 @@ object Main {
*/
def process(args: Arguments, path: ClassPath)(classname: String): Unit = {
// find the classfile
- val file = path.openClass(Names.encode(
+ val filename = Names.encode(
if (classname == "scala.AnyRef") "java.lang.Object"
- else classname));
+ else classname).replace('.', File.separatorChar) + ".class";
+ val file = path.getRoot().lookupPath(filename, false);
// if the classfile exists...
- if (file.exists) {
+ if (file != null) {
if (verbose)
Console.println(Console.BOLD + "FILENAME" + Console.RESET +
" = " + file.getPath);
// construct a reader for the classfile content
- val reader = new ByteArrayReader(file.content);
+ val reader = new ByteArrayReader(file.read());
// parse the classfile
val clazz = new Classfile(reader);
// check if there is a Scala signature attribute
@@ -133,10 +136,10 @@ object Main {
// construct a custom class path
val path = arguments.getArgument("-classpath") match {
case None => arguments.getArgument("-cp") match {
- case None => new ClassPath
- case Some(path) => new ClassPath { override val classPath = path }
+ case None => new ClassPath()
+ case Some(path) => new ClassPath(path)
}
- case Some(path) => new ClassPath { override val classPath = path }
+ case Some(path) => new ClassPath(path)
}
// print the classpath if output is verbose
if (verbose)
diff --git a/sources/scala/tools/util/ClassPath.java b/sources/scala/tools/util/ClassPath.java
index fee5ca435c..8df26355c8 100644
--- a/sources/scala/tools/util/ClassPath.java
+++ b/sources/scala/tools/util/ClassPath.java
@@ -24,20 +24,44 @@ public class ClassPath {
public static final String PATH_SEPARATOR =
System.getProperty("path.separator", ":");
+ /** The location of the scala library classes */
+ public static final String SCALA_LIBRARY_CLASSPATH =
+ System.getProperty("scala.library.class.path", "");
+
+ /** The location of the scala library sources */
+ public static final String SCALA_LIBRARY_SOURCEPATH =
+ System.getProperty("scala.library.source.path", "");
+
+ /** The current VM's boot class path */
+ public static final String RUNTIME_BOOTCLASSPATH =
+ System.getProperty("sun.boot.class.path", "");
+
+ /** The current VM's extension directory path */
+ public static final String RUNTIME_EXTDIRS =
+ System.getProperty("java.ext.dirs", "");
+
+ /** The implicit boot class path */
+ public static final String IMPLICIT_BOOTCLASSPATH =
+ concat(new String[]{
+ SCALA_LIBRARY_CLASSPATH,
+ SCALA_LIBRARY_SOURCEPATH,
+ RUNTIME_BOOTCLASSPATH});
+
/** The default class path */
- public static final String CLASSPATH =
+ public static final String DEFAULT_CLASSPATH =
System.getProperty("scala.class.path", ".");
/** The default source path */
- public static final String SOURCEPATH = "";
+ public static final String DEFAULT_SOURCEPATH =
+ System.getProperty("scala.source.path", "");
/** The default boot class path */
- public static final String BOOTCLASSPATH =
- getDefaultBootClassPath();
+ public static final String DEFAULT_BOOTCLASSPATH =
+ System.getProperty("scala.boot.class.path", IMPLICIT_BOOTCLASSPATH);
/** The default extension directory path */
- public static final String EXTDIRS =
- System.getProperty("java.ext.dirs", "");
+ public static final String DEFAULT_EXTDIRS =
+ System.getProperty("scala.ext.dirs", RUNTIME_EXTDIRS);
//########################################################################
// Public Functions
@@ -88,12 +112,18 @@ public class ClassPath {
//########################################################################
// Private Functions
- /** Returns the default boot class path. */
- private static String getDefaultBootClassPath() {
- String java = System.getProperty("sun.boot.class.path");
- String scala = System.getProperty("scala.boot.class.path");
- if (java == null) return scala == null ? "" : scala;
- return scala == null ? java : java + PATH_SEPARATOR + scala;
+ /** Returns the concatenation of the two paths. */
+ private static String concat(String path1, String path2) {
+ if (path1.length() == 0) return path2;
+ if (path2.length() == 0) return path1;
+ return path1 + PATH_SEPARATOR + path2;
+ }
+
+ /** Returns the concatenation of the array of paths. */
+ private static String concat(String[] paths) {
+ String path = "";
+ for (int i = 0; i < paths.length; i++) path = concat(path, paths[i]);
+ return path;
}
//########################################################################
@@ -107,7 +137,7 @@ public class ClassPath {
/** Initializes this instance with default paths. */
public ClassPath() {
- this(CLASSPATH);
+ this(DEFAULT_CLASSPATH);
}
/**
@@ -115,20 +145,21 @@ public class ClassPath {
* default source, boot class and extension directory paths.
*/
public ClassPath(String classpath) {
- this(classpath, SOURCEPATH, BOOTCLASSPATH, EXTDIRS);
+ this(classpath, DEFAULT_SOURCEPATH, DEFAULT_BOOTCLASSPATH,
+ DEFAULT_EXTDIRS);
}
/** Initializes this instance with the specified paths. */
public ClassPath(String classpath, String sourcepath, String bootclasspath,
String extdirs)
{
- // replace first empty path in bootclasspath by BOOTCLASSPATH
- if (!bootclasspath.equals(BOOTCLASSPATH)) {
+ // replace first empty path in bootclasspath by IMPLICIT_BOOTCLASSPATH
+ if (!bootclasspath.equals(IMPLICIT_BOOTCLASSPATH)) {
String path = PATH_SEPARATOR + bootclasspath + PATH_SEPARATOR;
int index = path.indexOf(PATH_SEPARATOR + PATH_SEPARATOR);
if (index >= 0)
bootclasspath =
- path.substring(1, index + 1) + BOOTCLASSPATH +
+ path.substring(1, index + 1) + IMPLICIT_BOOTCLASSPATH +
path.substring(index + 1, path.length() - 1);
}
Set files = new LinkedHashSet();
diff --git a/sources/scalac/CompilerCommand.java b/sources/scalac/CompilerCommand.java
index a5178ee50d..1e014ee452 100644
--- a/sources/scalac/CompilerCommand.java
+++ b/sources/scalac/CompilerCommand.java
@@ -137,19 +137,19 @@ public class CompilerCommand extends CommandParser {
this.classpath = new StringOptionParser(this,
"classpath", "Specify where to find user class files",
- "path", ClassPath.CLASSPATH),
+ "path", ClassPath.DEFAULT_CLASSPATH),
this.sourcepath = new StringOptionParser(this,
"sourcepath", "Specify where to find input source files",
- "path", ClassPath.SOURCEPATH),
+ "path", ClassPath.DEFAULT_SOURCEPATH),
this.bootclasspath = new StringOptionParser(this,
"bootclasspath", "Override location of bootstrap class files",
- "path", ClassPath.BOOTCLASSPATH),
+ "path", ClassPath.DEFAULT_BOOTCLASSPATH),
this.extdirs = new StringOptionParser(this,
"extdirs", "Override location of installed extensions",
- "dirs", ClassPath.EXTDIRS),
+ "dirs", ClassPath.DEFAULT_EXTDIRS),
this.outpath = new StringOptionParser(this,
"d", "Specify where to place generated class files",