java.h revision 4680
0N/A/*
4680N/A * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/A#ifndef _JAVA_H_
0N/A#define _JAVA_H_
0N/A
0N/A#include <stdio.h>
0N/A#include <stdlib.h>
0N/A#include <string.h>
0N/A#include <limits.h>
0N/A
0N/A#include <jni.h>
0N/A#include <jvm.h>
0N/A
0N/A/*
0N/A * Get system specific defines.
0N/A */
0N/A#include "emessages.h"
0N/A#include "java_md.h"
0N/A#include "jli_util.h"
0N/A
0N/A#include "manifest_info.h"
0N/A#include "version_comp.h"
0N/A#include "wildcard.h"
0N/A#include "splashscreen.h"
0N/A
0N/A# define KB (1024UL)
0N/A# define MB (1024UL * KB)
0N/A# define GB (1024UL * MB)
0N/A
0N/A#define CURRENT_DATA_MODEL (CHAR_BIT * sizeof(void*))
0N/A
0N/A/*
0N/A * The following environment variable is used to influence the behavior
0N/A * of the jre exec'd through the SelectVersion routine. The command line
0N/A * options which specify the version are not passed to the exec'd version,
0N/A * because that jre may be an older version which wouldn't recognize them.
0N/A * This environment variable is known to this (and later) version and serves
0N/A * to suppress the version selection code. This is not only for efficiency,
0N/A * but also for correctness, since any command line options have been
0N/A * removed which would cause any value found in the manifest to be used.
0N/A * This would be incorrect because the command line options are defined
0N/A * to take precedence.
0N/A *
0N/A * The value associated with this environment variable is the MainClass
0N/A * name from within the executable jar file (if any). This is strictly a
0N/A * performance enhancement to avoid re-reading the jar file manifest.
0N/A *
0N/A */
0N/A#define ENV_ENTRY "_JAVA_VERSION_SET"
0N/A
0N/A#define SPLASH_FILE_ENV_ENTRY "_JAVA_SPLASH_FILE"
0N/A#define SPLASH_JAR_ENV_ENTRY "_JAVA_SPLASH_JAR"
0N/A
0N/A/*
0N/A * Pointers to the needed JNI invocation API, initialized by LoadJavaVM.
0N/A */
0N/Atypedef jint (JNICALL *CreateJavaVM_t)(JavaVM **pvm, void **env, void *args);
0N/Atypedef jint (JNICALL *GetDefaultJavaVMInitArgs_t)(void *args);
4632N/Atypedef jint (JNICALL *GetCreatedJavaVMs_t)(JavaVM **vmBuf, jsize bufLen, jsize *nVMs);
0N/A
0N/Atypedef struct {
0N/A CreateJavaVM_t CreateJavaVM;
0N/A GetDefaultJavaVMInitArgs_t GetDefaultJavaVMInitArgs;
4632N/A GetCreatedJavaVMs_t GetCreatedJavaVMs;
0N/A} InvocationFunctions;
0N/A
0N/Aint
0N/AJLI_Launch(int argc, char ** argv, /* main argc, argc */
0N/A int jargc, const char** jargv, /* java args */
0N/A int appclassc, const char** appclassv, /* app classpath */
0N/A const char* fullversion, /* full version defined */
0N/A const char* dotversion, /* dot version defined */
0N/A const char* pname, /* program name */
0N/A const char* lname, /* launcher name */
0N/A jboolean javaargs, /* JAVA_ARGS */
0N/A jboolean cpwildcard, /* classpath wildcard */
0N/A jboolean javaw, /* windows-only javaw */
0N/A jint ergo_class /* ergnomics policy */
0N/A);
0N/A
0N/A/*
0N/A * Prototypes for launcher functions in the system specific java_md.c.
0N/A */
0N/A
0N/Ajboolean
0N/ALoadJavaVM(const char *jvmpath, InvocationFunctions *ifn);
0N/A
0N/Avoid
0N/AGetXUsagePath(char *buf, jint bufsize);
0N/A
0N/Ajboolean
0N/AGetApplicationHome(char *buf, jint bufsize);
0N/A
0N/A#define GetArch() GetArchPath(CURRENT_DATA_MODEL)
0N/A
2581N/A/*
2581N/A * Different platforms will implement this, here
2581N/A * pargc is a pointer to the original argc,
2581N/A * pargv is a pointer to the original argv,
2581N/A * jrepath is an accessible path to the jre as determined by the call
2581N/A * so_jrepath is the length of the buffer jrepath
2581N/A * jvmpath is an accessible path to the jvm as determined by the call
2581N/A * so_jvmpath is the length of the buffer jvmpath
2581N/A */
2581N/Avoid CreateExecutionEnvironment(int *argc, char ***argv,
2581N/A char *jrepath, jint so_jrepath,
4680N/A char *jvmpath, jint so_jvmpath,
4680N/A char *jvmcfg, jint so_jvmcfg);
2581N/A
517N/A/* Reports an error message to stderr or a window as appropriate. */
517N/Avoid JLI_ReportErrorMessage(const char * message, ...);
0N/A
517N/A/* Reports a system error message to stderr or a window */
517N/Avoid JLI_ReportErrorMessageSys(const char * message, ...);
517N/A
517N/A/* Reports an error message only to stderr. */
517N/Avoid JLI_ReportMessage(const char * message, ...);
0N/A
0N/A/*
517N/A * Reports an exception which terminates the vm to stderr or a window
0N/A * as appropriate.
0N/A */
517N/Avoid JLI_ReportExceptionDescription(JNIEnv * env);
0N/Avoid PrintMachineDependentOptions();
0N/A
0N/Aconst char *jlong_format_specifier();
0N/A
0N/A/*
0N/A * Block current thread and continue execution in new thread
0N/A */
0N/Aint ContinueInNewThread0(int (JNICALL *continuation)(void *),
0N/A jlong stack_size, void * args);
0N/A
0N/A/* sun.java.launcher.* platform properties. */
0N/Avoid SetJavaLauncherPlatformProps(void);
3408N/Avoid SetJavaCommandLineProp(char* what, int argc, char** argv);
0N/Avoid SetJavaLauncherProp(void);
0N/A
0N/A/*
0N/A * Functions defined in java.c and used in java_md.c.
0N/A */
4680N/Ajint ReadKnownVMs(const char *jvmcfg, jboolean speculative);
0N/Achar *CheckJvmType(int *argc, char ***argv, jboolean speculative);
0N/Avoid AddOption(char *str, void *info);
0N/A
0N/Aenum ergo_policy {
0N/A DEFAULT_POLICY = 0,
0N/A NEVER_SERVER_CLASS,
0N/A ALWAYS_SERVER_CLASS
0N/A};
0N/A
0N/Aconst char* GetProgramName();
0N/Aconst char* GetDotVersion();
0N/Aconst char* GetFullVersion();
0N/Ajboolean IsJavaArgs();
0N/Ajboolean IsJavaw();
0N/Ajint GetErgoPolicy();
0N/A
0N/Ajboolean ServerClassMachine();
0N/A
4680N/Aint ContinueInNewThread(InvocationFunctions* ifn, jlong threadStackSize,
4680N/A int argc, char** argv,
4680N/A int mode, char *what, int ret);
4680N/A
4680N/Aint JVMInit(InvocationFunctions* ifn, jlong threadStackSize,
4680N/A int argc, char** argv,
4680N/A int mode, char *what, int ret);
0N/A
16N/A/*
16N/A * Initialize platform specific settings
16N/A */
16N/Avoid InitLauncher(jboolean javaw);
0N/A
647N/A/*
4680N/A * For MacOSX and Windows/Unix compatibility we require these
4680N/A * entry points, some of them may be stubbed out on Windows/Unixes.
4680N/A */
4680N/Avoid PostJVMInit(JNIEnv *env, jstring mainClass, JavaVM *vm);
4680N/Avoid ShowSplashScreen();
4680N/Avoid RegisterThread();
4680N/A/*
4680N/A * this method performs additional platform specific processing and
4680N/A * should return JNI_TRUE to indicate the argument has been consumed,
4680N/A * otherwise returns JNI_FALSE to allow the calling logic to further
4680N/A * process the option.
4680N/A */
4680N/Ajboolean ProcessPlatformOption(const char *arg);
4680N/A
4680N/A/*
647N/A * This allows for finding classes from the VM's bootstrap class loader directly,
647N/A * FindClass uses the application class loader internally, this will cause
647N/A * unnecessary searching of the classpath for the required classes.
647N/A *
647N/A */
647N/Atypedef jclass (JNICALL FindClassFromBootLoader_t(JNIEnv *env,
1645N/A const char *name));
647N/Ajclass FindBootStrapClass(JNIEnv *env, const char *classname);
4680N/A
4680N/Aint JNICALL JavaMain(void * args); /* entry point */
4680N/A
4680N/Aenum LaunchMode { // cf. sun.launcher.LauncherHelper
4680N/A LM_UNKNOWN = 0,
4680N/A LM_CLASS,
4680N/A LM_JAR
4680N/A};
4680N/A
4680N/Astatic const char *launchModeNames[]
4680N/A = { "Unknown", "Main class", "JAR file" };
4680N/A
4680N/Atypedef struct {
4680N/A int argc;
4680N/A char **argv;
4680N/A int mode;
4680N/A char *what;
4680N/A InvocationFunctions ifn;
4680N/A} JavaMainArgs;
4680N/A
4680N/A#define NULL_CHECK0(e) if ((e) == 0) { \
4680N/A JLI_ReportErrorMessage(JNI_ERROR); \
4680N/A return 0; \
4680N/A }
4680N/A
4680N/A#define NULL_CHECK(e) if ((e) == 0) { \
4680N/A JLI_ReportErrorMessage(JNI_ERROR); \
4680N/A return; \
4680N/A }
4680N/A
0N/A#endif /* _JAVA_H_ */