jni_env_ext-inl.h revision 68d8b42ddec39ec0174162d90d4abaa004d1983e
1576ca0cd692c0b6ae70e776de91015b8ff000a08Ian Rogers/* 2576ca0cd692c0b6ae70e776de91015b8ff000a08Ian Rogers * Copyright (C) 2011 The Android Open Source Project 3576ca0cd692c0b6ae70e776de91015b8ff000a08Ian Rogers * 4576ca0cd692c0b6ae70e776de91015b8ff000a08Ian Rogers * Licensed under the Apache License, Version 2.0 (the "License"); 5576ca0cd692c0b6ae70e776de91015b8ff000a08Ian Rogers * you may not use this file except in compliance with the License. 6576ca0cd692c0b6ae70e776de91015b8ff000a08Ian Rogers * You may obtain a copy of the License at 7576ca0cd692c0b6ae70e776de91015b8ff000a08Ian Rogers * 8576ca0cd692c0b6ae70e776de91015b8ff000a08Ian Rogers * http://www.apache.org/licenses/LICENSE-2.0 9576ca0cd692c0b6ae70e776de91015b8ff000a08Ian Rogers * 10576ca0cd692c0b6ae70e776de91015b8ff000a08Ian Rogers * Unless required by applicable law or agreed to in writing, software 11576ca0cd692c0b6ae70e776de91015b8ff000a08Ian Rogers * distributed under the License is distributed on an "AS IS" BASIS, 12576ca0cd692c0b6ae70e776de91015b8ff000a08Ian Rogers * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13576ca0cd692c0b6ae70e776de91015b8ff000a08Ian Rogers * See the License for the specific language governing permissions and 14576ca0cd692c0b6ae70e776de91015b8ff000a08Ian Rogers * limitations under the License. 15576ca0cd692c0b6ae70e776de91015b8ff000a08Ian Rogers */ 16576ca0cd692c0b6ae70e776de91015b8ff000a08Ian Rogers 1768d8b42ddec39ec0174162d90d4abaa004d1983eIan Rogers#ifndef ART_RUNTIME_JNI_ENV_EXT_INL_H_ 1868d8b42ddec39ec0174162d90d4abaa004d1983eIan Rogers#define ART_RUNTIME_JNI_ENV_EXT_INL_H_ 19576ca0cd692c0b6ae70e776de91015b8ff000a08Ian Rogers 2068d8b42ddec39ec0174162d90d4abaa004d1983eIan Rogers#include "jni_env_ext.h" 21576ca0cd692c0b6ae70e776de91015b8ff000a08Ian Rogers 22576ca0cd692c0b6ae70e776de91015b8ff000a08Ian Rogers#include "utils.h" 23576ca0cd692c0b6ae70e776de91015b8ff000a08Ian Rogers 24576ca0cd692c0b6ae70e776de91015b8ff000a08Ian Rogersnamespace art { 25576ca0cd692c0b6ae70e776de91015b8ff000a08Ian Rogers 26576ca0cd692c0b6ae70e776de91015b8ff000a08Ian Rogerstemplate<typename T> 27576ca0cd692c0b6ae70e776de91015b8ff000a08Ian Rogersinline T JNIEnvExt::AddLocalReference(mirror::Object* obj) { 28576ca0cd692c0b6ae70e776de91015b8ff000a08Ian Rogers IndirectRef ref = locals.Add(local_ref_cookie, obj); 29576ca0cd692c0b6ae70e776de91015b8ff000a08Ian Rogers 30576ca0cd692c0b6ae70e776de91015b8ff000a08Ian Rogers // TODO: fix this to understand PushLocalFrame, so we can turn it on. 31576ca0cd692c0b6ae70e776de91015b8ff000a08Ian Rogers if (false) { 32576ca0cd692c0b6ae70e776de91015b8ff000a08Ian Rogers if (check_jni) { 33576ca0cd692c0b6ae70e776de91015b8ff000a08Ian Rogers size_t entry_count = locals.Capacity(); 34576ca0cd692c0b6ae70e776de91015b8ff000a08Ian Rogers if (entry_count > 16) { 35576ca0cd692c0b6ae70e776de91015b8ff000a08Ian Rogers locals.Dump(LOG(WARNING) << "Warning: more than 16 JNI local references: " 36576ca0cd692c0b6ae70e776de91015b8ff000a08Ian Rogers << entry_count << " (most recent was a " << PrettyTypeOf(obj) << ")\n"); 37576ca0cd692c0b6ae70e776de91015b8ff000a08Ian Rogers // TODO: LOG(FATAL) in a later release? 38576ca0cd692c0b6ae70e776de91015b8ff000a08Ian Rogers } 39576ca0cd692c0b6ae70e776de91015b8ff000a08Ian Rogers } 40576ca0cd692c0b6ae70e776de91015b8ff000a08Ian Rogers } 41576ca0cd692c0b6ae70e776de91015b8ff000a08Ian Rogers 42576ca0cd692c0b6ae70e776de91015b8ff000a08Ian Rogers return reinterpret_cast<T>(ref); 43576ca0cd692c0b6ae70e776de91015b8ff000a08Ian Rogers} 44576ca0cd692c0b6ae70e776de91015b8ff000a08Ian Rogers 45576ca0cd692c0b6ae70e776de91015b8ff000a08Ian Rogers} // namespace art 46576ca0cd692c0b6ae70e776de91015b8ff000a08Ian Rogers 4768d8b42ddec39ec0174162d90d4abaa004d1983eIan Rogers#endif // ART_RUNTIME_JNI_ENV_EXT_INL_H_ 48