Message3645
package jython;
import java.util.Arrays;
import java.util.List;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;
class Foo {
private int amount;
public Foo(int amount) {
this.amount = amount;
}
public int getAmount() {
return amount;
}
public void setAmount(int amount) {
this.amount = amount;
}
}
public class JythonExpression {
public static void main(String[] args) {
final List<Foo> foos = Arrays.asList(new Foo(200), new
Foo(10), new Foo(5000));
ScriptEngine engine = new ScriptEngineManager()
.getEngineByName("python");
engine.put("foos", foos);
engine.put("afoo", new Foo(12));
try {
Boolean result =
(Boolean)engine.eval("foo.amount > 1");
System.out.println(result);
} catch (ScriptException e) {
e.printStackTrace();
}
}
}
results in :
Exception in thread "main" java.lang.VerifyError: class
com.sun.script.jython.JythonScope overrides final method
__findattr__.(Ljava/lang/String;)Lorg/python/core/PyObject;
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:675)
at
java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
at java.net.URLClassLoader.access$000(URLClassLoader.java:56)
at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:316)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:288)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:374)
at
com.sun.script.jython.JythonScriptEngineFactory.getScriptEngine(JythonSc
riptEngineFactory.java:132)
at
javax.script.ScriptEngineManager.getEngineByName(ScriptEngineManager.jav
a:225)
at jython.JythonExpression.main(JythonExpression.java:31) |
|
Date |
User |
Action |
Args |
2008-10-07 16:00:31 | jsamsa | set | messageid: <1223395231.32.0.703467693086.issue1145@psf.upfronthosting.co.za> |
2008-10-07 16:00:31 | jsamsa | set | recipients:
+ jsamsa |
2008-10-07 16:00:30 | jsamsa | link | issue1145 messages |
2008-10-07 16:00:28 | jsamsa | create | |
|