src/java.base/share/native/libjava/jni_util.h
author aivanov
Wed, 30 Oct 2019 14:08:07 +0000
changeset 58859 3fc5905f2bec
parent 58728 6d5c7f91e0b5
permissions -rw-r--r--
8232724: Remove indirection with calling JNU_NewStringPlatform Reviewed-by: dholmes, clanger
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
58859
3fc5905f2bec 8232724: Remove indirection with calling JNU_NewStringPlatform
aivanov
parents: 58728
diff changeset
     2
 * Copyright (c) 1997, 2019, 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 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
JNIEXPORT const char *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
GetStringPlatformChars(JNIEnv *env, jstring jstr, jboolean *isCopy);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
JNIEXPORT jstring JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
JNU_NewStringPlatform(JNIEnv *env, const char *str);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
JNIEXPORT const char * JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
JNU_GetStringPlatformChars(JNIEnv *env, jstring jstr, jboolean *isCopy);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
JNU_ReleaseStringPlatformChars(JNIEnv *env, jstring jstr, const char *str);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
/* Class constants */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
JNIEXPORT jclass JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
JNU_ClassString(JNIEnv *env);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
/* Copy count number of arguments from src to dst. Array bounds
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
 * and ArrayStoreException are checked.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
JNIEXPORT jint JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
JNU_CopyObjectArray(JNIEnv *env, jobjectArray dst, jobjectArray src,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
                    jint count);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
/* Invoke a object-returning static method, based on class name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
 * method name, and signature string.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
 * The caller should check for exceptions by setting hasException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
 * argument. If the caller is not interested in whether an exception
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
 * has occurred, pass in NULL.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
JNIEXPORT jvalue JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
JNU_CallStaticMethodByName(JNIEnv *env,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
                           jboolean *hasException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
                           const char *class_name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
                           const char *name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
                           const char *signature,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
                           ...);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
/* Invoke an instance method by name.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
JNIEXPORT jvalue JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
JNU_CallMethodByName(JNIEnv *env,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
                     jboolean *hasException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
                     jobject obj,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
                     const char *name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
                     const char *signature,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
                     ...);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
JNIEXPORT jvalue JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
JNU_CallMethodByNameV(JNIEnv *env,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
                      jboolean *hasException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
                      jobject obj,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
                      const char *name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
                      const char *signature,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
                      va_list args);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
/* Construct a new object of class, specifying the class by name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
 * and specififying which constructor to run and what arguments to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
 * pass to it.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
 * The method will return an initialized instance if successful.
21278
ef8a3a2a72f2 8022746: List of spelling errors in API doc
malenkov
parents: 16479
diff changeset
   157
 * It will return NULL if an error has occurred (for example if
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
 * it ran out of memory) and the appropriate Java exception will
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
 * have been thrown.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
JNIEXPORT jobject JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
JNU_NewObjectByName(JNIEnv *env, const char *class_name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
                    const char *constructor_sig, ...);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
/* returns:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
 * 0: object is not an instance of the class named by classname.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
 * 1: object is an instance of the class named by classname.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
 * -1: the class named by classname cannot be found. An exception
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
 * has been thrown.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
JNIEXPORT jint JNICALL
57868
7ae075afc72f 8230104: JNU_IsInstanceOfByName needs const parameter
rriggs
parents: 51151
diff changeset
   172
JNU_IsInstanceOfByName(JNIEnv *env, jobject object, const char *classname);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
/* Get or set class and instance fields.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
 * Note that set functions take a variable number of arguments,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
 * but only one argument of the appropriate type can be passed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
 * For example, to set an integer field i to 100:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
 * JNU_SetFieldByName(env, &exc, obj, "i", "I", 100);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
 * To set a float field f to 12.3:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
 * JNU_SetFieldByName(env, &exc, obj, "f", "F", 12.3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
 * The caller should check for exceptions by setting hasException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
 * argument. If the caller is not interested in whether an exception
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
 * has occurred, pass in NULL.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
JNIEXPORT jvalue JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
JNU_GetFieldByName(JNIEnv *env,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
                   jboolean *hasException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
                   jobject obj,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
                   const char *name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
                   const char *sig);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
JNU_SetFieldByName(JNIEnv *env,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
                   jboolean *hasException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
                   jobject obj,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
                   const char *name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
                   const char *sig,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
                   ...);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
JNIEXPORT jvalue JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
JNU_GetStaticFieldByName(JNIEnv *env,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
                         jboolean *hasException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
                         const char *classname,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
                         const char *name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
                         const char *sig);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
/************************************************************************
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
 * Miscellaneous utilities used by the class libraries
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
#define IS_NULL(obj) ((obj) == NULL)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
#define JNU_IsNull(env,obj) ((obj) == NULL)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
22258
db80f864ed8f 8030875: Macros for checking and returning on exceptions
rriggs
parents: 21278
diff changeset
   219
/************************************************************************
22637
d4b45e70a981 8031737: CHECK_NULL and CHECK_EXCEPTION macros cleanup
rriggs
parents: 22258
diff changeset
   220
 * Miscellaneous utilities used by the class libraries to return from
d4b45e70a981 8031737: CHECK_NULL and CHECK_EXCEPTION macros cleanup
rriggs
parents: 22258
diff changeset
   221
 * 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
   222
 */
