subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject svn commit: r1544489 - in /subversion/trunk/subversion/bindings/javahl/native/jniwrapper: jni_channel.cpp jni_channel.hpp jni_class_cache.cpp jni_io_stream.cpp jni_io_stream.hpp jni_object.hpp
Date Fri, 22 Nov 2013 11:21:53 GMT
Author: brane
Date: Fri Nov 22 11:21:53 2013
New Revision: 1544489

URL: http://svn.apache.org/r1544489
Log:
Second round of converting newstyle JavaHL native classes to cache all
method and field IDs.

[in subversion/bindings/javahl]
* native/jniwrapper/jni_object.hpp (ClassCache):
   Declare new cached classes: input_stream, output_stream and byte_buffer.
* native/jniwrapper/jni_class_cache.cpp (ClassCache::ClassCache):
   Init members and call static initializers for wrapped classes:
   InputStream, OutputStream and ByteChannel::ByteBuffer.

* native/jniwrapper/jni_channel.hpp,
  native/jniwrapper/jni_channel.cpp,
  native/jniwrapper/jni_io_stream.hpp,
  native/jniwrapper/jni_io_stream.cpp:
   Convert all wrapper classes to init static method IDs and use
   the cached class references.

Modified:
    subversion/trunk/subversion/bindings/javahl/native/jniwrapper/jni_channel.cpp
    subversion/trunk/subversion/bindings/javahl/native/jniwrapper/jni_channel.hpp
    subversion/trunk/subversion/bindings/javahl/native/jniwrapper/jni_class_cache.cpp
    subversion/trunk/subversion/bindings/javahl/native/jniwrapper/jni_io_stream.cpp
    subversion/trunk/subversion/bindings/javahl/native/jniwrapper/jni_io_stream.hpp
    subversion/trunk/subversion/bindings/javahl/native/jniwrapper/jni_object.hpp

Modified: subversion/trunk/subversion/bindings/javahl/native/jniwrapper/jni_channel.cpp
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/native/jniwrapper/jni_channel.cpp?rev=1544489&r1=1544488&r2=1544489&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/native/jniwrapper/jni_channel.cpp (original)
+++ subversion/trunk/subversion/bindings/javahl/native/jniwrapper/jni_channel.cpp Fri Nov
22 11:21:53 2013
@@ -23,6 +23,7 @@
 
 #include <stdexcept>
 
+#include "jni_object.hpp"
 #include "jni_array.hpp"
 #include "jni_channel.hpp"
 
