1 /* 2 * Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 #include <stdio.h> 25 #include <string.h> 26 #include <stdlib.h> 27 #include "jni.h" 28 #include "jni_tools.h" 29 30 extern "C" { 31 32 #define ARGS_COUNT 6 33 34 JNIEXPORT jobject JNICALL 35 Java_vm_mlvm_meth_stress_jni_nativeAndMH_Test_native01( 36 JNIEnv * pEnv, jclass clazz, 37 jstring a1, 38 jobject a2, 39 jobject a3, 40 jobject a4, 41 jobject a5, 42 jobject a6, 43 jobject mhToCall) 44 { 45 jclass mhClass; 46 jmethodID mid; 47 jclass objectClass; 48 jobjectArray arguments; 49 jobject result; 50 51 if ( ! NSK_JNI_VERIFY(pEnv, (mhClass = NSK_CPP_STUB2(GetObjectClass, pEnv, mhToCall)) != NULL) ) 52 return NULL; 53 54 if ( ! NSK_JNI_VERIFY(pEnv, NULL != (mid = NSK_CPP_STUB4(GetMethodID, pEnv, mhClass, 55 "invokeWithArguments", 56 "([Ljava/lang/Object;)Ljava/lang/Object;"))) ) 57 return NULL; 58 59 NSK_JNI_VERIFY(pEnv, NULL != (objectClass = NSK_CPP_STUB2(FindClass, pEnv, "java/lang/Object"))); 60 61 NSK_JNI_VERIFY(pEnv, NULL != (arguments = NSK_CPP_STUB4(NewObjectArray, pEnv, ARGS_COUNT, objectClass, NULL))); 62 63 NSK_JNI_VERIFY_VOID(pEnv, NSK_CPP_STUB4(SetObjectArrayElement, pEnv, arguments, 0, a1)); 64 NSK_JNI_VERIFY_VOID(pEnv, NSK_CPP_STUB4(SetObjectArrayElement, pEnv, arguments, 1, a2)); 65 NSK_JNI_VERIFY_VOID(pEnv, NSK_CPP_STUB4(SetObjectArrayElement, pEnv, arguments, 2, a3)); 66 NSK_JNI_VERIFY_VOID(pEnv, NSK_CPP_STUB4(SetObjectArrayElement, pEnv, arguments, 3, a4)); 67 NSK_JNI_VERIFY_VOID(pEnv, NSK_CPP_STUB4(SetObjectArrayElement, pEnv, arguments, 4, a5)); 68 NSK_JNI_VERIFY_VOID(pEnv, NSK_CPP_STUB4(SetObjectArrayElement, pEnv, arguments, 5, a6)); 69 70 // Swap arguments 71 NSK_JNI_VERIFY(pEnv, NULL != (result = NSK_CPP_STUB4(CallObjectMethod, pEnv, mhToCall, mid, arguments))); 72 return result; 73 } 74 75 }