Native libraries: Fixed IllegalArgumentException: URI scheme is not "file" when using FlatLaf in WebStart. (issue #668; regression in FlatLaf 3.1)

This commit is contained in:
Karl Tauber
2023-04-17 21:33:56 +02:00
parent 4afb150106
commit 65a0f467ae
2 changed files with 9 additions and 1 deletions

View File

@@ -8,6 +8,8 @@ FlatLaf Change Log
"Material Theme UI Lite" themes; issue #667; regression in FlatLaf 3.1). "Material Theme UI Lite" themes; issue #667; regression in FlatLaf 3.1).
- Fixed too large tree row height in "Carbon", "Dark Purple", "Gray", - Fixed too large tree row height in "Carbon", "Dark Purple", "Gray",
"Material Design Dark", "Monokai Pro", "One Dark" and "Spacegray" themes. "Material Design Dark", "Monokai Pro", "One Dark" and "Spacegray" themes.
- Native libraries: Fixed `IllegalArgumentException: URI scheme is not "file"`
when using FlatLaf in WebStart. (issue #668; regression in FlatLaf 3.1)
## 3.1 ## 3.1

View File

@@ -18,6 +18,7 @@ package com.formdev.flatlaf.ui;
import java.io.File; import java.io.File;
import java.net.URL; import java.net.URL;
import java.security.CodeSource;
import com.formdev.flatlaf.FlatSystemProperties; import com.formdev.flatlaf.FlatSystemProperties;
import com.formdev.flatlaf.util.LoggingFacade; import com.formdev.flatlaf.util.LoggingFacade;
import com.formdev.flatlaf.util.NativeLibrary; import com.formdev.flatlaf.util.NativeLibrary;
@@ -128,10 +129,15 @@ class FlatNativeLibrary
private static File findLibraryBesideJar( String classifier, String ext ) { private static File findLibraryBesideJar( String classifier, String ext ) {
try { try {
// get location of FlatLaf jar // get location of FlatLaf jar
URL jarUrl = FlatNativeLibrary.class.getProtectionDomain().getCodeSource().getLocation(); CodeSource codeSource = FlatNativeLibrary.class.getProtectionDomain().getCodeSource();
URL jarUrl = (codeSource != null) ? codeSource.getLocation() : null;
if( jarUrl == null ) if( jarUrl == null )
return null; return null;
// if url is not a file, then we're running in a special environment (e.g. WebStart)
if( !"file".equals( jarUrl.getProtocol() ) )
return null;
File jarFile = new File( jarUrl.toURI() ); File jarFile = new File( jarUrl.toURI() );
// if jarFile is a directory, then we're in a development environment // if jarFile is a directory, then we're in a development environment