Skip to content

Commit

Permalink
Implement JVM_IsContainerized and fix JVM_IsUseContainerSupport
Browse files Browse the repository at this point in the history
An implementation of JVM_IsContainerized has been added.

The signature of JVM_IsUseContainerSupport has been fixed.

Closes: #19801

Signed-off-by: Babneet Singh <sbabneet@ca.ibm.com>
  • Loading branch information
babsingh committed Jul 8, 2024
1 parent 677181c commit fe56122
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
7 changes: 4 additions & 3 deletions runtime/j9vm/java11vmi.c
Original file line number Diff line number Diff line change
Expand Up @@ -1731,12 +1731,13 @@ JVM_IsSharingEnabled(JNIEnv *env)
#endif /* JAVA_SPEC_VERSION >= 16 */

JNIEXPORT jboolean JNICALL
JVM_IsUseContainerSupport(JNIEnv *env)
JVM_IsUseContainerSupport(void)
{
J9VMThread *const currentThread = (J9VMThread *)env;
J9JavaVM *vm = currentThread->javaVM;
J9JavaVM *vm = BFUjavaVM;
jboolean result = JNI_FALSE;

Assert_SC_true(NULL != vm);

if (J9_ARE_ALL_BITS_SET(vm->extendedRuntimeFlags2, J9_EXTENDED_RUNTIME2_USE_CONTAINER_SUPPORT)) {
/* Return true if -XX:+UseContainerSupport is specified. This option is enabled by default. */
result = JNI_TRUE;
Expand Down
17 changes: 16 additions & 1 deletion runtime/j9vm/javanextvmi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -793,10 +793,25 @@ JVM_GetCDSConfigStatus()
#endif /* JAVA_SPEC_VERSION >= 23 */

#if JAVA_SPEC_VERSION >= 24
/**
* @brief Determine if the JVM is running inside a container.
*
* @return JNI_TRUE if running inside a container; otherwise, JNI_FALSE
*/
JNIEXPORT jboolean JNICALL
JVM_IsContainerized(void)
{
return JNI_FALSE;
J9JavaVM *vm = BFUjavaVM;
jboolean isContainerized = JNI_FALSE;

Assert_SC_true(NULL != vm);

OMRPORT_ACCESS_FROM_J9PORT(vm->portLibrary);
if (omrsysinfo_is_running_in_container()) {
isContainerized = JNI_TRUE;
}

return isContainerized;
}
#endif /* JAVA_SPEC_VERSION >= 24 */

Expand Down
2 changes: 1 addition & 1 deletion runtime/redirector/forwarders.m4
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ _IF([JAVA_SPEC_VERSION >= 16],
[_X(JVM_DefineArchivedModules, JNICALL, false, void, JNIEnv *env, jobject obj1, jobject obj2)])
_IF([JAVA_SPEC_VERSION >= 16],
[_X(JVM_LogLambdaFormInvoker, JNICALL, false, void, JNIEnv *env, jstring str)])
_X(JVM_IsUseContainerSupport, JNICALL, false, jboolean, JNIEnv *env)
_X(JVM_IsUseContainerSupport, JNICALL, false, jboolean, void)
_X(AsyncGetCallTrace, JNICALL, false, void, void *trace, jint depth, void *ucontext)
_IF([JAVA_SPEC_VERSION >= 17],
[_X(JVM_DumpClassListToFile, JNICALL, false, void, JNIEnv *env, jstring str)])
Expand Down

0 comments on commit fe56122

Please sign in to comment.