Skip to content
Permalink
Browse files

Fix local referencing issues.

  • Loading branch information
Thrameos committed Jan 4, 2020
1 parent d015893 commit 4346b75fd71d5e03a4313bca173c103e7b412f97
@@ -12,7 +12,7 @@
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*****************************************************************************/
#include <Python.h> // FIXME work on bytes, remove when complete
#include <jpype.h>
@@ -58,7 +58,7 @@ JPMatch::Type JPArrayClass::canConvertToJava(PyObject* obj)
return JPMatch::_implicit; // FIXME this should be JPMatch::_explicit under java rules.
}

#if PY_MAJOR_VERSION >= 3
#if PY_MAJOR_VERSION >= 3
// Bytes are byte[]
if (PyBytes_Check(obj) && m_ComponentType == JPTypeManager::_byte)
{
@@ -142,7 +142,7 @@ jvalue JPArrayClass::convertToJava(PyObject* obj)
return res;
}

#if PY_MAJOR_VERSION >= 3
#if PY_MAJOR_VERSION >= 3
if (PyBytes_Check(obj) && m_ComponentType == JPTypeManager::_byte)
{
Py_ssize_t size = 0;
@@ -211,6 +211,6 @@ JPValue JPArrayClass::newInstance(int length)
{
JPJavaFrame frame;
jvalue v;
v.l = m_ComponentType->newArrayInstance(frame, length);
v.l = frame.keep(m_ComponentType->newArrayInstance(frame, length));
return JPValue(this, v);
}
@@ -77,15 +77,15 @@ JPMatch::Type JPBoxedClass::canConvertToJava(PyObject* pyobj)
JP_TRACE_OUT;
}

// Specializations for each of the boxed types.
// Specializations for each of the boxed types.
// This sets up the table of conversions that we allow

//============================================================

jclass findClass(const string& str)
{
JPJavaFrame frame;
return frame.FindClass(str);
return (jclass) frame.keep((jobject) frame.FindClass(str));
}

//============================================================
@@ -12,7 +12,7 @@
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*****************************************************************************/
#include <jpype.h>

@@ -230,7 +230,7 @@ void JPClass::setArrayRange(JPJavaFrame& frame, jarray a, jsize start, jsize len
JP_TRACE_IN("JPClass::setArrayRange");
jobjectArray array = (jobjectArray) a;

// Verify before we start the conversion, as we wont be able
// Verify before we start the conversion, as we wont be able
// to abort once we start
JPPySequence seq(JPPyRef::_use, vals);
JP_TRACE("Verify argument types");
@@ -286,17 +286,17 @@ JPPyObject JPClass::convertToPythonObject(jvalue obj)
{
JP_TRACE_IN("JPClass::convertToPythonObject");

// FIXME returning None likely incorrect from java prospective.
// Java still knows the type of null objects thus
// converting to None would pose a problem as we lose type.
// We would need subclass None for this to make sense so we
// FIXME returning None likely incorrect from java prospective.
// Java still knows the type of null objects thus
// converting to None would pose a problem as we lose type.
// We would need subclass None for this to make sense so we
// can carry both the type and the null, but Python considers
// None a singleton so this is not an option.
//
// None a singleton so this is not an option.
//
// Of course if we don't mind that "Object is None" would
// fail, but "Object == None" would be true, the we
// could support null objects properly. However, this would
// need to work as "None == Object" which may be hard to
// need to work as "None == Object" which may be hard to
// achieve.
//
// We will still need to have the concept of null objects
@@ -378,8 +378,7 @@ jvalue JPClass::convertToJava(PyObject* obj)
if (value != NULL)
{
JP_TRACE("Value");
res.l = frame.NewLocalRef(value->getJavaObject());
res.l = frame.keep(res.l);
res.l = frame.keep(frame.NewLocalRef(value->getJavaObject()));
return res;
}

@@ -712,7 +712,7 @@ jclass JPJni::getPrimitiveClass(jclass clz)
{
JPJavaFrame frame;
jfieldID fid = frame.GetStaticFieldID(clz, "TYPE", "Ljava/lang/Class;");
jclass res = (jclass) frame.GetStaticObjectField(clz, fid);
jclass res = (jclass) frame.keep(frame.GetStaticObjectField(clz, fid));
return res;
}

@@ -43,7 +43,7 @@ def setUp(self):
logger = logging.getLogger(__name__)
logger.info("Running testsuite using JVM %s" % jvm_path)
classpath_arg = "-Djava.class.path=%s"
args = ["-ea", "-Xmx256M", "-Xms16M" ]
args = ["-ea", "-Xmx256M", "-Xms16M", "-Xcheck:jni" ]
# TODO: enabling this check crashes the JVM with: FATAL ERROR in native method: Bad global or local ref passed to JNI
#"-Xcheck:jni",
if self._jar:

0 comments on commit 4346b75

Please sign in to comment.
You can’t perform that action at this time.