subversion-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Philip Martin <phi...@codematters.co.uk>
Subject Re: svn commit: r1801108 - in /subversion/trunk/subversion/bindings/javahl/native: Array.cpp CreateJ.cpp Iterator.cpp OperationContext.cpp RemoteSession.cpp RevisionRangeList.cpp
Date Thu, 06 Jul 2017 21:03:19 GMT
philip@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?

-- 
Philip

Mime
View raw message