release layer , allowing full access for Python applications to Java class libraries. With JPype, you can use Java-specific libraries from Python, creating hybrid applications that combine Java and Python code. Unlike Jython, integration with Java is not achieved by creating a Python variant for the JVM but through interaction at the level of both virtual machines using shared memory. The proposed approach allows not only for good performance but also provides access to all CPython and Java libraries. The project code under the Apache 2.0 license.
Key Changes:
- JChar is supported as a return type. For compatibility, JChar is inherited from 'str' and implements implicit conversion to 'int'. Thus, it passes checks in contracts. However, this means it is no longer considered a numeric type in Python, and therefore isinstance(c, int) returns False, which is consistent with Java's type conversion rules.
- An operator has been introduced to cast the Java type Type@obj (@ is the Python operator for inner product, which does not exist in Java).
- A notation for creating Java arrays has been added. Type[s1][s2][s3] for fixed-size arrays, Type[:][:][:] for arrays that will be created later.
- @FunctionalInterface allows creating Java functors from Python objects with __call__.
- Deprecated JIterator, using JException as a factory, get_default_jvm_path, and jpype.reflect.
- By default, there is no conversion of Java strings to Python strings.
- Python has deprecated '__int__', so implicit conversions between integer and floating-point types will raise TypeError.
- Using JException is announced as deprecated. To catch all exceptions or check if an object is of Java exception type, use java.lang.Throwable.
- Cascading causes of Java exceptions are now reflected in Python stack frames.
- Using JString is announced as deprecated. To create a Java string or check if an object is of Java string type, use java.lang.String.
- repr methods in Java classes have been updated.
- java.util.List complies with contracts for collections.abc.Sequence and collections.abc.MutableSequence.
- java.util.Collection complies with the contract for collections.abc.Collection.
- Java classes are closed and will raise TypeError when extended from Python.
- Handling Control-C carefully. Previous versions crashed when Java handled the Control-C signal because they would terminate Java during the call. Now JPype will throw an InterruptedException when returning from Java. Control-C will not interrupt large Java procedures as currently implemented, since Java does not have a special mechanism for this.
A corrective release 1.0.1 has been formed, which includes changes to work around issues with the Python 3.8.4 release. Python changed the logic regarding the use of '__setattr__' for 'object' and 'type', preventing its use for modifying derived classes. Additionally, error checking has been delegated from the '__setattr__' method, so exception types in some validity checks need to be updated accordingly.
Source: opennet.ru
