aboutsummaryrefslogtreecommitdiff
path: root/libjava/gij.cc
diff options
context:
space:
mode:
authorTom Tromey <tromey@cygnus.com>1999-10-22 19:43:41 +0000
committerTom Tromey <tromey@gcc.gnu.org>1999-10-22 19:43:41 +0000
commitb8c3c4f0146f82c900a995c8e98b83a2147115fd (patch)
tree5b2911a12a79d2934e95d0632e658c09f9826b4a /libjava/gij.cc
parent2fca54beb25b7aea46d0d7077df92ee7e3e051f6 (diff)
downloadgcc-b8c3c4f0146f82c900a995c8e98b83a2147115fd.zip
gcc-b8c3c4f0146f82c900a995c8e98b83a2147115fd.tar.gz
gcc-b8c3c4f0146f82c900a995c8e98b83a2147115fd.tar.bz2
Makefile.in: Rebuilt.
* Makefile.in: Rebuilt. * Makefile.am (java/lang/ClassLoader.h): New target. * java/lang/natClassLoader.cc (_Jv_FindClass): Removed reference to `redirect'. * include/java-props.h (_Jv_Compiler_Properties): Changed declaration. * gcj/array.h (JvRunMain, _Jv_RunMain): Don't declare. * include/jvm.h (_Jv_GCSetInitialHeapSize, _Jv_GCSetMaximumHeapSize): Declare. (JvRunMain, _Jv_RunMain): Declare. (_Jv_SetMaximumHeapSize, _Jv_SetInitialHeapSize): Declare. * nogc.cc (_Jv_GCSetInitialHeapSize): New function. (_Jv_GCSetMaximumHeapSize): Likewise. * boehm.cc (_Jv_GCSetInitialHeapSize): New function. (_Jv_GCSetMaximumHeapSize): Likewise. * prims.cc (parse_heap_size): New function. (_Jv_SetInitialHeapSize): Likewise. (_Jv_SetMaximumHeapSize): Likewise. (_Jv_Compiler_Properties): New global. * gij.cc (help): New function. (version): Likewise. (heap_size): Likewise. (heap_max_size): Likewise. (main): Parse arguments. Set _Jv_Compiler_Properties. Include <config.h>, <java-props.h>. (_Jv_Compiler_Properties): Removed. From-SVN: r30133
Diffstat (limited to 'libjava/gij.cc')
-rw-r--r--libjava/gij.cc107
1 files changed, 100 insertions, 7 deletions
diff --git a/libjava/gij.cc b/libjava/gij.cc
index b851b77..f07c495 100644
--- a/libjava/gij.cc
+++ b/libjava/gij.cc
@@ -8,27 +8,120 @@ details. */
/* Author: Kresten Krab Thorup <krab@gnu.org> */
+#include <config.h>
+
#include <jvm.h>
#include <gcj/cni.h>
+#include <java-props.h>
+
#include <stdio.h>
+#include <string.h>
#include <java/lang/System.h>
#include <java/util/Properties.h>
-// This is used to initialize the compiled-in system properties.
-const char *_Jv_Compiler_Properties[] =
+static void
+help ()
+{
+ printf ("Usage: gij [OPTION] ... CLASS [ARGS] ...\n\n");
+ printf ("Interpret Java bytecodes\n\n");
+ printf (" -DVAR=VAL define property VAR with value VAL\n");
+ printf (" --help print this help, then exit\n");
+ printf (" --ms=NUMBER set initial heap size\n");
+ printf (" --mx=NUMBER set maximum heap size\n");
+ printf (" --version print version number, then exit\n");
+ printf ("\nSee http://sourceware.cygnus.com/java/ for information on reporting bugs\n");
+ exit (0);
+}
+
+static void
+version ()
{
- NULL
-};
+ printf ("gij (GNU libgcj) version %s\n\n", VERSION);
+ printf ("Copyright (C) 1999 Cygnus Solutions.\n");
+ printf ("This is free software; see the source for copying conditions. There is NO\n");
+ printf ("warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n");
+ exit (0);
+}
int
main (int argc, const char **argv)
{
- if (argc < 2)
+ /* We rearrange ARGV so that all the -D options appear near the
+ beginning. */
+ int last_D_option = 0;
+
+ int i;
+ for (i = 1; i < argc; ++i)
+ {
+ const char *arg = argv[i];
+
+ /* A non-option stops processing. */
+ if (arg[0] != '-')
+ break;
+ /* A "--" stops processing. */
+ if (! strcmp (arg, "--"))
+ {
+ ++i;
+ break;
+ }
+
+ if (! strncmp (arg, "-D", 2))
+ {
+ argv[last_D_option++] = arg + 2;
+ continue;
+ }
+
+ /* Allow both single or double hyphen for all remaining
+ options. */
+ if (arg[1] == '-')
+ ++arg;
+
+ if (! strcmp (arg, "-help"))
+ help ();
+ else if (! strcmp (arg, "-version"))
+ version ();
+ /* FIXME: use getopt and avoid the ugliness here.
+ We at least need to handle the argument in a better way. */
+ else if (! strncmp (arg, "-ms=", 4))
+ _Jv_SetInitialHeapSize (arg + 4);
+ else if (! strcmp (arg, "-ms"))
+ {
+ if (i >= argc - 1)
+ {
+ no_argument:
+ fprintf (stderr, "gij: option requires an argument -- `%s'\n",
+ argv[i]);
+ fprintf (stderr, "Try `gij --help' for more information.\n");
+ exit (1);
+ }
+ _Jv_SetInitialHeapSize (argv[++i]);
+ }
+ else if (! strncmp (arg, "-mx=", 4))
+ _Jv_SetMaximumHeapSize (arg + 4);
+ else if (! strcmp (arg, "-mx"))
+ {
+ if (i >= argc - 1)
+ goto no_argument;
+ _Jv_SetMaximumHeapSize (argv[++i]);
+ }
+ else
+ {
+ fprintf (stderr, "gij: unrecognized option -- `%s'\n", argv[i]);
+ fprintf (stderr, "Try `gij --help' for more information.\n");
+ exit (1);
+ }
+ }
+
+ argv[last_D_option] = NULL;
+ _Jv_Compiler_Properties = argv;
+
+ if (argc - i < 1)
{
- printf ("usage: %s CLASS [ARGS]...\n", argv[0]);
+ fprintf (stderr, "Usage: gij [OPTION] ... CLASS [ARGS] ...\n");
+ fprintf (stderr, "Try `gij --help' for more information.\n");
exit (1);
}
- _Jv_RunMain (argv[1], argc - 1, argv + 1);
+ _Jv_RunMain (argv[i], argc - i, argv + i);
}