From ba26fd8430a6b0f4f2e1303c5943ac30c0882dab Mon Sep 17 00:00:00 2001 From: Gengchen Tuo Date: Fri, 23 Aug 2024 12:45:47 -0400 Subject: [PATCH] Add native method stubs for jdk.jfr.internal.jvm Signed-off-by: Gengchen Tuo --- runtime/jcl/CMakeLists.txt | 8 + runtime/jcl/common/jdk_jfr_internal_JVM.cpp | 451 ++++++++++++++++++++ runtime/jcl/exports.cmake | 65 +++ runtime/jcl/module.xml | 1 + runtime/jcl/uma/jfr_exports.xml | 65 +++ runtime/jcl/uma/jfr_objects.xml | 24 ++ 6 files changed, 614 insertions(+) create mode 100644 runtime/jcl/common/jdk_jfr_internal_JVM.cpp create mode 100644 runtime/jcl/uma/jfr_objects.xml diff --git a/runtime/jcl/CMakeLists.txt b/runtime/jcl/CMakeLists.txt index ab78c86f0b1..c78a29866f5 100644 --- a/runtime/jcl/CMakeLists.txt +++ b/runtime/jcl/CMakeLists.txt @@ -238,6 +238,14 @@ if(NOT JAVA_SPEC_VERSION LESS 19) ) endif() +if(J9VM_OPT_JFR) + # JFR sources + target_sources(jclse + PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR}/common/jdk_jfr_internal_JVM.cpp + ) +endif() + include(exports.cmake) target_enable_ddr(jclse) diff --git a/runtime/jcl/common/jdk_jfr_internal_JVM.cpp b/runtime/jcl/common/jdk_jfr_internal_JVM.cpp new file mode 100644 index 00000000000..7134a69da82 --- /dev/null +++ b/runtime/jcl/common/jdk_jfr_internal_JVM.cpp @@ -0,0 +1,451 @@ +/******************************************************************************* + * Copyright IBM Corp. and others 2024 + * + * This program and the accompanying materials are made available under + * the terms of the Eclipse Public License 2.0 which accompanies this + * distribution and is available at https://www.eclipse.org/legal/epl-2.0/ + * or the Apache License, Version 2.0 which accompanies this distribution and + * is available at https://www.apache.org/licenses/LICENSE-2.0. + * + * This Source Code may also be made available under the following + * Secondary Licenses when the conditions for such availability set + * forth in the Eclipse Public License, v. 2.0 are satisfied: GNU + * General Public License, version 2 with the GNU Classpath + * Exception [1] and GNU General Public License, version 2 with the + * OpenJDK Assembly Exception [2]. + * + * [1] https://www.gnu.org/software/classpath/license.html + * [2] https://openjdk.org/legal/assembly-exception.html + * + * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0 OR GPL-2.0-only WITH OpenJDK-assembly-exception-1.0 + *******************************************************************************/ + +#include "jni.h" + +extern "C" { + +void JNICALL +Java_jdk_jfr_internal_JVM_registerNatives(JNIEnv *env, jclass clazz) +{ + // TODO: implementation +} + +void JNICALL +Java_jdk_jfr_internal_JVM_markChunkFinal(JNIEnv *env, jclass clazz) +{ + // TODO: implementation +} + +void JNICALL +Java_jdk_jfr_internal_JVM_beginRecording(JNIEnv *env, jclass clazz) +{ + // TODO: implementation +} + +jboolean JNICALL +Java_jdk_jfr_internal_JVM_isRecording(JNIEnv *env, jclass clazz) +{ + // TODO: implementation + return JNI_FALSE; +} + +void JNICALL +Java_jdk_jfr_internal_JVM_endRecording(JNIEnv *env, jclass clazz) +{ + // TODO: implementation +} + +jlong JNICALL +Java_jdk_jfr_internal_JVM_counterTime(JNIEnv *env, jclass clazz) +{ + // TODO: implementation + return 0; +} + +jboolean JNICALL +Java_jdk_jfr_internal_JVM_emitEvent(JNIEnv *env, jclass clazz, jlong eventTypeId, jlong timestamp, jlong periodicType) +{ + // TODO: implementation + return JNI_FALSE; +} + +jobject JNICALL +Java_jdk_jfr_internal_JVM_getAllEventClasses(JNIEnv *env, jclass clazz) +{ + // TODO: implementation + return NULL; +} + +jlong JNICALL +Java_jdk_jfr_internal_JVM_getUnloadedEventClassCount(JNIEnv *env, jclass clazz) +{ + // TODO: implementation + return 0; +} + +jlong JNICALL +Java_jdk_jfr_internal_JVM_getClassId(JNIEnv *env, jclass clz, jobject clazz) +{ + // TODO: implementation + return 0; +} + +jstring JNICALL +Java_jdk_jfr_internal_JVM_getPid(JNIEnv *env, jclass clazz) +{ + // TODO: implementation + return NULL; +} + +jlong JNICALL +Java_jdk_jfr_internal_JVM_getStackTraceId(JNIEnv *env, jclass clazz, jint skipCount) +{ + // TODO: implementation + return 0; +} + +jlong JNICALL +Java_jdk_jfr_internal_JVM_getThreadId(JNIEnv *env, jclass clazz, jobject t) +{ + // TODO: implementation + return 0; +} + +jlong JNICALL +Java_jdk_jfr_internal_JVM_getTicksFrequency(JNIEnv *env, jclass clazz) +{ + // TODO: implementation + return 0; +} + +void JNICALL +Java_jdk_jfr_internal_JVM_log(JNIEnv *env, jclass clazz, jint tagSetId, jint level, jstring message) +{ + // TODO: implementation +} + +void JNICALL +Java_jdk_jfr_internal_JVM_logEvent(JNIEnv *env, jclass clazz, jint level, jobjectArray lines, jboolean system) +{ + // TODO: implementation +} + +void JNICALL +Java_jdk_jfr_internal_JVM_subscribeLogLevel(JNIEnv *env, jclass clazz, jobject lt, jint tagSetId) +{ + // TODO: implementation +} + +void JNICALL +Java_jdk_jfr_internal_JVM_retransformClasses(JNIEnv *env, jclass clazz, jobjectArray classes) +{ + // TODO: implementation +} + +void JNICALL +Java_jdk_jfr_internal_JVM_setEnabled(JNIEnv *env, jclass clazz, jlong eventTypeId, jboolean enabled) +{ + // TODO: implementation +} + +void JNICALL +Java_jdk_jfr_internal_JVM_setFileNotification(JNIEnv *env, jclass clazz, jlong delta) +{ + // TODO: implementation +} + +void JNICALL +Java_jdk_jfr_internal_JVM_setGlobalBufferCount(JNIEnv *env, jclass clazz, jlong count) +{ + // TODO: implementation +} + +void JNICALL +Java_jdk_jfr_internal_JVM_setGlobalBufferSize(JNIEnv *env, jclass clazz, jlong size) +{ + // TODO: implementation +} + +void JNICALL +Java_jdk_jfr_internal_JVM_setMemorySize(JNIEnv *env, jclass clazz, jlong size) +{ + // TODO: implementation +} + +void JNICALL +Java_jdk_jfr_internal_JVM_setMethodSamplingPeriod(JNIEnv *env, jclass clazz, jlong type, jlong periodMillis) +{ + // TODO: implementation +} + +void JNICALL +Java_jdk_jfr_internal_JVM_setOutput(JNIEnv *env, jclass clazz, jstring file) +{ + // TODO: implementation +} + +void JNICALL +Java_jdk_jfr_internal_JVM_setForceInstrumentation(JNIEnv *env, jclass clazz, jboolean force) +{ + // TODO: implementation +} + +void JNICALL +Java_jdk_jfr_internal_JVM_setCompressedIntegers(JNIEnv *env, jclass clazz, jboolean compressed) +{ + // TODO: implementation +} + +void JNICALL +Java_jdk_jfr_internal_JVM_setStackDepth(JNIEnv *env, jclass clazz, jint depth) +{ + // TODO: implementation +} + +void JNICALL +Java_jdk_jfr_internal_JVM_setStackTraceEnabled(JNIEnv *env, jclass clazz, jlong eventTypeId, jboolean enabled) +{ + // TODO: implementation +} + +void JNICALL +Java_jdk_jfr_internal_JVM_setThreadBufferSize(JNIEnv *env, jclass clazz, jlong size) +{ + // TODO: implementation +} + +jboolean JNICALL +Java_jdk_jfr_internal_JVM_setThreshold(JNIEnv *env, jclass clazz, jlong eventTypeId, jlong ticks) +{ + // TODO: implementation + return JNI_FALSE; +} + +void JNICALL +Java_jdk_jfr_internal_JVM_storeMetadataDescriptor(JNIEnv *env, jclass clazz, jbyteArray bytes) +{ + // TODO: implementation +} + +jboolean JNICALL +Java_jdk_jfr_internal_JVM_getAllowedToDoEventRetransforms(JNIEnv *env, jclass clazz) +{ + // TODO: implementation + return JNI_FALSE; +} + +jboolean JNICALL +Java_jdk_jfr_internal_JVM_createJFR(JNIEnv *env, jclass clazz, jboolean simulateFailure) +{ + // TODO: implementation + return JNI_FALSE; +} + +jboolean JNICALL +Java_jdk_jfr_internal_JVM_destroyJFR(JNIEnv *env, jclass clazz) +{ + // TODO: implementation + return JNI_FALSE; +} + +jboolean JNICALL +Java_jdk_jfr_internal_JVM_isAvailable(JNIEnv *env, jclass clazz) +{ + // TODO: implementation + return JNI_FALSE; +} + +jdouble JNICALL +Java_jdk_jfr_internal_JVM_getTimeConversionFactor(JNIEnv *env, jclass clazz) +{ + // TODO: implementation + return 0; +} + +jlong JNICALL +Java_jdk_jfr_internal_JVM_getTypeId__Ljava_lang_Class_2(JNIEnv *env, jclass clazz, jobject clazz2) +{ + // TODO: implementation + return 0; +} + +jobject JNICALL +Java_jdk_jfr_internal_JVM_getEventWriter(JNIEnv *env, jclass clazz) +{ + // TODO: implementation + return NULL; +} + +jobject JNICALL +Java_jdk_jfr_internal_JVM_newEventWriter(JNIEnv *env, jclass clazz) +{ + // TODO: implementation + return NULL; +} + +void JNICALL +Java_jdk_jfr_internal_JVM_flush__Ljava_lang_Object_2II(JNIEnv *env, jclass clazz, jobject writer, jint uncommittedSize, jint requestedSize) +{ + // TODO: implementation +} + +jlong JNICALL +Java_jdk_jfr_internal_JVM_commit(JNIEnv *env, jclass clazz, jlong nextPosition) +{ + // TODO: implementation + return 0; +} + +void JNICALL +Java_jdk_jfr_internal_JVM_flush__(JNIEnv *env, jclass clazz) +{ + // TODO: implementation +} + +void JNICALL +Java_jdk_jfr_internal_JVM_setRepositoryLocation(JNIEnv *env, jclass clazz, jstring dirText) +{ + // TODO: implementation +} + +void JNICALL +Java_jdk_jfr_internal_JVM_setDumpPath(JNIEnv *env, jclass clazz, jstring dumpPathText) +{ + // TODO: implementation +} + +jstring JNICALL +Java_jdk_jfr_internal_JVM_getDumpPath(JNIEnv *env, jclass clazz) +{ + // TODO: implementation + return NULL; +} + +void JNICALL +Java_jdk_jfr_internal_JVM_abort(JNIEnv *env, jclass clazz, jstring errorMsg) +{ + // TODO: implementation +} + +jboolean JNICALL +Java_jdk_jfr_internal_JVM_addStringConstant(JNIEnv *env, jclass clazz, jlong id, jstring s) +{ + // TODO: implementation + return JNI_FALSE; +} + +void JNICALL +Java_jdk_jfr_internal_JVM_uncaughtException(JNIEnv *env, jclass clazz, jobject thread, jthrowable t) +{ + // TODO: implementation +} + +jboolean JNICALL +Java_jdk_jfr_internal_JVM_setCutoff(JNIEnv *env, jclass clazz, jlong eventTypeId, jlong cutoffTicks) +{ + // TODO: implementation + return JNI_FALSE; +} + +jboolean JNICALL +Java_jdk_jfr_internal_JVM_setThrottle(JNIEnv *env, jclass clazz, jlong eventTypeId, jlong eventSampleSize, jlong period_ms) +{ + // TODO: implementation + return JNI_FALSE; +} + +void JNICALL +Java_jdk_jfr_internal_JVM_emitOldObjectSamples(JNIEnv *env, jclass clazz, jlong cutoff, jboolean emitAll, jboolean skipBFS) +{ + // TODO: implementation +} + +jboolean JNICALL +Java_jdk_jfr_internal_JVM_shouldRotateDisk(JNIEnv *env, jclass clazz) +{ + // TODO: implementation + return JNI_FALSE; +} + +void JNICALL +Java_jdk_jfr_internal_JVM_exclude(JNIEnv *env, jclass clazz, jobject thread) +{ + // TODO: implementation +} + +void JNICALL +Java_jdk_jfr_internal_JVM_include(JNIEnv *env, jclass clazz, jobject thread) +{ + // TODO: implementation +} + +jboolean JNICALL +Java_jdk_jfr_internal_JVM_isExcluded__Ljava_lang_Thread_2(JNIEnv *env, jclass clazz, jobject thread) +{ + // TODO: implementation + return JNI_FALSE; +} + +jboolean JNICALL +Java_jdk_jfr_internal_JVM_isExcluded__Ljava_lang_Class_2(JNIEnv *env, jclass clazz, jobject eventClass) +{ + // TODO: implementation + return JNI_FALSE; +} + +jboolean JNICALL +Java_jdk_jfr_internal_JVM_isInstrumented(JNIEnv *env, jclass clazz, jobject eventClass) +{ + // TODO: implementation + return JNI_FALSE; +} + +jlong JNICALL +Java_jdk_jfr_internal_JVM_getChunkStartNanos(JNIEnv *env, jclass clazz) +{ + // TODO: implementation + return 0; +} + +jboolean JNICALL +Java_jdk_jfr_internal_JVM_setConfiguration(JNIEnv *env, jclass clazz, jobject eventClass, jobject configuration) +{ + // TODO: implementation + return JNI_FALSE; +} + +jobject JNICALL +Java_jdk_jfr_internal_JVM_getConfiguration(JNIEnv *env, jclass clazz, jobject eventClass) +{ + // TODO: implementation + return NULL; +} + +jlong JNICALL +Java_jdk_jfr_internal_JVM_getTypeId__Ljava_lang_String_2(JNIEnv *env, jclass clazz, jstring name) +{ + // TODO: implementation + return 0; +} + +jboolean JNICALL +Java_jdk_jfr_internal_JVM_isContainerized(JNIEnv *env, jclass clazz) +{ + // TODO: implementation + return JNI_FALSE; +} + +jlong JNICALL +Java_jdk_jfr_internal_JVM_hostTotalMemory(JNIEnv *env, jclass clazz) +{ + // TODO: implementation + return 0; +} + +void JNICALL +java_jdk_jfr_internal_JVM_emitDataLoss(JNIEnv *env, jclass clazz, jlong bytes) +{ + // TODO: implementation +} + +} diff --git a/runtime/jcl/exports.cmake b/runtime/jcl/exports.cmake index f1822b11e1f..5606213ea04 100644 --- a/runtime/jcl/exports.cmake +++ b/runtime/jcl/exports.cmake @@ -690,6 +690,71 @@ endif() if(J9VM_OPT_JFR) omr_add_exports(jclse Java_com_ibm_oti_vm_VM_triggerExecutionSample + Java_jdk_jfr_internal_JVM_registerNatives + Java_jdk_jfr_internal_JVM_markChunkFinal + Java_jdk_jfr_internal_JVM_beginRecording + Java_jdk_jfr_internal_JVM_isRecording + Java_jdk_jfr_internal_JVM_endRecording + Java_jdk_jfr_internal_JVM_counterTime + Java_jdk_jfr_internal_JVM_emitEvent + Java_jdk_jfr_internal_JVM_getAllEventClasses + Java_jdk_jfr_internal_JVM_getUnloadedEventClassCount + Java_jdk_jfr_internal_JVM_getClassId + Java_jdk_jfr_internal_JVM_getPid + Java_jdk_jfr_internal_JVM_getStackTraceId + Java_jdk_jfr_internal_JVM_getThreadId + Java_jdk_jfr_internal_JVM_getTicksFrequency + Java_jdk_jfr_internal_JVM_log + Java_jdk_jfr_internal_JVM_logEvent + Java_jdk_jfr_internal_JVM_subscribeLogLevel + Java_jdk_jfr_internal_JVM_retransformClasses + Java_jdk_jfr_internal_JVM_setEnabled + Java_jdk_jfr_internal_JVM_setFileNotification + Java_jdk_jfr_internal_JVM_setGlobalBufferCount + Java_jdk_jfr_internal_JVM_setGlobalBufferSize + Java_jdk_jfr_internal_JVM_setMemorySize + Java_jdk_jfr_internal_JVM_setMethodSamplingPeriod + Java_jdk_jfr_internal_JVM_setOutput + Java_jdk_jfr_internal_JVM_setForceInstrumentation + Java_jdk_jfr_internal_JVM_setCompressedIntegers + Java_jdk_jfr_internal_JVM_setStackDepth + Java_jdk_jfr_internal_JVM_setStackTraceEnabled + Java_jdk_jfr_internal_JVM_setThreadBufferSize + Java_jdk_jfr_internal_JVM_setThreshold + Java_jdk_jfr_internal_JVM_storeMetadataDescriptor + Java_jdk_jfr_internal_JVM_getAllowedToDoEventRetransforms + Java_jdk_jfr_internal_JVM_createJFR + Java_jdk_jfr_internal_JVM_destroyJFR + Java_jdk_jfr_internal_JVM_isAvailable + Java_jdk_jfr_internal_JVM_getTimeConversionFactor + Java_jdk_jfr_internal_JVM_getTypeId + Java_jdk_jfr_internal_JVM_getEventWriter + Java_jdk_jfr_internal_JVM_newEventWriter + Java_jdk_jfr_internal_JVM_flush__Ljava_lang_Object_2II + Java_jdk_jfr_internal_JVM_commit + Java_jdk_jfr_internal_JVM_flush__ + Java_jdk_jfr_internal_JVM_setRepositoryLocation + Java_jdk_jfr_internal_JVM_setDumpPath + Java_jdk_jfr_internal_JVM_getDumpPath + Java_jdk_jfr_internal_JVM_abort + Java_jdk_jfr_internal_JVM_addStringConstant + Java_jdk_jfr_internal_JVM_uncaughtException + Java_jdk_jfr_internal_JVM_setCutoff + Java_jdk_jfr_internal_JVM_setThrottle + Java_jdk_jfr_internal_JVM_emitOldObjectSamples + Java_jdk_jfr_internal_JVM_shouldRotateDisk + Java_jdk_jfr_internal_JVM_exclude + Java_jdk_jfr_internal_JVM_include + Java_jdk_jfr_internal_JVM_isExcluded + Java_jdk_jfr_internal_JVM_isExcluded + Java_jdk_jfr_internal_JVM_isInstrumented + Java_jdk_jfr_internal_JVM_getChunkStartNanos + Java_jdk_jfr_internal_JVM_setConfiguration + Java_jdk_jfr_internal_JVM_getConfiguration + Java_jdk_jfr_internal_JVM_getTypeId + Java_jdk_jfr_internal_JVM_isContainerized + Java_jdk_jfr_internal_JVM_hostTotalMemory + java_jdk_jfr_internal_JVM_emitDataLoss ) endif() diff --git a/runtime/jcl/module.xml b/runtime/jcl/module.xml index 32e3639884c..f4a5eab10ad 100644 --- a/runtime/jcl/module.xml +++ b/runtime/jcl/module.xml @@ -65,6 +65,7 @@ SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0-only WITH Classpath-ex + diff --git a/runtime/jcl/uma/jfr_exports.xml b/runtime/jcl/uma/jfr_exports.xml index 441ec79b575..b8618492c58 100644 --- a/runtime/jcl/uma/jfr_exports.xml +++ b/runtime/jcl/uma/jfr_exports.xml @@ -21,4 +21,69 @@ SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0-only WITH Classpath-ex --> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/runtime/jcl/uma/jfr_objects.xml b/runtime/jcl/uma/jfr_objects.xml new file mode 100644 index 00000000000..841a753f788 --- /dev/null +++ b/runtime/jcl/uma/jfr_objects.xml @@ -0,0 +1,24 @@ + + + +