Archiviert
13
0

Close library classloader and improve PluginDescriptionFile (#8901)

Dieser Commit ist enthalten in:
Bjarne Koll 2023-02-22 21:54:27 +01:00 committet von GitHub
Ursprung a9ab68427c
Commit 87bb3e6f4c
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 4AEE18F83AFDEB23

Datei anzeigen

@ -748,10 +748,10 @@ index 0000000000000000000000000000000000000000..f9a2c55a354c877749db3f92956de802
+} +}
diff --git a/src/main/java/io/papermc/paper/plugin/entrypoint/classloader/PaperPluginClassLoader.java b/src/main/java/io/papermc/paper/plugin/entrypoint/classloader/PaperPluginClassLoader.java diff --git a/src/main/java/io/papermc/paper/plugin/entrypoint/classloader/PaperPluginClassLoader.java b/src/main/java/io/papermc/paper/plugin/entrypoint/classloader/PaperPluginClassLoader.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..4fa7147d0dcbfd7e40f6eab1f7b0c6d8bbcf6906 index 0000000000000000000000000000000000000000..392eb260b44d5f9e685ce09596c19f0af9cc0339
--- /dev/null --- /dev/null
+++ b/src/main/java/io/papermc/paper/plugin/entrypoint/classloader/PaperPluginClassLoader.java +++ b/src/main/java/io/papermc/paper/plugin/entrypoint/classloader/PaperPluginClassLoader.java
@@ -0,0 +1,194 @@ @@ -0,0 +1,204 @@
+package io.papermc.paper.plugin.entrypoint.classloader; +package io.papermc.paper.plugin.entrypoint.classloader;
+ +
+import io.papermc.paper.plugin.configuration.PluginMeta; +import io.papermc.paper.plugin.configuration.PluginMeta;
@ -770,6 +770,7 @@ index 0000000000000000000000000000000000000000..4fa7147d0dcbfd7e40f6eab1f7b0c6d8
+import java.io.File; +import java.io.File;
+import java.io.IOException; +import java.io.IOException;
+import java.net.URL; +import java.net.URL;
+import java.net.URLClassLoader;
+import java.nio.file.Path; +import java.nio.file.Path;
+import java.util.ArrayList; +import java.util.ArrayList;
+import java.util.Collections; +import java.util.Collections;
@ -793,7 +794,7 @@ index 0000000000000000000000000000000000000000..4fa7147d0dcbfd7e40f6eab1f7b0c6d8
+ registerAsParallelCapable(); + registerAsParallelCapable();
+ } + }
+ +
+ private final ClassLoader libraryLoader; + private final URLClassLoader libraryLoader;
+ private final Set<String> seenIllegalAccess = Collections.newSetFromMap(new ConcurrentHashMap<>()); + private final Set<String> seenIllegalAccess = Collections.newSetFromMap(new ConcurrentHashMap<>());
+ private final Logger logger; + private final Logger logger;
+ @Nullable + @Nullable
@ -801,7 +802,7 @@ index 0000000000000000000000000000000000000000..4fa7147d0dcbfd7e40f6eab1f7b0c6d8
+ @Nullable + @Nullable
+ private PluginClassLoaderGroup group; + private PluginClassLoaderGroup group;
+ +
+ public PaperPluginClassLoader(Logger logger, Path source, JarFile file, PaperPluginMeta configuration, ClassLoader parentLoader, ClassLoader libraryLoader) throws IOException { + public PaperPluginClassLoader(Logger logger, Path source, JarFile file, PaperPluginMeta configuration, ClassLoader parentLoader, URLClassLoader libraryLoader) throws IOException {
+ super(source, file, configuration, parentLoader); + super(source, file, configuration, parentLoader);
+ this.libraryLoader = libraryLoader; + this.libraryLoader = libraryLoader;
+ +
@ -904,9 +905,9 @@ index 0000000000000000000000000000000000000000..4fa7147d0dcbfd7e40f6eab1f7b0c6d8
+ config.getProvidedPlugins(), + config.getProvidedPlugins(),
+ config.getMainClass(), + config.getMainClass(),
+ "", // Classloader load order api + "", // Classloader load order api
+ List.of(), // Dependencies + config.getPluginDependencies(), // Dependencies
+ List.of(), // Soft Depends + config.getPluginSoftDependencies(), // Soft Depends
+ List.of(), // Load Before + config.getLoadBeforePlugins(), // Load Before
+ config.getVersion(), + config.getVersion(),
+ Map.of(), // Commands, we use a separate system + Map.of(), // Commands, we use a separate system
+ config.getDescription(), + config.getDescription(),
@ -945,6 +946,15 @@ index 0000000000000000000000000000000000000000..4fa7147d0dcbfd7e40f6eab1f7b0c6d8
+ ", group=" + this.group + + ", group=" + this.group +
+ '}'; + '}';
+ } + }
+
+ @Override
+ public void close() throws IOException {
+ try {
+ super.close();
+ } finally {
+ this.libraryLoader.close();
+ }
+ }
+} +}
diff --git a/src/main/java/io/papermc/paper/plugin/entrypoint/classloader/PaperSimplePluginClassLoader.java b/src/main/java/io/papermc/paper/plugin/entrypoint/classloader/PaperSimplePluginClassLoader.java diff --git a/src/main/java/io/papermc/paper/plugin/entrypoint/classloader/PaperSimplePluginClassLoader.java b/src/main/java/io/papermc/paper/plugin/entrypoint/classloader/PaperSimplePluginClassLoader.java
new file mode 100644 new file mode 100644