Path: blob/master/runtime/j9vm31/jnireflect.cpp
5985 views
/*******************************************************************************1* Copyright (c) 2021, 2021 IBM Corp. and others2*3* This program and the accompanying materials are made available under4* the terms of the Eclipse Public License 2.0 which accompanies this5* distribution and is available at https://www.eclipse.org/legal/epl-2.0/6* or the Apache License, Version 2.0 which accompanies this distribution and7* is available at https://www.apache.org/licenses/LICENSE-2.0.8*9* This Source Code may also be made available under the following10* Secondary Licenses when the conditions for such availability set11* forth in the Eclipse Public License, v. 2.0 are satisfied: GNU12* General Public License, version 2 with the GNU Classpath13* Exception [1] and GNU General Public License, version 2 with the14* OpenJDK Assembly Exception [2].15*16* [1] https://www.gnu.org/software/classpath/license.html17* [2] http://openjdk.java.net/legal/assembly-exception.html18*19* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 OR LicenseRef-GPL-2.0 WITH Assembly-exception20*******************************************************************************/2122#include "j9vm31.h"2324jmethodID JNICALL25FromReflectedMethod(JNIEnv *env, jobject method)26{27const jint NUM_ARGS = 2;28J9_CEL4RO64_ArgType argTypes[NUM_ARGS] = { CEL4RO64_type_JNIEnv64, CEL4RO64_type_jobject };29uint64_t argValues[NUM_ARGS] = { JNIENV64_FROM_JNIENV31(env), method };30jmethodID returnValue = NULL;31FUNCTION_DESCRIPTOR_FROM_JNIENV31(env, FromReflectedMethod);32j9_cel4ro64_call_function(functionDescriptor, argTypes, argValues, NUM_ARGS, CEL4RO64_type_jmethodID, &returnValue);33return returnValue;34}3536jfieldID JNICALL37FromReflectedField(JNIEnv *env, jobject field)38{39const jint NUM_ARGS = 2;40J9_CEL4RO64_ArgType argTypes[NUM_ARGS] = { CEL4RO64_type_JNIEnv64, CEL4RO64_type_jobject };41uint64_t argValues[NUM_ARGS] = { JNIENV64_FROM_JNIENV31(env), field };42jfieldID returnValue = NULL;43FUNCTION_DESCRIPTOR_FROM_JNIENV31(env, FromReflectedField);44j9_cel4ro64_call_function(functionDescriptor, argTypes, argValues, NUM_ARGS, CEL4RO64_type_jfieldID, &returnValue);45return returnValue;46}4748jobject JNICALL49ToReflectedMethod(JNIEnv *env, jclass cls, jmethodID methodID, jboolean isStatic)50{51const jint NUM_ARGS = 4;52J9_CEL4RO64_ArgType argTypes[NUM_ARGS] = { CEL4RO64_type_JNIEnv64, CEL4RO64_type_jclass, CEL4RO64_type_jmethodID, CEL4RO64_type_jboolean };53uint64_t argValues[NUM_ARGS] = { JNIENV64_FROM_JNIENV31(env), cls, methodID, (uint64_t)isStatic };54jobject returnValue = NULL;55FUNCTION_DESCRIPTOR_FROM_JNIENV31(env, ToReflectedMethod);56j9_cel4ro64_call_function(functionDescriptor, argTypes, argValues, NUM_ARGS, CEL4RO64_type_jobject, &returnValue);57return returnValue;58}5960jobject JNICALL61ToReflectedField(JNIEnv *env, jclass cls, jfieldID fieldID, jboolean isStatic)62{63const jint NUM_ARGS = 4;64J9_CEL4RO64_ArgType argTypes[NUM_ARGS] = { CEL4RO64_type_JNIEnv64, CEL4RO64_type_jclass, CEL4RO64_type_jfieldID, CEL4RO64_type_jboolean };65uint64_t argValues[NUM_ARGS] = { JNIENV64_FROM_JNIENV31(env), cls, fieldID, (uint64_t)isStatic };66jobject returnValue = NULL;67FUNCTION_DESCRIPTOR_FROM_JNIENV31(env, ToReflectedField);68j9_cel4ro64_call_function(functionDescriptor, argTypes, argValues, NUM_ARGS, CEL4RO64_type_jobject, &returnValue);69return returnValue;70}717273