You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
On newer JDK versions, the options --add-exports and --add-opens are sometimes needed to break the encapsulation. See https://openjdk.org/jeps/261
This works with the java command:
$ java --add-exports java.base/jdk.internal.misc=ALL-UNNAMED --add-opens java.base/java.lang.module=ALL-UNNAMED -version
openjdk version "11.0.22" 2024-01-16
OpenJDK Runtime Environment (build 11.0.22+7-post-Debian-1deb11u1)
OpenJDK 64-Bit Server VM (build 11.0.22+7-post-Debian-1deb11u1, mixed mode, sharing)
However, this doesn't work with pyjnius:
$ cat test.py
import jnius_config
jnius_config.add_options(
'--add-exports', 'java.base/jdk.internal.misc=ALL-UNNAMED',
'--add-opens', 'java.base/java.lang.module=ALL-UNNAMED',
)
import jnius
$ python test.py
Unrecognized option: --add-exports
Traceback (most recent call last):
File "/path/to/test.py", line 6, in <module>
import jnius
File "/path/to/ve/lib/python3.9/site-packages/jnius/__init__.py", line 45, in <module>
from .reflect import * # noqa
File "/path/to/ve/lib/python3.9/site-packages/jnius/reflect.py", line 19, in <module>
class Class(JavaClass, metaclass=MetaJavaClass):
File "jnius/jnius_export_class.pxi", line 117, in jnius.MetaJavaClass.__new__
File "jnius/jnius_export_class.pxi", line 177, in jnius.MetaJavaClass.resolve_class
File "jnius/jnius_env.pxi", line 11, in jnius.get_jnienv
File "jnius/jnius_jvm_dlopen.pxi", line 95, in jnius.get_platform_jnienv
File "jnius/jnius_jvm_dlopen.pxi", line 87, in jnius.create_jnienv
SystemError: JVM failed to start: -1
This was tested with pyjnius 1.6.1 on Python 3.9.2 with openjdk-11-jdk 11.0.22u7 on Debian 11.
The text was updated successfully, but these errors were encountered:
The module related options, --add-reads, --add-exports, --add-opens, --add-modules, --limit-modules, --module-path, --patch-module, and --upgrade-module-path must be passed as option strings using their “option=value” format instead of their “option value” format. (Note the required = between “option” and “value”.) For example, to export java.management/sun.management to ALL-UNNAMED pass option string "--add-exports=java.management/sun.management=ALL-UNNAMED".
I believe this should be documented here, and the add_options() method should warn the user about it if the options contains any of the --add-reads, --add-exports, --add-opens, --add-modules, --limit-modules, --module-path, --patch-module, and --upgrade-module-path in the unsupported format.
On newer JDK versions, the options
--add-exports
and--add-opens
are sometimes needed to break the encapsulation. See https://openjdk.org/jeps/261This works with the
java
command:However, this doesn't work with pyjnius:
This was tested with pyjnius 1.6.1 on Python 3.9.2 with openjdk-11-jdk 11.0.22u7 on Debian 11.
The text was updated successfully, but these errors were encountered: