Skip to content

Add implementation for isValueObject()#23625

Merged
hangshao0 merged 1 commit intoeclipse-openj9:masterfrom
AditiS11:TestJNIIsValueObject
Apr 6, 2026
Merged

Add implementation for isValueObject()#23625
hangshao0 merged 1 commit intoeclipse-openj9:masterfrom
AditiS11:TestJNIIsValueObject

Conversation

@AditiS11
Copy link
Copy Markdown

@AditiS11 AditiS11 commented Apr 1, 2026

Add implementation for isValueObject().
Returns true if the object class is a valuetype.

Required for runtime/valhalla/inlinetypes/TestJNIIsValueObject.java.

@AditiS11 AditiS11 force-pushed the TestJNIIsValueObject branch from 9dbb98c to 44c2204 Compare April 1, 2026 15:26
@theresa-m theresa-m added comp:vm project:valhalla Used to track Project Valhalla related work labels Apr 1, 2026
Comment thread runtime/vm/jnicsup.cpp

#if defined(J9VM_OPT_VALHALLA_VALUE_TYPES)
static jboolean JNICALL
isValueObject(JNIEnv *env, jobject obj)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I see that new methods are also added to runtime/j9vm31/jnicsup.cpp.

@AditiS11 AditiS11 force-pushed the TestJNIIsValueObject branch from 44c2204 to c6274cc Compare April 2, 2026 04:37
Comment thread runtime/include/jni.h.m4
ifelse(eval(JAVA_SPEC_VERSION >= 9), 1, ` jobject (JNICALL * GetModule)(JNIEnv *env, jclass clazz);', `dnl')
ifelse(eval(JAVA_SPEC_VERSION >= 19), 1, ` jboolean (JNICALL * IsVirtualThread)(JNIEnv *env, jobject obj);', `dnl')
ifelse(eval(JAVA_SPEC_VERSION >= 24), 1, ` jlong (JNICALL *GetStringUTFLengthAsLong)(JNIEnv *env, jstring string);', `dnl')
#if defined(J9VM_OPT_VALHALLA_VALUE_TYPES)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I wonder if these c preprocessor directives will work in an m4 file.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

m4 will ignore this and this line will appear verbatim in the jdk; it's not likely that users will define J9VM_OPT_VALHALLA_VALUE_TYPES and so this will have no effect. It must be rewritten to use JAVA_SPEC_VERSION or a new name which would need to be added to the m4 command line.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I expect this to be changed to a JAVA_SPEC_VERSION check once Valhalla is released.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

In the meantime, we get the following in jni.h:

    jboolean (JNICALL * IsVirtualThread)(JNIEnv *env, jobject obj);
    jlong (JNICALL *GetStringUTFLengthAsLong)(JNIEnv *env, jstring string);
#if defined(J9VM_OPT_VALHALLA_VALUE_TYPES)
jboolean (JNICALL *IsValueObject)(JNIEnv *env, jobject obj);
#endif /* defined(J9VM_OPT_VALHALLA_VALUE_TYPES) */
};

This will not work for the tests renabled in adoptium/aqa-tests#6995.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

A minor nit: The new function pointer should be indented like other fields.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@AditiS11 @hangshao0 What is being done about this?

Copy link
Copy Markdown
Author

@AditiS11 AditiS11 Apr 7, 2026

Choose a reason for hiding this comment

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

I thought of adding a new name to the m4 command line. I am still looking into it.

@theresa-m theresa-m requested a review from hangshao0 April 2, 2026 11:49
Comment thread runtime/j9vm31/exports.cmake Outdated
@AditiS11 AditiS11 force-pushed the TestJNIIsValueObject branch from c6274cc to 8897ec4 Compare April 2, 2026 17:10
Add implementation for isValueObject().
Returns true if the object class is a valuetype.

Signed-off-by: Aditi Srinivas M <Aditi.Srini@ibm.com>
@AditiS11 AditiS11 force-pushed the TestJNIIsValueObject branch from 8897ec4 to 2994112 Compare April 6, 2026 05:46
@hangshao0
Copy link
Copy Markdown
Contributor

Jenkins test sanity.functional,extended alinuxval jdknext

@hangshao0 hangshao0 merged commit ec4c9ff into eclipse-openj9:master Apr 6, 2026
7 checks passed
@theresa-m
Copy link
Copy Markdown
Contributor

@AditiS11 please also open a pull request to enable TestJNIIsValueObject.

AditiS11 pushed a commit to AditiS11/openj9 that referenced this pull request Apr 10, 2026
Add J9VM_OPT_VALHALLA_VALUE_TYPES to m4 command line
so that IsValueObject() can be declared for valhalla build.
Related: eclipse-openj9#23625

Signed-off-by: Aditi Srinivas M <Aditi.Srini@ibm.com>
AditiS11 pushed a commit to AditiS11/openj9 that referenced this pull request Apr 10, 2026
Add J9VM_OPT_VALHALLA_VALUE_TYPES to m4 command line so that
IsValueObject() can be declared conditionally for valhalla build.
Related: eclipse-openj9#23625

Signed-off-by: Aditi Srinivas M <Aditi.Srini@ibm.com>
AditiS11 pushed a commit to AditiS11/openj9 that referenced this pull request Apr 11, 2026
Add J9VM_OPT_VALHALLA_VALUE_TYPES to m4 command line so that
IsValueObject() can be declared conditionally for valhalla build.
Related: eclipse-openj9#23625

Signed-off-by: Aditi Srinivas M <Aditi.Srini@ibm.com>
AditiS11 pushed a commit to AditiS11/aqa-tests that referenced this pull request Apr 11, 2026
Enable runtime/valhalla/inlinetypes/TestJNIIsValueObject.java
Fixed by: eclipse-openj9/openj9#23625
AditiS11 pushed a commit to AditiS11/openj9 that referenced this pull request Apr 13, 2026
Add J9VM_OPT_VALHALLA_VALUE_TYPES to m4 command line so that
IsValueObject() can be declared conditionally for valhalla build.
Remove incorrect env parameter from IsVirtualThread() and GetStringUTFLengthAsLong().
Related: eclipse-openj9#23625

Signed-off-by: Aditi Srinivas M <Aditi.Srini@ibm.com>
AditiS11 pushed a commit to AditiS11/openj9 that referenced this pull request Apr 13, 2026
Add J9VM_OPT_VALHALLA_VALUE_TYPES to m4 command line so that
IsValueObject() can be declared conditionally for valhalla build.
Remove incorrect env parameter from IsVirtualThread()
and GetStringUTFLengthAsLong().
Related: eclipse-openj9#23625

Signed-off-by: Aditi Srinivas M <Aditi.Srini@ibm.com>
AditiS11 pushed a commit to AditiS11/openj9-openjdk-jdk.valuetypes that referenced this pull request Apr 14, 2026
Scc uses the wrong class version for migrated value classes.
Related: eclipse-openj9/openj9#23625
Signed-off-by: Aditi Srinivas M <Aditi.Srini@ibm.com>
karianna pushed a commit to adoptium/aqa-tests that referenced this pull request Apr 15, 2026
Enable runtime/valhalla/inlinetypes/TestJNIIsValueObject.java
Fixed by: eclipse-openj9/openj9#23625

Co-authored-by: Aditi Srinivas M <Aditi.Srini@ibm.com>
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

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants