Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[MacOS Catalina] NPE: Couldn't execute theme name query with the Os

See original GitHub issue

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
	at java.base/java.util.regex.Matcher.getTextLength(
	at java.base/java.util.regex.Matcher.reset(
	at java.base/java.util.regex.Matcher.<init>(
	at java.base/java.util.regex.Pattern.matcher(
	at com.jthemedetecor.MacOSThemeDetector.isDarkTheme(
	at com.jthemedetecor.MacOSThemeDetector.isDark(

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

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:1
  • Comments:11

github_iconTop GitHub Comments

nybbs2003commented, Jul 4, 2022

In the meantime, does anyone know how to silence the logger?

I don’t fully understand how the logger works. I’ve tried using

java.util.logging.Logger.getLogger("com.jthemedetecor.MacOSThemeDetector").level = Level.OFF
	java.util.logging.Logger.getLogger("com.jthemedetecor").level = Level.OFF

in my code, but that does nothing.

Whenever I search “how to disable a org.slf4j.Logger” people are talking about things like log4j. It’s very confusing. I don’t think I have log4j installed, but just in case I tried adding a “” to my classpath with but that is not doing anything either.

use the following two lines in = com.jthemedetecor
logger.jthemedetecor.level = off


ctippercommented, May 22, 2022

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Original item can't be found in Mac OS Catalina
I installed Mac OS Catalina 10.15 beta. When I go to Finder and tap on folders in the sidebar, an alert window appears...
Read more >
Where is the .zshrc file on Mac? - Super User
zshrc file is not present by default in macOS Catalina, we need to create it. Steps for creation: Open Terminal; Type touch ~/.zshrc...
Read more >
Word for Mac document stops responding when you try to ...
Resolution ; 1. Exit all Microsoft Office for Mac programs. ; 2. On the Go menu, click Home. ; 3. Open Library. Note...
Read more >
XAMPP permissions on Mac OS X? - Stack Overflow
Tried the above but the option to amend the permission was not available for the htdocs folder,. My solution was: Open applications folder;...
Read more >
macOS - Wikipedia
macOS is a Unix operating system developed and marketed by Apple Inc. since 2001. It is the primary operating system for Apple's Mac...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found