Codemesh Runtime v3 C++ API Reference
3.9.205
|
A C++ wrapper for Java types. More...
#include <xmog_java_class.h>
Public Types | |
enum | xmog_interceptor_result { IcpDoneWithResult = 1, IcpContinue = 0, IcpError = -1 } |
A value used to signal further interceptor processing requirements. More... | |
enum | xmog_interceptor_when { IcpBefore = 0, IcpAfter = 1 } |
A value used to signal the interceptor call reason. More... | |
enum | xmog_interceptor_what { IcpFieldGet = 0, IcpFieldSet = 1, IcpMethod = 2, IcpCtor = 3, IcpArrayCreate = 4, IcpArrayGet = 5, IcpArraySet = 6, IcpStringFromNativeChars = 7, IcpNativeCharsFromString = 8, IcpIsNull = 9, IcpIsInstanceOf = 10, IcpSpecial = 16 } |
A value used to signal the interceptor type. More... | |
typedef void(XMOG_CALLING_CONVENTION * | XMOG_THROW_METHOD) (jobject exc, xmog_flags flags) |
A typedef for the method that can be used to throw an exception. More... | |
typedef xmog_java_ref *(XMOG_CALLING_CONVENTION * | XMOG_FACTORY_METHOD) (jobject obj, xmog_flags src, xmog_flags dest, const char *classNameUTF, xmog_localenv *env) |
A typedef for the method that can be used to return a heap-allocated instance of a proxy type based on a JNI reference. More... | |
typedef xmog_java_ref *(XMOG_CALLING_CONVENTION * | XMOG_TOJAVA_METHOD) (xmog_java_ref *nobj, xmog_localenv *env) |
A typedef for the method that can be used to perform custom object conversion for a native type that is being transformed into a Java object. More... | |
typedef xmog_java_ref *(XMOG_CALLING_CONVENTION * | XMOG_FROMJAVA_METHOD) (xmog_java_ref *jobj, xmog_localenv *env) |
A typedef for the method that can be used to perform custom object initialization for a proxy type that is being created for an existing Java object. More... | |
typedef xmog_interceptor_result(XMOG_CALLING_CONVENTION * | XMOG_INTERCEPTOR) (xmog_base *obj, xmog_java_dynamic *dyn, xmog_java_values *vals, xmog_interceptor_when when, xmog_interceptor_what what, xmog_java_value *result, xmog_localenv *env, xmog_flags &flags) |
A typedef for a method that can be registered to handle or augment the processing of proxy API calls. More... | |
Public Types inherited from xmog_base | |
enum | flags { STAND_ALONE = 1, ARRAY_ELEMENT = 2, DYNAMIC = 4, DELEGATE = 8, LOCAL = 16, WEAK_GLOBAL = 32, GLOBAL = 64, REMOTE = 128, CACHING = 256, CACHE_INVALID = 512, CACHE_DIRTY = 1024, CACHE_LAZY_WRITE = 2048, OWNS_DELEGATE = 4096, STRING_DIRTY = 8192, STRING_PTR = 16384, STRING_WPTR = 32768, INDIRECT = 65536, NONVIRT = 131072, SUPPRESS_LOGGING = 262144, CATEGORY = 15, TYPE = 240, CACHE = 3840 } |
The possible flag values. More... | |
Public Member Functions | |
xmog_java_class () | |
The default constructor. | |
xmog_java_class (const char *classNameUTF, bool bDelayInit=false, XMOG_FACTORY_METHOD factoryMethod=NULL_FACTORY_METHOD, XMOG_THROW_METHOD throwMethod=NULL_THROW_METHOD, XMOG_TOJAVA_METHOD toJavaMethod=NULL_TOJAVA_METHOD, XMOG_FROMJAVA_METHOD fromJavaMethod=NULL_FROMJAVA_METHOD, xmog_localenv *env=NULL) | |
The constructor that creates an instance based on the classname. More... | |
xmog_java_class (const char *classNameUTF, const char *version, const char *config, bool bDelayInit=false, XMOG_FACTORY_METHOD factoryMethod=NULL_FACTORY_METHOD, XMOG_THROW_METHOD throwMethod=NULL_THROW_METHOD, XMOG_TOJAVA_METHOD toJavaMethod=NULL_TOJAVA_METHOD, XMOG_FROMJAVA_METHOD fromJavaMethod=NULL_FROMJAVA_METHOD, xmog_localenv *env=NULL) | |
The constructor that creates an instance based on the classname and a named configuration. More... | |
xmog_java_class (const char *classNameUTF, jbyte *bytes, jint length, bool bDelayInit=false, XMOG_FACTORY_METHOD factoryMethod=NULL_FACTORY_METHOD, XMOG_THROW_METHOD throwMethod=NULL_THROW_METHOD, XMOG_TOJAVA_METHOD toJavaMethod=NULL_TOJAVA_METHOD, XMOG_FROMJAVA_METHOD fromJavaMethod=NULL_FROMJAVA_METHOD, xmog_localenv *env=NULL) | |
The constructor that creates an instance based on class bytes. More... | |
xmog_java_class (const char *classNameUTF, jbyte *bytes, jint length, jbyte *stubBytes, jint stubLength, jbyte *skelBytes, jint skelLength, bool bDelayInit=false, XMOG_FACTORY_METHOD factoryMethod=NULL_FACTORY_METHOD, XMOG_THROW_METHOD throwMethod=NULL_THROW_METHOD, XMOG_TOJAVA_METHOD toJavaMethod=NULL_TOJAVA_METHOD, XMOG_FROMJAVA_METHOD fromJavaMethod=NULL_FROMJAVA_METHOD, xmog_localenv *env=NULL) | |
The constructor that creates an instance based on class bytes. More... | |
xmog_java_class (jclass _local, xmog_flags _flags, const char *classNameUTF=NULL, xmog_localenv *env=NULL) | |
The constructor that creates an instance based on an existing JNI reference. More... | |
void * | operator new (size_t) |
An overloaded operator new to support the automatic detection of whether or not the object is heap-allocated. | |
void | operator delete (void *) |
An overloaded operator delete to support the safe cleanup of instances independent of whether they are allcoated on the heap or not. | |
void | has_peer_unmarshaller (bool bHPU) |
Sets the flag that indicates that the class has at least one peer unmarshaller registered for it. More... | |
bool | has_peer_unmarshaller () const |
Returns true if the class has at least one peer unmarshaller registered. More... | |
jint | get_hashcode (xmog_localenv *env=NULL) |
Returns the instance's hashcode. More... | |
jclass | get_jclass (xmog_localenv *env=NULL) |
Returns the internal JNI reference to the type. More... | |
jclass | get_jclass (xmog_localenv *env, bool bSuppressExceptions) |
Returns the internal JNI reference to the type. More... | |
const char * | get_class_name () const |
Returns the class name. | |
const char * | getClassName (xmog_localenv *env=NULL) |
Returns the classname. More... | |
void | add_field (xmog_java_field *_field) |
Adds a field to the list of fields that this instance is aware of. More... | |
xmog_java_field * | get_fields () |
Returns a pointer to the first field. | |
void | remove_field (xmog_java_field *_field) |
Removes a field from the list of field that this instance is aware of. More... | |
void | add_method (xmog_java_method *_method) |
Adds a method to the list of methods that this instance is aware of. More... | |
xmog_java_method * | get_methods () |
Returns a pointer to the first method or constructor. | |
void | remove_method (xmog_java_method *_method) |
Removes a method from the list of methods that this instance is aware of. More... | |
void | throw_ (jthrowable throwable, xmog_flags flags, int error_code=0, xmog_localenv *env=NULL) |
Throws an instance of the proxy type represented by this instance. More... | |
xmog_java_class * | get_array_class () |
Returns the xmog_java_class instance that represents the array type for this instance's represented type. | |
jobject | from (const xmog_base &srcInstance, xmog_flags flags=xmog_base::GLOBAL, xmog_localenv *env=NULL) |
Returns an object reference or null if the given instance is incompatible with this class. More... | |
void | setInterceptor (XMOG_INTERCEPTOR icp) |
Sets an API interceptor for the Java type represented by this instance. More... | |
void | setOwnsClassName () |
Used internally for housekeeping. | |
xmog_java_class::XMOG_INTERCEPTOR | getInterceptor () const |
Returns an installed interceptor or NULL if there is none. | |
Public Member Functions inherited from xmog_java_ref | |
xmog_java_ref () | |
The default constructor. | |
xmog_java_ref (const xmog_null &) | |
The from null constructor. More... | |
xmog_java_ref (xmog_java_array *_arr, jint _index) | |
The array element constructor. More... | |
xmog_java_ref (xmog_java_class *_clazz, xmog_java_dynamic *_dynamic, xmog_flags _flags) | |
The constructor that allows the dynamic resolution of class-related information. More... | |
XMOG_EXPLICIT | xmog_java_ref (xmog_base *_delegate, bool _owns_delegate=true) |
The constructor that allows the creation of an instance to handle all requests by delegating to another instance. More... | |
xmog_java_ref (xmog_java_ref *_ref, xmog_java_dynamic *_dynamic, xmog_flags _flags) | |
The constructor that allows the dynamic resolution of instance-related information. More... | |
xmog_java_ref (jobject _local, xmog_flags _flags) | |
The constructor that sets an existing JNI reference into a wrapper instance. More... | |
~xmog_java_ref () | |
Deletes the reference we hold to the wrapped Java instance. | |
bool | operator== (const xmog_null &) const |
Compares the instance for equality with null . | |
bool | operator== (const xmog_java_ref &) const |
Compares the instance for equality with another instance. More... | |
bool | operator!= (const xmog_null &) const |
Compares the instance for inequality with null . | |
bool | operator!= (const xmog_java_ref &) const |
Compares the instance for inequality with another instance. More... | |
bool | operator! () const |
Returns true if the instance refers to null , false otherwise. | |
jboolean | xmog_equals (const xmog_java_ref &_rhs, xmog_localenv *env=NULL) |
Returns true if both instances are null or satisfy the equality test. More... | |
jint | xmog_hashCode (xmog_localenv *env=NULL) |
Returns the Java instance's hashCode. More... | |
jobject | xmog_toString (xmog_localenv *env=NULL) |
Returns the Java instance's toString() valus as a global reference. More... | |
virtual jobject | get_jobject_ (xmog_localenv *env=NULL) const |
Returns this instance's object reference. More... | |
virtual void | xmog_monitor_enter (xmog_localenv *env=NULL) const |
Attempts to enter into a lock on the object. | |
virtual void | xmog_monitor_exit (xmog_localenv *env=NULL) const |
Leaves a lock in the object. | |
Public Member Functions inherited from xmog_base | |
xmog_base () | |
The default contructor. More... | |
xmog_base (xmog_java_array *_ref, jint _index) | |
The constructor for Java array elements. More... | |
xmog_base (xmog_java_ref *_ref, xmog_java_dynamic *_dynamic, xmog_flags _flags) | |
The constructor for indirect and user-defined types. More... | |
xmog_base (xmog_java_class *_clazz, xmog_java_dynamic *_dynamic, xmog_flags _flags) | |
The constructor for indirect and user-defined types. More... | |
XMOG_EXPLICIT | xmog_base (xmog_base *_delegate, bool _owns_delegate=true) |
The constructor for delegating objects. More... | |
xmog_base (jobject _local, xmog_flags _flags) | |
The constructor for direct types. More... | |
virtual | ~xmog_base () |
The virtual destructor. | |
virtual void | copy_jobject_ (xmog_base *_rhs, xmog_localenv *env=NULL) |
Sets this instance's object reference to a duplicate of the given object's reference. More... | |
virtual jobject | get_owning_jobject_ (xmog_localenv *env=NULL) |
Returns this instance's owner. More... | |
virtual jobject | get_released_local_jobject_ (xmog_localenv *env=NULL) const |
Returns this instance's object reference as a local reference and removes it from this instance's ownership. More... | |
virtual bool | is_null_ (xmog_localenv *env=NULL) const |
Tests the instance for null . | |
virtual bool | is_same_ (const xmog_base &_rhs, xmog_localenv *env=NULL) const |
Tests whether this instance references the same instance as the other instance. | |
virtual jobject | duplicate_jobject_ (xmog_localenv *env=NULL) const |
Returns a duplicate of this instance's object reference. More... | |
virtual void | set_jobject_ (xmog_base *_rhs, xmog_localenv *env=NULL) |
Sets this instance's object reference to the given object's reference. More... | |
virtual void | transfer_jobject_ (xmog_base *_rhs, xmog_localenv *env=NULL) |
Sets this instance's object reference to the given object's reference and removes ownership from the other object. More... | |
virtual xmog_base * | xmog_to_ (xmog_flags flags, xmog_localenv *env=NULL) |
Converts a reference from one reference type to another. More... | |
virtual xmog_base * | xmog_fill_with_standalone_for_ (xmog_base *_rhs, xmog_localenv *env=NULL) |
Populates the object with a stand-alone reference based on another object. More... | |
virtual xmog_java_class * | xmog_get_java_peer (xmog_localenv *env=NULL) |
Returns NULL if the type does not have a Java peer type, a pointer to the type's xmog_java_class otherwise. More... | |
virtual int | xmog_create_java_peer (xmog_java_class *clazz, xmog_localenv *env=NULL, xmog_flags flags=xmog_base::GLOBAL) |
Creates a Java peer instance for this type. More... | |
virtual int | xmog_to_java_peer (xmog_localenv *env=NULL) |
Sets the native instance's state into the Java peer instance. More... | |
virtual void | xmog_lazy_write (xmog_localenv *env=NULL) |
Performs a lazy write operation on the instance. More... | |
virtual void | xmog_invalidate (xmog_localenv *env=NULL) |
Invalidates any cached values in the instance. More... | |
void | release_standalone (xmog_localenv *env=NULL) |
Releases the internally maintained object if the instance is a stand-alone (direct) instance and not an indirect instance. More... | |
void | release_delegate () |
Releases the internally maintained delegate. | |
Static Public Member Functions | |
static jint | calculate_hashcode (const char *_classNameUTF) |
A utility method for calculating the hashcode of a classname. More... | |
static jobject | get_bootstrap_classloader (xmog_localenv *env=NULL) |
Returns the classloader used by the Codemesh framework. This method only works for 1.2 or later JVMs because it relies on the post 1.1 classloader specification. More... | |
static void | bootstrap (xmog_localenv *env=NULL) |
Injects the custom classloader types into the JVM. More... | |
static void | initThread (xmog_localenv *env=NULL) |
Performs per-thread initialization in relation with the custom classloader. More... | |
static void | add_class (xmog_java_class *clazz) |
Adds a proxy class to the proper list of classes. More... | |
static void | remove_class (xmog_java_class *clazz) |
Removes a proxy class from the proper list of classes. More... | |
static xmog_java_class * | get_classes () |
Returns the first class in the list of regular types. | |
static xmog_java_class * | get_throwables () |
Returns the first class in the list of throwable types. | |
static char * | getClassName (jobject inst, xmog_localenv *env=NULL) |
Returns the classname of the given instance. More... | |
static char * | getClassClassName (jclass clazz, xmog_localenv *env=NULL) |
Returns the classname of a given class instance. More... | |
static xmog_java_class * | get_exact_throwable_for (const char *classNameUTF) |
Returns the exact xmog_java_class instance for the given name that has a non-NULL exception factory method. More... | |
static xmog_java_class * | get_best_throwable_for (xmog_base *throwable, bool bRemote, xmog_localenv *env=NULL) |
Returns the best matching xmog_java_class instance for the given throwable and that has a non-NULL exception factory method. More... | |
static xmog_java_class * | get_class_named (const char *classNameUTF) |
Returns the xmog_java_class instance for the given name that has a non-NULL instance factory method. More... | |
static jbyte | calculateMaximumSupportedClassVersion () |
Calculates the maximum supported class version. | |
static void | addLocalResourceRoot (const char *filenameUTF, bool preferred=false, xmog_localenv *env=NULL) |
Adds a file to the classpath used by the custom classloader. More... | |
static void | addInMemoryResourceRoot (const jbyte *bytes, size_t len, bool preferred=false, xmog_localenv *env=NULL) |
Adds the embedded classes to the classpath used by the custom classloader. More... | |
static void | addDirectoryJarFiles (const char *dirnameUTF, bool preferred=false, xmog_localenv *env=NULL) |
Adds all jarfiles in the specified directory to the classpath used by the custom classloader. More... | |
static void | setSecurityManager (xmog_java_method &mSSM, const xmog_java_ref &sm, xmog_localenv *env) |
Returns the method used to set the security manager. | |
static bool | call_bool_indirect (xmog_java_method *method, jobject instance, xmog_java_values *values, xmog_localenv *env) |
Calls a Java method indirectly. More... | |
static jboolean | call_boolean_indirect (xmog_java_method *method, jobject instance, xmog_java_values *values, xmog_localenv *env) |
Calls a Java method indirectly. More... | |
static jbyte | call_byte_indirect (xmog_java_method *method, jobject instance, xmog_java_values *values, xmog_localenv *env) |
Calls a Java method indirectly. More... | |
static jchar | call_char_indirect (xmog_java_method *method, jobject instance, xmog_java_values *values, xmog_localenv *env) |
Calls a Java method indirectly. More... | |
static jdouble | call_double_indirect (xmog_java_method *method, jobject instance, xmog_java_values *values, xmog_localenv *env) |
Calls a Java method indirectly. More... | |
static jfloat | call_float_indirect (xmog_java_method *method, jobject instance, xmog_java_values *values, xmog_localenv *env) |
Calls a Java method indirectly. More... | |
static jint | call_int_indirect (xmog_java_method *method, jobject instance, xmog_java_values *values, xmog_localenv *env) |
Calls a Java method indirectly. More... | |
static jlong | call_long_indirect (xmog_java_method *method, jobject instance, xmog_java_values *values, xmog_localenv *env) |
Calls a Java method indirectly. More... | |
static jshort | call_short_indirect (xmog_java_method *method, jobject instance, xmog_java_values *values, xmog_localenv *env) |
Calls a Java method indirectly. More... | |
static jobject | call_object_indirect (xmog_java_method *method, jobject instance, xmog_java_values *values, xmog_localenv *env) |
Calls a Java method indirectly. More... | |
static void | call_void_indirect (xmog_java_method *method, jobject instance, xmog_java_values *values, xmog_localenv *env) |
Calls a Java method indirectly. More... | |
static xmog_java_method & | getClass_method () |
Returns a reference to a method wrapping around getClass(). | |
static xmog_java_method & | isInstance_method () |
Returns a reference to a method wrapping around isInstance(). | |
static int | getInterceptorCount () |
Returns the total number of interceptors registered with all types. | |
Static Public Attributes | |
static XMOG_THROW_METHOD | NULL_THROW_METHOD |
An instance that can be used in places where no exception factory is required. | |
static XMOG_FACTORY_METHOD | NULL_FACTORY_METHOD |
An instance that can be used in places where no instance factory is required. | |
static XMOG_TOJAVA_METHOD | NULL_TOJAVA_METHOD |
An instance that can be used in places where no to-Java specialization is required. | |
static XMOG_FROMJAVA_METHOD | NULL_FROMJAVA_METHOD |
An instance that can be used in places where no from-Java specialization is required. | |
Additional Inherited Members | |
Public Attributes inherited from xmog_base | |
XMOG_JOBJECT_HOLDER | owner_ |
The owner or identity of the object. More... | |
union { | |
xmog_java_dynamic * dynamic_ | |
A pointer to an object that can access indirectly specified information. | |
jint index_ | |
The index of an array element. | |
}; | |
Data or object that provides assistance in accessing indirectly specified elements. More... | |
xmog_flags | flags_ |
The flags governing the type and other housekeeping information. | |
A C++ wrapper for Java types.
This class provides basic proxy services for Java types. It has a number of constructors that allow the instantiation of a wrapper object based on a classname or on an existing JNI reference. It also utility methods that bootstrap a classloader that will be used by the native application and allow the efficient lookup of a class wrapper instance based on its classname.
typedef xmog_java_ref*(XMOG_CALLING_CONVENTION * xmog_java_class::XMOG_FACTORY_METHOD) (jobject obj, xmog_flags src, xmog_flags dest, const char *classNameUTF, xmog_localenv *env) |
A typedef for the method that can be used to return a heap-allocated instance of a proxy type based on a JNI reference.
Every generated proxy class maintains a pointer to a function of this type that can be used as a factory method for instances of that proxy type. This method can then be used to dynamically create a proxy instance solely based on the type of the Java object (or additional factors).
exc | an existing JNI reference to a Java instance. |
src | bitflags describing the type of reference we have. |
dest | bitflags describing the type of reference we want. |
classNameUTF | the classname of the exception instance. |
env | a local environment pointer. |
typedef xmog_java_ref*(XMOG_CALLING_CONVENTION * xmog_java_class::XMOG_FROMJAVA_METHOD) (xmog_java_ref *jobj, xmog_localenv *env) |
A typedef for the method that can be used to perform custom object initialization for a proxy type that is being created for an existing Java object.
When a Java method returns a reference as a result of its invocation, we usually simply wrap the reference in the proxy type for the declared return type. This is not always sufficient. For example: a user might wish to derive custom data types from a proxy type on the C++ side. These data types may contain data fields that should be persisted to the Java side and that should be read from the Java side when such a persisted instance is given back as the result of a method call. There are two issues to solve. The first involves creating an instance of the proper type and the second involves initializing that instance with the correct data.
typedef xmog_interceptor_result(XMOG_CALLING_CONVENTION * xmog_java_class::XMOG_INTERCEPTOR) (xmog_base *obj, xmog_java_dynamic *dyn, xmog_java_values *vals, xmog_interceptor_when when, xmog_interceptor_what what, xmog_java_value *result, xmog_localenv *env, xmog_flags &flags) |
A typedef for a method that can be registered to handle or augment the processing of proxy API calls.
obj | the instance on which the API is performed (may be NULL for static APIs). |
dyn | the element representing the API that is being performed. |
vals | the arguments that are passed to the API. |
when | the interceptor call time (can be called before and/or after the proxy operation). |
what | the interceptor call reason. This argument helps us in casting the dyn argument to the correct concrete type, for example xmog_java_field or xmog_java_method . |
result | the result value of the interceptor call. Only used if the interceptor returns IcpDone . |
env | the local call environment passed to the API. |
flags | a reference to the flags that are passed to the API. |
typedef xmog_java_ref*(XMOG_CALLING_CONVENTION * xmog_java_class::XMOG_TOJAVA_METHOD) (xmog_java_ref *nobj, xmog_localenv *env) |
A typedef for the method that can be used to perform custom object conversion for a native type that is being transformed into a Java object.
When a Java method returns a reference as a result of its invocation, we usually simply wrap the reference in the proxy type for the declared return type. This is not always sufficient. For example: a user might wish to derive custom data types from a proxy type on the C++ side. These data types may contain data fields that should be persisted to the Java side and that should be retrievable from the Java side when such a persisted instance is given back as the result of another method call.
This method is responsible for instantiating a proper Java peer object and for persisting the native instance in that Java object. The act of persisting the native object needs to include both the object's state and enough type information to allow the framework to instantiate the correct native type when the object is read back from Java. It is assumed that the native object is a subtype of a proxy type, thereby allowing its use with the generated typesystem.
A value used to signal the interceptor type.
Enumerator | |
---|---|
IcpFieldSet | A 'get field value' request is being processed. The |
IcpMethod | A 'set field value' request is being processed. The |
IcpCtor | A 'call method' request is being processed. The |
IcpArrayCreate | A 'invoke constructor' request is being processed. The |
xmog_java_class::xmog_java_class | ( | const char * | classNameUTF, |
bool | bDelayInit = false , |
||
XMOG_FACTORY_METHOD | factoryMethod = NULL_FACTORY_METHOD , |
||
XMOG_THROW_METHOD | throwMethod = NULL_THROW_METHOD , |
||
XMOG_TOJAVA_METHOD | toJavaMethod = NULL_TOJAVA_METHOD , |
||
XMOG_FROMJAVA_METHOD | fromJavaMethod = NULL_FROMJAVA_METHOD , |
||
xmog_localenv * | env = NULL |
||
) |
The constructor that creates an instance based on the classname.
This constructor can be used to easily create a wrapper instance that is not associated with a named configuration (for example for a built-in Java framework type that is always available, no matter what the classpath is).
classNameUTF | the UTF representation of the classname. The classname should be provided in slash-separated (internal) format. |
bDelayInit | true if the wrapper instance should immediately try to load the Java type, false if not. A generated framework typically uses delayed initialization to give the programmer a chance to control the time at which the JVM is loaded. The default value is false. |
factoryMethod | the method that returns a dynamically allocated instance of a proxy type based on an existing JNI reference. |
throwMethod | the method that throws an exception of a proxy type based on an existing JNI reference. |
toJavaMethod | the method that creates and initializes a Java object for a native object. |
fromJavaMethod | the method that creates and initializes a native object for a Java object. |
env | the local environment to use. The default value is NULL. |
xmog_java_class::xmog_java_class | ( | const char * | classNameUTF, |
const char * | version, | ||
const char * | config, | ||
bool | bDelayInit = false , |
||
XMOG_FACTORY_METHOD | factoryMethod = NULL_FACTORY_METHOD , |
||
XMOG_THROW_METHOD | throwMethod = NULL_THROW_METHOD , |
||
XMOG_TOJAVA_METHOD | toJavaMethod = NULL_TOJAVA_METHOD , |
||
XMOG_FROMJAVA_METHOD | fromJavaMethod = NULL_FROMJAVA_METHOD , |
||
xmog_localenv * | env = NULL |
||
) |
The constructor that creates an instance based on the classname and a named configuration.
This constructor can be used to easily create a wrapper instance that is associated with a named configuration (the named configuration would contain classpath information necessary to locate the type). The code generator will tpyically use this form of the constructor to associate a Java type with configuration information. Depending on the configuration mechanism you are using, this information might be used or not.
classNameUTF | the UTF representation of the classname. The classname should be provided in slash-separated (internal) format. |
version | the version number of the named configuration. |
config | the name of the named configuration. |
bDelayInit | true if the wrapper instance should immediately try to load the Java type, false if not. A generated framework typically uses delayed initialization to give the programmer a chance to control the time at which the JVM is loaded. The default value is false. |
factoryMethod | the method that returns a dynamically allocated instance of a proxy type based on an existing JNI reference. |
throwMethod | the method that throws an exception of a proxy type based on an existing JNI reference. |
toJavaMethod | the method that creates and initializes a Java object for a native object. |
fromJavaMethod | the method that creates and initializes a native object for a Java object. |
env | the local environment to use. The default value is NULL. |
xmog_java_class::xmog_java_class | ( | const char * | classNameUTF, |
jbyte * | bytes, | ||
jint | length, | ||
bool | bDelayInit = false , |
||
XMOG_FACTORY_METHOD | factoryMethod = NULL_FACTORY_METHOD , |
||
XMOG_THROW_METHOD | throwMethod = NULL_THROW_METHOD , |
||
XMOG_TOJAVA_METHOD | toJavaMethod = NULL_TOJAVA_METHOD , |
||
XMOG_FROMJAVA_METHOD | fromJavaMethod = NULL_FROMJAVA_METHOD , |
||
xmog_localenv * | env = NULL |
||
) |
The constructor that creates an instance based on class bytes.
This constructor can be used to easily create a wrapper instance that injects a Java type defined in native code into the JVM.
classNameUTF | the UTF representation of the classname. The classname should be provided in slash-separated (internal) format. |
bytes | the class bytes. |
length | the number of bytes that represent the type. |
bDelayInit | true if the wrapper instance should immediately try to load the Java type, false if not. A generated framework typically uses delayed initialization to give the programmer a chance to control the time at which the JVM is loaded. The default value is false. |
factoryMethod | the method that returns a dynamically allocated instance of a proxy type based on an existing JNI reference. |
throwMethod | the method that throws an exception of a proxy type based on an existing JNI reference. |
toJavaMethod | the method that creates and initializes a Java object for a native object. |
fromJavaMethod | the method that creates and initializes a native object for a Java object. |
env | the local environment to use. The default value is NULL. |
xmog_java_class::xmog_java_class | ( | const char * | classNameUTF, |
jbyte * | bytes, | ||
jint | length, | ||
jbyte * | stubBytes, | ||
jint | stubLength, | ||
jbyte * | skelBytes, | ||
jint | skelLength, | ||
bool | bDelayInit = false , |
||
XMOG_FACTORY_METHOD | factoryMethod = NULL_FACTORY_METHOD , |
||
XMOG_THROW_METHOD | throwMethod = NULL_THROW_METHOD , |
||
XMOG_TOJAVA_METHOD | toJavaMethod = NULL_TOJAVA_METHOD , |
||
XMOG_FROMJAVA_METHOD | fromJavaMethod = NULL_FROMJAVA_METHOD , |
||
xmog_localenv * | env = NULL |
||
) |
The constructor that creates an instance based on class bytes.
This constructor can be used to easily create a wrapper instance that injects a Java type defined in native code into the JVM.
classNameUTF | the UTF representation of the classname. The classname should be provided in slash-separated (internal) format. |
bytes | the class bytes. |
length | the number of bytes that represent the type. |
stubBytes | the class bytes of the RMI stub type. |
stubLength | the number of bytes that represent the RMI stub type. |
skelBytes | the RMI skeleton class bytes. |
skelLength | the number of bytes that represent the RMI skeleton type. |
bDelayInit | true if the wrapper instance should immediately try to load the Java type, false if not. A generated framework typically uses delayed initialization to give the programmer a chance to control the time at which the JVM is loaded. The default value is false. |
factoryMethod | the method that returns a dynamically allocated instance of a proxy type based on an existing JNI reference. |
throwMethod | the method that throws an exception of a proxy type based on an existing JNI reference. |
toJavaMethod | the method that creates and initializes a Java object for a native object. |
fromJavaMethod | the method that creates and initializes a native object for a Java object. |
env | the local environment to use. The default value is NULL. |
xmog_java_class::xmog_java_class | ( | jclass | _local, |
xmog_flags | _flags, | ||
const char * | classNameUTF = NULL , |
||
xmog_localenv * | env = NULL |
||
) |
The constructor that creates an instance based on an existing JNI reference.
This constructor can be used to easily create a wrapper instance that wraps around a JNI reference to a class.
_local | the JNI reference. This can be any type of reference but the _flags field needs to have the corresponding type bit set. |
_flags | the reference type information. |
classNameUTF | the UTF representation of the classname. The classname should be provided in slash-separated (internal) format. The default value is NULL, in which case the name will be calculated. |
env | the local environment to use. The default value is NULL. |
|
static |
Adds a proxy class to the proper list of classes.
Depending on the value of teh various factory methods, the class instance gets added to the list of types and possibly to the list of exception types.
clazz | the class to add. |
void xmog_java_class::add_field | ( | xmog_java_field * | _field | ) |
Adds a field to the list of fields that this instance is aware of.
This method does not perform any searches to prevent the insertion of duplicate entries. The developer is in charge of making sure that fields are not added more than once. Problems would arise if the same dynamically allocated instance were added more than once because the corresponding remove method will call delete() on the instance and any removal after the first one would cause memory corruption.
_field | the field wrapper instance to add. |
void xmog_java_class::add_method | ( | xmog_java_method * | _method | ) |
Adds a method to the list of methods that this instance is aware of.
This method does not perform any searches to prevent the insertion of duplicate entries. The developer is in charge of making sure that fields are not added more than once. Problems would arise if the same dynamically allocated instance were added more than once because the corresponding remove method will call delete() on the instance and any removal after the first one would cause memory corruption.
_method | the method wrapper instance to add. |
|
static |
Adds all jarfiles in the specified directory to the classpath used by the custom classloader.
This method only works for 1.2 or later JVMs because it relies on the post 1.1 classloader specification.
dirnameUTF | the name of the directory in which we look for jarfiles that will be added to the classpath. |
preferred | true if the classes in that classpath root should override classes. that might already be loaded by a parent classloader. The default value is false. |
env | the local environment to use. The default value is NULL. |
|
static |
Adds the embedded classes to the classpath used by the custom classloader.
This method only works for 1.2 or later JVMs because it relies on the post 1.1 classloader specification.
bytes | pointer to the beginning of the memory area that contains the embedded jarfile. |
len | the number of bytes in the embedded jarfile. |
preferred | true if the classes in that classpath root should override classes. that might already be loaded by a parent classloader. The default value is false. |
env | the local environment to use. The default value is NULL. |
|
static |
Adds a file to the classpath used by the custom classloader.
This method only works for 1.2 or later JVMs because it relies on the post 1.1 classloader specification.
filenameUTF | the full path of the directory or file that should be added to the classpath. |
preferred | true if the classes in that classpath root should override classes that might already be loaded by a parent classloader. The default value is false. |
env | the local environment to use. The default value is NULL . |
|
static |
Injects the custom classloader types into the JVM.
This method only works for 1.2 or later JVMs because it relies on the post 1.1 classloader specification.
env | the local environment to use. The default value is NULL. |
|
static |
A utility method for calculating the hashcode of a classname.
This method replaces periods in the name with slashes when calculating the hashcode. This removes a potential source of hashcode mismatches when internal and external classname representations are mixed up.
_classNameUTF | the classname for which we wish to calculate a hash. |
|
static |
Calls a Java method indirectly.
method | the method to call. |
instance | the instance pointer on which to call the method. May be NULL for static methods. |
values | the method arguments. |
env | the local call environment. |
|
static |
Calls a Java method indirectly.
method | the method to call. |
instance | the instance pointer on which to call the method. May be NULL for static methods. |
values | the method arguments. |
env | the local call environment. |
|
static |
Calls a Java method indirectly.
method | the method to call. |
instance | the instance pointer on which to call the method. May be NULL for static methods. |
values | the method arguments. |
env | the local call environment. |
|
static |
Calls a Java method indirectly.
method | the method to call. |
instance | the instance pointer on which to call the method. May be NULL for static methods. |
values | the method arguments. |
env | the local call environment. |
|
static |
Calls a Java method indirectly.
method | the method to call. |
instance | the instance pointer on which to call the method. May be NULL for static methods. |
values | the method arguments. |
env | the local call environment. |
|
static |
Calls a Java method indirectly.
method | the method to call. |
instance | the instance pointer on which to call the method. May be NULL for static methods. |
values | the method arguments. |
env | the local call environment. |
|
static |
Calls a Java method indirectly.
method | the method to call. |
instance | the instance pointer on which to call the method. May be NULL for static methods. |
values | the method arguments. |
env | the local call environment. |
|
static |
Calls a Java method indirectly.
method | the method to call. |
instance | the instance pointer on which to call the method. May be NULL for static methods. |
values | the method arguments. |
env | the local call environment. |
|
static |
Calls a Java method indirectly.
method | the method to call. |
instance | the instance pointer on which to call the method. May be NULL for static methods. |
values | the method arguments. |
env | the local call environment. |
|
static |
Calls a Java method indirectly.
method | the method to call. |
instance | the instance pointer on which to call the method. May be NULL for static methods. |
values | the method arguments. |
env | the local call environment. |
|
static |
Calls a Java method indirectly.
method | the method to call. |
instance | the instance pointer on which to call the method. May be NULL for static methods. |
values | the method arguments. |
env | the local call environment. |
jobject xmog_java_class::from | ( | const xmog_base & | srcInstance, |
xmog_flags | flags = xmog_base::GLOBAL , |
||
xmog_localenv * | env = NULL |
||
) |
Returns an object reference or null
if the given instance is incompatible with this class.
This method represents the heart of the casting mechanism in the framework. It takes one proxy instance as input and returns a proper reference if the original instance was type compatible.
srcInstance | the instance that we wish to "convert" to the type represented by this class. |
flags | the reference type of the target instance. The default value is GLOBAL . |
env | the local call environment to use. The default valus is NULL . |
|
static |
Returns the best matching xmog_java_class instance for the given throwable and that has a non-NULL exception factory method.
This method is used to find the best available proxy type for a given exception. We don't always have the exact exception type that was thrown in Java available as a C++ proxy type. Because of that, we want to throw the best matching exception, which means that we search for the most derived type in the exception type's inheritance hierarchy.
throwable | the exception that was thrown in Java. |
bRemote | true if the JVM is out-of-process, false otherwise. |
env | the local environment to use. The default value is NULL. |
|
static |
Returns the classloader used by the Codemesh framework. This method only works for 1.2 or later JVMs because it relies on the post 1.1 classloader specification.
env | the local environment to use. The default value is NULL. |
|
static |
Returns the xmog_java_class instance for the given name
that has a non-NULL instance factory method.
This method is used to find the proxy class for a Java class of a given name. Such a lookup is useful for scenarios where all we have is a Java classname and what we need is the proxy instance that provides
classNameUTF | the classname in slash form, for example java/lang/String . |
|
static |
Returns the exact xmog_java_class instance for the given name that has a non-NULL exception factory method.
This method is used to find the exact exception type by name and is useful because we can easily compare based on the hashvalue.
classNameUTF | the classname in slash form, for example java/lang/String . |
jint xmog_java_class::get_hashcode | ( | xmog_localenv * | env = NULL | ) |
Returns the instance's hashcode.
The hashcode is based on the classname.
env | the local environment pointer. The default value is NULL. |
jclass xmog_java_class::get_jclass | ( | xmog_localenv * | env, |
bool | bSuppressExceptions | ||
) |
Returns the internal JNI reference to the type.
env | the local environment pointer. |
bSuppressExceptions | passed to distinguish this method from the regular version of this method. |
jclass xmog_java_class::get_jclass | ( | xmog_localenv * | env = NULL | ) |
Returns the internal JNI reference to the type.
env | the local environment pointer. The default value is NULL. |
|
static |
Returns the classname of a given class instance.
clazz | the JNI class handle for which we want a classname. |
env | the local environment pointer. The default value is NULL. |
|
static |
Returns the classname of the given instance.
This is implemented internally by invoking getClass().getName() on the given object.
inst | the object in whose classname we;re interested. |
env | a local environment pointer. |
const char* xmog_java_class::getClassName | ( | xmog_localenv * | env = NULL | ) |
Returns the classname.
env | the local environment pointer. The default value is NULL. |
bool xmog_java_class::has_peer_unmarshaller | ( | ) | const |
Returns true
if the class has at least one peer unmarshaller registered.
Peer unmarshallers are registered using the xmog_peer::register_unmarshaller() method. Every peer unmarshaller is not just dependent on the Java type but also on the C++ type identifier.
void xmog_java_class::has_peer_unmarshaller | ( | bool | bHPU | ) |
Sets the flag that indicates that the class has at least one peer unmarshaller registered for it.
Peer unmarshallers are registered using the xmog_peer::register_unmarshaller() method. Every peer unmarshaller is not just dependent on the Java type but also on the C++ type identifier.
bHPU | true if the class has at least one peer unmarshaller. |
|
static |
Performs per-thread initialization in relation with the custom classloader.
This method only works for 1.2 or later JVMs because it relies on the post 1.1 classloader specification.
env | the local environment to use. The default value is NULL. |
|
static |
Removes a proxy class from the proper list of classes.
Depending on the value of teh various factory methods, the class instance gets removed from the list of types and possibly from the list of exception types.
clazz | the class to remove. |
void xmog_java_class::remove_field | ( | xmog_java_field * | _field | ) |
Removes a field from the list of field that this instance is aware of.
The developer is in charge of making sure that fields are not added more than once. Problems would arise if the same dynamically allocated instance were added more than once because the remove method will call delete() on the instance and any removal after the first one would cause memory corruption.
_field | the field wrapper instance to remove. |
void xmog_java_class::remove_method | ( | xmog_java_method * | _method | ) |
Removes a method from the list of methods that this instance is aware of.
The developer is in charge of making sure that fields are not added more than once. Problems would arise if the same dynamically allocated instance were added more than once because the remove method will call delete() on the instance and any removal after the first one would cause memory corruption.
_method | the method wrapper instance to remove. |
void xmog_java_class::setInterceptor | ( | XMOG_INTERCEPTOR | icp | ) |
Sets an API interceptor for the Java type represented by this instance.
API interceptors allow the overriding of proxy API invocations on a per-type basis. This allows you to customize the way a C++ proxy type interacts with its corresponding Java type. You could for example implement caching schemes using an interceptor or you could implement schemes that translate field accesses into method invocations.
icp | an interceptor that will handle certain kinds of accesses for this type. |