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: dummy.c 8299 2007-08-13 08:41:18Z michi $
38 #include "toolbox/logging.h"
40 #include "vm/global.h"
41 #include "vm/primitive.h"
44 #include "vmcore/class.h"
45 #include "vmcore/method.h"
46 #include "vmcore/utf8.h"
47 #include "vmcore/classcache.h"
48 #include "vmcore/loader.h"
51 /* global variables ***********************************************************/
53 char *_Jv_bootclasspath;
56 java_handle_t *javastring_new_slash_to_dot(utf *u)
58 vm_abort("javastring_new_slash_to_dot");
64 /* access *********************************************************************/
66 bool access_is_accessible_class(classinfo *referer, classinfo *cls)
71 bool access_is_accessible_member(classinfo *referer, classinfo *declarer,
74 vm_abort("access_is_accessible_member");
80 /* asm ************************************************************************/
82 void asm_abstractmethoderror(void)
87 void intrp_asm_abstractmethoderror(void)
92 void asm_getclassvalues_atomic(vftbl_t *super, vftbl_t *sub, castinfo *out)
97 void intrp_asm_getclassvalues_atomic(vftbl_t *super, vftbl_t *sub, castinfo *out)
103 /* builtin ********************************************************************/
105 java_handle_t *builtin_clone(void *env, java_handle_t *o)
112 int32_t builtin_isanysubclass(classinfo *sub, classinfo *super)
119 java_handle_t *builtin_new(classinfo *c)
126 java_objectarray *builtin_anewarray(int32_t size, classinfo *componentclass)
134 /* code ***********************************************************************/
136 void code_free_code_of_method(methodinfo *m)
141 methodinfo *code_get_methodinfo_for_pv(u1 *pv)
147 /* codegen ********************************************************************/
149 u1 *codegen_generate_stub_compiler(methodinfo *m)
154 codeinfo *codegen_generate_stub_native(methodinfo *m, functionptr f)
159 #if defined(ENABLE_INTRP)
160 u1 *intrp_createcompilerstub(methodinfo *m)
166 void removecompilerstub(u1 *stub)
170 void removenativestub(u1 *stub)
175 /* exceptions *****************************************************************/
177 void exceptions_clear_exception(void)
181 void exceptions_print_current_exception(void)
186 void exceptions_throw_abstractmethoderror(void)
188 fprintf(stderr, "java.lang.AbstractMethodError\n");
193 void exceptions_throw_classcircularityerror(classinfo *c)
195 fprintf(stderr, "java.lang.ClassCircularityError: ");
197 utf_display_printable_ascii(c->name);
203 void exceptions_throw_classformaterror(classinfo *c, const char *message, ...)
207 fprintf(stderr, "java.lang.ClassFormatError: ");
209 utf_display_printable_ascii(c->name);
210 fprintf(stderr, ": ");
212 va_start(ap, message);
213 vfprintf(stderr, message, ap);
221 void exceptions_throw_incompatibleclasschangeerror(classinfo *c)
223 fprintf(stderr, "java.lang.IncompatibleClassChangeError: ");
226 utf_fprint_printable_ascii_classname(stderr, c->name);
233 void exceptions_throw_internalerror(const char *message, ...)
237 fprintf(stderr, "java.lang.InternalError: ");
239 va_start(ap, message);
240 vfprintf(stderr, message, ap);
246 void exceptions_throw_linkageerror(const char *message, classinfo *c)
248 fprintf(stderr, "java.lang.LinkageError: %s", message);
251 utf_fprint_printable_ascii_classname(stderr, c->name);
258 void exceptions_throw_noclassdeffounderror(utf *name)
260 fprintf(stderr, "java.lang.NoClassDefFoundError: ");
261 utf_fprint_printable_ascii(stderr, name);
267 void exceptions_throw_noclassdeffounderror_wrong_name(classinfo *c, utf *name)
269 fprintf(stderr, "java.lang.NoClassDefFoundError: ");
270 utf_fprint_printable_ascii(stderr, c->name);
271 fprintf(stderr, " (wrong name: ");
272 utf_fprint_printable_ascii(stderr, name);
273 fprintf(stderr, ")\n");
278 void exceptions_throw_verifyerror(methodinfo *m, const char *message)
280 fprintf(stderr, "java.lang.VerifyError: ");
281 utf_fprint_printable_ascii(stderr, m->name);
282 fprintf(stderr, ": %s", message);
287 void exceptions_throw_nosuchfielderror(classinfo *c, utf *name)
289 fprintf(stderr, "java.lang.NoSuchFieldError: ");
290 utf_fprint_printable_ascii(stderr, c->name);
291 fprintf(stderr, ".");
292 utf_fprint_printable_ascii(stderr, name);
298 void exceptions_throw_nosuchmethoderror(classinfo *c, utf *name, utf *desc)
300 fprintf(stderr, "java.lang.NoSuchMethodError: ");
301 utf_fprint_printable_ascii(stderr, c->name);
302 fprintf(stderr, ".");
303 utf_fprint_printable_ascii(stderr, name);
304 utf_fprint_printable_ascii(stderr, desc);
310 void exceptions_throw_unsupportedclassversionerror(classinfo *c,
311 const char *message, ...)
315 fprintf(stderr, "java.lang.UnsupportedClassVersionError: " );
317 utf_display_printable_ascii(c->name);
318 fprintf(stderr, ": ");
320 va_start(ap, message);
321 vfprintf(stderr, message, ap);
329 void exceptions_throw_classnotfoundexception(utf *name)
331 fprintf(stderr, "java.lang.ClassNotFoundException: ");
332 utf_fprint_printable_ascii(stderr, name);
338 void exceptions_throw_nullpointerexception(void)
340 fprintf(stderr, "java.lang.NullPointerException\n");
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 void gc_reference_register(java_objectheader **ref)
365 int64_t gc_get_heap_size(void)
370 int64_t gc_get_free_bytes(void)
375 int64_t gc_get_total_bytes(void)
380 int64_t gc_get_max_heap_size(void)
386 /* heap ***********************************************************************/
388 void *heap_alloc_uncollectable(uint32_t bytelength)
390 return calloc(bytelength, 1);
393 s4 heap_get_hashcode(java_objectheader *o)
399 /* jit ************************************************************************/
401 void jit_invalidate_code(methodinfo *m)
403 vm_abort("jit_invalidate_code");
407 /* lock ***********************************************************************/
409 void lock_init_object_lock(java_object_t *o)
413 bool lock_monitor_enter(java_object_t *o)
418 bool lock_monitor_exit(java_object_t *o)
424 /* md *************************************************************************/
426 void md_param_alloc(methoddesc *md)
430 void md_param_alloc_native(methoddesc *md)
435 /* memory *********************************************************************/
437 void *mem_alloc(int32_t size)
439 /* real implementation in src/mm/memory.c clears memory */
441 return calloc(size, 1);
444 void *mem_realloc(void *src, int32_t len1, int32_t len2)
446 return realloc(src, len2);
449 void mem_free(void *m, int32_t size)
454 void *dump_alloc(int32_t size)
459 void dump_release(int32_t size)
463 int32_t dump_size(void)
469 /* primitive ******************************************************************/
471 classinfo *primitive_class_get_by_type(int type)
477 classinfo *primitive_class_get_by_char(char ch)
484 /* properties *****************************************************************/
486 void properties_add(char *key, char *value)
490 char *properties_get(char *key)
496 /* resolve ********************************************************************/
498 bool resolve_class_from_typedesc(typedesc *d, bool checkaccess, bool link, classinfo **result)
505 /* stupid resolving implementation used by resolve_classref_or_classinfo_eager */
506 /* This function does eager resolving without any access checks. */
508 static classinfo * dummy_resolve_class_from_name(classinfo *referer,
512 classinfo *cls = NULL;
519 /* lookup if this class has already been loaded */
521 cls = classcache_lookup(referer->classloader, classname);
524 /* resolve array types */
526 if (classname->text[0] == '[') {
527 utf_ptr = classname->text + 1;
528 len = classname->blength - 1;
530 /* classname is an array type name */
538 /* the component type is a reference type */
539 /* resolve the component type */
540 if ((cls = dummy_resolve_class_from_name(referer,
541 utf_new(utf_ptr,len),
542 checkaccess)) == NULL)
543 return NULL; /* exception */
545 /* create the array class */
546 cls = class_array_of(cls,false);
548 return NULL; /* exception */
554 if (!(cls = load_class_from_classloader(classname,
555 referer->classloader)))
556 return false; /* exception */
560 /* the class is now loaded */
562 assert(cls->state & CLASS_LOADED);
568 classinfo * resolve_classref_or_classinfo_eager(classref_or_classinfo cls,
575 if (IS_CLASSREF(cls)) {
576 /* we must resolve this reference */
578 if ((c = dummy_resolve_class_from_name(cls.ref->referer, cls.ref->name,
579 checkaccess)) == NULL)
583 /* cls has already been resolved */
588 assert(c->state & CLASS_LOADED);
595 /* stacktrace *****************************************************************/
597 java_objectarray *stacktrace_getClassContext()
603 /* threads ********************************************************************/
605 intptr_t threads_get_current_tid(void)
610 void threads_stopworld(void)
614 void threads_startworld(void)
619 /* vm *************************************************************************/
621 void vm_printconfig(void)
625 void vm_abort(const char *text, ...)
629 /* print the log message */
632 vfprintf(stderr, text, ap);
635 /* now abort the VM */
640 java_handle_t *vm_call_method(methodinfo *m, java_handle_t *o, ...)
648 void stringtable_update(void)
650 log_println("stringtable_update: REMOVE ME!");
653 java_object_t *literalstring_new(utf *u)
655 log_println("literalstring_new: REMOVE ME!");
661 void print_dynamic_super_statistics(void)
667 * These are local overrides for various environment variables in Emacs.
668 * Please do not remove this and leave it at the end of the file, where
669 * Emacs will automagically detect them.
670 * ---------------------------------------------------------------------
673 * indent-tabs-mode: t
677 * vim:noexpandtab:sw=4:ts=4: