Back to index

lightning-sunbird  0.9+nobinonly
Classes | Defines | Functions | Variables
ProxyJNI.cpp File Reference
#include "nscore.h"
#include "jvmmgr.h"
#include "nsISecureEnv.h"
#include "nsIJVMPlugin.h"
#include "nsHashtable.h"
#include "nsVoidArray.h"
#include "plstr.h"
#include "ProxyClassLoader.h"
#include "ProxyJNI.h"
#include "nsDataHashtable.h"

Go to the source code of this file.

Classes

struct  JNIMember
struct  JNIField
struct  JNIMethod
struct  JavaClassMember
class  JavaClassMemberKey
class  MarshalledArgs
 Marshalls a va_list into a jvalue array, and destructor automatically deletes when the args go out of scope. More...
class  ProxyJNIEnv

Defines

#define IMPLEMENT_METHOD_FAMILY(methodName, returnType, jvalueField)
#define IMPLEMENT_METHOD_FAMILY(methodName, returnType, jvalueField)
#define IMPLEMENT_GET_FIELD(methodName, returnType, jvalueField)
#define IMPLEMENT_SET_FIELD(methodName, fieldType, jvalueField)
#define IMPLEMENT_METHOD_FAMILY(methodName, returnType, jvalueField)
#define IMPLEMENT_GET_FIELD(methodName, returnType, jvalueField)
#define IMPLEMENT_SET_FIELD(methodName, fieldType, jvalueField)
#define IMPLEMENT_NEW_ARRAY(methodName, type)
#define IMPLEMENT_GET_ARRAY_ELEMENTS(methodName, type)
#define IMPLEMENT_RELEASE_ARRAY_ELEMENTS(methodName, type)
#define IMPLEMENT_GET_ARRAY_REGION(methodName, type)
#define IMPLEMENT_SET_ARRAY_REGION(methodName, type)
#define REFERENCE_METHOD_FAMILY(methodName)   &methodName, &methodName##V, &methodName##A,

Functions

static jni_type get_jni_type (char sig)
static PRBool get_method_type (const char *sig, PRUint32 &arg_count, jni_type *&arg_types, jni_type &return_type)
JNIEnvCreateProxyJNI (nsIJVMPlugin *jvmPlugin, nsISecureEnv *inSecureEnv)
 Creates a proxy JNIEnv using the given JVM plugin, and optional native JNIEnv*.
void DeleteProxyJNI (JNIEnv *env)
 Deletes the proxy JNIEnv.
nsISecureEnvGetSecureEnv (JNIEnv *env)
 Returns the secure env associated with the given proxy env.
 PR_IMPLEMENT (void) SetSecurityContext(JNIEnv *env
proxyEnv SetSecurityContext (context)
 PR_IMPLEMENT (nsresult) GetSecurityContext(JNIEnv *env

Variables

static jvalue kErrorValue
nsISecurityContext *context
ProxyJNIEnv
proxyEnv = (ProxyJNIEnv*)env

Define Documentation

#define IMPLEMENT_GET_ARRAY_ELEMENTS (   methodName,
  type 
)
Value:
static type* JNICALL methodName(JNIEnv *env, type##Array array, jboolean *isCopy)                       \
    {                                                                                                       \
        type* outElements = NULL;                                                                           \
        nsISecureEnv* secureEnv = GetSecureEnv(env);                                                        \
        nsresult result;    \
        result = secureEnv->GetArrayElements(type##_type, array, isCopy, &outElements);         \
        return outElements;                                                                                 \
    }                                                                                                       \

Definition at line 1149 of file ProxyJNI.cpp.

#define IMPLEMENT_GET_ARRAY_REGION (   methodName,
  type 
)
Value:
static void JNICALL methodName(JNIEnv *env, type##Array array, jsize start, jsize len, type* buf)       \
    {                                                                                                       \
        nsISecureEnv* secureEnv = GetSecureEnv(env);                                                        \
        nsresult result;    \
        result = secureEnv->GetArrayRegion(type##_type, array, start, len, buf);                    \
    }                                                                                                       \

Definition at line 1189 of file ProxyJNI.cpp.

#define IMPLEMENT_GET_FIELD (   methodName,
  returnType,
  jvalueField 
)
Value:
static returnType JNICALL methodName(JNIEnv *env, jobject obj, jfieldID fieldID)        \
    {                                                                                       \
        return GetField(env, obj, (JNIField*)fieldID).jvalueField;                          \
    }                                                                                       \

Definition at line 978 of file ProxyJNI.cpp.

#define IMPLEMENT_GET_FIELD (   methodName,
  returnType,
  jvalueField 
)
Value:
static returnType JNICALL methodName(JNIEnv *env, jclass clazz, jfieldID fieldID)       \
    {                                                                                       \
        return GetStaticField(env, clazz, (JNIField*)fieldID).jvalueField;                  \
    }                                                                                       \

Definition at line 978 of file ProxyJNI.cpp.

#define IMPLEMENT_METHOD_FAMILY (   methodName,
  returnType,
  jvalueField 
)
Value:
static returnType JNICALL methodName(JNIEnv *env, jobject obj, jmethodID methodID, ...)                 \
    {                                                                                                       \
        va_list args; va_start(args, methodID);                                                             \
        returnType result = InvokeMethod(env, obj, (JNIMethod*)methodID, args).jvalueField;                 \
        va_end(args);                                                                                       \
        return result;                                                                                      \
    }                                                                                                       \
                                                                                                            \
    static returnType JNICALL methodName##V(JNIEnv *env, jobject obj, jmethodID methodID, va_list args)     \
    {                                                                                                       \
        return InvokeMethod(env, obj, (JNIMethod*)methodID, args).jvalueField;                              \
    }                                                                                                       \
                                                                                                            \
    static returnType JNICALL methodName##A(JNIEnv *env, jobject obj, jmethodID methodID, jvalue * args)    \
    {                                                                                                       \
        return InvokeMethod(env, obj, (JNIMethod*)methodID, args).jvalueField;                              \
    }                                                                                                       \

Definition at line 898 of file ProxyJNI.cpp.

#define IMPLEMENT_METHOD_FAMILY (   methodName,
  returnType,
  jvalueField 
)
Value:
static returnType JNICALL methodName(JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, ...)               \
    {                                                                                                                   \
        va_list args; va_start(args, methodID);                                                                         \
        returnType result = InvokeNonVirtualMethod(env, obj, clazz, (JNIMethod*)methodID, args).jvalueField;            \
        va_end(args);                                                                                                   \
        return result;                                                                                                  \
    }                                                                                                                   \
                                                                                                                        \
    static returnType JNICALL methodName##V(JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, va_list args)   \
    {                                                                                                                   \
        return InvokeNonVirtualMethod(env, obj, clazz, (JNIMethod*)methodID, args).jvalueField;                         \
    }                                                                                                                   \
                                                                                                                        \
    static returnType JNICALL methodName##A(JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, jvalue * args)  \
    {                                                                                                                   \
        return InvokeNonVirtualMethod(env, obj, clazz, (JNIMethod*)methodID, args).jvalueField;                         \
    }                                                                                                                   \

