Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-11-03 01:50:07 +01:00
Update Upstream (#1643)
44863cf Don't access PluginClassLoader directly (#2045)
Dieser Commit ist enthalten in:
Ursprung
44078d1820
Commit
668227ee6c
@ -25,7 +25,6 @@ import com.sk89q.worldedit.internal.util.LogManagerCompat;
|
|||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
import org.bukkit.plugin.java.PluginClassLoader;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
@ -45,14 +44,17 @@ public class ClassSourceValidator {
|
|||||||
|
|
||||||
private static final String SEPARATOR_LINE = Strings.repeat("*", 46);
|
private static final String SEPARATOR_LINE = Strings.repeat("*", 46);
|
||||||
private static final Method loadClass;
|
private static final Method loadClass;
|
||||||
|
private static Class<?> pluginClassLoaderClass;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
Method tmp;
|
Method tmp;
|
||||||
try {
|
try {
|
||||||
tmp = PluginClassLoader.class.getDeclaredMethod("loadClass0",
|
pluginClassLoaderClass = Class.forName("org.bukkit.plugin.java.PluginClassLoader", false,
|
||||||
|
Bukkit.class.getClassLoader());
|
||||||
|
tmp = pluginClassLoaderClass.getDeclaredMethod("loadClass0",
|
||||||
String.class, boolean.class, boolean.class, boolean.class);
|
String.class, boolean.class, boolean.class, boolean.class);
|
||||||
tmp.setAccessible(true);
|
tmp.setAccessible(true);
|
||||||
} catch (NoSuchMethodException e) {
|
} catch (NoSuchMethodException | ClassNotFoundException e) {
|
||||||
tmp = null;
|
tmp = null;
|
||||||
}
|
}
|
||||||
loadClass = tmp;
|
loadClass = tmp;
|
||||||
@ -96,7 +98,7 @@ public class ClassSourceValidator {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
ClassLoader targetLoader = target.getClass().getClassLoader();
|
ClassLoader targetLoader = target.getClass().getClassLoader();
|
||||||
if (!(targetLoader instanceof PluginClassLoader)) {
|
if (!(pluginClassLoaderClass.isAssignableFrom(targetLoader.getClass()))) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
for (Class<?> testClass : classes) {
|
for (Class<?> testClass : classes) {
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren