Home | History | Annotate | Download | only in 989-method-trace-throw
      1 /*
      2  * Copyright (C) 2013 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 #include <inttypes.h>
     18 
     19 #include <cstdio>
     20 #include <memory>
     21 
     22 #include "android-base/logging.h"
     23 #include "android-base/stringprintf.h"
     24 
     25 #include "jni.h"
     26 #include "jvmti.h"
     27 #include "scoped_local_ref.h"
     28 
     29 // Test infrastructure
     30 #include "jni_binder.h"
     31 #include "jni_helper.h"
     32 #include "jvmti_helper.h"
     33 #include "test_env.h"
     34 #include "ti_macros.h"
     35 
     36 namespace art {
     37 namespace Test989StackTraceThrow {
     38 
     39 extern "C" JNIEXPORT
     40 jfloat JNICALL Java_art_Test989_returnFloatNative(JNIEnv* env, jclass klass) {
     41   jmethodID targetMethod = env->GetStaticMethodID(klass, "doGetFloat", "()F");
     42   return env->CallStaticFloatMethod(klass, targetMethod);
     43 }
     44 extern "C" JNIEXPORT
     45 jdouble JNICALL Java_art_Test989_returnDoubleNative(JNIEnv* env, jclass klass) {
     46   jmethodID targetMethod = env->GetStaticMethodID(klass, "doGetDouble", "()D");
     47   return env->CallStaticDoubleMethod(klass, targetMethod);
     48 }
     49 
     50 extern "C" JNIEXPORT jobject JNICALL Java_art_Test989_returnValueNative(JNIEnv* env, jclass klass) {
     51   jmethodID targetMethod = env->GetStaticMethodID(klass, "mkTestObject", "()Ljava/lang/Object;");
     52   return env->CallStaticObjectMethod(klass, targetMethod);
     53 }
     54 
     55 extern "C" JNIEXPORT void JNICALL Java_art_Test989_doNothingNative(JNIEnv* env ATTRIBUTE_UNUSED,
     56                                                                    jclass klass ATTRIBUTE_UNUSED) {
     57   return;
     58 }
     59 
     60 extern "C" JNIEXPORT void JNICALL Java_art_Test989_throwANative(JNIEnv* env,
     61                                                                 jclass klass) {
     62   jmethodID targetMethod = env->GetStaticMethodID(klass, "doThrowA", "()V");
     63   env->CallStaticVoidMethod(klass, targetMethod);
     64 }
     65 
     66 extern "C" JNIEXPORT void JNICALL Java_art_Test989_acceptValueNative(JNIEnv* env,
     67                                                                      jclass klass,
     68                                                                      jobject arg) {
     69   jmethodID targetMethod = env->GetStaticMethodID(klass, "printObject", "(Ljava/lang/Object;)V");
     70   env->CallStaticVoidMethod(klass, targetMethod, arg);
     71 }
     72 
     73 }  // namespace Test989StackTraceThrow
     74 }  // namespace art
     75 
     76