Bugs item #1674537, was opened at 2007-03-05 19:52
Message generated for change (Comment added) made by cgroves
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=112867&aid=1674537&group_id=12867
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
>Category: Jythonc compiler
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Brian Schlining (hohonuuli)
Assigned to: Nobody/Anonymous (nobody)
Summary: Bogus import fails silently
Initial Comment:
ENVIRONMENT: Jython 2.2b1 on java1.5.0_07 (JIT: null) on Mac OS X 10.4.8
When jython encounters a incorrectly named imported java class it fails silently; Here's an example. Below is it the imports of my jython module and the first funciton in the module. The line 'from org.mbari.vcr import Timecode' is bogus; it should be 'from org.mbari.movie import Timecode'. The jython class is created up to the bogus line
# Start module - mbari.eitsdb
import exceptions
import mbari.aveddb
from org.mbari.vars.annotation.model import Association
from org.mbari.vars.annotation.model import CameraData
from org.mbari.vars.annotation.model import CameraPlatformDeployment
from org.mbari.vars.annotation.model import Observation
from org.mbari.vars.annotation.model import PhysicalData
from org.mbari.vars.annotation.model import VideoArchive
from org.mbari.vars.annotation.model import VideoArchiveSet
from org.mbari.vars.annotation.model import VideoFrame
from org.mbari.vars.annotation.model.dao import VideoArchiveDAO
from org.mbari.vars.annotation.model.dao import VideoArchiveSetDAO
from org.mbari.vcr import Timecode # <-- MISNAMED IMPORT
from org.slf4j import Logger
from org.slf4j import LoggerFactory
def importEvents(url, frameRate):
pass
This is the result of trying to load the module:
>>> import mbari.eitsdb
>>> dir(mbari.eitsdb)
['Association', 'CameraData', 'CameraPlatformDeployment', 'Observation', 'PhysicalData', 'VideoArchive', 'VideoArchiveDAO', 'VideoArchiveSet', 'VideoArchiveSetDAO', 'VideoFrame', '__doc__', '__file__', '__name__', 'exceptions', 'mbari']
>>> mbari.eitsdb.importEvents(url, frameRate)
AttributeError: module 'mbari.eitsdb' has no attribute 'importEvents'
So Jython is loading the module up to the point that it encounters a bad import, but it fails silently so it appears the module loaded fine, until I try to access a method that is in the module after the bogus line.
----------------------------------------------------------------------
>Comment By: Charles Groves (cgroves)
Date: 2007-07-07 18:14
Message:
Logged In: YES
user_id=1174327
Originator: NO
Since this is just jythonc, I moved it to the jythonc group. I'm planning
on closing all of those out once we finish up a replacement for jythonc.
----------------------------------------------------------------------
Comment By: Utkarsh Upadhyay (musically_ut)
Date: 2007-07-01 02:30
Message:
Logged In: YES
user_id=1749279
Originator: NO
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
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=112867&aid=1674537&group_id=12867
|