-
Notifications
You must be signed in to change notification settings - Fork 738
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JVM_GetVmArguments add vm access #3023
Conversation
runtime/j9vm/java11vmi.c
Outdated
@@ -1470,16 +1473,22 @@ JVM_GetVmArguments(JNIEnv *env) { | |||
|
|||
vmJniClass = (jclass)internalFunctions->j9jni_createLocalRef(env, vmClass->classObject); | |||
|
|||
/* exit vm before calling jni */ | |||
internalFunctions->internalExitVMToJNI(currentThread); | |||
|
|||
mid = (*env)->GetStaticMethodID(env, vmJniClass, "getVMArgs", "()[Ljava/lang/String;"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To avoid getting & releasing vmaccess around every call, you can use the VM version of getMethodID:
(jmethodID) vmFunctions->getJNIMethodID(vmThread, method);
This doesn't do the static check for you but given it's VM code, seems safe enough to me.
150b2f6
to
66b028c
Compare
I've updated the function to use |
runtime/j9vm/java11vmi.c
Outdated
} else { | ||
result = (jobjectArray)((*env)->CallObjectMethod(env, vmJniClass, mid)); | ||
if (NULL != vmClass) { | ||
J9Method* method = method = internalFunctions->findJNIMethod(currentThread, vmClass, "getVMArgs", "()[Ljava/lang/String;"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
J9Method* method = method =
runtime/j9vm/java11vmi.c
Outdated
jmethodID mid = (jmethodID)internalFunctions->getJNIMethodID(currentThread, method); | ||
|
||
if (NULL != mid) { | ||
jclass vmJniClass = vmJniClass = (jclass)internalFunctions->j9jni_createLocalRef(env, vmClass->classObject); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
jclass vmJniClass = vmJniClass =
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can fail - it needs a nullcheck / exception check. You'll have to look at j9jni_createLocalRef() to see what the contract is on failure.
JVM_GetVmArguments implementation is missing vm access for internal methods see eclipse-openj9#2975 Signed-off-by: Theresa Mammarella <Theresa.T.Mammarella@ibm.com>
66b028c
to
fcf4eaf
Compare
I've added error checking for |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Jenkins test sanity,extended zlinux jdk11 |
Jenkins test sanity zlinux jdk11 |
Jenkins test extended zlinux jdk11 |
Jenkins test sanity win jdk11 |
JVM_GetVmArguments implementation is missing vm access for internal methods
see #2975
Signed-off-by: Theresa Mammarella Theresa.T.Mammarella@ibm.com