Skip to content

Commit

Permalink
Native window decorations: fixed loading of native library when using…
Browse files Browse the repository at this point in the history
… JPMS for application (issue #289)
  • Loading branch information
DevCharly committed Mar 31, 2021
1 parent f3e6642 commit 983b341
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ FlatLaf Change Log

#### 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
when window is maximized. (issue #296)
- Button and ToggleButton: Do not paint background of disabled (and unselected)
toolBar buttons. (issue #292; regression since fixing #112)
- Fixed crash when running in Webswing. (issue #290)


## 1.1.1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,7 @@ static FlatNativeWindowBorder.Provider getInstance() {
if( SystemInfo.isX86_64 )
libraryName += "_64";

nativeLibrary = new NativeLibrary( libraryName,
FlatWindowsNativeWindowBorder.class.getClassLoader(), true );
nativeLibrary = new NativeLibrary( libraryName, null, true );
}

// check whether native library was successfully loaded
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,15 @@ public class NativeLibrary

/**
* 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 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
*/
public NativeLibrary( String libraryName, ClassLoader classLoader, boolean supported ) {
Expand All @@ -68,7 +74,9 @@ private static boolean loadLibraryFromJar( String libraryName, ClassLoader class
libraryName = decorateLibraryName( libraryName );

// find library
URL libraryUrl = classLoader.getResource( libraryName );
URL libraryUrl = (classLoader != null)
? classLoader.getResource( libraryName )
: NativeLibrary.class.getResource( "/" + libraryName );
if( libraryUrl == null ) {
log( "Library '" + libraryName + "' not found", null );
return false;
Expand Down

0 comments on commit 983b341

Please sign in to comment.