[Jython-dev] RE: [Jython-users] Jython string coercion to java String
by maohai huang other posts by this author
Apr 23 2003 12:21PM messages near this date
[Jython-dev] readline support - uniread
|
[Jython-dev] Pre-release progress
Thanks Jeff. I see your and finn's replies ( athttp://aspn.activestate.com/ASPN/Mail/Message
/1580322) and wonder why doesn't Jython reflect on Java Stringand find out all the classes a
nd interfaces it inherits, andtest if c is an instance of any of them, instead of hard-wirin
g it like:
> if (c == String.class || c == Object.class || c == Serializable.class) ma0hai
Jeff Emanuel <JEmanuel@[...].com> wrote:
Please look in the mailing list archives for a recent
discussion on converting jython strings to CharSequence.
The same issues apply.
-----Original Message-----
From: maohai huang [mailto:lists_mh@[...].com]
Sent: Tuesday, April 22, 2003 4:47 PM
To: jython-users@[...].net
Subject: [Jython-users] Jython string coercion to java String
hi, I have this java class
public class Foo {
public void com(java.lang.Comparable c) {
}
}
in jython I want to pass it a jython string:
jython
Jython 2.1 on java1.4.1_01 (JIT: null)
Type "copyright", "credits" or "license" for more information.
> >> import Foo
> >> f=Foo()
> >> f.com('as')
Traceback (innermost last):
File "", line 1, in ?
TypeError: com(): 1st arg can't be coerced to java.lang.Comparable
> >>
I would expect jython to know that Java String class
implements the java.lang.Comparable interface, and
does some coercion so that it would work, just
as if I typed this:
> >>from java.lang import String
...
> >>f.com(String('as'))
Am I missing something? sorry if this is an old question.
thanks
ma0hai
---------------------------------
Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo.
Attachments:
unknown1
Thread:
Jeff Emanuel
maohai huang
|