From efcbc1fbdbb30cda824e659923929e17bc9a588e Mon Sep 17 00:00:00 2001 From: Karl Tauber Date: Thu, 14 Oct 2021 18:59:26 +0200 Subject: [PATCH] Native window decorations: catch `UnsatisfiedLinkError` when trying to load `jawt.dll` to avoid an application crash (Java 8 on Windows 10 only) --- CHANGELOG.md | 8 ++++++++ .../formdev/flatlaf/ui/FlatWindowsNativeWindowBorder.java | 5 +++++ 2 files changed, 13 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4198d2c6..6e2db6ba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,14 @@ FlatLaf Change Log ================== +## 1.6.1-SNAPSHOT + +#### Fixed bugs + +- Native window decorations: Catch `UnsatisfiedLinkError` when trying to load + `jawt.dll` to avoid an application crash (Java 8 on Windows 10 only). + + ## 1.6 #### New features and improvements diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatWindowsNativeWindowBorder.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatWindowsNativeWindowBorder.java index 9bcca253..311e46c3 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatWindowsNativeWindowBorder.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatWindowsNativeWindowBorder.java @@ -96,6 +96,11 @@ class FlatWindowsNativeWindowBorder // Java 9 and later does not have this problem. try { System.loadLibrary( "jawt" ); + } catch( UnsatisfiedLinkError ex ) { + // log error only if native library jawt.dll not already loaded + String message = ex.getMessage(); + if( message == null || !message.contains( "already loaded in another classloader" ) ) + LoggingFacade.INSTANCE.logSevere( null, ex ); } catch( Exception ex ) { LoggingFacade.INSTANCE.logSevere( null, ex ); }