1 // natRuntime.cc - Implementation of native side of Runtime class.
3 /* Copyright (C) 1998, 1999, 2000 Red Hat, Inc.
5 This file is part of libgcj.
7 This software is copyrighted work licensed under the terms of the
8 Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
17 #include <java/lang/Runtime.h>
18 #include <java/lang/UnknownError.h>
19 #include <java/lang/UnsatisfiedLinkError.h>
24 /* FIXME: we don't always need this. The next libtool will let us use
25 AC_LTDL_PREOPEN to see if we do. */
26 const lt_dlsymlist lt_preloaded_symbols[1] = { { 0, 0 } };
30 java::lang::Runtime::exit (jint status)
34 // Make status right for Unix. This is perhaps strange.
35 if (status < 0 || status > 255)
39 _Jv_RunAllFinalizers ();
45 java::lang::Runtime::freeMemory (void)
47 return _Jv_GCFreeMemory ();
51 java::lang::Runtime::gc (void)
57 java::lang::Runtime::load (jstring path)
59 JvSynchronize sync (this);
61 using namespace java::lang;
63 jint len = _Jv_GetStringUTFLength (path);
65 jsize total = JvGetStringUTFRegion (path, 0, path->length(), buf);
67 // FIXME: make sure path is absolute.
68 lt_dlhandle h = lt_dlopen (buf);
71 const char *msg = lt_dlerror ();
72 _Jv_Throw (new UnsatisfiedLinkError (JvNewStringLatin1 (msg)));
75 _Jv_Throw (new UnknownError
76 (JvNewStringLatin1 ("Runtime.load not implemented")));
81 java::lang::Runtime::loadLibrary (jstring lib)
83 JvSynchronize sync (this);
85 using namespace java::lang;
87 jint len = _Jv_GetStringUTFLength (lib);
89 jsize total = JvGetStringUTFRegion (lib, 0, lib->length(), buf);
91 // FIXME: make sure path is absolute.
92 lt_dlhandle h = lt_dlopenext (buf);
95 const char *msg = lt_dlerror ();
96 _Jv_Throw (new UnsatisfiedLinkError (JvNewStringLatin1 (msg)));
99 _Jv_Throw (new UnknownError
100 (JvNewStringLatin1 ("Runtime.loadLibrary not implemented")));
101 #endif /* USE_LTDL */
105 java::lang::Runtime::loadLibraryInternal (jstring lib)
107 JvSynchronize sync (this);
108 using namespace java::lang;
110 jint len = _Jv_GetStringUTFLength (lib);
112 jsize total = JvGetStringUTFRegion (lib, 0, lib->length(), buf);
114 // FIXME: make sure path is absolute.
115 lt_dlhandle h = lt_dlopenext (buf);
119 #endif /* USE_LTDL */
123 java::lang::Runtime::init (void)
125 finalize_on_exit = false;
132 java::lang::Runtime::runFinalization (void)
134 _Jv_RunFinalizers ();
138 java::lang::Runtime::totalMemory (void)
140 return _Jv_GCTotalMemory ();
144 java::lang::Runtime::traceInstructions (jboolean)
150 java::lang::Runtime::traceMethodCalls (jboolean)