java_lang_Throwable.cc revision ee1d79a603c77c0667b27c075a983579d5c51f7e
11240dade91d6c4bbf4e367ca608fcdc15348da45Elliott Hughes/* 21240dade91d6c4bbf4e367ca608fcdc15348da45Elliott Hughes * Copyright (C) 2008 The Android Open Source Project 31240dade91d6c4bbf4e367ca608fcdc15348da45Elliott Hughes * 41240dade91d6c4bbf4e367ca608fcdc15348da45Elliott Hughes * Licensed under the Apache License, Version 2.0 (the "License"); 51240dade91d6c4bbf4e367ca608fcdc15348da45Elliott Hughes * you may not use this file except in compliance with the License. 61240dade91d6c4bbf4e367ca608fcdc15348da45Elliott Hughes * You may obtain a copy of the License at 71240dade91d6c4bbf4e367ca608fcdc15348da45Elliott Hughes * 81240dade91d6c4bbf4e367ca608fcdc15348da45Elliott Hughes * http://www.apache.org/licenses/LICENSE-2.0 91240dade91d6c4bbf4e367ca608fcdc15348da45Elliott Hughes * 101240dade91d6c4bbf4e367ca608fcdc15348da45Elliott Hughes * Unless required by applicable law or agreed to in writing, software 111240dade91d6c4bbf4e367ca608fcdc15348da45Elliott Hughes * distributed under the License is distributed on an "AS IS" BASIS, 121240dade91d6c4bbf4e367ca608fcdc15348da45Elliott Hughes * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 131240dade91d6c4bbf4e367ca608fcdc15348da45Elliott Hughes * See the License for the specific language governing permissions and 141240dade91d6c4bbf4e367ca608fcdc15348da45Elliott Hughes * limitations under the License. 151240dade91d6c4bbf4e367ca608fcdc15348da45Elliott Hughes */ 161240dade91d6c4bbf4e367ca608fcdc15348da45Elliott Hughes 171240dade91d6c4bbf4e367ca608fcdc15348da45Elliott Hughes#include "jni_internal.h" 1853b8b09fc80329539585dcf43657bc5f4ecefdffIan Rogers#include "scoped_fast_native_object_access.h" 19aaa208006d7c8cc0f381c4aa9b525be24066c495Ian Rogers#include "thread.h" 201240dade91d6c4bbf4e367ca608fcdc15348da45Elliott Hughes 211240dade91d6c4bbf4e367ca608fcdc15348da45Elliott Hughesnamespace art { 221240dade91d6c4bbf4e367ca608fcdc15348da45Elliott Hughes 230512f02dd6623c0870c11fbf3274d7462f732136Elliott Hughesstatic jobject Throwable_nativeFillInStackTrace(JNIEnv* env, jclass) { 2453b8b09fc80329539585dcf43657bc5f4ecefdffIan Rogers ScopedFastNativeObjectAccess soa(env); 25ee1d79a603c77c0667b27c075a983579d5c51f7eSebastien Hertz return soa.Self()->CreateInternalStackTrace<false>(soa); 261240dade91d6c4bbf4e367ca608fcdc15348da45Elliott Hughes} 271240dade91d6c4bbf4e367ca608fcdc15348da45Elliott Hughes 280512f02dd6623c0870c11fbf3274d7462f732136Elliott Hughesstatic jobjectArray Throwable_nativeGetStackTrace(JNIEnv* env, jclass, jobject javaStackState) { 2953b8b09fc80329539585dcf43657bc5f4ecefdffIan Rogers if (javaStackState == nullptr) { 3053b8b09fc80329539585dcf43657bc5f4ecefdffIan Rogers return nullptr; 3132f8569b58142eb93f6fa88c2cbfc4c619a95ee8Jesse Wilson } 3253b8b09fc80329539585dcf43657bc5f4ecefdffIan Rogers ScopedFastNativeObjectAccess soa(env); 3353b8b09fc80329539585dcf43657bc5f4ecefdffIan Rogers return Thread::InternalStackTraceToStackTraceElementArray(soa, javaStackState); 341240dade91d6c4bbf4e367ca608fcdc15348da45Elliott Hughes} 351240dade91d6c4bbf4e367ca608fcdc15348da45Elliott Hughes 360512f02dd6623c0870c11fbf3274d7462f732136Elliott Hughesstatic JNINativeMethod gMethods[] = { 3753b8b09fc80329539585dcf43657bc5f4ecefdffIan Rogers NATIVE_METHOD(Throwable, nativeFillInStackTrace, "!()Ljava/lang/Object;"), 3853b8b09fc80329539585dcf43657bc5f4ecefdffIan Rogers NATIVE_METHOD(Throwable, nativeGetStackTrace, "!(Ljava/lang/Object;)[Ljava/lang/StackTraceElement;"), 391240dade91d6c4bbf4e367ca608fcdc15348da45Elliott Hughes}; 401240dade91d6c4bbf4e367ca608fcdc15348da45Elliott Hughes 411240dade91d6c4bbf4e367ca608fcdc15348da45Elliott Hughesvoid register_java_lang_Throwable(JNIEnv* env) { 42eac766769e3114a078c188ea26776a81f0edb3cfElliott Hughes REGISTER_NATIVE_METHODS("java/lang/Throwable"); 431240dade91d6c4bbf4e367ca608fcdc15348da45Elliott Hughes} 441240dade91d6c4bbf4e367ca608fcdc15348da45Elliott Hughes 451240dade91d6c4bbf4e367ca608fcdc15348da45Elliott Hughes} // namespace art 46