imagej / pyimagej

Use ImageJ from Python
https://pyimagej.readthedocs.io/
Other
474 stars 83 forks source link

WARNING: An illegal reflective access operation has occurred #219

Closed jaredbrewer closed 2 years ago

jaredbrewer commented 2 years ago

import imagej

ij = imagej.init(mode='gui')

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by net.imagej.legacy.IJ1Helper (file:/Users/jared/.jgo/net.imagej/imagej/RELEASE/bf9da2ebe6c78d8bd105a97ce32adcfe853ce5e97dd621b9e35936d1c6abf90c/imagej-legacy-0.38.1.jar) to method com.apple.eawt.Application.getApplication()
WARNING: Please consider reporting this to the maintainers of net.imagej.legacy.IJ1Helper
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
/opt/homebrew/Caskroom/mambaforge/base/lib/python3.10/multiprocessing/resource_tracker.py:224: UserWarning: resource_tracker: There appear to be 1 leaked semaphore objects to clean up at shutdown
  warnings.warn('resource_tracker: There appear to be %d '
elevans commented 2 years ago

Hi @jaredbrewer

Can you provide more information on this issue? What version of MacOS and Java are you using? If you have access to other Macs, can you reproduce this error?

ctrueden commented 2 years ago

The warnings about illegal reflective access come from Java 11. They can be safely ignored. If you use Java 8, you will not see such warnings.

@elevans We might want to add this as a section to Common Errors in the docs.

jaredbrewer commented 2 years ago

Yes, I am using Java 11 on macOS 12.6. Is there an expectation that whatever is prompting the underlying error will be resolved in the future or is it entirely safe for the long-term?

ctrueden commented 2 years ago

@jaredbrewer It is entirely safe while using Java 11, for sure. We are still exploring updates to ImageJ2+Fiji et al. to support Java 17, 18, and beyond. At some point, Java may remove support for this sort of reflection access, but they have not yet done so. It is difficult because most dependency injection frameworks, including SciJava Common, rely on reflection to connect components and plugins together. We have a new version of SciJava in development that does dependency injection entirely without reflection, using the Jigsaw/JPMS system introduced in Java 9, which should help eliminate these errors as the software continues to evolve.

ctrueden commented 2 years ago

I worked around this issue with 135bbf971bfa2f017c00ea624e8be38849f0c620, so these messages no longer appear.