|
From: John M. <joh...@ya...> - 2001-02-12 06:19:36
|
Ugh! I've been working all day translating some low level JPython
classes to Java. I want to see how much it improves performance.
But I'm getting the following error when trying to use the Java classes
in JPython. Here's a brief example in hope that someone will point out
my error.
$ cat Queue.java
public class Queue {
int i;
public Queue(int n) {
super();
this.i = n;
}
public void foo(int i, char c) {
System.out.println("i=" + i + " c=" + c);
}
}
$ cat MsgQueue.java
import Queue;
public class MsgQueue {
public MsgQueue(boolean qSize) {
super();
System.out.println("qSize=" + qSize);
}
public void putMsg(Queue q) {
synchronized (this) {
System.out.println("in synchronized putMsg");
}
}
}
$ CLASSPATH=$CLASSPATH:$(pwd)
$ javac Queue.java
$ javac MsgQueue.java
$ cat TestMsgQueue.py
#! /usr/bin/env jpython
import MsgQueue, Queue
class Test(MsgQueue):
def __init__(self):
MsgQueue.__init__(self, 0)
startQ = Queue(10)
print 'startQ=%s' % `startQ`
print 'type(startQ)=%s' % `type(startQ)`
self.putMsg(startQ)
t = Test()
$ TestMsgQueue.py
qSize=false
startQ=Queue@4fec48
type(startQ)=<jclass org.python.core.PyInstance at 6411754>
Traceback (innermost last):
File "TestMsgQueue.py", line 15, in ?
File "TestMsgQueue.py", line 13, in __init__
TypeError: putMsg(): 1st arg can't be coerced to Queue
$
__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail - only $35
a year! http://personal.mail.yahoo.com/
|