java_lang_Throwable.cc revision 277ccbd200ea43590dfc06a93ae184a765327ad0
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 17277ccbd200ea43590dfc06a93ae184a765327ad0Andreas Gampe#include "java_lang_Throwable.h" 18277ccbd200ea43590dfc06a93ae184a765327ad0Andreas Gampe 191240dade91d6c4bbf4e367ca608fcdc15348da45Elliott Hughes#include "jni_internal.h" 2053b8b09fc80329539585dcf43657bc5f4ecefdffIan Rogers#include "scoped_fast_native_object_access.h" 21aaa208006d7c8cc0f381c4aa9b525be24066c495Ian Rogers#include "thread.h" 221240dade91d6c4bbf4e367ca608fcdc15348da45Elliott Hughes 231240dade91d6c4bbf4e367ca608fcdc15348da45Elliott Hughesnamespace art { 241240dade91d6c4bbf4e367ca608fcdc15348da45Elliott Hughes 250512f02dd6623c0870c11fbf3274d7462f732136Elliott Hughesstatic jobject Throwable_nativeFillInStackTrace(JNIEnv* env, jclass) { 2653b8b09fc80329539585dcf43657bc5f4ecefdffIan Rogers ScopedFastNativeObjectAccess soa(env); 27ee1d79a603c77c0667b27c075a983579d5c51f7eSebastien Hertz return soa.Self()->CreateInternalStackTrace<false>(soa); 281240dade91d6c4bbf4e367ca608fcdc15348da45Elliott Hughes} 291240dade91d6c4bbf4e367ca608fcdc15348da45Elliott Hughes 300512f02dd6623c0870c11fbf3274d7462f732136Elliott Hughesstatic jobjectArray Throwable_nativeGetStackTrace(JNIEnv* env, jclass, jobject javaStackState) { 3153b8b09fc80329539585dcf43657bc5f4ecefdffIan Rogers if (javaStackState == nullptr) { 3253b8b09fc80329539585dcf43657bc5f4ecefdffIan Rogers return nullptr; 3332f8569b58142eb93f6fa88c2cbfc4c619a95ee8Jesse Wilson } 3453b8b09fc80329539585dcf43657bc5f4ecefdffIan Rogers ScopedFastNativeObjectAccess soa(env); 3553b8b09fc80329539585dcf43657bc5f4ecefdffIan Rogers return Thread::InternalStackTraceToStackTraceElementArray(soa, javaStackState); 361240dade91d6c4bbf4e367ca608fcdc15348da45Elliott Hughes} 371240dade91d6c4bbf4e367ca608fcdc15348da45Elliott Hughes 380512f02dd6623c0870c11fbf3274d7462f732136Elliott Hughesstatic JNINativeMethod gMethods[] = { 3953b8b09fc80329539585dcf43657bc5f4ecefdffIan Rogers NATIVE_METHOD(Throwable, nativeFillInStackTrace, "!()Ljava/lang/Object;"), 4053b8b09fc80329539585dcf43657bc5f4ecefdffIan Rogers NATIVE_METHOD(Throwable, nativeGetStackTrace, "!(Ljava/lang/Object;)[Ljava/lang/StackTraceElement;"), 411240dade91d6c4bbf4e367ca608fcdc15348da45Elliott Hughes}; 421240dade91d6c4bbf4e367ca608fcdc15348da45Elliott Hughes 431240dade91d6c4bbf4e367ca608fcdc15348da45Elliott Hughesvoid register_java_lang_Throwable(JNIEnv* env) { 44eac766769e3114a078c188ea26776a81f0edb3cfElliott Hughes REGISTER_NATIVE_METHODS("java/lang/Throwable"); 451240dade91d6c4bbf4e367ca608fcdc15348da45Elliott Hughes} 461240dade91d6c4bbf4e367ca608fcdc15348da45Elliott Hughes 471240dade91d6c4bbf4e367ca608fcdc15348da45Elliott Hughes} // namespace art 48