Modify

Opened 4 years ago

Closed 4 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 Don-vip)

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.

See:
https://josm.openstreetmap.de/browser/josm/trunk/src/org/openstreetmap/josm/gui/MainApplication.java#L1075

IMO PluginHandler.getPluginClassLoaders() should be used instead.
This fixes the issue.
Can we change this?

Attachments (3)

JOSM-plugin-laf-classloader-fix.diff (683 bytes ) - added by DevCharly 4 years ago.
JOSM-plugin-laf-classloader-fix-colors.png (112.1 KB ) - added by DevCharly 4 years ago.
JOSM-plugin-laf-classloader-fix-plugins.png (35.5 KB ) - added by DevCharly 4 years ago.

Download all attachments as: .zip

Change History (8)

by DevCharly, 4 years ago

comment:1 by DevCharly, 4 years ago

Color preferences without/with fix:


Plugin preferences without/with fix:


comment:2 by stoecker, 4 years ago

Milestone: 21.0121.02

Milestone renamed

comment:3 by skyper, 4 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 Don-vip, 4 years ago

Description: modified (diff)

comment:5 by Don-vip, 4 years ago

Resolution: fixed
Status: newclosed

In 17512/josm:

fix #20456 - use correct classloader when loading look-and-feel from plugins (patch by DevCharly)

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain team.
as The resolution will be set.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.