use of org.graalvm.compiler.hotspot.management.libgraal.annotation.JMXToLibGraal in project graal by oracle.
the class JMXToLibGraalEntryPoints method pollRegistrations.
/**
* Returns the pending {@link DynamicMBean} registrations.
*/
@JMXToLibGraal(PollRegistrations)
@CEntryPoint(name = "Java_org_graalvm_compiler_hotspot_management_JMXToLibGraalCalls_pollRegistrations")
@SuppressWarnings({ "try", "unused" })
static JNI.JLongArray pollRegistrations(JNI.JNIEnv env, JNI.JClass hsClazz, @CEntryPoint.IsolateThreadContext long isolateThreadId) {
JNIMethodScope scope = LibGraalUtil.openScope(JMXToLibGraalEntryPoints.class, PollRegistrations, env);
try (JNIMethodScope s = scope) {
List<MBeanProxy<?>> registrations = MBeanProxy.drainRegistrations();
JNI.JLongArray res = JNIUtil.NewLongArray(env, registrations.size());
CLongPointer elems = JNIUtil.GetLongArrayElements(env, res, WordFactory.nullPointer());
try {
ObjectHandles globalHandles = ObjectHandles.getGlobal();
for (int i = 0; i < registrations.size(); i++) {
long handle = globalHandles.create(registrations.get(i)).rawValue();
elems.write(i, handle);
}
} finally {
JNIUtil.ReleaseLongArrayElements(env, res, elems, JNI.JArray.MODE_WRITE_RELEASE);
}
scope.setObjectResult(res);
}
return scope.getObjectResult();
}
use of org.graalvm.compiler.hotspot.management.libgraal.annotation.JMXToLibGraal in project graal by oracle.
the class JMXToLibGraalEntryPoints method getMBeanInfo.
/**
* Returns the {@link MBeanInfo} encoded as a byte array using {@link OptionsEncoder}.
*/
@JMXToLibGraal(GetMBeanInfo)
@CEntryPoint(name = "Java_org_graalvm_compiler_hotspot_management_JMXToLibGraalCalls_getMBeanInfo")
@SuppressWarnings({ "try", "unused" })
static JNI.JByteArray getMBeanInfo(JNI.JNIEnv env, JNI.JClass hsClazz, @CEntryPoint.IsolateThreadContext long isolateThreadId, long handle) {
JNIMethodScope scope = LibGraalUtil.openScope(JMXToLibGraalEntryPoints.class, GetMBeanInfo, env);
try (JNIMethodScope s = scope) {
ObjectHandles globalHandles = ObjectHandles.getGlobal();
MBeanProxy<?> registration = globalHandles.get(WordFactory.pointer(handle));
MBeanInfo info = registration.getBean().getMBeanInfo();
Map<String, Object> map = new LinkedHashMap<>();
map.put("bean.class", info.getClassName());
map.put("bean.description", info.getDescription());
for (MBeanAttributeInfo attr : info.getAttributes()) {
putAttributeInfo(map, attr);
}
int opCounter = 0;
for (MBeanOperationInfo op : info.getOperations()) {
putOperationInfo(map, op, ++opCounter);
}
scope.setObjectResult(mapToRaw(env, map));
}
return scope.getObjectResult();
}
Aggregations