]>
git.proxmox.com Git - ceph.git/blob - ceph/src/java/native/JniConstants.cpp
2 * Copyright (C) 2010 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #include "JniConstants.h"
18 #include "ScopedLocalRef.h"
22 jclass
JniConstants::inet6AddressClass
;
23 jclass
JniConstants::inetAddressClass
;
24 jclass
JniConstants::inetSocketAddressClass
;
25 jclass
JniConstants::stringClass
;
27 static jclass
findClass(JNIEnv
* env
, const char* name
) {
28 ScopedLocalRef
<jclass
> localClass(env
, env
->FindClass(name
));
29 jclass result
= reinterpret_cast<jclass
>(env
->NewGlobalRef(localClass
.get()));
31 fprintf(stderr
, "failed to find class '%s'", name
);
37 void JniConstants::init(JNIEnv
* env
) {
38 inet6AddressClass
= findClass(env
, "java/net/Inet6Address");
39 inetAddressClass
= findClass(env
, "java/net/InetAddress");
40 inetSocketAddressClass
= findClass(env
, "java/net/InetSocketAddress");
41 stringClass
= findClass(env
, "java/lang/String");