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;
64 void compiler_unlock()
68 java_objectheader *javastring_new_slash_to_dot(utf *u)
70 vm_abort("javastring_new_slash_to_dot");
76 /* access *********************************************************************/
78 bool access_is_accessible_class(classinfo *referer, classinfo *cls)
83 bool access_is_accessible_member(classinfo *referer, classinfo *declarer,
86 vm_abort("access_is_accessible_member");
92 /* asm ************************************************************************/
94 void asm_abstractmethoderror(void)
99 void intrp_asm_abstractmethoderror(void)
104 void asm_getclassvalues_atomic(vftbl_t *super, vftbl_t *sub, castinfo *out)
109 void intrp_asm_getclassvalues_atomic(vftbl_t *super, vftbl_t *sub, castinfo *out)
115 /* builtin ********************************************************************/
117 java_objectheader *builtin_clone(void *env, java_objectheader *o)
124 s4 builtin_isanysubclass(classinfo *sub, classinfo *super)
131 java_objectheader *builtin_new(classinfo *c)
138 java_objectarray *builtin_anewarray(s4 size, classinfo *componentclass)
146 /* code ***********************************************************************/
148 void code_free_code_of_method(methodinfo *m)
153 methodinfo *code_get_methodinfo_for_pv(u1 *pv)
159 /* codegen ********************************************************************/
161 codeinfo *codegen_createnativestub(functionptr f, methodinfo *m)
166 u1 *createcompilerstub(methodinfo *m)
171 #if defined(ENABLE_INTRP)
172 u1 *intrp_createcompilerstub(methodinfo *m)
178 void removecompilerstub(u1 *stub)
182 void removenativestub(u1 *stub)
187 /* exceptions *****************************************************************/
189 void exceptions_clear_exception(void)
193 void exceptions_print_current_exception(void)
197 void exceptions_throw_abstractmethoderror(void)
199 fprintf(stderr, "java.lang.AbstractMethodError\n");
204 void exceptions_throw_classcircularityerror(classinfo *c)
206 fprintf(stderr, "java.lang.ClassCircularityError: ");
208 utf_display_printable_ascii(c->name);
214 void exceptions_throw_classformaterror(classinfo *c, const char *message, ...)
218 fprintf(stderr, "java.lang.ClassFormatError: ");
220 utf_display_printable_ascii(c->name);
221 fprintf(stderr, ": ");
223 va_start(ap, message);
224 vfprintf(stderr, message, ap);
232 void exceptions_throw_incompatibleclasschangeerror(classinfo *c)
234 fprintf(stderr, "java.lang.IncompatibleClassChangeError: ");
237 utf_fprint_printable_ascii_classname(stderr, c->name);
244 void exceptions_throw_internalerror(const char *message, ...)
248 fprintf(stderr, "java.lang.InternalError: ");
250 va_start(ap, message);
251 vfprintf(stderr, message, ap);
257 void exceptions_throw_linkageerror(const char *message, classinfo *c)
259 fprintf(stderr, "java.lang.LinkageError: %s", message);
262 utf_fprint_printable_ascii_classname(stderr, c->name);
269 void exceptions_throw_noclassdeffounderror(utf *name)
271 fprintf(stderr, "java.lang.NoClassDefFoundError: ");
272 utf_fprint_printable_ascii(stderr, name);
278 void exceptions_throw_noclassdeffounderror_wrong_name(classinfo *c, utf *name)
280 fprintf(stderr, "java.lang.NoClassDefFoundError: ");
281 utf_fprint_printable_ascii(stderr, c->name);
282 fprintf(stderr, " (wrong name: ");
283 utf_fprint_printable_ascii(stderr, name);
284 fprintf(stderr, ")\n");
289 void exceptions_throw_outofmemoryerror(void)
291 fprintf(stderr, "java.lang.OutOfMemoryError\n");
296 void exceptions_throw_verifyerror(methodinfo *m, const char *message)
298 fprintf(stderr, "java.lang.VerifyError: ");
299 utf_fprint_printable_ascii(stderr, m->name);
300 fprintf(stderr, ": %s", message);
305 void exceptions_throw_nosuchfielderror(classinfo *c, utf *name)
307 fprintf(stderr, "java.lang.NoSuchFieldError: ");
308 utf_fprint_printable_ascii(stderr, c->name);
309 fprintf(stderr, ".");
310 utf_fprint_printable_ascii(stderr, name);
316 void exceptions_throw_nosuchmethoderror(classinfo *c, utf *name, utf *desc)
318 fprintf(stderr, "java.lang.NoSuchMethodError: ");
319 utf_fprint_printable_ascii(stderr, c->name);
320 fprintf(stderr, ".");
321 utf_fprint_printable_ascii(stderr, name);
322 utf_fprint_printable_ascii(stderr, desc);
328 void exceptions_throw_unsupportedclassversionerror(classinfo *c,
329 const char *message, ...)
333 fprintf(stderr, "java.lang.UnsupportedClassVersionError: " );
335 utf_display_printable_ascii(c->name);
336 fprintf(stderr, ": ");
338 va_start(ap, message);
339 vfprintf(stderr, message, ap);
347 void exceptions_throw_illegalaccessexception(classinfo *c)
349 fprintf(stderr, "java.lang.IllegalAccessException: ");
352 utf_fprint_printable_ascii_classname(stderr, c->name);
359 void exceptions_throw_nullpointerexception(void)
361 fprintf(stderr, "java.lang.NullPointerException\n");
366 void classnotfoundexception_to_noclassdeffounderror(void)
368 /* Can that one happen? */
374 /* finalizer ******************************************************************/
376 void finalizer_notify(void)
378 vm_abort("finalizer_notify");
381 void finalizer_run(void *o, void *p)
383 vm_abort("finalizer_run");
387 /* gc *************************************************************************/
389 s8 gc_get_heap_size(void)
394 s8 gc_get_free_bytes(void)
399 s8 gc_get_total_bytes(void)
404 s8 gc_get_max_heap_size(void)
410 /* heap ***********************************************************************/
412 void *heap_alloc_uncollectable(u4 bytelength)
414 return calloc(bytelength, 1);
417 s4 heap_get_hashcode(java_objectheader *o)
423 /* jit ************************************************************************/
425 void jit_invalidate_code(methodinfo *m)
427 vm_abort("jit_invalidate_code");
431 /* lock ***********************************************************************/
433 void lock_init_object_lock(java_objectheader *o)
437 bool lock_monitor_enter(java_objectheader *o)
442 bool lock_monitor_exit(java_objectheader *o)
448 /* md *************************************************************************/
450 void md_param_alloc(methoddesc *md)
455 /* memory *********************************************************************/
457 void *mem_alloc(s4 size)
459 /* real implementation in src/mm/memory.c clears memory */
461 return calloc(size, 1);
464 void *mem_realloc(void *src, s4 len1, s4 len2)
466 return realloc(src, len2);
469 void mem_free(void *m, s4 size)
474 void *dump_alloc(s4 size)
479 void dump_release(s4 size)
489 /* properties *****************************************************************/
491 char *properties_get(char *key)
497 /* resolve ********************************************************************/
499 bool resolve_class_from_typedesc(typedesc *d, bool checkaccess, bool link, classinfo **result)
506 /* stupid resolving implementation used by resolve_classref_or_classinfo_eager */
507 /* This function does eager resolving without any access checks. */
509 static classinfo * dummy_resolve_class_from_name(classinfo *referer,
513 classinfo *cls = NULL;
520 /* lookup if this class has already been loaded */
522 cls = classcache_lookup(referer->classloader, classname);
525 /* resolve array types */
527 if (classname->text[0] == '[') {
528 utf_ptr = classname->text + 1;
529 len = classname->blength - 1;
531 /* classname is an array type name */
539 /* the component type is a reference type */
540 /* resolve the component type */
541 if ((cls = dummy_resolve_class_from_name(referer,
542 utf_new(utf_ptr,len),
543 checkaccess)) == NULL)
544 return NULL; /* exception */
546 /* create the array class */
547 cls = class_array_of(cls,false);
549 return NULL; /* exception */
555 if (!(cls = load_class_from_classloader(classname,
556 referer->classloader)))
557 return false; /* exception */
561 /* the class is now loaded */
563 assert(cls->state & CLASS_LOADED);
569 classinfo * resolve_classref_or_classinfo_eager(classref_or_classinfo cls,
576 if (IS_CLASSREF(cls)) {
577 /* we must resolve this reference */
579 if ((c = dummy_resolve_class_from_name(cls.ref->referer, cls.ref->name,
580 checkaccess)) == NULL)
584 /* cls has already been resolved */
589 assert(c->state & CLASS_LOADED);
596 /* stacktrace *****************************************************************/
598 java_objectarray *stacktrace_getClassContext()
604 /* threads ********************************************************************/
606 pthread_key_t threads_current_threadobject_key;
608 ptrint threads_get_current_tid(void)
614 /* vm *************************************************************************/
616 void vm_abort(const char *text, ...)
620 /* print the log message */
623 vfprintf(stderr, text, ap);
626 /* now abort the VM */
631 java_objectheader *vm_call_method(methodinfo *m, java_objectheader *o, ...)
639 void stringtable_update(void)
641 log_println("stringtable_update: REMOVE ME!");
644 java_objectheader *literalstring_new(utf *u)
646 log_println("literalstring_new: REMOVE ME!");
652 void print_dynamic_super_statistics(void)
658 * These are local overrides for various environment variables in Emacs.
659 * Please do not remove this and leave it at the end of the file, where
660 * Emacs will automagically detect them.
661 * ---------------------------------------------------------------------
664 * indent-tabs-mode: t
668 * vim:noexpandtab:sw=4:ts=4: