00001 #ifndef _jlString_h_included_ 00002 #define _jlString_h_included_ 00003 00004 /*! 00005 * @file jlString.h 00006 * 00007 * @brief Public interface to native implementation of 00008 * @c @b java.lang.String 00009 * 00010 * Two parallel sets of definitions are used here, one for internal 00011 * implementation purposes, the other for the JNI interface. The first 00012 * uses internal data types (via @link #JLSTRING_LOCAL_DEFINED 00013 \#ifdef JLSTRING_LOCAL_DEFINED@endlink) where the second does not. 00014 * Instead, it uses @c @b <jni.h> data types. Those types @e must 00015 * match up for JNI to work, yet by keeping them 00016 * absolutely separate, application JNI code does @e not have 00017 * @b any dependencies on the core code of this JVM implementation. 00018 * 00019 * Even though there is only apparently @e one set of definitions, 00020 * the @c @b \#ifdef statement controls which set is used. 00021 * 00022 * This file must be included by JNI code along with the 00023 * @c @b java.lang.Class JNI header file. The following example 00024 * shows how to call one of the @e local native methods of this class 00025 * from the JNI environment. Notice that although this is not necessary 00026 * due to the local implementation shortcut defined in 00027 * @link jvm/src/native.c native.c@endlink, it is not only possible, 00028 * but sometimes quite desirable to do so. 00029 * 00030 * @verbatim 00031 #include <jni.h> 00032 #include <solaris/jni_md.h> ... or appropriate platform-specifics 00033 00034 #include "java_lang_String.h" ... JNI definitions 00035 #include "jlString.h" ... this file 00036 00037 JNIEXPORT jstring JNICALL 00038 Java_java_lang_String_intern(JNIEnv *env, jobject thisobj) 00039 { 00040 jstring s; 00041 00042 s = jlString_intern(thisobj); ... call native implementation 00043 00044 return(s); 00045 } 00046 @endverbatim 00047 * 00048 * @attention This local native method implementation is defined 00049 * in @link jvm/src/native.c native.c@endlink and 00050 * does @e not make use of the @b JNIENV pointer in 00051 * @e any manner. 00052 * 00053 * @attention Although @link #jvalue jvalue@endlink is indeed a part 00054 * of both this implementation and the standard JNI interface 00055 * through @c @b <jni.h> , it is @e not recommended to use 00056 * it if at all possible. Due to the fact that both 00057 * definitions involve unions, along with the slightly 00058 * differing contents between the two versions, it is almost 00059 * certain that there will be compilation compatibility 00060 * problems in the memory layouts from one platform to 00061 * another, and possibly between the layouts between them on 00062 * any given platform. Since @link #jvalue jvalue@endlink 00063 * is not specificaly a @e Java type, but instead a JNI 00064 * construction, this may not be a problem, but this 00065 * advisory is raised anyway in order to encourage reliable 00066 * implementation of JNI. 00067 * 00068 * 00069 * @section Control 00070 * 00071 * \$URL: https://svn.apache.org/path/name/jlString.h $ \$Id: jlString.h 0 09/28/2005 dlydick $ 00072 * 00073 * Copyright 2005 The Apache Software Foundation 00074 * or its licensors, as applicable. 00075 * 00076 * Licensed under the Apache License, Version 2.0 ("the License"); 00077 * you may not use this file except in compliance with the License. 00078 * You may obtain a copy of the License at 00079 * 00080 * http://www.apache.org/licenses/LICENSE-2.0 00081 * 00082 * Unless required by applicable law or agreed to in writing, 00083 * software distributed under the License is distributed on an 00084 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 00085 * either express or implied. 00086 * 00087 * See the License for the specific language governing permissions 00088 * and limitations under the License. 00089 * 00090 * @version \$LastChangedRevision: 0 $ 00091 * 00092 * @date \$LastChangedDate: 09/28/2005 $ 00093 * 00094 * @author \$LastChangedBy: dlydick $ 00095 * Original code contributed by Daniel Lydick on 09/28/2005. 00096 * 00097 * @section Reference 00098 * 00099 */ 00100 00101 /**********************************************************************/ 00102 #ifdef JLSTRING_LOCAL_DEFINED 00103 00104 ARCH_COPYRIGHT_APACHE(jlString, h, "$URL: https://svn.apache.org/path/name/jlString.h $ $Id: jlString.h 0 09/28/2005 dlydick $"); 00105 00106 /**********************************************************************/ 00107 #else /* JLSTRING_LOCAL_DEFINED */ 00108 00109 #include "jlObject.h" 00110 00111 /* There is currently nothing else needed here */ 00112 00113 #endif /* JLSTRING_LOCAL_DEFINED */ 00114 /**********************************************************************/ 00115 00116 /*! 00117 * @name Unified set of prototypes for functions 00118 * in @link jvm/src/jlString.c jlString.c@endlink 00119 * 00120 * @brief JNI table index and external reference to 00121 * each function that locally implements a JNI native method. 00122 * 00123 * The JVM native interface ordinal definition base for this class 00124 * is 30. An enumeration is used so the compiler can help the use 00125 * to not choose duplicate values. 00126 * 00127 */ 00128 00129 /*@{ */ /* Begin grouped definitions */ 00130 00131 typedef enum 00132 { 00133 00134 JLSTRING_NMO_INTERN = 30 /**< Ordinal for 00135 @link #jlString_intern() intern()@endlink */ 00136 00137 } jlString_nmo_enum; 00138 00139 /* 00140 * Add one function prototype below 00141 * for each local native method enumeration above: 00142 */ 00143 00144 /*! 00145 * @brief JNI hook to @link #jlString_intern() intern()@endlink 00146 */ 00147 extern jvm_object_hash jlString_intern(jvm_object_hash objhash); 00148 00149 /*@} */ /* End grouped definitions */ 00150 00151 00152 /**********************************************************************/ 00153 00154 /*! 00155 * @name Connection to local native method tables. 00156 * 00157 * @brief These manifest constant code fragments are designed to be 00158 * inserted directly into locations in 00159 * @link jvm/src/native.c native.c@endlink without any other 00160 * modification to that file except a @e single entry to actually 00161 * invoke the method. 00162 * 00163 */ 00164 /*@{*/ 00165 00166 /*! 00167 * @brief Complete list of local native method ordinals 00168 * for @c @b java.lang.String 00169 */ 00170 #define NATIVE_TABLE_JLSTRING \ 00171 case JLSTRING_NMO_INTERN: 00172 00173 /*! 00174 * @brief Table of local native methods and their descriptors 00175 * for @c @b java.lang.String 00176 */ 00177 #define NATIVE_TABLE_JLSTRING_ORDINALS \ 00178 { \ 00179 { JLSTRING_NMO_INTERN, "intern", "()Ljava/lang/String" }, \ 00180 \ 00181 /* Add other method entries here */ \ 00182 \ 00183 \ 00184 /* End of table marker */ \ 00185 { JVMCFG_JLOBJECT_NMO_NULL, \ 00186 CHEAT_AND_USE_NULL_TO_INITIALIZE, \ 00187 CHEAT_AND_USE_NULL_TO_INITIALIZE } \ 00188 } 00189 00190 #define NATIVE_TABLE_JLSTRING_JVOID /**< No @c @b (jvoid) methods */ 00191 00192 /*! 00193 * @brief @c @b (jobject) local native method ordinal table 00194 * for @c @b java.lang.String 00195 */ 00196 #define NATIVE_TABLE_JLSTRING_JOBJECT \ 00197 case JLSTRING_NMO_INTERN: 00198 00199 #define NATIVE_TABLE_JLSTRING_JINT /**< No @c @b (jint) methods */ 00200 #define NATIVE_TABLE_JLSTRING_JFLOAT /**< No @c @b (jfloat) methods */ 00201 #define NATIVE_TABLE_JLSTRING_JLONG /**< No @c @b (jlong) methods */ 00202 #define NATIVE_TABLE_JLSTRING_JDOUBLE /**< No @c @b (jdouble) methods*/ 00203 00204 /*@}*/ 00205 00206 #endif /* _jlString_h_included_ */ 00207 00208 00209 /* EOF */ 00210