blob: 7aba5ce096a9f5643c35e3ac773781d98a4e07b3 [file] [log] [blame]
duke6e45e102007-12-01 00:00:00 +00001/*
ksrinie3ec45d2010-07-09 11:04:34 -07002 * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
duke6e45e102007-12-01 00:00:00 +00003 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
ohair2283b9d2010-05-25 15:58:33 -07007 * published by the Free Software Foundation. Oracle designates this
duke6e45e102007-12-01 00:00:00 +00008 * particular file as subject to the "Classpath" exception as provided
ohair2283b9d2010-05-25 15:58:33 -07009 * by Oracle in the LICENSE file that accompanied this code.
duke6e45e102007-12-01 00:00:00 +000010 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
ohair2283b9d2010-05-25 15:58:33 -070021 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
duke6e45e102007-12-01 00:00:00 +000024 */
25
26#ifndef _JAVA_H_
27#define _JAVA_H_
28
29#include <stdio.h>
30#include <stdlib.h>
31#include <string.h>
32#include <limits.h>
33
34#include <jni.h>
35#include <jvm.h>
36
37/*
38 * Get system specific defines.
39 */
40#include "emessages.h"
41#include "java_md.h"
42#include "jli_util.h"
43
44#include "manifest_info.h"
45#include "version_comp.h"
46#include "wildcard.h"
47#include "splashscreen.h"
48
49# define KB (1024UL)
50# define MB (1024UL * KB)
51# define GB (1024UL * MB)
52
53#define CURRENT_DATA_MODEL (CHAR_BIT * sizeof(void*))
54
55/*
56 * The following environment variable is used to influence the behavior
57 * of the jre exec'd through the SelectVersion routine. The command line
58 * options which specify the version are not passed to the exec'd version,
59 * because that jre may be an older version which wouldn't recognize them.
60 * This environment variable is known to this (and later) version and serves
61 * to suppress the version selection code. This is not only for efficiency,
62 * but also for correctness, since any command line options have been
63 * removed which would cause any value found in the manifest to be used.
64 * This would be incorrect because the command line options are defined
65 * to take precedence.
66 *
67 * The value associated with this environment variable is the MainClass
68 * name from within the executable jar file (if any). This is strictly a
69 * performance enhancement to avoid re-reading the jar file manifest.
70 *
71 */
72#define ENV_ENTRY "_JAVA_VERSION_SET"
73
74#define SPLASH_FILE_ENV_ENTRY "_JAVA_SPLASH_FILE"
75#define SPLASH_JAR_ENV_ENTRY "_JAVA_SPLASH_JAR"
76
77/*
78 * Pointers to the needed JNI invocation API, initialized by LoadJavaVM.
79 */
80typedef jint (JNICALL *CreateJavaVM_t)(JavaVM **pvm, void **env, void *args);
81typedef jint (JNICALL *GetDefaultJavaVMInitArgs_t)(void *args);
82
83typedef struct {
84 CreateJavaVM_t CreateJavaVM;
85 GetDefaultJavaVMInitArgs_t GetDefaultJavaVMInitArgs;
86} InvocationFunctions;
87
88int
89JLI_Launch(int argc, char ** argv, /* main argc, argc */
90 int jargc, const char** jargv, /* java args */
91 int appclassc, const char** appclassv, /* app classpath */
92 const char* fullversion, /* full version defined */
93 const char* dotversion, /* dot version defined */
94 const char* pname, /* program name */
95 const char* lname, /* launcher name */
96 jboolean javaargs, /* JAVA_ARGS */
97 jboolean cpwildcard, /* classpath wildcard */
98 jboolean javaw, /* windows-only javaw */
99 jint ergo_class /* ergnomics policy */
100);
101
102/*
103 * Prototypes for launcher functions in the system specific java_md.c.
104 */
105
106jboolean
107LoadJavaVM(const char *jvmpath, InvocationFunctions *ifn);
108
109void
110GetXUsagePath(char *buf, jint bufsize);
111
112jboolean
113GetApplicationHome(char *buf, jint bufsize);
114
115#define GetArch() GetArchPath(CURRENT_DATA_MODEL)
116
ksrinie3ec45d2010-07-09 11:04:34 -0700117/*
118 * Different platforms will implement this, here
119 * pargc is a pointer to the original argc,
120 * pargv is a pointer to the original argv,
121 * jrepath is an accessible path to the jre as determined by the call
122 * so_jrepath is the length of the buffer jrepath
123 * jvmpath is an accessible path to the jvm as determined by the call
124 * so_jvmpath is the length of the buffer jvmpath
125 */
126void CreateExecutionEnvironment(int *argc, char ***argv,
127 char *jrepath, jint so_jrepath,
128 char *jvmpath, jint so_jvmpath);
129
ksrini0e817162008-08-26 10:21:20 -0700130/* Reports an error message to stderr or a window as appropriate. */
131void JLI_ReportErrorMessage(const char * message, ...);
132
133/* Reports a system error message to stderr or a window */
134void JLI_ReportErrorMessageSys(const char * message, ...);
135
136/* Reports an error message only to stderr. */
137void JLI_ReportMessage(const char * message, ...);
duke6e45e102007-12-01 00:00:00 +0000138
139/*
ksrini0e817162008-08-26 10:21:20 -0700140 * Reports an exception which terminates the vm to stderr or a window
duke6e45e102007-12-01 00:00:00 +0000141 * as appropriate.
142 */
ksrini0e817162008-08-26 10:21:20 -0700143void JLI_ReportExceptionDescription(JNIEnv * env);
duke6e45e102007-12-01 00:00:00 +0000144void PrintMachineDependentOptions();
145
146const char *jlong_format_specifier();
147
148/*
149 * Block current thread and continue execution in new thread
150 */
151int ContinueInNewThread0(int (JNICALL *continuation)(void *),
152 jlong stack_size, void * args);
153
154/* sun.java.launcher.* platform properties. */
155void SetJavaLauncherPlatformProps(void);
mchungea290e22011-01-21 09:43:57 -0800156void SetJavaCommandLineProp(char* what, int argc, char** argv);
duke6e45e102007-12-01 00:00:00 +0000157void SetJavaLauncherProp(void);
158
159/*
160 * Functions defined in java.c and used in java_md.c.
161 */
162jint ReadKnownVMs(const char *jrepath, const char * arch, jboolean speculative);
163char *CheckJvmType(int *argc, char ***argv, jboolean speculative);
164void AddOption(char *str, void *info);
165
166enum ergo_policy {
167 DEFAULT_POLICY = 0,
168 NEVER_SERVER_CLASS,
169 ALWAYS_SERVER_CLASS
170};
171
172const char* GetProgramName();
173const char* GetDotVersion();
174const char* GetFullVersion();
175jboolean IsJavaArgs();
176jboolean IsJavaw();
duke6e45e102007-12-01 00:00:00 +0000177jint GetErgoPolicy();
178
179jboolean ServerClassMachine();
180
mchungea290e22011-01-21 09:43:57 -0800181static int ContinueInNewThread(InvocationFunctions* ifn,
182 int argc, char** argv,
183 int mode, char *what, int ret);
duke6e45e102007-12-01 00:00:00 +0000184
ksrini52cded22008-03-06 07:51:28 -0800185/*
186 * Initialize platform specific settings
187 */
188void InitLauncher(jboolean javaw);
duke6e45e102007-12-01 00:00:00 +0000189
ksrini20a64b22008-09-24 15:07:41 -0700190/*
191 * This allows for finding classes from the VM's bootstrap class loader directly,
192 * FindClass uses the application class loader internally, this will cause
193 * unnecessary searching of the classpath for the required classes.
194 *
195 */
196typedef jclass (JNICALL FindClassFromBootLoader_t(JNIEnv *env,
mchungb2ce9412009-08-06 16:35:24 -0700197 const char *name));
ksrini20a64b22008-09-24 15:07:41 -0700198jclass FindBootStrapClass(JNIEnv *env, const char *classname);
duke6e45e102007-12-01 00:00:00 +0000199#endif /* _JAVA_H_ */