File: android.rst

package info (click to toggle)
python-jpype 1.5.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,984 kB
  • sloc: python: 18,767; cpp: 17,931; java: 8,448; xml: 1,305; makefile: 154; sh: 35
file content (95 lines) | stat: -rw-r--r-- 3,357 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
JPype for Android
=================

We ported JPype to the Android system.  There are a number of important
differences between JPype on Android and on a JVM.  The Andoid platform uses
the Dalvik virtual machine(DVM) which supports only a portion of the Java
specification.  As a result some portions of JPype have been removed or
function differently.

Supported Functions
-------------------

The following features operate the same on both the JVM and DVM version.

- Java classes using ``jpype.JClass``
- Access to Java methods and fields
- Java arrays using ``jpype.JArray`` including slicing and direct transfers
- Java primitive types, string type, and boxed types
- Java.nio byte buffer including memory mapped data
- Python collections API for Java collection types
- Class customizers and type conversions
- Support of scientific codes such as numpy
- Implementation of Java interfaces using JProxy


Functional differences
----------------------

When using JPype on Android, the virtual machine is started prior to the start
of Python.  Thus, there is no need to lauch the machine.  Instead to use jpype
only the statement ``import jpype`` is required.  In addtion, the following
functions have been removed...

- ``jpype.startJVM`` is removed as the virtual machine cannot be started more
  than once.

- ``jpype.shutdownJVM`` is removed as DVM cannot to stopped during operation.

- ``jpype.addClassPath`` is removed as DVM does not support class path based
  jar loading.  Dex files can be loaded dynamically using the Android API.

- ``jpype.getDefaultJVMPath`` is removed as there is no JVM on Android. 

- ``jpype.beans`` has been removed as adding addition properties for semantic
  sugar increase the memory profile unnecessarily.

- attach and detaching of threads is not allowed and those entry points have been
  removed.


Removed JPype Services
----------------------

Not all JPype services are provided on Android as some functions depend on the
internals of the JVM.  These include...

- The dynamic class loader does not operate on JPype as DVM does not support
  jar files.

- jpype.imports and jpype.JPackage use the jar file system to identify packages
  which is not available on DVM.  Therefore, all classes must be loaded use
  ``jpype.JClass``.

- jpype support for Javadoc was removed as DVM does not support Javadoc jars in
  the classpath.

- jpype does not install interrupt handlers for ^C on Android.


Unsupported Java libraries
--------------------------

Some Java libraries are not supported on Android.

- Bytecode manipulation libraries to not function on DVM. This means generation
  of dynamic classes, manipulation of loaded classes, and Java agent code will
  not function.

- Some standard Java libraries are not implemented on Android such as AWT.
  Jar libraries that access these unimplemented libraries will not function.

- Private JVM internal classes such as ``sun.*`` are not implemented and cannot be used.


Behavior differences
--------------------

Some changes in JPype behavior occur simply because the DVM operates
differently.  These changes include

- java.lang.Class.forName will not load classes from classes.dex.  Attempting
  to access classes with forName will get ClassNotFoundException.  Applying
  forName to base classes that use the system classloader function as expected.