From: Fabrizio L. <re...@bu...> - 2016-04-13 15:00:27
|
New submission from Fabrizio Lungo: I am sure there are probably other objects that cause this, but if you instantiate a `PyInteger` before any other call within the jython library, it will then cause the instantiation of a `PythonInterpreter` to always throw a NullPointerException. This is very easy to reproduce: ``` public class NPETest { public static void main(String[] args) { new PyInteger(0); new PythonInterpreter(); } } ``` When the above code is run, the following warning message is printed: ``` init: Bootstrapping class not in BootstrapTypesSingleton.getInstance()[class=class org.python.core.PyInteger] ``` This can be avoided by getting the class loader to load the `PyObject` class before instantiating the new `PyInteger` even indirectly through loading `PyInteger`: adding `System.out.println(PyInteger.gcMonitorGlobal);` before instantiating the PyInteger works. This seems to only works because `PyInteger.gcMonitorGlobal` is inherited from `PyObject`. I am not sure if adding a static code block that forces initialisation in `PyInteger` will help, or even be the best way to resolve this but it might work as a temporary fix. This may be related to #1671 or the fix introduced for it. ---------- components: Core, Library messages: 10835 nosy: flungo severity: normal status: open title: NPE for PythonInterpreter after new PyInteger type: crash versions: Jython 2.7 _______________________________________ Jython tracker <re...@bu...> <http://bugs.jython.org/issue2492> _______________________________________ |