Does jython depend on java class.

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.

Thanx
 
A

Alan Kennedy

[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,
 
A

angel

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 said:
[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,
 
A

Alan Kennedy

[angel]
[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,
 
Y

Ype Kingma

angel said:
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 said:
[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,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top