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