Skip to content

JPype 1.0.0

Compare
Choose a tag to compare
@Thrameos Thrameos released this 15 Jul 04:45
  • JChar is supported as a return type, thus rather than returning a string where a JChar is expected. For compatibility JChar is
    derived from str and implements implicit conversion to an int 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 thus isinstance(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 used matmul operator as to allow an easy way to cast an object to a Java type. When a cast to a Java type is required, use Type@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 or new 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 support Type[sz] to create an array of a fixed size and Type[:] to create an array type which can be instantiated later. This call be applied to multiple dimensions to create fixed sized arrays Type[s1][s2][s3] to declare multi-dimension array types Type[:][:][:] or to create a new multi dimensional array with unspecified dimensions Type[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 of JException 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 a TypeError.

  • Use of JException is discouraged. To catch all exceptions or test if an object is a Java exception type, use java.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, use java.lang.String.

  • Updated the repr methods on Java classes.

  • java.util.List completes the contract for collections.abc.Sequence and collections.abc.MutableSequence.

  • java.util.Collection completes the contract for collections.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.