db80f864ed8f 8030875: Macros for checking and returning on exceptions
rriggs
parents: 21278
diff changeset
   223
22637
d4b45e70a981 8031737: CHECK_NULL and CHECK_EXCEPTION macros cleanup
rriggs
parents: 22258
diff changeset
   224
#define CHECK_NULL(x)                           \
d4b45e70a981 8031737: CHECK_NULL and CHECK_EXCEPTION macros cleanup
rriggs
parents: 22258
diff changeset
   225
    do {                                        \
d4b45e70a981 8031737: CHECK_NULL and CHECK_EXCEPTION macros cleanup
rriggs
parents: 22258
diff changeset
   226
        if ((x) == NULL) {                      \
d4b45e70a981 8031737: CHECK_NULL and CHECK_EXCEPTION macros cleanup
rriggs
parents: 22258
diff changeset
   227
            return;                             \
d4b45e70a981 8031737: CHECK_NULL and CHECK_EXCEPTION macros cleanup
rriggs
parents: 22258
diff changeset
   228
        }                                       \
d4b45e70a981 8031737: CHECK_NULL and CHECK_EXCEPTION macros cleanup
rriggs
parents: 22258
diff changeset
   229
    } while (0)                                 \
d4b45e70a981 8031737: CHECK_NULL and CHECK_EXCEPTION macros cleanup
rriggs
parents: 22258
diff changeset
   230
51151
d6b131d2bc8b 8193419: Better Internet address support
vtewari
parents: 49557
diff changeset
   231
#define CHECK_NULL_THROW_NPE(env, x, msg)         \
d6b131d2bc8b 8193419: Better Internet address support
vtewari
parents: 49557
diff changeset
   232
    do {                                        \
d6b131d2bc8b 8193419: Better Internet address support
vtewari
parents: 49557
diff changeset
   233
        if ((x) == NULL) {                      \
d6b131d2bc8b 8193419: Better Internet address support
vtewari
parents: 49557
diff changeset
   234
           JNU_ThrowNullPointerException((env), (msg));\
d6b131d2bc8b 8193419: Better Internet address support
vtewari
parents: 49557
diff changeset
   235
           return;                              \
d6b131d2bc8b 8193419: Better Internet address support
vtewari
parents: 49557
diff changeset
   236
        }                                       \
d6b131d2bc8b 8193419: Better Internet address support
vtewari
parents: 49557
diff changeset
   237
    } while(0)                                  \
d6b131d2bc8b 8193419: Better Internet address support
vtewari
parents: 49557
diff changeset
   238
d6b131d2bc8b 8193419: Better Internet address support
vtewari
parents: 49557
diff changeset
   239
#define CHECK_NULL_THROW_NPE_RETURN(env, x, msg, z)\
d6b131d2bc8b 8193419: Better Internet address support
vtewari
parents: 49557
diff changeset
   240
    do {                                        \
d6b131d2bc8b 8193419: Better Internet address support
vtewari
parents: 49557
diff changeset
   241
        if ((x) == NULL) {                      \
d6b131d2bc8b 8193419: Better Internet address support
vtewari
parents: 49557
diff changeset
   242
           JNU_ThrowNullPointerException((env), (msg));\
d6b131d2bc8b 8193419: Better Internet address support
vtewari
parents: 49557
diff changeset
   243
           return (z);                          \
d6b131d2bc8b 8193419: Better Internet address support
vtewari
parents: 49557
diff changeset
   244
        }                                       \
d6b131d2bc8b 8193419: Better Internet address support
vtewari
parents: 49557
diff changeset
   245
    } while(0)                                  \
d6b131d2bc8b 8193419: Better Internet address support
vtewari
parents: 49557
diff changeset
   246
22637
d4b45e70a981 8031737: CHECK_NULL and CHECK_EXCEPTION macros cleanup
rriggs
parents: 22258
diff changeset
   247
