jnicallback.h 964 B

12345678910111213141516171819202122232425262728293031
  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. #ifndef JAVA_ROCKSJNI_JNICALLBACK_H_
  9. #define JAVA_ROCKSJNI_JNICALLBACK_H_
  10. #include <jni.h>
  11. #include "rocksdb/rocksdb_namespace.h"
  12. namespace ROCKSDB_NAMESPACE {
  13. class JniCallback {
  14. public:
  15. JniCallback(JNIEnv* env, jobject jcallback_obj);
  16. virtual ~JniCallback();
  17. protected:
  18. JavaVM* m_jvm;
  19. jobject m_jcallback_obj;
  20. JNIEnv* getJniEnv(jboolean* attached) const;
  21. void releaseJniEnv(jboolean& attached) const;
  22. };
  23. } // namespace ROCKSDB_NAMESPACE
  24. // @lint-ignore TXT4 T25377293 Grandfathered in
  25. #endif // JAVA_ROCKSJNI_JNICALLBACK_H_