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
36 #include "toolbox/logging.h"
38 #include "vm/global.h"
39 #include "vm/primitive.h"
42 #include "vmcore/class.h"
43 #include "vmcore/method.h"
44 #include "vmcore/utf8.h"
45 #include "vmcore/classcache.h"
46 #include "vmcore/loader.h"
49 /* global variables ***********************************************************/
51 char *_Jv_bootclasspath;
54 java_handle_t *javastring_new_slash_to_dot(utf *u)
56 vm_abort("javastring_new_slash_to_dot");
62 /* access *********************************************************************/
64 bool access_is_accessible_class(classinfo *referer, classinfo *cls)
69 bool access_is_accessible_member(classinfo *referer, classinfo *declarer,
72 vm_abort("access_is_accessible_member");
78 /* asm ************************************************************************/
80 void asm_abstractmethoderror(void)
85 void intrp_asm_abstractmethoderror(void)
90 void asm_getclassvalues_atomic(vftbl_t *super, vftbl_t *sub, castinfo *out)
95 void intrp_asm_getclassvalues_atomic(vftbl_t *super, vftbl_t *sub, castinfo *out)
101 /* builtin ********************************************************************/
103 java_handle_t *builtin_clone(void *env, java_handle_t *o)
110 int32_t builtin_isanysubclass(classinfo *sub, classinfo *super)
117 java_handle_t *builtin_new(classinfo *c)
124 java_handle_objectarray_t *builtin_anewarray(int32_t size, classinfo *componentclass)
131 java_handle_bytearray_t *builtin_newarray_byte(int32_t size)
139 /* code ***********************************************************************/
141 void code_free_code_of_method(methodinfo *m)
146 methodinfo *code_get_methodinfo_for_pv(u1 *pv)
152 /* codegen ********************************************************************/
154 u1 *codegen_generate_stub_compiler(methodinfo *m)
159 codeinfo *codegen_generate_stub_native(methodinfo *m, functionptr f)
164 #if defined(ENABLE_INTRP)
165 u1 *intrp_createcompilerstub(methodinfo *m)
171 void removecompilerstub(u1 *stub)
175 void removenativestub(u1 *stub)
180 /* exceptions *****************************************************************/
182 void exceptions_clear_exception(void)
186 void exceptions_print_current_exception(void)
191 void exceptions_throw_abstractmethoderror(void)
193 fprintf(stderr, "java.lang.AbstractMethodError\n");
198 void exceptions_throw_classcircularityerror(classinfo *c)
200 fprintf(stderr, "java.lang.ClassCircularityError: ");
202 utf_display_printable_ascii(c->name);
208 void exceptions_throw_classformaterror(classinfo *c, const char *message, ...)
212 fprintf(stderr, "java.lang.ClassFormatError: ");
214 utf_display_printable_ascii(c->name);
215 fprintf(stderr, ": ");
217 va_start(ap, message);
218 vfprintf(stderr, message, ap);
226 void exceptions_throw_incompatibleclasschangeerror(classinfo *c)
228 fprintf(stderr, "java.lang.IncompatibleClassChangeError: ");
231 utf_fprint_printable_ascii_classname(stderr, c->name);
238 void exceptions_throw_internalerror(const char *message, ...)
242 fprintf(stderr, "java.lang.InternalError: ");
244 va_start(ap, message);
245 vfprintf(stderr, message, ap);
251 void exceptions_throw_linkageerror(const char *message, classinfo *c)
253 fprintf(stderr, "java.lang.LinkageError: %s", message);
256 utf_fprint_printable_ascii_classname(stderr, c->name);
263 void exceptions_throw_noclassdeffounderror(utf *name)
265 fprintf(stderr, "java.lang.NoClassDefFoundError: ");
266 utf_fprint_printable_ascii(stderr, name);
272 void exceptions_throw_noclassdeffounderror_wrong_name(classinfo *c, utf *name)
274 fprintf(stderr, "java.lang.NoClassDefFoundError: ");
275 utf_fprint_printable_ascii(stderr, c->name);
276 fprintf(stderr, " (wrong name: ");
277 utf_fprint_printable_ascii(stderr, name);
278 fprintf(stderr, ")\n");
283 void exceptions_throw_verifyerror(methodinfo *m, const char *message)
285 fprintf(stderr, "java.lang.VerifyError: ");
286 utf_fprint_printable_ascii(stderr, m->name);
287 fprintf(stderr, ": %s", message);
292 void exceptions_throw_nosuchfielderror(classinfo *c, utf *name)
294 fprintf(stderr, "java.lang.NoSuchFieldError: ");
295 utf_fprint_printable_ascii(stderr, c->name);
296 fprintf(stderr, ".");
297 utf_fprint_printable_ascii(stderr, name);
303 void exceptions_throw_nosuchmethoderror(classinfo *c, utf *name, utf *desc)
305 fprintf(stderr, "java.lang.NoSuchMethodError: ");
306 utf_fprint_printable_ascii(stderr, c->name);
307 fprintf(stderr, ".");
308 utf_fprint_printable_ascii(stderr, name);
309 utf_fprint_printable_ascii(stderr, desc);
315 void exceptions_throw_unsupportedclassversionerror(classinfo *c,
316 const char *message, ...)
320 fprintf(stderr, "java.lang.UnsupportedClassVersionError: " );
322 utf_display_printable_ascii(c->name);
323 fprintf(stderr, ": ");
325 va_start(ap, message);
326 vfprintf(stderr, message, ap);
334 void exceptions_throw_classnotfoundexception(utf *name)
336 fprintf(stderr, "java.lang.ClassNotFoundException: ");
337 utf_fprint_printable_ascii(stderr, name);
343 void exceptions_throw_nullpointerexception(void)
345 fprintf(stderr, "java.lang.NullPointerException\n");
351 /* finalizer ******************************************************************/
353 void finalizer_notify(void)
355 vm_abort("finalizer_notify");
358 void finalizer_run(void *o, void *p)
360 vm_abort("finalizer_run");
364 /* gc *************************************************************************/
366 int64_t gc_get_heap_size(void)
371 int64_t gc_get_free_bytes(void)
376 int64_t gc_get_total_bytes(void)
381 int64_t gc_get_max_heap_size(void)
387 /* heap ***********************************************************************/
389 void *heap_alloc_uncollectable(uint32_t bytelength)
391 return calloc(bytelength, 1);
395 /* jit ************************************************************************/
397 void jit_invalidate_code(methodinfo *m)
399 vm_abort("jit_invalidate_code");
403 /* lock ***********************************************************************/
405 void lock_init_object_lock(java_object_t *o)
409 bool lock_monitor_enter(java_object_t *o)
414 bool lock_monitor_exit(java_object_t *o)
420 /* md *************************************************************************/
422 void md_param_alloc(methoddesc *md)
426 void md_param_alloc_native(methoddesc *md)
431 /* memory *********************************************************************/
433 void *mem_alloc(int32_t size)
435 /* real implementation in src/mm/memory.c clears memory */
437 return calloc(size, 1);
440 void *mem_realloc(void *src, int32_t len1, int32_t len2)
442 return realloc(src, len2);
445 void mem_free(void *m, int32_t size)
450 void *dump_alloc(int32_t size)
455 void dump_release(int32_t size)
459 int32_t dump_size(void)
465 /* primitive ******************************************************************/
467 classinfo *primitive_class_get_by_type(int type)
473 classinfo *primitive_class_get_by_char(char ch)
480 /* properties *****************************************************************/
482 void properties_add(char *key, char *value)
486 char *properties_get(char *key)
492 /* resolve ********************************************************************/
494 bool resolve_class_from_typedesc(typedesc *d, bool checkaccess, bool link, classinfo **result)
501 /* stupid resolving implementation used by resolve_classref_or_classinfo_eager */
502 /* This function does eager resolving without any access checks. */
504 static classinfo * dummy_resolve_class_from_name(classinfo *referer,
508 classinfo *cls = NULL;
515 /* lookup if this class has already been loaded */
517 cls = classcache_lookup(referer->classloader, classname);
520 /* resolve array types */
522 if (classname->text[0] == '[') {
523 utf_ptr = classname->text + 1;
524 len = classname->blength - 1;
526 /* classname is an array type name */
534 /* the component type is a reference type */
535 /* resolve the component type */
536 if ((cls = dummy_resolve_class_from_name(referer,
537 utf_new(utf_ptr,len),
538 checkaccess)) == NULL)
539 return NULL; /* exception */
541 /* create the array class */
542 cls = class_array_of(cls,false);
544 return NULL; /* exception */
550 if (!(cls = load_class_from_classloader(classname,
551 referer->classloader)))
552 return false; /* exception */
556 /* the class is now loaded */
558 assert(cls->state & CLASS_LOADED);
564 classinfo * resolve_classref_or_classinfo_eager(classref_or_classinfo cls,
571 if (IS_CLASSREF(cls)) {
572 /* we must resolve this reference */
574 if ((c = dummy_resolve_class_from_name(cls.ref->referer, cls.ref->name,
575 checkaccess)) == NULL)
579 /* cls has already been resolved */
584 assert(c->state & CLASS_LOADED);
591 /* stacktrace *****************************************************************/
593 java_handle_objectarray_t *stacktrace_getClassContext()
599 /* threads ********************************************************************/
601 intptr_t threads_get_current_tid(void)
606 void threads_cast_stopworld(void)
610 void threads_cast_startworld(void)
615 /* vm *************************************************************************/
617 void vm_printconfig(void)
621 void vm_abort(const char *text, ...)
625 /* print the log message */
628 vfprintf(stderr, text, ap);
631 /* now abort the VM */
636 java_handle_t *vm_call_method(methodinfo *m, java_handle_t *o, ...)
644 void stringtable_update(void)
646 log_println("stringtable_update: REMOVE ME!");
649 java_object_t *literalstring_new(utf *u)
651 log_println("literalstring_new: REMOVE ME!");
657 void print_dynamic_super_statistics(void)
663 * These are local overrides for various environment variables in Emacs.
664 * Please do not remove this and leave it at the end of the file, where
665 * Emacs will automagically detect them.
666 * ---------------------------------------------------------------------
669 * indent-tabs-mode: t
673 * vim:noexpandtab:sw=4:ts=4: