runtime.c

来自「kaffe是一个java虚拟机的源代码。里面包含了一些java例程和标准的jav」· C语言 代码 · 共 130 行

C
130
字号
/* * java.lang.Runtime.c * * Copyright (c) 1996, 1997 *	Transvirtual Technologies, Inc.  All rights reserved. * * See the file "license.terms" for information on usage and redistribution  * of this file.  */#include "config.h"#include "config-std.h"#include "config-mem.h"#include "config-io.h"#include "../../../kaffe/kaffevm/gtypes.h"#include <native.h>#include "files.h"#include "defs.h"#include "java_io_File.h"#include "java_lang_Runtime.h"#include "../../../kaffe/kaffevm/external.h"#include "../../../kaffe/kaffevm/gc.h"#include "../../../kaffe/kaffevm/support.h"#include "../../../kaffe/kaffevm/stringSupport.h"extern size_t gc_heap_limit;extern size_t gc_heap_total;extern jboolean runFinalizerOnExit;/* * Exit this VM */voidjava_lang_Runtime_exitInternal(struct Hjava_lang_Runtime* r, jint v){	EXIT (v);}/* * Exec another program. */struct Hjava_lang_Process*java_lang_Runtime_execInternal(struct Hjava_lang_Runtime* this,		HArrayOfObject* argv, HArrayOfObject* arge, Hjava_io_File* dir){	return (struct Hjava_lang_Process*)execute_java_constructor(	    "kaffe.lang.UNIXProcess", 0, 0,	    "([Ljava/lang/String;[Ljava/lang/String;Ljava/io/File;)V",	    argv, arge, dir);}/* * Free memory. */jlongjava_lang_Runtime_freeMemory(struct Hjava_lang_Runtime* this){	/* This is a particularly inaccurate guess - it's basically how	 * much more memory we can claim from the heap, and ignores any	 * free memory already within the GC system.	 * Well it'll do for now.	 */	return (gc_heap_limit - gc_heap_total);}/* * Total memory. */jlongjava_lang_Runtime_totalMemory(struct Hjava_lang_Runtime* this){	return (gc_heap_limit);}/* * Run the garbage collector. */voidjava_lang_Runtime_gc(struct Hjava_lang_Runtime* this){	invokeGC();}/* * Run any pending finialized methods. *  Finalising is part of the garbage collection system - so just run that. */voidjava_lang_Runtime_runFinalization(struct Hjava_lang_Runtime* this){	invokeGC();}/* * Enable/disable tracing of instructions. */voidjava_lang_Runtime_traceInstructions(struct Hjava_lang_Runtime* this, jboolean on){	if (on == true) {		SignalError("java.lang.RuntimeException", "Cannot trace instructions");   	}}/* * Enable/disable tracing of method calls. */voidjava_lang_Runtime_traceMethodCalls(struct Hjava_lang_Runtime* this, jboolean on){	if (on == true) {		SignalError("java.lang.RuntimeException", "Cannot trace method calls");   	}}/* * Inform the runtime that it must run the finalizer when it exits. */voidjava_lang_Runtime_runFinalizersOnExit(jboolean on){	runFinalizerOnExit = on;}jintJava_sun_misc_VM_getState(JNIEnv* env, jobject vm){	return (0);}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?