Codemesh Runtime v3 C++ API Reference  3.9.205
xmog_java_class.h
1 //
2 // Copyright (c) 1999-2020 by Codemesh, Inc.. ALL RIGHTS RESERVED.
3 //
4 
5 
6 #ifndef xmog_java_class_inc
7 #define xmog_java_class_inc
8 
9 
10 class xmog_localenv;
11 class xmog_java_field;
12 class xmog_java_method;
13 struct xmog_java_values;
14 
15 
16 #include "xmog_java_ref.h"
17 
18 
31 class XMOG_DECLSPEC xmog_java_class : public xmog_java_ref
32 {
33 public:
34 
46  typedef void (XMOG_CALLING_CONVENTION *XMOG_THROW_METHOD)( jobject exc, xmog_flags flags );
47 
53  static XMOG_THROW_METHOD NULL_THROW_METHOD;
54 
69  typedef xmog_java_ref * (XMOG_CALLING_CONVENTION *XMOG_FACTORY_METHOD)( jobject obj, xmog_flags src, xmog_flags dest, const char * classNameUTF, xmog_localenv * env );
70 
74  static XMOG_FACTORY_METHOD NULL_FACTORY_METHOD;
75 
93  typedef xmog_java_ref * (XMOG_CALLING_CONVENTION *XMOG_TOJAVA_METHOD)( xmog_java_ref * nobj, xmog_localenv * env );
94 
98  static XMOG_TOJAVA_METHOD NULL_TOJAVA_METHOD;
99 
113  typedef xmog_java_ref * (XMOG_CALLING_CONVENTION *XMOG_FROMJAVA_METHOD)( xmog_java_ref * jobj, xmog_localenv * env );
114 
118  static XMOG_FROMJAVA_METHOD NULL_FROMJAVA_METHOD;
119 
124  {
125  IcpDoneWithResult = 1,
126  IcpContinue = 0,
127  IcpError = -1
128  };
129 
134  {
135  IcpBefore = 0,
136  IcpAfter = 1
137  };
138 
143  {
144  IcpFieldGet = 0,
145  IcpFieldSet = 1,
146  IcpMethod = 2,
147  IcpCtor = 3,
148  IcpArrayCreate = 4,
149  IcpArrayGet = 5,
150  IcpArraySet = 6,
151  IcpStringFromNativeChars = 7,
152  IcpNativeCharsFromString = 8,
153  IcpIsNull = 9,
154  IcpIsInstanceOf = 10,
155  IcpSpecial = 16
156  };
157 
174  typedef xmog_interceptor_result (XMOG_CALLING_CONVENTION *XMOG_INTERCEPTOR)(
175  xmog_base * obj,
176  xmog_java_dynamic * dyn,
177  xmog_java_values * vals,
180  xmog_java_value * result,
181  xmog_localenv * env,
182  xmog_flags & flags );
183 
184 private:
185 
189  static jbyte MAXIMUM_SUPPORTED_MAJOR_VERSION;
190 
191  XMOG_FACTORY_METHOD factoryMethod_;
192 
193  XMOG_THROW_METHOD throwMethod_;
194 
195  XMOG_TOJAVA_METHOD toJavaMethod_;
196 
197  XMOG_FROMJAVA_METHOD fromJavaMethod_;
198 
199  char * classNameUTF_;
200 
201  char * version_;
202 
203  char * config_;
204 
205  jbyte * bytes_;
206 
207  jint length_;
208 
209  jbyte * stubBytes_;
210 
211  jint stubLength_;
212 
213  jbyte * skelBytes_;
214 
215  jint skelLength_;
216 
217  jint hash_code_;
218 
219  jint array_dim_;
220 
221  bool bDelayInit_;
222 
223  bool bOwnsClassName_;
224 
225  bool bIsException_;
226 
227  bool bInRemove_;
228 
229  bool bHasUnmarshaller_;
230 
231  xmog_java_field * fields_;
232 
233  xmog_java_method * methods_;
234 
235  xmog_java_class * array_class_;
236 
237  xmog_java_class * next_class_;
238 
239  xmog_java_class * next_throwable_;
240 
241  // the interceptor registered for the class
242  XMOG_INTERCEPTOR icp_;
243 
244  // the count of registered interceptors
245  static int ICP_COUNT;
246 
247  void initClassFromClassName( xmog_localenv * env = NULL, bool bSuppressExceptions = false );
248 
249  void initClassNameFromRef( xmog_localenv * env = NULL );
250 
251  jclass defineClass( const char * classNameUtf, jobject clToUse, const jbyte * bytes, jint length, xmog_localenv * env );
252 
253 public:
254 
258  xmog_java_class();
259 
280  xmog_java_class( const char * classNameUTF,
281  bool bDelayInit = false,
282  XMOG_FACTORY_METHOD factoryMethod = NULL_FACTORY_METHOD,
283  XMOG_THROW_METHOD throwMethod = NULL_THROW_METHOD,
284  XMOG_TOJAVA_METHOD toJavaMethod = NULL_TOJAVA_METHOD,
285  XMOG_FROMJAVA_METHOD fromJavaMethod = NULL_FROMJAVA_METHOD,
286  xmog_localenv * env = NULL );
287 
313  xmog_java_class( const char * classNameUTF,
314  const char * version,
315  const char * config,
316  bool bDelayInit = false,
317  XMOG_FACTORY_METHOD factoryMethod = NULL_FACTORY_METHOD,
318  XMOG_THROW_METHOD throwMethod = NULL_THROW_METHOD,
319  XMOG_TOJAVA_METHOD toJavaMethod = NULL_TOJAVA_METHOD,
320  XMOG_FROMJAVA_METHOD fromJavaMethod = NULL_FROMJAVA_METHOD,
321  xmog_localenv * env = NULL );
322 
345  xmog_java_class( const char * classNameUTF,
346  jbyte * bytes,
347  jint length,
348  bool bDelayInit = false,
349  XMOG_FACTORY_METHOD factoryMethod = NULL_FACTORY_METHOD,
350  XMOG_THROW_METHOD throwMethod = NULL_THROW_METHOD,
351  XMOG_TOJAVA_METHOD toJavaMethod = NULL_TOJAVA_METHOD,
352  XMOG_FROMJAVA_METHOD fromJavaMethod = NULL_FROMJAVA_METHOD,
353  xmog_localenv * env = NULL );
354 
381  xmog_java_class( const char * classNameUTF,
382  jbyte * bytes,
383  jint length,
384  jbyte * stubBytes,
385  jint stubLength,
386  jbyte * skelBytes,
387  jint skelLength,
388  bool bDelayInit = false,
389  XMOG_FACTORY_METHOD factoryMethod = NULL_FACTORY_METHOD,
390  XMOG_THROW_METHOD throwMethod = NULL_THROW_METHOD,
391  XMOG_TOJAVA_METHOD toJavaMethod = NULL_TOJAVA_METHOD,
392  XMOG_FROMJAVA_METHOD fromJavaMethod = NULL_FROMJAVA_METHOD,
393  xmog_localenv * env = NULL );
394 
409  xmog_java_class( jclass _local, xmog_flags _flags, const char * classNameUTF = NULL, xmog_localenv * env = NULL );
410 
415  void * operator new ( size_t );
416 
421  void operator delete( void * );
422 
423  virtual ~xmog_java_class();
424 
435  void has_peer_unmarshaller( bool bHPU );
436 
445  bool has_peer_unmarshaller() const;
446 
453  jint get_hashcode( xmog_localenv * env = NULL );
454 
460  jclass get_jclass( xmog_localenv * env = NULL );
461 
469  jclass get_jclass( xmog_localenv * env, bool bSuppressExceptions );
470 
474  const char * get_class_name() const;
475 
481  const char * getClassName( xmog_localenv * env = NULL );
482 
494  void add_field( xmog_java_field * _field );
495 
499  xmog_java_field * get_fields();
500 
511  void remove_field( xmog_java_field * _field );
512 
524  void add_method( xmog_java_method * _method );
525 
529  xmog_java_method * get_methods();
530 
541  void remove_method( xmog_java_method * _method );
542 
552  static jint calculate_hashcode( const char * _classNameUTF );
553 
560  static jobject get_bootstrap_classloader( xmog_localenv * env = NULL );
561 
570  static void bootstrap( xmog_localenv * env = NULL );
571 
579  static void initThread( xmog_localenv * env = NULL );
580 
589  static void add_class( xmog_java_class * clazz );
590 
599  static void remove_class( xmog_java_class * clazz );
600 
604  static xmog_java_class * get_classes();
605 
609  static xmog_java_class * get_throwables();
610 
624  void throw_( jthrowable throwable, xmog_flags flags, int error_code = 0, xmog_localenv * env = NULL );
625 
637  static char * getClassName( jobject inst, xmog_localenv * env = NULL );
638 
645  static char * getClassClassName( jclass clazz, xmog_localenv * env = NULL );
646 
656  static xmog_java_class * get_exact_throwable_for( const char * classNameUTF );
657 
672  static xmog_java_class * get_best_throwable_for( xmog_base * throwable, bool bRemote, xmog_localenv * env = NULL );
673 
684  static xmog_java_class * get_class_named( const char * classNameUTF );
685 
690  xmog_java_class * get_array_class();
691 
704  jobject from( const xmog_base & srcInstance, xmog_flags flags = xmog_base::GLOBAL, xmog_localenv * env = NULL );
705 
709  static jbyte calculateMaximumSupportedClassVersion();
710 
722  static void addLocalResourceRoot( const char * filenameUTF, bool preferred = false, xmog_localenv * env = NULL );
723 
735  static void addInMemoryResourceRoot( const jbyte * bytes, size_t len, bool preferred = false, xmog_localenv * env = NULL );
736 
748  static void addDirectoryJarFiles( const char * dirnameUTF, bool preferred = false, xmog_localenv * env = NULL );
749 
753  static void setSecurityManager( xmog_java_method & mSSM, const xmog_java_ref & sm, xmog_localenv * env );
754 
763  static bool call_bool_indirect( xmog_java_method * method, jobject instance, xmog_java_values * values, xmog_localenv * env );
764 
773  static jboolean call_boolean_indirect( xmog_java_method * method, jobject instance, xmog_java_values * values, xmog_localenv * env );
774 
783  static jbyte call_byte_indirect( xmog_java_method * method, jobject instance, xmog_java_values * values, xmog_localenv * env );
784 
793  static jchar call_char_indirect( xmog_java_method * method, jobject instance, xmog_java_values * values, xmog_localenv * env );
794 
803  static jdouble call_double_indirect( xmog_java_method * method, jobject instance, xmog_java_values * values, xmog_localenv * env );
804 
813  static jfloat call_float_indirect( xmog_java_method * method, jobject instance, xmog_java_values * values, xmog_localenv * env );
814 
823  static jint call_int_indirect( xmog_java_method * method, jobject instance, xmog_java_values * values, xmog_localenv * env );
824 
833  static jlong call_long_indirect( xmog_java_method * method, jobject instance, xmog_java_values * values, xmog_localenv * env );
834 
843  static jshort call_short_indirect( xmog_java_method * method, jobject instance, xmog_java_values * values, xmog_localenv * env );
844 
853  static jobject call_object_indirect( xmog_java_method * method, jobject instance, xmog_java_values * values, xmog_localenv * env );
854 
863  static void call_void_indirect( xmog_java_method * method, jobject instance, xmog_java_values * values, xmog_localenv * env );
864 
868  static xmog_java_method & getClass_method();
869 
873  static xmog_java_method & isInstance_method();
874 
887  void setInterceptor( XMOG_INTERCEPTOR icp );
888 
890  void setOwnsClassName();
891 
895  xmog_java_class::XMOG_INTERCEPTOR getInterceptor() const;
896 
900  static int getInterceptorCount();
901 };
902 
903 
904 #if !defined (XMOG_LACKS_INLINE_FUNCTIONS)
905 # include "xmog_java_class.inl"
906 #endif
907 
908 
909 
910 #endif /* xmog_java_class_inc */
xmog_java_class::xmog_interceptor_when
xmog_interceptor_when
A value used to signal the interceptor call reason.
Definition: xmog_java_class.h:133
xmog_base::flags
flags
The possible flag values.
Definition: xmog_base.h:383
xmog_java_values
A helper type used to convey Java arguments around inside the framework.
Definition: xmog_java_value.h:105
xmog_java_class::xmog_interceptor_result
xmog_interceptor_result
A value used to signal further interceptor processing requirements.
Definition: xmog_java_class.h:123
xmog_java_dynamic
The baseclass for types that dynamically derive the value of Java proxy items.
Definition: xmog_java_dynamic.h:28
xmog_java_field
A class implementing the xmog_java_dynamic interface for accessing Java fields via JNI or Codemesh's ...
Definition: xmog_java_field.h:36
xmog_java_class::NULL_TOJAVA_METHOD
static XMOG_TOJAVA_METHOD NULL_TOJAVA_METHOD
An instance that can be used in places where no to-Java specialization is required.
Definition: xmog_java_class.h:98
xmog_java_class::XMOG_INTERCEPTOR
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.
Definition: xmog_java_class.h:174
xmog_java_class::XMOG_FROMJAVA_METHOD
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 th...
Definition: xmog_java_class.h:113
xmog_java_class::NULL_THROW_METHOD
static XMOG_THROW_METHOD NULL_THROW_METHOD
An instance that can be used in places where no exception factory is required.
Definition: xmog_java_class.h:53
xmog_java_method
A class implementing the xmog_java_dynamic interface for accessing Java methods via JNI or Codemesh's...
Definition: xmog_java_method.h:38
xmog_java_class::NULL_FACTORY_METHOD
static XMOG_FACTORY_METHOD NULL_FACTORY_METHOD
An instance that can be used in places where no instance factory is required.
Definition: xmog_java_class.h:74
xmog_base
The baseclass for all proxy types in the framework.
Definition: xmog_base.h:29
xmog_java_class::xmog_interceptor_what
xmog_interceptor_what
A value used to signal the interceptor type.
Definition: xmog_java_class.h:142
xmog_localenv
A class representing per-thread information for the integration runtime.
Definition: xmog_localenv.h:32
xmog_java_ref
The wrapper base type representing C++ proxy instances for Java objects.
Definition: xmog_java_ref.h:19
xmog_java_class::XMOG_TOJAVA_METHOD
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 ...
Definition: xmog_java_class.h:93
xmog_java_class::NULL_FROMJAVA_METHOD
static XMOG_FROMJAVA_METHOD NULL_FROMJAVA_METHOD
An instance that can be used in places where no from-Java specialization is required.
Definition: xmog_java_class.h:118
xmog_java_class
A C++ wrapper for Java types.
Definition: xmog_java_class.h:31
xmog_java_class::XMOG_FACTORY_METHOD
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 o...
Definition: xmog_java_class.h:69

Copyright (c) 1999-2020 by Codemesh, Inc., ALL RIGHTS RESERVED.