Does jython depend on java class.

Alan Kennedy alanmk at hotmail.com
Fri Jul 30 07:52:21 EDT 2004


[angel]
>>>A java runtime environment includes jvm and java class (for example
>>>classes.zip in sun jre). Of course jython need jvm,but does it need java
>>>class.

[Alan Kennedy]
>>Yes, jython requires specific classes at runtime.
>>
>>For example, the python dictionary type is implemented by the java
>>classes org.python.core.PyStringMap and org.python.core.PyDictionary.
>>The .class files for these classes are stored in jython.jar, which
>>always has to be loadable/in-your-classpath when your java application
>>uses jython.

[angel]
 > I still want to confirm if jython requires standard java class, for
 > example java.lang.* java.util.* ...
 > From the word "the python dictionary type is implemented by the java
 > classes org.python.core.PyStringMap and
 >  org.python.core.PyDictionary" , I guess jython should depend on
 > java.lang.String, java.util.Hashtable ...
 >
 > So jython doesn't only compile python source code to java bytecode,
 > it is implemented by java language. Is it correct?

Yes, jython does require java classes, e.g. java.util.*, java.lang.*, 
etc, at runtime.

Attempting to summarise:-

1. Jython compiles all jython classes to java bytecode.

2. The java bytecode generated is layered upon a jython-specific 
"runtime" which implements jython semantics for data types: i.e. 
org.python.core.*

3. The classes in this jython specific runtime depend on java platform 
classes, i.e. java.util.*, java.io.*, etc.

This can be seen by looking at the source for jython, i.e.

$jython_home/org/python/core/*.java

where you will see the jython "runtime" files containing import 
statements of the form

import java.io.*;
import java.util.*;
import java.lang.ref.*;

For example, the import list for org.python.core.PyList.java is

import java.util.Vector;

which shows that jython lists are built on java.util.Vector objects, 
the definition of which obviously must be available when jython 
programs use lists. This is true both when the code is compiled 
dynamically by jython, and when it is compiled statically by jythonc.

HTH,

-- 
alan kennedy
------------------------------------------------------
check http headers here: http://xhaus.com/headers
email alan:              http://xhaus.com/contact/alan



More information about the Python-list mailing list