Skip to content

Don't use SystemClassLoader to load craftbukkit #35

Description

@MrSteppy

Here is a line from the current source code:

final Class<?> cls = Class.forName(mainClass, true, ClassLoader.getSystemClassLoader());

final Class<?> cls = Class.forName(mainClass, true, ClassLoader.getSystemClassLoader());

This code is called when loading the craftbukkit main method and uses the SystemClassLoader to load those classes. If a developer now wants to load paperclip, craftbukkit and all those classes with a custom ClassLoader this single line ruins that for him, since Java tries (reasonably) a lot, to make it impossible to change the SystemClassLoader.

I would suggest to change the part ClassLoader.getSystemClassLoader() to Perpclip.class.getClassLoader() so that custom class loaders can be used to load the bukkit and minecraft classes

Activity

  1. changed the title [-]Don't use SystemClassLoader[/-] [+]Don't use SystemClassLoader to load craftbukkit[/+] on Feb 28, 2021
  2. DenWav commented on Apr 6, 2021

    @DenWav
    Member

    Using the system classloader is very intentional, as certain things in CraftBukkit may get unhappy if it's not loaded by the system classloader. At this point we do this purely out of maximum-compatibility with CraftBukkit - we don't want it to have any idea that it wasn't started directly with java -jar.

    Paperclip is a low-level jar patching & bootstrapper system, I'm not sure I can see a reason for Paperclip to be called by anything else other than the system classloader.

    Here's what I'll do:
    I'll first check if Paperclip is running in the system classloader. If it is, we use the current system to modify the system classloader and start CraftBukkit.

    If Paperclip is not running in the system classloader, but it is running in a URLClassLoader, we can handle that case as well.

    If neither of those cases are true, Paperclip will error and quit.

    For more flexibility in this area you could just run Paperclip with -Dpaperclip.patchonly=true and run the output jar however you want instead.

  3. MrSteppy commented on Jun 17, 2021

    @MrSteppy
    Author

    Well, that option certanly helps a lot, thankyou

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions