fixed loading FlatLaf properties files in NetBeans (broken since commit again; issue #1026)

now using old implementation again (before commit 2ac7234c32), but if that does not find properties file, then fallback to new implementation from commit 2ac7234c32
This commit is contained in:
Karl Tauber
2025-09-29 21:30:41 +02:00
parent 5e4f00f0c8
commit 119b4a922d

View File

@@ -205,19 +205,31 @@ class UIDefaultsLoader
if( classLoader != null && !addonClassLoaders.contains( classLoader ) ) if( classLoader != null && !addonClassLoaders.contains( classLoader ) )
addonClassLoaders.add( classLoader ); addonClassLoaders.add( classLoader );
packageName = packageName.replace( '.', '/' );
if( classLoader == null ) if( classLoader == null )
classLoader = FlatLaf.class.getClassLoader(); classLoader = FlatLaf.class.getClassLoader();
boolean found = false;
for( Class<?> lafClass : lafClasses ) {
String propertiesName = packageName + '/' + simpleClassName( lafClass ) + ".properties";
try( InputStream in = classLoader.getResourceAsStream( propertiesName ) ) {
if( in != null ) {
properties.load( in );
found = true;
}
}
}
// fallback for named Java modules
if( !found ) {
// Get package URL using ClassLoader.getResource(...) because this works // Get package URL using ClassLoader.getResource(...) because this works
// also in named Java modules, even without opening the package in module-info.java. // also in named Java modules, even without opening the package in module-info.java.
// This extra step is necessary because ClassLoader.getResource("<package>/<file>.properties") // This extra step is necessary because ClassLoader.getResource("<package>/<file>.properties")
// does not work for named Java modules. // does not work for named Java modules.
URL url = classLoader.getResource( packageName.replace( '.', '/' ) ); URL url = classLoader.getResource( packageName );
if( url == null ) { if( url == null )
LoggingFacade.INSTANCE.logSevere( "FlatLaf: Failed to find package '"
+ packageName + "' to load properties files.", null );
continue; continue;
}
String packageUrl = url.toExternalForm(); String packageUrl = url.toExternalForm();
if( !packageUrl.endsWith( "/" ) ) if( !packageUrl.endsWith( "/" ) )
packageUrl = packageUrl.concat( "/" ); packageUrl = packageUrl.concat( "/" );
@@ -231,6 +243,7 @@ class UIDefaultsLoader
// ignore // ignore
} }
} }
}
} else if( source instanceof URL ) { } else if( source instanceof URL ) {
// load from package URL // load from package URL
String packageUrl = ((URL)source).toExternalForm(); String packageUrl = ((URL)source).toExternalForm();