jdk/src/share/native/common/jni_util.h
author herrick
Fri, 12 Jun 2009 14:56:32 -0400
changeset 3111 fefdeafb7ab9
parent 2 90ce3da70b43
child 5506 202f599c92aa
permissions -rw-r--r--
6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7 6845973: Update JDK7 with deployment changes in 6u13, 6u14 4802695: Support 64-bit Java Plug-in and Java webstart on Windows/Linux on AMD64 6825019: DownloadManager should not be loaded and referenced for full JRE 6738770: REGRESSION:JSException throws when use LiveConnect javascript facility 6772884: plugin2 : java.lang.OutOfMemoryError or crash 6707535: Crossing domain hole affecting multiple sites/domains using plug-in 6728071: Non-verification of Update files may allow unintended updates 6704154: Code loaded from local filesystem should not get access to localhost 6727081: Web Start security restrictions bypass using special extension jnlp 6727079: Java Web Start Socket() restriction bypass 6727071: Cache location/user name information disclosure in SingleInstanceImpl. 6716217: AppletClassLoader adds permissions based on codebase regardless of CS 6694892: Java Webstart inclusion via system properties override [CVE-2008-2086] 6704074: localhost socket access due to cache location exposed 6703909: Java webstart arbitrary file creation using nativelib 6665315: browser crashes when deployment.properties has more slashes ( / ) 6660121: Encoding values in JNLP files can cause buffer overflow 6606110: URLConnection.setProxiedHost for resources that are loaded via proxy 6581221: SSV(VISTA): Redirection FAILS to work if user does a downgrade install 6609756: Buffer Overflow in Java ActiveX component 6608712: Bypassing the same origin policy in Java with crafted names 6534630: "gnumake clobber" doesn't 6849953: JDK7 - replacement of bufferoverflowU.lib on amd64 breaks build 6849029: Need some JDK7 merge clean-up after comments on the webrev 6847582: Build problem on JDK7 with isSecureProperty in merge 6827935: JDK 7 deployment merging - problem in Compiler-msvm.gmk 6823215: latest merge fixes from 6u12 -> JDK7 6816153: further mergers for JDK7 deployment integration 6807074: Fix Java Kernel and JQS in initial JDK7 builds Summary: Initial changeset for implementing 6uX Deployment Features into JDK7 Reviewed-by: dgu, billyh
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
     2
 * Copyright 1997-2004 Sun Microsystems, Inc.  All Rights Reserved.
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
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Sun designates this
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * by Sun in the LICENSE file that accompanied this code.
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
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 * CA 95054 USA or visit www.sun.com if you need additional information or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
 * have any questions.
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
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * will often return silently if an exception has occured, and callers
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
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
 * JVM_LastErrorString for the detail string.  If the last-error
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,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
                             const char *defaultMessage);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
