blob: 2c90b3ba789e55f4fb3518bda6012bad9da5f70e [file] [log] [blame]
Elliott Hughes2faa5f12012-01-30 14:42:07 -08001/*
2 * Copyright (C) 2011 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 */
Ian Rogersdf20fe02011-07-20 20:34:16 -070016
Brian Carlstromfc0e3212013-07-17 14:40:12 -070017#ifndef ART_RUNTIME_JNI_INTERNAL_H_
18#define ART_RUNTIME_JNI_INTERNAL_H_
Ian Rogersdf20fe02011-07-20 20:34:16 -070019
Ian Rogers68d8b422014-07-17 11:09:10 -070020#include <jni.h>
Elliott Hughesae80b492012-04-24 10:43:17 -070021#include <iosfwd>
Elliott Hughes0af55432011-08-17 18:37:28 -070022
Andreas Gampe13b27842016-11-07 16:48:23 -080023#include "base/macros.h"
24
Ian Rogersdf20fe02011-07-20 20:34:16 -070025namespace art {
Ian Rogersdf20fe02011-07-20 20:34:16 -070026
Andreas Gampe08883de2016-11-08 13:20:52 -080027class ArtField;
Andreas Gampe13b27842016-11-07 16:48:23 -080028class ArtMethod;
29
Ian Rogers68d8b422014-07-17 11:09:10 -070030const JNINativeInterface* GetJniNativeInterface();
Mathieu Chartier4d87df62016-01-07 15:14:19 -080031const JNINativeInterface* GetRuntimeShutdownNativeInterface();
Ian Rogers68d8b422014-07-17 11:09:10 -070032
Elliott Hughesa4f94742012-05-29 16:28:38 -070033int ThrowNewException(JNIEnv* env, jclass exception_class, const char* msg, jobject cause);
34
Andreas Gampe13b27842016-11-07 16:48:23 -080035namespace jni {
36
37ALWAYS_INLINE
Andreas Gampe08883de2016-11-08 13:20:52 -080038static inline ArtField* DecodeArtField(jfieldID fid) {
39 return reinterpret_cast<ArtField*>(fid);
40}
41
42ALWAYS_INLINE
43static inline jfieldID EncodeArtField(ArtField* field) {
44 return reinterpret_cast<jfieldID>(field);
45}
46
47ALWAYS_INLINE
Andreas Gampe13b27842016-11-07 16:48:23 -080048static inline jmethodID EncodeArtMethod(ArtMethod* art_method) {
49 return reinterpret_cast<jmethodID>(art_method);
50}
51
52ALWAYS_INLINE
53static inline ArtMethod* DecodeArtMethod(jmethodID method_id) {
54 return reinterpret_cast<ArtMethod*>(method_id);
55}
56
57} // namespace jni
Ian Rogersdf20fe02011-07-20 20:34:16 -070058} // namespace art
Carl Shapiroea4dca82011-08-01 13:45:38 -070059
Elliott Hughesb465ab02011-08-24 11:21:21 -070060std::ostream& operator<<(std::ostream& os, const jobjectRefType& rhs);
Ian Rogers68d8b422014-07-17 11:09:10 -070061
Brian Carlstromfc0e3212013-07-17 14:40:12 -070062#endif // ART_RUNTIME_JNI_INTERNAL_H_