00001 #ifndef _jlClass_h_included_ 00002 #define _jlClass_h_included_ 00003 00004 /*! 00005 * @file jlClass.h 00006 * 00007 * @brief Public interface to native implementation of 00008 * @c @b java.lang.Class 00009 * 00010 * Two parallel sets of definitions are used here, one for internal 00011 * implementation purposes, the other for JNI the interface. The first 00012 * uses internal data types (via @link #JLCLASS_LOCAL_DEFINED 00013 \#ifdef JLCLASS_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_Class.h" ... JNI definitions 00035 #include "jlClass.h" ... this file 00036 00037 JNIEXPORT jboolean JNICALL 00038 Java_java_lang_Class_isArray(JNIEnv *env, jobject thisobj) 00039 { 00040 jboolean b; 00041 00042 b = jlClass_isArray(thisobj); ... call native implementation 00043 00044 return(b); 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/jlClass.h $ \$Id: jlClass.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 JLCLASS_LOCAL_DEFINED 00103 00104 ARCH_COPYRIGHT_APACHE(jlClass, h, "$URL: https://svn.apache.org/path/name/jlClass.h $ $Id: jlClass.h 0 09/28/2005 dlydick $"); 00105 00106 /**********************************************************************/ 00107 #else /* JLCLASS_LOCAL_DEFINED */ 00108 00109 #include "jlObject.h" 00110 00111 /* There is currently nothing else needed here */ 00112 00113 #endif /* JLCLASS_LOCAL_DEFINED */ 00114 /**********************************************************************/ 00115 /*! 00116 * @name Unified set of prototypes for functions 00117 * in @link jvm/src/jlClass.c jlClass.c@endlink 00118 * 00119 * @brief JNI table index and external reference to 00120 * each function that locally implements a JNI native method. 00121 * 00122 * The JVM native interface ordinal definition base for this class 00123 * is 20. An enumeration is used so the compiler can help the use 00124 * to not choose duplicate values. 00125 * 00126 */ 00127 00128 00129 /*@{ */ /* Begin grouped definitions */ 00130 00131 00132 typedef enum 00133 { 00134 00135 JLCLASS_NMO_ISARRAY = 20, /**< Ordinal for 00136 @link #jlClass_isArray() isArray()@endlink */ 00137 00138 JLCLASS_NMO_ISPRIMATIVE = 21 /**< Ordinal for 00139 @link #jlClass_isPrimative() isPrimative()@endlink */ 00140 00141 } jlClass_nmo_enum; 00142 00143 /* 00144 * Add one function prototype below 00145 * for each local native method enumeration above: 00146 */ 00147 00148 /*! 00149 * @brief JNI hook to @link #jlClass_isArray() isArray()@endlink 00150 */ 00151 extern jboolean jlClass_isArray(jvm_object_hash objhash); 00152 00153 /*! 00154 * @brief JNI hook to @link #jlClass_isPrimative() isPrimative()@endlink 00155 */ 00156 extern jboolean jlClass_isPrimative(jvm_object_hash objhash); 00157 00158 /*@} */ /* End grouped definitions */ 00159 00160 00161 /*! 00162 * @name Connection to local native method tables. 00163 * 00164 * @brief These manifest constant code fragments are designed to be 00165 * inserted directly into locations in 00166 * @link jvm/src/native.c native.c@endlink without any other 00167 * modification to that file except a @e single entry to actually 00168 * invoke the method. 00169 * 00170 */ 00171 /*@{ */ /* Begin grouped definitions */ 00172 00173 /*! 00174 * @brief Complete list of local native method ordinals 00175 * for @c @b java.lang.Class 00176 */ 00177 #define NATIVE_TABLE_JLCLASS \ 00178 case JLCLASS_NMO_ISARRAY: \ 00179 case JLCLASS_NMO_ISPRIMATIVE: 00180 00181 /*! 00182 * @brief Table of local native methods and their descriptors 00183 * for @c @b java.lang.Class 00184 */ 00185 #define NATIVE_TABLE_JLCLASS_ORDINALS \ 00186 { \ 00187 { JLCLASS_NMO_ISARRAY, "isArray", "()V" }, \ 00188 { JLCLASS_NMO_ISPRIMATIVE, "isPrimative", "()V" }, \ 00189 \ 00190 /* Add other method entries here */ \ 00191 \ 00192 \ 00193 /* End of table marker */ \ 00194 { JVMCFG_JLOBJECT_NMO_NULL, \ 00195 CHEAT_AND_USE_NULL_TO_INITIALIZE, \ 00196 CHEAT_AND_USE_NULL_TO_INITIALIZE } \ 00197 } 00198 00199 #define NATIVE_TABLE_JLCLASS_JVOID /**< No @c @b (jvoid) methods */ 00200 #define NATIVE_TABLE_JLCLASS_JOBJECT /**< No @c @b (jobject) methods*/ 00201 00202 /*! 00203 * @brief @c @b (jint) local native method ordinal table 00204 * for @c @b java.lang.Class 00205 */ 00206 #define NATIVE_TABLE_JLCLASS_JINT \ 00207 case JLCLASS_NMO_ISARRAY: \ 00208 case JLCLASS_NMO_ISPRIMATIVE: 00209 00210 #define NATIVE_TABLE_JLCLASS_JFLOAT /**< No @c @b (jfloat) methods */ 00211 #define NATIVE_TABLE_JLCLASS_JLONG /**< No @c @b (jlong) methods */ 00212 #define NATIVE_TABLE_JLCLASS_JDOUBLE /**< No @c @b (jdouble) methods*/ 00213 00214 /*@} */ /* End grouped definitions */ 00215 00216 00217 #endif /* _jlClass_h_included_ */ 00218 00219 00220 /* EOF */ 00221