mirror of
https://github.com/corda/corda.git
synced 2025-01-04 04:04:27 +00:00
add support for passing properties to the VM via JNI; use vm.builtins property to specify builtin libraries
This commit is contained in:
parent
2de0decfe3
commit
b12b779c7f
@ -4,9 +4,9 @@ public class File {
|
||||
private static final String FileSeparator
|
||||
= System.getProperty("file.separator");
|
||||
|
||||
static {
|
||||
System.loadLibrary("natives");
|
||||
}
|
||||
// static {
|
||||
// System.loadLibrary("natives");
|
||||
// }
|
||||
|
||||
private final String path;
|
||||
|
||||
|
@ -1,9 +1,9 @@
|
||||
package java.io;
|
||||
|
||||
public class FileInputStream extends InputStream {
|
||||
static {
|
||||
System.loadLibrary("natives");
|
||||
}
|
||||
// static {
|
||||
// System.loadLibrary("natives");
|
||||
// }
|
||||
|
||||
private int fd;
|
||||
|
||||
|
@ -1,9 +1,9 @@
|
||||
package java.io;
|
||||
|
||||
public class FileOutputStream extends OutputStream {
|
||||
static {
|
||||
System.loadLibrary("natives");
|
||||
}
|
||||
// static {
|
||||
// System.loadLibrary("natives");
|
||||
// }
|
||||
|
||||
private int fd;
|
||||
|
||||
|
@ -19,9 +19,9 @@ public abstract class System {
|
||||
|
||||
private static Property properties;
|
||||
|
||||
static {
|
||||
loadLibrary("natives");
|
||||
}
|
||||
// static {
|
||||
// loadLibrary("natives");
|
||||
// }
|
||||
|
||||
public static final PrintStream out = new PrintStream
|
||||
(new BufferedOutputStream(new FileOutputStream(FileDescriptor.out)), true);
|
||||
|
@ -5,9 +5,9 @@ public class Inflater {
|
||||
private static final int Z_STREAM_END = 1;
|
||||
private static final int Z_NEED_DICT = 2;
|
||||
|
||||
static {
|
||||
System.loadLibrary("natives");
|
||||
}
|
||||
// static {
|
||||
// System.loadLibrary("natives");
|
||||
// }
|
||||
|
||||
private long peer;
|
||||
private byte[] input;
|
||||
|
2
makefile
2
makefile
@ -55,7 +55,7 @@ warnings = -Wall -Wextra -Werror -Wunused-parameter \
|
||||
|
||||
common-cflags = $(warnings) -fno-rtti -fno-exceptions \
|
||||
-I$(JAVA_HOME)/include -idirafter $(src) -I$(bld) -D__STDC_LIMIT_MACROS \
|
||||
-DBUILTIN_LIBRARIES=\"natives,tlscontext,scaler\" -D_JNI_IMPLEMENTATION_
|
||||
-D_JNI_IMPLEMENTATION_
|
||||
|
||||
system = posix
|
||||
asm = x86
|
||||
|
@ -496,9 +496,8 @@ Java_java_lang_Runtime_load(Thread* t, jclass, jstring name, jboolean mapName)
|
||||
char n[length + 1];
|
||||
stringChars(t, *name, n);
|
||||
|
||||
#ifdef BUILTIN_LIBRARIES
|
||||
if (mapName) {
|
||||
const char* s = BUILTIN_LIBRARIES;
|
||||
if (mapName and t->m->builtins) {
|
||||
const char* s = t->m->builtins;
|
||||
while (*s) {
|
||||
if (strncmp(s, n, length) == 0
|
||||
and (s[length] == ',' or s[length] == 0))
|
||||
@ -511,7 +510,6 @@ Java_java_lang_Runtime_load(Thread* t, jclass, jstring name, jboolean mapName)
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif // BUILTIN_LIBRARIES
|
||||
|
||||
for (System::Library* lib = t->m->libraries; lib; lib = lib->next()) {
|
||||
if (lib->name()
|
||||
|
@ -1837,9 +1837,12 @@ JNI_GetDefaultJavaVMInitArgs(void* args)
|
||||
JDK1_1InitArgs* a = static_cast<JDK1_1InitArgs*>(args);
|
||||
a->maxHeapSize = 128 * 1024 * 1024;
|
||||
a->classpath = ".";
|
||||
a->properties = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define BUILTINS_PROPERTY "vm.builtins"
|
||||
|
||||
extern "C" JNIEXPORT jint JNICALL
|
||||
JNI_CreateJavaVM(Machine** m, Thread** t, void* args)
|
||||
{
|
||||
@ -1851,6 +1854,15 @@ JNI_CreateJavaVM(Machine** m, Thread** t, void* args)
|
||||
Processor* p = makeProcessor(s);
|
||||
|
||||
*m = new (s->allocate(sizeof(Machine))) Machine(s, h, f, p);
|
||||
|
||||
if (a->properties) {
|
||||
for (const char** p = a->properties; *p; ++p) {
|
||||
if (strncmp(*p, BUILTINS_PROPERTY, sizeof(BUILTINS_PROPERTY)) == 0) {
|
||||
(*m)->builtins = (*p) + sizeof(BUILTINS_PROPERTY);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
*t = p->makeThread(*m, 0, 0);
|
||||
|
||||
return 0;
|
||||
|
@ -1350,6 +1350,7 @@ Machine::Machine(System* system, Heap* heap, Finder* finder,
|
||||
rootThread(0),
|
||||
exclusive(0),
|
||||
jniReferences(0),
|
||||
builtins(0),
|
||||
activeCount(0),
|
||||
liveCount(0),
|
||||
localThread(0),
|
||||
|
@ -1127,6 +1127,7 @@ class Machine {
|
||||
Thread* rootThread;
|
||||
Thread* exclusive;
|
||||
Reference* jniReferences;
|
||||
const char* builtins;
|
||||
unsigned activeCount;
|
||||
unsigned liveCount;
|
||||
System::Local* localThread;
|
||||
|
13
src/main.cpp
13
src/main.cpp
@ -28,12 +28,15 @@ main(int ac, const char** av)
|
||||
const char* class_ = 0;
|
||||
int argc = 0;
|
||||
const char** argv = 0;
|
||||
int propertyCount = 0;
|
||||
|
||||
for (int i = 1; i < ac; ++i) {
|
||||
if (strcmp(av[i], "-cp") == 0) {
|
||||
vmArgs.classpath = const_cast<char*>(av[++i]);
|
||||
} else if (strncmp(av[i], "-Xmx", 4) == 0) {
|
||||
vmArgs.maxHeapSize = atoi(av[i] + 4);
|
||||
} else if (strncmp(av[i], "-D", 2) == 0) {
|
||||
++ propertyCount;
|
||||
} else {
|
||||
class_ = av[i++];
|
||||
if (i < ac) {
|
||||
@ -44,6 +47,16 @@ main(int ac, const char** av)
|
||||
}
|
||||
}
|
||||
|
||||
const char* properties[propertyCount + 1];
|
||||
properties[propertyCount] = 0;
|
||||
for (int i = 1; i < ac; ++i) {
|
||||
if (strncmp(av[i], "-D", 2) == 0) {
|
||||
properties[--propertyCount] = av[i] + 2;
|
||||
}
|
||||
}
|
||||
|
||||
vmArgs.properties = const_cast<char**>(properties);
|
||||
|
||||
if (class_ == 0) {
|
||||
usageAndExit(av[0]);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user