Make --CLASSPATH by a synonym for --classpath and -classpath.
authorPer Bothner <per@bothner.com>
Sun, 3 Mar 2002 08:35:11 +0000 (00:35 -0800)
committerPer Bothner <bothner@gcc.gnu.org>
Sun, 3 Mar 2002 08:35:11 +0000 (00:35 -0800)
Implement --bootclasspath.

From-SVN: r50247

gcc/java/ChangeLog
gcc/java/gcj.texi
gcc/java/gjavah.c
gcc/java/jcf-dump.c
gcc/java/jcf-path.c
gcc/java/jcf.h
gcc/java/jvspec.c
gcc/java/lang-options.h
gcc/java/lang.c

index 57ad8d4ce771d2f3678327f14a8022ca445b83bc..8db656dc7a325495d6f6e895c1ca93ee322ce6e4 100644 (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.
index e88e8fb2cde0f0a74058bba562636a8f425b2060..271a4e756cd81c36914190e3861df114413ddb44 100644 (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.
-
-@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}
index 7034e58e5535f0e7111b659fd74bf6dd7d28ab5b..b88ca8c118b7b52f6c6363583378ab98623acbaa 100644 (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:
index c845067e6869cca76c3df2e7af2a65ca552901ba..cf063ac747d0d0b7218db11858b3c51de1583fb7 100644 (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:
index efdd84333026b82ee5723754f7539c1e878a2b76..0976705532b6ffafc26be1b46aa1f396bf2e67c0 100644 (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,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)
     {
index 86a0c55ff29ab841441c6baa85edc41ec4c59d51..ea096395b1cbac9800316ac453438d0e7b85efbd 100644 (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));
index 202c7c8e0475ba0cc7361542dbf3e64e7ce7543a..58aa1c6fc789cc928ce61c6bb962569a9d616499 100644 (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);
index 3397fa8def85d13bd212210e3e36c2464ded0cd9..90e3190871d4fbdb9be9b7feb194a2b5251f2fac 100644 (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",
index 9732f1a6eee56c37df57e1a289f4decce7ca31c5..a71f5ccc89ea65f5a2769dd719daa8a65123086b 100644 (file)
@@ -263,6 +263,8 @@ java_decode_option (argc, argv)
 {
   char *p = argv[0];
 
+  jcf_path_init ();
+
   if (strcmp (p, "-version") == 0)
     {
       version_flag = 1;
@@ -308,7 +310,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
@@ -318,6 +320,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)
     {