re PR libgcj/20090 (gij should be implemented in Java)
2005-04-01 Thomas Fitzsimmons <fitzsim@redhat.com> * gcj.texi (Invoking gij): Add descriptions of new -X options. Mention recognized-and-ignored compatibility options. (Memory allocation): Add descriptions of JvMalloc, JvRealloc and JvFree. (About CNI): Add Memory allocation section. 2005-04-01 Thomas Fitzsimmons <fitzsim@redhat.com> PR libgcj/20090, PR libgcj/20526 * gij.cc (nonstandard_opts_help): New function. (add_option): New function. (main): Support java options. Set java.class.path. Don't set _Jv_Jar_Class_Path. * prims.cc (parse_x_arg): New function. (parse_init_args): Call parse_x_arg for -X and _ options, when ignoreUnrecognized is true. (new _Jv_RunMain): New vm_args variant. (old _Jv_RunMain): Call new vm_args _Jv_RunMain. (_Jv_Jar_Class_Path): Remove variable. * include/java-props.h: Likewise. * include/cni.h (JvRealloc): New function. * include/jvm.h (_Jv_RunMain): Declare vm_args variant. * java/lang/natRuntime.cc (insertSystemProperties): Remove _Jv_Jar_Class_Path logic. Use JV_VERSION and JV_API_VERSION macros. * configure.ac (JV_VERSION): Define. (JV_API_VERSION): Likewise. * configure: Regenerate. * include/config.h.in: Regenerate. From-SVN: r97429
This commit is contained in:
parent
ca6ca8fa9c
commit
b6121641fc
12 changed files with 473 additions and 125 deletions
|
@ -1,3 +1,11 @@
|
||||||
|
2005-04-01 Thomas Fitzsimmons <fitzsim@redhat.com>
|
||||||
|
|
||||||
|
* gcj.texi (Invoking gij): Add descriptions of new -X options.
|
||||||
|
Mention recognized-and-ignored compatibility options.
|
||||||
|
(Memory allocation): Add descriptions of JvMalloc, JvRealloc and
|
||||||
|
JvFree.
|
||||||
|
(About CNI): Add Memory allocation section.
|
||||||
|
|
||||||
2005-04-01 Tom Tromey <tromey@redhat.com>
|
2005-04-01 Tom Tromey <tromey@redhat.com>
|
||||||
|
|
||||||
* decl.c (java_init_decl_processing): Fix types of
|
* decl.c (java_init_decl_processing): Fix types of
|
||||||
|
|
|
@ -949,16 +949,26 @@ be retrieved at runtime using the @code{java.lang.System.getProperty}
|
||||||
method.
|
method.
|
||||||
|
|
||||||
@item -ms=@var{number}
|
@item -ms=@var{number}
|
||||||
This sets the initial heap size.
|
Equivalent to @code{-Xms}.
|
||||||
|
|
||||||
@item -mx=@var{number}
|
@item -mx=@var{number}
|
||||||
This sets the maximum heap size.
|
Equivalent to @code{-Xmx}.
|
||||||
|
|
||||||
@item -X
|
@item -X
|
||||||
@itemx -X@var{argument}
|
@itemx -X@var{argument}
|
||||||
Supplying @code{-X} by itself will cause @code{gij} to list all the
|
Supplying @code{-X} by itself will cause @code{gij} to list all the
|
||||||
supported @code{-X} options. Currently there are none. Unrecognized
|
supported @code{-X} options. Currently these options are supported:
|
||||||
@code{-X} options are ignored, for compatibility with other runtimes.
|
|
||||||
|
@table @gcctabopt
|
||||||
|
@item -Xms@var{size}
|
||||||
|
Set the initial heap size.
|
||||||
|
|
||||||
|
@item -Xmx@var{size}
|
||||||
|
Set the maximum heap size.
|
||||||
|
@end table
|
||||||
|
|
||||||
|
Unrecognized @code{-X} options are ignored, for compatibility with
|
||||||
|
other runtimes.
|
||||||
|
|
||||||
@item -jar
|
@item -jar
|
||||||
This indicates that the name passed to @code{gij} should be interpreted
|
This indicates that the name passed to @code{gij} should be interpreted
|
||||||
|
@ -971,6 +981,9 @@ Print help, then exit.
|
||||||
@item --showversion
|
@item --showversion
|
||||||
Print version number and continue.
|
Print version number and continue.
|
||||||
|
|
||||||
|
@item --fullversion
|
||||||
|
Print detailed version information, then exit.
|
||||||
|
|
||||||
@item --version
|
@item --version
|
||||||
Print version number, then exit.
|
Print version number, then exit.
|
||||||
|
|
||||||
|
@ -979,6 +992,12 @@ Print version number, then exit.
|
||||||
Each time a class is initialized, print a short message on standard error.
|
Each time a class is initialized, print a short message on standard error.
|
||||||
@end table
|
@end table
|
||||||
|
|
||||||
|
@code{gij} also recognizes and ignores the following options, for
|
||||||
|
compatibility with existing application launch scripts:
|
||||||
|
@code{-client}, @code{-server}, @code{-hotspot}, @code{-jrockit},
|
||||||
|
@code{-agentlib}, @code{-agentpath}, @code{-debug}, @code{-d32},
|
||||||
|
@code{-d64}, @code{-javaagent} and @code{-noclassgc}.
|
||||||
|
|
||||||
@c man end
|
@c man end
|
||||||
|
|
||||||
@node Invoking gcj-dbtool
|
@node Invoking gcj-dbtool
|
||||||
|
@ -1250,6 +1269,7 @@ alternative to the standard JNI (Java Native Interface).
|
||||||
* Objects and Classes:: C++ and Java classes.
|
* Objects and Classes:: C++ and Java classes.
|
||||||
* Class Initialization:: How objects are initialized.
|
* Class Initialization:: How objects are initialized.
|
||||||
* Object allocation:: How to create Java objects in C++.
|
* Object allocation:: How to create Java objects in C++.
|
||||||
|
* Memory allocation:: How to allocate and free memory.
|
||||||
* Arrays:: Dealing with Java arrays in C++.
|
* Arrays:: Dealing with Java arrays in C++.
|
||||||
* Methods:: Java methods in C++.
|
* Methods:: Java methods in C++.
|
||||||
* Strings:: Information about Java Strings.
|
* Strings:: Information about Java Strings.
|
||||||
|
@ -1630,6 +1650,27 @@ java::util::Hashtable *ht = new java::util::Hashtable(120);
|
||||||
@end example
|
@end example
|
||||||
|
|
||||||
|
|
||||||
|
@node Memory allocation
|
||||||
|
@section Memory allocation
|
||||||
|
|
||||||
|
When allocting memory in @acronym{CNI} methods it is best to handle
|
||||||
|
out-of-memory conditions by throwing a Java exception. These
|
||||||
|
functions are provided for that purpose:
|
||||||
|
|
||||||
|
@deftypefun void* JvMalloc (jsize @var{size})
|
||||||
|
Calls malloc. Throws @code{java.lang.OutOfMemoryError} if allocation
|
||||||
|
fails.
|
||||||
|
@end deftypefun
|
||||||
|
|
||||||
|
@deftypefun void* JvRealloc (void* @var{ptr}, jsize @var{size})
|
||||||
|
Calls realloc. Throws @code{java.lang.OutOfMemoryError} if
|
||||||
|
reallocation fails.
|
||||||
|
@end deftypefun
|
||||||
|
|
||||||
|
@deftypefun void JvFree (void* @var{ptr})
|
||||||
|
Calls free.
|
||||||
|
@end deftypefun
|
||||||
|
|
||||||
@node Arrays
|
@node Arrays
|
||||||
@section Arrays
|
@section Arrays
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,27 @@
|
||||||
|
2005-04-01 Thomas Fitzsimmons <fitzsim@redhat.com>
|
||||||
|
|
||||||
|
PR libgcj/20090, PR libgcj/20526
|
||||||
|
* gij.cc (nonstandard_opts_help): New function.
|
||||||
|
(add_option): New function.
|
||||||
|
(main): Support java options. Set java.class.path. Don't set
|
||||||
|
_Jv_Jar_Class_Path.
|
||||||
|
* prims.cc (parse_x_arg): New function.
|
||||||
|
(parse_init_args): Call parse_x_arg for -X and _ options, when
|
||||||
|
ignoreUnrecognized is true.
|
||||||
|
(new _Jv_RunMain): New vm_args variant.
|
||||||
|
(old _Jv_RunMain): Call new vm_args _Jv_RunMain.
|
||||||
|
(_Jv_Jar_Class_Path): Remove variable.
|
||||||
|
* include/java-props.h: Likewise.
|
||||||
|
* include/cni.h (JvRealloc): New function.
|
||||||
|
* include/jvm.h (_Jv_RunMain): Declare vm_args variant.
|
||||||
|
* java/lang/natRuntime.cc (insertSystemProperties): Remove
|
||||||
|
_Jv_Jar_Class_Path logic. Use JV_VERSION and JV_API_VERSION
|
||||||
|
macros.
|
||||||
|
* configure.ac (JV_VERSION): Define.
|
||||||
|
(JV_API_VERSION): Likewise.
|
||||||
|
* configure: Regenerate.
|
||||||
|
* include/config.h.in: Regenerate.
|
||||||
|
|
||||||
2005-04-01 Mark Anderson <mark@panonet.net>
|
2005-04-01 Mark Anderson <mark@panonet.net>
|
||||||
|
|
||||||
* java/lang/natDouble.cc (parseDouble): Handle NaN, Infinity and
|
* java/lang/natDouble.cc (parseDouble): Handle NaN, Infinity and
|
||||||
|
|
11
libjava/configure
vendored
11
libjava/configure
vendored
|
@ -13829,6 +13829,17 @@ _ACEOF
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
cat >>confdefs.h <<\_ACEOF
|
||||||
|
#define JV_VERSION "1.4.2"
|
||||||
|
_ACEOF
|
||||||
|
|
||||||
|
|
||||||
|
cat >>confdefs.h <<\_ACEOF
|
||||||
|
#define JV_API_VERSION "1.4"
|
||||||
|
_ACEOF
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
case "${with_gxx_include_dir}" in
|
case "${with_gxx_include_dir}" in
|
||||||
yes)
|
yes)
|
||||||
{ { echo "$as_me:$LINENO: error: --with-gxx-include-dir=[dir] requires a directory" >&5
|
{ { echo "$as_me:$LINENO: error: --with-gxx-include-dir=[dir] requires a directory" >&5
|
||||||
|
|
|
@ -1196,6 +1196,9 @@ GCJVERSION=$gcjversion
|
||||||
AC_SUBST(GCJVERSION)
|
AC_SUBST(GCJVERSION)
|
||||||
AC_DEFINE_UNQUOTED(GCJVERSION, "$GCJVERSION", [Short GCJ version ID])
|
AC_DEFINE_UNQUOTED(GCJVERSION, "$GCJVERSION", [Short GCJ version ID])
|
||||||
|
|
||||||
|
AC_DEFINE(JV_VERSION, "1.4.2", [Compatibility version string])
|
||||||
|
AC_DEFINE(JV_API_VERSION, "1.4", [API compatibility version string])
|
||||||
|
|
||||||
TL_AC_GXX_INCLUDE_DIR
|
TL_AC_GXX_INCLUDE_DIR
|
||||||
|
|
||||||
# We check for sys/filio.h because Solaris 2.5 defines FIONREAD there.
|
# We check for sys/filio.h because Solaris 2.5 defines FIONREAD there.
|
||||||
|
|
|
@ -108,6 +108,12 @@ JvMalloc (jsize size)
|
||||||
return _Jv_Malloc (size);
|
return _Jv_Malloc (size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern inline void *
|
||||||
|
JvRealloc (void *ptr, jsize size)
|
||||||
|
{
|
||||||
|
return _Jv_Realloc (ptr, size);
|
||||||
|
}
|
||||||
|
|
||||||
extern inline void
|
extern inline void
|
||||||
JvFree (void *ptr)
|
JvFree (void *ptr)
|
||||||
{
|
{
|
||||||
|
|
307
libjava/gij.cc
307
libjava/gij.cc
|
@ -1,26 +1,20 @@
|
||||||
/* Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation
|
/* Copyright (C) 1999-2005 Free Software Foundation
|
||||||
|
|
||||||
This file is part of libgcj.
|
This file is part of libgcj.
|
||||||
|
|
||||||
This software is copyrighted work licensed under the terms of the
|
This software is copyrighted work licensed under the terms of the
|
||||||
Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
|
Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
|
||||||
details. */
|
details. */
|
||||||
|
|
||||||
/* Author: Kresten Krab Thorup <krab@gnu.org> */
|
|
||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
|
||||||
#include <jvm.h>
|
#include <jvm.h>
|
||||||
#include <gcj/cni.h>
|
#include <gcj/cni.h>
|
||||||
#include <java-props.h>
|
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include <java/lang/System.h>
|
|
||||||
#include <java/util/Properties.h>
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
help ()
|
help ()
|
||||||
{
|
{
|
||||||
|
@ -46,105 +40,262 @@ help ()
|
||||||
static void
|
static void
|
||||||
version ()
|
version ()
|
||||||
{
|
{
|
||||||
|
printf ("java version " JV_VERSION "\n");
|
||||||
printf ("gij (GNU libgcj) version %s\n\n", __VERSION__);
|
printf ("gij (GNU libgcj) version %s\n\n", __VERSION__);
|
||||||
printf ("Copyright (C) 2005 Free Software Foundation, Inc.\n");
|
printf ("Copyright (C) 2005 Free Software Foundation, Inc.\n");
|
||||||
printf ("This is free software; see the source for copying conditions. There is NO\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");
|
printf ("warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
static void
|
||||||
main (int argc, const char **argv)
|
nonstandard_opts_help ()
|
||||||
{
|
{
|
||||||
/* We rearrange ARGV so that all the -D options appear near the
|
printf (" -Xms<size> set initial heap size\n");
|
||||||
beginning. */
|
printf (" -Xmx<size> set maximum heap size\n");
|
||||||
int last_D_option = 0;
|
exit (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
add_option (JvVMInitArgs& vm_args, char const* option, void const* extra)
|
||||||
|
{
|
||||||
|
vm_args.options =
|
||||||
|
(JvVMOption*) JvRealloc (vm_args.options,
|
||||||
|
(vm_args.nOptions + 1) * sizeof (JvVMOption));
|
||||||
|
|
||||||
|
vm_args.options[vm_args.nOptions].optionString = const_cast<char*> (option);
|
||||||
|
vm_args.options[vm_args.nOptions].extraInfo = const_cast<void*> (extra);
|
||||||
|
++vm_args.nOptions;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main (int argc, char const** argv)
|
||||||
|
{
|
||||||
|
JvVMInitArgs vm_args;
|
||||||
bool jar_mode = false;
|
bool jar_mode = false;
|
||||||
|
|
||||||
|
vm_args.options = NULL;
|
||||||
|
vm_args.nOptions = 0;
|
||||||
|
vm_args.ignoreUnrecognized = true;
|
||||||
|
|
||||||
|
// Command-line options always override the CLASSPATH environment
|
||||||
|
// variable.
|
||||||
|
char *classpath = getenv("CLASSPATH");
|
||||||
|
|
||||||
|
if (classpath)
|
||||||
|
{
|
||||||
|
char* darg = (char*) JvMalloc (strlen (classpath)
|
||||||
|
+ sizeof ("-Djava.class.path="));
|
||||||
|
sprintf (darg, "-Djava.class.path=%s", classpath);
|
||||||
|
add_option (vm_args, darg, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Handle arguments to the java command. Store in vm_args arguments
|
||||||
|
// handled by the invocation API.
|
||||||
int i;
|
int i;
|
||||||
for (i = 1; i < argc; ++i)
|
for (i = 1; i < argc; ++i)
|
||||||
{
|
{
|
||||||
const char *arg = argv[i];
|
char* arg = const_cast<char*> (argv[i]);
|
||||||
|
|
||||||
/* A non-option stops processing. */
|
// A non-option stops processing.
|
||||||
if (arg[0] != '-')
|
if (arg[0] != '-')
|
||||||
break;
|
break;
|
||||||
/* A "--" stops processing. */
|
|
||||||
|
// A "--" stops processing.
|
||||||
if (! strcmp (arg, "--"))
|
if (! strcmp (arg, "--"))
|
||||||
{
|
{
|
||||||
++i;
|
++i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! strncmp (arg, "-D", 2))
|
// Allow both single or double hyphen for all options.
|
||||||
{
|
|
||||||
argv[last_D_option++] = arg + 2;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (! strcmp (arg, "-jar"))
|
|
||||||
{
|
|
||||||
jar_mode = true;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Allow both single or double hyphen for all remaining
|
|
||||||
options. */
|
|
||||||
if (arg[1] == '-')
|
if (arg[1] == '-')
|
||||||
++arg;
|
++arg;
|
||||||
|
|
||||||
if (! strcmp (arg, "-help") || ! strcmp (arg, "-?"))
|
// Ignore JIT options
|
||||||
help ();
|
if (! strcmp (arg, "-client"))
|
||||||
else if (! strcmp (arg, "-version"))
|
continue;
|
||||||
{
|
else if (! strcmp (arg, "-server"))
|
||||||
version ();
|
continue;
|
||||||
exit (0);
|
else if (! strcmp (arg, "-hotspot"))
|
||||||
}
|
continue;
|
||||||
else if (! strcmp (arg, "-showversion"))
|
else if (! strcmp (arg, "-jrockit"))
|
||||||
version ();
|
continue;
|
||||||
/* FIXME: use getopt and avoid the ugliness here.
|
// Ignore JVM Tool Interface options
|
||||||
We at least need to handle the argument in a better way. */
|
else if (! strncmp (arg, "-agentlib:", sizeof ("-agentlib:") - 1))
|
||||||
else if (! strncmp (arg, "-ms=", 4))
|
continue;
|
||||||
_Jv_SetInitialHeapSize (arg + 4);
|
else if (! strncmp (arg, "-agentpath:", sizeof ("-agentpath:") - 1))
|
||||||
else if (! strcmp (arg, "-ms"))
|
continue;
|
||||||
{
|
else if (! strcmp (arg, "-classpath") || ! strcmp (arg, "-cp"))
|
||||||
if (i >= argc - 1)
|
{
|
||||||
{
|
if (i >= argc - 1)
|
||||||
|
{
|
||||||
no_arg:
|
no_arg:
|
||||||
fprintf (stderr, "gij: option requires an argument -- `%s'\n",
|
fprintf (stderr, "gij: option requires an argument -- `%s'\n",
|
||||||
argv[i]);
|
argv[i]);
|
||||||
fprintf (stderr, "Try `gij --help' for more information.\n");
|
fprintf (stderr, "Try `gij --help' for more information.\n");
|
||||||
exit (1);
|
exit (1);
|
||||||
}
|
}
|
||||||
_Jv_SetInitialHeapSize (argv[++i]);
|
|
||||||
|
// Sun seems to translate the -classpath option into
|
||||||
|
// -Djava.class.path because if both -classpath and
|
||||||
|
// -Djava.class.path are specified on the java command line,
|
||||||
|
// the last one always wins.
|
||||||
|
char* darg = (char*) JvMalloc (strlen (argv[++i])
|
||||||
|
+ sizeof ("-Djava.class.path="));
|
||||||
|
sprintf (darg, "-Djava.class.path=%s", argv[i]);
|
||||||
|
add_option (vm_args, darg, NULL);
|
||||||
|
}
|
||||||
|
else if (! strcmp (arg, "-debug"))
|
||||||
|
{
|
||||||
|
char* xarg = strdup ("-Xdebug");
|
||||||
|
add_option (vm_args, xarg, NULL);
|
||||||
|
}
|
||||||
|
else if (! strncmp (arg, "-D", sizeof ("-D") - 1))
|
||||||
|
add_option (vm_args, arg, NULL);
|
||||||
|
// Ignore 32/64-bit JIT options
|
||||||
|
else if (! strcmp (arg, "-d32") || ! strcmp (arg, "-d64"))
|
||||||
|
continue;
|
||||||
|
else if (! strcmp (arg, "-enableassertions") || ! strcmp (arg, "-ea"))
|
||||||
|
{
|
||||||
|
if (i >= argc - 1)
|
||||||
|
goto no_arg;
|
||||||
|
// FIXME: hook up assertion support
|
||||||
|
++i;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
else if (! strcmp (arg, "-disableassertions") || ! strcmp (arg, "-da"))
|
||||||
|
{
|
||||||
|
if (i >= argc - 1)
|
||||||
|
goto no_arg;
|
||||||
|
// FIXME
|
||||||
|
++i;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
else if (! strcmp (arg, "-enablesystemassertions")
|
||||||
|
|| ! strcmp (arg, "-esa"))
|
||||||
|
{
|
||||||
|
// FIXME: hook up system assertion support
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
else if (! strcmp (arg, "-disablesystemassertions")
|
||||||
|
|| ! strcmp (arg, "-dsa"))
|
||||||
|
{
|
||||||
|
// FIXME
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
else if (! strcmp (arg, "-jar"))
|
||||||
|
{
|
||||||
|
jar_mode = true;
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
else if (! strncmp (arg, "-mx=", 4))
|
// Ignore java.lang.instrument option
|
||||||
_Jv_SetMaximumHeapSize (arg + 4);
|
else if (! strncmp (arg, "-javaagent:", sizeof ("-javaagent:") - 1))
|
||||||
|
continue;
|
||||||
|
else if (! strcmp (arg, "-noclassgc"))
|
||||||
|
{
|
||||||
|
char* xarg = strdup ("-Xnoclassgc");
|
||||||
|
add_option (vm_args, xarg, NULL);
|
||||||
|
}
|
||||||
|
// -ms=n
|
||||||
|
else if (! strncmp (arg, "-ms=", sizeof ("-ms=") - 1))
|
||||||
|
{
|
||||||
|
arg[1] = 'X';
|
||||||
|
arg[2] = 'm';
|
||||||
|
arg[3] = 's';
|
||||||
|
add_option (vm_args, arg, NULL);
|
||||||
|
}
|
||||||
|
// -ms n
|
||||||
|
else if (! strcmp (arg, "-ms"))
|
||||||
|
{
|
||||||
|
if (i >= argc - 1)
|
||||||
|
goto no_arg;
|
||||||
|
|
||||||
|
char* xarg = (char*) JvMalloc (strlen (argv[++i])
|
||||||
|
+ sizeof ("-Xms"));
|
||||||
|
sprintf (xarg, "-Xms%s", argv[i]);
|
||||||
|
add_option (vm_args, xarg, NULL);
|
||||||
|
}
|
||||||
|
// -msn
|
||||||
|
else if (! strncmp (arg, "-ms", sizeof ("-ms") - 1))
|
||||||
|
{
|
||||||
|
char* xarg = (char*) JvMalloc (strlen (arg) + sizeof ("X"));
|
||||||
|
sprintf (xarg, "-Xms%s", arg + sizeof ("-Xms") - 1);
|
||||||
|
add_option (vm_args, xarg, NULL);
|
||||||
|
}
|
||||||
|
// -mx=n
|
||||||
|
else if (! strncmp (arg, "-mx=", sizeof ("-mx=") - 1))
|
||||||
|
{
|
||||||
|
arg[1] = 'X';
|
||||||
|
arg[2] = 'm';
|
||||||
|
arg[3] = 'x';
|
||||||
|
add_option (vm_args, arg, NULL);
|
||||||
|
}
|
||||||
|
// -mx n
|
||||||
else if (! strcmp (arg, "-mx"))
|
else if (! strcmp (arg, "-mx"))
|
||||||
{
|
{
|
||||||
if (i >= argc - 1)
|
if (i >= argc - 1)
|
||||||
goto no_arg;
|
goto no_arg;
|
||||||
_Jv_SetMaximumHeapSize (argv[++i]);
|
|
||||||
|
char* xarg = (char*) JvMalloc (strlen (argv[++i])
|
||||||
|
+ sizeof ("-Xmx"));
|
||||||
|
sprintf (xarg, "-Xmx%s", argv[i]);
|
||||||
|
add_option (vm_args, xarg, NULL);
|
||||||
}
|
}
|
||||||
else if (! strcmp (arg, "-cp") || ! strcmp (arg, "-classpath"))
|
// -mxn
|
||||||
|
else if (! strncmp (arg, "-mx", sizeof ("-mx") - 1))
|
||||||
|
{
|
||||||
|
char* xarg = (char*) JvMalloc (strlen (arg) + sizeof ("X"));
|
||||||
|
sprintf (xarg, "-Xmx%s", arg + sizeof ("-Xmx") - 1);
|
||||||
|
add_option (vm_args, xarg, NULL);
|
||||||
|
}
|
||||||
|
// -ss=n
|
||||||
|
else if (! strncmp (arg, "-ss=", sizeof ("-ss=") - 1))
|
||||||
|
{
|
||||||
|
arg[1] = 'X';
|
||||||
|
arg[2] = 's';
|
||||||
|
arg[3] = 's';
|
||||||
|
add_option (vm_args, arg, NULL);
|
||||||
|
}
|
||||||
|
// -ss n
|
||||||
|
else if (! strcmp (arg, "-ss"))
|
||||||
{
|
{
|
||||||
if (i >= argc - 1)
|
if (i >= argc - 1)
|
||||||
goto no_arg;
|
goto no_arg;
|
||||||
// We set _Jv_Jar_Class_Path. If the user specified `-jar'
|
|
||||||
// then the jar code will override this. This is the
|
char* xarg = (char*) JvMalloc (strlen (argv[++i])
|
||||||
// correct behavior.
|
+ sizeof ("-Xss"));
|
||||||
_Jv_Jar_Class_Path = argv[++i];
|
sprintf (xarg, "-Xss%s", argv[i]);
|
||||||
|
add_option (vm_args, xarg, NULL);
|
||||||
}
|
}
|
||||||
else if (! strcmp (arg, "-verbose") || ! strcmp (arg, "-verbose:class"))
|
// -ssn
|
||||||
gcj::verbose_class_flag = true;
|
else if (! strncmp (arg, "-ss", sizeof ("-ss") - 1))
|
||||||
else if (arg[1] == 'X')
|
|
||||||
{
|
{
|
||||||
if (arg[2] == '\0')
|
char* xarg = (char*) JvMalloc (strlen (arg) + sizeof ("X"));
|
||||||
{
|
sprintf (xarg, "-Xss%s", arg + sizeof ("-Xss") - 1);
|
||||||
printf ("gij: currently no -X options are recognized\n");
|
add_option (vm_args, xarg, NULL);
|
||||||
exit (0);
|
|
||||||
}
|
|
||||||
/* Ignore other -X options. */
|
|
||||||
}
|
}
|
||||||
|
// This handles all the option variants that begin with
|
||||||
|
// -verbose.
|
||||||
|
else if (! strncmp (arg, "-verbose", 8))
|
||||||
|
add_option (vm_args, arg, NULL);
|
||||||
|
else if (! strcmp (arg, "-version"))
|
||||||
|
{
|
||||||
|
version ();
|
||||||
|
exit (0);
|
||||||
|
}
|
||||||
|
else if (! strcmp (arg, "-fullversion"))
|
||||||
|
{
|
||||||
|
printf ("java full version \"gcj-" JV_VERSION "\"\n");
|
||||||
|
exit (0);
|
||||||
|
}
|
||||||
|
else if (! strcmp (arg, "-showversion"))
|
||||||
|
version ();
|
||||||
|
else if (! strcmp (arg, "-help") || ! strcmp (arg, "-?"))
|
||||||
|
help ();
|
||||||
|
else if (! strcmp (arg, "-X"))
|
||||||
|
nonstandard_opts_help ();
|
||||||
|
else if (! strncmp (arg, "-X", 2))
|
||||||
|
add_option (vm_args, arg, NULL);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fprintf (stderr, "gij: unrecognized option -- `%s'\n", argv[i]);
|
fprintf (stderr, "gij: unrecognized option -- `%s'\n", argv[i]);
|
||||||
|
@ -153,9 +304,6 @@ main (int argc, const char **argv)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
argv[last_D_option] = NULL;
|
|
||||||
_Jv_Compiler_Properties = argv;
|
|
||||||
|
|
||||||
if (argc - i < 1)
|
if (argc - i < 1)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "Usage: gij [OPTION] ... CLASS [ARGS] ...\n");
|
fprintf (stderr, "Usage: gij [OPTION] ... CLASS [ARGS] ...\n");
|
||||||
|
@ -166,5 +314,16 @@ main (int argc, const char **argv)
|
||||||
exit (1);
|
exit (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
_Jv_RunMain (NULL, argv[i], argc - i, argv + i, jar_mode);
|
// -jar mode overrides all other modes of specifying class path:
|
||||||
|
// -CLASSPATH, -Djava.class.path, -classpath and -cp.
|
||||||
|
if (jar_mode)
|
||||||
|
{
|
||||||
|
char* darg = (char*) JvMalloc (strlen (argv[i])
|
||||||
|
+ sizeof ("-Djava.class.path="));
|
||||||
|
sprintf (darg, "-Djava.class.path=%s", argv[i]);
|
||||||
|
add_option (vm_args, darg, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
_Jv_RunMain (&vm_args, NULL, argv[i], argc - i,
|
||||||
|
(char const**) (argv + i), jar_mode);
|
||||||
}
|
}
|
||||||
|
|
|
@ -364,6 +364,9 @@
|
||||||
/* Define if you want a bytecode interpreter. */
|
/* Define if you want a bytecode interpreter. */
|
||||||
#undef INTERPRETER
|
#undef INTERPRETER
|
||||||
|
|
||||||
|
/* API compatibility version string */
|
||||||
|
#undef JV_API_VERSION
|
||||||
|
|
||||||
/* Define if hash synchronization is in use */
|
/* Define if hash synchronization is in use */
|
||||||
#undef JV_HASH_SYNCHRONIZATION
|
#undef JV_HASH_SYNCHRONIZATION
|
||||||
|
|
||||||
|
@ -373,6 +376,9 @@
|
||||||
/* Indicate that linker is not able to 8-byte align static data */
|
/* Indicate that linker is not able to 8-byte align static data */
|
||||||
#undef JV_LINKER_CANNOT_8BYTE_ALIGN_STATICS
|
#undef JV_LINKER_CANNOT_8BYTE_ALIGN_STATICS
|
||||||
|
|
||||||
|
/* Compatibility version string */
|
||||||
|
#undef JV_VERSION
|
||||||
|
|
||||||
/* Define if we want to use debug calls into the garbage collector. */
|
/* Define if we want to use debug calls into the garbage collector. */
|
||||||
#undef LIBGCJ_GC_DEBUG
|
#undef LIBGCJ_GC_DEBUG
|
||||||
|
|
||||||
|
|
|
@ -23,9 +23,6 @@ typedef struct
|
||||||
extern const char **_Jv_Compiler_Properties;
|
extern const char **_Jv_Compiler_Properties;
|
||||||
extern int _Jv_Properties_Count;
|
extern int _Jv_Properties_Count;
|
||||||
|
|
||||||
// The JAR file to add to the beginning of java.class.path.
|
|
||||||
extern const char *_Jv_Jar_Class_Path;
|
|
||||||
|
|
||||||
// Properties taken from the user's environment.
|
// Properties taken from the user's environment.
|
||||||
extern property_pair *_Jv_Environment_Properties;
|
extern property_pair *_Jv_Environment_Properties;
|
||||||
|
|
||||||
|
|
|
@ -360,6 +360,9 @@ extern "C" void JvRunMain (jclass klass, int argc, const char **argv);
|
||||||
void _Jv_RunMain (jclass klass, const char *name, int argc, const char **argv,
|
void _Jv_RunMain (jclass klass, const char *name, int argc, const char **argv,
|
||||||
bool is_jar);
|
bool is_jar);
|
||||||
|
|
||||||
|
void _Jv_RunMain (struct _Jv_VMInitArgs *vm_args, jclass klass,
|
||||||
|
const char *name, int argc, const char **argv, bool is_jar);
|
||||||
|
|
||||||
// Delayed until after _Jv_AllocBytes is declared.
|
// Delayed until after _Jv_AllocBytes is declared.
|
||||||
//
|
//
|
||||||
// Note that we allocate this as unscanned memory -- the vtables
|
// Note that we allocate this as unscanned memory -- the vtables
|
||||||
|
|
|
@ -369,8 +369,8 @@ java::lang::Runtime::insertSystemProperties (java::util::Properties *newprops)
|
||||||
// (introduced in 1.2), and earlier versioning properties. Some
|
// (introduced in 1.2), and earlier versioning properties. Some
|
||||||
// programs rely on seeing values that they expect, so we claim to
|
// programs rely on seeing values that they expect, so we claim to
|
||||||
// be a 1.4-ish VM for their sake.
|
// be a 1.4-ish VM for their sake.
|
||||||
SET ("java.version", "1.4.2");
|
SET ("java.version", JV_VERSION);
|
||||||
SET ("java.runtime.version", "1.4.2");
|
SET ("java.runtime.version", JV_VERSION);
|
||||||
SET ("java.vendor", "Free Software Foundation, Inc.");
|
SET ("java.vendor", "Free Software Foundation, Inc.");
|
||||||
SET ("java.vendor.url", "http://gcc.gnu.org/java/");
|
SET ("java.vendor.url", "http://gcc.gnu.org/java/");
|
||||||
SET ("java.class.version", "46.0");
|
SET ("java.class.version", "46.0");
|
||||||
|
@ -380,7 +380,7 @@ java::lang::Runtime::insertSystemProperties (java::util::Properties *newprops)
|
||||||
SET ("java.vm.version", __VERSION__);
|
SET ("java.vm.version", __VERSION__);
|
||||||
SET ("java.vm.vendor", "Free Software Foundation, Inc.");
|
SET ("java.vm.vendor", "Free Software Foundation, Inc.");
|
||||||
SET ("java.vm.name", "GNU libgcj");
|
SET ("java.vm.name", "GNU libgcj");
|
||||||
SET ("java.specification.version", "1.4");
|
SET ("java.specification.version", JV_API_VERSION);
|
||||||
SET ("java.specification.name", "Java(tm) Platform API Specification");
|
SET ("java.specification.name", "Java(tm) Platform API Specification");
|
||||||
SET ("java.specification.vendor", "Sun Microsystems Inc.");
|
SET ("java.specification.vendor", "Sun Microsystems Inc.");
|
||||||
|
|
||||||
|
@ -569,30 +569,6 @@ java::lang::Runtime::insertSystemProperties (java::util::Properties *newprops)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (_Jv_Jar_Class_Path)
|
|
||||||
newprops->put(JvNewStringLatin1 ("java.class.path"),
|
|
||||||
JvNewStringLatin1 (_Jv_Jar_Class_Path));
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// FIXME: find libgcj.zip and append its path?
|
|
||||||
char *classpath = ::getenv("CLASSPATH");
|
|
||||||
jstring cp = newprops->getProperty (JvNewStringLatin1("java.class.path"));
|
|
||||||
java::lang::StringBuffer *sb = new java::lang::StringBuffer ();
|
|
||||||
|
|
||||||
if (classpath)
|
|
||||||
{
|
|
||||||
sb->append (JvNewStringLatin1 (classpath));
|
|
||||||
sb->append (_Jv_platform_path_separator);
|
|
||||||
}
|
|
||||||
if (cp != NULL)
|
|
||||||
sb->append (cp);
|
|
||||||
else
|
|
||||||
sb->append ((jchar) '.');
|
|
||||||
|
|
||||||
newprops->put(JvNewStringLatin1 ("java.class.path"),
|
|
||||||
sb->toString ());
|
|
||||||
}
|
|
||||||
|
|
||||||
// The name used to invoke this process (argv[0] in C).
|
// The name used to invoke this process (argv[0] in C).
|
||||||
SET ("gnu.gcj.progname", _Jv_GetSafeArg (0));
|
SET ("gnu.gcj.progname", _Jv_GetSafeArg (0));
|
||||||
|
|
||||||
|
|
148
libjava/prims.cc
148
libjava/prims.cc
|
@ -85,9 +85,6 @@ static java::lang::OutOfMemoryError *no_memory;
|
||||||
const char **_Jv_Compiler_Properties = NULL;
|
const char **_Jv_Compiler_Properties = NULL;
|
||||||
int _Jv_Properties_Count = 0;
|
int _Jv_Properties_Count = 0;
|
||||||
|
|
||||||
// The JAR file to add to the beginning of java.class.path.
|
|
||||||
const char *_Jv_Jar_Class_Path;
|
|
||||||
|
|
||||||
#ifndef DISABLE_GETENV_PROPERTIES
|
#ifndef DISABLE_GETENV_PROPERTIES
|
||||||
// Property key/value pairs.
|
// Property key/value pairs.
|
||||||
property_pair *_Jv_Environment_Properties;
|
property_pair *_Jv_Environment_Properties;
|
||||||
|
@ -909,9 +906,115 @@ namespace gcj
|
||||||
bool runtimeInitialized = false;
|
bool runtimeInitialized = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// We accept all non-standard options accepted by Sun's java command,
|
||||||
|
// for compatibility with existing application launch scripts.
|
||||||
|
static jint
|
||||||
|
parse_x_arg (char* option_string)
|
||||||
|
{
|
||||||
|
if (strlen (option_string) <= 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if (! strcmp (option_string, "int"))
|
||||||
|
{
|
||||||
|
// FIXME: this should cause the vm to never load shared objects
|
||||||
|
}
|
||||||
|
else if (! strcmp (option_string, "mixed"))
|
||||||
|
{
|
||||||
|
// FIXME: allow interpreted and native code
|
||||||
|
}
|
||||||
|
else if (! strcmp (option_string, "batch"))
|
||||||
|
{
|
||||||
|
// FIXME: disable background JIT'ing
|
||||||
|
}
|
||||||
|
else if (! strcmp (option_string, "debug"))
|
||||||
|
{
|
||||||
|
// FIXME: add JDWP/JVMDI support
|
||||||
|
}
|
||||||
|
else if (! strncmp (option_string, "bootclasspath:", 14))
|
||||||
|
{
|
||||||
|
// FIXME: add a parse_bootclasspath_arg function
|
||||||
|
}
|
||||||
|
else if (! strncmp (option_string, "bootclasspath/a:", 16))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
else if (! strncmp (option_string, "bootclasspath/p:", 16))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
else if (! strcmp (option_string, "check:jni"))
|
||||||
|
{
|
||||||
|
// FIXME: enable strict JNI checking
|
||||||
|
}
|
||||||
|
else if (! strcmp (option_string, "future"))
|
||||||
|
{
|
||||||
|
// FIXME: enable strict class file format checks
|
||||||
|
}
|
||||||
|
else if (! strcmp (option_string, "noclassgc"))
|
||||||
|
{
|
||||||
|
// FIXME: disable garbage collection for classes
|
||||||
|
}
|
||||||
|
else if (! strcmp (option_string, "incgc"))
|
||||||
|
{
|
||||||
|
// FIXME: incremental garbage collection
|
||||||
|
}
|
||||||
|
else if (! strncmp (option_string, "loggc:", 6))
|
||||||
|
{
|
||||||
|
if (option_string[6] == '\0')
|
||||||
|
{
|
||||||
|
fprintf (stderr,
|
||||||
|
"libgcj: filename argument expected for loggc option\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
// FIXME: set gc logging filename
|
||||||
|
}
|
||||||
|
else if (! strncmp (option_string, "ms", 2))
|
||||||
|
{
|
||||||
|
// FIXME: ignore this option until PR 20699 is fixed.
|
||||||
|
// _Jv_SetInitialHeapSize (option_string + 2);
|
||||||
|
}
|
||||||
|
else if (! strncmp (option_string, "mx", 2))
|
||||||
|
_Jv_SetMaximumHeapSize (option_string + 2);
|
||||||
|
else if (! strcmp (option_string, "prof"))
|
||||||
|
{
|
||||||
|
// FIXME: enable profiling of program running in vm
|
||||||
|
}
|
||||||
|
else if (! strncmp (option_string, "runhprof:", 9))
|
||||||
|
{
|
||||||
|
// FIXME: enable specific type of vm profiling. add a
|
||||||
|
// parse_runhprof_arg function
|
||||||
|
}
|
||||||
|
else if (! strcmp (option_string, "rs"))
|
||||||
|
{
|
||||||
|
// FIXME: reduced system signal usage. disable thread dumps,
|
||||||
|
// only terminate in response to user-initiated calls,
|
||||||
|
// e.g. System.exit()
|
||||||
|
}
|
||||||
|
else if (! strncmp (option_string, "ss", 2))
|
||||||
|
{
|
||||||
|
// FIXME: set thread stack size
|
||||||
|
}
|
||||||
|
else if (! strcmp (option_string, "X:+UseAltSigs"))
|
||||||
|
{
|
||||||
|
// FIXME: use signals other than SIGUSR1 and SIGUSR2
|
||||||
|
}
|
||||||
|
else if (! strcmp (option_string, "share:off"))
|
||||||
|
{
|
||||||
|
// FIXME: don't share class data
|
||||||
|
}
|
||||||
|
else if (! strcmp (option_string, "share:auto"))
|
||||||
|
{
|
||||||
|
// FIXME: share class data where possible
|
||||||
|
}
|
||||||
|
else if (! strcmp (option_string, "share:on"))
|
||||||
|
{
|
||||||
|
// FIXME: fail if impossible to share class data
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static jint
|
static jint
|
||||||
parse_verbose_args (char* option_string,
|
parse_verbose_args (char* option_string,
|
||||||
bool ignore_unrecognized)
|
bool ignore_unrecognized)
|
||||||
{
|
{
|
||||||
size_t len = sizeof ("-verbose");
|
size_t len = sizeof ("-verbose");
|
||||||
|
|
||||||
|
@ -1045,7 +1148,7 @@ parse_init_args (JvVMInitArgs* vm_args)
|
||||||
"-verbose", sizeof ("-verbose") - 1))
|
"-verbose", sizeof ("-verbose") - 1))
|
||||||
{
|
{
|
||||||
jint result = parse_verbose_args (option_string,
|
jint result = parse_verbose_args (option_string,
|
||||||
vm_args->ignoreUnrecognized);
|
vm_args->ignoreUnrecognized);
|
||||||
if (result < 0)
|
if (result < 0)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -1061,11 +1164,20 @@ parse_init_args (JvVMInitArgs* vm_args)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else if (vm_args->ignoreUnrecognized)
|
else if (vm_args->ignoreUnrecognized)
|
||||||
{
|
{
|
||||||
if (option_string[0] == '_'
|
if (option_string[0] == '_')
|
||||||
|| ! strncmp (option_string, "-X", 2))
|
parse_x_arg (option_string + 1);
|
||||||
continue;
|
else if (! strncmp (option_string, "-X", 2))
|
||||||
|
parse_x_arg (option_string + 2);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
unknown_option:
|
||||||
|
fprintf (stderr, "libgcj: unknown option: %s\n", option_string);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
goto unknown_option;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1167,8 +1279,8 @@ _Jv_CreateJavaVM (JvVMInitArgs* vm_args)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
_Jv_RunMain (jclass klass, const char *name, int argc, const char **argv,
|
_Jv_RunMain (JvVMInitArgs *vm_args, jclass klass, const char *name, int argc,
|
||||||
bool is_jar)
|
const char **argv, bool is_jar)
|
||||||
{
|
{
|
||||||
#ifndef DISABLE_MAIN_ARGS
|
#ifndef DISABLE_MAIN_ARGS
|
||||||
_Jv_SetArgs (argc, argv);
|
_Jv_SetArgs (argc, argv);
|
||||||
|
@ -1178,12 +1290,7 @@ _Jv_RunMain (jclass klass, const char *name, int argc, const char **argv,
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Set this very early so that it is seen when java.lang.System
|
if (_Jv_CreateJavaVM (vm_args) < 0)
|
||||||
// is initialized.
|
|
||||||
if (is_jar)
|
|
||||||
_Jv_Jar_Class_Path = strdup (name);
|
|
||||||
|
|
||||||
if (_Jv_CreateJavaVM (NULL) < 0)
|
|
||||||
{
|
{
|
||||||
fprintf (stderr, "libgcj: couldn't create virtual machine\n");
|
fprintf (stderr, "libgcj: couldn't create virtual machine\n");
|
||||||
exit (1);
|
exit (1);
|
||||||
|
@ -1225,6 +1332,13 @@ _Jv_RunMain (jclass klass, const char *name, int argc, const char **argv,
|
||||||
runtime->exit (status);
|
runtime->exit (status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
_Jv_RunMain (jclass klass, const char *name, int argc, const char **argv,
|
||||||
|
bool is_jar)
|
||||||
|
{
|
||||||
|
_Jv_RunMain (NULL, klass, name, argc, argv, is_jar);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
JvRunMain (jclass klass, int argc, const char **argv)
|
JvRunMain (jclass klass, int argc, const char **argv)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue