Prioritise own classes where possible#3366
Merged
Merged
Conversation
Proximyst
commented
May 13, 2020
This adds the server property `Paper.DisableClassPrioritization` to disable prioritization of own classes for plugins' classloaders. This value is by default not present, and this will therefore break any plugins which abuse behaviour related to not using their own classes while still loading their own. This is often an issue with failing to relocate or shade properly, such as when shading plugin APIs like Vault. A plugin's classloader will first look in the same jar as it is loading in for a requested class, then load it. It does not re-use other plugins' classes if it has the chance to avoid doing so. If a class is not found in the same jar as it is loading for and it does find it elsewhere, it will still choose the class elsewhere. This is intended behaviour, as it will only prioritise classes it has in its own jar, no other plugins' classes will be prioritised in any other order than the one they were registered in. The patch in general terms just loads the class in the plugin's jar before it starts looking elsewhere for it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This adds the server property
Paper.DisableClassPrioritizationto disableprioritization of own classes for plugins' classloaders.
This value is by default not present, and this will therefore break any
plugins which abuse behaviour related to not using their own classes
while still loading their own. This is often an issue with failing to
relocate or shade properly, such as when shading plugin APIs like Vault.
A plugin's classloader will first look in the same jar as it is loading
in for a requested class, then load it. It does not re-use other
plugins' classes if it has the chance to avoid doing so.
If a class is not found in the same jar as it is loading for and it does
find it elsewhere, it will still choose the class elsewhere. This is
intended behaviour, as it will only prioritise classes it has in its own
jar, no other plugins' classes will be prioritised in any other order
than the one they were registered in.
The patch in general terms just loads the class in the plugin's jar
before it starts looking elsewhere for it.