50
50
#include " oops/instanceMirrorKlass.hpp"
51
51
#include " oops/method.inline.hpp"
52
52
#include " oops/objArrayKlass.inline.hpp"
53
+ #include " oops/recordComponent.hpp"
53
54
#include " oops/trainingData.hpp"
54
55
#include " oops/typeArrayOop.inline.hpp"
55
56
#include " prims/jvmtiExport.hpp"
@@ -401,7 +402,7 @@ C2V_VMENTRY_NULL(jobject, asResolvedJavaMethod, (JNIEnv* env, jobject, jobject e
401
402
methodHandle method (THREAD, InstanceKlass::cast (holder)->method_with_idnum (slot));
402
403
JVMCIObject result = JVMCIENV->get_jvmci_method (method, JVMCI_CHECK_NULL);
403
404
return JVMCIENV->get_jobject (result);
404
- }
405
+ C2V_END
405
406
406
407
C2V_VMENTRY_PREFIX (jboolean, updateCompilerThreadCanCallJava, (JNIEnv* env, jobject, jboolean newState))
407
408
return CompilerThreadCanCallJava::update (thread, newState) != nullptr ;
@@ -2246,6 +2247,28 @@ C2V_VMENTRY_NULL(jobjectArray, getDeclaredMethods, (JNIEnv* env, jobject, ARGUME
2246
2247
return JVMCIENV->get_jobjectArray (methods);
2247
2248
C2V_END
2248
2249
2250
+ C2V_VMENTRY_NULL (jobjectArray, getRecordComponents, (JNIEnv* env, jobject, ARGUMENT_PAIR(klass)))
2251
+ Klass* klass = UNPACK_PAIR(Klass, klass);
2252
+ if (klass == nullptr ) {
2253
+ JVMCI_THROW_NULL (NullPointerException);
2254
+ }
2255
+ if (!klass->is_instance_klass ()) {
2256
+ return nullptr ;
2257
+ }
2258
+
2259
+ InstanceKlass* iklass = InstanceKlass::cast(klass);
2260
+ Array<RecordComponent*>* components = iklass->record_components ();
2261
+ if (components == nullptr ) {
2262
+ return nullptr ;
2263
+ }
2264
+ JVMCIObjectArray res = JVMCIENV->new_ResolvedJavaRecordComponent_array (components->length (), JVMCI_CHECK_NULL);
2265
+ for (int i = 0 ; i < components->length (); i++) {
2266
+ JVMCIObject component = JVMCIENV->new_HotSpotResolvedJavaRecordComponent (JVMCIENV->wrap (klass_obj), i, components->at (i), JVMCI_CHECK_NULL);
2267
+ JVMCIENV->put_object_at (res, i, component);
2268
+ }
2269
+ return JVMCIENV->get_jobjectArray (res);
2270
+ C2V_END
2271
+
2249
2272
C2V_VMENTRY_NULL (jobjectArray, getAllMethods, (JNIEnv* env, jobject, ARGUMENT_PAIR(klass)))
2250
2273
Klass* klass = UNPACK_PAIR(Klass, klass);
2251
2274
if (klass == nullptr ) {
@@ -3107,18 +3130,35 @@ C2V_VMENTRY_NULL(jbyteArray, getEncodedExecutableAnnotationValues, (JNIEnv* env,
3107
3130
return get_encoded_annotation_values(method->method_holder (), raw_annotations, category, memberType, THREAD, JVMCIENV);
3108
3131
C2V_END
3109
3132
3110
- C2V_VMENTRY_NULL (jbyteArray, getEncodedFieldAnnotationValues, (JNIEnv* env, jobject, ARGUMENT_PAIR(klass), jint index, jint category))
3133
+ C2V_VMENTRY_NULL (jbyteArray, getEncodedFieldAnnotationValues, (JNIEnv* env, jobject, ARGUMENT_PAIR(klass), jint index, jboolean is_field, jint category))
3111
3134
CompilerThreadCanCallJava canCallJava(thread, true ); // Requires Java support
3112
3135
InstanceKlass* holder = check_field(InstanceKlass::cast(UNPACK_PAIR(Klass, klass)), index, JVMCI_CHECK_NULL);
3113
- fieldDescriptor fd (holder, index);
3114
- AnnotationArray* raw_annotations;
3115
- if (category == CompilerToVM::DECLARED_ANNOTATIONS) {
3116
- raw_annotations = fd.annotations ();
3117
- } else if (category == CompilerToVM::TYPE_ANNOTATIONS) {
3118
- raw_annotations = fd.type_annotations ();
3136
+ AnnotationArray* raw_annotations = nullptr ;
3137
+ if (is_field) {
3138
+ fieldDescriptor fd (holder, index);
3139
+ if (category == CompilerToVM::DECLARED_ANNOTATIONS) {
3140
+ raw_annotations = fd.annotations ();
3141
+ } else if (category == CompilerToVM::TYPE_ANNOTATIONS) {
3142
+ raw_annotations = fd.type_annotations ();
3143
+ } else {
3144
+ THROW_MSG_NULL (vmSymbols::java_lang_IllegalArgumentException (),
3145
+ err_msg (" %d" , category));
3146
+ }
3119
3147
} else {
3120
- THROW_MSG_NULL (vmSymbols::java_lang_IllegalArgumentException (),
3121
- err_msg (" %d" , category));
3148
+ Array<RecordComponent*>* components = holder->record_components ();
3149
+ if (components == nullptr ) {
3150
+ THROW_MSG_NULL (vmSymbols::java_lang_IllegalArgumentException (),
3151
+ err_msg (" %s has no record components" , holder->name ()->as_C_string ()));
3152
+ }
3153
+ RecordComponent* rc = components->at (index);
3154
+ if (category == CompilerToVM::DECLARED_ANNOTATIONS) {
3155
+ raw_annotations = rc->annotations ();
3156
+ } else if (category == CompilerToVM::TYPE_ANNOTATIONS) {
3157
+ raw_annotations = rc->type_annotations ();
3158
+ } else {
3159
+ THROW_MSG_NULL (vmSymbols::java_lang_IllegalArgumentException (),
3160
+ err_msg (" %d" , category));
3161
+ }
3122
3162
}
3123
3163
return get_encoded_annotation_values(holder, raw_annotations, category, nullptr , THREAD, JVMCIENV);
3124
3164
C2V_END
@@ -3324,13 +3364,13 @@ C2V_END
3324
3364
#define OBJECT " Ljava/lang/Object;"
3325
3365
#define CLASS " Ljava/lang/Class;"
3326
3366
#define OBJECTCONSTANT " Ljdk/vm/ci/hotspot/HotSpotObjectConstantImpl;"
3327
- #define EXECUTABLE " Ljava/lang/reflect/Executable;"
3328
3367
#define STACK_TRACE_ELEMENT " Ljava/lang/StackTraceElement;"
3329
3368
#define INSTALLED_CODE " Ljdk/vm/ci/code/InstalledCode;"
3330
3369
#define BYTECODE_FRAME " Ljdk/vm/ci/code/BytecodeFrame;"
3331
3370
#define JAVACONSTANT " Ljdk/vm/ci/meta/JavaConstant;"
3332
3371
#define INSPECTED_FRAME_VISITOR " Ljdk/vm/ci/code/stack/InspectedFrameVisitor;"
3333
3372
#define RESOLVED_METHOD " Ljdk/vm/ci/meta/ResolvedJavaMethod;"
3373
+ #define RESOLVED_RECORD_COMPONENT " Ljdk/vm/ci/meta/ResolvedJavaRecordComponent;"
3334
3374
#define FIELDINFO " Ljdk/vm/ci/hotspot/HotSpotResolvedObjectTypeImpl$FieldInfo;"
3335
3375
#define HS_RESOLVED_TYPE " Ljdk/vm/ci/hotspot/HotSpotResolvedJavaType;"
3336
3376
#define HS_INSTALLED_CODE " Ljdk/vm/ci/hotspot/HotSpotInstalledCode;"
@@ -3339,8 +3379,8 @@ C2V_END
3339
3379
#define HS_CONFIG " Ljdk/vm/ci/hotspot/HotSpotVMConfig;"
3340
3380
#define HS_STACK_FRAME_REF " Ljdk/vm/ci/hotspot/HotSpotStackFrameReference;"
3341
3381
#define HS_SPECULATION_LOG " Ljdk/vm/ci/hotspot/HotSpotSpeculationLog;"
3342
- #define REFLECTION_EXECUTABLE " Ljava/lang/reflect/Executable;"
3343
- #define REFLECTION_FIELD " Ljava/lang/reflect/Field;"
3382
+ #define EXECUTABLE " Ljava/lang/reflect/Executable;"
3383
+ #define FIELD " Ljava/lang/reflect/Field;"
3344
3384
3345
3385
// Types wrapping VM pointers. The ...2 macro is for a pair: (wrapper, pointer)
3346
3386
#define HS_METHOD " Ljdk/vm/ci/hotspot/HotSpotResolvedJavaMethodImpl;"
@@ -3436,6 +3476,7 @@ JNINativeMethod CompilerToVM::methods[] = {
3436
3476
{CC " boxPrimitive" , CC " (" OBJECT " )" OBJECTCONSTANT, FN_PTR (boxPrimitive)},
3437
3477
{CC " getDeclaredConstructors" , CC " (" HS_KLASS2 " )[" RESOLVED_METHOD, FN_PTR (getDeclaredConstructors)},
3438
3478
{CC " getDeclaredMethods" , CC " (" HS_KLASS2 " )[" RESOLVED_METHOD, FN_PTR (getDeclaredMethods)},
3479
+ {CC " getRecordComponents" , CC " (" HS_KLASS2 " )[" RESOLVED_RECORD_COMPONENT, FN_PTR (getRecordComponents)},
3439
3480
{CC " getAllMethods" , CC " (" HS_KLASS2 " )[" RESOLVED_METHOD, FN_PTR (getAllMethods)},
3440
3481
{CC " getDeclaredFieldsInfo" , CC " (" HS_KLASS2 " )[" FIELDINFO, FN_PTR (getDeclaredFieldsInfo)},
3441
3482
{CC " readStaticFieldValue" , CC " (" HS_KLASS2 " JC)" JAVACONSTANT, FN_PTR (readStaticFieldValue)},
@@ -3462,11 +3503,11 @@ JNINativeMethod CompilerToVM::methods[] = {
3462
3503
{CC " unhand" , CC " (J)" OBJECT, FN_PTR (unhand)},
3463
3504
{CC " updateHotSpotNmethod" , CC " (" HS_NMETHOD " )V" , FN_PTR (updateHotSpotNmethod)},
3464
3505
{CC " getCode" , CC " (" HS_INSTALLED_CODE " )[B" , FN_PTR (getCode)},
3465
- {CC " asReflectionExecutable" , CC " (" HS_METHOD2 " )" REFLECTION_EXECUTABLE, FN_PTR (asReflectionExecutable)},
3466
- {CC " asReflectionField" , CC " (" HS_KLASS2 " I)" REFLECTION_FIELD, FN_PTR (asReflectionField)},
3506
+ {CC " asReflectionExecutable" , CC " (" HS_METHOD2 " )" EXECUTABLE, FN_PTR (asReflectionExecutable)},
3507
+ {CC " asReflectionField" , CC " (" HS_KLASS2 " I)" FIELD, FN_PTR (asReflectionField)},
3467
3508
{CC " getEncodedClassAnnotationValues" , CC " (" HS_KLASS2 " I)[B" , FN_PTR (getEncodedClassAnnotationValues)},
3468
3509
{CC " getEncodedExecutableAnnotationValues" , CC " (" HS_METHOD2 HS_KLASS2 " I)[B" , FN_PTR (getEncodedExecutableAnnotationValues)},
3469
- {CC " getEncodedFieldAnnotationValues" , CC " (" HS_KLASS2 " II )[B" , FN_PTR (getEncodedFieldAnnotationValues)},
3510
+ {CC " getEncodedFieldAnnotationValues" , CC " (" HS_KLASS2 " IZI )[B" , FN_PTR (getEncodedFieldAnnotationValues)},
3470
3511
{CC " getFailedSpeculations" , CC " (J[[B)[[B" , FN_PTR (getFailedSpeculations)},
3471
3512
{CC " getFailedSpeculationsAddress" , CC " (" HS_METHOD2 " )J" , FN_PTR (getFailedSpeculationsAddress)},
3472
3513
{CC " releaseFailedSpeculations" , CC " (J)V" , FN_PTR (releaseFailedSpeculations)},
0 commit comments