[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: svn commit: r1801108 - in /subversion/trunk/subversion/bindings/javahl/native: Array.cpp CreateJ.cpp Iterator.cpp OperationContext.cpp RemoteSession.cpp RevisionRangeList.cpp

From: Philip Martin <philip_at_codematters.co.uk>
Date: Thu, 06 Jul 2017 22:03:19 +0100

philip_at_apache.org writes:

> Author: philip
> Date: Thu Jul 6 20:56:14 2017
> New Revision: 1801108
> URL: http://svn.apache.org/viewvc?rev=1801108&view=rev
> Log:
> Add exception checks to some of the JavaHL native code to avoid JVM
> warnings about JNI problems of the form:
> WARNING in native method: JNI call made without checking exceptions when required to

I've upgraded my JDK and it produced all these warnings. I'm not sure
of the rules for JNI exception checking, take Iterator.cpp for example.
The call to JNIUtil::getInv() in Iterator::next() needs to be checked or
the warning is generated:

  jobject Iterator::next() const
    if (!m_jiterator)
      return NULL;

    JNIEnv* env = JNIUtil::getEnv();
    if (JNIUtil::isJavaExceptionThrown())
      return NULL;

    static jmethodID next_mid = 0;

however similar code in Iterator::hasNext() doesn't need the check, at
least as far as the warning is concerned:

  bool Iterator::hasNext() const
    if (!m_jiterator)
      return false;

    JNIEnv* env = JNIUtil::getEnv();

    static jmethodID hasNext_mid = 0;

Both functions are used by the testsuite but only Iterator::next()
causes the warning. Is Iterator::hasNext() correct to omit the check or
is this a limitation of the warning system? Should all calls to
JNIUtil::getEnv() be checked?

Received on 2017-07-06 23:03:26 CEST

This is an archived mail posted to the Subversion Dev mailing list.