src/java.base/share/native/libjava/jni_util.h
author aivanov
Mon, 21 Oct 2019 21:36:26 +0100
changeset 58728 6d5c7f91e0b5
parent 58493 55a8d95c7787
child 58859 3fc5905f2bec
permissions -rw-r--r--
8232624: Java cannot start: NewStringPlatform missing Reviewed-by: dholmes, alanb, redestad
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
49440
396ea30afbd5 8200178: Remove mapfiles for JDK native libraries
ihse
parents: 49121
diff changeset
     2
 * Copyright (c) 1997, 2018, Oracle and/or its affiliates. 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
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3111
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3111
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
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
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3111
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3111
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3111
diff changeset
    23
 * questions.
2
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 JNI_UTIL_H
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
#define JNI_UTIL_H
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
#include "jni.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
#include "jlong.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
#ifdef __cplusplus
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
extern "C" {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
#endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * This file contains utility functions that can be implemented in pure JNI.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * Caution: Callers of functions declared in this file should be
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * particularly aware of the fact that these functions are convenience
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * functions, and as such are often compound operations, each one of
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * which may throw an exception. Therefore, the functions this file
21278
ef8a3a2a72f2 8022746: List of spelling errors in API doc
malenkov
parents: 16479
diff changeset
    43
 * will often return silently if an exception has occurred, and callers
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * must check for exception themselves.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
/* Throw a Java exception by name. Similar to SignalError. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
JNU_ThrowByName(JNIEnv *env, const char *name, const char *msg);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
/* Throw common exceptions */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
JNU_ThrowNullPointerException(JNIEnv *env, const char *msg);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
JNU_ThrowArrayIndexOutOfBoundsException(JNIEnv *env, const char *msg);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
JNU_ThrowOutOfMemoryError(JNIEnv *env, const char *msg);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
JNU_ThrowIllegalArgumentException(JNIEnv *env, const char *msg);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
JNU_ThrowInternalError(JNIEnv *env, const char *msg);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
JNU_ThrowIOException(JNIEnv *env, const char *msg);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
JNU_ThrowClassNotFoundException(JNIEnv *env, const char *msg);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
/* Throw an exception by name, using the string returned by
39318
2006d1d41c8b 8158023: SocketExceptions contain too little information sometimes
clanger
parents: 33653
diff changeset
    74
 * getLastErrorString for the detail string. If the last-error
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
 * string is NULL, use the given default detail string.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
JNU_ThrowByNameWithLastError(JNIEnv *env, const char *name,
39318
2006d1d41c8b 8158023: SocketExceptions contain too little information sometimes
clanger
parents: 33653
diff changeset
    79
                             const char *defaultDetail);
2006d1d41c8b 8158023: SocketExceptions contain too little information sometimes
clanger
parents: 33653
diff changeset
    80
2006d1d41c8b 8158023: SocketExceptions contain too little information sometimes
clanger
parents: 33653
diff changeset
    81
/* Throw an exception by name, using a given message and the string
2006d1d41c8b 8158023: SocketExceptions contain too little information sometimes
clanger
parents: 33653
diff changeset
    82
 * returned by getLastErrorString to construct the detail string.
2006d1d41c8b 8158023: SocketExceptions contain too little information sometimes
clanger
parents: 33653
diff changeset
    83
 */
2006d1d41c8b 8158023: SocketExceptions contain too little information sometimes
clanger
parents: 33653
diff changeset
    84
JNIEXPORT void JNICALL
2006d1d41c8b 8158023: SocketExceptions contain too little information sometimes
clanger
parents: 33653
diff changeset
    85
JNU_ThrowByNameWithMessageAndLastError
2006d1d41c8b 8158023: SocketExceptions contain too little information sometimes
clanger
parents: 33653
diff changeset
    86
  (JNIEnv *env, const char *name, const char *message);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
/* Throw an IOException, using the last-error string for the detail
39318
2006d1d41c8b 8158023: SocketExceptions contain too little information sometimes
clanger
parents: 33653
diff changeset
    89
 * string. If the last-error string is NULL, use the given default
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
 * detail string.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
JNU_ThrowIOExceptionWithLastError(JNIEnv *env, const char *defaultDetail);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
/* Convert between Java strings and i18n C strings */
58728
6d5c7f91e0b5 8232624: Java cannot start: NewStringPlatform missing
aivanov
parents: 58493
diff changeset
    96
JNIEXPORT jstring
6d5c7f91e0b5 8232624: Java cannot start: NewStringPlatform missing
aivanov
parents: 58493
diff changeset
    97
NewStringPlatform(JNIEnv *env, const char *str);
6d5c7f91e0b5 8232624: Java cannot start: NewStringPlatform missing
aivanov
parents: 58493
diff changeset
    98
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
JNIEXPORT const char *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
GetStringPlatformChars(JNIEnv *env, jstring jstr, jboolean *isCopy);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
JNIEXPORT jstring JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
JNU_NewStringPlatform(JNIEnv *env, const char *str);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
JNIEXPORT const char * JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
JNU_GetStringPlatformChars(JNIEnv *env, jstring jstr, jboolean *isCopy);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
JNU_ReleaseStringPlatformChars(JNIEnv *env, jstring jstr, const char *str);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
/* Class constants */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
JNIEXPORT jclass JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
JNU_ClassString(JNIEnv *env);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
/* Copy count number of arguments from src to dst. Array bounds
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
 * and ArrayStoreException are checked.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
JNIEXPORT jint JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
JNU_CopyObjectArray(JNIEnv *env, jobjectArray dst, jobjectArray src,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
                    jint count);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
/* Invoke a object-returning static method, based on class name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
 * method name, and signature string.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
 * The caller should check for exceptions by setting hasException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
 * argument. If the caller is not interested in whether an exception
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
 * has occurred, pass in NULL.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
JNIEXPORT jvalue JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
JNU_CallStaticMethodByName(JNIEnv *env,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
                           jboolean *hasException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
                           const char *class_name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
                           const char *name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
                           const char *signature,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
                           ...);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
/* Invoke an instance method by name.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
JNIEXPORT jvalue JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
JNU_CallMethodByName(JNIEnv *env,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
                     jboolean *hasException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
                     jobject obj,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
                     const char *name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
                     const char *signature,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
                     ...);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
JNIEXPORT jvalue JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
JNU_CallMethodByNameV(JNIEnv *env,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
                      jboolean *hasException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
                      jobject obj,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
                      const char *name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
                      const char *signature,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
                      va_list args);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
/* Construct a new object of class, specifying the class by name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
 * and specififying which constructor to run and what arguments to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
 * pass to it.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
 * The method will return an initialized instance if successful.
21278
ef8a3a2a72f2 8022746: List of spelling errors in API doc
malenkov
parents: 16479
diff changeset
   160
 * It will return NULL if an error has occurred (for example if
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
 * it ran out of memory) and the appropriate Java exception will
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
 * have been thrown.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
JNIEXPORT jobject JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
JNU_NewObjectByName(JNIEnv *env, const char *class_name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
                    const char *constructor_sig, ...);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
/* returns:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
 * 0: object is not an instance of the class named by classname.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
 * 1: object is an instance of the class named by classname.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
 * -1: the class named by classname cannot be found. An exception
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
 * has been thrown.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
JNIEXPORT jint JNICALL
57868
7ae075afc72f 8230104: JNU_IsInstanceOfByName needs const parameter
rriggs
parents: 51151
diff changeset
   175
JNU_IsInstanceOfByName(JNIEnv *env, jobject object, const char *classname);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
/* Get or set class and instance fields.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
 * Note that set functions take a variable number of arguments,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
 * but only one argument of the appropriate type can be passed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
 * For example, to set an integer field i to 100:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
 * JNU_SetFieldByName(env, &exc, obj, "i", "I", 100);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
 * To set a float field f to 12.3:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
 * JNU_SetFieldByName(env, &exc, obj, "f", "F", 12.3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
 * The caller should check for exceptions by setting hasException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
 * argument. If the caller is not interested in whether an exception
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
 * has occurred, pass in NULL.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
JNIEXPORT jvalue JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
JNU_GetFieldByName(JNIEnv *env,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
                   jboolean *hasException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
                   jobject obj,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
                   const char *name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
                   const char *sig);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
JNU_SetFieldByName(JNIEnv *env,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
                   jboolean *hasException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
                   jobject obj,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
                   const char *name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
                   const char *sig,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
                   ...);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
JNIEXPORT jvalue JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
JNU_GetStaticFieldByName(JNIEnv *env,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
                         jboolean *hasException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
                         const char *classname,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
                         const char *name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
                         const char *sig);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
/************************************************************************
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
 * Miscellaneous utilities used by the class libraries
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
#define IS_NULL(obj) ((obj) == NULL)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
#define JNU_IsNull(env,obj) ((obj) == NULL)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
22258
db80f864ed8f 8030875: Macros for checking and returning on exceptions
rriggs
parents: 21278
diff changeset
   222
/************************************************************************
22637
d4b45e70a981 8031737: CHECK_NULL and CHECK_EXCEPTION macros cleanup
rriggs
parents: 22258
diff changeset
   223
 * Miscellaneous utilities used by the class libraries to return from
d4b45e70a981 8031737: CHECK_NULL and CHECK_EXCEPTION macros cleanup
rriggs
parents: 22258
diff changeset
   224
 * a function if a value is NULL or an exception is pending.
22258
db80f864ed8f 8030875: Macros for checking and returning on exceptions
rriggs
parents: 21278
diff changeset
   225
 */
db80f864ed8f 8030875: Macros for checking and returning on exceptions
rriggs
parents: 21278
diff changeset
   226
22637
d4b45e70a981 8031737: CHECK_NULL and CHECK_EXCEPTION macros cleanup
rriggs
parents: 22258
diff changeset
   227
#define CHECK_NULL(x)                           \
d4b45e70a981 8031737: CHECK_NULL and CHECK_EXCEPTION macros cleanup
rriggs
parents: 22258
diff changeset
   228
    do {                                        \
d4b45e70a981 8031737: CHECK_NULL and CHECK_EXCEPTION macros cleanup
rriggs
parents: 22258
diff changeset
   229
        if ((x) == NULL) {                      \
d4b45e70a981 8031737: CHECK_NULL and CHECK_EXCEPTION macros cleanup
rriggs
parents: 22258
diff changeset
   230
            return;                             \
d4b45e70a981 8031737: CHECK_NULL and CHECK_EXCEPTION macros cleanup
rriggs
parents: 22258
diff changeset
   231
        }                                       \
d4b45e70a981 8031737: CHECK_NULL and CHECK_EXCEPTION macros cleanup
rriggs
parents: 22258
diff changeset
   232
    } while (0)                                 \
d4b45e70a981 8031737: CHECK_NULL and CHECK_EXCEPTION macros cleanup
rriggs
parents: 22258
diff changeset
   233
51151
d6b131d2bc8b 8193419: Better Internet address support
vtewari
parents: 49557
diff changeset
   234
#define CHECK_NULL_THROW_NPE(env, x, msg)         \
d6b131d2bc8b 8193419: Better Internet address support
vtewari
parents: 49557
diff changeset
   235
    do {                                        \
d6b131d2bc8b 8193419: Better Internet address support
vtewari
parents: 49557
diff changeset
   236
        if ((x) == NULL) {                      \
d6b131d2bc8b 8193419: Better Internet address support
vtewari
parents: 49557
diff changeset
   237
           JNU_ThrowNullPointerException((env), (msg));\
d6b131d2bc8b 8193419: Better Internet address support
vtewari
parents: 49557
diff changeset
   238
           return;                              \
d6b131d2bc8b 8193419: Better Internet address support
vtewari
parents: 49557
diff changeset
   239
        }                                       \
d6b131d2bc8b 8193419: Better Internet address support
vtewari
parents: 49557
diff changeset
   240
    } while(0)                                  \
d6b131d2bc8b 8193419: Better Internet address support
vtewari
parents: 49557
diff changeset
   241
d6b131d2bc8b 8193419: Better Internet address support
vtewari
parents: 49557
diff changeset
   242
#define CHECK_NULL_THROW_NPE_RETURN(env, x, msg, z)\
d6b131d2bc8b 8193419: Better Internet address support
vtewari
parents: 49557
diff changeset
   243
    do {                                        \
d6b131d2bc8b 8193419: Better Internet address support
vtewari
parents: 49557
diff changeset
   244
        if ((x) == NULL) {                      \
d6b131d2bc8b 8193419: Better Internet address support
vtewari
parents: 49557
diff changeset
   245
           JNU_ThrowNullPointerException((env), (msg));\
d6b131d2bc8b 8193419: Better Internet address support
vtewari
parents: 49557
diff changeset
   246
           return (z);                          \
d6b131d2bc8b 8193419: Better Internet address support
vtewari
parents: 49557
diff changeset
   247
        }                                       \
d6b131d2bc8b 8193419: Better Internet address support
vtewari
parents: 49557
diff changeset
   248
    } while(0)                                  \
d6b131d2bc8b 8193419: Better Internet address support
vtewari
parents: 49557
diff changeset
   249
22637
d4b45e70a981 8031737: CHECK_NULL and CHECK_EXCEPTION macros cleanup
rriggs
parents: 22258
diff changeset
   250
#define CHECK_NULL_RETURN(x, y)                 \
d4b45e70a981 8031737: CHECK_NULL and CHECK_EXCEPTION macros cleanup
rriggs
parents: 22258
diff changeset
   251
    do {                                        \
d4b45e70a981 8031737: CHECK_NULL and CHECK_EXCEPTION macros cleanup
rriggs
parents: 22258
diff changeset
   252
        if ((x) == NULL) {                      \
d4b45e70a981 8031737: CHECK_NULL and CHECK_EXCEPTION macros cleanup
rriggs
parents: 22258
diff changeset
   253
            return (y);                         \
d4b45e70a981 8031737: CHECK_NULL and CHECK_EXCEPTION macros cleanup
rriggs
parents: 22258
diff changeset
   254
        }                                       \
d4b45e70a981 8031737: CHECK_NULL and CHECK_EXCEPTION macros cleanup
rriggs
parents: 22258
diff changeset
   255
    } while (0)                                 \
22258
db80f864ed8f 8030875: Macros for checking and returning on exceptions
rriggs
parents: 21278
diff changeset
   256
23013
1cf3dddf9ff7 8035640: JNU_CHECK_EXCEPTION should support c++ JNI syntax
pchelko
parents: 22938
diff changeset
   257
#ifdef __cplusplus
1cf3dddf9ff7 8035640: JNU_CHECK_EXCEPTION should support c++ JNI syntax
pchelko
parents: 22938
diff changeset
   258
#define JNU_CHECK_EXCEPTION(env)                \
1cf3dddf9ff7 8035640: JNU_CHECK_EXCEPTION should support c++ JNI syntax
pchelko
parents: 22938
diff changeset
   259
    do {                                        \
1cf3dddf9ff7 8035640: JNU_CHECK_EXCEPTION should support c++ JNI syntax
pchelko
parents: 22938
diff changeset
   260
        if ((env)->ExceptionCheck()) {          \
1cf3dddf9ff7 8035640: JNU_CHECK_EXCEPTION should support c++ JNI syntax
pchelko
parents: 22938
diff changeset
   261
            return;                             \
1cf3dddf9ff7 8035640: JNU_CHECK_EXCEPTION should support c++ JNI syntax
pchelko
parents: 22938
diff changeset
   262
        }                                       \
1cf3dddf9ff7 8035640: JNU_CHECK_EXCEPTION should support c++ JNI syntax
pchelko
parents: 22938
diff changeset
   263
    } while (0)                                 \
1cf3dddf9ff7 8035640: JNU_CHECK_EXCEPTION should support c++ JNI syntax
pchelko
parents: 22938
diff changeset
   264
1cf3dddf9ff7 8035640: JNU_CHECK_EXCEPTION should support c++ JNI syntax
pchelko
parents: 22938
diff changeset
   265
#define JNU_CHECK_EXCEPTION_RETURN(env, y)      \
1cf3dddf9ff7 8035640: JNU_CHECK_EXCEPTION should support c++ JNI syntax
pchelko
parents: 22938
diff changeset
   266
    do {                                        \
1cf3dddf9ff7 8035640: JNU_CHECK_EXCEPTION should support c++ JNI syntax
pchelko
parents: 22938
diff changeset
   267
        if ((env)->ExceptionCheck()) {          \
1cf3dddf9ff7 8035640: JNU_CHECK_EXCEPTION should support c++ JNI syntax
pchelko
parents: 22938
diff changeset
   268
            return (y);                         \
1cf3dddf9ff7 8035640: JNU_CHECK_EXCEPTION should support c++ JNI syntax
pchelko
parents: 22938
diff changeset
   269
        }                                       \
1cf3dddf9ff7 8035640: JNU_CHECK_EXCEPTION should support c++ JNI syntax
pchelko
parents: 22938
diff changeset
   270
    } while (0)
1cf3dddf9ff7 8035640: JNU_CHECK_EXCEPTION should support c++ JNI syntax
pchelko
parents: 22938
diff changeset
   271
#else
22637
d4b45e70a981 8031737: CHECK_NULL and CHECK_EXCEPTION macros cleanup
rriggs
parents: 22258
diff changeset
   272
#define JNU_CHECK_EXCEPTION(env)                \
d4b45e70a981 8031737: CHECK_NULL and CHECK_EXCEPTION macros cleanup
rriggs
parents: 22258
diff changeset
   273
    do {                                        \
d4b45e70a981 8031737: CHECK_NULL and CHECK_EXCEPTION macros cleanup
rriggs
parents: 22258
diff changeset
   274
        if ((*env)->ExceptionCheck(env)) {      \
d4b45e70a981 8031737: CHECK_NULL and CHECK_EXCEPTION macros cleanup
rriggs
parents: 22258
diff changeset
   275
            return;                             \
d4b45e70a981 8031737: CHECK_NULL and CHECK_EXCEPTION macros cleanup
rriggs
parents: 22258
diff changeset
   276
        }                                       \
d4b45e70a981 8031737: CHECK_NULL and CHECK_EXCEPTION macros cleanup
rriggs
parents: 22258
diff changeset
   277
    } while (0)                                 \
d4b45e70a981 8031737: CHECK_NULL and CHECK_EXCEPTION macros cleanup
rriggs
parents: 22258
diff changeset
   278
d4b45e70a981 8031737: CHECK_NULL and CHECK_EXCEPTION macros cleanup
rriggs
parents: 22258
diff changeset
   279
#define JNU_CHECK_EXCEPTION_RETURN(env, y)      \
d4b45e70a981 8031737: CHECK_NULL and CHECK_EXCEPTION macros cleanup
rriggs
parents: 22258
diff changeset
   280
    do {                                        \
d4b45e70a981 8031737: CHECK_NULL and CHECK_EXCEPTION macros cleanup
rriggs
parents: 22258
diff changeset
   281
        if ((*env)->ExceptionCheck(env)) {      \
d4b45e70a981 8031737: CHECK_NULL and CHECK_EXCEPTION macros cleanup
rriggs
parents: 22258
diff changeset
   282
            return (y);                         \
d4b45e70a981 8031737: CHECK_NULL and CHECK_EXCEPTION macros cleanup
rriggs
parents: 22258
diff changeset
   283
        }                                       \
d4b45e70a981 8031737: CHECK_NULL and CHECK_EXCEPTION macros cleanup
rriggs
parents: 22258
diff changeset
   284
    } while (0)
23013
1cf3dddf9ff7 8035640: JNU_CHECK_EXCEPTION should support c++ JNI syntax
pchelko
parents: 22938
diff changeset
   285
#endif /* __cplusplus */
58493
55a8d95c7787 8231355: Remove unused utility methods in libjava
redestad
parents: 57868
diff changeset
   286
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
/************************************************************************
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
 * Debugging utilities
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
JNIEXPORT jstring JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
JNU_ToString(JNIEnv *env, jobject object);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
58493
55a8d95c7787 8231355: Remove unused utility methods in libjava
redestad
parents: 57868
diff changeset
   294
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
 * Package shorthand for use by native libraries
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
#define JNU_JAVAPKG         "java/lang/"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
#define JNU_JAVAIOPKG       "java/io/"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
#define JNU_JAVANETPKG      "java/net/"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
 * Check if the current thread is attached to the VM, and returns
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
 * the JNIEnv of the specified version if the thread is attached.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
 * If the current thread is not attached, this function returns 0.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
 * If the current thread is attached, this function returns the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
 * JNI environment, or returns (void *)JNI_ERR if the specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
 * version is not supported.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
JNIEXPORT void * JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
JNU_GetEnv(JavaVM *vm, jint version);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
 * Warning free access to pointers stored in Java long fields.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
#define JNU_GetLongFieldAsPtr(env,obj,id) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
    (jlong_to_ptr((*(env))->GetLongField((env),(obj),(id))))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
#define JNU_SetLongFieldFromPtr(env,obj,id,val) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
    (*(env))->SetLongField((env),(obj),(id),ptr_to_jlong(val))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
3111
fefdeafb7ab9 6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents: 2
diff changeset
   323
/*
fefdeafb7ab9 6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents: 2
diff changeset
   324
 * Internal use only.
fefdeafb7ab9 6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents: 2
diff changeset
   325
 */
fefdeafb7ab9 6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents: 2
diff changeset
   326
enum {
fefdeafb7ab9 6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents: 2
diff changeset
   327
    NO_ENCODING_YET = 0,        /* "sun.jnu.encoding" not yet set */
fefdeafb7ab9 6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents: 2
diff changeset
   328
    NO_FAST_ENCODING,           /* Platform encoding is not fast */
fefdeafb7ab9 6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents: 2
diff changeset
   329
    FAST_8859_1,                /* ISO-8859-1 */
fefdeafb7ab9 6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents: 2
diff changeset
   330
    FAST_CP1252,                /* MS-DOS Cp1252 */
45572
07f412070bd9 8181147: JNI_GetStringPlatformChars should have a fast path for UTF-8
redestad
parents: 39318
diff changeset
   331
    FAST_646_US,                /* US-ASCII : ISO646-US */
07f412070bd9 8181147: JNI_GetStringPlatformChars should have a fast path for UTF-8
redestad
parents: 39318
diff changeset
   332
    FAST_UTF_8
3111
fefdeafb7ab9 6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents: 2
diff changeset
   333
};
fefdeafb7ab9 6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents: 2
diff changeset
   334
49557
7b00ac6c11ab 8201246: Export native function to set platform encoding
rriggs
parents: 49440
diff changeset
   335
JNIEXPORT void InitializeEncoding(JNIEnv *env, const char *name);
3111
fefdeafb7ab9 6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents: 2
diff changeset
   336
16479
d845c18d13f2 8005716: Enhance JNI specification to allow support of static JNI libraries in Embedded JREs
alanb
parents: 5506
diff changeset
   337
void* getProcessHandle();
d845c18d13f2 8005716: Enhance JNI specification to allow support of static JNI libraries in Embedded JREs
alanb
parents: 5506
diff changeset
   338
d845c18d13f2 8005716: Enhance JNI specification to allow support of static JNI libraries in Embedded JREs
alanb
parents: 5506
diff changeset
   339
void buildJniFunctionName(const char *sym, const char *cname,
d845c18d13f2 8005716: Enhance JNI specification to allow support of static JNI libraries in Embedded JREs
alanb
parents: 5506
diff changeset
   340
                          char *jniEntryName);
3111
fefdeafb7ab9 6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents: 2
diff changeset
   341
49440
396ea30afbd5 8200178: Remove mapfiles for JDK native libraries
ihse
parents: 49121
diff changeset
   342
JNIEXPORT size_t JNICALL
396ea30afbd5 8200178: Remove mapfiles for JDK native libraries
ihse
parents: 49121
diff changeset
   343
getLastErrorString(char *buf, size_t len);
396ea30afbd5 8200178: Remove mapfiles for JDK native libraries
ihse
parents: 49121
diff changeset
   344
396ea30afbd5 8200178: Remove mapfiles for JDK native libraries
ihse
parents: 49121
diff changeset
   345
JNIEXPORT int JNICALL
396ea30afbd5 8200178: Remove mapfiles for JDK native libraries
ihse
parents: 49121
diff changeset
   346
getErrorString(int err, char *buf, size_t len);
33653
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   347
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   348
#ifdef STATIC_BUILD
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   349
/* Macros for handling declaration of static/dynamic
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   350
 * JNI library Load/Unload functions
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   351
 *
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   352
 * Use DEF_JNI_On{Un}Load when you want a static and non-static entry points.
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   353
 * Use DEF_STATIC_JNI_On{Un}Load when you only want a static one.
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   354
 *
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   355
 * LIBRARY_NAME must be set to the name of the library
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   356
 */
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   357
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   358
/* These three macros are needed to get proper concatenation of
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   359
 * the LIBRARY_NAME
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   360
 *
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   361
 * NOTE: LIBRARY_NAME must be set for static builds.
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   362
 */
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   363
#define ADD_LIB_NAME3(name, lib) name ## lib
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   364
#define ADD_LIB_NAME2(name, lib) ADD_LIB_NAME3(name, lib)
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   365
#define ADD_LIB_NAME(entry) ADD_LIB_NAME2(entry, LIBRARY_NAME)
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   366
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   367
#define DEF_JNI_OnLoad \
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   368
ADD_LIB_NAME(JNI_OnLoad_)(JavaVM *vm, void *reserved) \
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   369
{ \
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   370
  jint JNICALL ADD_LIB_NAME(JNI_OnLoad_dynamic_)(JavaVM *vm, void *reserved); \
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   371
  ADD_LIB_NAME(JNI_OnLoad_dynamic_)(vm, reserved); \
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   372
  return JNI_VERSION_1_8; \
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   373
} \
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   374
jint JNICALL ADD_LIB_NAME(JNI_OnLoad_dynamic_)
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   375
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   376
#define DEF_STATIC_JNI_OnLoad \
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   377
JNIEXPORT jint JNICALL ADD_LIB_NAME(JNI_OnLoad_)(JavaVM *vm, void *reserved) { \
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   378
    return JNI_VERSION_1_8; \
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   379
}
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   380
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   381
#define DEF_JNI_OnUnload \
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   382
ADD_LIB_NAME(JNI_OnUnload_)(JavaVM *vm, void *reserved) \
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   383
{ \
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   384
  void JNICALL ADD_LIB_NAME(JNI_OnUnload_dynamic_)(JavaVM *vm, void *reserved); \
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   385
  ADD_LIB_NAME(JNI_OnUnload_dynamic_)(vm, reserved); \
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   386
} \
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   387
void JNICALL ADD_LIB_NAME(JNI_OnUnload_dynamic_)
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   388
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   389
#define DEF_STATIC_JNI_OnUnload \
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   390
ADD_LIB_NAME(JNI_OnUnload_)
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   391
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   392
#else
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   393
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   394
#define DEF_JNI_OnLoad JNI_OnLoad
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   395
#define DEF_STATIC_JNI_OnLoad
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   396
#define DEF_JNI_OnUnload JNI_OnUnload
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   397
#define DEF_STATIC_JNI_OnUnload
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   398
#endif
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   399
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   400
#ifdef STATIC_BUILD
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   401
/* Macros for handling declaration of static/dynamic
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   402
 * Agent library Load/Attach/Unload functions
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   403
 *
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   404
 * Use DEF_Agent_OnLoad, DEF_Agent_OnAttach or DEF_Agent_OnUnload
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   405
 *     when you want both static and non-static entry points.
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   406
 * Use DEF_STATIC_Agent_OnLoad, DEF_STATIC_Agent_OnAttach or
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   407
 *     DEF_STATIC_Agent_OnUnload when you only want a static one.
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   408
 *
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   409
 * LIBRARY_NAME must be set to the name of the library for static builds.
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   410
 */
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   411
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   412
#define DEF_Agent_OnLoad \
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   413
ADD_LIB_NAME(Agent_OnLoad_)(JavaVM *vm, char *options, void *reserved) \
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   414
{ \
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   415
  jint JNICALL ADD_LIB_NAME(Agent_OnLoad_dynamic_)(JavaVM *vm, char *options, void *reserved); \
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   416
  return ADD_LIB_NAME(Agent_OnLoad_dynamic_)(vm, options, reserved); \
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   417
} \
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   418
jint JNICALL ADD_LIB_NAME(Agent_OnLoad_dynamic_)
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   419
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   420
#define DEF_STATIC_Agent_OnLoad \
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   421
JNIEXPORT jint JNICALL ADD_LIB_NAME(Agent_OnLoad_)(JavaVM *vm, char *options, void *reserved) { \
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   422
    return JNI_FALSE; \
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   423
}
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   424
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   425
#define DEF_Agent_OnAttach \
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   426
ADD_LIB_NAME(Agent_OnAttach_)(JavaVM *vm, char *options, void *reserved) \
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   427
{ \
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   428
  jint JNICALL ADD_LIB_NAME(Agent_OnAttach_dynamic_)(JavaVM *vm, char *options, void *reserved); \
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   429
  return ADD_LIB_NAME(Agent_OnAttach_dynamic_)(vm, options, reserved); \
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   430
} \
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   431
jint JNICALL ADD_LIB_NAME(Agent_OnAttach_dynamic_)
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   432
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   433
#define DEF_STATIC_Agent_OnAttach \
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   434
JNIEXPORT jint JNICALL ADD_LIB_NAME(Agent_OnLoad_)(JavaVM *vm, char *options, void *reserved) { \
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   435
    return JNI_FALSE; \
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   436
}
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   437
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   438
#define DEF_Agent_OnUnload \
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   439
ADD_LIB_NAME(Agent_OnUnload_)(JavaVM *vm) \
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   440
{ \
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   441
  void JNICALL ADD_LIB_NAME(Agent_OnUnload_dynamic_)(JavaVM *vm); \
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   442
  ADD_LIB_NAME(Agent_OnUnload_dynamic_)(vm); \
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   443
} \
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   444
void JNICALL ADD_LIB_NAME(Agent_OnUnload_dynamic_)
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   445
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   446
#define DEF_STATIC_Agent_OnUnload \
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   447
ADD_LIB_NAME(Agent_OnUnload_)
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   448
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   449
#else
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   450
#define DEF_Agent_OnLoad Agent_OnLoad
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   451
#define DEF_Agent_OnAttach Agent_OnAttach
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   452
#define DEF_Agent_OnUnload Agent_OnUnload
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   453
#define DEF_STATIC_Agent_OnLoad
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   454
#define DEF_STATIC_Agent_OnAttach
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   455
#define DEF_STATIC_Agent_OnUnload
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   456
#endif
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   457
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
#ifdef __cplusplus
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
} /* extern "C" */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
#endif /* __cplusplus */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
#endif /* JNI_UTIL_H */