limits of java interoperability?
"Stefan Richthofer" <[email protected]>
| Newsgroups | gmane.comp.lang.jython.devel |
|---|---|
| Message-ID | <trinity-eb35ab89-a85a-48fd-9771-cdf7b7b84477-1413677287187@3capp-gmx-bs11> |
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