From e523547b1939f07f5feef30fe50deb9a3513380b Mon Sep 17 00:00:00 2001 From: Alexey Pelykh Date: Thu, 31 Jan 2013 14:54:23 +0200 Subject: [PATCH] Allow avian.bootstrap to accept multiple libraries --- src/jnienv.cpp | 10 ---------- src/jnienv.h | 10 ++++++++++ src/machine.cpp | 23 ++++++++++++++++++++++- 3 files changed, 32 insertions(+), 11 deletions(-) diff --git a/src/jnienv.cpp b/src/jnienv.cpp index 2a70b10855..c8f27fb0b7 100644 --- a/src/jnienv.cpp +++ b/src/jnienv.cpp @@ -3709,16 +3709,6 @@ populateJNITables(JavaVMVTable* vmTable, JNIEnvVTable* envTable) } // namespace vm -#define BOOTSTRAP_PROPERTY "avian.bootstrap" -#define CRASHDIR_PROPERTY "avian.crash.dir" -#define EMBED_PREFIX_PROPERTY "avian.embed.prefix" -#define CLASSPATH_PROPERTY "java.class.path" -#define JAVA_HOME_PROPERTY "java.home" -#define BOOTCLASSPATH_PREPEND_OPTION "bootclasspath/p" -#define BOOTCLASSPATH_OPTION "bootclasspath" -#define BOOTCLASSPATH_APPEND_OPTION "bootclasspath/a" -#define BOOTCLASSPATH_APPEND_OPTION "bootclasspath/a" - extern "C" JNIEXPORT jint JNICALL JNI_GetDefaultJavaVMInitArgs(void*) { diff --git a/src/jnienv.h b/src/jnienv.h index 5b8c46685b..8dbd1f8c7d 100644 --- a/src/jnienv.h +++ b/src/jnienv.h @@ -13,6 +13,16 @@ #include "machine.h" +#define BOOTSTRAP_PROPERTY "avian.bootstrap" +#define CRASHDIR_PROPERTY "avian.crash.dir" +#define EMBED_PREFIX_PROPERTY "avian.embed.prefix" +#define CLASSPATH_PROPERTY "java.class.path" +#define JAVA_HOME_PROPERTY "java.home" +#define BOOTCLASSPATH_PREPEND_OPTION "bootclasspath/p" +#define BOOTCLASSPATH_OPTION "bootclasspath" +#define BOOTCLASSPATH_APPEND_OPTION "bootclasspath/a" +#define BOOTCLASSPATH_APPEND_OPTION "bootclasspath/a" + namespace vm { void diff --git a/src/machine.cpp b/src/machine.cpp index c3c398bd92..e060cd0a9e 100644 --- a/src/machine.cpp +++ b/src/machine.cpp @@ -3008,6 +3008,13 @@ Machine::Machine(System* system, Heap* heap, Finder* bootFinder, populateJNITables(&javaVMVTable, &jniEnvVTable); + const char* bootstrapProperty = strdup(findProperty(this, BOOTSTRAP_PROPERTY)); + const char* bootstrapPropertyEnd = bootstrapProperty + (bootstrapProperty ? strlen(bootstrapProperty) : 0); + char* codeLibraryName = (char*)bootstrapProperty; + char* codeLibraryNameEnd = 0; + if (codeLibraryName && (codeLibraryNameEnd = strchr(codeLibraryName, system->pathSeparator()))) + *codeLibraryNameEnd = 0; + if (not system->success(system->make(&localThread)) or not system->success(system->make(&stateLock)) or not system->success(system->make(&heapLock)) or @@ -3015,10 +3022,24 @@ Machine::Machine(System* system, Heap* heap, Finder* bootFinder, not system->success(system->make(&referenceLock)) or not system->success(system->make(&shutdownLock)) or not system->success - (system->load(&libraries, findProperty(this, "avian.bootstrap")))) + (system->load(&libraries, bootstrapProperty))) { system->abort(); } + + System::Library* additionalLibrary = 0; + while (codeLibraryNameEnd && codeLibraryNameEnd + 1 < bootstrapPropertyEnd) { + codeLibraryName = codeLibraryNameEnd + 1; + codeLibraryNameEnd = strchr(codeLibraryName, system->pathSeparator()); + if (codeLibraryNameEnd) + *codeLibraryNameEnd = 0; + + if (!system->success(system->load(&additionalLibrary, codeLibraryName))) + system->abort(); + libraries->setNext(additionalLibrary); + } + + free((void*)bootstrapProperty); } void