#define CHECK_NULL_RETURN(x, y)                 \
d4b45e70a981 8031737: CHECK_NULL and CHECK_EXCEPTION macros cleanup
rriggs
parents: 22258
diff changeset
   248
    do {                                        \
d4b45e70a981 8031737: CHECK_NULL and CHECK_EXCEPTION macros cleanup
rriggs
parents: 22258
diff changeset
   249
        if ((x) == NULL) {                      \
d4b45e70a981 8031737: CHECK_NULL and CHECK_EXCEPTION macros cleanup
rriggs
parents: 22258
diff changeset
   250
            return (y);                         \
d4b45e70a981 8031737: CHECK_NULL and CHECK_EXCEPTION macros cleanup
rriggs
parents: 22258
diff changeset
   251
        }                                       \
d4b45e70a981 8031737: CHECK_NULL and CHECK_EXCEPTION macros cleanup
rriggs
parents: 22258
diff changeset
   252
    } while (0)                                 \
22258
db80f864ed8f 8030875: Macros for checking and returning on exceptions
rriggs
parents: 21278
diff changeset
   253
23013
1cf3dddf9ff7 8035640: JNU_CHECK_EXCEPTION should support c++ JNI syntax
pchelko
parents: 22938
diff changeset
   254
#ifdef __cplusplus
1cf3dddf9ff7 8035640: JNU_CHECK_EXCEPTION should support c++ JNI syntax
pchelko
parents: 22938
diff changeset
   255
#define JNU_CHECK_EXCEPTION(env)                \
1cf3dddf9ff7 8035640: JNU_CHECK_EXCEPTION should support c++ JNI syntax
pchelko
parents: 22938
diff changeset
   256
    do {                                        \
1cf3dddf9ff7 8035640: JNU_CHECK_EXCEPTION should support c++ JNI syntax
pchelko
parents: 22938
diff changeset
   257
        if ((env)->ExceptionCheck()) {          \
1cf3dddf9ff7 8035640: JNU_CHECK_EXCEPTION should support c++ JNI syntax
pchelko
parents: 22938
diff changeset
   258
            return;                             \
1cf3dddf9ff7 8035640: JNU_CHECK_EXCEPTION should support c++ JNI syntax
pchelko
parents: 22938
diff changeset
   259
        }                                       \
1cf3dddf9ff7 8035640: JNU_CHECK_EXCEPTION should support c++ JNI syntax
pchelko
parents: 22938
diff changeset
   260
    } while (0)                                 \
1cf3dddf9ff7 8035640: JNU_CHECK_EXCEPTION should support c++ JNI syntax
pchelko
parents: 22938
diff changeset
   261
1cf3dddf9ff7 8035640: JNU_CHECK_EXCEPTION should support c++ JNI syntax
pchelko
parents: 22938
diff changeset
   262
#define JNU_CHECK_EXCEPTION_RETURN(env, y)      \
1cf3dddf9ff7 8035640: JNU_CHECK_EXCEPTION should support c++ JNI syntax
pchelko
parents: 22938
diff changeset
   263
    do {                                        \
1cf3dddf9ff7 8035640: JNU_CHECK_EXCEPTION should support c++ JNI syntax
pchelko
parents: 22938
diff changeset
   264
        if ((env)->ExceptionCheck()) {          \
1cf3dddf9ff7 8035640: JNU_CHECK_EXCEPTION should support c++ JNI syntax
pchelko
parents: 22938
diff changeset
   265
            return (y);                         \
1cf3dddf9ff7 8035640: JNU_CHECK_EXCEPTION should support c++ JNI syntax
pchelko
parents: 22938
diff changeset
   266
        }                                       \
1cf3dddf9ff7 8035640: JNU_CHECK_EXCEPTION should support c++ JNI syntax
pchelko
parents: 22938
diff changeset
   267
    } while (0)
1cf3dddf9ff7 8035640: JNU_CHECK_EXCEPTION should support c++ JNI syntax
pchelko
parents: 22938
diff changeset
   268
#else
22637
d4b45e70a981 8031737: CHECK_NULL and CHECK_EXCEPTION macros cleanup
rriggs
parents: 22258
diff changeset
   269
#define JNU_CHECK_EXCEPTION(env)                \
d4b45e70a981 8031737: CHECK_NULL and CHECK_EXCEPTION macros cleanup
rriggs
parents: 22258
diff changeset
   270
    do {                                        \
d4b45e70a981 8031737: CHECK_NULL and CHECK_EXCEPTION macros cleanup
rriggs
parents: 22258
diff changeset
   271
        if ((*env)->ExceptionCheck(env)) {      \
d4b45e70a981 8031737: CHECK_NULL and CHECK_EXCEPTION macros cleanup
rriggs
parents: 22258
diff changeset
   272
            return;                             \
d4b45e70a981 8031737: CHECK_NULL and CHECK_EXCEPTION macros cleanup
rriggs
parents: 22258
diff changeset
   273
        }                                       \
d4b45e70a981 8031737: CHECK_NULL and CHECK_EXCEPTION macros cleanup
rriggs
parents: 22258
diff changeset
   274
    } while (0)                                 \
