Fw: limits of java interoperability?

"Stefan Richthofer" <[email protected]>
Newsgroups gmane.comp.lang.jython.devel
Message-ID <trinity-f065994a-f4ec-4a83-a396-9f10bc3e838a-1413678224446@3capp-gmx-bs11>
Okay, the issue demonstrated in testReturnString() comes because Jython returns strings as unicode-objects to Python. So I would consider it "okay" behavior, somewhat cumbersome though, since the method explicitly returns type "String". I guess this is the trade-off to pay for automatic type conversions...

However this does not explain the inner classes issue.

Gesendet: Sonntag, 19. Oktober 2014 um 02:08 Uhr

Von: "Stefan Richthofer" <[email protected]>

An: "Jython Developers" <[email protected]>

Betreff: limits of java interoperability?

Hello everybody,

it appears that Java interoperation does not work with inner classes or with objects created on java-side that were returned to Python. I find these limits quite disappointing and wonder if these are bugs or if I do something wrong. I assembled a trivial example to demonstrate these issues. Can you reproduce them? Are they well known limits or bugs?

------------(Java-file DemoClass.java)-----------------

import org.python.core.*;

public class DemoClass extends PyObject {

static class DemoInner {

public String demoMemberString = "inner member";

public int demoMemberInt = 42;

public void inner_test() {

System.out.println("inner_test!!");

}

}

public String demoMemberString = "member";

public int demoMemberInt = 4;

public void test() {

System.out.println("test!!");

}

public DemoInner makeInner() {

return new DemoInner();

}

public String makeString() {

return "test makeString";

}

public DemoClass makeDemo() {

DemoClass result = new DemoClass();

result.demoMemberInt = 25;

result.demoMemberString = "Java-created demo";

return result;

}

--------------demo jython script-----------------

def testReturnString():

dc = DemoClass()

print dc.demoMemberInt

print dc.demoMemberString

print dc.test()

dc2 = dc.makeDemo()

str = String("abcdef")

print str

print str.charAt(5) #works

str2 = dc.makeString()

print str2

print str2.charAt(5) #works not

def testInner():

dc = DemoClass()

print dc.demoMemberInt

print dc.demoMemberString

print dc.test() #works

dc2 = dc.makeDemo()

print dc2

print dc2.demoMemberInt

inner = dc.makeInner()

print inner

print inner.inner_test() #works not

print inner.demoMemberString #works not

if __name__ == '__main__':

import sys

from java.lang import String

sys.path.append('/home/stefan/eclipseWorkspace/JythonDemo-Java/bin')

import DemoClass

#select an issue to demonstrate:

#testReturnString()

testInner()

I scanned through the list of open issues, but could not find these. Please apologize if I overlooked something.

-Stefan

------------------------------------------------------------------------------
Comprehensive Server Monitoring with Site24x7.
Monitor 10 servers for $9/Month.
Get alerted through email, SMS, voice calls or mobile push notifications.
Take corrective actions from your mobile device.
http://p.sf.net/sfu/Zoho

_______________________________________________
Jython-dev mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jython-dev
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.