Uploaded image for project: 'BuildTools'
  1. BuildTools
  2. BUILDTOOLS-634

Using JavaPlugin#getProvidingPlugin with classes from declared libraries yields IllegalArgumentException

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: Minor Minor
    • None
    • Windows 10

      Java 17.0.1

    • CraftBukkit version 3508-Spigot-fa893f0-50ef122 (MC: 1.19) (Implementing API version 1.19-R0.1-SNAPSHOT)
    • Yes

      Presuming a plugin declares a library in the plugin.yml file. If the plugin, or the library decides to invoke JavaPlugin#getProvidingPlugin, where the passed class is a class from one of the libraries declared in the plugin.yml file. The result is that an instance of IllegalArgumentException yields. 

       

      For example the library IF (com.github.stefvanschie.inventoryframework:IF:0.10.6), was used, which itself uses JavaPlugin#getProvidingPlugin on one of its own classes. This would work with the assumption that the library gets directly shaded into the jar, thus directly loaded by the a plugin's classloader. But when instead declaring it in plugin.yml the library gets loaded with an instance of LibraryLoader which does not instanceof PluginClassLoader thus fails the check on line 423 in JavaPlugin.

            Unassigned Unassigned
            Conclure Alexander Lorentzson
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: