The .hh files created with the header file generator are all
included here as are the C functions implementing these methods.
- $Id: native.c 998 2004-03-30 21:59:27Z twisti $
+ $Id: native.c 1322 2004-07-17 12:29:18Z motse $
*/
#include "config.h"
#include "global.h"
+#include "options.h"
#include "jni.h"
#include "native.h"
-#include "nativetypes.hh"
#include "builtin.h"
#include "asmpart.h"
#include "tables.h"
#include "loader.h"
#include "jni.h"
-#include "toolbox/loging.h"
+#include "jit/jit.h"
+#include "toolbox/logging.h"
#include "toolbox/memory.h"
#include "threads/thread.h"
#include "threads/threadio.h"
#include "threads/threadio.h"
+/* include table of native functions */
+
+#include "nativetable.inc"
+
+
/* searchpath for classfiles */
char *classpath;
/* for java-string to char conversion */
#define MAXSTRINGSIZE 1000
+
/******************** systemclasses required for native methods ***************/
classinfo *class_java_lang_Class;
classinfo *class_java_lang_VMClass;
-/* static classinfo *class_java_lang_Cloneable=0; */ /* now in global.h */
classinfo *class_java_lang_System;
classinfo *class_java_lang_ClassLoader;
classinfo *class_gnu_java_lang_SystemClassLoader;
methodinfo *method_vmclass_init;
+/* system exception classes required in cacao */
+
+classinfo *class_java_lang_Throwable;
+classinfo *class_java_lang_Exception;
+classinfo *class_java_lang_Error;
+
+
+/* exception/error super class */
+
+char *string_java_lang_Throwable =
+ "java/lang/Throwable";
+
+char *string_java_lang_VMThrowable =
+ "java/lang/VMThrowable";
+
+
/* specify some exception strings for code generation */
char *string_java_lang_ArithmeticException =
char *string_java_lang_CloneNotSupportedException =
"java/lang/CloneNotSupportedException";
+char *string_java_lang_Exception =
+ "java/lang/Exception";
+
char *string_java_lang_IllegalArgumentException =
"java/lang/IllegalArgumentException";
+char *string_java_lang_IllegalMonitorStateException =
+ "java/lang/IllegalMonitorStateException";
+
char *string_java_lang_NegativeArraySizeException =
"java/lang/NegativeArraySizeException";
/* specify some error strings for code generation */
+char *string_java_lang_AbstractMethodError =
+ "java/lang/AbstractMethodError";
+
+char *string_java_lang_ClassCircularityError =
+ "java/lang/ClassCircularityError";
+
char *string_java_lang_ClassFormatError =
"java/lang/ClassFormatError";
+char *string_java_lang_Error =
+ "java/lang/Error";
+
+char *string_java_lang_ExceptionInInitializerError =
+ "java/lang/ExceptionInInitializerError";
+
+char *string_java_lang_IncompatibleClassChangeError =
+ "java/lang/IncompatibleClassChangeError";
+
+char *string_java_lang_InternalError =
+ "java/lang/InternalError";
+
char *string_java_lang_LinkageError =
"java/lang/LinkageError";
char *string_java_lang_OutOfMemoryError =
"java/lang/OutOfMemoryError";
+char *string_java_lang_VerifyError =
+ "java/lang/VerifyError";
+
+char *string_java_lang_VirtualMachineError =
+ "java/lang/VirtualMachineError";
+
/* the system classloader object */
struct java_lang_ClassLoader *SystemClassLoader = NULL;
void use_class_as_object(classinfo *c)
{
- vftbl *vt;
-/* vftbl *newtbl; */
-
- if (!class_java_lang_Class)
- class_java_lang_Class = class_new(utf_new_char ("java/lang/Class"));
-
- vt = class_java_lang_Class->vftbl;
-
-
if (!c->classvftbl) {
- c->classvftbl = true;
-
- /* copy_vftbl(&newtbl, vt);
- newtbl->class = c->header.vftbl->class;
- newtbl->baseval = c->header.vftbl->baseval;
- newtbl->diffval = c->header.vftbl->diffval;
- c->header.vftbl = newtbl;*/
-
c->header.vftbl = class_java_lang_Class->vftbl;
-
- if (!class_java_lang_VMClass) {
- loader_load_sysclass(&class_java_lang_VMClass,
- utf_new_char("java/lang/VMClass"));
-
- method_vmclass_init =
- class_findmethod(class_java_lang_VMClass,
- utf_new_char("<init>"),
- utf_new_char("(Lgnu/classpath/RawData;)V"));
-
- if (method_vmclass_init == 0) {
- class_showmethods(class_java_lang_VMClass);
- panic("Needed class initializer for VMClass could not be found");
- }
- }
- {
- java_objectheader *vmo = builtin_new(class_java_lang_VMClass);
-
- if (!vmo) panic("Error while creating instance of java/lang/VMClass");
- asm_calljavafunction(method_vmclass_init, vmo, c, NULL, NULL);
- c->vmClass = (java_lang_VMClass *) vmo;
- /*log_text("VMCLASS has been attached");*/
- }
- }
+ c->classvftbl = true;
+ }
+
}
#include "nat/GdkPixbufDecoder.c"
#include "nat/GtkScrollPanePeer.c"
#include "nat/GtkFileDialogPeer.c"
-#include "nat/GtkLabelPeer.c"
#endif
#undef JOWENN_DEBUG
#undef JOWENN_DEBUG1
-/* table for locating native methods */
-static struct nativeref {
- char *classname;
- char *methodname;
- char *descriptor;
- bool isstatic;
- functionptr func;
-} nativetable [] = {
-
-#include "nativetable.hh"
-
-};
-
-
#define NATIVETABLESIZE (sizeof(nativetable)/sizeof(struct nativeref))
/* table for fast string comparison */
-static struct nativecompref {
- utf *classname;
- utf *methodname;
- utf *descriptor;
- bool isstatic;
- functionptr func;
-} nativecomptable [NATIVETABLESIZE];
+static nativecompref nativecomptable[NATIVETABLESIZE];
/* string comparsion table initialized */
static bool nativecompdone = false;
/******************************************************************************/
/******************************************************************************/
-/*--------------- native method calls & classes used -------------------------*/
+/* init_system_exceptions *****************************************************
-void throw_exception_exit()
+ load, link and compile exceptions used in the system
+
+*******************************************************************************/
+
+void init_system_exceptions()
{
- java_lang_String *message;
+ /* java/lang/Throwable */
+
+ class_java_lang_Throwable =
+ class_new(utf_new_char(string_java_lang_Throwable));
+ class_load(class_java_lang_Throwable);
+ class_link(class_java_lang_Throwable);
+
+ /* java/lang/Exception */
+
+ class_java_lang_Exception =
+ class_new(utf_new_char(string_java_lang_Exception));
+ class_load(class_java_lang_Exception);
+ class_link(class_java_lang_Exception);
+
+ /* java/lang/Error */
+
+ class_java_lang_Error =
+ class_new(utf_new_char(string_java_lang_Error));
+ class_load(class_java_lang_Error);
+ class_link(class_java_lang_Error);
+}
+
+
+void compile_all_class_methods(classinfo *c)
+{
+ s4 i;
+
+ for (i = 0; i < c->methodscount; i++) {
+ (void) jit_compile(&(c->methods[i]));
+ }
+}
+
+
+static void throw_exception_exit_intern(bool doexit)
+{
+ java_objectheader *xptr;
+ classinfo *c;
+ methodinfo *pss;
if (*exceptionptr) {
- printf("Exception in thread \"main\" ");
- utf_display_classname((*exceptionptr)->vftbl->class->name);
+ xptr = *exceptionptr;
+
+ /* clear exception, because we are calling jit code again */
+ *exceptionptr = NULL;
+
+ c = xptr->vftbl->class;
- /* do we have a detail message? */
- message = ((java_lang_Throwable *) *exceptionptr)->detailMessage;
+ pss = class_resolveclassmethod(c,
+ utf_new_char("printStackTrace"),
+ utf_new_char("()V"),
+ class_java_lang_Object,
+ false);
- if (message) {
- printf(": ");
- utf_display(javastring_toutf(message, false));
+ /* print the stacktrace */
+ if (pss) {
+ asm_calljavafunction(pss, xptr, NULL, NULL, NULL);
+
+ /* this normally means, we are EXTREMLY out of memory, but may be
+ any other exception */
+ if (*exceptionptr) {
+ utf_fprint_classname(stderr, c->name);
+ fprintf(stderr, "\n");
+ }
+
+ } else {
+ utf_fprint_classname(stderr, c->name);
+ fprintf(stderr, ": printStackTrace()V not found!\n");
}
- printf("\n");
- fflush(stdout);
- /* clear exception, whatever... */
- *exceptionptr = NULL;
+ fflush(stderr);
/* good bye! */
- exit(1);
+ if (doexit) {
+ exit(1);
+ }
}
}
-java_objectheader *new_exception(char *classname)
+void throw_exception()
{
- classinfo *c = class_new(utf_new_char(classname));
+ throw_exception_exit_intern(false);
+}
+
+
+void throw_exception_exit()
+{
+ throw_exception_exit_intern(true);
+}
+
+
+void throw_main_exception()
+{
+ fprintf(stderr, "Exception in thread \"main\" ");
+ fflush(stderr);
+
+ throw_exception_exit_intern(false);
+}
+
+
+void throw_main_exception_exit()
+{
+ fprintf(stderr, "Exception in thread \"main\" ");
+ fflush(stderr);
+
+ throw_exception_exit_intern(true);
+}
+
+
+void throw_cacao_exception_exit(char *exception, char *message)
+{
+ s4 i;
+ char *tmp;
+ s4 len;
- if (!c->linked) {
- printf("Exception class %s not linked! You probably have not set your CLASSPATH properly.\n", classname);
- exit(1);
+ len = strlen(exception);
+ tmp = MNEW(char, len);
+ strncpy(tmp, exception, len);
+
+ /* convert to classname */
+
+ for (i = len - 1; i >= 0; i--) {
+ if (tmp[i] == '/') tmp[i] = '.';
}
- return native_new_and_init(c);
+ fprintf(stderr, "Exception in thread \"main\" %s", tmp);
+
+ MFREE(tmp, char, len);
+
+ if (strlen(message) > 0)
+ fprintf(stderr, ": %s", message);
+
+ fprintf(stderr, "\n");
+ fflush(stderr);
+
+ /* good bye! */
+ exit(1);
+}
+
+
+#define CREATENEW_EXCEPTION(ex) \
+ java_objectheader *newEx; \
+ java_objectheader *oldexception=*exceptionptr;\
+ *exceptionptr=0;\
+ newEx=ex;\
+ *exceptionptr=oldexception;\
+ return newEx;
+
+java_objectheader *new_exception(char *classname)
+{
+ classinfo *c = class_new(utf_new_char(classname));
+
+ CREATENEW_EXCEPTION(native_new_and_init(c));
}
java_objectheader *new_exception_message(char *classname, char *message)
{
classinfo *c = class_new(utf_new_char(classname));
- if (!c->linked) {
- printf("Exception class %s not linked! You probably have not set your CLASSPATH properly.\n", classname);
- exit(1);
- }
+ CREATENEW_EXCEPTION(native_new_and_init_string(c, javastring_new_char(message)));
+}
- return native_new_and_init_string(c, javastring_new_char(message));
+
+java_objectheader *new_exception_throwable(char *classname, java_lang_Throwable *throwable)
+{
+ classinfo *c = class_new(utf_new_char(classname));
+
+ CREATENEW_EXCEPTION(native_new_and_init_throwable(c, throwable));
}
{
classinfo *c = class_new(utf_new_char(classname));
- if (!c->linked) {
- printf("Exception class %s not linked! You probably have not set your CLASSPATH properly.\n", classname);
- exit(1);
- }
-
- return native_new_and_init_string(c, javastring_new(message));
+ CREATENEW_EXCEPTION(native_new_and_init_string(c, javastring_new(message)));
}
{
classinfo *c = class_new(utf_new_char(classname));
- if (!c->linked) {
- printf("Exception class %s not linked! You probably have not set your CLASSPATH properly.\n", classname);
- exit(1);
- }
-
- return native_new_and_init_string(c, message);
+ CREATENEW_EXCEPTION(native_new_and_init_string(c, message));
}
{
classinfo *c = class_new(utf_new_char(classname));
- if (!c->linked) {
- printf("Exception class %s not linked! You probably have not set your CLASSPATH properly.\n", classname);
- exit(1);
- }
-
- return native_new_and_init_int(c, i);
+ CREATENEW_EXCEPTION(native_new_and_init_int(c, i));
}
void native_loadclasses()
{
- static int classesLoaded=0; /*temporary hack JoWenn*/
- if (classesLoaded) return;
+ static int classesLoaded = 0; /*temporary hack JoWenn*/
+
+ if (classesLoaded)
+ return;
+
classesLoaded = 1;
- /*class_java_lang_System =*/
- (void) class_new(utf_new_char("java/lang/VMClass"));/*JoWenn*/
- (void) class_new(utf_new_char("java/lang/Class"));/*JoWenn*/
+ class_java_lang_Cloneable =
+ class_new(utf_new_char("java/lang/Cloneable"));
+ class_load(class_java_lang_Cloneable);
+ class_link(class_java_lang_Cloneable);
- /* class_new adds the class to the list of classes to be loaded */
- if (!class_java_lang_Cloneable)
- class_java_lang_Cloneable =
- class_new(utf_new_char("java/lang/Cloneable"));
+ class_java_lang_Class =
+ class_new(utf_new_char("java/lang/Class"));
+ class_load(class_java_lang_Class);
+ class_link(class_java_lang_Class);
- if (!class_java_lang_Class)
- class_java_lang_Class =
- class_new(utf_new_char("java/lang/Class"));
+ class_java_lang_VMClass =
+ class_new(utf_new_char("java/lang/VMClass"));
+ class_load(class_java_lang_VMClass);
+ class_link(class_java_lang_VMClass);
class_java_lang_ClassLoader =
- class_new(utf_new_char("java/lang/ClassLoader"));
+ class_new(utf_new_char("java/lang/ClassLoader"));
+ class_load(class_java_lang_ClassLoader);
+ class_link(class_java_lang_ClassLoader);
/* load classes for wrapping primitive types */
- class_java_lang_Double = class_new(utf_new_char("java/lang/Double"));
- class_init(class_java_lang_Double);
+ class_java_lang_Double = class_new(utf_new_char("java/lang/Double"));
+ class_load(class_java_lang_Double);
+ class_link(class_java_lang_Double);
+
+ class_java_lang_Float = class_new(utf_new_char("java/lang/Float"));
+ class_load(class_java_lang_Float);
+ class_link(class_java_lang_Float);
- class_java_lang_Float = class_new(utf_new_char("java/lang/Float"));
class_java_lang_Character = class_new(utf_new_char("java/lang/Character"));
- class_java_lang_Integer = class_new(utf_new_char("java/lang/Integer"));
- class_java_lang_Long = class_new(utf_new_char("java/lang/Long"));
- class_java_lang_Byte = class_new(utf_new_char("java/lang/Byte"));
- class_java_lang_Short = class_new(utf_new_char("java/lang/Short"));
- class_java_lang_Boolean = class_new(utf_new_char("java/lang/Boolean"));
- class_java_lang_Void = class_new(utf_new_char("java/lang/Void"));
+ class_load(class_java_lang_Character);
+ class_link(class_java_lang_Character);
- classesLoaded = 1;
-}
+ class_java_lang_Integer = class_new(utf_new_char("java/lang/Integer"));
+ class_load(class_java_lang_Integer);
+ class_link(class_java_lang_Integer);
+ class_java_lang_Long = class_new(utf_new_char("java/lang/Long"));
+ class_load(class_java_lang_Long);
+ class_link(class_java_lang_Long);
-/*************** adds a class to the vector of loaded classes ****************/
+ class_java_lang_Byte = class_new(utf_new_char("java/lang/Byte"));
+ class_load(class_java_lang_Byte);
+ class_link(class_java_lang_Byte);
-void systemclassloader_addclass(classinfo *c)
-{
- methodinfo *m;
+ class_java_lang_Short = class_new(utf_new_char("java/lang/Short"));
+ class_load(class_java_lang_Short);
+ class_link(class_java_lang_Short);
- /* find method addClass of java.lang.ClassLoader */
- m = class_resolvemethod(class_java_lang_ClassLoader,
- utf_new_char("addClass"),
- utf_new_char("(Ljava/lang/Class;)")
- );
-
- if (!m)
- panic("warning: cannot initialize classloader");
-
- /* prepare class to be passed as argument */
- use_class_as_object (c);
-
- /* call 'addClass' */
- asm_calljavafunction(m,
- (java_objectheader*) SystemClassLoader,
- (java_objectheader*) c,
- NULL,
- NULL
- );
-}
+ class_java_lang_Boolean = class_new(utf_new_char("java/lang/Boolean"));
+ class_load(class_java_lang_Boolean);
+ class_link(class_java_lang_Boolean);
+ class_java_lang_Void = class_new(utf_new_char("java/lang/Void"));
+ class_load(class_java_lang_Void);
+ class_link(class_java_lang_Void);
-/*************** adds a library to the vector of loaded libraries *************/
-
-void systemclassloader_addlibrary(java_objectheader *o)
-{
- log_text("systemclassloader_addlibrary");
}
}
-/********************* add loaded library name *******************************/
-
-void systemclassloader_addlibname(java_objectheader *o)
-{
- methodinfo *m;
- jfieldID id;
-
- m = class_resolvemethod(loader_load_sysclass(NULL, utf_new_char("java/util/Vector")),
- utf_new_char("addElement"),
- utf_new_char("(Ljava/lang/Object;)V"));
-
- if (!m) panic("cannot initialize classloader");
-
- id = envTable.GetStaticFieldID(&env,
- class_java_lang_ClassLoader,
- "loadedLibraryNames",
- "Ljava/util/Vector;");
-
- if (!id) panic("can not access ClassLoader");
-
- asm_calljavafunction(m,
- envTable.GetStaticObjectField(&env, class_java_lang_ClassLoader, id),
- o,
- NULL,
- NULL);
-}
-
-
/********************* function: native_setclasspath **************************/
void native_setclasspath(char *path)
MFREE(buffer, char, buffer_len);
- exit(1);
+/* exit(1); */
/* keep compiler happy */
return NULL;
*******************************************************************************/
-/* java_objectheader *javastring_new(utf *u) */
java_lang_String *javastring_new(utf *u)
{
char *utf_ptr = u->text; /* current utf character in utf string */
java_chararray *a;
s4 i;
-/* log_text("javastring_new");*/
-
- s = (java_lang_String*) builtin_new(class_java_lang_String);
+ s = (java_lang_String *) builtin_new(class_java_lang_String);
a = builtin_newarray_char(utflength);
/* javastring or character-array could not be created */
- if ((!a) || (!s))
+ if (!a || !s)
return NULL;
/* decompress utf-string */
s->offset = 0;
s->count = utflength;
-/* return (java_objectheader*) s; */
return s;
}
java_lang_String *s; /* result-string */
java_chararray *a;
- /*log_text("javastring_new_char");*/
s = (java_lang_String *) builtin_new(class_java_lang_String);
a = builtin_newarray_char(len);
/* javastring or character-array could not be created */
- if ((!a) || (!s))
+ if (!a || !s)
return NULL;
/* copy text */
s->offset = 0;
s->count = len;
-/* return (java_objectheader*) s; */
return s;
}
methodinfo *m;
java_objectheader *o;
- /* if c==NULL it is probebly because loader_load failed */
- if (!c) return *exceptionptr;
+ if (!c)
+ return *exceptionptr;
- o = builtin_new(c); /* create object */
+ o = builtin_new(c); /* create object */
- /*
- printf("native_new_and_init ");
- utf_display(c->name);
- printf("\n");
- */
- if (!o) return NULL;
- /* printf("o!=NULL\n"); */
+ if (!o)
+ return NULL;
+
/* find initializer */
m = class_findmethod(c,
utf_new_char("<init>"),
utf_new_char("()V"));
- if (!m) { /* initializer not found */
+ if (!m) { /* initializer not found */
if (verbose) {
char logtext[MAXLOGTEXT];
sprintf(logtext, "Warning: class has no instance-initializer: ");
- utf_sprint(logtext + strlen(logtext), c->name);
+ utf_sprint_classname(logtext + strlen(logtext), c->name);
log_text(logtext);
}
return o;
methodinfo *m;
java_objectheader *o;
- /* if c==NULL it is probebly because loader_load failed */
- if (!c) return *exceptionptr;
+ if (!c)
+ return *exceptionptr;
o = builtin_new(c); /* create object */
-
- if (!o) return NULL;
+
+ if (!o)
+ return NULL;
/* find initializer */
if (verbose) {
char logtext[MAXLOGTEXT];
sprintf(logtext, "Warning: class has no instance-initializer: ");
- utf_sprint(logtext + strlen(logtext), c->name);
+ utf_sprint_classname(logtext + strlen(logtext), c->name);
log_text(logtext);
}
return o;
methodinfo *m;
java_objectheader *o;
- /* if c == NULL it is probebly because loader_load failed */
- if (!c) return *exceptionptr;
+ if (!c)
+ return *exceptionptr;
o = builtin_new(c); /* create object */
if (verbose) {
char logtext[MAXLOGTEXT];
sprintf(logtext, "Warning: class has no instance-initializer: ");
- utf_sprint(logtext + strlen(logtext), c->name);
+ utf_sprint_classname(logtext + strlen(logtext), c->name);
log_text(logtext);
}
return o;
/* call initializer */
+#if defined(__I386__) || defined(__POWERPC__)
asm_calljavafunction(m, o, (void *) i, NULL, NULL);
+#else
+ asm_calljavafunction(m, o, (void *) (s8) i, NULL, NULL);
+#endif
+
+ return o;
+}
+
+
+java_objectheader *native_new_and_init_throwable(classinfo *c, java_lang_Throwable *t)
+{
+ methodinfo *m;
+ java_objectheader *o;
+
+ if (!c)
+ return *exceptionptr;
+
+ o = builtin_new(c); /* create object */
+
+ if (!o) return NULL;
+
+ /* find initializer */
+
+ m = class_findmethod(c,
+ utf_new_char("<init>"),
+ utf_new_char("(Ljava/lang/Throwable;)V"));
+
+ if (!m) { /* initializer not found */
+ if (verbose) {
+ char logtext[MAXLOGTEXT];
+ sprintf(logtext, "Warning: class has no instance-initializer: ");
+ utf_sprint_classname(logtext + strlen(logtext), c->name);
+ log_text(logtext);
+ }
+ return o;
+ }
+
+ /* call initializer */
+
+ asm_calljavafunction(m, o, t, NULL, NULL);
return o;
}
if (!js->header.vftbl)
/* vftbl of javastring is NULL */
- js->header.vftbl = class_java_lang_String -> vftbl;
+ js->header.vftbl = class_java_lang_String->vftbl;
if (!a->header.objheader.vftbl)
/* vftbl of character-array is NULL */
buflength = u2_utflength(unicode_pos, unicode_length);
buffer = MNEW(char, buflength);
- /* memory allocation failed */
- if (!buffer) {
- printf("length: %d\n",buflength);
- log_text("utf_new_u2:buffer==NULL");
- }
-
left = buflength;
pos = buffer;
literalstring *s; /* hashtable element */
java_lang_String *js; /* u2-array wrapped in javastring */
java_chararray *stringdata; /* copy of u2-array */
- u4 key;
- u4 slot;
+ classinfo *c;
+ u4 key;
+ u4 slot;
u2 i;
//#define DEBUG_LITERALSTRING_U2
stringdata->header.objheader.vftbl = primitivetype_table[ARRAYTYPE_CHAR].arrayvftbl;
stringdata->header.size = length;
+ /* if we use eager loading, we have to check loaded String class */
+ if (opt_eager) {
+ class_java_lang_String =
+ class_new_intern(utf_new_char("java/lang/String"));
+
+ if (!class_load(class_java_lang_String))
+ return NULL;
+
+ list_addfirst(&unlinkedclasses, class_java_lang_String);
+ }
+
/* create new javastring */
js = LNEW(java_lang_String);
- js->header.vftbl = class_java_lang_String->vftbl;
+ js->header.vftbl = class_java_lang_String->vftbl;
js->value = stringdata;
js->offset = 0;
js->count = length;
+#ifdef DEBUG_LITERALSTRING_U2
+ printf("literalstring_u2: newly created at %p\n", js);
+ utf_display(javastring_toutf(js, 0));
+ printf("\n\n");
+ fflush(stdout);
+#endif
+
/* create new literalstring */
s = NEW(literalstring);
s->hashlink = string_hash.ptr[slot];
s->string = (java_objectheader *) js;
string_hash.ptr[slot] = s;
- /* update numbe of hashtable entries */
+ /* update number of hashtable entries */
string_hash.entries++;
/* reorganization of hashtable */
the external chains is approx. 2 */
u4 i;
- literalstring *s;
+ literalstring *s;
hashtable newhash; /* the new hashtable */
/* create new hashtable, double the size */
string_hash = newhash;
}
-#ifdef DEBUG_LITERALSTRING_U2
- printf("literalstring_u2: newly created at %p\n", js);
- utf_display(javastring_toutf(js, 0));
- printf("\n\n");
- fflush(stdout);
-#endif
-
return (java_objectheader *) js;
}
u4 utflength = utf_strlen(u); /* length of utf-string if uncompressed */
java_chararray *a; /* u2-array constructed from utf string */
u4 i;
-/* log_text("literalstring_new"); */
-/* utf_display(u);*/
- /*if (utflength==0) while (1) sleep(60);*/
-/* log_text("------------------"); */
+
/* allocate memory */
a = lit_mem_alloc(sizeof(java_chararray) + sizeof(u2) * (utflength - 1) + 10);
java_lang_String *s = (java_lang_String *) sobj;
java_chararray *a = s->value;
- log_text("literalstring_free called");
-
/* dispose memory of java.lang.String object */
LFREE(s, java_lang_String);
}
-void copy_vftbl(vftbl **dest, vftbl *src)
+void copy_vftbl(vftbl_t **dest, vftbl_t *src)
{
*dest = src;
#if 0
goto next_type;
nomatch:
+ ;
}
/* no primitive type and no arrayclass, so must be object */
*pos++ = ';';
next_type:
+ ;
}
}
}
-/******************************************************************************************
+/* get_parametertypes **********************************************************
- use the descriptor of a method to generate a java/lang/Class array
- which contains the classes of the parametertypes of the method
+ use the descriptor of a method to generate a java/lang/Class array
+ which contains the classes of the parametertypes of the method
-*******************************************************************************************/
+*******************************************************************************/
java_objectarray* get_parametertypes(methodinfo *m)
{
utf_nextu2(&utf_ptr);
/* determine number of parameters */
- while ( *utf_ptr != ')' ) {
- get_type(&utf_ptr,desc_end,true);
- parametercount++;
+ while (*utf_ptr != ')') {
+ get_type(&utf_ptr, desc_end, true);
+ parametercount++;
}
/* create class-array */
result = builtin_anewarray(parametercount, class_java_lang_Class);
- utf_ptr = descr->text;
+ utf_ptr = descr->text;
utf_nextu2(&utf_ptr);
/* get returntype classes */
for (i = 0; i < parametercount; i++)
- result->data[i] = (java_objectheader *) get_type(&utf_ptr,desc_end, false);
+ result->data[i] =
+ (java_objectheader *) get_type(&utf_ptr, desc_end, false);
return result;
}
+/* get_exceptiontypes **********************************************************
+ get the exceptions which can be thrown by a method
-
-/******************************************************************************************
-
- get the exceptions which can be thrown by a method
-
-*******************************************************************************************/
+*******************************************************************************/
java_objectarray* get_exceptiontypes(methodinfo *m) {
u2 exccount=m->thrownexceptionscount;
/*--------------------------------------------------------*/
-java_objectarray *builtin_asm_createclasscontextarray(classinfo **end,classinfo **start) {
+java_objectarray *builtin_asm_createclasscontextarray(classinfo **end,classinfo **start)
+{
+#if defined(__GNUC__)
#warning platform dependend
+#endif
java_objectarray *tmpArray;
int i;
classinfo **current;
classinfo *c;
size_t size=(((size_t)start)-((size_t)end)) / sizeof (classinfo*);
-/* printf("end %p, start %p, size %ld\n",end,start,size);*/
+ /*printf("end %p, start %p, size %ld\n",end,start,size);*/
if (!class_java_lang_Class)
class_java_lang_Class = class_new(utf_new_char ("java/lang/Class"));
if (!class_java_lang_SecurityManager)
}
-java_lang_ClassLoader *builtin_asm_getclassloader(classinfo **end,classinfo **start) {
+java_lang_ClassLoader *builtin_asm_getclassloader(classinfo **end,classinfo **start)
+{
+#if defined(__GNUC__)
#warning platform dependend
+#endif
int i;
classinfo **current;
classinfo *c;