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.