Skip to content
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

Merged
merged 1 commit into from
Oct 15, 2018

Conversation

theresa-m
Copy link
Contributor

JVM_GetVmArguments implementation is missing vm access for internal methods

see #2975

Signed-off-by: Theresa Mammarella Theresa.T.Mammarella@ibm.com

@@ -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;");
Copy link
Member

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.

@theresa-m
Copy link
Contributor Author

I've updated the function to use getJNIMethodID

} else {
result = (jobjectArray)((*env)->CallObjectMethod(env, vmJniClass, mid));
if (NULL != vmClass) {
J9Method* method = method = internalFunctions->findJNIMethod(currentThread, vmClass, "getVMArgs", "()[Ljava/lang/String;");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

J9Method* method = method =

jmethodID mid = (jmethodID)internalFunctions->getJNIMethodID(currentThread, method);

if (NULL != mid) {
jclass vmJniClass = vmJniClass = (jclass)internalFunctions->j9jni_createLocalRef(env, vmClass->classObject);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

jclass vmJniClass = vmJniClass =

Copy link
Member

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>
@theresa-m
Copy link
Contributor Author

I've added error checking for j9jni_createLocalRef

Copy link
Member

@DanHeidinga DanHeidinga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@DanHeidinga
Copy link
Member

Jenkins test sanity,extended zlinux jdk11

@DanHeidinga DanHeidinga self-assigned this Oct 12, 2018
@DanHeidinga
Copy link
Member

Jenkins test sanity zlinux jdk11

@DanHeidinga
Copy link
Member

Jenkins test extended zlinux jdk11

@DanHeidinga
Copy link
Member

Jenkins test sanity win jdk11

@DanHeidinga DanHeidinga merged commit 42ca716 into eclipse-openj9:master Oct 15, 2018
@DanHeidinga DanHeidinga added this to the Release 0.11.0 milestone Oct 15, 2018
@theresa-m theresa-m deleted the getvmargs_fix branch October 17, 2018 17:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants