From a598aa855b8832476c72923cb3edfbb3ec4acb67 Mon Sep 17 00:00:00 2001 From: Bukkit/Spigot Date: Wed, 3 Jan 2018 15:43:47 +1100 Subject: [PATCH] Be more resilient to asynchronous package loads like URLClassLoader By: md_5 --- .../org/bukkit/plugin/java/PluginClassLoader.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) 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 9fc6bd7721..7e41e79a4f 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 @@ -104,10 +104,16 @@ final class PluginClassLoader extends URLClassLoader { if (dot != -1) { String pkgName = name.substring(0, dot); if (getPackage(pkgName) == null) { - if (manifest != null) { - definePackage(pkgName, manifest, url); - } else { - definePackage(pkgName, null, null, null, null, null, null, null); + try { + if (manifest != null) { + definePackage(pkgName, manifest, url); + } else { + definePackage(pkgName, null, null, null, null, null, null, null); + } + } catch (IllegalArgumentException ex) { + if (getPackage(pkgName) == null) { + throw new IllegalStateException("Cannot find package " + pkgName); + } } } }