Message12208

Author navneethnarendra
Recipients navneethnarendra
Date 2018-12-17.08:16:08
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1545034570.18.0.788709270274.issue2721@psf.upfronthosting.co.za>
In-reply-to
Content
Here is the stack-trace when running the below Java program to invoke simple python code:
************
Exception in thread "main" Traceback (most recent call last):
  File "/Users/<user>/Downloads/jython-standalone-2.7.1.jar/Lib/site.py", line 68, in <module>
  File "/Users/<user>/Downloads/jython-standalone-2.7.1.jar/Lib/os.py", line 426, in <module>
java.lang.IllegalAccessError: tried to access method org.python.core.PyList.getList()Ljava/util/List; from class org.python.core.PyShadowString
	at org.python.core.PyShadowString.isTarget(PyShadowString.java:108)
	at org.python.core.PyShadowString.__eq__(PyShadowString.java:170)
	at org.python.core.PyObject._eq(PyObject.java:1525)
	at org.python.core.PyObject.equals(PyObject.java:318)
	at org.python.core.PyObject.object___contains__(PyObject.java:1769)
	at org.python.core.PyObject.__contains__(PyObject.java:1764)
	at org.python.core.PyObject._in(PyObject.java:1744)
	at os$py.f$0(/Users/<user>/Downloads/jython-standalone 2.7.1.jar/Lib/os.py:726)
	at os$py.call_function(/Users/<user>/Downloads/jython-standalone-2.7.1.jar/Lib/os.py)
	at org.python.core.PyTableCode.call(PyTableCode.java:167)
	at org.python.core.PyCode.call(PyCode.java:18)
	at org.python.core.imp.createFromCode(imp.java:436)
	at org.python.core.util.importer.importer_load_module(importer.java:109)
	at org.python.modules.zipimport.zipimporter.zipimporter_load_module(zipimporter.java:163)
	at org.python.modules.zipimport.zipimporter$zipimporter_load_module_exposer.__call__(Unknown Source)
	at org.python.core.PyBuiltinMethodNarrow.__call__(PyBuiltinMethodNarrow.java:46)
	at org.python.core.imp.loadFromLoader(imp.java:587)
	at org.python.core.imp.find_module(imp.java:537)
	at org.python.core.imp.import_next(imp.java:840)
	at org.python.core.imp.import_module_level(imp.java:959)
	at org.python.core.imp.importName(imp.java:1062)
	at org.python.core.ImportFunction.__call__(__builtin__.java:1280)
	at org.python.core.PyObject.__call__(PyObject.java:431)
	at org.python.core.__builtin__.__import__(__builtin__.java:1232)
	at org.python.core.imp.importOne(imp.java:1081)
	at site$py.f$0(/Users/<user>/Downloads/jython-standalone-2.7.1.jar/Lib/site.py:637)
	at site$py.call_function(/Users/<user>/Downloads/jython-standalone-2.7.1.jar/Lib/site.py)
	at org.python.core.PyTableCode.call(PyTableCode.java:167)
	at org.python.core.PyCode.call(PyCode.java:18)
	at org.python.core.imp.createFromCode(imp.java:436)
	at org.python.core.util.importer.importer_load_module(importer.java:109)
	at org.python.modules.zipimport.zipimporter.zipimporter_load_module(zipimporter.java:163)
	at org.python.modules.zipimport.zipimporter$zipimporter_load_module_exposer.__call__(Unknown Source)
	at org.python.core.PyBuiltinMethodNarrow.__call__(PyBuiltinMethodNarrow.java:46)
	at org.python.core.imp.loadFromLoader(imp.java:587)
	at org.python.core.imp.find_module(imp.java:537)
	at org.python.core.imp.import_next(imp.java:840)
	at org.python.core.imp.import_first(imp.java:861)
	at org.python.core.imp.load(imp.java:716)
	at org.python.core.Py.importSiteIfSelected(Py.java:1558)
	at org.python.util.PythonInterpreter.<init>(PythonInterpreter.java:116)
	at org.python.util.PythonInterpreter.<init>(PythonInterpreter.java:94)
	at org.python.util.PythonInterpreter.<init>(PythonInterpreter.java:71)
	at PythonInJava.main(PythonInJava.java:17)
java.lang.IllegalAccessError: java.lang.IllegalAccessError: tried to access method org.python.core.PyList.getList()Ljava/util/List; from class org.python.core.PyShadowString

*********** JAVA ************
import java.util.Properties;
import org.python.util.PythonInterpreter;

public class PythonInJava {

        @SuppressWarnings("resource")
        public static void main(final String[] args) throws Exception {
                System.setProperty("python.cachedir.skip", "true");

                Properties p = new Properties();
                p.setProperty("python.path","/Users/<user>/Downloads/jython-standalone-2.7.1.jar");
                p.setProperty("python.home","/Users/<user>/Downloads/jython-standalone-2.7.1.jar");
                p.setProperty("python.prefix","/Users/<user>/Downloads/jython-standalone-2.7.1.jar");
                PythonInterpreter.initialize(System.getProperties(), p, new String[] {});
                PythonInterpreter interpreter = new PythonInterpreter();
                interpreter.exec("import sys");
                interpreter.exec("sys.path.append(\"/Library/Python/2.7/site-packages\")");
                interpreter.execfile("/Users/<user>/test.py");
        }
}
History
Date User Action Args
2018-12-17 08:16:10navneethnarendrasetrecipients: + navneethnarendra
2018-12-17 08:16:10navneethnarendrasetmessageid: <1545034570.18.0.788709270274.issue2721@psf.upfronthosting.co.za>
2018-12-17 08:16:09navneethnarendralinkissue2721 messages
2018-12-17 08:16:08navneethnarendracreate