Issue1693847
Created on 2007-04-03.19:16:50 by crapo, last changed 2009-03-14.01:44:02 by fwierzbicki.
File name |
Uploaded |
Description |
Edit |
Remove |
AltB.py
|
crapo,
2007-04-03.19:16:50
|
AltB.py |
|
|
msg1553 (view) |
Author: Andrew W Crapo (crapo) |
Date: 2007-04-03.19:16:50 |
|
I have a small Jython test project in PyDev with structure:
src
bpkg
__init__.py
AltB.py
B.py
NonClassCode.py
From this I wish to run jythonc to create a jar file, b.jar. Note that B.py uses a Java class A in a.jar.
AltB.py is as follows (also attached):
********************************
from NonClassCode import MyFunction
class AltB:
def __init__(self):
pass
def giveGreeting(self, greeting):
"@sig public java.lang.String giveGreeting(java.lang.String greeting)"
MyFunction(greeting + " from AltB")
return "MyFunction called OK"
if __name__ == '__main__':
b = AltB()
b.giveGreeting("Hello")
********************************
NonClassCode.py is:
********************************
def MyFunction(greeting):
print greeting
********************************
I have set classpath to include a.jar. When I run jythonc, I get this output:
processing __init__
processing AltB
processing bpkg.NonClassCode
processing B
Note that I have tried "from bpkg.NonClassCode import MyFunction" in AltB.py, but it seems to have no effect. As this message suggests, NonClassCode.java is placed in .../jpywork/bpkg/bpkg. Note that if NonClassCode is not imported, it isn't placed in the wrong directory.
The jar file created, b.jar, has AltB in it but the method giveGreeting isn't visible. From a Java project I can create an instance of AltB, but I cannot call the method. Looking at the generated Java code, there is no public method.
This is in contrast to the following class B (in B.py):
********************************
import java
from com.ge.research.test import A
class B(java.lang.Object):
def __init__(self):
pass
def sayHello(self, a):
"@sig public java.lang.String sayHello(com.ge.research.test.A a)"
return a.sayHello()
if __name__ == '__main__':
b = B()
a = A()
b.sayHello(a)
*********************************
This generates Java code with a public method sayHello which I can call from Java code that imports AltB from b.jar.
I have not discovered the pattern of when this works as I would expect and when it does not. If there is a way to get consistent behavior please let me know.
|
msg4279 (view) |
Author: Frank Wierzbicki (fwierzbicki) |
Date: 2009-03-14.01:44:02 |
|
jythonc is no longer maintained.
|
|
Date |
User |
Action |
Args |
2009-03-14 01:44:02 | fwierzbicki | set | status: open -> closed resolution: wont fix messages:
+ msg4279 nosy:
+ fwierzbicki |
2007-04-03 19:16:50 | crapo | create | |
|