~ubuntu-branches/ubuntu/trusty/subversion/trusty-proposed

« back to all changes in this revision

Viewing changes to subversion/bindings/javahl/native/SVNBase.cpp

  • Committer: Package Import Robot
  • Author(s): Andy Whitcroft
  • Date: 2012-06-21 15:36:36 UTC
  • mfrom: (0.4.13 sid)
  • Revision ID: package-import@ubuntu.com-20120621153636-amqqmuidgwgxz1ly
Tags: 1.7.5-1ubuntu1
* Merge from Debian unstable.  Remaining changes:
  - Create pot file on build.
  - Build a python-subversion-dbg package.
  - Build-depend on python-dbg.
  - Build-depend on default-jre-headless/-jdk.
  - Do not apply java-build patch.
  - debian/rules: Manually create the doxygen output directory, otherwise
    we get weird build failures when running parallel builds.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/**
2
2
 * @copyright
3
3
 * ====================================================================
4
 
 * Copyright (c) 2003-2006 CollabNet.  All rights reserved.
5
 
 *
6
 
 * This software is licensed as described in the file COPYING, which
7
 
 * you should have received as part of this distribution.  The terms
8
 
 * are also available at http://subversion.tigris.org/license-1.html.
9
 
 * If newer versions of this license are posted there, you may use a
10
 
 * newer version instead, at your option.
11
 
 *
12
 
 * This software consists of voluntary contributions made by many
13
 
 * individuals.  For exact contribution history, see the revision
14
 
 * history and logs, available at http://subversion.tigris.org/.
 
4
 *    Licensed to the Apache Software Foundation (ASF) under one
 
5
 *    or more contributor license agreements.  See the NOTICE file
 
6
 *    distributed with this work for additional information
 
7
 *    regarding copyright ownership.  The ASF licenses this file
 
8
 *    to you under the Apache License, Version 2.0 (the
 
9
 *    "License"); you may not use this file except in compliance
 
10
 *    with the License.  You may obtain a copy of the License at
 
11
 *
 
12
 *      http://www.apache.org/licenses/LICENSE-2.0
 
13
 *
 
14
 *    Unless required by applicable law or agreed to in writing,
 
15
 *    software distributed under the License is distributed on an
 
16
 *    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 
17
 *    KIND, either express or implied.  See the License for the
 
18
 *    specific language governing permissions and limitations
 
19
 *    under the License.
15
20
 * ====================================================================
16
21
 * @endcopyright
17
22
 *
23
28
#include "JNIUtil.h"
24
29
 
25
30
SVNBase::SVNBase()
 
31
    : pool(JNIUtil::getPool())
26
32
{
 
33
  jthis = NULL;
27
34
}
28
35
 
29
36
SVNBase::~SVNBase()
30
37
{
31
38
}
32
39
 
33
 
jlong SVNBase::getCppAddr()
 
40
jlong SVNBase::getCppAddr() const
34
41
{
35
42
  return reinterpret_cast<jlong>(this);
36
43
}
39
46
                                     const char *className)
40
47
{
41
48
  JNIEnv *env = JNIUtil::getEnv();
 
49
 
42
50
  findCppAddrFieldID(fid, className, env);
43
51
  if (*fid == 0)
44
52
    {
47
55
  else
48
56
    {
49
57
      jlong cppAddr = env->GetLongField(jthis, *fid);
50
 
      return (JNIUtil::isJavaExceptionThrown() ? 0 : cppAddr);
 
58
      if (JNIUtil::isJavaExceptionThrown())
 
59
        return 0;
 
60
 
 
61
      if (cppAddr)
 
62
        {
 
63
          /* jthis is not guaranteed to be the same between JNI invocations, so
 
64
             we do a little dance here and store the updated version in our
 
65
             object for this invocation.
 
66
 
 
67
             findCppAddrForJObject() is, by necessity, called before any other
 
68
             methods on the C++ object, so by doing this we can guarantee a
 
69
             valid jthis pointer for subsequent uses. */
 
70
          (reinterpret_cast<SVNBase *> (cppAddr))->jthis = jthis;
 
71
        }
 
72
      return cppAddr;
51
73
    }
52
74
}
53
75
 
60
82
  JNIUtil::enqueueForDeletion(this);
61
83
}
62
84
 
63
 
void SVNBase::dispose(jobject jthis, jfieldID *fid, const char *className)
 
85
void SVNBase::dispose(jfieldID *fid, const char *className)
64
86
{
 
87
  jobject my_jthis = this->jthis;
 
88
 
65
89
  delete this;
66
90
  JNIEnv *env = JNIUtil::getEnv();
67
91
  SVNBase::findCppAddrFieldID(fid, className, env);
68
92
  if (*fid == 0)
69
93
    return;
70
94
 
71
 
  env->SetLongField(jthis, *fid, 0);
 
95
  env->SetLongField(my_jthis, *fid, 0);
72
96
  if (JNIUtil::isJavaExceptionThrown())
73
97
    return;
74
98
}