|
From: Chris M. <ch...@bo...> - 2001-11-17 20:28:09
|
My program works fine in jython, but I can't use jythonc to create an
applet.
I narrowed the problem down to this line of python code:
import random
The stack trace given when I try to run the applet is as follows (it's
longer than that, but I'm trying to keep the message short).
Java Traceback:
at org.python.core.Py.JavaError(Py.java)
at org.python.core.BytecodeLoader.makeCode(BytecodeLoader.java)
at org.python.core.Py.compile_flags(Py.java)
at org.python.core.Py.compile_flags(Py.java)
at org.python.core.Py.compile_flags(Py.java)
at org.python.core.__builtin__.eval(__builtin__.java)
at org.python.core.__builtin__.eval(__builtin__.java)
at java.lang.reflect.Method.invoke(Native Method)
at
org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java)
at
org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java)
at org.python.core.PyObject.__call__(PyObject.java)
at random$_PyInner._verify$1(random.java:377)
at random$_PyInner.call_function(random.java:310)
at org.python.core.PyTableCode.call(PyTableCode.java)
at org.python.core.PyTableCode.call(PyTableCode.java)
at org.python.core.PyFunction.__call__(PyFunction.java)
at random$_PyInner.main$31(random.java:1029)
at random$_PyInner.call_function(random.java:370)
at org.python.core.PyTableCode.call(PyTableCode.java)
at org.python.core.PyCode.call(PyCode.java)
<snip>
So, it appears that the _verify method in the random module is doing an
eval! That's all well and good, but I don't have org.python.core.parser
anywhere in my jar file. Oops.
It turns out that adding that file doesn't help. If I use the --all
flag, I get this:
Java Traceback:
at org.python.core.Py.JavaError(Py.java)
at org.python.core.BytecodeLoader.makeCode(BytecodeLoader.java)
at org.python.core.Py.compile_flags(Py.java)
at org.python.core.Py.compile_flags(Py.java)
at org.python.core.Py.compile_flags(Py.java)
at org.python.core.__builtin__.eval(__builtin__.java)
at org.python.core.__builtin__.eval(__builtin__.java)
at java.lang.reflect.Method.invoke(Native Method)
at
org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java)
at
org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java)
at org.python.core.PyObject.__call__(PyObject.java)
at random$_PyInner._verify$1(random.java:377)
....
File "/usr/local/jython-2.1a3/Lib/random.py", line 0, in main
File "/usr/local/jython-2.1a3/Lib/random.py", line 0, in _verify
java.security.AccessControlException: access denied
(java.lang.RuntimePermission createClassLoader)
at
java.security.AccessControlContext.checkPermission(AccessControlContext.java:272)
at
java.security.AccessController.checkPermission(AccessController.java:399)
at
java.lang.SecurityManager.checkPermission(SecurityManager.java:545)
at
java.lang.SecurityManager.checkCreateClassLoader(SecurityManager.java:610)
at java.lang.ClassLoader.<init>(ClassLoader.java:234)
at org.python.core.BytecodeLoader1.<init>(BytecodeLoader1.java)
at org.python.core.BytecodeLoader.makeLoader(BytecodeLoader.java)
at org.python.core.BytecodeLoader.makeClass(BytecodeLoader.java)
at org.python.core.BytecodeLoader.makeCode(BytecodeLoader.java)
at org.python.core.Py.compile_flags(Py.java)
at org.python.core.Py.compile_flags(Py.java)
at org.python.core.Py.compile_flags(Py.java)
etc, etc.
So, I tried not importing random at all, but rather doing a simple eval:
print eval("1 + 1")
Again, I am required to use --all (which kind of makes sense), and
again, I get an AccessControlException just like above.
Does this mean that I can't use eval or any module that uses eval in my
applets?
C
|