Uploaded image for project: 'Spigot'
  1. Spigot
  2. SPIGOT-4539

Spigot missing module-info.java

XMLWordPrintable

    • Icon: New Feature New Feature
    • Resolution: Unresolved
    • Icon: Minor Minor
    • None
    • None
    • 1.13.2-R0.1-SNAPSHOT
    • Yes

      Using the module system on the server jar is impossible due to missing requirements. This is because the spigot/craftbukkit server depends on classes from the non-standard java.scripting and java.sql modules.

      What currently happens
      When someone runs the server using the module system (java --module-path ./ -m craftbukkit), the non modular jar gets loaded as a module that opens and exports everything and that only has java.base as a dependency. However, this does not include the two required non-standard modules and thus they will not get loaded. The server than throws a ClassDefNotFound error because classes of those modules are used but not loaded.

      What is needed to fix this
      This problem can be fixed by making the server jar a modular jar. This can be simply done by creating a module-info.java file and compiling it together with all other class files. The module file should simply export everything and open everything and it should add the right requirements for the modules used. In other words, it should look as followed:

      open module MODULE_NAME_HERE {
          // To not break things, the module name should be the same for spigot and bukkit
          requires java.base; // not necessary
          requires java.scripting;
          requires java.sql;Labels
      
          exports org.bukkit;
          exports org.bukkit.advancements;
          exports org.bukkit.attribute;
          // ... and so on
      
          exports org.bukkit.craftbukkit.v1_13_R2;
          exports org.bukkit.craftbukkit.v1_13_R2.advancements;
          // ... and so on
      
          exports net.minecraft.server.v1_13_R2;
      
          exports io.netty.buffer;
          exports io.netty.channel;
          // ... and so on for every other package containing any class
      }

      The best thing is, maybe the build tools can be updated to do this automatically: add a new exports for every package that contains any class file. Another good thing is that it breaks nothing. Everything not using the module system will just ignore the module info. And as everything is open and exported to everyone, nothing using this system will break.

            Unassigned Unassigned
            Remceau Remco van Hooff
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: