Releases: jpype-project/jpype
JPype 1.0.1
This is a single issue patch release for compatibility with Python 3.8.4.
- Workarounds for Python 3.8.4 release. Python altered logic regarding the use of
__setattr__
for object and type, preventing it from being used to alter derived classes. Also the checking for errors was delegated from the__setattr__
method so exception types on some sanity checks needed to be updated accordingly.
JPype 1.0.0
-
JChar
is supported as a return type, thus rather than returning a string where aJChar
is expected. For compatibilityJChar
is
derived fromstr
and implements implicit conversion to anint
when used in numeric operations. Therefore, it passes the return, argument, and field contracts. But that means it is no longer considered a numerical type to Python and thusisinstance(c, int)
is False. This is consistent with the Java type conversion rules. -
Introduced Python operator for Java casting. In Java to cast to a type you would use
(Type) obj
, but Python does not support anything similar. Therefore, we are enlisting the rarely usedmatmul
operator as to allow an easy way to cast an object to a Java type. When a cast to a Java type is required, useType@obj
or(Type)@obj
. -
Introduced array notation to create Java arrays. In earlier versions, JArray factory was required to make a new array type. But this is tedious to read. In Java the notation would be
Type[]
to declare a type ornew Type[sz]
to make a new array. Python does not directly support this notation, but it does allow for unspecified array sizes using a slice. All Java class types supportType[sz]
to create an array of a fixed size andType[:]
to create an array type which can be instantiated later. This call be applied to multiple dimensions to create fixed sized arraysType[s1][s2][s3]
to declare multi-dimension array typesType[:][:][:]
or to create a new multi dimensional array with unspecified dimensionsType[sz][:][:]
. Applying a slice with limits to a class is unsupported. -
Java classes annotated with
@FunctionalInterface
can be converted from any Python object that implements__call__
. This allows functions, lambdas, and class constructors to be used whereever Java accepts a lambda. -
Deprecated class and functions were removed.
JIterator
, use ofJException
as a factory,get_default_jvm_path
,jpype.reflect
module. -
Default for starting JVM is now to return Java strings rather than convert.
-
Python deprecated
__int__
so implicit conversions between float and integer types will produce aTypeError
. -
Use of
JException
is discouraged. To catch all exceptions or test if an object is a Java exception type, usejava.lang.Throwable
. -
Chained Java exception causes are now reflected in the Python stackframes.
-
Use of
JString
is discouraged. To create a Java string or test if an object is a Java string type, usejava.lang.String
. -
Updated the repr methods on Java classes.
-
java.util.List
completes the contract forcollections.abc.Sequence
andcollections.abc.MutableSequence
. -
java.util.Collection
completes the contract forcollections.abc.Collection
. -
Java classes are closed and will raise
TypeError
if extended in Python. -
Handles Control-C gracefully. Previous versions crash whenever Java handles the Control-C signal as they would shutdown Java during a call. Now JPype will produce a
InterruptedException
when returning from Java. Control-C will not break out of large Java procedures as currently implemented as Java does not have a specific provision for this.
JPype 0.7.5
This release is to fix an issue in which the development release was accidentally published as the source release on PyPi. v0.7.4 built from source from PyPi and on the Anaconda distributions should be replaced with this version. Changes in this release include
- Updated documentation
- A revised release and testing process which should prevent similar issues in the future
JPype 0.7.4
This is a quick fix release to deal with a memory leak in array handling which allowed arrays to escape garbage collection when created from Python or as part of variable argument methods.
-
Corrected a resource leak in arrays that affects array initialization, and variable
argument methods. -
Upgraded diagnostic tracing and JNI checks to prevent future resource leaks.
JPype 0.7.3
This is a maintenance release correcting a number of issues from NumPy removal. Yet another stepping stone on the way to 1.0.
-
Replaced type management system, memory management for internal
classes is now completely in Java to allow enhancements for
buffer support and revised type conversion system. -
Python module
jpype.reflect
will be removed in the next release. -
jpype.startJVM
optionconvertStrings
default will become False
in the next release. -
Undocumented feature of using a Python type in
JObject(obj, type=tp)
is deprecated to support casting to Python wrapper types in Java in a
future release. -
Dropped support for Cygwin platform.
-
JFloat
properly follows Java rules for conversion fromJDouble
.
Floats outside of range map to inf and -inf. -
java.lang.Number
converts automatically from Python and Java numbers.
Java primitive types will cast to their proper box type when passed
to methods and fields taking Number. -
java.lang.Object
andjava.lang.Number
box signed, sized numpy types
(int8, int16, int32, int64, float32, float64) to the Java boxed type
with the same size automatically. Architecture dependent numpy
types map to Long or Double like other Python types. -
Explicit casting using primitives such as JInt will not produce an
OverflowError
. Implicit casting from Python types such as int or float
will. -
Returns for number type primitives will retain their return type
information. These are derived from Pythonint
andfloat
types
thus no change in behavior unless chaining from a Java methods
which is not allowed in Java without a cast.
JBoolean
andJChar
still produce Python types only. -
Add support for direct conversion of multi-dimensional primitive arrays
withJArray.of(array, [dtype=type])
-
java.nio.Buffer
derived objects can convert to memoryview if they
are direct. They can be converted to NumPy arrays with
numpy.asarray(memoryview(obj))
. -
Proxies created with
@JImplements
properly implementtoString
,
hashCode
, andequals
. -
Proxies pass Python exceptions properly rather converting to
java.lang.RuntimeException
-
JProxy.unwrap()
will return the original instance object for proxies
created with JProxy. Otherwise will return the proxy. -
JProxy instances created with the
convert=True
argument will automatic
unwrap when passed from Java to Python. -
JProxy only creates one copy of the invocation handler per
garbage collection rather than once per use. Thus proxy objects
placed in memory containers will have the same object id so long
as Java holds on to it. -
@JImplements
with keyword argumentdeferred
can be started
prior to starting the JVM. Methods are checked at first object
creation. -
Fix bug that was causing
java.lang.Comparable
,byte[]
,
andchar[]
to be unhashable. -
Fix bug causing segfault when throwing Exceptions which lack a
default constructor. -
Fixed segfault when methods called by proxy have incorrect number of
arguments. -
Fixed stack overflow crash on iterating ImmutableList
-
java.util.Map
conforms to Pythoncollections.abc.Mapping
API. -
java.lang.ArrayIndexOutOfBoundsException
can be caught with
IndexError
for consistency with Python exception usage. -
java.lang.NullPointerException
can be caught withValueError
for consistency with Python exception usage. -
Replaced type conversion system, type conversions test conversion
once per type improving speed and increasing flexiblity. -
User defined implicit conversions can be created with
@JConversion
decorator on Python function taking Java class and Python object.
Converter function must produce a Java class instance. -
pathlib.Path
can be implicitly converted intojava.lang.File
andjava.lang.Path
. -
datetime.datatime
can implicitly convert tojava.time.Instant
. -
dict
andcollections.abc.Mapping
can convert tojava.util.Map
if all element are convertable to Java. Otherwise,TypeError
is
raised. -
list
andcollections.abc.Sequence
can convert tojava.util.Collection
if all elements are convertable to Java. Otherwise,TypeError
is
raised.
JPype 0.7.2
-
C++ and Java exceptions hold the traceback as a Python exception
cause. It is no longer necessary to call stacktrace() to retrieve
the traceback information. -
Speed for call return path has been improved by a factor of 3.
-
Multidimensional array buffer transfers increase speed transfers
to numpy substantially (orders of magnitude). Multidimension primitive
transfers are read-only copies produced inside the JVM with C contiguous
layout. -
All exposed internals have been replaced with CPython implementations
thus symbols__javaclass__
,__javavalue__
, and__javaproxy__
have been removed. A dedicated Java slot has been added to all CPython
types derived from_jpype
class types. All private tables have been
moved to CPython. Java types must derive from the metaclassJClass
which enforces type slots. Mixins of Python base classes is not
permitted. Objects, Proxies, Exceptions, Numbers, and Arrays
derive directly from internal CPython implementations. -
Internal improvements to tracing and exception handling.
-
Memory leak in convertToDirectBuffer has been corrected.
-
Arrays slices are now a view which support writeback to the original
like numpy array. Array slices are no longer covariant returns of
list or numpy.array depending on the build procedure. -
Array slices support steps for both set and get.
-
Arrays now implement
__reversed__
-
Incorrect mapping of floats between 0 and 1 to False in setting
Java boolean array members is corrected. -
Java arrays now properly assert range checks when setting elements
from sequences. -
Java arrays support memoryview API and no longer required numpy
to transfer buffer contents. -
Numpy is no longer an optional extra. Memory transfer to numpy
is available without compiling for numpy support. -
JInterface is now a meta class. Use isinstance(cls, JInterface)
to test for interfaces. -
Fixed memory leak in Proxy invocation
-
Fixed bug with Proxy not converting when passed as an argument to
Python functions during execution of proxies -
Missing tlds "mil", "net", and "edu" added to default imports.
-
Enhanced error reporting for UnsupportedClassVersion during startup.
-
Corrections for collection methods to improve complience with
Python containers.-
java.util.Map gives KeyError if the item is not found. Values that
arenull
still returnNone
as expected. Useget()
if
empty keys are to be treated asNone
. -
java.util.Collection
__delitem__
was removed as it overloads
oddly betweenremove(Object)
andremove(int)
on Lists.
Use Javaremove()
method to access the original Java behavior,
but a cast is strongly recommended to to handle the overload.
-
-
java.lang.IndexOutOfBoundsException can be caught with IndexError
for complience when accessingjava.util.List
elements.
JPype 0.7.1
-
Updated the keyword safe list for Python 3.
-
Automatic conversion of CharSequence from Python strings.
-
java.lang.AutoCloseable supports Python "with" statement.
-
Hash codes for boxed types work properly in Python 3 and can be
used as dictionary keys again (same as JPype 0.6). Java arrays
have working hash codes, but as they are mutable should not
be used as dictionary keys. java.lang.Character, java.lang.Float,
and java.lang.Double all work as dictionary keys, but due to
differences in the hashing algorithm do not index to the same
location as Python native types and thus may cause issues
when used as dictionary keys. -
Updated getJVMVersion to work with JDK 9+.
-
Added support for pickling of Java objects using optional module
jpype.pickle
-
Fixed incorrect string conversion on exceptions.
str()
was
incorrectly returninggetMessage
rather thantoString
. -
Fixed an issue with JDK 12 regarding calling methods with reflection.
-
Removed limitations having to do with CallerSensitive methods. Methods
affected are listed in :doc:caller-sensitive
. Caller sensitive
methods now receive an internal JPype class as the desut -
Fixed segfault when converting null elements while accessing a slice
from a Java object array. -
PyJPMethod now supports the FunctionType API.
-
Tab completion with Jedi is supported. Jedi is the engine behind
tab completion in many popular editors and shells such as IPython.
Jedi version 0.14.1 is required for tab completion as earlier versions
did not support annotations on compiled classes. Tab completion
with older versions requires use of the IPython greedy method. -
JProxy objects now are returned from Java as the Python objects
that originate from. Older style proxy classes return the
inst or dict. New style return the proxy class instance.
Thus proxy classes can be stored on generic Java containers
and retrieved as Python objects.
JPype 0.7
-
Doc strings are generated for classes and methods.
-
Complete rewrite of the core module code to deal unattached threads,
improved hardening, and member management. Massive number of internal
bugs were identified during the rewrite and corrected.
See the :doc:ChangeLog-0.7
for details of all changes. -
API breakage:
-
Java strings conversion behavior has changed. The previous behavior was
switchable, but only the default convert to Python was working.
Converting to automatically lead to problems in which is was impossible
to work with classes like StringBuilder in Java. To convert a Java
string usestr()
. Therefore, string conversion is currently selected
by a switch at the start of the JVM. The default shall be False
starting in JPype 0.8. New code is encouraged to use the future default
of False. For the transition period the default will be True with a
warning if not policy was selected to encourage developers to pick the
string conversion policy that best applies to their application. -
Java exceptions are now derived from Python exception. The old wrapper
types have been removed. Catch the exception with the actual Java
exception type rather thanJException
. -
Undocumented exceptions issued from within JPype have been mapped to the
corresponding Python exception types such asTypeError
and
ValueError
appropriately. Code catching exceptions from previous
versions should be checked to make sure all exception paths are being
handled. -
Undocumented property import of Java bean pattern get/set accessors was
removed as the default. It is available withimport jpype.beans
, but
its use is discouraged.
-
-
API rework:
- JPype factory methods now act as base classes for dynamic
class trees. - Static fields and methods are now available in object
instances. - Inner classes are now imported with the parent class.
jpype.imports
works with Python 2.7.- Proxies and customizers now use decorators rather than
exposing internal classes. ExistingJProxy
code
still works. - Decorator style proxies use
@JImplements
and@JOverload
to create proxies from regular classes. - Decorator style customizers use
@JImplementionFor
- Module
jpype.types
was introduced containing only
the Java type wrappers. Usefrom jpype.types import *
to
pull in this subset of JPype.
- JPype factory methods now act as base classes for dynamic
-
synchronized
using the Pythonwith
statement now works
for locking of Java objects. -
Previous bug in initialization of arrays from list has been
corrected. -
Added extra verbiage to the to the raised exception when an overloaded
method could not be matched. It now prints a list of all possible method
signatures. -
The following is now DEPRECATED
jpype.reflect.*
- All class information is available with.class_
- Unnecessary
JException
from string now issues a warning.
-
The following is now REMOVED
- Python thread option for
JPypeReferenceQueue
. References are always handled with
with the Java cleanup routine. The undocumentedsetUsePythonThreadForDaemon()
has been removed. - Undocumented switch to change strings from automatic to manual
conversion has been removed. - Artifical base classes
JavaClass
andJavaObject
have been removed. - Undocumented old style customizers have been removed.
- Many internal jpype symbols have been removed from the namespace to
prevent leakage of symbols on imports.
- Python thread option for
-
promoted
--install-option
to a--global-option
as it applies to the build as well
as install. -
Added
--enable-tracing
to setup.py to allow for compiling with tracing
for debugging. -
Ant is required to build jpype from source, use
--ant=
with setup.py
to direct to a specific ant.
Bug fix release
-
Java reference counting has been converted to use JNI
PushLocalFrame/PopLocalFrame. Several resource leaks
were removed. -
java.lang.Class<>.forName() will now return the java.lang.Class.
Work arounds for requiring the class loader are no longer needed.
Customizers now support customization of static members. -
Support of java.lang.Class<>
-
java.lang.Object().getClass() on Java objects returns a java.lang.Class
rather than the Python class -
java.lang.Object().class on Java objects returns the python class
as do all python objects -
java.lang.Object.class_ maps to the java statement 'java.lang.Object.class' and
returns the java.lang.Class<java.lang.object> -
java.lang.Class supports reflection methods
-
private fields and methods can be accessed via reflection
-
annotations are avaiable via reflection
-
Java objects and arrays will not accept setattr unless the
attribute corresponds to a java method or field whith
the exception of private attributes that begin with
underscore. -
Added support for automatic conversion of boxed types.
-
Boxed types automatically convert to python primitives.
-
Boxed types automatically convert to java primitives when resolving functions.
-
Functions taking boxed or primitives still resolve based on closest match.
-
Python integer primitives will implicitly match java float and double as per
Java specification. -
Added support for try with resources for java.lang.Closeable.
Use python "with MyJavaResource() as resource:" statement
to automatically close a resource at the end of a block.
Python 3 Support
v0.6.0 Bump version: 0.5.7 → 0.6.0