MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MemberId< C > Struct Template Reference

#include <jtie_tconv_idcache_impl.hpp>

Inheritance diagram for MemberId< C >:

Public Types

typedef C::memberID_t ID_t

Static Public Member Functions

static void setClass (JNIEnv *env, jclass cls)
static jclass getClass (JNIEnv *env)
static ID_t getId (JNIEnv *env, jclass cls)
static void releaseRef (JNIEnv *env, jclass cls)

Static Public Attributes

static unsigned long nIdLookUps = 0

Detailed Description

template<typename C>
struct MemberId< C >

Provides uniform access to the JNI Field/Method ID of a Java class member as described by the member info type 'C'.

This base class does not cache the member ID and the class object, but it retrieves the member ID from JNI upon each access; different caching strategies are provided by derived classes.

This class (and its derived classes) impose a strict usage pattern. For example, given definitions...

// Defines the field info type for MyClass.myField. JTIE_DEFINE_FIELD_MEMBER_INFO(_MyClass_myField)

// Provides a (cached) access to field Id of MyClass.myField. typedef JniMemberId< _MyClass_myField > MyClass_myField;

any use of a member ID must be bracketed by getClass() and releaseRef():

// obtain a class reference jclass cls = MyClass_myField::getClass(env); if (cls == NULL) { // exception pending } else { // get the field ID valid along with the class reference jfieldID fid = MyClass_myField::getId(env, cls); if (fid == NULL) { // exception pending } else { // OK to access field using 'fid' } // allow for releasing the class reference MyClass_myField::releaseRef(env, cls); }

Derived classes implement any caching underneath this usage pattern.

Definition at line 156 of file jtie_tconv_idcache_impl.hpp.

Member Function Documentation

template<typename C >
static jclass MemberId< C >::getClass ( JNIEnv *  env)
inlinestatic

Returns a JNI Reference to the class declaring the member specified by info type 'C'.

Depending upon the underlying caching strategy, a returned reference may be local or global, weak or strong; the scope of its use must be demarcated by releaseRef().

Pre condition:

  • this thread has no pending JNI exception (!env->ExceptionCheck())

Post condition:

  • return value is NULL:
    • this thread has a pending JNI exception (env->ExceptionCheck()) otherwise:
    • this thread has no pending JNI exception (!env->ExceptionCheck())
    • the returned reference is valid (at least) until releaseRef()

Reimplemented in MemberIdPreloadedStrongCache< C >, MemberIdPreloadedWeakCache< C >, MemberIdStrongCache< C >, and MemberIdWeakCache< C >.

Definition at line 196 of file jtie_tconv_idcache_impl.hpp.

Here is the caller graph for this function:

template<typename C >
static ID_t MemberId< C >::getId ( JNIEnv *  env,
jclass  cls 
)
inlinestatic

Returns the JNI Field/Method ID of a Java class member.

The member ID is only valid along with a class object obtained by getClass() and before releaseRef().

Pre condition:

  • this thread has no pending JNI exception (!env->ExceptionCheck())
  • a valid class reference obtained by getClass(): assert(cls != NULL)

Post condition:

  • return value is NULL:
    • this thread has a pending JNI exception (env->ExceptionCheck()) otherwise:
    • this thread has no pending JNI exception (!env->ExceptionCheck())
    • the returned member ID is valid (at least) until releaseRef()

Reimplemented in MemberIdCache< C >.

Definition at line 239 of file jtie_tconv_idcache_impl.hpp.

Here is the caller graph for this function:

template<typename C >
static void MemberId< C >::releaseRef ( JNIEnv *  env,
jclass  cls 
)
inlinestatic

Allows for a class reference to be released along with any member IDs.

Pre condition:

  • a valid class reference obtained by getClass(): assert(cls != NULL)
  • this thread may have a pending JNI exception (env->ExceptionCheck())

Reimplemented in MemberIdPreloadedWeakCache< C >, MemberIdStrongCache< C >, and MemberIdWeakCache< C >.

Definition at line 254 of file jtie_tconv_idcache_impl.hpp.

template<typename C >
static void MemberId< C >::setClass ( JNIEnv *  env,
jclass  cls 
)
inlinestatic

Allows for storing a (global) class reference.

Usually only called from getClass(), but enables "cache preloading" from a (native, static) function called at class initialization.

Pre condition:

  • this thread has no pending JNI exception (!env->ExceptionCheck())
  • a valid local or global class reference: assert(cls != NULL)

Reimplemented in MemberIdStrongCache< C >, and MemberIdWeakCache< C >.

Definition at line 172 of file jtie_tconv_idcache_impl.hpp.


The documentation for this struct was generated from the following file: