|
| <prev next> |
ZipException - duplicate class workaround, another jythonc problem: msg#00000lang.jython.user
In attempting to follow an article on using Jython with Ant (http://www.pycs.net/users/0000177/stories/11.html), I ran in to an issue I had seen mentioned twice before this year on this mailing list. That issue had to do with running jythonc and running into a ZipException that complained about a duplicate class entry. The questions about the issue didn't appear to elicit any response. I investigated the problem and came up with a work-around to address the immediate problem, however, I'm sure I didn't uncover the root cause of the issue. I was able to reproduce the problem and dug around to figure out what was happening. The problem strike point is in jython/Tools/jythonc/jar.py in the JarArchive.dumpFiles method where it loops through a sequence of packages and adds each package via the JarArchive.addPackage method call. In that method, a for loop using the result of a call to util.listAllClasses is attempted; within the loop, the call to self.zipfile.putNextEntry is where the exception occurs. I was able to put in a workaround in the addPackage method that uses a 'done' dictionary to record what has already been added to the zip file and checks for the target entry before attempting the add. I thought that was kind of a hacky solution and chased the problem upstream one step to the util.listAllClasses function. In that function, a call is made to get classes using sys.packageManager.doDir() and from _ypm.doDir() but no duplicate detection is done. My workaround is to add the duplicate detection in this function. Perhaps the problem should be chased upstream further but I did not do so as the trail became more obscure for me to track. The workaround code (inserted just before the classes.extend(classes2) statement in util.listAllClasses): # # Identify and eliminate duplication of class names # dups = [className for className in classes2 if className in classes] for className in dups: classes2.remove(className) Anyway, that workaround "fixes" the problem with the ZipException when using jythonc. Even so, I'm still not able to execute the jython ant task (from the article). An exception stating that there is no public execute method is emitted. And indeed, in the jythonc generated Java code (SimpleTask.java) for the Jython script SimpleTask.py, there is no such beast. The Java method signature spec using the "@sig ..." notation is present in the docstring for the execute method so I don't know why the generated Java code doesn't have "public static PyObject execute(...)". The closest method to that is "private static PyObject execute$1(PyFrame frame)" which is followed by the Java comment /* @sig public void execute() */ that presumably came from the docstring in SimpleTask.py for the execute method. I'm using J2SDK 1.4.2_07 on a Windows98 box. I tried this using Jython 2.1 and the latest from CVS. Anybody have insight into what the problem is (and the solution)? -- Kip Lehman kipster <dash> t <at> earthlink <dot> net ------------------------------------------------------- This SF.Net email is sponsored by: NEC IT Guy Games. Get your fingers limbered up and give it your best shot. 4 great events, 4 opportunities to win big! Highest score wins.NEC IT Guy Games. Play to win an NEC 61 plasma display. Visit http://www.necitguy.com/?r=20
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Next by Date: | Red Robin JyDT for Eclipse: vote for functionality, Red Robin |
|---|---|
| Next by Thread: | Red Robin JyDT for Eclipse: vote for functionality, Red Robin |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |