annotate src/java.base/share/native/libjava/jni_util.h @ 49564:7b00ac6c11ab

8201246: Export native function to set platform encoding Reviewed-by: rriggs Contributed-by: andrew_m_leonard@uk.ibm.com
author rriggs
date Tue, 10 Apr 2018 10:49:17 -0400
parents 396ea30afbd5
children d6b131d2bc8b
rev   line source
duke@2 1 /*
ihse@49445 2 * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
duke@2 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@2 4 *
duke@2 5 * This code is free software; you can redistribute it and/or modify it
duke@2 6 * under the terms of the GNU General Public License version 2 only, as
ohair@5506 7 * published by the Free Software Foundation. Oracle designates this
duke@2 8 * particular file as subject to the "Classpath" exception as provided
ohair@5506 9 * by Oracle in the LICENSE file that accompanied this code.
duke@2 10 *
duke@2 11 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@2 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@2 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@2 14 * version 2 for more details (a copy is included in the LICENSE file that
duke@2 15 * accompanied this code).
duke@2 16 *
duke@2 17 * You should have received a copy of the GNU General Public License version
duke@2 18 * 2 along with this work; if not, write to the Free Software Foundation,
duke@2 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@2 20 *
ohair@5506 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
ohair@5506 22 * or visit www.oracle.com if you need additional information or have any
ohair@5506 23 * questions.
duke@2 24 */
duke@2 25
duke@2 26 #ifndef JNI_UTIL_H
duke@2 27 #define JNI_UTIL_H
duke@2 28
duke@2 29 #include "jni.h"
duke@2 30 #include "jlong.h"
duke@2 31
duke@2 32 #ifdef __cplusplus
duke@2 33 extern "C" {
duke@2 34 #endif
duke@2 35
duke@2 36 /*
duke@2 37 * This file contains utility functions that can be implemented in pure JNI.
duke@2 38 *
duke@2 39 * Caution: Callers of functions declared in this file should be
duke@2 40 * particularly aware of the fact that these functions are convenience
duke@2 41 * functions, and as such are often compound operations, each one of
duke@2 42 * which may throw an exception. Therefore, the functions this file
malenkov@21278 43 * will often return silently if an exception has occurred, and callers
duke@2 44 * must check for exception themselves.
duke@2 45 */
duke@2 46
duke@2 47 /* Throw a Java exception by name. Similar to SignalError. */
duke@2 48 JNIEXPORT void JNICALL
duke@2 49 JNU_ThrowByName(JNIEnv *env, const char *name, const char *msg);
duke@2 50
duke@2 51 /* Throw common exceptions */
duke@2 52 JNIEXPORT void JNICALL
duke@2 53 JNU_ThrowNullPointerException(JNIEnv *env, const char *msg);
duke@2 54
duke@2 55 JNIEXPORT void JNICALL
duke@2 56 JNU_ThrowArrayIndexOutOfBoundsException(JNIEnv *env, const char *msg);
duke@2 57
duke@2 58 JNIEXPORT void JNICALL
duke@2 59 JNU_ThrowOutOfMemoryError(JNIEnv *env, const char *msg);
duke@2 60
duke@2 61 JNIEXPORT void JNICALL
duke@2 62 JNU_ThrowIllegalArgumentException(JNIEnv *env, const char *msg);
duke@2 63
duke@2 64 JNIEXPORT void JNICALL
duke@2 65 JNU_ThrowIllegalAccessError(JNIEnv *env, const char *msg);
duke@2 66
duke@2 67 JNIEXPORT void JNICALL
duke@2 68 JNU_ThrowIllegalAccessException(JNIEnv *env, const char *msg);
duke@2 69
duke@2 70 JNIEXPORT void JNICALL
duke@2 71 JNU_ThrowInternalError(JNIEnv *env, const char *msg);
duke@2 72
duke@2 73 JNIEXPORT void JNICALL
duke@2 74 JNU_ThrowIOException(JNIEnv *env, const char *msg);
duke@2 75
duke@2 76 JNIEXPORT void JNICALL
duke@2 77 JNU_ThrowNoSuchFieldException(JNIEnv *env, const char *msg);
duke@2 78
duke@2 79 JNIEXPORT void JNICALL
duke@2 80 JNU_ThrowNoSuchMethodException(JNIEnv *env, const char *msg);
duke@2 81
duke@2 82 JNIEXPORT void JNICALL
duke@2 83 JNU_ThrowClassNotFoundException(JNIEnv *env, const char *msg);
duke@2 84
duke@2 85 JNIEXPORT void JNICALL
duke@2 86 JNU_ThrowNumberFormatException(JNIEnv *env, const char *msg);
duke@2 87
duke@2 88 JNIEXPORT void JNICALL
duke@2 89 JNU_ThrowNoSuchFieldError(JNIEnv *env, const char *msg);
duke@2 90
duke@2 91 JNIEXPORT void JNICALL
duke@2 92 JNU_ThrowNoSuchMethodError(JNIEnv *env, const char *msg);
duke@2 93
duke@2 94 JNIEXPORT void JNICALL
duke@2 95 JNU_ThrowStringIndexOutOfBoundsException(JNIEnv *env, const char *msg);
duke@2 96
duke@2 97 JNIEXPORT void JNICALL
duke@2 98 JNU_ThrowInstantiationException(JNIEnv *env, const char *msg);
duke@2 99
duke@2 100 /* Throw an exception by name, using the string returned by
clanger@39318 101 * getLastErrorString for the detail string. If the last-error
duke@2 102 * string is NULL, use the given default detail string.
duke@2 103 */
duke@2 104 JNIEXPORT void JNICALL
duke@2 105 JNU_ThrowByNameWithLastError(JNIEnv *env, const char *name,
clanger@39318 106 const char *defaultDetail);
clanger@39318 107
clanger@39318 108 /* Throw an exception by name, using a given message and the string
clanger@39318 109 * returned by getLastErrorString to construct the detail string.
clanger@39318 110 */
clanger@39318 111 JNIEXPORT void JNICALL
clanger@39318 112 JNU_ThrowByNameWithMessageAndLastError
clanger@39318 113 (JNIEnv *env, const char *name, const char *message);
duke@2 114
duke@2 115 /* Throw an IOException, using the last-error string for the detail
clanger@39318 116 * string. If the last-error string is NULL, use the given default
duke@2 117 * detail string.
duke@2 118 */
duke@2 119 JNIEXPORT void JNICALL
duke@2 120 JNU_ThrowIOExceptionWithLastError(JNIEnv *env, const char *defaultDetail);
duke@2 121
duke@2 122 /* Convert between Java strings and i18n C strings */
duke@2 123 JNIEXPORT jstring
duke@2 124 NewStringPlatform(JNIEnv *env, const char *str);
duke@2 125
duke@2 126 JNIEXPORT const char *
duke@2 127 GetStringPlatformChars(JNIEnv *env, jstring jstr, jboolean *isCopy);
duke@2 128
duke@2 129 JNIEXPORT jstring JNICALL
duke@2 130 JNU_NewStringPlatform(JNIEnv *env, const char *str);
duke@2 131
duke@2 132 JNIEXPORT const char * JNICALL
duke@2 133 JNU_GetStringPlatformChars(JNIEnv *env, jstring jstr, jboolean *isCopy);
duke@2 134
duke@2 135 JNIEXPORT void JNICALL
duke@2 136 JNU_ReleaseStringPlatformChars(JNIEnv *env, jstring jstr, const char *str);
duke@2 137
duke@2 138 /* Class constants */
duke@2 139 JNIEXPORT jclass JNICALL
duke@2 140 JNU_ClassString(JNIEnv *env);
duke@2 141
duke@2 142 JNIEXPORT jclass JNICALL
duke@2 143 JNU_ClassClass(JNIEnv *env);
duke@2 144
duke@2 145 JNIEXPORT jclass JNICALL
duke@2 146 JNU_ClassObject(JNIEnv *env);
duke@2 147
duke@2 148 JNIEXPORT jclass JNICALL
duke@2 149 JNU_ClassThrowable(JNIEnv *env);
duke@2 150
duke@2 151 /* Copy count number of arguments from src to dst. Array bounds
duke@2 152 * and ArrayStoreException are checked.
duke@2 153 */
duke@2 154 JNIEXPORT jint JNICALL
duke@2 155 JNU_CopyObjectArray(JNIEnv *env, jobjectArray dst, jobjectArray src,
duke@2 156 jint count);
duke@2 157
duke@2 158 /* Invoke a object-returning static method, based on class name,
duke@2 159 * method name, and signature string.
duke@2 160 *
duke@2 161 * The caller should check for exceptions by setting hasException
duke@2 162 * argument. If the caller is not interested in whether an exception
duke@2 163 * has occurred, pass in NULL.
duke@2 164 */
duke@2 165 JNIEXPORT jvalue JNICALL
duke@2 166 JNU_CallStaticMethodByName(JNIEnv *env,
duke@2 167 jboolean *hasException,
duke@2 168 const char *class_name,
duke@2 169 const char *name,
duke@2 170 const char *signature,
duke@2 171 ...);
duke@2 172
duke@2 173 /* Invoke an instance method by name.
duke@2 174 */
duke@2 175 JNIEXPORT jvalue JNICALL
duke@2 176 JNU_CallMethodByName(JNIEnv *env,
duke@2 177 jboolean *hasException,
duke@2 178 jobject obj,
duke@2 179 const char *name,
duke@2 180 const char *signature,
duke@2 181 ...);
duke@2 182
duke@2 183 JNIEXPORT jvalue JNICALL
duke@2 184 JNU_CallMethodByNameV(JNIEnv *env,
duke@2 185 jboolean *hasException,
duke@2 186 jobject obj,
duke@2 187 const char *name,
duke@2 188 const char *signature,
duke@2 189 va_list args);
duke@2 190
duke@2 191 /* Construct a new object of class, specifying the class by name,
duke@2 192 * and specififying which constructor to run and what arguments to
duke@2 193 * pass to it.
duke@2 194 *
duke@2 195 * The method will return an initialized instance if successful.
malenkov@21278 196 * It will return NULL if an error has occurred (for example if
duke@2 197 * it ran out of memory) and the appropriate Java exception will
duke@2 198 * have been thrown.
duke@2 199 */
duke@2 200 JNIEXPORT jobject JNICALL
duke@2 201 JNU_NewObjectByName(JNIEnv *env, const char *class_name,
duke@2 202 const char *constructor_sig, ...);
duke@2 203
duke@2 204 /* returns:
duke@2 205 * 0: object is not an instance of the class named by classname.
duke@2 206 * 1: object is an instance of the class named by classname.
duke@2 207 * -1: the class named by classname cannot be found. An exception
duke@2 208 * has been thrown.
duke@2 209 */
duke@2 210 JNIEXPORT jint JNICALL
duke@2 211 JNU_IsInstanceOfByName(JNIEnv *env, jobject object, char *classname);
duke@2 212
duke@2 213
duke@2 214 /* Get or set class and instance fields.
duke@2 215 * Note that set functions take a variable number of arguments,
duke@2 216 * but only one argument of the appropriate type can be passed.
duke@2 217 * For example, to set an integer field i to 100:
duke@2 218 *
duke@2 219 * JNU_SetFieldByName(env, &exc, obj, "i", "I", 100);
duke@2 220 *
duke@2 221 * To set a float field f to 12.3:
duke@2 222 *
duke@2 223 * JNU_SetFieldByName(env, &exc, obj, "f", "F", 12.3);
duke@2 224 *
duke@2 225 * The caller should check for exceptions by setting hasException
duke@2 226 * argument. If the caller is not interested in whether an exception
duke@2 227 * has occurred, pass in NULL.
duke@2 228 */
duke@2 229 JNIEXPORT jvalue JNICALL
duke@2 230 JNU_GetFieldByName(JNIEnv *env,
duke@2 231 jboolean *hasException,
duke@2 232 jobject obj,
duke@2 233 const char *name,
duke@2 234 const char *sig);
duke@2 235 JNIEXPORT void JNICALL
duke@2 236 JNU_SetFieldByName(JNIEnv *env,
duke@2 237 jboolean *hasException,
duke@2 238 jobject obj,
duke@2 239 const char *name,
duke@2 240 const char *sig,
duke@2 241 ...);
duke@2 242
duke@2 243 JNIEXPORT jvalue JNICALL
duke@2 244 JNU_GetStaticFieldByName(JNIEnv *env,
duke@2 245 jboolean *hasException,
duke@2 246 const char *classname,
duke@2 247 const char *name,
duke@2 248 const char *sig);
duke@2 249 JNIEXPORT void JNICALL
duke@2 250 JNU_SetStaticFieldByName(JNIEnv *env,
duke@2 251 jboolean *hasException,
duke@2 252 const char *classname,
duke@2 253 const char *name,
duke@2 254 const char *sig,
duke@2 255 ...);
duke@2 256
duke@2 257
duke@2 258 /*
duke@2 259 * Calls the .equals method.
duke@2 260 */
duke@2 261 JNIEXPORT jboolean JNICALL
duke@2 262 JNU_Equals(JNIEnv *env, jobject object1, jobject object2);
duke@2 263
duke@2 264
duke@2 265 /************************************************************************
duke@2 266 * Thread calls
duke@2 267 *
duke@2 268 * Convenience thread-related calls on the java.lang.Object class.
duke@2 269 */
duke@2 270
duke@2 271 JNIEXPORT void JNICALL
duke@2 272 JNU_MonitorWait(JNIEnv *env, jobject object, jlong timeout);
duke@2 273
duke@2 274 JNIEXPORT void JNICALL
duke@2 275 JNU_Notify(JNIEnv *env, jobject object);
duke@2 276
duke@2 277 JNIEXPORT void JNICALL
duke@2 278 JNU_NotifyAll(JNIEnv *env, jobject object);
duke@2 279
duke@2 280
duke@2 281 /************************************************************************
duke@2 282 * Miscellaneous utilities used by the class libraries
duke@2 283 */
duke@2 284
duke@2 285 #define IS_NULL(obj) ((obj) == NULL)
duke@2 286 #define JNU_IsNull(env,obj) ((obj) == NULL)
duke@2 287
rriggs@22258 288 /************************************************************************
rriggs@22637 289 * Miscellaneous utilities used by the class libraries to return from
rriggs@22637 290 * a function if a value is NULL or an exception is pending.
rriggs@22258 291 */
rriggs@22258 292
rriggs@22637 293 #define CHECK_NULL(x) \
rriggs@22637 294 do { \
rriggs@22637 295 if ((x) == NULL) { \
rriggs@22637 296 return; \
rriggs@22637 297 } \
rriggs@22637 298 } while (0) \
rriggs@22258 299
rriggs@22637 300 #define CHECK_NULL_RETURN(x, y) \
rriggs@22637 301 do { \
rriggs@22637 302 if ((x) == NULL) { \
rriggs@22637 303 return (y); \
rriggs@22637 304 } \
rriggs@22637 305 } while (0) \
rriggs@22637 306
pchelko@23013 307 #ifdef __cplusplus
pchelko@23013 308 #define JNU_CHECK_EXCEPTION(env) \
pchelko@23013 309 do { \
pchelko@23013 310 if ((env)->ExceptionCheck()) { \
pchelko@23013 311 return; \
pchelko@23013 312 } \
pchelko@23013 313 } while (0) \
pchelko@23013 314
pchelko@23013 315 #define JNU_CHECK_EXCEPTION_RETURN(env, y) \
pchelko@23013 316 do { \
pchelko@23013 317 if ((env)->ExceptionCheck()) { \
pchelko@23013 318 return (y); \
pchelko@23013 319 } \
pchelko@23013 320 } while (0)
pchelko@23013 321 #else
rriggs@22637 322 #define JNU_CHECK_EXCEPTION(env) \
rriggs@22637 323 do { \
rriggs@22637 324 if ((*env)->ExceptionCheck(env)) { \
rriggs@22637 325 return; \
rriggs@22637 326 } \
rriggs@22637 327 } while (0) \
rriggs@22637 328
rriggs@22637 329 #define JNU_CHECK_EXCEPTION_RETURN(env, y) \
rriggs@22637 330 do { \
rriggs@22637 331 if ((*env)->ExceptionCheck(env)) { \
rriggs@22637 332 return (y); \
rriggs@22637 333 } \
rriggs@22637 334 } while (0)
pchelko@23013 335 #endif /* __cplusplus */
duke@2 336 /************************************************************************
duke@2 337 * Debugging utilities
duke@2 338 */
duke@2 339
duke@2 340 JNIEXPORT void JNICALL
duke@2 341 JNU_PrintString(JNIEnv *env, char *hdr, jstring string);
duke@2 342
duke@2 343 JNIEXPORT void JNICALL
duke@2 344 JNU_PrintClass(JNIEnv *env, char *hdr, jobject object);
duke@2 345
duke@2 346 JNIEXPORT jstring JNICALL
duke@2 347 JNU_ToString(JNIEnv *env, jobject object);
duke@2 348
duke@2 349 /*
duke@2 350 * Package shorthand for use by native libraries
duke@2 351 */
duke@2 352 #define JNU_JAVAPKG "java/lang/"
duke@2 353 #define JNU_JAVAIOPKG "java/io/"
duke@2 354 #define JNU_JAVANETPKG "java/net/"
duke@2 355
duke@2 356 /*
duke@2 357 * Check if the current thread is attached to the VM, and returns
duke@2 358 * the JNIEnv of the specified version if the thread is attached.
duke@2 359 *
duke@2 360 * If the current thread is not attached, this function returns 0.
duke@2 361 *
duke@2 362 * If the current thread is attached, this function returns the
duke@2 363 * JNI environment, or returns (void *)JNI_ERR if the specified
duke@2 364 * version is not supported.
duke@2 365 */
duke@2 366 JNIEXPORT void * JNICALL
duke@2 367 JNU_GetEnv(JavaVM *vm, jint version);
duke@2 368
duke@2 369 /*
duke@2 370 * Warning free access to pointers stored in Java long fields.
duke@2 371 */
duke@2 372 #define JNU_GetLongFieldAsPtr(env,obj,id) \
duke@2 373 (jlong_to_ptr((*(env))->GetLongField((env),(obj),(id))))
duke@2 374 #define JNU_SetLongFieldFromPtr(env,obj,id,val) \
duke@2 375 (*(env))->SetLongField((env),(obj),(id),ptr_to_jlong(val))
duke@2 376
herrick@3111 377 /*
herrick@3111 378 * Internal use only.
herrick@3111 379 */
herrick@3111 380 enum {
herrick@3111 381 NO_ENCODING_YET = 0, /* "sun.jnu.encoding" not yet set */
herrick@3111 382 NO_FAST_ENCODING, /* Platform encoding is not fast */
herrick@3111 383 FAST_8859_1, /* ISO-8859-1 */
herrick@3111 384 FAST_CP1252, /* MS-DOS Cp1252 */
redestad@45572 385 FAST_646_US, /* US-ASCII : ISO646-US */
redestad@45572 386 FAST_UTF_8
herrick@3111 387 };
herrick@3111 388
herrick@3111 389 int getFastEncoding();
herrick@3111 390
rriggs@49564 391 JNIEXPORT void InitializeEncoding(JNIEnv *env, const char *name);
herrick@3111 392
alanb@16479 393 void* getProcessHandle();
alanb@16479 394
alanb@16479 395 void buildJniFunctionName(const char *sym, const char *cname,
alanb@16479 396 char *jniEntryName);
herrick@3111 397
ihse@49445 398 JNIEXPORT size_t JNICALL
ihse@49445 399 getLastErrorString(char *buf, size_t len);
ihse@49445 400
ihse@49445 401 JNIEXPORT int JNICALL
ihse@49445 402 getErrorString(int err, char *buf, size_t len);
bobv@33653 403
bobv@33653 404 #ifdef STATIC_BUILD
bobv@33653 405 /* Macros for handling declaration of static/dynamic
bobv@33653 406 * JNI library Load/Unload functions
bobv@33653 407 *
bobv@33653 408 * Use DEF_JNI_On{Un}Load when you want a static and non-static entry points.
bobv@33653 409 * Use DEF_STATIC_JNI_On{Un}Load when you only want a static one.
bobv@33653 410 *
bobv@33653 411 * LIBRARY_NAME must be set to the name of the library
bobv@33653 412 */
bobv@33653 413
bobv@33653 414 /* These three macros are needed to get proper concatenation of
bobv@33653 415 * the LIBRARY_NAME
bobv@33653 416 *
bobv@33653 417 * NOTE: LIBRARY_NAME must be set for static builds.
bobv@33653 418 */
bobv@33653 419 #define ADD_LIB_NAME3(name, lib) name ## lib
bobv@33653 420 #define ADD_LIB_NAME2(name, lib) ADD_LIB_NAME3(name, lib)
bobv@33653 421 #define ADD_LIB_NAME(entry) ADD_LIB_NAME2(entry, LIBRARY_NAME)
bobv@33653 422
bobv@33653 423 #define DEF_JNI_OnLoad \
bobv@33653 424 ADD_LIB_NAME(JNI_OnLoad_)(JavaVM *vm, void *reserved) \
bobv@33653 425 { \
bobv@33653 426 jint JNICALL ADD_LIB_NAME(JNI_OnLoad_dynamic_)(JavaVM *vm, void *reserved); \
bobv@33653 427 ADD_LIB_NAME(JNI_OnLoad_dynamic_)(vm, reserved); \
bobv@33653 428 return JNI_VERSION_1_8; \
bobv@33653 429 } \
bobv@33653 430 jint JNICALL ADD_LIB_NAME(JNI_OnLoad_dynamic_)
bobv@33653 431
bobv@33653 432 #define DEF_STATIC_JNI_OnLoad \
bobv@33653 433 JNIEXPORT jint JNICALL ADD_LIB_NAME(JNI_OnLoad_)(JavaVM *vm, void *reserved) { \
bobv@33653 434 return JNI_VERSION_1_8; \
bobv@33653 435 }
bobv@33653 436
bobv@33653 437 #define DEF_JNI_OnUnload \
bobv@33653 438 ADD_LIB_NAME(JNI_OnUnload_)(JavaVM *vm, void *reserved) \
bobv@33653 439 { \
bobv@33653 440 void JNICALL ADD_LIB_NAME(JNI_OnUnload_dynamic_)(JavaVM *vm, void *reserved); \
bobv@33653 441 ADD_LIB_NAME(JNI_OnUnload_dynamic_)(vm, reserved); \
bobv@33653 442 } \
bobv@33653 443 void JNICALL ADD_LIB_NAME(JNI_OnUnload_dynamic_)
bobv@33653 444
bobv@33653 445 #define DEF_STATIC_JNI_OnUnload \
bobv@33653 446 ADD_LIB_NAME(JNI_OnUnload_)
bobv@33653 447
bobv@33653 448 #else
bobv@33653 449
bobv@33653 450 #define DEF_JNI_OnLoad JNI_OnLoad
bobv@33653 451 #define DEF_STATIC_JNI_OnLoad
bobv@33653 452 #define DEF_JNI_OnUnload JNI_OnUnload
bobv@33653 453 #define DEF_STATIC_JNI_OnUnload
bobv@33653 454 #endif
bobv@33653 455
bobv@33653 456 #ifdef STATIC_BUILD
bobv@33653 457 /* Macros for handling declaration of static/dynamic
bobv@33653 458 * Agent library Load/Attach/Unload functions
bobv@33653 459 *
bobv@33653 460 * Use DEF_Agent_OnLoad, DEF_Agent_OnAttach or DEF_Agent_OnUnload
bobv@33653 461 * when you want both static and non-static entry points.
bobv@33653 462 * Use DEF_STATIC_Agent_OnLoad, DEF_STATIC_Agent_OnAttach or
bobv@33653 463 * DEF_STATIC_Agent_OnUnload when you only want a static one.
bobv@33653 464 *
bobv@33653 465 * LIBRARY_NAME must be set to the name of the library for static builds.
bobv@33653 466 */
bobv@33653 467
bobv@33653 468 #define DEF_Agent_OnLoad \
bobv@33653 469 ADD_LIB_NAME(Agent_OnLoad_)(JavaVM *vm, char *options, void *reserved) \
bobv@33653 470 { \
bobv@33653 471 jint JNICALL ADD_LIB_NAME(Agent_OnLoad_dynamic_)(JavaVM *vm, char *options, void *reserved); \
bobv@33653 472 return ADD_LIB_NAME(Agent_OnLoad_dynamic_)(vm, options, reserved); \
bobv@33653 473 } \
bobv@33653 474 jint JNICALL ADD_LIB_NAME(Agent_OnLoad_dynamic_)
bobv@33653 475
bobv@33653 476 #define DEF_STATIC_Agent_OnLoad \
bobv@33653 477 JNIEXPORT jint JNICALL ADD_LIB_NAME(Agent_OnLoad_)(JavaVM *vm, char *options, void *reserved) { \
bobv@33653 478 return JNI_FALSE; \
bobv@33653 479 }
bobv@33653 480
bobv@33653 481 #define DEF_Agent_OnAttach \
bobv@33653 482 ADD_LIB_NAME(Agent_OnAttach_)(JavaVM *vm, char *options, void *reserved) \
bobv@33653 483 { \
bobv@33653 484 jint JNICALL ADD_LIB_NAME(Agent_OnAttach_dynamic_)(JavaVM *vm, char *options, void *reserved); \
bobv@33653 485 return ADD_LIB_NAME(Agent_OnAttach_dynamic_)(vm, options, reserved); \
bobv@33653 486 } \
bobv@33653 487 jint JNICALL ADD_LIB_NAME(Agent_OnAttach_dynamic_)
bobv@33653 488
bobv@33653 489 #define DEF_STATIC_Agent_OnAttach \
bobv@33653 490 JNIEXPORT jint JNICALL ADD_LIB_NAME(Agent_OnLoad_)(JavaVM *vm, char *options, void *reserved) { \
bobv@33653 491 return JNI_FALSE; \
bobv@33653 492 }
bobv@33653 493
bobv@33653 494 #define DEF_Agent_OnUnload \
bobv@33653 495 ADD_LIB_NAME(Agent_OnUnload_)(JavaVM *vm) \
bobv@33653 496 { \
bobv@33653 497 void JNICALL ADD_LIB_NAME(Agent_OnUnload_dynamic_)(JavaVM *vm); \
bobv@33653 498 ADD_LIB_NAME(Agent_OnUnload_dynamic_)(vm); \
bobv@33653 499 } \
bobv@33653 500 void JNICALL ADD_LIB_NAME(Agent_OnUnload_dynamic_)
bobv@33653 501
bobv@33653 502 #define DEF_STATIC_Agent_OnUnload \
bobv@33653 503 ADD_LIB_NAME(Agent_OnUnload_)
bobv@33653 504
bobv@33653 505 #else
bobv@33653 506 #define DEF_Agent_OnLoad Agent_OnLoad
bobv@33653 507 #define DEF_Agent_OnAttach Agent_OnAttach
bobv@33653 508 #define DEF_Agent_OnUnload Agent_OnUnload
bobv@33653 509 #define DEF_STATIC_Agent_OnLoad
bobv@33653 510 #define DEF_STATIC_Agent_OnAttach
bobv@33653 511 #define DEF_STATIC_Agent_OnUnload
bobv@33653 512 #endif
bobv@33653 513
duke@2 514 #ifdef __cplusplus
duke@2 515 } /* extern "C" */
duke@2 516 #endif /* __cplusplus */
duke@2 517
duke@2 518 #endif /* JNI_UTIL_H */