/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
/*
* Gamma (Hotspot internal engineering test) launcher based on 6.0u22 JDK,
* search "GAMMA" for gamma specific changes.
*
* GAMMA: gamma launcher is much simpler than regular java launcher in that
* JVM is either statically linked in or it is installed in the
* same directory where the launcher exists, so we don't have to
* worry about choosing the right JVM based on command line flag, jar
* they are commented out with #ifndef GAMMA, hopefully it'll be easier
* to maintain this file in sync with regular JDK launcher.
*/
/*
* Shared source for 'java' command line tool.
*
* If JAVA_ARGS is defined, then acts as a launcher for applications. For
* instance, the JDK command line tools such as javac and javadoc (see
* makefiles for more details) are built with this program. Any arguments
* prefixed with '-J' will be passed directly to the 'java' command.
*/
#ifdef GAMMA
# ifdef JAVA_ARGS
# endif
# if !defined(LINK_INTO_AOUT) && !defined(LINK_INTO_LIBJVM)
# endif
#endif
/*
* One job of the launcher is to remove command line options which the
* vm does not understand and will not process. These options include
* options which select which style of vm is run (e.g. -client and
* -server) as well as options which select the data model to use.
* Additionally, for tools which invoke an underlying vm "-J-foo"
* options are turned into "-foo" options to the vm. This option
* filtering is handled in a number of places in the launcher, some of
* it in machine-dependent code. In this file, the function
* CheckJVMType removes vm style options and TranslateApplicationArgs
* removes "-J" prefixes. On unix platforms, the
* CreateExecutionEnvironment function from the unix java_md.c file
* processes and removes -d<n> options. However, in case
* CreateExecutionEnvironment does not need to exec because
* LD_LIBRARY_PATH is set acceptably and the data model does not need
* to be changed, ParseArguments will screen out the redundant -d<n>
* options and prevent them from being passed to the vm; this is done
* by using the machine-dependent call
* RemovableMachineDependentOption.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <jni.h>
#include <jvm.h>
#include "java.h"
#ifndef GAMMA
#include "manifest_info.h"
#include "version_comp.h"
#include "splashscreen.h"
#endif
#include "wildcard.h"
#ifndef FULL_VERSION
#endif
/*
* The following environment variable is used to influence the behavior
* of the jre exec'd through the SelectVersion routine. The command line
* options which specify the version are not passed to the exec'd version,
* because that jre may be an older version which wouldn't recognize them.
* This environment variable is known to this (and later) version and serves
* to suppress the version selection code. This is not only for efficiency,
* but also for correctness, since any command line options have been
* removed which would cause any value found in the manifest to be used.
* This would be incorrect because the command line options are defined
* to take precedence.
*
* The value associated with this environment variable is the MainClass
* name from within the executable jar file (if any). This is strictly a
* performance enhancement to avoid re-reading the jar file manifest.
*
* A NOTE TO DEVELOPERS: For performance reasons it is important that
* the program image remain relatively small until after SelectVersion
* CreateExecutionEnvironment have finished their possibly recursive
* processing. Watch everything, but resist all temptations to use Java
* interfaces.
*/
#ifndef GAMMA
#endif
static char *progname;
#ifndef GAMMA
/*
* Entries for splash screen environment variables.
* putenv is performed in SelectVersion. We need
* them in memory until UnsetEnv, so they are made static
* global instead of auto local.
*/
#endif
/*
* List of VM options to be specified when the VM is created.
*/
/*
* Prototypes for functions internal to launcher.
*/
static void SetClassPath(const char *s);
static void SetJavaLauncherProp(void);
#ifdef JAVA_ARGS
static jboolean AddApplicationOptions(void);
#endif
static void PrintUsage(void);
#ifndef GAMMA
/* Maximum supported entries from jvm.cfg. */
/* Values for vmdesc.flag */
#define VM_KNOWN 0
struct vmdesc {
char *name;
int flag;
char *alias;
char *server_class;
};
static int knownVMsCount = 0;
static int knownVMsLimit = 0;
static void GrowKnownVMs();
static int KnownVMIndex(const char* name);
static void FreeKnownVMs();
static void ShowSplashScreen();
#endif /* ifndef GAMMA */
/* flag which if set suppresses error messages from the launcher */
static int noExitErrorMessage = 0;
/*
* Running Java code in primordial thread caused many problems. We will
* create a new thread to invoke JVM. See 6316197 for more information.
*/
struct JavaMainArgs {
int argc;
char ** argv;
char * jarfile;
char * classname;
};
/*
* Entry point.
*/
int
{
char *jarfile = 0;
char *classname = 0;
char *s = 0;
int ret;
if (getenv("_JAVA_LAUNCHER_DEBUG") != 0) {
printf("----_JAVA_LAUNCHER_DEBUG----\n");
}
#ifndef GAMMA
/*
* Make sure the specified version of the JRE is running.
*
* There are three things to note about the SelectVersion() routine:
* 1) If the version running isn't correct, this routine doesn't
* return (either the correct version has been exec'd or an error
* was issued).
* 2) Argc and Argv in this scope are *not* altered by this routine.
* It is the responsibility of subsequent code to ignore the
* arguments handled by this routine.
* 3) As a side-effect, the variable "main_class" is guaranteed to
* be set (if it should ever be set). This isn't exactly the
* poster child for structured programming, but it is a small
* price to pay for not processing a jar file operand twice.
* (Note: This side effect has been disabled. See comment on
* bugid 5030265 below.)
*/
#endif /* ifndef GAMMA */
/* copy original argv */
{
int i;
for(i = 0; i < argc+1; i++)
original_argv[i] = argv[i];
}
ifn.CreateJavaVM = 0;
if (_launcher_debug)
start = CounterGet();
exit(6);
}
if (_launcher_debug) {
end = CounterGet();
printf("%ld micro seconds to LoadJavaVM\n",
}
#ifdef JAVA_ARGS /* javac, jar and friends. */
progname = "java";
#else /* java, oldjava, javaw and friends */
#ifdef PROGNAME
#else
progname = s + 1;
}
#endif /* PROGNAME */
#endif /* JAVA_ARGS */
++argv;
--argc;
#ifdef JAVA_ARGS
/* Preprocess wrapper arguments */
if (!AddApplicationOptions()) {
exit(1);
}
#endif
/* Set default CLASSPATH */
if ((s = getenv("CLASSPATH")) == 0) {
s = ".";
}
#ifndef JAVA_ARGS
SetClassPath(s);
#endif
/*
* Parse command line options; if the return value of
* ParseArguments is false, the program should exit.
*/
}
/* Override class path if -jar flag was specified */
if (jarfile != 0) {
}
/* set the -Dsun.java.command pseudo property */
/* Set the -Dsun.java.launcher pseudo property */
/* set the -Dsun.java.launcher.* platform properties */
#ifndef GAMMA
/* Show the splash screen if needed */
#endif
/*
* Done with all command line processing and potential re-execs so
* clean up the environment.
*/
#ifndef GAMMA
(void)UnsetEnv(SPLASH_FILE_ENV_ENTRY);
(void)UnsetEnv(SPLASH_JAR_ENV_ENTRY);
#endif
/*
* If user doesn't specify stack size, check if VM has a preference.
* Note that HotSpot no longer supports JNI_VERSION_1_1 but it will
* return its default stack size through the init args structure.
*/
if (threadStackSize == 0) {
if (args1_1.javaStackSize > 0) {
}
}
{ /* Create a new thread to create JVM and invoke main method */
}
}
int JNICALL
{
int ret = 0;
/*
* Error message to print or display; by default the message will
* only be displayed in a window.
*/
/* Initialize the virtual machine */
if (_launcher_debug)
start = CounterGet();
ReportErrorMessage("Could not create the Java virtual machine.",
JNI_TRUE);
exit(1);
}
if (printVersion || showVersion) {
goto leave;
}
if (printVersion) {
ret = 0;
goto leave;
}
if (showVersion) {
}
}
/* If the user specified neither a class name nor a JAR file */
PrintUsage();
goto leave;
}
#ifndef GAMMA
FreeKnownVMs(); /* after last possible PrintUsage() */
#endif
if (_launcher_debug) {
end = CounterGet();
printf("%ld micro seconds to InitializeJVM\n",
}
if (_launcher_debug) {
int i = 0;
for (; i < argc; i++) {
}
}
ret = 1;
/*
* Get the application's main class.
*
* See bugid 5030265. The Main-Class name has already been parsed
* from the manifest, but not parsed properly for UTF-8 support.
* Hence the code here ignores the value previously extracted and
* uses the pre-existing code to reextract the value. This is
* possibly an end of release cycle expedient. However, it has
* also been discovered that passing some character sets through
* the environment has "strange" behavior on some variants of
* Windows. Hence, maybe the manifest parsing code local to the
* launcher should never be enhanced.
*
* Hence, future work should either:
* 1) Correct the local parsing code and verify that the
* Main-Class attribute gets properly passed through
* all environments,
* 2) Remove the vestages of maintaining main_class through
* the environment (and remove these comments).
*/
if (jarfile != 0) {
goto leave;
}
if (mainClassName == NULL) {
"attribute from\n%s";
sizeof(char));
goto leave;
}
goto leave;
}
goto leave;
}
} else {
if (mainClassName == NULL) {
sizeof(char) );
goto leave;
}
goto leave;
}
goto leave;
}
}
/* Get the application's main method */
} else {
message = "No main method found in specified class.";
}
goto leave;
}
{ /* Make sure the main method is public */
goto leave;
}
mid =
"getModifiers", "()I");
goto leave;
}
message = "Main method not public.";
goto leave;
}
}
/* Build argument array */
goto leave;
}
/* Invoke main method. */
/*
* The launcher's exit code (in the absence of calls to
* System.exit) will be non-zero if main threw an exception.
*/
/*
* Detach the main thread so that it appears to have ended when
* the application's main method exits. This will invoke the
* uncaught exception handler machinery if main threw an
* exception. An uncaught exception handler cannot change the
* launcher's return code except by calling System.exit.
*/
message = "Could not detach main thread.";
ret = 1;
goto leave;
}
/*
* Wait for all non-daemon threads to end, then destroy the VM.
* This will actually create a trivial new Java waiter thread
* named "DestroyJavaVM", but this will be seen as a different
* thread from the one that executed main, even though they are
* the same C thread. This allows mainThread.join() and
* mainThread.isAlive() to work as expected.
*/
return ret;
}
#ifndef GAMMA
/*
* Checks the command line options to find which JVM type was
* specified. If no command line option was given for the JVM type,
* the default type is used. The environment variable
* JDK_ALTERNATE_VM and the command line option -XXaltjvm= are also
* checked as ways of specifying which JVM type to invoke.
*/
char *
int i, argi;
int argc;
char **newArgv;
int newArgvIdx = 0;
int isVMType;
/* To make things simpler we always copy the argv array */
/* The program name is always present */
isVMType = 0;
#ifdef JAVA_ARGS
if (arg[0] != '-') {
continue;
}
#else
argi++;
}
continue;
}
if (arg[0] != '-') break;
#endif
/* Did the user pass an explicit VM type? */
i = KnownVMIndex(arg);
if (i >= 0) {
isVMType = 1;
}
/* Did the user specify an "alternate" VM? */
isVMType = 1;
jvmidx = -1;
}
if (!isVMType) {
}
}
/*
* Finish copying the arguments if we aborted the above loop.
* NOTE that if we aborted via "break" then we did NOT copy the
* last argument above, and in addition argi will be less than
* argc.
*/
argi++;
}
/* argv is null-terminated */
newArgv[newArgvIdx] = 0;
/* Copy back argv */
*pargc = newArgvIdx;
/* use the default VM type if not specified (no alias processing) */
/* Use a different VM type if we are on a server class machine? */
(ServerClassMachine() == JNI_TRUE)) {
}
if (_launcher_debug) {
}
return result;
}
/* if using an alternate VM, no alias processing */
if (jvmidx < 0)
return jvmtype;
/* Resolve aliases first */
{
int loopCount = 0;
if (loopCount > knownVMsCount) {
if (!speculative) {
ReportErrorMessage("Error: Corrupt jvm.cfg file; cycle in alias list.",
JNI_TRUE);
exit(1);
} else {
return "ERROR";
/* break; */
}
}
if (nextIdx < 0) {
if (!speculative) {
ReportErrorMessage2("Error: Unable to resolve VM alias %s",
exit(1);
} else {
return "ERROR";
}
}
loopCount++;
}
}
case VM_WARN:
if (!speculative) {
}
/* fall through */
case VM_IGNORE:
/* fall through */
case VM_KNOWN:
break;
case VM_ERROR:
if (!speculative) {
exit(1);
} else {
return "ERROR";
}
}
return jvmtype;
}
#endif /* ifndef GAMMA */
/* copied from HotSpot function "atomll()" */
static int
jlong n = 0;
if (args_read != 1) {
return 0;
}
while (*s != '\0' && *s >= '0' && *s <= '9') {
s++;
}
// 4705540: illegal if more characters are found after the first non-digit
if (strlen(s) > 1) {
return 0;
}
switch (*s) {
case 'T': case 't':
return 1;
case 'G': case 'g':
return 1;
case 'M': case 'm':
return 1;
case 'K': case 'k':
return 1;
case '\0':
*result = n;
return 1;
default:
/* Create JVM with default stack and let VM handle malformed -Xss string*/
return 0;
}
}
/*
* Adds a new VM option with the given given name and value.
*/
void
{
/*
* Expand options array if needed to accommodate at least one more
* VM option.
*/
if (numOptions >= maxOptions) {
if (options == 0) {
maxOptions = 4;
} else {
maxOptions *= 2;
}
}
}
}
}
static void
SetClassPath(const char *s)
{
char *def;
s = JLI_WildcardExpandClasspath(s);
}
#ifndef GAMMA
/*
* The SelectVersion() routine ensures that an appropriate version of
* the JRE is running. The specification for the appropriate version
* is obtained from either the manifest of a jar file (preferred) or
* from command line options.
* The routine also parses splash screen command line options and
* passes on their values in private environment variables.
*/
static void
{
char *arg;
char **new_argv;
char **new_argp;
char *operand;
int jarflag = 0;
int headlessflag = 0;
char *env_in;
int res;
/*
* If the version has already been selected, set *main_class
* with the value passed through the environment (if any) and
* simply return.
*/
if (*env_in != '\0')
return;
}
/*
* Scan through the arguments for options relevant to multiple JRE
* support. For reference, the command line syntax is defined as:
*
* SYNOPSIS
* java [options] class [argument...]
*
* java [options] -jar file.jar [argument...]
*
* As the scan is performed, make a copy of the argument list with
* the version specification options (new to 1.5) removed, so that
* a version less than 1.5 can be exec'd.
*
* Note that due to the syntax of the native Windows interface
* CreateProcess(), processing similar to the following exists in
* the Windows platform specific routine ExecJRE (in java_md.c).
* Changes here should be reproduced there.
*/
argc--;
argv++;
restrict_search = 1;
restrict_search = 0;
} else {
jarflag = 1;
/* deal with "unfortunate" classpath syntax */
(argc >= 2)) {
argc--;
argv++;
}
/*
* Checking for headless toolkit option in the some way as AWT does:
* "true" means true and any other value means false
*/
headlessflag = 1;
headlessflag = 0;
}
}
argc--;
argv++;
}
if (argc <= 0) { /* No operand? Possibly legit with -[full]version */
} else {
argc--;
}
while (argc-- > 0) /* Copy over [argument...] */
/*
* If there is a jar file, read the manifest. If the jarfile can't be
* read, the manifest can't be read from the jar file, or the manifest
* is corrupt, issue the appropriate error messages and exit.
*
* Even if there isn't a jar file, construct a manifest_info structure
* containing the command line information. It's a convenient way to carry
* this data around.
*/
if (res == -1)
ReportErrorMessage2("Unable to access jarfile %s",
else
ReportErrorMessage2("Invalid or corrupt jarfile %s",
exit(1);
}
/*
* Command line splash screen option should have precedence
* over the manifest, so the manifest data is used only if
* splash_file_name has not been initialized above during command
* line parsing
*/
}
} else {
info.jre_restrict_search = 0;
}
/*
* Passing on splash screen info in environment variables
*/
if (splash_file_name && !headlessflag) {
char* splash_file_entry = JLI_MemAlloc(strlen(SPLASH_FILE_ENV_ENTRY "=")+strlen(splash_file_name)+1);
}
if (splash_jar_name && !headlessflag) {
}
/*
* The JRE-Version and JRE-Restrict-Search values (if any) from the
* manifest are overwritten by any specified on the command line.
*/
if (restrict_search != -1)
/*
* "Valid" returns (other than unrecoverable errors) follow. Set
* main_class as a side-effect of this routine.
*/
/*
* If no version selection information is found either on the command
* line or in the manifest, simply return.
*/
return;
}
/*
* Check for correct syntax of the version specification (JSR 56).
*/
ReportErrorMessage2("Syntax error in version specification \"%s\"",
exit(1);
}
/*
* Find the appropriate JVM on the system. Just to be as forgiving as
* possible, if the standard algorithms don't locate an appropriate
* jre, check to see if the one running will satisfy the requirements.
* This can happen on systems which haven't been set-up for multiple
* JRE support.
*/
if (_launcher_debug)
printf("JRE-Version = %s, JRE-Restrict-Search = %s Selected = %s\n",
return;
} else {
"Unable to locate JRE meeting specification \"%s\"",
exit(1);
}
}
/*
* If I'm not the chosen one, exec the chosen one. Returning from
* ExecJRE indicates that I am indeed the chosen one.
*
* The private environment variable _JAVA_VERSION_SET is used to
* prevent the chosen one from re-reading the manifest file and
* using the values found within to override the (potential) command
* line flags stripped from argv (because the target may not
* understand them). Passing the MainClass value is an optimization
* to avoid locating, expanding and parsing the manifest extra
* times.
*/
} else {
exit(1);
}
}
return;
}
#endif /* ifndef GAMMA */
/*
* Parses command line arguments. Returns JNI_FALSE if launcher
* should exit without starting vm (e.g. certain version and usage
* options); returns JNI_TRUE if vm needs to be started to process
* given options. *pret (the launcher process return value) is set to
* 0 for a normal exit.
*/
static jboolean
{
char *arg;
*pret = 1;
if (argc < 1) {
ReportErrorMessage2("%s requires class path specification",
PrintUsage();
return JNI_FALSE;
}
SetClassPath(*argv);
PrintUsage();
*pret = 0;
return JNI_FALSE;
return JNI_TRUE;
return JNI_FALSE;
/*
* The following case provide backward compatibility with old-style
* command line options.
*/
*pret = 0;
return JNI_FALSE;
noExitErrorMessage = 1;
char *p = arg + 5;
if (*p) {
} else {
}
/* No longer supported */
"Warning: %s option is no longer supported.\n",
arg);
; /* Ignore machine independent options already handled */
} else if (RemovableMachineDependentOption(arg) ) {
; /* Do not pass option to vm. */
}
else {
}
}
if (--argc >= 0) {
if (jarflag) {
*pclassname = 0;
} else {
*pjarfile = 0;
*pclassname = *argv++;
}
}
return JNI_TRUE;
}
/*
* Initializes the Java Virtual Machine. Also frees options array when
* finished.
*/
static jboolean
{
jint r;
if (_launcher_debug) {
int i = 0;
printf("JavaVM args:\n ");
printf("ignoreUnrecognized is %s, ",
for (i = 0; i < numOptions; i++)
printf(" option[%2d] = '%s'\n",
}
return r == JNI_OK;
}
#define NULL_CHECK0(e) if ((e) == 0) return 0
#define NULL_CHECK(e) if ((e) == 0) return
if (platformEncoding == NULL) {
if (propname) {
"getProperty",
}
}
return platformEncoding;
}
"isSupported",
}
/*
* Returns a new Java string object for the specified platform string.
*/
static jstring
{
if (s == NULL)
return 0;
if (ary != 0) {
} else {
/*If the encoding specified in sun.jnu.encoding is not
endorsed by "Charset.isSupported" we have to fall back
to use String(byte[]) explicitly here without specifying
the encoding name, in which the StringCoding class will
pickup the iso-8859-1 as the fallback converter for us.
*/
"([B)V"));
}
return str;
}
}
return 0;
}
/*
* Returns a new array of Java string objects for the specified
* array of platform strings.
*/
static jobjectArray
{
int i;
for (i = 0; i < strc; i++) {
}
return ary;
}
/*
* Loads a class, convert the '.' to '/'.
*/
static jclass
{
if (_launcher_debug)
start = CounterGet();
do {
c = *t++;
*s++ = (c == '.') ? '/' : c;
} while (c != '\0');
if (_launcher_debug) {
end = CounterGet();
printf("%ld micro seconds to load main class\n",
printf("----_JAVA_LAUNCHER_DEBUG----\n");
}
return cls;
}
/*
* Returns the main class name for the specified jar file.
*/
static jstring
{
if (man != 0) {
"getMainAttributes",
"()Ljava/util/jar/Attributes;"));
if (attr != 0) {
"getValue",
}
}
return result;
}
#ifdef JAVA_ARGS
/*
* For tools, convert command line args thus:
* javac -cp foo:foo/"*" -J-ms32m ...
* java -ms32m -cp JLI_WildcardExpandClasspath(foo:foo/"*") ...
*/
static void
{
int i;
/* Copy the VM arguments (i.e. prefixed with -J) */
for (i = 0; i < NUM_ARGS; i++) {
}
}
for (i = 0; i < argc; i++) {
ReportErrorMessage("Error: the -J option should not be "
"followed by a space.", JNI_TRUE);
exit(1);
}
}
}
/* Copy the rest of the arguments */
for (i = 0; i < NUM_ARGS; i++) {
}
}
for (i = 0; i < argc; i++) {
if (arg[0] == '-') {
continue;
#ifdef EXPAND_CLASSPATH_WILDCARDS
&& i < argc - 1) {
i++;
continue;
}
#endif
}
}
*nargv = 0;
}
/*
* For our tools, we try to add 3 VM options:
* -Denv.class.path=<envcp>
* -Dapplication.home=<apphome>
* -Djava.class.path=<appcp>
* <envcp> is the user's setting of CLASSPATH -- for instance the user
* tells javac where to find binary classes through this environment
* variable. Notice that users will be able to compile against our
* tools classes (sun.tools.javac.Main) only if they explicitly add
* tools.jar to CLASSPATH.
* <apphome> is the directory where the application is installed.
* <appcp> is the classpath to where our apps' classfiles are.
*/
static jboolean
{
int size, i;
int strlenHome;
{
const char *s = getenv("CLASSPATH");
if (s) {
s = (char *) JLI_WildcardExpandClasspath(s);
/* 40 for -Denv.class.path= */
}
}
return JNI_FALSE;
}
/* 40 for '-Dapplication.home=' */
/* How big is the application's classpath? */
for (i = 0; i < NUM_APP_CLASSPATH; i++) {
}
for (i = 0; i < NUM_APP_CLASSPATH; i++) {
}
return JNI_TRUE;
}
#endif /* JAVA_ARGS */
/*
* inject the -Dsun.java.command pseudo property into the args structure
* this pseudo property is used in the HotSpot VM to expose the
* Java class name and arguments to the main method to the VM. The
* HotSpot VM uses this pseudo property to store the Java class name
* (or jar file name) and the arguments to the class's main method
* to the instrumentation memory region. The sun.java.command pseudo
* property is not exported by HotSpot to the Java layer.
*/
void
{
int i = 0;
/* unexpected, one of these should be set. just return without
* setting the property
*/
return;
}
/* if the class name is not set, then use the jarfile name */
}
/* determine the amount of memory to allocate assuming
* the individual components will be space separated
*/
for (i = 0; i < argc; i++) {
}
/* allocate the memory */
/* build the -D string */
*javaCommand = '\0';
for (i = 0; i < argc; i++) {
/* the components of the string are space separated. In
* the case of embedded white space, the relationship of
* the white space separated components to their true
* positional arguments will be ambiguous. This issue may
* be addressed in a future release.
*/
}
}
/*
* JVM would like to know if it's created by a standard Sun launcher, or by
* user native application, the following property indicates the former.
*/
void SetJavaLauncherProp() {
}
/*
* Prints the version information from the java.version and other properties.
*/
static void
{
}
/*
* Prints default usage message.
*/
static void
PrintUsage(void)
{
#ifndef GAMMA
int i;
#endif
"Usage: %s [-options] class [args...]\n"
" (to execute a class)\n"
" or %s [-options] -jar jarfile [args...]\n"
" (to execute a jar file)\n"
"\n"
"where options include:\n",
progname);
#ifndef GAMMA
}
for (i=1; i<knownVMsCount; i++) {
}
for (i=1; i<knownVMsCount; i++) {
"the \"%s\" VM [deprecated]\n",
}
/* The first known VM is the default */
{
(ServerClassMachine() == JNI_TRUE)) {
punctuation = ", ";
reason = "because you are running on a server-class machine.\n";
}
reason);
}
#endif /* ifndef GAMMA */
" A %c separated list of directories, JAR archives,\n"
" and ZIP archives to search for class files.\n"
" -D<name>=<value>\n"
" set a system property\n"
" -verbose[:class|gc|jni]\n"
" enable verbose output\n"
" -version print product version and exit\n"
" -version:<value>\n"
" require the specified version to run\n"
" -showversion print product version and continue\n"
" -jre-restrict-search | -jre-no-restrict-search\n"
" -? -help print this help message\n"
" -X print help on non-standard options\n"
" -ea[:<packagename>...|:<classname>]\n"
" -enableassertions[:<packagename>...|:<classname>]\n"
" enable assertions\n"
" -da[:<packagename>...|:<classname>]\n"
" -disableassertions[:<packagename>...|:<classname>]\n"
" disable assertions\n"
" -esa | -enablesystemassertions\n"
" enable system assertions\n"
" -dsa | -disablesystemassertions\n"
" disable system assertions\n"
" -agentlib:<libname>[=<options>]\n"
" load native agent library <libname>, e.g. -agentlib:hprof\n"
" see also, -agentlib:jdwp=help and -agentlib:hprof=help\n"
" -agentpath:<pathname>[=<options>]\n"
" load native agent library by full pathname\n"
" -javaagent:<jarpath>[=<options>]\n"
" load Java programming language agent, see java.lang.instrument\n"
" -splash:<imagepath>\n"
" show splash screen with specified image\n"
}
/*
* Print usage message for -X options.
*/
static jint
{
/*
A 32 bit cushion to prevent buffer overrun, noting that
fopen(3C) may fail if the buffer exceeds MAXPATHLEN.
*/
size_t n;
/* Note the FILE_SEPARATOR is platform dependent */
if (fp == 0) {
return 1;
}
}
return 0;
}
#ifndef GAMMA
/*
* Read the jvm.cfg file and fill the knownJVMs[] array.
*
* The functionality of the jvm.cfg file is subject to change without
* notice and the mechanism will be removed in the future.
*
* The lexical structure of the jvm.cfg file is as follows:
*
* jvmcfg := { vmLine }
* vmLine := knownLine
* | aliasLine
* | warnLine
* | ignoreLine
* | errorLine
* | predicateLine
* | commentLine
* knownLine := flag "KNOWN" EOL
* warnLine := flag "WARN" EOL
* ignoreLine := flag "IGNORE" EOL
* errorLine := flag "ERROR" EOL
* aliasLine := flag "ALIASED_TO" flag EOL
* predicateLine := flag "IF_SERVER_CLASS" flag EOL
* commentLine := "#" text EOL
* flag := "-" identifier
*
* The semantics are that when someone specifies a flag on the command line:
* - if the flag appears on a knownLine, then the identifier is used as
* the name of the directory holding the JVM library (the name of the JVM).
* - if the flag appears as the first flag on an aliasLine, the identifier
* of the second flag is used as the name of the JVM.
* - if the flag appears on a warnLine, the identifier is used as the
* name of the JVM, but a warning is generated.
* - if the flag appears on an ignoreLine, the identifier is recognized as the
* name of a JVM, but the identifier is ignored and the default vm used
* - if the flag appears on an errorLine, an error is generated.
* - if the flag appears as the first flag on a predicateLine, and
* the machine on which you are running passes the predicate indicated,
* then the identifier of the second flag is used as the name of the JVM,
* otherwise the identifier of the first flag is used as the name of the JVM.
* If no flag is given on the command line, the first vmLine of the jvm.cfg
* file determines the name of the JVM.
* PredicateLines are only interpreted on first vmLine of a jvm.cfg file,
* since they only make sense if someone hasn't specified the name of the
* JVM on the command line.
*
* The intent of the jvm.cfg file is to allow several JVM libraries to
* be installed in different subdirectories of a single JRE installation,
* for space-savings and convenience in testing.
* The intent is explicitly not to provide a full aliasing or predicate
* mechanism.
*/
{
int cnt = 0;
int lineno = 0;
int vmType;
char *tmpPtr;
if (_launcher_debug) {
start = CounterGet();
}
if (!speculative) {
JNI_TRUE);
exit(1);
} else {
return -1;
}
}
vmType = VM_UNKNOWN;
lineno++;
if (line[0] == '#')
continue;
if (line[0] != '-') {
lineno, jvmCfgName);
}
if (cnt >= knownVMsLimit) {
}
if (*tmpPtr == 0) {
lineno, jvmCfgName);
} else {
/* Null-terminate this string for JLI_StringDup below */
*tmpPtr++ = 0;
if (*tmpPtr == 0) {
lineno, jvmCfgName);
} else {
if (*tmpPtr != 0) {
}
if (*tmpPtr == 0) {
lineno, jvmCfgName);
} else {
/* Null terminate altVMName */
*tmpPtr = 0;
}
"IF_SERVER_CLASS",
strlen("IF_SERVER_CLASS"))) {
if (*tmpPtr != 0) {
}
if (*tmpPtr == 0) {
lineno, jvmCfgName);
} else {
/* Null terminate server class VM name */
*tmpPtr = 0;
}
} else {
lineno, &jvmCfgName[0]);
}
}
}
if (_launcher_debug)
if (vmType != VM_UNKNOWN) {
switch (vmType) {
default:
break;
case VM_ALIASED_TO:
if (_launcher_debug) {
printf(" name: %s vmType: %s alias: %s\n",
}
break;
case VM_IF_SERVER_CLASS:
if (_launcher_debug) {
printf(" name: %s vmType: %s server_class: %s\n",
}
break;
}
cnt++;
}
}
knownVMsCount = cnt;
if (_launcher_debug) {
end = CounterGet();
}
return cnt;
}
static void
{
int newMax;
}
}
}
/* Returns index of VM or -1 if not found */
static int
{
int i;
for (i = 0; i < knownVMsCount; i++) {
return i;
}
}
return -1;
}
static void
{
int i;
for (i = 0; i < knownVMsCount; i++) {
}
}
/*
* Displays the splash screen according to the jar file name
* and image file names stored in environment variables
*/
static void
{
int data_size;
void *image_data;
if (jar_name) {
if (image_data) {
DoSplashInit();
}
} else if (file_name) {
DoSplashInit();
} else {
return;
}
}
#endif /* ifndef GAMMA */