[Jython] Generated Java file doesn't extend base class?

Johannes Eble skywalkerpackage at hotmail.com
Mon Dec 16 15:08:26 EST 2002


Hello all,

I try to create Java class files from Python for a Java Agents
Environment (Grasshopper, see www.ikv.de). I use Jython for this task.

In order to create a minimal Grasshopper mobile agent you just have to
extend de.ikv.grasshopper.agent.MobileAgent and to overwrite the
live() methode. This looks as follows in Java:

// sample file HelloAgent.java
import de.ikv.grasshopper.agent.MobileAgent;

public class HelloAgent extends MobileAgent {
	public void live() {
		log("Hello Agent!");
	}
}

Therfore, I thought the equivalent Python code would look like this:

# HelloAgent.py
from de.ikv.grasshopper.agent import MobileAgent

class HelloAgent(de.ikv.grasshopper.agent.MobileAgent):
	def live(self):
		"@sig public void live()"
       		 log("Hello Agent!")




I don't get a compilation error, but it doesn't work because the
generated Java file (HelloAgent.java) extends java.lang.Object and not
de.ikv.grasshopper.agent.MobileAgent

Why? Can't I force jythonc to generate a Java file that extends
de.ikv.grasshopper.MobileAgent?

Any help would be great.

ByeBye

Johannes



More information about the Python-list mailing list