[[[
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<jstring>(oStr));
       *m_objectID = 0;
-      strncat(m_objectID, name, JNIUtil::formatBufferSize -1);
 
+      if(jthis == NULL)
+        {
+          strcpy(m_objectID, "<static>");
+        }
+      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<jstring>(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;

Reply via email to