lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From va...@apache.org
Subject svn commit: r757503 - in /lucene/pylucene/trunk: ./ Makefile jcc/CHANGES jcc/jcc/sources/JCCEnv.cpp jcc/jcc/sources/functions.cpp
Date Mon, 23 Mar 2009 19:05:29 GMT
Author: vajda
Date: Mon Mar 23 19:05:29 2009
New Revision: 757503

URL: http://svn.apache.org/viewvc?rev=757503&view=rev
Log:
 - fixed bug with failing to detect missing initVM() call
 - failure to call attachCurrentThread() now reported with error, not crash

Modified:
    lucene/pylucene/trunk/   (props changed)
    lucene/pylucene/trunk/Makefile
    lucene/pylucene/trunk/jcc/CHANGES
    lucene/pylucene/trunk/jcc/jcc/sources/JCCEnv.cpp
    lucene/pylucene/trunk/jcc/jcc/sources/functions.cpp

Propchange: lucene/pylucene/trunk/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Mon Mar 23 19:05:29 2009
@@ -1,4 +1,5 @@
 lucene-java-*
+distrib
 build
 dist
 t

Modified: lucene/pylucene/trunk/Makefile
URL: http://svn.apache.org/viewvc/lucene/pylucene/trunk/Makefile?rev=757503&r1=757502&r2=757503&view=diff
==============================================================================
--- lucene/pylucene/trunk/Makefile (original)
+++ lucene/pylucene/trunk/Makefile Mon Mar 23 19:05:29 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
@@ -57,14 +57,14 @@
 #PREFIX_PYTHON=/usr
 #ANT=ant
 #PYTHON=$(PREFIX_PYTHON)/bin/python
-#JCC=$(PYTHON) /System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site-packages/JCC-2.1-py2.3-macosx-10.4-i386.egg/jcc/__init__.py
+#JCC=$(PYTHON) /System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site-packages/JCC-2.2-py2.3-macosx-10.4-i386.egg/jcc/__init__.py
 #NUM_FILES=2
 
 # Mac OS X  (Python 2.3.5, Java 1.5, setuptools 0.6c7, PPC Mac OS X 10.4)
 #PREFIX_PYTHON=/usr
 #ANT=ant
 #PYTHON=$(PREFIX_PYTHON)/bin/python
-#JCC=$(PYTHON) /System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site-packages/JCC-2.1-py2.3-macosx-10.4-ppc.egg/jcc/__init__.py
+#JCC=$(PYTHON) /System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site-packages/JCC-2.2-py2.3-macosx-10.4-ppc.egg/jcc/__init__.py
 #NUM_FILES=2
 
 # Linux     (Ubuntu 6.06, Python 2.4, Java 1.5, no setuptools)

Modified: lucene/pylucene/trunk/jcc/CHANGES
URL: http://svn.apache.org/viewvc/lucene/pylucene/trunk/jcc/CHANGES?rev=757503&r1=757502&r2=757503&view=diff
==============================================================================
--- lucene/pylucene/trunk/jcc/CHANGES (original)
+++ lucene/pylucene/trunk/jcc/CHANGES Mon Mar 23 19:05:29 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/trunk/jcc/jcc/sources/JCCEnv.cpp
URL: http://svn.apache.org/viewvc/lucene/pylucene/trunk/jcc/jcc/sources/JCCEnv.cpp?rev=757503&r1=757502&r2=757503&view=diff
==============================================================================
--- lucene/pylucene/trunk/jcc/jcc/sources/JCCEnv.cpp (original)
+++ lucene/pylucene/trunk/jcc/jcc/sources/JCCEnv.cpp Mon Mar 23 19:05:29 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/trunk/jcc/jcc/sources/functions.cpp
URL: http://svn.apache.org/viewvc/lucene/pylucene/trunk/jcc/jcc/sources/functions.cpp?rev=757503&r1=757502&r2=757503&view=diff
==============================================================================
--- lucene/pylucene/trunk/jcc/jcc/sources/functions.cpp (original)
+++ lucene/pylucene/trunk/jcc/jcc/sources/functions.cpp Mon Mar 23 19:05:29 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;
               }
 



Mime
View raw message