jSystemThemeDetector: [MacOS Catalina] NPE: Couldn't execute theme name query with the Os
Hi,
Just noticed this NPE, wondered if this is normal or an OS-related issue somehow.
My code calls OsThemeDetector.getDetector().isDark() at some point, and the full stack trace reads
[AWT-EventQueue-0] ERROR com.jthemedetecor.MacOSThemeDetector - Couldn't execute theme name query with the Os
java.lang.NullPointerException
at java.base/java.util.regex.Matcher.getTextLength(Matcher.java:1770)
at java.base/java.util.regex.Matcher.reset(Matcher.java:416)
at java.base/java.util.regex.Matcher.<init>(Matcher.java:253)
at java.base/java.util.regex.Pattern.matcher(Pattern.java:1133)
at com.jthemedetecor.MacOSThemeDetector.isDarkTheme(MacOSThemeDetector.java:96)
at com.jthemedetecor.MacOSThemeDetector.isDark(MacOSThemeDetector.java:86)
More specifically, the NPE is due to the following call (within the isDark() method) returning the ‘0’ byte:
Foundation.invoke(userDefaults, "objectForKey:", Foundation.nsString("AppleInterfaceStyle"))
I should mention that this happens during daytime (and luckily isDark() returns false), so no harm done (besides an avoidable(?) pollution of the logger)
Any clue where that might come from?
In case this helps: using version 3.7 @ openjdk11 @ macOS 10.15.7
About this issue
- Original URL
- State: open
- Created 3 years ago
- Reactions: 1
- Comments: 15
use the following two lines in log4j2.properties
reference
It sounds like you don’t want logging at all, in which case you should add sl4j-nop (no-op) logger to your dependencies. I only know log4j with that if you have a logging configuration (log4j2.xml) on your classpath it should ignore libraries that are not configured. This library uses logback with sl4j I have no knowledge of that but it shouldn’t matter if you are not using it.