Issue1145

classification
Title: Jython 2.5 compatibility problem with JSR 223
Type: Severity: normal
Components: Core Versions: 2.5alpha3
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: leosoto Nosy List: fkorling, fwierzbicki, jsamsa, leosoto, thijs, tuska
Priority: Keywords:

Created on 2008-10-07.16:00:07 by jsamsa, last changed 2008-12-08.20:23:45 by thijs.

Messages
msg3645 (view) Author: Jason Samsa (jsamsa) Date: 2008-10-07.16:00:27
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)
msg3646 (view) Author: Leonardo Soto (leosoto) Date: 2008-10-07.16:07:45
The breakage is obviously related to the PyObject API change I made on
r5155 (__findattr__ refactor). Looks like we will have to submit an
alternative engine ("python25?"). Which makes me wonder if JSR 223
contains any provision to support different versions of the same
language. In such case, we may want to exploit that.
msg3890 (view) Author: Thijs Triemstra (thijs) Date: 2008-12-08.20:23:45
I also encountered this while trying to get Jython 2.5 working with Ant's 
script task. Only managed to get Jython 2.2.1 working.
History
Date User Action Args
2008-12-08 20:23:45thijssetnosy: + thijs
messages: + msg3890
2008-11-17 14:13:16tuskasetnosy: + tuska
2008-11-11 08:25:01fkorlingsetnosy: + fkorling
2008-11-01 13:58:20fwierzbickisetcomponents: + Core
2008-10-07 16:07:48leosotosetmessages: + msg3646
2008-10-07 16:02:24fwierzbickisetassignee: leosoto
nosy: + fwierzbicki, leosoto
2008-10-07 16:00:55jsamsasettitle: Jython 2.5 compatibility with JSR 223 -> Jython 2.5 compatibility problem with JSR 223
2008-10-07 16:00:30jsamsasetmessages: + msg3645
2008-10-07 16:00:08jsamsacreate