d4b45e70a981 8031737: CHECK_NULL and CHECK_EXCEPTION macros cleanup
rriggs
parents: 22258
diff changeset
   275
d4b45e70a981 8031737: CHECK_NULL and CHECK_EXCEPTION macros cleanup
rriggs
parents: 22258
diff changeset
   276
#define JNU_CHECK_EXCEPTION_RETURN(env, y)      \
d4b45e70a981 8031737: CHECK_NULL and CHECK_EXCEPTION macros cleanup
rriggs
parents: 22258
diff changeset
   277
    do {                                        \
d4b45e70a981 8031737: CHECK_NULL and CHECK_EXCEPTION macros cleanup
rriggs
parents: 22258
diff changeset
   278
        if ((*env)->ExceptionCheck(env)) {      \
d4b45e70a981 8031737: CHECK_NULL and CHECK_EXCEPTION macros cleanup
rriggs
parents: 22258
diff changeset
   279
            return (y);                         \
d4b45e70a981 8031737: CHECK_NULL and CHECK_EXCEPTION macros cleanup
rriggs
parents: 22258
diff changeset
   280
        }                                       \
d4b45e70a981 8031737: CHECK_NULL and CHECK_EXCEPTION macros cleanup
rriggs
parents: 22258
diff changeset
   281
    } while (0)
23013
1cf3dddf9ff7 8035640: JNU_CHECK_EXCEPTION should support c++ JNI syntax
pchelko
parents: 22938
diff changeset
   282
#endif /* __cplusplus */
58493
55a8d95c7787 8231355: Remove unused utility methods in libjava
redestad
parents: 57868
diff changeset
   283
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
/************************************************************************
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
 * Debugging utilities
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
JNIEXPORT jstring JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
JNU_ToString(JNIEnv *env, jobject object);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
58493
55a8d95c7787 8231355: Remove unused utility methods in libjava
redestad
parents: 57868
diff changeset
   291
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
 * Package shorthand for use by native libraries
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
#define JNU_JAVAPKG         "java/lang/"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
#define JNU_JAVAIOPKG       "java/io/"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
#define JNU_JAVANETPKG      "java/net/"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
 * Check if the current thread is attached to the VM, and returns
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
 * the JNIEnv of the specified version if the thread is attached.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
 * If the current thread is not attached, this function returns 0.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
 * If the current thread is attached, this function returns the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
 * JNI environment, or returns (void *)JNI_ERR if the specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
 * version is not supported.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
JNIEXPORT void * JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
JNU_GetEnv(JavaVM *vm, jint version);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
 * Warning free access to pointers stored in Java long fields.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
#define JNU_GetLongFieldAsPtr(env,obj,id) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
    (jlong_to_ptr((*(env))->GetLongField((env),(obj),(id))))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
#define JNU_SetLongFieldFromPtr(env,obj,id,val) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
    (*(env))->SetLongField((env),(obj),(id),ptr_to_jlong(val))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
3111
fefdeafb7ab9 6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents: 2
diff changeset
   320
/*
fefdeafb7ab9 6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents: 2
diff changeset
   321
 * Internal use only.
fefdeafb7ab9 6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents: 2
diff changeset
   322
 */
fefdeafb7ab9 6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents: 2
diff changeset
   323
enum {
fefdeafb7ab9 6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents: 2
diff changeset
   324
    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
   325
    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
   326
    FAST_8859_1,                /* ISO-8859-1 */
fefdeafb7ab9 6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents: 2
diff changeset
   327
    FAST_CP1252,                /* MS-DOS Cp1252 */
45572
07f412070bd9 8181147: JNI_GetStringPlatformChars should have a fast path for UTF-8
redestad
parents: 39318
diff changeset
   328
    FAST_646_US,                /* US-ASCII : ISO646-US */
07f412070bd9 8181147: JNI_GetStringPlatformChars should have a fast path for UTF-8
redestad
parents: 39318
diff changeset
   329
    FAST_UTF_8
3111
fefdeafb7ab9 6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents: 2
diff changeset
   330
};
fefdeafb7ab9 6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents: 2
diff changeset
   331
