-
JCharis supported as a return type, thus rather than returning a string where aJCharis expected. For compatibilityJCharis
derived fromstrand implements implicit conversion to anintwhen 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 usedmatmuloperator as to allow an easy way to cast an object to a Java type. When a cast to a Java type is required, useType@objor(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
@FunctionalInterfacecan 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 ofJExceptionas a factory,get_default_jvm_path,jpype.reflectmodule. -
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
JExceptionis 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
JStringis 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.Listcompletes the contract forcollections.abc.Sequenceandcollections.abc.MutableSequence. -
java.util.Collectioncompletes the contract forcollections.abc.Collection. -
Java classes are closed and will raise
TypeErrorif 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
InterruptedExceptionwhen 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.