blob: d1a1105d0d50641503c31e6d6cd8c3869e088c8e [file] [log] [blame]
Elliott Hughes1240dad2011-09-09 16:24:50 -07001/*
2 * Copyright (C) 2008 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 "jni_internal.h"
Ian Rogers53b8b092014-03-13 23:45:53 -070018#include "scoped_fast_native_object_access.h"
Ian Rogersaaa20802011-09-11 21:47:37 -070019#include "thread.h"
Elliott Hughes1240dad2011-09-09 16:24:50 -070020
Elliott Hughes1240dad2011-09-09 16:24:50 -070021namespace art {
22
Elliott Hughes0512f022012-03-15 22:10:52 -070023static jobject Throwable_nativeFillInStackTrace(JNIEnv* env, jclass) {
Ian Rogers53b8b092014-03-13 23:45:53 -070024 ScopedFastNativeObjectAccess soa(env);
Ian Rogers00f7d0e2012-07-19 15:28:27 -070025 return soa.Self()->CreateInternalStackTrace(soa);
Elliott Hughes1240dad2011-09-09 16:24:50 -070026}
27
Elliott Hughes0512f022012-03-15 22:10:52 -070028static jobjectArray Throwable_nativeGetStackTrace(JNIEnv* env, jclass, jobject javaStackState) {
Ian Rogers53b8b092014-03-13 23:45:53 -070029 if (javaStackState == nullptr) {
30 return nullptr;
Jesse Wilson32f85692011-11-22 11:00:41 -050031 }
Ian Rogers53b8b092014-03-13 23:45:53 -070032 ScopedFastNativeObjectAccess soa(env);
33 return Thread::InternalStackTraceToStackTraceElementArray(soa, javaStackState);
Elliott Hughes1240dad2011-09-09 16:24:50 -070034}
35
Elliott Hughes0512f022012-03-15 22:10:52 -070036static JNINativeMethod gMethods[] = {
Ian Rogers53b8b092014-03-13 23:45:53 -070037 NATIVE_METHOD(Throwable, nativeFillInStackTrace, "!()Ljava/lang/Object;"),
38 NATIVE_METHOD(Throwable, nativeGetStackTrace, "!(Ljava/lang/Object;)[Ljava/lang/StackTraceElement;"),
Elliott Hughes1240dad2011-09-09 16:24:50 -070039};
40
Elliott Hughes1240dad2011-09-09 16:24:50 -070041void register_java_lang_Throwable(JNIEnv* env) {
Elliott Hugheseac76672012-05-24 21:56:51 -070042 REGISTER_NATIVE_METHODS("java/lang/Throwable");
Elliott Hughes1240dad2011-09-09 16:24:50 -070043}
44
45} // namespace art