49557
7b00ac6c11ab 8201246: Export native function to set platform encoding
rriggs
parents: 49440
diff changeset
   332
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
   333
16479
d845c18d13f2 8005716: Enhance JNI specification to allow support of static JNI libraries in Embedded JREs
alanb
parents: 5506
diff changeset
   334
void* getProcessHandle();
d845c18d13f2 8005716: Enhance JNI specification to allow support of static JNI libraries in Embedded JREs
alanb
parents: 5506
diff changeset
   335
d845c18d13f2 8005716: Enhance JNI specification to allow support of static JNI libraries in Embedded JREs
alanb
parents: 5506
diff changeset
   336
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
   337
                          char *jniEntryName);
3111
fefdeafb7ab9 6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents: 2
diff changeset
   338
49440
396ea30afbd5 8200178: Remove mapfiles for JDK native libraries
ihse
parents: 49121
diff changeset
   339
JNIEXPORT size_t JNICALL
396ea30afbd5 8200178: Remove mapfiles for JDK native libraries
ihse
parents: 49121
diff changeset
   340
getLastErrorString(char *buf, size_t len);
396ea30afbd5 8200178: Remove mapfiles for JDK native libraries
ihse
parents: 49121
diff changeset
   341
396ea30afbd5 8200178: Remove mapfiles for JDK native libraries
ihse
parents: 49121
diff changeset
   342
JNIEXPORT int JNICALL
396ea30afbd5 8200178: Remove mapfiles for JDK native libraries
ihse
parents: 49121
diff changeset
   343
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
   344
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   345
#ifdef STATIC_BUILD
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   346
/* 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
   347
 * JNI library Load/Unload functions
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   348
 *
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   349
 * 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
   350
 * 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
   351
 *
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   352
 * 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
   353
 */
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
/* 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
   356
 * the LIBRARY_NAME
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
 * 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
   359
 */
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   360
#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
   361
#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
   362
#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
   363
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   364
#define DEF_JNI_OnLoad \
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   365
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
   366
{ \
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   367
  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
   368
  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
   369
  return JNI_VERSION_1_8; \
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   370
} \
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   371
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
   372
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   373
#define DEF_STATIC_JNI_OnLoad \
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   374
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
   375
    return JNI_VERSION_1_8; \
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   376
}
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   377
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   378
#define DEF_JNI_OnUnload \
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   379
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
   380
{ \
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   381
  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
   382
  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
   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_)
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   385
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   386
#define DEF_STATIC_JNI_OnUnload \
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   387
ADD_LIB_NAME(JNI_OnUnload_)
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
#else
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   390
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   391
#define DEF_JNI_OnLoad JNI_OnLoad
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   392
#define DEF_STATIC_JNI_OnLoad
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   393
#define DEF_JNI_OnUnload JNI_OnUnload
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   394
#define DEF_STATIC_JNI_OnUnload
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   395
#endif
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   396
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   397
#ifdef STATIC_BUILD
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   398
/* 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
   399
 * Agent library Load/Attach/Unload functions
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   400
 *
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   401
 * 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
   402
 *     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
   403
 * 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
   404
 *     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
   405
 *
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   406
 * 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
   407
 */
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
#define DEF_Agent_OnLoad \
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   410
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
   411
{ \
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   412
  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
   413
  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
   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_)
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   416
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   417
#define DEF_STATIC_Agent_OnLoad \
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   418
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
   419
    return JNI_FALSE; \
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   420
}
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   421
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   422
#define DEF_Agent_OnAttach \
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   423
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
   424
{ \
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   425
  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
   426
  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
   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_)
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   429
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   430
#define DEF_STATIC_Agent_OnAttach \
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   431
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
   432
    return JNI_FALSE; \
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   433
}
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   434
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   435
#define DEF_Agent_OnUnload \
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   436
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
   437
{ \
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   438
  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
   439
  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
   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_)
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   442
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   443
#define DEF_STATIC_Agent_OnUnload \
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   444
ADD_LIB_NAME(Agent_OnUnload_)
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
#else
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   447
#define DEF_Agent_OnLoad Agent_OnLoad
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   448
#define DEF_Agent_OnAttach Agent_OnAttach
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   449
#define DEF_Agent_OnUnload Agent_OnUnload
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   450
#define DEF_STATIC_Agent_OnLoad
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   451
#define DEF_STATIC_Agent_OnAttach
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   452
#define DEF_STATIC_Agent_OnUnload
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   453
#endif
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   454
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
#ifdef __cplusplus
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
} /* extern "C" */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
#endif /* __cplusplus */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
#endif /* JNI_UTIL_H */