1 /* 2 * Copyright (C) 2010 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 #ifndef JNI_CONSTANTS_H_included 18 #define JNI_CONSTANTS_H_included 19 20 #include <jni.h> 21 22 /** 23 * A cache to avoid calling FindClass at runtime. 24 */ 25 struct JniConstants { 26 // Initialized cached heap objects. This should be called in JNI_OnLoad. 27 static void Initialize(JNIEnv* env); 28 29 // Invalidate cached heap objects. This should be called in JNI_OnUnload. 30 static void Invalidate(); 31 32 static jclass GetBooleanClass(JNIEnv* env); 33 static jclass GetByteBufferClass(JNIEnv* env); 34 static jclass GetDoubleClass(JNIEnv* env); 35 static jclass GetErrnoExceptionClass(JNIEnv* env); 36 static jclass GetFileDescriptorClass(JNIEnv* env); 37 static jclass GetGaiExceptionClass(JNIEnv* env); 38 static jclass GetInet6AddressClass(JNIEnv* env); 39 static jclass GetInet6AddressHolderClass(JNIEnv* env); 40 static jclass GetInetAddressClass(JNIEnv* env); 41 static jclass GetInetAddressHolderClass(JNIEnv* env); 42 static jclass GetInetSocketAddressClass(JNIEnv* env); 43 static jclass GetInetSocketAddressHolderClass(JNIEnv* env); 44 static jclass GetIntegerClass(JNIEnv* env); 45 static jclass GetLocaleDataClass(JNIEnv* env); 46 static jclass GetLongClass(JNIEnv* env); 47 static jclass GetNetlinkSocketAddressClass(JNIEnv* env); 48 static jclass GetPacketSocketAddressClass(JNIEnv* env); 49 static jclass GetVmSocketAddressClass(JNIEnv* env); 50 static jclass GetPrimitiveByteArrayClass(JNIEnv* env); 51 static jclass GetStringClass(JNIEnv* env); 52 static jclass GetStructAddrinfoClass(JNIEnv* env); 53 static jclass GetStructCmsghdrClass(JNIEnv* env); 54 static jclass GetStructFlockClass(JNIEnv* env); 55 static jclass GetStructGroupReqClass(JNIEnv* env); 56 static jclass GetStructIfaddrsClass(JNIEnv* env); 57 static jclass GetStructLingerClass(JNIEnv* env); 58 static jclass GetStructMsghdrClass(JNIEnv* env); 59 static jclass GetStructPasswdClass(JNIEnv* env); 60 static jclass GetStructPollfdClass(JNIEnv* env); 61 static jclass GetStructStatClass(JNIEnv* env); 62 static jclass GetStructStatVfsClass(JNIEnv* env); 63 static jclass GetStructTimespecClass(JNIEnv* env); 64 static jclass GetStructTimevalClass(JNIEnv* env); 65 static jclass GetStructUcredClass(JNIEnv* env); 66 static jclass GetStructUtsnameClass(JNIEnv* env); 67 static jclass GetUnixSocketAddressClass(JNIEnv* env); 68 }; 69 70 #endif // JNI_CONSTANTS_H_included 71