From 2a85660dc27b7059ea083a775a99a0c206abeee4 Mon Sep 17 00:00:00 2001 From: Per Bothner Date: Sun, 3 Mar 2002 00:35:11 -0800 Subject: [PATCH] Make --CLASSPATH by a synonym for --classpath and -classpath. Implement --bootclasspath. From-SVN: r50247 --- gcc/java/ChangeLog | 27 +++++++++++++++++ gcc/java/gcj.texi | 35 +++++++++------------- gcc/java/gjavah.c | 11 +++---- gcc/java/jcf-dump.c | 11 +++---- gcc/java/jcf-path.c | 66 +++++++++++++++++------------------------ gcc/java/jcf.h | 2 +- gcc/java/jvspec.c | 8 +++-- gcc/java/lang-options.h | 6 ++-- gcc/java/lang.c | 11 ++++++- 9 files changed, 101 insertions(+), 76 deletions(-) diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog index 57ad8d4ce771..8db656dc7a32 100644 --- a/gcc/java/ChangeLog +++ b/gcc/java/ChangeLog @@ -1,3 +1,30 @@ +2002-03-02 Per Bothner + + Make --CLASSPATH by a synonym for --classpath and -classpath. + Implement --bootclasspath. + * jcf-path.c (classpath_u): Rename static variable to classpath_user. + (classpath_l): Remove. + (jcf_path_CLASSPATH_arg): Remove. + (jcf_path_bootclasspath_arg): New function. + (jcf_path_seal): Simplify accordingly. + + * jcf.h (jcf_path_bootclasspath_arg): New declarations. + (jcf_path_CLASSPATH): Remove declaration. + * jvspec.c (jvgenmain_spec): Also accept -fbootclasspath*. + (lang_specific_driver): Translate -bootclasspath. + * lang-options.h: Add --bootclasspath. Update --CLASSPATH. + * lang.c (decode_lang_options): Do jcf_path_init first. + Handle -fCLASSPATH same as -fclasspath. Also process -fbootclasspath. + * gjavah.c: Also handle --bootclasspath. + Handle --CLASSPATH as a synonum for --classpath. + * jcf-dump.c: Likewise. + + "." is not part of system path, but is the default for --classpath. + * jcf-path.c (jcf_path_init): Don't add "." to sys_dirs. + (jcf_path_seal): Add "." if no CLASSPATH specified. + + * gcj.texi: Document changes. + 2002-03-01 Bryce McKinlay * expr.c (build_java_arraystore_check): Fix formatting. diff --git a/gcc/java/gcj.texi b/gcc/java/gcj.texi index e88e8fb2cde0..271a4e756cd8 100644 --- a/gcc/java/gcj.texi +++ b/gcc/java/gcj.texi @@ -240,16 +240,16 @@ compatibility with tools like @code{javac} is imported, we recommend always using @code{-I} instead of the other options for manipulating the class path. -@item --CLASSPATH=@var{path} -This sets the class path to @var{path}, a colon-separated list of paths -(on Windows-based systems, a semicolon-separate list of paths). Using -this option causes the built in path to be suppressed. - @item --classpath=@var{path} This sets the class path to @var{path}, a colon-separated list of paths -(on Windows-based systems, a semicolon-separate list of paths). This -differs from the @code{--classpath} option in that it does not suppress -the built-in system path. +(on Windows-based systems, a semicolon-separate list of paths). +This does not override the builtin (``boot'') search path. + +@item --CLASSPATH=@var{path} +Deprecated synonym for @code{--classpath}. + +@item --bootclasspath=@var{path} +Where to find the standard builtin classes, such as @code{java.lang.String}. @item CLASSPATH This is an environment variable which holds a list of paths. @@ -262,21 +262,14 @@ The final class path is constructed like so: First come all directories specified via @code{-I}. @item -If @option{--CLASSPATH} is specified, its value is appended and processing -stops. That is, @option{--CLASSPATH} suppresses all the options mentioned -later in this list. - -@item -If @option{--classpath} is specified, its value is appended and the -@code{CLASSPATH} environment variable is suppressed. - -@item -If the @code{CLASSPATH} environment variable is specified (and was not -suppressed by @option{--classpath} or @option{--CLASSPATH}), then its -value is appended. +If @option{--classpath} is specified, its value is appended. +Otherwise, if the @code{CLASSPATH} environment variable is specified, +then its value is appended. +Otherwise, the current directory (@code{"."}) is appended. @item -Finally, the built-in system directory, @file{libgcj.jar}, is appended. +Finally, if @code{--bootclasspath} was specified, append its value. +Otherwise, append the built-in system directory, @file{libgcj.jar}. @end itemize The classfile built by @code{gcj} for the class @code{java.lang.Object} diff --git a/gcc/java/gjavah.c b/gcc/java/gjavah.c index 7034e58e5535..b88ca8c118b7 100644 --- a/gcc/java/gjavah.c +++ b/gcc/java/gjavah.c @@ -2102,7 +2102,8 @@ DEFUN(process_file, (jcf, out), #define LONG_OPT(Num) ((Num) + 128) #define OPT_classpath LONG_OPT (0) -#define OPT_CLASSPATH LONG_OPT (1) +#define OPT_CLASSPATH OPT_classpath +#define OPT_bootclasspath LONG_OPT (1) #define OPT_HELP LONG_OPT (2) #define OPT_TEMP LONG_OPT (3) #define OPT_VERSION LONG_OPT (4) @@ -2119,6 +2120,7 @@ DEFUN(process_file, (jcf, out), static const struct option options[] = { { "classpath", required_argument, NULL, OPT_classpath }, + { "bootclasspath", required_argument, NULL, OPT_bootclasspath }, { "CLASSPATH", required_argument, NULL, OPT_CLASSPATH }, { "help", no_argument, NULL, OPT_HELP }, { "stubs", no_argument, &stubs, 1 }, @@ -2158,10 +2160,9 @@ help () printf (" -friend TEXT Insert TEXT as `friend' declaration\n"); printf (" -prepend TEXT Insert TEXT before start of class\n"); printf ("\n"); - printf (" --CLASSPATH PATH Set path to find .class files, overriding\n\ - built-in class path\n"); printf (" --classpath PATH Set path to find .class files\n"); printf (" -IDIR Append directory to class path\n"); + printf (" --bootclasspath PATH Override built-in class path\n"); printf (" -d DIRECTORY Set output directory name\n"); printf (" -o FILE Set output file name\n"); printf (" -td DIRECTORY Set temporary directory name\n"); @@ -2241,8 +2242,8 @@ DEFUN(main, (argc, argv), jcf_path_classpath_arg (optarg); break; - case OPT_CLASSPATH: - jcf_path_CLASSPATH_arg (optarg); + case OPT_bootclasspath: + jcf_path_bootclasspath_arg (optarg); break; case OPT_HELP: diff --git a/gcc/java/jcf-dump.c b/gcc/java/jcf-dump.c index c845067e6869..cf063ac747d0 100644 --- a/gcc/java/jcf-dump.c +++ b/gcc/java/jcf-dump.c @@ -774,7 +774,8 @@ DEFUN(process_class, (jcf), #define LONG_OPT(Num) ((Num) + 128) #define OPT_classpath LONG_OPT (0) -#define OPT_CLASSPATH LONG_OPT (1) +#define OPT_CLASSPATH OPT_classpath +#define OPT_bootclasspath LONG_OPT (1) #define OPT_HELP LONG_OPT (2) #define OPT_VERSION LONG_OPT (3) #define OPT_JAVAP LONG_OPT (4) @@ -782,6 +783,7 @@ DEFUN(process_class, (jcf), static const struct option options[] = { { "classpath", required_argument, NULL, OPT_classpath }, + { "bootclasspath", required_argument, NULL, OPT_bootclasspath }, { "CLASSPATH", required_argument, NULL, OPT_CLASSPATH }, { "help", no_argument, NULL, OPT_HELP }, { "verbose", no_argument, NULL, 'v' }, @@ -806,10 +808,9 @@ help () printf (" -c Disassemble method bodies\n"); printf (" --javap Generate output in `javap' format\n"); printf ("\n"); - printf (" --CLASSPATH PATH Set path to find .class files, overriding\n\ - built-in class path\n"); printf (" --classpath PATH Set path to find .class files\n"); printf (" -IDIR Append directory to class path\n"); + printf (" --bootclasspath PATH Override built-in class path\n"); printf (" -o FILE Set output file name\n"); printf ("\n"); printf (" --help Print this help, then exit\n"); @@ -876,8 +877,8 @@ DEFUN(main, (argc, argv), jcf_path_classpath_arg (optarg); break; - case OPT_CLASSPATH: - jcf_path_CLASSPATH_arg (optarg); + case OPT_bootclasspath: + jcf_path_bootclasspath_arg (optarg); break; case OPT_HELP: diff --git a/gcc/java/jcf-path.c b/gcc/java/jcf-path.c index efdd84333026..0976705532b6 100644 --- a/gcc/java/jcf-path.c +++ b/gcc/java/jcf-path.c @@ -1,6 +1,6 @@ /* Handle CLASSPATH, -classpath, and path searching. - Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc. + Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -72,7 +72,8 @@ static void add_path PARAMS ((struct entry **, const char *, int)); built-in system directory (only libgcj.jar) CLASSPATH environment variable -classpath option overrides $CLASSPATH - -CLASSPATH option overrides $CLASSPATH, -classpath, and built-in + -CLASSPATH option is a synonym for -classpath (for compatibility) + -bootclasspath overrides built-in -I prepends path to list We implement this by keeping several path lists, and then simply @@ -85,10 +86,7 @@ static struct entry *include_dirs; static struct entry *classpath_env; /* This holds the -classpath command-line option. */ -static struct entry *classpath_u; - -/* This holds the -CLASSPATH command-line option. */ -static struct entry *classpath_l; +static struct entry *classpath_user; /* This holds the default directories. Some of these will have the "system" flag set. */ @@ -222,6 +220,8 @@ add_path (entp, cp, is_system) } } +static int init_done = 0; + /* Initialize the path module. */ void jcf_path_init () @@ -231,7 +231,9 @@ jcf_path_init () struct stat stat_b; int found = 0, len; - add_entry (&sys_dirs, ".", 0); + if (init_done) + return; + init_done = 1; sep[0] = DIR_SEPARATOR; sep[1] = '\0'; @@ -284,27 +286,25 @@ jcf_path_init () add_path (&classpath_env, cp, 0); } -/* Call this when -CLASSPATH is seen on the command line. - This is the override-all switch, even the built in classes - are overridden. +/* Call this when -classpath is seen on the command line. + This overrides only the $CLASSPATH environment variable. */ void -jcf_path_CLASSPATH_arg (path) +jcf_path_classpath_arg (path) const char *path; { - free_entry (&classpath_l); - add_path (&classpath_l, path, 0); + free_entry (&classpath_user); + add_path (&classpath_user, path, 0); } -/* Call this when -classpath is seen on the command line. - This overrides only the $CLASSPATH environment variable. +/* Call this when -bootclasspath is seen on the command line. */ void -jcf_path_classpath_arg (path) +jcf_path_bootclasspath_arg (path) const char *path; { - free_entry (&classpath_u); - add_path (&classpath_u, path, 0); + free_entry (&sys_dirs); + add_path (&sys_dirs, path, 1); } /* Call this when -I is seen on the command line. */ @@ -322,42 +322,32 @@ void jcf_path_seal (print) int print; { - int do_system = 1; struct entry *secondary; sealed = include_dirs; include_dirs = NULL; - if (classpath_l) + if (classpath_user) { - secondary = classpath_l; - classpath_l = NULL; - do_system = 0; - } - else if (classpath_u) - { - secondary = classpath_u; - classpath_u = NULL; + secondary = classpath_user; + classpath_user = NULL; } else { + if (! classpath_env) + add_entry (&classpath_env, ".", 0); + secondary = classpath_env; classpath_env = NULL; } - free_entry (&classpath_l); - free_entry (&classpath_u); + + free_entry (&classpath_user); free_entry (&classpath_env); append_entry (&sealed, secondary); - - if (do_system) - { - append_entry (&sealed, sys_dirs); - sys_dirs = NULL; - } - else - free_entry (&sys_dirs); + append_entry (&sealed, sys_dirs); + sys_dirs = NULL; if (print) { diff --git a/gcc/java/jcf.h b/gcc/java/jcf.h index 86a0c55ff29a..ea096395b1cb 100644 --- a/gcc/java/jcf.h +++ b/gcc/java/jcf.h @@ -271,8 +271,8 @@ extern void jcf_dependency_print_dummies PARAMS ((void)); /* Declarations for path handling code. */ extern void jcf_path_init PARAMS ((void)); -extern void jcf_path_CLASSPATH_arg PARAMS ((const char *)); extern void jcf_path_classpath_arg PARAMS ((const char *)); +extern void jcf_path_bootclasspath_arg PARAMS ((const char *)); extern void jcf_path_include_arg PARAMS ((const char *)); extern void jcf_path_seal PARAMS ((int)); extern void *jcf_path_start PARAMS ((void)); diff --git a/gcc/java/jvspec.c b/gcc/java/jvspec.c index 202c7c8e0475..58aa1c6fc789 100644 --- a/gcc/java/jvspec.c +++ b/gcc/java/jvspec.c @@ -1,6 +1,6 @@ /* Specific flags and argument handling of the front-end of the GNU compiler for the Java(TM) language. - Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc. + Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc. This file is part of GNU CC. @@ -66,8 +66,8 @@ static const char jvgenmain_spec[] = %{