mirror of
https://github.com/corda/corda.git
synced 2025-01-07 13:38:47 +00:00
support -Xbootclasspath and -Xbootclasspath/a options
This commit is contained in:
parent
cfaf690306
commit
a2ba391b89
@ -1878,6 +1878,16 @@ parseSize(const char* s)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
append(char** p, const char* value, unsigned length, char tail)
|
||||||
|
{
|
||||||
|
if (length) {
|
||||||
|
memcpy(*p, value, length);
|
||||||
|
*p += length;
|
||||||
|
*((*p)++) = tail;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
namespace vm {
|
namespace vm {
|
||||||
@ -2052,6 +2062,9 @@ populateJNITables(JavaVMVTable* vmTable, JNIEnvVTable* envTable)
|
|||||||
#define BUILTINS_PROPERTY "avian.builtins"
|
#define BUILTINS_PROPERTY "avian.builtins"
|
||||||
#define BOOTSTRAP_PROPERTY "avian.bootstrap"
|
#define BOOTSTRAP_PROPERTY "avian.bootstrap"
|
||||||
#define CLASSPATH_PROPERTY "java.class.path"
|
#define CLASSPATH_PROPERTY "java.class.path"
|
||||||
|
#define BOOTCLASSPATH_PREPEND_OPTION "bootclasspath/p"
|
||||||
|
#define BOOTCLASSPATH_OPTION "bootclasspath"
|
||||||
|
#define BOOTCLASSPATH_APPEND_OPTION "bootclasspath/a"
|
||||||
|
|
||||||
extern "C" JNIEXPORT jint JNICALL
|
extern "C" JNIEXPORT jint JNICALL
|
||||||
JNI_GetDefaultJavaVMInitArgs(void*)
|
JNI_GetDefaultJavaVMInitArgs(void*)
|
||||||
@ -2068,15 +2081,28 @@ JNI_CreateJavaVM(Machine** m, Thread** t, void* args)
|
|||||||
const char* builtins = 0;
|
const char* builtins = 0;
|
||||||
const char* bootLibrary = 0;
|
const char* bootLibrary = 0;
|
||||||
const char* classpath = 0;
|
const char* classpath = 0;
|
||||||
const char* bootClasspathPrepend = 0;
|
const char* bootClasspathPrepend = "";
|
||||||
|
const char* bootClasspath = "";
|
||||||
|
const char* bootClasspathAppend = "";
|
||||||
|
|
||||||
for (int i = 0; i < a->nOptions; ++i) {
|
for (int i = 0; i < a->nOptions; ++i) {
|
||||||
if (strncmp(a->options[i].optionString, "-Xmx", 4) == 0) {
|
if (strncmp(a->options[i].optionString, "-X", 2) == 0) {
|
||||||
heapLimit = parseSize(a->options[i].optionString + 4);
|
const char* p = a->options[i].optionString + 2;
|
||||||
} else if (strncmp(a->options[i].optionString,
|
if (strncmp(p, "mx", 2) == 0) {
|
||||||
"-Xbootclasspath/p:", 16) == 0)
|
heapLimit = parseSize(p + 2);
|
||||||
{
|
} else if (strncmp(p, BOOTCLASSPATH_PREPEND_OPTION ":",
|
||||||
bootClasspathPrepend = a->options[i].optionString + 16;
|
sizeof(BOOTCLASSPATH_PREPEND_OPTION)) == 0)
|
||||||
|
{
|
||||||
|
bootClasspathPrepend = p + sizeof(BOOTCLASSPATH_PREPEND_OPTION);
|
||||||
|
} else if (strncmp(p, BOOTCLASSPATH_OPTION ":",
|
||||||
|
sizeof(BOOTCLASSPATH_OPTION)) == 0)
|
||||||
|
{
|
||||||
|
bootClasspath = p + sizeof(BOOTCLASSPATH_OPTION);
|
||||||
|
} else if (strncmp(p, BOOTCLASSPATH_APPEND_OPTION ":",
|
||||||
|
sizeof(BOOTCLASSPATH_APPEND_OPTION)) == 0)
|
||||||
|
{
|
||||||
|
bootClasspathAppend = p + sizeof(BOOTCLASSPATH_APPEND_OPTION);
|
||||||
|
}
|
||||||
} else if (strncmp(a->options[i].optionString, "-D", 2) == 0) {
|
} else if (strncmp(a->options[i].optionString, "-D", 2) == 0) {
|
||||||
const char* p = a->options[i].optionString + 2;
|
const char* p = a->options[i].optionString + 2;
|
||||||
if (strncmp(p, BUILTINS_PROPERTY "=",
|
if (strncmp(p, BUILTINS_PROPERTY "=",
|
||||||
@ -2101,18 +2127,19 @@ JNI_CreateJavaVM(Machine** m, Thread** t, void* args)
|
|||||||
|
|
||||||
if (classpath == 0) classpath = ".";
|
if (classpath == 0) classpath = ".";
|
||||||
|
|
||||||
unsigned bcppl = bootClasspathPrepend ? strlen(bootClasspathPrepend) : 0;
|
unsigned bcppl = strlen(bootClasspathPrepend);
|
||||||
|
unsigned bcpl = strlen(bootClasspath);
|
||||||
|
unsigned bcpal = strlen(bootClasspathAppend);
|
||||||
unsigned cpl = strlen(classpath);
|
unsigned cpl = strlen(classpath);
|
||||||
|
|
||||||
unsigned classpathBufferSize = bcppl + cpl + 2;
|
unsigned classpathBufferSize = bcppl + bcpl + bcpal + cpl + 4;
|
||||||
char classpathBuffer[classpathBufferSize];
|
char classpathBuffer[classpathBufferSize];
|
||||||
|
char* classpathPointer = classpathBuffer;
|
||||||
|
|
||||||
if (bootClasspathPrepend) {
|
append(&classpathPointer, bootClasspathPrepend, bcppl, PATH_SEPARATOR);
|
||||||
snprintf(classpathBuffer, classpathBufferSize, "%s%c%s",
|
append(&classpathPointer, bootClasspath, bcpl, PATH_SEPARATOR);
|
||||||
bootClasspathPrepend, PATH_SEPARATOR, classpath);
|
append(&classpathPointer, bootClasspathAppend, bcpal, PATH_SEPARATOR);
|
||||||
} else {
|
append(&classpathPointer, classpath, cpl, 0);
|
||||||
memcpy(classpathBuffer, classpath, cpl + 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
System* s = makeSystem();
|
System* s = makeSystem();
|
||||||
Heap* h = makeHeap(s, heapLimit);
|
Heap* h = makeHeap(s, heapLimit);
|
||||||
|
21
src/main.cpp
21
src/main.cpp
@ -30,6 +30,8 @@ usageAndExit(const char* name)
|
|||||||
"\t[{-cp|-classpath} <classpath>]\n"
|
"\t[{-cp|-classpath} <classpath>]\n"
|
||||||
"\t[-Xmx<maximum heap size>]\n"
|
"\t[-Xmx<maximum heap size>]\n"
|
||||||
"\t[-Xbootclasspath/p:<classpath to prepend to bootstrap classpath>]\n"
|
"\t[-Xbootclasspath/p:<classpath to prepend to bootstrap classpath>]\n"
|
||||||
|
"\t[-Xbootclasspath:<bootstrap classpath>]\n"
|
||||||
|
"\t[-Xbootclasspath/a:<classpath to append to bootstrap classpath>]\n"
|
||||||
"\t[-D<property name>=<property value> ...]\n"
|
"\t[-D<property name>=<property value> ...]\n"
|
||||||
"\t<class name> [<argument> ...]\n", name);
|
"\t<class name> [<argument> ...]\n", name);
|
||||||
exit(-1);
|
exit(-1);
|
||||||
@ -73,21 +75,20 @@ main(int ac, const char** av)
|
|||||||
++ vmArgs.nOptions;
|
++ vmArgs.nOptions;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef BOOT_CLASSPATH
|
||||||
|
++ vmArgs.nOptions;
|
||||||
|
#endif
|
||||||
|
|
||||||
JavaVMOption options[vmArgs.nOptions];
|
JavaVMOption options[vmArgs.nOptions];
|
||||||
vmArgs.options = options;
|
vmArgs.options = options;
|
||||||
|
|
||||||
#ifdef BOOT_CLASSPATH
|
|
||||||
unsigned classpathBufferSize
|
|
||||||
= sizeof(BOOT_CLASSPATH) + 1 + strlen(classpath);
|
|
||||||
char classpathBuffer[classpathBufferSize];
|
|
||||||
|
|
||||||
snprintf(classpathBuffer, classpathBufferSize, "%s%c%s",
|
|
||||||
BOOT_CLASSPATH, PATH_SEPARATOR, classpath);
|
|
||||||
classpath = classpathBuffer;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
unsigned optionIndex = 0;
|
unsigned optionIndex = 0;
|
||||||
|
|
||||||
|
#ifdef BOOT_CLASSPATH
|
||||||
|
options[optionIndex++].optionString
|
||||||
|
= const_cast<char*>("-Xbootclasspath:" BOOT_CLASSPATH);
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef BOOT_LIBRARY
|
#ifdef BOOT_LIBRARY
|
||||||
options[optionIndex++].optionString
|
options[optionIndex++].optionString
|
||||||
= const_cast<char*>("-Davian.bootstrap=" BOOT_LIBRARY);
|
= const_cast<char*>("-Davian.bootstrap=" BOOT_LIBRARY);
|
||||||
|
Loading…
Reference in New Issue
Block a user