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)
105 /* builtin ********************************************************************/
107 java_objectheader *builtin_clone(void *env, java_objectheader *o)
114 s4 builtin_isanysubclass(classinfo *sub, classinfo *super)
121 java_objectheader *builtin_new(classinfo *c)
129 /* code ***********************************************************************/
131 void code_free_code_of_method(methodinfo *m)
136 methodinfo *code_get_methodinfo_for_pv(u1 *pv)
142 /* codegen ********************************************************************/
144 codeinfo *codegen_createnativestub(functionptr f, methodinfo *m)
149 u1 *createcompilerstub(methodinfo *m)
154 #if defined(ENABLE_INTRP)
155 u1 *intrp_createcompilerstub(methodinfo *m)
161 void removecompilerstub(u1 *stub)
165 void removenativestub(u1 *stub)
170 /* exceptions *****************************************************************/
172 void exceptions_clear_exception(void)
176 void exceptions_print_current_exception(void)
180 void exceptions_throw_abstractmethoderror(void)
182 fprintf(stderr, "java.lang.AbstractMethodError\n");
187 void exceptions_throw_classcircularityerror(classinfo *c)
189 fprintf(stderr, "java.lang.ClassCircularityError: ");
191 utf_display_printable_ascii(c->name);
197 void exceptions_throw_classformaterror(classinfo *c, const char *message, ...)
201 fprintf(stderr, "java.lang.ClassFormatError: ");
203 utf_display_printable_ascii(c->name);
204 fprintf(stderr, ": ");
206 va_start(ap, message);
207 vfprintf(stderr, message, ap);
215 void exceptions_throw_incompatibleclasschangeerror(classinfo *c)
217 fprintf(stderr, "java.lang.IncompatibleClassChangeError: ");
220 utf_fprint_printable_ascii_classname(stderr, c->name);
227 void exceptions_throw_internalerror(const char *message, ...)
231 fprintf(stderr, "java.lang.InternalError: ");
233 va_start(ap, message);
234 vfprintf(stderr, message, ap);
240 void exceptions_throw_linkageerror(const char *message, classinfo *c)
242 fprintf(stderr, "java.lang.LinkageError: %s", message);
245 utf_fprint_printable_ascii_classname(stderr, c->name);
252 void exceptions_throw_noclassdeffounderror(utf *name)
254 fprintf(stderr, "java.lang.NoClassDefFoundError: ");
255 utf_fprint_printable_ascii(stderr, name);
261 void exceptions_throw_outofmemoryerror(void)
263 fprintf(stderr, "java.lang.OutOfMemoryError\n");
268 void exceptions_throw_verifyerror(methodinfo *m, const char *message)
270 fprintf(stderr, "java.lang.VerifyError: ");
271 utf_fprint_printable_ascii(stderr, m->name);
272 fprintf(stderr, ": %s", message);
277 void exceptions_throw_nosuchfielderror(classinfo *c, utf *name)
279 fprintf(stderr, "java.lang.NoSuchFieldError: ");
280 utf_fprint_printable_ascii(stderr, c->name);
281 fprintf(stderr, ".");
282 utf_fprint_printable_ascii(stderr, name);
288 void exceptions_throw_nosuchmethoderror(classinfo *c, utf *name, utf *desc)
290 fprintf(stderr, "java.lang.NoSuchMethodError: ");
291 utf_fprint_printable_ascii(stderr, c->name);
292 fprintf(stderr, ".");
293 utf_fprint_printable_ascii(stderr, name);
294 utf_fprint_printable_ascii(stderr, desc);
300 void exceptions_throw_unsupportedclassversionerror(classinfo *c,
301 const char *message, ...)
305 fprintf(stderr, "java.lang.UnsupportedClassVersionError: " );
307 utf_display_printable_ascii(c->name);
308 fprintf(stderr, ": ");
310 va_start(ap, message);
311 vfprintf(stderr, message, ap);
319 void exceptions_throw_illegalaccessexception(classinfo *c)
321 fprintf(stderr, "java.lang.IllegalAccessException: ");
324 utf_fprint_printable_ascii_classname(stderr, c->name);
331 void exceptions_throw_nullpointerexception(void)
333 fprintf(stderr, "java.lang.NullPointerException\n");
338 void classnotfoundexception_to_noclassdeffounderror(void)
340 /* Can that one happen? */
346 /* finalizer ******************************************************************/
348 void finalizer_notify(void)
350 vm_abort("finalizer_notify");
353 void finalizer_run(void *o, void *p)
355 vm_abort("finalizer_run");
359 /* gc *************************************************************************/
361 s8 gc_get_heap_size(void)
366 s8 gc_get_free_bytes(void)
371 s8 gc_get_total_bytes(void)
376 s8 gc_get_max_heap_size(void)
382 /* heap ***********************************************************************/
384 void *heap_alloc_uncollectable(u4 bytelength)
386 return calloc(bytelength, 1);
389 s4 heap_get_hashcode(java_objectheader *o)
395 /* jit ************************************************************************/
397 void jit_invalidate_code(methodinfo *m)
399 vm_abort("jit_invalidate_code");
403 /* lock ***********************************************************************/
405 void lock_init_object_lock(java_objectheader *o)
409 bool lock_monitor_enter(java_objectheader *o)
414 bool lock_monitor_exit(java_objectheader *o)
420 /* md *************************************************************************/
422 void md_param_alloc(methoddesc *md)
427 /* memory *********************************************************************/
429 void *mem_alloc(s4 size)
431 /* real implementation in src/mm/memory.c clears memory */
433 return calloc(size, 1);
436 void *mem_realloc(void *src, s4 len1, s4 len2)
438 return realloc(src, len2);
441 void mem_free(void *m, s4 size)
446 void *dump_alloc(s4 size)
451 void dump_release(s4 size)
461 /* properties *****************************************************************/
463 char *properties_get(char *key)
469 /* resolve ********************************************************************/
471 /* stupid resolving implementation used by resolve_classref_or_classinfo_eager */
472 /* This function does eager resolving without any access checks. */
474 static classinfo * dummy_resolve_class_from_name(classinfo *referer,
478 classinfo *cls = NULL;
485 /* lookup if this class has already been loaded */
487 cls = classcache_lookup(referer->classloader, classname);
490 /* resolve array types */
492 if (classname->text[0] == '[') {
493 utf_ptr = classname->text + 1;
494 len = classname->blength - 1;
496 /* classname is an array type name */
504 /* the component type is a reference type */
505 /* resolve the component type */
506 if ((cls = dummy_resolve_class_from_name(referer,
507 utf_new(utf_ptr,len),
508 checkaccess)) == NULL)
509 return NULL; /* exception */
511 /* create the array class */
512 cls = class_array_of(cls,false);
514 return NULL; /* exception */
520 if (!(cls = load_class_from_classloader(classname,
521 referer->classloader)))
522 return false; /* exception */
526 /* the class is now loaded */
528 assert(cls->state & CLASS_LOADED);
534 classinfo * resolve_classref_or_classinfo_eager(classref_or_classinfo cls,
541 if (IS_CLASSREF(cls)) {
542 /* we must resolve this reference */
544 if ((c = dummy_resolve_class_from_name(cls.ref->referer, cls.ref->name,
545 checkaccess)) == NULL)
549 /* cls has already been resolved */
554 assert(c->state & CLASS_LOADED);
561 /* stacktrace *****************************************************************/
563 java_objectarray *stacktrace_getClassContext()
569 /* threads ********************************************************************/
571 pthread_key_t threads_current_threadobject_key;
573 ptrint threads_get_current_tid(void)
579 /* vm *************************************************************************/
581 void vm_abort(const char *text, ...)
585 /* print the log message */
588 vfprintf(stderr, text, ap);
591 /* now abort the VM */
596 java_objectheader *vm_call_method(methodinfo *m, java_objectheader *o, ...)
604 void stringtable_update(void)
606 log_println("stringtable_update: REMOVE ME!");
609 java_objectheader *literalstring_new(utf *u)
611 log_println("literalstring_new: REMOVE ME!");
617 void print_dynamic_super_statistics(void)
623 * These are local overrides for various environment variables in Emacs.
624 * Please do not remove this and leave it at the end of the file, where
625 * Emacs will automagically detect them.
626 * ---------------------------------------------------------------------
629 * indent-tabs-mode: t
633 * vim:noexpandtab:sw=4:ts=4: