Does jython depend on java class.

Discussion in 'Python' started by angel, Jul 29, 2004.

  1. angel

    angel Guest

    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
     
    angel, Jul 29, 2004
    #1
    1. Advertising

  2. angel

    Alan Kennedy Guest

    [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
     
    Alan Kennedy, Jul 29, 2004
    #2
    1. Advertising

  3. angel

    angel Guest

    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" <>
    ??????:KM7Oc.5748$...
    > [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
     
    angel, Jul 30, 2004
    #3
  4. angel

    Alan Kennedy Guest

    [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
     
    Alan Kennedy, Jul 30, 2004
    #4
  5. angel

    Ype Kingma Guest

    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" <>
    > ??????:KM7Oc.5748$...
    >> [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
     
    Ype Kingma, Jul 30, 2004
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. David McNab
    Replies:
    0
    Views:
    509
    David McNab
    Apr 9, 2004
  2. Divya Prakash
    Replies:
    0
    Views:
    450
    Divya Prakash
    Dec 19, 2006
  3. Sunil

    On what does size of data types depend?

    Sunil, Oct 5, 2005, in forum: C Programming
    Replies:
    35
    Views:
    1,426
    Anonymous 7843
    Oct 12, 2005
  4. Philipp
    Replies:
    1
    Views:
    335
    Victor Bazarov
    Aug 2, 2006
  5. Jay Levitt
    Replies:
    3
    Views:
    89
    Eric Hodel
    Feb 19, 2006
Loading...

Share This Page