1 /* *****************************************************************
3 * Copyright 2015 Samsung Electronics All Rights Reserved.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
19 ******************************************************************/
21 #include "jni_object.h"
23 #define LOG_TAG "TM_JObject"
25 JObject::JObject(JNIEnv *env) : m_pEnv( env ),
32 JObject::JObject(JNIEnv *env, jobject obj) : m_pEnv(NULL),
37 if ( NULL == env || NULL == obj)
44 m_pClazz = m_pEnv->GetObjectClass( obj );
47 JObject::JObject(JNIEnv *env, const char *classPath) : m_pEnv(NULL),
52 if ( NULL == env || NULL == classPath)
54 LOGI("JObject Invalid parameters");
59 //m_pClazz = GetJClass( classPath );
63 LOGE( "GetJClass failed [%s]" , classPath);
67 jmethodID mid = env->GetMethodID(m_pClazz, "<init>", "()V");
70 LOGE( "GetMethodID failed [%s]" , classPath);
74 m_pObject = env->NewObject(m_pClazz, mid);
81 if (m_pObject && m_fIsNewObject)
83 m_pEnv->DeleteLocalRef( m_pObject );
86 if (m_pClazz && !m_fIsNewObject)
88 m_pEnv->DeleteLocalRef( m_pClazz );
93 jobject JObject::getObject() const
99 void JObject::detachObject()
103 m_fIsNewObject = false;