Author: amiloslavskiy
Date: Tue Sep 29 12:12:59 2020
New Revision: 1882115
URL: http://svn.apache.org/viewvc?rev=1882115&view=rev
Log:
JavaHL: Fix incorrect cache in SVNBase::createCppBoundObject
The problem here is that 'SVNBase::createCppBoundObject' can work
with different classes (see argument), but it cached methodID of
'<init>' for the first class processed. When invoked with a
different class later, it will call wring '<init>' method.
The error is seen when running JavaHL tests with JDK14.
Error message is:
FATAL ERROR in native method: Wrong object class or methodID passed to JNI call
at <...>.javahl.util.SubstLib.translateOutputStream(Native Method)
at <...>.javahl.SVNUtil.translateStream(SVNUtil.java:1046)
at <...>.javahl.UtilTests.testTranslateStream(UtilTests.java:521)
<...>
[in subversion/bindings/javahl]
* native/SVNBase.cpp
(createCppBoundObject): Do not cache methodID.
Modified:
subversion/trunk/subversion/bindings/javahl/native/SVNBase.cpp
Modified: subversion/trunk/subversion/bindings/javahl/native/SVNBase.cpp
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/native/SVNBase.cpp?rev=1882115&r1=1882114&r2=1882115&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/native/SVNBase.cpp (original)
+++ subversion/trunk/subversion/bindings/javahl/native/SVNBase.cpp Tue Sep 29
12:12:59 2020
@@ -107,13 +107,9 @@ jobject SVNBase::createCppBoundObject(co
if (JNIUtil::isJavaExceptionThrown())
return NULL;
- static jmethodID ctor = 0;
- if (ctor == 0)
- {
- ctor = env->GetMethodID(clazz, "<init>", "(J)V");
- if (JNIUtil::isJavaExceptionThrown())
- return NULL;
- }
+ jmethodID ctor = env->GetMethodID(clazz, "<init>", "(J)V");
+ if (JNIUtil::isJavaExceptionThrown())
+ return NULL;
jlong cppAddr = this->getCppAddr();