Native window decorations: fixed loading of native library when using JPMS for application (issue #289)

This commit is contained in:
Karl Tauber
2021-04-01 01:07:35 +02:00
parent f3e6642f05
commit 983b341f33
3 changed files with 14 additions and 5 deletions

View File

@@ -5,11 +5,13 @@ FlatLaf Change Log
#### Fixed bugs #### Fixed bugs
- Fixed crash when running in Webswing. (issue #290) - Native window decorations: Fixed loading of native library when using Java
Platform Module System (JPMS) for application. (issue #289)
- Native window decorations: Removed superfluous pixel-line at top of screen - Native window decorations: Removed superfluous pixel-line at top of screen
when window is maximized. (issue #296) when window is maximized. (issue #296)
- Button and ToggleButton: Do not paint background of disabled (and unselected) - Button and ToggleButton: Do not paint background of disabled (and unselected)
toolBar buttons. (issue #292; regression since fixing #112) toolBar buttons. (issue #292; regression since fixing #112)
- Fixed crash when running in Webswing. (issue #290)
## 1.1.1 ## 1.1.1

View File

@@ -103,8 +103,7 @@ class FlatWindowsNativeWindowBorder
if( SystemInfo.isX86_64 ) if( SystemInfo.isX86_64 )
libraryName += "_64"; libraryName += "_64";
nativeLibrary = new NativeLibrary( libraryName, nativeLibrary = new NativeLibrary( libraryName, null, true );
FlatWindowsNativeWindowBorder.class.getClassLoader(), true );
} }
// check whether native library was successfully loaded // check whether native library was successfully loaded

View File

@@ -42,9 +42,15 @@ public class NativeLibrary
/** /**
* Load native library from given classloader. * Load native library from given classloader.
* <p>
* Note regarding Java Platform Module System (JPMS):
* If classloader is {@code null}, the library can be only loaded from the module
* that contains this class.
* If classloader is not {@code null}, then the package that contains the library
* must be specified as "open" in module-info.java of the module that contains the library.
* *
* @param libraryName resource name of the native library (without "lib" prefix and without extension) * @param libraryName resource name of the native library (without "lib" prefix and without extension)
* @param classLoader the classloader used to locate the library * @param classLoader the classloader used to locate the library, or {@code null}
* @param supported whether the native library is supported on the current platform * @param supported whether the native library is supported on the current platform
*/ */
public NativeLibrary( String libraryName, ClassLoader classLoader, boolean supported ) { public NativeLibrary( String libraryName, ClassLoader classLoader, boolean supported ) {
@@ -68,7 +74,9 @@ public class NativeLibrary
libraryName = decorateLibraryName( libraryName ); libraryName = decorateLibraryName( libraryName );
// find library // find library
URL libraryUrl = classLoader.getResource( libraryName ); URL libraryUrl = (classLoader != null)
? classLoader.getResource( libraryName )
: NativeLibrary.class.getResource( "/" + libraryName );
if( libraryUrl == null ) { if( libraryUrl == null ) {
log( "Library '" + libraryName + "' not found", null ); log( "Library '" + libraryName + "' not found", null );
return false; return false;