Commit 2a85660d by Per Bothner Committed by Per Bothner

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

	Implement --bootclasspath.

From-SVN: r50247
parent c26a6db8
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> 2002-03-01 Bryce McKinlay <bryce@waitaki.otago.ac.nz>
* expr.c (build_java_arraystore_check): Fix formatting. * expr.c (build_java_arraystore_check): Fix formatting.
......
...@@ -240,16 +240,16 @@ compatibility with tools like @code{javac} is imported, we recommend ...@@ -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 always using @code{-I} instead of the other options for manipulating the
class path. 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} @item --classpath=@var{path}
This sets the class path to @var{path}, a colon-separated list of paths 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 (on Windows-based systems, a semicolon-separate list of paths).
differs from the @code{--classpath} option in that it does not suppress This does not override the builtin (``boot'') search path.
the built-in system 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 @item CLASSPATH
This is an environment variable which holds a list of paths. This is an environment variable which holds a list of paths.
...@@ -262,21 +262,14 @@ The final class path is constructed like so: ...@@ -262,21 +262,14 @@ The final class path is constructed like so:
First come all directories specified via @code{-I}. First come all directories specified via @code{-I}.
@item @item
If @option{--CLASSPATH} is specified, its value is appended and processing If @option{--classpath} is specified, its value is appended.
stops. That is, @option{--CLASSPATH} suppresses all the options mentioned Otherwise, if the @code{CLASSPATH} environment variable is specified,
later in this list. 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 @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 @end itemize
The classfile built by @code{gcj} for the class @code{java.lang.Object} The classfile built by @code{gcj} for the class @code{java.lang.Object}
......
...@@ -2102,7 +2102,8 @@ DEFUN(process_file, (jcf, out), ...@@ -2102,7 +2102,8 @@ DEFUN(process_file, (jcf, out),
#define LONG_OPT(Num) ((Num) + 128) #define LONG_OPT(Num) ((Num) + 128)
#define OPT_classpath LONG_OPT (0) #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_HELP LONG_OPT (2)
#define OPT_TEMP LONG_OPT (3) #define OPT_TEMP LONG_OPT (3)
#define OPT_VERSION LONG_OPT (4) #define OPT_VERSION LONG_OPT (4)
...@@ -2119,6 +2120,7 @@ DEFUN(process_file, (jcf, out), ...@@ -2119,6 +2120,7 @@ DEFUN(process_file, (jcf, out),
static const struct option options[] = static const struct option options[] =
{ {
{ "classpath", required_argument, NULL, OPT_classpath }, { "classpath", required_argument, NULL, OPT_classpath },
{ "bootclasspath", required_argument, NULL, OPT_bootclasspath },
{ "CLASSPATH", required_argument, NULL, OPT_CLASSPATH }, { "CLASSPATH", required_argument, NULL, OPT_CLASSPATH },
{ "help", no_argument, NULL, OPT_HELP }, { "help", no_argument, NULL, OPT_HELP },
{ "stubs", no_argument, &stubs, 1 }, { "stubs", no_argument, &stubs, 1 },
...@@ -2158,10 +2160,9 @@ help () ...@@ -2158,10 +2160,9 @@ help ()
printf (" -friend TEXT Insert TEXT as `friend' declaration\n"); printf (" -friend TEXT Insert TEXT as `friend' declaration\n");
printf (" -prepend TEXT Insert TEXT before start of class\n"); printf (" -prepend TEXT Insert TEXT before start of class\n");
printf ("\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 (" --classpath PATH Set path to find .class files\n");
printf (" -IDIR Append directory to class path\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 (" -d DIRECTORY Set output directory name\n");
printf (" -o FILE Set output file name\n"); printf (" -o FILE Set output file name\n");
printf (" -td DIRECTORY Set temporary directory name\n"); printf (" -td DIRECTORY Set temporary directory name\n");
...@@ -2241,8 +2242,8 @@ DEFUN(main, (argc, argv), ...@@ -2241,8 +2242,8 @@ DEFUN(main, (argc, argv),
jcf_path_classpath_arg (optarg); jcf_path_classpath_arg (optarg);
break; break;
case OPT_CLASSPATH: case OPT_bootclasspath:
jcf_path_CLASSPATH_arg (optarg); jcf_path_bootclasspath_arg (optarg);
break; break;
case OPT_HELP: case OPT_HELP:
......
...@@ -774,7 +774,8 @@ DEFUN(process_class, (jcf), ...@@ -774,7 +774,8 @@ DEFUN(process_class, (jcf),
#define LONG_OPT(Num) ((Num) + 128) #define LONG_OPT(Num) ((Num) + 128)
#define OPT_classpath LONG_OPT (0) #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_HELP LONG_OPT (2)
#define OPT_VERSION LONG_OPT (3) #define OPT_VERSION LONG_OPT (3)
#define OPT_JAVAP LONG_OPT (4) #define OPT_JAVAP LONG_OPT (4)
...@@ -782,6 +783,7 @@ DEFUN(process_class, (jcf), ...@@ -782,6 +783,7 @@ DEFUN(process_class, (jcf),
static const struct option options[] = static const struct option options[] =
{ {
{ "classpath", required_argument, NULL, OPT_classpath }, { "classpath", required_argument, NULL, OPT_classpath },
{ "bootclasspath", required_argument, NULL, OPT_bootclasspath },
{ "CLASSPATH", required_argument, NULL, OPT_CLASSPATH }, { "CLASSPATH", required_argument, NULL, OPT_CLASSPATH },
{ "help", no_argument, NULL, OPT_HELP }, { "help", no_argument, NULL, OPT_HELP },
{ "verbose", no_argument, NULL, 'v' }, { "verbose", no_argument, NULL, 'v' },
...@@ -806,10 +808,9 @@ help () ...@@ -806,10 +808,9 @@ help ()
printf (" -c Disassemble method bodies\n"); printf (" -c Disassemble method bodies\n");
printf (" --javap Generate output in `javap' format\n"); printf (" --javap Generate output in `javap' format\n");
printf ("\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 (" --classpath PATH Set path to find .class files\n");
printf (" -IDIR Append directory to class path\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 (" -o FILE Set output file name\n");
printf ("\n"); printf ("\n");
printf (" --help Print this help, then exit\n"); printf (" --help Print this help, then exit\n");
...@@ -876,8 +877,8 @@ DEFUN(main, (argc, argv), ...@@ -876,8 +877,8 @@ DEFUN(main, (argc, argv),
jcf_path_classpath_arg (optarg); jcf_path_classpath_arg (optarg);
break; break;
case OPT_CLASSPATH: case OPT_bootclasspath:
jcf_path_CLASSPATH_arg (optarg); jcf_path_bootclasspath_arg (optarg);
break; break;
case OPT_HELP: case OPT_HELP:
......
/* Handle CLASSPATH, -classpath, and path searching. /* 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 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 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)); ...@@ -72,7 +72,8 @@ static void add_path PARAMS ((struct entry **, const char *, int));
built-in system directory (only libgcj.jar) built-in system directory (only libgcj.jar)
CLASSPATH environment variable CLASSPATH environment variable
-classpath option overrides $CLASSPATH -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 -I prepends path to list
We implement this by keeping several path lists, and then simply We implement this by keeping several path lists, and then simply
...@@ -85,10 +86,7 @@ static struct entry *include_dirs; ...@@ -85,10 +86,7 @@ static struct entry *include_dirs;
static struct entry *classpath_env; static struct entry *classpath_env;
/* This holds the -classpath command-line option. */ /* This holds the -classpath command-line option. */
static struct entry *classpath_u; static struct entry *classpath_user;
/* This holds the -CLASSPATH command-line option. */
static struct entry *classpath_l;
/* This holds the default directories. Some of these will have the /* This holds the default directories. Some of these will have the
"system" flag set. */ "system" flag set. */
...@@ -222,6 +220,8 @@ add_path (entp, cp, is_system) ...@@ -222,6 +220,8 @@ add_path (entp, cp, is_system)
} }
} }
static int init_done = 0;
/* Initialize the path module. */ /* Initialize the path module. */
void void
jcf_path_init () jcf_path_init ()
...@@ -231,7 +231,9 @@ jcf_path_init () ...@@ -231,7 +231,9 @@ jcf_path_init ()
struct stat stat_b; struct stat stat_b;
int found = 0, len; int found = 0, len;
add_entry (&sys_dirs, ".", 0); if (init_done)
return;
init_done = 1;
sep[0] = DIR_SEPARATOR; sep[0] = DIR_SEPARATOR;
sep[1] = '\0'; sep[1] = '\0';
...@@ -284,27 +286,25 @@ jcf_path_init () ...@@ -284,27 +286,25 @@ jcf_path_init ()
add_path (&classpath_env, cp, 0); add_path (&classpath_env, cp, 0);
} }
/* Call this when -CLASSPATH is seen on the command line. /* Call this when -classpath is seen on the command line.
This is the override-all switch, even the built in classes This overrides only the $CLASSPATH environment variable.
are overridden.
*/ */
void void
jcf_path_CLASSPATH_arg (path) jcf_path_classpath_arg (path)
const char *path; const char *path;
{ {
free_entry (&classpath_l); free_entry (&classpath_user);
add_path (&classpath_l, path, 0); add_path (&classpath_user, path, 0);
} }
/* Call this when -classpath is seen on the command line. /* Call this when -bootclasspath is seen on the command line.
This overrides only the $CLASSPATH environment variable.
*/ */
void void
jcf_path_classpath_arg (path) jcf_path_bootclasspath_arg (path)
const char *path; const char *path;
{ {
free_entry (&classpath_u); free_entry (&sys_dirs);
add_path (&classpath_u, path, 0); add_path (&sys_dirs, path, 1);
} }
/* Call this when -I is seen on the command line. */ /* Call this when -I is seen on the command line. */
...@@ -322,42 +322,32 @@ void ...@@ -322,42 +322,32 @@ void
jcf_path_seal (print) jcf_path_seal (print)
int print; int print;
{ {
int do_system = 1;
struct entry *secondary; struct entry *secondary;
sealed = include_dirs; sealed = include_dirs;
include_dirs = NULL; include_dirs = NULL;
if (classpath_l) if (classpath_user)
{ {
secondary = classpath_l; secondary = classpath_user;
classpath_l = NULL; classpath_user = NULL;
do_system = 0;
}
else if (classpath_u)
{
secondary = classpath_u;
classpath_u = NULL;
} }
else else
{ {
if (! classpath_env)
add_entry (&classpath_env, ".", 0);
secondary = classpath_env; secondary = classpath_env;
classpath_env = NULL; classpath_env = NULL;
} }
free_entry (&classpath_l);
free_entry (&classpath_u); free_entry (&classpath_user);
free_entry (&classpath_env); free_entry (&classpath_env);
append_entry (&sealed, secondary); append_entry (&sealed, secondary);
append_entry (&sealed, sys_dirs);
if (do_system) sys_dirs = NULL;
{
append_entry (&sealed, sys_dirs);
sys_dirs = NULL;
}
else
free_entry (&sys_dirs);
if (print) if (print)
{ {
......
...@@ -271,8 +271,8 @@ extern void jcf_dependency_print_dummies PARAMS ((void)); ...@@ -271,8 +271,8 @@ extern void jcf_dependency_print_dummies PARAMS ((void));
/* Declarations for path handling code. */ /* Declarations for path handling code. */
extern void jcf_path_init PARAMS ((void)); 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_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_include_arg PARAMS ((const char *));
extern void jcf_path_seal PARAMS ((int)); extern void jcf_path_seal PARAMS ((int));
extern void *jcf_path_start PARAMS ((void)); extern void *jcf_path_start PARAMS ((void));
......
/* Specific flags and argument handling of the front-end of the /* Specific flags and argument handling of the front-end of the
GNU compiler for the Java(TM) language. 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. This file is part of GNU CC.
...@@ -66,8 +66,8 @@ static const char jvgenmain_spec[] = ...@@ -66,8 +66,8 @@ static const char jvgenmain_spec[] =
%{<femit-class-file} %{<femit-class-files} %{<fencoding*}\ %{<femit-class-file} %{<femit-class-files} %{<fencoding*}\
%{<fuse-boehm-gc} %{<fhash-synchronization} %{<fjni}\ %{<fuse-boehm-gc} %{<fhash-synchronization} %{<fjni}\
%{<findirect-dispatch} \ %{<findirect-dispatch} \
%{<fno-store-check}\ %{<fno-store-check} %{<foutput-class-dir}\
%{<fclasspath*} %{<fCLASSPATH*} %{<foutput-class-dir}\ %{<fclasspath*} %{<fCLASSPATH*} %{<fbootclasspath*}\
%{<fuse-divide-subroutine} %{<fno-use-divide-subroutine}\ %{<fuse-divide-subroutine} %{<fno-use-divide-subroutine}\
%{<fcheck-references} %{<fno-check-references}\ %{<fcheck-references} %{<fno-check-references}\
%{<ffilelist-file}\ %{<ffilelist-file}\
...@@ -329,6 +329,7 @@ lang_specific_driver (in_argc, in_argv, in_added_libraries) ...@@ -329,6 +329,7 @@ lang_specific_driver (in_argc, in_argv, in_added_libraries)
quote = argv[i]; quote = argv[i];
} }
else if (strcmp(argv[i], "-classpath") == 0 else if (strcmp(argv[i], "-classpath") == 0
|| strcmp(argv[i], "-bootclasspath") == 0
|| strcmp(argv[i], "-CLASSPATH") == 0) || strcmp(argv[i], "-CLASSPATH") == 0)
{ {
quote = argv[i]; quote = argv[i];
...@@ -522,6 +523,7 @@ lang_specific_driver (in_argc, in_argv, in_added_libraries) ...@@ -522,6 +523,7 @@ lang_specific_driver (in_argc, in_argv, in_added_libraries)
} }
if (strcmp (argv[i], "-classpath") == 0 if (strcmp (argv[i], "-classpath") == 0
|| strcmp (argv[i], "-bootclasspath") == 0
|| strcmp (argv[i], "-CLASSPATH") == 0) || strcmp (argv[i], "-CLASSPATH") == 0)
{ {
arglist[j] = concat ("-f", argv[i]+1, "=", argv[i+1], NULL); arglist[j] = concat ("-f", argv[i]+1, "=", argv[i+1], NULL);
......
...@@ -34,10 +34,12 @@ DEFINE_LANG_NAME ("Java") ...@@ -34,10 +34,12 @@ DEFINE_LANG_NAME ("Java")
N_("Disable assignability checks for stores into object arrays") }, N_("Disable assignability checks for stores into object arrays") },
{ "-fjni", { "-fjni",
N_("Assume native functions are implemented using JNI") }, N_("Assume native functions are implemented using JNI") },
{ "--CLASSPATH", { "--bootclasspath",
N_("Set class path and suppress system path") }, N_("Replace system path") },
{ "--classpath", { "--classpath",
N_("Set class path") }, N_("Set class path") },
{ "--CLASSPATH",
N_("Set class path (deprecated: use --classpath instead)") },
{ "--main", { "--main",
N_("Choose class whose main method should be used") }, N_("Choose class whose main method should be used") },
{ "--encoding", { "--encoding",
......
...@@ -263,6 +263,8 @@ java_decode_option (argc, argv) ...@@ -263,6 +263,8 @@ java_decode_option (argc, argv)
{ {
char *p = argv[0]; char *p = argv[0];
jcf_path_init ();
if (strcmp (p, "-version") == 0) if (strcmp (p, "-version") == 0)
{ {
version_flag = 1; version_flag = 1;
...@@ -308,7 +310,7 @@ java_decode_option (argc, argv) ...@@ -308,7 +310,7 @@ java_decode_option (argc, argv)
#define CLARG "-fCLASSPATH=" #define CLARG "-fCLASSPATH="
if (strncmp (p, CLARG, sizeof (CLARG) - 1) == 0) 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; return 1;
} }
#undef CLARG #undef CLARG
...@@ -319,6 +321,13 @@ java_decode_option (argc, argv) ...@@ -319,6 +321,13 @@ java_decode_option (argc, argv)
return 1; return 1;
} }
#undef CLARG #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) else if (strncmp (p, "-I", 2) == 0)
{ {
jcf_path_include_arg (p + 2); jcf_path_include_arg (p + 2);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment