You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by va...@apache.org on 2009/03/23 20:07:22 UTC
svn commit: r757506 - in /lucene/pylucene/branches/pylucene_2_4: Makefile
jcc/CHANGES jcc/jcc/sources/JCCEnv.cpp jcc/jcc/sources/functions.cpp
Author: vajda
Date: Mon Mar 23 19:07:22 2009
New Revision: 757506
URL: http://svn.apache.org/viewvc?rev=757506&view=rev
Log:
- merged trunk rev 757503
- prepared PyLucene 2.4.1 RC6
Modified:
lucene/pylucene/branches/pylucene_2_4/Makefile
lucene/pylucene/branches/pylucene_2_4/jcc/CHANGES
lucene/pylucene/branches/pylucene_2_4/jcc/jcc/sources/JCCEnv.cpp
lucene/pylucene/branches/pylucene_2_4/jcc/jcc/sources/functions.cpp
Modified: lucene/pylucene/branches/pylucene_2_4/Makefile
URL: http://svn.apache.org/viewvc/lucene/pylucene/branches/pylucene_2_4/Makefile?rev=757506&r1=757505&r2=757506&view=diff
==============================================================================
--- lucene/pylucene/branches/pylucene_2_4/Makefile (original)
+++ lucene/pylucene/branches/pylucene_2_4/Makefile Mon Mar 23 19:07:22 2009
@@ -14,7 +14,7 @@
# site-packages directory.
#
-VERSION=2.4.1-rc5
+VERSION=2.4.1-rc6
LUCENE_SVN_VER=HEAD
LUCENE_VER=2.4.1
LUCENE_SVN=http://svn.apache.org/repos/asf/lucene/java/tags/lucene_2_4_1
Modified: lucene/pylucene/branches/pylucene_2_4/jcc/CHANGES
URL: http://svn.apache.org/viewvc/lucene/pylucene/branches/pylucene_2_4/jcc/CHANGES?rev=757506&r1=757505&r2=757506&view=diff
==============================================================================
--- lucene/pylucene/branches/pylucene_2_4/jcc/CHANGES (original)
+++ lucene/pylucene/branches/pylucene_2_4/jcc/CHANGES Mon Mar 23 19:07:22 2009
@@ -18,6 +18,7 @@
- passing strings for byte[] or char[] is no longer supported, use JArray
- failure to call initVM() now reported with error instead of crash
- failure to find class now reported with error instead of crash
+ - failure to call attachCurrentThread() now reported with error, not crash
Version 2.0 -> 2.1
------------------
Modified: lucene/pylucene/branches/pylucene_2_4/jcc/jcc/sources/JCCEnv.cpp
URL: http://svn.apache.org/viewvc/lucene/pylucene/branches/pylucene_2_4/jcc/jcc/sources/JCCEnv.cpp?rev=757506&r1=757505&r2=757506&view=diff
==============================================================================
--- lucene/pylucene/branches/pylucene_2_4/jcc/jcc/sources/JCCEnv.cpp (original)
+++ lucene/pylucene/branches/pylucene_2_4/jcc/jcc/sources/JCCEnv.cpp Mon Mar 23 19:07:22 2009
@@ -71,7 +71,7 @@
}
#endif
- if (vm != NULL)
+ if (vm)
set_vm(vm, vm_env);
else
this->vm = NULL;
@@ -132,8 +132,25 @@
{
jclass cls = NULL;
- if (env->vm)
- cls = get_vm_env()->FindClass(className);
+ if (vm)
+ {
+ JNIEnv *vm_env = get_vm_env();
+
+ if (vm_env)
+ cls = vm_env->FindClass(className);
+#ifdef PYTHON
+ else
+ {
+ PythonGIL gil;
+
+ PyErr_SetString(PyExc_RuntimeError, "attachCurrentThread() must be called first");
+ throw pythonError(NULL);
+ }
+#else
+ else
+ throw exception(NULL);
+#endif
+ }
#ifdef PYTHON
else
{
@@ -239,14 +256,30 @@
jobject JCCEnv::newObject(jclass (*initializeClass)(), jmethodID **mids,
int m, ...)
{
- jclass cls;
+ jclass cls = (*initializeClass)();
+ JNIEnv *vm_env = get_vm_env();
jobject obj;
- va_list ap;
- va_start(ap, m);
- cls = (*initializeClass)();
- obj = get_vm_env()->NewObjectV(cls, (*mids)[m], ap);
- va_end(ap);
+ if (vm_env)
+ {
+ va_list ap;
+
+ va_start(ap, m);
+ obj = vm_env->NewObjectV(cls, (*mids)[m], ap);
+ va_end(ap);
+ }
+#ifdef PYTHON
+ else
+ {
+ PythonGIL gil;
+
+ PyErr_SetString(PyExc_RuntimeError, "attachCurrentThread() must be called first");
+ throw pythonError(NULL);
+ }
+#else
+ else
+ throw exception(NULL);
+#endif
reportException();
@@ -611,7 +644,8 @@
{
if (object == Py_None)
return NULL;
- else if (PyUnicode_Check(object))
+
+ if (PyUnicode_Check(object))
{
if (sizeof(Py_UNICODE) == sizeof(jchar))
{
Modified: lucene/pylucene/branches/pylucene_2_4/jcc/jcc/sources/functions.cpp
URL: http://svn.apache.org/viewvc/lucene/pylucene/branches/pylucene_2_4/jcc/jcc/sources/functions.cpp?rev=757506&r1=757505&r2=757506&view=diff
==============================================================================
--- lucene/pylucene/branches/pylucene_2_4/jcc/jcc/sources/functions.cpp (original)
+++ lucene/pylucene/branches/pylucene_2_4/jcc/jcc/sources/functions.cpp Mon Mar 23 19:07:22 2009
@@ -110,6 +110,20 @@
va_start(check, types);
#endif
+ if (!env->vm)
+ {
+ PyErr_SetString(PyExc_RuntimeError, "initVM() must be called first");
+ return -1;
+ }
+
+ JNIEnv *vm_env = env->get_vm_env();
+
+ if (!vm_env)
+ {
+ PyErr_SetString(PyExc_RuntimeError, "attachCurrentThread() must be called first");
+ return -1;
+ }
+
unsigned int pos = 0;
int array = 0;
@@ -171,7 +185,7 @@
int ok =
(obj == Py_None ||
(PyObject_TypeCheck(obj, &Object$$Type) &&
- env->get_vm_env()->IsInstanceOf(((t_Object *) obj)->object.this$, cls)));
+ vm_env->IsInstanceOf(((t_Object *) obj)->object.this$, cls)));
Py_DECREF(obj);
if (ok)
@@ -182,13 +196,13 @@
}
}
else if (PyObject_TypeCheck(arg, &Object$$Type) &&
- env->get_vm_env()->IsInstanceOf(((t_Object *) arg)->object.this$, cls))
+ vm_env->IsInstanceOf(((t_Object *) arg)->object.this$, cls))
break;
else if (PyObject_TypeCheck(arg, &FinalizerProxy$$Type))
{
arg = ((t_fp *) arg)->object;
if (PyObject_TypeCheck(arg, &Object$$Type) &&
- env->get_vm_env()->IsInstanceOf(((t_Object *) arg)->object.this$, cls))
+ vm_env->IsInstanceOf(((t_Object *) arg)->object.this$, cls))
break;
}