1 //  Copyright (c) 2011-present, Facebook, Inc.  All rights reserved.
2 //  This source code is licensed under both the GPLv2 (found in the
3 //  COPYING file in the root directory) and Apache 2.0 License
4 //  (found in the LICENSE.Apache file in the root directory).
5 //
6 // This file implements the callback "bridge" between Java and C++ for
7 // JNI Callbacks from C++ to sub-classes or org.rocksdb.RocksCallbackObject
8 
9 #ifndef JAVA_ROCKSJNI_JNICALLBACK_H_
10 #define JAVA_ROCKSJNI_JNICALLBACK_H_
11 
12 #include <jni.h>
13 
14 #include "rocksdb/rocksdb_namespace.h"
15 
16 namespace ROCKSDB_NAMESPACE {
17 class JniCallback {
18  public:
19   JniCallback(JNIEnv* env, jobject jcallback_obj);
20   virtual ~JniCallback();
21 
22  protected:
23   JavaVM* m_jvm;
24   jobject m_jcallback_obj;
25   JNIEnv* getJniEnv(jboolean* attached) const;
26   void releaseJniEnv(jboolean& attached) const;
27   };
28   }  // namespace ROCKSDB_NAMESPACE
29 
30 // @lint-ignore TXT4 T25377293 Grandfathered in
31 #endif  // JAVA_ROCKSJNI_JNICALLBACK_H_
32