Skip to content

Commit 36d8839

Browse files
committed
Avoid startup warning on non-Linux platforms
The --add-opens flag for sun.awt.X11 only works on Linux; otherwise, a warning is issued: WARNING: package sun.awt.X11 not in java.desktop Similarly, com.apple.eawt reflection should be tolerated on macOS, but not requested on non-macOS platforms.
1 parent 3404aaa commit 36d8839

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/imagej/__init__.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1365,7 +1365,11 @@ def _create_jvm(
13651365
# Disable illegal reflection access warnings.
13661366
sj.config.add_option("--add-opens=java.base/java.lang=ALL-UNNAMED")
13671367
sj.config.add_option("--add-opens=java.base/java.util=ALL-UNNAMED")
1368-
sj.config.add_option("--add-opens=java.desktop/sun.awt.X11=ALL-UNNAMED")
1368+
if sys.platform == "linux":
1369+
sj.config.add_option("--add-opens=java.desktop/sun.awt.X11=ALL-UNNAMED")
1370+
elif sys.platform == "darwin":
1371+
sj.config.add_option("--add-opens=java.desktop/com.apple.eawt=ALL-UNNAMED")
1372+
13691373
except RuntimeError as e:
13701374
_logger.warning("Failed to guess the Java version.")
13711375
_logger.debug(e, exc_info=True)

0 commit comments

Comments
 (0)