Opened 5 years ago
Closed 5 years ago
#20456 closed defect (fixed)
[Patch] Classloader problem with loading look and feel from plugin (FlatLaf)
| Reported by: | DevCharly | Owned by: | team |
|---|---|---|---|
| Priority: | normal | Milestone: | 21.02 |
| Component: | Core | Version: | |
| Keywords: | Cc: |
Description (last modified by )
There is a problem with classloaders and look and feel plugins.
JOSM uses two different classloaders for same laf plugin:
- PluginClassLoader to load laf plugin
- DynamicURLClassLoader for laf initialization
Both classloaders include the laf plugin jar (flatlaf.jar in my case).
So it seems to work, but FlatLaf can not find the properties files in the plugin and JOSM specific colors and UI delegates are missing.
The necessary information to load plugin properties files is stored in a static variable in class FlatLaf.
Because class FlatLaf is loaded into two classloaders, there are two instances of the static variable.
The static variable is set in FlatLafPlugin constructor by invoking FlatLaf.registerCustomDefaultsSource().
This is done with a PluginClassLoader.
Later when the laf is initialized with UIManager.setLookAndFeel(), this static variable is null because this is done in DynamicURLClassLoader.
Tried to workaround this without success.
The reason for the different classloaders is that PluginHandler.getResourceClassLoaders() is used in MainApplication.setupUIManager() to find/load the laf class from a plugin.
IMO PluginHandler.getPluginClassLoaders() should be used instead.
This fixes the issue.
Can we change this?
Attachments (3)
Change History (8)
by , 5 years ago
| Attachment: | JOSM-plugin-laf-classloader-fix.diff added |
|---|
by , 5 years ago
| Attachment: | JOSM-plugin-laf-classloader-fix-colors.png added |
|---|
by , 5 years ago
| Attachment: | JOSM-plugin-laf-classloader-fix-plugins.png added |
|---|
comment:1 by , 5 years ago
comment:3 by , 5 years ago
| Summary: | Classloader problem with loading look and feel from plugin (FlatLaf) → [Patch] Classloader problem with loading look and feel from plugin (FlatLaf) |
|---|
comment:4 by , 5 years ago
| Description: | modified (diff) |
|---|



Color preferences without/with fix:
Plugin preferences without/with fix: