imagej / ImageJ

Public domain software for processing and analyzing scientific images
http://imagej.org
Other
513 stars 218 forks source link

ImageJ module question #194

Open imagingbook opened 1 year ago

imagingbook commented 1 year ago

I noticed that the ij Java module does not appear as a named module when InageJ is executed. For example, inside a plugin

IJ.log("IJ module = " + IJ.class.getModule());
IJ.log("IJ module name = " + IJ.class.getModule().getName()); 

gives

IJ module = unnamed module @10571272
IJ module name = null

and also the module is not listed by

for (Module m : ModuleLayer.boot().modules()) {
     IJ.log(m.toString());
}

Unfortunately this is the same for other external modules that are loaded by IJ (including my own). Being no expert on this, the motive behind this question is that I want to use annotations on imported modules for specific settings.

Is this perhaps related to ij.jar being compiled for language level 1.6?

Running IJ 1.53v under Java 17.0.5 (WIn7).

rasband commented 1 year ago

On Jan 8, 2023, at 1:33 PM, Wilhelm Burger @.***> wrote:

I noticed that the ij Java module does not appear as a named module when InageJ is executed. For example, inside a plugin

This problem does not appear to be related to ij.jar being compiled for Java 1.6. I compiled ij.jar for Java 8 (and Java 11) and the problem persisted. The ij.jar file is compiled for Java 1.6 because Fiji does not launch with ij.jar files compiled for Java 8.

-wayne

IJ.log("IJ module = " + IJ.class.getModule()); IJ.log("IJ module name = " + IJ.class.getModule().getName());

gives

IJ module = unnamed module @10571272 IJ module name = null

and also the module is not listed by

for (Module m : ModuleLayer.boot().modules()) { IJ.log(m.toString()); }

Unfortunately this is the same for other external modules that are loaded by IJ (including my own). Being no expert on this, the motive behind this question is that I want to use annotations on imported modules for specific settings.

Is this perhaps related to ij.jar being compiled for language level 1.6?

Running IJ 1.53v under Java 17.0.5 (WIn7).

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you are subscribed to this thread.

imagingbook commented 1 year ago

Interesting ... (that was quick)! Just guessing, but could it be necessary to define a dedicated ModuleLayer for IJ's class loaders to make modules "visible"?

https://stackoverflow.com/questions/72412555/whats-the-relationship-between-a-classloader-and-a-module-as-per-java-9 https://docs.oracle.com/javase/9/docs/api/java/lang/ModuleLayer.html

rasband commented 1 year ago

ModuleLayer requires Java 9 or later, so it is not something ImageJ can use.