Skip to content

Use PluginClassLoader#libraryLoader for Bukkit libraries #58

@SkytAsul

Description

@SkytAsul

By doing this, the plugin's "real" classloader won't get polluted by libraries and this would prevent issues when multiple versions of the same library are loaded by multiple plugins.

E.g.:

  • Plugin A loads library X through Libby
  • Plugin B loads library X using the "libraries" section of plugin.yml
  • Plugin C depends on B and wants to load a class of library X. It expects to get a class from the plugin B's version of library X, but since the "global" classpath is polluted with plugin A's libraries loaded by Libby, we end up with the version of X from A.

By loading the Libby libraries in the "libraries" classloader, we automatically get the benefit that classes are only fetched in class loaders that are either 1. plugin classloader or 2. library classloader of (transitive) dependencies (https://hub.spigotmc.org/stash/projects/SPIGOT/repos/bukkit/browse/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java#205).

This issue is blocking for me because my plugins, which don't use Libby in any way, are being polluted by another unrelated plugin using Libby.
I am open for discussion and can propose changes in a Pull Request.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions