#include <stdint.h>
#include <sys/stat.h>
-#include "mm/memory.h"
+#include "mm/memory.hpp"
#include "native/jni.hpp"
#include "native/llni.h"
-#include "native/native.h"
+#include "native/native.hpp"
#if defined(ENABLE_JNI_HEADERS)
# include "native/vm/include/java_lang_VMClassLoader.h"
#endif
-#include "toolbox/logging.h"
-#include "toolbox/list.h"
+#include "toolbox/logging.hpp"
+#include "toolbox/list.hpp"
#if defined(ENABLE_ASSERTION)
#include "vm/assertion.hpp"
#endif
+#include "vm/array.hpp"
#include "vm/jit/builtin.hpp"
-#include "vm/class.h"
-#include "vm/classcache.h"
+#include "vm/class.hpp"
+#include "vm/classcache.hpp"
#include "vm/exceptions.hpp"
#include "vm/globals.hpp"
-#include "vm/initialize.h"
+#include "vm/initialize.hpp"
#include "vm/javaobjects.hpp"
-#include "vm/linker.h"
+#include "vm/linker.hpp"
#include "vm/loader.hpp"
#include "vm/options.h"
#include "vm/primitive.hpp"
#include "vm/statistics.h"
#include "vm/string.hpp"
#include "vm/vm.hpp"
-#include "vm/zip.h"
+#include "vm/zip.hpp"
#include "vm/jit/asmpart.h"
*/
JNIEXPORT jclass JNICALL Java_java_lang_VMClassLoader_defineClass(JNIEnv *env, jclass clazz, jobject cl, jstring name, jbyteArray data, jint offset, jint len, jobject pd)
{
- utf *utfname;
- classinfo *c;
- classloader_t *loader;
- java_handle_bytearray_t* ba;
- uint8_t* stream;
+ utf* utfname;
+ classinfo* c;
+ classloader_t* loader;
+ uint8_t* stream;
#if defined(ENABLE_JVMTI)
jint new_class_data_len = 0;
/* check the indexes passed */
- if ((offset < 0) || (len < 0) || ((offset + len) > LLNI_array_size(data))) {
+ ByteArray ba(data);
+
+ if ((offset < 0) || (len < 0) || ((offset + len) > ba.get_length())) {
exceptions_throw_arrayindexoutofboundsexception();
return NULL;
}
else
#endif
{
- ba = (java_handle_bytearray_t*) data;
- stream = (uint8_t *) &LLNI_array_direct(ba, offset);
+ stream = ((uint8_t *) ba.get_raw_data_ptr()) + offset;
c = class_define(utfname, loader, len, stream, (java_handle_t *) pd);
}
java_handle_t *o; /* vector being created */
methodinfo *m; /* "add" method of vector */
java_handle_t *path; /* path to be added */
- list_classpath_entry *lce; /* classpath entry */
utf *utfname; /* utf to look for */
char *buffer; /* char buffer */
char *namestart; /* start of name to use */
/* iterate over all classpath entries */
- for (lce = (list_classpath_entry*) list_first(list_classpath_entries); lce != NULL;
- lce = (list_classpath_entry*) list_next(list_classpath_entries, lce)) {
+ for (List<list_classpath_entry*>::iterator it = list_classpath_entries->begin(); it != list_classpath_entries->end(); it++) {
+ list_classpath_entry* lce = *it;
+
/* clear path pointer */
path = NULL;
#if defined(ENABLE_ASSERTION)
java_handle_t *js;
methodinfo *m;
- assertion_name_t *item;
#endif
/* new HashMap() */
return NULL;
}
- item = (assertion_name_t *)list_first(list_assertion_names);
+ for (List<assertion_name_t*>::iterator it = list_assertion_names->begin(); it != list_assertion_names->end(); it++) {
+ assertion_name_t* item = *it;
- while (item != NULL) {
- if (item->package == false) {
- item = (assertion_name_t *)list_next(list_assertion_names, item);
+ if (item->package == false)
continue;
- }
if (strcmp(item->name, "") == 0) {
/* unnamed package wanted */
else {
vm_call_method(m, hm, js, jfalse);
}
-
- item = (assertion_name_t *)list_next(list_assertion_names, item);
}
#endif
#if defined(ENABLE_ASSERTION)
java_handle_t *js;
methodinfo *m;
- assertion_name_t *item;
#endif
/* new HashMap() */
return NULL;
}
- item = (assertion_name_t *)list_first(list_assertion_names);
+ for (List<assertion_name_t*>::iterator it = list_assertion_names->begin(); it != list_assertion_names->end(); it++) {
+ assertion_name_t* item = *it;
- while (item != NULL) {
- if (item->package == true) {
- item = (assertion_name_t *)list_next(list_assertion_names, item);
+ if (item->package == true)
continue;
- }
js = javastring_new_from_ascii(item->name);
if (js == NULL) {
else {
vm_call_method(m, hm, js, jfalse);
}
-
- item = (assertion_name_t *)list_next(list_assertion_names, item);
}
#endif
*******************************************************************************/
-// FIXME
-extern "C" {
void _Jv_java_lang_VMClassLoader_init(void)
{
- utf *u;
+ utf* u = utf_new_char("java/lang/VMClassLoader");
- u = utf_new_char("java/lang/VMClassLoader");
-
- native_method_register(u, methods, NATIVE_METHODS_COUNT);
-}
+ NativeMethods& nm = VM::get_current()->get_nativemethods();
+ nm.register_methods(u, methods, NATIVE_METHODS_COUNT);
}