Home | History | Annotate | Download | only in 992-source-data
      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 #include <memory>
     19 #include <stdio.h>
     20 
     21 #include "android-base/logging.h"
     22 #include "android-base/stringprintf.h"
     23 
     24 #include "jni.h"
     25 #include "jvmti.h"
     26 #include "scoped_local_ref.h"
     27 
     28 // Test infrastructure
     29 #include "jni_binder.h"
     30 #include "jni_helper.h"
     31 #include "jvmti_helper.h"
     32 #include "test_env.h"
     33 #include "ti_macros.h"
     34 
     35 namespace art {
     36 namespace Test992SourceFile {
     37 
     38 extern "C" JNIEXPORT
     39 jstring JNICALL Java_art_Test992_getSourceFileName(JNIEnv* env,
     40                                                    jclass klass ATTRIBUTE_UNUSED,
     41                                                    jclass target) {
     42   char* file = nullptr;
     43   if (JvmtiErrorToException(env, jvmti_env, jvmti_env->GetSourceFileName(target, &file))) {
     44     return nullptr;
     45   }
     46   jstring ret = env->NewStringUTF(file);
     47   jvmti_env->Deallocate(reinterpret_cast<unsigned char*>(file));
     48   return ret;
     49 }
     50 
     51 }  // namespace Test992SourceFile
     52 }  // namespace art
     53 
     54