mirror of
https://github.com/corda/corda.git
synced 2025-01-19 11:16:54 +00:00
enable JMX support for openjdk-src build and implement GetInputArgumentArray
This commit is contained in:
parent
5dbcbb825b
commit
4b9cb4f4e4
@ -48,6 +48,7 @@ openjdk-sources = \
|
|||||||
$(openjdk-src)/share/native/java/util/zip/ZipEntry.c \
|
$(openjdk-src)/share/native/java/util/zip/ZipEntry.c \
|
||||||
$(openjdk-src)/share/native/java/util/zip/ZipFile.c \
|
$(openjdk-src)/share/native/java/util/zip/ZipFile.c \
|
||||||
$(openjdk-src)/share/native/java/util/zip/zip_util.c \
|
$(openjdk-src)/share/native/java/util/zip/zip_util.c \
|
||||||
|
$(openjdk-src)/share/native/sun/management/VMManagementImpl.c \
|
||||||
$(openjdk-src)/share/native/sun/misc/GC.c \
|
$(openjdk-src)/share/native/sun/misc/GC.c \
|
||||||
$(openjdk-src)/share/native/sun/misc/MessageUtils.c \
|
$(openjdk-src)/share/native/sun/misc/MessageUtils.c \
|
||||||
$(openjdk-src)/share/native/sun/misc/NativeSignalHandler.c \
|
$(openjdk-src)/share/native/sun/misc/NativeSignalHandler.c \
|
||||||
@ -112,6 +113,7 @@ openjdk-headers-classes = \
|
|||||||
java.util.zip.Inflater \
|
java.util.zip.Inflater \
|
||||||
java.util.zip.ZipEntry \
|
java.util.zip.ZipEntry \
|
||||||
java.util.zip.ZipFile \
|
java.util.zip.ZipFile \
|
||||||
|
sun.management.VMManagementImpl \
|
||||||
sun.misc.GC \
|
sun.misc.GC \
|
||||||
sun.misc.MessageUtils \
|
sun.misc.MessageUtils \
|
||||||
sun.misc.NativeSignalHandler \
|
sun.misc.NativeSignalHandler \
|
||||||
@ -151,6 +153,7 @@ openjdk-cflags = \
|
|||||||
"-I$(openjdk-src)/share/native/java/lang/fdlibm/include" \
|
"-I$(openjdk-src)/share/native/java/lang/fdlibm/include" \
|
||||||
"-I$(openjdk-src)/share/native/java/net" \
|
"-I$(openjdk-src)/share/native/java/net" \
|
||||||
"-I$(openjdk-src)/share/native/java/util/zip" \
|
"-I$(openjdk-src)/share/native/java/util/zip" \
|
||||||
|
"-I$(openjdk-src)/share/native/sun/management" \
|
||||||
"-I$(openjdk-src)/share/native/sun/nio/ch" \
|
"-I$(openjdk-src)/share/native/sun/nio/ch" \
|
||||||
"-I$(openjdk-src)/share/javavm/include" \
|
"-I$(openjdk-src)/share/javavm/include" \
|
||||||
-D_LITTLE_ENDIAN \
|
-D_LITTLE_ENDIAN \
|
||||||
@ -291,13 +294,15 @@ else
|
|||||||
"-I$(openjdk-src)/solaris/native/java/lang" \
|
"-I$(openjdk-src)/solaris/native/java/lang" \
|
||||||
"-I$(openjdk-src)/solaris/native/java/net" \
|
"-I$(openjdk-src)/solaris/native/java/net" \
|
||||||
"-I$(openjdk-src)/solaris/native/java/util" \
|
"-I$(openjdk-src)/solaris/native/java/util" \
|
||||||
|
"-I$(openjdk-src)/solaris/native/sun/management" \
|
||||||
"-I$(openjdk-src)/solaris/native/sun/nio/ch" \
|
"-I$(openjdk-src)/solaris/native/sun/nio/ch" \
|
||||||
"-I$(openjdk-src)/solaris/javavm/include" \
|
"-I$(openjdk-src)/solaris/javavm/include" \
|
||||||
"-I$(openjdk-src)/solaris/hpi/include"
|
"-I$(openjdk-src)/solaris/hpi/include"
|
||||||
endif
|
endif
|
||||||
|
|
||||||
openjdk-local-sources = \
|
openjdk-local-sources = \
|
||||||
$(src)/openjdk/my_net_util.c
|
$(src)/openjdk/my_net_util.c \
|
||||||
|
$(src)/openjdk/my_management.c
|
||||||
|
|
||||||
c-objects = $(foreach x,$(1),$(patsubst $(2)/%.c,$(3)/%-openjdk.o,$(x)))
|
c-objects = $(foreach x,$(1),$(patsubst $(2)/%.c,$(3)/%-openjdk.o,$(x)))
|
||||||
|
|
||||||
|
@ -572,7 +572,7 @@ main(int ac, const char** av)
|
|||||||
p->initialize(&image, code, CodeCapacity);
|
p->initialize(&image, code, CodeCapacity);
|
||||||
|
|
||||||
Machine* m = new (h->allocate(sizeof(Machine))) Machine
|
Machine* m = new (h->allocate(sizeof(Machine))) Machine
|
||||||
(s, h, f, 0, p, c, 0, 0);
|
(s, h, f, 0, p, c, 0, 0, 0, 0);
|
||||||
Thread* t = p->makeThread(m, 0, 0);
|
Thread* t = p->makeThread(m, 0, 0);
|
||||||
|
|
||||||
enter(t, Thread::ActiveState);
|
enter(t, Thread::ActiveState);
|
||||||
|
@ -355,7 +355,7 @@ class MyClasspath : public Classpath {
|
|||||||
|
|
||||||
MyClasspath(System* s, Allocator* allocator, const char* javaHome,
|
MyClasspath(System* s, Allocator* allocator, const char* javaHome,
|
||||||
const char* embedPrefix):
|
const char* embedPrefix):
|
||||||
allocator(allocator), ranNetOnLoad(0)
|
allocator(allocator), ranNetOnLoad(0), ranManagementOnLoad(0)
|
||||||
{
|
{
|
||||||
class StringBuilder {
|
class StringBuilder {
|
||||||
public:
|
public:
|
||||||
@ -613,6 +613,7 @@ class MyClasspath : public Classpath {
|
|||||||
unsigned zipEntryCsizeField;
|
unsigned zipEntryCsizeField;
|
||||||
unsigned zipEntryMethodField;
|
unsigned zipEntryMethodField;
|
||||||
bool ranNetOnLoad;
|
bool ranNetOnLoad;
|
||||||
|
bool ranManagementOnLoad;
|
||||||
char buffer[BufferSize];
|
char buffer[BufferSize];
|
||||||
JmmInterface jmmInterface;
|
JmmInterface jmmInterface;
|
||||||
};
|
};
|
||||||
@ -1615,6 +1616,9 @@ getBootstrapResources(Thread* t, object, uintptr_t* arguments)
|
|||||||
extern "C" JNIEXPORT jint JNICALL
|
extern "C" JNIEXPORT jint JNICALL
|
||||||
net_JNI_OnLoad(JavaVM*, void*);
|
net_JNI_OnLoad(JavaVM*, void*);
|
||||||
|
|
||||||
|
extern "C" JNIEXPORT jint JNICALL
|
||||||
|
management_JNI_OnLoad(JavaVM*, void*);
|
||||||
|
|
||||||
void JNICALL
|
void JNICALL
|
||||||
loadLibrary(Thread* t, object, uintptr_t* arguments)
|
loadLibrary(Thread* t, object, uintptr_t* arguments)
|
||||||
{
|
{
|
||||||
@ -1643,6 +1647,23 @@ loadLibrary(Thread* t, object, uintptr_t* arguments)
|
|||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
} else if (strcmp(n, "management") == 0) {
|
||||||
|
bool ran;
|
||||||
|
|
||||||
|
{ ACQUIRE(t, t->m->classLock);
|
||||||
|
|
||||||
|
local::MyClasspath* c = static_cast<local::MyClasspath*>
|
||||||
|
(t->m->classpath);
|
||||||
|
|
||||||
|
ran = c->ranManagementOnLoad;
|
||||||
|
c->ranManagementOnLoad = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (not ran) {
|
||||||
|
management_JNI_OnLoad(t->m, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
} else if (strcmp(n, "zip") == 0
|
} else if (strcmp(n, "zip") == 0
|
||||||
or strcmp(n, "nio") == 0)
|
or strcmp(n, "nio") == 0)
|
||||||
{
|
{
|
||||||
@ -5118,6 +5139,27 @@ GetVersion(Thread*)
|
|||||||
return JMM_VERSION_1_0;
|
return JMM_VERSION_1_0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint64_t
|
||||||
|
getInputArgumentArray(Thread* t, uintptr_t*)
|
||||||
|
{
|
||||||
|
object array = makeObjectArray
|
||||||
|
(t, type(t, Machine::StringType), t->m->argumentCount);
|
||||||
|
PROTECT(t, array);
|
||||||
|
|
||||||
|
for (unsigned i = 0; i < t->m->argumentCount; ++i) {
|
||||||
|
object argument = makeString(t, t->m->arguments[i]);
|
||||||
|
set(t, array, ArrayBody + (i * BytesPerWord), argument);
|
||||||
|
}
|
||||||
|
|
||||||
|
return reinterpret_cast<uintptr_t>(makeLocalReference(t, array));
|
||||||
|
}
|
||||||
|
|
||||||
|
jobjectArray JNICALL
|
||||||
|
GetInputArgumentArray(Thread* t)
|
||||||
|
{
|
||||||
|
return reinterpret_cast<jobjectArray>(run(t, getInputArgumentArray, 0));
|
||||||
|
}
|
||||||
|
|
||||||
jint JNICALL
|
jint JNICALL
|
||||||
GetOptionalSupport(Thread*, jmmOptionalSupport* support)
|
GetOptionalSupport(Thread*, jmmOptionalSupport* support)
|
||||||
{
|
{
|
||||||
@ -5203,6 +5245,7 @@ EXPORT(JVM_GetManagement)(jint version)
|
|||||||
interface->GetBoolAttribute = GetBoolAttribute;
|
interface->GetBoolAttribute = GetBoolAttribute;
|
||||||
interface->GetMemoryManagers = GetMemoryManagers;
|
interface->GetMemoryManagers = GetMemoryManagers;
|
||||||
interface->GetMemoryPools = GetMemoryPools;
|
interface->GetMemoryPools = GetMemoryPools;
|
||||||
|
interface->GetInputArgumentArray = GetInputArgumentArray;
|
||||||
|
|
||||||
return interface;
|
return interface;
|
||||||
} else {
|
} else {
|
||||||
|
@ -3337,15 +3337,24 @@ JNI_CreateJavaVM(Machine** m, Thread** t, void* args)
|
|||||||
|
|
||||||
const char** properties = static_cast<const char**>
|
const char** properties = static_cast<const char**>
|
||||||
(h->allocate(sizeof(const char*) * propertyCount));
|
(h->allocate(sizeof(const char*) * propertyCount));
|
||||||
|
|
||||||
const char** propertyPointer = properties;
|
const char** propertyPointer = properties;
|
||||||
|
|
||||||
|
const char** arguments = static_cast<const char**>
|
||||||
|
(h->allocate(sizeof(const char*) * a->nOptions));
|
||||||
|
|
||||||
|
const char** argumentPointer = arguments;
|
||||||
|
|
||||||
for (int i = 0; i < a->nOptions; ++i) {
|
for (int i = 0; i < a->nOptions; ++i) {
|
||||||
if (strncmp(a->options[i].optionString, "-D", 2) == 0) {
|
if (strncmp(a->options[i].optionString, "-D", 2) == 0) {
|
||||||
*(propertyPointer++) = a->options[i].optionString + 2;
|
*(propertyPointer++) = a->options[i].optionString + 2;
|
||||||
}
|
}
|
||||||
|
*(argumentPointer++) = a->options[i].optionString;
|
||||||
}
|
}
|
||||||
|
|
||||||
*m = new (h->allocate(sizeof(Machine)))
|
*m = new (h->allocate(sizeof(Machine)))
|
||||||
Machine(s, h, bf, af, p, c, properties, propertyCount);
|
Machine
|
||||||
|
(s, h, bf, af, p, c, properties, propertyCount, arguments, a->nOptions);
|
||||||
|
|
||||||
*t = p->makeThread(*m, 0, 0);
|
*t = p->makeThread(*m, 0, 0);
|
||||||
|
|
||||||
|
@ -2399,7 +2399,8 @@ namespace vm {
|
|||||||
|
|
||||||
Machine::Machine(System* system, Heap* heap, Finder* bootFinder,
|
Machine::Machine(System* system, Heap* heap, Finder* bootFinder,
|
||||||
Finder* appFinder, Processor* processor, Classpath* classpath,
|
Finder* appFinder, Processor* processor, Classpath* classpath,
|
||||||
const char** properties, unsigned propertyCount):
|
const char** properties, unsigned propertyCount,
|
||||||
|
const char** arguments, unsigned argumentCount):
|
||||||
vtable(&javaVMVTable),
|
vtable(&javaVMVTable),
|
||||||
system(system),
|
system(system),
|
||||||
heapClient(new (heap->allocate(sizeof(HeapClient)))
|
heapClient(new (heap->allocate(sizeof(HeapClient)))
|
||||||
@ -2415,6 +2416,8 @@ Machine::Machine(System* system, Heap* heap, Finder* bootFinder,
|
|||||||
jniReferences(0),
|
jniReferences(0),
|
||||||
properties(properties),
|
properties(properties),
|
||||||
propertyCount(propertyCount),
|
propertyCount(propertyCount),
|
||||||
|
arguments(arguments),
|
||||||
|
argumentCount(argumentCount),
|
||||||
activeCount(0),
|
activeCount(0),
|
||||||
liveCount(0),
|
liveCount(0),
|
||||||
daemonCount(0),
|
daemonCount(0),
|
||||||
@ -2481,6 +2484,8 @@ Machine::dispose()
|
|||||||
heap->free(heapPool[i], ThreadHeapSizeInBytes);
|
heap->free(heapPool[i], ThreadHeapSizeInBytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
heap->free(arguments, sizeof(const char*) * argumentCount);
|
||||||
|
|
||||||
heap->free(properties, sizeof(const char*) * propertyCount);
|
heap->free(properties, sizeof(const char*) * propertyCount);
|
||||||
|
|
||||||
static_cast<HeapClient*>(heapClient)->dispose();
|
static_cast<HeapClient*>(heapClient)->dispose();
|
||||||
|
@ -1273,7 +1273,8 @@ class Machine {
|
|||||||
|
|
||||||
Machine(System* system, Heap* heap, Finder* bootFinder, Finder* appFinder,
|
Machine(System* system, Heap* heap, Finder* bootFinder, Finder* appFinder,
|
||||||
Processor* processor, Classpath* classpath, const char** properties,
|
Processor* processor, Classpath* classpath, const char** properties,
|
||||||
unsigned propertyCount);
|
unsigned propertyCount, const char** arguments,
|
||||||
|
unsigned argumentCount);
|
||||||
|
|
||||||
~Machine() {
|
~Machine() {
|
||||||
dispose();
|
dispose();
|
||||||
@ -1295,6 +1296,8 @@ class Machine {
|
|||||||
Reference* jniReferences;
|
Reference* jniReferences;
|
||||||
const char** properties;
|
const char** properties;
|
||||||
unsigned propertyCount;
|
unsigned propertyCount;
|
||||||
|
const char** arguments;
|
||||||
|
unsigned argumentCount;
|
||||||
unsigned activeCount;
|
unsigned activeCount;
|
||||||
unsigned liveCount;
|
unsigned liveCount;
|
||||||
unsigned daemonCount;
|
unsigned daemonCount;
|
||||||
|
2
src/openjdk/my_management.c
Normal file
2
src/openjdk/my_management.c
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
#define JNI_OnLoad management_JNI_OnLoad
|
||||||
|
#include "management.c"
|
Loading…
Reference in New Issue
Block a user