@@ -32,79 +33,60 @@ namespace Java {
 
 namespace {
 // Get the ByteBuffer's internal array.
-jbyteArray get_array(Env env, jclass cls, jobject buffer,
-                     MethodID& mid_has_array, MethodID& mid_get_array)
+jbyteArray get_array(Env env, jobject buffer,
+                     const MethodID& mid_has_array,
+                     const MethodID& mid_get_array)
 {
-  if (!mid_has_array)
-    mid_has_array = env.GetMethodID(cls, "hasArray", "()Z");
   if (!env.CallBooleanMethod(buffer, mid_has_array))
     return NULL;
-
-  if (!mid_get_array)
-    mid_get_array = env.GetMethodID(cls, "array", "()[B");
   return jbyteArray(env.CallObjectMethod(buffer, mid_get_array));
 }
 
 // Get the offset in the ByteBuffer's array. NEVER call this function
 // unless the buffer actually has an accessible array.
-jint get_array_offset(Env env, jclass cls, jobject buffer,
-                      MethodID& mid_get_array_offset)
+jint get_array_offset(Env env, jobject buffer,
+                      const MethodID& mid_get_array_offset)
 {
-  if (!mid_get_array_offset)
-    mid_get_array_offset = env.GetMethodID(cls, "arrayOffset", "()I");
   return env.CallIntMethod(buffer, mid_get_array_offset);
 }
 
 // Get the remaining space in a ByteBuffer.
-jint get_remaining(Env env, jclass cls, jobject buffer,
-                   MethodID& mid_get_remaining)
+jint get_remaining(Env env, jobject buffer,
+                   const MethodID& mid_get_remaining)
 {
-  if (!mid_get_remaining)
-    mid_get_remaining = env.GetMethodID(cls, "remaining", "()I");
   return env.CallIntMethod(buffer, mid_get_remaining);
 }
 
 // Get the current position of a ByteBuffer.
-jint get_position(Env env, jclass cls, jobject buffer,
-                  MethodID& mid_get_position)
+jint get_position(Env env, jobject buffer,
+                  const MethodID& mid_get_position)
 {
-  if (!mid_get_position)
-    mid_get_position = env.GetMethodID(cls, "position", "()I");
   return env.CallIntMethod(buffer, mid_get_position);
 }
 
 // Set the new position of a ByteBuffer.
-void set_position(Env env, jclass cls, jobject buffer,
-                  MethodID& mid_set_position,
+void set_position(Env env, jobject buffer,
+                  const MethodID& mid_set_position,
                   jint new_position)
 {
-  if (!mid_set_position)
-    mid_set_position = env.GetMethodID(cls,  "position",
-                                       "(I)Ljava/nio/Buffer;");
   env.CallObjectMethod(buffer, mid_set_position, new_position);
 }
 
 // Get byte array contents from a ByteBuffer.
-void get_bytearray(Env env, jclass cls, jobject buffer,
-                   MethodID& mid_get_bytearray,
+void get_bytearray(Env env, jobject buffer,
+                   const MethodID& mid_get_bytearray,
                    ByteArray& array, jint length = -1, jint offset = 0)
 {
-  if (!mid_get_bytearray)
-    mid_get_bytearray = env.GetMethodID(cls, "get",
-                                        "([BII)Ljava/nio/ByteBuffer;");
   env.CallObjectMethod(
       buffer, mid_get_bytearray, array.get(), offset,
       (length >= 0 ? length : (array.length() - offset)));
 }
 
 // Put byte array contents into a ByteBuffer.
-void put_bytearray(Env env, jclass cls, jobject buffer,
-                   MethodID& mid_put_bytearray,
+void put_bytearray(Env env, jobject buffer,
+                   const MethodID& mid_put_bytearray,
                    ByteArray& array, jint length = -1, jint offset = 0)
 {
-  if (!mid_put_bytearray)
-    mid_put_bytearray = env.GetMethodID(cls, "put",
-                                        "([BII)Ljava/nio/ByteBuffer;");
   env.CallObjectMethod(buffer, mid_put_bytearray,
                        array.get(), offset,
                        (length >= 0 ? length : (array.length() - offset)));
@@ -131,21 +113,47 @@ struct BadReaderWriter : public ChannelR
 ChannelReader& ByteChannel::m_null_reader = bad_reader_writer;
 ChannelWriter& ByteChannel::m_null_writer = bad_reader_writer;
 
-const char* const ByteChannel::m_byte_buffer_class_name =
+const char* const ByteChannel::ByteBuffer::m_class_name =
   "java/nio/ByteBuffer";
 
+MethodID ByteChannel::ByteBuffer::m_mid_has_array;
+MethodID ByteChannel::ByteBuffer::m_mid_get_array;
+MethodID ByteChannel::ByteBuffer::m_mid_get_array_offset;
+MethodID ByteChannel::ByteBuffer::m_mid_get_remaining;
+MethodID ByteChannel::ByteBuffer::m_mid_get_position;
+MethodID ByteChannel::ByteBuffer::m_mid_set_position;
+MethodID ByteChannel::ByteBuffer::m_mid_get_bytearray;
+MethodID ByteChannel::ByteBuffer::m_mid_put_bytearray;
+
+void ByteChannel::ByteBuffer::static_init(Env env)
+{
+  const jclass cls = ClassCache::get_byte_buffer();
+  m_mid_has_array = env.GetMethodID(cls, "hasArray", "()Z");
+  m_mid_get_array = env.GetMethodID(cls, "array", "()[B");
+  m_mid_get_array_offset = env.GetMethodID(cls, "arrayOffset", "()I");
+  m_mid_get_remaining = env.GetMethodID(cls, "remaining", "()I");
+  m_mid_get_position = env.GetMethodID(cls, "position", "()I");
+  m_mid_set_position = env.GetMethodID(cls,  "position",
+                                       "(I)Ljava/nio/Buffer;");
+  m_mid_get_bytearray = env.GetMethodID(cls, "get",
+                                        "([BII)Ljava/nio/ByteBuffer;");
+  m_mid_put_bytearray = env.GetMethodID(cls, "put",
+                                        "([BII)Ljava/nio/ByteBuffer;");
+}
+
+
 jint ByteChannel::read(jobject destination)
 {
-  const jint remaining = get_remaining(m_env, m_cls_byte_buffer, destination,
-                                       m_mid_byte_buffer_get_remaining);
+  const jint remaining = get_remaining(m_env, destination,
+                                       ByteBuffer::m_mid_get_remaining);
   if (!remaining)
     {
       // No space in the buffer; don't try to read anything.
       return 0;
     }
 
-  const jint position = get_position(m_env, m_cls_byte_buffer, destination,
-                                     m_mid_byte_buffer_get_position);
+  const jint position = get_position(m_env, destination,
+                                     ByteBuffer::m_mid_get_position);
 
   jint bytes_read = 0;
   void* data = m_env.GetDirectBufferAddress(destination);
@@ -157,14 +165,14 @@ jint ByteChannel::read(jobject destinati
   else
     {
       // It was not a direct buffer ... see if it has an array.
-      jbyteArray raw_array = get_array(m_env, m_cls_byte_buffer, destination,
-                                       m_mid_byte_buffer_has_array,
-                                       m_mid_byte_buffer_get_array);
+      jbyteArray raw_array = get_array(m_env, destination,
+                                       ByteBuffer::m_mid_has_array,
+                                       ByteBuffer::m_mid_get_array);
       if (raw_array)
         {
           const jint array_offset = get_array_offset(
-              m_env, m_cls_byte_buffer, destination,
-              m_mid_byte_buffer_get_array_offset);
+              m_env, destination,
+              ByteBuffer::m_mid_get_array_offset);
           ByteArray array(m_env, raw_array);
           ByteArray::MutableContents contents(array);
           data = contents.data();
@@ -175,8 +183,8 @@ jint ByteChannel::read(jobject destinati
   if (data)
     {
       if (bytes_read > 0)
-        set_position(m_env, m_cls_byte_buffer, destination,
-                     m_mid_byte_buffer_set_position,
+        set_position(m_env, destination,
+                     ByteBuffer::m_mid_set_position,
                      position + bytes_read);
       return bytes_read;
     }
@@ -187,24 +195,24 @@ jint ByteChannel::read(jobject destinati
   ByteArray::MutableContents contents(array);
   bytes_read = m_reader(m_env, contents.data(), contents.length());
   if (bytes_read > 0)
-    put_bytearray(m_env, m_cls_byte_buffer, destination,
-                  m_mid_byte_buffer_put_bytearray,
+    put_bytearray(m_env, destination,
+                  ByteBuffer::m_mid_put_bytearray,
                   array, bytes_read);
   return bytes_read;
 }
 
 jint ByteChannel::write(jobject source)
 {
-  const jint remaining = get_remaining(m_env, m_cls_byte_buffer, source,
-                                       m_mid_byte_buffer_get_remaining);
+  const jint remaining = get_remaining(m_env, source,
+                                       ByteBuffer::m_mid_get_remaining);
   if (!remaining)
     {
       // No data in the buffer; don't try to write anything.
       return 0;
     }
 
-  const jint position = get_position(m_env, m_cls_byte_buffer, source,
-                                     m_mid_byte_buffer_get_position);
+  const jint position = get_position(m_env, source,
+                                     ByteBuffer::m_mid_get_position);
 
   jint bytes_written = 0;
   const void* data = m_env.GetDirectBufferAddress(source);
@@ -216,14 +224,14 @@ jint ByteChannel::write(jobject source)
   else
     {
       // It was not a direct buffer ... see if it has an array.
-      jbyteArray raw_array = get_array(m_env, m_cls_byte_buffer, source,
-                                       m_mid_byte_buffer_has_array,
-                                       m_mid_byte_buffer_get_array);
+      jbyteArray raw_array = get_array(m_env, source,
+                                       ByteBuffer::m_mid_has_array,
+                                       ByteBuffer::m_mid_get_array);
       if (raw_array)
         {
           const jint array_offset = get_array_offset(
-              m_env, m_cls_byte_buffer, source,
-              m_mid_byte_buffer_get_array_offset);
+              m_env, source,
+              ByteBuffer::m_mid_get_array_offset);
           const ByteArray array(m_env, raw_array);
           ByteArray::Contents contents(array);
           data = contents.data();
@@ -234,8 +242,8 @@ jint ByteChannel::write(jobject source)
   if (data)
     {
       if (bytes_written > 0)
-        set_position(m_env, m_cls_byte_buffer, source,
-                     m_mid_byte_buffer_set_position,
+        set_position(m_env, source,
+                     ByteBuffer::m_mid_set_position,
                      position + bytes_written);
       return bytes_written;
     }
@@ -243,8 +251,8 @@ jint ByteChannel::write(jobject source)
   // No accessible array, either. Oh well. Get an array from the
   // buffer and read data from that.
   ByteArray array(m_env, remaining);
-  get_bytearray(m_env, m_cls_byte_buffer, source,
-                m_mid_byte_buffer_get_bytearray,
+  get_bytearray(m_env, source,
+                ByteBuffer::m_mid_get_bytearray,
                 array);
   ByteArray::Contents contents(array);
   bytes_written = m_writer(m_env, contents.data(), contents.length());

Modified: subversion/trunk/subversion/bindings/javahl/native/jniwrapper/jni_channel.hpp
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/native/jniwrapper/jni_channel.hpp?rev=1544489&r1=1544488&r2=1544489&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/native/jniwrapper/jni_channel.hpp (original)
+++ subversion/trunk/subversion/bindings/javahl/native/jniwrapper/jni_channel.hpp Fri Nov
22 11:21:53 2013
@@ -81,8 +81,7 @@ public:
   explicit ByteChannel(Env env, ChannelReader& reader, ChannelWriter& writer)
     : m_env(env),
       m_reader(reader),
-      m_writer(writer),
-      m_cls_byte_buffer(env.FindClass(m_byte_buffer_class_name))
+      m_writer(writer)
     {}
 
   /**
@@ -106,8 +105,7 @@ protected:
   explicit ByteChannel(Env env, ChannelReader& reader)
     : m_env(env),
       m_reader(reader),
-      m_writer(m_null_writer),
-      m_cls_byte_buffer(env.FindClass(m_byte_buffer_class_name))
+      m_writer(m_null_writer)
     {}
 
   /**
@@ -116,8 +114,7 @@ protected:
   explicit ByteChannel(Env env, ChannelWriter& writer)
     : m_env(env),
       m_reader(m_null_reader),
-      m_writer(writer),
-      m_cls_byte_buffer(env.FindClass(m_byte_buffer_class_name))
+      m_writer(writer)
     {}
 
 private:
@@ -129,16 +126,20 @@ private:
   static ChannelWriter& m_null_writer;
 
   // Private references for the java.nio.ByteBuffer class.
-  static const char* const m_byte_buffer_class_name;
-  const jclass m_cls_byte_buffer;
-  MethodID m_mid_byte_buffer_has_array;
-  MethodID m_mid_byte_buffer_get_array;
-  MethodID m_mid_byte_buffer_get_array_offset;
-  MethodID m_mid_byte_buffer_get_remaining;
-  MethodID m_mid_byte_buffer_get_position;
-  MethodID m_mid_byte_buffer_set_position;
-  MethodID m_mid_byte_buffer_get_bytearray;
-  MethodID m_mid_byte_buffer_put_bytearray;
+  friend class ClassCache;
+  struct ByteBuffer
+  {
+    static const char* const m_class_name;
+    static void static_init(Env env);
+    static MethodID m_mid_has_array;
+    static MethodID m_mid_get_array;
+    static MethodID m_mid_get_array_offset;
+    static MethodID m_mid_get_remaining;
+    static MethodID m_mid_get_position;
+    static MethodID m_mid_set_position;
+    static MethodID m_mid_get_bytearray;
+    static MethodID m_mid_put_bytearray;
+  };
 };
 
 

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=1544489&r1=1544488&r2=1544489&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 Fri
Nov 22 11:21:53 2013
@@ -30,6 +30,8 @@
 #include "jni_object.hpp"
 #include "jni_string.hpp"
 
+#include "jni_channel.hpp"
+#include "jni_io_stream.hpp"
 #include "jni_list.hpp"
 #include "jni_string_map.hpp"
 
@@ -102,6 +104,12 @@ ClassCache::ClassCache(Env env)
     SVN_JAVAHL_JNIWRAPPER_CLASS_CACHE_INIT(map_entry, BaseMap::Entry),
     SVN_JAVAHL_JNIWRAPPER_CLASS_CACHE_INIT(hash_map, BaseMutableMap),
 
+    SVN_JAVAHL_JNIWRAPPER_CLASS_CACHE_INIT(input_stream, InputStream),
+    SVN_JAVAHL_JNIWRAPPER_CLASS_CACHE_INIT(output_stream, OutputStream),
+
+    SVN_JAVAHL_JNIWRAPPER_CLASS_CACHE_INIT(byte_buffer,
+                                           ByteChannel::ByteBuffer),
+
     SVN_JAVAHL_JNIWRAPPER_CLASS_CACHE_INIT(subversion_exception,
                                            ::JavaHL::SubversionException)
 {
@@ -120,6 +128,11 @@ ClassCache::ClassCache(Env env)
   BaseMap::Entry::static_init(env);
   BaseMutableMap::static_init(env);
 
+  InputStream::static_init(env);
+  OutputStream::static_init(env);
+
+  ByteChannel::ByteBuffer::static_init(env);
+
   // no-op: ::JavaHL::SubversionException::static_init(env);
 }
 #undef SVN_JAVAHL_JNIWRAPPER_CLASS_CACHE_INIT

Modified: subversion/trunk/subversion/bindings/javahl/native/jniwrapper/jni_io_stream.cpp
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/native/jniwrapper/jni_io_stream.cpp?rev=1544489&r1=1544488&r2=1544489&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/native/jniwrapper/jni_io_stream.cpp (original)
+++ subversion/trunk/subversion/bindings/javahl/native/jniwrapper/jni_io_stream.cpp Fri Nov
22 11:21:53 2013
@@ -168,6 +168,26 @@ apr_status_t cleanup_global_object(void*
 
 const char* const InputStream::m_class_name = "java/io/InputStream";
 
+MethodID InputStream::m_mid_close;
+MethodID InputStream::m_mid_mark_supported;
+MethodID InputStream::m_mid_mark;
+MethodID InputStream::m_mid_reset;
+MethodID InputStream::m_mid_read_byte;
+MethodID InputStream::m_mid_read_bytearray;
+MethodID InputStream::m_mid_skip;
+
+void InputStream::static_init(Env env)
+{
+  const jclass cls = ClassCache::get_input_stream();
+  m_mid_close = env.GetMethodID(cls, "close", "()V");
+  m_mid_mark_supported = env.GetMethodID(cls, "markSupported", "()Z");
+  m_mid_mark = env.GetMethodID(cls, "mark", "(I)V");
+  m_mid_reset = env.GetMethodID(cls, "reset", "()V");
+  m_mid_read_byte = env.GetMethodID(cls, "read", "()I");
+  m_mid_read_bytearray = env.GetMethodID(cls, "read", "([BII)I");
+  m_mid_skip = env.GetMethodID(cls, "skip", "(J)J");
+}
+
 svn_stream_t*
 InputStream::get_global_stream(Env env, jobject jstream,
                                const SVN::Pool& pool)
@@ -219,6 +239,18 @@ svn_stream_t* InputStream::get_stream(co
 
 const char* const OutputStream::m_class_name = "java/io/OutputStream";
 
+MethodID OutputStream::m_mid_close;
+MethodID OutputStream::m_mid_write_byte;
+MethodID OutputStream::m_mid_write_bytearray;
+
+void OutputStream::static_init(Env env)
+{
+  const jclass cls = ClassCache::get_output_stream();
+  m_mid_close = env.GetMethodID(cls, "close", "()V");
+  m_mid_write_byte = env.GetMethodID(cls, "write", "(I)V");
+  m_mid_write_bytearray = env.GetMethodID(cls, "write", "([BII)V");
+}
+
 svn_stream_t*
 OutputStream::get_global_stream(Env env, jobject jstream,
                                const SVN::Pool& pool)

Modified: subversion/trunk/subversion/bindings/javahl/native/jniwrapper/jni_io_stream.hpp
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/native/jniwrapper/jni_io_stream.hpp?rev=1544489&r1=1544488&r2=1544489&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/native/jniwrapper/jni_io_stream.hpp (original)
+++ subversion/trunk/subversion/bindings/javahl/native/jniwrapper/jni_io_stream.hpp Fri Nov
22 11:21:53 2013
@@ -49,7 +49,7 @@ public:
    * Constructs a wrapper around an existing @c InputStream @a jstream.
    */
   explicit InputStream(Env env, jobject jstream)
-    : Object(env, m_class_name, jstream)
+    : Object(env, ClassCache::get_input_stream(), jstream)
     {}
 
   /**
@@ -73,8 +73,6 @@ public:
    */
   void close()
     {
-      if (!m_mid_close)
-        m_mid_close = m_env.GetMethodID(m_class, "close", "()V");
       m_env.CallVoidMethod(m_jthis, m_mid_close);
     }
 
@@ -83,9 +81,6 @@ public:
    */
   bool mark_supported()
     {
-      if (!m_mid_mark_supported)
-        m_mid_mark_supported = m_env.GetMethodID(m_class,
-                                                 "markSupported", "()Z");
       return m_env.CallBooleanMethod(m_jthis, m_mid_mark_supported);
     }
 
@@ -94,8 +89,6 @@ public:
    */
   void mark(jint readlimit)
     {
-      if (!m_mid_mark)
-        m_mid_mark = m_env.GetMethodID(m_class, "mark", "(I)V");
       m_env.CallVoidMethod(m_jthis, m_mid_mark, readlimit);
     }
 
@@ -104,8 +97,6 @@ public:
    */
   void reset()
     {
-      if (!m_mid_reset)
-        m_mid_reset = m_env.GetMethodID(m_class, "reset", "()V");
       m_env.CallVoidMethod(m_jthis, m_mid_reset);
     }
 
@@ -114,8 +105,6 @@ public:
    */
   jint read()
     {
-      if (!m_mid_read_byte)
-        m_mid_read_byte = m_env.GetMethodID(m_class, "read", "()I");
       return m_env.CallIntMethod(m_jthis, m_mid_read_byte);
     }
 
@@ -124,8 +113,6 @@ public:
    */
   jint read(ByteArray& dst, jint length = -1, jint offset = 0)
     {
-      if (!m_mid_read_bytearray)
-        m_mid_read_bytearray = m_env.GetMethodID(m_class, "read", "([BII)I");
       return m_env.CallIntMethod(m_jthis, m_mid_read_bytearray,
                                  dst.get(), offset,
                                  (length >= 0 ? length
@@ -149,20 +136,20 @@ public:
    */
   jlong skip(jlong count)
     {
-      if (!m_mid_skip)
-        m_mid_skip = m_env.GetMethodID(m_class, "skip", "(J)J");
       return m_env.CallLongMethod(m_jthis, m_mid_skip, count);
     }
 
 private:
+  friend class ClassCache;
+  static void static_init(Env env);
   static const char* const m_class_name;
-  MethodID m_mid_close;
-  MethodID m_mid_mark_supported;
-  MethodID m_mid_mark;
-  MethodID m_mid_reset;
-  MethodID m_mid_read_byte;
-  MethodID m_mid_read_bytearray;
-  MethodID m_mid_skip;
+  static MethodID m_mid_close;
+  static MethodID m_mid_mark_supported;
+  static MethodID m_mid_mark;
+  static MethodID m_mid_reset;
+  static MethodID m_mid_read_byte;
+  static MethodID m_mid_read_bytearray;
+  static MethodID m_mid_skip;
 };
 
 
@@ -178,7 +165,7 @@ public:
    * Constructs a wrapper around an existing @c OutputStream @a jstream.
    */
   explicit OutputStream(Env env, jobject jstream)
-    : Object(env, m_class_name, jstream)
+    : Object(env, ClassCache::get_output_stream(), jstream)
     {}
 
   /**
@@ -202,8 +189,6 @@ public:
    */
   void close()
     {
-      if (!m_mid_close)
-        m_mid_close = m_env.GetMethodID(m_class, "close", "()V");
       m_env.CallVoidMethod(m_jthis, m_mid_close);
     }
 
@@ -212,8 +197,6 @@ public:
    */
   void write(jint byte)
     {
-      if (!m_mid_write_byte)
-        m_mid_write_byte = m_env.GetMethodID(m_class, "write", "(I)V");
       m_env.CallVoidMethod(m_jthis, m_mid_write_byte, byte);
     }
 
@@ -222,8 +205,6 @@ public:
    */
   void write(const ByteArray& src, jint length = -1, jint offset = 0)
     {
-      if (!m_mid_write_bytearray)
-        m_mid_write_bytearray = m_env.GetMethodID(m_class, "write", "([BII)V");
       m_env.CallVoidMethod(m_jthis, m_mid_write_bytearray,
                            src.get(), offset,
                            (length >= 0 ? length
@@ -255,10 +236,12 @@ public:
     }
 
 private:
+  friend class ClassCache;
+  static void static_init(Env env);
   static const char* const m_class_name;
-  MethodID m_mid_close;
-  MethodID m_mid_write_byte;
-  MethodID m_mid_write_bytearray;
+  static MethodID m_mid_close;
+  static MethodID m_mid_write_byte;
+  static MethodID m_mid_write_bytearray;
 };
 
 } // namespace Java

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=1544489&r1=1544488&r2=1544489&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/native/jniwrapper/jni_object.hpp (original)
+++ subversion/trunk/subversion/bindings/javahl/native/jniwrapper/jni_object.hpp Fri Nov 22
11:21:53 2013
@@ -155,6 +155,11 @@ class ClassCache
   SVN_JAVAHL_JNIWRAPPER_CACHED_CLASS(map_entry);
   SVN_JAVAHL_JNIWRAPPER_CACHED_CLASS(hash_map);
 
+  SVN_JAVAHL_JNIWRAPPER_CACHED_CLASS(input_stream);
+  SVN_JAVAHL_JNIWRAPPER_CACHED_CLASS(output_stream);
+
+  SVN_JAVAHL_JNIWRAPPER_CACHED_CLASS(byte_buffer);
+
   SVN_JAVAHL_JNIWRAPPER_CACHED_CLASS(subversion_exception);
 #undef SVN_JAVAHL_JNIWRAPPER_CACHED_CLASS
 



Mime
View raw message