Server mocking framework: Load a plugin that already has been loaded before unit test. Impossible?

Background I'm a developer of a mocking framework, which is used to test plugins for minecraft servers. One of the main functionalities of that mocking framework is the ability to load plugin classes, which holds the initial methods triggered whenever the plugin is enabled. Here comes one issue, when running a real minecraft server these plugins are loaded with separate classloaders, which means that every internal resource of each plugin will be isolated. This will not be the case for our mocking framework, as all plugins are loaded by the SystemClassLoader (or whatever the default java class loader is called). That means that if you're loading multiple plugins, then there is a possibility of a clash between internal file names. Another issue is that the API we're using requires us to have a specific classloader for the plugin class. We're using ByteBuddy to deal with this. But it throws exceptions whenever plugin classes are defined as final. The solution I'm searching for Anyhow, that's the background for my problems. I'm therefore wondering if there's any way to load a class that already has been loaded and substitute all the reference of the old class to the new class. Or something similar. From what I know, this is not possible (and probably should not be), but is there anything that would achieve a similar result?
1 Reply
JavaBot
JavaBot12mo ago
This post has been reserved for your question.
Hey @Thorinwasher! Please use /close or the Close Post button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here. 💤 Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived. If your question was not answered yet, feel free to re-open this post or create a new one. In case your post is not getting any attention, you can try to use /help ping. Warning: abusing this will result in moderative actions taken against you.
Want results from more Discord servers?
Add your server