Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move logging configuration to beginning of call() method #233

Merged
merged 2 commits into from
Jan 15, 2024

Conversation

melissalinkert
Copy link
Member

This ensures that the correct log level is set before OpenCV is loaded.

Compare using --log-level ERROR with and without this PR.

@melissalinkert
Copy link
Member Author

75cc25a adds one more potential fix to address the illegal access warning logged to stderr, as noted by @erindiel :

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.esotericsoftware.reflectasm.AccessClassLoader (file:/home/melissa/bioformats2raw/build/distributions/bioformats2raw-0.9.0-SNAPSHOT/lib/reflectasm-1.11.9.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain)
WARNING: Please consider reporting this to the maintainers of com.esotericsoftware.reflectasm.AccessClassLoader
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

The full stack trace, which results from setting JAVA_OPTS="--illegal-access=debug":

WARNING: Illegal reflective access by com.esotericsoftware.reflectasm.AccessClassLoader (file:/home/melissa/bioformats2raw/build/distributions/bioformats2raw-0.9.0-SNAPSHOT/lib/reflectasm-1.11.9.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain)
	at com.esotericsoftware.reflectasm.AccessClassLoader.getDefineClassMethod(AccessClassLoader.java:111)
	at com.esotericsoftware.reflectasm.AccessClassLoader.defineClass(AccessClassLoader.java:73)
	at com.esotericsoftware.reflectasm.AccessClassLoader.defineAccessClass(AccessClassLoader.java:57)
	at com.esotericsoftware.reflectasm.ConstructorAccess.get(ConstructorAccess.java:99)
	at com.esotericsoftware.kryo.util.DefaultInstantiatorStrategy.newInstantiatorOf(DefaultInstantiatorStrategy.java:59)
	at com.esotericsoftware.kryo.Kryo.newInstantiator(Kryo.java:1190)
	at com.esotericsoftware.kryo.Kryo.newInstance(Kryo.java:1199)
	at com.esotericsoftware.kryo.serializers.FieldSerializer.create(FieldSerializer.java:163)
	at com.esotericsoftware.kryo.serializers.FieldSerializer.read(FieldSerializer.java:122)
	at com.esotericsoftware.kryo.Kryo.readObject(Kryo.java:774)
	at loci.formats.Memoizer$KryoDeser.loadReader(Memoizer.java:169)
	at loci.formats.Memoizer.loadMemo(Memoizer.java:924)
	at loci.formats.Memoizer.setId(Memoizer.java:702)
	at loci.formats.ReaderWrapper.setId(ReaderWrapper.java:692)
	at loci.formats.ChannelSeparator.setId(ChannelSeparator.java:317)
	at com.glencoesoftware.bioformats2raw.Converter.convert(Converter.java:1241)
	at com.glencoesoftware.bioformats2raw.Converter.call(Converter.java:1176)
	at com.glencoesoftware.bioformats2raw.Converter.call(Converter.java:104)
	at picocli.CommandLine.executeUserObject(CommandLine.java:2041)
	at picocli.CommandLine.access$1500(CommandLine.java:148)
	at picocli.CommandLine$RunLast.executeUserObjectOfLastSubcommandWithSameParent(CommandLine.java:2461)
	at picocli.CommandLine$RunLast.handle(CommandLine.java:2453)
	at picocli.CommandLine$RunLast.handle(CommandLine.java:2415)
	at picocli.CommandLine$AbstractParseResultHandler.handleParseResult(CommandLine.java:2264)
	at picocli.CommandLine.parseWithHandlers(CommandLine.java:2664)
	at picocli.CommandLine.parseWithHandler(CommandLine.java:2599)
	at picocli.CommandLine.call(CommandLine.java:2875)
	at com.glencoesoftware.bioformats2raw.Converter.main(Converter.java:2946)

This warning only shows up when a memo file is loaded, so either the memo file must exist prior to conversion or multiple workers need to be used in order to see the warning.

EsotericSoftware/reflectasm#64 and EsotericSoftware/kryo#692 are relevant upstream issues.

From what I can tell (based on this documentation in particular), --add-opens java.base/java.lang=ALL-UNNAMED (as used in 75cc25a) is the next best option if the problematic library cannot be updated. Definitely happy to hear better ideas though.

Copy link
Member

@erindiel erindiel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With this PR, OpenCV warnings are no longer logged when using --log-level ERROR and illegal access warnings are removed regardless of log level. 👍🏻

@chris-allan chris-allan merged commit 58f6e40 into glencoesoftware:master Jan 15, 2024
4 checks passed
@sbesson
Copy link
Member

sbesson commented Jan 22, 2024

Unfortunately, 75cc25a seems to have caused regression on JDK 8 runtime environments when using the 0.9.0 distribution bundle - see #237

Reproduced locally

sbesson@Sebastiens-MacBook-Pro-3 Downloads % jenv local 1.8   
sbesson@Sebastiens-MacBook-Pro-3 Downloads % ./bioformats2raw-0.9.0/bin/bioformats2raw test.fake test.zarr
Unrecognized option: --add-opens
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
sbesson@Sebastiens-MacBook-Pro-3 Downloads % jenv local 11.0
sbesson@Sebastiens-MacBook-Pro-3 Downloads % ./bioformats2raw-0.9.0/bin/bioformats2raw test.fake test.zarr
sbesson@Sebastiens-MacBook-Pro-3 Downloads % rm -rf test.zarr 
sbesson@Sebastiens-MacBook-Pro-3 Downloads % jenv local 17.0
sbesson@Sebastiens-MacBook-Pro-3 Downloads % ./bioformats2raw-0.9.0/bin/bioformats2raw test.fake test.zarr

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

4 participants