Re: [PATCH] JavaHL: Support logging of the static method calls

2012-06-05 Thread Hyrum K Wright
Looks good, +1 to commit to trunk.

-Hyrum

On Wed, Jun 6, 2012 at 1:39 AM, Vladimir Berezniker  wrote:
> [[[
> JavaHL: Support logging of the static method calls
>
> [ in subversion/bindings/javahl/native ]
>
> * JNIStackElement.cpp
>   (JNIStackElement): Add logic to deal with NULL jthis, which happens with
>     static method calls
> ]]]



-- 

uberSVN: Apache Subversion Made Easy
http://www.uberSVN.com/


[PATCH] JavaHL: Support logging of the static method calls

2012-06-05 Thread Vladimir Berezniker
[[[
JavaHL: Support logging of the static method calls

[ in subversion/bindings/javahl/native ]

* JNIStackElement.cpp
  (JNIStackElement): Add logic to deal with NULL jthis, which happens with
static method calls
]]]
Index: subversion/bindings/javahl/native/JNIStackElement.cpp
===
--- subversion/bindings/javahl/native/JNIStackElement.cpp   (revision 
1345120)
+++ subversion/bindings/javahl/native/JNIStackElement.cpp   (working copy)
@@ -58,20 +58,28 @@
 return;
 }
 
-  // This will call java.lang.Object.toString, even when it is
-  // overriden.
-  jobject oStr = env->CallNonvirtualObjectMethod(jthis, jlo, mid);
-  if (JNIUtil::isJavaExceptionThrown())
-return;
-
-  // Copy the result to a buffer.
-  JNIStringHolder name(reinterpret_cast(oStr));
   *m_objectID = 0;
-  strncat(m_objectID, name, JNIUtil::formatBufferSize -1);
 
+  if(jthis == NULL)
+{
+  strcpy(m_objectID, "");
+}
+  else
+{
+  // This will call java.lang.Object.toString, even when it is
+  // overriden.
+  jobject oStr = env->CallNonvirtualObjectMethod(jthis, jlo, mid);
+  if (JNIUtil::isJavaExceptionThrown())
+return;
+
+  // Copy the result to a buffer.
+  JNIStringHolder name(reinterpret_cast(oStr));
+  strncat(m_objectID, name, JNIUtil::formatBufferSize -1);
+  env->DeleteLocalRef(oStr);
+}
+
   // Release the Java string.
   env->DeleteLocalRef(jlo);
-  env->DeleteLocalRef(oStr);
 
   // Remember the parameter for the exit of the method.
   m_clazz = clazz;