Linux: fixed UnsatisfiedLinkError: com.formdev.flatlaf.ui.FlatNativeWindowsLibrary.getOSBuildNumberImpl() (regression in PR #643, commit 07ad467c73)

added additional platform checks to `FlatNative<platform>Library.isLoaded()` methods
This commit is contained in:
Karl Tauber
2023-02-10 21:33:26 +01:00
parent 7e91d78633
commit 546382e471
3 changed files with 7 additions and 5 deletions

View File

@@ -23,6 +23,7 @@ import java.awt.event.MouseEvent;
import java.awt.geom.AffineTransform;
import javax.swing.JDialog;
import javax.swing.JFrame;
import com.formdev.flatlaf.util.SystemInfo;
/**
* Native methods for Linux.
@@ -35,7 +36,7 @@ import javax.swing.JFrame;
class FlatNativeLinuxLibrary
{
static boolean isLoaded() {
return FlatNativeLibrary.isLoaded();
return SystemInfo.isLinux && FlatNativeLibrary.isLoaded();
}
// direction for _NET_WM_MOVERESIZE message

View File

@@ -17,6 +17,7 @@
package com.formdev.flatlaf.ui;
import java.awt.Window;
import com.formdev.flatlaf.util.SystemInfo;
/**
* Native methods for Windows.
@@ -31,7 +32,7 @@ public class FlatNativeWindowsLibrary
private static long osBuildNumber = Long.MIN_VALUE;
public static boolean isLoaded() {
return FlatNativeLibrary.isLoaded();
return SystemInfo.isWindows && FlatNativeLibrary.isLoaded();
}
/**

View File

@@ -126,9 +126,9 @@ public class SystemInfo
// For older Java versions, use native library to get OS build number.
boolean isWin_11_orLater = false;
try {
isWin_11_orLater = (isWindows_10_orLater &&
(scanVersion( StringUtils.removeLeading( osName, "windows " ) ) >= toVersion( 11, 0, 0, 0 )) ||
(FlatNativeWindowsLibrary.isLoaded() && FlatNativeWindowsLibrary.getOSBuildNumber() >= 22000));
isWin_11_orLater = isWindows_10_orLater &&
(scanVersion( StringUtils.removeLeading( osName, "windows " ) ) >= toVersion( 11, 0, 0, 0 ) ||
(FlatNativeWindowsLibrary.isLoaded() && FlatNativeWindowsLibrary.getOSBuildNumber() >= 22000));
} catch( Throwable ex ) {
// catch to avoid that application can not start if native library is not up-to-date
LoggingFacade.INSTANCE.logSevere( null, ex );