Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-12-15 19:10:09 +01:00
c97ce029e9
PaperMC believes that 1.16.2 is now ready for general release as we fixed the main issue plagueing the 1.16.x release, the MapLike data conversion issues. Until now, it was not safe for a server to convert a world to 1.16.2 without data conversion issues around villages and potentially other things. If you did, those MapLike errors meant something went wrong. This is now resolved. Big thanks to all those that helped, notably @BillyGalbreath and @Proximyst who did large parts of the update process with me. Please as always, backup your worlds and test before updating to 1.16.2! If you update to 1.16.2, there is no going back to an older build than this. --------------------------------- Co-authored-by: William Blake Galbreath <Blake.Galbreath@GMail.com> Co-authored-by: Mariell Hoversholm <proximyst@proximyst.com> Co-authored-by: krolik-exe <69214078+krolik-exe@users.noreply.github.com> Co-authored-by: BillyGalbreath <BillyGalbreath@users.noreply.github.com> Co-authored-by: stonar96 <minecraft.stonar96@gmail.com> Co-authored-by: Shane Freeder <theboyetronic@gmail.com> Co-authored-by: Jason <jasonpenilla2@me.com> Co-authored-by: kashike <kashike@vq.lc> Co-authored-by: Aurora <21148213+aurorasmiles@users.noreply.github.com> Co-authored-by: KennyTV <kennytv@t-online.de> Co-authored-by: commandblockguy <commandblockguy1@gmail.com> Co-authored-by: DigitalRegent <misterwener@gmail.com> Co-authored-by: ishland <ishlandmc@yeah.net>
81 Zeilen
4.2 KiB
Diff
81 Zeilen
4.2 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Mariell Hoversholm <proximyst@proximyst.com>
|
|
Date: Mon, 27 Apr 2020 12:31:59 +0200
|
|
Subject: [PATCH] Prioritise own classes where possible
|
|
|
|
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.
|
|
|
|
diff --git a/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java b/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java
|
|
index 9d1f7cdf12029c8198792fd299f92be476040222..384edf9890dfbd1cddfdcac4db1ebe9a4d761f78 100644
|
|
--- a/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java
|
|
+++ b/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java
|
|
@@ -50,6 +50,7 @@ import org.yaml.snakeyaml.error.YAMLException;
|
|
*/
|
|
public final class JavaPluginLoader implements PluginLoader {
|
|
final Server server;
|
|
+ private static final boolean DISABLE_CLASS_PRIORITIZATION = Boolean.getBoolean("Paper.DisableClassPrioritization"); // Paper
|
|
private final Pattern[] fileFilters = new Pattern[]{Pattern.compile("\\.jar$")};
|
|
private final Map<String, Class<?>> classes = new ConcurrentHashMap<String, Class<?>>();
|
|
private final Map<String, java.util.concurrent.locks.ReentrantReadWriteLock> classLoadLock = new java.util.HashMap<String, java.util.concurrent.locks.ReentrantReadWriteLock>(); // Paper
|
|
@@ -193,6 +194,11 @@ public final class JavaPluginLoader implements PluginLoader {
|
|
|
|
@Nullable
|
|
Class<?> getClassByName(final String name) {
|
|
+ // Paper start - prioritize self
|
|
+ return getClassByName(name, null);
|
|
+ }
|
|
+ Class<?> getClassByName(final String name, PluginClassLoader requester) {
|
|
+ // Paper end
|
|
// Paper start - make MT safe
|
|
Class<?> cachedClass = classes.get(name);
|
|
if (cachedClass != null) {
|
|
@@ -204,6 +210,16 @@ public final class JavaPluginLoader implements PluginLoader {
|
|
classLoadLockCount.compute(name, (x, prev) -> prev != null ? prev + 1 : 1);
|
|
}
|
|
lock.writeLock().lock();try {
|
|
+ // Paper start - prioritize self
|
|
+ if (!DISABLE_CLASS_PRIORITIZATION && requester != null) {
|
|
+ try {
|
|
+ cachedClass = requester.findClass(name, false);
|
|
+ } catch (ClassNotFoundException cnfe) {}
|
|
+ if (cachedClass != null) {
|
|
+ return cachedClass;
|
|
+ }
|
|
+ }
|
|
+ // Paper end-
|
|
cachedClass = classes.get(name);
|
|
// Paper end
|
|
|
|
diff --git a/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java b/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java
|
|
index 3a02dbe9d183bc907dcce081d8338d5716ed5242..28e5c6591fb594ca79ee92480cedc8f549e3fe01 100644
|
|
--- a/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java
|
|
+++ b/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java
|
|
@@ -108,7 +108,7 @@ public final class PluginClassLoader extends URLClassLoader { // Spigot
|
|
|
|
if (result == null) {
|
|
if (checkGlobal) {
|
|
- result = loader.getClassByName(name);
|
|
+ result = loader.getClassByName(name, this); // Paper - prioritize self
|
|
|
|
if (result != null) {
|
|
PluginDescriptionFile provider = ((PluginClassLoader) result.getClassLoader()).description;
|