Message1531
I am using jython 2.2rc1, and I think that the problem is not located only in jythonc, which is soon to be deprecated.
My test code:
Base.java:
###Code Begins:
public class Base
{
public String hello(String s){
return "Hello "+s;
}
}
###Code Ends.
Sub.py:
###Code Beings:
import Base
class Sub(Base):
def hi(self,s):
"@seg public String hi(String s1)"
return 'Hi '+s;
###Code Ends
App.java:
###Code begind:
public class App{
public static void main(String [] args){
Sub sub=new Sub();
String response=sub.hi("Utk");
System.out.println(response);
}
}
###Code ends
Now, when I use "jythonc Sub.py" (without compiling Base.java to Base.class)
I get this:
###
Creating .java files:
Sub module
Compiling .java to .class...
Compiling with args: ['/opt/sun-jdk-1.6.0.01/bin/javac', '-classpath', '/home/utkarsh/Jython/jython2.2rc1/jython.jar:.:./jpywork::/home/utkarsh/Jython/jython2.2rc1/Tools/jythonc:/home/utkarsh/Jython/jython2.2rc1/Lib:__classpath__', './jpywork/Sub.java']
0
###
Now, the Sub.class file is generated in the ./jpywork folder, not in the currect directory. Compiling App.java yeilds this error message:
###
App.java:3: cannot find symbol
symbol : class Sub
location: class App
Sub sub=new Sub();
^
###
After copying the Sub.class file from the ./jpyworks directory, this error:
###
App.java:4: cannot find symbol
symbol : method hi(java.lang.String)
location: class Sub
String response=sub.hi("Greetings");
^
###
Hence, the Sub.java file was smoorhtly created wothout any reference to the Base.java file, a bug, in my opinion.
However, if I try importing Sub.py in jython 2.2rc1, I get this encouraging message:
>>> import Sub
Traceback (innermost last):
File "<console>", line 1, in ?
File "/home/utkarsh/Jython/TestingCode/Sub.py", line 1, in ?
ImportError: no module named Base
>>>
On jython2.2b1, the import went smoothly, which was the initial bug itself.
After compiling the Base.java to Base.class, and then running "jythonc Sub.py", I get this (among other irrelevent lines):
###
Creating .java files:
Sub module
Sub extends Base <<<<<<< NOTE THIS LINE
Compiling .java to .class...
Compiling with args: ['/opt/sun-jdk-1.6.0.01/bin/javac', '-classpath', '/home/utkarsh/Jython/jython2.2rc1/jython.jar:.:./jpywork::/home/utkarsh/Jython/jython2.2rc1/Tools/jythonc:/home/utkarsh/Jython/jython2.2rc1/Lib:__classpath__', './jpywork/Sub.java']
0
###
There has been significant change in the ~/src/org/python/core/JavaImportHelper.java,
Hence afterwards, everything works fine, both in App.java and after "import Sub.py". (The Sub.class file made by jythonc is still made in ./jpyworks)
I think that this bug should be completely corrected if we resort to the JythonFactory method of extending code.
So can this bug be closed now?
~~
musically_ut |
|
Date |
User |
Action |
Args |
2008-02-20 17:17:46 | admin | link | issue1674537 messages |
2008-02-20 17:17:46 | admin | create | |
|