/* src/vm/javaobjects.cpp - functions to create and access Java objects
- Copyright (C) 2008 Theobroma Systems Ltd.
+ Copyright (C) 2008, 2009 Theobroma Systems Ltd.
This file is part of CACAO.
#include "native/vm/reflection.hpp"
-#include "vm/access.h"
+#include "vm/access.hpp"
#include "vm/jit/builtin.hpp"
#include "vm/global.h"
#include "vm/globals.hpp"
-#include "vm/initialize.h"
+#include "vm/initialize.hpp"
#include "vm/javaobjects.hpp"
#if defined(ENABLE_JAVASE)
+/**
+ * Invokes the static Java method getSystemClassLoader().
+ *
+ * @return Return value of the invocation or NULL in
+ * case of an exception.
+ */
+java_handle_t* java_lang_ClassLoader::invoke_getSystemClassLoader()
+{
+ methodinfo *m;
+ java_handle_t *clo;
+ classloader_t *cl;
+
+ assert(class_java_lang_Object);
+ assert(class_java_lang_ClassLoader);
+ assert(class_java_lang_ClassLoader->state & CLASS_LINKED);
+
+ m = class_resolveclassmethod(class_java_lang_ClassLoader,
+ utf_getSystemClassLoader,
+ utf_void__java_lang_ClassLoader,
+ class_java_lang_Object,
+ false);
+
+ if (m == NULL)
+ return NULL;
+
+ clo = vm_call_method(m, NULL);
+
+ if (clo == NULL)
+ return NULL;
+
+ cl = loader_hashtable_classloader_add(clo);
+
+ return cl;
+}
+
+
/**
* Constructs a Java object with the given
* java.lang.reflect.Constructor.
if (h == NULL)
return NULL;
-
+
// Call initializer.
(void) Reflection::invoke(m, h, args);
return result;
}
-
-// Legacy C interface.
-
-extern "C" {
- java_handle_t* java_lang_reflect_Constructor_create(methodinfo* m) { return java_lang_reflect_Constructor(m).get_handle(); }
- java_handle_t* java_lang_reflect_Field_create(fieldinfo* f) { return java_lang_reflect_Field(f).get_handle(); }
- java_handle_t* java_lang_reflect_Method_create(methodinfo* m) { return java_lang_reflect_Method(m).get_handle(); }
-}
-
#endif // ENABLE_JAVASE