src/java.base/share/native/libjava/jni_util.h
author rriggs
Tue, 10 Apr 2018 10:49:17 -0400
changeset 49557 7b00ac6c11ab
parent 49440 396ea30afbd5
child 51151 d6b131d2bc8b
child 56721 01b558efd286
permissions -rw-r--r--
8201246: Export native function to set platform encoding Reviewed-by: rriggs Contributed-by: andrew_m_leonard@uk.ibm.com
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_ThrowIllegalAccessError(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_ThrowIllegalAccessException(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_ThrowInternalError(JNIEnv *env, const char *msg);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
JNU_ThrowIOException(JNIEnv *env, const char *msg);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
JNU_ThrowNoSuchFieldException(JNIEnv *env, const char *msg);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
JNU_ThrowNoSuchMethodException(JNIEnv *env, const char *msg);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
JNU_ThrowClassNotFoundException(JNIEnv *env, const char *msg);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
JNU_ThrowNumberFormatException(JNIEnv *env, const char *msg);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
JNU_ThrowNoSuchFieldError(JNIEnv *env, const char *msg);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
JNU_ThrowNoSuchMethodError(JNIEnv *env, const char *msg);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
JNU_ThrowStringIndexOutOfBoundsException(JNIEnv *env, const char *msg);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
JNU_ThrowInstantiationException(JNIEnv *env, const char *msg);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
/* Throw an exception by name, using the string returned by
39318
2006d1d41c8b 8158023: SocketExceptions contain too little information sometimes
clanger
parents: 33653
diff changeset
   101
 * getLastErrorString for the detail string. If the last-error
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
 * string is NULL, use the given default detail string.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
JNU_ThrowByNameWithLastError(JNIEnv *env, const char *name,
39318
2006d1d41c8b 8158023: SocketExceptions contain too little information sometimes
clanger
parents: 33653
diff changeset
   106
                             const char *defaultDetail);
2006d1d41c8b 8158023: SocketExceptions contain too little information sometimes
clanger
parents: 33653
diff changeset
   107
2006d1d41c8b 8158023: SocketExceptions contain too little information sometimes
clanger
parents: 33653
diff changeset
   108
/* 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
   109
 * returned by getLastErrorString to construct the detail string.
2006d1d41c8b 8158023: SocketExceptions contain too little information sometimes
clanger
parents: 33653
diff changeset
   110
 */
2006d1d41c8b 8158023: SocketExceptions contain too little information sometimes
clanger
parents: 33653
diff changeset
   111
JNIEXPORT void JNICALL
2006d1d41c8b 8158023: SocketExceptions contain too little information sometimes
clanger
parents: 33653
diff changeset
   112
JNU_ThrowByNameWithMessageAndLastError
2006d1d41c8b 8158023: SocketExceptions contain too little information sometimes
clanger
parents: 33653
diff changeset
   113
  (JNIEnv *env, const char *name, const char *message);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
/* 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
   116
 * string. If the last-error string is NULL, use the given default
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
 * detail string.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
JNU_ThrowIOExceptionWithLastError(JNIEnv *env, const char *defaultDetail);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
/* Convert between Java strings and i18n C strings */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
JNIEXPORT jstring
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
NewStringPlatform(JNIEnv *env, const char *str);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
JNIEXPORT const char *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
GetStringPlatformChars(JNIEnv *env, jstring jstr, jboolean *isCopy);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
JNIEXPORT jstring JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
JNU_NewStringPlatform(JNIEnv *env, const char *str);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
JNIEXPORT const char * JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
JNU_GetStringPlatformChars(JNIEnv *env, jstring jstr, jboolean *isCopy);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
JNU_ReleaseStringPlatformChars(JNIEnv *env, jstring jstr, const char *str);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
/* Class constants */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
JNIEXPORT jclass JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
JNU_ClassString(JNIEnv *env);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
JNIEXPORT jclass JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
JNU_ClassClass(JNIEnv *env);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
JNIEXPORT jclass JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
JNU_ClassObject(JNIEnv *env);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
JNIEXPORT jclass JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
JNU_ClassThrowable(JNIEnv *env);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
/* Copy count number of arguments from src to dst. Array bounds
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
 * and ArrayStoreException are checked.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
JNIEXPORT jint JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
JNU_CopyObjectArray(JNIEnv *env, jobjectArray dst, jobjectArray src,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
                    jint count);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
/* Invoke a object-returning static method, based on class name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
 * method name, and signature string.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
 * The caller should check for exceptions by setting hasException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
 * argument. If the caller is not interested in whether an exception
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
 * has occurred, pass in NULL.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
JNIEXPORT jvalue JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
JNU_CallStaticMethodByName(JNIEnv *env,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
                           jboolean *hasException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
                           const char *class_name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
                           const char *name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
                           const char *signature,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
                           ...);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
/* Invoke an instance method by name.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
JNIEXPORT jvalue JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
JNU_CallMethodByName(JNIEnv *env,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
                     jboolean *hasException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
                     jobject obj,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
                     const char *name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
                     const char *signature,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
                     ...);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
JNIEXPORT jvalue JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
JNU_CallMethodByNameV(JNIEnv *env,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
                      jboolean *hasException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
                      jobject obj,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
                      const char *name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
                      const char *signature,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
                      va_list args);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
/* Construct a new object of class, specifying the class by name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
 * and specififying which constructor to run and what arguments to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
 * pass to it.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
 * The method will return an initialized instance if successful.
21278
ef8a3a2a72f2 8022746: List of spelling errors in API doc
malenkov
parents: 16479
diff changeset
   196
 * It will return NULL if an error has occurred (for example if
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
 * it ran out of memory) and the appropriate Java exception will
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
 * have been thrown.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
JNIEXPORT jobject JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
JNU_NewObjectByName(JNIEnv *env, const char *class_name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
                    const char *constructor_sig, ...);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
/* returns:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
 * 0: object is not an instance of the class named by classname.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
 * 1: object is an instance of the class named by classname.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
 * -1: the class named by classname cannot be found. An exception
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
 * has been thrown.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
JNIEXPORT jint JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
JNU_IsInstanceOfByName(JNIEnv *env, jobject object, char *classname);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
/* Get or set class and instance fields.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
 * Note that set functions take a variable number of arguments,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
 * but only one argument of the appropriate type can be passed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
 * For example, to set an integer field i to 100:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
 * JNU_SetFieldByName(env, &exc, obj, "i", "I", 100);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
 * To set a float field f to 12.3:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
 * JNU_SetFieldByName(env, &exc, obj, "f", "F", 12.3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
 * The caller should check for exceptions by setting hasException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
 * argument. If the caller is not interested in whether an exception
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
 * has occurred, pass in NULL.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
JNIEXPORT jvalue JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
JNU_GetFieldByName(JNIEnv *env,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
                   jboolean *hasException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
                   jobject obj,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
                   const char *name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
                   const char *sig);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
JNU_SetFieldByName(JNIEnv *env,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
                   jboolean *hasException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
                   jobject obj,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
                   const char *name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
                   const char *sig,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
                   ...);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
JNIEXPORT jvalue JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
JNU_GetStaticFieldByName(JNIEnv *env,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
                         jboolean *hasException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
                         const char *classname,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
                         const char *name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
                         const char *sig);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
JNU_SetStaticFieldByName(JNIEnv *env,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
                         jboolean *hasException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
                         const char *classname,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
                         const char *name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
                         const char *sig,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
                         ...);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
 * Calls the .equals method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
JNIEXPORT jboolean JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
JNU_Equals(JNIEnv *env, jobject object1, jobject object2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
/************************************************************************
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
 * Thread calls
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
 * Convenience thread-related calls on the java.lang.Object class.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
JNU_MonitorWait(JNIEnv *env, jobject object, jlong timeout);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
JNU_Notify(JNIEnv *env, jobject object);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
JNU_NotifyAll(JNIEnv *env, jobject object);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
/************************************************************************
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
 * Miscellaneous utilities used by the class libraries
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
#define IS_NULL(obj) ((obj) == NULL)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
#define JNU_IsNull(env,obj) ((obj) == NULL)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
22258
db80f864ed8f 8030875: Macros for checking and returning on exceptions
rriggs
parents: 21278
diff changeset
   288
/************************************************************************
22637
d4b45e70a981 8031737: CHECK_NULL and CHECK_EXCEPTION macros cleanup
rriggs
parents: 22258
diff changeset
   289
 * Miscellaneous utilities used by the class libraries to return from
d4b45e70a981 8031737: CHECK_NULL and CHECK_EXCEPTION macros cleanup
rriggs
parents: 22258
diff changeset
   290
 * 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
   291
 */
db80f864ed8f 8030875: Macros for checking and returning on exceptions
rriggs
parents: 21278
diff changeset
   292
22637
d4b45e70a981 8031737: CHECK_NULL and CHECK_EXCEPTION macros cleanup
rriggs
parents: 22258
diff changeset
   293
#define CHECK_NULL(x)                           \
d4b45e70a981 8031737: CHECK_NULL and CHECK_EXCEPTION macros cleanup
rriggs
parents: 22258
diff changeset
   294
    do {                                        \
d4b45e70a981 8031737: CHECK_NULL and CHECK_EXCEPTION macros cleanup
rriggs
parents: 22258
diff changeset
   295
        if ((x) == NULL) {                      \
d4b45e70a981 8031737: CHECK_NULL and CHECK_EXCEPTION macros cleanup
rriggs
parents: 22258
diff changeset
   296
            return;                             \
d4b45e70a981 8031737: CHECK_NULL and CHECK_EXCEPTION macros cleanup
rriggs
parents: 22258
diff changeset
   297
        }                                       \
d4b45e70a981 8031737: CHECK_NULL and CHECK_EXCEPTION macros cleanup
rriggs
parents: 22258
diff changeset
   298
    } while (0)                                 \
d4b45e70a981 8031737: CHECK_NULL and CHECK_EXCEPTION macros cleanup
rriggs
parents: 22258
diff changeset
   299
d4b45e70a981 8031737: CHECK_NULL and CHECK_EXCEPTION macros cleanup
rriggs
parents: 22258
diff changeset
   300
#define CHECK_NULL_RETURN(x, y)                 \
d4b45e70a981 8031737: CHECK_NULL and CHECK_EXCEPTION macros cleanup
rriggs
parents: 22258
diff changeset
   301
    do {                                        \
d4b45e70a981 8031737: CHECK_NULL and CHECK_EXCEPTION macros cleanup
rriggs
parents: 22258
diff changeset
   302
        if ((x) == NULL) {                      \
d4b45e70a981 8031737: CHECK_NULL and CHECK_EXCEPTION macros cleanup
rriggs
parents: 22258
diff changeset
   303
            return (y);                         \
d4b45e70a981 8031737: CHECK_NULL and CHECK_EXCEPTION macros cleanup
rriggs
parents: 22258
diff changeset
   304
        }                                       \
d4b45e70a981 8031737: CHECK_NULL and CHECK_EXCEPTION macros cleanup
rriggs
parents: 22258
diff changeset
   305
    } while (0)                                 \
22258
db80f864ed8f 8030875: Macros for checking and returning on exceptions
rriggs
parents: 21278
diff changeset
   306
23013
1cf3dddf9ff7 8035640: JNU_CHECK_EXCEPTION should support c++ JNI syntax
pchelko
parents: 22938
diff changeset
   307
#ifdef __cplusplus
1cf3dddf9ff7 8035640: JNU_CHECK_EXCEPTION should support c++ JNI syntax
pchelko
parents: 22938
diff changeset
   308
#define JNU_CHECK_EXCEPTION(env)                \
1cf3dddf9ff7 8035640: JNU_CHECK_EXCEPTION should support c++ JNI syntax
pchelko
parents: 22938
diff changeset
   309
    do {                                        \
1cf3dddf9ff7 8035640: JNU_CHECK_EXCEPTION should support c++ JNI syntax
pchelko
parents: 22938
diff changeset
   310
        if ((env)->ExceptionCheck()) {          \
1cf3dddf9ff7 8035640: JNU_CHECK_EXCEPTION should support c++ JNI syntax
pchelko
parents: 22938
diff changeset
   311
            return;                             \
1cf3dddf9ff7 8035640: JNU_CHECK_EXCEPTION should support c++ JNI syntax
pchelko
parents: 22938
diff changeset
   312
        }                                       \
1cf3dddf9ff7 8035640: JNU_CHECK_EXCEPTION should support c++ JNI syntax
pchelko
parents: 22938
diff changeset
   313
    } while (0)                                 \
1cf3dddf9ff7 8035640: JNU_CHECK_EXCEPTION should support c++ JNI syntax
pchelko
parents: 22938
diff changeset
   314
1cf3dddf9ff7 8035640: JNU_CHECK_EXCEPTION should support c++ JNI syntax
pchelko
parents: 22938
diff changeset
   315
#define JNU_CHECK_EXCEPTION_RETURN(env, y)      \
1cf3dddf9ff7 8035640: JNU_CHECK_EXCEPTION should support c++ JNI syntax
pchelko
parents: 22938
diff changeset
   316
    do {                                        \
1cf3dddf9ff7 8035640: JNU_CHECK_EXCEPTION should support c++ JNI syntax
pchelko
parents: 22938
diff changeset
   317
        if ((env)->ExceptionCheck()) {          \
1cf3dddf9ff7 8035640: JNU_CHECK_EXCEPTION should support c++ JNI syntax
pchelko
parents: 22938
diff changeset
   318
            return (y);                         \
1cf3dddf9ff7 8035640: JNU_CHECK_EXCEPTION should support c++ JNI syntax
pchelko
parents: 22938
diff changeset
   319
        }                                       \
1cf3dddf9ff7 8035640: JNU_CHECK_EXCEPTION should support c++ JNI syntax
pchelko
parents: 22938
diff changeset
   320
    } while (0)
1cf3dddf9ff7 8035640: JNU_CHECK_EXCEPTION should support c++ JNI syntax
pchelko
parents: 22938
diff changeset
   321
#else
22637
d4b45e70a981 8031737: CHECK_NULL and CHECK_EXCEPTION macros cleanup
rriggs
parents: 22258
diff changeset
   322
#define JNU_CHECK_EXCEPTION(env)                \
d4b45e70a981 8031737: CHECK_NULL and CHECK_EXCEPTION macros cleanup
rriggs
parents: 22258
diff changeset
   323
    do {                                        \
d4b45e70a981 8031737: CHECK_NULL and CHECK_EXCEPTION macros cleanup
rriggs
parents: 22258
diff changeset
   324
        if ((*env)->ExceptionCheck(env)) {      \
d4b45e70a981 8031737: CHECK_NULL and CHECK_EXCEPTION macros cleanup
rriggs
parents: 22258
diff changeset
   325
            return;                             \
d4b45e70a981 8031737: CHECK_NULL and CHECK_EXCEPTION macros cleanup
rriggs
parents: 22258
diff changeset
   326
        }                                       \
d4b45e70a981 8031737: CHECK_NULL and CHECK_EXCEPTION macros cleanup
rriggs
parents: 22258
diff changeset
   327
    } while (0)                                 \
d4b45e70a981 8031737: CHECK_NULL and CHECK_EXCEPTION macros cleanup
rriggs
parents: 22258
diff changeset
   328
d4b45e70a981 8031737: CHECK_NULL and CHECK_EXCEPTION macros cleanup
rriggs
parents: 22258
diff changeset
   329
#define JNU_CHECK_EXCEPTION_RETURN(env, y)      \
d4b45e70a981 8031737: CHECK_NULL and CHECK_EXCEPTION macros cleanup
rriggs
parents: 22258
diff changeset
   330
    do {                                        \
d4b45e70a981 8031737: CHECK_NULL and CHECK_EXCEPTION macros cleanup
rriggs
parents: 22258
diff changeset
   331
        if ((*env)->ExceptionCheck(env)) {      \
d4b45e70a981 8031737: CHECK_NULL and CHECK_EXCEPTION macros cleanup
rriggs
parents: 22258
diff changeset
   332
            return (y);                         \
d4b45e70a981 8031737: CHECK_NULL and CHECK_EXCEPTION macros cleanup
rriggs
parents: 22258
diff changeset
   333
        }                                       \
d4b45e70a981 8031737: CHECK_NULL and CHECK_EXCEPTION macros cleanup
rriggs
parents: 22258
diff changeset
   334
    } while (0)
23013
1cf3dddf9ff7 8035640: JNU_CHECK_EXCEPTION should support c++ JNI syntax
pchelko
parents: 22938
diff changeset
   335
#endif /* __cplusplus */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
/************************************************************************
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
 * Debugging utilities
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
JNU_PrintString(JNIEnv *env, char *hdr, jstring string);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
JNU_PrintClass(JNIEnv *env, char *hdr, jobject object);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
JNIEXPORT jstring JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
JNU_ToString(JNIEnv *env, jobject object);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
 * Package shorthand for use by native libraries
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
#define JNU_JAVAPKG         "java/lang/"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
#define JNU_JAVAIOPKG       "java/io/"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
#define JNU_JAVANETPKG      "java/net/"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
 * Check if the current thread is attached to the VM, and returns
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
 * the JNIEnv of the specified version if the thread is attached.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
 * If the current thread is not attached, this function returns 0.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
 * If the current thread is attached, this function returns the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
 * JNI environment, or returns (void *)JNI_ERR if the specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
 * version is not supported.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
JNIEXPORT void * JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
JNU_GetEnv(JavaVM *vm, jint version);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
 * Warning free access to pointers stored in Java long fields.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
#define JNU_GetLongFieldAsPtr(env,obj,id) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
    (jlong_to_ptr((*(env))->GetLongField((env),(obj),(id))))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
#define JNU_SetLongFieldFromPtr(env,obj,id,val) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
    (*(env))->SetLongField((env),(obj),(id),ptr_to_jlong(val))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
3111
fefdeafb7ab9 6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents: 2
diff changeset
   377
/*
fefdeafb7ab9 6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents: 2
diff changeset
   378
 * Internal use only.
fefdeafb7ab9 6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents: 2
diff changeset
   379
 */
fefdeafb7ab9 6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents: 2
diff changeset
   380
enum {
fefdeafb7ab9 6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents: 2
diff changeset
   381
    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
   382
    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
   383
    FAST_8859_1,                /* ISO-8859-1 */
fefdeafb7ab9 6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents: 2
diff changeset
   384
    FAST_CP1252,                /* MS-DOS Cp1252 */
45572
07f412070bd9 8181147: JNI_GetStringPlatformChars should have a fast path for UTF-8
redestad
parents: 39318
diff changeset
   385
    FAST_646_US,                /* US-ASCII : ISO646-US */
07f412070bd9 8181147: JNI_GetStringPlatformChars should have a fast path for UTF-8
redestad
parents: 39318
diff changeset
   386
    FAST_UTF_8
3111
fefdeafb7ab9 6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents: 2
diff changeset
   387
};
fefdeafb7ab9 6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents: 2
diff changeset
   388
fefdeafb7ab9 6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents: 2
diff changeset
   389
int getFastEncoding();
fefdeafb7ab9 6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents: 2
diff changeset
   390
49557
7b00ac6c11ab 8201246: Export native function to set platform encoding
rriggs
parents: 49440
diff changeset
   391
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
   392
16479
d845c18d13f2 8005716: Enhance JNI specification to allow support of static JNI libraries in Embedded JREs
alanb
parents: 5506
diff changeset
   393
void* getProcessHandle();
d845c18d13f2 8005716: Enhance JNI specification to allow support of static JNI libraries in Embedded JREs
alanb
parents: 5506
diff changeset
   394
d845c18d13f2 8005716: Enhance JNI specification to allow support of static JNI libraries in Embedded JREs
alanb
parents: 5506
diff changeset
   395
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
   396
                          char *jniEntryName);
3111
fefdeafb7ab9 6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents: 2
diff changeset
   397
49440
396ea30afbd5 8200178: Remove mapfiles for JDK native libraries
ihse
parents: 49121
diff changeset
   398
JNIEXPORT size_t JNICALL
396ea30afbd5 8200178: Remove mapfiles for JDK native libraries
ihse
parents: 49121
diff changeset
   399
getLastErrorString(char *buf, size_t len);
396ea30afbd5 8200178: Remove mapfiles for JDK native libraries
ihse
parents: 49121
diff changeset
   400
396ea30afbd5 8200178: Remove mapfiles for JDK native libraries
ihse
parents: 49121
diff changeset
   401
JNIEXPORT int JNICALL
396ea30afbd5 8200178: Remove mapfiles for JDK native libraries
ihse
parents: 49121
diff changeset
   402
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
   403
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   404
#ifdef STATIC_BUILD
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   405
/* 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
   406
 * JNI library Load/Unload functions
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
 * 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
   409
 * 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
   410
 *
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   411
 * 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
   412
 */
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   413
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   414
/* 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
   415
 * the LIBRARY_NAME
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
 * 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
   418
 */
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   419
#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
   420
#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
   421
#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
   422
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   423
#define DEF_JNI_OnLoad \
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   424
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
   425
{ \
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   426
  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
   427
  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
   428
  return JNI_VERSION_1_8; \
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
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
   431
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   432
#define DEF_STATIC_JNI_OnLoad \
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   433
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
   434
    return JNI_VERSION_1_8; \
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   435
}
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
#define DEF_JNI_OnUnload \
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   438
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
   439
{ \
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   440
  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
   441
  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
   442
} \
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   443
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
   444
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   445
#define DEF_STATIC_JNI_OnUnload \
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   446
ADD_LIB_NAME(JNI_OnUnload_)
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   447
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   448
#else
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   449
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   450
#define DEF_JNI_OnLoad JNI_OnLoad
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   451
#define DEF_STATIC_JNI_OnLoad
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   452
#define DEF_JNI_OnUnload JNI_OnUnload
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   453
#define DEF_STATIC_JNI_OnUnload
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   454
#endif
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   455
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   456
#ifdef STATIC_BUILD
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   457
/* 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
   458
 * Agent library Load/Attach/Unload functions
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   459
 *
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   460
 * 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
   461
 *     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
   462
 * 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
   463
 *     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
   464
 *
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   465
 * 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
   466
 */
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   467
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   468
#define DEF_Agent_OnLoad \
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   469
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
   470
{ \
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   471
  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
   472
  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
   473
} \
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   474
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
   475
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   476
#define DEF_STATIC_Agent_OnLoad \
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   477
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
   478
    return JNI_FALSE; \
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   479
}
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   480
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   481
#define DEF_Agent_OnAttach \
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   482
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
   483
{ \
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   484
  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
   485
  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
   486
} \
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   487
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
   488
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   489
#define DEF_STATIC_Agent_OnAttach \
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   490
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
   491
    return JNI_FALSE; \
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   492
}
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   493
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   494
#define DEF_Agent_OnUnload \
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   495
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
   496
{ \
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   497
  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
   498
  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
   499
} \
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   500
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
   501
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   502
#define DEF_STATIC_Agent_OnUnload \
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   503
ADD_LIB_NAME(Agent_OnUnload_)
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   504
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   505
#else
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   506
#define DEF_Agent_OnLoad Agent_OnLoad
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   507
#define DEF_Agent_OnAttach Agent_OnAttach
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   508
#define DEF_Agent_OnUnload Agent_OnUnload
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   509
#define DEF_STATIC_Agent_OnLoad
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   510
#define DEF_STATIC_Agent_OnAttach
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   511
#define DEF_STATIC_Agent_OnUnload
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   512
#endif
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 32846
diff changeset
   513
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
#ifdef __cplusplus
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
} /* extern "C" */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
#endif /* __cplusplus */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
#endif /* JNI_UTIL_H */