subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject svn commit: r1539212 - in /subversion/trunk/subversion/bindings/javahl/native/jniwrapper: jni_base.cpp jni_class_cache.cpp jni_env.hpp jni_object.hpp
Date Wed, 06 Nov 2013 02:15:50 GMT
Author: brane
Date: Wed Nov  6 02:15:50 2013
New Revision: 1539212

URL: http://svn.apache.org/r1539212
Log:
Declaring extern "C" functions as friends is apparently tricky if
compatibility with a wide range of compilers is important ...
so we do without them.

* subversion/bindings/javahl/native/jniwrapper/jni_env.hpp
  (JNI_OnLoad): Remove friend declaration.
  (Java::Env::static_init): New static initializer.

* subversion/bindings/javahl/native/jniwrapper/jni_object.hpp
  (JNI_OnLoad, JNI_OnUnload): Remove friend declarations.
  (Java::ClassCache::create): New static initializer.
  (Java::ClassCache::destroy): New static finalizer.

* subversion/bindings/javahl/native/jniwrapper/jni_base.cpp
  (Java::Env::static_init): Implement.
  (JNI_OnLoad): Call Java::Env::static_init and Java::ClassCache::create.
* subversion/bindings/javahl/native/jniwrapper/jni_class_cache.cpp
  (Java::ClassCache::create, Java::ClassCache::destroy): Implement.

Modified:
    subversion/trunk/subversion/bindings/javahl/native/jniwrapper/jni_base.cpp
    subversion/trunk/subversion/bindings/javahl/native/jniwrapper/jni_class_cache.cpp
    subversion/trunk/subversion/bindings/javahl/native/jniwrapper/jni_env.hpp
    subversion/trunk/subversion/bindings/javahl/native/jniwrapper/jni_object.hpp

Modified: subversion/trunk/subversion/bindings/javahl/native/jniwrapper/jni_base.cpp
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/native/jniwrapper/jni_base.cpp?rev=1539212&r1=1539211&r2=1539212&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/native/jniwrapper/jni_base.cpp (original)
+++ subversion/trunk/subversion/bindings/javahl/native/jniwrapper/jni_base.cpp Wed Nov  6
02:15:50 2013
@@ -38,8 +38,8 @@
 JNIEXPORT jint JNICALL
 JNI_OnLoad(JavaVM* jvm, void*)
 {
-  ::Java::Env::m_jvm = jvm;
-  new ::Java::ClassCache(::Java::Env());
+  ::Java::Env::static_init(jvm);
+  ::Java::ClassCache::create();
   return JNI_VERSION_1_2;
 }
 
@@ -50,7 +50,7 @@ JNI_OnLoad(JavaVM* jvm, void*)
 JNIEXPORT void JNICALL
 JNI_OnUnload(JavaVM*, void*)
 {
-  delete ::Java::ClassCache::m_instance;
+  ::Java::ClassCache::destroy();
 }
 
 
@@ -59,6 +59,10 @@ namespace Java {
 // class Java::Env
 
 ::JavaVM* Env::m_jvm = NULL;
+void Env::static_init(::JavaVM* jvm)
+{
+  m_jvm = jvm;
+}
 
 ::JNIEnv* Env::env_from_jvm()
 {

Modified: subversion/trunk/subversion/bindings/javahl/native/jniwrapper/jni_class_cache.cpp
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/native/jniwrapper/jni_class_cache.cpp?rev=1539212&r1=1539211&r2=1539212&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/native/jniwrapper/jni_class_cache.cpp (original)
+++ subversion/trunk/subversion/bindings/javahl/native/jniwrapper/jni_class_cache.cpp Wed
Nov  6 02:15:50 2013
@@ -32,6 +32,18 @@ namespace Java {
 
 const ClassCache* ClassCache::m_instance = NULL;
 
+void ClassCache::create()
+{
+  new ClassCache(Env());
+}
+
+void ClassCache::destroy()
+{
+  const ClassCache* const instance = m_instance;
+  m_instance = NULL;
+  delete instance;
+}
+
 ClassCache::~ClassCache() {}
 
 #define SVN_JAVAHL_JNIWRAPPER_CLASS_CACHE_INIT(M, C)    \

Modified: subversion/trunk/subversion/bindings/javahl/native/jniwrapper/jni_env.hpp
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/native/jniwrapper/jni_env.hpp?rev=1539212&r1=1539211&r2=1539212&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/native/jniwrapper/jni_env.hpp (original)
+++ subversion/trunk/subversion/bindings/javahl/native/jniwrapper/jni_env.hpp Wed Nov  6 02:15:50
2013
@@ -412,8 +412,6 @@ public:
 
 private:
   ::JNIEnv* m_env;
-
-  friend JNIEXPORT jint JNICALL ::JNI_OnLoad(::JavaVM*, void*);
   static ::JavaVM* m_jvm;
   static ::JNIEnv* env_from_jvm();
 
@@ -429,6 +427,10 @@ private:
     }
 
   void throw_java_out_of_memory(const char* message) const;
+
+public:
+  /* This static initializer must only be called by JNI_OnLoad */
+  static void static_init(::JavaVM*);
 };
 
 

Modified: subversion/trunk/subversion/bindings/javahl/native/jniwrapper/jni_object.hpp
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/native/jniwrapper/jni_object.hpp?rev=1539212&r1=1539211&r2=1539212&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/native/jniwrapper/jni_object.hpp (original)
+++ subversion/trunk/subversion/bindings/javahl/native/jniwrapper/jni_object.hpp Wed Nov 
6 02:15:50 2013
@@ -130,8 +130,6 @@ private:
  */
 class ClassCache
 {
-  friend JNIEXPORT jint JNICALL ::JNI_OnLoad(::JavaVM*, void*);
-  friend JNIEXPORT void JNICALL ::JNI_OnUnload(::JavaVM*, void*);
   explicit ClassCache(Env env);
   ~ClassCache();
 
@@ -152,6 +150,13 @@ class ClassCache
   SVN_JAVAHL_JNIWRAPPER_CACHED_CLASS(string);
   SVN_JAVAHL_JNIWRAPPER_CACHED_CLASS(subversion_exception);
 #undef SVN_JAVAHL_JNIWRAPPER_CACHED_CLASS
+
+public:
+  /* This static initializer must only be called by JNI_OnLoad */
+  static void create();
+
+  /* This static finalizer must only be called by JNI_OnUnload */
+  static void destroy();
 };
 
 



Mime
View raw message