From 7774243d110bd90f7583b0627a0a06d8c9251fb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?A248=20=F0=9F=87=B5=F0=9F=87=B8=F0=9F=87=AA=F0=9F=87=AD?= Date: Sat, 24 May 2025 14:18:41 -0500 Subject: [PATCH] Add plugin details to zip file errors (#12580) Helps debug classloading across plugin boundaries. Zip file errors can be thrown for multiple reasons, and they are capable of affecting other plugins' classloading. --- .../org/bukkit/plugin/java/PluginClassLoader.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/paper-api/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java b/paper-api/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java index 7e4f7cb2a..37827b19e 100644 --- a/paper-api/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java +++ b/paper-api/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java @@ -206,7 +206,16 @@ public final class PluginClassLoader extends URLClassLoader implements io.paperm if (result == null) { String path = name.replace('.', '/').concat(".class"); - JarEntry entry = jar.getJarEntry(path); + // Add details to zip file errors - help debug classloading + JarEntry entry; + try { + entry = jar.getJarEntry(path); + } catch (IllegalStateException zipFileClosed) { + if (plugin == null) { + throw zipFileClosed; + } + throw new IllegalStateException("The plugin classloader for " + plugin.getName() + " has thrown a zip file error.", zipFileClosed); + } if (entry != null) { byte[] classBytes;