1 /* src/cacaoh/dummy.c - dummy functions for cacaoh
3 Copyright (C) 2007 R. Grafl, A. Krall, C. Kruegel,
4 C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
5 E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
6 J. Wenninger, Institut f. Computersprachen - TU Wien
8 This file is part of CACAO.
10 This program is free software; you can redistribute it and/or
11 modify it under the terms of the GNU General Public License as
12 published by the Free Software Foundation; either version 2, or (at
13 your option) any later version.
15 This program is distributed in the hope that it will be useful, but
16 WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
25 $Id: headers.c 6286 2007-01-10 10:03:38Z twisti $
37 #if defined(ENABLE_THREADS)
41 #include "toolbox/logging.h"
45 #include "vm/global.h"
48 #include "vmcore/class.h"
49 #include "vmcore/method.h"
50 #include "vmcore/utf8.h"
51 #include "vmcore/classcache.h"
52 #include "vmcore/loader.h"
55 /* global variables ***********************************************************/
57 char *_Jv_bootclasspath;
60 java_objectheader *javastring_new_slash_to_dot(utf *u)
62 vm_abort("javastring_new_slash_to_dot");
68 /* access *********************************************************************/
70 bool access_is_accessible_class(classinfo *referer, classinfo *cls)
75 bool access_is_accessible_member(classinfo *referer, classinfo *declarer,
78 vm_abort("access_is_accessible_member");
84 /* asm ************************************************************************/
86 void asm_abstractmethoderror(void)
91 void intrp_asm_abstractmethoderror(void)
96 void asm_getclassvalues_atomic(vftbl_t *super, vftbl_t *sub, castinfo *out)
101 void intrp_asm_getclassvalues_atomic(vftbl_t *super, vftbl_t *sub, castinfo *out)
107 /* builtin ********************************************************************/
109 java_objectheader *builtin_clone(void *env, java_objectheader *o)
116 s4 builtin_isanysubclass(classinfo *sub, classinfo *super)
123 java_objectheader *builtin_new(classinfo *c)
130 java_objectarray *builtin_anewarray(s4 size, classinfo *componentclass)
138 /* code ***********************************************************************/
140 void code_free_code_of_method(methodinfo *m)
145 methodinfo *code_get_methodinfo_for_pv(u1 *pv)
151 /* codegen ********************************************************************/
153 u1 *codegen_generate_stub_compiler(methodinfo *m)
158 codeinfo *codegen_generate_stub_native(methodinfo *m, functionptr f)
163 #if defined(ENABLE_INTRP)
164 u1 *intrp_createcompilerstub(methodinfo *m)
170 void removecompilerstub(u1 *stub)
174 void removenativestub(u1 *stub)
179 /* exceptions *****************************************************************/
181 void exceptions_clear_exception(void)
185 void exceptions_print_current_exception(void)
190 void exceptions_throw_abstractmethoderror(void)
192 fprintf(stderr, "java.lang.AbstractMethodError\n");
197 void exceptions_throw_classcircularityerror(classinfo *c)
199 fprintf(stderr, "java.lang.ClassCircularityError: ");
201 utf_display_printable_ascii(c->name);
207 void exceptions_throw_classformaterror(classinfo *c, const char *message, ...)
211 fprintf(stderr, "java.lang.ClassFormatError: ");
213 utf_display_printable_ascii(c->name);
214 fprintf(stderr, ": ");
216 va_start(ap, message);
217 vfprintf(stderr, message, ap);
225 void exceptions_throw_incompatibleclasschangeerror(classinfo *c)
227 fprintf(stderr, "java.lang.IncompatibleClassChangeError: ");
230 utf_fprint_printable_ascii_classname(stderr, c->name);
237 void exceptions_throw_internalerror(const char *message, ...)
241 fprintf(stderr, "java.lang.InternalError: ");
243 va_start(ap, message);
244 vfprintf(stderr, message, ap);
250 void exceptions_throw_linkageerror(const char *message, classinfo *c)
252 fprintf(stderr, "java.lang.LinkageError: %s", message);
255 utf_fprint_printable_ascii_classname(stderr, c->name);
262 void exceptions_throw_noclassdeffounderror(utf *name)
264 fprintf(stderr, "java.lang.NoClassDefFoundError: ");
265 utf_fprint_printable_ascii(stderr, name);
271 void exceptions_throw_noclassdeffounderror_wrong_name(classinfo *c, utf *name)
273 fprintf(stderr, "java.lang.NoClassDefFoundError: ");
274 utf_fprint_printable_ascii(stderr, c->name);
275 fprintf(stderr, " (wrong name: ");
276 utf_fprint_printable_ascii(stderr, name);
277 fprintf(stderr, ")\n");
282 void exceptions_throw_verifyerror(methodinfo *m, const char *message)
284 fprintf(stderr, "java.lang.VerifyError: ");
285 utf_fprint_printable_ascii(stderr, m->name);
286 fprintf(stderr, ": %s", message);
291 void exceptions_throw_nosuchfielderror(classinfo *c, utf *name)
293 fprintf(stderr, "java.lang.NoSuchFieldError: ");
294 utf_fprint_printable_ascii(stderr, c->name);
295 fprintf(stderr, ".");
296 utf_fprint_printable_ascii(stderr, name);
302 void exceptions_throw_nosuchmethoderror(classinfo *c, utf *name, utf *desc)
304 fprintf(stderr, "java.lang.NoSuchMethodError: ");
305 utf_fprint_printable_ascii(stderr, c->name);
306 fprintf(stderr, ".");
307 utf_fprint_printable_ascii(stderr, name);
308 utf_fprint_printable_ascii(stderr, desc);
314 void exceptions_throw_unsupportedclassversionerror(classinfo *c,
315 const char *message, ...)
319 fprintf(stderr, "java.lang.UnsupportedClassVersionError: " );
321 utf_display_printable_ascii(c->name);
322 fprintf(stderr, ": ");
324 va_start(ap, message);
325 vfprintf(stderr, message, ap);
333 void exceptions_throw_nullpointerexception(void)
335 fprintf(stderr, "java.lang.NullPointerException\n");
340 void classnotfoundexception_to_noclassdeffounderror(void)
342 /* Can that one happen? */
348 /* finalizer ******************************************************************/
350 void finalizer_notify(void)
352 vm_abort("finalizer_notify");
355 void finalizer_run(void *o, void *p)
357 vm_abort("finalizer_run");
361 /* gc *************************************************************************/
363 s8 gc_get_heap_size(void)
368 s8 gc_get_free_bytes(void)
373 s8 gc_get_total_bytes(void)
378 s8 gc_get_max_heap_size(void)
384 /* heap ***********************************************************************/
386 void *heap_alloc_uncollectable(u4 bytelength)
388 return calloc(bytelength, 1);
391 s4 heap_get_hashcode(java_objectheader *o)
397 /* jit ************************************************************************/
399 void jit_invalidate_code(methodinfo *m)
401 vm_abort("jit_invalidate_code");
405 /* lock ***********************************************************************/
407 void lock_init_object_lock(java_objectheader *o)
411 bool lock_monitor_enter(java_objectheader *o)
416 bool lock_monitor_exit(java_objectheader *o)
422 /* md *************************************************************************/
424 void md_param_alloc(methoddesc *md)
429 /* memory *********************************************************************/
431 void *mem_alloc(s4 size)
433 /* real implementation in src/mm/memory.c clears memory */
435 return calloc(size, 1);
438 void *mem_realloc(void *src, s4 len1, s4 len2)
440 return realloc(src, len2);
443 void mem_free(void *m, s4 size)
448 void *dump_alloc(s4 size)
453 void dump_release(s4 size)
463 /* properties *****************************************************************/
465 char *properties_get(char *key)
471 /* resolve ********************************************************************/
473 bool resolve_class_from_typedesc(typedesc *d, bool checkaccess, bool link, classinfo **result)
480 /* stupid resolving implementation used by resolve_classref_or_classinfo_eager */
481 /* This function does eager resolving without any access checks. */
483 static classinfo * dummy_resolve_class_from_name(classinfo *referer,
487 classinfo *cls = NULL;
494 /* lookup if this class has already been loaded */
496 cls = classcache_lookup(referer->classloader, classname);
499 /* resolve array types */
501 if (classname->text[0] == '[') {
502 utf_ptr = classname->text + 1;
503 len = classname->blength - 1;
505 /* classname is an array type name */
513 /* the component type is a reference type */
514 /* resolve the component type */
515 if ((cls = dummy_resolve_class_from_name(referer,
516 utf_new(utf_ptr,len),
517 checkaccess)) == NULL)
518 return NULL; /* exception */
520 /* create the array class */
521 cls = class_array_of(cls,false);
523 return NULL; /* exception */
529 if (!(cls = load_class_from_classloader(classname,
530 referer->classloader)))
531 return false; /* exception */
535 /* the class is now loaded */
537 assert(cls->state & CLASS_LOADED);
543 classinfo * resolve_classref_or_classinfo_eager(classref_or_classinfo cls,
550 if (IS_CLASSREF(cls)) {
551 /* we must resolve this reference */
553 if ((c = dummy_resolve_class_from_name(cls.ref->referer, cls.ref->name,
554 checkaccess)) == NULL)
558 /* cls has already been resolved */
563 assert(c->state & CLASS_LOADED);
570 /* stacktrace *****************************************************************/
572 java_objectarray *stacktrace_getClassContext()
578 /* threads ********************************************************************/
580 pthread_key_t threads_current_threadobject_key;
582 ptrint threads_get_current_tid(void)
587 void threads_cast_stopworld(void)
591 void threads_cast_startworld(void)
596 /* vm *************************************************************************/
598 void vm_abort(const char *text, ...)
602 /* print the log message */
605 vfprintf(stderr, text, ap);
608 /* now abort the VM */
613 java_objectheader *vm_call_method(methodinfo *m, java_objectheader *o, ...)
621 void stringtable_update(void)
623 log_println("stringtable_update: REMOVE ME!");
626 java_objectheader *literalstring_new(utf *u)
628 log_println("literalstring_new: REMOVE ME!");
634 void print_dynamic_super_statistics(void)
640 * These are local overrides for various environment variables in Emacs.
641 * Please do not remove this and leave it at the end of the file, where
642 * Emacs will automagically detect them.
643 * ---------------------------------------------------------------------
646 * indent-tabs-mode: t
650 * vim:noexpandtab:sw=4:ts=4: