Error for File type ImageJ2 Parameter

imagej
#1

File Parameter’s seem to be broken. I’m not sure which repo is causing this. To reproduce, run the following Python script

# @File test_file

print( test_file )

which throws error

[ERROR] Module threw exception
java.lang.NullPointerException
	at org.scijava.ui.UserInterface.chooseFile(UserInterface.java:165)
	at org.scijava.ui.DefaultUIService.chooseFile(DefaultUIService.java:313)
	at org.scijava.ui.FilePreprocessor.process(FilePreprocessor.java:71)
	at org.scijava.module.ModuleRunner.preProcess(ModuleRunner.java:105)
	at org.scijava.module.ModuleRunner.run(ModuleRunner.java:157)
	at org.scijava.module.ModuleRunner.call(ModuleRunner.java:127)
	at org.scijava.module.ModuleRunner.call(ModuleRunner.java:66)
	at org.scijava.thread.DefaultThreadService$3.call(DefaultThreadService.java:238)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.lang.Thread.run(Thread.java:834)
[ERROR] Module threw exception
java.lang.NullPointerException
	at org.scijava.ui.UserInterface.chooseFile(UserInterface.java:165)
	at org.scijava.ui.DefaultUIService.chooseFile(DefaultUIService.java:313)
	at org.scijava.ui.FilePreprocessor.process(FilePreprocessor.java:71)
	at org.scijava.module.ModuleRunner.preProcess(ModuleRunner.java:105)
	at org.scijava.module.ModuleRunner.run(ModuleRunner.java:157)
	at org.scijava.module.ModuleRunner.call(ModuleRunner.java:127)
	at org.scijava.module.ModuleRunner.call(ModuleRunner.java:66)
	at org.scijava.thread.DefaultThreadService$3.call(DefaultThreadService.java:238)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.lang.Thread.run(Thread.java:834)
2 Likes
#2

Interesting, this seems to be a bug in scijava-common that was exposed only by the latest update of imagej-legacy.

In this commit, the overridden method chooseFile(File, String) was replaced by an override of chooseFile(String, File, String), hence exposing the default method chooseFile(File, String) of org.scijava.ui.UserInterface:

This will throw the reported exception when style is null. @kephale if you have time to file a PR fixing this, that would be great. I’ll try to do it within the next few days otherwise.

As a workaround, you can set style="" in your script parameter:

#@ File (style="") test_file

print( test_file )
1 Like
Issue with unique #@File script parameter in Fiji
#3

@imagejan thank you very much! I am unable to do the PR in the near future.

#4

In the meantime, I filed this PR:

@ctrueden would you mind reviewing and merging? It seems this issue is a show-stopper for a number of people now, including @kephale, @NicoKiaru and @LThomas.

See also:

1 Like
#5

I merged it. Will try to get a new scijava-common released ASAP. There is one other fix I am pursuing first. If it drags on and you don’t see progress for several more days, please feel free to ping me again.

2 Likes