From: Updike, C. <Cla...@jh...> - 2005-09-16 17:36:49
|
Seems to work for me: Jython 2.2a2 on java1.4.2_08 (JIT: null) Type "copyright", "credits" or "license" for more information. >>> import java >>> import array >>> sa =3D array.array(java.lang.String, ['hello','whirled']) >>> java.util.Arrays.asList(sa) [hello, whirled] >>> You should use array instead of jarray for 2.2. It aligns with cpython better (although jarray and array use the same underlying functionality). Eventually jarray will go away. -Clark -----Original Message----- From: On Behalf Of Berlin Brown Sent: Friday, September 16, 2005 1:26 PM To: jyt...@li... Subject: [Jython-users] Jython and jarray.array , passing args to java methods Hmm, maybe I am missing something simple, but I can't=20 pass a jarray.array to a java method that uses arrays? =20 Does this functionality exist and what am I missing. =20 This is with the newest July2005 release of jython. |
From: Berlin B. <ber...@gm...> - 2005-09-16 17:51:37
|
Currently the code is mostly java based, meaning the java code is returning= =20 an array and I am passing that array to another java method and it is=20 blowing up. I might need to inject something there. ie. package org.dog; public org.dog.Stuff [] getFood() public void setFood(org.dog.String [] a) in python: b =3D getFood() print b ... I get the array contents here? so it is converted to a python array? setFood(b)=20 ... Error cannot convert the type. I guess I would need something in between getFood and setFood On 9/16/05, Updike, Clark <Cla...@jh...> wrote: >=20 > Seems to work for me: >=20 > Jython 2.2a2 on java1.4.2_08 (JIT: null) > Type "copyright", "credits" or "license" for more information. > >>> import java > >>> import array > >>> sa =3D array.array(java.lang.String, ['hello','whirled']) > >>> java.util.Arrays.asList(sa) > [hello, whirled] > >>> >=20 > You should use array instead of jarray for 2.2. It aligns > with cpython better (although jarray and array use the same > underlying functionality). Eventually jarray will go away. >=20 > -Clark >=20 > -----Original Message----- > From: On Behalf Of Berlin Brown > Sent: Friday, September 16, 2005 1:26 PM > To: jyt...@li... > Subject: [Jython-users] Jython and jarray.array , passing args to java > methods >=20 >=20 > Hmm, maybe I am missing something simple, but I can't > pass a jarray.array to a java method that uses arrays? > Does this functionality exist and what am I missing. > This is with the newest July2005 release of jython. > |
From: Jeff E. <jem...@fr...> - 2005-09-16 17:56:07
|
Stuff is probably not a String. There's your failed conversion. Berlin Brown wrote: > Currently the code is mostly java based, meaning the java code is returning > an array and I am passing that array to another java method and it is > blowing up. I might need to inject something there. > > ie. > > package org.dog; > public org.dog.Stuff [] getFood() > public void setFood(org.dog.String [] a) > > in python: > > b = getFood() > print b > ... I get the array contents here? so it is converted to a python array? > > setFood(b) > ... Error cannot convert the type. > > I guess I would need something in between getFood and setFood > > > > > On 9/16/05, Updike, Clark <Cla...@jh...> wrote: > >>Seems to work for me: >> >>Jython 2.2a2 on java1.4.2_08 (JIT: null) >>Type "copyright", "credits" or "license" for more information. >> >>>>>import java >>>>>import array >>>>>sa = array.array(java.lang.String, ['hello','whirled']) >>>>>java.util.Arrays.asList(sa) >> >>[hello, whirled] >> >>You should use array instead of jarray for 2.2. It aligns >>with cpython better (although jarray and array use the same >>underlying functionality). Eventually jarray will go away. >> >>-Clark >> >>-----Original Message----- >>From: On Behalf Of Berlin Brown >>Sent: Friday, September 16, 2005 1:26 PM >>To: jyt...@li... >>Subject: [Jython-users] Jython and jarray.array , passing args to java >>methods >> >> >>Hmm, maybe I am missing something simple, but I can't >>pass a jarray.array to a java method that uses arrays? >>Does this functionality exist and what am I missing. >>This is with the newest July2005 release of jython. >> > > |
From: Diez B. R. <de...@we...> - 2005-09-16 18:56:04
|
Berlin Brown wrote: > Currently the code is mostly java based, meaning the java code is > returning an array and I am passing that array to another java method > and it is blowing up. I might need to inject something there. > > ie. > > package org.dog; > public org.dog.Stuff [] getFood() > public void setFood(org.dog.String [] a) > > in python: > > b = getFood() > print b > ... I get the array contents here? so it is converted to a python array? > > setFood(b) > ... Error cannot convert the type. > > I guess I would need something in between getFood and setFood Do post the actual outputs, _especially_ the error! Diez |
From: Ray D. <ray...@ya...> - 2005-09-18 02:19:51
|
Do you have a typo there? "org.dog.String"? Did you mean org.dog.Stuff, or were you really trying to pass an array of Stuffs into a method that expects an array of Strings? (and they're not compatible with each other?) I have passed an array I got from Java to Java thru Jython (2.2), no problem there, e.g.: targets = wldm.getTargets() availableModules = wldm.getAvailableModules(ModuleType.EAR, targets) works just fine... (targets is a Java array of Targets) --- Berlin Brown <ber...@gm...> wrote: > Currently the code is mostly java based, meaning the > java code is returning > an array and I am passing that array to another java > method and it is > blowing up. I might need to inject something there. > > ie. > > package org.dog; > public org.dog.Stuff [] getFood() > public void setFood(org.dog.String [] a) > > in python: > > b = getFood() > print b > ... I get the array contents here? so it is > converted to a python array? > > setFood(b) > ... Error cannot convert the type. > > I guess I would need something in between getFood > and setFood > > > > > On 9/16/05, Updike, Clark <Cla...@jh...> > wrote: > > > > Seems to work for me: > > > > Jython 2.2a2 on java1.4.2_08 (JIT: null) > > Type "copyright", "credits" or "license" for more > information. > > >>> import java > > >>> import array > > >>> sa = array.array(java.lang.String, > ['hello','whirled']) > > >>> java.util.Arrays.asList(sa) > > [hello, whirled] > > >>> > > > > You should use array instead of jarray for 2.2. It > aligns > > with cpython better (although jarray and array use > the same > > underlying functionality). Eventually jarray will > go away. > > > > -Clark > > > > -----Original Message----- > > From: On Behalf Of Berlin Brown > > Sent: Friday, September 16, 2005 1:26 PM > > To: jyt...@li... > > Subject: [Jython-users] Jython and jarray.array , > passing args to java > > methods > > > > > > Hmm, maybe I am missing something simple, but I > can't > > pass a jarray.array to a java method that uses > arrays? > > Does this functionality exist and what am I > missing. > > This is with the newest July2005 release of > jython. > > > __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com |