paul@135 | 1 | <?xml version="1.0" encoding="iso-8859-1"?> |
paul@135 | 2 | <html xmlns="http://www.w3.org/1999/xhtml"> |
paul@135 | 3 | <head> |
paul@135 | 4 | <title>ClassFile</title> |
paul@135 | 5 | <meta name="generator" content="amaya 8.1a, see http://www.w3.org/Amaya/" /> |
paul@135 | 6 | <link xmlns:xlink="http://www.w3.org/1999/xlink" href="styles.css" |
paul@135 | 7 | rel="stylesheet" type="text/css" /> |
paul@135 | 8 | </head> |
paul@135 | 9 | |
paul@135 | 10 | <body> |
paul@135 | 11 | <h1>ClassFile</h1> |
paul@135 | 12 | |
paul@135 | 13 | <p>The ClassFile collection of packages and utilities provides a means of |
paul@135 | 14 | importing Java classes and packages directly into Python, without the need |
paul@135 | 15 | for a Java virtual machine, so that the classes may be instantiated, |
paul@135 | 16 | accessed, run and manipulated just like Python classes, and that the |
paul@135 | 17 | resulting objects and methods can be accessed and manipulated just like |
paul@135 | 18 | Python objects and methods.</p> |
paul@135 | 19 | |
paul@135 | 20 | <h2>Quick Example</h2> |
paul@135 | 21 | |
paul@135 | 22 | <p class="prompt">cd tests/</p> |
paul@135 | 23 | |
paul@135 | 24 | <p class="prompt">javac Value.java</p> |
paul@135 | 25 | |
paul@135 | 26 | <p class="prompt">../runclass.py Value</p> |
paul@135 | 27 | |
paul@135 | 28 | <p class="result">v.getValue() correct: 123<br /> |
paul@135 | 29 | v.getValue() correct: 456<br /> |
paul@135 | 30 | v.isPositive() correct: 1<br /> |
paul@135 | 31 | v.isPositive() correct: 0<br /> |
paul@135 | 32 | v.compare(-790) correct: -1<br /> |
paul@135 | 33 | v.compare(-788) correct: 1<br /> |
paul@135 | 34 | v.compare(-789) correct: 0<br /> |
paul@135 | 35 | v.getValue() == v2.getValue() correct: 0<br /> |
paul@135 | 36 | v2.add(-123) correct: 0<br /> |
paul@135 | 37 | v2.getValue() correct: 255</p> |
paul@135 | 38 | |
paul@135 | 39 | <p class="prompt">java Value</p> |
paul@135 | 40 | |
paul@135 | 41 | <p class="result">v.getValue() correct: 123<br /> |
paul@135 | 42 | v.getValue() correct: 456<br /> |
paul@135 | 43 | v.isPositive() correct: true<br /> |
paul@135 | 44 | v.isPositive() correct: false<br /> |
paul@135 | 45 | v.compare(-790) correct: -1<br /> |
paul@135 | 46 | v.compare(-788) correct: 1<br /> |
paul@135 | 47 | v.compare(-789) correct: 0<br /> |
paul@135 | 48 | v.getValue() == v2.getValue() correct: false<br /> |
paul@135 | 49 | v2.add(-123) correct: 0<br /> |
paul@135 | 50 | v2.getValue() correct: 255</p> |
paul@135 | 51 | |
paul@135 | 52 | <h2>Motivation</h2> |
paul@135 | 53 | |
paul@135 | 54 | <p>Pick one of the following:</p> |
paul@135 | 55 | <ul> |
paul@135 | 56 | <li>The need/desire to access Java libraries from Python without firing up |
paul@135 | 57 | Java virtual machines or switching to Jython (and thereby losing access |
paul@135 | 58 | to various CPython libraries).</li> |
paul@135 | 59 | <li>Static typing for the Python environment, albeit achieved by writing |
paul@135 | 60 | Java or other appropriate languages.</li> |
paul@135 | 61 | <li>Having an open source environment from top to bottom to run Java |
paul@135 | 62 | bytecode on.</li> |
paul@135 | 63 | <li>Experimentation around import hooks, bytecode generation; observation |
paul@135 | 64 | of different runtime and type systems interacting.</li> |
paul@135 | 65 | </ul> |
paul@135 | 66 | </body> |
paul@135 | 67 | </html> |