|
From: Jeff T. <je...@so...> - 2001-03-25 05:25:42
|
Hi,
I've just installed jython-2.1a1, and found something a bit odd. When I
try to compile ('jythonc') Demo/javaclass/Graph.py, the compiler
complains that it can't find classes in jython.jar[1]. However, jython.jar is
in the classpath:
Compiling with args: ['/usr/local/java/jdk1.2.2/bin/javac', '-classpath', '"/home/jeff/jython-2.1a1/jython.jar::./jpywork::/home/jeff/jython-2.1a1/Tools/jythonc:/home/jeff/jython-2.1a1/Demo/javaclasses/.:/home/jeff/jython-2.1a1/Lib"', './jpywork/pygraph/Graph.java']
And when I enter the command manually:
/usr/local/java/jdk1.2.2/bin/javac -classpath "/home/jeff/jython-2.1a1/jython.jar::./jpywork::/home/jeff/jython-2.1a1/Tools/jythonc:/home/jeff/jython-2.1a1/Demo/javaclasses/.:/home/jeff/jython-2.1a1/Lib" ./jpywork/pygraph/Graph.java
Everything works fine.
After a bit of digging, I found the problem: jython is wrapping the
classpath in quotes. This is corrupting the first and last classpath
entries.
This problem is only obvious if you do not have your CLASSPATH set. For
most people, this bug would manifest itself as seemingly random
classpath issues, as jars sometimes are not picked up.
So why don't you need quotes? Well I thought the quotes were only to
protect the string from the shell. Therefore if you're using
runtime.exec(), you don't need to quote arguments.
However I'm quite likely wrong ;) So perhaps someone on a windows
computer should verify that my patch doesn't break things.
I can post a self-contained test case if needed, but a basic
demonstration is:
export CLASSPATH=
cd $JYTHON_HOME/Demo/javaclasses
jythonc --package pygraph Graph.py
Thanks,
--Jeff
--------- Patch -----------
Index: Tools/jythonc/javac.py
===================================================================
RCS file: /cvsroot/jython/jython/Tools/jythonc/javac.py,v
retrieving revision 2.12
diff -u -r2.12 javac.py
--- Tools/jythonc/javac.py 2001/02/07 16:52:42 2.12
+++ Tools/jythonc/javac.py 2001/03/25 05:09:40
@@ -76,7 +76,7 @@
if sourcedir:
cpath.append(sourcedir)
cpath.extend(sys.path)
- cpath = '"%s"' % sep.join(cpath)
+ cpath = '%s' % sep.join(cpath)
cmd.extend([cpathopt, cpath])
cmd.extend(files)
print 'Compiling with args:', cmd
---------------------------
[1] Full listing:
~/jython-2.1a1/Demo/javaclasses$ ../../jythonc --package pygraph Graph.py
*sys-package-mgr*: processing new jar, '/home/jeff/jython-2.1a1/jython.jar'
*sys-package-mgr*: processing new jar, '/usr/local/java/jdk1.2.2/jre/lib/rt.jar'
*sys-package-mgr*: processing new jar, '/usr/local/java/jdk1.2.2/jre/lib/i18n.jar'
*sys-package-mgr*: processing new jar, '/usr/local/java/jdk1.2.2/jre/lib/ext/iiimp.jar'
processing Graph
Required packages:
java.awt
Creating adapters:
java.awt.event.ActionListener used in Graph
Creating .java files:
Graph module
Graph extends java.awt.Canvas
Compiling .java to .class...
Compiling with args: ['/usr/local/java/jdk1.2.2/bin/javac', '-classpath', '"/home/jeff/jython-2.1a1/jython.jar::./jpywork::/home/jeff/jython-2.1a1/Tools/jythonc:/home/jeff/jython-2.1a1/Demo/javaclasses/.:/home/jeff/jython-2.1a1/Lib"', './jpywork/pygraph/Graph.java']
1 ./jpywork/pygraph/Graph.java:3: Package org.python.core not found in import.
import org.python.core.*;
^
./jpywork/pygraph/Graph.java:5: Interface org.python.core.PyProxy of class pygraph.Graph not found.
public class Graph extends java.awt.Canvas implements org.python.core.PyProxy {
^
./jpywork/pygraph/Graph.java:9: Superclass pygraph.PyFunctionTable of nested class pygraph.Graph. _PyInner not found.
public static class _PyInner extends PyFunctionTable implements PyRunnable {
^
./jpywork/pygraph/Graph.java:9: Interface pygraph.PyRunnable of nested class pygraph.Graph. _PyInner not found.
public static class _PyInner extends PyFunctionTable implements PyRunnable {
^
4 errors
ERROR DURING JAVA COMPILATION... EXITING
nescafe:~/jython-2.1a1/Demo/javaclasses$
/usr/local/java/jdk1.2.2/bin/javac -classpath
"/home/jeff/jython-2.1a1/jython.jar::./jpywork::/home/jeff/jython-2.1a1/Tools/jythonc:/home/jeff/jython-2.1a1/Demo/javaclasses/.:/home/jeff/jython-2.1a1/Lib"
./jpywork/pygraph/Graph.java
Note: ./jpywork/pygraph/Graph.java uses or overrides a deprecated API.
Recompile with "-deprecation" for details.
1 warning
nescafe:~/jython-2.1a1/Demo/javaclasses$
|