jdk/src/share/bin/java.h
author ksrini
Wed, 24 Sep 2008 15:07:41 -0700
changeset 1323 e14a3b3536cd
parent 1145 404b11752c57
child 1331 05e272c957d8
permissions -rw-r--r--
6742159: (launcher) improve the java launching mechanism Summary: improves launching, also addresses 6694671 and 6749732 Reviewed-by: darcy, dholmes
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
715
f16baef3a20e 6719955: Update copyright year
xdono
parents: 39
diff changeset
     2
 * Copyright 1998-2008 Sun Microsystems, Inc.  All Rights Reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Sun designates this
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * by Sun in the LICENSE file that accompanied this code.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 * CA 95054 USA or visit www.sun.com if you need additional information or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
 * have any questions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
#ifndef _JAVA_H_
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
#define _JAVA_H_
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
#include <stdio.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
#include <stdlib.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
#include <string.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
#include <limits.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
#include <jni.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
#include <jvm.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * Get system specific defines.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
#include "emessages.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
#include "java_md.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
#include "jli_util.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
#include "manifest_info.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
#include "version_comp.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
#include "wildcard.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
#include "splashscreen.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
# define KB (1024UL)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
# define MB (1024UL * KB)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
# define GB (1024UL * MB)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
#define CURRENT_DATA_MODEL (CHAR_BIT * sizeof(void*))
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 * The following environment variable is used to influence the behavior
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 * of the jre exec'd through the SelectVersion routine.  The command line
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 * options which specify the version are not passed to the exec'd version,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 * because that jre may be an older version which wouldn't recognize them.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
 * This environment variable is known to this (and later) version and serves
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
 * to suppress the version selection code.  This is not only for efficiency,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
 * but also for correctness, since any command line options have been
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
 * removed which would cause any value found in the manifest to be used.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
 * This would be incorrect because the command line options are defined
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
 * to take precedence.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
 * The value associated with this environment variable is the MainClass
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
 * name from within the executable jar file (if any). This is strictly a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
 * performance enhancement to avoid re-reading the jar file manifest.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
#define ENV_ENTRY "_JAVA_VERSION_SET"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
#define SPLASH_FILE_ENV_ENTRY "_JAVA_SPLASH_FILE"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
#define SPLASH_JAR_ENV_ENTRY "_JAVA_SPLASH_JAR"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
 * Pointers to the needed JNI invocation API, initialized by LoadJavaVM.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
typedef jint (JNICALL *CreateJavaVM_t)(JavaVM **pvm, void **env, void *args);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
typedef jint (JNICALL *GetDefaultJavaVMInitArgs_t)(void *args);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
typedef struct {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
    CreateJavaVM_t CreateJavaVM;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
    GetDefaultJavaVMInitArgs_t GetDefaultJavaVMInitArgs;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
} InvocationFunctions;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
int
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
JLI_Launch(int argc, char ** argv,              /* main argc, argc */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
        int jargc, const char** jargv,          /* java args */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
        int appclassc, const char** appclassv,  /* app classpath */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
        const char* fullversion,                /* full version defined */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
        const char* dotversion,                 /* dot version defined */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
        const char* pname,                      /* program name */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
        const char* lname,                      /* launcher name */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
        jboolean javaargs,                      /* JAVA_ARGS */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
        jboolean cpwildcard,                    /* classpath wildcard */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
        jboolean javaw,                         /* windows-only javaw */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
        jint     ergo_class                     /* ergnomics policy */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
 * Prototypes for launcher functions in the system specific java_md.c.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
jboolean
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
LoadJavaVM(const char *jvmpath, InvocationFunctions *ifn);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
void
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
GetXUsagePath(char *buf, jint bufsize);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
jboolean
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
GetApplicationHome(char *buf, jint bufsize);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
#define GetArch() GetArchPath(CURRENT_DATA_MODEL)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
void CreateExecutionEnvironment(int *_argc,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
                                       char ***_argv,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
                                       char jrepath[],
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
                                       jint so_jrepath,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
                                       char jvmpath[],
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
                                       jint so_jvmpath,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
                                       char **original_argv);
1145
404b11752c57 6685121: (launcher) make ReportErrorMessages accessible by other launcher subsystems
ksrini
parents: 715
diff changeset
   124
/* Reports an error message to stderr or a window as appropriate. */
404b11752c57 6685121: (launcher) make ReportErrorMessages accessible by other launcher subsystems
ksrini
parents: 715
diff changeset
   125
void JLI_ReportErrorMessage(const char * message, ...);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
1145
404b11752c57 6685121: (launcher) make ReportErrorMessages accessible by other launcher subsystems
ksrini
parents: 715
diff changeset
   127
/* Reports a system error message to stderr or a window */
404b11752c57 6685121: (launcher) make ReportErrorMessages accessible by other launcher subsystems
ksrini
parents: 715
diff changeset
   128
void JLI_ReportErrorMessageSys(const char * message, ...);
404b11752c57 6685121: (launcher) make ReportErrorMessages accessible by other launcher subsystems
ksrini
parents: 715
diff changeset
   129
404b11752c57 6685121: (launcher) make ReportErrorMessages accessible by other launcher subsystems
ksrini
parents: 715
diff changeset
   130
/* Reports an error message only to stderr. */
404b11752c57 6685121: (launcher) make ReportErrorMessages accessible by other launcher subsystems
ksrini
parents: 715
diff changeset
   131
void JLI_ReportMessage(const char * message, ...);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
/*
1145
404b11752c57 6685121: (launcher) make ReportErrorMessages accessible by other launcher subsystems
ksrini
parents: 715
diff changeset
   134
 * Reports an exception which terminates the vm to stderr or a window
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
 * as appropriate.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
 */
1145
404b11752c57 6685121: (launcher) make ReportErrorMessages accessible by other launcher subsystems
ksrini
parents: 715
diff changeset
   137
void JLI_ReportExceptionDescription(JNIEnv * env);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
void PrintMachineDependentOptions();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
const char *jlong_format_specifier();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
 * Block current thread and continue execution in new thread
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
int ContinueInNewThread0(int (JNICALL *continuation)(void *),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
                        jlong stack_size, void * args);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
/* sun.java.launcher.* platform properties. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
void SetJavaLauncherPlatformProps(void);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
void SetJavaCommandLineProp(char* classname, char* jarfile, int argc, char** argv);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
void SetJavaLauncherProp(void);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
 * Functions defined in java.c and used in java_md.c.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
jint ReadKnownVMs(const char *jrepath, const char * arch, jboolean speculative);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
char *CheckJvmType(int *argc, char ***argv, jboolean speculative);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
void AddOption(char *str, void *info);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
enum ergo_policy {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
   DEFAULT_POLICY = 0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
   NEVER_SERVER_CLASS,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
   ALWAYS_SERVER_CLASS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
const char* GetProgramName();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
const char* GetDotVersion();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
const char* GetFullVersion();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
jboolean IsJavaArgs();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
jboolean IsJavaw();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
jint GetErgoPolicy();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
jboolean ServerClassMachine();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
static int ContinueInNewThread(InvocationFunctions* ifn, int argc, char** argv,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
                        char* jarfile, char* classname, int ret);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
39
560da37936db 6596475: (launcher) javaw should call InitCommonControls
ksrini
parents: 2
diff changeset
   178
/*
560da37936db 6596475: (launcher) javaw should call InitCommonControls
ksrini
parents: 2
diff changeset
   179
 * Initialize platform specific settings
560da37936db 6596475: (launcher) javaw should call InitCommonControls
ksrini
parents: 2
diff changeset
   180
 */
560da37936db 6596475: (launcher) javaw should call InitCommonControls
ksrini
parents: 2
diff changeset
   181
void InitLauncher(jboolean javaw);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
1323
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents: 1145
diff changeset
   183
/*
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents: 1145
diff changeset
   184
 * This allows for finding classes from the VM's bootstrap class loader directly,
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents: 1145
diff changeset
   185
 * FindClass uses the application class loader internally, this will cause
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents: 1145
diff changeset
   186
 * unnecessary searching of the classpath for the required classes.
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents: 1145
diff changeset
   187
 *
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents: 1145
diff changeset
   188
 */
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents: 1145
diff changeset
   189
typedef jclass (JNICALL FindClassFromBootLoader_t(JNIEnv *env,
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents: 1145
diff changeset
   190
                                                const char *name,
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents: 1145
diff changeset
   191
                                                jboolean throwError));
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents: 1145
diff changeset
   192
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents: 1145
diff changeset
   193
jclass FindBootStrapClass(JNIEnv *env, const char *classname);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
#endif /* _JAVA_H_ */