/* Throw an IOException, using the last-error string for the detail
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
 * string.  If the last-error string is NULL, use the given default
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
 * detail string.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
JNU_ThrowIOExceptionWithLastError(JNIEnv *env, const char *defaultDetail);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
/* Convert between Java strings and i18n C strings */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
JNIEXPORT jstring
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
NewStringPlatform(JNIEnv *env, const char *str);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
JNIEXPORT const char *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
GetStringPlatformChars(JNIEnv *env, jstring jstr, jboolean *isCopy);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
JNIEXPORT jstring JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
JNU_NewStringPlatform(JNIEnv *env, const char *str);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
JNIEXPORT const char * JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
JNU_GetStringPlatformChars(JNIEnv *env, jstring jstr, jboolean *isCopy);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
JNU_ReleaseStringPlatformChars(JNIEnv *env, jstring jstr, const char *str);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
/* Class constants */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
JNIEXPORT jclass JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
JNU_ClassString(JNIEnv *env);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
JNIEXPORT jclass JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
JNU_ClassClass(JNIEnv *env);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
JNIEXPORT jclass JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
JNU_ClassObject(JNIEnv *env);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
JNIEXPORT jclass JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
JNU_ClassThrowable(JNIEnv *env);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
/* Copy count number of arguments from src to dst. Array bounds
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
 * and ArrayStoreException are checked.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
JNIEXPORT jint JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
JNU_CopyObjectArray(JNIEnv *env, jobjectArray dst, jobjectArray src,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
                    jint count);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
/* Invoke a object-returning static method, based on class name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
 * method name, and signature string.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
 * The caller should check for exceptions by setting hasException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
 * argument. If the caller is not interested in whether an exception
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
 * has occurred, pass in NULL.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
JNIEXPORT jvalue JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
JNU_CallStaticMethodByName(JNIEnv *env,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
                           jboolean *hasException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
                           const char *class_name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
                           const char *name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
                           const char *signature,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
                           ...);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
/* Invoke an instance method by name.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
JNIEXPORT jvalue JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
JNU_CallMethodByName(JNIEnv *env,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
                     jboolean *hasException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
                     jobject obj,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
                     const char *name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
                     const char *signature,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
                     ...);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
JNIEXPORT jvalue JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
JNU_CallMethodByNameV(JNIEnv *env,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
                      jboolean *hasException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
                      jobject obj,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
                      const char *name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
                      const char *signature,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
                      va_list args);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
/* Construct a new object of class, specifying the class by name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
 * and specififying which constructor to run and what arguments to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
 * pass to it.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
 * The method will return an initialized instance if successful.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
 * It will return NULL if an error has occured (for example if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
 * it ran out of memory) and the appropriate Java exception will
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
 * have been thrown.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
JNIEXPORT jobject JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
JNU_NewObjectByName(JNIEnv *env, const char *class_name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
                    const char *constructor_sig, ...);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
/* returns:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
 * 0: object is not an instance of the class named by classname.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
 * 1: object is an instance of the class named by classname.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
 * -1: the class named by classname cannot be found. An exception
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
 * has been thrown.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
JNIEXPORT jint JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
JNU_IsInstanceOfByName(JNIEnv *env, jobject object, char *classname);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
/* Get or set class and instance fields.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
 * Note that set functions take a variable number of arguments,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
 * but only one argument of the appropriate type can be passed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
 * For example, to set an integer field i to 100:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
 * JNU_SetFieldByName(env, &exc, obj, "i", "I", 100);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
 * To set a float field f to 12.3:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
 * JNU_SetFieldByName(env, &exc, obj, "f", "F", 12.3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
 * The caller should check for exceptions by setting hasException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
 * argument. If the caller is not interested in whether an exception
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
 * has occurred, pass in NULL.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
JNIEXPORT jvalue JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
JNU_GetFieldByName(JNIEnv *env,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
                   jboolean *hasException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
                   jobject obj,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
                   const char *name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
                   const char *sig);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
JNU_SetFieldByName(JNIEnv *env,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
                   jboolean *hasException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
                   jobject obj,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
                   const char *name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
                   const char *sig,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
                   ...);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
JNIEXPORT jvalue JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
JNU_GetStaticFieldByName(JNIEnv *env,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
                         jboolean *hasException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
                         const char *classname,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
                         const char *name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
                         const char *sig);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
JNU_SetStaticFieldByName(JNIEnv *env,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
                         jboolean *hasException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
                         const char *classname,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
                         const char *name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
                         const char *sig,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
                         ...);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
 * Calls the .equals method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
JNIEXPORT jboolean JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
JNU_Equals(JNIEnv *env, jobject object1, jobject object2);
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
 * Thread calls
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
 * Convenience thread-related calls on the java.lang.Object class.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
JNU_MonitorWait(JNIEnv *env, jobject object, jlong timeout);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
JNU_Notify(JNIEnv *env, jobject object);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
JNU_NotifyAll(JNIEnv *env, jobject object);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
/************************************************************************
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
 * Miscellaneous utilities used by the class libraries
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
#define IS_NULL(obj) ((obj) == NULL)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
#define JNU_IsNull(env,obj) ((obj) == NULL)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
/************************************************************************
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
 * Debugging utilities
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
JNU_PrintString(JNIEnv *env, char *hdr, jstring string);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
JNU_PrintClass(JNIEnv *env, char *hdr, jobject object);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
JNIEXPORT jstring JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
JNU_ToString(JNIEnv *env, jobject object);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
 * Package shorthand for use by native libraries
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
#define JNU_JAVAPKG         "java/lang/"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
#define JNU_JAVAIOPKG       "java/io/"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
#define JNU_JAVANETPKG      "java/net/"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
 * Check if the current thread is attached to the VM, and returns
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
 * the JNIEnv of the specified version if the thread is attached.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
 * If the current thread is not attached, this function returns 0.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
 * If the current thread is attached, this function returns the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
 * JNI environment, or returns (void *)JNI_ERR if the specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
 * version is not supported.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
JNIEXPORT void * JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
JNU_GetEnv(JavaVM *vm, jint version);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
 * Warning free access to pointers stored in Java long fields.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
#define JNU_GetLongFieldAsPtr(env,obj,id) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
    (jlong_to_ptr((*(env))->GetLongField((env),(obj),(id))))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
#define JNU_SetLongFieldFromPtr(env,obj,id,val) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
    (*(env))->SetLongField((env),(obj),(id),ptr_to_jlong(val))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
3111
fefdeafb7ab9 6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents: 2
diff changeset
   323
/*
fefdeafb7ab9 6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents: 2
diff changeset
   324
 * Internal use only.
fefdeafb7ab9 6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents: 2
diff changeset
   325
 */
fefdeafb7ab9 6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents: 2
diff changeset
   326
enum {
fefdeafb7ab9 6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents: 2
diff changeset
   327
    NO_ENCODING_YET = 0,        /* "sun.jnu.encoding" not yet set */
fefdeafb7ab9 6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents: 2
diff changeset
   328
    NO_FAST_ENCODING,           /* Platform encoding is not fast */
fefdeafb7ab9 6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents: 2
diff changeset
   329
    FAST_8859_1,                /* ISO-8859-1 */
fefdeafb7ab9 6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents: 2
diff changeset
   330
    FAST_CP1252,                /* MS-DOS Cp1252 */
fefdeafb7ab9 6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents: 2
diff changeset
   331
    FAST_646_US                 /* US-ASCII : ISO646-US */
fefdeafb7ab9 6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents: 2
diff changeset
   332
};
fefdeafb7ab9 6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents: 2
diff changeset
   333
fefdeafb7ab9 6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents: 2
diff changeset
   334
jstring nativeNewStringPlatform(JNIEnv *env, const char *str);
fefdeafb7ab9 6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents: 2
diff changeset
   335
fefdeafb7ab9 6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents: 2
diff changeset
   336
char* nativeGetStringPlatformChars(JNIEnv *env, jstring jstr, jboolean *isCopy);
fefdeafb7ab9 6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents: 2
diff changeset
   337
fefdeafb7ab9 6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents: 2
diff changeset
   338
int getFastEncoding();
fefdeafb7ab9 6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents: 2
diff changeset
   339
fefdeafb7ab9 6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents: 2
diff changeset
   340
void initializeEncoding();
fefdeafb7ab9 6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents: 2
diff changeset
   341
fefdeafb7ab9 6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents: 2
diff changeset
   342
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
#ifdef __cplusplus
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
} /* extern "C" */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
#endif /* __cplusplus */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
#endif /* JNI_UTIL_H */