Skip to content

Conversation

@AditiS11
Copy link

Related: #22642
Add the implementation for method JVM_CopyOfSpecialArray

With this change test/jdk/java/lang/invoke/BigArityTest.java passes.

@theresa-m
Copy link
Contributor

Please open a pull request to remove test/jdk/java/lang/invoke/BigArityTest.java from https://github.com/adoptium/aqa-tests/blob/master/openjdk/excludes/ProblemList_openjdkvalhalla-openj9.txt once this change is merged.

{
assert(!"JVM_CopyOfSpecialArray unimplemented");
return NULL;
j9object_t origObj;
Copy link
Contributor

Choose a reason for hiding this comment

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

Initialize these variables to null or 0.

J9VMThread *currentThread = (J9VMThread *)env;
J9InternalVMFunctions *vmFuncs = currentThread->javaVM->internalVMFunctions;
vmFuncs->internalEnterVMFromJNI(currentThread);

Copy link
Contributor

Choose a reason for hiding this comment

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

Remove the extra space.

vmFuncs->internalEnterVMFromJNI(currentThread);


if (orig == NULL) {
Copy link
Contributor

Choose a reason for hiding this comment

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

When comparing a variable to a constant put the constant on the left as per our coding standards.


if (NULL == orig) {
vmFuncs->setCurrentException(currentThread, J9VMCONSTANTPOOL_JAVALANGNULLPOINTEREXCEPTION, NULL);
vmFuncs->internalExitVMToJNI(currentThread);
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of having multiple return points that need to make this call I recommend jumping to a label similar to what is done in newArrayHelper in this file.

}
origObj = J9_JNI_UNWRAP_REFERENCE(orig);
origClass = J9OBJECT_CLAZZ(currentThread, origObj);
componentClass = ((J9ArrayClass *)origClass)->leafComponentType;
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't see that the componentClass is used anywhere.

origClass = J9OBJECT_CLAZZ(currentThread, origObj);
componentClass = ((J9ArrayClass *)origClass)->leafComponentType;
origLength = J9INDEXABLEOBJECT_SIZE(currentThread, origObj);
if (from < 0 || to > (jint)origLength || from > to) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Add parenthesis around each statement.

componentClass = ((J9ArrayClass *)origClass)->leafComponentType;
origLength = J9INDEXABLEOBJECT_SIZE(currentThread, origObj);
if (from < 0 || to > (jint)origLength || from > to) {
vmFuncs->setCurrentException(currentThread, J9VMCONSTANTPOOL_JAVALANGARRAYINDEXOUTOFBOUNDSEXCEPTION, NULL);
Copy link
Contributor

Choose a reason for hiding this comment

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

Does the ri throw ArrayIndexOutOfBoundsException for from > to as well?

Copy link
Author

Choose a reason for hiding this comment

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

It throws IllegalArgumentException if from >= to. Will change it.

JNIEXPORT jarray JNICALL
JVM_CopyOfSpecialArray(JNIEnv *env, jarray orig, jint from, jint to)
{
assert(!"JVM_CopyOfSpecialArray unimplemented");
Copy link
Contributor

Choose a reason for hiding this comment

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

I just noticed there is a copyFlattenableArray method in ValueTypeHelpers.hpp. Can this method be reused here?

Copy link
Author

@AditiS11 AditiS11 Dec 5, 2025

Choose a reason for hiding this comment

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

I feel that the copyFlattenableArray method can’t be used here because it requires a special Valhalla stack frame to be built before the call. I’m not sure how the frame could be constructed from here.

Related: eclipse-openj9#22642
Add the implementation for method JVM_CopyOfSpecialArray
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp:vm project:valhalla Used to track Project Valhalla related work test excluded

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants