By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,558 Members | 1,163 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,558 IT Pros & Developers. It's quick & easy.

Does jython depend on java class.

P: n/a
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.

Thanx
Jul 18 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
[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.


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.

Jython also includes its own specialised classloader, due to the
highly dynamic nature of jython class construction, which can cause
problems in certain security-conscious environments. This classloader
can be bypassed by compiling jython classes to java with jythonc. But
even with jythonc-generated java classes the dependency on jython.jar
remains, because of the need for access to the definitions of
org.python.core.PyDictionary, etc.

HTH,

--
alan kennedy
------------------------------------------------------
check http headers here: http://xhaus.com/headers
email alan: http://xhaus.com/contact/alan
Jul 18 '05 #2

P: n/a
Thank you for your reply.

But 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?

Thanx

"Alan Kennedy" <al****@hotmail.com>
??????:KM*****************@news.indigo.ie...
[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.


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.

Jython also includes its own specialised classloader, due to the
highly dynamic nature of jython class construction, which can cause
problems in certain security-conscious environments. This classloader
can be bypassed by compiling jython classes to java with jythonc. But
even with jythonc-generated java classes the dependency on jython.jar
remains, because of the need for access to the definitions of
org.python.core.PyDictionary, etc.

HTH,

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

Jul 18 '05 #3

P: n/a
[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
Jul 18 '05 #4

P: n/a
angel wrote:
Thank you for your reply.

But 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 dynamically compiles Python modules to java classes, and
Jython's Python interpreter is written in Java. The classes
of the compiled modules closely cooperate with this interpreter,
much like CPython.

The implementation of the Jython interpreter relies on the Java standard
library (java.lang.*, java.util.*) as any other Java program.

OTOH, Jython also provides any Java package on the class path
as a Python package, and one can eg. implement a Java interface by
subclassing in Python.

Kind regards,
Ype


Thanx

"Alan Kennedy" <al****@hotmail.com>
??????:KM*****************@news.indigo.ie...
[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.


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.

Jython also includes its own specialised classloader, due to the
highly dynamic nature of jython class construction, which can cause
problems in certain security-conscious environments. This classloader
can be bypassed by compiling jython classes to java with jythonc. But
even with jythonc-generated java classes the dependency on jython.jar
remains, because of the need for access to the definitions of
org.python.core.PyDictionary, etc.

HTH,

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


--
email at xs4all.nl
Jul 18 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.