ClassDescriptor cd=md.getClassDesc();
generateHeader(fm, md, outmethod);
int startindex=0;
-
+ outmethod.println("JNIPUSHFRAME();");
if (md.getModifiers().isStatic()) {
outmethod.println("jobject rec=JNIWRAP(((void **)(((char *) &(global_defs_p->classobjs->___length___))+sizeof(int)))[" + cd.getId() + "]);");
} else {
if (md.getReturnType()!=null) {
if (md.getReturnType().isPtr()) {
outmethod.println("struct ___Object___ * retobj=JNIUNWRAP(retval);");
- outmethod.println("JNIclearstack();");
+ outmethod.println("JNIPOPFRAME();");
outmethod.println("return retobj;");
} else {
- outmethod.println("JNIclearstack();");
+ outmethod.println("JNIPOPFRAME();");
outmethod.println("return retval;");
}
}
#ifdef THREADS
struct lockvector * lvector;
#endif
+#ifdef JNI
+ struct jnireferences ** jnirefs;
+#endif
#ifdef STM
unsigned int tc_size;
cliststruct_t **tc_structs;
char *fieldname;
};
+struct _jobject {
+ void * ref;
+};
+
+#define MAXJNIREFS 2048
+struct jnireferences {
+ struct jnireferences * next;
+ int index
+ struct _jobject array[MAXJNIREFS];
+};
+
+#ifndef MAC
+struct _jobject * getwrapped(void * objptr);
+void jnipushframe();
+void jnipopframe();
+
+extern __thread struct jnireferences * jnirefs;
+#define JNIUNWRAP(x) ((x==NULL)?NULL:x->ref)
+#define JNIWRAP(x) getwrapper(x);
+#define JNIPUSHFRAME() jnipushframe();
+#define JNIPOPFRAME() jnipopframe();
+#endif
+
jint RC_GetVersion(JNIEnv *);
jclass RC_DefineClass(JNIEnv * env, const char * c, jobject loader, const jbyte * buf, jsize bufLen);
jclass RC_FindClass(JNIEnv * env, const char *classname);
#include<jni.h>
#include<jni-private.h>
+#ifndef MAC
+struct _jobject * getwrapped(void * objptr) {
+ if ((jnirefs->index)>=MAXJNIREFS)
+ printf("OVERFLOW IN JOBJECT\n");
+ struct _jobject *ptr=&jnirefs->array[jnirefs->index++];
+ ptr->ref=objptr;
+ return ptr;
+}
+
+void jnipushframe() {
+ struct jnireferences *ptr=calloc(1, sizeof(struct jnireferences));
+ ptr->next=jnirefs;
+ jnirefs=ptr;
+}
+
+void jnipopframe() {
+ struct jnireferences *ptr=jnirefs;
+ jnirefs=ptr->next;
+ free(ptr);
+}
+#endif
+
jint RC_GetVersion(JNIEnv * env) {
return JNI_VERSION_1_1;
}