Main Page | Namespace List | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

jlClass.h File Reference


Detailed Description

Public interface to native implementation of java.lang.Class.

Two parallel sets of definitions are used here, one for internal implementation purposes, the other for JNI the interface. The first uses internal data types (via #ifdef JLCLASS_LOCAL_DEFINED) where the second does not. Instead, it uses <jni.h> data types. Those types must match up for JNI to work, yet by keeping them absolutely separate, application JNI code does not have any dependencies on the core code of this JVM implementation.

Even though there is only apparently one set of definitions, the #ifdef statement controls which set is used.

This file must be included by JNI code along with the java.lang.Class JNI header file. The following example shows how to call one of the local native methods of this class from the JNI environment. Notice that although this is not necessary due to the local implementation shortcut defined in native.c, it is not only possible, but sometimes quite desirable to do so.

   #include <jni.h>
   #include <solaris/jni_md.h>   ... or appropriate platform-specifics
  
   #include "java_lang_Class.h"  ... JNI definitions
   #include "jlClass.h"          ... this file
  
   JNIEXPORT jboolean JNICALL
       Java_java_lang_Class_isArray(JNIEnv  *env, jobject  thisobj)
   {
       jboolean b;

       b = jlClass_isArray(thisobj); ... call native implementation

       return(b);
   }
   

Attention:
This local native method implementation is defined in native.c and does not make use of the JNIENV pointer in any manner.

Although jvalue is indeed a part of both this implementation and the standard JNI interface through <jni.h> , it is not recommended to use it if at all possible. Due to the fact that both definitions involve unions, along with the slightly differing contents between the two versions, it is almost certain that there will be compilation compatibility problems in the memory layouts from one platform to another, and possibly between the layouts between them on any given platform. Since jvalue is not specificaly a Java type, but instead a JNI construction, this may not be a problem, but this advisory is raised anyway in order to encourage reliable implementation of JNI.

Control

$URL: https://svn.apache.org/path/name/jlClass.h $ $Id: jlClass.h 0 09/28/2005 dlydick $

Copyright 2005 The Apache Software Foundation or its licensors, as applicable.

Licensed under the Apache License, Version 2.0 ("the License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

See the License for the specific language governing permissions and limitations under the License.

Version:
$LastChangedRevision: 0 $
Date:
$LastChangedDate: 09/28/2005 $
Author:
$LastChangedBy: dlydick $ Original code contributed by Daniel Lydick on 09/28/2005.

Reference

Definition in file jlClass.h.

#include "jlObject.h"

Go to the source code of this file.

Connection to local native method tables.

These manifest constant code fragments are designed to be inserted directly into locations in native.c without any other modification to that file except a single entry to actually invoke the method.

#define NATIVE_TABLE_JLCLASS
 Complete list of local native method ordinals for java.lang.Class.
#define NATIVE_TABLE_JLCLASS_JDOUBLE
 No (jdouble) methods.
#define NATIVE_TABLE_JLCLASS_JFLOAT
 No (jfloat) methods.
#define NATIVE_TABLE_JLCLASS_JINT
 (jint) local native method ordinal table for java.lang.Class
#define NATIVE_TABLE_JLCLASS_JLONG
 No (jlong) methods.
#define NATIVE_TABLE_JLCLASS_JOBJECT
 No (jobject) methods.
#define NATIVE_TABLE_JLCLASS_JVOID
 No (jvoid) methods.
#define NATIVE_TABLE_JLCLASS_ORDINALS
 Table of local native methods and their descriptors for java.lang.Class.

Unified set of prototypes for functions

JNI table index and external reference to each function that locally implements a JNI native method.

in jlClass.c

The JVM native interface ordinal definition base for this class is 20. An enumeration is used so the compiler can help the use to not choose duplicate values.

enum  jlClass_nmo_enum { JLCLASS_NMO_ISARRAY = 20, JLCLASS_NMO_ISPRIMATIVE = 21 }
jboolean jlClass_isArray (jvm_object_hash objhash)
 JNI hook to isArray().
jboolean jlClass_isPrimative (jvm_object_hash objhash)
 JNI hook to isPrimative().


Define Documentation

#define NATIVE_TABLE_JLCLASS
 

Value:

Complete list of local native method ordinals for java.lang.Class.

Definition at line 176 of file jlClass.h.

Referenced by native_verify_ordinal_definition().

#define NATIVE_TABLE_JLCLASS_ORDINALS
 

Value:

{                                                      \
        { JLCLASS_NMO_ISARRAY,     "isArray", "()V"     }, \
        { JLCLASS_NMO_ISPRIMATIVE, "isPrimative", "()V" }, \
                                                           \
        /* Add other method entries here */                \
                                                           \
                                                           \
        /* End of table marker */                          \
        { JVMCFG_JLOBJECT_NMO_NULL,                        \
          CHEAT_AND_USE_NULL_TO_INITIALIZE,                \
          CHEAT_AND_USE_NULL_TO_INITIALIZE }               \
    }
Table of local native methods and their descriptors for java.lang.Class.

Definition at line 184 of file jlClass.h.

#define NATIVE_TABLE_JLCLASS_JVOID
 

No (jvoid) methods.

Definition at line 198 of file jlClass.h.

#define NATIVE_TABLE_JLCLASS_JOBJECT
 

No (jobject) methods.

Definition at line 199 of file jlClass.h.

#define NATIVE_TABLE_JLCLASS_JINT
 

Value:

(jint) local native method ordinal table for java.lang.Class

Definition at line 205 of file jlClass.h.

#define NATIVE_TABLE_JLCLASS_JFLOAT
 

No (jfloat) methods.

Definition at line 209 of file jlClass.h.

#define NATIVE_TABLE_JLCLASS_JLONG
 

No (jlong) methods.

Definition at line 210 of file jlClass.h.

#define NATIVE_TABLE_JLCLASS_JDOUBLE
 

No (jdouble) methods.

Definition at line 211 of file jlClass.h.


Enumeration Type Documentation

enum jlClass_nmo_enum
 

Enumerator:
JLCLASS_NMO_ISARRAY  Ordinal for isArray().
JLCLASS_NMO_ISPRIMATIVE  Ordinal for isPrimative().

Definition at line 131 of file jlClass.h.


Function Documentation

jboolean jlClass_isArray jvm_object_hash  objhashthis  ) 
 

JNI hook to isArray().

Parameters:
objhashthis Object table hash of this object.
Returns:
jtrue if this class is an array, else jfalse.
< Class is an array type where arraydims contains number of dimensions

Definition at line 93 of file jlClass.c.

References CLASS, CLASS_STATUS_ARRAY, jfalse, jtrue, jvm_class_index_null, and OBJECT_CLASS_LINKAGE.

Referenced by Java_java_lang_Class_isArray(), and native_run_local_return_jint().

jboolean jlClass_isPrimative jvm_object_hash  objhashthis  ) 
 

JNI hook to isPrimative().

Parameters:
objhashthis Object table hash of this object.
Returns:
jtrue if this class is a primative, else jfalse.
< Primative for java.lang.Class

Definition at line 124 of file jlClass.c.

References jfalse.

Referenced by Java_java_lang_Class_isPrimitive(), and native_run_local_return_jint().


Generated on Fri Sep 30 18:59:46 2005 by  doxygen 1.4.4