Make --CLASSPATH by a synonym for --classpath and -classpath.

Implement --bootclasspath.

From-SVN: r50249
This commit is contained in:
Per Bothner 2002-03-03 00:38:37 -08:00 committed by Per Bothner
parent 0f36c42ea2
commit fab76a82ba
9 changed files with 104 additions and 79 deletions

View File

@ -1,3 +1,30 @@
2002-03-02 Per Bothner <per@bothner.com>
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 <bryce@waitaki.otago.ac.nz>
* expr.c (build_java_arraystore_check): Fix formatting.

View File

@ -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.
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
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.
@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}

View File

@ -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:

View File

@ -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:

View File

@ -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,18 +286,6 @@ 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.
*/
void
jcf_path_CLASSPATH_arg (path)
const char *path;
{
free_entry (&classpath_l);
add_path (&classpath_l, path, 0);
}
/* Call this when -classpath is seen on the command line.
This overrides only the $CLASSPATH environment variable.
*/
@ -303,8 +293,18 @@ void
jcf_path_classpath_arg (path)
const char *path;
{
free_entry (&classpath_u);
add_path (&classpath_u, path, 0);
free_entry (&classpath_user);
add_path (&classpath_user, path, 0);
}
/* Call this when -bootclasspath is seen on the command line.
*/
void
jcf_path_bootclasspath_arg (path)
const char *path;
{
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)
{

View File

@ -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));

View File

@ -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[] =
%{<femit-class-file} %{<femit-class-files} %{<fencoding*}\
%{<fuse-boehm-gc} %{<fhash-synchronization} %{<fjni}\
%{<findirect-dispatch} \
%{<fno-store-check}\
%{<fclasspath*} %{<fCLASSPATH*} %{<foutput-class-dir}\
%{<fno-store-check} %{<foutput-class-dir}\
%{<fclasspath*} %{<fCLASSPATH*} %{<fbootclasspath*}\
%{<fuse-divide-subroutine} %{<fno-use-divide-subroutine}\
%{<fcheck-references} %{<fno-check-references}\
%{<ffilelist-file}\
@ -329,6 +329,7 @@ lang_specific_driver (in_argc, in_argv, in_added_libraries)
quote = argv[i];
}
else if (strcmp(argv[i], "-classpath") == 0
|| strcmp(argv[i], "-bootclasspath") == 0
|| strcmp(argv[i], "-CLASSPATH") == 0)
{
quote = argv[i];
@ -522,6 +523,7 @@ lang_specific_driver (in_argc, in_argv, in_added_libraries)
}
if (strcmp (argv[i], "-classpath") == 0
|| strcmp (argv[i], "-bootclasspath") == 0
|| strcmp (argv[i], "-CLASSPATH") == 0)
{
arglist[j] = concat ("-f", argv[i]+1, "=", argv[i+1], NULL);

View File

@ -34,10 +34,12 @@ DEFINE_LANG_NAME ("Java")
N_("Disable assignability checks for stores into object arrays") },
{ "-fjni",
N_("Assume native functions are implemented using JNI") },
{ "--CLASSPATH",
N_("Set class path and suppress system path") },
{ "--bootclasspath",
N_("Replace system path") },
{ "--classpath",
N_("Set class path") },
{ "--CLASSPATH",
N_("Set class path (deprecated: use --classpath instead)") },
{ "--main",
N_("Choose class whose main method should be used") },
{ "--encoding",

View File

@ -261,6 +261,8 @@ java_decode_option (argc, argv)
{
char *p = argv[0];
jcf_path_init ();
if (strcmp (p, "-version") == 0)
{
version_flag = 1;
@ -306,7 +308,7 @@ java_decode_option (argc, argv)
#define CLARG "-fCLASSPATH="
if (strncmp (p, CLARG, sizeof (CLARG) - 1) == 0)
{
jcf_path_CLASSPATH_arg (p + sizeof (CLARG) - 1);
jcf_path_classpath_arg (p + sizeof (CLARG) - 1);
return 1;
}
#undef CLARG
@ -316,6 +318,13 @@ java_decode_option (argc, argv)
jcf_path_classpath_arg (p + sizeof (CLARG) - 1);
return 1;
}
#undef CLARG
#define CLARG "-fbootclasspath="
if (strncmp (p, CLARG, sizeof (CLARG) - 1) == 0)
{
jcf_path_bootclasspath_arg (p + sizeof (CLARG) - 1);
return 1;
}
#undef CLARG
else if (strncmp (p, "-I", 2) == 0)
{