Definition at line 898 of file ProxyJNI.cpp.

#define IMPLEMENT_METHOD_FAMILY (   methodName,
  returnType,
  jvalueField 
)
Value:
static returnType JNICALL methodName(JNIEnv *env, jclass clazz, jmethodID methodID, ...)                \
    {                                                                                                       \
        va_list args; va_start(args, methodID);                                                             \
        returnType result = InvokeStaticMethod(env, clazz, (JNIMethod*)methodID, args).jvalueField;         \
        va_end(args);                                                                                       \
        return result;                                                                                      \
    }                                                                                                       \
                                                                                                            \
    static returnType JNICALL methodName##V(JNIEnv *env, jclass clazz, jmethodID methodID, va_list args)    \
    {                                                                                                       \
        return InvokeStaticMethod(env, clazz, (JNIMethod*)methodID, args).jvalueField;                      \
    }                                                                                                       \
                                                                                                            \
    static returnType JNICALL methodName##A(JNIEnv *env, jclass clazz, jmethodID methodID, jvalue * args)   \
    {                                                                                                       \
        return InvokeStaticMethod(env, clazz, (JNIMethod*)methodID, args).jvalueField;                      \
    }                                                                                                       \

Definition at line 898 of file ProxyJNI.cpp.

#define IMPLEMENT_NEW_ARRAY (   methodName,
  type 
)
Value:
static type##Array JNICALL methodName(JNIEnv *env, jsize len)                                   \
    {                                                                                               \
        type##Array outArray = NULL;                                                                \
        nsISecureEnv* secureEnv = GetSecureEnv(env);                                                \
        nsresult result; \
        result = secureEnv->NewArray(type##_type, len, (jarray*)&outArray);             \
        return outArray;                                                                            \
    }                                                                                               \

Definition at line 1128 of file ProxyJNI.cpp.

#define IMPLEMENT_RELEASE_ARRAY_ELEMENTS (   methodName,
  type 
)
Value:
static void JNICALL methodName(JNIEnv *env, type##Array array, type* elems, jint mode)                  \
    {                                                                                                       \
        nsISecureEnv* secureEnv = GetSecureEnv(env);                                                        \
        nsresult result;    \
        result = secureEnv->ReleaseArrayElements(type##_type, array, elems, mode);                  \
    }                                                                                                       \

Definition at line 1170 of file ProxyJNI.cpp.

#define IMPLEMENT_SET_ARRAY_REGION (   methodName,
  type 
)
Value:
static void JNICALL methodName(JNIEnv *env, type##Array array, jsize start, jsize len, type* buf)       \
    {                                                                                                       \
        nsISecureEnv* secureEnv = GetSecureEnv(env);                                                        \
        nsresult result;    \
        result = secureEnv->SetArrayRegion(type##_type, array, start, len, buf);                    \
    }                                                                                                       \

Definition at line 1208 of file ProxyJNI.cpp.

#define IMPLEMENT_SET_FIELD (   methodName,
  fieldType,
  jvalueField 
)
Value:
static void JNICALL methodName(JNIEnv *env, jobject obj, jfieldID fieldID, fieldType value)     \
    {                                                                                               \
        jvalue fieldValue;                                                                          \
        fieldValue.jvalueField = value;                                                             \
        SetField(env, obj, (JNIField*)fieldID, fieldValue);                                         \
    }                                                                                               \

Definition at line 1006 of file ProxyJNI.cpp.

#define IMPLEMENT_SET_FIELD (   methodName,
  fieldType,
  jvalueField 
)
Value:
static void JNICALL methodName(JNIEnv *env, jclass clazz, jfieldID fieldID, fieldType value)    \
    {                                                                                               \
        jvalue fieldValue;                                                                          \
        fieldValue.jvalueField = value;                                                             \
        SetStaticField(env, clazz, (JNIField*)fieldID, fieldValue);                                 \
    }                                                                                               \

Definition at line 1006 of file ProxyJNI.cpp.

#define REFERENCE_METHOD_FAMILY (   methodName)    &methodName, &methodName##V, &methodName##A,

Function Documentation

JNIEnv* CreateProxyJNI ( nsIJVMPlugin jvmPlugin,
nsISecureEnv inSecureEnv 
)

Creates a proxy JNIEnv using the given JVM plugin, and optional native JNIEnv*.

Definition at line 1743 of file ProxyJNI.cpp.

{
    ProxyJNIEnv* proxyEnv = new ProxyJNIEnv(jvmPlugin, inSecureEnv);
    if (proxyEnv->getSecureEnv() == NULL) {
        delete proxyEnv;
        return NULL;
    }
    return proxyEnv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void DeleteProxyJNI ( JNIEnv proxyEnv)

Deletes the proxy JNIEnv.

Releases the connection to the underlying JVM.

Definition at line 1753 of file ProxyJNI.cpp.

{
    ProxyJNIEnv* proxyEnv = (ProxyJNIEnv*)env;
    if (proxyEnv != NULL)
        delete proxyEnv;
}

Here is the caller graph for this function:

static jni_type get_jni_type ( char  sig) [static]

Definition at line 60 of file ProxyJNI.cpp.

{
    switch (sig) {
    case 'L':
    case '[':
        return jobject_type;
    case 'Z':
        return jboolean_type;
    case 'B':
        return jbyte_type;
    case 'C':
        return jchar_type;
    case 'S':
        return jshort_type;
    case 'I':
        return jint_type;
    case 'J':
        return jlong_type;
    case 'F':
        return jfloat_type;
    case 'D':
        return jdouble_type;
    case 'V':
        return jvoid_type;
    }
    return jvoid_type;
}

Here is the caller graph for this function:

static PRBool get_method_type ( const char *  sig,
PRUint32 arg_count,
jni_type *&  arg_types,
jni_type return_type 
) [static]

Definition at line 88 of file ProxyJNI.cpp.

{
    arg_count = 0;
    if (sig[0] == '(') {
        nsVoidArray vec;
        ++sig;
        while (*sig != ')' && *sig) {
            char arg_sig = *sig;
            jni_type arg_type = get_jni_type(arg_sig);
            if (arg_type == jobject_type) {
                // could be an array or an object.
                while (*sig == '[') ++sig;
                if (*sig == 'L') {
                    // skip over "className;"
                    ++sig;
                    while (*sig != ';') ++sig;
                }
            }
            // skip over scalar or ';'.
            ++sig;
            vec.AppendElement((void *) arg_type);
        }
        arg_count = vec.Count();
        arg_types = new jni_type[arg_count];
        for (int index = arg_count - 1; index >= 0; --index)
            arg_types[index] = jni_type((jint)NS_PTR_TO_INT32(vec.ElementAt(index)));
        if (*sig == ')') {
            char return_sig = *++sig;
            return_type = get_jni_type(return_sig);
        }
    }
    return PR_FALSE;
}

Here is the call graph for this function:

Returns the secure env associated with the given proxy env.

Definition at line 1760 of file ProxyJNI.cpp.

{
    ProxyJNIEnv* proxyEnv = (ProxyJNIEnv*)env;
    return proxyEnv->getSecureEnv();
}

Here is the call graph for this function:

Definition at line 292 of file plarena.c.

{
    PLArena *a;

    for (a = pool->first.next; a; a = a->next) {
        if (PR_UPTRDIFF(mark, a->base) < PR_UPTRDIFF(a->avail, a->base)) {
            a->avail = (PRUword)PL_ARENA_ALIGN(pool, mark);
            FreeArenaList(pool, a, PR_FALSE);
            return;
        }
    }
}

Here is the call graph for this function:

Definition at line 1045 of file prprf.c.

{
    SprintfState ss;
    int rv;

    ss.stuff = FuncStuff;
    ss.func = func;
    ss.arg = arg;
    ss.maxlen = 0;
    rv = dosprintf(&ss, fmt, ap);
    return (rv < 0) ? (PRUint32)-1 : ss.maxlen;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

jvalue kErrorValue [static]

Definition at line 276 of file ProxyJNI.cpp.

Definition at line 1767 of file ProxyJNI.cpp.